Skip to content

Commit fae2734

Browse files
committed
Properly destroy textures before creating new ones
1 parent ab5e8a7 commit fae2734

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ const createScatterplot = (initialProperties = {}) => {
494494
let tmpColors = isMultipleColors(newColors) ? newColors : [newColors];
495495
tmpColors = tmpColors.map((color) => toRgba(color, true));
496496

497+
if (colorTex) colorTex.destroy();
498+
497499
try {
498500
setter(tmpColors);
499501
colorTex = createColorTexture();
@@ -570,6 +572,8 @@ const createScatterplot = (initialProperties = {}) => {
570572
if (!+newOpacity || +newOpacity <= 0) return;
571573

572574
opacity = +newOpacity;
575+
576+
if (colorTex) colorTex.destroy();
573577
colorTex = createColorTexture();
574578
};
575579

@@ -828,7 +832,9 @@ const createScatterplot = (initialProperties = {}) => {
828832

829833
numPoints = newPoints.length;
830834

835+
if (stateTex) stateTex.destroy();
831836
stateTex = createStateTexture(newPoints);
837+
832838
normalPointsIndexBuffer({
833839
usage: 'static',
834840
type: 'float',

0 commit comments

Comments
 (0)