Skip to content

Class: RectPrimitive ​

Experimental

Instanced, anti-aliased rectangles with borders and rounded corners in a single draw call. Style-only updates (fill, borderColor, borderWidth/cornerRadius) re-upload only the affected instance attribute; coordinate updates re-upload the positions.

Implements ​

Constructors ​

Constructor ​

ts
new RectPrimitive(ctx, data?): RectPrimitive;

Experimental

Parameters ​

ParameterType
ctxPrimitiveContext
dataPartial<RectData>

Returns ​

RectPrimitive

Properties ​

PropertyModifierTypeDescription
objectreadonlyMeshExperimental The mesh to add to a scene.

Accessors ​

instanceCount ​

Get Signature ​

ts
get instanceCount(): number;

Experimental

Number of rect instances currently drawn.

Returns ​

number


ready ​

Get Signature ​

ts
get ready(): Promise<void>;

Experimental

Resolves once the pattern (if any) is drawn: its code loads on first use.

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<RectData>

Returns ​

void

Implementation of ​

Primitive.update

Released under the MIT License.