From e6f7d2ac79020197fba79d99048ccbfd27c1e02f Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Wed, 14 Oct 2015 16:24:43 +0200 Subject: [PATCH] avoid unnecessary Math.sqrt operations --- src/math/Matrix4.js | 4 ++-- src/math/Vector3.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index ab6d63f3be..7fad9b70d5 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -341,7 +341,7 @@ THREE.Matrix4.prototype = { z.subVectors( eye, target ).normalize(); - if ( z.length() === 0 ) { + if ( z.lengthSq() === 0 ) { z.z = 1; @@ -349,7 +349,7 @@ THREE.Matrix4.prototype = { x.crossVectors( up, z ).normalize(); - if ( x.length() === 0 ) { + if ( x.lengthSq() === 0 ) { z.x += 0.0001; x.crossVectors( up, z ).normalize(); diff --git a/src/math/Vector3.js b/src/math/Vector3.js index 2c430ad52e..d53f32ed4a 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -701,7 +701,7 @@ THREE.Vector3.prototype = { angleTo: function ( v ) { - var theta = this.dot( v ) / ( this.length() * v.length() ); + var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) ); // clamp, to handle numerical problems -- GitLab