Home Reference Source
public class | source

Emitter

Extends:

Particle → Emitter

Direct Subclass:

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.

Constructor Summary

Public Constructor
public

constructor(properties: object): *

Constructs an Emitter instance.

Member Summary

Public Members
public

age: *

public

behaviours: array

The behaviours for particles emitted by this emitter.

public

Ensures that particles emitted by this emitter are positioned according to the emitter's properties.

public

Determines if the emitter will dispatch internal events.

public
public

currentEmitTime: integer

The current emit iteration.

public

The friction coefficient for all particle to emit by.

public
public

The behaviours for the emitter.

public
public

The emitter's internal event dispatcher.

public

The emitter's id.

public

The index of the emitter as it is added to the system.

public

initializers: array

The initializers for particles emitted by this emitter.

public

Determines if the emitter is emitting particles or not.

public

life: *

public
public

parent: *

public

particles: array

The particles emitted by this emitter.

public

The number of particles to emit per second (a [particle]/b [s])

public

totalEmitTimes: integer

The total number of times the emitter should emit particles.

public

The class type.

Method Summary

Public Methods
public

Adds a behaviour to the emitter.

public

addBehaviours(behaviours: array<Behaviour>): Emitter

Adds multiple behaviours to the emitter.

public

Adds an emitter behaviour to the emitter.

public

addEmitterBehaviours(behaviours: array<Behaviour>): Emitter

Adds multiple behaviours to the emitter.

public

Adds a particle initializer to the emitter.

public

addInitializers(initializers: array<Initializer>): Emitter

Adds multiple particle initializers to the emitter.

public

Adds the event listener for the EMITTER_DEAD event.

public

Creates a particle by retreiving one from the pool and setting it up with the supplied initializer and behaviour.

public

destroy(): *

Kills the emitter.

public

dispatch(event: string, target: object<Particle>)

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

public

emit(totalEmitTimes: number, life: number): Emitter

Sets the total number of times the emitter should emit particles as well as the emitter's life. Also intializes the emitter rate. This enables the emitter to emit particles.

public

Experimental emit method that is designed to be called from the System.emit method.

public

generate(time: number): *

Generates new particles.

public

integrate(time: number): *

Runs the integration algorithm on the emitter and all particles.

public

Removes all behaviours from the emitter.

public

Removes all behaviours from the emitter.

public

Removes all initializers.

public

Kills all of the emitter's particles.

public

Removes the behaviour from the emitter's behaviours array.

public

Removes the behaviour from the emitter's behaviours array.

public

Removes an initializer from the emitter's initializers array.

public

setBehaviours(behaviours: array<Behaviour>): Emitter

Sets the emitter's behaviours.

public

setEmitterBehaviours(behaviours: array<Behaviour>): Emitter

Sets the emitter's behaviours.

public

setInitializers(initializers: array<Initializer>): Emitter

Sets the emitter's particle initializers.

public

Sets the life of the emitter.

public

setPosition(newPosition: object): Emitter

Sets the position of the emitter.

public

setRate(rate: Rate): Emitter

Sets the emitter rate.

public

setRotation(newRotation: object): Emitter

Sets the rotation of the emitter.

public

setTotalEmitTimes(totalEmitTimes: number): Emitter

Sets the total emit times for the emitter.

public

setupParticle(particle: Particle): *

Sets up a particle by running all initializers on it and setting its behaviours.

public

stopEmit(): *

Stops the emitter from emitting particles.

public

update(time: number): *

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

public

Updates the emitter's emitter behaviours.

Inherited Summary

From class Particle
public

The particle's acceleration

public

The particle's age

public

The particle's alpha

public

behaviours: array

The particle's behaviours array

public

The particle's body

public

The particle's color store

public

Determines if the particle is dead or not

public

The particle's distance to the camera, only set by the GPURenderer for depth sorting purposes.

public

The particle's easing

public

The particle's energy loss

public

The particle's unique id

public

The particle's life

public

The particle's mass

public

The particle's last position, velocity and acceleration

public

The particle's parent

public

The particle's position

public

The particle's radius

public

The particle's rotation

public

The particle's scale

public

Determines if the particle is sleeping or not

public

The particle's transform collection

public

The class type.

public

Determines whether to use alpha or not

public

Determines whether to use color or not

public

The particle's velocity

public

addBehaviour(behaviour: Behaviour): *

Adds a behaviour to the particle.

public

addBehaviours(behaviours: array<Behaviour>): *

Adds multiple behaviours to the particle.

public

destroy(): *

Destroys the particle.

public

Gets the particle's current direction.

public

Removes all behaviours from the particle.

public

removeBehaviour(behaviour: Behaviour): *

Removes the behaviour from the particle.

public

Resets the particle's default properties and clear's its particle's position, velocity, acceleration, color and rotation. Also destroy's the particle's transform collection & removes all behaviours.

public

update(time: number, index: integer): *

Updates the particle's properties by applying each behaviour to the particle. Will also update the particle's energy, unless it's age is greater than it's life in which case it will be destroyed.

Public Constructors

public constructor(properties: object): * source

Constructs an Emitter instance.

Override:

Particle#constructor

Params:

NameTypeAttributeDescription
properties object

The properties to instantiate the emitter with

Return:

*

void

Public Members

public age: * source

The particle's age

Override:

Particle#age

public behaviours: array source

The behaviours for particles emitted by this emitter.

Override:

Particle#behaviours

public bindEmitter: boolean source

Ensures that particles emitted by this emitter are positioned according to the emitter's properties.

public bindEmitterEvent: boolean source

Determines if the emitter will dispatch internal events. Defaults to false

public cID: number source

public currentEmitTime: integer source

The current emit iteration.

public damping: number source

The friction coefficient for all particle to emit by.

public dead: boolean source

Determines if the particle is dead or not

Override:

Particle#dead

public emitterBehaviours: array source

The behaviours for the emitter.

public energy: number source

The particle's energy loss

Override:

Particle#energy

public eventDispatcher: EventDispatcher source

The emitter's internal event dispatcher.

public id: string source

The emitter's id.

Override:

Particle#id

public index: number | undefined source

The index of the emitter as it is added to the system.

public initializers: array source

The initializers for particles emitted by this emitter.

public isEmitting: boolean source

Determines if the emitter is emitting particles or not.

public life: * source

The particle's life

Override:

Particle#life

public name: string source

public parent: * source

The particle's parent

Override:

Particle#parent

public particles: array source

The particles emitted by this emitter.

public rate: Rate source

The number of particles to emit per second (a [particle]/b [s])

public totalEmitTimes: integer source

The total number of times the emitter should emit particles.

public type: string source

The class type.

Override:

Particle#type

Public Methods

public addBehaviour(behaviour: Behaviour): Emitter source

Adds a behaviour to the emitter. All emitter behaviours are added to each particle when they are emitted.

Override:

Particle#addBehaviour

Params:

NameTypeAttributeDescription
behaviour Behaviour

The behaviour to add to the emitter

Return:

Emitter

public addBehaviours(behaviours: array<Behaviour>): Emitter source

Adds multiple behaviours to the emitter.

Override:

Particle#addBehaviours

Params:

NameTypeAttributeDescription
behaviours array<Behaviour>

an array of emitter behaviours

Return:

Emitter

public addEmitterBehaviour(behaviour: Behaviour): Emitter source

Adds an emitter behaviour to the emitter.

Params:

NameTypeAttributeDescription
behaviour Behaviour

The behaviour to add to the emitter

Return:

Emitter

public addEmitterBehaviours(behaviours: array<Behaviour>): Emitter source

Adds multiple behaviours to the emitter.

Params:

NameTypeAttributeDescription
behaviours array<Behaviour>

an array of emitter behaviours

Return:

Emitter

public addInitializer(initializer: Initializer): Emitter source

Adds a particle initializer to the emitter. Each initializer is run on each particle when they are created.

Params:

NameTypeAttributeDescription
initializer Initializer

The initializer to add

Return:

Emitter

public addInitializers(initializers: array<Initializer>): Emitter source

Adds multiple particle initializers to the emitter.

Params:

NameTypeAttributeDescription
initializers array<Initializer>

an array of particle initializers

Return:

Emitter

public addOnEmitterDeadEventListener(-: onEmitterDead): Emitter source

Adds the event listener for the EMITTER_DEAD event.

Params:

NameTypeAttributeDescription
- onEmitterDead

The function to call when the EMITTER_DEAD is dispatched.

Return:

Emitter

public createParticle(): Emitter source

Creates a particle by retreiving one from the pool and setting it up with the supplied initializer and behaviour.

Return:

Emitter

public destroy(): * source

Kills the emitter.

Override:

Particle#destroy

Return:

*

void

public dispatch(event: string, target: object<Particle>) source

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

Params:

NameTypeAttributeDescription
event string

The event to dispatch

target object<Particle>
  • optional
  • default: this

The event target

public emit(totalEmitTimes: number, life: number): Emitter source

Sets the total number of times the emitter should emit particles as well as the emitter's life. Also intializes the emitter rate. This enables the emitter to emit particles.

Params:

NameTypeAttributeDescription
totalEmitTimes number
  • optional
  • default: Infinity

the total number of times to emit particles

life number
  • optional
  • default: Infinity

the life of this emitter in milliseconds

Return:

Emitter

public experimental_emit(): Emitter source

Experimental emit method that is designed to be called from the System.emit method.

Return:

Emitter

public generate(time: number): * source

Generates new particles.

Params:

NameTypeAttributeDescription
time number

System engine time

Return:

*

void

public integrate(time: number): * source

Runs the integration algorithm on the emitter and all particles. Updates the particles with the timstamp passed.

Params:

NameTypeAttributeDescription
time number

System engine time

Return:

*

void

public removeAllBehaviours(): Emitter source

Removes all behaviours from the emitter.

Override:

Particle#removeAllBehaviours

Return:

Emitter

public removeAllEmitterBehaviours(): Emitter source

Removes all behaviours from the emitter.

Return:

Emitter

public removeAllInitializers(): Emitter source

Removes all initializers.

Return:

Emitter

public removeAllParticles(): * source

Kills all of the emitter's particles.

Return:

*

void

public removeBehaviour(behaviour: Behaviour): Emitter source

Removes the behaviour from the emitter's behaviours array.

Override:

Particle#removeBehaviour

Params:

NameTypeAttributeDescription
behaviour Behaviour

The behaviour to remove

Return:

Emitter

public removeEmitterBehaviour(behaviour: Behaviour): Emitter source

Removes the behaviour from the emitter's behaviours array.

Params:

NameTypeAttributeDescription
behaviour Behaviour

The behaviour to remove

Return:

Emitter

public removeInitializer(initializer: Initializer): Emitter source

Removes an initializer from the emitter's initializers array.

Params:

NameTypeAttributeDescription
initializer Initializer

The initializer to remove

Return:

Emitter

public setBehaviours(behaviours: array<Behaviour>): Emitter source

Sets the emitter's behaviours.

Params:

NameTypeAttributeDescription
behaviours array<Behaviour>

an array of emitter behaviours

Return:

Emitter

public setEmitterBehaviours(behaviours: array<Behaviour>): Emitter source

Sets the emitter's behaviours.

Params:

NameTypeAttributeDescription
behaviours array<Behaviour>

an array of emitter behaviours

Return:

Emitter

public setInitializers(initializers: array<Initializer>): Emitter source

Sets the emitter's particle initializers.

Params:

NameTypeAttributeDescription
initializers array<Initializer>

an array of particle initializers

Return:

Emitter

public setLife(life: number): Emitter source

Sets the life of the emitter.

Params:

NameTypeAttributeDescription
life number
  • optional
  • default: Infinity

the life of this emitter in milliseconds

Return:

Emitter

public setPosition(newPosition: object): Emitter source

Sets the position of the emitter.

Params:

NameTypeAttributeDescription
newPosition object

an object the new x, y and z props

Return:

Emitter

public setRate(rate: Rate): Emitter source

Sets the emitter rate.

Params:

NameTypeAttributeDescription
rate Rate

a rate initializer object

Return:

Emitter

public setRotation(newRotation: object): Emitter source

Sets the rotation of the emitter.

Params:

NameTypeAttributeDescription
newRotation object

an object the new x, y and z props

Return:

Emitter

public setTotalEmitTimes(totalEmitTimes: number): Emitter source

Sets the total emit times for the emitter.

Params:

NameTypeAttributeDescription
totalEmitTimes number
  • optional
  • default: Infinity

the total number of times to emit particles

Return:

Emitter

public setupParticle(particle: Particle): * source

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

Params:

NameTypeAttributeDescription
particle Particle

The particle to setup

Return:

*

void

public stopEmit(): * source

Stops the emitter from emitting particles.

Return:

*

void

public update(time: number): * source

Updates the emitter according to the time passed by calling the generate and integrate methods. The generate method creates particles, the integrate method updates existing particles.

If the emitter age is greater than time, the emitter is killed.

This method also indexes/deindexes particles.

Override:

Particle#update

Params:

NameTypeAttributeDescription
time number

System engine time

Return:

*

void

public updateEmitterBehaviours(time: number): * source

Updates the emitter's emitter behaviours.

Params:

NameTypeAttributeDescription
time number

System engine time

Return:

*

void