Files
editor/packages/nodes/src/wall/definition.ts
T
Wassim SAMADandClaude Opus 4.7 9bcb25d0aa Phase 5 Stage C continued: wall, door, window now in registry floor plan
Three remaining kinds at Stage C this session:

wall → C
 - buildWallFloorplan: uses ctx.siblings to gather other walls in the
   level, runs calculateLevelMiters, computes plan footprint via
   getWallPlanFootprint. Same visual output as legacy.
 - getFloorplanWall thickness exaggeration inlined (~25 lines from
   editor/lib/floorplan/walls.ts) to keep nodes/wall self-contained.
 - floorplan-panel.tsx's wallPolygons short-circuits to [] when wall
   is registered.
 - Performance note: recomputes level miter data per wall (O(N²) for N
   walls in a level). Acceptable for typical scenes; ctx.levelData?.
   miters optimization deferred to Stage B's wall design pass.

door → C
 - buildDoorFloorplan: inlines getOpeningFootprint math from
   floorplan-panel.tsx (40 lines, pure math). Uses ctx.parent as the
   wall to compute direction + perpendicular for the cutout footprint.
 - Returns null when parent isn't a wall (orphaned doors during
   placement).

window → C
 - buildWindowFloorplan: same shape as door, glass-blue tint to
   distinguish visually.

Both share the legacy openingsPolygons gating:
 - floorplan-panel.tsx's openingsPolygons useMemo filters per kind so
   a partial migration still works (e.g., if only door registers, only
   doors get skipped). When both registered, returns [] entirely.

Item C intentionally deferred — needs parent-chain transform helpers
(buildFloorplanItemEntry / getItemFloorplanTransform from editor/lib/
floorplan/items.ts) exposed publicly or moved into core. A focused
session is the right place to design that boundary.

Stage B for door / window / wall still pending — each is a focused
session per kind (large geometry math extractions, wall needs ctx.
levelData design).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 16:43:53 -04:00

85 lines
2.6 KiB
TypeScript

import type { NodeDefinition } from '@pascal-app/core'
import { buildWallFloorplan } from './floorplan'
import { wallParametrics } from './parametrics'
import { WallNode } from './schema'
/**
* Wall — the Phase 3 stress test of the registry-driven node model.
*
* Stage A: registered (capabilities, relations, parametrics, presentation).
* Stage B: deferred — wall geometry depends on level-batch miter data that
* doesn't fit the generic `(node, ctx) => Group` shape without `ctx.
* levelData?.miters`. See plan's "GeometryContext" extension note.
* `renderer` + `system` keep wrap-exporting legacy WallRenderer +
* WallSystem + WallCutout.
* Stage C: `def.floorplan` builder produces the mitered plan footprint
* polygon using `ctx.siblings` to assemble miter context.
* floorplan-panel.tsx's `wallPolygons` short-circuits to [] when
* wall is registered.
*/
export const wallDefinition: NodeDefinition<typeof WallNode> = {
kind: 'wall',
schemaVersion: 1,
schema: WallNode,
category: 'structure',
defaults: () => ({
object: 'node',
parentId: null,
visible: true,
metadata: {},
children: [],
start: [0, 0],
end: [3, 0],
frontSide: 'unknown',
backSide: 'unknown',
}),
capabilities: {
// Wall move is bespoke (endpoint drag, linked-wall corner cascade,
// ALT-detach). Omitting `movable` keeps the legacy MoveWallTool via
// capability-driven dispatch.
selectable: { hitVolume: 'bbox' },
// Front + back faces host items (paintings, shelves, switches).
surfaces: {
sides: { faces: 'all' },
},
duplicable: true,
deletable: true,
},
relations: {
hosts: ['door', 'window', 'item'],
affectsSpatial: ['slab', 'ceiling', 'zone'],
linkedBy: 'endpoint-match',
cascadeDelete: 'descendants',
},
parametrics: wallParametrics,
renderer: {
kind: 'parametric',
module: () => import('./renderer'),
},
system: {
module: () => import('./system'),
// Priority 4 mirrors the legacy WallSystem's useFrame priority.
priority: 4,
},
// Stage C: floor-plan rendering. ctx.siblings provides other walls in
// the level so `calculateLevelMiters` can compute correct corner joins.
floorplan: buildWallFloorplan,
presentation: {
label: 'Wall',
description: 'A straight or curved wall segment. Hosts doors, windows, and wall-mounted items.',
icon: { kind: 'iconify', name: 'lucide:wall' },
paletteSection: 'structure',
paletteOrder: 10,
},
mcp: {
description: 'A wall segment defined by start + end points, with optional curve sagitta.',
},
}