简略回答一下哈
1、借助绘图控件完成鼠标绘制路线,推荐类似这种CesiumDrawHelper
2、获得点的集合后,
// 设置起始时间
const start = Cesium.JulianDate.fromDate(new Date(2022, 4, 26, 16))
const stop = Cesium.JulianDate.addSeconds(start, flyPath.length, new Cesium.JulianDate())
// 计算飞行的path
function computeFlightPath() {
const property = new Cesium.SampledPositionProperty()
for (let i = 0; i < flyPath.length; i++) {
const time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate())
const position = Cesium.Cartesian3.fromDegrees(
flyPath[i][0],
flyPath[i][1],
flyPath[i][2]
)
property.addSample(time, position)
}
return property
}
// 之后增加飞机模型
const airPlaneEntity = viewer.entities.add({
id: id,
availability: new Cesium.TimeIntervalCollection([
new Cesium.TimeInterval({
start: start,
stop: stop
})
]),
position: position,
orientation: new Cesium.VelocityOrientationProperty(position),
model: {
uri: uri,
minimumPixelSize: 64,
maximumScale: 10
}
})
以上为部分精简代码,可以参考完成。