瀏覽代碼

Set OrbitControls polar angle limits to [0.01, pi-0.01]

OrbitControls suffers from gimbal lock: if you rotate all the way to the
north or south pole, it will feel 'stuck' in the east-west direction.
This patch fixes the issue by setting the default minimum and maximum
polar angles to 0.01 and pi-0.01 radians, which eliminates any
perceptible gimbal lock effect at ordinary browser frame rates.
Leo Singer 11 年之前
父節點
當前提交
9eb00dc24b
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      examples/js/controls/OrbitControls.js

+ 4 - 3
examples/js/controls/OrbitControls.js

@@ -60,9 +60,10 @@ THREE.OrbitControls = function ( object, domElement ) {
 	this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
 	this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
 
 
 	// How far you can orbit vertically, upper and lower limits.
 	// How far you can orbit vertically, upper and lower limits.
-	// Range is 0 to Math.PI radians.
-	this.minPolarAngle = 0; // radians
-	this.maxPolarAngle = Math.PI; // radians
+	// Range is 0.01 to Math.PI-0.01 radians, which is sufficient to avoid
+	// noticable gimbal lock.
+	this.minPolarAngle = 0.01; // radians
+	this.maxPolarAngle = Math.PI - 0.01; // radians
 
 
 	// Set to true to disable use of the keys
 	// Set to true to disable use of the keys
 	this.noKeys = false;
 	this.noKeys = false;