Skip to main content

Overview

The Rectangle primitive represents a closed rectangular path in 3D space. It is defined by a center point, width (along the X-axis), and breadth (along the Z-axis). The rectangle lies in the XZ plane with Y as the normal direction. Use Cases:
  • Creating rectangular shapes and boundaries
  • Base profiles for extrusion
  • Floor plans and section cuts
  • Offset operations for creating concentric rectangles

Constructor

Rust Constructor Parameters

id
String
required
Unique identifier for the rectangle instance

TypeScript Constructor Parameters

options
IRectangleOptions
Configuration options for the rectangle
options.ogid
string
Optional unique identifier (auto-generated if not provided)
options.center
Vector3
required
Center point of the rectangle
options.width
number
required
Width of the rectangle along the X-axis
options.breadth
number
required
Breadth of the rectangle along the Z-axis
options.color
number
required
Rectangle color as a hexadecimal number (e.g., 0x00ff00 for green)

Methods

set_config

Updates the rectangle’s geometric parameters.

generate_geometry

Generates four vertices forming the rectangle and creates edges connecting them. The geometry includes a face for the closed rectangle.

get_geometry_serialized

Returns serialized vertex buffer data including the closing vertex (first vertex repeated).

get_offset_serialized

Generates an offset rectangle at the specified distance. Positive distances create larger rectangles, negative distances create smaller ones.
distance
number
required
Distance to offset the rectangle (positive = outward, negative = inward)
acuteThresholdDegrees
number
default:"35.0"
Angle threshold for beveling acute corners
bevel
boolean
default:"true"
Enable beveling at acute angles

get_brep_serialized

Returns the complete BREP representation including vertices, edges, and face.

getConfig

Returns the current rectangle configuration.

discardGeometry

Disposes of the current geometry.

Properties

id
String
Unique identifier for the rectangle instance
center
Vector3
Center point of the rectangle (default: origin)
width
f64
Width along the X-axis (default: 1.0)
breadth
f64
Breadth along the Z-axis (default: 1.0)
brep
Brep
Internal BREP representation with 4 vertices, 4 edges, and 1 face
color
number
Rectangle color (TypeScript only, settable)

Code Examples

Creating a Basic Rectangle

Creating a Square

Generating Offset Rectangles

Creating Concentric Rectangles

Updating Rectangle Dimensions

Getting Rectangle Vertices

Live Demo

Rectangle Demo

Try the Rectangle primitive in the browser

See Also

Polygon

Complex 2D shapes with holes

Polyline

Connected line segments

Line

Straight line segments
Last modified on March 14, 2026