Browse Source

use divideScalar to avoid zero division

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

+ 1 - 1
src/math/Vector2.js

@@ -302,7 +302,7 @@ THREE.Vector2.prototype = {
 
 			if ( newLength !== oldLength ) {
 
-				this.multiplyScalar( newLength / oldLength );
+				this.divideScalar( oldLength ).multiplyScalar( newLength );
 
 			}
 

+ 1 - 1
src/math/Vector3.js

@@ -532,7 +532,7 @@ THREE.Vector3.prototype = {
 
 			if ( newLength !== oldLength ) {
 
-				this.multiplyScalar( newLength / oldLength );
+				this.divideScalar( oldLength ).multiplyScalar( newLength );
 
 			}