Easy one: Changing colors of entities

Hi!

This seems like a very easy question, but I can’t get it figured out.

I create entities from a WFS-response (GeoJson) and store them in the variable “building”. So “building” contains all my entities.

building.push(viewer.entities.add({

id : id,

name : "Building "+ id,

polygon : {

hierarchy : {

positions : Cesium.Cartesian3.fromDegreesArray(coor),

holes : holePositions

},

material : Cesium.Color.RED.withAlpha(0.5),

outline : true,

outlineColor : Cesium.Color.BLACK,

extrudedHeight : height

}

}));

Now, in my application I want the users to have the option to change the colors of the enities (by height for example).

So, I have to loop over the “building” variable, check the height of the entity and change its color according to its height.

What’s the easiest way to do update an entity? Because I cannot seem to access the properties of the entities. I tried doing it with the use of the “building” variable, but updating it, does not change the color of my entities:

building[i]._polygon._material._color._value = newColor;

Wout

Generally, you should never access members directly that starts with ‘_’. Those are private and not meant to be consumed by an application. Instead, use properties.
This code will work

building[i].polygon.material.color = newColor; // newColor must be an instance of Cesium.Color

``

Because those are properties and not members, they have events that notify the scene about that change, rather than updating a private member directly so nothing could observe it