ParticleEmitter
Pooled 2D particles.
ts
import { ParticleEmitter, EmitterConfig, Range } from "willow";ParticleEmitter
ts
class ParticleEmitter extends NodeExtends Node.
Particle emitter node managing a pool of simulated 2D particles.
ParticleEmitter: constructors
ts
new ParticleEmitter(name?: string, config?: EmitterConfig)Constructs a new particle emitter node with optional name and config.
ParticleEmitter: properties
| Member | Description |
|---|---|
config: EmitterConfig | Emitter configuration controlling particle spawning and physics. |
readonly particleCount: int | Current number of active particles alive in the simulation. |
readonly aliveCount: int | Alias for particleCount. Current number of active alive particles. |
readonly active: boolean | Whether the emitter is currently active and spawning particles. |
seed: int | Deterministic RNG seed state for particle variations. |
ParticleEmitter: methods
| Member | Description |
|---|---|
start(): void | Begins emitting particles according to the emitter config rate. |
stop(): void | Stops emitting new particles; live particles continue until death. |
reset(): void | Stops emission and immediately clears all active particles. |
burst(count: int): void | Spawns a burst of particles immediately. |
update(dt: float): void | Advances particle simulation and quad rendering by dt seconds. |
setSeed(seed: int): void | Sets the random seed for reproducible particle variation. |
bounds(): Rect | Axis-aligned bounding box covering all currently alive particles. |
ParticleEmitter: static methods
| Member | Description |
|---|---|
static create(name: string, config: EmitterConfig): ParticleEmitter | Factory creating a new particle emitter node. |
EmitterConfig
ts
class EmitterConfigConfiguration options for particle emitter simulation and visuals.
EmitterConfig: constructors
ts
new EmitterConfig()Constructs an EmitterConfig with default settings.
EmitterConfig: properties
| Member | Description |
|---|---|
maxParticles: int | Maximum pool size of concurrent particles. Defaults to 128. |
emitRate: float | Emission rate in particles spawned per second. Defaults to 10.0. |
lifetime: Range | Lifetime range of spawned particles in seconds. |
lifetimeMin: float | Minimum particle lifetime in seconds. Defaults to 1.0. |
lifetimeMax: float | Maximum particle lifetime in seconds. Defaults to 1.0. |
speed: Range | Initial particle speed range in pixels per second. |
speedMin: float | Minimum initial speed in pixels per second. Defaults to 50.0. |
speedMax: float | Maximum initial speed in pixels per second. Defaults to 50.0. |
angle: Range | Emission angle range in radians. Defaults to full circle [0, 2*PI]. |
angleMin: float | Minimum emission angle in radians. Defaults to 0.0. |
angleMax: float | Maximum emission angle in radians. Defaults to 2*PI. |
gravityX: float | Constant horizontal acceleration applied to particles. Defaults to 0.0. |
gravityY: float | Constant vertical acceleration applied to particles. Defaults to 0.0. |
startScale: float | Scale factor at particle birth. Defaults to 1.0. |
endScale: float | Scale factor at particle death. Defaults to 1.0. |
scaleStart: float | Alias for startScale. Scale factor at particle birth. Defaults to 1.0. |
scaleEnd: float | Alias for endScale. Scale factor at particle death. Defaults to 1.0. |
startAlpha: float | Alpha multiplier at particle birth. Defaults to 1.0. |
endAlpha: float | Alpha multiplier at particle death. Defaults to 0.0. |
alphaStart: float | Alias for startAlpha. Alpha multiplier at particle birth. Defaults to 1.0. |
alphaEnd: float | Alias for endAlpha. Alpha multiplier at particle death. Defaults to 0.0. |
startColor: Color | Tint color at particle birth. Defaults to white. |
endColor: Color | Tint color at particle death. Defaults to white. |
colorStart: Color | Alias for startColor. Tint color at particle birth. |
colorEnd: Color | Alias for endColor. Tint color at particle death. |
blendMode: string | Compositor blend mode for particles. Defaults to "add". |
worldSpace: boolean | When true, emitted particles remain in world space rather than following node. Defaults to false. |
Range
ts
class RangeA min/max range of numbers. EmitterConfig uses it for lifetime, speed and angle.
Range: constructors
ts
new Range(min: float, max: float)Range: properties
| Member | Description |
|---|---|
min: float | Lower bound, inclusive. |
max: float | Upper bound, inclusive. |
Range: methods
| Member | Description |
|---|---|
random(): float | A uniformly-distributed random value in [min, max]. Returns min when min === max. |