Renderer · class

ParticleBatch

Explained in Hello world.

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

Constructor

new

constructor(gl: WebGL2RenderingContext, capacity: number, options: ParticleBatchOptions)
ParameterTypeDescription
glWebGL2RenderingContext
capacitynumber
optionsParticleBatchOptions

Properties

NameTypeDescription
programreadonlyWebGLProgram
uniformsreadonlyRecord<string, WebGLUniformLocation>
texturereadonlySurfaceTexture | nullThe sprite's own: its image, its flipbook and its fades. See ParticleBatchOptions.
cellsreadonlyreadonly [number, number]
blendCellsreadonlyboolean
softDepthreadonlynumber
cameraFadereadonlynumber
cameraOffsetreadonlynumber
materialreadonlyParticleMaterialWhich material compiled this batch's program, so reuse can be checked.

Methods

upload

upload(gl: WebGL2RenderingContext, given: ParticleInstances, eye: ArrayLike<number>): void

Send this frame's particles.

ParameterTypeDescription
glWebGL2RenderingContext
givenParticleInstances
eyeArrayLike<number>
More

Only the live prefix of each array, which is what the pool's compaction exists for: a pool at a tenth of its capacity uploads a tenth of the bytes.

bindMaterial

bindMaterial(gl: WebGL2RenderingContext): void

Bind this material's own constants. Called once per draw, before drawTo.

ParameterTypeDescription
glWebGL2RenderingContext

drawTo

drawTo(gl: WebGL2RenderingContext, count: number): void

Draw the live particles.

ParameterTypeDescription
glWebGL2RenderingContext
countnumber
More

Depth tested but not written, so a puff is correctly hidden behind the deck and never hides a puff behind it. Culling off, because a blade seen from behind is exactly as valid as one seen from the front.

dispose

dispose(gl: WebGL2RenderingContext): void
ParameterTypeDescription
glWebGL2RenderingContext