| | |
| | | import CreateFrustum from '@/utils/cesium/frustum/CreateFrustum' |
| | | |
| | | export function useTaskViewInfo (viewer, wsInfo, removeEntitys) { |
| | | const newViewer = unref(viewer) |
| | | const newViewer = isRef(viewer) ? viewer : ref(viewer) |
| | | |
| | | let viewInfoFrustum |
| | | // 设置视椎 |
| | |
| | | const attitude_head = 180 + host.attitude_head |
| | | const gimbal_pitch = 90 - Number(host?.payloads[0]?.gimbal_pitch) || 0 |
| | | |
| | | viewInfoFrustum = new CreateFrustum(newViewer, { |
| | | viewInfoFrustum = new CreateFrustum(newViewer.value, { |
| | | position: { |
| | | longitude: host.longitude, |
| | | latitude: host.latitude, |
| | |
| | | |
| | | function setAircraftGltf () { |
| | | const host = deviceOsdInfo.value?.data?.host |
| | | const aircraftEntity = newViewer.entities.getById('aircraftGltf') |
| | | const aircraftEntity = newViewer.value?.entities.getById('aircraftGltf') |
| | | const position = Cesium.Cartesian3.fromDegrees(host.longitude, host.latitude, host.height) |
| | | if (aircraftEntity) { |
| | | aircraftEntity.position = new Cesium.ConstantPositionProperty(position) |
| | | return |
| | | } |
| | | |
| | | newViewer.entities.add({ |
| | | newViewer.value?.entities.add({ |
| | | id: 'aircraftGltf', |
| | | position, |
| | | model: { |
| | |
| | | // 视椎加载处理 |
| | | const deviceOsdInfo = computed(() => wsInfo.value?.device_osd) |
| | | |
| | | watch(deviceOsdInfo, () => { |
| | | const host = deviceOsdInfo.value?.data?.host |
| | | |
| | | if ([14, 0].includes(host.mode_code)) { |
| | | mapEntityRemove() |
| | | return |
| | | watch( |
| | | [ |
| | | () => deviceOsdInfo.value, |
| | | () => newViewer.value |
| | | ], |
| | | ( |
| | | [curDeviceOsdInfo, curViewer], |
| | | ) => { |
| | | const host = deviceOsdInfo.value?.data?.host |
| | | |
| | | if (!curViewer) return |
| | | |
| | | if ([14, 0].includes(host.mode_code)) { |
| | | mapEntityRemove() |
| | | return |
| | | } |
| | | |
| | | setCreateFrustum(host) |
| | | setAircraftGltf() |
| | | } |
| | | |
| | | setCreateFrustum(host) |
| | | setAircraftGltf() |
| | | }) |
| | | ) |
| | | |
| | | const mapEntityRemove = () => { |
| | | viewInfoFrustum?.clear() |
| | | |
| | | newViewer.entities.removeById('aircraftGltf') |
| | | newViewer.value?.entities.removeById('aircraftGltf') |
| | | |
| | | removeEntitys && removeEntitys() |
| | | } |