Skip to main content

Overview

The Polyline primitive represents a connected sequence of line segments in 3D space. It is defined by a series of points and can be either open or closed. When the first and last points coincide, the polyline automatically detects and creates a closed loop. Use Cases:
  • Creating complex paths and contours
  • Defining irregular shapes
  • Profile curves for extrusion
  • Offset operations for parallel paths
  • Closed polygons and open paths

Constructor

Rust Constructor Parameters

id
String
required
Unique identifier for the polyline instance

TypeScript Constructor Parameters

options
IPolylineOptions
Configuration options for the polyline
options.ogid
string
Optional unique identifier (auto-generated if not provided)
options.points
Vector3[]
required
Array of points defining the polyline path
options.color
number
required
Polyline color as a hexadecimal number (e.g., 0x00ff00 for green)
options.fatLines
boolean
default:"false"
Enable thick line rendering using Line2
options.width
number
default:"20"
Line width when fatLines is enabled

Methods

set_config

Updates the polyline’s points and automatically checks if it’s closed.

add_point

Adds a single point to the polyline and regenerates the geometry.

add_multiple_points

Replaces all points with the provided array.

generate_geometry

Generates vertices and edges from the points. For closed polylines, creates a face and the closing edge.

get_geometry_serialized

Returns serialized vertex buffer data. For closed polylines, includes the first vertex repeated at the end.

get_offset_serialized

Generates an offset path parallel to the polyline. The behavior differs for open vs. closed polylines.
distance
number
required
Distance to offset the polyline (positive or negative)
acuteThresholdDegrees
number
default:"35.0"
Angle threshold for beveling acute corners
bevel
boolean
default:"true"
Enable beveling at acute angles

is_closed

Returns whether the polyline forms a closed loop.

get_points

Returns serialized points as JSON.

get_brep_serialized

Returns the complete BREP representation.

Properties

id
String
Unique identifier for the polyline instance
points
Vec<Vector3>
Array of points defining the polyline path
is_closed
bool
Whether the polyline forms a closed loop (automatically detected)
brep
Brep
Internal BREP representation containing vertices, edges, and optionally a face for closed polylines
isClosed
boolean
Indicates if the polyline is closed (TypeScript property)
color
number
Polyline color (TypeScript only, settable)

Code Examples

Creating an Open Polyline

Creating a Closed Polygon

Adding Points Incrementally

Generating Offset Polylines

Using Fat Lines

Complex Path Example

Live Demo

Polyline Demo

Try the Polyline primitive in the browser

See Also

Line

Straight line segments

Arc

Circular arc segments

Curve

Smooth curves through control points
Last modified on March 14, 2026