Renderer · class

ParticlePool

Explained in Hello world.

class ParticlePool
import { ParticlePool } from '@driftengine/core';

Constructor

new

constructor(options: ParticlePoolOptions)
ParameterTypeDescription
optionsParticlePoolOptions

Properties

NameTypeDescription
instancesreadonlyInstanceData
particlesreadonlyParticleInstancesThe same particles, as a particle material wants them. See ParticleInstances.

Accessors

NameTypeDescription
livegetnumberHow many particles are alive.

Methods

emit

emit(x: number, y: number, z: number, vx: number, vy: number, vz: number, seed: number, sizeScale?: number, lifeScale?: number): void

Add one particle.

ParameterTypeDescription
xnumber
ynumber
znumber
vxnumber
vynumber
vznumber
seednumber
sizeScale?number
lifeScale?number
More

seed drives the per-particle variation instead of Math.random, so a caller inside a deterministic system can pass a tick count and get the same plume twice — which a replay needs, since the same run has to look the same on the way to being a clip.

update

update(dt: number): void

Advance every particle and rebuild the instance buffer.

ParameterTypeDescription
dtnumber
More

Compacting as it goes: live particles are written to the front of the instance data, so the draw call submits exactly the live count and dead particles cost nothing but the loop iteration.

clear

clear(): void

Drop everything, for a respawn or a scene change.