Renderer · class

BoltPool

Explained in Hello world.

class BoltPool
import { BoltPool } from '@driftengine/core';

Constructor

new

constructor(options: BoltPoolOptions)
ParameterTypeDescription
optionsBoltPoolOptions

Properties

NameTypeDescription
segmentsreadonlyBoltSegments

Accessors

NameTypeDescription
livegetnumberHow many arcs are alive.

Methods

strike

strike(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, seed: number, brightness?: number, /** * Multiplier on the pool's lifetime for this arc alone. * * A volley of arcs that all die on the same frame reads as one object being * switched off, which is the most predictable thing a flash can do. Varying it * per strike is the cheapest way to make a burst decay like several discharges. */ lifeScale?: number): void

Strike an arc between two points.

ParameterTypeDescription
x0number
y0number
z0number
x1number
y1number
z1number
seednumber
brightness?number
/** * Multiplier on the pool's lifetime for this arc alone. * * A volley of arcs that all die on the same frame reads as one object being * switched off
which is the most predictable thing a flash can do. Varying it * per strike is the cheapest way to make a burst decay like several discharges. */ lifeScale?: number
More

seed drives the path instead of Math.random, so a caller inside a deterministic system can pass a tick count and get the same lightning twice.

update

update(dt: number): void

Age every arc, re-strike the ones whose path is due, and rebuild the segment arrays.

ParameterTypeDescription
dtnumber
More

Compacting as it goes, like the particle pool: live segments are written to the front, so a draw submits exactly the live count and a dead arc costs one loop iteration.

clear

clear(): void

Drop everything, for a respawn or a scene change.