[SOLVED] Drawling many lines with drawLineArrays

I have a question to about using drawLineArrays. I have a somewhat large amount of vertices I want to draw to represent the physics state - 200-250k vertices. In order to improve the rendering speed, instead of using drawLine, I gather all the vertices into position and color arrays, then draw them in the postUpdate method.

This fails though with some cryptic error about maximum call stack. I assumed that I simply exceeded the vertex buffer size. I then broke them into smaller buffers, to make sure not to exceed 64k vertices each. This helped with getting rid of the initial error, but the app still crashed, due to buffer size mismatch.

The way I render them, is simply by passing the first array to drawLineArrays, then the second, until no arrays left to draw. I assume that the issue might be that the current API doesn’t support multiple calls to drawLineArrays in the same frame, changing the buffer size?

@mvaligursky would you have any recommendation?

If it helps, it doesn’t complain about positions, but only about COLORS. If I disable colors, no errors appear, but also no lines are visible, of course. Both arrays are populated at the same time, though, and have the same size:

That was unexpected. The fix: https://github.com/playcanvas/engine/pull/4173 :slight_smile:


That was quick! Thank you, @mvaligursky !