Renderer · interface
BoltPoolOptions
A pool of short-lived electrical arcs — lightning, and anything else that strikes between two points and crackles while it lasts.
Explained in Hello world.
interface BoltPoolOptionsimport type { BoltPoolOptions } from '@driftengine/core';In depth
The simulation half only, exactly like ParticlePool: this class holds no GL
resources, so it is testable without a context, and the drawing lives in
BoltBatch where the standing rule says WebGL belongs. What comes out is a
flat array of segment endpoints, which is the one thing a ribbon of quads
needs and the one thing a caller can check.
It advances rather than evaluates, so it is for real-time scenes only. update(dt) steps
an internal cursor, which means the same plan stepped by two different sequences of dt
produces different arcs. A consumer that renders one plan twice, once against a wall clock for
a preview and once against a frame index for an export, cannot make the two agree. Reported
from outside, alongside the observation that PlumeRenderer.draw has the signature that does
work: it takes the time to evaluate at rather than a step to advance by, so the same second
draws the same smoke however the frames were spaced. A stateless variant here is not built.
A bolt is a jagged polyline between its two ends, and the jaggedness is re-drawn while it lives rather than animated. That is what separates lightning from a wire: real arcs do not bend smoothly, they are replaced, many times a second, by a different path between the same two points. Interpolating node positions produces a wobbling snake, which reads as a rope or a tentacle; re-striking produces the crackle.
Displacement is mid-point subdivision, seeded, so a replay strikes the same
bolts the run did. Nothing here reads a clock or Math.random.
Properties
| Name | Type | Description |
|---|---|---|
capacity | number | How many arcs may be alive at once. |
nodes | number | Nodes per arc, both ends included. Must be 2^k + 1 so mid-point
subdivision lands exactly on it; anything else is rounded up to the next. |
lifeSec | number | Seconds an arc lives. |
jitter | number | How far a node may wander off the straight line, as a share of the span. |
restrikeHz | number | How many times a second a live arc re-draws its path. |