How get the Entity reference from a called CallBackProperty Callback function

Good time of a day, dear Cesium community.

I like the flexibility that Cesium gives with several layers of APIs, and find Entity API very powerful and convenient.
CallbackProperty for instance gives an easy way for building dynamic visualizations.
The only thing I haven’t find in API reference and in code samples is
how get the Entity reference from a called CallBackProperty Callback function.

Imagine that we have many models and wish for each to show a dynamic Label or Billboard with
a current information about speed and position.
I can do that with CallBackProperty but as for now I create a different Callback function for each Entity.

I checked the context of the call, but it gives just CallBackProperty itself and no reference to which Entity it belongs.

I’d appreciate any advise.

Vladimir

Hello Vladimir,

Thanks! I’m glad you’re having a good experience with Cesium thus far.

I don’t believe there is any way to access the Entity from the callback function at this time. That’s a really good idea though! I’ve written up a GitHub issue here: https://github.com/AnalyticalGraphicsInc/cesium/issues/3726

Thanks,

Hannah

Thank you, Hannah, for the quick response and creation GitHub request.
I think the easy way to implement this would be just to add the third variable to the call of a callback

Honestly, I’m not sure if there is an easy way to implement this. You will have to make changes in Property and in the Visualizer for each type of primitive. For example
Change these three functions to take an entity: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/DataSources/Property.js#L117-L140

Then, using Billboard as an example, pass in the Entity every time you call the Property functions from BillboardVisualizer.update: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/DataSources/BillboardVisualizer.js#L109

Finally, you’ll have to change CallbackProperty.getValue to take an entity: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/DataSources/CallbackProperty.js#L65

I think that’s everything. I’m not sure if that’s the best way to implement it, but that’s probably where I would start. The Entity API implementation is very complicated, so I’m not 100% sure. Someone else might have a different suggestion.

Best,

Hannah