Skip to content

Class: GeometryBuilder ​

Defined in: src/GeometryBuilder.ts:18

Encapsulates purely mathematical geometry operations:

  • World Matrix multiplication
  • PartsColor / vertex color synthesis
  • Shape bilinear interpolation
  • UV generation

Constructors ​

Constructor ​

new GeometryBuilder(runtimeManager): GeometryBuilder

Defined in: src/GeometryBuilder.ts:68

Parameters ​

runtimeManager ​

SSRuntimeManager

Returns ​

GeometryBuilder

Properties ​

parentMatrix ​

parentMatrix: Float32Array<ArrayBufferLike> | null = null

Defined in: src/GeometryBuilder.ts:43

Optional parent 2D-affine applied to every emitted world position, packed as [m00, m01, m10, m11, tx, ty]. Used when this builder renders an instance-part child animation: the child computes its geometry in its own local space, and this matrix (the parent instance part's world transform, accumulated through any nesting) places it under the parent. null = the builder renders a root animation and emits world positions unchanged.

Methods ​

buildEffectCommand() ​

buildEffectCommand(partIdx, plan, particleOffset, quadCount, outPositions, outUvs, outColors, outIndices, vertexOffset?, indexOffset?, partAlpha?): void

Defined in: src/GeometryBuilder.ts:497

Builds geometry for a single Effect draw command (one emitter group of particle quads) out of an EffectDrawPlan.

The plan's flat verts/uvs/colors/indices arrays are sliced by the command's particleOffset/quadCount. Particle vertices are produced by the WASM runtime in the effect's local space (y-flip already applied), so the effect part's world matrix is baked in here, matching buildNormal/ buildShape/buildMesh. UVs and colors are emitted normalized (0..1) by the runtime and copied through unchanged. Indices are command-local 0-based.

vertexOffset / indexOffset let several commands be packed into a single shared buffer (effect dynamic batching): each command writes its vertices starting at vertexOffset, and its indices — rebased by vertexOffset — starting at indexOffset. partAlpha folds the effect part's own opacity into the per-vertex alpha so one merged Mesh can carry commands from parts with differing alpha under a single mesh alpha.

Parameters ​

partIdx ​

number

plan ​

EffectDrawPlan

particleOffset ​

number

quadCount ​

number

outPositions ​

Float32Array

outUvs ​

Float32Array

outColors ​

Float32Array

outIndices ​

Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

vertexOffset? ​

number = 0

indexOffset? ​

number = 0

partAlpha? ​

number = 1

Returns ​

void


buildMesh() ​

buildMesh(partIdx, frameData, pCount, iCount, invTexW, invTexH, outPositions, outUvs, outColors, outCustom0, outIndices, vertexOffset?, indexOffset?): void

Defined in: src/GeometryBuilder.ts:393

Builds geometry for a Skinned Mesh part. vertexOffset / indexOffset pack several parts into one shared buffer; indices are rebased by vertexOffset.

Parameters ​

partIdx ​

number

frameData ​

FrameData

pCount ​

number

iCount ​

number

invTexW ​

number

invTexH ​

number

outPositions ​

Float32Array

outUvs ​

Float32Array

outColors ​

Float32Array

outCustom0 ​

Float32Array

outIndices ​

Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

vertexOffset? ​

number = 0

indexOffset? ​

number = 0

Returns ​

void


buildNormal() ​

buildNormal(partIdx, frameData, invTexW, invTexH, outPositions, outUvs, outColors, outCustom0, vertexOffset?): void

Defined in: src/GeometryBuilder.ts:145

Builds geometry for a Normal part.

vertexOffset packs several parts into one shared buffer, as in buildEffectCommand.

Parameters ​

partIdx ​

number

frameData ​

FrameData

invTexW ​

number

invTexH ​

number

outPositions ​

Float32Array

outUvs ​

Float32Array

outColors ​

Float32Array

outCustom0 ​

Float32Array

vertexOffset? ​

number = 0

Returns ​

void


buildShape() ​

buildShape(partIdx, frameData, numVerts, invTexW, invTexH, outPositions, outUvs, outColors, outCustom0, outIndices, vertexOffset?, indexOffset?): void

Defined in: src/GeometryBuilder.ts:242

Builds geometry for a Shape part. vertexOffset / indexOffset pack several parts into one shared buffer; indices are rebased by vertexOffset.

Parameters ​

partIdx ​

number

frameData ​

FrameData

numVerts ​

number

invTexW ​

number

invTexH ​

number

outPositions ​

Float32Array

outUvs ​

Float32Array

outColors ​

Float32Array

outCustom0 ​

Float32Array

outIndices ​

Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

vertexOffset? ​

number = 0

indexOffset? ​

number = 0

Returns ​

void


updateWorldPositions() ​

updateWorldPositions(): void

Defined in: src/GeometryBuilder.ts:102

Marks the views over the geometry stale; the first build of each kind fetches its own afterwards. Must be called once per frame, after the frame data and before building geometry.

Returns ​

void


composeAffine() ​

static composeAffine(parent, child, out?): Float32Array

Defined in: src/GeometryBuilder.ts:79

Compose two 2D affines (each [m00, m01, m10, m11, tx, ty]) so the result applied to a point equals parent(child(point)). When parent is null (the identity case) the result is just child: copied into out when provided (so callers can keep a stable per-child buffer), else returned directly with no allocation.

Parameters ​

parent ​

Float32Array<ArrayBufferLike> | null

child ​

Float32Array

out? ​

Float32Array<ArrayBufferLike>

Returns ​

Float32Array