ParticleCollectionBuilder Namespace

Function

Name Description
ParticleCollectionBuilder.create Creates a new ParticleCollectionBuilder.

Defined in

ParticleCollectionBuilder Interface

Interface for producing a collection of particles suitable for use in particle effects. Particle effects involve animating hundreds or thousands of small particles to simulate phenomena like smoke, fire, snow, etc. A particle collection represents each particle as a quad (rectangle) displaying an image. The position of each particle corresponds to the centroid of its quad. The transparency and size of each particle can be specified individually. By default, the quads will always rotate to face the camera such that the image is fully visible.

Creating a particle collection using a ParticleCollectionBuilder is far more efficient (in both CPU and GPU usage) than doing so using a GraphicBuilder.

see interactive demonstrations of Snow and Rain and Fire and Smoke particle effects.

see SnowEffect for an example of a particle effect.

Methods

Name Description
addParticle(particle: ParticleProps): void Add a particle to the collection.  
finish(): undefined | RenderGraphic Produces a finished graphic from the accumulated particles.  

Properties

Name Type Description
size Readonly<WritableXAndY> The default size of each particle, used by ParticleCollectionBuilder.addParticle if ParticleProps.size is omitted.  
transparency number The default transparency for newly-added particles as an integer in [0,255], used by ParticleCollectionBuilder.addParticle if ParticleProps.transparency is omitted.  

Defined in

Last Updated: 11 June, 2024