Thin Instances - GLB Models

Hi Folks!

I’m trying to get thin instances working for GLB models and have tried about 10 things and haven’t been able to get it to work. I think there is a subtle error in this code but I don’t know what it is.

I did in fact check the docs for both instances and thin instances.

In the below example, the thin instances works for spheres. But the moment I comment out sphere (“loadedModel”) and substitute it for a mesh, and use the lines below specifically for .gltf / .glb models , it no longer works. Also, without doing the instances, the model loads correctly, so it isn’t the model. I think its probably a 3 - 5 line code fix. Is there anyone willing to help me figure out how to correctly do thin instances of .GLB models?

loadedModel.isVisible = false;
loadedModel.setParent(null);

https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/thinInstances/

the ImportMeshAsync function is async so you have to await it:

var loadedModels = await BABYLON.SceneLoader.ImportMeshAsync(

And thus flag the root function as async:

var createScene = async function() {

and loadedModels is a list so:

const loadedModel = loadedModels.meshes[0];

Thin instances test | Babylon.js Playground

@Deltakosh

Hi sir,

Thanks for your response. I looked at the Playground you linked and checked the code in it and it still only appears to show one instance instead of two.

Can you see if I made a mistake and if so where it is? Sorry for the trouble.

loadedModels.meshes[0] is the root of the hierarchy and is not a mesh with geometry. The real meshes are children of this node:

2 Likes

Thank you so much! So helpful!