diff --git a/src/math/Quaternion.js b/src/math/Quaternion.js index af433777f10092ed15d45ef78af2eeedd074fbf9..27e1ffedaf0a6b75fe907ed2b9a3ecad9a783113 100644 --- a/src/math/Quaternion.js +++ b/src/math/Quaternion.js @@ -349,54 +349,48 @@ Object.assign( Quaternion.prototype, { }, - setFromUnitVectors: function () { + setFromUnitVectors: function ( vFrom, vTo ) { // assumes direction vectors vFrom and vTo are normalized - var r; - var EPS = 0.000001; - return function setFromUnitVectors( vFrom, vTo ) { - - r = vFrom.dot( vTo ) + 1; - - if ( r < EPS ) { - - r = 0; + var r = vFrom.dot( vTo ) + 1; - if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { + if ( r < EPS ) { - this._x = - vFrom.y; - this._y = vFrom.x; - this._z = 0; - this._w = r; + r = 0; - } else { + if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { - this._x = 0; - this._y = - vFrom.z; - this._z = vFrom.y; - this._w = r; - - } + this._x = - vFrom.y; + this._y = vFrom.x; + this._z = 0; + this._w = r; } else { - // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 - - this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; - this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; - this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; + this._x = 0; + this._y = - vFrom.z; + this._z = vFrom.y; this._w = r; } - return this.normalize(); + } else { - }; + // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 - }(), + this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; + this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; + this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; + this._w = r; + + } + + return this.normalize(); + + }, angleTo: function ( q ) {