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>
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
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,
|
|
},
|
|
],
|
|
}
|
|
}
|