Modifying entity properties after their creation


I'm currently using Cesium to visualize some paths given some corresponding latitude/longitude/altitude points. I am using polylineVolumes ( primitive: polylineVolumeGraphics ) to show the inaccuracy of the lat/long/alt points (e.g., 5-meter error).

Everything is going great so far. However, I've been trying to add some on-screen buttons to control the polylineVolumes' visibility, color, fill, etc. I managed to control their visibility via:

toggleVisibility : function( bool ) {
    this.tubes[i].show = bool;

However, I can't seem to be able to change the polylineVolumes' colors (material or outlineColor) doing the same thing:

    this.tubes[i].material = Cesium.Color.RED;
    // or
    this.tubes[i].outlineColor = Cesium.Color.RED;

I've been going through Cesium.js and trying to understand how properties are being set and updated on entities, but I've been having a hard time grasping everything.

My question is: Is it possible to change the polylineVolumes' colors (material and outlineColor) after they have been created, and if so, what is the recommended way?

A more generalized question would be: What is the intended way to modify entities' properties after they have been created?

I tried searching for these questions before posting, but what I found either didn't help or wasn't asked already. Sorry if I missed something.



It looks like your code is correct. Here’s a quick example I threw together to show how to change the polyline volume color, so you can compare code and see if you’re doing something different:

The great thing about the Entity API is it’s easy to change the property value on the fly. However, we are aware of a few bugs. It’s possible you’re running into this:



Hello, when you say its easy to update entity properties on the fly. Do you mean its okay to manually take an entity and just add a property via the normal js way of updating a property or do I need to create propertyBags and use that as a way of managing extra properties being added to the entity?

If you’re changing a property that already exists (like position, orientation etc) then you’ll need to use a CallbackProperty to mark the entity as dynamic, see these code examples:

If you’re just creating your own properties on the fly, because everything in JavaScript is an object, then it isn’t something that CesiumJS would be aware of/needs to interact with, so it should be all good.

Feel free to create a new thread for your question/issue.