Skip to content

Commit afac92b

Browse files
committed
add test, making sure we don't call vao.draw when vertexCount===0
1 parent 94fb8a4 commit afac92b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/jasmine/tests/gl3d_plot_interact_test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,33 @@ describe('Test gl3d plots', function() {
531531
.then(done);
532532
});
533533

534+
it('@gl should avoid passing empty lines to webgl', function(done) {
535+
var obj;
536+
537+
Plotly.plot(gd, [{
538+
type: 'scatter3d',
539+
mode: 'lines',
540+
x: [1],
541+
y: [2],
542+
z: [3]
543+
}])
544+
.then(function() {
545+
obj = gd._fullLayout.scene._scene.glplot.objects[0];
546+
spyOn(obj.vao, 'draw').and.callThrough();
547+
548+
expect(obj.vertexCount).toBe(0, '# of vertices');
549+
550+
return Plotly.restyle(gd, 'line.color', 'red');
551+
})
552+
.then(function() {
553+
expect(obj.vertexCount).toBe(0, '# of vertices');
554+
// calling this with no vertex causes WebGL warnings,
555+
// see https://github.com/plotly/plotly.js/issues/1976
556+
expect(obj.vao.draw).toHaveBeenCalledTimes(0);
557+
})
558+
.catch(failTest)
559+
.then(done);
560+
});
534561
});
535562

536563
describe('Test gl3d modebar handlers', function() {

0 commit comments

Comments
 (0)