Browse Source

Fix variable instantiation problem

Occurs when calling lookAt after getWorldQuaternion
Johannes Deml 6 years ago
parent
commit
3bbbab7ff4
1 changed files with 9 additions and 16 deletions
  1. 9 16
      src/core/Object3D.js

+ 9 - 16
src/core/Object3D.js

@@ -277,14 +277,13 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 
 		// This method does not support objects having non-uniformly-scaled parent(s)
 		// This method does not support objects having non-uniformly-scaled parent(s)
 
 
-		if ( _position === undefined ) {
+		if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
-			_q1 = new Quaternion();
-			_m1 = new Matrix4();
-			_target = new Vector3();
-			_position = new Vector3();
+		if ( _m1 === undefined ) _m1 = new Matrix4();
 
 
-		}
+		if ( _target === undefined ) _target = new Vector3();
+
+		if ( _position === undefined ) _position = new Vector3();
 
 
 		if ( x.isVector3 ) {
 		if ( x.isVector3 ) {
 
 
@@ -475,12 +474,9 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 
 	getWorldQuaternion: function ( target ) {
 	getWorldQuaternion: function ( target ) {
 
 
-		if ( _scale === undefined ) {
+		if ( _position === undefined ) _position = new Vector3();
 
 
-			_position = new Vector3();
-			_scale = new Vector3();
-
-		}
+		if ( _scale === undefined ) _scale = new Vector3();
 
 
 		if ( target === undefined ) {
 		if ( target === undefined ) {
 
 
@@ -499,12 +495,9 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 
 	getWorldScale: function ( target ) {
 	getWorldScale: function ( target ) {
 
 
-		if ( _quaternion === undefined ) {
-
-			_position = new Vector3();
-			_quaternion = new Quaternion();
+		if ( _position === undefined ) _position = new Vector3();
 
 
-		}
+		if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
 		if ( target === undefined ) {
 		if ( target === undefined ) {