Modifying entity properties after their creation

1,253 views
Skip to first unread message

thomas.wa...@gmail.com

unread,
Jun 6, 2016, 9:26:13 AM6/6/16
to cesium-dev
Hello,

I'm currently using Cesium to visualize some paths given some corresponding latitude/longitude/altitude points. I am using polylineVolumes ( primitive: polylineVolumeGraphics http://cesiumjs.org/Cesium/Build/Documentation/PolylineVolumeGraphics.html ) 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.

Thanks!

Hannah Pinkos

unread,
Jun 6, 2016, 11:26:33 AM6/6/16
to cesium-dev, thomas.wa...@gmail.com
Hello,

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: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Hello%20World.html&label=Showcases&gist=30ff0e6ac0a6749ed9174bcf947ad9c5

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: https://github.com/AnalyticalGraphicsInc/cesium/issues/3807

Best,

Hannah

xtho...@gmail.com

unread,
Aug 1, 2019, 12:01:00 PM8/1/19
to cesium-dev
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?

Omar Shehata

unread,
Aug 13, 2019, 6:11:59 PM8/13/19
to cesium-dev
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.
Reply all
Reply to author
Forward
0 new messages