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

cullingBounds :CullingBounds|null

Description:
  • Optional region used for particle culling.
Source:
Optional region used for particle culling.
Type:

cullingBounds

Description:
  • Sets the optional region used for particle culling.
Source:
Sets the optional region used for particle culling.

(readonly) emitters :Array.<Emitter>

Description:
  • Registered emitters emitting active particles.
Source:
Registered emitters emitting active particles.
Type:

(readonly) globalForces :Array.<Force>

Description:
  • Registered global environmental forces affecting all active particles.
Source:
Registered global environmental forces affecting all active particles.
Type:

(readonly) particles :Array.<Particle>

Description:
  • Common pool of active particles.
Source:
Common pool of active particles.
Type:

(static) VERSION :string

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

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

fillFlatArray(targetArray) → {number}

Description:
  • Fills a provided TypedArray with particle data for WebGL.
Source:
Parameters:
Name Type Description
targetArray Float32Array The array to write data into.
Returns:
The number of particles written.
Type
number

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

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

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

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