Each tool is now a direct copy of the legacy implementation, relocated
under @pascal-app/nodes/<kind>/ and dispatched via the registry's
def.affordanceTools. No DragAction abstraction, no clever live-drag
exception, no novel snap pipeline — same code, same UX, same
performance, same history dance.
Ports:
- fence/curve-tool.tsx (legacy CurveFenceTool, 1:1)
- fence/move-tool.tsx (legacy MoveFenceTool, 1:1 — including
the mesh.position + useLiveTransforms
exception that the legacy uses for fence
specifically)
- wall/curve-tool.tsx (legacy CurveWallTool, 1:1)
- slab/move-tool.tsx (legacy MoveSlabTool, 1:1)
- ceiling/move-tool.tsx (legacy MoveCeilingTool, 1:1 — preview
fill + outline overlay preserved)
Drops the obsolete DragAction-based action files
(packages/nodes/src/{fence,wall,slab,ceiling}/actions/{curve,move}.ts)
and their now-empty actions/ directories where applicable. Fence
keeps actions/move-endpoint.ts since that port works.
Editor public surface gains `getWallGridStep` + `snapScalarToGrid`
(transitional exports — Stage F moves them into @pascal-app/nodes).
ToolManager + MoveTool dispatch unchanged: the same legacy-fallback
branches now mount the registry component because the affordances are
declared, but the rendered behavior matches the legacy because the
implementations are copies.
Per-kind progress: fence D ✅ (curve / move-endpoint / move / placement
all kind-owned), slab D ✅, ceiling D ✅, wall D 🟡 (curve only,
endpoint/move/placement still legacy).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
106 lines
3.4 KiB
TypeScript
106 lines
3.4 KiB
TypeScript
import type { NodeDefinition } from '@pascal-app/core'
|
|
import { buildFenceFloorplan } from './floorplan'
|
|
import { buildFenceGeometry } from './geometry'
|
|
import { fenceParametrics } from './parametrics'
|
|
import { FenceNode } from './schema'
|
|
|
|
/**
|
|
* Fence — Phase 5 batch kind. Stage B complete: `def.geometry` drives
|
|
* the rebuild via the generic `<GeometrySystem>`; `<ParametricNodeRenderer>`
|
|
* mounts the empty group. No per-kind renderer or system file.
|
|
*
|
|
* Capabilities:
|
|
* - **No `movable`**: fence move is bespoke endpoint-drag. Capability-
|
|
* driven dispatch keeps the legacy MoveFenceTool until the
|
|
* affordance port (Stage D).
|
|
* - `surfaces.sides`, `selectable`, `duplicable`, `deletable` standard.
|
|
*
|
|
* Relations: `linkedBy: 'endpoint-match'` for corner cascade.
|
|
*/
|
|
export const fenceDefinition: NodeDefinition<typeof FenceNode> = {
|
|
kind: 'fence',
|
|
schemaVersion: 1,
|
|
schema: FenceNode,
|
|
category: 'structure',
|
|
|
|
defaults: () => ({
|
|
object: 'node',
|
|
parentId: null,
|
|
visible: true,
|
|
metadata: {},
|
|
start: [0, 0],
|
|
end: [3, 0],
|
|
height: 1.8,
|
|
thickness: 0.08,
|
|
baseHeight: 0.22,
|
|
postSpacing: 2,
|
|
postSize: 0.1,
|
|
topRailHeight: 0.04,
|
|
groundClearance: 0,
|
|
edgeInset: 0.015,
|
|
baseStyle: 'grounded',
|
|
showInfill: true,
|
|
color: '#ffffff',
|
|
style: 'slat',
|
|
}),
|
|
|
|
capabilities: {
|
|
selectable: { hitVolume: 'bbox' },
|
|
surfaces: { sides: { faces: 'all' } },
|
|
duplicable: true,
|
|
deletable: true,
|
|
},
|
|
|
|
relations: {
|
|
linkedBy: 'endpoint-match',
|
|
cascadeDelete: 'none',
|
|
},
|
|
|
|
parametrics: fenceParametrics,
|
|
|
|
// Stage D: kind-owned placement tool. Two-click flow (start → end)
|
|
// with live preview, length / angle HUD, snap to walls / fences /
|
|
// grid. Mounted by ToolManager when `useEditor.tool === 'fence'`
|
|
// via the registry's getRegistryTool() — falls back to the legacy
|
|
// tools[phase][tool] map when missing.
|
|
tool: () => import('./tool'),
|
|
|
|
// Stage B: pure geometry function. Generic <GeometrySystem> rebuilds
|
|
// on dirtyNodes; <ParametricNodeRenderer> mounts the empty group.
|
|
// `renderer` + `system` fields dropped along with their files.
|
|
geometry: buildFenceGeometry,
|
|
// Stage C: floor-plan rendering. FloorplanRegistryLayer iterates kinds
|
|
// with `floorplan` set and renders via FloorplanGeometryRenderer.
|
|
// Legacy `floorplanFenceEntries` short-circuits to [] when fence is
|
|
// registered (see floorplan-panel.tsx).
|
|
floorplan: buildFenceFloorplan,
|
|
// Stage D — all four fence drag-affordances live in this folder.
|
|
// curve / move-endpoint / move are 1:1 ports of the legacy tools
|
|
// (same snap pipeline, same history dance, same cursor render),
|
|
// relocated under `@pascal-app/nodes` and dispatched via
|
|
// `def.affordanceTools`. Placement lives in `def.tool` (see below).
|
|
affordanceTools: {
|
|
curve: () => import('./curve-tool'),
|
|
'move-endpoint': () => import('./move-endpoint-tool'),
|
|
move: () => import('./move-tool'),
|
|
},
|
|
|
|
toolHints: [
|
|
{ key: 'Left click', label: 'Set fence start / end' },
|
|
{ key: 'Shift', label: 'Allow non-45° angles' },
|
|
{ key: 'Esc', label: 'Cancel' },
|
|
],
|
|
|
|
presentation: {
|
|
label: 'Fence',
|
|
description: 'A straight or curved fence segment with configurable posts and infill.',
|
|
icon: { kind: 'iconify', name: 'lucide:fence' },
|
|
paletteSection: 'structure',
|
|
paletteOrder: 20,
|
|
},
|
|
|
|
mcp: {
|
|
description: 'A fence segment defined by start + end points, with optional curve sagitta.',
|
|
},
|
|
}
|