Include thinInstanceIndex for OnPointerOverTrigger, OnPointerOutTrigger

Hi, I’ve been working with thin instances and pointer events using the action manager. Would it be possible to include the thinInstanceIndex when you hover a mesh that has thin instances? Or maybe even a different over & out events for each thin instance?

It might be too specific to the project I’m working on as we store different data based on the thin instance index but I feel that it might be useful as instanced meshes for comparison would trigger individual events.

The data sort of already exists as we have a picking result here:

Welcome aboard!

Could you setup a small repro in the Playground? I think all picking methods in Babylon are using the same underlying code, and thin instances are handled by this code: you get the thin instance index in the thinInstanceIndex property of the PickingInfo structure.

So, I feel it should work. Have you enabled thin instances picking with mesh.thinInstanceEnablePicking = true?

2 Likes

Thanks!

I set up a playground that tried to convey what feature could be missing. If using the action manager we don’t know what thin instance index is pointer over/out. Whereas for instanced meshes the action manager would trigger for each instance.

But as I wrote this might be too specific to the project I’m working on and can be solved just using scene.pick().

Hopefully it’s not too confusing what the texts mean when hovering the 4 different spheres.
https://playground.babylonjs.com/#3H8B60

When this PR is merged:

You will be able to access the pickResult structure used to trigger the on pointer out/over events of the ActionManager through event.additionalData.pickResult. So no need to issue an additional scene.pick query.

3 Likes

This is exactly what I needed today, love the power of this community :tada:.

One nitpick, I found it confusing that pickResult was nested under additionalData instead of spread into the object. It makes it inconsistent with the object available on other triggers. For instance, I would have expected the following:

actionManager.processTrigger(Constants.ACTION_OnPointerOverTrigger, ActionEvent.CreateNew(mesh, undefined, { pointerId, ...pickResult }));

at ActionManager: pass pickResult to pointer out / over triggers by Popov72 · Pull Request #10931 · BabylonJS/Babylon.js · GitHub. I’ve added the ... to spread the object.

Thanks for this @saaratrix and @Evgeni_Popov.

Hi @Evgeni_Popov , BabylonJS newbie here (loving it already!).

Following up on this question, it seems like OnPointerOverTrigger doesn’t trigger when we move the pointer from one thin instance to another without interruption. What would be the best way to trigger anytime a thin instance is picked (even if they overlap)?

I’ve tweaked the original playground a bit to reproduce: https://playground.babylonjs.com/#3H8B60#3

2 Likes

We have the same problem here: An application here that is basically using ThinInstances for everything and we had to implement our own pick logic as we were suffering from the fact that we do not get an event when moving from one ThinInstance to another. If there was a solution for registering for such events, we could remove a lot of custom code out of our application!

cc @Evgeni_Popov in case he missed the post the first time

Already fixed here:

1 Like