diff --git a/src/core/CoreNode.ts b/src/core/CoreNode.ts index 814a9ec7..9fb59430 100644 --- a/src/core/CoreNode.ts +++ b/src/core/CoreNode.ts @@ -1312,12 +1312,19 @@ export class CoreNode extends EventEmitter { this.props.texture = null; this.props.shader = this.stage.defShaderCtr; + const children = [...this.children]; + for (let i = 0; i < children.length; i++) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + children[i]!.destroy(); + } + // This very action will also remove the node from the parent's children array + this.parent = null; + if (this.rtt) { this.stage.renderer.removeRTTNode(this); } this.removeAllListeners(); - this.parent = null; } renderQuads(renderer: CoreRenderer): void {