From the docs:
With regards to updating BufferGeometries, the most important thing to understand is that you cannot resize buffers (this is very costly, basically the equivalent to creating a new geometry). You can however update the content of buffers
Let’s say I pre-allocate an array with size of 1000 (using instancing):
geometry.addAttribute( 'myAttribute', new InstancedBufferAttribute(new Float32Array(1000), 3).setDynamic(true));
- What do i do if I need more than 1000? I don’t know prehand how much is the maximum i’ll need.
- Performance wise - is it better to pre-allocate let’s say 10,000 and re-allocate (how?) later, thus potentially wasting memory but if that’s a good guess than never re-allocate again?
All the examples use a fixed maximum but there is nothing saying how to resize it (even with the cost).