From 9eb00dc24b0de1f7ea450380fd75346d5667e2a6 Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Fri, 2 May 2014 14:17:32 -0700 Subject: [PATCH] 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. --- examples/js/controls/OrbitControls.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/js/controls/OrbitControls.js b/examples/js/controls/OrbitControls.js index fc5ca09245..4361924832 100644 --- a/examples/js/controls/OrbitControls.js +++ b/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 // 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 this.noKeys = false; -- GitLab