Browse Source

Merge pull request #16039 from WestLangley/dev-closure

Quaternion: Remove unneeded closure
Mr.doob 6 years ago
parent
commit
bb3a5787fe
1 changed files with 24 additions and 30 deletions
  1. 24 30
      src/math/Quaternion.js

+ 24 - 30
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
 		// assumes direction vectors vFrom and vTo are normalized
 
 
-		var r;
-
 		var EPS = 0.000001;
 		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 {
 			} 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;
 				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 ) {
 	angleTo: function ( q ) {