Child/Parent relationship

Started by nathan, April 11, 2013, 12:40:47 AM

Previous topic - Next topic

nathan

Why is there no method like
Object3D[] getChildren()
but there is
Object3D[] getParents()

I have a group of objects (From another example, it is a car and its 4 wheels).  I want them all to move together, so I add them as children to another object, which is a collision mesh.  And, now I would like to pass the reference to the outer object around, and change all the children simultaneously.  For instance, I want to change visibility, or remove them from the world.

All I can think of doing is extend the Object3D class, override the addChild() function to also add the child to a list.  Then add a getChildren() function that just returns that list as an array and use this in my own functions. 

I just don't understand why there is no getChildren() function?

EgonOlsen

Because there's no cyclic reference. A child knows its parent(s). A parent has no idea about its child(s). If you need that, you can extend Object3D and add it yourself.

nathan