Skip to content

Class: TextPrimitive ​

Experimental

Batched label set. Create with createTextPrimitive; add object to a scene.

ready resolves once every typesetting triggered so far has finished (a fresh promise after each update that re-typesets), including loading the text engine when the first labels arrive before it has loaded, and the default font faces the labels need; visual tests and chart.ready await it before capturing.

Implements ​

Constructors ​

Constructor ​

ts
new TextPrimitive(context, options?): TextPrimitive;

Experimental

Parameters ​

ParameterType
contextPrimitiveContext
optionsTextPrimitiveOptions

Returns ​

TextPrimitive

Properties ​

PropertyModifierTypeDescription
objectreadonlyObject3DExperimental Root to add to a scene: a plain Object3D holding the troika BatchedText once the text engine has loaded. Its renderOrder is forwarded to the batch (a plain parent's order would not affect its children's sorting, and a Group's would sort them apart from sibling primitives).

Accessors ​

decorationCount ​

Get Signature ​

ts
get decorationCount(): number;

Experimental

Number of decoration lines drawn (font.lineposition), for debugging and tests.

Returns ​

number


pooledCount ​

Get Signature ​

ts
get pooledCount(): number;

Experimental

Number of pooled (idle) troika members, for debugging and tests.

Returns ​

number


ready ​

Get Signature ​

ts
get ready(): Promise<void>;

Experimental

Resolves when all typesetting requested so far has completed and been packed, including loading the text engine first if labels arrived before it had loaded, and the default font faces the labels are drawn with.

Returns ​

Promise<void>

Methods ​

dispose() ​

ts
dispose(): void;

Experimental

Release GPU resources. The primitive must not be used afterwards.

Returns ​

void

Implementation of ​

Primitive.dispose


setTransform() ​

ts
setTransform(transform): void;

Experimental

Set the data → world transform (cheap: uniforms only, no buffer uploads).

Parameters ​

ParameterType
transformDataTransform

Returns ​

void

Implementation of ​

Primitive.setTransform


setViewport() ​

ts
setViewport(size): void;

Experimental

Update viewport-dependent uniforms (resolution, pixel ratio).

Parameters ​

ParameterType
sizeViewportSize

Returns ​

void

Implementation of ​

Primitive.setViewport


update() ​

ts
update(patch): void;

Experimental

Replace or patch the primitive's data. Omitted fields keep their previous values.

Parameters ​

ParameterType
patchPartial<TextData>

Returns ​

void

Implementation of ​

Primitive.update


whenReady() ​

ts
whenReady(): Promise<void>;

Experimental

Same as ready, as a method.

Returns ​

Promise<void>

Released under the MIT License.