* feat(editor): group R/T — keyboard rotate for multi-selections Extract the rigid rotate/translate math from the group gizmos into group-transform-shared (rotateGroupPatches / translateGroupPatches) and add a keyboard group-rotate path: R/T on a multi-selection steps the whole group ±45° around its bbox center, welded junctions and connected-component expansion included, committed as one updateNodes batch (one undo step). Single-selection R/T arms (reference, door/window flip, registry keyboardActions) are untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): polygon participant kind — slabs/ceilings/zones join group transforms classifyParticipant learns a 'polygon' kind ([x,z] vertex arrays + optional hole rings): slab/ceiling/zone now ride along in group move and rotate — the two 3D gizmos and the keyboard group R/T all flow through the shared rotateGroupPatches/translateGroupPatches, so the wiring is the classifier plus the rotate gizmo's spread sampling. Zone's 3D renderer merges its live polygon override so it previews during the drag (slab/ceiling already rebuild via getEffectiveNode in their systems). Classifier + patch unit tests included. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): 2D floorplan group drag — Photoshop-style multi-selection move Plain pointer-down on a transformable member of a multi-selection now slides the whole selection rigidly in the floor plan (the 2D parity fill for the 3D GroupMoveHandle), instead of collapsing the selection to the pressed node. A plain click (no drag) still collapses on release; modified clicks, Cmd-drag direct move, and reshape affordances keep their paths. The move-handle dot routes through the same group session when its node is part of the multi-selection. The session shares group-transform-shared verbatim: welded LinkedNeighbor endpoints, connected-component expansion, live previews via useLiveNodeOverrides.setMany, grid snapping on the delta plus Figma alignment through applyFloorplanAlignment (guides in every mode except off, magnetic pull in lines mode), interaction scope handle-drag with the shared group-move label, and a single batched updateNodes (one undo). A dashed group bbox overlay shows what rides along and tracks the live delta. clientToPlan moves to lib/floorplan/plan-coords for reuse. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): group manipulation polish — helper text + shortcuts dialog Multi-selection select-mode HUD now advertises the group gestures (drag any member to move the whole selection, R/T to step-rotate), and the keyboard-shortcuts dialog documents both under Selection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): restore zone renderer useLiveNodeOverrides import Formatter stripped it between the import and usage edits; nodes' tsc --build catches it where the cached turbo typecheck did not. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): tag the 2D group selection box for drivability data-group-selection-box on the overlay <g> so smoke drivers and devtools can assert the multi-selection chrome. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): multi-selection shows highlight only — hide per-node edit chrome While 2+ nodes are selected the group is manipulated as one rigid piece, so per-member edit affordances hide in both views: the 2D overlay pass strips handle/dimension chrome centrally (stripHandleChrome — body highlight, hit targets, and zone name text stay), and in 3D the slab / ceiling boundary editors and slab hole click-to-edit outlines mount only for a sole selection (the arrow-handle rig, wall side arrows, selection affordances, and floating menu were already single-gated). Transformable members show a move cursor in the floor plan. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): 3D body-drag group move replaces the move gizmo cross Pressing any transformable member of a multi-selection in 3D and dragging past the threshold now slides the whole selection on the ground plane (group-move-3d.ts, armed from the selection manager's pointer-down choke point) — same participant snapshot, welded junctions, grid + alignment snapping, live overrides, and single-undo commit as the 2D session; the 2D dashed bbox rides the same delta in split view. A plain click still collapses the selection to the pressed node. The purple GroupMoveHandle cross is deleted, and the hover cursor advertises the gesture: 'move' over any transformable member in both views (3D selection-manager cursor + 2D entry cursor). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): group action menu — move / duplicate / delete the whole selection Multi-selections get a floating Move / Duplicate / Delete pill in BOTH views (GroupFloatingActionMenu anchored above the 3D group bbox, FloorplanGroupActionMenu anchored above the 2D dashed group box); the single-node menus are now sole-selection only. All three actions target the whole selection via shared group-actions: - Move starts a group pick-up: the selection rides the cursor (delta-relative, grid + alignment snapped) across BOTH surfaces — floorplan via the scene CTM, 3D via a ground-plane raycast through a three-context bridge published by the selection manager — until a click places it as one undo step; Escape / right-click cancels. - Duplicate clones the selection through the clipboard pipeline (subtrees + id remap, without touching the user's clipboard — new duplicateNodesToLevel), selects the clones, and picks them up; cancelling deletes the clones again. The pick-up scopes to the selection (no component expansion / welded links) because the clones sit exactly on the originals, and falls back to participant-data bounds because the clones' meshes haven't mounted yet. - Delete removes everything selected with the keyboard arm's bulk-confirm semantics. Verified end-to-end with the scripted smoke (16/16): chrome hiding, 2D/3D/split group drags, R/T round-trip, one-step undo, menu move / duplicate / delete, 3D move cursor. (Headless runs of the suite can deadlock in SwiftShader's GL readback on the split-view resize — environment-only; run headed.) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): group transforms no longer re-create auto rooms Every group commit (2D/3D body drags, pick-up, rotate gizmo, keyboard R/T) now wraps its single updateNodes in pauseSpaceDetection / resumeSpaceDetection: the wall-driven room auto-detection rolls its baseline forward instead of treating rigidly-moved walls as a new room and duplicating its floors/ceilings. Room creation stays where it belongs — building and editing walls. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): polygon hosts carry their attached items in group transforms Ceiling-mounted items are children of the ceiling, but polygon hosts (slab/ceiling) move by rewriting vertices — no group transform — so, unlike wall children which ride the wall mesh, their children were left behind by group moves/rotates. collectParticipants now snapshots a polygon participant's positioned children (level-frame coords, since the host group sits at the origin) so they ride every group path. Unit test included. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): click picks up the group; the 2D dashed box is the drag handle Clicking a selected member of a multi-selection (no drag) now enters the group pick-up — the same click-to-move the sole-selection has — instead of collapsing the selection, in 2D and 3D alike; clicking outside still deselects. The 2D dashed selection box is itself the group's handle: move cursor across its whole area, press-drag anywhere inside slides the group, a plain click picks it up, and holding Cmd/Ctrl/Shift lets clicks pass through to the entries so membership toggling keeps working. HUD hint + shortcuts dialog updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): 3D dashed group selection box doubles as the drag handle The multi-selection now shows a dashed wireframe box in 3D (sibling of the 2D dashed rect): move cursor across its whole volume, press-drag anywhere on it slides the group, a plain click picks it up, and holding a selection modifier passes the press through so members inside can still be toggled. Rides the shared live-drag delta so it tracks the group mid-gesture in both panes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): mid-move R/T, 2D corner rotate, realtime opening symbols, box cursor + Esc hint - R/T while carrying a group (body drag or pick-up) now rotates the carried snapshots around the rest pivot — identical to the idle keyboard rotate — instead of leaking into the store mid-session; the session keydown owns the keys in capture phase and the group-move HUD advertises them. - The 2D dashed box grows corner rotate handles: drag a corner to spin the group in 15° steps, Shift for free rotation — the floor-plan sibling of the 3D rotate gizmo, sharing its scope, HUD hints, and single-undo + space-detection-paused commit. - Door / window floor-plan symbols now track wall drags in realtime: their defs merge the walls' live overrides (wallFloorplanSiblingOverrides) so ctx.parent is the effective wall instead of the stale store one. - The 3D selection box asserts the move cursor across its whole volume on pointer move (the old ''-guard lost to app default cursors). - Multi-select HUD + shortcuts dialog mention Esc / click-outside to clear, and the mid-move rotate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): rotate cursor + spinning box on 2D corner rotate; Delete ends a carry - The 2D corner handles show a proper curved-arrow rotate cursor (inline SVG data URI, black glyph with white halo, grab fallback). - The dashed selection box spins live with the group during a corner rotate: the rotate session publishes pivot+angle through the shared drag store and the box applies the SVG rotate transform. - Delete / Backspace during any group session (drag, rotate, pick-up) reverts the session first and then lets the global Delete arm remove the selection — no more dangling carry after deleting mid-move; the duplicate flow's cancel still discards the clones instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): per-node direct manipulation stands down for multi-selections Cmd is both the selection-toggle key and the single-node direct-move / direct-rotate trigger, so a Cmd+click that wobbled past the drag threshold over a selected member (slab or any kind) armed the legacy single-node move and yanked that one member out of the group. All four per-node direct-manipulation entry points — the 3D Cmd-drag move and Cmd+right-drag rotate in the selection manager, and their 2D siblings in the registry layer — now require the pressed node to be the SOLE selection; with a multi-selection the gesture is simply not registered (the group sessions own plain drags, Cmd+click keeps toggling). The shortcuts dialog notes the single-selection scope. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): group gestures own their ending pointerup — no synthesized click leak use-node-events synthesizes a selection click on EVERY canvas pointerup (deliberately more forgiving than R3F's onClick). Body drags were safe only because inputDragging suppresses it, but the pick-up flows leaked it as a race: the release that started a pick-up could collapse the multi-selection to the pressed node first (then only that node was carried), and the placement press re-selected whatever sat under the cursor after commit. The group sessions now claim their gesture-ending pointer events in the CAPTURE phase and stop propagation, so the canvas never sees them and no click is synthesized: the pick-up claims the placement press on pointerdown and commits on its pointerup; the 3D and 2D drag/rotate sessions stop their ending pointerup (split view: a 2D-started release over the 3D canvas had the same hole). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): screen-rect marquee tests projected oriented bounds, not double-inflated AABBs The 3D screen-rect box select intersected the marquee with each node's world AABB re-boxed in screen space — two nested axis-aligned inflations. Any oblique camera padded every node's claim, and rotated geometry (now common: group rotation) made it flagrant — a diagonal wall's world AABB spans a full square, so marquees selected objects visually far from the cursor. Membership now tests the marquee against the convex hull of the node's ORIENTED (local-frame) bounding box projected to screen — tight under any rotation and camera, uniform for every kind. Pure helpers (convexHull2D / rectIntersectsHull) live in marquee-geometry.ts with unit tests covering the diagonal-wall regression, containment both ways, and edge-only crossings. The plane marquee variant was already precise and is untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): keep box select alive after group gestures The capture-phase stopPropagation the sessions used to silence the canvas's synthesized selection click also killed the window bubble listeners that clear the box-select pointer suppression — and the mouse pointerId is constant, so one group gesture left the marquee dead until blur. The sessions now use the designed suppression instead: they hold inputDragging raised through the release event's dispatch (lowered on a 0ms timer) so use-node-events suppresses the click itself, and every other pointerup listener runs normally. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): marquee membership by plan footprint; 2D item highlight; site line steps back - The 3D screen-rect marquee now projects itself onto the active level's floor plane and tests the DATA kinds exactly there — walls/fences by their segment, slabs/ceilings/zones by their polygon — matching the plane-marquee tool's semantics. This kills the two remaining imprecision sources the hull pass couldn't: vertex-baked rotation (polygon/fence geometry lives in level coords, so after a group rotation even the local bbox is an inflated axis-aligned square) and ceiling parallax (an elevated plane projects to a screen quad offset from its room, selecting 'from far'). Mesh-transform kinds (items, columns) keep the projected oriented-bbox hull test; plan-space segment/polygon intersection helpers join marquee-geometry.ts with unit tests. - Selected items finally read as selected in the floor plan: palette stroke + heavier weight on the footprint, plus a selection ring drawn above the thumbnail (the move dot used to be the only cue, and it hides in multi-selections). - The site's dashed property line drops to 20% opacity while a multi or in-flight marquee selection exists so it stops fighting the dashed group selection box. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): 2D marquee plan-footprint membership; item marquee preview; overlays re-measure after undo - The 2D screen marquee intersected each entry's getBoundingClientRect — an axis-aligned DOM box, inflated for rotated polygons and diagonal walls (the same double-inflation class as the 3D bug). It now maps the marquee through the scene CTM into a plan quad (rotated views included) and tests the data kinds exactly — walls/fences by segment, slab/ceiling/zone by polygon — reusing the shared marquee-geometry helpers; other kinds keep the DOM-rect fallback. - Items now show the marquee preview tint in 2D (highlighted viewState = the same palette stroke + thumbnail ring the selection shows, slightly lighter), instead of giving zero feedback until the drop. - Everything that measures the selection's meshes (2D/3D dashed boxes, the 3D group menu anchor, the rotate gizmo pivot) re-measures once the meshes settle after a scene change via useMeshSettleEpoch — an undo after a move no longer leaves the box at the pre-undo position (computeGroupBox reads mesh world bounds, which lag the store commit by a frame or two). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): dim the actual site boundary line during multi-selections The earlier dimming targeted registry-layer site entries, but the site lives at the scene root — outside the level DFS and the building-scoped sweep — so no entry ever matched and the dashed property line kept full opacity next to the dashed group selection box. Move the dimming to FloorplanSiteLayer (the component that actually draws the line) and drop the dead registry plumbing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Pascal Editor
A 3D building editor built with React Three Fiber and WebGPU.
https://github.com/user-attachments/assets/8b50e7cf-cebe-4579-9cf3-8786b35f7b6b
Repository Architecture
This is a Turborepo monorepo with three main packages:
editor/
├── apps/
│ └── editor/ # Next.js application
├── packages/
│ ├── core/ # Schema definitions, state management, systems
│ ├── viewer/ # 3D rendering components
│ └── ui/ # Shared UI components
Separation of Concerns
| Package | Responsibility |
|---|---|
| @pascal-app/core | Node schemas, scene state (Zustand), systems (geometry generation), spatial queries, event bus |
| @pascal-app/viewer | 3D rendering via React Three Fiber, default camera/controls, post-processing |
| apps/editor | UI components, tools, custom behaviors, editor-specific systems |
The viewer renders the scene with sensible defaults. The editor extends it with interactive tools, selection management, and editing capabilities.
Stores
Each package has its own Zustand store for managing state:
| Store | Package | Responsibility |
|---|---|---|
useScene |
@pascal-app/core |
Scene data: nodes, root IDs, dirty nodes, CRUD operations. Persisted to IndexedDB with undo/redo via Zundo. |
useViewer |
@pascal-app/viewer |
Viewer state: current selection (building/level/zone IDs), level display mode (stacked/exploded/solo), camera mode. |
useEditor |
apps/editor |
Editor state: active tool, structure layer visibility, panel states, editor-specific preferences. |
Access patterns:
// Subscribe to state changes (React component)
const nodes = useScene((state) => state.nodes)
const levelId = useViewer((state) => state.selection.levelId)
const activeTool = useEditor((state) => state.tool)
// Access state outside React (callbacks, systems)
const node = useScene.getState().nodes[id]
useViewer.getState().setSelection({ levelId: 'level_123' })
Core Concepts
Nodes
Nodes are the data primitives that describe the 3D scene. All nodes extend BaseNode:
BaseNode {
id: string // Auto-generated with type prefix (e.g., "wall_abc123")
type: string // Discriminator for type-safe handling
parentId: string | null // Parent node reference
visible: boolean
camera?: Camera // Optional saved camera position
metadata?: JSON // Arbitrary metadata (e.g., { isTransient: true })
}
Node Hierarchy:
Site
└── Building
└── Level
├── Wall → Item (doors, windows)
├── Slab
├── Ceiling → Item (lights)
├── Roof
├── Zone
├── Scan (3D reference)
└── Guide (2D reference)
Nodes are stored in a flat dictionary (Record<id, Node>), not a nested tree. Parent-child relationships are defined via parentId and children arrays.
Scene State (Zustand Store)
The scene is managed by a Zustand store in @pascal-app/core:
useScene.getState() = {
nodes: Record<id, AnyNode>, // All nodes
rootNodeIds: string[], // Top-level nodes (sites)
dirtyNodes: Set<string>, // Nodes pending system updates
createNode(node, parentId),
updateNode(id, updates),
deleteNode(id),
}
Middleware:
- Persist - Saves to IndexedDB (excludes transient nodes)
- Temporal (Zundo) - Undo/redo with 50-step history
Scene Registry
The registry maps node IDs to their Three.js objects for fast lookup:
sceneRegistry = {
nodes: Map<id, Object3D>, // ID → 3D object
byType: {
wall: Set<id>,
item: Set<id>,
zone: Set<id>,
// ...
}
}
Renderers register their refs using the useRegistry hook:
const ref = useRef<Mesh>(null!)
useRegistry(node.id, 'wall', ref)
This allows systems to access 3D objects directly without traversing the scene graph.
Node Renderers
Renderers are React components that create Three.js objects for each node type:
SceneRenderer
└── NodeRenderer (dispatches by type)
├── BuildingRenderer
├── LevelRenderer
├── WallRenderer
├── SlabRenderer
├── ZoneRenderer
├── ItemRenderer
└── ...
Pattern:
- Renderer creates a placeholder mesh/group
- Registers it with
useRegistry - Systems update geometry based on node data
Example (simplified):
const WallRenderer = ({ node }) => {
const ref = useRef<Mesh>(null!)
useRegistry(node.id, 'wall', ref)
return (
<mesh ref={ref}>
<boxGeometry args={[0, 0, 0]} /> {/* Replaced by WallSystem */}
<meshStandardMaterial />
{node.children.map(id => <NodeRenderer key={id} nodeId={id} />)}
</mesh>
)
}
Systems
Systems are React components that run in the render loop (useFrame) to update geometry and transforms. They process dirty nodes marked by the store.
Core Systems (in @pascal-app/core):
| System | Responsibility |
|---|---|
WallSystem |
Generates wall geometry with mitering and CSG cutouts for doors/windows |
SlabSystem |
Generates floor geometry from polygons |
CeilingSystem |
Generates ceiling geometry |
RoofSystem |
Generates roof geometry |
ItemSystem |
Positions items on walls, ceilings, or floors (slab elevation) |
Viewer Systems (in @pascal-app/viewer):
| System | Responsibility |
|---|---|
LevelSystem |
Handles level visibility and vertical positioning (stacked/exploded/solo modes) |
ScanSystem |
Controls 3D scan visibility |
GuideSystem |
Controls guide image visibility |
Processing Pattern:
useFrame(() => {
for (const id of dirtyNodes) {
const obj = sceneRegistry.nodes.get(id)
const node = useScene.getState().nodes[id]
// Update geometry, transforms, etc.
updateGeometry(obj, node)
dirtyNodes.delete(id)
}
})
Dirty Nodes
When a node changes, it's marked as dirty in useScene.getState().dirtyNodes. Systems check this set each frame and only recompute geometry for dirty nodes.
// Automatic: createNode, updateNode, deleteNode mark nodes dirty
useScene.getState().updateNode(wallId, { thickness: 0.2 })
// → wallId added to dirtyNodes
// → WallSystem regenerates geometry next frame
// → wallId removed from dirtyNodes
Manual marking:
useScene.getState().dirtyNodes.add(wallId)
Event Bus
Inter-component communication uses a typed event emitter (mitt):
// Node events
emitter.on('wall:click', (event) => { ... })
emitter.on('item:enter', (event) => { ... })
emitter.on('zone:context-menu', (event) => { ... })
// Grid events (background)
emitter.on('grid:click', (event) => { ... })
// Event payload
NodeEvent {
node: AnyNode
position: [x, y, z]
localPosition: [x, y, z]
normal?: [x, y, z]
stopPropagation: () => void
}
Spatial Grid Manager
Handles collision detection and placement validation:
spatialGridManager.canPlaceOnFloor(levelId, position, dimensions, rotation)
spatialGridManager.canPlaceOnWall(wallId, t, height, dimensions)
spatialGridManager.getSlabElevationAt(levelId, x, z)
Used by item placement tools to validate positions and calculate slab elevations.
Editor Architecture
The editor extends the viewer with:
Tools
Tools are activated via the toolbar and handle user input for specific operations:
- SelectTool - Selection and manipulation
- WallTool - Draw walls
- ZoneTool - Create zones
- ItemTool - Place furniture/fixtures
- SlabTool - Create floor slabs
Selection Manager
The editor uses a custom selection manager with hierarchical navigation:
Site → Building → Level → Zone → Items
Each depth level has its own selection strategy for hover/click behavior.
Editor-Specific Systems
ZoneSystem- Controls zone visibility based on level mode- Custom camera controls with node focusing
Data Flow
User Action (click, drag)
↓
Tool Handler
↓
useScene.createNode() / updateNode()
↓
Node added/updated in store
Node marked dirty
↓
React re-renders NodeRenderer
useRegistry() registers 3D object
↓
System detects dirty node (useFrame)
Updates geometry via sceneRegistry
Clears dirty flag
Building a Plugin
The editor is extensible: a plugin ships node kinds (schema, 3D/2D rendering, placement tools, inspector parametrics) and left-rail panels through the same Plugin manifest the built-ins use — there is no separate internal API.
- Contract reference —
wiki/architecture/plugin-authoring.md: thePluginshape, panel contributions, discovery (setPluginDiscovery), lifecycle, and what's in/out of v1. - Worked example —
packages/plugin-trees: a first-party plugin (procedural trees, flowers, grass + a presets panel) structurally identical to a third-party pack. Copy it as a starting point.
Technology Stack
- React 19 + Next.js 16
- Three.js (WebGPU renderer)
- React Three Fiber + Drei
- Zustand (state management)
- Zod (schema validation)
- Zundo (undo/redo)
- three-bvh-csg (Boolean geometry operations)
- Turborepo (monorepo management)
- Bun (package manager)
Getting Started
Development
Run the development server from the root directory to enable hot reload for all packages:
# Install dependencies
bun install
# Run development server (builds packages + starts editor with watch mode)
bun dev
# This will:
# 1. Build @pascal-app/core and @pascal-app/viewer
# 2. Start watching both packages for changes
# 3. Start the Next.js editor dev server
# Open http://localhost:3000
Important: Always run bun dev from the root directory to ensure the package watchers are running. This enables hot reload when you edit files in packages/core/src/ or packages/viewer/src/.
Building for Production
# Build all packages
turbo build
# Build specific package
turbo build --filter=@pascal-app/core
Publishing Packages
# Build packages
turbo build --filter=@pascal-app/core --filter=@pascal-app/viewer
# Publish to npm
npm publish --workspace=@pascal-app/core --access public
npm publish --workspace=@pascal-app/viewer --access public
Key Files
| Path | Description |
|---|---|
packages/core/src/schema/ |
Node type definitions (Zod schemas) |
packages/core/src/store/use-scene.ts |
Scene state store |
packages/core/src/hooks/scene-registry/ |
3D object registry |
packages/core/src/systems/ |
Geometry generation systems |
packages/viewer/src/components/renderers/ |
Node renderers |
packages/viewer/src/components/viewer/ |
Main Viewer component |
apps/editor/components/tools/ |
Editor tools |
apps/editor/store/ |
Editor-specific state |