|
@@ -42,7 +42,7 @@ THREE.OrbitControls = function ( object, domElement ) {
|
|
|
this.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 ].
|
|
|
+ // If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI )
|
|
|
this.minAzimuthAngle = - Infinity; // radians
|
|
|
this.maxAzimuthAngle = Infinity; // radians
|
|
|
|
|
@@ -139,6 +139,8 @@ THREE.OrbitControls = function ( object, domElement ) {
|
|
|
var lastPosition = new THREE.Vector3();
|
|
|
var lastQuaternion = new THREE.Quaternion();
|
|
|
|
|
|
+ var twoPI = 2 * Math.PI;
|
|
|
+
|
|
|
return function update() {
|
|
|
|
|
|
var position = scope.object.position;
|
|
@@ -170,7 +172,29 @@ THREE.OrbitControls = function ( object, domElement ) {
|
|
|
}
|
|
|
|
|
|
// restrict theta to be between desired limits
|
|
|
- spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) );
|
|
|
+
|
|
|
+ var min = scope.minAzimuthAngle;
|
|
|
+ var max = scope.maxAzimuthAngle;
|
|
|
+
|
|
|
+ if ( isFinite ( min ) && isFinite( max ) ) {
|
|
|
+
|
|
|
+ if ( min < - Math.PI ) min += twoPI; else if ( min > Math.PI ) min -= twoPI;
|
|
|
+
|
|
|
+ if ( max < - Math.PI ) max += twoPI; else if ( max > Math.PI ) max -= twoPI;
|
|
|
+
|
|
|
+ if ( min < max ) {
|
|
|
+
|
|
|
+ spherical.theta = Math.max( min, Math.min( max, spherical.theta ) );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ spherical.theta = ( spherical.theta > ( min + max ) / 2 ) ?
|
|
|
+ Math.max( min, spherical.theta ) :
|
|
|
+ Math.min( max, spherical.theta );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// restrict phi to be between desired limits
|
|
|
spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
|