59 lines
2.1 KiB
JavaScript
59 lines
2.1 KiB
JavaScript
|
|
const img4_0 = require('../../../assets/map/gangkou_index/point/ico21.png')
|
|
const img4_0_1 = require('../../../assets/map/gangkou_index/point/icon27.png')
|
|
const img4_0_2 = require('../../../assets/map/gangkou_index/point/icon28.png')
|
|
const img4_0_3 = require('../../../assets/map/gangkou_index/point/icon29.png')
|
|
const Cesium = window.Cesium
|
|
const imgMap = {
|
|
img4_0, img4_0_1, img4_0_2, img4_0_3
|
|
}
|
|
export { imgMap }
|
|
export default class DragEntity {
|
|
constructor(val) {
|
|
this.viewer = val.viewer
|
|
}
|
|
addEntity(point) {
|
|
point.property = new Cesium.SampledPositionProperty()
|
|
const start = Cesium.JulianDate.now()
|
|
const position = Cesium.Cartesian3.fromDegrees(point.x, point.y, 0)
|
|
point.property.addSample(start, position)
|
|
point.lastTime = start
|
|
const entityOption = {
|
|
id: point.id,
|
|
name: point.name,
|
|
position: point.property,
|
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
billboard: {
|
|
image: imgMap[point.icon_type],
|
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
},
|
|
orientation: new Cesium.VelocityOrientationProperty(point.property),
|
|
|
|
monitoItems: {
|
|
data: point
|
|
}
|
|
}
|
|
|
|
this.viewer.entities.add(entityOption)
|
|
this.viewer.clock.startTime = start.clone()
|
|
this.viewer.clock.currentTime = start.clone()
|
|
this.viewer.clock.clockRange = Cesium.ClockRange.CLAMPED
|
|
this.viewer.clock.shouldAnimate = false
|
|
}
|
|
|
|
getPosition(point) {
|
|
if (this.viewer.clock.shouldAnimate === false) {
|
|
this.viewer.clock.shouldAnimate = true
|
|
}
|
|
const position = Cesium.Cartesian3.fromDegrees(point.x, point.y, 0)
|
|
const entity = this.viewer.entities.getById(point.id)
|
|
entity.billboard.image = imgMap[point.icon_type]
|
|
const nextTime = Cesium.JulianDate.addSeconds(point.lastTime, 10, new Cesium.JulianDate())
|
|
point.property.addSample(nextTime, position)
|
|
point.lastTime = nextTime
|
|
}
|
|
}
|