From 137609815a89f21386e5b73d0686bf5c43258b50 Mon Sep 17 00:00:00 2001 From: jihongshun <1151753686@qq.com> Date: 星期一, 15 九月 2025 10:04:45 +0800 Subject: [PATCH] fix+ --- src/views/system/flightRouteSimulation/index.vue | 110 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 63 insertions(+), 47 deletions(-) diff --git a/src/views/system/flightRouteSimulation/index.vue b/src/views/system/flightRouteSimulation/index.vue index d143340..53aa4a5 100644 --- a/src/views/system/flightRouteSimulation/index.vue +++ b/src/views/system/flightRouteSimulation/index.vue @@ -106,7 +106,11 @@ id: 'frustumOutline', positionProperty : new Cesium.SampledPositionProperty(), orientation : new Cesium.SampledProperty(Cesium.Quaternion),//鏃犱汉鏈烘湞鍚� - sztOrientation : new Cesium.SampledProperty(Cesium.Quaternion),//浜戝彴鏈濆悜 + // sztOrientation : new Cesium.SampledProperty(Cesium.Quaternion),//浜戝彴鏈濆悜 + holderHeadingProperty : new Cesium.SampledProperty(Number),//浜戝彴鏈濆悜heading + holderPitchProperty : new Cesium.SampledProperty(Number),//浜戝彴鏈濆悜pitch + holderRollProperty : new Cesium.SampledProperty(Number),//浜戝彴鏈濆悜roll + // flyHeadingProperty : new Cesium.SampledProperty(Number),//鏃犱汉鏈篽eading } }, mounted() { @@ -171,7 +175,7 @@ roll:item.roll || 0, // speed: speeds[index] || 0, speed: 80, - // flyHeading:item.flyHeading + flyHeading:item.flyHeading }; }); this.trajectoryData = result @@ -453,13 +457,16 @@ // Cesium.Math.toRadians(data.roll) // ); const hpr = new Cesium.HeadingPitchRoll( - Cesium.Math.toRadians(0), + Cesium.Math.toRadians(data.flyHeading), Cesium.Math.toRadians(0), Cesium.Math.toRadians(0) ); const quaternion = Cesium.Transforms.headingPitchRollQuaternion(position, hpr); + // // 娣诲姞椋炴満鏈濆悜閲囨牱 this.orientation.addSample(time, quaternion); + //鏃犱汉鏈篽eading + // this.flyHeadingProperty.addSample(time, data.flyHeading) //浜戝彴 const szthpr = new Cesium.HeadingPitchRoll( Cesium.Math.toRadians(data.heading), @@ -470,8 +477,11 @@ // console.log( Cesium.Math.toRadians(data.heading)) const sztquaternion = Cesium.Transforms.headingPitchRollQuaternion(position, szthpr); console.log(sztquaternion) - this.sztOrientation.addSample(time, sztquaternion); - console.log(this.sztOrientation) + // this.sztOrientation.addSample(time, sztquaternion); + this.holderHeadingProperty.addSample(time, data.heading) + this.holderPitchProperty.addSample(time, data.pitch) + this.holderRollProperty.addSample(time, data.roll) + // console.log(this.sztOrientation) // console.log(this.orientation) }) // console.log(">> positionProperty:",this.positionProperty ); @@ -505,6 +515,11 @@ trailTime: 60 }, orientation:this.orientation + // orientation: { + // heading: Cesium.Math.toRadians(this.flyHeadingProperty), + // pitch: Cesium.Math.toRadians(0), + // roll: Cesium.Math.toRadians(0), + // } }) }, // 鏇存柊瑙嗛敟浣撲綅缃拰鏈濆悜 @@ -554,7 +569,7 @@ }, getCurrentPosition() { let viewer = window['cesiumContainer'].viewer; - console.log(this.sztOrientation) + // console.log(this.sztOrientation) // 鑾峰彇褰撳墠鏃堕棿 const currentTime = viewer.clock.currentTime; console.log("褰撳墠鏃堕棿锛�", Cesium.JulianDate.toDate(currentTime)); @@ -579,53 +594,54 @@ this.currentHeight = cartographicPosition.height; this.c3Position = Cesium.Cartesian3.fromDegrees(this.currentLongitude, this.currentLatitude,this.currentHeight) //鐩告満鍙樺寲 - const quaternion = this.orientation.getValue(currentTime) - // if(quaternion) { - // const hpr111 = Cesium.HeadingPitchRoll.fromQuaternion(quaternion) - // console.log('鐩告満鐨� ' +Cesium.Math.toDegrees(hpr111.heading).toFixed(2)) - // } - //浜戝彴鍙樺寲 - const sztquaternion = this.sztOrientation.getValue(currentTime) - console.log(sztquaternion) - if (sztquaternion) { - const hpr = Cesium.HeadingPitchRoll.fromQuaternion(sztquaternion) - console.log(hpr) - this.heading = (Cesium.Math.toDegrees(hpr.heading).toFixed(2)-143.32384000000002 ) - // this.heading = 180 - this.pitch = (Cesium.Math.toDegrees(hpr.pitch).toFixed(2) - 14.33) - // this.roll = Cesium.Math.toDegrees(hpr.roll).toFixed(2) - this.roll = 0 - // console.log('褰撳墠浣嶇疆 - heading ' + this.heading) - console.log(`褰撳墠浣嶇疆 - heading: ${this.heading}, pitch: ${this.pitch}, roll: ${this.roll}`); + const holderUavHeading = this.holderHeadingProperty.getValue(currentTime) + if(holderUavHeading) { + this.heading = holderUavHeading } + //浜戝彴鍙樺寲 + // const sztquaternion = this.sztOrientation.getValue(currentTime) + // console.log(sztquaternion) + // if (sztquaternion) { + // const hpr = Cesium.HeadingPitchRoll.fromQuaternion(sztquaternion) + // console.log(hpr) + // this.heading = (Cesium.Math.toDegrees(hpr.heading).toFixed(2)-143.32384000000002 ) + // // this.heading = 180 + // this.pitch = (Cesium.Math.toDegrees(hpr.pitch).toFixed(2) - 14.33) + // // this.roll = Cesium.Math.toDegrees(hpr.roll).toFixed(2) + // this.roll = 0 + // // console.log('褰撳墠浣嶇疆 - heading ' + this.heading) + // console.log(`褰撳墠浣嶇疆 - heading: ${this.heading}, pitch: ${this.pitch}, roll: ${this.roll}`); + // } + const holderYtHeading = this.holderHeadingProperty.getValue(currentTime) + const holderYtPitch = this.holderPitchProperty.getValue(currentTime) + const holderYtRoll = this.holderRollProperty.getValue(currentTime) + if(holderYtHeading) { + // this.heading = Cesium.Math.toDegrees(holderYtHeading).toFixed(2) + // this.pitch = Cesium.Math.toDegrees(holderYtPitch).toFixed(2) + // this.roll = Cesium.Math.toDegrees(holderYtRoll).toFixed(2) + this.heading = holderYtHeading + this.pitch = holderYtPitch + this.roll = holderYtRoll + console.log('褰撳墠浣嶇疆 - heading ' + this.heading) + console.log(`褰撳墠浣嶇疆 - heading: ${this.heading}, pitch: ${this.pitch}, roll: ${this.roll}`); + } + // console.log(sztquaternion) + // if (sztquaternion) { + // const hpr = Cesium.HeadingPitchRoll.fromQuaternion(sztquaternion) + // console.log(hpr) + // this.heading = (Cesium.Math.toDegrees(hpr.heading).toFixed(2)-143.32384000000002 ) + // // this.heading = 180 + // this.pitch = (Cesium.Math.toDegrees(hpr.pitch).toFixed(2) - 14.33) + // // this.roll = Cesium.Math.toDegrees(hpr.roll).toFixed(2) + // this.roll = 0 + // // console.log('褰撳墠浣嶇疆 - heading ' + this.heading) + // console.log(`褰撳墠浣嶇疆 - heading: ${this.heading}, pitch: ${this.pitch}, roll: ${this.roll}`); + // } this.updateFrustum(); } else { console.log("鏃犳硶鑾峰彇褰撳墠浣嶇疆"); } - }, - quaternionToHeadingPitchRoll(quaternion) { - const x = quaternion.x; - const y = quaternion.y; - const z = quaternion.z; - const w = quaternion.w; - - // 鏋勫缓鏃嬭浆鐭╅樀鍏冪礌 - const m11 = 1 - 2 * (y * y + z * z); - const m12 = 2 * (x * y - w * z); - const m13 = 2 * (x * z + w * y); - const m21 = 2 * (x * y + w * z); - const m22 = 1 - 2 * (x * x + z * z); - const m23 = 2 * (y * z - w * x); - const m31 = 2 * (x * z - w * y); - const m32 = 2 * (y * z + w * x); - const m33 = 1 - 2 * (x * x + y * y); - - const heading = Math.atan2(m21, m11); - const pitch = Math.asin(-m31); - const roll = Math.atan2(m32, m33); - - return new Cesium.HeadingPitchRoll(heading, pitch, roll); }, showGZ(){ let viewer = window['cesiumContainer'].viewer; -- Gitblit v1.9.3