Browse Source

align code of clampLength to setLength

Mugen87 9 years ago
parent
commit
c4c85e8883
2 changed files with 4 additions and 4 deletions
  1. 2 2
      src/math/Vector2.js
  2. 2 2
      src/math/Vector3.js

+ 2 - 2
src/math/Vector2.js

@@ -296,9 +296,9 @@ THREE.Vector2.prototype = {
 
 		var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
 
-		if ( newLength !== oldLength ) {
+		if ( oldLength !== 0 && newLength !== oldLength ) {
 
-			this.divideScalar( oldLength ).multiplyScalar( newLength );
+			this.multiplyScalar( newLength / oldLength );
 
 		}
 

+ 2 - 2
src/math/Vector3.js

@@ -526,9 +526,9 @@ THREE.Vector3.prototype = {
 
 		var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
 
-		if ( newLength !== oldLength ) {
+		if ( oldLength !== 0 && newLength !== oldLength ) {
 
-			this.divideScalar( oldLength ).multiplyScalar( newLength );
+			this.multiplyScalar( newLength / oldLength );
 
 		}