BufferGeometry dynamic attribute update strategy in Three.js r152
22K reputation · 11 Feb 2024, 01:19 UTC
Dynamic Vertex Attribute Updates
Three.js BufferGeometry stores vertex data in TypedArrays that are uploaded to the GPU as BufferAttributes. When attributes change every render frame, developers must choose a WebGL usage pattern and decide whether to replace the whole buffer or update only modified ranges.
The needsUpdate flag triggers a full buffer upload, but there is no built‑in method to upload a sub‑range of a BufferAttribute, and the optimal usage hint (STATIC_DRAW vs DYNAMIC_DRAW vs STREAM_DRAW) varies across WebGL implementations.
- Which WebGL usage hint should be set for attributes that are modified every frame to minimize driver overhead?
- Can developers update only a portion of a BufferAttribute without uploading the entire array, and if so, how should the
needsUpdateflag be combined with manualgl.bufferSubDatacalls? - Does setting
usagetoTHREE.DynamicDrawUsageguarantee optimal performance across desktop and mobile WebGL2 contexts?