From 7e302c923dec48881738eac64dfc1641d7c61885 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Tue, 17 Oct 2023 17:09:46 +0800
Subject: [PATCH] 无人机位置实时更新、朝向问题解决
---
src/hooks/use-cesium-tsa.ts | 13 ++++---------
src/pages/page-web/projects/tsa.vue | 6 +-----
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/src/hooks/use-cesium-tsa.ts b/src/hooks/use-cesium-tsa.ts
index bbf48af..d70dfcf 100644
--- a/src/hooks/use-cesium-tsa.ts
+++ b/src/hooks/use-cesium-tsa.ts
@@ -144,14 +144,12 @@
const addPoint = (pointOption: pointOption) => {
if (!pointOption.longitude && !pointOption.latitude) return
const position = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude)
- const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(pointOption.heading, pointOption.pitch, pointOption.roll))
viewer?.entities.add({
- position: Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude),
+ position,
billboard: pointOption.billboard,
point: pointOption.point,
label: pointOption.label,
id: pointOption.id,
- orientation
})
}
@@ -168,17 +166,14 @@
const pointEntity = viewer?.entities.getById(id)
return pointEntity
}
- // 更新实体位置
+ // 更新图片实体位置
function updateEntityPosition (longitude:number, latitude:number, id:string, params?:any) {
const entity = getEntityById(id) as Cesium.Entity
const position = Cesium.Cartesian3.fromDegrees(longitude, latitude)
- const heading = Cesium.Math.toRadians(params.heading)
- const pitch = Cesium.Math.toRadians(params.pitch)
- const roll = Cesium.Math.toRadians(params.roll)
- const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(heading, pitch, roll))
+ const heading = Cesium.Math.toRadians(-params.heading)
if (Cesium.defined(entity)) {
entity.position = position
- entity.orientation = orientation
+ entity.billboard.rotation = heading
}
}
// 飞行 flyto
diff --git a/src/pages/page-web/projects/tsa.vue b/src/pages/page-web/projects/tsa.vue
index ec804aa..adba68c 100644
--- a/src/pages/page-web/projects/tsa.vue
+++ b/src/pages/page-web/projects/tsa.vue
@@ -332,12 +332,9 @@
if (!droneEntity) {
droneEntity = cesium.getEntityById('drone_fly')
}
- console.log(data.deviceInfo[data.currentSn], '====deviceInfo====')
if (droneEntity) {
const orientation = {
heading: data.deviceInfo[data.currentSn].attitude_head,
- pitch: data.deviceInfo[data.currentSn].attitude_pitch,
- roll: data.deviceInfo[data.currentSn].attitude_roll
}
cesium.updateEntityPosition(data.deviceInfo[data.currentSn].longitude, data.deviceInfo[data.currentSn].latitude, 'drone_fly', orientation)
} else {
@@ -352,10 +349,9 @@
width: 36,
height: 36,
scale: 1.0,
+ rotation: 0.0
},
heading: data.deviceInfo[data.currentSn].attitude_head,
- pitch: data.deviceInfo[data.currentSn].attitude_pitch,
- roll: data.deviceInfo[data.currentSn].attitude_roll
}
cesium.addPoint(setting)
}
--
Gitblit v1.9.3