nape-js API
    Preparing search index...

    Interface ParticleEmitterOptions

    Configuration options for ParticleEmitter.

    interface ParticleEmitterOptions {
        allowRotation?: boolean;
        bounds?: ParticleBounds;
        burstCount?: number;
        burstInterval?: number;
        enabled?: boolean;
        lifetimeMax?: number;
        lifetimeMin?: number;
        maxParticles?: number;
        onCollide?: (body: Body, other: Body) => void;
        onDeath?: (body: Body, reason: ParticleDeathReason) => void;
        onSpawn?: (state: ParticleSpawnState, body: Body) => void;
        onUpdate?: (body: Body, age: number, dt: number) => void;
        origin: Vec2 | Body;
        overflowPolicy?: ParticleOverflowPolicy;
        particleCbType?: CbType;
        particleFilter?: InteractionFilter;
        particleMaterial?: Material;
        particlePolygon?: Vec2[];
        particleRadius?: number;
        particleShape?: ParticleShape;
        random?: () => number;
        rate?: number;
        selfCollision?: boolean;
        space: Space;
        spawn?: SpawnPattern;
        velocity?: VelocityPattern;
    }
    Index

    Properties

    allowRotation?: boolean

    Whether particles can rotate.

    true

    Optional world-space bounds — particles outside die instantly.

    burstCount?: number

    Periodic-burst count (particles per burst). Combined with burstInterval, fires a burst every burstInterval seconds.

    0

    burstInterval?: number

    Period of automatic bursts in seconds. Has no effect when burstCount is 0.

    0

    enabled?: boolean

    Whether the emitter is active.

    true

    lifetimeMax?: number

    Lifetime range maximum (s).

    1

    lifetimeMin?: number

    Lifetime range minimum (s).

    1

    maxParticles?: number

    Maximum simultaneously alive particles. The pool size is capped at this value too.

    512

    onCollide?: (body: Body, other: Body) => void

    Fired when a particle's body collides with another body. Requires particleCbType to be set. The handler runs from inside a Space callback — do not mutate the space synchronously; use ParticleEmitter.requestKill for deferred cleanup.

    onDeath?: (body: Body, reason: ParticleDeathReason) => void

    Fired when a particle dies (lifetime, bounds, manual, or killAll).

    onSpawn?: (state: ParticleSpawnState, body: Body) => void

    Fired once per spawn, after the body is in the space.

    onUpdate?: (body: Body, age: number, dt: number) => void

    Fired every update() for each live particle (ages > 0).

    origin: Vec2 | Body

    Spawn anchor. A Vec2 is captured by reference (mutating it after construction moves the emitter); a Body is tracked by position each spawn (the body does not need to be in the same space). Required.

    overflowPolicy?: ParticleOverflowPolicy

    Policy when maxParticles is reached.

    "drop-oldest"

    particleCbType?: CbType

    Collision-callback type tagged on every particle body. Required for onCollide to fire. The emitter never auto-creates one — pass your own if you need it (so multiple emitters can share a type, or a single emitter can match a user-defined cbType).

    particleFilter?: InteractionFilter

    Filter applied to every particle shape. If omitted and selfCollision is false, the emitter generates a self-excluding filter automatically.

    particleMaterial?: Material

    Material applied to every particle shape.

    new Material()

    particlePolygon?: Vec2[]

    Polygon vertices in body-local space (used when particleShape: "polygon"). Defaults to a small square.

    particleRadius?: number

    Radius for circle particles. Ignored for polygon.

    2

    particleShape?: ParticleShape

    Body shape for each particle.

    "circle"

    random?: () => number

    Deterministic RNG. All emitter randomness (spawn jitter, velocity cone, lifetime sampling) flows through this.

    Math.random

    rate?: number

    Continuous spawn rate in particles/second. Accumulated across update() calls — fractional rates work. 0 disables continuous spawning (use ParticleEmitter.emit for manual bursts).

    0

    selfCollision?: boolean

    When false and no explicit particleFilter is given, particles receive a generated filter that skips its own group — particles in the same emitter never collide with each other. Has no effect when particleFilter is provided.

    false

    space: Space

    Space the emitted particle bodies live in. Required.

    spawn?: SpawnPattern

    Spawn-position pattern.

    { kind: "point" }

    velocity?: VelocityPattern

    Initial velocity pattern.

    { kind: "fixed", value: (0, 0) }