The effect backends
Five kinds of thing an effect is made of, each behind one contract the runtime leases, re-seats and re-fires.
| Kind | What it is | What its spec carries |
|---|---|---|
emitter | A particle or mesh emitter | the particles.create spec |
geometry | Generated geometry the effect owns | mesh, material, transform |
material | A material applied to a mesh the caller already has | target, material, lanes |
decal | An oriented box projector stamped onto whatever it covers | material, opacity, position, rotation, size |
feature | A render feature held for the length of the play | identity, params |
geometry's transform takes either { position, rotation, scale } or the
ribbon form { from, to, width } — a strip stretched between two world points,
which is what a beam, a trail and a tether all are.
material records the mesh's own material before it stamps and puts it back
when the play ends.
feature writes its params into featureParams(identity), which the render
feature reads each frame. A render feature is compiled as its own chunk, so that
table is the channel between a play and the pass it drives; active says
whether any play currently holds it.
There is one entry per feature identity, so two plays through the same feature
share it: the newest one's parameters are what the pass reads, and active
stays true until the last of them lets go.
The contract
{
key(spec) -> string, -- the pool bucket; same key = interchangeable
acquire(spec) -> instance, -- the only member that allocates
seat(instance, spec), -- re-tune and re-position one the pool holds
start(instance), -- begin
stop(instance), -- stop producing; what is drawing finishes
quiet(instance), -- stop and remove now
place(instance, position), -- retarget
bytes(instance) -> number, -- GPU bytes it holds
active(instance) -> boolean, -- still drawing after it stopped producing
silence(instance) -> (reason?, detail?),
free(instance), -- reached only by an explicit drain
}
A family that needs a way of drawing this module does not ship registers one
with effects.registerBackend(kind, backend) rather than widening the runtime.
Scoped to this part · feeds back into the world's score.