| | |
| | | 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),//无人机heading |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | roll:item.roll || 0, |
| | | // speed: speeds[index] || 0, |
| | | speed: 80, |
| | | // flyHeading:item.flyHeading |
| | | flyHeading:item.flyHeading |
| | | }; |
| | | }); |
| | | this.trajectoryData = result |
| | |
| | | // 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); |
| | | //无人机heading |
| | | // this.flyHeadingProperty.addSample(time, data.flyHeading) |
| | | //云台 |
| | | const szthpr = new Cesium.HeadingPitchRoll( |
| | | Cesium.Math.toRadians(data.heading), |
| | |
| | | // 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 ); |
| | |
| | | trailTime: 60 |
| | | }, |
| | | orientation:this.orientation |
| | | // orientation: { |
| | | // heading: Cesium.Math.toRadians(this.flyHeadingProperty), |
| | | // pitch: Cesium.Math.toRadians(0), |
| | | // roll: Cesium.Math.toRadians(0), |
| | | // } |
| | | }) |
| | | }, |
| | | // 更新视锥体位置和朝向 |
| | |
| | | }, |
| | | 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)); |
| | |
| | | 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; |