Camera Panning to Mouse wheel click

Hi Guys,

How can I modify the panning behavior so that when you click the mouse wheel and hold it, it will do the panning. Not the right click.

Thanks in advance

Hi macleodjb,

From context and from your other question, I’m guessing that by “panning” you’re referring to rotating the ArcRotateCamera. Probably the best way to do this is by customizing the camera inputs for a default ArcRotateCamera. Hope this helps, and best of luck!

No I am not referring to rotating. Panning so the scene only moves left to right. In any of the demos. You hold down the right mouse button and the camera will pan.

I just want the panning to happen when holding down the wheel instead

Okay. I think the same answer applies, though: you’ll need to customize the camera inputs to respond to the mouse wheel click. The docs page I linked to should have information about one way to do that. You could also implement it yourself by translating the camera based on direction vectors retrieved from the camera’s world matrix, but I don’t think that would be easier than looking at what the cameras already do and replicating it for a different button.


camera._panningMouseButton = 1

Be sure to set if after you attach the camera.


1 Like

Hey @syntheticmagus!
Sorry being a smartass. It’s actually a hidden public property not documented in API and I know about it just because I was implementing a HammerJS based input and I was looking at the camera source code the last days oftenly :slight_smile:
EDIT: so actually your answer is correct, I just pointed out how exactly we can do it :slight_smile:

@roland No worries, I didn’t think you were being a smartass at all! :smile: Thank you for knowing an easier approach and sharing it. I didn’t know about it before, so I got to learn something too!

1 Like

Thanks to you both. Very helpful

1 Like

If you do not want to use the hidden property, you can also pass the value in the attachControl parameters

1 Like

I was curious why is this quite important parameter hidden and as we can see it’s not and it is available at attach time. So it is a much cleaner way to set it that way. Thank you very much!

1 Like