I have entities which are logically grouped by parent-child relationship. I would like to be able to
toggle visibility of such a group by their parent. What is the best way to achieve this in terms of performance and
without abusing the api?
I’m trying to achieve the same as ‘imageryLayers’ works, but for entities. Currently, only visibility is what I’m trying to implement.
In the future, I’d like to set ‘global effects’ per such ‘entity layer’ such as global tint (implemented with ambient lightning maybe?)
or translucency for all entities in a ‘layer’.
Reading and digging through the forum and api led me to use CustomDataSource as the way to implement it.
So far this is what I’ve done :
-
Created a CustomDataSource for each parent, and filled it’s entities’ with my data
-
Added and removed that CustomDataSource from the viewer to toggle it’s entities visibility.
After playing with the visibility twice or more, the ‘_visualizers.length’ in the DataSourceDisplay becomes undefined, throwing an exception.
I guess they are destroyed and not recycled after the data source is removed. Maybe I just need to keep the EntityCollection and create a new
data source each time?
If my solution of using CustomDataSource is the right way, then implementing global effects would
require writing some visualizers and shaders to take the effect parameters into account? Or there’s a better way?
Thanks!