Skip to main content

Overview

The ArcPrimitive class creates a circular arc segment defined by a center point, radius, and start/end angles. It extends the kernel Arc class and implements the IPrimitive interface for selection and editing capabilities.

Constructor

new ArcPrimitive(arcConfig?: ArcOptions)
arcConfig
ArcOptions
Configuration object for the arc primitive

ArcOptions

ogid
string
Unique identifier for the arc object. Auto-generated if not provided.
center
Array<number>
required
Center point coordinates as [x, y, z]
radius
number
required
Radius of the arc
startAngle
number
required
Starting angle in radians
endAngle
number
required
Ending angle in radians
segments
number
required
Number of segments to approximate the arc curve. Higher values create smoother arcs.
color
number
required
Arc color as hexadecimal number (e.g., 0xFF0000 for red)

Properties

arcCenter
Vector3
Sets the center point of the arc. Updates geometry automatically.
arcRadius
number
Gets or sets the arc radius. Updates geometry automatically.
arcStartAngle
number
Gets or sets the starting angle in radians. Updates geometry automatically.
arcEndAngle
number
Gets or sets the ending angle in radians. Updates geometry automatically.
arcSegments
number
Gets or sets the number of segments. Updates geometry automatically.
arcColor
number
Gets or sets the arc color. Updates appearance automatically.
selected
boolean
Indicates whether the arc is currently selected
edit
boolean
Indicates whether the arc is in edit mode
ogType
string
Returns 'ArcPrimitive' - the type identifier

Methods

getOPConfig()

Returns the current configuration of the arc.
getOPConfig(): ArcOptions
Returns: ArcOptions - Current arc configuration

setOPGeometry()

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

Examples

Create a Semicircle

import { ArcPrimitive } from 'openplans';

const semicircle = new ArcPrimitive({
  center: [0, 0, 0],
  radius: 5,
  startAngle: 0,
  endAngle: Math.PI, // 180 degrees
  segments: 16,
  color: 0x000000
});

Create a Full Circle

const circle = new ArcPrimitive({
  center: [10, 0, 0],
  radius: 3,
  startAngle: 0,
  endAngle: Math.PI * 2, // 360 degrees
  segments: 32,
  color: 0x0000FF // Blue
});

Create a Quarter Arc

const quarterArc = new ArcPrimitive({
  center: [0, 0, 0],
  radius: 10,
  startAngle: 0,
  endAngle: Math.PI / 2, // 90 degrees
  segments: 16,
  color: 0xFF0000 // Red
});

Update Arc Properties

// Increase radius
quarterArc.arcRadius = 15;

// Make it smoother
quarterArc.arcSegments = 32;

// Change color to green
quarterArc.arcColor = 0x00FF00;

Get Arc Configuration

const config = semicircle.getOPConfig();
console.log(config);
// Output:
// {
//   ogid: 'auto-generated-id',
//   center: [0, 0, 0],
//   radius: 5,
//   startAngle: 0,
//   endAngle: 3.14159...,
//   segments: 16,
//   color: 0x000000
// }
Last modified on March 7, 2026