@ahrowe/ui 0.41.2 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs-types/common/floorPlan/floorPlan.graph.d.ts +10 -3
- package/dist/cjs-types/common/floorPlan/floorPlan.plan.d.ts +5 -0
- package/dist/cjs-types/common/floorPlan/floorPlan.rooms.d.ts +6 -2
- package/dist/cjs-types/common/floorPlan/floorPlan.snap.d.ts +1 -3
- package/dist/cjs-types/common/floorPlan/index.d.ts +1 -3
- package/dist/cjs-types/common/planCanvas/planCanvas.types.d.ts +1 -1
- package/dist/cjs-types/common/roomDrawer/roomDrawer.types.d.ts +29 -8
- package/dist/cjs-types/common/roomViewer/roomViewer.types.d.ts +4 -2
- package/dist/esm/common/floorPlan/floorPlan.faces.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.faces.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.geometry.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.geometry.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.graph.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.graph.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.hit.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.hit.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.json.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.json.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.mesh.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.mesh.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.path.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.path.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.plan.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.plan.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.rooms.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.rooms.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.snap.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.snap.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.triangulate.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.triangulate.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.types.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.types.mjs.map +1 -1
- package/dist/esm/common/planCanvas/planCanvas.mjs +1 -1
- package/dist/esm/common/planCanvas/planCanvas.mjs.map +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs.map +1 -1
- package/dist/esm/common/roomViewer/roomViewer.mjs +1 -1
- package/dist/esm/common/roomViewer/roomViewer.mjs.map +1 -1
- package/dist/esm/floor-plan.mjs +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/floor-plan.cjs +1 -0
- package/dist/floorPlan-DLe5XAx6.cjs +2 -0
- package/dist/floorPlan-DLe5XAx6.cjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/types/common/floorPlan/floorPlan.graph.d.ts +10 -3
- package/dist/types/common/floorPlan/floorPlan.plan.d.ts +5 -0
- package/dist/types/common/floorPlan/floorPlan.rooms.d.ts +6 -2
- package/dist/types/common/floorPlan/floorPlan.snap.d.ts +1 -3
- package/dist/types/common/floorPlan/index.d.ts +1 -3
- package/dist/types/common/planCanvas/planCanvas.types.d.ts +1 -1
- package/dist/types/common/roomDrawer/roomDrawer.types.d.ts +29 -8
- package/dist/types/common/roomViewer/roomViewer.types.d.ts +4 -2
- package/docs/CLAUDE.md +3 -1
- package/docs/FloorPlan.md +18 -14
- package/docs/RoomDrawer.md +42 -13
- package/docs/RoomViewer.md +1 -14
- package/package.json +18 -1
- package/dist/cjs-types/common/floorPlan/legacySvg.d.ts +0 -27
- package/dist/esm/common/floorPlan/legacySvg.mjs +0 -2
- package/dist/esm/common/floorPlan/legacySvg.mjs.map +0 -1
- package/dist/types/common/floorPlan/legacySvg.d.ts +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.snap.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.snap.ts"],"sourcesContent":["/**\n * Snapping, and the screen-to-world conversion it depends on.\n *\n * Two things here are deliberately different from the previous implementation:\n *\n * 1. Conversion and snapping are separate. `clientToWorld` only converts; `resolveSnap`\n * is the only thing that decides. The old `clientToSVG` called `snapPt` internally,\n * which made grid snap unconditional and left no way to hold Alt to disable it.\n *\n * 2. Every tolerance is in SCREEN PIXELS, converted through the current zoom at the\n * point of use. A fixed world-unit tolerance (the old `WALL_TOLERANCE = 8`) means\n * snapping covers a smaller and smaller part of the screen as you zoom in, until it\n * stops working.\n */\n\nimport { dist, pointToSegment, projectOnSegment, segmentIntersection } from './floorPlan.geometry';\nimport type { PlanFloor, PlanPoint } from './floorPlan.types';\n\nexport enum SnapKind {\n None = 'none',\n Node = 'node',\n /** A point projected onto a wall's centreline. */\n Wall = 'wall',\n /** The crossing of two walls, or of a wall with the active angle ray. */\n Intersection = 'intersection',\n /** On the infinite line continuing an existing wall. */\n Extension = 'extension',\n /** Shares an x or y coordinate with an existing node. */\n Alignment = 'alignment',\n /** On a ray at a multiple of `angleStepDeg` from `origin`. */\n Angle = 'angle',\n Grid = 'grid',\n}\n\nexport interface SnapGuide {\n kind: SnapKind;\n a: PlanPoint;\n b: PlanPoint;\n /** Render as an unbounded construction line rather than a segment. */\n infinite?: boolean;\n}\n\nexport interface SnapOptions {\n /** Which snaps are active. Pass `[]` (Alt held) to disable snapping entirely. */\n enabled: SnapKind[];\n /** Millimetres. 0 disables grid snap. */\n gridSize: number;\n /** Degrees. 45 gives 0/45/90. 0 disables angle lock. */\n angleStepDeg: number;\n toleranceScreenPx: number;\n /** Nodes are the most valuable snap, so they get a little more room. */\n nodeToleranceScreenPx?: number;\n}\n\nexport const DEFAULT_SNAP_OPTIONS: SnapOptions = {\n enabled: [\n SnapKind.Node,\n SnapKind.Intersection,\n SnapKind.Wall,\n SnapKind.Angle,\n SnapKind.Extension,\n SnapKind.Alignment,\n SnapKind.Grid,\n ],\n gridSize: 100,\n angleStepDeg: 0,\n toleranceScreenPx: 10,\n nodeToleranceScreenPx: 12,\n};\n\nexport interface SnapContext {\n floor: PlanFloor;\n /** World units per screen pixel at the current zoom. See `screenScale`. */\n pxToWorld: number;\n /** The anchored point. Required for angle lock; also enables the length readout. */\n origin?: PlanPoint;\n /**\n * A direction in radians that angle lock measures from, in ADDITION to the world axes.\n *\n * Pass the direction of the wall being continued and the lock offers perpendicular and\n * parallel to that wall, not just to the world. Without it, angle lock is only useful\n * on a building that happens to be aligned to the page.\n */\n referenceAngle?: number;\n excludeWallIds?: ReadonlySet<string>;\n excludeNodeIds?: ReadonlySet<string>;\n options?: Partial<SnapOptions>;\n}\n\nexport interface SnapResult {\n point: PlanPoint;\n kind: SnapKind;\n nodeId?: string;\n wallId?: string;\n /** Parameter along `wallId`, for `SnapKind.Wall`. */\n t?: number;\n /** Everything an overlay needs to draw to explain the snap. */\n guides: SnapGuide[];\n /** Radians from `origin` to `point`, when an origin was given. */\n angle?: number;\n /** Distance from `origin` to `point`, when an origin was given. */\n distance?: number;\n /**\n * Set when angle lock produced the result, saying what it locked against: the world\n * axes, or the reference direction that was passed in.\n */\n angleRelativeTo?: 'world' | 'reference';\n}\n\n/** An infinite line as a point and a unit direction. */\ninterface Line {\n kind: SnapKind;\n point: PlanPoint;\n dir: PlanPoint;\n residual: number;\n /** Angle lock only: which basis the ray was measured from. */\n relativeTo?: 'world' | 'reference';\n}\n\n/** World units per screen pixel, from the element's current transform. */\nexport function screenScale(svg: SVGSVGElement): number {\n const ctm = svg.getScreenCTM();\n if (!ctm) return 1;\n // Measured rather than read off ctm.a, so a non-uniform or rotated transform still\n // gives a sensible scalar.\n const scale = Math.hypot(ctm.a, ctm.b);\n return scale === 0 ? 1 : 1 / scale;\n}\n\n/**\n * Client (screen) coordinates to world coordinates. Pure conversion, no snapping.\n *\n * Uses `getBoundingClientRect` arithmetic against an explicit viewport rather than\n * `getScreenCTM`, which returns `null` in jsdom and so makes anything built on it\n * untestable.\n */\nexport function clientToWorld(\n clientX: number,\n clientY: number,\n rect: { left: number; top: number },\n view: { x: number; y: number; zoom: number },\n): PlanPoint {\n return {\n x: view.x + (clientX - rect.left) / view.zoom,\n y: view.y + (clientY - rect.top) / view.zoom,\n };\n}\n\nfunction perpendicularDistanceToLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): number {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n return Math.abs(vx * line.dir.y - vy * line.dir.x);\n}\n\nfunction projectOnLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): PlanPoint {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n const along = vx * line.dir.x + vy * line.dir.y;\n return { x: line.point.x + line.dir.x * along, y: line.point.y + line.dir.y * along };\n}\n\nfunction intersectLines(l1: Line, l2: Line): PlanPoint | null {\n const denom = l1.dir.x * l2.dir.y - l1.dir.y * l2.dir.x;\n if (Math.abs(denom) < 1e-9) return null;\n const dx = l2.point.x - l1.point.x;\n const dy = l2.point.y - l1.point.y;\n const t = (dx * l2.dir.y - dy * l2.dir.x) / denom;\n return { x: l1.point.x + l1.dir.x * t, y: l1.point.y + l1.dir.y * t };\n}\n\nfunction angleBetween(l1: Line, l2: Line): number {\n const dot = Math.abs(l1.dir.x * l2.dir.x + l1.dir.y * l2.dir.y);\n return Math.acos(Math.min(1, dot));\n}\n\nfunction roundTo(value: number, step: number): number {\n return step > 0 ? Math.round(value / step) * step : value;\n}\n\n/**\n * Resolves a raw pointer position to the point the user meant.\n *\n * Two stages, because half of these snaps are constraints rather than points. A hard\n * snap (node, intersection, wall) fixes both degrees of freedom, so the first match\n * wins. A constraint (angle lock, extension, alignment) removes only one, so a flat\n * \"first match wins\" list would kick the point off the angle ray the moment an\n * alignment also matched. Two constraints intersect; one constraint is projected onto\n * and then slid ALONG to the nearest grid position, which is what lets angle lock and\n * grid coexist instead of fighting.\n */\nexport function resolveSnap(raw: PlanPoint, ctx: SnapContext): SnapResult {\n const options: SnapOptions = { ...DEFAULT_SNAP_OPTIONS, ...ctx.options };\n const enabled = new Set(options.enabled);\n\n /**\n * Measures the resolved point back against the origin, so every branch reports the\n * same angle and distance without each one having to compute them. Taking them from\n * the final point rather than from whichever branch produced it means they always\n * describe what the user actually gets.\n */\n const finish = (result: SnapResult): SnapResult => {\n if (!ctx.origin) return result;\n const dx = result.point.x - ctx.origin.x;\n const dy = result.point.y - ctx.origin.y;\n return { ...result, angle: Math.atan2(dy, dx), distance: Math.hypot(dx, dy) };\n };\n\n if (enabled.size === 0) return finish({ point: raw, kind: SnapKind.None, guides: [] });\n\n const tol = options.toleranceScreenPx * ctx.pxToWorld;\n const nodeTol = (options.nodeToleranceScreenPx ?? options.toleranceScreenPx) * ctx.pxToWorld;\n const { floor } = ctx;\n\n /**\n * Angle lock, when the caller has asked for it, is a HARD constraint rather than\n * another proximity snap: `angleStepDeg > 0` only happens because the user latched the\n * lock or held the modifier. Gating it by tolerance like the ambient snaps would mean\n * it silently stopped applying as soon as you dragged more than a few pixels off the\n * ray, which is the opposite of what a lock is for.\n */\n const lockedRay: Line | null = (() => {\n if (!enabled.has(SnapKind.Angle) || !ctx.origin || options.angleStepDeg <= 0) return null;\n const step = (options.angleStepDeg * Math.PI) / 180;\n const rawAngle = Math.atan2(raw.y - ctx.origin.y, raw.x - ctx.origin.x);\n\n // Measure from the world axes, and also from the reference direction when one was\n // given, so \"square to the wall I am continuing\" is available as well as \"square to\n // the page\". Whichever ray the pointer is closest to wins.\n const bases: Array<{ angle: number; relativeTo: 'world' | 'reference' }> = [{ angle: 0, relativeTo: 'world' }];\n if (ctx.referenceAngle !== undefined) {\n bases.push({ angle: ctx.referenceAngle, relativeTo: 'reference' });\n }\n\n let best: Line | null = null;\n for (const base of bases) {\n const snapped = base.angle + Math.round((rawAngle - base.angle) / step) * step;\n const dir = { x: Math.cos(snapped), y: Math.sin(snapped) };\n const line: Line = {\n kind: SnapKind.Angle,\n point: ctx.origin,\n dir,\n residual: 0,\n relativeTo: base.relativeTo,\n };\n line.residual = perpendicularDistanceToLine(raw, line);\n if (!best || line.residual < best.residual) best = line;\n }\n return best;\n })();\n\n /**\n * While the lock is on, a hard snap is only allowed to win if it sits ON the ray.\n * Otherwise \"hold the angle\" would be quietly overridden by any nearby corner, which\n * is exactly the case the lock exists to prevent.\n */\n const allowedByLock = (p: PlanPoint): boolean => !lockedRay || perpendicularDistanceToLine(p, lockedRay) <= tol;\n\n // ── Stage A: hard snaps ──────────────────────────────────────────────────────\n\n if (enabled.has(SnapKind.Node)) {\n let best: { id: string; point: PlanPoint; d: number } | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const d = dist(raw, node);\n if (d <= nodeTol && allowedByLock(node) && (!best || d < best.d)) {\n best = { id: node.id, point: { x: node.x, y: node.y }, d };\n }\n }\n if (best) {\n return finish({ point: best.point, kind: SnapKind.Node, nodeId: best.id, guides: [] });\n }\n }\n\n const walls = Object.values(floor.walls).filter((w) => !ctx.excludeWallIds?.has(w.id));\n\n if (enabled.has(SnapKind.Intersection)) {\n let best: { point: PlanPoint; d: number } | null = null;\n for (let i = 0; i < walls.length; i++) {\n for (let j = i + 1; j < walls.length; j++) {\n const a = floor.nodes[walls[i].a];\n const b = floor.nodes[walls[i].b];\n const c = floor.nodes[walls[j].a];\n const d2 = floor.nodes[walls[j].b];\n if (!a || !b || !c || !d2) continue;\n const hit = segmentIntersection(a, b, c, d2);\n if (!hit.point) continue;\n const d = dist(raw, hit.point);\n if (d <= tol && allowedByLock(hit.point) && (!best || d < best.d)) {\n best = { point: hit.point, d };\n }\n }\n }\n if (best) return finish({ point: best.point, kind: SnapKind.Intersection, guides: [] });\n }\n\n if (enabled.has(SnapKind.Wall)) {\n let best: { wallId: string; point: PlanPoint; t: number; d: number } | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const r = pointToSegment(raw, a, b);\n if (r.dist <= tol && allowedByLock(r.point) && (!best || r.dist < best.d)) {\n // Project exactly: intent is allowed to be approximate, the model is not.\n best = { wallId: wall.id, point: projectOnSegment(raw, a, b), t: r.t, d: r.dist };\n }\n }\n if (best) {\n return finish({\n point: best.point,\n kind: SnapKind.Wall,\n wallId: best.wallId,\n t: best.t,\n guides: [],\n });\n }\n }\n\n // ── Stage B: constraints ─────────────────────────────────────────────────────\n\n const constraints: Line[] = [];\n\n if (enabled.has(SnapKind.Extension)) {\n let best: Line | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const len = dist(a, b);\n if (len < 1e-6) continue;\n const dir = { x: (b.x - a.x) / len, y: (b.y - a.y) / len };\n const line: Line = { kind: SnapKind.Extension, point: { x: a.x, y: a.y }, dir, residual: 0 };\n line.residual = perpendicularDistanceToLine(raw, line);\n // Only beyond the segment itself; on the segment, the wall snap already applies.\n const onSegment = pointToSegment(raw, a, b).dist <= tol;\n if (line.residual <= tol && !onSegment && (!best || line.residual < best.residual)) {\n best = line;\n }\n }\n if (best) constraints.push(best);\n }\n\n if (enabled.has(SnapKind.Alignment)) {\n let bestV: Line | null = null;\n let bestH: Line | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const dx = Math.abs(raw.x - node.x);\n if (dx <= tol && (!bestV || dx < bestV.residual)) {\n bestV = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 0, y: 1 },\n residual: dx,\n };\n }\n const dy = Math.abs(raw.y - node.y);\n if (dy <= tol && (!bestH || dy < bestH.residual)) {\n bestH = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 1, y: 0 },\n residual: dy,\n };\n }\n }\n if (bestV) constraints.push(bestV);\n if (bestH) constraints.push(bestH);\n }\n\n const guideFor = (line: Line, through: PlanPoint): SnapGuide => ({\n kind: line.kind,\n a: { x: through.x - line.dir.x * 1e5, y: through.y - line.dir.y * 1e5 },\n b: { x: through.x + line.dir.x * 1e5, y: through.y + line.dir.y * 1e5 },\n infinite: true,\n });\n\n if (lockedRay) {\n // The ray is fixed; the only freedom left is where along it the point sits. Another\n // constraint that genuinely crosses it pins that down, which is the useful\n // \"45 degrees AND level with that corner\" case.\n const crossing = constraints\n .filter((c) => c.residual <= tol && angleBetween(lockedRay, c) > (15 * Math.PI) / 180)\n .sort((a, b) => a.residual - b.residual)[0];\n\n if (crossing) {\n const point = intersectLines(lockedRay, crossing);\n if (point && dist(point, raw) <= tol * 4) {\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point), guideFor(crossing, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n }\n\n let point = projectOnLine(raw, lockedRay);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the ray to a round length, rather than rounding both coordinates,\n // which would take the point straight back off it.\n const along = (point.x - lockedRay.point.x) * lockedRay.dir.x + (point.y - lockedRay.point.y) * lockedRay.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: lockedRay.point.x + lockedRay.dir.x * snappedAlong,\n y: lockedRay.point.y + lockedRay.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n\n if (constraints.length >= 2) {\n const sorted = [...constraints].sort((a, b) => a.residual - b.residual);\n const [l1, l2] = sorted;\n const point = intersectLines(l1, l2);\n // Two nearly parallel constraints intersect somewhere useless and far away.\n if (point && angleBetween(l1, l2) > (15 * Math.PI) / 180 && dist(point, raw) <= tol * 2) {\n return finish({\n point,\n kind: SnapKind.Intersection,\n guides: [guideFor(l1, point), guideFor(l2, point)],\n });\n }\n }\n\n if (constraints.length >= 1) {\n const line = [...constraints].sort((a, b) => a.residual - b.residual)[0];\n let point = projectOnLine(raw, line);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the constraint to a round distance, rather than rounding both\n // coordinates, which would take the point back off the line.\n const along = (point.x - line.point.x) * line.dir.x + (point.y - line.point.y) * line.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: line.point.x + line.dir.x * snappedAlong,\n y: line.point.y + line.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: line.kind,\n guides: [guideFor(line, point)],\n angleRelativeTo: line.relativeTo,\n });\n }\n\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n return finish({\n point: { x: roundTo(raw.x, options.gridSize), y: roundTo(raw.y, options.gridSize) },\n kind: SnapKind.Grid,\n guides: [],\n });\n }\n\n return finish({ point: raw, kind: SnapKind.None, guides: [] });\n}\n"],"mappings":"gIAkBA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OACA,EAAA,KAAA,OAEA,EAAA,KAAA,OAEA,EAAA,aAAA,eAEA,EAAA,UAAA,YAEA,EAAA,UAAA,YAEA,EAAA,MAAA,QACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EAsBa,EAAoC,CAC/C,QAAS,oEAQT,EACA,SAAU,IACV,aAAc,EACd,kBAAmB,GACnB,sBAAuB,EACzB,EAoDA,SAAgB,EAAY,EAA4B,CACtD,IAAM,EAAM,EAAI,aAAa,EAC7B,GAAI,CAAC,EAAK,MAAO,GAGjB,IAAM,EAAQ,KAAK,MAAM,EAAI,EAAG,EAAI,CAAC,EACrC,OAAO,IAAU,EAAI,EAAI,EAAI,CAC/B,CASA,SAAgB,EACd,EACA,EACA,EACA,EACW,CACX,MAAO,CACL,EAAG,EAAK,GAAK,EAAU,EAAK,MAAQ,EAAK,KACzC,EAAG,EAAK,GAAK,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AK,GAAK,KAAK,GAAM,KAAO,EAAK,EAAO,CAAG,GAAK,EAAM,EACpF,OAAO,EAAO,CACZ,QACA,KAAA,eACA,OAAQ,CAAC,EAAS,EAAI,CAAK,EAAG,EAAS,EAAI,CAAK,CAAC,CACnD,CAAC,CAEL,CAEA,GAAI,EAAY,QAAU,EAAG,CAC3B,IAAM,EAAO,CAAC,GAAG,CAAW,CAAC,CAAC,MAAM,EAAG,IAAM,EAAE,SAAW,EAAE,QAAQ,CAAC,CAAC,GAClE,EAAQ,EAAc,EAAK,CAAI,EACnC,GAAI,EAAQ,IAAA,MAAiB,GAAK,EAAQ,SAAW,EAAG,CAItD,IAAM,EAAe,GADN,EAAM,EAAI,EAAK,MAAM,GAAK,EAAK,IAAI,GAAK,EAAM,EAAI,EAAK,MAAM,GAAK,EAAK,IAAI,EACtD,EAAQ,QAAQ,EACpD,EAAQ,CACN,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,EAC/B,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,CACjC,CACF,CACA,OAAO,EAAO,CACZ,QACA,KAAM,EAAK,KACX,OAAQ,CAAC,EAAS,EAAM,CAAK,CAAC,EAC9B,gBAAiB,EAAK,UACxB,CAAC,CACH,CAUA,OARI,EAAQ,IAAA,MAAiB,GAAK,EAAQ,SAAW,EAC5C,EAAO,CACZ,MAAO,CAAE,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,EAAG,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,CAAE,EAClF,KAAA,OACA,OAAQ,CAAC,CACX,CAAC,EAGI,EAAO,CAAE,MAAO,EAAK,KAAA,OAAqB,OAAQ,CAAC,CAAE,CAAC,CAC/D"}
|
|
1
|
+
{"version":3,"file":"floorPlan.snap.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.snap.ts"],"sourcesContent":["/**\n * Snapping, and the screen-to-world conversion it depends on.\n *\n * Two things here are deliberately different from the previous implementation:\n *\n * 1. Conversion and snapping are separate. `clientToWorld` only converts; `resolveSnap`\n * is the only thing that decides. The old `clientToSVG` called `snapPt` internally,\n * which made grid snap unconditional and left no way to hold Alt to disable it.\n *\n * 2. Every tolerance is in SCREEN PIXELS, converted through the current zoom at the\n * point of use. A fixed world-unit tolerance (the old `WALL_TOLERANCE = 8`) means\n * snapping covers a smaller and smaller part of the screen as you zoom in, until it\n * stops working.\n */\n\nimport { dist, pointToSegment, projectOnSegment, segmentIntersection } from './floorPlan.geometry';\nimport type { PlanFloor, PlanPoint } from './floorPlan.types';\n\nexport enum SnapKind {\n None = 'none',\n Node = 'node',\n /** A point projected onto a wall's centreline. */\n Wall = 'wall',\n /** The crossing of two walls, or of a wall with the active angle ray. */\n Intersection = 'intersection',\n /** On the infinite line continuing an existing wall. */\n Extension = 'extension',\n /** Shares an x or y coordinate with an existing node. */\n Alignment = 'alignment',\n /** On a ray at a multiple of `angleStepDeg` from `origin`. */\n Angle = 'angle',\n Grid = 'grid',\n}\n\nexport interface SnapGuide {\n kind: SnapKind;\n a: PlanPoint;\n b: PlanPoint;\n /** Render as an unbounded construction line rather than a segment. */\n infinite?: boolean;\n}\n\nexport interface SnapOptions {\n /** Which snaps are active. Pass `[]` (Alt held) to disable snapping entirely. */\n enabled: SnapKind[];\n /** Millimetres. 0 disables grid snap. */\n gridSize: number;\n /** Degrees. 45 gives 0/45/90. 0 disables angle lock. */\n angleStepDeg: number;\n toleranceScreenPx: number;\n /** Nodes are the most valuable snap, so they get a little more room. */\n nodeToleranceScreenPx?: number;\n}\n\nexport const DEFAULT_SNAP_OPTIONS: SnapOptions = {\n enabled: [\n SnapKind.Node,\n SnapKind.Intersection,\n SnapKind.Wall,\n SnapKind.Angle,\n SnapKind.Extension,\n SnapKind.Alignment,\n SnapKind.Grid,\n ],\n gridSize: 100,\n angleStepDeg: 0,\n toleranceScreenPx: 10,\n nodeToleranceScreenPx: 12,\n};\n\nexport interface SnapContext {\n floor: PlanFloor;\n /** World units per screen pixel at the current zoom: `1 / view.zoom`. */\n pxToWorld: number;\n /** The anchored point. Required for angle lock; also enables the length readout. */\n origin?: PlanPoint;\n /**\n * A direction in radians that angle lock measures from, in ADDITION to the world axes.\n *\n * Pass the direction of the wall being continued and the lock offers perpendicular and\n * parallel to that wall, not just to the world. Without it, angle lock is only useful\n * on a building that happens to be aligned to the page.\n */\n referenceAngle?: number;\n excludeWallIds?: ReadonlySet<string>;\n excludeNodeIds?: ReadonlySet<string>;\n options?: Partial<SnapOptions>;\n}\n\nexport interface SnapResult {\n point: PlanPoint;\n kind: SnapKind;\n nodeId?: string;\n wallId?: string;\n /** Parameter along `wallId`, for `SnapKind.Wall`. */\n t?: number;\n /** Everything an overlay needs to draw to explain the snap. */\n guides: SnapGuide[];\n /** Radians from `origin` to `point`, when an origin was given. */\n angle?: number;\n /** Distance from `origin` to `point`, when an origin was given. */\n distance?: number;\n /**\n * Set when angle lock produced the result, saying what it locked against: the world\n * axes, or the reference direction that was passed in.\n */\n angleRelativeTo?: 'world' | 'reference';\n}\n\n/** An infinite line as a point and a unit direction. */\ninterface Line {\n kind: SnapKind;\n point: PlanPoint;\n dir: PlanPoint;\n residual: number;\n /** Angle lock only: which basis the ray was measured from. */\n relativeTo?: 'world' | 'reference';\n}\n\n/**\n * Client (screen) coordinates to world coordinates. Pure conversion, no snapping.\n *\n * Uses `getBoundingClientRect` arithmetic against an explicit viewport rather than\n * `getScreenCTM`, which returns `null` in jsdom and so makes anything built on it\n * untestable.\n */\nexport function clientToWorld(\n clientX: number,\n clientY: number,\n rect: { left: number; top: number },\n view: { x: number; y: number; zoom: number },\n): PlanPoint {\n return {\n x: view.x + (clientX - rect.left) / view.zoom,\n y: view.y + (clientY - rect.top) / view.zoom,\n };\n}\n\nfunction perpendicularDistanceToLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): number {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n return Math.abs(vx * line.dir.y - vy * line.dir.x);\n}\n\nfunction projectOnLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): PlanPoint {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n const along = vx * line.dir.x + vy * line.dir.y;\n return { x: line.point.x + line.dir.x * along, y: line.point.y + line.dir.y * along };\n}\n\nfunction intersectLines(l1: Line, l2: Line): PlanPoint | null {\n const denom = l1.dir.x * l2.dir.y - l1.dir.y * l2.dir.x;\n if (Math.abs(denom) < 1e-9) return null;\n const dx = l2.point.x - l1.point.x;\n const dy = l2.point.y - l1.point.y;\n const t = (dx * l2.dir.y - dy * l2.dir.x) / denom;\n return { x: l1.point.x + l1.dir.x * t, y: l1.point.y + l1.dir.y * t };\n}\n\nfunction angleBetween(l1: Line, l2: Line): number {\n const dot = Math.abs(l1.dir.x * l2.dir.x + l1.dir.y * l2.dir.y);\n return Math.acos(Math.min(1, dot));\n}\n\nfunction roundTo(value: number, step: number): number {\n return step > 0 ? Math.round(value / step) * step : value;\n}\n\n/**\n * Resolves a raw pointer position to the point the user meant.\n *\n * Two stages, because half of these snaps are constraints rather than points. A hard\n * snap (node, intersection, wall) fixes both degrees of freedom, so the first match\n * wins. A constraint (angle lock, extension, alignment) removes only one, so a flat\n * \"first match wins\" list would kick the point off the angle ray the moment an\n * alignment also matched. Two constraints intersect; one constraint is projected onto\n * and then slid ALONG to the nearest grid position, which is what lets angle lock and\n * grid coexist instead of fighting.\n */\nexport function resolveSnap(raw: PlanPoint, ctx: SnapContext): SnapResult {\n const options: SnapOptions = { ...DEFAULT_SNAP_OPTIONS, ...ctx.options };\n const enabled = new Set(options.enabled);\n\n /**\n * Measures the resolved point back against the origin, so every branch reports the\n * same angle and distance without each one having to compute them. Taking them from\n * the final point rather than from whichever branch produced it means they always\n * describe what the user actually gets.\n */\n const finish = (result: SnapResult): SnapResult => {\n if (!ctx.origin) return result;\n const dx = result.point.x - ctx.origin.x;\n const dy = result.point.y - ctx.origin.y;\n return { ...result, angle: Math.atan2(dy, dx), distance: Math.hypot(dx, dy) };\n };\n\n if (enabled.size === 0) return finish({ point: raw, kind: SnapKind.None, guides: [] });\n\n const tol = options.toleranceScreenPx * ctx.pxToWorld;\n const nodeTol = (options.nodeToleranceScreenPx ?? options.toleranceScreenPx) * ctx.pxToWorld;\n const { floor } = ctx;\n\n /**\n * Angle lock, when the caller has asked for it, is a HARD constraint rather than\n * another proximity snap: `angleStepDeg > 0` only happens because the user latched the\n * lock or held the modifier. Gating it by tolerance like the ambient snaps would mean\n * it silently stopped applying as soon as you dragged more than a few pixels off the\n * ray, which is the opposite of what a lock is for.\n */\n const lockedRay: Line | null = (() => {\n if (!enabled.has(SnapKind.Angle) || !ctx.origin || options.angleStepDeg <= 0) return null;\n const step = (options.angleStepDeg * Math.PI) / 180;\n const rawAngle = Math.atan2(raw.y - ctx.origin.y, raw.x - ctx.origin.x);\n\n // Measure from the world axes, and also from the reference direction when one was\n // given, so \"square to the wall I am continuing\" is available as well as \"square to\n // the page\". Whichever ray the pointer is closest to wins.\n const bases: Array<{ angle: number; relativeTo: 'world' | 'reference' }> = [{ angle: 0, relativeTo: 'world' }];\n if (ctx.referenceAngle !== undefined) {\n bases.push({ angle: ctx.referenceAngle, relativeTo: 'reference' });\n }\n\n let best: Line | null = null;\n for (const base of bases) {\n const snapped = base.angle + Math.round((rawAngle - base.angle) / step) * step;\n const dir = { x: Math.cos(snapped), y: Math.sin(snapped) };\n const line: Line = {\n kind: SnapKind.Angle,\n point: ctx.origin,\n dir,\n residual: 0,\n relativeTo: base.relativeTo,\n };\n line.residual = perpendicularDistanceToLine(raw, line);\n if (!best || line.residual < best.residual) best = line;\n }\n return best;\n })();\n\n /**\n * While the lock is on, a hard snap is only allowed to win if it sits ON the ray.\n * Otherwise \"hold the angle\" would be quietly overridden by any nearby corner, which\n * is exactly the case the lock exists to prevent.\n */\n const allowedByLock = (p: PlanPoint): boolean => !lockedRay || perpendicularDistanceToLine(p, lockedRay) <= tol;\n\n // ── Stage A: hard snaps ──────────────────────────────────────────────────────\n\n if (enabled.has(SnapKind.Node)) {\n let best: { id: string; point: PlanPoint; d: number } | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const d = dist(raw, node);\n if (d <= nodeTol && allowedByLock(node) && (!best || d < best.d)) {\n best = { id: node.id, point: { x: node.x, y: node.y }, d };\n }\n }\n if (best) {\n return finish({ point: best.point, kind: SnapKind.Node, nodeId: best.id, guides: [] });\n }\n }\n\n const walls = Object.values(floor.walls).filter((w) => !ctx.excludeWallIds?.has(w.id));\n\n if (enabled.has(SnapKind.Intersection)) {\n let best: { point: PlanPoint; d: number } | null = null;\n for (let i = 0; i < walls.length; i++) {\n for (let j = i + 1; j < walls.length; j++) {\n const a = floor.nodes[walls[i].a];\n const b = floor.nodes[walls[i].b];\n const c = floor.nodes[walls[j].a];\n const d2 = floor.nodes[walls[j].b];\n if (!a || !b || !c || !d2) continue;\n const hit = segmentIntersection(a, b, c, d2);\n if (!hit.point) continue;\n const d = dist(raw, hit.point);\n if (d <= tol && allowedByLock(hit.point) && (!best || d < best.d)) {\n best = { point: hit.point, d };\n }\n }\n }\n if (best) return finish({ point: best.point, kind: SnapKind.Intersection, guides: [] });\n }\n\n if (enabled.has(SnapKind.Wall)) {\n let best: { wallId: string; point: PlanPoint; t: number; d: number } | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const r = pointToSegment(raw, a, b);\n if (r.dist <= tol && allowedByLock(r.point) && (!best || r.dist < best.d)) {\n // Project exactly: intent is allowed to be approximate, the model is not.\n best = { wallId: wall.id, point: projectOnSegment(raw, a, b), t: r.t, d: r.dist };\n }\n }\n if (best) {\n return finish({\n point: best.point,\n kind: SnapKind.Wall,\n wallId: best.wallId,\n t: best.t,\n guides: [],\n });\n }\n }\n\n // ── Stage B: constraints ─────────────────────────────────────────────────────\n\n const constraints: Line[] = [];\n\n if (enabled.has(SnapKind.Extension)) {\n let best: Line | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const len = dist(a, b);\n if (len < 1e-6) continue;\n const dir = { x: (b.x - a.x) / len, y: (b.y - a.y) / len };\n const line: Line = { kind: SnapKind.Extension, point: { x: a.x, y: a.y }, dir, residual: 0 };\n line.residual = perpendicularDistanceToLine(raw, line);\n // Only beyond the segment itself; on the segment, the wall snap already applies.\n const onSegment = pointToSegment(raw, a, b).dist <= tol;\n if (line.residual <= tol && !onSegment && (!best || line.residual < best.residual)) {\n best = line;\n }\n }\n if (best) constraints.push(best);\n }\n\n if (enabled.has(SnapKind.Alignment)) {\n let bestV: Line | null = null;\n let bestH: Line | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const dx = Math.abs(raw.x - node.x);\n if (dx <= tol && (!bestV || dx < bestV.residual)) {\n bestV = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 0, y: 1 },\n residual: dx,\n };\n }\n const dy = Math.abs(raw.y - node.y);\n if (dy <= tol && (!bestH || dy < bestH.residual)) {\n bestH = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 1, y: 0 },\n residual: dy,\n };\n }\n }\n if (bestV) constraints.push(bestV);\n if (bestH) constraints.push(bestH);\n }\n\n const guideFor = (line: Line, through: PlanPoint): SnapGuide => ({\n kind: line.kind,\n a: { x: through.x - line.dir.x * 1e5, y: through.y - line.dir.y * 1e5 },\n b: { x: through.x + line.dir.x * 1e5, y: through.y + line.dir.y * 1e5 },\n infinite: true,\n });\n\n if (lockedRay) {\n // The ray is fixed; the only freedom left is where along it the point sits. Another\n // constraint that genuinely crosses it pins that down, which is the useful\n // \"45 degrees AND level with that corner\" case.\n const crossing = constraints\n .filter((c) => c.residual <= tol && angleBetween(lockedRay, c) > (15 * Math.PI) / 180)\n .sort((a, b) => a.residual - b.residual)[0];\n\n if (crossing) {\n const point = intersectLines(lockedRay, crossing);\n if (point && dist(point, raw) <= tol * 4) {\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point), guideFor(crossing, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n }\n\n let point = projectOnLine(raw, lockedRay);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the ray to a round length, rather than rounding both coordinates,\n // which would take the point straight back off it.\n const along = (point.x - lockedRay.point.x) * lockedRay.dir.x + (point.y - lockedRay.point.y) * lockedRay.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: lockedRay.point.x + lockedRay.dir.x * snappedAlong,\n y: lockedRay.point.y + lockedRay.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n\n if (constraints.length >= 2) {\n const sorted = [...constraints].sort((a, b) => a.residual - b.residual);\n const [l1, l2] = sorted;\n const point = intersectLines(l1, l2);\n // Two nearly parallel constraints intersect somewhere useless and far away.\n if (point && angleBetween(l1, l2) > (15 * Math.PI) / 180 && dist(point, raw) <= tol * 2) {\n return finish({\n point,\n kind: SnapKind.Intersection,\n guides: [guideFor(l1, point), guideFor(l2, point)],\n });\n }\n }\n\n if (constraints.length >= 1) {\n const line = [...constraints].sort((a, b) => a.residual - b.residual)[0];\n let point = projectOnLine(raw, line);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the constraint to a round distance, rather than rounding both\n // coordinates, which would take the point back off the line.\n const along = (point.x - line.point.x) * line.dir.x + (point.y - line.point.y) * line.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: line.point.x + line.dir.x * snappedAlong,\n y: line.point.y + line.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: line.kind,\n guides: [guideFor(line, point)],\n angleRelativeTo: line.relativeTo,\n });\n }\n\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n return finish({\n point: { x: roundTo(raw.x, options.gridSize), y: roundTo(raw.y, options.gridSize) },\n kind: SnapKind.Grid,\n guides: [],\n });\n }\n\n return finish({ point: raw, kind: SnapKind.None, guides: [] });\n}\n"],"mappings":"mHAkBA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OACA,EAAA,KAAA,OAEA,EAAA,KAAA,OAEA,EAAA,aAAA,eAEA,EAAA,UAAA,YAEA,EAAA,UAAA,YAEA,EAAA,MAAA,QACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EAsBa,EAAoC,CAC/C,QAAS,oEAQT,EACA,SAAU,IACV,aAAc,EACd,kBAAmB,GACnB,sBAAuB,EACzB,EA0DA,SAAgB,EACd,EACA,EACA,EACA,EACW,CACX,MAAO,CACL,EAAG,EAAK,GAAK,EAAU,EAAK,MAAQ,EAAK,KACzC,EAAG,EAAK,GAAK,EAAU,EAAK,KAAO,EAAK,IAC1C,CACF,CAEA,SAAS,EAA4B,EAAc,EAAoD,CACrG,IAAM,EAAK,EAAE,EAAI,EAAK,MAAM,EACtB,EAAK,EAAE,EAAI,EAAK,MAAM,EAC5B,OAAO,KAAK,IAAI,EAAK,EAAK,IAAI,EAAI,EAAK,EAAK,IAAI,CAAC,CACnD,CAEA,SAAS,EAAc,EAAc,EAAuD,CAC1F,IAAM,EAAK,EAAE,EAAI,EAAK,MAAM,EACtB,EAAK,EAAE,EAAI,EAAK,MAAM,EACtB,EAAQ,EAAK,EAAK,IAAI,EAAI,EAAK,EAAK,IAAI,EAC9C,MAAO,CAAE,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,EAAO,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,CAAM,CACtF,CAEA,SAAS,EAAe,EAAU,EAA4B,CAC5D,IAAM,EAAQ,EAAG,IAAI,EAAI,EAAG,IAAI,EAAI,EAAG,IAAI,EAAI,EAAG,IAAI,EACtD,GAAI,KAAK,IAAI,CAAK,EAAI,KAAM,O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,QACA,KAAM,EAAK,KACX,OAAQ,CAAC,EAAS,EAAM,CAAK,CAAC,EAC9B,gBAAiB,EAAK,UACxB,CAAC,CACH,CAUA,OARI,EAAQ,IAAA,MAAiB,GAAK,EAAQ,SAAW,EAC5C,EAAO,CACZ,MAAO,CAAE,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,EAAG,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,CAAE,EAClF,KAAA,OACA,OAAQ,CAAC,CACX,CAAC,EAGI,EAAO,CAAE,MAAO,EAAK,KAAA,OAAqB,OAAQ,CAAC,CAAE,CAAC,CAC/D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{signedArea as e,stripSpurs as t}from"./floorPlan.geometry.mjs";var n=1e-9;function r(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function i(e,t){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}function a(e,t,i,a){let o=r(e,t,i),s=r(e,i,a),c=r(e,a,t);return!((o<-1e-9||s<-1e-9||c<-1e-9)&&(o>n||s>n||c>n))}function o(e,t){let n=e.slice(),r=t.filter(e=>e.length>=3).map(e=>({ring:e,index:e.reduce((t,n,r)=>n.x>e[t].x?r:t,0)})).sort((e,t)=>t.ring[t.index].x-e.ring[e.index].x);for(let e of r){let t=e.ring[e.index],r=-1,i=1/0;for(let a=0;a<n.length;a++){if(n[a].x<t.x)continue;let o=(n[a].x-t.x)**2+(n[a].y-t.y)**2;o<i&&s(t,n[a],n,e.ring)&&(i=o,r=a)}if(r<0)for(let e=0;e<n.length;e++){let a=(n[e].x-t.x)**2+(n[e].y-t.y)**2;a<i&&(i=a,r=e)}let a=[];for(let t=0;t<=e.ring.length;t++)a.push(e.ring[(e.index+t)%e.ring.length]);n=[...n.slice(0,r+1),...a,...n.slice(r)]}return n}function s(e,t,n,i){for(let a of[n,i])for(let n=0;n<a.length;n++){let i=a[n],o=a[(n+1)%a.length];if(i===e||o===e||i===t||o===t)continue;let s=r(e,t,i),c=r(e,t,o),l=r(i,o,e),u=r(i,o,t);if(s*c<0&&l*u<0)return!1}return!0}function c(s,c=[]){let l=t(s);if(l.length<3)return{vertices:[],indices:[]};let u=o(l,c.map(e=>t(e)).filter(e=>e.length>=3)),d=e(u)<0?u.slice().reverse():u.slice(),f=d.map((e,t)=>t),p=[],m=f.length*f.length;for(;f.length>3&&m-->0;){let e=!1;for(let t=0;t<f.length;t++){let o=f[(t+f.length-1)%f.length],s=f[t],c=f[(t+1)%f.length],l=d[o],u=d[s],m=d[c];if(r(l,u,m)<=n)continue;let h=!1;for(let e of f){if(e===o||e===s||e===c)continue;let t=d[e];if(!(i(t,l)||i(t,u)||i(t,m))&&a(t,l,u,m)){h=!0;break}}if(!h){p.push(o,s,c),f.splice(t,1),e=!0;break}}if(!e)break}return f.length===3&&p.push(f[0],f[1],f[2]),{vertices:d,indices:p}}export{c as triangulate};
|
|
2
2
|
//# sourceMappingURL=floorPlan.triangulate.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.triangulate.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.triangulate.ts"],"sourcesContent":["/**\n * Ear clipping for simple polygons, with holes bridged into the outer ring first.\n *\n * Written out rather than pulled in: a floor slab is the only thing in this package that\n * needs a triangulator, and a dependency is a poor trade for one file.\n *\n * The rooms this runs on come from face extraction, so they are already closed, already\n * consistently wound, and free of self-intersections. That is what makes plain ear\n * clipping enough: it is O(n²) and it cannot cope with a self-intersecting ring, and\n * neither limit matters for a room with a few dozen corners.\n */\n\nimport { signedArea, stripSpurs } from './floorPlan.geometry';\nimport type { PlanPoint } from './floorPlan.types';\n\nconst EPS = 1e-9;\n\nfunction area2(a: PlanPoint, b: PlanPoint, c: PlanPoint): number {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\nfunction samePoint(a: PlanPoint, b: PlanPoint): boolean {\n return Math.abs(a.x - b.x) < EPS && Math.abs(a.y - b.y) < EPS;\n}\n\n/** Inclusive of the edges: a vertex lying on one would still leave a sliver behind. */\nfunction inTriangle(p: PlanPoint, a: PlanPoint, b: PlanPoint, c: PlanPoint): boolean {\n const d1 = area2(p, a, b);\n const d2 = area2(p, b, c);\n const d3 = area2(p, c, a);\n const neg = d1 < -EPS || d2 < -EPS || d3 < -EPS;\n const pos = d1 > EPS || d2 > EPS || d3 > EPS;\n return !(neg && pos);\n}\n\n/**\n * Joins each hole to the outer ring with a pair of coincident edges, leaving one ring\n * that ear clipping can take. The bridge runs from the hole's rightmost vertex to a\n * visible vertex of the outer ring, which is the standard construction: going rightwards\n * from the extreme point of a hole must leave it, so the first outer edge hit is visible\n * from it.\n */\nfunction bridgeHoles(outer: PlanPoint[], holes: PlanPoint[][]): PlanPoint[] {\n let ring = outer.slice();\n\n // Rightmost hole first: bridging it cannot cross a hole further right.\n const queue = holes\n .filter((h) => h.length >= 3)\n .map((h) => ({ ring: h, index: h.reduce((best, p, i) => (p.x > h[best].x ? i : best), 0) }))\n .sort((a, b) => b.ring[b.index].x - a.ring[a.index].x);\n\n for (const hole of queue) {\n const from = hole.ring[hole.index];\n\n // The outer vertex to bridge to: the one that is visible and, among those, closest.\n let best = -1;\n let bestDist = Infinity;\n for (let i = 0; i < ring.length; i++) {\n if (ring[i].x < from.x) continue; // must lie to the right, or the bridge doubles back\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist && visible(from, ring[i], ring, hole.ring)) {\n bestDist = d;\n best = i;\n }\n }\n // Nothing to the right was visible, so fall back to the nearest vertex anywhere. The\n // ring stays closed either way; at worst the slab gains a seam nobody can see.\n if (best < 0) {\n for (let i = 0; i < ring.length; i++) {\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist) {\n bestDist = d;\n best = i;\n }\n }\n }\n\n // Walk the hole from its bridge vertex, then come back along the bridge.\n const woven: PlanPoint[] = [];\n for (let k = 0; k <= hole.ring.length; k++) {\n woven.push(hole.ring[(hole.index + k) % hole.ring.length]);\n }\n ring = [...ring.slice(0, best + 1), ...woven, ...ring.slice(best)];\n }\n\n return ring;\n}\n\n/** Whether the segment from `a` to `b` crosses any edge of the rings it has to avoid. */\nfunction visible(a: PlanPoint, b: PlanPoint, ring: PlanPoint[], hole: PlanPoint[]): boolean {\n for (const poly of [ring, hole]) {\n for (let i = 0; i < poly.length; i++) {\n const p = poly[i];\n const q = poly[(i + 1) % poly.length];\n if (p === a || q === a || p === b || q === b) continue;\n const d1 = area2(a, b, p);\n const d2 = area2(a, b, q);\n const d3 = area2(p, q, a);\n const d4 = area2(p, q, b);\n if (d1 * d2 < 0 && d3 * d4 < 0) return false;\n }\n }\n return true;\n}\n\n/**\n * Triangulates a ring and its holes into index triples over the returned vertex list.\n *\n * The vertices come back as well as the indices because bridging a hole duplicates the\n * two vertices it joins, so the caller cannot simply index into what it passed in.\n */\nexport function triangulate(\n outer: readonly PlanPoint[],\n holes: readonly (readonly PlanPoint[])[] = [],\n): { vertices: PlanPoint[]; indices: number[] } {\n // A dangling wall inside a room puts the same vertex in the ring twice, which is not a\n // simple polygon and would stall ear clipping on a zero-area ear.\n const cleanOuter = stripSpurs(outer);\n if (cleanOuter.length < 3) return { vertices: [], indices: [] };\n\n const ring = bridgeHoles(\n cleanOuter,\n holes.map((h) => stripSpurs(h)).filter((h) => h.length >= 3),\n );\n\n // Ear clipping wants a counter-clockwise ring under the usual maths convention.\n const vertices = signedArea(ring) < 0 ? ring.slice().reverse() : ring.slice();\n\n const live = vertices.map((_, i) => i);\n const indices: number[] = [];\n let guard = live.length * live.length;\n\n while (live.length > 3 && guard-- > 0) {\n let clipped = false;\n for (let i = 0; i < live.length; i++) {\n const ai = live[(i + live.length - 1) % live.length];\n const bi = live[i];\n const ci = live[(i + 1) % live.length];\n const a = vertices[ai];\n const b = vertices[bi];\n const c = vertices[ci];\n if (area2(a, b, c) <= EPS) continue; // reflex or degenerate: not an ear\n\n let blocked = false;\n for (const vi of live) {\n if (vi === ai || vi === bi || vi === ci) continue;\n const v = vertices[vi];\n // Bridging a hole duplicates the two vertices it joins, so a candidate can sit\n // exactly on a corner of the ear. Counting that as \"inside\" blocks every ear in\n // the ring and the triangulation comes back empty.\n if (samePoint(v, a) || samePoint(v, b) || samePoint(v, c)) continue;\n if (inTriangle(v, a, b, c)) {\n blocked = true;\n break;\n }\n }\n if (blocked) continue;\n\n indices.push(ai, bi, ci);\n live.splice(i, 1);\n clipped = true;\n break;\n }\n // No ear found: the ring is degenerate in a way this cannot reduce further. Stopping\n // beats spinning, and the caller gets whatever was triangulated so far.\n if (!clipped) break;\n }\n if (live.length === 3) indices.push(live[0], live[1], live[2]);\n\n return { vertices, indices };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"floorPlan.triangulate.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.triangulate.ts"],"sourcesContent":["/**\n * Ear clipping for simple polygons, with holes bridged into the outer ring first.\n *\n * Written out rather than pulled in: a floor slab is the only thing in this package that\n * needs a triangulator, and a dependency is a poor trade for one file.\n *\n * The rooms this runs on come from face extraction, so they are already closed, already\n * consistently wound, and free of self-intersections. That is what makes plain ear\n * clipping enough: it is O(n²) and it cannot cope with a self-intersecting ring, and\n * neither limit matters for a room with a few dozen corners.\n */\n\nimport { signedArea, stripSpurs } from './floorPlan.geometry';\nimport type { PlanPoint } from './floorPlan.types';\n\nconst EPS = 1e-9;\n\nfunction area2(a: PlanPoint, b: PlanPoint, c: PlanPoint): number {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\nfunction samePoint(a: PlanPoint, b: PlanPoint): boolean {\n return Math.abs(a.x - b.x) < EPS && Math.abs(a.y - b.y) < EPS;\n}\n\n/** Inclusive of the edges: a vertex lying on one would still leave a sliver behind. */\nfunction inTriangle(p: PlanPoint, a: PlanPoint, b: PlanPoint, c: PlanPoint): boolean {\n const d1 = area2(p, a, b);\n const d2 = area2(p, b, c);\n const d3 = area2(p, c, a);\n const neg = d1 < -EPS || d2 < -EPS || d3 < -EPS;\n const pos = d1 > EPS || d2 > EPS || d3 > EPS;\n return !(neg && pos);\n}\n\n/**\n * Joins each hole to the outer ring with a pair of coincident edges, leaving one ring\n * that ear clipping can take. The bridge runs from the hole's rightmost vertex to a\n * visible vertex of the outer ring, which is the standard construction: going rightwards\n * from the extreme point of a hole must leave it, so the first outer edge hit is visible\n * from it.\n */\nfunction bridgeHoles(outer: PlanPoint[], holes: PlanPoint[][]): PlanPoint[] {\n let ring = outer.slice();\n\n // Rightmost hole first: bridging it cannot cross a hole further right.\n const queue = holes\n .filter((h) => h.length >= 3)\n .map((h) => ({ ring: h, index: h.reduce((best, p, i) => (p.x > h[best].x ? i : best), 0) }))\n .sort((a, b) => b.ring[b.index].x - a.ring[a.index].x);\n\n for (const hole of queue) {\n const from = hole.ring[hole.index];\n\n // The outer vertex to bridge to: the one that is visible and, among those, closest.\n let best = -1;\n let bestDist = Infinity;\n for (let i = 0; i < ring.length; i++) {\n if (ring[i].x < from.x) continue; // must lie to the right, or the bridge doubles back\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist && visible(from, ring[i], ring, hole.ring)) {\n bestDist = d;\n best = i;\n }\n }\n // Nothing to the right was visible, so fall back to the nearest vertex anywhere. The\n // ring stays closed either way; at worst the slab gains a seam nobody can see.\n if (best < 0) {\n for (let i = 0; i < ring.length; i++) {\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist) {\n bestDist = d;\n best = i;\n }\n }\n }\n\n // Walk the hole from its bridge vertex, then come back along the bridge.\n const woven: PlanPoint[] = [];\n for (let k = 0; k <= hole.ring.length; k++) {\n woven.push(hole.ring[(hole.index + k) % hole.ring.length]);\n }\n ring = [...ring.slice(0, best + 1), ...woven, ...ring.slice(best)];\n }\n\n return ring;\n}\n\n/** Whether the segment from `a` to `b` crosses any edge of the rings it has to avoid. */\nfunction visible(a: PlanPoint, b: PlanPoint, ring: PlanPoint[], hole: PlanPoint[]): boolean {\n for (const poly of [ring, hole]) {\n for (let i = 0; i < poly.length; i++) {\n const p = poly[i];\n const q = poly[(i + 1) % poly.length];\n if (p === a || q === a || p === b || q === b) continue;\n const d1 = area2(a, b, p);\n const d2 = area2(a, b, q);\n const d3 = area2(p, q, a);\n const d4 = area2(p, q, b);\n if (d1 * d2 < 0 && d3 * d4 < 0) return false;\n }\n }\n return true;\n}\n\n/**\n * Triangulates a ring and its holes into index triples over the returned vertex list.\n *\n * The vertices come back as well as the indices because bridging a hole duplicates the\n * two vertices it joins, so the caller cannot simply index into what it passed in.\n */\nexport function triangulate(\n outer: readonly PlanPoint[],\n holes: readonly (readonly PlanPoint[])[] = [],\n): { vertices: PlanPoint[]; indices: number[] } {\n // A dangling wall inside a room puts the same vertex in the ring twice, which is not a\n // simple polygon and would stall ear clipping on a zero-area ear.\n const cleanOuter = stripSpurs(outer);\n if (cleanOuter.length < 3) return { vertices: [], indices: [] };\n\n const ring = bridgeHoles(\n cleanOuter,\n holes.map((h) => stripSpurs(h)).filter((h) => h.length >= 3),\n );\n\n // Ear clipping wants a counter-clockwise ring under the usual maths convention.\n const vertices = signedArea(ring) < 0 ? ring.slice().reverse() : ring.slice();\n\n const live = vertices.map((_, i) => i);\n const indices: number[] = [];\n let guard = live.length * live.length;\n\n while (live.length > 3 && guard-- > 0) {\n let clipped = false;\n for (let i = 0; i < live.length; i++) {\n const ai = live[(i + live.length - 1) % live.length];\n const bi = live[i];\n const ci = live[(i + 1) % live.length];\n const a = vertices[ai];\n const b = vertices[bi];\n const c = vertices[ci];\n if (area2(a, b, c) <= EPS) continue; // reflex or degenerate: not an ear\n\n let blocked = false;\n for (const vi of live) {\n if (vi === ai || vi === bi || vi === ci) continue;\n const v = vertices[vi];\n // Bridging a hole duplicates the two vertices it joins, so a candidate can sit\n // exactly on a corner of the ear. Counting that as \"inside\" blocks every ear in\n // the ring and the triangulation comes back empty.\n if (samePoint(v, a) || samePoint(v, b) || samePoint(v, c)) continue;\n if (inTriangle(v, a, b, c)) {\n blocked = true;\n break;\n }\n }\n if (blocked) continue;\n\n indices.push(ai, bi, ci);\n live.splice(i, 1);\n clipped = true;\n break;\n }\n // No ear found: the ring is degenerate in a way this cannot reduce further. Stopping\n // beats spinning, and the caller gets whatever was triangulated so far.\n if (!clipped) break;\n }\n if (live.length === 3) indices.push(live[0], live[1], live[2]);\n\n return { vertices, indices };\n}\n"],"mappings":"sEAeA,IAAM,EAAM,KAEZ,SAAS,EAAM,EAAc,EAAc,EAAsB,CAC/D,OAAQ,EAAE,EAAI,EAAE,IAAM,EAAE,EAAI,EAAE,IAAM,EAAE,EAAI,EAAE,IAAM,EAAE,EAAI,EAAE,EAC5D,CAEA,SAAS,EAAU,EAAc,EAAuB,CACtD,OAAO,KAAK,IAAI,EAAE,EAAI,EAAE,CAAC,EAAI,GAAO,KAAK,IAAI,EAAE,EAAI,EAAE,CAAC,EAAI,CAC5D,CAGA,SAAS,EAAW,EAAc,EAAc,EAAc,EAAuB,CACnF,IAAM,EAAK,EAAM,EAAG,EAAG,CAAC,EAClB,EAAK,EAAM,EAAG,EAAG,CAAC,EAClB,EAAK,EAAM,EAAG,EAAG,CAAC,EAGxB,MAAO,GAFK,EAAK,OAAQ,EAAK,OAAQ,EAAK,SAC/B,EAAK,GAAO,EAAK,GAAO,EAAK,GAE3C,CASA,SAAS,EAAY,EAAoB,EAAmC,CAC1E,IAAI,EAAO,EAAM,MAAM,EAGjB,EAAQ,EACX,OAAQ,GAAM,EAAE,QAAU,CAAC,CAAC,CAC5B,IAAK,IAAO,CAAE,KAAM,EAAG,MAAO,EAAE,QAAQ,EAAM,EAAG,IAAO,EAAE,EAAI,EAAE,EAAK,CAAC,EAAI,EAAI,EAAO,CAAC,CAAE,EAAE,CAAC,CAC3F,MAAM,EAAG,IAAM,EAAE,KAAK,EAAE,MAAM,CAAC,EA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,EAAI,EAAI,CAAE,EACvB,EAAK,OAAO,EAAG,CAAC,EAChB,EAAU,GACV,KADU,CAEZ,CAGA,GAAI,CAAC,EAAS,KAChB,CAGA,OAFI,EAAK,SAAW,GAAG,EAAQ,KAAK,EAAK,GAAI,EAAK,GAAI,EAAK,EAAE,EAEtD,CAAE,WAAU,SAAQ,CAC7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var e=function(e){return e.Metric=`metric`,e.Imperial=`imperial`,e}({}),t=function(e){return e.Exterior=`exterior`,e.Interior=`interior`,e.Partition=`partition`,e.Virtual=`virtual`,e}({}),n=function(e){return e.Door=`door`,e.Window=`window`,e.Archway=`archway`,e.Gap=`gap`,e}({}),r=function(e){return e.None=`none`,e.StartLeft=`startLeft`,e.StartRight=`startRight`,e.EndLeft=`endLeft`,e.EndRight=`endRight`,e.Double=`double`,e.Sliding=`sliding`,e}({}),i=function(e){return e.ZeroLengthWall=`zeroLengthWall`,e.SelfLoopWall=`selfLoopWall`,e.DuplicateWall=`duplicateWall`,e.CoincidentNodes=`coincidentNodes`,e.UnsplitCrossing=`unsplitCrossing`,e.UnsplitNodeOnWall=`unsplitNodeOnWall`,e.OverlappingWalls=`overlappingWalls`,e.OrphanNode=`orphanNode`,e.DanglingOpening=`danglingOpening`,e.UnmatchedRoom=`unmatchedRoom`,e.OpeningDropped=`openingDropped`,e}({});export{r as DoorSwing,n as OpeningKind,i as PlanIssueKind,e as PlanUnitSystem,t as WallType};
|
|
2
2
|
//# sourceMappingURL=floorPlan.types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.types.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.types.ts"],"sourcesContent":["/**\n * Floor plan model: a planar wall graph whose rooms are derived, not stored.\n *\n * Nodes and walls are first-class and shared, so the wall between two rooms is one\n * wall. An opening therefore cuts it exactly once, which is what the previous\n * room-polygon model could not express.\n *\n * GEOMETRY INVARIANT: every coordinate, length, thickness, offset and height in this\n * module is in MILLIMETRES. There is deliberately no per-plan scale factor: one would\n * have to be threaded through every geometry function, and a single missed call site\n * is a silent 1000x error that no type can catch. `unitSystem` below drives display\n * formatting only and is never read by geometry.\n */\n\n/** A point in plan space, in millimetres. y increases downwards, as in SVG. */\nexport interface PlanPoint {\n x: number;\n y: number;\n}\n\nexport enum PlanUnitSystem {\n /** Display as m / cm / mm. */\n Metric = 'metric',\n /** Display as feet and inches. Storage stays millimetres. */\n Imperial = 'imperial',\n}\n\nexport enum WallType {\n /** Load-bearing envelope wall. */\n Exterior = 'exterior',\n /** Load-bearing interior wall. */\n Interior = 'interior',\n /** Non-load-bearing partition. */\n Partition = 'partition',\n /**\n * A room boundary with no physical wall, for dividing open-plan space. It still\n * closes a face, so it produces two rooms, but renders as a thin dashed line and\n * extrudes to nothing in 3D.\n */\n Virtual = 'virtual',\n}\n\nexport enum OpeningKind {\n /** A real door leaf, with a swing and a threshold. */\n Door = 'door',\n /** Glazed opening with a sill above floor level. */\n Window = 'window',\n /** Structural opening with a head but no leaf. */\n Archway = 'archway',\n /**\n * A plain hole in the wall with no jamb detailing. Distinct from \"no wall at all\":\n * a Gap is a marked span of a wall that exists, which is what lets a gap-style\n * rendering stay unambiguous.\n */\n Gap = 'gap',\n}\n\nexport enum DoorSwing {\n None = 'none',\n /** Hinged at the opening's start, opening towards the wall's left normal. */\n StartLeft = 'startLeft',\n StartRight = 'startRight',\n EndLeft = 'endLeft',\n EndRight = 'endRight',\n /** Two leaves, hinged at both ends. */\n Double = 'double',\n Sliding = 'sliding',\n}\n\n/** A graph vertex. Structurally assignable to `PlanPoint`. */\nexport interface PlanNode {\n id: string;\n x: number;\n y: number;\n}\n\n/**\n * An undirected edge between two nodes. `a` and `b` define the wall's own direction,\n * which is what opening offsets and door swings are measured against.\n *\n * The wall is centred on the segment a..b, extending `thickness / 2` to each side.\n * There is no eccentric offset in this version.\n */\nexport interface PlanWall {\n id: string;\n a: string;\n b: string;\n /** Millimetres. Must be greater than 0. */\n thickness: number;\n /** Millimetres above this wall's base. Omit to inherit `PlanFloor.height`. */\n height?: number;\n /** Millimetres above the floor's finished level. Defaults to 0. */\n baseHeight?: number;\n type: WallType;\n}\n\n/**\n * An opening cut into exactly one wall. Because a shared wall is one wall, an opening\n * between two rooms exists exactly once and needs no de-duplication anywhere.\n */\nexport interface PlanOpening {\n id: string;\n wallId: string;\n kind: OpeningKind;\n /**\n * Distance in millimetres from the wall's node `a` to the opening's CENTRE, measured\n * along the centreline.\n *\n * Deliberately absolute rather than a 0..1 parameter: with a parameter, stretching a\n * wall by dragging one of its nodes would rescale every door on it. Absolute offsets\n * are clamped instead when a wall shortens.\n */\n offset: number;\n /** Millimetres, along the wall. */\n width: number;\n /**\n * Height of the opening's BOTTOM above the floor, in millimetres: 0 for a door, around\n * 900 for a window. Nothing in the 2D plan reads it, since a plan is a horizontal cut\n * and every opening looks the same from above. It is here so the same plan can drive a\n * 3D view later without the heights having to be invented or asked for again.\n */\n sill: number;\n /** Height of the opening's TOP above the floor, in millimetres. Typically 2100. */\n head: number;\n /** Only meaningful for `OpeningKind.Door`. */\n swing?: DoorSwing;\n}\n\n/**\n * Room METADATA. This is not a geometric object: the polygon comes from face\n * extraction. The trailing `wallIds` / `area` fields are a match cache maintained by\n * `derivePlan`, and are the reason a room's name survives edits.\n */\nexport interface PlanRoom {\n id: string;\n name: string;\n /** Any CSS colour. Omit to use the theme default. */\n colour?: string;\n /** Free-form usage tag (\"kitchen\", \"bath\"), for later fixture and 3D defaults. */\n usage?: string;\n /**\n * A point that lay inside the room's polygon when it was last written. Used as the\n * label position and as the secondary identity signal during matching.\n */\n anchor: PlanPoint;\n /** Set once the user drags the label; `derivePlan` then stops moving it. */\n anchorPinned: boolean;\n /** Monotonic creation counter, used as a deterministic tie-break when matching. */\n seq: number;\n /** Match cache: the wall ids on this room's boundary at the last successful match. */\n wallIds: string[];\n /** Match cache: area in mm² at the last successful match. */\n area: number;\n}\n\nexport interface PlanFloor {\n id: string;\n label: string;\n /** Finished floor level of this storey, millimetres above datum. */\n elevation: number;\n /** Default storey height in millimetres, used when a wall omits its own `height`. */\n height: number;\n /**\n * Keyed by id for O(1) lookup. Ids must not be numeric strings ('n_12', never '12'),\n * so that JavaScript preserves insertion order and iteration stays reproducible.\n */\n nodes: Record<string, PlanNode>;\n walls: Record<string, PlanWall>;\n openings: Record<string, PlanOpening>;\n rooms: Record<string, PlanRoom>;\n}\n\nexport interface FloorPlan {\n id: string;\n name?: string;\n /** Schema version, for future migrations. */\n version: 1;\n /** Display formatting only. Never read by geometry. */\n unitSystem: PlanUnitSystem;\n floors: PlanFloor[];\n /**\n * Bumped by every mutating operation. Use it as the memo key for `derivePlan`, so a\n * gesture that does not actually change the graph does not trigger a re-derive.\n */\n revision: number;\n}\n\n/**\n * A raw face from the planar walk, before room metadata is attached.\n *\n * WINDING: `outer` is positively wound under the shoelace formula, which in SVG's\n * y-down space means it reads as visually CLOCKWISE. Anything downstream that assumes\n * counter-clockwise (extruded slab normals, most triangulators) must flip it.\n */\nexport interface PlanFace {\n /**\n * Derived from the boundary itself, so it is stable across derives for as long as\n * the geometry is unchanged. Safe to use as a React key.\n */\n id: string;\n /** Outer ring, closed implicitly: the first vertex is not repeated at the end. */\n outer: PlanPoint[];\n /** Inner rings from nested components, wound opposite to `outer`. */\n holes: PlanPoint[][];\n /** mm², always positive, with holes already subtracted. */\n area: number;\n /** mm, outer ring only. */\n perimeter: number;\n /**\n * Wall ids on the boundary, in traversal order. A dangling wall inside this face\n * appears TWICE, once per direction, so consumers needing unique ids must dedupe.\n */\n wallIds: string[];\n nodeIds: string[];\n}\n\n/** A face with its matched metadata. This is what the components render. */\nexport interface DerivedRoom extends PlanFace {\n /** `null` when no `PlanRoom` matched this face during this derive. */\n roomId: string | null;\n meta: PlanRoom | null;\n /** Guaranteed inside `outer` and outside every hole. The label position. */\n anchor: PlanPoint;\n}\n\nexport enum PlanIssueKind {\n ZeroLengthWall = 'zeroLengthWall',\n SelfLoopWall = 'selfLoopWall',\n DuplicateWall = 'duplicateWall',\n CoincidentNodes = 'coincidentNodes',\n /** Two walls cross with no node at the intersection. Corrupts face extraction. */\n UnsplitCrossing = 'unsplitCrossing',\n /** A node sits on a wall's interior but that wall was never split there. */\n UnsplitNodeOnWall = 'unsplitNodeOnWall',\n /** Two walls leave a node in the same direction, tying the angular sort. */\n OverlappingWalls = 'overlappingWalls',\n OrphanNode = 'orphanNode',\n DanglingOpening = 'danglingOpening',\n /** A `PlanRoom` matched no face this derive. It is kept, never deleted. */\n UnmatchedRoom = 'unmatchedRoom',\n /** An opening was moved or dropped because its wall no longer has room for it. */\n OpeningDropped = 'openingDropped',\n}\n\nexport interface PlanIssue {\n kind: PlanIssueKind;\n message: string;\n nodeIds?: string[];\n wallIds?: string[];\n roomIds?: string[];\n openingIds?: string[];\n}\n\nexport interface PlanDerivation {\n /** The floor with room match caches and anchors refreshed. Pure: a new object. */\n floor: PlanFloor;\n rooms: DerivedRoom[];\n issues: PlanIssue[];\n}\n\n/** The uniform result of every graph mutation. All of them are pure. */\nexport interface PlanEdit<T = void> {\n floor: PlanFloor;\n result: T;\n issues: PlanIssue[];\n}\n\n/**\n * The viewport: which world point sits at the canvas's top-left corner, and how many\n * screen pixels one world millimetre occupies.\n *\n * A 6m plan filling a 600px canvas is `zoom: 0.1`. Note this is a transform on a group,\n * not an SVG `viewBox`: handles, labels and hit tolerances are then sized in screen\n * pixels and stay constant as you zoom, instead of scaling with the drawing.\n */\nexport interface PlanView {\n x: number;\n y: number;\n zoom: number;\n}\n\n/** What is currently selected or hovered. */\nexport type PlanSelection =\n | { type: 'room'; id: string }\n | { type: 'wall'; id: string }\n | { type: 'opening'; id: string }\n | { type: 'node'; id: string };\n"],"mappings":"aAoBA,IAAY,EAAL,SAAA,EAAA,OAEL,GAAA,OAAA,SAEA,EAAA,SAAA,YACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,SAAA,WAEA,EAAA,SAAA,WAEA,EAAA,UAAA,YAMA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,KAAA,OAEA,EAAA,OAAA,SAEA,EAAA,QAAA,UAMA,EAAA,IAAA,OACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OAEA,EAAA,UAAA,YACA,EAAA,WAAA,aACA,EAAA,QAAA,UACA,EAAA,SAAA,WAEA,EAAA,OAAA,SACA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EA8JY,EAAL,SAAA,EAAA,OACL,GAAA,eAAA,iBACA,EAAA,aAAA,eACA,EAAA,cAAA,gBACA,EAAA,gBAAA,kBAEA,EAAA,gBAAA,kBAEA,EAAA,kBAAA,oBAEA,EAAA,iBAAA,mBACA,EAAA,WAAA,aACA,EAAA,gBAAA,kBAEA,EAAA,cAAA,gBAEA,EAAA,eAAA,kBACF,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"floorPlan.types.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.types.ts"],"sourcesContent":["/**\n * Floor plan model: a planar wall graph whose rooms are derived, not stored.\n *\n * Nodes and walls are first-class and shared, so the wall between two rooms is one\n * wall. An opening therefore cuts it exactly once, which is what the previous\n * room-polygon model could not express.\n *\n * GEOMETRY INVARIANT: every coordinate, length, thickness, offset and height in this\n * module is in MILLIMETRES. There is deliberately no per-plan scale factor: one would\n * have to be threaded through every geometry function, and a single missed call site\n * is a silent 1000x error that no type can catch. `unitSystem` below drives display\n * formatting only and is never read by geometry.\n */\n\n/** A point in plan space, in millimetres. y increases downwards, as in SVG. */\nexport interface PlanPoint {\n x: number;\n y: number;\n}\n\nexport enum PlanUnitSystem {\n /** Display as m / cm / mm. */\n Metric = 'metric',\n /** Display as feet and inches. Storage stays millimetres. */\n Imperial = 'imperial',\n}\n\nexport enum WallType {\n /** Load-bearing envelope wall. */\n Exterior = 'exterior',\n /** Load-bearing interior wall. */\n Interior = 'interior',\n /** Non-load-bearing partition. */\n Partition = 'partition',\n /**\n * A room boundary with no physical wall, for dividing open-plan space. It still\n * closes a face, so it produces two rooms, but renders as a thin dashed line and\n * extrudes to nothing in 3D.\n */\n Virtual = 'virtual',\n}\n\nexport enum OpeningKind {\n /** A real door leaf, with a swing and a threshold. */\n Door = 'door',\n /** Glazed opening with a sill above floor level. */\n Window = 'window',\n /** Structural opening with a head but no leaf. */\n Archway = 'archway',\n /**\n * A plain hole in the wall with no jamb detailing. Distinct from \"no wall at all\":\n * a Gap is a marked span of a wall that exists, which is what lets a gap-style\n * rendering stay unambiguous.\n */\n Gap = 'gap',\n}\n\nexport enum DoorSwing {\n None = 'none',\n /** Hinged at the opening's start, opening towards the wall's left normal. */\n StartLeft = 'startLeft',\n StartRight = 'startRight',\n EndLeft = 'endLeft',\n EndRight = 'endRight',\n /** Two leaves, hinged at both ends. */\n Double = 'double',\n Sliding = 'sliding',\n}\n\n/** A graph vertex. Structurally assignable to `PlanPoint`. */\nexport interface PlanNode {\n id: string;\n x: number;\n y: number;\n}\n\n/**\n * An undirected edge between two nodes. `a` and `b` define the wall's own direction,\n * which is what opening offsets and door swings are measured against.\n *\n * The wall is centred on the segment a..b, extending `thickness / 2` to each side.\n * There is no eccentric offset in this version.\n */\nexport interface PlanWall {\n id: string;\n a: string;\n b: string;\n /** Millimetres. Must be greater than 0. */\n thickness: number;\n /** Millimetres above this wall's base. Omit to inherit `PlanFloor.height`. */\n height?: number;\n /** Millimetres above the floor's finished level. Defaults to 0. */\n baseHeight?: number;\n type: WallType;\n}\n\n/**\n * An opening cut into exactly one wall. Because a shared wall is one wall, an opening\n * between two rooms exists exactly once and needs no de-duplication anywhere.\n */\nexport interface PlanOpening {\n id: string;\n wallId: string;\n kind: OpeningKind;\n /**\n * Distance in millimetres from the wall's node `a` to the opening's CENTRE, measured\n * along the centreline.\n *\n * Deliberately absolute rather than a 0..1 parameter: with a parameter, stretching a\n * wall by dragging one of its nodes would rescale every door on it. Absolute offsets\n * are clamped instead when a wall shortens.\n */\n offset: number;\n /** Millimetres, along the wall. */\n width: number;\n /**\n * Height of the opening's BOTTOM above the floor, in millimetres: 0 for a door, around\n * 900 for a window. Nothing in the 2D plan reads it, since a plan is a horizontal cut\n * and every opening looks the same from above. It is here so the same plan can drive a\n * 3D view later without the heights having to be invented or asked for again.\n */\n sill: number;\n /** Height of the opening's TOP above the floor, in millimetres. Typically 2100. */\n head: number;\n /** Only meaningful for `OpeningKind.Door`. */\n swing?: DoorSwing;\n}\n\n/**\n * Room METADATA. This is not a geometric object: the polygon comes from face\n * extraction. The trailing `wallIds` / `area` fields are a match cache maintained by\n * `derivePlan`, and are the reason a room's name survives edits.\n */\nexport interface PlanRoom {\n id: string;\n name: string;\n /** Any CSS colour. Omit to use the theme default. */\n colour?: string;\n /** Free-form usage tag (\"kitchen\", \"bath\"), for later fixture and 3D defaults. */\n usage?: string;\n /**\n * A point that lay inside the room's polygon when it was last written. Used as the\n * label position and as the secondary identity signal during matching.\n */\n anchor: PlanPoint;\n /** Set once the user drags the label; `derivePlan` then stops moving it. */\n anchorPinned: boolean;\n /** Monotonic creation counter, used as a deterministic tie-break when matching. */\n seq: number;\n /** Match cache: the wall ids on this room's boundary at the last successful match. */\n wallIds: string[];\n /** Match cache: area in mm² at the last successful match. */\n area: number;\n}\n\nexport interface PlanFloor {\n id: string;\n label: string;\n /** Finished floor level of this storey, millimetres above datum. */\n elevation: number;\n /** Default storey height in millimetres, used when a wall omits its own `height`. */\n height: number;\n /**\n * Keyed by id for O(1) lookup. Ids must not be numeric strings ('n_12', never '12'),\n * so that JavaScript preserves insertion order and iteration stays reproducible.\n */\n nodes: Record<string, PlanNode>;\n walls: Record<string, PlanWall>;\n openings: Record<string, PlanOpening>;\n rooms: Record<string, PlanRoom>;\n}\n\nexport interface FloorPlan {\n id: string;\n name?: string;\n /** Schema version, for future migrations. */\n version: 1;\n /** Display formatting only. Never read by geometry. */\n unitSystem: PlanUnitSystem;\n floors: PlanFloor[];\n /**\n * Bumped by every mutating operation. Use it as the memo key for `derivePlan`, so a\n * gesture that does not actually change the graph does not trigger a re-derive.\n */\n revision: number;\n}\n\n/**\n * A raw face from the planar walk, before room metadata is attached.\n *\n * WINDING: `outer` is positively wound under the shoelace formula, which in SVG's\n * y-down space means it reads as visually CLOCKWISE. Anything downstream that assumes\n * counter-clockwise (extruded slab normals, most triangulators) must flip it.\n */\nexport interface PlanFace {\n /**\n * Derived from the boundary itself, so it is stable across derives for as long as\n * the geometry is unchanged. Safe to use as a React key.\n */\n id: string;\n /** Outer ring, closed implicitly: the first vertex is not repeated at the end. */\n outer: PlanPoint[];\n /** Inner rings from nested components, wound opposite to `outer`. */\n holes: PlanPoint[][];\n /** mm², always positive, with holes already subtracted. */\n area: number;\n /** mm, outer ring only. */\n perimeter: number;\n /**\n * Wall ids on the boundary, in traversal order. A dangling wall inside this face\n * appears TWICE, once per direction, so consumers needing unique ids must dedupe.\n */\n wallIds: string[];\n nodeIds: string[];\n}\n\n/** A face with its matched metadata. This is what the components render. */\nexport interface DerivedRoom extends PlanFace {\n /** `null` when no `PlanRoom` matched this face during this derive. */\n roomId: string | null;\n meta: PlanRoom | null;\n /** Guaranteed inside `outer` and outside every hole. The label position. */\n anchor: PlanPoint;\n}\n\nexport enum PlanIssueKind {\n ZeroLengthWall = 'zeroLengthWall',\n SelfLoopWall = 'selfLoopWall',\n DuplicateWall = 'duplicateWall',\n CoincidentNodes = 'coincidentNodes',\n /** Two walls cross with no node at the intersection. Corrupts face extraction. */\n UnsplitCrossing = 'unsplitCrossing',\n /** A node sits on a wall's interior but that wall was never split there. */\n UnsplitNodeOnWall = 'unsplitNodeOnWall',\n /** Two walls leave a node in the same direction, tying the angular sort. */\n OverlappingWalls = 'overlappingWalls',\n OrphanNode = 'orphanNode',\n DanglingOpening = 'danglingOpening',\n /** A `PlanRoom` matched no face this derive. It is kept, never deleted. */\n UnmatchedRoom = 'unmatchedRoom',\n /** An opening was moved or dropped because its wall no longer has room for it. */\n OpeningDropped = 'openingDropped',\n}\n\nexport interface PlanIssue {\n kind: PlanIssueKind;\n message: string;\n nodeIds?: string[];\n wallIds?: string[];\n roomIds?: string[];\n openingIds?: string[];\n}\n\nexport interface PlanDerivation {\n /** The floor with room match caches and anchors refreshed. Pure: a new object. */\n floor: PlanFloor;\n rooms: DerivedRoom[];\n issues: PlanIssue[];\n}\n\n/** The uniform result of every graph mutation. All of them are pure. */\nexport interface PlanEdit<T = void> {\n floor: PlanFloor;\n result: T;\n issues: PlanIssue[];\n}\n\n/**\n * The viewport: which world point sits at the canvas's top-left corner, and how many\n * screen pixels one world millimetre occupies.\n *\n * A 6m plan filling a 600px canvas is `zoom: 0.1`. Note this is a transform on a group,\n * not an SVG `viewBox`: handles, labels and hit tolerances are then sized in screen\n * pixels and stay constant as you zoom, instead of scaling with the drawing.\n */\nexport interface PlanView {\n x: number;\n y: number;\n zoom: number;\n}\n\n/** What is currently selected or hovered. */\nexport type PlanSelection =\n | { type: 'room'; id: string }\n | { type: 'wall'; id: string }\n | { type: 'opening'; id: string }\n | { type: 'node'; id: string };\n"],"mappings":"AAoBA,IAAY,EAAL,SAAA,EAAA,OAEL,GAAA,OAAA,SAEA,EAAA,SAAA,YACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,SAAA,WAEA,EAAA,SAAA,WAEA,EAAA,UAAA,YAMA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,KAAA,OAEA,EAAA,OAAA,SAEA,EAAA,QAAA,UAMA,EAAA,IAAA,OACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OAEA,EAAA,UAAA,YACA,EAAA,WAAA,aACA,EAAA,QAAA,UACA,EAAA,SAAA,WAEA,EAAA,OAAA,SACA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EA8JY,EAAL,SAAA,EAAA,OACL,GAAA,eAAA,iBACA,EAAA,aAAA,eACA,EAAA,cAAA,gBACA,EAAA,gBAAA,kBAEA,EAAA,gBAAA,kBAEA,EAAA,kBAAA,oBAEA,EAAA,iBAAA,mBACA,EAAA,WAAA,aACA,EAAA,gBAAA,kBAEA,EAAA,cAAA,gBAEA,EAAA,eAAA,kBACF,EAAA,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{OpeningKind as e}from"../floorPlan/floorPlan.types.mjs";import{buildWallPaths as t,openingGeometry as n}from"../floorPlan/floorPlan.path.mjs";import r from"./planCanvas.module.mjs";import{useMemo as i}from"react";import a from"classnames";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";var l=1,u=[];function d(e){let t=e/1e6;return`${t.toFixed(+(t<10))} m²`}function f(e){return e.length===0?``:`${e.map((e,t)=>`${t===0?`M`:`L`} ${e.x},${e.y}`).join(` `)} Z`}function p(e){return[f(e.outer),...e.holes.map(f)].filter(Boolean).join(` `)}function m(f){let{ref:m,floor:h,underlay:g,rooms:_,view:v,selection:y=u,hovered:b=null,interactiveRooms:x=!1,interactiveOpenings:S=!1,showGrid:C=!1,gridSize:w=100,showRoomLabels:T=!0,showOpeningSymbols:E=!0,getRoomColor:D,renderRoomLabel:O,getRoomLabel:k,formatArea:A=d,onRoomActivate:j,onOpeningActivate:M,onBackgroundActivate:N,onHoverChange:P,overlay:F,worldOverlay:I,size:L,className:R,style:z,classNames:B,styles:V,"aria-label":H}=f,U=v.zoom>0?1/v.zoom:1,W=l*U,G=i(()=>t(h),[h]),K=i(()=>g?Object.values(g.walls).flatMap(e=>{let t=g.nodes[e.a],n=g.nodes[e.b];return t&&n?[{id:e.id,x1:t.x,y1:t.y,x2:n.x,y2:n.y}]:[]}):[],[g]),q=e=>({x:(e.x-v.x)*v.zoom,y:(e.y-v.y)*v.zoom}),J=i(()=>{if(!C||w<=0)return null;let e=L.width*U,t=L.height*U,n=w*Math.max(1,10**Math.ceil(Math.log10(e/w/60))),r=Math.floor(v.x/n)*n,i=Math.floor(v.y/n)*n,a=[],o=[];for(let t=r;t<=v.x+e;t+=n)a.push(t);for(let e=i;e<=v.y+t;e+=n)o.push(e);return{verticals:a,horizontals:o,step:n,worldW:e,worldH:t}},[C,w,L.width,L.height,U,v.x,v.y]),Y=(e,t)=>y.some(n=>n.type===e&&n.id===t),X=(e,t)=>b?.type===e&&b.id===t,Z=i(()=>{let e=new Set(y.filter(e=>e.type===`room`).map(e=>e.id)),t=new Set;for(let n of _)if(n.roomId&&e.has(n.roomId))for(let e of n.wallIds)t.add(e);return t},[_,y]),Q=i(()=>Z.size>0?t(h,{wallIds:Z}):{groups:[],caps:[]},[h,Z]);function $(t){let i=n(h,t);if(!i)return null;let o=h.walls[t.wallId],l=o?o.thickness/2:50,{p1:u,p2:d,normal:f,dir:p,centre:m}=i,g=Y(`opening`,t.id),_=X(`opening`,t.id),v=Math.hypot(d.x-u.x,d.y-u.y),y=[];if(E&&t.kind===e.Door){let e=t.swing!==`endLeft`&&t.swing!==`endRight`,n=e?u:d,i=e?1:-1,a={x:n.x+f.x*v,y:n.y+f.y*v},o={x:n.x+p.x*v*i,y:n.y+p.y*v*i};y.push(s(`path`,{className:r.planCanvasDoorLeaf,d:`M ${n.x},${n.y} L ${a.x},${a.y}`,strokeWidth:W},`leaf`),s(`path`,{className:r.planCanvasDoorSwing,d:`M ${a.x},${a.y} A ${v},${v} 0 0,${+!e} ${o.x},${o.y}`,strokeWidth:W},`swing`))}E&&t.kind===e.Window&&y.push(s(`path`,{className:r.planCanvasWindowPane,d:`M ${u.x},${u.y} L ${d.x},${d.y}`,strokeWidth:W*2},`pane`));let b=`M ${u.x+f.x*l},${u.y+f.y*l} L ${d.x+f.x*l},${d.y+f.y*l} L ${d.x-f.x*l},${d.y-f.y*l} L ${u.x-f.x*l},${u.y-f.y*l} Z`;return c(`g`,{className:a(g&&r.planCanvasOpeningSelected,_&&r.planCanvasOpeningHovered,B?.opening),style:V?.opening,"data-opening-kind":t.kind,children:[y,s(`path`,{className:a(r.planCanvasOpeningHit,S&&r.planCanvasOpeningHitInteractive),d:b,onClick:S&&M?e=>{e.stopPropagation(),M(t.id)}:void 0,onPointerEnter:P?()=>P({type:`opening`,id:t.id}):void 0,children:S&&s(`title`,{children:t.kind})}),(g||_)&&s(`path`,{className:r.planCanvasOpeningOutline,d:b,vectorEffect:`non-scaling-stroke`}),s(`path`,{className:a(r.planCanvasJamb,Z.has(t.wallId)&&r.planCanvasJambHighlighted),d:`M ${u.x-f.x*l},${u.y-f.y*l} L ${u.x+f.x*l},${u.y+f.y*l} M ${d.x-f.x*l},${d.y-f.y*l} L ${d.x+f.x*l},${d.y+f.y*l}`,strokeWidth:W}),m&&null]},t.id)}return c(`svg`,{ref:m,className:a(r.planCanvas,R,B?.canvas),style:{...z,...V?.canvas},viewBox:`0 0 ${Math.max(1,L.width)} ${Math.max(1,L.height)}`,width:L.width,height:L.height,role:`img`,"aria-label":H,onClick:N?()=>N():void 0,onPointerLeave:P?()=>P(null):void 0,children:[c(`g`,{transform:`translate(${-v.x*v.zoom} ${-v.y*v.zoom}) scale(${v.zoom})`,children:[J&&c(`g`,{className:a(r.planCanvasGrid,B?.grid),style:V?.grid,"aria-hidden":`true`,children:[J.verticals.map(e=>s(`line`,{x1:e,y1:v.y,x2:e,y2:v.y+J.worldH,strokeWidth:U},`v${e}`)),J.horizontals.map(e=>s(`line`,{x1:v.x,y1:e,x2:v.x+J.worldW,y2:e,strokeWidth:U},`h${e}`))]}),K.length>0&&s(`g`,{className:a(r.planCanvasUnderlay,B?.underlay),style:V?.underlay,"aria-hidden":`true`,children:K.map(e=>s(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,strokeWidth:1.5},e.id))}),s(`g`,{className:a(r.planCanvasRooms,B?.rooms),style:V?.rooms,children:_.map(e=>{let t=e.roomId?Y(`room`,e.roomId):!1,n=e.roomId?X(`room`,e.roomId):!1,i=e.meta?D?.(e.meta,e.area):void 0,o=k?.(e.meta,{area:e.area})
|
|
1
|
+
"use client";import{OpeningKind as e}from"../floorPlan/floorPlan.types.mjs";import{buildWallPaths as t,openingGeometry as n}from"../floorPlan/floorPlan.path.mjs";import r from"./planCanvas.module.mjs";import{useMemo as i}from"react";import a from"classnames";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";var l=1,u=[];function d(e){let t=e/1e6;return`${t.toFixed(+(t<10))} m²`}function f(e){return e.length===0?``:`${e.map((e,t)=>`${t===0?`M`:`L`} ${e.x},${e.y}`).join(` `)} Z`}function p(e){return[f(e.outer),...e.holes.map(f)].filter(Boolean).join(` `)}function m(f){let{ref:m,floor:h,underlay:g,rooms:_,view:v,selection:y=u,hovered:b=null,interactiveRooms:x=!1,interactiveOpenings:S=!1,showGrid:C=!1,gridSize:w=100,showRoomLabels:T=!0,showOpeningSymbols:E=!0,getRoomColor:D,renderRoomLabel:O,getRoomLabel:k,formatArea:A=d,onRoomActivate:j,onOpeningActivate:M,onBackgroundActivate:N,onHoverChange:P,overlay:F,worldOverlay:I,size:L,className:R,style:z,classNames:B,styles:V,"aria-label":H}=f,U=v.zoom>0?1/v.zoom:1,W=l*U,G=i(()=>t(h),[h]),K=i(()=>g?Object.values(g.walls).flatMap(e=>{let t=g.nodes[e.a],n=g.nodes[e.b];return t&&n?[{id:e.id,x1:t.x,y1:t.y,x2:n.x,y2:n.y}]:[]}):[],[g]),q=e=>({x:(e.x-v.x)*v.zoom,y:(e.y-v.y)*v.zoom}),J=i(()=>{if(!C||w<=0)return null;let e=L.width*U,t=L.height*U,n=w*Math.max(1,10**Math.ceil(Math.log10(e/w/60))),r=Math.floor(v.x/n)*n,i=Math.floor(v.y/n)*n,a=[],o=[];for(let t=r;t<=v.x+e;t+=n)a.push(t);for(let e=i;e<=v.y+t;e+=n)o.push(e);return{verticals:a,horizontals:o,step:n,worldW:e,worldH:t}},[C,w,L.width,L.height,U,v.x,v.y]),Y=(e,t)=>y.some(n=>n.type===e&&n.id===t),X=(e,t)=>b?.type===e&&b.id===t,Z=i(()=>{let e=new Set(y.filter(e=>e.type===`room`).map(e=>e.id)),t=new Set;for(let n of _)if(n.roomId&&e.has(n.roomId))for(let e of n.wallIds)t.add(e);return t},[_,y]),Q=i(()=>Z.size>0?t(h,{wallIds:Z}):{groups:[],caps:[]},[h,Z]);function $(t){let i=n(h,t);if(!i)return null;let o=h.walls[t.wallId],l=o?o.thickness/2:50,{p1:u,p2:d,normal:f,dir:p,centre:m}=i,g=Y(`opening`,t.id),_=X(`opening`,t.id),v=Math.hypot(d.x-u.x,d.y-u.y),y=[];if(E&&t.kind===e.Door){let e=t.swing!==`endLeft`&&t.swing!==`endRight`,n=e?u:d,i=e?1:-1,a={x:n.x+f.x*v,y:n.y+f.y*v},o={x:n.x+p.x*v*i,y:n.y+p.y*v*i};y.push(s(`path`,{className:r.planCanvasDoorLeaf,d:`M ${n.x},${n.y} L ${a.x},${a.y}`,strokeWidth:W},`leaf`),s(`path`,{className:r.planCanvasDoorSwing,d:`M ${a.x},${a.y} A ${v},${v} 0 0,${+!e} ${o.x},${o.y}`,strokeWidth:W},`swing`))}E&&t.kind===e.Window&&y.push(s(`path`,{className:r.planCanvasWindowPane,d:`M ${u.x},${u.y} L ${d.x},${d.y}`,strokeWidth:W*2},`pane`));let b=`M ${u.x+f.x*l},${u.y+f.y*l} L ${d.x+f.x*l},${d.y+f.y*l} L ${d.x-f.x*l},${d.y-f.y*l} L ${u.x-f.x*l},${u.y-f.y*l} Z`;return c(`g`,{className:a(g&&r.planCanvasOpeningSelected,_&&r.planCanvasOpeningHovered,B?.opening),style:V?.opening,"data-opening-kind":t.kind,children:[y,s(`path`,{className:a(r.planCanvasOpeningHit,S&&r.planCanvasOpeningHitInteractive),d:b,onClick:S&&M?e=>{e.stopPropagation(),M(t.id)}:void 0,onPointerEnter:P?()=>P({type:`opening`,id:t.id}):void 0,children:S&&s(`title`,{children:t.kind})}),(g||_)&&s(`path`,{className:r.planCanvasOpeningOutline,d:b,vectorEffect:`non-scaling-stroke`}),s(`path`,{className:a(r.planCanvasJamb,Z.has(t.wallId)&&r.planCanvasJambHighlighted),d:`M ${u.x-f.x*l},${u.y-f.y*l} L ${u.x+f.x*l},${u.y+f.y*l} M ${d.x-f.x*l},${d.y-f.y*l} L ${d.x+f.x*l},${d.y+f.y*l}`,strokeWidth:W}),m&&null]},t.id)}return c(`svg`,{ref:m,className:a(r.planCanvas,R,B?.canvas),style:{...z,...V?.canvas},viewBox:`0 0 ${Math.max(1,L.width)} ${Math.max(1,L.height)}`,width:L.width,height:L.height,role:`img`,"aria-label":H,onClick:N?()=>N():void 0,onPointerLeave:P?()=>P(null):void 0,children:[c(`g`,{transform:`translate(${-v.x*v.zoom} ${-v.y*v.zoom}) scale(${v.zoom})`,children:[J&&c(`g`,{className:a(r.planCanvasGrid,B?.grid),style:V?.grid,"aria-hidden":`true`,children:[J.verticals.map(e=>s(`line`,{x1:e,y1:v.y,x2:e,y2:v.y+J.worldH,strokeWidth:U},`v${e}`)),J.horizontals.map(e=>s(`line`,{x1:v.x,y1:e,x2:v.x+J.worldW,y2:e,strokeWidth:U},`h${e}`))]}),K.length>0&&s(`g`,{className:a(r.planCanvasUnderlay,B?.underlay),style:V?.underlay,"aria-hidden":`true`,children:K.map(e=>s(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,strokeWidth:1.5},e.id))}),s(`g`,{className:a(r.planCanvasRooms,B?.rooms),style:V?.rooms,children:_.map(e=>{let t=e.roomId?Y(`room`,e.roomId):!1,n=e.roomId?X(`room`,e.roomId):!1,i=e.meta?D?.(e.meta,e.area):void 0,o=k?.(e.meta,{area:e.area});return s(`path`,{className:a(r.planCanvasRoomFill,n&&r.planCanvasRoomFillHovered,x&&r.planCanvasRoomFillInteractive,B?.roomFill),"data-state":t?`selected`:n?`hovered`:void 0,style:{...V?.roomFill,...i?{fill:i}:null},d:p(e),fillRule:`evenodd`,tabIndex:x?0:void 0,role:x?`button`:void 0,"aria-pressed":x?t:void 0,onClick:x&&j&&e.roomId?t=>{t.stopPropagation(),j(e.roomId)}:void 0,onKeyDown:x&&j&&e.roomId?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),j(e.roomId))}:void 0,onPointerEnter:P&&e.roomId?()=>P({type:`room`,id:e.roomId}):void 0,children:x&&o&&s(`title`,{children:o})},e.id)})}),c(`g`,{className:a(r.planCanvasWalls,B?.walls),style:V?.walls,"aria-hidden":`true`,children:[s(`g`,{className:r.planCanvasWallOutline,children:G.groups.map(e=>s(`path`,{className:B?.wallBody,style:V?.wallBody,d:e.d,strokeWidth:e.thickness},`o${e.thickness}`))}),s(`g`,{className:r.planCanvasWallFill,children:G.groups.map(e=>{let t=e.thickness-2*W;return t<=0?null:s(`path`,{d:e.d,strokeWidth:t},`f${e.thickness}`)})}),c(`g`,{className:r.planCanvasRoomEdgeSelected,children:[Q.groups.map(e=>s(`path`,{className:r.planCanvasRoomEdgeOutline,d:e.d,strokeWidth:e.thickness},`o${e.thickness}`)),Q.groups.map(e=>{let t=e.thickness-2*W;return t<=0?null:s(`path`,{className:r.planCanvasRoomEdgeFill,d:e.d,strokeWidth:t},`f${e.thickness}`)})]}),s(`g`,{className:r.planCanvasWallCaps,children:G.caps.filter(e=>!Z.has(e.wallId)).map((e,t)=>s(`line`,{x1:e.a.x,y1:e.a.y,x2:e.b.x,y2:e.b.y,strokeWidth:W},`${e.wallId}-${e.reason}-${t}`))}),s(`g`,{className:r.planCanvasRoomEdgeCaps,children:Q.caps.map((e,t)=>s(`line`,{x1:e.a.x,y1:e.a.y,x2:e.b.x,y2:e.b.y,strokeWidth:W},`${e.wallId}-${e.reason}-${t}`))})]}),s(`g`,{className:a(r.planCanvasOpenings,B?.openings),style:V?.openings,children:Object.values(h.openings).map($)}),c(`g`,{className:r.planCanvasSelection,"aria-hidden":`true`,children:[y.filter(e=>e.type===`wall`).map(e=>{let t=h.walls[e.id];if(!t)return null;let n=h.nodes[t.a],i=h.nodes[t.b];return!n||!i?null:s(`line`,{x1:n.x,y1:n.y,x2:i.x,y2:i.y,strokeWidth:t.thickness,className:r.planCanvasWallSelected},e.id)}),b?.type===`wall`&&!Y(`wall`,b.id)&&(()=>{let e=h.walls[b.id];if(!e)return null;let t=h.nodes[e.a],n=h.nodes[e.b];return!t||!n?null:s(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,strokeWidth:e.thickness,className:r.planCanvasWallHovered})})()]}),I]}),c(`g`,{className:a(r.planCanvasScreen,B?.overlay),style:V?.overlay,children:[T&&_.map(e=>{let t=q(e.anchor);if(t.x<-200||t.y<-200||t.x>L.width+200||t.y>L.height+200)return null;let n=O?.(e.meta,{area:e.area,faceId:e.id});return n===null?null:s(`g`,{className:a(r.planCanvasRoomLabel,B?.roomLabel),style:V?.roomLabel,transform:`translate(${t.x} ${t.y})`,"aria-hidden":`true`,children:n===void 0?c(o,{children:[s(`text`,{className:r.planCanvasRoomName,textAnchor:`middle`,children:e.meta?.name??``}),s(`text`,{className:r.planCanvasRoomArea,textAnchor:`middle`,dy:`1.2em`,children:A(e.area)})]}):n},e.id)}),F]})]})}export{m as default};
|
|
2
2
|
//# sourceMappingURL=planCanvas.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planCanvas.mjs","names":[],"sources":["../../../../package/common/planCanvas/planCanvas.tsx"],"sourcesContent":["import { useMemo, type ReactElement } from 'react';\nimport cx from 'classnames';\n\nimport {\n OpeningKind,\n buildWallPaths,\n openingGeometry,\n type DerivedRoom,\n type PlanOpening,\n type PlanPoint,\n type PlanSelection,\n} from '../floorPlan';\nimport type { PlanCanvasProps } from './planCanvas.types';\nimport styles from './planCanvas.module.pcss';\n\n/**\n * The read-only renderer shared by RoomDrawer and RoomViewer.\n *\n * It owns the projection, the layer stack, and the accessible room shapes. It owns no\n * editing state: the drawer supplies its handles and previews through `overlay`. Having\n * one renderer is the point, so that a plan cannot look different in the editor than it\n * does in the viewer.\n *\n * The viewport is a TRANSFORM on a group, not an SVG `viewBox`. That is what lets the\n * screen-space layer draw labels and handles at a fixed pixel size while the drawing\n * itself scales.\n */\n\nconst DEFAULT_OUTLINE_PX = 1;\n\n/** Stable identity, so a default-valued `selection` prop does not re-run memos. */\nconst EMPTY_SELECTION: readonly PlanSelection[] = [];\n\nfunction formatAreaDefault(areaMm2: number): string {\n const m2 = areaMm2 / 1_000_000;\n return `${m2.toFixed(m2 < 10 ? 1 : 0)} m²`;\n}\n\nfunction ringToPath(ring: PlanPoint[]): string {\n if (ring.length === 0) return '';\n return `${ring.map((p, i) => `${i === 0 ? 'M' : 'L'} ${p.x},${p.y}`).join(' ')} Z`;\n}\n\n/** Outer ring plus holes as one path; `fill-rule: evenodd` punches the holes out. */\nfunction faceToPath(face: DerivedRoom): string {\n return [ringToPath(face.outer), ...face.holes.map(ringToPath)].filter(Boolean).join(' ');\n}\n\n/**\n * The ref lands on the `<svg>` itself, which is what a consumer wants for measuring or\n * screenshotting. Both the drawer and the viewer expose it as `getSvgElement()`.\n */\nfunction PlanCanvas(props: PlanCanvasProps) {\n const {\n ref,\n floor,\n underlay,\n rooms,\n view,\n selection = EMPTY_SELECTION,\n hovered = null,\n interactiveRooms = false,\n interactiveOpenings = false,\n showGrid = false,\n gridSize = 100,\n showRoomLabels = true,\n showOpeningSymbols = true,\n getRoomColor,\n renderRoomLabel,\n getRoomLabel,\n formatArea = formatAreaDefault,\n onRoomActivate,\n onOpeningActivate,\n onBackgroundActivate,\n onHoverChange,\n overlay,\n worldOverlay,\n size,\n className,\n style,\n classNames,\n styles: slotStyles,\n 'aria-label': ariaLabel,\n } = props;\n\n const pxToWorld = view.zoom > 0 ? 1 / view.zoom : 1;\n const outlineWidth = DEFAULT_OUTLINE_PX * pxToWorld;\n\n const wallPaths = useMemo(() => buildWallPaths(floor), [floor]);\n\n /**\n * Centrelines only, at one stroke width. The underlay is there to line walls up\n * against, so it wants to read as a tracing rather than compete with the floor being\n * drawn; the two-pass thick-wall treatment would give it equal weight.\n */\n const underlayLines = useMemo(() => {\n if (!underlay) return [];\n return Object.values(underlay.walls).flatMap((wall) => {\n const a = underlay.nodes[wall.a];\n const b = underlay.nodes[wall.b];\n return a && b ? [{ id: wall.id, x1: a.x, y1: a.y, x2: b.x, y2: b.y }] : [];\n });\n }, [underlay]);\n\n /** World point to screen point, for the untransformed layer. */\n const toScreen = (p: PlanPoint) => ({\n x: (p.x - view.x) * view.zoom,\n y: (p.y - view.y) * view.zoom,\n });\n\n // Grid lines are generated for the visible rect only. Deliberately not an SVG\n // <pattern>: a pattern needs an id, and two canvases on one page then collide.\n const gridLines = useMemo(() => {\n if (!showGrid || gridSize <= 0) return null;\n const worldW = size.width * pxToWorld;\n const worldH = size.height * pxToWorld;\n // Keep the line count sane when zoomed far out.\n const step = gridSize * Math.max(1, Math.pow(10, Math.ceil(Math.log10(worldW / gridSize / 60))));\n const startX = Math.floor(view.x / step) * step;\n const startY = Math.floor(view.y / step) * step;\n const verticals: number[] = [];\n const horizontals: number[] = [];\n for (let x = startX; x <= view.x + worldW; x += step) verticals.push(x);\n for (let y = startY; y <= view.y + worldH; y += step) horizontals.push(y);\n return { verticals, horizontals, step, worldW, worldH };\n }, [showGrid, gridSize, size.width, size.height, pxToWorld, view.x, view.y]);\n\n const isSelected = (type: string, id: string) => selection.some((entry) => entry.type === type && entry.id === id);\n const isHovered = (type: string, id: string) => hovered?.type === type && hovered.id === id;\n\n /**\n * The walls bounding the selected rooms. A SELECTED room is marked by colouring its\n * boundary rather than by flooding its floor, which would bury its doors and its label;\n * hover keeps the faint floor tint instead, since the two say different things.\n */\n const highlightedWalls = useMemo(() => {\n const selectedRooms = new Set(selection.filter((entry) => entry.type === 'room').map((entry) => entry.id));\n const ids = new Set<string>();\n for (const room of rooms) {\n if (room.roomId && selectedRooms.has(room.roomId)) {\n // A wall shared by two selected rooms belongs to both; the set draws it once.\n for (const id of room.wallIds) ids.add(id);\n }\n }\n return ids;\n }, [rooms, selection]);\n\n const roomEdge = useMemo(\n () => (highlightedWalls.size > 0 ? buildWallPaths(floor, { wallIds: highlightedWalls }) : { groups: [], caps: [] }),\n [floor, highlightedWalls],\n );\n\n function renderOpening(opening: PlanOpening) {\n const geo = openingGeometry(floor, opening);\n if (!geo) return null;\n const wall = floor.walls[opening.wallId];\n const half = wall ? wall.thickness / 2 : 50;\n const { p1, p2, normal, dir, centre } = geo;\n\n const selected = isSelected('opening', opening.id);\n const hoveredNow = isHovered('opening', opening.id);\n const width = Math.hypot(p2.x - p1.x, p2.y - p1.y);\n\n const parts: ReactElement[] = [];\n\n if (showOpeningSymbols && opening.kind === OpeningKind.Door) {\n // Leaf plus swing arc, drawn on the wall's left side.\n const hingeAtStart = opening.swing !== 'endLeft' && opening.swing !== 'endRight';\n const hinge = hingeAtStart ? p1 : p2;\n const sweepDir = hingeAtStart ? 1 : -1;\n const leafEnd = { x: hinge.x + normal.x * width, y: hinge.y + normal.y * width };\n const arcEnd = {\n x: hinge.x + dir.x * width * sweepDir,\n y: hinge.y + dir.y * width * sweepDir,\n };\n parts.push(\n <path\n key='leaf'\n className={styles.planCanvasDoorLeaf}\n d={`M ${hinge.x},${hinge.y} L ${leafEnd.x},${leafEnd.y}`}\n strokeWidth={outlineWidth}\n />,\n <path\n key='swing'\n className={styles.planCanvasDoorSwing}\n d={`M ${leafEnd.x},${leafEnd.y} A ${width},${width} 0 0,${hingeAtStart ? 0 : 1} ${arcEnd.x},${arcEnd.y}`}\n strokeWidth={outlineWidth}\n />,\n );\n }\n\n if (showOpeningSymbols && opening.kind === OpeningKind.Window) {\n // A pane line down the middle of the wall's thickness.\n parts.push(\n <path\n key='pane'\n className={styles.planCanvasWindowPane}\n d={`M ${p1.x},${p1.y} L ${p2.x},${p2.y}`}\n strokeWidth={outlineWidth * 2}\n />,\n );\n }\n\n const hitPath = `M ${p1.x + normal.x * half},${p1.y + normal.y * half} L ${\n p2.x + normal.x * half\n },${p2.y + normal.y * half} L ${p2.x - normal.x * half},${p2.y - normal.y * half} L ${\n p1.x - normal.x * half\n },${p1.y - normal.y * half} Z`;\n\n return (\n <g\n key={opening.id}\n className={cx(\n selected && styles.planCanvasOpeningSelected,\n hoveredNow && styles.planCanvasOpeningHovered,\n classNames?.opening,\n )}\n style={slotStyles?.opening}\n data-opening-kind={opening.kind}\n >\n {parts}\n <path\n className={cx(styles.planCanvasOpeningHit, interactiveOpenings && styles.planCanvasOpeningHitInteractive)}\n d={hitPath}\n onClick={\n interactiveOpenings && onOpeningActivate\n ? (e) => {\n e.stopPropagation();\n onOpeningActivate(opening.id);\n }\n : undefined\n }\n onPointerEnter={onHoverChange ? () => onHoverChange({ type: 'opening', id: opening.id }) : undefined}\n >\n {interactiveOpenings && <title>{opening.kind}</title>}\n </path>\n {(selected || hoveredNow) && (\n <path className={styles.planCanvasOpeningOutline} d={hitPath} vectorEffect='non-scaling-stroke' />\n )}\n {/* The jamb faces, so an opening reads as a hole with sides rather than a blank. */}\n <path\n className={cx(\n styles.planCanvasJamb,\n // The jamb face belongs to the wall it is cut into, so it follows that wall\n // into the highlight rather than staying white against it.\n highlightedWalls.has(opening.wallId) && styles.planCanvasJambHighlighted,\n )}\n d={`M ${p1.x - normal.x * half},${p1.y - normal.y * half} L ${p1.x + normal.x * half},${\n p1.y + normal.y * half\n } M ${p2.x - normal.x * half},${p2.y - normal.y * half} L ${p2.x + normal.x * half},${\n p2.y + normal.y * half\n }`}\n strokeWidth={outlineWidth}\n />\n {centre && null}\n </g>\n );\n }\n\n return (\n <svg\n ref={ref}\n className={cx(styles.planCanvas, className, classNames?.canvas)}\n style={{ ...style, ...slotStyles?.canvas }}\n viewBox={`0 0 ${Math.max(1, size.width)} ${Math.max(1, size.height)}`}\n width={size.width}\n height={size.height}\n role='img'\n aria-label={ariaLabel}\n onClick={onBackgroundActivate ? () => onBackgroundActivate() : undefined}\n onPointerLeave={onHoverChange ? () => onHoverChange(null) : undefined}\n >\n <g transform={`translate(${-view.x * view.zoom} ${-view.y * view.zoom}) scale(${view.zoom})`}>\n {/* 1. Grid */}\n {gridLines && (\n <g className={cx(styles.planCanvasGrid, classNames?.grid)} style={slotStyles?.grid} aria-hidden='true'>\n {gridLines.verticals.map((x) => (\n <line key={`v${x}`} x1={x} y1={view.y} x2={x} y2={view.y + gridLines.worldH} strokeWidth={pxToWorld} />\n ))}\n {gridLines.horizontals.map((y) => (\n <line key={`h${y}`} x1={view.x} y1={y} x2={view.x + gridLines.worldW} y2={y} strokeWidth={pxToWorld} />\n ))}\n </g>\n )}\n\n {/* 1b. The storey below, traced */}\n {underlayLines.length > 0 && (\n <g\n className={cx(styles.planCanvasUnderlay, classNames?.underlay)}\n style={slotStyles?.underlay}\n aria-hidden='true'\n >\n {/* Screen units: the rule sets vector-effect: non-scaling-stroke, so the width\n is read in screen pixels rather than world millimetres. */}\n {underlayLines.map((line) => (\n <line key={line.id} x1={line.x1} y1={line.y1} x2={line.x2} y2={line.y2} strokeWidth={1.5} />\n ))}\n </g>\n )}\n\n {/* 2. Room fills — the only hit target for room selection */}\n <g className={cx(styles.planCanvasRooms, classNames?.rooms)} style={slotStyles?.rooms}>\n {rooms.map((room) => {\n const selected = room.roomId ? isSelected('room', room.roomId) : false;\n const hoveredNow = room.roomId ? isHovered('room', room.roomId) : false;\n const colour = room.meta ? getRoomColor?.(room.meta, room.area) : undefined;\n const label =\n getRoomLabel?.(room.meta, { area: room.area }) ??\n `${room.meta?.name ?? 'Unnamed room'}, ${formatArea(room.area)}`;\n\n return (\n <path\n key={room.id}\n className={cx(\n styles.planCanvasRoomFill,\n hoveredNow && styles.planCanvasRoomFillHovered,\n interactiveRooms && styles.planCanvasRoomFillInteractive,\n classNames?.roomFill,\n )}\n data-state={selected ? 'selected' : hoveredNow ? 'hovered' : undefined}\n style={{ ...slotStyles?.roomFill, ...(colour ? { fill: colour } : null) }}\n d={faceToPath(room)}\n fillRule='evenodd'\n tabIndex={interactiveRooms ? 0 : undefined}\n role={interactiveRooms ? 'button' : undefined}\n aria-pressed={interactiveRooms ? selected : undefined}\n onClick={\n interactiveRooms && onRoomActivate && room.roomId\n ? (e) => {\n e.stopPropagation();\n onRoomActivate(room.roomId!);\n }\n : undefined\n }\n onKeyDown={\n interactiveRooms && onRoomActivate && room.roomId\n ? (e) => {\n if (e.key !== 'Enter' && e.key !== ' ') return;\n e.preventDefault();\n onRoomActivate(room.roomId!);\n }\n : undefined\n }\n onPointerEnter={\n onHoverChange && room.roomId ? () => onHoverChange({ type: 'room', id: room.roomId! }) : undefined\n }\n >\n {/* Both a <title> and the aria-label: aria-label on SVG shapes is\n unreliable in older Safari/VoiceOver, and <title> doubles as the\n native tooltip. */}\n {interactiveRooms && <title>{label}</title>}\n </path>\n );\n })}\n </g>\n\n {/* 3. Wall bodies — outline pass, then fill pass. Never interleaved: the visible\n outline is what is left of the first pass after the second covers its middle. */}\n <g className={cx(styles.planCanvasWalls, classNames?.walls)} style={slotStyles?.walls} aria-hidden='true'>\n <g className={styles.planCanvasWallOutline}>\n {wallPaths.groups.map((group) => (\n <path\n key={`o${group.thickness}`}\n className={classNames?.wallBody}\n style={slotStyles?.wallBody}\n d={group.d}\n strokeWidth={group.thickness}\n />\n ))}\n </g>\n <g className={styles.planCanvasWallFill}>\n {wallPaths.groups.map((group) => {\n const fillWidth = group.thickness - 2 * outlineWidth;\n // Zoomed far out the fill would invert; walls collapsing to solid lines is\n // the right look at that scale.\n if (fillWidth <= 0) return null;\n return <path key={`f${group.thickness}`} d={group.d} strokeWidth={fillWidth} />;\n })}\n </g>\n <g className={styles.planCanvasRoomEdgeSelected}>\n {/* The same two passes the walls themselves use, on the same path data: an\n outline at full thickness, then a fill inside it. Recolouring only the body\n left the wall edged in its normal colour, so it did not read as one object. */}\n {roomEdge.groups.map((group) => (\n <path\n key={`o${group.thickness}`}\n className={styles.planCanvasRoomEdgeOutline}\n d={group.d}\n strokeWidth={group.thickness}\n />\n ))}\n {roomEdge.groups.map((group) => {\n const fillWidth = group.thickness - 2 * outlineWidth;\n if (fillWidth <= 0) return null;\n return (\n <path\n key={`f${group.thickness}`}\n className={styles.planCanvasRoomEdgeFill}\n d={group.d}\n strokeWidth={fillWidth}\n />\n );\n })}\n </g>\n\n <g className={styles.planCanvasWallCaps}>\n {/* A highlighted wall's caps are drawn below in the highlight colour. Skipped\n here rather than painted over: an antialiased hairline is never fully\n covered, and the two would blend into a pale seam. */}\n {wallPaths.caps\n .filter((cap) => !highlightedWalls.has(cap.wallId))\n .map((cap, i) => (\n <line\n key={`${cap.wallId}-${cap.reason}-${i}`}\n x1={cap.a.x}\n y1={cap.a.y}\n x2={cap.b.x}\n y2={cap.b.y}\n strokeWidth={outlineWidth}\n />\n ))}\n </g>\n <g className={styles.planCanvasRoomEdgeCaps}>\n {roomEdge.caps.map((cap, i) => (\n <line\n key={`${cap.wallId}-${cap.reason}-${i}`}\n x1={cap.a.x}\n y1={cap.a.y}\n x2={cap.b.x}\n y2={cap.b.y}\n strokeWidth={outlineWidth}\n />\n ))}\n </g>\n </g>\n\n {/* 4. Openings */}\n <g className={cx(styles.planCanvasOpenings, classNames?.openings)} style={slotStyles?.openings}>\n {Object.values(floor.openings).map(renderOpening)}\n </g>\n\n {/* 5. Selection / hover outlines for walls and nodes */}\n <g className={styles.planCanvasSelection} aria-hidden='true'>\n {selection\n .filter((entry) => entry.type === 'wall')\n .map((entry) => {\n const wall = floor.walls[entry.id];\n if (!wall) return null;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return null;\n return (\n <line\n key={entry.id}\n x1={a.x}\n y1={a.y}\n x2={b.x}\n y2={b.y}\n strokeWidth={wall.thickness}\n className={styles.planCanvasWallSelected}\n />\n );\n })}\n {hovered?.type === 'wall' &&\n !isSelected('wall', hovered.id) &&\n (() => {\n const wall = floor.walls[hovered.id];\n if (!wall) return null;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return null;\n return (\n <line\n x1={a.x}\n y1={a.y}\n x2={b.x}\n y2={b.y}\n strokeWidth={wall.thickness}\n className={styles.planCanvasWallHovered}\n />\n );\n })()}\n </g>\n\n {worldOverlay}\n </g>\n\n {/* Screen space: sized in pixels, so labels and handles stay constant under zoom */}\n <g className={cx(styles.planCanvasScreen, classNames?.overlay)} style={slotStyles?.overlay}>\n {showRoomLabels &&\n rooms.map((room) => {\n const at = toScreen(room.anchor);\n if (at.x < -200 || at.y < -200 || at.x > size.width + 200 || at.y > size.height + 200) {\n return null;\n }\n const custom = renderRoomLabel?.(room.meta, { area: room.area, faceId: room.id });\n if (custom === null) return null;\n\n return (\n <g\n key={room.id}\n className={cx(styles.planCanvasRoomLabel, classNames?.roomLabel)}\n style={slotStyles?.roomLabel}\n transform={`translate(${at.x} ${at.y})`}\n aria-hidden='true'\n >\n {custom !== undefined ? (\n custom\n ) : (\n <>\n <text className={styles.planCanvasRoomName} textAnchor='middle'>\n {room.meta?.name ?? ''}\n </text>\n <text className={styles.planCanvasRoomArea} textAnchor='middle' dy='1.2em'>\n {formatArea(room.area)}\n </text>\n </>\n )}\n </g>\n );\n })}\n {overlay}\n </g>\n </svg>\n );\n}\n\nexport default PlanCanvas;\n"],"mappings":"mUA4BA,IAAM,EAAqB,EAGrB,EAA4C,CAAC,EAEnD,SAAS,EAAkB,EAAyB,CAClD,IAAM,EAAK,EAAU,IACrB,MAAO,GAAG,EAAG,QAAQ,IAAK,GAAU,EAAE,IACxC,CAEA,SAAS,EAAW,EAA2B,CAE7C,OADI,EAAK,SAAW,EAAU,GACvB,GAAG,EAAK,KAAK,EAAG,IAAM,GAAG,IAAM,EAAI,IAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,GACjF,CAGA,SAAS,EAAW,EAA2B,CAC7C,MAAO,CAAC,EAAW,EAAK,KAAK,EAAG,GAAG,EAAK,MAAM,IAAI,CAAU,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACzF,CAMA,SAAS,EAAW,EAAwB,CAC1C,GAAM,CACJ,MACA,QACA,WACA,QACA,OACA,YA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AG,EAAI,MAAQ,EAAG,EAAI,MAAQ,EAAG,EAAI,EAAK,MAAQ,KAAO,EAAG,EAAI,EAAK,OAAS,IAChF,OAAO,KAET,IAAM,EAAS,IAAkB,EAAK,KAAM,CAAE,KAAM,EAAK,KAAM,OAAQ,EAAK,EAAG,CAAC,EAGhF,OAFI,IAAW,KAAa,KAG1B,EAAC,IAAD,CAEE,UAAW,EAAG,EAAO,oBAAqB,GAAY,SAAS,EAC/D,MAAO,GAAY,UACnB,UAAW,aAAa,EAAG,EAAE,GAAG,EAAG,EAAE,GACrC,cAAY,OAEX,SAAA,IAAW,IAAA,GAGV,EAAA,EAAA,CAAA,SAAA,CACE,EAAC,OAAD,CAAM,UAAW,EAAO,mBAAoB,WAAW,SACpD,SAAA,EAAK,MAAM,MAAQ,EAChB,CAAA,EACN,EAAC,OAAD,CAAM,UAAW,EAAO,mBAAoB,WAAW,SAAS,GAAG,QAChE,SAAA,EAAW,EAAK,IAAI,CACjB,CAAA,CACN,CAAA,CAAA,EATF,CAWD,EAlBI,EAAK,EAkBT,CAEP,CAAC,EACF,CACA,CACA,CAAA,CAAA,GAET"}
|
|
1
|
+
{"version":3,"file":"planCanvas.mjs","names":[],"sources":["../../../../package/common/planCanvas/planCanvas.tsx"],"sourcesContent":["import { useMemo, type ReactElement } from 'react';\nimport cx from 'classnames';\n\nimport {\n OpeningKind,\n buildWallPaths,\n openingGeometry,\n type DerivedRoom,\n type PlanOpening,\n type PlanPoint,\n type PlanSelection,\n} from '../floorPlan';\nimport type { PlanCanvasProps } from './planCanvas.types';\nimport styles from './planCanvas.module.pcss';\n\n/**\n * The read-only renderer shared by RoomDrawer and RoomViewer.\n *\n * It owns the projection, the layer stack, and the accessible room shapes. It owns no\n * editing state: the drawer supplies its handles and previews through `overlay`. Having\n * one renderer is the point, so that a plan cannot look different in the editor than it\n * does in the viewer.\n *\n * The viewport is a TRANSFORM on a group, not an SVG `viewBox`. That is what lets the\n * screen-space layer draw labels and handles at a fixed pixel size while the drawing\n * itself scales.\n */\n\nconst DEFAULT_OUTLINE_PX = 1;\n\n/** Stable identity, so a default-valued `selection` prop does not re-run memos. */\nconst EMPTY_SELECTION: readonly PlanSelection[] = [];\n\nfunction formatAreaDefault(areaMm2: number): string {\n const m2 = areaMm2 / 1_000_000;\n return `${m2.toFixed(m2 < 10 ? 1 : 0)} m²`;\n}\n\nfunction ringToPath(ring: PlanPoint[]): string {\n if (ring.length === 0) return '';\n return `${ring.map((p, i) => `${i === 0 ? 'M' : 'L'} ${p.x},${p.y}`).join(' ')} Z`;\n}\n\n/** Outer ring plus holes as one path; `fill-rule: evenodd` punches the holes out. */\nfunction faceToPath(face: DerivedRoom): string {\n return [ringToPath(face.outer), ...face.holes.map(ringToPath)].filter(Boolean).join(' ');\n}\n\n/**\n * The ref lands on the `<svg>` itself, which is what a consumer wants for measuring or\n * screenshotting. Both the drawer and the viewer expose it as `getSvgElement()`.\n */\nfunction PlanCanvas(props: PlanCanvasProps) {\n const {\n ref,\n floor,\n underlay,\n rooms,\n view,\n selection = EMPTY_SELECTION,\n hovered = null,\n interactiveRooms = false,\n interactiveOpenings = false,\n showGrid = false,\n gridSize = 100,\n showRoomLabels = true,\n showOpeningSymbols = true,\n getRoomColor,\n renderRoomLabel,\n getRoomLabel,\n formatArea = formatAreaDefault,\n onRoomActivate,\n onOpeningActivate,\n onBackgroundActivate,\n onHoverChange,\n overlay,\n worldOverlay,\n size,\n className,\n style,\n classNames,\n styles: slotStyles,\n 'aria-label': ariaLabel,\n } = props;\n\n const pxToWorld = view.zoom > 0 ? 1 / view.zoom : 1;\n const outlineWidth = DEFAULT_OUTLINE_PX * pxToWorld;\n\n const wallPaths = useMemo(() => buildWallPaths(floor), [floor]);\n\n /**\n * Centrelines only, at one stroke width. The underlay is there to line walls up\n * against, so it wants to read as a tracing rather than compete with the floor being\n * drawn; the two-pass thick-wall treatment would give it equal weight.\n */\n const underlayLines = useMemo(() => {\n if (!underlay) return [];\n return Object.values(underlay.walls).flatMap((wall) => {\n const a = underlay.nodes[wall.a];\n const b = underlay.nodes[wall.b];\n return a && b ? [{ id: wall.id, x1: a.x, y1: a.y, x2: b.x, y2: b.y }] : [];\n });\n }, [underlay]);\n\n /** World point to screen point, for the untransformed layer. */\n const toScreen = (p: PlanPoint) => ({\n x: (p.x - view.x) * view.zoom,\n y: (p.y - view.y) * view.zoom,\n });\n\n // Grid lines are generated for the visible rect only. Deliberately not an SVG\n // <pattern>: a pattern needs an id, and two canvases on one page then collide.\n const gridLines = useMemo(() => {\n if (!showGrid || gridSize <= 0) return null;\n const worldW = size.width * pxToWorld;\n const worldH = size.height * pxToWorld;\n // Keep the line count sane when zoomed far out.\n const step = gridSize * Math.max(1, Math.pow(10, Math.ceil(Math.log10(worldW / gridSize / 60))));\n const startX = Math.floor(view.x / step) * step;\n const startY = Math.floor(view.y / step) * step;\n const verticals: number[] = [];\n const horizontals: number[] = [];\n for (let x = startX; x <= view.x + worldW; x += step) verticals.push(x);\n for (let y = startY; y <= view.y + worldH; y += step) horizontals.push(y);\n return { verticals, horizontals, step, worldW, worldH };\n }, [showGrid, gridSize, size.width, size.height, pxToWorld, view.x, view.y]);\n\n const isSelected = (type: string, id: string) => selection.some((entry) => entry.type === type && entry.id === id);\n const isHovered = (type: string, id: string) => hovered?.type === type && hovered.id === id;\n\n /**\n * The walls bounding the selected rooms. A SELECTED room is marked by colouring its\n * boundary rather than by flooding its floor, which would bury its doors and its label;\n * hover keeps the faint floor tint instead, since the two say different things.\n */\n const highlightedWalls = useMemo(() => {\n const selectedRooms = new Set(selection.filter((entry) => entry.type === 'room').map((entry) => entry.id));\n const ids = new Set<string>();\n for (const room of rooms) {\n if (room.roomId && selectedRooms.has(room.roomId)) {\n // A wall shared by two selected rooms belongs to both; the set draws it once.\n for (const id of room.wallIds) ids.add(id);\n }\n }\n return ids;\n }, [rooms, selection]);\n\n const roomEdge = useMemo(\n () => (highlightedWalls.size > 0 ? buildWallPaths(floor, { wallIds: highlightedWalls }) : { groups: [], caps: [] }),\n [floor, highlightedWalls],\n );\n\n function renderOpening(opening: PlanOpening) {\n const geo = openingGeometry(floor, opening);\n if (!geo) return null;\n const wall = floor.walls[opening.wallId];\n const half = wall ? wall.thickness / 2 : 50;\n const { p1, p2, normal, dir, centre } = geo;\n\n const selected = isSelected('opening', opening.id);\n const hoveredNow = isHovered('opening', opening.id);\n const width = Math.hypot(p2.x - p1.x, p2.y - p1.y);\n\n const parts: ReactElement[] = [];\n\n if (showOpeningSymbols && opening.kind === OpeningKind.Door) {\n // Leaf plus swing arc, drawn on the wall's left side.\n const hingeAtStart = opening.swing !== 'endLeft' && opening.swing !== 'endRight';\n const hinge = hingeAtStart ? p1 : p2;\n const sweepDir = hingeAtStart ? 1 : -1;\n const leafEnd = { x: hinge.x + normal.x * width, y: hinge.y + normal.y * width };\n const arcEnd = {\n x: hinge.x + dir.x * width * sweepDir,\n y: hinge.y + dir.y * width * sweepDir,\n };\n parts.push(\n <path\n key='leaf'\n className={styles.planCanvasDoorLeaf}\n d={`M ${hinge.x},${hinge.y} L ${leafEnd.x},${leafEnd.y}`}\n strokeWidth={outlineWidth}\n />,\n <path\n key='swing'\n className={styles.planCanvasDoorSwing}\n d={`M ${leafEnd.x},${leafEnd.y} A ${width},${width} 0 0,${hingeAtStart ? 0 : 1} ${arcEnd.x},${arcEnd.y}`}\n strokeWidth={outlineWidth}\n />,\n );\n }\n\n if (showOpeningSymbols && opening.kind === OpeningKind.Window) {\n // A pane line down the middle of the wall's thickness.\n parts.push(\n <path\n key='pane'\n className={styles.planCanvasWindowPane}\n d={`M ${p1.x},${p1.y} L ${p2.x},${p2.y}`}\n strokeWidth={outlineWidth * 2}\n />,\n );\n }\n\n const hitPath = `M ${p1.x + normal.x * half},${p1.y + normal.y * half} L ${\n p2.x + normal.x * half\n },${p2.y + normal.y * half} L ${p2.x - normal.x * half},${p2.y - normal.y * half} L ${\n p1.x - normal.x * half\n },${p1.y - normal.y * half} Z`;\n\n return (\n <g\n key={opening.id}\n className={cx(\n selected && styles.planCanvasOpeningSelected,\n hoveredNow && styles.planCanvasOpeningHovered,\n classNames?.opening,\n )}\n style={slotStyles?.opening}\n data-opening-kind={opening.kind}\n >\n {parts}\n <path\n className={cx(styles.planCanvasOpeningHit, interactiveOpenings && styles.planCanvasOpeningHitInteractive)}\n d={hitPath}\n onClick={\n interactiveOpenings && onOpeningActivate\n ? (e) => {\n e.stopPropagation();\n onOpeningActivate(opening.id);\n }\n : undefined\n }\n onPointerEnter={onHoverChange ? () => onHoverChange({ type: 'opening', id: opening.id }) : undefined}\n >\n {interactiveOpenings && <title>{opening.kind}</title>}\n </path>\n {(selected || hoveredNow) && (\n <path className={styles.planCanvasOpeningOutline} d={hitPath} vectorEffect='non-scaling-stroke' />\n )}\n {/* The jamb faces, so an opening reads as a hole with sides rather than a blank. */}\n <path\n className={cx(\n styles.planCanvasJamb,\n // The jamb face belongs to the wall it is cut into, so it follows that wall\n // into the highlight rather than staying white against it.\n highlightedWalls.has(opening.wallId) && styles.planCanvasJambHighlighted,\n )}\n d={`M ${p1.x - normal.x * half},${p1.y - normal.y * half} L ${p1.x + normal.x * half},${\n p1.y + normal.y * half\n } M ${p2.x - normal.x * half},${p2.y - normal.y * half} L ${p2.x + normal.x * half},${\n p2.y + normal.y * half\n }`}\n strokeWidth={outlineWidth}\n />\n {centre && null}\n </g>\n );\n }\n\n return (\n <svg\n ref={ref}\n className={cx(styles.planCanvas, className, classNames?.canvas)}\n style={{ ...style, ...slotStyles?.canvas }}\n viewBox={`0 0 ${Math.max(1, size.width)} ${Math.max(1, size.height)}`}\n width={size.width}\n height={size.height}\n role='img'\n aria-label={ariaLabel}\n onClick={onBackgroundActivate ? () => onBackgroundActivate() : undefined}\n onPointerLeave={onHoverChange ? () => onHoverChange(null) : undefined}\n >\n <g transform={`translate(${-view.x * view.zoom} ${-view.y * view.zoom}) scale(${view.zoom})`}>\n {/* 1. Grid */}\n {gridLines && (\n <g className={cx(styles.planCanvasGrid, classNames?.grid)} style={slotStyles?.grid} aria-hidden='true'>\n {gridLines.verticals.map((x) => (\n <line key={`v${x}`} x1={x} y1={view.y} x2={x} y2={view.y + gridLines.worldH} strokeWidth={pxToWorld} />\n ))}\n {gridLines.horizontals.map((y) => (\n <line key={`h${y}`} x1={view.x} y1={y} x2={view.x + gridLines.worldW} y2={y} strokeWidth={pxToWorld} />\n ))}\n </g>\n )}\n\n {/* 1b. The storey below, traced */}\n {underlayLines.length > 0 && (\n <g\n className={cx(styles.planCanvasUnderlay, classNames?.underlay)}\n style={slotStyles?.underlay}\n aria-hidden='true'\n >\n {/* Screen units: the rule sets vector-effect: non-scaling-stroke, so the width\n is read in screen pixels rather than world millimetres. */}\n {underlayLines.map((line) => (\n <line key={line.id} x1={line.x1} y1={line.y1} x2={line.x2} y2={line.y2} strokeWidth={1.5} />\n ))}\n </g>\n )}\n\n {/* 2. Room fills — the only hit target for room selection */}\n <g className={cx(styles.planCanvasRooms, classNames?.rooms)} style={slotStyles?.rooms}>\n {rooms.map((room) => {\n const selected = room.roomId ? isSelected('room', room.roomId) : false;\n const hoveredNow = room.roomId ? isHovered('room', room.roomId) : false;\n const colour = room.meta ? getRoomColor?.(room.meta, room.area) : undefined;\n const label = getRoomLabel?.(room.meta, { area: room.area });\n\n return (\n <path\n key={room.id}\n className={cx(\n styles.planCanvasRoomFill,\n hoveredNow && styles.planCanvasRoomFillHovered,\n interactiveRooms && styles.planCanvasRoomFillInteractive,\n classNames?.roomFill,\n )}\n data-state={selected ? 'selected' : hoveredNow ? 'hovered' : undefined}\n style={{ ...slotStyles?.roomFill, ...(colour ? { fill: colour } : null) }}\n d={faceToPath(room)}\n fillRule='evenodd'\n tabIndex={interactiveRooms ? 0 : undefined}\n role={interactiveRooms ? 'button' : undefined}\n aria-pressed={interactiveRooms ? selected : undefined}\n onClick={\n interactiveRooms && onRoomActivate && room.roomId\n ? (e) => {\n e.stopPropagation();\n onRoomActivate(room.roomId!);\n }\n : undefined\n }\n onKeyDown={\n interactiveRooms && onRoomActivate && room.roomId\n ? (e) => {\n if (e.key !== 'Enter' && e.key !== ' ') return;\n e.preventDefault();\n onRoomActivate(room.roomId!);\n }\n : undefined\n }\n onPointerEnter={\n onHoverChange && room.roomId ? () => onHoverChange({ type: 'room', id: room.roomId! }) : undefined\n }\n >\n {/* Both a <title> and the aria-label: aria-label on SVG shapes is\n unreliable in older Safari/VoiceOver, and <title> doubles as the\n native tooltip. */}\n {interactiveRooms && label && <title>{label}</title>}\n </path>\n );\n })}\n </g>\n\n {/* 3. Wall bodies — outline pass, then fill pass. Never interleaved: the visible\n outline is what is left of the first pass after the second covers its middle. */}\n <g className={cx(styles.planCanvasWalls, classNames?.walls)} style={slotStyles?.walls} aria-hidden='true'>\n <g className={styles.planCanvasWallOutline}>\n {wallPaths.groups.map((group) => (\n <path\n key={`o${group.thickness}`}\n className={classNames?.wallBody}\n style={slotStyles?.wallBody}\n d={group.d}\n strokeWidth={group.thickness}\n />\n ))}\n </g>\n <g className={styles.planCanvasWallFill}>\n {wallPaths.groups.map((group) => {\n const fillWidth = group.thickness - 2 * outlineWidth;\n // Zoomed far out the fill would invert; walls collapsing to solid lines is\n // the right look at that scale.\n if (fillWidth <= 0) return null;\n return <path key={`f${group.thickness}`} d={group.d} strokeWidth={fillWidth} />;\n })}\n </g>\n <g className={styles.planCanvasRoomEdgeSelected}>\n {/* The same two passes the walls themselves use, on the same path data: an\n outline at full thickness, then a fill inside it. Recolouring only the body\n left the wall edged in its normal colour, so it did not read as one object. */}\n {roomEdge.groups.map((group) => (\n <path\n key={`o${group.thickness}`}\n className={styles.planCanvasRoomEdgeOutline}\n d={group.d}\n strokeWidth={group.thickness}\n />\n ))}\n {roomEdge.groups.map((group) => {\n const fillWidth = group.thickness - 2 * outlineWidth;\n if (fillWidth <= 0) return null;\n return (\n <path\n key={`f${group.thickness}`}\n className={styles.planCanvasRoomEdgeFill}\n d={group.d}\n strokeWidth={fillWidth}\n />\n );\n })}\n </g>\n\n <g className={styles.planCanvasWallCaps}>\n {/* A highlighted wall's caps are drawn below in the highlight colour. Skipped\n here rather than painted over: an antialiased hairline is never fully\n covered, and the two would blend into a pale seam. */}\n {wallPaths.caps\n .filter((cap) => !highlightedWalls.has(cap.wallId))\n .map((cap, i) => (\n <line\n key={`${cap.wallId}-${cap.reason}-${i}`}\n x1={cap.a.x}\n y1={cap.a.y}\n x2={cap.b.x}\n y2={cap.b.y}\n strokeWidth={outlineWidth}\n />\n ))}\n </g>\n <g className={styles.planCanvasRoomEdgeCaps}>\n {roomEdge.caps.map((cap, i) => (\n <line\n key={`${cap.wallId}-${cap.reason}-${i}`}\n x1={cap.a.x}\n y1={cap.a.y}\n x2={cap.b.x}\n y2={cap.b.y}\n strokeWidth={outlineWidth}\n />\n ))}\n </g>\n </g>\n\n {/* 4. Openings */}\n <g className={cx(styles.planCanvasOpenings, classNames?.openings)} style={slotStyles?.openings}>\n {Object.values(floor.openings).map(renderOpening)}\n </g>\n\n {/* 5. Selection / hover outlines for walls and nodes */}\n <g className={styles.planCanvasSelection} aria-hidden='true'>\n {selection\n .filter((entry) => entry.type === 'wall')\n .map((entry) => {\n const wall = floor.walls[entry.id];\n if (!wall) return null;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return null;\n return (\n <line\n key={entry.id}\n x1={a.x}\n y1={a.y}\n x2={b.x}\n y2={b.y}\n strokeWidth={wall.thickness}\n className={styles.planCanvasWallSelected}\n />\n );\n })}\n {hovered?.type === 'wall' &&\n !isSelected('wall', hovered.id) &&\n (() => {\n const wall = floor.walls[hovered.id];\n if (!wall) return null;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return null;\n return (\n <line\n x1={a.x}\n y1={a.y}\n x2={b.x}\n y2={b.y}\n strokeWidth={wall.thickness}\n className={styles.planCanvasWallHovered}\n />\n );\n })()}\n </g>\n\n {worldOverlay}\n </g>\n\n {/* Screen space: sized in pixels, so labels and handles stay constant under zoom */}\n <g className={cx(styles.planCanvasScreen, classNames?.overlay)} style={slotStyles?.overlay}>\n {showRoomLabels &&\n rooms.map((room) => {\n const at = toScreen(room.anchor);\n if (at.x < -200 || at.y < -200 || at.x > size.width + 200 || at.y > size.height + 200) {\n return null;\n }\n const custom = renderRoomLabel?.(room.meta, { area: room.area, faceId: room.id });\n if (custom === null) return null;\n\n return (\n <g\n key={room.id}\n className={cx(styles.planCanvasRoomLabel, classNames?.roomLabel)}\n style={slotStyles?.roomLabel}\n transform={`translate(${at.x} ${at.y})`}\n aria-hidden='true'\n >\n {custom !== undefined ? (\n custom\n ) : (\n <>\n <text className={styles.planCanvasRoomName} textAnchor='middle'>\n {room.meta?.name ?? ''}\n </text>\n <text className={styles.planCanvasRoomArea} textAnchor='middle' dy='1.2em'>\n {formatArea(room.area)}\n </text>\n </>\n )}\n </g>\n );\n })}\n {overlay}\n </g>\n </svg>\n );\n}\n\nexport default PlanCanvas;\n"],"mappings":"mUA4BA,IAAM,EAAqB,EAGrB,EAA4C,CAAC,EAEnD,SAAS,EAAkB,EAAyB,CAClD,IAAM,EAAK,EAAU,IACrB,MAAO,GAAG,EAAG,QAAQ,IAAK,GAAU,EAAE,IACxC,CAEA,SAAS,EAAW,EAA2B,CAE7C,OADI,EAAK,SAAW,EAAU,GACvB,GAAG,EAAK,KAAK,EAAG,IAAM,GAAG,IAAM,EAAI,IAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,GACjF,CAGA,SAAS,EAAW,EAA2B,CAC7C,MAAO,CAAC,EAAW,EAAK,KAAK,EAAG,GAAG,EAAK,MAAM,IAAI,CAAU,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACzF,CAMA,SAAS,EAAW,EAAwB,CAC1C,GAAM,CACJ,MACA,QACA,WACA,QACA,OACA,YAAY,EACZ,UAAU,KACV,mBAAmB,GACnB,sBAAsB,GACtB,WAAW,GACX,WAAW,IACX,iBAAiB,GACjB,qBAAqB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