Renderer · interface
InstanceData
One base mesh drawn many times in a single call.
Explained in Hello world.
interface InstanceDataimport type { InstanceData } from '@driftengine/core';In depth
A field of grass is tens of thousands of copies of the same few triangles. Submitted individually that is tens of thousands of draw calls, which is the one thing a browser renderer cannot absorb; as instances it is one call and the GPU does the rest. This is what makes "dress the world" affordable at all.
Per-instance attributes advance once per instance rather than once per vertex
(vertexAttribDivisor), so the base mesh is uploaded once and never again.
Properties
| Name | Type | Description |
|---|---|---|
positionsreadonly | Float32Array | 3 floats each: world position. |
scaleAndYawreadonly | Float32Array | 2 floats each: uniform scale, then yaw in radians. |
tintsreadonly | Float32Array | 3 floats each: multiplied into the base mesh's colour. |
windResponsereadonly | Float32Array | 3 floats each: how far this instance bends, how much the gust moves it,
and a phase offset.MorePer instance rather than global so a field does not sway in lockstep — uniform motion is the single clearest sign that foliage is a texture with an animation on it rather than many separate plants. |
capacityreadonly | number | |
count | number | How many instances are live; the rest of the buffer is ignored. |