I’m fairly new to Babylon,though I have used the basic viewer in the past. I have a reasonable understanding of gltf and have written a simple exporter for my configurator application. My gltf file describes a fairly simple model consisting of a number of top level nodes with each node referencing one of a large number of possible meshes each with a distinct transformation - not all of the possible meshes are referenced in the model at any one time. I’m looking for a way to swap node meshes from the model in javascript after it has been loaded into Babylon via LoadMeshAsync.
The model displays fine, but when I inspect it in javascript I notice that it seems to be optimised and only contains the meshes from the gltf which are referenced in the scene.
How would I go about loading all meshes and then programmatically swapping them in the current scene model? I’m guessing I need to use an asset container. Can anyone point me to any relevant documentation or (even better) some code examples?
On a related note. Is it possible to load a gltf model held locally as a javascript string into the Babylon viewer?
The setEnabled function might work, though I’m not quite sure at what level it operates. I also suspect I may be confusing a gltf Mesh object with a Babylon Mesh object.
I have a fixed number of gltf meshes - which define actual geometries through vertex attributes. I also have a number of top level nodes which can reference/instance any one of those meshes at a different position in the scene. All nodes could instance the same mesh or all could instance different meshes. IIUC the setEnabled function would effectively operate at the level of the gltf node rather than the gltf mesh which might not solve my problem.
I’ll look into Babylon Playground to see if I can create a simple example to explore this further.
If I understand you correctly, you’d have to node.getChildMeshes() or scene.getMeshByName("") to access the correct meshes. Obbiously you need some way to id the meshes you want to setEnabled(), be it via hardcoding or a specific way your gltf is structured.
I used getChildMeshes on each node and it returns the expected number of sub nodes, however calling setEnabled(false) on each of these has no effect. Oh well, need to dig deeper.