创建卫星系统轨道视图

master
叶志超 2022-05-27 12:51:56 +08:00
parent e3b9529827
commit 51744eac8f
2 changed files with 47 additions and 38 deletions

View File

@ -5,53 +5,17 @@
</vc-layer-imagery>
<vc-navigation :offset="[10, 40]" :position="'top-left'" :printOpts="false" :locationOpts="false" :otherOpts="false" />
<vc-datasource-czml v-if="czml" :czml="czml" @ready="onDataSourceReady" />
<SatelliteSystemView />
</vc-viewer>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { useStore } from 'vuex'
import entity from '../api/entity'
import earth from '../assets/earth.jpg'
import SatelliteSystemView from './SatelliteSystemView.vue';
//
const store = useStore()
const czml = computed(() => './CZML/' + store.getters["satelliteSystem/name"] + '.czml')
const onDataSourceReady = ({ viewer, cesiumObject }) => {
viewer.flyTo(cesiumObject)
entity.load(cesiumObject.entities.values)
//
viewer.selectedEntity = entity.find('Constellation')
}
// /
let vcViewerInstance: any = null
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
}
})
//
const onViewerReady = ({ viewer }) => {
vcViewerInstance = viewer
viewer.scene.debugShowFramesPerSecond = false
//

View File

@ -0,0 +1,45 @@
<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>