getPoints() {
let data = [];
data[0] = [
{ longitude: 116.405419, dimension: 39.918034, height: 0, time: 0 },
{ longitude: 116.2821, dimension: 39.918145, height: 0, time: 40 },
{
longitude: 115.497402,
dimension: 39.344641,
height: 70000,
time: 100,
},
{
longitude: 107.942392,
dimension: 29.559967,
height: 70000,
time: 280,
},
{
longitude: 106.549265,
dimension: 29.559967,
height: 70000,
time: 360,
},
];
data[1] = [
{ longitude: 116.405419, dimension: 39.918034, height: 0, time: 0 },
{ longitude: 117.034586, dimension: 39.881202, height: 0, time: 40 },
{
longitude: 116.340088,
dimension: 38.842224,
height: 70000,
time: 100,
},
{
longitude: 113.489176,
dimension: 23.464017,
height: 70000,
time: 280,
},
{ longitude: 113.262084, dimension: 23.13901, height: 0, time: 360 },
{ longitude: 110.262084, dimension: 23.13700, height: 0, time: 500 },
];
// 起始时间
let start = Cesium.JulianDate.fromDate(new Date());
start = Cesium.JulianDate.addHours(start, 8, new Cesium.JulianDate());
// 结束时间
let stop1 = Cesium.JulianDate.addSeconds(
start,
360,
new Cesium.JulianDate()
);
let stop2 = Cesium.JulianDate.addSeconds(
start,
500,
new Cesium.JulianDate()
);
move(start, stop1, data[0]);
move(start, stop2, data[1]);
function move(start, stop, data) {
viewer.clock.startTime = start.clone();
viewer.clock.currentTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.multiplier = 20;
viewer.timeline.zoomTo(start, stop);
viewer.clock.clockRange = 1;
let property = computeFlight(data);
// // 添加模型
viewer.entities.add({
availability: new Cesium.TimeIntervalCollection([
new Cesium.TimeInterval({
start: start,
stop: stop,
}),
]),
position: property,
orientation: new Cesium.VelocityOrientationProperty(property),
// 模型数据
billboard: {
image: require("../assets/image/mainSizer/standard.png"),
width: 63,
height: 63,
},
});
}
/**
* 计算飞行
* @param source 数据坐标
* @returns {SampledPositionProperty|*}
*/
function computeFlight(source) {
// 取样位置 相当于一个集合
let property = new Cesium.SampledPositionProperty();
for (let i = 0; i < source.length; i++) {
let time = Cesium.JulianDate.addSeconds(
start,
source[i].time,
new Cesium.JulianDate()
);
let position = Cesium.Cartesian3.fromDegrees(
source[i].longitude,
source[i].dimension,
source[i].height
);
// 添加位置,和时间对应
property.addSample(time, position);
}
return property;
}
},
以上是demo,场景是两个或多个模型同时出发,给不同的停止时间,先停下来的会消失,最后一个停下的就在原地。
怎么解决消失的问题,或者我想在运动结束时重新添加模型,怎样监听运动结束。