1. A concise explanation of the problem you're experiencing.
Hello, I have a problem. Can anyone help me?
There is a car that runs over time. In the viewer.clock.onTick method, I get the location of the car according to the current time. The location is then set to polyline. The polyline position changed but the effect was not smooth.
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
var radar = viewer.entities.add({
id: "radar",
name: 'radar polyline',
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights(
[0, 0, 0,
0, 0, 1000]
),
width: 3,
material: new Cesium.PolylineOutlineMaterialProperty({
color: Cesium.Color.fromCssColorString('#00FF00'),
outlineWidth: 0,
})
}
});
var oldloclon = 0;
var oldloclat = 0;
viewer.clock.onTick.addEventListener(function (clock) {
var loc = position.getValue(clock.currentTime);
var loc1 = Cesium.Cartographic.fromCartesian(loc);
var loclon = Cesium.Math.toDegrees(loc1.longitude).toFixed(5);
var loclat = Cesium.Math.toDegrees(loc1.latitude).toFixed(5);
if (oldloclon != loclon || oldloclat != loclat) {
//console.log(loclon + "**********" + loclat);
//var et = viewer.entities.getById("radar");
//if (et != null) {
// viewer.entities.remove(et);
//}
radar.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
[loclon, loclat, 0,
loclon, loclat, 1000]
);
oldloclon = loclon;
oldloclat = loclat;
}
});
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I want to use polyline to represent a bunch of lasers from the car, and the laser follows the car.
4. The Cesium version you're using, your operating system and browser.
cesium-1.38,Chrome