# Strange behavior on Color CallbackProperty

**URL:** <https://community.cesium.com/t/strange-behavior-on-color-callbackproperty/6567>\
**Category:** CesiumJS\
**Created:** [February 13, 2018, 7:37pm UTC](https://community.cesium.com/t/strange-behavior-on-color-callbackproperty/6567 "2018-02-13T19:37:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Ten\_Eyck](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ten_eyck/32/27541_2.png) [@Kevin\_Ten\_Eyck](https://community.cesium.com/u/Kevin_Ten_Eyck)\
**Post date:** [February 13, 2018, 7:37pm UTC](https://community.cesium.com/t/strange-behavior-on-color-callbackproperty/6567/1 "2018-02-13T19:37:59Z")

</div>

**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.

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Hello%20World.html&label=Showcases&gist=597f70cabafafd4133a447a32ad16131)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

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

1.42

Windows 10

Chrome 63

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [February 19, 2018, 5:26pm UTC](https://community.cesium.com/t/strange-behavior-on-color-callbackproperty/6567/2 "2018-02-19T17:26:49Z")

</div>

Hi Kevin,

From the example you provided, I don’t see a need to use a callback function as [**ColorMaterialProperty**](https://cesiumjs.org/Cesium/Build/Documentation/ColorMaterialProperty.html?classFilter=colorMa) 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](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Callback%20Property.html&label=Showcases), 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
