Gnist

Gnist

The core particle engine that manages the simulation pipeline and particle lifecycle.

Constructor

new Gnist(configopt)

Description:
  • Initializes an empty simulation pipeline.
Source:
Parameters:
Name Type Attributes Default Description
config EngineConfig <optional>
{} Engine configuration options.

Classes

Gnist

Members

config :EngineConfig

Description:
  • Engine configuration options.
Source:
Engine configuration options.
Type:

(static) INFINITE_DURATION :number

Description:
  • Constant value representing an infinite particle lifespan.
Source:
Constant value representing an infinite particle lifespan.
Type:
  • number

(static) VERSION

Description:
  • The current semantic version of the Gnist particle engine.
Source:
The current semantic version of the Gnist particle engine.

Methods

addEmitter(emitter) → {this}

Description:
  • Registers an emitter into the simulation pipeline.
Source:
Parameters:
Name Type Description
emitter Emitter The emitter instance to register.
Returns:
The Gnist engine instance for method chaining.
Type
this

addGlobalForce(force) → {this}

Description:
  • Registers a global environmental force into the simulation pipeline.
Source:
Parameters:
Name Type Description
force Force The force instance to register.
Returns:
The Gnist engine instance for method chaining.
Type
this

emitParticles(dt) → {void}

Description:
  • Iterates through registered emitters to emit new particles.
Source:
Parameters:
Name Type Description
dt number Time elapsed since the last frame (in seconds).
Returns:
Type
void

getEmitter(id) → {Emitter|null}

Description:
  • Finds a registered emitter by its unique identifier.
Source:
Parameters:
Name Type Description
id string The unique identifier of the target emitter.
Returns:
The emitter instance if found, null otherwise.
Type
Emitter | null

getEmitters() → {Array.<Emitter>}

Description:
  • Gets the current list of registered emitters.
Source:
Returns:
Type
Array.<Emitter>

getGlobalForce(id) → {Force|null}

Description:
  • Finds a registered global environmental force by its unique identifier.
Source:
Parameters:
Name Type Description
id string The unique identifier of the target force.
Returns:
The force instance if found, null otherwise.
Type
Force | null

getGlobalForces() → {Array.<Force>}

Description:
  • Gets the current list of registered global environmental forces.
Source:
Returns:
Type
Array.<Force>

getParticles() → {Array.<Particle>}

Description:
  • Gets the current list of active particles of the common particle pool.
Source:
Returns:
Type
Array.<Particle>

removeEmitter(id) → {boolean}

Description:
  • Removes an emitter from the simulation pipeline by its unique identifier.
Source:
Parameters:
Name Type Description
id string The unique identifier of the target emitter.
Returns:
True if found and successfully removed, false otherwise.
Type
boolean

removeGlobalForce(id) → {boolean}

Description:
  • Removes a global environmental force from the simulation pipeline by its unique identifier.
Source:
Parameters:
Name Type Description
id string The unique identifier of the target force.
Returns:
True if found and successfully removed, false otherwise.
Type
boolean

tickParticles(dt) → {void}

Description:
  • Updates particle lifecycles, applies global and scoped emitter-specific forces, moves particles, and applies modifiers.
Source:
Parameters:
Name Type Description
dt number Time elapsed since the last frame (in seconds).
Returns:
Type
void

update(dt) → {void}

Description:
  • Steps the simulation pipeline forward by a given time delta.
Source:
Parameters:
Name Type Description
dt number Time elapsed since the last frame (in seconds).
Returns:
Type
void