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>
114 lines
3.7 KiB
TypeScript
114 lines
3.7 KiB
TypeScript
import type { NodeDefinition } from '@pascal-app/core'
|
|
import { buildSlabFloorplan } from './floorplan'
|
|
import {
|
|
slabAddVertexAffordance,
|
|
slabMoveEdgeAffordance,
|
|
slabMoveVertexAffordance,
|
|
} from './floorplan-affordances'
|
|
import { slabFloorplanMoveTarget } from './floorplan-move'
|
|
import { buildSlabGeometry } from './geometry'
|
|
import { slabParametrics } from './parametrics'
|
|
import { SlabNode } from './schema'
|
|
|
|
/**
|
|
* Slab — Phase 5 batch kind, polygon-based. Stage B: `def.geometry`
|
|
* drives the rebuild via generic <GeometrySystem>; <ParametricNodeRenderer>
|
|
* mounts the empty group. No per-kind renderer or system file.
|
|
*
|
|
* Capabilities:
|
|
* - **No `movable`**: slab's "move" today is whole-slab translation via
|
|
* legacy `MoveSlabTool`, which integrates with the floor-plan boundary /
|
|
* hole editors. Capability-driven dispatch keeps the legacy mover.
|
|
* - **`surfaces.top`**: items host on the slab top at `elevation`.
|
|
* - `selectable`, `duplicable`, `deletable` standard.
|
|
*
|
|
* Relations:
|
|
* - `hosts: ['item']` — items mount on the slab top.
|
|
* - `cascadeDelete: 'descendants'` — deleting a slab removes hosted items.
|
|
*/
|
|
export const slabDefinition: NodeDefinition<typeof SlabNode> = {
|
|
kind: 'slab',
|
|
schemaVersion: 1,
|
|
schema: SlabNode,
|
|
category: 'structure',
|
|
|
|
defaults: () => ({
|
|
object: 'node',
|
|
parentId: null,
|
|
visible: true,
|
|
metadata: {},
|
|
polygon: [],
|
|
holes: [],
|
|
holeMetadata: [],
|
|
elevation: 0.05,
|
|
autoFromWalls: false,
|
|
}),
|
|
|
|
capabilities: {
|
|
selectable: { hitVolume: 'bbox' },
|
|
surfaces: {
|
|
top: { height: (n) => (n as SlabNode).elevation },
|
|
},
|
|
duplicable: true,
|
|
deletable: true,
|
|
},
|
|
|
|
relations: {
|
|
hosts: ['item'],
|
|
cascadeDelete: 'descendants',
|
|
},
|
|
|
|
parametrics: slabParametrics,
|
|
|
|
// Stage D: kind-owned placement tool. Multi-click polygon drawing
|
|
// with axis/45° snap (Shift to defeat).
|
|
tool: () => import('./tool'),
|
|
|
|
// Stage D — all four slab drag-affordances live in this folder.
|
|
// boundary-edit / hole-edit are thin <PolygonEditor> wrappers; move
|
|
// is a 1:1 port of the legacy MoveSlabTool (scene.update per tick
|
|
// with the same history dance, no live-drag exception).
|
|
affordanceTools: {
|
|
'boundary-edit': () => import('./boundary-editor'),
|
|
'hole-edit': () => import('./hole-editor'),
|
|
move: () => import('./move-tool'),
|
|
},
|
|
|
|
// Stage B: pure geometry function.
|
|
geometry: buildSlabGeometry,
|
|
// Stage C: floor-plan rendering. Legacy `slabPolygons` short-circuits
|
|
// to [] when slab is registered (see floorplan-panel.tsx).
|
|
floorplan: buildSlabFloorplan,
|
|
// 2D move handler — translates polygon by cursor delta from first
|
|
// pointer position. The 3D `MoveSlabTool` in `affordanceTools.move`
|
|
// skips events sourced from the 2D scene so the two paths don't
|
|
// double-write on commit.
|
|
floorplanMoveTarget: slabFloorplanMoveTarget,
|
|
// Sister to `affordanceTools['boundary-edit']` (the 3D `PolygonEditor`
|
|
// wrapper). The 2D version edits the same `polygon` field via SVG
|
|
// pointer events on the vertex handles emitted by `def.floorplan`.
|
|
floorplanAffordances: {
|
|
'move-vertex': slabMoveVertexAffordance,
|
|
'add-vertex': slabAddVertexAffordance,
|
|
'move-edge': slabMoveEdgeAffordance,
|
|
},
|
|
|
|
toolHints: [
|
|
{ key: 'Left click', label: 'Trace slab outline' },
|
|
{ key: 'Enter', label: 'Finish slab' },
|
|
{ key: 'Esc', label: 'Cancel' },
|
|
],
|
|
|
|
presentation: {
|
|
label: 'Slab',
|
|
description: 'A polygon-bounded floor surface that hosts items on top.',
|
|
icon: { kind: 'url', src: '/icons/floor.png' },
|
|
paletteSection: 'structure',
|
|
paletteOrder: 30,
|
|
},
|
|
|
|
mcp: {
|
|
description: 'A polygon-bounded slab (floor) with optional cutout holes.',
|
|
},
|
|
}
|