Hi there!
I have this setup:
const result = await SceneLoader.ImportMeshAsync('', './assets/', 'untitled.glb', scene);
mesh = result.meshes[0] as Mesh;
return mesh.createInstance(name);
Where the glb file is an export from Blender. When the code runs, I get this in the browser’s console
BJS - [18:58:03]: Instances should only be created for meshes with geometry.
If I check the geometry from the mesh above, I see that it’s actually null. Am I doing something wrong when exporting the glb file from Blender? Or am I missing something in the code?
Welcome to the forums!
The first mesh when loading a glTF (or glb) is a root mesh that just contains a transform to convert right-handed data to left-handed data. The root mesh has children that contains the hierarchy of the glTF scene. If you want to create an instance from this, the best option is to load using asset containers and call assetContainer.instantiateModelsToScene
.
2 Likes
Thanks a lot, @bghgary! That helped and I’m now able to instantiate the model properly
Another question that I have now is - how would I remove one particular instance of InstantiatedEntries? I’ve tried with scene.removeTransformNode
o it’s nodes, but that doesn’t seem to do the trick. Any ideas?
Nevermind, calling dispose on the meshes did the trick
2 Likes
I think disposing the meshes work, but I’m not sure if it will remove everything. For example, are the animation groups removed when the mesh is removed? @Deltakosh maybe we can add a method to remove the items created in InstantiatedEntries?
I feel it is absolutely possible yes. We should track it