Changing color on large number of lines

Hi

I've loaded a geojson file consisting of a polyline with roughly 1200 segments, where each segment has a few different properties, as a corridor. So far everything works as expected. However I now want to update the colors of each segment based its properties. I've come up with the following code which does what I want (ds is my geojson datasource and color_map is a function that maps a property value to a color):

let entities = ds.entities.values
for (let entity of entities) {
  p = entity.properties[property].getValue()
  c = color_map(p)
  entity.corridor.material = new Cesium.ColorMaterialProperty(new Cesium.Color(c[0]/255,c[1]/255,c[2]/255,1))
}

However it is extremely slow. It takes 7-10 seconds (chrome on windows 7) between triggering the function and the colors being updated. Why is this code so extremely slow and is there a better way to achieve this?

Thanks

Dag

Hey Dag,

I think entities by default assume their properties are static to speed up performance. If you know some properties will be dynamic you can use a Callback Property (https://cesiumjs.org/Cesium/Build/Documentation/CallbackProperty.html). There are some examples of using it on Sandcastle, here’s a good one:

Let me know if that fixes it!