Strange behavior on Color CallbackProperty

1. A concise explanation of the problem you’re experiencing.

I’m using the CallbackProperty for a polyline material color and that is working as I would expect. After a user performs an action in my application I want to change the polyline material to a constant color so that the material is no longer evaluating every frame and this new color lives outside of the callback. After I set the new material it doesn’t change the color, but if I set the material a second time; it works fine. Am I using the callback property incorrectly or is Cesium ignoring my first attempt to change the value of the material for some reason?

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

Here is a simplified version that shows the problem.

3. The Cesium version you’re using, your operating system and browser.

1.42

Windows 10

Chrome 63

Hi Kevin,

From the example you provided, I don’t see a need to use a callback function as ColorMaterialProperty already signals to the entity that the value has changed. I modified your example to use the following code, and it works as expected:

// Add a polyline to the scene. Positions are dynamic.

var isConstant = false;

var redLine = viewer.entities.add({

polyline : {

// This callback updates positions each frame.

positions : Cesium.Cartesian3.fromDegreesArray([-110, 40, -120, 40]),

width : 10,

material : new Cesium.ColorMaterialProperty(Cesium.Color.GREEN)

}

});

setTimeout(function () {

console.log(‘1 sec’);

redLine.polyline.material.color = Cesium.Color.RED;

}, 1000);

setTimeout(function () {

console.log(‘2 sec’);

redLine.polyline.material.color = Cesium.Color.BLUE;

}, 2000);

``

However to clarify on how you use the callback function, you would do something like the original example, where the callabckProperty is provided as the property, and the function you pass as a parameter returns the modified valued.

Thanks, hope that clears things up,

Gabby