How to stop rotation/limit it orbit camera

So I have noticed I am able to fully rotate around the scene if I drag my mouse along the tabs of the browser or the windows task bar I am wondering if there is a way to limit the rotation or even better not to rotate the scene at all when the mouse leaves it or have the scene still rotate even if the mouse isn’t hovering on the scene …

I hope this makes sense heres a video of the problem:

It seems you are using OrbitControls with enabled damping, right?

If so, consider to only call controls.update() if the pointer is over the screen. This can be detected in various ways, e.g. via pointerleave and pointerenter event listeners.

https://jsfiddle.net/b0Lgzwf7/

TBH, I find the resulting behavior confusing. I don’t think I would add this to my app…

2 Likes

Thanks for the reply I’ve tried with this method before the problem is I can put my mouse in the top left corner of the browser window (so its on the tabs) move the mouse to the far right along the tabs and then rotate the scene from there so in affect I can still rotate the scene 360 degrees if I do this enough times I don’t know if that makes sense?

Also right to left

Hi i would like a camera with no rotation, only panning and a little of zooming. I’ve used a orbitcontrol , i just want to slide and no rotation, is that possible?

Thank you it was not all problem i had to change mouse buttons

Now i need to change the one finger into two finger touch to pan.

What is the eventlistener for two finger on screen? Thanks.

pointerdown/pointermove/pointerup
the event has an array of touches. google it. :slight_smile:
Nowdays you can type that kind of question into google search, and it will answer it with AI.

(unless you mean hooking into orbitcontrols to get the event, which I don’t think you can.)

Usually you can just let orbitcontrols do its thing, and you track events yourself in parallel.. and do controls.enabled = false when You need to do something special to the camera yourself, then back to true when you’re done doing your changes to the camera, and orbitcontrols will adapt as best it can, and enforce its constraints on its next update.