Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

}

}

Expand All @@ -605,19 +609,15 @@ class Object3D extends EventDispatcher {

}

// update children
// make sure descendants are updated if required

const children = this.children;

for ( let i = 0, l = children.length; i < l; i ++ ) {

const child = children[ i ];

if ( child.matrixWorldAutoUpdate === true || force === true ) {

child.updateMatrixWorld( force );

}
child.updateMatrixWorld( force );

}

Expand All @@ -627,25 +627,29 @@ 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 );

}

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 ) {

Expand All @@ -655,11 +659,7 @@ class Object3D extends EventDispatcher {

const child = children[ i ];

if ( child.matrixWorldAutoUpdate === true ) {

child.updateWorldMatrix( false, true );

}
child.updateWorldMatrix( false, true );

}

Expand Down
7 changes: 4 additions & 3 deletions test/unit/src/core/Object3D.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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, [
Expand Down Expand Up @@ -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,
Expand Down