module:Particles

module:Particles

Particles generator class
particles demo

Constructor

# new module:Particles(positionDefinition, base, generatoropt, updateropt, optionsopt)

Particles constructor

Parameters:
Name Type Attributes Description
positionDefinition PositionDefinition

Origin for all particles

base Component

Blueprint for each particle

generator OptionsGenerator <optional>

Initialization function for all particles data

updater ParticlesCallback <optional>

Function called on each particle draw (should not be computation intensive)

options ParticleOptions <optional>

Extends

Members

# (static) defaultData :ParticleData

Type:
  • ParticleData

# (static) defaultOptions :ParticleOptions

Type:
  • ParticleOptions

Methods

# (static) from(definition) → {Particles}

Parameters:
Name Type Description
definition Object

Particles definition

Returns:
Type
Particles

# generate(number, …params) → {Particles}

Create new particles

Parameters:
Name Type Attributes Description
number Number

Number of particles to generate

params * <repeatable>

Additional parameters for the generator function

Returns:

Itself

Type
Particles

Type Definitions

# OptionsGenerator(index)

Parameters:
Name Type Description
index Number

Index of the particle

Returns:

ParticleData

# ParticleData

Type:
  • Object
Properties
Name Type Attributes Default Description
position Position <optional>
new Position()

Position of the particle

rotation Number <optional>
0

Rotation applied to the particle

scale Number | Position <optional>
1

Scaling ratio or a pair of value for horizontal and vertical scaling

ttl Number <optional>

Time to live, number of frames the particle is displayed. This number will be decremented and the data removed when it reach 0

# ParticleOptions

Type:
  • Object
Properties
Name Type Attributes Default Description
frequency Number <optional>
1

Frequency of emission (randomized)

emit Number | Array.<Number> <optional>

Number or range of particles emitted

args Array <optional>

Arguments passed to the generator function

# ParticlesCallback(data, index, …params)

Parameters:
Name Type Attributes Description
data ParticleData

One particle data

index Number

Index of the particle

params * <repeatable>

Additional parameters