Click to allow it only when the mouse is not spinning

Hello,

I have a (simple?) Problem.

There is a Click event in the window (or Canvas) that informs me which material is clicked.
scene.pick (scene.pointerX, scene.pointerY);

But if I click so Mousedown and the camera Rotate and mouseup on a mesh stand, this is now selected. That should not be, only if I consciously click on it.

What I tried was to put a Mousedown event on the window (or in the canvas) and a mousemove so that when a Mousedown takes place and at the same time a Mousemove the click for Babylon should not be scored.

But apparently that is blocked by babylon, at least I can not query a mouse down during the click.

I hope you can help me
Daniel

Hey!

Can you repro on the playground? Maybe you want to detach the camera from the canvas when you detect your mousedown and reattach it on mouseup?

Sure :smiley:

As you can see, if you click while you move, the click scored as a click… But i want that the click does not score if i move the Object.

https://www.babylonjs-playground.com/#A7UM5D

Click & Drag the Object and do mouseup on one of the Objects

As you can see here, if you move while you click it does not work - https://www.babylonjs-playground.com/#A7UM5D#1

This should work:
https://www.babylonjs-playground.com/#A7UM5D#2

1 Like

okay wow, I did not think it was that easy … xD

Big thank you!!

Just a little Question - is it Possible to have a Pointer-Cursor on Clickable Meshes?

(just for future googler and if the PG got removed):

canvas.addEventListener("click", function (event) {
        if (camera.inertialAlphaOffset || camera.inertialBetaOffset) {
            return;
        }
});

To Answer my own Question about Cursor change - yes it’s Possible :smiley:

canvas.on(“mousemove”, function (event) {
var pickResult = parent.scene.pick(parent.scene.pointerX, parent.scene.pointerY);
if(pickResult.pickedMesh.id == “myID”)
{
(this).css("cursor", "pointer"); } else { (this).css(“cursor”, “default”);
}
});

1 Like

PG are immutable so no worries :wink: