Polylines "flash" when some parameter is changed

32 views
Skip to first unread message

daniel...@gmail.com

unread,
Feb 23, 2020, 2:54:38 PM2/23/20
to cesium-dev
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


Omar Shehata

unread,
Feb 26, 2020, 10:13:18 AM2/26/20
to cesium-dev
Entities will "flash" like this because they are created asynchronously. If you know your entity is going to change a lot, consider using a CallbackProperty.

Here's a thread with more detail on this issue: https://groups.google.com/d/msg/cesium-dev/5N1P_qPmbPo/rbnHNKFoAQAJ

daniel...@gmail.com

unread,
Feb 27, 2020, 9:24:30 AM2/27/20
to cesium-dev
Many thanks!
Reply all
Reply to author
Forward
0 new messages