Skip to content

Class: MaskTreePlanner<T> ​

Defined in: src/MaskTree.ts:63

One mask set for a whole instance tree. SpriteStudio 7.6 masks as if every draw of the tree went through one stencil, in one sequence: a sub-animation is drawn in its instance part's place. So each writer holds over an open interval of that sequence:

  • a pure mask (PartTypeMask / draw_as_mask), from the start of its own animation to itself — it never leaves the instance it sits in;
  • a clipping writer (mask_write), from itself to the end of the tree — one written inside an instance keeps clipping the caller's later parts, at any depth.

This walks the tree depth-first, numbering every draw-order rank of every visible context (a sub-animation right after its instance part), and collects the writers of all of them. A part at sequence number s is covered by the writers whose open < s and s < close (or close < 0). How that is then drawn — a coverage bitmap in ssplayer-pixi, the stencil in ssplayer-webgl — is the renderer's.

A writer's op follows its effective mask_influence: its own AND its instance part's, one level deep, like any target (see MaskComposition).

Output is reusable SoA, valid until the next plan() call. Allocation-free in steady state; a context's sequence array is allocated the first time it is seen or grows.

Type Parameters ​

T ​

T extends InternalPlayerBase<T>

Constructors ​

Constructor ​

new MaskTreePlanner<T>(capacity?): MaskTreePlanner<T>

Defined in: src/MaskTree.ts:103

capacity is the renderer's budget for the whole tree: a coverage bitmap needs a bit per writer, a stencil only a counter deep enough for the writers overlapping at one pixel. Each context still plans at most MAX_MASK_WRITERS of its own.

Parameters ​

capacity? ​

number = MAX_MASK_WRITERS

Returns ​

MaskTreePlanner<T>

Properties ​

capacity ​

readonly capacity: number

Defined in: src/MaskTree.ts:65

Writers the tree can hold; past it they are dropped and exceeded is set.


close ​

readonly close: Float32Array

Defined in: src/MaskTree.ts:73

Interval end on the tree sequence (exclusive); -1 for a clipping writer, which holds to the end of the tree. A sentinel rather than a large number so the replay's comparisons stay exact at shader precisions.


count ​

count: number = 0

Defined in: src/MaskTree.ts:81

Writers found by the last plan().


exceeded ​

exceeded: boolean = false

Defined in: src/MaskTree.ts:83

True when the tree held more writers than there are bits (extras dropped).


isClipping ​

readonly isClipping: Uint8Array

Defined in: src/MaskTree.ts:77

1 = clipping writer, 0 = pure mask.


meta ​

readonly meta: Float32Array

Defined in: src/MaskTree.ts:79

Replay metadata (open, close, bit, opInvert) x capacity; bit === index.


open ​

readonly open: Float32Array

Defined in: src/MaskTree.ts:67

Interval start on the tree sequence (exclusive).


opInvert ​

readonly opInvert: Uint8Array

Defined in: src/MaskTree.ts:75

Effective op: 1 = invert (mask_influence 1), 0 = increment.

Methods ​

plan() ​

plan(root, frameData, matrix, visitor): number

Defined in: src/MaskTree.ts:126

Number the tree under root and collect its writers. frameData is the root's frame and matrix its placement; instance children are reached through the same resolver the renderers draw them with, so exactly the sub-animations that are drawn are numbered.

Asks the runtime for each visible child's frame, which can grow WASM memory: a caller holding views into it re-derives them afterwards.

A tree with no part that can write a mask is not walked: it returns 0 and numbers nothing.

Parameters ​

root ​

T

frameData ​

FrameData

matrix ​

Float32Array<ArrayBufferLike> | null

visitor ​

MaskTreeVisitor<T>

Returns ​

number


seqOf() ​

seqOf(player): Float32Array<ArrayBufferLike> | undefined

Defined in: src/MaskTree.ts:140

Sequence number of each draw-order rank of player, as numbered by the last plan() that found writers. Undefined for a player that was not part of it.

Parameters ​

player ​

T

Returns ​

Float32Array<ArrayBufferLike> | undefined