Picking instances using EXT_mesh_gpu_instancing

I’m trying loading a glb file containg EXT_mesh_gpu_instancing objects. It loads just fine but I cant pick the instanced meshes. There are several instanced meshes, blue chairs for example. Tried it in the sandbox and also using pickResult. Is this something that should work or do I need to use some workaround for picking instanced meshes using EXT_mesh_gpu_instancing?

Model file is from this thread:

direct link to file:

Your are using thin instances which are utterly fast but cannot be picked
On my phone right now so let me ask @Evgeni_Popov if we have an option to use instances instead of thin instances in that case

No, we don’t have such an option currently, but I think I can add it.


Pinging @bghgary as I wonder if we should

If this specific gltf extension is used this is the expected tradeoff right?

Maybe you should export with regular instances?

Another option would be to add the possibility to support picking for thin instances?

Yes even better :wink:

The spec doesn’t indicate one way or another. If we can add support for picking for thin instances, that would be the best option I think.

That works for me

Added to my todo list.


Thanks for the speedy response! So, if I understand correctly meshes using EXT_mesh_gpu_instancing will become thin instances in babylon? And by adding support for picking on thin instances it will also work for the meshes that use EXT_mesh_gpu_instancing? That would be awesome!

totally :slight_smile:

I’m working on the picking!

1 Like

Done! will be live in a few minutes

Here’s a PG with thin instances picking enabled: the selected thin instance is highlighted so that you can see what’s going on (check also the console log where the coordinates of the picked point are dumped, as well as the thin instance index).


1 Like

Cool! Your example using the boxes works really well.

I tried getting the picking work loading the gltf-stadium scene but failed. Link to playground:

The file is also linked as a zip-file in the first post.

Any ideas what needs to be done?
I also tried the stadium scene in the sandbox but the picking does not seem to work for the thin instances.

That’s because picking on thin instances does not work correctly if the base mesh has not an identity matrix transform.

Having a look at that.

Will be fixed by:

PG with translated / scaled / rotated base mesh: Babylon.js Playground

1 Like

I still cant get my playground scene to work with the the picking. Can you check what I need to todo different? I only get picking on non thin instances in the scene.

It is not meshes that are passed to the callback function of SceneLoader.Append but an object with meshes, cameras, lights, etc inside.

So, in your PG, you should pass newMeshes.meshes to whenDonefunction.

Thanks! That seemes todo it:) I noticed that it does not work in the sandbox when picking mode is on. Maybe thin instances picking should also be toggled on/off when toggling picking in the sandbox.