RectEmitter

RectEmitter

Particle emitter that emits particles from a rectangular area.

Constructor

new RectEmitter(configopt)

Description:
  • Initializes a rectangle emitter with a given top-left origin position, width, and height. Particles are emitted randomly from the rectangular area using a uniform distribution.
Source:
Parameters:
Name Type Attributes Default Description
config RectEmitterConfig <optional>
{} RectEmitter configuration options.

Extends

Classes

RectEmitter

Members

emissionSource :string

Description:
  • Emission source mode, defining the geometric distribution and initial direction of emitted particles. The default direction depends on both the emission source mode and the emitter type and can be overridden by specifying `particleBlueprint.direction` in the emitter config.
Source:
Overrides:
See:
Emission source mode, defining the geometric distribution and initial direction of emitted particles. The default direction depends on both the emission source mode and the emitter type and can be overridden by specifying `particleBlueprint.direction` in the emitter config.
Type:
  • string

height :number

Description:
  • Height of the emission rectangle.
Source:
Height of the emission rectangle.
Type:
  • number

particlesPerSecond :number

Description:
  • Continuous emission rate of new particles per second.
Source:
Overrides:
Continuous emission rate of new particles per second.
Type:
  • number

width :number

Description:
  • Width of the emission rectangle.
Source:
Width of the emission rectangle.
Type:
  • number

x :number

Description:
  • Horizontal coordinate of the top-left corner of the emission rectangle.
Source:
Overrides:
Horizontal coordinate of the top-left corner of the emission rectangle.
Type:
  • number

y :number

Description:
  • Vertical coordinate of the top-left corner of the emission rectangle.
Source:
Overrides:
Vertical coordinate of the top-left corner of the emission rectangle.
Type:
  • number

Methods

addModifier(modifier) → {void}

Description:
  • Registers a modifier to be applied to the particles emitted by the emitter.
Source:
Overrides:
Parameters:
Name Type Description
modifier Modifier Modifier instance to register.
Throws:
Error
Returns:
Type
void

addScopedForce(force) → {void}

Description:
  • Registers a scoped emitter-specific force to be applied to the particles emitted by the emitter.
Source:
Overrides:
Parameters:
Name Type Description
force Force Force instance to register.
Returns:
Type
void

getModifier(id) → {Modifier|null}

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

getScopedForce(id) → {Force|null}

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

pause() → {void}

Description:
  • Temporarily halts particle emission and locks internal tracking.
Source:
Overrides:
Returns:
Type
void

removeModifier(id) → {boolean}

Description:
  • Removes a modifier from any of the emitter's registered modifier lists by its unique identifier.
Source:
Overrides:
Parameters:
Name Type Description
id string The unique identifier of the target modifier.
Returns:
True if found and successfully removed, false otherwise.
Type
boolean

removeScopedForce(id) → {boolean}

Description:
  • Removes a scoped emitter-specific force from the emitter's registered forces lists by its unique identifier.
Source:
Overrides:
Parameters:
Name Type Description
id string The unique identifier of the target force.
Returns:
True if found and successfully removed, false otherwise.
Type
boolean

resume() → {void}

Description:
  • Resumes particle emission and internal tracking from where they were paused.
Source:
Overrides:
Returns:
Type
void

start() → {void}

Description:
  • Starts or forcefully restarts particle emission from the beginning. Resets internal tracking and sets the emitter to an active state.
Source:
Overrides:
Returns:
Type
void

stop() → {void}

Description:
  • Halts particle emission and resets internal tracking. The emitter is deactivated but remains ready to be started again.
Source:
Overrides:
Returns:
Type
void

update(dt, particlePool) → {void}

Description:
  • Updates the emitter's internal timer and returns any new particles to be emitted in the current frame.
Source:
Overrides:
Parameters:
Name Type Description
dt number Time elapsed since the last frame (in seconds).
particlePool Array.<Particle> Reference to the internal collection of active particles in the main {Gnist} class.
Returns:
Type
void