Files
global-navigation-satellite…/src/render/components/SatelliteSystemView.vue

45 lines
1.2 KiB
Vue
Raw Normal View History

2022-05-27 12:51:56 +08:00
<template>
<vc-datasource-czml v-if="czml" :czml="czml" @ready="onDataSourceReady" />
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { useStore } from 'vuex'
import entity from '../api/entity'
// 卫星轨道数据处理
let vcViewerInstance: any = null
const store = useStore()
const czml = computed(() => './CZML/' + store.getters["satelliteSystem/name"] + '.czml')
const onDataSourceReady = ({ viewer, cesiumObject }) => {
if (!vcViewerInstance) vcViewerInstance = viewer
viewer.flyTo(cesiumObject)
entity.load(cesiumObject.entities.values)
// 显示卫星导航系统的科普信息
viewer.selectedEntity = entity.find('Constellation')
}
// 显示/隐藏、跟踪卫星等交互操作
store.subscribeAction(({ type, payload }) => {
// 显示/隐藏卫星
if (type === 'satelliteSystem/toggleShow') {
const satellite = entity.get(payload)
if (!satellite) return
satellite.show = !satellite.show
}
// 跟踪卫星
if (type === 'satelliteSystem/track') {
const satellite = entity.get(payload)
if (!satellite || !vcViewerInstance) return
vcViewerInstance.selectedEntity = satellite
vcViewerInstance.trackedEntity = satellite
}
})
</script>