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

832 views
Skip to first unread message

hunt...@gmail.com

unread,
Feb 25, 2019, 10:53:02 PM2/25/19
to cesium-dev
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.

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html#c=nVVRb9owEP4rES8EKTMOBJJs0K1QpE7rNKl020PTBzc5gjXHRrZDR6f+99lJaIH2AWqefLnvvu8uuY854VlKlGaASJbdCMHuifwOvHRv/yXcMUfDX+18dNrXkLW9OiS4AgapDS9KnmoquNtxmnx7FOipYEIajNv5VMefEv7kHdScsBJOLmpBe1Xv7CXh84NW8pzBpNTa1GnPS7UCnjnlKiMa1Oe25ywIU+C9cKVLSP9A9kxJF9vQeDzWsoTOjpY1hQeQCLimmoJCqq4/W5uIehZnT2r6EkYSE7mbtBodlOcOVLlJ67kTB4yg3Yb3odegyuIt4Ft6pE2GAzl2VvWo7G9NZANzxg6HB2cKipYF+lXF3HZaXaeCa0I5yPYWaXEPG1FJGb8iNpN3qxZWgm1ywc3bbDpaUpBEpsuNCTVUUyLNy6CE99FCiuICcgmgzqUkG/f2pbm3zwcfxwhHOAp6XjBAGPdw2PeOQA1Q7A/88DRQgPAgCqLICwIUx8NBPDwW1ce+7wV9yxVH8Wko36D6MR4e11bYi+JB4AXYKDRTOYorNMOIw/6JXGbwQRhHJ1H5vgXhYf+9qJ4RiEN8IipAQTjsRcMjUYOeneD2y7jrNLAl0HxprQk3gcLYiKSE7XzM1pvQ78uvN7Oto5WamdUxKdY+9oNV9iF4cnU+/WbTdje12bBHIYob4TabVz/cete+39b71iSiZg/RVjBKK+bxPvP17MJUfKoZX5WtHfc9dSdXP2cvhVtea6T0hsFZPYsvtFgJqZ1SMhehroZixaw9d+9L47sapUrZRkfdLWiU0bVDs3HSOnCnpOWkjChlnixKxub0EZLW2ahr8vdgTBBrvj/WIBnZ2JSlf3ZVBxFCo665vkbp+m9xp+J/


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


Thanks!
-Tim

Omar Shehata

unread,
Feb 26, 2019, 9:20:16 PM2/26/19
to cesium-dev
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):

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Primitive.js#L291

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:

Tim Hunter

unread,
Feb 27, 2019, 3:34:35 AM2/27/19
to cesiu...@googlegroups.com
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.

-Tim
 


--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/5N1P_qPmbPo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages