1. A concise explanation of the problem you're experiencing.
Polyline entities flash for a moment when adding new entities even though their availability should prevent them from showing.
The sandcastle code below will demonstrate the issue clearly. Let it run for 20-30 seconds and you'll notice the flashing. Am I doing something wrong? Should I use primitives instead?
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
var viewer = new Cesium.Viewer('cesiumContainer', {
shouldAnimate : true
});
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(5,5,4000000),
orientation: {
heading: 0,
pitch: Cesium.Math.toRadians(-90),
roll: 0
}
});
var startDate = Cesium.JulianDate.fromIso8601('2018-09-16T00:00:00.000Z');
var endDate = Cesium.JulianDate.fromIso8601('2018-09-16T00:05:00.000Z');
viewer.clock.currentTime = startDate;
viewer.clock.startTime = startDate;
viewer.clock.endTime = endDate;
viewer.clock.clockRange = Cesium.ClockRange.CLAMPED;
var pos1 = Cesium.Cartesian3.fromDegrees(0,0,800000);
var pos2 = Cesium.Cartesian3.fromDegrees(10, 10, 0);
var positions = new Cesium.SampledPositionProperty();
positions.setInterpolationOptions({
interpolationDegrees: 5,
interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
});
positions.addSample(startDate, pos1);
positions.addSample(endDate, pos2);
var ufo = new Cesium.Entity({
id: 'UFO',
position: positions,
path: {
show: true,
leadTime: 300,
trailTime: 300,
resolution: 1
},
point: {
color: Cesium.Color.YELLOW,
pixelSize: 9
},
label: {
text: 'UFO',
pixelOffset: Cesium.Cartesian2.fromArray([-35, -15])
}
});
var radar = new Cesium.Entity({
id: 'Radar',
position: new Cesium.Cartesian3.fromDegrees(10,0,0),
point: {
color: Cesium.Color.WHITE,
pixelSize: 15
},
label: {
text: 'Radar',
pixelOffset: Cesium.Cartesian2.fromArray([45,20])
}
});
viewer.entities.add(ufo);
viewer.entities.add(radar);
var RAY_COLOR = new Cesium.Color(0.0, 1.0, 0.0, 0.8);
function radarPing() {
var s = Cesium.JulianDate.clone(viewer.clock.currentTime);
var e = Cesium.JulianDate.clone(s);
Cesium.JulianDate.addSeconds(e, 10, e);
var availability = Cesium.TimeIntervalCollection.fromJulianDateArray({
julianDates: [s, e]
});
var radarPos = radar.position.getValue(s);
var curUfoPos = ufo.position.getValue(s);
var ray = new Cesium.Entity({
availability: availability,
polyline: new Cesium.PolylineGraphics({
positions: [radarPos, curUfoPos],
followSurface: false,
width: 1.0,
material: RAY_COLOR
})
});
viewer.entities.add(ray);
}
var timer = setInterval(radarPing, 1000);
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I'm receiving real-time data via Server-Sent Events and I want to add polylines representing that data. I also want the data to disappear after some time but retain the ability to use the playback controls to go back in time.
I'm open to suggestions if there is a better way to do this.
4. The Cesium version you're using, your operating system and browser.
v1.49, Windows 10, Firefox and Chrome