Touch screen gestures

Hi guys,

I’m just wondering how people are handling touch screen gestures in Babylon? I’ve done some searching but it hasn’t seemed to turn up very much…

I’m currently using a free camera and would like to emulate all it’s functionality on touch screen devices. Out the box I can look left and right (mimicking the mouse) but I would also like to be able to move with pinching gestures (i.e ‘zoom in’ and ‘zoom out’). How are people configuring touch gestures?

Thanks! :slight_smile:

Adding @PolygonalSun our own input hero !!!

As far as I know, the FreeCamera’s mouse and touch input doesn’t have any built-in way of supporting gestures but you might be able to make use of the BaseCameraPointersInput class by creating a custom pointer input that extends the functionality of BaseCameraPointersInput. You can then override the use of onTouch and onMultiTouch to handle any gestures (like pinch and zoom). You can then just add your custom gesture class to your camera’s inputs:

// Example: Let's assume our new class is called 'FreeCameraGestureInput'
// First, we'll remove the old mouse inputs
camera.inputs.removeMouse();
// Now, we'll just add the new one to replace it
camera.inputs.add(new FreeCameraGestureInput());

If you want to see an example of a class that uses BaseCameraPointersInput, check out ArcRotateCameraPointersInput.

1 Like

Hi there @Olly_Bolland just checking in, is your question answered? Or do you need any further help? :slightly_smiling_face: