Overview
TheDoorSystem is a React component that processes dirty door nodes and generates 3D door geometry. It supports:
- Parametric door geometry with configurable segments (panels, glass, empty)
- CSG cutouts in parent walls for door openings
- Commercial hardware (door closers, panic bars)
- Multi-segment layouts with independent column divisions per segment
- Threshold, handle, and hinge customization
useFrame hook at priority 3, ensuring doors update after items and slabs but before wall CSG operations.
Location
How It Works
Processing Pipeline
Update door geometry
For each dirty door:
- Generate new geometry from door parameters
- Create frame members (left post, right post, head)
- Build leaf segments (panels, glass, or empty)
- Add hardware (handle, hinges, closer, panic bar)
- Update the invisible cutout mesh for wall CSG
Mark parent wall dirty
Trigger parent wall rebuild so its CSG cutout reflects the updated door geometry.
Geometry Generation
TheupdateDoorMesh() function builds door geometry in these steps:
- Create invisible hitbox (root mesh for selection)
- Build frame members (left post, right post, head)
- Add threshold if enabled
- Build leaf segments with content padding border strips
- Generate segment content (panels with raised details, glass panes, or empty fill)
- Add hardware (handle, door closer, panic bar, hinges)
- Update cutout mesh (always full door dimensions, 1m deep for wall CSG)
Props
TheDoorSystem 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
DoorNode Schema
The system processesDoorNode objects with these properties:
Unique door identifier
Center of the door in wall-local coordinates
[x, y, z]Euler rotation in radians
[x, y, z]Overall door width in meters
Overall door height in meters
Width of frame members in meters
Depth of frame in meters (perpendicular to wall)
Whether to show threshold at door base
Height of threshold in meters
Which side the hinges are on
Direction the door swings
Array of segments stacked top to bottom, each defining its own column layout
Whether to show door handle
Height of handle from floor in meters
Which side the handle is on
Leaf inner margin
[x, y] in metersWhether to show commercial door closer hardware
Whether to show panic bar (emergency exit hardware)
Height of panic bar from floor in meters
Parent wall ID
DoorSegment Schema
Each segment in thesegments array has:
'panel': Opaque with raised/recessed panel detail'glass': Transparent glazed pane'empty': Flat opaque fill
Relative height proportion (segments are stacked top to bottom)
Relative width proportions for columns within this segment
Thickness of column dividers in meters
Depth of raised panel (positive = raised, negative = recessed)
Inset from segment edges to panel detail in meters
External Systems
- Scene Registry (
sceneRegistry.nodes): Maps node IDs to THREE.js meshes - Wall System (
WallSystem): Applies CSG subtraction using door’s cutout mesh
Door Geometry Details
Frame Construction
The frame consists of three members:- Left post: Full height,
frameThicknesswide - Right post: Full height,
frameThicknesswide - Head (top bar): Full width,
frameThicknesstall
Leaf Layout
The leaf occupies the full opening with no bottom frame:Segment Processing
Segments are stacked top to bottom:Hardware
Hinges (door-system.tsx:227-241)
Three knuckle-style hinges positioned:- Bottom: 0.25m from floor
- Middle: Centered vertically
- Top: 0.25m from top
Handle (door-system.tsx:194-209)
Lever-style handle with backplate and grip, positioned on front face athandleHeight.
Door Closer (door-system.tsx:211-218)
Commercial closer with body and arm, mounted at top of leaf.Panic Bar (door-system.tsx:220-224)
Horizontal push bar atpanicBarHeight, spanning 72% of leaf width.
CSG Cutouts
The door creates a cutout in its parent wall using Constructive Solid Geometry:Create cutout mesh
Invisible mesh named
'cutout' with full door dimensions (width × height × 1.0m deep).Wall CSG subtraction
Parent wall system subtracts the cutout brush from wall geometry using
three-bvh-csg.Usage in Viewer
- Monitors the
dirtyNodesstore - Updates doors when they’re marked dirty
- Triggers parent wall CSG updates
Multi-Column Segments
Each segment can have independent column divisions:Materials
The system uses three materials:Performance Notes
- Only updates dirty doors (not all doors every frame)
- Reuses shared material instances across all doors
- Disposes old geometries to prevent memory leaks
- Root mesh is invisible hitbox; all visuals are child meshes
- Runs at priority
3(after items, before wall CSG)
Coordinate System
Doors use wall-local coordinates:- X-axis: Along wall length
- Y-axis: Height (up)
- Z-axis: Perpendicular to wall (through thickness)
position is its center, with Y = height/2 so the base sits at floor level.
Related
- WallSystem - Applies CSG cutouts for doors
- WindowSystem - Similar CSG-based opening system
- ItemSystem - Positions door hardware items