| | |
| | | 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 |
| | | }) |
| | | } |
| | | |
| | |
| | | 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 |
| | |
| | | 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 { |
| | |
| | | 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) |
| | | } |