Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit OrbitControls horizontal rotation

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.

like image 821
armoucar Avatar asked Aug 14 '14 13:08

armoucar


1 Answers

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

like image 155
WestLangley Avatar answered Oct 17 '22 18:10

WestLangley