BABYLON.PointerEventTypes.POINTERTAP is triggered independently if the user clicked in a mobile device, or a computer, that’s ok but there is any chance to know if the user pressed left or right mouse click on PC?
Thank you in advance.
BABYLON.PointerEventTypes.POINTERTAP is triggered independently if the user clicked in a mobile device, or a computer, that’s ok but there is any chance to know if the user pressed left or right mouse click on PC?
Thank you in advance.
It seems these PointerEventTypes are not available yet in the Babylon API.
You could use the event.button
-property:
scene.onPointerObservable.add((pointerInfo) => {
switch (pointerInfo.type) {
case BABYLON.PointerEventTypes.POINTERTAP:
switch (pointerInfo.event.button) {
case 0:
console.log("LEFT");
break;
case 1:
console.log("MIDDLE");
break;
case 2:
console.log("RIGHT");
break;
}
break;
}
});
Consider that event.which
property also works, but is deprecated!
It seems that pointerInfo.event.button returns a number but thank you so much!
Did you try the provided code above?
Thats why I used a switch clause
You have to interpret the returned numbers with some sort of condition!
The PointerEventTypes are also just static constants, containing a number (like Enums)
Sorry my bad! I just copied pointerInfo.event.button and compared with “LEFT”