Numa Posted April 6, 2016 Share Posted April 6, 2016 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 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 6, 2016 Share Posted April 6, 2016 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!!! Quote Link to comment Share on other sites More sharing options...
adam Posted April 6, 2016 Share Posted April 6, 2016 14 hours ago, Numa said: is there a mesh.children[] mesh.getChildMeshes() http://www.babylonjs-playground.com/#25WR97#4 you don't need to update it though Wingnut 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 6, 2016 Share Posted April 6, 2016 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 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 6, 2016 Share Posted April 6, 2016 mesh.getChildMeshes() cool! I should read the BJS docs someday, huh? Thx guys (and hi). Sorry for the mis-answer, Numsy. Thx for the pg, jk! Quote Link to comment Share on other sites More sharing options...
Numa Posted April 6, 2016 Author Share Posted April 6, 2016 Awesome thanks everyone! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 10, 2016 Share Posted April 10, 2016 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.) 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. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.