I set `camera.attachControl(canvas, true, true, 1);' to use right click for panning the arcRotateCamera but it doesn't work

Hello everyone

I set camera.attachControl(canvas, true, true, 1) to panning the camera with right click but I cannot panning the camera and I don’t know why I have such a problem, is it because of my camera position?

here is my PG: https://www.babylonjs-playground.com/#Y21CI9#5

So I took a look at that PG and here’s what I’ve found. First of all, right-click is the default option for panning so if you want to use right-click, you can use either camera.attachControl(canvas, true, true, 2) or camera.attachControl(canvas, true, true). The number for the fourth argument is derived from the button parameter of the MouseEvent object.

Second, you’re not seeing any panning movement because of both how we calculate panning movment distance and the scale of your scene.

The way that we calculate panning movement distance is to take the 2D offset (derived from MouseEvent) and divide it by panningSensibility. We then plug that into the equation for how far we will move the camera. Because you’re using such a massive scale for your scene, the camera is technically moving but doesn’t move enough to matter. This behavior feels incorrect to me so I’m going to investigate it further to come up with a better solution.

In the meantime, if you lower the camera.panningSensibility (in this case, I recommend camera.panningSensibility = 1), it should at least work as a workaround for the time being.

1 Like

Hi @PolygonalSun
thanks a lot for helping, I set camera.panningSensibility = 1 and then it works. :pray: :pray: :pray: