| | |
| | | this.centerVectorZC = null |
| | | this.dashLineList = [] |
| | | this.flip = { x: false, y: false, z: false } |
| | | this.editingEnabled = false |
| | | this.interaction = { type: null, axis: null } |
| | | |
| | | this.planeCtx = { activeShape: null, polygonPositionList: [], centerPoint: null } |
| | | this.axisModelUris = { axisX: 'gltf/green-arrows.gltf', axisY: 'gltf/red-arrows.gltf', axisZ: 'gltf/blue-arrows.gltf' } |
| | |
| | | } |
| | | } |
| | | |
| | | setControllerVisibility (show) { |
| | | const s = !!show |
| | | if (this.axisEntyX) this.axisEntyX.show = s |
| | | if (this.axisEntyY) this.axisEntyY.show = s |
| | | if (this.axisEntyZ) this.axisEntyZ.show = s |
| | | if (this.sphereEntyX) this.sphereEntyX.show = s |
| | | if (this.sphereEntyY) this.sphereEntyY.show = s |
| | | if (this.sphereEntyZ) this.sphereEntyZ.show = s |
| | | if (this.overlayModels.axisX) this.overlayModels.axisX.show = s |
| | | if (this.overlayModels.axisY) this.overlayModels.axisY.show = s |
| | | if (this.overlayModels.axisZ) this.overlayModels.axisZ.show = s |
| | | if (this.overlayModels.sphereX) this.overlayModels.sphereX.show = s |
| | | if (this.overlayModels.sphereY) this.overlayModels.sphereY.show = s |
| | | if (this.overlayModels.sphereZ) this.overlayModels.sphereZ.show = s |
| | | if (!s) this.dashLineList.forEach(ele => { ele.show = false }) |
| | | } |
| | | |
| | | setEditingEnabled (flag) { |
| | | this.editingEnabled = !!flag |
| | | this.setControllerVisibility(this.editingEnabled) |
| | | } |
| | | |
| | | /** |
| | | * 注入当前平面上下文(面实体、顶点列表、中心点) |
| | | * @param {{activeShape:Cesium.Entity,polygonPositionList:Cesium.Cartesian3[],centerPoint:Cesium.Cartesian3}} ctx 上下文 |
| | |
| | | setPlaneContext (ctx) { |
| | | this.planeCtx = ctx |
| | | this.centerPoint = ctx.centerPoint |
| | | this.setEditingEnabled(true) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.centerVectorXC = g.centerVectorXC |
| | | this.centerVectorYC = g.centerVectorYC |
| | | this.centerVectorZC = g.centerVectorZC |
| | | if (this.interaction && this.interaction.type === 'rotation' && this.interaction.axis) { |
| | | this.setRotationAxisFocus(this.interaction.axis) |
| | | } else { |
| | | this.setControllerVisibility(this.editingEnabled) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | let translationController = this._translationController() |
| | | |
| | | masterController.setInputAction((e) => { |
| | | if (!this.editingEnabled) return |
| | | const results = viewer.scene.drillPick(e.position) |
| | | let hit = null |
| | | let id = null |
| | |
| | | let isTranslation = false |
| | | |
| | | if (id.slice(0, 6) === 'sphere') { |
| | | if (rotationController.startRotation(hit, this.centerPoint)) { isRotation = true; this._setDragRotationFocus(rotationController.state.currentAxis) } |
| | | if (rotationController.startRotation(hit, this.centerPoint)) { isRotation = true; this.interaction = { type: 'rotation', axis: rotationController.state.currentAxis }; this._setDragRotationFocus(rotationController.state.currentAxis) } |
| | | } else if (id.slice(0, 4) === 'axis') { |
| | | if (translationController.startTranslation(hit, this.centerPoint)) { isTranslation = true; translationController.state.lastMousePosition = new Cesium.Cartesian2(e.position.x, e.position.y); this._setDragTranslationHighlight(translationController.state.currentAxis) } |
| | | if (translationController.startTranslation(hit, this.centerPoint)) { isTranslation = true; this.interaction = { type: 'translation', axis: translationController.state.currentAxis }; translationController.state.lastMousePosition = new Cesium.Cartesian2(e.position.x, e.position.y); this._setDragTranslationHighlight(translationController.state.currentAxis) } |
| | | } |
| | | if (!isRotation && !isTranslation) return |
| | | this.setDistanceLabelsVisibility(false) |
| | |
| | | this.bindHover() |
| | | if (isRotation) rotationController.endRotation() |
| | | if (isTranslation) translationController.endTranslation() |
| | | this.interaction = { type: null, axis: null } |
| | | if (typeof onUpdate === 'function') onUpdate(this.planeCtx.polygonPositionList) |
| | | this.createAxisEntity(...this.planeCtx.polygonPositionList) |
| | | this.updateDistanceLabels() |
| | | this.setDistanceLabelsVisibility(true) |
| | | this.setControllerVisibility(this.editingEnabled) |
| | | }, Cesium.ScreenSpaceEventType.LEFT_UP) |
| | | }, Cesium.ScreenSpaceEventType.LEFT_DOWN) |
| | | } |
| | |
| | | bindHover () { |
| | | const handler = this.eventHub.get('hover') |
| | | handler.setInputAction((arg) => { |
| | | if (!this.editingEnabled) { |
| | | this.axisEntyZ && (this.axisEntyZ.model.silhouetteSize = new Cesium.CallbackProperty(() => 0, false)) |
| | | this.axisEntyX && (this.axisEntyX.model.silhouetteSize = new Cesium.CallbackProperty(() => 0, false)) |
| | | this.axisEntyY && (this.axisEntyY.model.silhouetteSize = new Cesium.CallbackProperty(() => 0, false)) |
| | | if (this.overlayModels.axisZ) this.overlayModels.axisZ.silhouetteSize = 0 |
| | | if (this.overlayModels.axisX) this.overlayModels.axisX.silhouetteSize = 0 |
| | | if (this.overlayModels.axisY) this.overlayModels.axisY.silhouetteSize = 0 |
| | | this.sphereEntyX && (this.sphereEntyX.model.silhouetteSize = new Cesium.CallbackProperty(() => 0, false)) |
| | | this.sphereEntyY && (this.sphereEntyY.model.silhouetteSize = new Cesium.CallbackProperty(() => 0, false)) |
| | | this.sphereEntyZ && (this.sphereEntyZ.model.silhouetteSize = new Cesium.CallbackProperty(() => 0, false)) |
| | | if (this.overlayModels.sphereX) this.overlayModels.sphereX.silhouetteSize = 0 |
| | | if (this.overlayModels.sphereY) this.overlayModels.sphereY.silhouetteSize = 0 |
| | | if (this.overlayModels.sphereZ) this.overlayModels.sphereZ.silhouetteSize = 0 |
| | | this.dashLineList.forEach(ele => { ele.show = false }) |
| | | return |
| | | } |
| | | const results = this.viewer.scene.drillPick(arg.endPosition) |
| | | let id = null |
| | | if (Array.isArray(results) && results.length > 0) { |