Mesh action interference when overlapping mesh appears... please help

Hey all,

So I think this is probably expected behavior but I am having a hard time figuring out how to solve this problem. I have a mesh, and when you click on it, a holographic copy of it appears which has a mesh drag behavior so you can position it. If you click on the hologram, the hologram disappears. The problem is that the hologram starts at the same location as the original, so the original click on the original mesh ends up registering on the hologram too making the hologram appear and disappear immediately. If you drag on the first click, it stays like it should, but I can’t rely on that. I need to make it so the first click only makes it appear, and subsequent clicks make it disappear.

Is there a way I can prevent the click on the hologram?

Here is a PG with the behavior: https://www.babylonjs-playground.com/#9UFEBE#31

Thanks

I’m not sure if this is what you have in mind: https://www.babylonjs-playground.com/#9UFEBE#33

The only relevant change was: OnPickTrigger instead of OnLeftPickTrigger , other than that you may want to disregard my code which increases the size of the hologram by a tiny amount and removes the !toggle style logic (just so that I could understand).

My guess as to why OnLeftPickTrigger was a problem is that perhaps it occurs on mouse up instead of on mouse down.

I didn’t understand the goal, but the pg above does the following:
clicking on sphere shows hologram
clicking and releasing on hologram hides hologram
clicking and dragging on hologram moves hologram

That is a good approach, however I am hoping to have different logic for right and left clicks. If I could find a way to do that with this logic it would be ideal. I have a similar suspicion about how OnLeftPick works, and it seems like it might be a flaw. Additionally, I would like to know if it is possible to prevent an event from propagating in the mesh actions. That might solve my problem too.

Thanks.

Maybe you could change the isPickable property of the meshes to be sure only the one you want to interact with at some point in time are piclkable ?

This would prevent the other meshes to react to the event.

sebavan, the only way I could do that is to set some kind of delayed function that enables the hologram to be pick-able after it is enabled, but there is no guarantee it will be after the undesired event propagates, and if I make it too long it could impact user experience. It’s a good idea, it just doesn’t seem like a clean way of doing it. Worth considering though if another solution can’t be found.

https://www.babylonjs-playground.com/#9UFEBE#34

You can still acces the button which was pressed through the event maybe it could fit ?

sebavan, you are absolutely correct. I can still filter by what button is pressed. That should work great. Thanks to timetocode as well for the initial suggestion. Kind of a weird issue but at least there is a work around! Not sure why I didn’t realize I could get the source event before this.

1 Like