Files
editor/packages/core
Wassim SAMADandClaude Opus 4.7 d10d7f8deb 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>
2026-05-15 10:51:22 -04:00
..
2026-02-05 08:22:19 +09:00

@pascal-app/core

Core library for Pascal 3D building editor.

Installation

npm install @pascal-app/core

Peer Dependencies

npm install react three @react-three/fiber @react-three/drei

What's Included

  • Node Schemas - Zod schemas for all building primitives (walls, slabs, items, etc.)
  • Scene State - Zustand store with IndexedDB persistence and undo/redo
  • Systems - Geometry generation for walls, floors, ceilings, roofs
  • Scene Registry - Fast lookup from node IDs to Three.js objects
  • Spatial Grid - Collision detection and placement validation
  • Event Bus - Typed event emitter for inter-component communication
  • Asset Storage - IndexedDB-based file storage for user-uploaded assets

Usage

import { useScene, WallNode, ItemNode } from '@pascal-app/core'

// Create a wall
const wall = WallNode.parse({
  points: [[0, 0], [5, 0]],
  height: 3,
  thickness: 0.2,
})

useScene.getState().createNode(wall, parentLevelId)

// Subscribe to scene changes
function MyComponent() {
  const nodes = useScene((state) => state.nodes)
  const walls = Object.values(nodes).filter(n => n.type === 'wall')

  return <div>Total walls: {walls.length}</div>
}

Node Types

  • SiteNode - Root container
  • BuildingNode - Building within a site
  • LevelNode - Floor level
  • WallNode - Vertical wall with optional openings
  • SlabNode - Floor slab
  • CeilingNode - Ceiling surface
  • RoofNode - Roof geometry
  • ZoneNode - Spatial zone/room
  • ItemNode - Furniture, fixtures, appliances
  • ScanNode - 3D scan reference
  • GuideNode - 2D guide image reference

Systems

Systems process dirty nodes each frame to update geometry:

  • WallSystem - Wall geometry with mitering and CSG cutouts
  • SlabSystem - Floor polygon generation
  • CeilingSystem - Ceiling geometry
  • RoofSystem - Roof generation
  • ItemSystem - Item positioning on walls/ceilings/floors

License

MIT