Overview
TheCeilingSystem is a React component that processes dirty ceiling nodes and generates 3D ceiling geometry. It supports:
- Polygon-based geometry matching room shapes
- Hole support for ceiling cutouts (skylights, vents)
- Configurable height positioning
- Grid mesh support for ceiling tile visualization
useFrame hook (default priority), ensuring ceilings update after core systems.
Location
How It Works
Processing Pipeline
Update geometry
For each dirty ceiling:
- Generate new flat geometry from the polygon
- Add holes to the shape
- Dispose old geometry and replace it
- Update optional grid mesh (for ceiling tiles)
Position at height
Set mesh position to
ceiling.height - 0.01 (slight offset to avoid z-fighting with upper-level slabs).Geometry Generation
ThegenerateCeilingGeometry() function:
- Create THREE.Shape from polygon points
- Add holes from the
holesarray - Create ShapeGeometry (flat, no extrusion)
- Rotate to lie flat in X-Z plane
Unlike slabs, ceilings use
ShapeGeometry instead of ExtrudeGeometry because they have zero thickness.Props
TheCeilingSystem component has no props. It reads state from the Zustand store:
Set of node IDs that need geometry updates
All nodes in the scene graph
Dependencies
CeilingNode Schema
The system processesCeilingNode objects with these properties:
Unique ceiling identifier
Array of
[x, z] coordinates defining the ceiling boundary in level coordinatesArray of polygons representing holes in the ceiling (for skylights, vents, etc.)
Ceiling height in meters (Y-axis position)
Child item IDs (ceiling-attached items like lights, fans)
External Systems
- Scene Registry (
sceneRegistry.nodes): Maps node IDs to THREE.js meshes
Usage Example
Coordinate System
Ceilings use the level coordinate system:- X-axis: Horizontal (left-right)
- Y-axis: Vertical (height)
- Z-axis: Horizontal (forward-back)
[x, z] plane, and the ceiling is positioned at height on the Y-axis.
Holes
Ceilings support multiple holes for architectural features:- Defined as polygons in the same coordinate system
- Automatically converted to THREE.Path and added to the shape
- Cut completely through the ceiling (since it’s flat)
Ceiling Grid Mesh
The system supports an optional'ceiling-grid' mesh for visualizing ceiling tiles:
Height Positioning
Ceilings are positioned at:-0.01 offset prevents z-fighting with upper-level slabs that might be at the same height.
Performance Notes
- Only updates dirty ceilings (not all ceilings every frame)
- Disposes old geometry before creating new geometry
- Uses flat
ShapeGeometryinstead of extruded geometry for efficiency - Updates both main mesh and grid mesh in a single pass
Integration with Other Systems
Item System
Ceiling-attached items (lights, fans) use the ceiling node to:- Position at correct height
- Orient downward
- Parent to the ceiling in the scene graph
Wall System
Walls and ceilings often share the same polygon coordinates to create enclosed rooms. The wall height typically matches the ceiling height.Related
- WallSystem - Manages wall geometry with mitering
- SlabSystem - Manages floor geometry
- ItemSystem - Positions ceiling-attached items