Overview
TheCuboid class creates 3D rectangular box shapes (also known as rectangular prisms or boxes). Cuboids are defined by their center point and dimensions along the X, Y, and Z axes.
Constructor
ICuboidOptions
Unique identifier for the cuboid. Auto-generated if not provided.
Center point of the cuboid in 3D space.
Width of the cuboid along the X-axis.
Height of the cuboid along the Y-axis.
Depth of the cuboid along the Z-axis.
Hexadecimal color value for the cuboid.
Methods
setConfig()
Updates the cuboid configuration and regenerates geometry.getBrepData()
Returns the B-Rep (Boundary Representation) data as a parsed JSON object.generateGeometry()
Regenerates the THREE.js geometry from the current configuration. Called automatically after setConfig().discardGeometry()
Disposes of the current geometry to free memory.Properties
Unique identifier for the cuboid instance.
Current cuboid configuration.
Get or set the cuboid width. Setting triggers geometry regeneration.
Get or set the cuboid color.
Enable or disable outline rendering for the cuboid edges.
Reference to the outline mesh if outline is enabled.
Usage Examples
Basic Cuboid
Cuboid with Outline
Cube (Equal Dimensions)
Dynamic Cuboid Scaling
Building Block
Implementation Details
Geometry Generation
Cuboids are created by defining a rectangular base on the XZ plane and extruding it along the Y-axis using theextrude_brep_face operation.
Rust Implementation: /workspace/source/main/opengeometry/src/primitives/cuboid.rs:80-129
Material Configuration
Cuboids use MeshStandardMaterial with transparency: Source:/workspace/source/main/opengeometry/src/shapes/cuboid.ts:100-104
B-Rep Structure
Cuboids have a well-defined B-Rep structure:- 8 vertices (corners)
- 12 edges (connecting corners)
- 6 faces (sides)
/workspace/source/main/opengeometry/src/primitives/cuboid.rs:86-128
Best Practices
Memory Management: Use
discardGeometry() when removing cuboids from the scene to properly free GPU memory.Live Demo
Cuboid Demo
Try the Cuboid shape in the browser
See Also
Wedge
Triangular prism shapes
Cylinder
Cylindrical shapes
Polygon
2D base shapes

