Renderer · interface
ParticleInstances
A pool's per-particle stream, as a particle material reads it.
Explained in Hello world.
interface ParticleInstancesimport type { ParticleInstances } from '@driftengine/core';In depth
Separate from InstanceData — which is a scatter stream, built for placing
thousands of static plants — because the two want different things and sharing
one of them cost this engine its whole particle look. A blade of grass needs a
yaw and a wind response and is opaque; a puff of smoke needs an age, a
seed and an opacity, and has no wind of its own because its velocity
already carries it.
Lacking those three, the scatter path had to fake the one that matters: a particle "faded" by having its colour multiplied toward black, which is a real fade only if the material is additive. Drawn through the opaque foliage shader it is not a fade at all — it is a grain turning into a black cube — and that, rather than any tuning, is why every effect built on this read as raw.
Properties
| Name | Type | Description |
|---|---|---|
positions | Float32Array | World position, three floats each. |
sizes | Float32Array | Metres from the centre to an edge, a half-width: the quad spans twice this. Then radians of roll about the particle's own axis. This said metres across until 4.8.3, and a caller who took it at its word drew every particle twice as wide as meant. |
spins | Float32Array | |
colors | Float32Array | Linear colour, three floats each. |
alphas | Float32Array | Opacity, 0 to 1 — a real one, not a colour standing in for it. |
ages | Float32Array | Age as a share of this particle's own life, for anything that evolves. |
seeds | Float32Array | Per-particle randomness, so neighbours never animate together. |
velocities | Float32Array | Current velocity, three floats each: what a streak is stretched along. |
framesoptional | Float32Array | A sprite's flipbook frame, one float each: its whole part names a cell of the image, counted
across then down from the top-left, and its fraction is how far toward the next a batch that
blends cells has come. Read by the 'sprite' material alone. Absent is frame 0. |
heightsoptional | Float32Array | A sprite's half-height in metres, one float each, beside sizes' half-width — a sprite need
not be square. Read by the 'sprite' material alone; absent or 0 is as tall as it is wide. |
count | number | |
capacity | number |