修复勾选卫星再修改载荷出现多余载荷,修复多目标轨迹回放不显示目标(因为时间错了)

This commit is contained in:
严争鸣 2025-02-19 18:35:06 +08:00
parent 516a54ee59
commit 2cf73646a7
6 changed files with 52 additions and 39 deletions

View File

@ -38,7 +38,7 @@ class SatelliteEntity {
set sensor(showSensor) {
// console.log(showSensor, 'showSensor')
this._sensor = showSensor
if (showSensor) {
if (showSensor && !this.sensorEntity) {
if (this._sensorType === 'conic') {
this.createConicSensor(this.entity)
} else if (this._sensorType === 'rectangle') {
@ -503,16 +503,17 @@ class SatelliteEntity {
viewer.scene.primitives.remove(this.sensorEntity)
}
this.sensorEntity = null
viewer.scene.preRender.addEventListener(this._listener)
this._listener = null
}
}
destroy() {
this.removeSensor()
viewer.entities.remove(this.entity)
this.underPointEntity && viewer.entities.remove(this.underPointEntity)
this.removeListener()
this.removeSensor()
}
removeListener() {

View File

@ -226,18 +226,18 @@ function addDaodan(trajData, type = 0) {
let minTime = 0
function initDaodan() {
saveDataToStore()
// minTime = getMinTime([
// ...toRaw(trajData.value.data),
// ...toRaw(interceptData.value.map(item => toRaw(item.data))).flat(Infinity),
// ])
// // console.log(minTime)
// addDaodan(trajData.value)
// aniIndexMap.set(trajData.value.id, 0)
// interceptData.value.forEach(item => {
// const { id, data } = item
// addDaodan(item, 1)
// aniIndexMap.set(id, 0)
// })
minTime = getMinTime([
...toRaw(trajData.value.data),
...toRaw(interceptData.value.map(item => toRaw(item.data))).flat(Infinity),
])
// console.log(minTime)
addDaodan(trajData.value)
aniIndexMap.set(trajData.value.id, 0)
interceptData.value.forEach(item => {
const { id, data } = item
addDaodan(item, 1)
aniIndexMap.set(id, 0)
})
}
function getMinTime(data) {

View File

@ -17,6 +17,7 @@ import EventList from './components/EventList'
import NewTask from './components/TaskList/components/NewTask'
import useTask from './components/TaskList/components/NewTask/hooks'
import { useEvent } from './components/EventList/hooks'
export default defineComponent({
setup() {
const show = ref(false)
@ -36,6 +37,13 @@ export default defineComponent({
const dd = ref(`DD-1`)
const paneClass = `border-1 h-full border-l-0 border-[var(--n-tab-border-color)] !p-2`
const { showMainEvent, mainEventData } = useEvent()
const addNewMainEvent = () => {
showMainEvent.value = true
mainEventData.value = {}
}
return () => (
<div class="flex flex-col bg-[#1c202c] w-h-full">
<div class="relative h-[60px]">
@ -114,9 +122,9 @@ export default defineComponent({
type="daterange"
clearable
/>
{/* <NButton type="primary" onClick={addNewTask}>
<NButton type="primary" onClick={addNewMainEvent}>
添加事件
</NButton> */}
</NButton>
</div>
<div class="flex-1">
<EventList dd={dd.value} />

View File

@ -23,6 +23,8 @@ export const useMultiMBTrajectory = () => {
const isPaused = ref<boolean>(false)
async function loadMultiHisTraj(timeRange: string[]) {
removeEntities()
const mbIds = [...mubiaoMap.keys()]
showEntity(false)
if (mbIds.length === 0) {
@ -33,13 +35,14 @@ export const useMultiMBTrajectory = () => {
id: mbId,
timeRange,
})
// console.log(points, posArray, timeArray)
timesMap.value.set(mbId, timeArray)
if (timeArray.length <= 1) {
continue
}
const color = Cesium.Color.fromRandom({ alpha: 1 })
createTarget(mbId, points, posArray as number[], color)
createTarget(mbId, points, posArray as number[], color, timeArray)
}
const allTime = [...timesMap.value.values()].flat()
@ -49,29 +52,33 @@ export const useMultiMBTrajectory = () => {
}
function showOrHideMultiHisTraj() {
if (showMultiHisTrajCom.value) {
reset()
}
// if (showMultiHisTrajCom.value) {
reset()
// }
showMultiHisTrajCom.value = !showMultiHisTrajCom.value
removeEntities()
if (!showMultiHisTrajCom.value) {
removeEntities()
showEntity(true)
}
}
function createTarget(
mbId: string,
points: TPoints,
posArray: number[],
color: Cesium.Color
color: Cesium.Color,
timeArray: number[]
) {
// const totalAnimationTime = points[points.length - 1].time
// console.log('totalAnimationTime', totalAnimationTime)
const positionProperty = new Cesium.SampledPositionProperty()
// const startTime = Cesium.JulianDate.now()
// 添加路径点到位置属性
points.forEach(point => {
points.forEach((point, index) => {
const pointEntity = createPoint(point.position, color)
pointsEntities.push(pointEntity)
const time = Cesium.JulianDate.fromDate(new Date(point.time))
const time = Cesium.JulianDate.fromDate(new Date(timeArray[index]))
// console.log(new Date(timeArray[index]).toLocaleString())
positionProperty.addSample(time, point.position)
})
@ -79,8 +86,10 @@ export const useMultiMBTrajectory = () => {
id: mbId,
targetType: '甲',
})
// console.log(mbEntityOpt)
// 创建实体
const mbTarget = viewer.entities.add({
show: true,
position: positionProperty,
// point: { pixelSize: 10, color: Cesium.Color.RED },
polyline: {
@ -95,7 +104,6 @@ export const useMultiMBTrajectory = () => {
...mbEntityOpt,
orientation: new Cesium.VelocityOrientationProperty(positionProperty),
})
mbTargetMap.set(mbId, mbTarget)
}
function createPoint(position: Cesium.Cartesian3, color: Cesium.Color) {
@ -173,7 +181,6 @@ export const useMultiMBTrajectory = () => {
viewer.entities.remove(mbTarget)
})
mbTargetMap.clear()
showEntity(true)
}
return {
customElapsedTime,

View File

@ -56,6 +56,12 @@ export const useMubiao = () => {
const addIds = difference(ids, [...mubiaoMap.keys()])
const removeIds = difference([...mubiaoMap.keys()], ids)
// 删除
if (removeIds.length > 0) {
removeIds.forEach(id => {
removeMubiao(id)
})
}
// 添加
if (addIds.length > 0) {
const nodes = filterTreeNodeByField({
@ -89,13 +95,6 @@ export const useMubiao = () => {
mubiaoMap.set(id, mbEntity)
})
}
// 删除
if (removeIds.length > 0) {
removeIds.forEach(id => {
removeMubiao(id)
})
}
}
async function postCheckedIds(ids: Array<string | number>) {

View File

@ -37,7 +37,9 @@ export function useSatellite() {
function addSatellites(ids: Array<string | number>) {
const addIds = difference(ids, [...satelliteMap.keys()])
const removeIds = difference([...satelliteMap.keys()], ids)
removeIds.forEach(id => {
removeSatellite(id)
})
if (addIds.length > 0) {
const nodes = filterTreeNodeByField({
treeData: satelliteList.value,
@ -53,10 +55,6 @@ export function useSatellite() {
}
})
}
removeIds.forEach(id => {
removeSatellite(id)
})
}
// 创建satellite entity 实例
function addSatellite({ id, tle }: ISatellite) {