three-nebula API
    Preparing search index...

    Class Vortex

    Behaviour that swirls particles around an axis — a coherent tangential flow field, with an optional inward/outward pull, for vortices, spell charge-ups, tornados and orbiting motes.

    Unlike the radial point forces (Attraction/Repulsion), the swirl direction is the tangent around the axis (axis × radial), so particles orbit rather than converge. The force is applied to the particle's velocity (not acceleration), so it is not subject to the Force 1:100 (MEASURE) scaling — magnitudes are intuitive (tune swirl/pull in the hundreds). Deterministic by construction (no randomness).

    Hierarchy (View Summary)

    Index
    • Constructs a Vortex behaviour instance.

      Parameters

      • center: Vector3D = ...

        A point on the swirl axis

      • axis: Vector3D = ...

        The axis particles swirl around (normalised internally)

      • swirl: number = DEFAULT_VORTEX_SWIRL

        Tangential force scalar (orbit speed)

      • pull: number = DEFAULT_VORTEX_PULL

        Radial force scalar: inward (+) / outward (−)

      • falloff: number = DEFAULT_VORTEX_FALLOFF

        Radial falloff exponent; force scales by 1 / dist^falloff

      • life: number = DEFAULT_LIFE

        The life of the behaviour

      • easing: EasingFunction = DEFAULT_BEHAVIOUR_EASING

        The behaviour's decaying trend

      • isEnabled: boolean = true

        Determines if the behaviour will be applied or not

      Returns Vortex

    _life: number
    age: number
    axis: Vector3D
    center: Vector3D
    dead: boolean
    energy: number
    falloff: number
    id: string
    isEnabled: boolean
    pull: number
    swirl: number
    type: string
    • get life(): number

      Gets the behaviour's life.

      Returns number

    • set life(life: number): void

      Ensures that life is infinity if an invalid value is supplied.

      Parameters

      • life: number

      Returns void

    • Compares the age of the behaviour vs integration time and determines if the behaviour should be set to dead or not.

      Parameters

      • particle: Particle
      • time: number
      • Optionalindex: number

      Returns void

    • Returns a new instance of the behaviour from the JSON object passed.

      Parameters

      • json: Record<string, unknown>

      Returns void

    • Mutates the particle's velocity, swirling it around the axis.

      Parameters

      • particle: Particle

        the particle to apply the behaviour to

      • time: number

        particle engine time

      • Optionalindex: number

        the particle index

      Returns void

    • Resets the behaviour properties.

      Parameters

      • center: Vector3D = ...
      • axis: Vector3D = ...
      • swirl: number = DEFAULT_VORTEX_SWIRL
      • pull: number = DEFAULT_VORTEX_PULL
      • falloff: number = DEFAULT_VORTEX_FALLOFF
      • Optionallife: number
      • Optionaleasing: EasingFunction

      Returns void

    • Creates a Vortex behaviour from JSON.

      Parameters

      • json: VortexJSON

        The JSON to construct the instance from.

      Returns Vortex