实现单机版
This commit is contained in:
@@ -19,6 +19,8 @@ import { VcViewer, VcLayerImagery, VcProviderImageryTianditu, VcNavigation, VcDa
|
||||
// import 'vue-cesium/dist/index.css'
|
||||
import earth from '../assets/earth.jpg'
|
||||
|
||||
import entity from '../api/entity'
|
||||
|
||||
const store = useStore()
|
||||
const czml = computed(() => './CZML/' + store.state.satelliteSystem.name + '.czml')
|
||||
|
||||
@@ -30,41 +32,43 @@ const getEntityById = id => {
|
||||
}
|
||||
const onDataSourceReady = ({ viewer, cesiumObject }) => {
|
||||
viewer.flyTo(cesiumObject)
|
||||
|
||||
entities = cesiumObject.entities.values
|
||||
entity.load(cesiumObject.entities.values)
|
||||
|
||||
// 显示卫星导航系统的科普信息
|
||||
viewer.selectedEntity = entities.find(entity => entity.id.startsWith('Constellation'))
|
||||
|
||||
// 将卫星状态信息存储到store中
|
||||
const satellites = entities.filter(entity => entity.id.startsWith('Satellite'))
|
||||
const satellite_state_arr = satellites.map(({ id, show }) => { return { id, show } })
|
||||
store.commit('satellites/set', satellite_state_arr)
|
||||
viewer.selectedEntity = entity.find('Constellation')
|
||||
}
|
||||
|
||||
let vcViewerInstance = null
|
||||
// const trackedSatelliteId = computed(() => store.state.trackedSatellite.id)
|
||||
// watch(trackedSatelliteId, (value) => {
|
||||
// const entity = getEntityById(value)
|
||||
|
||||
// if (!entity || !vcViewerInstance) return
|
||||
|
||||
// vcViewerInstance.selectedEntity = entity
|
||||
// vcViewerInstance.trackedEntity = entity
|
||||
// })
|
||||
|
||||
|
||||
// 显示/隐藏卫星
|
||||
store.subscribe(({ type, payload }) => {
|
||||
if (type === 'satellites/toggleShow') {
|
||||
const entity = getEntityById(payload)
|
||||
if (!entity) return
|
||||
const satellite = entity.get(payload)
|
||||
if (!satellite) return
|
||||
|
||||
entity.show = !entity.show
|
||||
satellite.show = !satellite.show
|
||||
}
|
||||
|
||||
if (type === 'satellites/track') {
|
||||
const satellite = entity.get(payload)
|
||||
if (!satellite || !vcViewerInstance) return
|
||||
|
||||
vcViewerInstance.selectedEntity = satellite
|
||||
vcViewerInstance.trackedEntity = satellite
|
||||
}
|
||||
})
|
||||
|
||||
let vcViewerInstance = null
|
||||
const trackedSatelliteId = computed(() => store.state.trackedSatellite.id)
|
||||
watch(trackedSatelliteId, (value) => {
|
||||
const entity = getEntityById(value)
|
||||
|
||||
if (!entity || !vcViewerInstance) return
|
||||
|
||||
vcViewerInstance.selectedEntity = entity
|
||||
vcViewerInstance.trackedEntity = entity
|
||||
})
|
||||
|
||||
const onTrackedEntityChanged = entity => {
|
||||
console.log(entity, '==============');
|
||||
store.commit('trackedSatellite/set', null)
|
||||
if (!entity) store.commit('trackedSatellite/set', null)
|
||||
}
|
||||
|
||||
const onViewerReady = ({ viewer }) => {
|
||||
|
||||
Reference in New Issue
Block a user