Hello.
I’m pretty new to Babylon though I’ve used te basic viewer and i have a reasonable understanding of webgk and gltf structure.
I created a gltf file which has multiple child nodes each of which can references a single mesh from a collection of very similar options. Initially each node references the same mesh but the intention is to interactively edit the model in javascript to change the meshes referenced by the nodes. Looking at the model in javascript after loading my single gltf, it looks like it is optimised so that it only contains the active meshes - ie those referenced in the root.
What is the correct way to achieve my objective? Im guessing i need to use asset containers? Any pointers to the relevant documentation or (even better) any sample code showing how to swap gltf meshes would be greatly appreciated.
Unfortunately AssetContainer will mostly provide a addAll or RemoveAll from scene, So the easiest in your case could be to load all your meshes, disable their root with setEnabled(false) and then simply reparent on demand with .parent = … and setEnabled(true)
If I understand you correctly I would create an extra disabled node and add every mesh option to that node to ensure it becomes part of the model but not a visible part. Then I reparent and re-enable a mesh on demand?
In my case I can have multiple instances of each mesh - in theory every top level node could instance the same mesh with a different transform matrix. Would your solution allow for that - I mean can I reparent a mesh to multiple nodes?
Looks like I had some misconceptions about how a gltf model mapped onto a Babylon scene.
I’m thinking the easiest solution for me would be if I could load a local gltf json string directly into Babylon. Do you know if there’s any mechanism to do this - can LoadMesh take a local javascript string as an argument rather than a url for example. Is there a LoadMeshFromString - don’t see one.