Jump to content

Parenting - inner workings


Numa
 Share

Recommended Posts

Hi there! I have a few questions on how Babylon handles parenting:

1. A is B's parent. What happens to A and B if I go: A.parent = B; ?

2. A is B's parent. B is C's parent. What happens if I go: A.parent = C; ? Infinite hierarchy?

3.A is B's parent. C is D's parent. How would I swap parent? What happens if I go:
B.parent = C; // B now has 2 parent, A and C ? Did A get disconnected? Did D lose his parent? Do all of this happen at the end of the frame or in real time?
D.parent = A; // What happens there?

4. is there a mesh.children[] or something similar I need to update when assigning new parents?

 

Thanks :)

 

Link to comment
Share on other sites

Darn, @Numa ... what great questions.  Phew!   #4 - no, but you can maintain your own children[] array and refresh it anytime by iterating thru scene.meshes array.  Same with scene.lights and scene.cameras.  Things parented to lights and cameras... have fewer inherited traits, I think.

Questions #1, #2, #3 - :) - those are BEGGING for The .Parent-Testing Playground  (fanfare and applause).

Yep, I'm thinkin' 5 test-parents.  One parent-mesh is varying .position slightly, another is varying rotation, a third is varying scaling, #4 is a rotating-positioning camera, and #5 is a rotating-positioning light. 

That's our team of test parents.  All simple animated.  Then, we'll feed Numa's questions #1-3 into that new testing playground...  and see what blows up!  YEAH!  The exploration is the fun part!  Grab the dynamite and fire extinguisher, and let's go!  :)  Those are good questions... I want to see the answers, too!  Let's go torturing!  Maybe write a doc about parenting!  PARTY!!!

Link to comment
Share on other sites

Greeting Wingnut and Numa

#4 You are able to get information on the children of a mesh using mesh.getChildren() but this is updated by BJS and meshes should not be added or deleted directly. This adaptation of the basic scene will show the results for getChildren() for the mesh box.

#1 gives a too much recursion error http://www.babylonjs-playground.com/#EJ5ZM#1

#2 gives a too much recursion error http://www.babylonjs-playground.com/#EJ5ZM#2

#3 parents swap http://www.babylonjs-playground.com/#EJ5ZM#3  try commenting and un-commenting lines 38 and 39

Link to comment
Share on other sites

SO... then... who is going to write our "All About Parenting" doc?  John?  Numa?  Adam?  Everyone? 

It needs to cover lights and cameras, too.  (parenting-from)

And perhaps it could remind the youngsters that a mesh... is not a child of abstractMesh, and abstractMesh is not a child of node, etc.  Possibly, remind us that subMesh are not children of mesh, and clones and instances are not children of their clone-template.  :) 

(I hope I'm correct with all that.)  :o 

JohnK has done BJS tutorials before, so he's got the goods.  Now that we have that "little eyeball" feature for viewing playgrounds embeded in doc files, we could really "use" playgrounds to help do the teaching.  Click the eyeball, and you get much more than a demo playground.  You get a fantastic presentation... completely done with a playground scene.  It's a 23 minute live-seeming presentation, with in-playground table of contents/menu, with click to continue buttons, sequential lessons, the whole she-bang.  Powerpoint meets BJS.  :)

Or, not.  But really, though, a decent tutorial about parenting.... would be quite handy.  kbye.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...