Phase 4 follow-on: floor-plan interaction + def.toolHints + spawn floorplan builder

Three additions on top of the floor-plan registry contract:

1. def.toolHints + RegisteredToolHelper (registry contract for the
   shortcut hint panel)

   - New ToolHint type in core: { key, label } static array.
   - Added `def.toolHints?: ToolHint[]` to NodeDefinition.
   - New <RegisteredToolHelper hints={...}> in editor — same visual
     styling as WallHelper / ItemHelper but data-driven.
   - HelperManager: registry-first check before falling through to the
     hand-written per-tool switch. Per-tool helper files get deleted
     as their kind migrates `toolHints` in.
   - Shelf + spawn definitions ship toolHints today; wall ports in
     Phase 3 Milestone C alongside its tool/affordance port.

2. Floor-plan interaction layer (selection + drag-to-move)

   - <FloorplanRegistryLayer> now wraps each entry in an interactive
     <g>:
       * Click → useViewer.setSelection({ selectedIds: [id] }).
         Selection visual is a thicker accent-colored stroke applied
         via withSelectionStyle() recursion through the FloorplanGeometry
         tree — kinds don't author selection decoration.
       * Drag → imperative SVG transform during the gesture, single
         updateNode commit on pointerup. Same "smooth move" pattern as
         MoveRegistryNodeTool for 3D drag: no per-tick store update,
         no React re-render storm, no zundo bloat. Coordinate
         conversion via svg.getScreenCTM().inverse().
       * useScene.temporal.pause/resume brackets the gesture so one
         drag = one undo step.
   - Global pointermove / pointerup listeners so the gesture survives
     the cursor leaving the entry's bounding box (matches the legacy
     elevator-resize-drag and item-drag patterns in floorplan-panel).

3. Spawn floor-plan builder (deferred wiring)

   - buildSpawnFloorplan written but NOT wired on the definition —
     spawn already renders in the legacy floorplan-panel.tsx via
     `floorplanSpawnEntries`, and wiring def.floorplan now would
     double-render. The pure builder lives in nodes/src/spawn/
     floorplan.ts ready to wire when the legacy inline branch is
     removed (Phase 5 spawn-floorplan migration PR — same shape as
     wall's feature flag, but per kind inside the legacy panel).

Plan updated: floor-plan interaction section locks the click/drag
contract in, wall-floor-plan-as-legacy note flags everything advanced
the user sees today as legacy that ports alongside Milestone C.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Wassim SAMAD
2026-05-15 10:51:22 -04:00
co-authored by Claude Opus 4.7
parent ac36297e7e
commit d10d7f8deb
8 changed files with 290 additions and 24 deletions
+4
View File
@@ -56,6 +56,10 @@ export const shelfDefinition: NodeDefinition<typeof ShelfNode> = {
preview: () => import('./preview'),
tool: () => import('./tool'),
toolHints: [
{ key: 'Left click', label: 'Place shelf' },
{ key: 'Esc', label: 'Cancel' },
],
presentation: {
label: 'Shelf',
+10
View File
@@ -34,7 +34,17 @@ export const spawnDefinition: NodeDefinition<typeof SpawnNode> = {
kind: 'parametric',
module: () => import('./renderer'),
},
// `floorplan: buildSpawnFloorplan` deferred — spawn already renders in
// the legacy floorplan-panel.tsx via `floorplanSpawnEntries`. Adding it
// here would double-render. The pure builder lives in
// ./floorplan.ts ready to wire when the legacy inline branch is
// removed (Phase 5 spawn-floorplan migration PR — same shape as the
// wall feature flag, but per kind in the legacy panel itself).
tool: () => import('./tool'),
toolHints: [
{ key: 'Left click', label: 'Place spawn point' },
{ key: 'Esc', label: 'Cancel' },
],
presentation: {
label: 'Spawn Point',
+48
View File
@@ -0,0 +1,48 @@
import type { FloorplanGeometry } from '@pascal-app/core'
import type { SpawnNode } from './schema'
/**
* 2D floor-plan marker for a spawn point. A small filled circle at the
* spawn's position, with a triangular arrow indicating the facing
* direction (rotation around Y, looking down at the X-Z plane).
*
* Color matches the 3D renderer's `SPAWN_COLOR = '#22c55e'` so the user
* sees the same visual identity in both views.
*
* Coordinates are level-local meters; rotation is radians.
*/
export function buildSpawnFloorplan(node: SpawnNode): FloorplanGeometry {
const [px, , pz] = node.position
const ry = node.rotation
return {
kind: 'group',
transform: { translate: [px, pz], rotate: ry },
children: [
// Direction-pointing triangle, base centered at origin, tip in -Z
// (forward). Matches the 3D arrow's orientation.
{
kind: 'polygon',
points: [
[0, -0.28],
[-0.18, 0.12],
[0.18, 0.12],
],
fill: '#22c55e',
opacity: 0.85,
},
// Spawn body marker — circle outline so the spawn is legible at
// small zoom levels where the triangle would shrink past visibility.
{
kind: 'circle',
cx: 0,
cy: 0,
r: 0.34,
stroke: '#22c55e',
strokeWidth: 0.025,
fill: '#22c55e',
opacity: 0.18,
},
],
}
}