1. A concise explanation of the problem you’re experiencing.
I’m drawing some routes on the map as polylines.
I’d like my routes to change their width on the basis of camera height (the farther the camera, the thinner the polyline).
When the width of my routes is updated them “flash”, just like them was destroyed and created from scratch
(I’ve experienced the same problem also changing the polyline material)
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
Track = viewer.entities.add({
polyline: {
positions: this.cartesianPositions,
clampToGround: false,
width: 6,
show: main.isTrackVisible,
material: this.defaultMaterial,
}
});
viewer.camera.changed.addEventListener(() => {
let maxWidth = 6;
let minWidth = 3.5;
let minHeight = 1;
let maxHeight = 6;
let clampedHeight = Math.clamp(height, minHeight, maxHeight);
let widthMult = 1 - Math.inverseLerp(minHeight, maxHeight, clampedHeight);
let width = minWidth + ((maxWidth - minWidth) * widthMult);
Track.polyline.width = width;
});
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I’d like my routes to change their width, and material, on the basis of camera height
4. The Cesium version you’re using, your operating system and browser.
1.66