Wholesale move of every remaining kind into its own subdirectory under
`packages/nodes/src/`, finishing the registry-driven migration. Each
kind now ships its definition, schema (re-exported from core), and any
of `geometry` / `renderer` / `system` / `floorplan` / `tool` /
`move-tool` / `panel` / `floorplan-move` / `floorplan-affordances` /
`parametrics` / `preview` it needs — no per-kind code remains under
`packages/editor/src/components/tools/` or
`packages/viewer/src/components/renderers/`.
Deleted (replaced by registry-driven equivalents):
- `tools/{ceiling,column,door,fence,item,slab,spawn,wall,window}/...`
(boundary editors, hole editors, placement tools, move tools,
endpoint movers, curve tools, helpers, math libs)
- `ui/helpers/{ceiling,slab,wall}-helper.tsx`
- `ui/panels/{column,door,elevator,item,roof,roof-segment,spawn,
stair,stair-segment,wall,window}-panel.tsx`
- `viewer/src/components/renderers/{building,ceiling,column,door,
elevator,fence,guide,item,level,roof,roof-segment,scan,site,slab,
spawn,stair,stair-segment,wall,window,zone}-renderer.tsx`
- `viewer/src/components/viewer/legacy-system.tsx`
Added under `packages/nodes/src/`:
- `building/`, `column/`, `elevator/`, `guide/`, `level/`, `roof/`,
`roof-segment/`, `scan/`, `shared/`, `site/`, `stair/`,
`stair-segment/` packages with definition + schema + renderer / system
/ floorplan / panel as appropriate.
- New `floorplan-move.ts` for every kind that supports 2D moves
(ceiling, door, item, shelf, slab, window) — single registry-driven
dispatch path via `def.floorplanMoveTarget`.
- New `floorplan-affordances.ts` for kinds with polygon / endpoint
drags (ceiling, fence, slab, wall) — using the shared
`polygon-vertex-affordance` factories.
- New per-kind `panel.tsx` for kinds with custom inspector content
(door, item, shelf, spawn, wall, window).
- New per-kind `tool.tsx` for placement (door, item, shelf, window).
- New per-kind `move-tool.tsx` for kinds with custom 3D move flows
(door, item, slab, window).
Coordinator + manager updates in `packages/editor/`:
- `tool-manager.tsx` resolves tools from the registry only — no
hardcoded type→component map.
- `panel-manager.tsx` resolves inspector panels the same way.
- `placement-{coordinator,strategies,types}.ts` extended with
shelf-surface placement.
- `selection-manager.tsx` adds the registry-selectable fallback.
- `floorplan-panel.tsx`, `floorplan-background-placement.ts`,
`floorplan-render-context.tsx` updated for the registry layer's new
contract (props, affordance dispatch, render context).
Viewer updates:
- `viewer/index.tsx` drops legacy renderer mounts.
- `node-renderer.tsx` resolves by registry only.
- `scene-bvh.tsx`, `use-node-events.ts`, `level-system.tsx`,
`wall-cutout.tsx`, `zone-system.tsx`, `materials.ts` adjusted for
the registry-only world.
Sidebar tree nodes for ceiling / fence / slab / shelf / tree-node
updated to read from the registered nodes instead of the deleted
legacy renderer trees.
Wiki: new `plugin-authoring.md` page, README index updated.
Tests in `packages/nodes/src/index.test.ts` validate every registered
kind has the required shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
150 lines
5.1 KiB
TypeScript
150 lines
5.1 KiB
TypeScript
import type {
|
|
FloorplanGeometry,
|
|
FloorplanPoint,
|
|
GeometryContext,
|
|
WallNode,
|
|
WindowNode,
|
|
} from '@pascal-app/core'
|
|
import { buildOpeningPlacementDimensions } from '../shared/opening-placement-dimensions'
|
|
|
|
/**
|
|
* Stage C floor-plan builder for window. Mirrors the legacy
|
|
* floorplan-panel window rendering:
|
|
*
|
|
* 1. Window footprint rectangle in the wall cutout (themed accent
|
|
* stroke when selected).
|
|
* 2. Inset inner outline — the "glass pane" frame inside the cutout.
|
|
* 3. Center mullion line down the middle of the opening, along the
|
|
* wall direction — the legacy's standard glass divider.
|
|
*
|
|
* Skipped vs the full legacy for now: arched / rounded opening shape
|
|
* variants, multi-pane mullion grids.
|
|
*/
|
|
export function buildWindowFloorplan(
|
|
node: WindowNode,
|
|
ctx: GeometryContext,
|
|
): FloorplanGeometry | null {
|
|
const wall = ctx.parent as WallNode | null
|
|
if (!wall || wall.type !== 'wall') return null
|
|
|
|
const [x1, z1] = wall.start
|
|
const [x2, z2] = wall.end
|
|
const dx = x2 - x1
|
|
const dz = z2 - z1
|
|
const length = Math.sqrt(dx * dx + dz * dz)
|
|
if (length < 1e-9) return null
|
|
|
|
const dirX = dx / length
|
|
const dirZ = dz / length
|
|
const perpX = -dirZ
|
|
const perpZ = dirX
|
|
|
|
const distance = node.position[0]
|
|
const width = node.width
|
|
const depth = wall.thickness ?? 0.1
|
|
const cx = x1 + dirX * distance
|
|
const cz = z1 + dirZ * distance
|
|
const halfWidth = width / 2
|
|
const halfDepth = depth / 2
|
|
|
|
const points: readonly FloorplanPoint[] = [
|
|
[cx - dirX * halfWidth + perpX * halfDepth, cz - dirZ * halfWidth + perpZ * halfDepth],
|
|
[cx + dirX * halfWidth + perpX * halfDepth, cz + dirZ * halfWidth + perpZ * halfDepth],
|
|
[cx + dirX * halfWidth - perpX * halfDepth, cz + dirZ * halfWidth - perpZ * halfDepth],
|
|
[cx - dirX * halfWidth - perpX * halfDepth, cz - dirZ * halfWidth - perpZ * halfDepth],
|
|
]
|
|
|
|
const view = ctx.viewState
|
|
const palette = view?.palette
|
|
const isSelected = view?.selected ?? false
|
|
const isHighlighted = view?.highlighted ?? false
|
|
const showSelectedChrome = isSelected || isHighlighted
|
|
|
|
// Same selection treatment as door — selected windows get a full
|
|
// orange body + outline so they read as the active target.
|
|
const accentColor = showSelectedChrome ? '#f97316' : 'rgba(31, 41, 55, 0.92)'
|
|
const fillColor = showSelectedChrome ? '#fed7aa' : 'rgba(255, 255, 255, 0.96)'
|
|
|
|
// Inner inset rectangle (the glass pane outline). Tangent inset
|
|
// pulls the long sides in slightly; normal inset reduces the depth.
|
|
const tangentInset = Math.min(width * 0.08, 0.12)
|
|
const normalInset = Math.min(depth * 0.22, 0.07)
|
|
const innerStartA: FloorplanPoint = [
|
|
cx - dirX * (halfWidth - tangentInset) + perpX * (halfDepth - normalInset),
|
|
cz - dirZ * (halfWidth - tangentInset) + perpZ * (halfDepth - normalInset),
|
|
]
|
|
const innerEndA: FloorplanPoint = [
|
|
cx + dirX * (halfWidth - tangentInset) + perpX * (halfDepth - normalInset),
|
|
cz + dirZ * (halfWidth - tangentInset) + perpZ * (halfDepth - normalInset),
|
|
]
|
|
const innerEndB: FloorplanPoint = [
|
|
cx + dirX * (halfWidth - tangentInset) - perpX * (halfDepth - normalInset),
|
|
cz + dirZ * (halfWidth - tangentInset) - perpZ * (halfDepth - normalInset),
|
|
]
|
|
const innerStartB: FloorplanPoint = [
|
|
cx - dirX * (halfWidth - tangentInset) - perpX * (halfDepth - normalInset),
|
|
cz - dirZ * (halfWidth - tangentInset) - perpZ * (halfDepth - normalInset),
|
|
]
|
|
|
|
// Center mullion — from the midpoint of the left edge to the
|
|
// midpoint of the right edge of the cutout.
|
|
const mullionStart: FloorplanPoint = [cx - dirX * halfWidth, cz - dirZ * halfWidth]
|
|
const mullionEnd: FloorplanPoint = [cx + dirX * halfWidth, cz + dirZ * halfWidth]
|
|
|
|
const children: FloorplanGeometry[] = [
|
|
// Outer footprint — white fill so the wall hatch underneath
|
|
// doesn't bleed through.
|
|
{
|
|
kind: 'polygon',
|
|
points,
|
|
fill: fillColor,
|
|
stroke: accentColor,
|
|
strokeWidth: showSelectedChrome ? 1.9 : 1.25,
|
|
vectorEffect: 'non-scaling-stroke',
|
|
strokeLinejoin: 'round',
|
|
},
|
|
// Inset glass-pane outline.
|
|
{
|
|
kind: 'polygon',
|
|
points: [innerStartA, innerEndA, innerEndB, innerStartB],
|
|
fill: 'none',
|
|
stroke: accentColor,
|
|
strokeOpacity: 0.6,
|
|
strokeWidth: showSelectedChrome ? 1.3 : 0.9,
|
|
vectorEffect: 'non-scaling-stroke',
|
|
strokeLinejoin: 'round',
|
|
},
|
|
// Center mullion.
|
|
{
|
|
kind: 'line',
|
|
x1: mullionStart[0],
|
|
y1: mullionStart[1],
|
|
x2: mullionEnd[0],
|
|
y2: mullionEnd[1],
|
|
stroke: accentColor,
|
|
strokeWidth: showSelectedChrome ? 1.6 : 1.1,
|
|
strokeOpacity: 0.85,
|
|
strokeLinecap: 'round',
|
|
vectorEffect: 'non-scaling-stroke',
|
|
},
|
|
]
|
|
|
|
// Move handle — orange dot at the window center. Only when selected.
|
|
if (isSelected) {
|
|
children.push({
|
|
kind: 'move-handle',
|
|
point: [cx, cz],
|
|
})
|
|
}
|
|
|
|
// Placement-measurement dimensions when actively moving — same
|
|
// contract as door (see `nodes/src/door/floorplan.ts`).
|
|
if (view?.moving) {
|
|
for (const dim of buildOpeningPlacementDimensions(node, ctx)) {
|
|
children.push(dim)
|
|
}
|
|
}
|
|
|
|
return { kind: 'group', children }
|
|
}
|