I’d like to see a good, valid explanation of why _children
isn’t exposed. [… ] If the people using Cesium don’t need it, why does Cesium need it? Why is Cesium tracking it?
It is a part of the API that does not offer a user-facing functionality. It is possible to set entity.show = false;
on a parent entity, and that will hide that entity and all the elements that this entity consists of. This parent-child relationship is generated only at construction time (and in fact, only in very few situations). It is not supposed to be modified by clients at runtime.
(The fact that these elements are called “children” may be an important detail here. I think that hardly anyone would ask this to be exposed if it was called _internalSubEntities
…)
Lastly, maybe I’m reading it wrong but your last answer sounds like, “we cant change it because that’s not what the docs currently says it does”.
The documentation is a form of specification here. It defines the API. It is a contract. Changing its current behavior would be a whole different category than the “breaking changes” that are listed in the change log. These usually refer to methods/classes being removed or renamed, usually with reasonable deprecation periods, and clear migration paths.
In response to your questions and theoretical issues, why not […]
Again, I can give justification for what I’d use a children list for. I’m just looking for justification as to why we aren’t allowed to have it. Your reasons listed above don’t make sense to me. They sound like a “what if”, that the developers (the Cesium team) could prevent with a few conditions and changes to the docs.
For the “why not…” part, I could go through that list, and give a variety of answers. These would usually boil down to bugs, inconsistencies, or undesired behavior. There are good reasons to avoid changes that cause unpredictable behavior for clients, or to avoid exposing internal implementation details.
So I’ll try a more goal-oriented approach here. And maybe this should be moved to its own thread, because it starts with a very basic question:
What exactly are you trying to accomplish?
(If the answer was “I want to access the children of an entity”, then you could do this, with entity._children
, with all the theoretical issues that this might entail. So maybe there’s a higher-level answer as well…)
The two main pieces of information right now are
This does seem to be strongly related to CZML and I’ll frankly admit that I’m not really deeply familiar with the details of CZML, and might have to ask about further details, and/or rely on others to chime in. But from what I’ve gathered from that description, it sounds like it should be possible to maintain an EntityCollection
and the entities that it contains, in a way that ensures the desired consistency and offers the desired convenience.
For example: Imagine you had some class, let’s call it EntityManager
, that offered a functionality like this
const entityWithChildren = create();
// Adds the given entity and its children to the collection (viewer)
entityManager.add(entityWithChildren);
const children = entityManager.getChildren(entityWithChildren);
// Remove the entity from the collection (viewer), and from its parent:
entityManager.remove(children[2]);
My gut feeling is that it should be possible to implement something like that with reasonable effort (although that’s only a gut feeling for now)