diff --git a/src/scene/immediate/immediate-batch.js b/src/scene/immediate/immediate-batch.js index e0bed82aac4..26113dbdefd 100644 --- a/src/scene/immediate/immediate-batch.js +++ b/src/scene/immediate/immediate-batch.js @@ -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 }; diff --git a/src/scene/immediate/immediate-batches.js b/src/scene/immediate/immediate-batches.js index e564c821855..cd6e3716af8 100644 --- a/src/scene/immediate/immediate-batches.js +++ b/src/scene/immediate/immediate-batches.js @@ -23,6 +23,10 @@ class ImmediateBatches { batch.onPreRender(visibleList, transparent); }); } + + clear() { + this.map.forEach(batch => batch.clear()); + } } export { ImmediateBatches }; diff --git a/src/scene/immediate/immediate.js b/src/scene/immediate/immediate.js index d2d9ee559ac..5203ffc8c7c 100644 --- a/src/scene/immediate/immediate.js +++ b/src/scene/immediate/immediate.js @@ -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