I am trying to add a polyline to viewer every minute. The polylines are constant. Once added they will not change. The number will increase over time. Example: If you added a polyline every minute for an hour, you would have 60 polylines at the end. I want to animate this, so if you scrolled the timeline from start to end, you would see the lines being added.
Previously I have animated moving entities. But the lines are moving, I just want to animate them being added to viewer over time. Not sure how to do this. This is what I have tried.
viewer.clock.startTime = modelStart.clone();
viewer.clock.stopTime = modelStop.clone();
viewer.clock.currentTime = modelStart.clone();
viewer.clock.multiplier = 1;
viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
viewer.clock.shouldAnimate = true;
viewer.timeline.zoomTo(modelStart, modelStop);
const avail = new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start: modelStart,
stop: modelStop,
})]);
...
In loop for each new time with new linePosition
...
const positionWithTime = new Cesium.SampledPositionProperty();
const linePosition = Cesium.Cartesian3.fromDegreesArrayHeights([
lon1, lat1, alt1, lon2, lat2, alt2
]);
newTime = Cesium.JulianDate.fromDate(time);
positionWithTime.addSample(newTime, linePosition);
viewer.clock.currentTime = newTime;
// This draws lines without timeline
/*
viewer.entities.add({
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights([
lon1, lat1, alt1, lon2, lat2, alt2
]),
material: Cesium.Color.RED,
}
});
*/
// Trying to draw a new line that will be added over time
// I tried this but no lines show up
viewer.entities.add({
availability: avail,
polyline: {
positions: positionWithTime,
material: Cesium.Color.RED,
}
});
// I also tried a callback, lines show up but not associated with time
viewer.entities.add({
availability: avail,
polyline: {
positions: new Cesium.CallbackProperty((time) => {
const linePosition = Cesium.Cartesian3.fromDegreesArrayHeights([
lon1, lat1, alt1, lon2, lat2, alt2
]);
return linePosition;
}, false),
material: Cesium.Color.RED,
}
});
end of loop
Any hints or suggestions?
Thanks in advance