From 8b89b724b38dd39cfda49b98411619dcecb86beb Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期一, 08 九月 2025 17:23:09 +0800
Subject: [PATCH] 航线莫你——视锥体更新

---
 src/views/system/flightRouteSimulation/index.vue |  106 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 86 insertions(+), 20 deletions(-)

diff --git a/src/views/system/flightRouteSimulation/index.vue b/src/views/system/flightRouteSimulation/index.vue
index 476d099..5118cb6 100644
--- a/src/views/system/flightRouteSimulation/index.vue
+++ b/src/views/system/flightRouteSimulation/index.vue
@@ -30,7 +30,10 @@
       //       latitude:46.55684464616254,    // 绾害
       //       height:33.157873665937274      // 楂樺害(绫�)
       //     },
-      //     speed: 0           // 閫熷害(鍏噷/灏忔椂)
+      //     heading:0,
+      //     pitch:-90,
+      //     roll:0,
+      //     speed: 10           // 閫熷害(鍏噷/灏忔椂)
       //   },
       //   {
       //     time: '2025-04-01T13:01:00Z', // ISO 8601鏍煎紡鏃堕棿
@@ -39,6 +42,9 @@
       //       latitude: 46.55684011411894,    // 绾害
       //       height: 37.91924525928209      // 楂樺害(绫�)
       //     },
+      //     heading:30,
+      //     pitch:45,
+      //     roll:45,
       //     speed: 10           // 閫熷害(鍏噷/灏忔椂)
       //   },
       //   {
@@ -49,6 +55,9 @@
       //       latitude: 46.556840114118955,    // 绾害
       //       height:87.91924526022864       // 楂樺害(绫�)
       //     },
+      //     heading:90,
+      //     pitch:0,
+      //     roll:45,
       //     speed: 20           // 閫熷害(鍏噷/灏忔椂)
       //   },
       //   {
@@ -59,6 +68,9 @@
       //       latitude: 46.556326837883375,    // 绾害
       //       height: 83.15663931356488       // 楂樺害(绫�)
       //     },
+      //     heading:180,
+      //     pitch:60,
+      //     roll:0,
       //     speed: 30           // 閫熷害(鍏噷/灏忔椂)
       //   },
       //   {
@@ -68,6 +80,9 @@
       //       latitude: 46.55632683788337,    // 绾害
       //       height: 33.15663931413056       // 楂樺害(绫�)
       //     },
+      //     heading:150,
+      //     pitch:0,
+      //     roll:45,
       //     speed: 80           // 閫熷害(鍏噷/灏忔椂)
       //   },
 
@@ -84,13 +99,14 @@
       aspectRatio: 1.0,  // 绾垫í姣�
       color: '#FF0000',  // 瑙嗛敟浣撻鑹�
       id: 'frustumOutline',
-      positionProperty : new Cesium.SampledPositionProperty()
+      positionProperty : new Cesium.SampledPositionProperty(),
+      orientation : new Cesium.SampledProperty(Cesium.Quaternion)
     }
   },
   mounted() {
     console.log(window.viewer)
     console.log(viewer)
-    this.showGZ()
+    // this.showGZ()
   },
   methods: {
     async handleKMZUpload(event) {
@@ -121,6 +137,9 @@
               latitude: item.lat,
               height: parseFloat(item.alt)
             },
+            heading:item.heading|| 0,
+            pitch:item.pitch|| 0,
+            roll:item.roll || 0,
             speed: speeds[index] || 0
           };
         });
@@ -166,10 +185,39 @@
       placemarks.forEach(placemark => {
         const coords = placemark.Point?.[0]?.coordinates?.[0];
         const height = placemark["wpml:height"]?.[0];
+        // 鎻愬彇 aircraftHeading
+        // 鎻愬彇 action 閲岀殑鍙傛暟
+        let heading = null;
+        let gimbalPitch = null, gimbalRoll = null, gimbalYaw = null;
+
+        if (placemark["wpml:actionGroup"]?.[0]?.["wpml:action"]) {
+          placemark["wpml:actionGroup"][0]["wpml:action"].forEach(action => {
+            let params = action["wpml:actionActuatorFuncParam"]?.[0];
+
+            if (!params) return;
+
+            // 椋炴満鑸悜瑙�
+            if (action["wpml:actionActuatorFunc"]?.[0] === "rotateYaw" &&
+                params["wpml:aircraftHeading"]) {
+              heading = Number(params["wpml:aircraftHeading"][0]);
+            }
+
+            // 浜戝彴瑙掑害
+            if (action["wpml:actionActuatorFunc"]?.[0] === "gimbalRotate") {
+              if (params["wpml:gimbalPitchRotateAngle"])
+                gimbalPitch = Number(params["wpml:gimbalPitchRotateAngle"][0]);
+              if (params["wpml:gimbalRollRotateAngle"])
+                gimbalRoll = Number(params["wpml:gimbalRollRotateAngle"][0]);
+              if (params["wpml:gimbalYawRotateAngle"])
+                gimbalYaw = Number(params["wpml:gimbalYawRotateAngle"][0]);
+            }
+          });
+        }
         if (coords) {
           coords.trim().split(" ").forEach(coord => {
             const [lng, lat] = coord.split(",").map(Number);
-            points.push({ lng, lat, alt: height });
+            //,heading:gimbalYaw || 0,pitch:gimbalPitch|| 0,roll:gimbalRoll|| 0
+            points.push({ lng, lat, alt: height,heading:gimbalYaw || 0,pitch:gimbalPitch|| 0,roll:gimbalRoll|| 0 });
           });
         }
       });
@@ -311,6 +359,7 @@
 
       // 鍒涘缓浣嶇疆鍜岄�熷害灞炴��
       const speedProperty = new Cesium.SampledProperty(Number)
+
       console.log(">> this.trajectoryData:", this.trajectoryData);
       // 娣诲姞閲囨牱鐐�
       this.trajectoryData.forEach(data => {
@@ -322,6 +371,16 @@
         )
         this.positionProperty.addSample(time, position)
         speedProperty.addSample(time, data.speed)
+            // 璁$畻鏈濆悜鍥涘厓鏁�
+        const hpr = new Cesium.HeadingPitchRoll(
+            Cesium.Math.toRadians(data.heading),
+            Cesium.Math.toRadians(data.pitch),
+            Cesium.Math.toRadians(data.roll)
+        );
+        const quaternion = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
+        
+        // // 娣诲姞鏈濆悜閲囨牱
+        this.orientation.addSample(data.time, quaternion);
       })
       console.log(">> positionProperty:",this.positionProperty );
 
@@ -346,7 +405,7 @@
         // },
         model: {
           uri: "/Model/M300.glb", // 娉ㄦ剰entitits.add鏂瑰紡鍔犺浇gltf鏂囦欢鏃讹紝杩欓噷鏄痷ri锛屼笉鏄痷rl锛屽苟涓旇繖绉嶆柟寮忓彧鑳藉姞杞�.glb鏍煎紡鐨勬枃浠�
-          scale:  1, // 缂╂斁姣斾緥
+          scale:  10, // 缂╂斁姣斾緥
           // minimumPixelSize: this.minSize, // 鏈�灏忓儚绱犲ぇ灏忥紝鍙互閬垮厤澶皬鐪嬩笉瑙�
           minimumPixelSize: 0, // 鏈�灏忓儚绱犲ぇ灏忥紝鍙互閬垮厤澶皬鐪嬩笉瑙�
           maximumScale: 20000, // 妯″瀷鐨勬渶澶ф瘮渚嬪昂澶у皬銆俶inimumPixelSize鐨勪笂闄�
@@ -369,13 +428,14 @@
           leadTime: 60,
           trailTime: 60
         },
-        orientation: Cesium.Quaternion.fromHeadingPitchRoll(
-            new Cesium.HeadingPitchRoll(
-                Cesium.Math.toRadians(45), // 鑸悜瑙�(姝e寳涓�0锛岄『鏃堕拡澧炲姞)
-                Cesium.Math.toRadians(45), // 淇话瑙�
-                Cesium.Math.toRadians(0)  // 缈绘粴瑙�
-            )
-        ),
+        // orientation: Cesium.Quaternion.fromHeadingPitchRoll(
+        //     new Cesium.HeadingPitchRoll(
+        //         Cesium.Math.toRadians(45), // 鑸悜瑙�(姝e寳涓�0锛岄『鏃堕拡澧炲姞)
+        //         Cesium.Math.toRadians(45), // 淇话瑙�
+        //         Cesium.Math.toRadians(0)  // 缈绘粴瑙�
+        //     )
+        // ),
+        orientation:this.orientation
       })
     },
      // 鏇存柊瑙嗛敟浣撲綅缃拰鏈濆悜
@@ -397,9 +457,6 @@
             roll: Cesium.Math.toRadians(this.roll),
           },
         });
-
-        // 鍙湪frustumOutline瀛樺湪鏃惰皟鐢╱pdate
-        this.frustumOutline.update();
       } else {
         console.warn('Frustum outline is not initialized');
       }
@@ -426,9 +483,8 @@
       const currentTime = viewer.clock.currentTime;
       
       // 浠� positionProperty 涓幏鍙栧綋鍓嶄綅缃�
-      console.log(this.positionProperty)
       const currentPosition = this.positionProperty.getValue(currentTime);
-
+      console.log('currentPosition>>>>>>>>>>>>>>>>>>>>>>>' + currentPosition)
       // 濡傛灉鑾峰彇鍒颁綅缃�
       if (currentPosition) {
         // 灏嗕綅缃粠 Cartesian 杞崲涓� Cartographic
@@ -439,7 +495,15 @@
         this.currentLatitude = Cesium.Math.toDegrees(cartographicPosition.latitude);
         this.currentHeight = cartographicPosition.height;
         this.c3Position = Cesium.Cartesian3.fromDegrees(this.currentLongitude, this.currentLatitude,this.currentHeight)
-        console.log(`褰撳墠浣嶇疆 - 缁忓害: ${this.currentLongitude}, 绾害: ${this.currentLatitude}, 楂樺害: ${this.currentHeight}`);
+        // console.log(`褰撳墠浣嶇疆 - 缁忓害: ${this.currentLongitude}, 绾害: ${this.currentLatitude}, 楂樺害: ${this.currentHeight}`);
+        const quaternion = this.orientation.getValue(currentTime)
+        if (quaternion) {
+          const hpr = Cesium.HeadingPitchRoll.fromQuaternion(quaternion)
+          this.heading = Cesium.Math.toDegrees(hpr.heading).toFixed(2)
+          this.pitch = Cesium.Math.toDegrees(hpr.pitch).toFixed(2)
+          this.roll = Cesium.Math.toDegrees(hpr.roll).toFixed(2)
+          console.log(`褰撳墠浣嶇疆 - heading: ${hpr.heading}, pitch: ${hpr.pitch}, roll: ${hpr.roll}`);
+        }
         this.updateFrustum();
       } else {
         console.log("鏃犳硶鑾峰彇褰撳墠浣嶇疆");
@@ -450,7 +514,8 @@
       this.camera = new Cesium.Camera(viewer.scene)
       // 瑙嗛敟浣撳弬鏁�
       this.camera.frustum = new Cesium.PerspectiveFrustum({
-        fov: Cesium.Math.PI_OVER_THREE,
+        // fov: Cesium.Math.PI_OVER_THREE,
+        fov: Cesium.Math.toRadians(10),
         // aspectRatio: this.aspectRatio,
         aspectRatio: 1920 / 1080,
       });
@@ -472,7 +537,8 @@
         camera: this.camera,
         frustumSplits: [0.01, 10000],
         color: Cesium.Color.fromCssColorString('#00ff00'),
-        updateOnChange: false,
+        // updateOnChange: false,
+        updateOnChange: true,
       })
       console.log(this.frustumOutline)
       viewer.scene.primitives.add(this.frustumOutline);

--
Gitblit v1.9.3