Renderer · interface

InstanceData

One base mesh drawn many times in a single call.

Explained in Hello world.

interface InstanceData
import 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

NameTypeDescription
positionsreadonlyFloat32Array3 floats each: world position.
scaleAndYawreadonlyFloat32Array2 floats each: uniform scale, then yaw in radians.
tintsreadonlyFloat32Array3 floats each: multiplied into the base mesh's colour.
windResponsereadonlyFloat32Array3 floats each: how far this instance bends, how much the gust moves it, and a phase offset.
More

Per 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.

capacityreadonlynumber
countnumberHow many instances are live; the rest of the buffer is ignored.