three-nebula API
    Preparing search index...

    Class FollowEmitter

    Emitters are the System engine's particle factories. They cause particles to be rendered by emitting them, and store all particle initializers and behaviours.

    Hierarchy (View Summary)

    Index
    • The FollowEmitter will emit particles when the mouse moves.

      Parameters

      • OptionalmouseTarget: EventTarget
      • Optionalease: number
      • OptionalpObj: Record<string, unknown>

      Returns FollowEmitter

    _allowEmitting: boolean
    _freeInstances: Emitter[]
    _inheritedScale: number
    _parentParticle: Particle | null
    _spawnCount: number
    _template: Emitter | null
    acceleration: Vector3D
    activeChildren: Map<Particle, Emitter[]>
    age: number
    alpha: number
    behaviours: Behaviour[]
    bindEmitter: boolean
    bindEmitterEvent: boolean
    body: unknown
    camera?: Camera
    canvas?: HTMLCanvasElement
    childNodes: Emitter[]
    cID: number
    color: RGB
    currentEmitTime: number
    damping: number
    dead: boolean
    distanceToCamera: number
    ease: number
    emitterBehaviours: Behaviour[]
    emitterId: string | null
    emitterInstanceId: string | null
    energy: number
    eventDispatcher: EventDispatcher
    hasBeenInitialized?: boolean
    id: string
    index?: number
    inherit: InheritConfig
    initializers: Initializer[]
    isEmitting: boolean
    life: number
    mass: number
    mousemoveHandler: (e: Event) => void
    mouseTarget: EventTarget
    name: string
    nodeId: string
    old: { acceleration: Vector3D; position: Vector3D; velocity: Vector3D }
    orphanPolicy: OrphanPolicy
    parent: Emitter | System | null
    particles: Particle[]
    position: Vector3D
    radius: number
    rate: Rate
    rng: RNG
    rotation: Vector3D
    scale: number
    seed: number
    sleep: boolean
    spawnIndex: number
    target?: unknown
    totalEmitTimes: number
    transform: Record<string, unknown>
    trigger: EmitterTrigger
    type: string
    useAlpha: boolean
    useColor: boolean
    velocity: Vector3D
    • get system(): System | null

      An emitter's parent is the System it was added to (a particle's parent is its emitter, hence the inherited parent field is narrowed here).

      Returns System | null

    • Assigns this node's tree-path id and recurses into its children, so the whole subtree gets stable addresses (e.g. "0", "0/children/1"). Called by System.addEmitter with the emitter's array index as the root path. Enforces the hard depth cap here — the single choke point both the JSON and code paths flow through — throwing on an over-deep tree rather than leaking at runtime.

      Parameters

      • nodeId: string
      • depth: number = 0
      • maxDepth: number = DEFAULT_MAX_DEPTH

      Returns void

    • Cold path: builds a fresh instance of this node. Config (initializers, behaviours, child templates) is shared by reference — it is read-only during simulation — while all mutable runtime state is per-instance. The instance gets its own Rate over the template's immutable Spans so interval counters don't collide across the many instances of one node.

      Returns Emitter

    • Handles the child instances riding a particle that has just died: each is either detached (its particles live on, per detach) or killed with it. Runs before the particle is reset so the mapping key is still valid.

      Parameters

      Returns void

    • Clears an instance's runtime state so a pooled instance is indistinguishable from a cold one. Deliberately does NOT touch the shared config arrays (that would mutate the template every other instance reads) — only per-instance mutable fields. totalEmitTimes/life are restored from the template since generate decrements them as the instance runs.

      Returns void

    • Spawns a child instance of every child node, bound to a just-created parent particle, and snapshots the parent transform for onCreate inheritance. The System owns the acquire (cap + accounting); a null return means the cap was hit and this child is dropped.

      Parameters

      Returns void

    • Bursts every death-trigger child node at a particle that has just died: the instance is placed at the death position and released as a free-running, still-emitting detached instance, so its one-shot burst outlives the parent. Runs before the particle is reset (its position is still valid).

      Parameters

      Returns void

    • Advances the child instances riding each still-live particle, after this emitter's own particles have moved this frame (topological order: a parent resolves before its children read its transform). Recurses via inst.update.

      Parameters

      • time: number

      Returns void

    • Warm-or-cold acquire of an instance of this node bound to parentParticle. Pops the free-list when possible (no allocation on the warm path), otherwise builds one. The instance is reseeded from the parent's id so its stream is deterministic. Call on the template node; the returned instance carries a _template back-reference for release.

      Parameters

      Returns Emitter

    • Nests a child emitter template under this one. The child is instanced once per particle this emitter spawns. Node ids are (re)assigned when the root is added to a System, so children may be attached in any order beforehand.

      Parameters

      Returns this

    • Proxy method for the internal event dispatcher's dispatchEvent method.

      Parameters

      • event: string
      • target: unknown = ...

      Returns void

    • Returns an instance to this node's free-list for reuse. Callers must ensure the instance has no live particles first (the System's release path only releases once a detached instance has drained).

      Parameters

      Returns void

    • Re-derives this emitter's seed (and particle stream) from the system seed and its index. Called by System.addEmitter / setSeed so that emitters loaded in the same order produce the same streams across runs.

      Parameters

      • systemSeed: number
      • index: number

      Returns this

    • Derives a child instance's seed from its node's tree-path address and the parent particle's (stable, deterministic) id, so a given parent always produces the same child stream. Mirrors reseed but keyed on identity rather than array index (a child instance has no fixed index).

      Parameters

      • nodeId: string
      • parentParticleId: string

      Returns this

    • Resets the particle's default properties and clears its position, velocity, acceleration, color and rotation.

      Returns this

    • Parameters

      • camera: Camera
      • canvas: HTMLCanvasElement

      Returns void

    • Sets up a particle by running all initializers on it and setting its behaviours. Also adds the particle to this.particles.

      Parameters

      • particle: Particle
      • Optionalindex: number

      Returns void

    • Updates the emitter according to the time passed by calling the generate and integrate methods.

      Parameters

      • time: number

      Returns void