GPUParticleSystem

This represents a GPU particle system in Babylon This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data

see

https://www.babylonjs-playground.com/#PU4WYI#4

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Find examples in Playground
  • new GPUParticleSystem(name: string, options: Partial<object>, scene: Scene, isAnimationSheetEnabled?: boolean): GPUParticleSystem
  • Instantiates a GPU particle system. Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.

    Parameters

    • name: string

      The name of the particle system

    • options: Partial<object>

      The options used to create the system

    • scene: Scene

      The scene the particle system belongs to

    • Optional isAnimationSheetEnabled: boolean

      Must be true if using a spritesheet to animate the particles texture

    Returns GPUParticleSystem

Properties

activeParticleCount

Find examples in Playground
activeParticleCount: number

Gets or set the number of active particles

animations

Find examples in Playground
animations: Animation[]

List of animations used by the particle system.

beginAnimationFrom

Find examples in Playground
beginAnimationFrom: number

Gets or sets the frame to start the animation from when beginAnimationOnStart is true

beginAnimationLoop

Find examples in Playground
beginAnimationLoop: boolean

Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true

beginAnimationOnStart

Find examples in Playground
beginAnimationOnStart: boolean

Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called

beginAnimationTo

Find examples in Playground
beginAnimationTo: number

Gets or sets the frame to end the animation on when beginAnimationOnStart is true

billboardMode

Find examples in Playground
billboardMode: number

Gets or sets the billboard mode to use when isBillboardBased = true. Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED

blendMode

Find examples in Playground
blendMode: number

Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.

color1

Find examples in Playground
color1: Color4

Random color of each particle after it has been emitted, between color1 and color2 vectors

color2

Find examples in Playground
color2: Color4

Random color of each particle after it has been emitted, between color1 and color2 vectors

colorDead

Find examples in Playground
colorDead: Color4

Color the particle will have at the end of its lifetime

customShader

Find examples in Playground
customShader: any

This can help using your own shader to render the particle system. The according effect will be created

direction1

Find examples in Playground
direction1: Vector3

Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. This only works when particleEmitterTyps is a BoxParticleEmitter

direction2

Find examples in Playground
direction2: Vector3

Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. This only works when particleEmitterTyps is a BoxParticleEmitter

disposeOnStop

Find examples in Playground
disposeOnStop: boolean

Specifies whether the particle system will be disposed once it reaches the end of the animation.

emitRate

Find examples in Playground
emitRate: number

The maximum number of particles to emit per frame

emitter

Find examples in Playground

The emitter represents the Mesh or position we are attaching the particle system to.

endSpriteCellID

Find examples in Playground
endSpriteCellID: number

If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display

forceDepthWrite

Find examples in Playground
forceDepthWrite: boolean

Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls to override the particles.

gravity

Find examples in Playground
gravity: Vector3

You can use gravity if you want to give an orientation to your particles.

id

Find examples in Playground
id: string

The id of the Particle system.

imageProcessingConfiguration

Find examples in Playground
imageProcessingConfiguration: ImageProcessingConfiguration

Sets the Default image processing configuration used either in the this material.

If sets to null, the scene one is in use.

isAnimationSheetEnabled

Find examples in Playground
isAnimationSheetEnabled: boolean

Gets or sets whether an animation sprite sheet is enabled or not on the particle system

isBillboardBased

Find examples in Playground
isBillboardBased: boolean

Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction

layerMask

Find examples in Playground
layerMask: number

The layer mask we are rendering the particles through.

limitVelocityDamping

Find examples in Playground
limitVelocityDamping: number

Gets or sets a value indicating the damping to apply if the limit velocity factor is reached

manualEmitCount

Find examples in Playground
manualEmitCount: number

If you want to launch only a few particles at once, that can be done, as well.

maxAngularSpeed

Find examples in Playground
maxAngularSpeed: number

Maximum angular speed of emitting particles (Z-axis rotation for each particle).

maxEmitBox

Find examples in Playground
maxEmitBox: Vector3

Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so. This only works when particleEmitterTyps is a BoxParticleEmitter

maxEmitPower

Find examples in Playground
maxEmitPower: number

Maximum power of emitting particles.

maxInitialRotation

Find examples in Playground
maxInitialRotation: number

Gets or sets the maximal initial rotation in radians.

maxLifeTime

Find examples in Playground
maxLifeTime: number

Maximum life time of emitting particles.

maxScaleX

Find examples in Playground
maxScaleX: number

Maximum scale of emitting particles on X axis.

maxScaleY

Find examples in Playground
maxScaleY: number

Maximum scale of emitting particles on Y axis.

maxSize

Find examples in Playground
maxSize: number

Maximum Size of emitting particles.

minAngularSpeed

Find examples in Playground
minAngularSpeed: number

Minimum angular speed of emitting particles (Z-axis rotation for each particle).

minEmitBox

Find examples in Playground
minEmitBox: Vector3

Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so. This only works when particleEmitterTyps is a BoxParticleEmitter

minEmitPower

Find examples in Playground
minEmitPower: number

Minimum power of emitting particles.

minInitialRotation

Find examples in Playground
minInitialRotation: number

Gets or sets the minimal initial rotation in radians.

minLifeTime

Find examples in Playground
minLifeTime: number

Minimum life time of emitting particles.

minScaleX

Find examples in Playground
minScaleX: number

Minimum scale of emitting particles on X axis.

minScaleY

Find examples in Playground
minScaleY: number

Minimum scale of emitting particles on Y axis.

minSize

Find examples in Playground
minSize: number

Minimum Size of emitting particles.

name

Find examples in Playground
name: string

The friendly name of the Particle system.

noiseStrength

Find examples in Playground
noiseStrength: Vector3

Gets or sets the strength to apply to the noise value (default is (10, 10, 10))

noiseTexture

Find examples in Playground

Gets or sets a texture used to add random noise to particle positions

onAnimationEnd

Find examples in Playground
onAnimationEnd: Nullable<function>

Callback triggered when the particle animation is ending.

onDisposeObservable

Find examples in Playground
onDisposeObservable: Observable<GPUParticleSystem>

An event triggered when the system is disposed.

particleEmitterType

Find examples in Playground
particleEmitterType: IParticleEmitterType

The particle emitter type defines the emitter used by the particle system. It can be for example box, sphere, or cone...

particleTexture

Find examples in Playground
particleTexture: Nullable<Texture>

The texture used to render each particle. (this can be a spritesheet)

preWarmCycles

Find examples in Playground
preWarmCycles: number

Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0

preWarmStepOffset

Find examples in Playground
preWarmStepOffset: number

Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)

preventAutoStart

Find examples in Playground
preventAutoStart: boolean

By default particle system starts as soon as they are created. This prevents the automatic start to happen and let you decide when to start emitting particles.

renderingGroupId

Find examples in Playground
renderingGroupId: number

The rendering group used by the Particle system to chose when to render.

spriteCellChangeSpeed

Find examples in Playground
spriteCellChangeSpeed: number

If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)

spriteCellHeight

Find examples in Playground
spriteCellHeight: number

If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use

spriteCellWidth

Find examples in Playground
spriteCellWidth: number

If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use

spriteRandomStartCell

Find examples in Playground
spriteRandomStartCell: boolean

This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID

startDelay

Find examples in Playground
startDelay: number

Defines the delay in milliseconds before starting the system (0 by default)

startSpriteCellID

Find examples in Playground
startSpriteCellID: number

If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display

targetStopDuration

Find examples in Playground
targetStopDuration: number

The amount of time the particle system is running (depends of the overall update speed).

textureMask

Find examples in Playground
textureMask: Color4

An optional mask to filter some colors out of the texture, or filter a part of the alpha channel

translationPivot

Find examples in Playground
translationPivot: Vector2

Gets or sets a Vector2 used to move the pivot (by default (0,0))

updateSpeed

Find examples in Playground
updateSpeed: number

The overall motion speed (0.01 is default update speed, faster updates = faster animation)

useRampGradients

Find examples in Playground
useRampGradients: boolean

Not supported by GPUParticleSystem Gets or sets a boolean indicating that ramp gradients must be used

see

http://doc.babylonjs.com/babylon101/particles#ramp-gradients

Static BLENDMODE_ADD

Find examples in Playground
BLENDMODE_ADD: number

Add current color and particle color multiplied by particle’s alpha

Static BLENDMODE_MULTIPLY

Find examples in Playground
BLENDMODE_MULTIPLY: number

Multiply current color with particle color

Static BLENDMODE_MULTIPLYADD

Find examples in Playground
BLENDMODE_MULTIPLYADD: number

Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha

Static BLENDMODE_ONEONE

Find examples in Playground
BLENDMODE_ONEONE: number

Source color is added to the destination color without alpha affecting the result

Static BLENDMODE_STANDARD

Find examples in Playground
BLENDMODE_STANDARD: number

Blend current color and particle color using particle’s alpha

Static IsSupported

Find examples in Playground
IsSupported: boolean

Gets a boolean indicating if the GPU particles can be rendered on current browser

Methods

addAlphaRemapGradient

Find examples in Playground
  • addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • min: number

      defines the alpha remap minimal range

    • max: number

      defines the alpha remap maximal range

    Returns IParticleSystem

    the current particle system

addAngularSpeedGradient

Find examples in Playground
  • Adds a new angular speed gradient

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the angular speed to affect to the specified gradient

    Returns GPUParticleSystem

    the current particle system

addColorGradient

Find examples in Playground
  • Adds a new color gradient

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • color1: Color4

      defines the color to affect to the specified gradient

    • Optional color2: Color4

      defines an additional color used to define a range ([color, color2]) with main color to pick the final color from

    Returns GPUParticleSystem

    the current particle system

addColorRemapGradient

Find examples in Playground
  • addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • min: number

      defines the color remap minimal range

    • max: number

      defines the color remap maximal range

    Returns IParticleSystem

    the current particle system

addDragGradient

Find examples in Playground
  • Adds a new drag gradient

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the drag value to affect to the specified gradient

    Returns GPUParticleSystem

    the current particle system

addEmitRateGradient

Find examples in Playground
  • addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the emit rate value to affect to the specified gradient

    • Optional factor2: number

      defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from

    Returns IParticleSystem

    the current particle system

addLifeTimeGradient

Find examples in Playground
  • addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the life time factor to affect to the specified gradient

    • Optional factor2: number

      defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from

    Returns IParticleSystem

    the current particle system

addLimitVelocityGradient

Find examples in Playground
  • Adds a new limit velocity gradient

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the limit velocity value to affect to the specified gradient

    Returns GPUParticleSystem

    the current particle system

addRampGradient

Find examples in Playground
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • color: Color3

      defines the color to affect to the specified gradient

    Returns IParticleSystem

    the current particle system

addSizeGradient

Find examples in Playground
  • Adds a new size gradient

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the size factor to affect to the specified gradient

    Returns GPUParticleSystem

    the current particle system

addStartSizeGradient

Find examples in Playground
  • addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the start size value to affect to the specified gradient

    • Optional factor2: number

      defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from

    Returns IParticleSystem

    the current particle system

addVelocityGradient

Find examples in Playground
  • Adds a new velocity gradient

    Parameters

    • gradient: number

      defines the gradient to use (between 0 and 1)

    • factor: number

      defines the velocity to affect to the specified gradient

    Returns GPUParticleSystem

    the current particle system

animate

Find examples in Playground
  • animate(preWarm?: boolean): void
  • Animates the particle system for the current frame by emitting new particles and or animating the living ones.

    Parameters

    • Optional preWarm: boolean

      defines if we are in the pre-warmimg phase

    Returns void

clone

Find examples in Playground
  • Clones the particle system.

    Parameters

    • name: string

      The name of the cloned object

    • newEmitter: any

      The new emitter to use

    Returns GPUParticleSystem

    the cloned particle system

createBoxEmitter

Find examples in Playground
  • Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)

    Parameters

    • direction1: Vector3

      Particles are emitted between the direction1 and direction2 from within the box

    • direction2: Vector3

      Particles are emitted between the direction1 and direction2 from within the box

    • minEmitBox: Vector3

      Particles are emitted from the box between minEmitBox and maxEmitBox

    • maxEmitBox: Vector3

      Particles are emitted from the box between minEmitBox and maxEmitBox

    Returns BoxParticleEmitter

    the emitter

createConeEmitter

Find examples in Playground

createCylinderEmitter

Find examples in Playground
  • createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter
  • Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)

    Parameters

    • Optional radius: number

      The radius of the emission cylinder

    • Optional height: number

      The height of the emission cylinder

    • Optional radiusRange: number

      The range of emission [0-1] 0 Surface only, 1 Entire Radius

    • Optional directionRandomizer: number

      How much to randomize the particle direction [0-1]

    Returns CylinderParticleEmitter

    the emitter

createDirectedCylinderEmitter

Find examples in Playground
  • Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)

    Parameters

    • Optional radius: number

      The radius of the cylinder to emit from

    • Optional height: number

      The height of the emission cylinder

    • Optional radiusRange: number

      the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)

    • Optional direction1: Vector3

      Particles are emitted between the direction1 and direction2 from within the cylinder

    • Optional direction2: Vector3

      Particles are emitted between the direction1 and direction2 from within the cylinder

    Returns CylinderDirectedParticleEmitter

    the emitter

createDirectedSphereEmitter

Find examples in Playground

createHemisphericEmitter

Find examples in Playground

createPointEmitter

Find examples in Playground

createSphereEmitter

Find examples in Playground

dispose

Find examples in Playground
  • dispose(disposeTexture?: boolean): void
  • Disposes the particle system and free the associated resources

    Parameters

    • Optional disposeTexture: boolean

      defines if the particule texture must be disposed as well (true by default)

    Returns void

getAlphaRemapGradients

Find examples in Playground

getAngularSpeedGradients

Find examples in Playground

getCapacity

Find examples in Playground
  • getCapacity(): number
  • Gets the maximum number of particles active at the same time.

    Returns number

    The max number of active particles.

getClassName

Find examples in Playground
  • getClassName(): string
  • Returns the string "GPUParticleSystem"

    Returns string

    a string containing the class name

getColorGradients

Find examples in Playground

getColorRemapGradients

Find examples in Playground

getDragGradients

Find examples in Playground

getEmitRateGradients

Find examples in Playground

getLifeTimeGradients

Find examples in Playground

getLimitVelocityGradients

Find examples in Playground

getRampGradients

Find examples in Playground

getScene

Find examples in Playground

getSizeGradients

Find examples in Playground

getStartSizeGradients

Find examples in Playground

getVelocityGradients

Find examples in Playground

isReady

Find examples in Playground
  • isReady(): boolean
  • Is this system ready to be used/rendered

    Returns boolean

    true if the system is ready

isStarted

Find examples in Playground
  • isStarted(): boolean
  • Gets if the system has been started. (Note: this will still be true after stop is called)

    Returns boolean

    True if it has been started, otherwise false.

rebuild

Find examples in Playground
  • rebuild(): void

removeAlphaRemapGradient

Find examples in Playground
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to remove

    Returns IParticleSystem

    the current particle system

removeAngularSpeedGradient

Find examples in Playground

removeColorGradient

Find examples in Playground

removeColorRemapGradient

Find examples in Playground
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to remove

    Returns IParticleSystem

    the current particle system

removeDragGradient

Find examples in Playground

removeEmitRateGradient

Find examples in Playground

removeLifeTimeGradient

Find examples in Playground

removeLimitVelocityGradient

Find examples in Playground

removeRampGradient

Find examples in Playground
  • Not supported by GPUParticleSystem

    Parameters

    • gradient: number

      defines the gradient to remove

    Returns IParticleSystem

    the current particle system

removeSizeGradient

Find examples in Playground

removeStartSizeGradient

Find examples in Playground

removeVelocityGradient

Find examples in Playground

render

Find examples in Playground
  • render(preWarm?: boolean): number
  • Renders the particle system in its current state

    Parameters

    • Optional preWarm: boolean

      defines if the system should only update the particles but not render them

    Returns number

    the current number of particles

reset

Find examples in Playground
  • reset(): void

serialize

Find examples in Playground
  • serialize(): any
  • Serializes the particle system to a JSON object.

    Returns any

    the JSON object

start

Find examples in Playground
  • start(delay?: number): void
  • Starts the particle system and begins to emit

    Parameters

    • Optional delay: number

      defines the delay in milliseconds before starting the system (this.startDelay by default)

    Returns void

stop

Find examples in Playground
  • stop(): void

Static Parse

Find examples in Playground
  • Parses a JSON object to create a GPU particle system.

    Parameters

    • parsedParticleSystem: any

      The JSON object to parse

    • scene: Scene

      The scene to create the particle system in

    • rootUrl: string

      The root url to use to load external dependencies like texture

    • Optional doNotStart: boolean

      Ignore the preventAutoStart attribute and does not start

    Returns GPUParticleSystem

    the parsed GPU particle system

Generated using TypeDoc