Skip to main content

BaseStair

The BaseStair class represents a staircase element in OpenPlans. It extends THREE.Group and provides functionality for creating customizable staircases with various types, including straight, L-shaped, U-shaped, spiral, and winder configurations.

Constructor

new BaseStair(baseStairConfig?: OPStair)
baseStairConfig
OPStair
Optional configuration object for the staircase. If not provided, default values will be used.

Properties

ogType
string
The element type identifier. Always set to ElementType.STAIR.
propertySet
OPStair
The current configuration of the staircase including dimensions, step counts, and materials.
subElements
Map<SubElementType, THREE.Object3D>
Map containing sub-elements of the staircase (steps, landing).
selected
boolean
Indicates whether the staircase is currently selected.
edit
boolean
Indicates whether the staircase is in edit mode.

Getters & Setters

labelName
string
The display name of the staircase element.
stairPosition
[number, number, number]
The 3D position of the staircase in the scene as [x, y, z].
stairWidth
number
The width of the staircase in meters.
totalHeight
number
The total vertical rise of the staircase in meters.
riserHeight
number
The desired height of each step (rise) in meters. Actual height is calculated to distribute evenly.
treadDepth
number
The depth of each step (run) in meters.
stairColor
number
The hexadecimal color value for the staircase.
stairMaterial
string
The material type of the staircase (e.g., ‘wood’, ‘concrete’, ‘steel’).

Methods

setOPConfig

setOPConfig(config: OPStair): void
Updates the staircase configuration and rebuilds the geometry.
config
OPStair
New configuration object for the staircase.

getOPConfig

getOPConfig(): OPStair
Returns the current staircase configuration. Returns: OPStair - The current staircase configuration object.

setOPGeometry

setOPGeometry(): void
Rebuilds the staircase geometry based on the current configuration, creating all steps and risers.

setOPMaterial

setOPMaterial(): void
Updates the material properties and colors of all steps.

showProfileView

showProfileView(status: boolean): void
Toggles the profile view mode for technical drawings.
status
boolean
True to show profile view (outline only), false to show normal view.

dispose

dispose(): void
Cleans up geometry, materials, and removes the staircase from the scene.

OPStair

The configuration interface for staircase elements.

Properties

ogid
string
Unique identifier for the staircase element.
labelName
string
required
Display name for the staircase.
type
ElementType.STAIR
required
Element type identifier.
stairType
StairType
required
Type of staircase (STRAIGHT, LSHAPED, USHAPED, SPIRAL, WINDER).
dimensions
object
required
Dimensions configuration for the staircase.
stairPosition
[number, number, number]
required
3D position of the staircase as [x, y, z].
riserHeight
number
required
Desired height of each step (rise) in meters. Standard is ~0.17m (17cm).
treadDepth
number
required
Depth of each step (run) in meters. Standard is ~0.28m (28cm).
numberOfSteps
number
required
Total number of steps. Calculated automatically based on totalHeight and riserHeight.
stairColor
number
required
Hexadecimal color value for the staircase (e.g., 0x8B7355 for wood brown).
stairMaterial
string
required
Material type of the staircase (e.g., ‘wood’, ‘concrete’, ‘steel’).
coordinates
Array<[number, number, number]>
required
Array of 4 corner coordinate points defining the staircase footprint. Calculated automatically.

StairType

Enum defining available staircase types:
  • STRAIGHT - Straight run staircase
  • LSHAPED - L-shaped staircase with landing
  • USHAPED - U-shaped staircase with landing
  • SPIRAL - Spiral staircase
  • WINDER - Winder staircase with wedge-shaped steps

Example

import { BaseStair, StairType, ElementType } from 'openplans';

// Create a straight staircase with default configuration
const stair = new BaseStair();

// Create a custom wooden staircase
const woodenStair = new BaseStair({
  labelName: 'Main Staircase',
  type: ElementType.STAIR,
  stairType: StairType.STRAIGHT,
  dimensions: {
    width: 1.2,
    totalHeight: 3.0,
    totalLength: 4.5, // Calculated automatically
  },
  stairPosition: [0, 0, 0],
  riserHeight: 0.17,      // 17cm standard riser
  treadDepth: 0.28,       // 28cm standard tread
  numberOfSteps: 18,      // Calculated automatically
  stairColor: 0x8B7355,   // Wood brown
  stairMaterial: 'wood',
  coordinates: [],
});

// Update staircase properties
woodenStair.totalHeight = 3.5;
woodenStair.stairWidth = 1.5;
woodenStair.riserHeight = 0.18;
woodenStair.stairColor = 0x654321;

// Get current configuration
const config = woodenStair.getOPConfig();
console.log(`Staircase has ${config.numberOfSteps} steps`);
console.log(`Total run: ${config.dimensions.totalLength.toFixed(2)}m`);

// Show profile view for technical drawings
woodenStair.showProfileView(true);

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

Building Code Notes

  • Standard riser height: 17-18cm (0.17-0.18m) for residential buildings
  • Standard tread depth: 25-30cm (0.25-0.30m) for comfortable stairs
  • Minimum width: 90cm (0.9m) for residential, 120cm (1.2m) for commercial
  • Rule of thumb: Riser (cm) + Tread (cm) should equal 45-48cm for comfort
The BaseStair class automatically calculates the number of steps based on the total height and desired riser height, ensuring even distribution across all steps.
Last modified on March 7, 2026