MothSwarm.component
README.md
MothSwarm
The sixteen moths orbiting the one live bulb over the ballroom, at (0, 11, 2). Shot 6 is where they are the subject; they are in the air from the ballroom on.
The component spawns nothing. demo.air's content() puts the moth bodies
under the entity this is attached to, and this moves them — so the number of
moths is the number of children, and adding one is adding a child.
What a moth does
Three motions layered, each a pure function of the clock and of the moth's own index:
- a slow orbit around the swarm centre, at
speedrevolutions a second scaled per moth; - a faster vertical bob over
risemetres, on its own phase and rate; - a stutter that occasionally throws the moth in at the light and back out.
The stutter is the one that matters. Without it sixteen bodies trace sixteen clean circles and read as an orbit diagram; with it they read as moths.
A small high-frequency flutter is laid over all three so nothing traces a clean path even between stutters.
Per-moth variation comes from an integer hash rather than from a seeded generator, so there is no random state to carry across a reload and two takes fly the same moths through the same air.
Fields
| field | what it is |
|---|---|
radius | half-extent of the orbit, in metres |
rise | half-extent of the vertical bob, in metres |
speed | revolutions a second, before the per-moth rate scale |
dart | how hard the stutter throws a moth at the light |
gain | master gain — 0 parks every moth at the centre and stops it moving |
ref:resetSwarm() puts the swarm back where it was at t = 0 and re-resolves the
children. demo.air.reset() calls it before a take.
Why it runs slower in the editor
Sixteen transform writes a frame feed the autosave dirty pipeline (OrigoZero/zero#5025) on a world several agents are authoring in at once. The swarm therefore flies at the film's own rate while a film is playing and at a twelfth of a second the rest of the time — still alive to look at, a fifth of the writes.
update runs in edit mode as well as in play (OrigoZero/zero#2743), so each
hook takes the mode that is not the other's and the swarm steps once a frame
whichever way that behaviour lands.
The bodies
Each moth is a small sphere wearing demo.air.moth, which is the
demo.air.glow shader: a body of light with no surface, additive, no depth
write. At 5.5 cm across and 3.2 glow intensity it reads as a lit speck against
the one bulb rather than as a ball with a highlight on it.