Sfoglia il codice sorgente

use divideScalar to avoid zero division

Mugen87 10 anni fa
parent
commit
57902f1bb7
2 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  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 );
 
 			}
 

粤ICP备19079148号