Skip to content

Commit 071418a

Browse files
committed
Merge pull request mrdoob#7343 from Mugen87/sqrt
Avoid unnecessary Math.sqrt operations
2 parents 91d7c95 + e6f7d2a commit 071418a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/math/Matrix4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,15 @@ THREE.Matrix4.prototype = {
341341

342342
z.subVectors( eye, target ).normalize();
343343

344-
if ( z.length() === 0 ) {
344+
if ( z.lengthSq() === 0 ) {
345345

346346
z.z = 1;
347347

348348
}
349349

350350
x.crossVectors( up, z ).normalize();
351351

352-
if ( x.length() === 0 ) {
352+
if ( x.lengthSq() === 0 ) {
353353

354354
z.x += 0.0001;
355355
x.crossVectors( up, z ).normalize();

src/math/Vector3.js

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

702702
angleTo: function ( v ) {
703703

704-
var theta = this.dot( v ) / ( this.length() * v.length() );
704+
var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
705705

706706
// clamp, to handle numerical problems
707707

0 commit comments

Comments
 (0)