dynamicBufferAttribute
Creates a dedicated, high-performance channel for efficiently sending frequently changing per-vertex data (like particle positions or water displacement) from the CPU (JavaScript) to the GPU shader.
Core Advantages
Its core advantage is performance. By signaling `DynamicDrawUsage` to the GPU, it uses the most suitable memory strategy for frequent updates, making it the standard and most efficient way to implement CPU-driven vertex animations like physics simulations or procedural deformations.
Common Uses
CPU-driven particle systems (updating position, color)
Procedural geometry deformation (e.g., water ripples, waving flags)
Real-time data visualization (e.g., audio visualizers)
Interactive vertex editing (e.g., 3D sculpting tools)
How to adjust
Adjustments are made by modifying its backing array in a JavaScript animation loop and setting `.needsUpdate = true`. For instance, on a plane, a JS loop can calculate a sine wave ripple that spreads over time and write it to the array. The shader then reads this data as a vertex height offset, resulting in a vivid water ripple effect spreading from the center, entirely driven by the CPU-side calculations.
Code Examples
1// In the vertex shader, apply the dynamic offset calculated on the CPU.
2// The source of rippleOffset is a dynamicBufferAttribute updated every frame in JS.
3position.y = position.y.add( rippleOffset );