Class ParticleSystem

Particle system, uses transform feedback on the GPU to update particles and VAO instancing to render them

Implements

Constructors

  • Create a new particle system

    Parameters

    • gl: WebGL2RenderingContext

      WebGL2 rendering context

    • maxParticles: number

      Maximum number of particles in the system

    • baseSize: number

      Size of the particle quad

    Returns ParticleSystem

Properties

acceleration: number

Acceleration or deceleration multiplier, default 1.0. Applied every frame, so keep values very close to 1.0

ageColour: RGBA

Change colour and alpha as particle reaches it's lifetime. Default: [0,0,0,1]

agePower: number

Age power curve

blendDest: number

Blend destination mode, default: 'ONE', leave alone unless you know what you are doing

blendSource: number

Blend source mode, default: 'SRC_ALPHA', leave alone unless you know what you are doing

direction1: XYZ

Particles will randomly emit in a direction between this vector and direction2

direction2: XYZ

Particles will randomly emit in a direction between this vector and direction1

duration: number

Duration of particle system in frames, -1 = forever. Default: -1

emitRate: number

Emission rate, number of particles per frame

emitterBoxMax: XYZ

Particles are spawned in a bounding box, defined by this vector as one corner

emitterBoxMin: XYZ

Particles are spawned in a bounding box, defined by this vector as one corner

enabled: boolean

When enabled, particles will be spawned and emitted

gravity: XYZ

Gravity vector. Default: [0, -9.81, 0]

localSpace: boolean

Particles transformed fixed to local coordinate space, generally leave as false

maxInitialRotation: number

Max initial random rotation of particles in radians

maxLifetime: number

Max lifetime of particles in seconds

maxPower: number

Max power (speed) of particles, this is multiplied by the direction vector

maxRotationSpeed: number

Max random rotation speed of particles in radians per second

maxSize: number

Max random size of particles

minInitialRotation: number

Min initial random rotation of particles in radians

minLifetime: number

Min lifetime of particles in seconds

minPower: number

Min power (speed) of particles, this is multiplied by the direction vector

minRotationSpeed: number

Min random rotation speed of particles in radians per second

minSize: number

Min random size of particles

preColour: RGBA

Colour multiplier pre-applied to particle texture before ageing

texture: WebGLTexture

Texture to use for particles

timeScale: number

Speed up or slow down time

Methods

  • Render the particle system and implement the renderable interface

    Parameters

    • gl: WebGL2RenderingContext

      WebGL2 rendering context

    • uniforms: UniformSet

      Uniforms to pass to the shaders

    Returns void