Universal camera behaves differently on touch inputs

https://playground.babylonjs.com/#0XYMA9#41 in this playground camera doesn’t behave as expected with touch events. why is that so? The reason I am interested is knowing why it does that because I am working offscreen canvas and I am binding events using postmessage and creating fake document model on worker thread and it works great except universal camera behaves the same way it behaves with touch events.

Adding @PolygonalSun our inputs guru

1 Like

So, the reason why there’s a difference in the behavior with touch when using a UniversalCamera is because the UniversalCamera, by default, has a specific touch input object (FreeCameraTouchInput) which operates differently from the standard mouse controls (FreeCameraMouseInput). This was done to allow for touch gestures to have some navigation control on the screen. If you want to use the same input object used by mouse but with touch, you should be able to do the following:

var touch = camera.inputs.attached.touch;
camera.inputs.remove(touch);
camera.inputs.attached.mouse.touchEnabled = true;

You can also just use a FreeCamera if you don’t also need default gamepad support found with cameras like the GamepadCamera (UniversalCamera is effectively a combination of the FreeCamera, GamepadCamera, and TouchCamera).

1 Like