diff --git a/src/scene/container/Container.ts b/src/scene/container/Container.ts index 58393e099b..5a84c43d20 100644 --- a/src/scene/container/Container.ts +++ b/src/scene/container/Container.ts @@ -1328,6 +1328,9 @@ export class Container extends EventE if (this.destroyed) return; this.destroyed = true; + // remove children is faster than removeChild.. + const oldChildren = this.removeChildren(0, this.children.length); + this.removeFromParent(); this.parent = null; this._mask = null; @@ -1344,8 +1347,6 @@ export class Container extends EventE const destroyChildren = typeof options === 'boolean' ? options : options?.children; - const oldChildren = this.removeChildren(0, this.children.length); - if (destroyChildren) { for (let i = 0; i < oldChildren.length; ++i)