Adding new vertices to geometry.attributes.position

I actually wanted to add new elements to the attribute buffer for positions in the animations loop, 1 element per second perhaps. The only way to add new elements to the array seemed to be replacing the array with a new one. Would that generate lots of objects to be GCed in this case? It would be nice to be able to append to the array.

The vertex buffer is uploaded to the GPU, and resizing it is unavoidably expensive at the WebGL API level. If you expect you’ll need to append new vertices often, it’s best to start with a larger buffer attribute to begin with, call geometry.setDrawRange(...) to limit how much of the buffer is drawn, and then expand the draw range as you write new vertices.

1 Like

that’s exactly what I ended doing and it seemed to work OK. Thanks for helping.

1 Like