Browse Source

Merge pull request #17060 from WestLangley/dev-panning_damping

OrbitControls: Normalize panning speed when damping is used
WestLangley 6 năm trước cách đây
mục cha
commit
750c504a2d

+ 10 - 1
examples/js/controls/OrbitControls.js

@@ -182,7 +182,16 @@ THREE.OrbitControls = function ( object, domElement ) {
 			spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
 			spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
 
 
 			// move target to panned location
 			// move target to panned location
-			scope.target.add( panOffset );
+
+			if ( scope.enableDamping === true ) {
+
+				scope.target.addScaledVector( panOffset, scope.dampingFactor );
+
+			} else {
+
+				scope.target.add( panOffset );
+
+			}
 
 
 			offset.setFromSpherical( spherical );
 			offset.setFromSpherical( spherical );
 
 

+ 10 - 1
examples/jsm/controls/OrbitControls.js

@@ -192,7 +192,16 @@ var OrbitControls = function ( object, domElement ) {
 			spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
 			spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
 
 
 			// move target to panned location
 			// move target to panned location
-			scope.target.add( panOffset );
+
+			if ( scope.enableDamping === true ) {
+
+				scope.target.addScaledVector( panOffset, scope.dampingFactor );
+
+			} else {
+
+				scope.target.add( panOffset );
+
+			}
 
 
 			offset.setFromSpherical( spherical );
 			offset.setFromSpherical( spherical );