Skip to content

Commit 57902f1

Browse files
committed
use divideScalar to avoid zero division
1 parent 4eccb8f commit 57902f1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/math/Vector2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ THREE.Vector2.prototype = {
302302

303303
if ( newLength !== oldLength ) {
304304

305-
this.multiplyScalar( newLength / oldLength );
305+
this.divideScalar( oldLength ).multiplyScalar( newLength );
306306

307307
}
308308

src/math/Vector3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ THREE.Vector3.prototype = {
532532

533533
if ( newLength !== oldLength ) {
534534

535-
this.multiplyScalar( newLength / oldLength );
535+
this.divideScalar( oldLength ).multiplyScalar( newLength );
536536

537537
}
538538

0 commit comments

Comments
 (0)