kevzettler Posted January 30, 2017 Share Posted January 30, 2017 I have an existing scene made in Babylon.js (scene1) I have a `.babylon` file (scene2) I want to append to scene1. Before appending scene2 to scene1 I want to do some operations on the meshes of scene2. `BABYLON.SceneLoader.Append` just immediately dumps everything from scene2 into the scope of scene1. This is not helpful. I have a lot of meshes in scene2 and scene1 with dynamic names so it's a lot of work to manually go through the merged array and look for the meshes that were in scene2. I was hoping I could use `BABYLON.SceneLoader.Load` for this. Load scene2, iterate over the scene2 meshes, then manually add them to scene1. Maybe I've missed something but, it doesn't like there is straightforward support for this. Seems like `BABYLON.SceneLoader.Load` is designed to load an initial scene only. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 30, 2017 Share Posted January 30, 2017 Hello! it's a kind of a hack but you can flag your meshes in Scene1 with something like mesh.metadata = "scene1" and after appending scene2, jut go through all meshes with metadata = null Quote Link to comment Share on other sites More sharing options...
gryff Posted January 30, 2017 Share Posted January 30, 2017 Hi kev I'm not sure if this would be called a "hack" or not, but this is the approach that I would take using Blender (I assume 3DMax has a similar feature). In Blender with the meshes of scene 1, I would create an Empty named "Scene1" and parent all the meshes in the scene to that Empty. Then repeat this with Scene2 but just change the name of the Empty to Scene2. Now in code I can var scen2 = scene.getMeshByName("Scene2"); var scen2Meshes = scene2.getChildren(); You can also get the meshes for Scene 1 this way. cheers, gryff Quote Link to comment Share on other sites More sharing options...
kevzettler Posted January 31, 2017 Author Share Posted January 31, 2017 @gryff I like this idea. I tried it. I have a problem though. Lots of my meshes are parented to an armature and adding an 'Empty' mesh and changing their parent to that breaks all my rigged animations. Any thoughts on a workaround? Quote Link to comment Share on other sites More sharing options...
gryff Posted January 31, 2017 Share Posted January 31, 2017 1 hour ago, kevzettler said: Lots of my meshes are parented to an armature Well @kevzettler : that kind of moves the goalposts a wee bit . It might help if you could describe scenes 1 and 2 a little more. Do both scenes have armatures? How many armatures in each scene? Are there meshes not bound to the armatures(s) in one or both scenes? How many meshes are bound to the armatures? And going back to your original post what do you mean by "dynamic names"? In fact what are you trying to accomplish? Depending on your answers, it may require someone with better coding skills than gryff cheers, gryff Quote Link to comment Share on other sites More sharing options...
kevzettler Posted January 31, 2017 Author Share Posted January 31, 2017 @gryff I'm making a game. scene1 is an environment map with static meshes no armatures. scene2 is a rigged character with modular limb components Think clothing equipment etc. Probably 1 armature. What I mean by "dynamic names" I don't know what future meshes for be added to scene2. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 31, 2017 Share Posted January 31, 2017 I would use the Blender option to freezeWorldMatrix for your static stuff. You could then use that to detect your background meshes. This is NOT a hack. It's a hack not to freeze background geometry . SceneLoader.Load is / was depreciated. It is implemented as a wrapper of SceneLoader.Append anyway, so I am not aware of any thing Load can do that Append cannot. You can avoid problems referencing the scene object defined Load, and messy callbacks that result with using more than 1 .babylon file. You could also use importMesh and get the list of contained meshes in the callback. Quote Link to comment Share on other sites More sharing options...
kevzettler Posted February 1, 2017 Author Share Posted February 1, 2017 Quote I would use the Blender option to freezeWorldMatrix for your static stuff. You could then use that to detect your background meshes. This is NOT a hack. It's a hack not to freeze background geometry . 1 I should have clarified The static scenes are all manually created in Babylon at the moment. Appreciate the tip though. Quote You could also use importMesh and get the list of contained meshes in the callback. This actually looks exactly what I need. A callback to tell what has been loaded is what I would expect here. Thanks @JCPalmer 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.