Files
editor/packages/nodes/src/wall/definition.ts
T
Wassim SAMADandClaude Opus 4.7 56e022a093 Phase 5 Stage D wall: port endpoint move, whole-move, placement (1:1 legacy)
Three remaining wall affordances ported into nodes/src/wall/ as
direct copies of the legacy implementations. Wall D is now complete.

  - move-endpoint-tool.tsx (426 LoC) — linked-wall corner cascade +
    Alt-detach + angle label. Mounted via `affordanceTools.move-endpoint`.
  - move-tool.tsx (804 LoC, the most complex tool in the editor) —
    center-drag with axis lock, linked-wall corner cascade via
    `planWallMoveJunctions`, bridge wall ghost previews, auto-slab
    live preview via `planAutoSlabsForLevel`, R/T rotation in 45°
    steps, Shift to bypass grid snap, isNew metadata strip on first
    commit. Mounted via `affordanceTools.move`.
  - tool.tsx (332 LoC) — two-click placement with length/angle HUD,
    Shift to bypass angle snap. Mounted via `def.tool`.

Editor public surface gains:
  - createWallOnCurrentLevel, snapWallDraftPoint, WallPlanPoint
  - MovingWallEndpoint type

ToolManager dispatch for `movingWallEndpoint` routes through the
registry with the legacy fallback (same shape as the fence
move-endpoint dispatch).

Wall is now A  C  D . Stage B still pending (geometry depends on
level-batch miter data, blocked on `ctx.levelData` design decision).
Stage E pending (drop WallPanel — has slider drags + actions).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 10:52:30 -04:00

98 lines
3.1 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,
// Stage D — all four wall drag affordances live in this folder.
// curve / move-endpoint / move are 1:1 ports of the legacy tools
// (same snap pipelines, linked-wall corner cascade with
// `planWallMoveJunctions`, ALT-detach, bridge wall previews,
// auto-slab live preview, history dances). Placement is wired via
// `def.tool`.
tool: () => import('./tool'),
affordanceTools: {
curve: () => import('./curve-tool'),
'move-endpoint': () => import('./move-endpoint-tool'),
move: () => import('./move-tool'),
},
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: 'url', src: '/icons/wall.png' },
paletteSection: 'structure',
paletteOrder: 10,
},
mcp: {
description: 'A wall segment defined by start + end points, with optional curve sagitta.',
},
}