From 307db148645230afc780a3d5d16ffb97aa32c189 Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期四, 03 七月 2025 16:38:58 +0800
Subject: [PATCH] 模型 && 设备相关

---
 src/utils/components/init-map.vue |  108 +++++++++++++++---------------------------------------
 1 files changed, 30 insertions(+), 78 deletions(-)

diff --git a/src/utils/components/init-map.vue b/src/utils/components/init-map.vue
index f26094c..6b1ea9d 100644
--- a/src/utils/components/init-map.vue
+++ b/src/utils/components/init-map.vue
@@ -8,10 +8,10 @@
     <div class="cesiumBotton">
       <div class="cesiumButtonGroup">
         <el-button id="groundPoi" @click="addGroundPoi()" type="primary">鍦伴潰鐐�</el-button>
-        <el-button id="groundPoi" @click="addGroundPoi()" type="primary">绌轰腑鐐�</el-button>
-        <el-button id="groundPoi" @click="addGroundPoi()" type="primary">鍋滅暀鏃堕棿</el-button>
+        <!-- <el-button id="groundPoi" @click="addGroundPoi()" type="primary">鍋滅暀鏃堕棿</el-button> -->
         <el-input v-model="mergeNumber" placeholder="璇疯緭鍏ュ悎骞惰寖鍥�" type="number" style="width: 150px;"></el-input>
         <el-button  @click="mergePoint()" type="success">鍚堝苟</el-button>
+        <el-button  @click="renderData()" type="success">鏁版嵁娓叉煋</el-button>
 
       </div>
     </div>
@@ -36,12 +36,23 @@
 let  viewerM;
 let  viewerC;
 let  counter = 0;
-let  pois = [125.1541, 46.5542,0] 
+ let globalon  = 125.1949
+let globalat = 46.5143
+let  pois = [globalon, globalat,0] 
+
+// let  pois = [0, 0,0] 
 let holdingPosition;
 let rightKeyMove = false
-// let  pois = [125.1541, 46.5542,0] 
 let  distance = 100; 
 export default {
+  props: {
+    towerUrl: {
+      type: String,
+      default() {
+        return ''
+      }
+    },
+  },
   data(){
     return{
         moveSpeed: 1,
@@ -108,8 +119,6 @@
     initViewer(cesiumId){
       //cesium鍏ㄧ悆30绫冲垎杈ㄧ巼鍦板舰璧勬簮token
       let imageryProvider1 = new Cesium.TileMapServiceImageryProvider({
-        // url: process.env.VUE_APP_BASE_GIS + "/daqing/dom-sea",
-        // url: process.env.VUE_APP_BASE_GIS + "/daqing/dom-sea",
         url: `https://192.168.1.2:9999/daqing/dom-sea/`,
       });
       let viewer = new Cesium.Viewer(cesiumId, {
@@ -124,6 +133,7 @@
           navigationHelpButton: false,
           navigationInstructionsInitiallyVisible: false,
           imageryProvider: imageryProvider1,
+          // imageryProvider: false,
           shadows: false,
           animation: false,
           infoBox: false,
@@ -132,6 +142,11 @@
           fullscreenButton: false,
           vrButton: false,
       });
+       // 鍏抽棴澶╃┖鐩掓晥鏋�
+      // viewer.scene.skyAtmosphere = undefined; // 鎴栬�呰缃负 null
+      
+      // // 鍏抽棴鍏夌収鏁堟灉
+      // viewer.scene.globe.enableLighting = false; // 鍏抽棴鍏夌収鏁堟灉
       window.viewer = viewer;
     //    viewer.imageryLayers.add(bdtvectoranoimagery);
       viewer._cesiumWidget._creditContainer.style.display="none";  
@@ -139,7 +154,7 @@
       
     },
     loadModel(){
-      const modelUrl = 'http://192.168.1.2:9001/model/tower.glb';  // GLB妯″瀷璺緞
+      const modelUrl = this.towerUrl;  // GLB妯″瀷璺緞
        // 娌垮師鐐瑰潗鏍囧拰鍦伴潰鐐瑰潗鏍囨柟鍚戜笂閫夊彇绌轰腑鐐圭殑璺濈
       //鍒濆鍖栫浉鏈虹獥鍙h瑙掑弬鏁�
       cameraPostion = viewerM.camera.position
@@ -149,17 +164,18 @@
 
       // 璁剧疆瑙嗚锛屼娇鍏堕粯璁ゆ煡鐪嬫煇涓湴鐞嗕綅缃�
       viewerM.scene.camera.setView({
-          destination: Cesium.Cartesian3.fromDegrees(125.1511, 46.5542, 349.0), // 浠ョ粡绾害璁剧疆浣嶇疆锛堜緥濡傦細澶у簡榫欏叴璺級
+          destination: Cesium.Cartesian3.fromDegrees(globalon, globalat, 349.0), // 浠ョ粡绾害璁剧疆浣嶇疆锛堜緥濡傦細澶у簡榫欏叴璺級
+          // destination: Cesium.Cartesian3.fromDegrees(0.0005, 0.0017, 207.8), // 浠ョ粡绾害璁剧疆浣嶇疆锛堜緥濡傦細澶у簡榫欏叴璺級
           orientation: {
-              heading: Cesium.Math.toRadians(86.94),  // 鏂瑰悜
-              pitch: Cesium.Math.toRadians(-30.22), // 淇
+              heading: Cesium.Math.toRadians(194.65),  // 鏂瑰悜
+              pitch: Cesium.Math.toRadians(-31.43), // 淇
               roll: 0
           }
       });
 
       //鍒涘缓妯″瀷
       const glbModelPoi = Cesium.Cartesian3.fromDegrees(pois[0], pois[1],pois[2]);
-      const heading = Cesium.Math.toRadians(10);
+      const heading = Cesium.Math.toRadians(0);
       const pitch = Cesium.Math.toRadians(0);
       const roll = Cesium.Math.toRadians(0);
       const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
@@ -214,9 +230,6 @@
       }
     },
     addGroundPoi() {
-      console.log('1111111111111111')
-      console.log(new Cesium.ScreenSpaceEventHandler(viewerM.canvas))
-      console.log(this)
         let createPinHandler = new Cesium.ScreenSpaceEventHandler(viewerM.canvas);
         let _this = this
         createPinHandler.setInputAction(function (click) {
@@ -232,7 +245,6 @@
                 let lng = Cesium.Math.toDegrees(cartographic.longitude);
                 let lat = Cesium.Math.toDegrees(cartographic.latitude);
                 height = cartographic.height;
-                // camPosition = lng+','+lat+','+height;
                 console.log(lng+','+lat+','+height)
             }
 
@@ -263,45 +275,12 @@
             聽聽聽聽const scalerNormalize聽=聽Cesium.Cartesian3.multiplyByScalar(normalize,distance,new聽Cesium.Cartesian3());
                 const tagert = Cesium.Cartesian3.add(holdingPosition,scalerNormalize,new聽Cesium.Cartesian3());
                 console.log(Cesium.Cartographic.fromCartesian(tagert))
-                var airCartographic= Cesium.Cartographic.fromCartesian(tagert)
-                var airPointLongitude= Cesium.Math.toDegrees(airCartographic.longitude);
-                var airPointLatitude = Cesium.Math.toDegrees(airCartographic.latitude);
-                var airPointHeight = airCartographic.height;
                 _this.creatPin("aerialPoiId"+counter,tagert,`绌�${counter}`,Cesium.Color.RED,viewerM);
                 _this.updateCameraMovement();
-                // console.log(direction)
-                // console.log(normalize聽)
-                // console.log(longitude)
-                // console.log(latitude)
-                // console.log(pois)
-                // console.log(azimuthtwopoi(longitude,latitude,pois[0],pois[1]))
-                // let data = {
-                //   id:(Date.now().toString(16) + Math.random().toString(16).slice(2, 10)).slice(0, 16),
-                //   label:`鍦伴潰鐐�${counter}`,
-                //   longitude:longitude,
-                //   latitude:latitude,
-                //   height:height,
-                //   children:[
-                //     {
-                //       id:(Date.now().toString(16) + Math.random().toString(16).slice(2, 10)).slice(0, 16),
-                //       label:`绌轰腑鐐�${counter}`,
-                //       longitude:airPointLongitude,
-                //       latitude:airPointLatitude,
-                //       height:airPointHeight,
-                //     }
-                //   ]
-                // }
-                // _this.$emit('rightClickEnd',data)
                 //缁撴潫鍙抽敭鐩戝惉
                 createPinHandler.destroy();
                 //缁撴潫涓诲浘鑱斿姩楣扮溂鐩戝惉
                 viewerM.scene.preRender.removeEventListener(_this.syncViewer());
-                // viewerM.scene.preRender.removeEventListener(this._preRenderCallback);
-                // if (this._preRenderCallback) {
-                //   this.viewerM.scene.preRender.removeEventListener(this._preRenderCallback);
-                //   this._preRenderCallback = null;
-                // }
-                //鏇存柊鐩告満瑙嗚涓虹┖涓偣
                 _this.changeCamera(tagert,_this.azimuthtwopoi(longitude,latitude,pois[0],pois[1]));
                 rightKeyMove = true
                 counter += 1;
@@ -341,7 +320,6 @@
         });
     },
     registerKeyboardEvents() {
-      console.log('11111111111111111111111')
       window.addEventListener("keydown", this.onKeyDown);
       window.addEventListener("keyup", this.onKeyUp);
     },
@@ -401,9 +379,6 @@
         case "1":
           viewerC.scene.mode = Cesium.SceneMode.SCENE3D;
           break;
-        // case "2":
-        //   viewerC.scene.mode = Cesium.SceneMode.SCENE2D;
-        //   break;
         case "3":
           viewerC.scene.mode = Cesium.SceneMode.COLUMBUS_VIEW;
           break;
@@ -411,22 +386,16 @@
     },
     onKeyUp(event) {
       //閿洏鎶捣杩涜鏇存柊宸︿晶绌轰腑鐐筽in
-      console.log(viewerM)
-      console.log(counter)
       //鑾峰彇鍙充晶鐩告満
       if(rightKeyMove){
         const camera = viewerC.camera;
-        console.log(camera)
         const carto = Cesium.Cartographic.fromCartesian(camera.position);
-        console.log(carto)
         //鍙充晶鐩告満瑙嗚杞寲涓虹粡绾害
         const lon = Cesium.Math.toDegrees(carto.longitude);
         const lat = Cesium.Math.toDegrees(carto.latitude);
         const height = carto.height;
         const position = Cesium.Cartesian3.fromDegrees(lon, lat, height)
-        console.log(position)
         let pinBuilder = new Cesium.PinBuilder();
-        // const dest = this.calculateDestinationPoint(lon, lat, camera.heading, speed);
         const groupEntity = viewerM.entities.getById("aerialPoiId"+(counter-1));
         //宸︿晶鍦板浘鍚屾鏇存柊pin绌轰腑鐐逛綅缃�
         if (groupEntity == undefined) {
@@ -521,17 +490,8 @@
       let rotSpeed = 1;
       if (this.keyState.shift) rotSpeed *= this.speedMultiplier;
       if (this.keyState.ctrl) rotSpeed *= this.slowMultiplier;
-      const multiplyByScalarrotateAmount = Cesium.Math.toRadians(0.5 * rotSpeed);
-
-      // if (this.keyState.up) camera.lookUp(rotateAmount);
-      // if (this.keyState.down) camera.lookDown(rotateAmount);
-      // if (this.keyState.left) camera.lookLeft(rotateAmount);
-      // if (this.keyState.right) camera.lookRight(rotateAmount);
       if (holdingPosition) {
-          // const groupPosition  = groupEntity.position.getValue(Cesium.JulianDate.now());
-          // console.log(groupPosition)
           const distance = Cesium.Cartesian3.distance(holdingPosition, camera.position);
-
           const surroundSpeed = 0.005; //鐜粫閫熷害,瑙掑害
           let cameraHeading = camera.heading;
           let cameraPitch = camera.pitch;
@@ -548,7 +508,6 @@
           if (this.keyState.right) camera.lookRight(rotateAmount);
       }
       this.resetRoll();
-
       // Schedule next frame
       this.animationFrameId = requestAnimationFrame(this.updateCameraMovement);
     }, 
@@ -573,9 +532,7 @@
 
       return { lon: toDeg(lon2Norm), lat: toDeg(lat2Rad) };
     },
-
     uavMoveForward(speed) {
-      console.log('11111' +speed)
       const camera = viewerC.camera;
       const carto = Cesium.Cartographic.fromCartesian(camera.position);
       const lon = Cesium.Math.toDegrees(carto.longitude);
@@ -626,15 +583,11 @@
     cammove_measure_point(){
       CesiumSurvey.cammeasureMovePoint(viewerM,'cammoveResultCon');
     },
+    renderData(){
+        this.$emit('renderData',viewerM)
+    },
     mergePoint(){
       let allEntities = viewerM.entities.values; // 鎵�鏈夊疄浣撳璞$粍鎴愮殑鏁扮粍
-      console.log(allEntities)
-      allEntities.forEach(entity => {
-        console.log('ID:', entity.id);
-        console.log('Position:', entity.position ? entity.position.getValue(Cesium.JulianDate.now()) : null);
-        console.log('Name:', entity.name);
-        console.log('Properties:', entity.properties); // 鑷畾涔夊睘鎬�
-      });
       const grouped = {};
       //鎵�鏈夊疄浣撳璞$粍鎴愮殑鏁扮粍杞崲鎴愬乏渚ф爲闇�瑕佺殑鏍煎紡
       allEntities.forEach(item => {
@@ -669,7 +622,6 @@
           ]
         };
       });
-      console.log(result)
       this.$emit('mergePoint',result,this.mergeNumber,viewerM)
     },
     genId() {

--
Gitblit v1.9.3