Changing material property of a polygon entity goes transparent for a few frames

Hi all! Cesium beginner here hoping you can help me...

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

I want to change the color of a polygon entity. When I do this there is a flash where the object turns transparent or invisible, and you see the underlying globe imagery. I would like the color to change cleanly without the visual disruption.

From what I've read in this group Cesium may not be optimized for changing properties like this after an entity has already been created, and the preferred approach is to use callback properties (which does indeed work much better with my example scene). However, I'm concerned having callbacks on many entities will slow things down, and I would prefer to explicitly change entities directly.

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

Toggle between red and blue in the drop down. On my system I see a few frames where the object turns transparent before it changes color.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I want to be able to cleanly change the color of 1 or many polygons at any time.

4. The Cesium version you're using, your operating system and browser.

Latest 1.54, Chrome and Firefox Windows 10. Tried both nvidia and intel gfx modes on my Dell XPS 9560 15".


This is something that has bothered me in the past as well. This is a “feature not a bug”. Entities in Cesium are created asynchronously, and when certain properties change, the underlying primitives are recreated, so there might be a few frames where nothing renders. This is usually nice because then the application/browser does not freeze when a lot of geometry/materials are being updated, but in cases like this it would be nice to synchronously create the underlying primitives.

When using the lower level primitive API, you can choose whether it should be sync/async. This is not exposed in the Entity API. If you’re interested in making this change to expose an asynchronous flag in the Entity API I think a contribution would be very welcome! I’d be happy to help out.

If you have a local build of CesiumJS set up, you can see how this would change your demo by hardcoding asynchronous = false in this line so it affects all entities (as long as they’re not draped over the globe/terrain, those use GroundPrimitive.js):

Although even after setting this, there seems to be 2 frames where the entity disappears, where it’s state is set to “READY” before being “COMPLETE”. There might be something else required to tweak. This is where this sync/async load happens:

The way Entities and Primitives relate is that when you create an entity, there will typically be a XVisualizer.js class responsible for creating the underlying primitives. So for example, when creating models, the ModelVisualizer is responsible for updating it:

For most geometries, there’s a GeometryVisualizer:

But the actual creation of the primitive would be in one of these batches, here:

Thanks Omar, this is good information and helps me understand a little better.

I’m familiarizing myself with the framework at the moment. I’d like to try digging into the code a bit so thank you for the pointers.


Hi, Tim

Have you advanced in this topic?