Skip to main content

BaseSlab

The BaseSlab class represents a horizontal concrete or floor slab element. It extends the Cuboid class and provides functionality for creating customizable floor slabs with various materials and dimensions.

Constructor

new BaseSlab(baseSlabConfig?: OPSlab)
baseSlabConfig
OPSlab
Optional configuration object for the slab. If not provided, default values will be used.

Properties

ogType
string
The element type identifier. Always set to ElementType.SLAB.
propertySet
OPSlab
The current configuration of the slab including dimensions, color, and material.
subElements
Map<SubElementType, THREE.Object3D>
Map containing sub-elements of the slab (body, finish, reinforcement).
selected
boolean
Indicates whether the slab is currently selected.
edit
boolean
Indicates whether the slab is in edit mode.

Getters & Setters

labelName
string
The display name of the slab element.
slabPosition
[number, number, number]
The 3D position of the slab in the scene as [x, y, z].
slabWidth
number
The width of the slab in meters (X-axis).
slabLength
number
The length of the slab in meters (Z-axis).
slabThickness
number
The thickness of the slab in meters (Y-axis).
slabColor
number
The hexadecimal color value for the slab.
slabMaterial
string
The material type of the slab (e.g., ‘concrete’, ‘wood’).

Methods

setOPConfig

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

getOPConfig

getOPConfig(): OPSlab
Returns the current slab configuration. Returns: OPSlab - The current slab configuration object.

setOPGeometry

setOPGeometry(): void
Rebuilds the slab geometry based on the current configuration.

setOPMaterial

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

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 slab from the scene.

OPSlab

The configuration interface for slab elements.

Properties

ogid
string
Unique identifier for the slab element.
labelName
string
required
Display name for the slab.
type
ElementType.SLAB
required
Element type identifier.
dimensions
object
required
Dimensions configuration for the slab.
slabPosition
[number, number, number]
required
3D position of the slab as [x, y, z].
slabThickness
number
required
Thickness of the slab in meters.
slabColor
number
required
Hexadecimal color value for the slab (e.g., 0xCCCCCC for gray).
slabMaterial
string
required
Material type of the slab (e.g., ‘concrete’, ‘wood’, ‘steel’).
coordinates
Array<[number, number, number]>
required
Array of 4 corner coordinate points defining the slab geometry. Calculated automatically.

Example

import { BaseSlab, ElementType } from 'openplans';

// Create a slab with default configuration
const slab = new BaseSlab();

// Create a custom concrete floor slab
const floorSlab = new BaseSlab({
  labelName: 'Ground Floor Slab',
  type: ElementType.SLAB,
  dimensions: {
    start: { x: -5, y: 0, z: -5 },
    end: { x: 5, y: 0, z: 5 },
    width: 10,
    length: 10,
  },
  slabPosition: [0, 0, 0],
  slabThickness: 0.2,
  slabColor: 0xCCCCCC,
  slabMaterial: 'concrete',
  coordinates: [],
});

// Update slab properties
floorSlab.slabThickness = 0.25;
floorSlab.slabWidth = 12;
floorSlab.slabLength = 15;
floorSlab.slabColor = 0xAAAAAA;

// Change material type
floorSlab.slabMaterial = 'reinforced-concrete';

// Get current configuration
const config = floorSlab.getOPConfig();
console.log(`Slab area: ${config.dimensions.width * config.dimensions.length} m²`);

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

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

Notes

  • The slab is positioned with its top surface at the Y position specified in slabPosition
  • The slab extends downward by its thickness value
  • Coordinates are automatically calculated based on the dimensions and represent the four corners
  • The default color (0xCCCCCC) represents a typical concrete gray color
Last modified on March 7, 2026