Skip to content

Commit

Permalink
Fix: Clean up lines for rendering even when the Layer is disabled (pl…
Browse files Browse the repository at this point in the history
…aycanvas#6353)

* Fix: Clean up lines for rendering even when the Layer is disabled

* Update src/scene/immediate/immediate-batch.js

Co-authored-by: Will Eastcott <will@playcanvas.com>

---------

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
Co-authored-by: Will Eastcott <will@playcanvas.com>
  • Loading branch information
3 people authored and slimbuck committed May 20, 2024
1 parent a0f48f4 commit 58a42d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/scene/immediate/immediate-batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ class ImmediateBatch {
this.meshInstance = new MeshInstance(this.mesh, this.material, identityGraphNode);
}

// clear lines when after they were rendered as their lifetime is one frame
this.positions.length = 0;
this.colors.length = 0;

// inject mesh instance into visible list to be rendered
visibleList.push(this.meshInstance);
}
}

clear() {
// clear lines after they are rendered as their lifetime is one frame
this.positions.length = 0;
this.colors.length = 0;
}
}

export { ImmediateBatch };
4 changes: 4 additions & 0 deletions src/scene/immediate/immediate-batches.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class ImmediateBatches {
batch.onPreRender(visibleList, transparent);
});
}

clear() {
this.map.forEach(batch => batch.clear());
}
}

export { ImmediateBatches };
1 change: 1 addition & 0 deletions src/scene/immediate/immediate.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class Immediate {
onPostRender() {

// clean up line batches
this.allBatches.forEach(batch => batch.clear());
this.allBatches.clear();

// all batches need updating next frame
Expand Down

0 comments on commit 58a42d6

Please sign in to comment.