three.js icon indicating copy to clipboard operation
three.js copied to clipboard

BatchedMesh: `bufferSubData` causes lag

Open marwie opened this issue 11 months ago • 5 comments

Description

Hi, I'm currently stress testing with 20 instances and ~300.000 vertices each. We have LODs generated and I reserve the vertex space of LOD 0 for each instance so the float32 buffer ends up being ~ 9.000.000

When LODs switch and setGeometry is called i noticed quite a few big lags which seem to be coming from the call to bufferSubData with the whole buffer.

My question is if this is currently expected or if I might be doing something wrong here.

image

image

Solution

I would hope this could be optimized by providing the ranges array and the batched mesh could keep track of which ranges have changed. Could this be a possible improvement?

Alternatives

Clamp the max size of a BatchedMesh (on my side)

Additional context

https://mastodon.gamedev.place/@marwi/112145459503913620

marwie avatar Mar 23 '24 14:03 marwie