Skip to main content

Board

The Board class represents a drawing board or canvas element in OpenPlans. It extends the Polygon class and provides a 2D surface for organizing and containing other architectural elements. Boards can have multiple layers for organizing different types of elements.

Constructor

new Board(boardConfig?: BoardOptions)
boardConfig
BoardOptions
Optional configuration object for the board. If not provided, default values will be used.

Properties

ogType
string
The element type identifier. Always set to 'BOARD'.
propertySet
BoardOptions
The current configuration of the board including dimensions, color, and layers.
subElements
Map<string, THREE.Object3D>
Map containing sub-elements added to the board.
selected
boolean
Indicates whether the board is currently selected.
edit
boolean
Indicates whether the board is in edit mode.

Getters & Setters

labelName
string
The display name of the board element. Updates the visual label.
width
number
The width of the board in meters.
height
number
The height of the board in meters.
start
{ x: number, y: number, z: number }
The starting corner position of the board.
boardColor
number
The hexadecimal color value for the board.

Methods

setOPConfig

setOPConfig(propertySet: BoardOptions): void
Updates the board configuration.
propertySet
BoardOptions
New configuration object for the board.

getOPConfig

getOPConfig(): BoardOptions
Returns the current board configuration. Returns: BoardOptions - The current board configuration object.

setOPGeometry

setOPGeometry(): void
Rebuilds the board geometry based on the current configuration. Calculates coordinates and updates the polygon shape.

setOPMaterial

setOPMaterial(): void
Updates the material properties of the board.

dispose

dispose(): void
Cleans up geometry, removes labels, and removes the board from the scene.

BoardOptions

The configuration interface for board elements.

Properties

ogid
string
Unique identifier for the board element.
center
object
required
Center point of the board (calculated automatically).
color
number
required
Hexadecimal color value for the board (e.g., 0xFFFFFF for white).
type
'BOARD'
required
Element type identifier.
coordinates
Array<[number, number, number]>
required
Array of 4 corner coordinate points defining the board geometry in anti-clockwise order, starting from top-left. Calculated automatically.
labelName
string
required
Display name for the board.
dimensions
object
required
Dimensions configuration for the board.
layers
string[]
Array of layer names for organizing elements on the board (e.g., [‘walls’, ‘furniture’, ‘dimensions’]).

Example

import { Board } from 'openplans';

// Create a board with default configuration
const board = new Board();

// Create a custom drawing board
const floorPlanBoard = new Board({
  center: { x: 0, y: 0, z: 0 },
  color: 0xFFFFFF,
  type: 'BOARD',
  coordinates: [],
  labelName: 'Ground Floor Plan',
  dimensions: {
    start: { x: 0, y: 0, z: 0 },
    end: { x: 20, y: -20, z: 0 },
    width: 20,
    height: 20,
  },
  layers: ['walls', 'doors', 'windows', 'furniture', 'dimensions'],
});

// Update board properties
floorPlanBoard.width = 25;
floorPlanBoard.height = 30;
floorPlanBoard.labelName = 'First Floor Plan';
floorPlanBoard.boardColor = 0xF0F0F0;

// Adjust starting position
floorPlanBoard.start = { x: -10, y: 10, z: 0 };

// Get current configuration
const config = floorPlanBoard.getOPConfig();
console.log(`Board area: ${config.dimensions.width * config.dimensions.height} m²`);
console.log(`Board has ${config.layers?.length || 0} layers`);

// Clean up when done
floorPlanBoard.dispose();

Usage Notes

  • The board is positioned in the XY plane and rotated to face the camera
  • Coordinates are calculated anti-clockwise starting from the top-left corner
  • The board serves as a container for other architectural elements
  • Layers can be used to organize different types of elements for better management
  • The label is displayed using CSS2D rendering for clear visibility
  • The board is positioned slightly below y=0 (at y=-0.01) to avoid z-fighting with other elements

Layer Organization

Common layer naming conventions:
  • 'walls' - Wall elements
  • 'doors' - Door elements
  • 'windows' - Window elements
  • 'furniture' - Furniture and fixtures
  • 'dimensions' - Dimension lines and annotations
  • 'grid' - Grid lines and reference lines
  • 'text' - Text labels and notes
Last modified on March 7, 2026