Browse Source

Merge pull request #17244 from JohannesDeml/object3d-temp-variable-init-regression-fix

Fix Object3D variable instantiation regression bug
Michael Herzog 6 years ago
parent
commit
9c9ed7fd89
2 changed files with 30 additions and 1 deletions
  1. 1 1
      src/core/Object3D.js
  2. 29 0
      test/unit/src/core/Object3D.tests.js

+ 1 - 1
src/core/Object3D.js

@@ -277,7 +277,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		// This method does not support objects having non-uniformly-scaled parent(s)
 
-		if ( _position === undefined ) {
+		if ( _target === undefined ) {
 
 			_q1 = new Quaternion();
 			_m1 = new Matrix4();

+ 29 - 0
test/unit/src/core/Object3D.tests.js

@@ -416,6 +416,35 @@ export default QUnit.module( 'Core', () => {
 
 		} );
 
+		QUnit.test( "localTransformVariableInstantiation", ( assert ) => {
+
+			var a = new Object3D();
+			var b = new Object3D();
+			var c = new Object3D();
+			var d = new Object3D();
+
+			a.getWorldDirection( new Vector3() );
+			a.lookAt( new Vector3( 0, - 1, 1 ) );
+
+			assert.ok( true, "Calling lookAt after getWorldDirection does not create errors" );
+
+			b.getWorldPosition( new Vector3() );
+			b.lookAt( new Vector3( 0, - 1, 1 ) );
+
+			assert.ok( true, "Calling lookAt after getWorldPosition does not create errors" );
+
+			c.getWorldQuaternion( new Quaternion() );
+			c.lookAt( new Vector3( 0, - 1, 1 ) );
+
+			assert.ok( true, "Calling lookAt after getWorldQuaternion does not create errors" );
+
+			d.getWorldScale( new Vector3() );
+			d.lookAt( new Vector3( 0, - 1, 1 ) );
+
+			assert.ok( true, "Calling lookAt after getWorldScale does not create errors" );
+
+		} );
+
 		QUnit.todo( "raycast", ( assert ) => {
 
 			assert.ok( false, "everything's gonna be alright" );