Hi,
I’m new to p5.js and WebGL, so I’m not sure if I’m using the right terminology.
Let’s start with the problem:
We’re currently displaying a map of objects (simple rectangles with text in them, plus some single lines). Unfortunately, the number elements can go up to 25,000, probably even more, which completely crushes the performance.
At the moment, we do all the draw calls in the draw() function, which I assume, is the main problem. In an older version, there’s a manual check, if an object is visible, which helps a little, but the performance is still quite bad. And, depending on the zoom level, there’s still quite a lot of objects to render, even with the visibility check.
Since we’re talking WebGL here, my gut feeling is, that doing all the draw calls in JavaScript in not the correct way to approach this. So, my question is, is it possible to throw the objects at the GPU once and let it do all the rendering? The positioning is static, so we really only need to move around the camera (and maybe do a re-render of the text inside the rectangles, once the zoom level changes).
I also had the approach to render a layer in setup() and use that one for scrolling around, this worked really fine, but only to a certain zoom level and then the image starts to become blurry. My guess would be, that there’s an upper limit to the bitmap size of createGraphics(), so the created bitmap does not match the image size I’m displaying. It’s also cut off at the end, that would match my assumption, that I exceeded the max image size.
Thanks in advance