伞形、半圆、棱形、锥形传感器。下面是该示例的核心 script 片段,供参考学习;完整可运行代码请进入在线 Demo 或查看仓库源码。
import * as Cesium from 'cesium'
import { defaultStatic } from '../defaultStaticConf'
import { CustomCesiumPlugin } from '@/utils/cesiumPluginsExtends/singleImport/CustomCesiumPlugin'
export default {
data () {
return {
currPosition: Cesium.Cartesian3.fromDegrees(117.224, 31.819, 128),
roll: 0,
pitch: 40,
heading: 0,
xHalfAngleDef: {
max: 89,
min: 1,
value: 80 //初始值
},
yHalfAngleDef: {
max: 2000000, min: 100000, value: 700000
},
HeadingDef: {
max: 360, min: 0, value: 90 //初始值
},
PitchDef: {
max: 360, min: 0, value: 0 //初始值
},
RollDef: {
max: 360,
min: 0,
value: 0 //初始值
}
}
},
mounted () {
this.initMap()
},
methods: {
initMap () {
const customCesiumPluginObj = new CustomCesiumPlugin({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer',
viewerConfig: {
infoBox: false,
shouldAnimate: true,
},
extraConfig: {},
MapImageryList: [],
defaultStatic
})
this.c_viewer = customCesiumPluginObj.viewer
this.customCesiumPlugin = customCesiumPluginObj.customCesiumPlugin
this.flyToPos()
this.initPhaseControl()
},
flyToPos () {
this.customCesiumPlugin.flyTo({
position: {
x: -1577100.7186109242,
y: 5851821.270502206,
z: 3447255.476239793
},
orientation: {
heading: Cesium.Math.toRadians(78.17580384898336),
pitch: Cesium.Math.toRadians(-29.981992162453782),
roll: Cesium.Math.toRadians(0.005676460617140785)
}
})
},
initPhaseControl () {
const _this = this
this.sensorEntity = this.customCesiumPlugin.createRadarPrimitive(
{
position: _this.currPosition,
heading: _this.heading,
pitch: _this.pitch,
roll: _this.roll
}
)
},
xHalfAngleChange (e) {
this.sensorEntity.angle = e.target.value
},
yHalfAngleChange (e) {
this.sensorEntity.radius = e.target.value
},
HeadingChange (e) {
this.heading = e.target.value
this.sensorEntity._rotation.heading = Cesium.Math.toRadians(
this.heading
)
},
PitchChange (e) {
this.pitch = e.target.value
this.sensorEntity._rotation.pitch = Cesium.Math.toRadians(this.pitch)
},
RollChange (e) {
this.roll = e.target.value
this.sensorEntity._rotation.roll = Cesium.Math.toRadians(this.roll)
}
},
beforeUnmount () {
this.c_viewer = null
this.customCesiumPlugin = null
}
}
安装:npm install cesium_dev_kit cesium