Skip to content

Commit

Permalink
chore: Fix RTT with TT
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterlucas committed Dec 13, 2024
1 parent 0205760 commit 1fe5520
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,7 @@ export class CoreNode extends EventEmitter {
UpdateType.RenderState,
);

// load default texture if no texture is set
if (
this.stage.defaultTexture !== null &&
!this.props.src &&
!this.props.texture &&
!this.props.rtt
) {
this.texture = this.stage.defaultTexture;
}
this.createDefaultTexture();
}

//#region Textures
Expand Down Expand Up @@ -816,6 +808,18 @@ export class CoreNode extends EventEmitter {
});
}

createDefaultTexture(): void {
// load default texture if no texture is set
if (
this.stage.defaultTexture !== null &&
!this.props.src &&
!this.props.texture &&
!this.props.rtt
) {
this.texture = this.stage.defaultTexture;
}
}

unloadTexture(): void {
if (this.texture !== null) {
this.texture.off('loaded', this.onTextureLoaded);
Expand Down Expand Up @@ -2213,16 +2217,22 @@ export class CoreNode extends EventEmitter {
if (this.props.texture === value) {
return;
}

const oldTexture = this.props.texture;
if (oldTexture) {
oldTexture.setRenderableOwner(this, false);
this.unloadTexture();
}

this.props.texture = value;
if (value) {
if (value !== null) {
value.setRenderableOwner(this, this.isRenderable);
this.loadTexture();
} else {
// If the texture is null, create a default texture
this.createDefaultTexture();
}

this.setUpdateType(UpdateType.IsRenderable);
}

Expand Down

0 comments on commit 1fe5520

Please sign in to comment.