How can I limit horizontal rotation on OrbitControls?
Inside the code I could see that it's possible to limit it vertically using minPolarAngle
and maxPolarAngle
. But I couldn't find a way to limit it horizontally.
--
Edit: I know that it OrbitControls doesn't rotate the Mesh but the Camera. I just want a solution to put horizontal limits on the camera.
EDIT: The ability to constrain camera movement both horizontally and vertically is now a feature of OrbitControls
.
// How far you can orbit vertically, upper and lower limits.
// Range is 0 to Math.PI radians.
controls.minPolarAngle = 0; // radians
controls.maxPolarAngle = Math.PI; // radians
// How far you can orbit horizontally, upper and lower limits.
// If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
controls.minAzimuthAngle = - Infinity; // radians
controls.maxAzimuthAngle = Infinity; // radians
three.js r.71
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With