Skip to main content

Overview

The LinePrimitive class creates a straight line segment between two points in 3D space. It extends the kernel Line class and implements the IPrimitive interface for selection and editing capabilities.

Constructor

new LinePrimitive(lineConfig?: LineOptions)
lineConfig
LineOptions
Configuration object for the line primitive

LineOptions

ogid
string
Unique identifier for the line object. Auto-generated if not provided.
startPoint
Array<number>
required
Starting point coordinates as [x, y, z]
endPoint
Array<number>
required
Ending point coordinates as [x, y, z]
color
number
required
Line color as hexadecimal number (e.g., 0xFF0000 for red)

Properties

startPoint
Array<number>
Gets or sets the starting point of the line. Updates geometry automatically.
endPoint
Array<number>
Gets or sets the ending point of the line. Updates geometry automatically.
lineColor
number
Gets or sets the line color. Updates appearance automatically.
selected
boolean
Indicates whether the line is currently selected
edit
boolean
Indicates whether the line is in edit mode
ogType
string
Returns 'LinePrimitive' - the type identifier

Methods

getOPConfig()

Returns the current configuration of the line.
getOPConfig(): LineOptions
Returns: LineOptions - Current line configuration

setOPGeometry()

Updates the line geometry based on current property values. Called automatically when properties change.
setOPGeometry(): void

Examples

Create a Basic Line

import { LinePrimitive } from 'openplans';

const line = new LinePrimitive({
  startPoint: [0, 0, 0],
  endPoint: [10, 5, 0],
  color: 0x000000
});

Update Line Position

// Move the end point
line.endPoint = [15, 10, 0];

// Change line color to red
line.lineColor = 0xFF0000;

Get Line Configuration

const config = line.getOPConfig();
console.log(config);
// Output:
// {
//   ogid: 'auto-generated-id',
//   startPoint: [0, 0, 0],
//   endPoint: [15, 10, 0],
//   color: 0xFF0000
// }

Create a Diagonal Line

const diagonal = new LinePrimitive({
  startPoint: [0, 0, 0],
  endPoint: [10, 10, 10],
  color: 0x00FF00 // Green
});
Last modified on March 7, 2026