jps0611 Posted February 13, 2018 Share Posted February 13, 2018 Howdy, 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. Thanks! JPS Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 13, 2018 Share Posted February 13, 2018 Hiya JPS, sorry for the slow replies. https://www.babylonjs-playground.com/#11XV5X#6 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. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
jps0611 Posted February 13, 2018 Author Share Posted February 13, 2018 Thanks so much @Wingnut! Let me spend some time diving into the details of this implementation. But at first blush this looks exactly like what I need! JPS Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 13, 2018 Share Posted February 13, 2018 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. Quote Link to comment Share on other sites More sharing options...
jps0611 Posted February 13, 2018 Author Share Posted February 13, 2018 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. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 13, 2018 Share Posted February 13, 2018 *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... https://www.babylonjs-playground.com/#11XV5X#8 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). GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
jps0611 Posted February 14, 2018 Author Share Posted February 14, 2018 Ha no wild goose chases. I learned a tons while going through this! Thanks again @Wingnut! JPS Wingnut and GameMonetize 2 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.