diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 9cd4a5486b20e2..4aad71c50e3df3 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -589,13 +589,17 @@ class Object3D extends EventDispatcher { if ( this.matrixWorldNeedsUpdate || force ) { - if ( this.parent === null ) { + if ( this.matrixWorldAutoUpdate === true ) { - this.matrixWorld.copy( this.matrix ); + if ( this.parent === null ) { - } else { + this.matrixWorld.copy( this.matrix ); - this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } } @@ -605,7 +609,7 @@ class Object3D extends EventDispatcher { } - // update children + // make sure descendants are updated if required const children = this.children; @@ -613,11 +617,7 @@ class Object3D extends EventDispatcher { const child = children[ i ]; - if ( child.matrixWorldAutoUpdate === true || force === true ) { - - child.updateMatrixWorld( force ); - - } + child.updateMatrixWorld( force ); } @@ -627,7 +627,7 @@ class Object3D extends EventDispatcher { const parent = this.parent; - if ( updateParents === true && parent !== null && parent.matrixWorldAutoUpdate === true ) { + if ( updateParents === true && parent !== null ) { parent.updateWorldMatrix( true, false ); @@ -635,17 +635,21 @@ class Object3D extends EventDispatcher { if ( this.matrixAutoUpdate ) this.updateMatrix(); - if ( this.parent === null ) { + if ( this.matrixWorldAutoUpdate === true ) { - this.matrixWorld.copy( this.matrix ); + if ( this.parent === null ) { - } else { + this.matrixWorld.copy( this.matrix ); - this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } } - // update children + // make sure descendants are updated if ( updateChildren === true ) { @@ -655,11 +659,7 @@ class Object3D extends EventDispatcher { const child = children[ i ]; - if ( child.matrixWorldAutoUpdate === true ) { - - child.updateWorldMatrix( false, true ); - - } + child.updateWorldMatrix( false, true ); } diff --git a/test/unit/src/core/Object3D.tests.js b/test/unit/src/core/Object3D.tests.js index 38261bde43412c..3527cc2bb8510b 100644 --- a/test/unit/src/core/Object3D.tests.js +++ b/test/unit/src/core/Object3D.tests.js @@ -987,8 +987,10 @@ export default QUnit.module( 'Core', () => { parent.position.set( 3, 2, 1 ); parent.updateMatrix(); - parent.matrixWorldNeedsUpdate = false; + parent.matrixAutoUpdate = true; + child.matrixAutoUpdate = true; + parent.matrixWorldNeedsUpdate = true; child.matrixWorldAutoUpdate = false; parent.updateMatrixWorld(); @@ -1004,7 +1006,6 @@ export default QUnit.module( 'Core', () => { child.position.set( 0, 0, 0 ); parent.position.set( 1, 2, 3 ); child.matrixWorldAutoUpdate = true; - parent.matrixAutoUpdate = true; parent.updateMatrixWorld(); assert.deepEqual( child.matrixWorld.elements, [ @@ -1237,7 +1238,7 @@ export default QUnit.module( 'Core', () => { child.matrixWorld.identity(); parent.matrixWorld.identity(); - object.updateWorldMatrix( true, true ); + child.updateWorldMatrix( true, true ); assert.deepEqual( child.matrixWorld.elements, m.identity().elements,