Jump to content

Possible to createInstance of group with children?


Recommended Posts


Is it possible to create a group that contains a few meshes and then create instances of that group which includes the child meshes? How might one go about doing so? Thus far my attempts to create an instance of the group on creates the transform node but no children.



Screen Shot 2018-02-12 at 10.09.20 PM.png

Link to comment
Share on other sites

Hiya JPS, sorry for the slow replies.


I built a little groupInstance() function (lines 41-58).  Works ok, it seems.  Called from lines 61 and 64.

It does it's best to build low-budget instances of groups.  Look it over... holler if you have comments or questions.

PS: I'm far from a pro coder, so, be patient and stay tuned.  Others may have better ideas... soon.  :)

Link to comment
Share on other sites

My pleasure.  :) We should probably have a built-into-BJS function that does this FOR US, eh? 

Whenever the framework needs to create MANY mesh with one command, the naming of those mesh is a little difficult.  And without naming the generated mesh, scene.getMeshByName() doesn't do so well at FINDING the generated mesh. 

Most BJS functions that generate mesh... "impose" a name onto the generated mesh.  I guess that works, as long as users know the naming-format of the imposed name.

I dunno if these are the real reasons why a groupInstance() function isn't yet core-installed... but maybe.  *shrug*  Thoughts? 

Perhaps not used often enough to warrant core-ifying such a thing.

Link to comment
Share on other sites

Your solution is awesome @Wingnut.  Interestingly, while investing your solution I discovered I was able to get the children pulled into the created instance. I think I may have had a bug in my code wherein I was only looking at the object in memory...not in the scene. When I've got some time tonight I'll whip up a playground to illustrate. 

Link to comment
Share on other sites

*nod*.  If you use parent.clone(), the children get installed.  (note: there is a doNotCloneChildren flag... available in the clone() parameters)

If you use parent.createInstance(), the children are left behind.

Soooo... my "clone the parent" method can be extremely streamlined...


No func needed. 

Thanks for teaching me stuff, Jps!  :)  I should read the BabylonJS docs someday, perhaps.  heh.

Sorry if I sent you on a "wild goose chase" (mis-direction).

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.

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.


  • Recently Browsing   0 members

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