How to rotate arcRotateCam with both left and right mouse clicks

I have a game with an arcRotateCam on a mesh. The camera works 99% like I want. However, I can only rotate the camera with left mouse click + drag. I’d like to also rotate the camera with right mouse click + drag (identical to how left click works). I’m sure there’s a really easy way to do this but I can’t figure it out.

my code is pretty much:

    const camera = new BABYLON.ArcRotateCamera("camera1", -Math.PI/2, 1.2, 200, position, scene);
    camera.attachControl(canvas, true);

Help is greatly appreciated, thanks!!

hello, you will need to add your own input:

is there a way to see the implementation of the left click rotate logic? because I dont know how to implement it myself. I see that I can probably use this one: ArcRotateCameraPointersInput - Babylon.js Documentation but I’m not sure how to attach it the right way (in other words, the doc doesn’t show how to attach it to the right click mouse). I’m trying this:

const rightClickInput = new BABYLON.ArcRotateCameraPointersInput();
rightClickInput.buttons = [3];
camera.inputs.add(rightClickInput);

but it doesnt seem to be working

Almost :slight_smile:
you can do this:

camera.attachControl(canvas, true, true, 3); // The 3 here indicates that panning will be done with button 3
camera.inputs.attached.pointers.buttons = [0, 2] // we will use button 0 and 2 (left and right) 

awesome, thanks. that did it

1 Like