Buffergeometry, setDrawRange and performance

I want to be able to dynamically add particles to a scene, but I know that once you populate a buffergeometry with a given amount of vertices, that’s what you have to work with.

So, my idea is to create a buffergeometry for 40000 vertices, which means the array will have a length of 120000. Most of the time I’ll only want to render, say, 4000 particles, though, and my thinking is that I can have the cake and eat it, too, by using the setdrawrange method and set the range equal to 0 - 3999 particles in this hypothetical case.

Sounds too good, to be true, though… So how does having a buffer geometry for 4000 vertices with an array with a length of 12000 compare to the scenario I dreamt up above in terms of performance? Is it a big hit?

I think that’s the right approach. You’ll be allocating the full amount of memory, but cost of rendering will be “only what you need”. See the Shared BufferGeometry section here: https://blog.mozvr.com/a-painter-performance-optimizations/.


Awesome! Thanks.