Bypass the Cesium.Color class, possible?

Hi everyone,
maybe a silly and newby question, is there a way to provide a raw information to construct a material of a boxgraphics? Something like this:
Instead of

  • material = Cesium.Color.fromCssColorString(‘rgba(42,254,228,1.0)’)

Willing to do this instead

  • material = {{“red”: 0.164705882352941, “green”: 0.164705882352941, “blue”: 0.164705882352941, “alpha”: 0.5}}

this is mostly to improve performances as the thousands entities in my app are slowing down a lot my application.
many thanks!

When you do:

boxGraphics.material = Cesium.Color.fromCssColorString(‘rgba(42,254,228,1.0)’);

It’s actually creating an instance of ColorMaterialProperty under the hood (that’s what boxGraphics.material actually is for static colors. So assigning a bare object like that won’t actually work.

However, I’m surprised this is the bottleneck for your app. Can you tell me a little bit more about your use case? Are you changing these colors dynamically? Or is it “load and done”? Do any of the objects share the same color?

Thanks,

Matt

Hi Matt,
thank you for your prompt response. Yes, I am also changing dynamically the colour of thousands of entities visible on the screen and I was exploring where I can reduce computational workload.

A similar approach I adopted was for the position of entities, with the instance of the entity as follows:
position={{ “x”: data.ecef[0], “y”: data.ecef[1], “z”: data.ecef[2] }}

where I skip the Cartesian3 calculation as I provide the ‘ecef’ data already formatted from within a database.

@Federico_Marcantogni This is actually the incorrect approach in both cases. Entity has time dynamic support built into it, this includes real time use cases (in case your app is ingesting live data). You will get much better performance using the time dynamic support.

For position, usually it’s the SampledPositionProperty that you want to use. Here is an example: Cesium Sandcastle

There is a similar SampledProperty class you can use for colors. (and there are a bunch of XXXProperty classes in the reference doc that you can browse to see what fits for you.

If your data is totally dynamic and you need to compute it on the fly, a CallbackProperty is what you want, see this Sandcastle as an example: Cesium Sandcastle

The property system is explained in more detail in Creating Entities – Cesium tutorial; (though the time dynamic nature is only touched on briefly).

Hope that helps.

1 Like