Skip to content

Class: LinePrimitive ​

Experimental

Thick anti-aliased polylines with joins, caps, dashes, per-vertex color and per-segment width, drawn in a single instanced draw call.

Implements ​

Constructors ​

Constructor ​

ts
new LinePrimitive(
   ctx,
   data?,
   options?
): LinePrimitive;

Experimental

Parameters ​

ParameterType
ctxPrimitiveContext
dataPartial<LineData>
optionsLinePrimitiveOptions

Returns ​

LinePrimitive

Properties ​

PropertyModifierTypeDescription
objectreadonlyMesh<InstancedBufferGeometry, ShaderMaterial>Experimental The mesh to add to a scene.

Accessors ​

instanceCount ​

Get Signature ​

ts
get instanceCount(): number;

Experimental

Number of segment instances currently drawn (including culled gap instances).

Returns ​

number


stream ​

Get Signature ​

ts
get stream(): Readonly<{
  capacity: number;
  head: number;
  origin: Readonly<Vec3>;
  sourceBase: number;
  vertexCount: number;
}>;

Experimental

The live vertex stream (debugging, tests): first vertex, vertex count, source serial base (see LineLayout), the RTC origin and the allocated capacity.

Returns ​

Readonly<{ capacity: number; head: number; origin: Readonly<Vec3>; sourceBase: number; vertexCount: number; }>

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


splice() ​

ts
splice(
   x,
   y,
   retain
): void;

Experimental

Streaming geometry update (E7.2): equivalent to update({ x, y }), given that input vertices [retain.at, retain.at + retain.to - retain.from) of x/y equal vertices [retain.from, retain.to) of the previous input (the caller guarantees it). Only the vertex stream before and after that range is rebuilt and uploaded; the retained vertices stay where they are in the buffers and the live range slides.

Falls back to a full update for 3D (z), multiple polylines (starts), per-point colors or widths, or when the buffers have no room at the growing end (then the stream is rebuilt with slack for the next edits). Dashed lines recompute their phase (O(n) CPU, one small upload).

Parameters ​

ParameterType
xNumericArray
yNumericArray
retainLineRetain

Returns ​

void


update() ​

ts
update(patch): void;

Experimental

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

Parameters ​

ParameterType
patchPartial<LineData>

Returns ​

void

Implementation of ​

Primitive.update

Released under the MIT License.