Custom camera controls switch click actions

Hello, I am working on a task and I need to change the control of ArcRotateCamera. Mainly, I need to keep the same behaviour but change which click activates which. Basically, right now with left click → rotation and with right click → translation. And I need simultaneous left + right click-> translation, right click → rotation. Is there a way to do it without creating custom camera control from scratch.

Hello and welcome to the Babylon community! Let’s check with our input master @PolygonalSun

Hey Khaki,
Unfortunately, this will require some custom input work BUT you don’t actually have to create a new Custom Input object for it. If that’s the only functionality that you need, all you need to do is just create a simple check during a POINTERMOVE event to see what buttons are pressed and move accordingly:

scene.onPointerObservable.add((eventData) => {
    const evt = eventData.event;

    if (evt.buttons === 3) {
        camera.inertialPanningX -= evt.movementX / camera.panningSensibility;
        camera.inertialPanningY += evt.movementY / camera.panningSensibility;
    }
    else if (evt.buttons === 2) {
        camera.inertialAlphaOffset -= evt.movementX / camera.angularSensibilityX;
        camera.inertialBetaOffset -= evt.movementY / camera.angularSensibilityY;
    }
}, BABYLON.PointerEventTypes.POINTERMOVE);

Using the buttons property, in the event provided, we can just see what buttons are active when the mouse is moved and modify the correct set of camera properties (PG Example in action: Custom inputs without a custom input | Babylon.js Playground (babylonjs.com))

The one caveat with this is that you can’t attach controls to the camera or else you’ll have some conflicting results.

1 Like

Thanks for the answer. It helped a lot!

1 Like