ParticleSystemComponent

ParticleSystemComponent

A Particle System component simulates things like clouds and flames by generating and animating large numbers of
small 2D images in the scene.

Constructor

new ParticleSystemComponent(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>

Particle options

Properties
Name Type Attributes Default Description
billboard boolean <optional>
true
depthTest boolean <optional>
true
depthWrite boolean <optional>
true
loop boolean <optional>
true
paused boolean <optional>
false
preWarm boolean <optional>
false
randomDirection boolean <optional>
false
sphereEmitFromShell boolean <optional>
false
colorOverLifetime Curve <optional>
localVelocityOverLifetime Curve <optional>
rotationSpeedOverLifetime Curve <optional>
sizeOverLifetime Curve <optional>
startAngle Curve <optional>
startColor Curve <optional>
startLifetime Curve <optional>
startSize Curve <optional>
startSpeed Curve <optional>
textureFrameOverLifetime Curve <optional>
worldVelocityOverLifetime Curve <optional>
blending number <optional>
'NoBlending'
coneAngle number <optional>

Default is pi/8

coneLength number <optional>
1
coneRadius number <optional>
1
discardThreshold number <optional>
0
duration number <optional>
5
localSpace number <optional>
true
maxParticles number <optional>
100
renderQueue number <optional>
3010
rotationSpeedScale number <optional>
1
seed number <optional>
-1
startAngleScale number <optional>
1
startSizeScale number <optional>
1
texture number <optional>
textureAnimationCycles number <optional>
1
textureTilesX number <optional>
1
textureTilesY number <optional>
1
time number <optional>
0
coneEmitFrom string <optional>
'base'
shapeType string <optional>
'cone'
boxExtents Vector3 <optional>

Default is new Vector3(1,1,1)

gravity Vector3 <optional>

Default is zero

startColorScale Vector4 <optional>

Default is new Vector4(1,1,1,1)

Example
var particleComponent = new ParticleSystemComponent({
    loop: true,
    preWarm: true,
    shapeType: 'sphere',
    sphereRadius: 0.5
});
var entity = world.createEntity([0, 0, 0], particleComponent).addToWorld();

Members

(static, readonly) SORT_CAMERA_DISTANCE :number

Sort particles by camera distance.

(static, readonly) SORT_NONE :number

No sorting of particles.

autoPlay :boolean

Whether to start playing when the ParticleSystemSystem plays.

Default Value:
  • true

billboard :boolean

If set to true, the particles will always face the camera.

blending :string

What type of blending to use for the particle mesh.

(readonly) boxExtents :Vector3

Extents of the box, if box shape is used. Read only. To change it, see the method setBoxExtents().

colorOverLifetime :Vector4Curve|null

Color of particles, as a curve over their life time.

coneAngle :number

Angle of the cone, if cone shape is used.

coneEmitFrom :string

Where to emit from, if using the cone shape. Set to 'base', 'volume' or 'volumeshell'.

coneLength :number

Length of the cone, if cone shape is used.

coneRadius :number

Radius of the cone, if cone shape is used.

depthTest :boolean

depthWrite :boolean

discardThreshold :number

At what alpha threshold should the fragments be discarded?

duration :number

The time for a full animation cycle of the emission.

emissionRate :Curve

Number of particles to emit per second

(readonly) entity :Entity|null

The entity which the component is attached on. Will be set when the component is attached to the entity.

gravity :Vector3

Force that makes particles fall.

localSpace :boolean

If set to true, the partiles will be simulated in local entity space. If set to false, world space is used.

localVelocityOverLifetime :Vector3Curve|null

The velocity of particles in local particle space.

loop :boolean

Whether to loop the particle emission after one duration cycle.

maxParticles :number

Maximum number of particles visible at the same time.

mesh :MeshData

(readonly) particles :Array.<ParticleData>

The current particles in the system.

(readonly) paused :boolean

Use the pause/play/stop methods if you want to modify the state.

Default Value:
  • false

preWarm :boolean

Pre-warm the emission (fast forward time one duration). Not available if looping is on.

randomDirection :boolean

Emit in random directions, instead of in the emitter volume direction.

renderQueue :number

rotationSpeedOverLifetime :Curve|null

The rotation speed in radians per second, specified using a curve over the particle life time.

rotationSpeedScale :number

Acts as a scale on the rotationSpeed curve.

seed :number

Randomization seed.

shapeType :string

Emitter volume. Set to 'sphere', 'cone', or 'box'.

sizeOverLifetime :Curve|null

This curve alters the size of particles over their life time.

sortMode :string

sphereEmitFromShell :boolean

Whether to emit from the sphere shell, if sphere shape is used.

startAngle :Curve|null

The initial angle of particles, as a curve over the emitter duration.

startAngleScale :number

Acts as a scale on the startAngle curve.

startColor :Vector4Curve|null

The initial color of particles as a color curve over the emitter duration.

startColorScale :Vector4

Acts as a scale on the color curve. Should be used at runtime.

startLifetime :Curve|null

Initial life time of particles, as a curve over the emitter duration.

startSize :Curve|null

Initial size of particles, as a curve over the emitter duration.

startSizeScale :number

Acts as a scale on the startSize curve.

startSpeed :Curve|null

Initial speed of the particles, described by a curve over the emitter duration.

texture :Texture|null

A texture for the particles.

textureAnimationCycles :number

How fast the texture animation should cycle. Acts as a scale on the textureFrameOverLifetime curve.

textureFrameOverLifetime :Curve|null

The current texture frame, given by a curve over the particle life time.

textureTilesX :number

Texture tiling in the X direction.

textureTilesY :number

Texture tiling in the Y direction.

(readonly) time :number

Current time in the system.

worldVelocityOverLifetime :Vector3Curve|null

Velocity of particles in world space.

Methods

clone() → {ParticleSystemComponent}

emitOne(position, direction)

Emit the next particle.

Parameters:
Name Type Description
position Vector3
direction Vector3

pause()

Pause the animation.

play()

Play the animation.

resume()

Resume the animation.

setBoxExtents(extents)

Set the boxExtents.

Parameters:
Name Type Description
extents Vector3

stop()

Stop the animation.