Documentation
    Preparing search index...

    Class ParticleEmitter

    A seeded, fixed-capacity CPU particle emitter. See the module documentation for the step order, the closed forms, the draw-order contract, and the determinism and allocation guarantees.

    Index
    • Validates and freezes the options into scalar fields, allocates the pool and the scratch vectors, and seeds the stream. This is the only allocating operation on the type.

      Parameters

      Returns ParticleEmitter

      RangeError on any out-of-domain option — see ParticleEmitterOptions for each field's domain. Options are checked eagerly because an emitter is authored once and stepped thousands of times: a NaN lifetime should fail where it was written, not as an invisible never-expiring particle ten seconds later.

    The storage this emitter drives. Read it to render, inspect, or checksum.

    random: SeededRandom

    This emitter's seeded stream (§33). Exposed for §34-style snapshotting via clone().

    • get alignToVelocity(): boolean

      Whether billboards rotate from velocity (atan2(vy, vx)).

      Returns boolean

    • get collisionPlaneY(): number | undefined

      Plane height for §36 MVP collision, or undefined when collision is off.

      Returns number | undefined

    • get droppedCount(): number

      Spawns that found the pool full and were discarded. A non-zero value means maxParticles is smaller than emissionRate × lifetime — the honest signal that the budget, not the authoring, is shaping the effect.

      Returns number

    • get elapsedTime(): number

      Emitter-local time in seconds: the sum of every deltaSeconds stepped so far.

      Returns number

    • get emissionAccumulator(): number

      Fractional remainder of the emission accumulator, in [0, 1).

      Returns number

    • get instanceFloats(): number

      Instance-stream stride this emitter's renderable must allocate — 8 by default, 10 when R-32 appearance is opted in.

      Returns number

    • get trailHeadWidth(): number

      Trail ribbon head width in world units, or -1 to use particle size.

      Returns number

    • Wires a simulation: "gpu" emitter to its device driver (module header, "GPU mode"; the contract and posture live on ParticleGpuSimulation).

      Binding is once: the driver owns device state this emitter's whole history flows into, and a mid-life swap would splice two unrelated device histories. A driver whose device died takes the particle state with it — build a new emitter (§34 posture).

      Parameters

      Returns void

      FourError INVALID_APPLICATION_STATE on a CPU-mode emitter, a second bind, or a driver whose capacity differs from the pool's.

    • Spawns up to count particles immediately, using the same draw order as automatic emission, and returns how many were actually created (the rest are counted as dropped).

      This is the §36 "burst" primitive exposed directly, for effects driven by game events rather than by the burst schedule.

      Parameters

      • count: number

      Returns number

      RangeError if count is not a non-negative safe integer.

    • Current colour of live particle index, including multi-stop ramps when configured. Writes straight RGBA into out; endpoints come from the pool.

      Parameters

      Returns Vector4

    • Current size of live particle index, including multi-stop ramps when configured. Endpoints come from the pool slot (spawn values).

      Parameters

      • index: number

      Returns number

    • Returns the emitter to its just-constructed state: pool emptied, stream rewound to its seed, elapsed time, accumulator, burst schedule, and counters zeroed. Stepping a reset emitter with the same deltas reproduces the original run bit for bit (§33, §34).

      Returns this

    • Advances the simulation by deltaSeconds (§7a: seconds), sampling force fields at absolute simulation time time.

      time defaults to ParticleEmitter.elapsedTime, which makes a standalone emitter self-consistent; the §39 loop passes the simulation clock instead. It is used only for field sampling — bursts and emission are scheduled on emitter-local elapsed time, so an emitter behaves the same whether it was created at simulation time 0 or 900.

      deltaSeconds === 0 is a legal no-op step: nothing moves, nothing ages, no burst window opens (the window [elapsed, elapsed) is empty) and the accumulator gains nothing.

      Parameters

      • deltaSeconds: number
      • time: number = ...

      Returns void

      RangeError if deltaSeconds is not a finite number >= 0, or if time is not finite. A negative step is rejected rather than run backwards: ageing backwards would resurrect nothing (the particle is already gone) and silently break the age invariant.