---
url: https://cri-middleware.github.io/SSPlayerForWeb/api/@spritestudio/ssplayer-webgl/classes/GeometryBuilder.md
---
# Class: GeometryBuilder

Defined in: ssplayer-core/dist/index.d.ts:2678

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: ssplayer-core/dist/index.d.ts:2713

#### Parameters

##### runtimeManager

[`SSRuntimeManager`](SSRuntimeManager.md)

#### Returns

`GeometryBuilder`

## Properties

### parentMatrix

> **parentMatrix**: `Float32Array`<`ArrayBufferLike`> | `null`

Defined in: ssplayer-core/dist/index.d.ts:2702

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: ssplayer-core/dist/index.d.ts:2766

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`](EffectDrawPlan.md)

##### particleOffset

`number`

##### quadCount

`number`

##### outPositions

`Float32Array`

##### outUvs

`Float32Array`

##### outColors

`Float32Array`

##### outIndices

`Uint16Array`<`ArrayBufferLike`> | `Uint32Array`<`ArrayBufferLike`>

##### vertexOffset?

`number`

##### indexOffset?

`number`

##### partAlpha?

`number`

#### Returns

`void`

***

### buildMesh()

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

Defined in: ssplayer-core/dist/index.d.ts:2747

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`](FrameData.md)

##### pCount

`number`

##### iCount

`number`

##### invTexW

`number`

##### invTexH

`number`

##### outPositions

`Float32Array`

##### outUvs

`Float32Array`

##### outColors

`Float32Array`

##### outCustom0

`Float32Array`

##### outIndices

`Uint16Array`<`ArrayBufferLike`> | `Uint32Array`<`ArrayBufferLike`>

##### vertexOffset?

`number`

##### indexOffset?

`number`

#### Returns

`void`

***

### buildNormal()

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

Defined in: ssplayer-core/dist/index.d.ts:2737

Builds geometry for a Normal part.

`vertexOffset` packs several parts into one shared buffer, as in
[buildEffectCommand](#buildeffectcommand).

#### Parameters

##### partIdx

`number`

##### frameData

[`FrameData`](FrameData.md)

##### invTexW

`number`

##### invTexH

`number`

##### outPositions

`Float32Array`

##### outUvs

`Float32Array`

##### outColors

`Float32Array`

##### outCustom0

`Float32Array`

##### vertexOffset?

`number`

#### Returns

`void`

***

### buildShape()

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

Defined in: ssplayer-core/dist/index.d.ts:2742

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`](FrameData.md)

##### numVerts

`number`

##### invTexW

`number`

##### invTexH

`number`

##### outPositions

`Float32Array`

##### outUvs

`Float32Array`

##### outColors

`Float32Array`

##### outCustom0

`Float32Array`

##### outIndices

`Uint16Array`<`ArrayBufferLike`> | `Uint32Array`<`ArrayBufferLike`>

##### vertexOffset?

`number`

##### indexOffset?

`number`

#### Returns

`void`

***

### updateWorldPositions()

> **updateWorldPositions**(): `void`

Defined in: ssplayer-core/dist/index.d.ts:2727

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: ssplayer-core/dist/index.d.ts:2721

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`
