Renderer · class

BoltBatch

One draw call for a pool of electrical arcs.

Explained in Hello world.

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

In depth

Four vertices per segment rather than instancing, because a segment's two endpoints are its geometry — there is no repeated base shape to instance, and an instanced version would upload the same two positions per vertex anyway.

Additive and depth-tested without writing depth, like every other emissive effect here: an arc adds light to what is behind it and must not occlude whatever is drawn next.

Constructor

new

constructor(gl: WebGL2RenderingContext, capacity: number, label: string)
ParameterTypeDescription
glWebGL2RenderingContext
capacitynumber
labelstring

Properties

NameTypeDescription
programreadonlyWebGLProgram
uniformsreadonlyRecord<string, WebGLUniformLocation>

Methods

upload

upload(gl: WebGL2RenderingContext, data: BoltSegments): number

Send this frame's arcs, expanding each segment to its four vertices.

ParameterTypeDescription
glWebGL2RenderingContext
dataBoltSegments
More

The expansion is segmentQuads.ts's because it is a fact about how the geometry is drawn rather than about GL — the pool is deliberately GL-free and testable, and the WebGPU batch needs exactly the same four vertices.

drawTo

drawTo(gl: WebGL2RenderingContext, segmentCount: number): void
ParameterTypeDescription
glWebGL2RenderingContext
segmentCountnumber

dispose

dispose(gl: WebGL2RenderingContext): void
ParameterTypeDescription
glWebGL2RenderingContext