Skip to content

Commit 3af4d2f

Browse files
committed
use glText[0].regl to clear viewport during selection when mode: 'text'
1 parent 9f3827c commit 3af4d2f

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

src/traces/scattergl/index.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,6 @@ function sceneUpdate(gd, subplot) {
273273
// traces in no-selection mode
274274
scene.scatter2d.draw(i);
275275
}
276-
if(scene.glText[i] && scene.textOptions[i]) {
277-
scene.glText[i].render();
278-
}
279276
}
280277

281278
// draw traces in selection mode
@@ -284,6 +281,12 @@ function sceneUpdate(gd, subplot) {
284281
scene.scatter2d.draw(scene.unselectBatch);
285282
}
286283

284+
for(i = 0; i < scene.count; i++) {
285+
if(scene.glText[i] && scene.textOptions[i]) {
286+
scene.glText[i].render();
287+
}
288+
}
289+
287290
scene.dirty = false;
288291
};
289292

@@ -301,24 +304,13 @@ function sceneUpdate(gd, subplot) {
301304
(height - vpSize.t) - (1 - yaxis.domain[1]) * vpSize.h
302305
];
303306

304-
var gl, regl;
305-
306307
if(scene.select2d) {
307-
regl = scene.select2d.regl;
308-
gl = regl._gl;
309-
gl.enable(gl.SCISSOR_TEST);
310-
gl.scissor(vp[0], vp[1], vp[2] - vp[0], vp[3] - vp[1]);
311-
gl.clearColor(0, 0, 0, 0);
312-
gl.clear(gl.COLOR_BUFFER_BIT);
308+
clearViewport(scene.select2d, vp);
313309
}
314-
315310
if(scene.scatter2d) {
316-
regl = scene.scatter2d.regl;
317-
gl = regl._gl;
318-
gl.enable(gl.SCISSOR_TEST);
319-
gl.scissor(vp[0], vp[1], vp[2] - vp[0], vp[3] - vp[1]);
320-
gl.clearColor(0, 0, 0, 0);
321-
gl.clear(gl.COLOR_BUFFER_BIT);
311+
clearViewport(scene.scatter2d, vp);
312+
} else if(scene.glText) {
313+
clearViewport(scene.glText[0], vp);
322314
}
323315
};
324316

@@ -361,6 +353,13 @@ function sceneUpdate(gd, subplot) {
361353
return scene;
362354
}
363355

356+
function clearViewport(comp, vp) {
357+
var gl = comp.regl._gl;
358+
gl.enable(gl.SCISSOR_TEST);
359+
gl.scissor(vp[0], vp[1], vp[2] - vp[0], vp[3] - vp[1]);
360+
gl.clearColor(0, 0, 0, 0);
361+
gl.clear(gl.COLOR_BUFFER_BIT);
362+
}
364363

365364
function plot(gd, subplot, cdata) {
366365
if(!cdata.length) return;

0 commit comments

Comments
 (0)