Skip to content

Commit

Permalink
fix: Move marking the outOfBound render state to the end of the updat…
Browse files Browse the repository at this point in the history
…e loop
  • Loading branch information
wouterlucas committed Sep 13, 2024
1 parent f6d278c commit 6e388ed
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ export class CoreNode extends EventEmitter {
}

const parent = this.props.parent;
let renderState = null;

if (this.updateType & UpdateType.ParentRenderTexture) {
let p = this.parent;
Expand Down Expand Up @@ -1015,8 +1016,15 @@ export class CoreNode extends EventEmitter {
}

if (this.updateType & UpdateType.RenderState) {
this.updateRenderState();
renderState = this.checkRenderBounds();
this.setUpdateType(UpdateType.IsRenderable);

// if we're not going out of bounds, update the render state
// this is done so the update loop can finish before we mark a node
// as out of bounds
if (renderState !== CoreNodeRenderState.OutOfBounds) {
this.updateRenderState(renderState);
}
}

if (this.updateType & UpdateType.IsRenderable) {
Expand Down Expand Up @@ -1120,6 +1128,13 @@ export class CoreNode extends EventEmitter {
this.sortChildren();
}

// If we're out of bounds, apply the render state now
// this is done so nodes can finish their entire update loop before
// being marked as out of bounds
if (renderState === CoreNodeRenderState.OutOfBounds) {
this.updateRenderState(renderState);
}

// reset update type
this.updateType = 0;
this.childUpdateType = 0;
Expand Down Expand Up @@ -1287,9 +1302,7 @@ export class CoreNode extends EventEmitter {
this.preloadBound = this.createPreloadBounds(this.strictBound);
}

updateRenderState() {
const renderState = this.checkRenderBounds();

updateRenderState(renderState: CoreNodeRenderState) {
if (renderState === this.renderState) {
return;
}
Expand Down

0 comments on commit 6e388ed

Please sign in to comment.