Wholesale move of every remaining kind into its own subdirectory under
`packages/nodes/src/`, finishing the registry-driven migration. Each
kind now ships its definition, schema (re-exported from core), and any
of `geometry` / `renderer` / `system` / `floorplan` / `tool` /
`move-tool` / `panel` / `floorplan-move` / `floorplan-affordances` /
`parametrics` / `preview` it needs — no per-kind code remains under
`packages/editor/src/components/tools/` or
`packages/viewer/src/components/renderers/`.
Deleted (replaced by registry-driven equivalents):
- `tools/{ceiling,column,door,fence,item,slab,spawn,wall,window}/...`
(boundary editors, hole editors, placement tools, move tools,
endpoint movers, curve tools, helpers, math libs)
- `ui/helpers/{ceiling,slab,wall}-helper.tsx`
- `ui/panels/{column,door,elevator,item,roof,roof-segment,spawn,
stair,stair-segment,wall,window}-panel.tsx`
- `viewer/src/components/renderers/{building,ceiling,column,door,
elevator,fence,guide,item,level,roof,roof-segment,scan,site,slab,
spawn,stair,stair-segment,wall,window,zone}-renderer.tsx`
- `viewer/src/components/viewer/legacy-system.tsx`
Added under `packages/nodes/src/`:
- `building/`, `column/`, `elevator/`, `guide/`, `level/`, `roof/`,
`roof-segment/`, `scan/`, `shared/`, `site/`, `stair/`,
`stair-segment/` packages with definition + schema + renderer / system
/ floorplan / panel as appropriate.
- New `floorplan-move.ts` for every kind that supports 2D moves
(ceiling, door, item, shelf, slab, window) — single registry-driven
dispatch path via `def.floorplanMoveTarget`.
- New `floorplan-affordances.ts` for kinds with polygon / endpoint
drags (ceiling, fence, slab, wall) — using the shared
`polygon-vertex-affordance` factories.
- New per-kind `panel.tsx` for kinds with custom inspector content
(door, item, shelf, spawn, wall, window).
- New per-kind `tool.tsx` for placement (door, item, shelf, window).
- New per-kind `move-tool.tsx` for kinds with custom 3D move flows
(door, item, slab, window).
Coordinator + manager updates in `packages/editor/`:
- `tool-manager.tsx` resolves tools from the registry only — no
hardcoded type→component map.
- `panel-manager.tsx` resolves inspector panels the same way.
- `placement-{coordinator,strategies,types}.ts` extended with
shelf-surface placement.
- `selection-manager.tsx` adds the registry-selectable fallback.
- `floorplan-panel.tsx`, `floorplan-background-placement.ts`,
`floorplan-render-context.tsx` updated for the registry layer's new
contract (props, affordance dispatch, render context).
Viewer updates:
- `viewer/index.tsx` drops legacy renderer mounts.
- `node-renderer.tsx` resolves by registry only.
- `scene-bvh.tsx`, `use-node-events.ts`, `level-system.tsx`,
`wall-cutout.tsx`, `zone-system.tsx`, `materials.ts` adjusted for
the registry-only world.
Sidebar tree nodes for ceiling / fence / slab / shelf / tree-node
updated to read from the registered nodes instead of the deleted
legacy renderer trees.
Wiki: new `plugin-authoring.md` page, README index updated.
Tests in `packages/nodes/src/index.test.ts` validate every registered
kind has the required shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
113 lines
3.7 KiB
TypeScript
113 lines
3.7 KiB
TypeScript
import type { NodeDefinition } from '@pascal-app/core'
|
|
import { buildWallFloorplan } from './floorplan'
|
|
import { wallCurveAffordance, wallMoveEndpointAffordance } from './floorplan-affordances'
|
|
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,
|
|
// 2D drag affordances triggered by `endpoint-handle` primitives in
|
|
// `def.floorplan`'s output. Sister to `affordanceTools` (3D) — the
|
|
// same legacy `MoveWallEndpointTool` flow, reachable from both the
|
|
// R3F canvas and the floor-plan SVG.
|
|
floorplanAffordances: {
|
|
'move-endpoint': wallMoveEndpointAffordance,
|
|
curve: wallCurveAffordance,
|
|
},
|
|
|
|
toolHints: [
|
|
{ key: 'Left click', label: 'Set wall start / end' },
|
|
{ key: 'Shift', label: 'Allow non-45° angles' },
|
|
{ key: 'Esc', label: 'Cancel' },
|
|
],
|
|
|
|
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.',
|
|
},
|
|
}
|