| | |
| | | |
| | | </div> |
| | | <div class="zoom-info"> |
| | | <el-tag type="success">倍率: {{ zoomRatio.toFixed(1) }}X</el-tag> |
| | | <el-tag type="success">距离: {{ betweenDistance.toFixed(1) }}米</el-tag> |
| | | <el-tag type="success">倍率: {{ zoomRatio.toFixed(1) }}X</el-tag><br> |
| | | <el-tag type="success">距离: {{ betweenDistance.toFixed(1) }}米</el-tag><br> |
| | | <el-tag type="success">P: {{ cameraP.toFixed(1) }} T: {{ cameraT.toFixed(1) }} </el-tag> |
| | | </div> |
| | | |
| | | |
| | |
| | | 28: '28X', |
| | | 56: '56X' |
| | | }, |
| | | betweenDistance:0 |
| | | betweenDistance:0, |
| | | cameraP:0.0, |
| | | cameraT:0.0 |
| | | } |
| | | }, |
| | | mounted(){ |
| | |
| | | setTimeout(() => { |
| | | viewerC.camera.changed.addEventListener(_this.onCameraChange) |
| | | }, 100); |
| | | |
| | | |
| | | //左侧树结构联动 |
| | | _this.dealTree() |
| | | //结束右键监听 |
| | | createPinHandler.destroy(); |
| | | //结束主图联动鹰眼监听 |
| | |
| | | } |
| | | }, |
| | | onKeyUp(event) { |
| | | console.log() |
| | | //键盘抬起进行更新左侧空中点pin |
| | | //获取右侧相机 |
| | | if(rightKeyMove){ |
| | |
| | | } |
| | | //计算两个点距离 |
| | | console.log(viewerM.entities) |
| | | const groupEntityGround = viewerM.entities.getById("groundPoiId"+(counter-1)); |
| | | const groupPosition = groupEntityGround.position.getValue(Cesium.JulianDate.now()); |
| | | if (groupPosition) { |
| | | const cartographic = Cesium.Cartographic.fromCartesian(groupPosition); |
| | | const longitude = Cesium.Math.toDegrees(cartographic.longitude); |
| | | const latitude = Cesium.Math.toDegrees(cartographic.latitude); |
| | | const point1 = Cesium.Cartesian3.fromDegrees(lon, lat); |
| | | const point2 = Cesium.Cartesian3.fromDegrees(longitude, latitude); |
| | | const gure = Cesium.Cartesian3.distance(point1, point2) |
| | | this.betweenDistance = gure |
| | | } |
| | | const groupEntityGround = viewerM.entities.getById("groundPoiId"+(counter-1)); |
| | | const groupPosition = groupEntityGround.position.getValue(Cesium.JulianDate.now()); |
| | | if (groupPosition) { |
| | | const cartographic = Cesium.Cartographic.fromCartesian(groupPosition); |
| | | const longitude = Cesium.Math.toDegrees(cartographic.longitude); |
| | | const latitude = Cesium.Math.toDegrees(cartographic.latitude); |
| | | const point1 = Cesium.Cartesian3.fromDegrees(lon, lat); |
| | | const point2 = Cesium.Cartesian3.fromDegrees(longitude, latitude); |
| | | const gure = Cesium.Cartesian3.distance(point1, point2) |
| | | this.betweenDistance = gure |
| | | } |
| | | |
| | | this.dealTree() |
| | | } |
| | | const key = event.key; |
| | | const lower = key.toLowerCase(); |
| | |
| | | resetView() { |
| | | // Fly back to the initial view (home) in 1 second |
| | | viewerC.camera.flyHome(1.0); |
| | | }, |
| | | dealTree(){ |
| | | let allEntities = viewerM.entities.values; // 所有实体对象组成的数组 |
| | | const grouped = {}; |
| | | //所有实体对象组成的数组转换成左侧树需要的格式 |
| | | allEntities.forEach(item => { |
| | | const match = item.id.match(/(groundPoiId|aerialPoiId)(\d+)/); |
| | | if (match) { |
| | | const type = match[1]; // groundPoiId or aerialPoiId |
| | | const index = match[2]; |
| | | if (!grouped[index]) grouped[index] = {}; |
| | | grouped[index][type] = item.position; |
| | | } |
| | | }) |
| | | const result = Object.keys(grouped).map((key, idx) => { |
| | | const group = grouped[key]; |
| | | const positionGround = group.groundPoiId.getValue(Cesium.JulianDate.now()) |
| | | const positionAerialPo = group.aerialPoiId.getValue(Cesium.JulianDate.now()) |
| | | const groundPos = Cesium.Cartographic.fromCartesian(positionGround); |
| | | const aerialPos = Cesium.Cartographic.fromCartesian(positionAerialPo); |
| | | return { |
| | | id: this.genId(), |
| | | label: `地面点${idx}`, |
| | | longitude: Cesium.Math.toDegrees(groundPos.longitude), |
| | | latitude: Cesium.Math.toDegrees(groundPos.latitude), |
| | | height: groundPos.height, |
| | | children: [ |
| | | { |
| | | id: this.genId(), |
| | | label: `空中点${idx}`, |
| | | longitude: Cesium.Math.toDegrees(aerialPos.longitude), |
| | | latitude: Cesium.Math.toDegrees(aerialPos.latitude), |
| | | height: aerialPos.height |
| | | } |
| | | ] |
| | | }; |
| | | }); |
| | | this.$emit('dealTreeData',result) |
| | | }, |
| | | mergePoint(){ |
| | | let allEntities = viewerM.entities.values; // 所有实体对象组成的数组 |
| | |
| | | }, |
| | | onSliderInput(val) { |
| | | this.zoomRatio = val; |
| | | } |
| | | }, |
| | | // 计算 heading(偏航角) |
| | | computeHeading(fromCartesian, toCartesian) { |
| | | const transform = Cesium.Transforms.eastNorthUpToFixedFrame(fromCartesian); |
| | | const direction = Cesium.Cartesian3.subtract( |
| | | toCartesian, |
| | | fromCartesian, |
| | | new Cesium.Cartesian3() |
| | | ); |
| | | const directionLocal = Cesium.Matrix4.multiplyByPointAsVector( |
| | | Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4()), |
| | | direction, |
| | | new Cesium.Cartesian3() |
| | | ); |
| | | Cesium.Cartesian3.normalize(directionLocal, directionLocal); |
| | | return Math.atan2(directionLocal.x, directionLocal.y); |
| | | }, |
| | | |
| | | // 计算 pitch(俯仰角) |
| | | computePitch(fromCartesian, toCartesian) { |
| | | const transform = Cesium.Transforms.eastNorthUpToFixedFrame(fromCartesian); |
| | | const direction = Cesium.Cartesian3.subtract( |
| | | toCartesian, |
| | | fromCartesian, |
| | | new Cesium.Cartesian3() |
| | | ); |
| | | const directionLocal = Cesium.Matrix4.multiplyByPointAsVector( |
| | | Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4()), |
| | | direction, |
| | | new Cesium.Cartesian3() |
| | | ); |
| | | Cesium.Cartesian3.normalize(directionLocal, directionLocal); |
| | | return Math.asin(directionLocal.z); // z轴向上 |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | |
| | | } |
| | | .moveResult{position:absolute;z-index:2;background-color:rgba(47,53,60,1);padding:0 5px;right:50%;bottom:30px; |
| | | border:1px solid rgba(255,255,255,.1);box-sizing:content-box;width:220px;height:30px;font-size:14px;text-align:center} |
| | | .cammoveResult{position:absolute;z-index:2;background-color:rgba(47,53,60,1);padding:0 5px;right:calc(50% - 40px);bottom:30px; |
| | | .cammoveResult{position:absolute;z-index:2;background-color:rgba(47,53,60,1);padding:0 5px;right:calc(50% - 140px);bottom:35px; |
| | | border:1px solid rgba(255,255,255,.1);box-sizing:content-box;width:400px;height:30px;font-size:14px;text-align:center} |
| | | .moveResultCon{margin-top:4px} |
| | | .cammoveResultCon{margin-top:4px;color: white;} |