I have an issue where a mesh is in front of another mesh and I’m using the actionManager on the mesh to register an onPickTrigger for each sphere.
Clicking each sphere makes it disappear. Clicking quickly to trigger the blue (front) and red (back) sphere results in the red (back) sphere receiving a double pick instead of a single pick. The plane will disappear if the red sphere receives an onDoublePick action.
Is this a bug or is there a better method to register quick clicks on a mesh?
Having a look at your code, I would say it’s not a bug :
Single click triggers instantly
Double click won’t “remove” the single click from the past
And then since you actually disable the sphere on single click, there is basically no chance to trigger a double click on it.
Eventually, you could set the “disappear” in some kind of a timeout, and disable this timeout on double click (adapt the delay with your speed need)
But anyway, I don’t know what is the usage, but I think you should try another UI mecanism than hiding on click, and not hidding + something else on double click
Thanks for your reply. The problem is the second click should trigger the red sphere. The blue sphere disappearing should allow for the second click to trigger the red sphere. The red sphere is receiving only only click but gets triggered as a double click.
This is for a game where the player needs to click items quickly to “destroy” them. I put this simple example together to figure out why certain meshes where not getting triggered. I discovered the double click trigger on the red (back) sphere by accident. I don’t want or need a double click action at all.
Doubleclick is emulated by Babylon and not using native doubleclick events. You can define the delta time between two clicks to be considered a double click. I am not sure this is the solution you are looking for, but it’s one way of fixing it
The default time is 300ms. Reducing it to 100 - https://playground.babylonjs.com/#TTQ6G7#2 works better. but then you will probably have hard time getting doubleclicks to work.
I thought about that, but seems like a hack instead of just having the single click work as expected. I don’t understand why the red sphere receives a double click trigger when the first click triggers the blue sphere.
Thanks! This is possibly what I’ll need to do. I don’t have any need for a doubleclick action, so this may be my solution. I tried disabling double click but didn’t seem to work.
Still troubles me that the red sphere receives a double click when it clearly only gets one click.
I didn’t have a look at the source code (so @RaananW will eventualy confirm) but I would say that the “double click” trigger is done in a global context (and not in a “per mesh” context). So what happens is, most likely :
First click → Blue disappears
Second click → delay < doubleClickDelay == true → Double Click Triggered → Red happens to be under the mouse since Blue is off → Red receives Double Click Event
Somehow, like if the DoubleClick was actually a SimpleClick with a flag “short delay” set to true
Thanks for that explanation. This makes sense, especially considering the double click delay trick that @RaananW works. I really appreciate you taking the time to help me out. I love this community!
@RaananW Thanks again for your help. I chose this as the “solution” since it works well in my situation of not needing double clicks. It still seems odd about the red sphere receiving the double click though. If someone needed quick click registration AND double click ability, this would not work.