MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / wallSystem

Function wallSystem

examples/scene-graph/room.ts:162–211  ·  view source on GitHub ↗
(dt: number)

Source from the content-addressed store, hash-verified

160
161// WallSystem (priority 4) — generates wall geometry with door cutouts
162function wallSystem(dt: number): void {
163 for (const id of dirtyNodes) {
164 const node = nodes.get(id);
165 if (!node || node.type !== 'wall') continue;
166
167 const handle = ensureSceneNode(id);
168 const wall = node as WallNode;
169
170 // Generate wall polygon
171 const polygon = generateWallVertices(wall);
172 if (polygon.length === 0) continue;
173
174 // Extrude wall polygon
175 extrudePolygon(handle, polygon, wall.height);
176
177 // Apply door cutouts via CSG box subtraction
178 for (const childId of wall.children) {
179 const child = nodes.get(childId);
180 if (!child || child.type !== 'door') continue;
181 const door = child as DoorNode;
182
183 // Compute door position along wall
184 const [sx, sz] = wall.start;
185 const [ex, ez] = wall.end;
186 const dx = ex - sx;
187 const dz = ez - sz;
188 const len = Math.sqrt(dx * dx + dz * dz);
189 const nx = -dz / len;
190 const nz = dx / len;
191
192 // Door center along wall
193 const cx = sx + dx * door.position;
194 const cz = sz + dz * door.position;
195
196 // Cutout box (slightly wider than wall thickness for clean cut)
197 const halfW = door.width * 0.5;
198 const wt = wall.thickness * 1.5;
199 subtractBox(handle,
200 cx - halfW * (dx / len) - nx * wt, 0.0, cz - halfW * (dz / len) - nz * wt,
201 cx + halfW * (dx / len) + nx * wt, door.height, cz + halfW * (dz / len) + nz * wt,
202 );
203 }
204
205 // White wall material
206 setSceneNodeColor(handle, 0.95, 0.95, 0.92, 1.0);
207 setSceneNodePbr(handle, 0.8, 0.0);
208
209 clearDirty(id);
210 }
211}
212
213// LightSystem (priority 5) — sets up lighting each frame
214function lightSystem(dt: number): void {

Callers

nothing calls this directly

Calls 8

extrudePolygonFunction · 0.90
subtractBoxFunction · 0.90
setSceneNodeColorFunction · 0.90
setSceneNodePbrFunction · 0.90
ensureSceneNodeFunction · 0.85
clearDirtyFunction · 0.85
generateWallVerticesFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected