@mark1russell7/room-view 0.2.1 → 0.2.3
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/README.md +39 -2
- package/build/{anchors-J6mcUeJn.js → anchors-Ba3OUmhF.js} +57 -3
- package/build/anchors-Ba3OUmhF.js.map +1 -0
- package/build/index.d.ts +190 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +341 -6
- package/build/index.js.map +1 -1
- package/build/layers-B5nL_lVW.js +247 -0
- package/build/layers-B5nL_lVW.js.map +1 -0
- package/build/layers-BO_MMtQJ.d.ts +294 -0
- package/build/layers-BO_MMtQJ.d.ts.map +1 -0
- package/build/{level-5Nb9rq5L.js → level-CXCIX08K.js} +125 -22
- package/build/level-CXCIX08K.js.map +1 -0
- package/build/{level-Bmz-H5iH.d.ts → level-Cjcf3u20.d.ts} +89 -6
- package/build/level-Cjcf3u20.d.ts.map +1 -0
- package/build/{loads-Bp8aH2HJ.d.ts → loads-Diy6-Ekz.d.ts} +2 -2
- package/build/{loads-Bp8aH2HJ.d.ts.map → loads-Diy6-Ekz.d.ts.map} +1 -1
- package/build/marks.d.ts +2 -3
- package/build/marks.d.ts.map +1 -1
- package/build/marks.js +2 -2
- package/build/sample.d.ts +2 -2
- package/build/schema.d.ts +3 -3
- package/build/schema.d.ts.map +1 -1
- package/build/schema.js +9 -6
- package/build/schema.js.map +1 -1
- package/build/solids-S_j17vFJ.d.ts +313 -0
- package/build/solids-S_j17vFJ.d.ts.map +1 -0
- package/build/three.d.ts +2 -3
- package/build/three.d.ts.map +1 -1
- package/build/three.js +1 -2
- package/build/three.js.map +1 -1
- package/package.json +1 -1
- package/build/anchors-BEnxNnSV.d.ts +0 -75
- package/build/anchors-BEnxNnSV.d.ts.map +0 -1
- package/build/anchors-J6mcUeJn.js.map +0 -1
- package/build/frames-BYMK5ZId.d.ts +0 -39
- package/build/frames-BYMK5ZId.d.ts.map +0 -1
- package/build/layers-CtgTEnmt.js +0 -90
- package/build/layers-CtgTEnmt.js.map +0 -1
- package/build/layers-D_HqUjYu.d.ts +0 -148
- package/build/layers-D_HqUjYu.d.ts.map +0 -1
- package/build/level-5Nb9rq5L.js.map +0 -1
- package/build/level-Bmz-H5iH.d.ts.map +0 -1
- package/build/room-DrXMmX_h.js +0 -29
- package/build/room-DrXMmX_h.js.map +0 -1
- package/build/room-NREa6vXr.d.ts +0 -163
- package/build/room-NREa6vXr.d.ts.map +0 -1
- package/build/solids-BHLnvDVu.d.ts +0 -120
- package/build/solids-BHLnvDVu.d.ts.map +0 -1
- package/build/units-BZmvVyu4.js +0 -30
- package/build/units-BZmvVyu4.js.map +0 -1
package/build/three.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three.js","names":[],"sources":["../src/viewer/geometry.ts","../src/viewer/theme.ts","../src/viewer/fade.ts","../src/viewer/view.ts","../src/viewer/model.ts","../src/viewer/content.ts","../src/viewer/outlets.ts","../src/viewer/viewer.ts"],"sourcesContent":["import { transformPoint3, type Point3, type Rotation3 } from \"@mark1russell7/layout-contract\";\nimport { BoxGeometry, ExtrudeGeometry, Shape, Vector2, type BufferGeometry } from \"three\";\nimport type { Solid } from \"../solids.ts\";\n\n/**\n * The three.js geometry of a solid, and its place in the room.\n * The origin of the geometry is the center of the solid. Thus three.js puts clear solids in the correct sequence.\n */\nexport interface SolidPlacement {\n /** The geometry, in meters, around its own origin. The caller disposes it. */\n readonly geometry: BufferGeometry;\n /** The position of the origin of the geometry in the room, where the z axis points up. */\n readonly position: Point3;\n /** The rotation of the geometry in the room. */\n readonly rotation: Rotation3;\n}\n\n/** The rotation that changes no direction. */\nconst NO_ROTATION: Rotation3 = { x: 0, y: 0, z: 0, w: 1 };\n\n/**\n * This function gives the three.js geometry of a solid, with its place in the room.\n *\n * A mesh with this geometry, this position and this rotation is in the space of the room: the z axis points up.\n * Put the mesh in a group with the rotation of `TO_Y_UP`. Then three.js shows it with the y axis up.\n */\nexport function solidGeometry(solid: Solid): SolidPlacement {\n const shape = solid.shape;\n if (shape.kind === \"box\") {\n const { box, transform } = shape;\n const center = { x: box.x + box.w / 2, y: box.y + box.h / 2, z: box.z + box.d / 2 };\n return { geometry: new BoxGeometry(box.w, box.h, box.d), position: transformPoint3(transform, center), rotation: transform.rotation };\n }\n let minX = Infinity;\n let maxX = -Infinity;\n let minY = Infinity;\n let maxY = -Infinity;\n for (const [x, y] of shape.ring) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n const centerX = (minX + maxX) / 2;\n const centerY = (minY + maxY) / 2;\n const outline = new Shape(shape.ring.map(([x, y]) => new Vector2(x - centerX, y - centerY)));\n const geometry = new ExtrudeGeometry(outline, { depth: shape.d, bevelEnabled: false, steps: 1, curveSegments: 1 });\n geometry.translate(0, 0, 0 - shape.d / 2);\n return { geometry, position: { x: centerX, y: centerY, z: shape.z + shape.d / 2 }, rotation: NO_ROTATION };\n}\n","import type { LoadLevel } from \"../loads.ts\";\n\n/**\n * The colors of a viewer. Each color is a CSS hex color, for example `#22364a`.\n * The viewer has no background: the page shows behind the model.\n */\nexport interface ViewerTheme {\n /** The color of the edges of each solid. */\n readonly edge: string;\n /** The color that marks the solids under the pointer and the selected solids. */\n readonly accent: string;\n readonly floor: string;\n readonly wall: string;\n readonly glass: string;\n /** The part of the glass that is not clear, from 0 to 1. */\n readonly glassOpacity: number;\n /** The color of an outlet with no circuit. */\n readonly outlet: string;\n /** The color of the marks of each level, and of the plates of the outlets of a circuit at each level of its load. */\n readonly levels: Readonly<Record<LoadLevel, string>>;\n /** The color of the line around the sign of a mark. It is the color of the page, so a sign is clear on each solid. */\n readonly halo: string;\n /**\n * The colors of a field mark, from the value `min` of its scale to the value `max`.\n * A theme with no such list gives a field the color of its level.\n */\n readonly field?: readonly string[] | undefined;\n /** The part of a field mark that is not clear, from 0 to 1. The default is 0.8. */\n readonly fieldOpacity?: number | undefined;\n /** The color of a placed object whose kind has no color in `objects`. */\n readonly object: string;\n /** The color of the placed objects of each kind. The key is the field `kind` of a placed object. */\n readonly objects: Readonly<Record<string, string>>;\n /** The color of the light from above. */\n readonly sky: string;\n /** The color of the light from below. */\n readonly ground: string;\n}\n\n/** The colors of a model of white card with ink edges, for a light page. */\nexport const LIGHT_THEME: ViewerTheme = {\n edge: \"#22364a\",\n accent: \"#f2b705\",\n floor: \"#dfe5ea\",\n wall: \"#fcfcfb\",\n glass: \"#8fc4e8\",\n glassOpacity: 0.35,\n outlet: \"#55677a\",\n levels: { unknown: \"#55677a\", ok: \"#1f5fa8\", near: \"#d9662f\", over: \"#c62f2f\" },\n halo: \"#ffffff\",\n object: \"#b8c0c8\",\n objects: { desk: \"#c9b596\", sofa: \"#8fa3b5\", rack: \"#3d4954\", computer: \"#5b6d7e\", display: \"#2c3640\" },\n sky: \"#ffffff\",\n ground: \"#b9c3cd\",\n};\n\n/** The colors of a blueprint, for a dark page. */\nexport const DARK_THEME: ViewerTheme = {\n edge: \"#cfe6ff\",\n accent: \"#ffd24a\",\n floor: \"#17395a\",\n wall: \"#1f4a73\",\n glass: \"#9fd0ff\",\n glassOpacity: 0.25,\n outlet: \"#a9bfd4\",\n levels: { unknown: \"#a9bfd4\", ok: \"#6fb3f2\", near: \"#f5a962\", over: \"#f0625f\" },\n halo: \"#0e2740\",\n object: \"#2a5580\",\n objects: { desk: \"#2a5a8a\", sofa: \"#28527c\", rack: \"#16324e\", computer: \"#3a74ad\", display: \"#122a42\" },\n sky: \"#ffffff\",\n ground: \"#7f9bb8\",\n};\n","import { pointInRing, type Point, type Point3, type Ring } from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallHasOutline, wallPoint, type WallFrame } from \"../frames.ts\";\nimport type { Room } from \"../room.ts\";\nimport { metersPer } from \"../units.ts\";\n\n/** The side of a wall that looks at the room. A wall between two parts of a room has the value `both`. */\nexport type InnerSide = \"left\" | \"right\" | \"both\";\n\n/** A wall, and the side of it that looks at the room. */\nexport interface WallShade {\n readonly frame: WallFrame;\n readonly inner: InnerSide;\n}\n\n/** The distance from a face of a wall to the points that find the floor, in meters. */\nconst PROBE = 0.05;\n\n/** A wall hides the room when it hides a strip of the floor that is deeper than this, in meters. */\nexport const HIDDEN_LIMIT = 0.3;\n\n/** This function gives the distance of a point of the plan across a wall. It is positive to the left of the line of the wall. */\nfunction across(frame: WallFrame, point: Point): number {\n return (point.x - frame.start.x) * frame.left.x + (point.y - frame.start.y) * frame.left.y;\n}\n\n/** This function tells if a floor is next to one face of a wall. `offset` is the distance across of points near that face. */\nfunction hasFloor(frame: WallFrame, offset: number, floors: readonly Ring[]): boolean {\n return [0.25, 0.5, 0.75].some((part) => {\n const point = wallPoint(frame, frame.length * part, offset);\n return floors.some((ring) => pointInRing(point.x, point.y, ring));\n });\n}\n\n/**\n * This function gives each wall that the model makes, with the side that looks at the room.\n *\n * A side looks at the room when a floor is next to it. For a wall with no floor on each side, the side is the side of `center`,\n * a point of the plan in meters. Without a center, such a wall has the value `both`.\n */\nexport function wallShades(room: Room, center?: Point): readonly WallShade[] {\n const scale = metersPer(room.unit);\n const floors = (room.floors ?? []).map((floor): Ring => floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n return wallFrames(room)\n .filter((frame) => wallHasOutline(frame))\n .map((frame): WallShade => {\n const left = hasFloor(frame, frame.leftOffset + PROBE, floors);\n const right = hasFloor(frame, frame.rightOffset - PROBE, floors);\n if (left !== right) return { frame, inner: left ? \"left\" : \"right\" };\n if (left || center === undefined) return { frame, inner: \"both\" };\n const side = across(frame, center);\n return { frame, inner: side > frame.leftOffset ? \"left\" : side < frame.rightOffset ? \"right\" : \"both\" };\n });\n}\n\n/**\n * This function gives the depth of the strip of the floor that a wall hides from a camera, in meters.\n *\n * `camera` is a point of the room in meters, with the z axis up. A camera above the wall, between its two faces, hides no strip.\n * A camera that is not above the top of the wall hides all of the floor behind the wall, and the depth is `Infinity`.\n */\nexport function hiddenDepth(frame: WallFrame, camera: Point3): number {\n const side = across(frame, camera);\n const gap = side > frame.leftOffset ? side - frame.leftOffset : side < frame.rightOffset ? frame.rightOffset - side : 0;\n if (!(gap > 0)) return 0;\n return camera.z > frame.height ? (frame.height * gap) / (camera.z - frame.height) : Infinity;\n}\n\n/**\n * This function gives the `id` of each wall that hides the room from a camera. A viewer makes these walls almost clear.\n *\n * A wall with one side to the room hides the room when the camera is on its other side.\n * A wall between two parts of a room hides the part behind it from each side.\n * `limit` is the depth of the hidden strip of the floor, in meters, above which a wall hides the room.\n */\nexport function hidingWalls(shades: readonly WallShade[], camera: Point3, limit: number = HIDDEN_LIMIT): ReadonlySet<string> {\n const hiding = new Set<string>();\n for (const { frame, inner } of shades) {\n const side = across(frame, camera);\n const cameraSide = side > frame.leftOffset ? \"left\" : side < frame.rightOffset ? \"right\" : undefined;\n if (cameraSide === undefined || cameraSide === inner) continue;\n if (hiddenDepth(frame, camera) > limit) hiding.add(frame.id);\n }\n return hiding;\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport type { ViewAngles } from \"@mark1russell7/visuals\";\n\n// The space of the viewer has the y axis up. The x axis is the x axis of the plan, and the negative z axis is the y axis of the plan.\n// At an azimuth of 0, the camera is south of the room and it looks north. At a polar angle of 0, it looks down from above.\n\n/** The view of a dollhouse: from the south-east, 38 degrees above the floor. */\nexport const HOME_VIEW: ViewAngles = { polar: (52 * Math.PI) / 180, azimuth: (35 * Math.PI) / 180 };\n\n/** The view of a plan: from above, with north at the top. */\nexport const TOP_VIEW: ViewAngles = { polar: 0, azimuth: 0 };\n\n/** This function gives a point of the room in the space of the viewer: the z axis of the room becomes the y axis. */\nexport function toViewer(point: Point3): Point3 {\n return { x: point.x, y: point.z, z: 0 - point.y };\n}\n\n/** This function gives a point of the viewer in the space of the room: the y axis of the viewer becomes the z axis. */\nexport function toRoom(point: Point3): Point3 {\n return { x: point.x, y: 0 - point.z, z: point.y };\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport type { Highlight } from \"@mark1russell7/visuals\";\nimport { Color, EdgesGeometry, Group, Mesh, MeshLambertMaterial, type BufferGeometry, type Material } from \"three\";\nimport { LineMaterial } from \"three/addons/lines/LineMaterial.js\";\nimport { LineSegments2 } from \"three/addons/lines/LineSegments2.js\";\nimport { LineSegmentsGeometry } from \"three/addons/lines/LineSegmentsGeometry.js\";\nimport { solidRecord } from \"../check.ts\";\nimport { outletLevels, type LoadLevel, type LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport { boundsOfSolids, sceneSolids, solidCorners, TO_Y_UP, type Solid, type SolidKind, type SolidOptions } from \"../solids.ts\";\nimport { metersPer } from \"../units.ts\";\nimport { wallShades, type WallShade } from \"./fade.ts\";\nimport { solidGeometry } from \"./geometry.ts\";\nimport type { ViewerTheme } from \"./theme.ts\";\nimport { toViewer } from \"./view.ts\";\n\n/** One solid of the model as three.js objects. */\nexport interface ModelPart {\n readonly solid: Solid;\n /** The name of the record of the solid, from `solidRecord`. Each part of one wall has the same name. */\n readonly record: string;\n /** The `id` of the wall that the part fades with: the wall itself, the wall of a window or the wall of an outlet. */\n readonly wall: string | undefined;\n /** The name of the record of the object that this object is in or on. */\n readonly holder: string | undefined;\n /** This value is true for an object with other objects in it. Such an object shows as a clear box. */\n readonly holds: boolean;\n /** The level of the circuit of an outlet. An outlet with no circuit has no level, and so has each other part. */\n readonly level: LoadLevel | undefined;\n readonly mesh: Mesh<BufferGeometry, MeshLambertMaterial>;\n readonly lines: LineSegments2;\n /** The fade of the part, from 0 for a solid part to 1 for a part that hides the room. The viewer changes it. */\n fade: number;\n}\n\n/** The model of a scene as three.js objects. */\nexport interface RoomModel {\n /** The group of each part. It has the rotation from the room to the space of the viewer. */\n readonly group: Group;\n readonly parts: readonly ModelPart[];\n /** Each corner of each solid, in the space of the viewer. */\n readonly corners: readonly Point3[];\n /** The center of the model, in the space of the viewer. */\n readonly center: Point3;\n /** The walls of the room, each with the side that looks at the room. */\n readonly shades: readonly WallShade[];\n}\n\n/** The width of the edges of each kind of solid, in CSS pixels. */\nconst EDGE_WIDTH: Readonly<Record<SolidKind, number>> = { floor: 1.25, wall: 1.25, glass: 1, outlet: 1, object: 1.25 };\n\n/** The part of a clear box of objects that is not clear. */\nconst HOLDER_OPACITY = 0.14;\n\n/** A part with an opacity above this value writes its depth, as a solid part does. */\nconst SOLID_OPACITY = 0.999;\n\n/** This function gives the `id` of each placed object that has an object in its box. */\nfunction holders(scene: Scene): ReadonlySet<string> {\n const scale = metersPer(scene.room.unit);\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n const found = new Set<string>();\n for (const object of scene.objects ?? []) {\n const parent = object.parent === undefined ? undefined : objects.get(object.parent);\n if (parent === undefined) continue;\n const x = object.at[0] * scale;\n const y = object.at[1] * scale;\n const z = ((object.lift ?? 0) + object.size[2] / 2) * scale;\n const [w, h, d] = [parent.size[0] * scale, parent.size[1] * scale, parent.size[2] * scale];\n if (Math.abs(x) < w / 2 && Math.abs(y) < h / 2 && z > 0 && z < d) found.add(parent.id);\n }\n return found;\n}\n\n/**\n * This function makes the three.js objects of a scene: one mesh with its edges for each solid.\n * The parts have no colors until `paintPart` gives them. The caller disposes the model with `disposeModel`.\n */\nexport function buildModel(scene: Scene, options: SolidOptions = {}, loads: LoadOptions = {}): RoomModel {\n const solids = sceneSolids(scene, options);\n const levels = outletLevels(scene, loads);\n const wallOfOpening = new Map((scene.room.openings ?? []).map((opening) => [opening.id, opening.wall] as const));\n const wallOfOutlet = new Map((scene.room.outlets ?? []).map((outlet) => [outlet.id, outlet.wall] as const));\n const parentOf = new Map((scene.objects ?? []).map((object) => [object.id, object.parent] as const));\n const holding = holders(scene);\n const group = new Group();\n group.quaternion.set(TO_Y_UP.rotation.x, TO_Y_UP.rotation.y, TO_Y_UP.rotation.z, TO_Y_UP.rotation.w);\n const parts = solids.map((solid): ModelPart => {\n const { geometry, position, rotation } = solidGeometry(solid);\n const mesh = new Mesh(geometry, new MeshLambertMaterial({ polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 1 }));\n mesh.position.set(position.x, position.y, position.z);\n mesh.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);\n const edges = new EdgesGeometry(geometry, 30);\n const lines = new LineSegments2(new LineSegmentsGeometry().fromEdgesGeometry(edges), new LineMaterial({ linewidth: EDGE_WIDTH[solid.kind] }));\n edges.dispose();\n mesh.add(lines);\n group.add(mesh);\n const parent = solid.kind === \"object\" ? parentOf.get(solid.source) : undefined;\n return {\n solid,\n record: solidRecord(solid.kind, solid.source),\n wall: solid.kind === \"wall\" ? solid.source : solid.kind === \"glass\" ? wallOfOpening.get(solid.source) : solid.kind === \"outlet\" ? wallOfOutlet.get(solid.source) : undefined,\n holder: parent === undefined ? undefined : solidRecord(\"object\", parent),\n holds: solid.kind === \"object\" && holding.has(solid.source),\n level: solid.kind === \"outlet\" ? levels.get(solid.source) : undefined,\n mesh,\n lines,\n fade: 0,\n };\n });\n // A pick uses the place of each mesh in the world before the first picture.\n group.updateMatrixWorld(true);\n const bounds = boundsOfSolids(solids);\n const middle = bounds === undefined ? { x: 0, y: 0, z: 0 } : { x: bounds.x + bounds.w / 2, y: bounds.y + bounds.h / 2, z: bounds.z + bounds.d / 2 };\n return {\n group,\n parts,\n corners: solids.flatMap((solid) => solidCorners(solid).map((corner) => toViewer(corner))),\n center: toViewer(middle),\n shades: wallShades(scene.room, bounds === undefined ? undefined : middle),\n };\n}\n\n/** This function sets the opacity of a material. A material that is not solid does not write its depth. */\nfunction setOpacity(material: Material, opacity: number): void {\n const clear = opacity < SOLID_OPACITY;\n if (material.transparent !== clear) {\n material.transparent = clear;\n material.depthWrite = !clear;\n material.needsUpdate = true;\n }\n material.opacity = opacity;\n}\n\n/** This function gives the color of a part in a theme, before a mark. */\nfunction baseColor(part: ModelPart, scene: Scene, theme: ViewerTheme): string {\n const kind = part.solid.kind;\n if (kind === \"outlet\") return part.level === undefined ? theme.outlet : theme.levels[part.level];\n if (kind !== \"object\") return theme[kind];\n const object = (scene.objects ?? []).find((candidate) => candidate.id === part.solid.source);\n return (object === undefined ? undefined : theme.objects[object.kind]) ?? theme.object;\n}\n\n/**\n * This function gives a part its colors: the colors of the theme, the fade of the part and its highlight.\n * A part with a highlight has some of the color `accent` of the theme, and a selected part has wide edges.\n * An outlet has the color of the level of its circuit.\n */\nexport function paintPart(part: ModelPart, scene: Scene, theme: ViewerTheme, mark: Highlight): void {\n const kind = part.solid.kind;\n const fill = part.mesh.material;\n const ink = part.lines.material;\n const color = baseColor(part, scene, theme);\n fill.color.set(color);\n if (mark !== 0) fill.color.lerp(new Color(theme.accent), mark === 2 ? 0.55 : 0.3);\n ink.color.set(theme.edge);\n ink.linewidth = EDGE_WIDTH[kind] * (mark === 2 ? 2 : 1);\n const still = 1 - part.fade;\n let opacity = kind === \"glass\" ? theme.glassOpacity : part.holds ? (mark === 0 ? HOLDER_OPACITY : 0.45) : 1;\n let edge = 1;\n if (kind === \"wall\") {\n opacity *= 0.08 + 0.92 * still;\n edge = 0.3 + 0.7 * still;\n } else if (kind === \"glass\" || kind === \"outlet\") {\n opacity *= 0.35 + 0.65 * still;\n edge = 0.35 + 0.65 * still;\n }\n setOpacity(fill, opacity);\n setOpacity(ink, edge);\n}\n\n/** This function releases the memory of the graphics card that a model uses. */\nexport function disposeModel(model: RoomModel): void {\n for (const part of model.parts) {\n part.mesh.geometry.dispose();\n part.mesh.material.dispose();\n part.lines.geometry.dispose();\n part.lines.material.dispose();\n }\n model.group.clear();\n}\n","import type { Highlight } from \"@mark1russell7/visuals\";\nimport type { StageContent, StageFrame, StagePick } from \"@mark1russell7/visuals/three\";\nimport type { Object3D, Raycaster } from \"three\";\nimport type { LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport type { Solid, SolidKind, SolidOptions } from \"../solids.ts\";\nimport { hidingWalls } from \"./fade.ts\";\nimport { buildModel, disposeModel, paintPart, type ModelPart } from \"./model.ts\";\nimport type { ViewerTheme } from \"./theme.ts\";\nimport { toRoom } from \"./view.ts\";\n\n/** A record of a scene that the viewer shows: a floor, a wall, a window, an outlet or a placed object. */\nexport interface ViewerRecord {\n /** The kind of the solids of the record. A window has the kind `glass`. */\n readonly kind: SolidKind;\n /** The `id` of the record in the scene. */\n readonly source: string;\n}\n\n/** The solid under the pointer, with its record. */\nexport interface ViewerPick extends ViewerRecord {\n /** The `id` of the solid. A wall with openings has more than one solid. */\n readonly solid: string;\n}\n\n/** The content of a stage that shows the solids of a scene. The value of a pick is the solid. */\nexport interface RoomContent extends StageContent<ViewerPick, ViewerTheme> {\n /** The solids of the scene. */\n readonly solids: readonly Solid[];\n /** This function gives the first solid of a record with a name, as a pick. A name of no record of the content gives `undefined`. */\n pickOf(record: string): ViewerPick | undefined;\n}\n\n/** The time in which a wall goes most of the way to clear or to solid, in seconds. */\nexport const FADE_TIME = 0.11;\n\n/**\n * This function makes the content of a stage that shows the solids of a scene.\n * The solids are the floors, the walls, the windows, the plates of the outlets and the placed objects.\n *\n * The walls between the camera and the room become almost clear, and the pointer goes through them.\n * An object in a clear box of objects gets the pick before the box. Each pick has its distance, so a mark in front of a solid gets the pick.\n * The space of the content has the y axis up: the z axis of the scene becomes the y axis.\n */\nexport function createRoomContent(scene: Scene, solids: SolidOptions = {}, loads: LoadOptions = {}): RoomContent {\n const model = buildModel(scene, solids, loads);\n const first = new Map<string, ModelPart>();\n for (const part of model.parts) if (!first.has(part.record)) first.set(part.record, part);\n const byMesh = new Map<Object3D, ModelPart>(model.parts.map((part) => [part.mesh, part]));\n const pickOfPart = (part: ModelPart): ViewerPick => ({ solid: part.solid.id, kind: part.solid.kind, source: part.solid.source });\n\n /** The walls that hide the room from the camera of the last step. */\n let hiding: ReadonlySet<string> = new Set();\n let theme: ViewerTheme | undefined;\n let highlightOf: (record: string) => Highlight = () => 0;\n const paintOne = (part: ModelPart): void => {\n if (theme !== undefined) paintPart(part, scene, theme, highlightOf(part.record));\n };\n\n return {\n objects: [model.group],\n extent: { corners: model.corners, center: model.center },\n solids: model.parts.map((part) => part.solid),\n has: (record) => first.has(record),\n pickOf(record): ViewerPick | undefined {\n const part = first.get(record);\n return part === undefined ? undefined : pickOfPart(part);\n },\n pick(ray: Raycaster): StagePick<ViewerPick> | undefined {\n // A wall that hides the room is clear, and the pointer goes through it.\n const open = model.parts.filter((part) => part.wall === undefined || !hiding.has(part.wall)).map((part) => part.mesh);\n const hits = ray.intersectObjects(open, false);\n const nearest = hits[0];\n const found = nearest === undefined ? undefined : byMesh.get(nearest.object);\n if (nearest === undefined || found === undefined) return undefined;\n if (found.holds) {\n // A clear box of objects: the pointer selects an object in the box before the box.\n for (const hit of hits) {\n const part = byMesh.get(hit.object);\n if (part !== undefined && part.holder === found.record) return { record: part.record, value: pickOfPart(part), distance: hit.distance };\n }\n }\n return { record: found.record, value: pickOfPart(found), distance: nearest.distance };\n },\n paint(nextTheme, highlight): void {\n theme = nextTheme;\n highlightOf = highlight;\n for (const part of model.parts) paintOne(part);\n },\n step(frame: StageFrame): boolean {\n hiding = hidingWalls(model.shades, toRoom(frame.camera.position));\n // Each wall goes to its goal: clear for a wall that hides the room, solid for each other wall.\n const rate = frame.settle ? 1 : 1 - Math.exp(0 - frame.seconds / FADE_TIME);\n let active = false;\n for (const part of model.parts) {\n if (part.wall === undefined) continue;\n const goal = hiding.has(part.wall) ? 1 : 0;\n if (part.fade === goal) continue;\n const next = part.fade + (goal - part.fade) * rate;\n part.fade = Math.abs(goal - next) < 0.01 ? goal : next;\n paintOne(part);\n active = active || part.fade !== goal;\n }\n return active;\n },\n dispose(): void {\n disposeModel(model);\n },\n };\n}\n","import { addPoints3, scalePoint3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport type { LinkMark, Mark, PointMark } from \"@mark1russell7/visuals/marks\";\nimport { sceneSpace } from \"../anchors.ts\";\nimport { recordName } from \"../check.ts\";\nimport { outletLevels, type LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport { OUTLET_PLATE, solidCorners, type Solid } from \"../solids.ts\";\n\n/** This function gives the center of a solid, in the space of the scene: the mean of its corners. */\nfunction centerOf(solid: Solid): Point3 {\n const corners = solidCorners(solid);\n const sum = corners.reduce((total, corner) => addPoints3(total, corner), { x: 0, y: 0, z: 0 });\n return scalePoint3(sum, 1 / Math.max(corners.length, 1));\n}\n\n/**\n * This function gives the marks of the outlets of a scene, in the space of the scene: meters, with the z axis up.\n *\n * - An outlet gives a point on the front of its plate. Its level is the level of its circuit, and `unknown` for no circuit of the room.\n * - A placed object with an outlet gives a link from that outlet to the center of the object.\n *\n * The record name of a point is the name of the record of its outlet, so the sign and the plate are one record.\n * The record name of a link is the name of the record of its object: that record has the outlet.\n * `solids` are the solids of the scene. An outlet or an object with no solid gives no mark. The first record of an `id` gives the mark.\n */\nexport function outletMarks(scene: Scene, solids: readonly Solid[], loads: LoadOptions = {}): readonly Mark[] {\n const space = sceneSpace(scene);\n const levels = outletLevels(scene, loads);\n /** The first solid of each outlet and of each placed object, by the name of its record. */\n const made = new Map<string, Solid>();\n for (const solid of solids) {\n const name = recordName(solid.kind, solid.source);\n if ((solid.kind === \"outlet\" || solid.kind === \"object\") && !made.has(name)) made.set(name, solid);\n }\n const circuits = new Map((scene.room.circuits ?? []).map((circuit) => [circuit.id, circuit.name ?? circuit.id] as const));\n const marks: Mark[] = [];\n\n const fronts = new Map<string, Point3>();\n for (const outlet of scene.room.outlets ?? []) {\n if (fronts.has(outlet.id) || !made.has(recordName(\"outlet\", outlet.id))) continue;\n const frame = space.frame({ on: \"wall\", wall: outlet.wall, face: outlet.face, offset: outlet.offset, height: outlet.height });\n if (frame === undefined) continue;\n // The plate is on the face of the wall, so its front is one depth of the plate out of the wall.\n const front = addPoints3(frame.at, scalePoint3(frame.out, OUTLET_PLATE.depth));\n fronts.set(outlet.id, front);\n const level = levels.get(outlet.id);\n const circuit = level === undefined || outlet.circuit === undefined ? \"\" : `, circuit ${circuits.get(outlet.circuit) ?? outlet.circuit}`;\n const point: PointMark = {\n type: \"point\",\n record: recordName(\"outlet\", outlet.id),\n kind: \"outlet\",\n level: level ?? \"unknown\",\n label: `Outlet ${outlet.id}${circuit}`.replace(/\\s+/g, \" \").trim(),\n frame: { at: front, out: frame.out },\n };\n marks.push(point);\n }\n\n const linked = new Set<string>();\n for (const object of scene.objects ?? []) {\n const from = object.outlet === undefined ? undefined : fronts.get(object.outlet);\n const solid = made.get(recordName(\"object\", object.id));\n if (object.outlet === undefined || from === undefined || solid === undefined || linked.has(object.id)) continue;\n linked.add(object.id);\n const link: LinkMark = {\n type: \"link\",\n record: recordName(\"object\", object.id),\n kind: \"feed\",\n level: levels.get(object.outlet) ?? \"unknown\",\n label: `Outlet ${object.outlet} to ${object.name ?? object.id}`.replace(/\\s+/g, \" \").trim(),\n from: { record: recordName(\"outlet\", object.outlet), at: from },\n to: { record: recordName(\"object\", object.id), at: centerOf(solid) },\n };\n marks.push(link);\n }\n return marks;\n}\n","import { fitView } from \"@mark1russell7/visuals\";\nimport { createMarkers, type MarkersOptions, type MarkersTheme } from \"@mark1russell7/visuals/markers\";\nimport { checkMarks, transformMarks, type Mark } from \"@mark1russell7/visuals/marks\";\nimport { createStage, stackContents, type StageContent } from \"@mark1russell7/visuals/three\";\nimport { solidRecord } from \"../check.ts\";\nimport type { LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport { TO_Y_UP, type SolidOptions } from \"../solids.ts\";\nimport { createRoomContent, type ViewerPick, type ViewerRecord } from \"./content.ts\";\nimport { outletMarks } from \"./outlets.ts\";\nimport { LIGHT_THEME, type ViewerTheme } from \"./theme.ts\";\nimport { HOME_VIEW, TOP_VIEW } from \"./view.ts\";\n\nexport type { ViewerPick, ViewerRecord } from \"./content.ts\";\n\n/** The name of a view: `home` looks into the room from a corner above it, and `top` shows the plan. */\nexport type ViewName = \"home\" | \"top\";\n\n/** The options of a viewer. */\nexport interface RoomViewerOptions {\n readonly scene: Scene;\n /** The colors. The default is `LIGHT_THEME`. */\n readonly theme?: ViewerTheme | undefined;\n /** The options of the model. */\n readonly solids?: SolidOptions | undefined;\n /** The options of the levels of the circuits. */\n readonly loads?: LoadOptions | undefined;\n /** The options of the picture of the marks, for example the radius of a sign. */\n readonly markers?: MarkersOptions | undefined;\n /**\n * The marks of the scene, in the space of the scene: meters, with the z axis up. `layerMarks` of the entry `/marks` gives them.\n * With no list, the viewer makes the marks of the outlets of the scene. An empty list gives a picture with no mark.\n * The viewer draws no mark with a fault. `checkMarks` of `@mark1russell7/visuals/marks` tells each fault.\n */\n readonly marks?: readonly Mark[] | undefined;\n /** The name of the picture for a screen reader. */\n readonly label?: string | undefined;\n /**\n * The viewer starts this function when the pointer goes to a different record, or to no record.\n * `mark` is the mark under the pointer. `pick` is then the first solid of the record of the mark, or `undefined` for a record with no solid.\n */\n readonly onHover?: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined;\n /** The viewer starts this function when a person selects a record with the pointer, or selects no record. The parameters are those of `onHover`. */\n readonly onSelect?: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined;\n}\n\n/** A viewer of one scene in a page. */\nexport interface RoomViewer {\n /** The canvas of the viewer. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /**\n * This function shows a different scene, with its marks. The view stays if a person moved it.\n * With no list of marks, the viewer makes the marks of the outlets of the scene.\n */\n setScene(scene: Scene, marks?: readonly Mark[]): void;\n /** This function changes the colors. */\n setTheme(theme: ViewerTheme): void;\n /** This function moves the camera to a view that shows all of the model. */\n setView(view: ViewName): void;\n /**\n * This function highlights records, as the pointer does. An empty list removes the highlights.\n * A record is a record of a solid, or the record name of a mark, for example `electrical/1:nook-2`.\n */\n highlight(records: readonly (ViewerRecord | string)[]): void;\n /** This function selects one record, or no record. It does not start `onSelect`. */\n select(record: ViewerRecord | string | undefined): void;\n /**\n * This function shows only the marks that a test accepts, for example the marks of one kind. The pointer does not find a mark that the picture does not show.\n * The test stays for each subsequent scene. A test that accepts each mark shows all of them again.\n */\n showMarks(test: (mark: Mark) => boolean): void;\n /** This function removes the canvas and releases the memory of the graphics card. */\n dispose(): void;\n}\n\n/** The options of the content of a viewer: the options of the model, of the levels and of the picture of the marks. */\nexport type ViewerContentOptions = Pick<RoomViewerOptions, \"solids\" | \"loads\" | \"markers\">;\n\n/** The record under the pointer for the stage: a solid of the room, or a mark. */\nexport type StageValue = ViewerPick | Mark;\n\n/** This function gives the name of a record for the stage. */\nexport function nameOf(record: ViewerRecord | string): string {\n return typeof record === \"string\" ? record : solidRecord(record.kind, record.source);\n}\n\n/**\n * This function makes a function that gives the colors of the marks of a viewer theme.\n * The marks paint each field again for a new theme object. So the function gives the same object while the viewer theme is the same.\n * A theme with no colors of a field gives a field the color of its level.\n */\nexport function marksThemes(): (theme: ViewerTheme) => MarkersTheme {\n let from: ViewerTheme | undefined;\n let to: MarkersTheme | undefined;\n return (theme) => {\n if (to === undefined || theme !== from) {\n to = { sky: theme.sky, ground: theme.ground, levels: theme.levels, halo: theme.halo, accent: theme.accent, field: theme.field ?? [], fieldOpacity: theme.fieldOpacity };\n }\n from = theme;\n return to;\n };\n}\n\n/** The content of a viewer for one scene, with the functions that use its marks. */\nexport interface ViewerContent {\n /** The solids of the scene, and its marks above them. */\n readonly content: StageContent<StageValue, ViewerTheme>;\n /** This function shows only the marks that a test accepts. The test gets each mark as the scene has it. */\n show(test: (mark: Mark) => boolean): void;\n /**\n * This function gives a record of the stage as a page gets it.\n * A mark gives the first solid of its record and the mark as the scene has it. A solid gives the solid.\n */\n told(value: StageValue | undefined): readonly [pick: ViewerPick | undefined, mark: Mark | undefined];\n}\n\n/**\n * This function makes the content of a viewer for a scene: the solids, and the marks above them.\n *\n * `marks` are in the space of the scene: meters, with the z axis up. With no list, the function makes the marks of the outlets of the scene.\n * A mark with a fault is not in the content. The space of the content has the y axis up.\n */\nexport function createViewerContent(scene: Scene, marks?: readonly Mark[], options: ViewerContentOptions = {}): ViewerContent {\n const room = createRoomContent(scene, options.solids, options.loads);\n const given = marks ?? outletMarks(scene, room.solids, options.loads);\n const faulty = new Set(checkMarks(given).map((fault) => fault.index));\n const good = given.filter((_, index) => !faulty.has(index));\n const onStage = transformMarks(good, TO_Y_UP);\n /** The mark of the scene for each mark of the stage. */\n const inScene = new Map<Mark, Mark>(onStage.map((mark, index) => [mark, good[index] ?? mark]));\n const sceneMark = (mark: Mark): Mark => inScene.get(mark) ?? mark;\n const markers = createMarkers(onStage, options.markers);\n const themeOf = marksThemes();\n const above: StageContent<StageValue, ViewerTheme> = {\n objects: markers.objects,\n extent: markers.extent,\n has: (record) => markers.has(record),\n pick: (ray) => markers.pick(ray),\n paint(theme, highlight): void {\n markers.paint(themeOf(theme), highlight);\n },\n step: (frame) => markers.step?.(frame) ?? false,\n dispose(): void {\n markers.dispose();\n },\n };\n return {\n content: stackContents<StageValue, ViewerTheme>([room, above]),\n show(test): void {\n markers.show((mark) => test(sceneMark(mark)));\n },\n told(value) {\n if (value === undefined) return [undefined, undefined];\n return \"type\" in value ? [room.pickOf(value.record), sceneMark(value)] : [value, undefined];\n },\n };\n}\n\n/**\n * This function makes a viewer of a scene in a container of a page. The viewer fills the container, so give the container a size.\n *\n * A person turns the model with a drag, and moves nearer with the wheel after a click in the picture.\n * The walls between the camera and the room become almost clear. A click selects the record of a solid or of a mark.\n * With the keyboard, the arrow keys turn the model, `+` and `-` change the distance, `Home` shows the first view and `T` shows the plan.\n *\n * The viewer draws the marks of the scene with `@mark1russell7/visuals/markers`. A point is a sign with the color and the shape of its level.\n * With no list of marks, each outlet has a sign. An outlet or an object with a highlight then shows a line from the outlet to each object on it.\n *\n * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.\n */\nexport function createRoomViewer(container: HTMLElement, options: RoomViewerOptions): RoomViewer | undefined {\n let accepted: (mark: Mark) => boolean = () => true;\n let current = createViewerContent(options.scene, options.marks, options);\n /** This function gives a record of the stage to a function of the page. */\n const tell = (to: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined, value: StageValue | undefined): void => {\n if (to === undefined) return;\n const [pick, mark] = current.told(value);\n if (mark === undefined) to(pick);\n else to(pick, mark);\n };\n\n const stage = createStage<StageValue, ViewerTheme>(container, {\n content: current.content,\n theme: options.theme ?? LIGHT_THEME,\n label: options.label ?? \"3D model of the room\",\n views: { home: fitView(HOME_VIEW), top: fitView(TOP_VIEW) },\n home: \"home\",\n keys: { t: \"top\" },\n onHover: (value) => tell(options.onHover, value),\n onSelect: (value) => tell(options.onSelect, value),\n });\n if (stage === undefined) {\n current.content.dispose();\n return undefined;\n }\n\n return {\n canvas: stage.canvas,\n setScene(scene: Scene, marks?: readonly Mark[]): void {\n current = createViewerContent(scene, marks, options);\n current.show(accepted);\n stage.setContent(current.content);\n },\n setTheme(theme: ViewerTheme): void {\n stage.setTheme(theme);\n },\n setView(view: ViewName): void {\n stage.setView(view);\n },\n highlight(records: readonly (ViewerRecord | string)[]): void {\n stage.highlight(records.map(nameOf));\n },\n select(record: ViewerRecord | string | undefined): void {\n stage.select(record === undefined ? undefined : nameOf(record));\n },\n showMarks(test: (mark: Mark) => boolean): void {\n accepted = test;\n current.show(test);\n stage.refresh();\n },\n dispose(): void {\n stage.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,cAAyB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;;;;;;;AAQxD,SAAgB,cAAc,OAA8B;CAC1D,MAAM,QAAQ,MAAM;CACpB,IAAI,MAAM,SAAS,OAAO;EACxB,MAAM,EAAE,KAAK,cAAc;EAC3B,MAAM,SAAS;GAAE,GAAG,IAAI,IAAI,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI,IAAI,IAAI;EAAE;EAClF,OAAO;GAAE,UAAU,IAAI,YAAY,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;GAAG,UAAU,gBAAgB,WAAW,MAAM;GAAG,UAAU,UAAU;EAAS;CACtI;CACA,IAAI,OAAO;CACX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;CACpB;CAEA,MAAM,QAAQ,YAAqC,WAAW;EAC5D,SAAS,QAAQ;EACjB,OAAO,QAAQ,SAAS;EACxB,OAAO,QAAQ,SAAS;EACxB,OAAO;GAAE,MAAM,QAAQ,SAAS;GAAG,KAAK,QAAQ,QAAQ;EAAE;EAC1D,MAAM;EACN,MAAM,EAAE,GAAG,MAAM;EACjB,UAAU,UAAU,KAAK,QAAQ,SAAS,KAAK;EAC/C,WAAW,UAAU,KAAK,QAAQ,UAAU,KAAK;CACnD,CAAC;CACD,IAAI,UAAU,KAAA,GAAW;EACvB,QAAQ,QAAQ,QAAQ;EACxB;CACF;CAEA,OAAO;EACL,QAAQ,MAAM;EACd,SAAS,OAAc,OAA+B;GACpD,UAAU,oBAAoB,OAAO,OAAO,OAAO;GACnD,QAAQ,KAAK,QAAQ;GACrB,MAAM,WAAW,QAAQ,OAAO;EAClC;EACA,SAAS,OAA0B;GACjC,MAAM,SAAS,KAAK;EACtB;EACA,QAAQ,MAAsB;GAC5B,MAAM,QAAQ,IAAI;EACpB;EACA,UAAU,SAAmD;GAC3D,MAAM,UAAU,QAAQ,IAAI,MAAM,CAAC;EACrC;EACA,OAAO,QAAiD;GACtD,MAAM,OAAO,WAAW,KAAA,IAAY,KAAA,IAAY,OAAO,MAAM,CAAC;EAChE;EACA,UAAU,MAAqC;GAC7C,WAAW;GACX,QAAQ,KAAK,IAAI;GACjB,MAAM,QAAQ;EAChB;EACA,UAAgB;GACd,MAAM,QAAQ;EAChB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"three.js","names":[],"sources":["../src/viewer/geometry.ts","../src/viewer/theme.ts","../src/viewer/fade.ts","../src/viewer/view.ts","../src/viewer/model.ts","../src/viewer/content.ts","../src/viewer/outlets.ts","../src/viewer/viewer.ts"],"sourcesContent":["import { transformPoint3, type Point3, type Rotation3 } from \"@mark1russell7/layout-contract\";\nimport { BoxGeometry, ExtrudeGeometry, Shape, Vector2, type BufferGeometry } from \"three\";\nimport type { Solid } from \"../solids.ts\";\n\n/**\n * The three.js geometry of a solid, and its place in the room.\n * The origin of the geometry is the center of the solid. Thus three.js puts clear solids in the correct sequence.\n */\nexport interface SolidPlacement {\n /** The geometry, in meters, around its own origin. The caller disposes it. */\n readonly geometry: BufferGeometry;\n /** The position of the origin of the geometry in the room, where the z axis points up. */\n readonly position: Point3;\n /** The rotation of the geometry in the room. */\n readonly rotation: Rotation3;\n}\n\n/** The rotation that changes no direction. */\nconst NO_ROTATION: Rotation3 = { x: 0, y: 0, z: 0, w: 1 };\n\n/**\n * This function gives the three.js geometry of a solid, with its place in the room.\n *\n * A mesh with this geometry, this position and this rotation is in the space of the room: the z axis points up.\n * Put the mesh in a group with the rotation of `TO_Y_UP`. Then three.js shows it with the y axis up.\n */\nexport function solidGeometry(solid: Solid): SolidPlacement {\n const shape = solid.shape;\n if (shape.kind === \"box\") {\n const { box, transform } = shape;\n const center = { x: box.x + box.w / 2, y: box.y + box.h / 2, z: box.z + box.d / 2 };\n return { geometry: new BoxGeometry(box.w, box.h, box.d), position: transformPoint3(transform, center), rotation: transform.rotation };\n }\n let minX = Infinity;\n let maxX = -Infinity;\n let minY = Infinity;\n let maxY = -Infinity;\n for (const [x, y] of shape.ring) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n const centerX = (minX + maxX) / 2;\n const centerY = (minY + maxY) / 2;\n const outline = new Shape(shape.ring.map(([x, y]) => new Vector2(x - centerX, y - centerY)));\n const geometry = new ExtrudeGeometry(outline, { depth: shape.d, bevelEnabled: false, steps: 1, curveSegments: 1 });\n geometry.translate(0, 0, 0 - shape.d / 2);\n return { geometry, position: { x: centerX, y: centerY, z: shape.z + shape.d / 2 }, rotation: NO_ROTATION };\n}\n","import type { LoadLevel } from \"../loads.ts\";\n\n/**\n * The colors of a viewer. Each color is a CSS hex color, for example `#22364a`.\n * The viewer has no background: the page shows behind the model.\n */\nexport interface ViewerTheme {\n /** The color of the edges of each solid. */\n readonly edge: string;\n /** The color that marks the solids under the pointer and the selected solids. */\n readonly accent: string;\n readonly floor: string;\n readonly wall: string;\n readonly glass: string;\n /** The part of the glass that is not clear, from 0 to 1. */\n readonly glassOpacity: number;\n /** The color of an outlet with no circuit. */\n readonly outlet: string;\n /** The color of the marks of each level, and of the plates of the outlets of a circuit at each level of its load. */\n readonly levels: Readonly<Record<LoadLevel, string>>;\n /** The color of the line around the sign of a mark. It is the color of the page, so a sign is clear on each solid. */\n readonly halo: string;\n /**\n * The colors of a field mark, from the value `min` of its scale to the value `max`.\n * A theme with no such list gives a field the color of its level.\n */\n readonly field?: readonly string[] | undefined;\n /** The part of a field mark that is not clear, from 0 to 1. The default is 0.8. */\n readonly fieldOpacity?: number | undefined;\n /** The color of a placed object whose kind has no color in `objects`. */\n readonly object: string;\n /** The color of the placed objects of each kind. The key is the field `kind` of a placed object. */\n readonly objects: Readonly<Record<string, string>>;\n /** The color of the light from above. */\n readonly sky: string;\n /** The color of the light from below. */\n readonly ground: string;\n}\n\n/** The colors of a model of white card with ink edges, for a light page. */\nexport const LIGHT_THEME: ViewerTheme = {\n edge: \"#22364a\",\n accent: \"#f2b705\",\n floor: \"#dfe5ea\",\n wall: \"#fcfcfb\",\n glass: \"#8fc4e8\",\n glassOpacity: 0.35,\n outlet: \"#55677a\",\n levels: { unknown: \"#55677a\", ok: \"#1f5fa8\", near: \"#d9662f\", over: \"#c62f2f\" },\n halo: \"#ffffff\",\n object: \"#b8c0c8\",\n objects: { desk: \"#c9b596\", sofa: \"#8fa3b5\", rack: \"#3d4954\", computer: \"#5b6d7e\", display: \"#2c3640\" },\n sky: \"#ffffff\",\n ground: \"#b9c3cd\",\n};\n\n/** The colors of a blueprint, for a dark page. */\nexport const DARK_THEME: ViewerTheme = {\n edge: \"#cfe6ff\",\n accent: \"#ffd24a\",\n floor: \"#17395a\",\n wall: \"#1f4a73\",\n glass: \"#9fd0ff\",\n glassOpacity: 0.25,\n outlet: \"#a9bfd4\",\n levels: { unknown: \"#a9bfd4\", ok: \"#6fb3f2\", near: \"#f5a962\", over: \"#f0625f\" },\n halo: \"#0e2740\",\n object: \"#2a5580\",\n objects: { desk: \"#2a5a8a\", sofa: \"#28527c\", rack: \"#16324e\", computer: \"#3a74ad\", display: \"#122a42\" },\n sky: \"#ffffff\",\n ground: \"#7f9bb8\",\n};\n","import { pointInRing, type Point, type Point3, type Ring } from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallHasOutline, wallPoint, type WallFrame } from \"../frames.ts\";\nimport type { Room } from \"../room.ts\";\nimport { metersPer } from \"../units.ts\";\n\n/** The side of a wall that looks at the room. A wall between two parts of a room has the value `both`. */\nexport type InnerSide = \"left\" | \"right\" | \"both\";\n\n/** A wall, and the side of it that looks at the room. */\nexport interface WallShade {\n readonly frame: WallFrame;\n readonly inner: InnerSide;\n}\n\n/** The distance from a face of a wall to the points that find the floor, in meters. */\nconst PROBE = 0.05;\n\n/** A wall hides the room when it hides a strip of the floor that is deeper than this, in meters. */\nexport const HIDDEN_LIMIT = 0.3;\n\n/** This function gives the distance of a point of the plan across a wall. It is positive to the left of the line of the wall. */\nfunction across(frame: WallFrame, point: Point): number {\n return (point.x - frame.start.x) * frame.left.x + (point.y - frame.start.y) * frame.left.y;\n}\n\n/** This function tells if a floor is next to one face of a wall. `offset` is the distance across of points near that face. */\nfunction hasFloor(frame: WallFrame, offset: number, floors: readonly Ring[]): boolean {\n return [0.25, 0.5, 0.75].some((part) => {\n const point = wallPoint(frame, frame.length * part, offset);\n return floors.some((ring) => pointInRing(point.x, point.y, ring));\n });\n}\n\n/**\n * This function gives each wall that the model makes, with the side that looks at the room.\n *\n * A side looks at the room when a floor is next to it. For a wall with no floor on each side, the side is the side of `center`,\n * a point of the plan in meters. Without a center, such a wall has the value `both`.\n */\nexport function wallShades(room: Room, center?: Point): readonly WallShade[] {\n const scale = metersPer(room.unit);\n const floors = (room.floors ?? []).map((floor): Ring => floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n return wallFrames(room)\n .filter((frame) => wallHasOutline(frame))\n .map((frame): WallShade => {\n const left = hasFloor(frame, frame.leftOffset + PROBE, floors);\n const right = hasFloor(frame, frame.rightOffset - PROBE, floors);\n if (left !== right) return { frame, inner: left ? \"left\" : \"right\" };\n if (left || center === undefined) return { frame, inner: \"both\" };\n const side = across(frame, center);\n return { frame, inner: side > frame.leftOffset ? \"left\" : side < frame.rightOffset ? \"right\" : \"both\" };\n });\n}\n\n/**\n * This function gives the depth of the strip of the floor that a wall hides from a camera, in meters.\n *\n * `camera` is a point of the room in meters, with the z axis up. A camera above the wall, between its two faces, hides no strip.\n * A camera that is not above the top of the wall hides all of the floor behind the wall, and the depth is `Infinity`.\n */\nexport function hiddenDepth(frame: WallFrame, camera: Point3): number {\n const side = across(frame, camera);\n const gap = side > frame.leftOffset ? side - frame.leftOffset : side < frame.rightOffset ? frame.rightOffset - side : 0;\n if (!(gap > 0)) return 0;\n return camera.z > frame.height ? (frame.height * gap) / (camera.z - frame.height) : Infinity;\n}\n\n/**\n * This function gives the `id` of each wall that hides the room from a camera. A viewer makes these walls almost clear.\n *\n * A wall with one side to the room hides the room when the camera is on its other side.\n * A wall between two parts of a room hides the part behind it from each side.\n * `limit` is the depth of the hidden strip of the floor, in meters, above which a wall hides the room.\n */\nexport function hidingWalls(shades: readonly WallShade[], camera: Point3, limit: number = HIDDEN_LIMIT): ReadonlySet<string> {\n const hiding = new Set<string>();\n for (const { frame, inner } of shades) {\n const side = across(frame, camera);\n const cameraSide = side > frame.leftOffset ? \"left\" : side < frame.rightOffset ? \"right\" : undefined;\n if (cameraSide === undefined || cameraSide === inner) continue;\n if (hiddenDepth(frame, camera) > limit) hiding.add(frame.id);\n }\n return hiding;\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport type { ViewAngles } from \"@mark1russell7/visuals\";\n\n// The space of the viewer has the y axis up. The x axis is the x axis of the plan, and the negative z axis is the y axis of the plan.\n// At an azimuth of 0, the camera is south of the room and it looks north. At a polar angle of 0, it looks down from above.\n\n/** The view of a dollhouse: from the south-east, 38 degrees above the floor. */\nexport const HOME_VIEW: ViewAngles = { polar: (52 * Math.PI) / 180, azimuth: (35 * Math.PI) / 180 };\n\n/** The view of a plan: from above, with north at the top. */\nexport const TOP_VIEW: ViewAngles = { polar: 0, azimuth: 0 };\n\n/** This function gives a point of the room in the space of the viewer: the z axis of the room becomes the y axis. */\nexport function toViewer(point: Point3): Point3 {\n return { x: point.x, y: point.z, z: 0 - point.y };\n}\n\n/** This function gives a point of the viewer in the space of the room: the y axis of the viewer becomes the z axis. */\nexport function toRoom(point: Point3): Point3 {\n return { x: point.x, y: 0 - point.z, z: point.y };\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport type { Highlight } from \"@mark1russell7/visuals\";\nimport { Color, EdgesGeometry, Group, Mesh, MeshLambertMaterial, type BufferGeometry, type Material } from \"three\";\nimport { LineMaterial } from \"three/addons/lines/LineMaterial.js\";\nimport { LineSegments2 } from \"three/addons/lines/LineSegments2.js\";\nimport { LineSegmentsGeometry } from \"three/addons/lines/LineSegmentsGeometry.js\";\nimport { solidRecord } from \"../check.ts\";\nimport { outletLevels, type LoadLevel, type LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport { boundsOfSolids, sceneSolids, solidCorners, TO_Y_UP, type Solid, type SolidKind, type SolidOptions } from \"../solids.ts\";\nimport { metersPer } from \"../units.ts\";\nimport { wallShades, type WallShade } from \"./fade.ts\";\nimport { solidGeometry } from \"./geometry.ts\";\nimport type { ViewerTheme } from \"./theme.ts\";\nimport { toViewer } from \"./view.ts\";\n\n/** One solid of the model as three.js objects. */\nexport interface ModelPart {\n readonly solid: Solid;\n /** The name of the record of the solid, from `solidRecord`. Each part of one wall has the same name. */\n readonly record: string;\n /** The `id` of the wall that the part fades with: the wall itself, the wall of a window or the wall of an outlet. */\n readonly wall: string | undefined;\n /** The name of the record of the object that this object is in or on. */\n readonly holder: string | undefined;\n /** This value is true for an object with other objects in it. Such an object shows as a clear box. */\n readonly holds: boolean;\n /** The level of the circuit of an outlet. An outlet with no circuit has no level, and so has each other part. */\n readonly level: LoadLevel | undefined;\n readonly mesh: Mesh<BufferGeometry, MeshLambertMaterial>;\n readonly lines: LineSegments2;\n /** The fade of the part, from 0 for a solid part to 1 for a part that hides the room. The viewer changes it. */\n fade: number;\n}\n\n/** The model of a scene as three.js objects. */\nexport interface RoomModel {\n /** The group of each part. It has the rotation from the room to the space of the viewer. */\n readonly group: Group;\n readonly parts: readonly ModelPart[];\n /** Each corner of each solid, in the space of the viewer. */\n readonly corners: readonly Point3[];\n /** The center of the model, in the space of the viewer. */\n readonly center: Point3;\n /** The walls of the room, each with the side that looks at the room. */\n readonly shades: readonly WallShade[];\n}\n\n/** The width of the edges of each kind of solid, in CSS pixels. */\nconst EDGE_WIDTH: Readonly<Record<SolidKind, number>> = { floor: 1.25, wall: 1.25, glass: 1, outlet: 1, object: 1.25 };\n\n/** The part of a clear box of objects that is not clear. */\nconst HOLDER_OPACITY = 0.14;\n\n/** A part with an opacity above this value writes its depth, as a solid part does. */\nconst SOLID_OPACITY = 0.999;\n\n/** This function gives the `id` of each placed object that has an object in its box. */\nfunction holders(scene: Scene): ReadonlySet<string> {\n const scale = metersPer(scene.room.unit);\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n const found = new Set<string>();\n for (const object of scene.objects ?? []) {\n const parent = object.parent === undefined ? undefined : objects.get(object.parent);\n if (parent === undefined) continue;\n const x = object.at[0] * scale;\n const y = object.at[1] * scale;\n const z = ((object.lift ?? 0) + object.size[2] / 2) * scale;\n const [w, h, d] = [parent.size[0] * scale, parent.size[1] * scale, parent.size[2] * scale];\n if (Math.abs(x) < w / 2 && Math.abs(y) < h / 2 && z > 0 && z < d) found.add(parent.id);\n }\n return found;\n}\n\n/**\n * This function makes the three.js objects of a scene: one mesh with its edges for each solid.\n * The parts have no colors until `paintPart` gives them. The caller disposes the model with `disposeModel`.\n */\nexport function buildModel(scene: Scene, options: SolidOptions = {}, loads: LoadOptions = {}): RoomModel {\n const solids = sceneSolids(scene, options);\n const levels = outletLevels(scene, loads);\n const wallOfOpening = new Map((scene.room.openings ?? []).map((opening) => [opening.id, opening.wall] as const));\n const wallOfOutlet = new Map((scene.room.outlets ?? []).map((outlet) => [outlet.id, outlet.wall] as const));\n const parentOf = new Map((scene.objects ?? []).map((object) => [object.id, object.parent] as const));\n const holding = holders(scene);\n const group = new Group();\n group.quaternion.set(TO_Y_UP.rotation.x, TO_Y_UP.rotation.y, TO_Y_UP.rotation.z, TO_Y_UP.rotation.w);\n const parts = solids.map((solid): ModelPart => {\n const { geometry, position, rotation } = solidGeometry(solid);\n const mesh = new Mesh(geometry, new MeshLambertMaterial({ polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 1 }));\n mesh.position.set(position.x, position.y, position.z);\n mesh.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);\n const edges = new EdgesGeometry(geometry, 30);\n const lines = new LineSegments2(new LineSegmentsGeometry().fromEdgesGeometry(edges), new LineMaterial({ linewidth: EDGE_WIDTH[solid.kind] }));\n edges.dispose();\n mesh.add(lines);\n group.add(mesh);\n const parent = solid.kind === \"object\" ? parentOf.get(solid.source) : undefined;\n return {\n solid,\n record: solidRecord(solid.kind, solid.source),\n wall: solid.kind === \"wall\" ? solid.source : solid.kind === \"glass\" ? wallOfOpening.get(solid.source) : solid.kind === \"outlet\" ? wallOfOutlet.get(solid.source) : undefined,\n holder: parent === undefined ? undefined : solidRecord(\"object\", parent),\n holds: solid.kind === \"object\" && holding.has(solid.source),\n level: solid.kind === \"outlet\" ? levels.get(solid.source) : undefined,\n mesh,\n lines,\n fade: 0,\n };\n });\n // A pick uses the place of each mesh in the world before the first picture.\n group.updateMatrixWorld(true);\n const bounds = boundsOfSolids(solids);\n const middle = bounds === undefined ? { x: 0, y: 0, z: 0 } : { x: bounds.x + bounds.w / 2, y: bounds.y + bounds.h / 2, z: bounds.z + bounds.d / 2 };\n return {\n group,\n parts,\n corners: solids.flatMap((solid) => solidCorners(solid).map((corner) => toViewer(corner))),\n center: toViewer(middle),\n shades: wallShades(scene.room, bounds === undefined ? undefined : middle),\n };\n}\n\n/** This function sets the opacity of a material. A material that is not solid does not write its depth. */\nfunction setOpacity(material: Material, opacity: number): void {\n const clear = opacity < SOLID_OPACITY;\n if (material.transparent !== clear) {\n material.transparent = clear;\n material.depthWrite = !clear;\n material.needsUpdate = true;\n }\n material.opacity = opacity;\n}\n\n/** This function gives the color of a part in a theme, before a mark. */\nfunction baseColor(part: ModelPart, scene: Scene, theme: ViewerTheme): string {\n const kind = part.solid.kind;\n if (kind === \"outlet\") return part.level === undefined ? theme.outlet : theme.levels[part.level];\n if (kind !== \"object\") return theme[kind];\n const object = (scene.objects ?? []).find((candidate) => candidate.id === part.solid.source);\n return (object === undefined ? undefined : theme.objects[object.kind]) ?? theme.object;\n}\n\n/**\n * This function gives a part its colors: the colors of the theme, the fade of the part and its highlight.\n * A part with a highlight has some of the color `accent` of the theme, and a selected part has wide edges.\n * An outlet has the color of the level of its circuit.\n */\nexport function paintPart(part: ModelPart, scene: Scene, theme: ViewerTheme, mark: Highlight): void {\n const kind = part.solid.kind;\n const fill = part.mesh.material;\n const ink = part.lines.material;\n const color = baseColor(part, scene, theme);\n fill.color.set(color);\n if (mark !== 0) fill.color.lerp(new Color(theme.accent), mark === 2 ? 0.55 : 0.3);\n ink.color.set(theme.edge);\n ink.linewidth = EDGE_WIDTH[kind] * (mark === 2 ? 2 : 1);\n const still = 1 - part.fade;\n let opacity = kind === \"glass\" ? theme.glassOpacity : part.holds ? (mark === 0 ? HOLDER_OPACITY : 0.45) : 1;\n let edge = 1;\n if (kind === \"wall\") {\n opacity *= 0.08 + 0.92 * still;\n edge = 0.3 + 0.7 * still;\n } else if (kind === \"glass\" || kind === \"outlet\") {\n opacity *= 0.35 + 0.65 * still;\n edge = 0.35 + 0.65 * still;\n }\n setOpacity(fill, opacity);\n setOpacity(ink, edge);\n}\n\n/** This function releases the memory of the graphics card that a model uses. */\nexport function disposeModel(model: RoomModel): void {\n for (const part of model.parts) {\n part.mesh.geometry.dispose();\n part.mesh.material.dispose();\n part.lines.geometry.dispose();\n part.lines.material.dispose();\n }\n model.group.clear();\n}\n","import type { Highlight } from \"@mark1russell7/visuals\";\nimport type { StageContent, StageFrame, StagePick } from \"@mark1russell7/visuals/three\";\nimport type { Object3D, Raycaster } from \"three\";\nimport type { LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport type { Solid, SolidKind, SolidOptions } from \"../solids.ts\";\nimport { hidingWalls } from \"./fade.ts\";\nimport { buildModel, disposeModel, paintPart, type ModelPart } from \"./model.ts\";\nimport type { ViewerTheme } from \"./theme.ts\";\nimport { toRoom } from \"./view.ts\";\n\n/** A record of a scene that the viewer shows: a floor, a wall, a window, an outlet or a placed object. */\nexport interface ViewerRecord {\n /** The kind of the solids of the record. A window has the kind `glass`. */\n readonly kind: SolidKind;\n /** The `id` of the record in the scene. */\n readonly source: string;\n}\n\n/** The solid under the pointer, with its record. */\nexport interface ViewerPick extends ViewerRecord {\n /** The `id` of the solid. A wall with openings has more than one solid. */\n readonly solid: string;\n}\n\n/** The content of a stage that shows the solids of a scene. The value of a pick is the solid. */\nexport interface RoomContent extends StageContent<ViewerPick, ViewerTheme> {\n /** The solids of the scene. */\n readonly solids: readonly Solid[];\n /** This function gives the first solid of a record with a name, as a pick. A name of no record of the content gives `undefined`. */\n pickOf(record: string): ViewerPick | undefined;\n}\n\n/** The time in which a wall goes most of the way to clear or to solid, in seconds. */\nexport const FADE_TIME = 0.11;\n\n/**\n * This function makes the content of a stage that shows the solids of a scene.\n * The solids are the floors, the walls, the windows, the plates of the outlets and the placed objects.\n *\n * The walls between the camera and the room become almost clear, and the pointer goes through them.\n * An object in a clear box of objects gets the pick before the box. Each pick has its distance, so a mark in front of a solid gets the pick.\n * The space of the content has the y axis up: the z axis of the scene becomes the y axis.\n */\nexport function createRoomContent(scene: Scene, solids: SolidOptions = {}, loads: LoadOptions = {}): RoomContent {\n const model = buildModel(scene, solids, loads);\n const first = new Map<string, ModelPart>();\n for (const part of model.parts) if (!first.has(part.record)) first.set(part.record, part);\n const byMesh = new Map<Object3D, ModelPart>(model.parts.map((part) => [part.mesh, part]));\n const pickOfPart = (part: ModelPart): ViewerPick => ({ solid: part.solid.id, kind: part.solid.kind, source: part.solid.source });\n\n /** The walls that hide the room from the camera of the last step. */\n let hiding: ReadonlySet<string> = new Set();\n let theme: ViewerTheme | undefined;\n let highlightOf: (record: string) => Highlight = () => 0;\n const paintOne = (part: ModelPart): void => {\n if (theme !== undefined) paintPart(part, scene, theme, highlightOf(part.record));\n };\n\n return {\n objects: [model.group],\n extent: { corners: model.corners, center: model.center },\n solids: model.parts.map((part) => part.solid),\n has: (record) => first.has(record),\n pickOf(record): ViewerPick | undefined {\n const part = first.get(record);\n return part === undefined ? undefined : pickOfPart(part);\n },\n pick(ray: Raycaster): StagePick<ViewerPick> | undefined {\n // A wall that hides the room is clear, and the pointer goes through it.\n const open = model.parts.filter((part) => part.wall === undefined || !hiding.has(part.wall)).map((part) => part.mesh);\n const hits = ray.intersectObjects(open, false);\n const nearest = hits[0];\n const found = nearest === undefined ? undefined : byMesh.get(nearest.object);\n if (nearest === undefined || found === undefined) return undefined;\n if (found.holds) {\n // A clear box of objects: the pointer selects an object in the box before the box.\n for (const hit of hits) {\n const part = byMesh.get(hit.object);\n if (part !== undefined && part.holder === found.record) return { record: part.record, value: pickOfPart(part), distance: hit.distance };\n }\n }\n return { record: found.record, value: pickOfPart(found), distance: nearest.distance };\n },\n paint(nextTheme, highlight): void {\n theme = nextTheme;\n highlightOf = highlight;\n for (const part of model.parts) paintOne(part);\n },\n step(frame: StageFrame): boolean {\n hiding = hidingWalls(model.shades, toRoom(frame.camera.position));\n // Each wall goes to its goal: clear for a wall that hides the room, solid for each other wall.\n const rate = frame.settle ? 1 : 1 - Math.exp(0 - frame.seconds / FADE_TIME);\n let active = false;\n for (const part of model.parts) {\n if (part.wall === undefined) continue;\n const goal = hiding.has(part.wall) ? 1 : 0;\n if (part.fade === goal) continue;\n const next = part.fade + (goal - part.fade) * rate;\n part.fade = Math.abs(goal - next) < 0.01 ? goal : next;\n paintOne(part);\n active = active || part.fade !== goal;\n }\n return active;\n },\n dispose(): void {\n disposeModel(model);\n },\n };\n}\n","import { addPoints3, scalePoint3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport type { LinkMark, Mark, PointMark } from \"@mark1russell7/visuals/marks\";\nimport { sceneSpace } from \"../anchors.ts\";\nimport { recordName } from \"../check.ts\";\nimport { outletLevels, type LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport { OUTLET_PLATE, solidCorners, type Solid } from \"../solids.ts\";\n\n/** This function gives the center of a solid, in the space of the scene: the mean of its corners. */\nfunction centerOf(solid: Solid): Point3 {\n const corners = solidCorners(solid);\n const sum = corners.reduce((total, corner) => addPoints3(total, corner), { x: 0, y: 0, z: 0 });\n return scalePoint3(sum, 1 / Math.max(corners.length, 1));\n}\n\n/**\n * This function gives the marks of the outlets of a scene, in the space of the scene: meters, with the z axis up.\n *\n * - An outlet gives a point on the front of its plate. Its level is the level of its circuit, and `unknown` for no circuit of the room.\n * - A placed object with an outlet gives a link from that outlet to the center of the object.\n *\n * The record name of a point is the name of the record of its outlet, so the sign and the plate are one record.\n * The record name of a link is the name of the record of its object: that record has the outlet.\n * `solids` are the solids of the scene. An outlet or an object with no solid gives no mark. The first record of an `id` gives the mark.\n */\nexport function outletMarks(scene: Scene, solids: readonly Solid[], loads: LoadOptions = {}): readonly Mark[] {\n const space = sceneSpace(scene);\n const levels = outletLevels(scene, loads);\n /** The first solid of each outlet and of each placed object, by the name of its record. */\n const made = new Map<string, Solid>();\n for (const solid of solids) {\n const name = recordName(solid.kind, solid.source);\n if ((solid.kind === \"outlet\" || solid.kind === \"object\") && !made.has(name)) made.set(name, solid);\n }\n const circuits = new Map((scene.room.circuits ?? []).map((circuit) => [circuit.id, circuit.name ?? circuit.id] as const));\n const marks: Mark[] = [];\n\n const fronts = new Map<string, Point3>();\n for (const outlet of scene.room.outlets ?? []) {\n if (fronts.has(outlet.id) || !made.has(recordName(\"outlet\", outlet.id))) continue;\n const frame = space.frame({ on: \"wall\", wall: outlet.wall, face: outlet.face, offset: outlet.offset, height: outlet.height });\n if (frame === undefined) continue;\n // The plate is on the face of the wall, so its front is one depth of the plate out of the wall.\n const front = addPoints3(frame.at, scalePoint3(frame.out, OUTLET_PLATE.depth));\n fronts.set(outlet.id, front);\n const level = levels.get(outlet.id);\n const circuit = level === undefined || outlet.circuit === undefined ? \"\" : `, circuit ${circuits.get(outlet.circuit) ?? outlet.circuit}`;\n const point: PointMark = {\n type: \"point\",\n record: recordName(\"outlet\", outlet.id),\n kind: \"outlet\",\n level: level ?? \"unknown\",\n label: `Outlet ${outlet.id}${circuit}`.replace(/\\s+/g, \" \").trim(),\n frame: { at: front, out: frame.out },\n };\n marks.push(point);\n }\n\n const linked = new Set<string>();\n for (const object of scene.objects ?? []) {\n const from = object.outlet === undefined ? undefined : fronts.get(object.outlet);\n const solid = made.get(recordName(\"object\", object.id));\n if (object.outlet === undefined || from === undefined || solid === undefined || linked.has(object.id)) continue;\n linked.add(object.id);\n const link: LinkMark = {\n type: \"link\",\n record: recordName(\"object\", object.id),\n kind: \"feed\",\n level: levels.get(object.outlet) ?? \"unknown\",\n label: `Outlet ${object.outlet} to ${object.name ?? object.id}`.replace(/\\s+/g, \" \").trim(),\n from: { record: recordName(\"outlet\", object.outlet), at: from },\n to: { record: recordName(\"object\", object.id), at: centerOf(solid) },\n };\n marks.push(link);\n }\n return marks;\n}\n","import { fitView } from \"@mark1russell7/visuals\";\nimport { createMarkers, type MarkersOptions, type MarkersTheme } from \"@mark1russell7/visuals/markers\";\nimport { checkMarks, transformMarks, type Mark } from \"@mark1russell7/visuals/marks\";\nimport { createStage, stackContents, type StageContent } from \"@mark1russell7/visuals/three\";\nimport { solidRecord } from \"../check.ts\";\nimport type { LoadOptions } from \"../loads.ts\";\nimport type { Scene } from \"../room.ts\";\nimport { TO_Y_UP, type SolidOptions } from \"../solids.ts\";\nimport { createRoomContent, type ViewerPick, type ViewerRecord } from \"./content.ts\";\nimport { outletMarks } from \"./outlets.ts\";\nimport { LIGHT_THEME, type ViewerTheme } from \"./theme.ts\";\nimport { HOME_VIEW, TOP_VIEW } from \"./view.ts\";\n\nexport type { ViewerPick, ViewerRecord } from \"./content.ts\";\n\n/** The name of a view: `home` looks into the room from a corner above it, and `top` shows the plan. */\nexport type ViewName = \"home\" | \"top\";\n\n/** The options of a viewer. */\nexport interface RoomViewerOptions {\n readonly scene: Scene;\n /** The colors. The default is `LIGHT_THEME`. */\n readonly theme?: ViewerTheme | undefined;\n /** The options of the model. */\n readonly solids?: SolidOptions | undefined;\n /** The options of the levels of the circuits. */\n readonly loads?: LoadOptions | undefined;\n /** The options of the picture of the marks, for example the radius of a sign. */\n readonly markers?: MarkersOptions | undefined;\n /**\n * The marks of the scene, in the space of the scene: meters, with the z axis up. `layerMarks` of the entry `/marks` gives them.\n * With no list, the viewer makes the marks of the outlets of the scene. An empty list gives a picture with no mark.\n * The viewer draws no mark with a fault. `checkMarks` of `@mark1russell7/visuals/marks` tells each fault.\n */\n readonly marks?: readonly Mark[] | undefined;\n /** The name of the picture for a screen reader. */\n readonly label?: string | undefined;\n /**\n * The viewer starts this function when the pointer goes to a different record, or to no record.\n * `mark` is the mark under the pointer. `pick` is then the first solid of the record of the mark, or `undefined` for a record with no solid.\n */\n readonly onHover?: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined;\n /** The viewer starts this function when a person selects a record with the pointer, or selects no record. The parameters are those of `onHover`. */\n readonly onSelect?: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined;\n}\n\n/** A viewer of one scene in a page. */\nexport interface RoomViewer {\n /** The canvas of the viewer. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /**\n * This function shows a different scene, with its marks. The view stays if a person moved it.\n * With no list of marks, the viewer makes the marks of the outlets of the scene.\n */\n setScene(scene: Scene, marks?: readonly Mark[]): void;\n /** This function changes the colors. */\n setTheme(theme: ViewerTheme): void;\n /** This function moves the camera to a view that shows all of the model. */\n setView(view: ViewName): void;\n /**\n * This function highlights records, as the pointer does. An empty list removes the highlights.\n * A record is a record of a solid, or the record name of a mark, for example `electrical/1:nook-2`.\n */\n highlight(records: readonly (ViewerRecord | string)[]): void;\n /** This function selects one record, or no record. It does not start `onSelect`. */\n select(record: ViewerRecord | string | undefined): void;\n /**\n * This function shows only the marks that a test accepts, for example the marks of one kind. The pointer does not find a mark that the picture does not show.\n * The test stays for each subsequent scene. A test that accepts each mark shows all of them again.\n */\n showMarks(test: (mark: Mark) => boolean): void;\n /** This function removes the canvas and releases the memory of the graphics card. */\n dispose(): void;\n}\n\n/** The options of the content of a viewer: the options of the model, of the levels and of the picture of the marks. */\nexport type ViewerContentOptions = Pick<RoomViewerOptions, \"solids\" | \"loads\" | \"markers\">;\n\n/** The record under the pointer for the stage: a solid of the room, or a mark. */\nexport type StageValue = ViewerPick | Mark;\n\n/** This function gives the name of a record for the stage. */\nexport function nameOf(record: ViewerRecord | string): string {\n return typeof record === \"string\" ? record : solidRecord(record.kind, record.source);\n}\n\n/**\n * This function makes a function that gives the colors of the marks of a viewer theme.\n * The marks paint each field again for a new theme object. So the function gives the same object while the viewer theme is the same.\n * A theme with no colors of a field gives a field the color of its level.\n */\nexport function marksThemes(): (theme: ViewerTheme) => MarkersTheme {\n let from: ViewerTheme | undefined;\n let to: MarkersTheme | undefined;\n return (theme) => {\n if (to === undefined || theme !== from) {\n to = { sky: theme.sky, ground: theme.ground, levels: theme.levels, halo: theme.halo, accent: theme.accent, field: theme.field ?? [], fieldOpacity: theme.fieldOpacity };\n }\n from = theme;\n return to;\n };\n}\n\n/** The content of a viewer for one scene, with the functions that use its marks. */\nexport interface ViewerContent {\n /** The solids of the scene, and its marks above them. */\n readonly content: StageContent<StageValue, ViewerTheme>;\n /** This function shows only the marks that a test accepts. The test gets each mark as the scene has it. */\n show(test: (mark: Mark) => boolean): void;\n /**\n * This function gives a record of the stage as a page gets it.\n * A mark gives the first solid of its record and the mark as the scene has it. A solid gives the solid.\n */\n told(value: StageValue | undefined): readonly [pick: ViewerPick | undefined, mark: Mark | undefined];\n}\n\n/**\n * This function makes the content of a viewer for a scene: the solids, and the marks above them.\n *\n * `marks` are in the space of the scene: meters, with the z axis up. With no list, the function makes the marks of the outlets of the scene.\n * A mark with a fault is not in the content. The space of the content has the y axis up.\n */\nexport function createViewerContent(scene: Scene, marks?: readonly Mark[], options: ViewerContentOptions = {}): ViewerContent {\n const room = createRoomContent(scene, options.solids, options.loads);\n const given = marks ?? outletMarks(scene, room.solids, options.loads);\n const faulty = new Set(checkMarks(given).map((fault) => fault.index));\n const good = given.filter((_, index) => !faulty.has(index));\n const onStage = transformMarks(good, TO_Y_UP);\n /** The mark of the scene for each mark of the stage. */\n const inScene = new Map<Mark, Mark>(onStage.map((mark, index) => [mark, good[index] ?? mark]));\n const sceneMark = (mark: Mark): Mark => inScene.get(mark) ?? mark;\n const markers = createMarkers(onStage, options.markers);\n const themeOf = marksThemes();\n const above: StageContent<StageValue, ViewerTheme> = {\n objects: markers.objects,\n extent: markers.extent,\n has: (record) => markers.has(record),\n pick: (ray) => markers.pick(ray),\n paint(theme, highlight): void {\n markers.paint(themeOf(theme), highlight);\n },\n step: (frame) => markers.step?.(frame) ?? false,\n dispose(): void {\n markers.dispose();\n },\n };\n return {\n content: stackContents<StageValue, ViewerTheme>([room, above]),\n show(test): void {\n markers.show((mark) => test(sceneMark(mark)));\n },\n told(value) {\n if (value === undefined) return [undefined, undefined];\n return \"type\" in value ? [room.pickOf(value.record), sceneMark(value)] : [value, undefined];\n },\n };\n}\n\n/**\n * This function makes a viewer of a scene in a container of a page. The viewer fills the container, so give the container a size.\n *\n * A person turns the model with a drag, and moves nearer with the wheel after a click in the picture.\n * The walls between the camera and the room become almost clear. A click selects the record of a solid or of a mark.\n * With the keyboard, the arrow keys turn the model, `+` and `-` change the distance, `Home` shows the first view and `T` shows the plan.\n *\n * The viewer draws the marks of the scene with `@mark1russell7/visuals/markers`. A point is a sign with the color and the shape of its level.\n * With no list of marks, each outlet has a sign. An outlet or an object with a highlight then shows a line from the outlet to each object on it.\n *\n * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.\n */\nexport function createRoomViewer(container: HTMLElement, options: RoomViewerOptions): RoomViewer | undefined {\n let accepted: (mark: Mark) => boolean = () => true;\n let current = createViewerContent(options.scene, options.marks, options);\n /** This function gives a record of the stage to a function of the page. */\n const tell = (to: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined, value: StageValue | undefined): void => {\n if (to === undefined) return;\n const [pick, mark] = current.told(value);\n if (mark === undefined) to(pick);\n else to(pick, mark);\n };\n\n const stage = createStage<StageValue, ViewerTheme>(container, {\n content: current.content,\n theme: options.theme ?? LIGHT_THEME,\n label: options.label ?? \"3D model of the room\",\n views: { home: fitView(HOME_VIEW), top: fitView(TOP_VIEW) },\n home: \"home\",\n keys: { t: \"top\" },\n onHover: (value) => tell(options.onHover, value),\n onSelect: (value) => tell(options.onSelect, value),\n });\n if (stage === undefined) {\n current.content.dispose();\n return undefined;\n }\n\n return {\n canvas: stage.canvas,\n setScene(scene: Scene, marks?: readonly Mark[]): void {\n current = createViewerContent(scene, marks, options);\n current.show(accepted);\n stage.setContent(current.content);\n },\n setTheme(theme: ViewerTheme): void {\n stage.setTheme(theme);\n },\n setView(view: ViewName): void {\n stage.setView(view);\n },\n highlight(records: readonly (ViewerRecord | string)[]): void {\n stage.highlight(records.map(nameOf));\n },\n select(record: ViewerRecord | string | undefined): void {\n stage.select(record === undefined ? undefined : nameOf(record));\n },\n showMarks(test: (mark: Mark) => boolean): void {\n accepted = test;\n current.show(test);\n stage.refresh();\n },\n dispose(): void {\n stage.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,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W,KAAA,IAAY,KAAA,IAAY,OAAO,MAAM,CAAC;EAChE;EACA,UAAU,MAAqC;GAC7C,WAAW;GACX,QAAQ,KAAK,IAAI;GACjB,MAAM,QAAQ;EAChB;EACA,UAAgB;GACd,MAAM,QAAQ;EAChB;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/room-view",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"description": "A room as data, and its 3D model from that data: walls with openings, floors, outlets, circuits and placed objects.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { t as WallFrame } from "./frames-BYMK5ZId.js";
|
|
2
|
-
import { _ as WallFace, c as PlacedObject, l as PlanPoint, p as Scene } from "./room-NREa6vXr.js";
|
|
3
|
-
import { Point3, Transform3 } from "@mark1russell7/layout-contract";
|
|
4
|
-
/** These are the surfaces that an anchor can be on. */
|
|
5
|
-
declare const ANCHOR_SURFACES: readonly ["wall", "floor", "ceiling", "object"];
|
|
6
|
-
/** A surface of an anchor. */
|
|
7
|
-
type AnchorSurface = (typeof ANCHOR_SURFACES)[number];
|
|
8
|
-
/** An anchor on a face of a wall. The lengths are in the unit of the room. */
|
|
9
|
-
interface WallAnchor {
|
|
10
|
-
readonly on: "wall";
|
|
11
|
-
/** The `id` of the wall. */
|
|
12
|
-
readonly wall: string;
|
|
13
|
-
readonly face: WallFace;
|
|
14
|
-
/** The distance along the line of the wall, from `from` to the anchor. */
|
|
15
|
-
readonly offset: number;
|
|
16
|
-
/** The height of the anchor above the floor. */
|
|
17
|
-
readonly height: number;
|
|
18
|
-
}
|
|
19
|
-
/** An anchor on the floor, at a point of the plan. */
|
|
20
|
-
interface FloorAnchor {
|
|
21
|
-
readonly on: "floor";
|
|
22
|
-
readonly at: PlanPoint;
|
|
23
|
-
/** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */
|
|
24
|
-
readonly floor?: string | undefined;
|
|
25
|
-
}
|
|
26
|
-
/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */
|
|
27
|
-
interface CeilingAnchor {
|
|
28
|
-
readonly on: "ceiling";
|
|
29
|
-
readonly at: PlanPoint;
|
|
30
|
-
/** The `id` of the floor below the point. Without it, the point is above any floor of the room. */
|
|
31
|
-
readonly floor?: string | undefined;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.
|
|
35
|
-
* The origin of that frame is the center of the bottom of the object.
|
|
36
|
-
*/
|
|
37
|
-
interface ObjectAnchor {
|
|
38
|
-
readonly on: "object";
|
|
39
|
-
/** The `id` of the placed object. */
|
|
40
|
-
readonly object: string;
|
|
41
|
-
/** The point in the frame of the object. The default is the center of its top. */
|
|
42
|
-
readonly at?: readonly [number, number, number] | undefined;
|
|
43
|
-
/** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */
|
|
44
|
-
readonly out?: readonly [number, number, number] | undefined;
|
|
45
|
-
}
|
|
46
|
-
/** An anchor: a place in the space of the core, for a record of an add-on. */
|
|
47
|
-
type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;
|
|
48
|
-
/** The position of an anchor in the room, in meters. */
|
|
49
|
-
interface AnchorFrame {
|
|
50
|
-
/** The point of the anchor. */
|
|
51
|
-
readonly at: Point3;
|
|
52
|
-
/** The unit vector out of the surface, into the space of the room. */
|
|
53
|
-
readonly out: Point3;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.
|
|
57
|
-
* Make it once with `sceneSpace`, and give it to each add-on.
|
|
58
|
-
*/
|
|
59
|
-
interface SceneSpace {
|
|
60
|
-
readonly scene: Scene;
|
|
61
|
-
/** The length of the unit of the room, in meters. */
|
|
62
|
-
readonly scale: number;
|
|
63
|
-
/** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */
|
|
64
|
-
readonly wall: (id: string) => WallFrame | undefined;
|
|
65
|
-
/** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */
|
|
66
|
-
readonly object: (id: string) => PlacedObject | undefined;
|
|
67
|
-
/** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */
|
|
68
|
-
readonly transform: (id: string) => Transform3 | undefined;
|
|
69
|
-
/** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */
|
|
70
|
-
readonly frame: (anchor: Anchor) => AnchorFrame | undefined;
|
|
71
|
-
}
|
|
72
|
-
/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */
|
|
73
|
-
declare function sceneSpace(scene: Scene): SceneSpace;
|
|
74
|
-
export { CeilingAnchor as a, SceneSpace as c, AnchorSurface as i, WallAnchor as l, Anchor as n, FloorAnchor as o, AnchorFrame as r, ObjectAnchor as s, ANCHOR_SURFACES as t, sceneSpace as u };
|
|
75
|
-
//# sourceMappingURL=anchors-BEnxNnSV.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchors-BEnxNnSV.d.ts","names":[],"sources":["../src/anchors.ts"],"mappings":";;;;cAUa;;KAGD,wBAAwB;;UAGnB;WACN;;WAEA;WACA,MAAM;;WAEN;;WAEA;;;UAIM;WACN;WACA,IAAI;;WAEJ;;;UAIM;WACN;WACA,IAAI;;WAEJ;;;;;;UAOM;WACN;;WAEA;;WAEA;;WAEA;;;KAIC,SAAS,aAAa,cAAc,gBAAgB;;UAG/C;;WAEN,IAAI;;WAEJ,KAAK;;;;;;UAOC;WACN,OAAO;;WAEP;;WAEA,OAAO,eAAe;;WAEtB,SAAS,eAAe;;WAExB,YAAY,eAAe;;WAE3B,QAAQ,QAAQ,WAAW;;;iBAiBtB,WAAW,OAAO,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchors-J6mcUeJn.js","names":[],"sources":["../src/frames.ts","../src/joins.ts","../src/solids.ts","../src/check.ts","../src/anchors.ts"],"sourcesContent":["import { rotationAbout, type Point, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport type { Room, Wall } from \"./room.ts\";\nimport { lengthsInRange, metersPer } from \"./units.ts\";\n\n/**\n * The frame of a wall, in meters. A point of the wall has a distance along the line and a distance across it.\n * The distance across is positive to the left, for a person who looks from the start to the end.\n */\nexport interface WallFrame {\n /** The `id` of the wall. */\n readonly id: string;\n readonly start: Point;\n readonly end: Point;\n /** The unit vector from the start to the end. A wall with the length 0, or with a length that is not finite, has the vector (1, 0). */\n readonly along: Point;\n /** The unit vector to the left of `along`. */\n readonly left: Point;\n readonly length: number;\n readonly thickness: number;\n readonly height: number;\n /** The distance across of the left face. It is 0 or more. */\n readonly leftOffset: number;\n /** The distance across of the right face. It is 0 or less. */\n readonly rightOffset: number;\n}\n\n/** This function gives the frame of one wall. `scale` is the length of the unit of the room in meters. */\nfunction frameOf(room: Room, wall: Wall, scale: number): WallFrame {\n const start = { x: wall.from[0] * scale, y: wall.from[1] * scale };\n const end = { x: wall.to[0] * scale, y: wall.to[1] * scale };\n const length = Math.hypot(end.x - start.x, end.y - start.y);\n const along = length > 0 && Number.isFinite(length) ? { x: (end.x - start.x) / length, y: (end.y - start.y) / length } : { x: 1, y: 0 };\n const thickness = (wall.thickness ?? room.wallThickness) * scale;\n const side = wall.side ?? \"center\";\n const leftOffset = side === \"left\" ? thickness : side === \"right\" ? 0 : thickness / 2;\n return {\n id: wall.id,\n start,\n end,\n along,\n left: { x: 0 - along.y, y: along.x },\n length,\n thickness,\n height: (wall.height ?? room.height) * scale,\n leftOffset,\n rightOffset: leftOffset - thickness,\n };\n}\n\n/** This function gives the frame of each wall of a room, in the sequence of the walls. */\nexport function wallFrames(room: Room): readonly WallFrame[] {\n const scale = metersPer(room.unit);\n return room.walls.map((wall) => frameOf(room, wall, scale));\n}\n\n/**\n * This function tells if a wall has an outline in the plan. Its ends and its thickness must be lengths in the range of the model,\n * and its length and its thickness must be above 0. Only such a wall makes a corner, and the model makes only such a wall.\n */\nexport function wallHasOutline(frame: WallFrame): boolean {\n return lengthsInRange(frame.start.x, frame.start.y, frame.end.x, frame.end.y, frame.thickness) && frame.length > 0 && frame.thickness > 0;\n}\n\n/** This function gives the point of the plan at a distance along a wall and a distance across it, in meters. */\nexport function wallPoint(frame: WallFrame, along: number, across: number): Point {\n return {\n x: frame.start.x + frame.along.x * along + frame.left.x * across,\n y: frame.start.y + frame.along.y * along + frame.left.y * across,\n };\n}\n\n/**\n * This function gives the transform from the frame of a wall to the room.\n * In the frame of a wall, x is the distance along the wall and y is the distance across it. The height above the floor is z.\n */\nexport function wallTransform(frame: WallFrame): Transform3 {\n return {\n position: { x: frame.start.x, y: frame.start.y, z: 0 },\n rotation: rotationAbout({ x: 0, y: 0, z: 1 }, Math.atan2(frame.along.y, frame.along.x)),\n };\n}\n","import { clipRing, type Point, type Ring } from \"@mark1russell7/layout-contract\";\nimport { wallHasOutline, wallPoint, type WallFrame } from \"./frames.ts\";\n\n/** The outline of one wall in the plan, after its corners with the other walls. */\nexport interface WallFootprint {\n /** The `id` of the wall. */\n readonly wall: string;\n /** The outline in meters, counter-clockwise and convex. It is empty for a wall with no outline (`wallHasOutline`) and for a wall that its corners remove. */\n readonly ring: Ring;\n /**\n * The part of the wall that has its full thickness: two distances along the wall, in meters.\n * An opening must be in this part. A wall with no such part has the two distances 0.\n */\n readonly clear: readonly [number, number];\n}\n\n/** The options of the corners of the walls. */\nexport interface JoinOptions {\n /** Two ends of walls at this distance or less make one corner. The unit is the meter, and the default is 1e-6. A value that is not finite gives the default. */\n readonly tolerance?: number | undefined;\n /**\n * The limit of a sharp corner. The faces of two walls meet at a point. When that point is farther from the corner\n * than this number of thicknesses, the two walls get square ends. The default is 4. A value that is not finite gives the default.\n */\n readonly miterLimit?: number | undefined;\n}\n\n/** The default distance in meters at which two ends of walls make one corner. */\nexport const JOIN_TOLERANCE = 1e-6;\n\n/** The default limit of a sharp corner, in thicknesses. */\nexport const MITER_LIMIT = 4;\n\n/** Two unit vectors with a cross product below this value are parallel. */\nconst PARALLEL = 1e-9;\n\n/** A corner of an outline with a turn of this value or less is flat, so the outline does not need it. */\nconst FLAT = 1e-12;\n\n/** Two points at this distance or less are one point. A point at this distance or less from a face of a wall is on the face. */\nconst SAME = 1e-9;\n\n/**\n * One end of a wall, as a person at the end sees it who looks along the wall.\n * `high` and `low` are the distances of the two faces along `normal`, the unit vector to the left of `out`.\n */\ninterface End {\n readonly point: Point;\n readonly out: Point;\n readonly normal: Point;\n readonly high: number;\n readonly low: number;\n readonly thickness: number;\n /** The points of the two faces at this end. The corners of the walls replace the square points. */\n highPoint: Point;\n lowPoint: Point;\n /** This value tells if the end makes a corner with a different end. */\n joined: boolean;\n}\n\n/** This function gives an option, or its default when the option has no value or a value that is not finite. */\nfunction finiteOr(value: number | undefined, fallback: number): number {\n return value !== undefined && Number.isFinite(value) ? value : fallback;\n}\n\n/** This function gives the point at a distance across from the point of an end. */\nfunction across(end: End, distance: number): Point {\n return { x: end.point.x + end.normal.x * distance, y: end.point.y + end.normal.y * distance };\n}\n\n/** This function makes the two ends of a wall, with square points. */\nfunction endsOf(frame: WallFrame): readonly [End, End] {\n const back = { x: 0 - frame.along.x, y: 0 - frame.along.y };\n const right = { x: 0 - frame.left.x, y: 0 - frame.left.y };\n const make = (point: Point, out: Point, normal: Point, high: number, low: number): End => {\n const end: End = { point, out, normal, high, low, thickness: frame.thickness, highPoint: point, lowPoint: point, joined: false };\n end.highPoint = across(end, high);\n end.lowPoint = across(end, low);\n return end;\n };\n return [\n make(frame.start, frame.along, frame.left, frame.leftOffset, frame.rightOffset),\n make(frame.end, back, right, 0 - frame.rightOffset, 0 - frame.leftOffset),\n ];\n}\n\n/** This function gives the point where two lines meet, or `undefined` for parallel lines. Each line has a point and a unit direction. */\nfunction meet(p: Point, d: Point, q: Point, e: Point): Point | undefined {\n const cross = d.x * e.y - d.y * e.x;\n if (Math.abs(cross) < PARALLEL) return undefined;\n const t = ((q.x - p.x) * e.y - (q.y - p.y) * e.x) / cross;\n return { x: p.x + d.x * t, y: p.y + d.y * t };\n}\n\n/**\n * This function makes the corner of the ends at one point. The ends are in sequence counter-clockwise.\n * The left face of each end meets the right face of the next end.\n */\nfunction joinEnds(ends: readonly End[], miterLimit: number): void {\n if (ends.length < 2) return;\n for (let i = 0; i < ends.length; i++) {\n const end = ends[i]!;\n const next = ends[(i + 1) % ends.length]!;\n end.joined = true;\n const corner = meet(across(end, end.high), end.out, across(next, next.low), next.out);\n if (corner === undefined) continue;\n const reach = Math.hypot(corner.x - end.point.x, corner.y - end.point.y);\n if (reach > miterLimit * Math.max(end.thickness, next.thickness)) continue;\n end.highPoint = corner;\n next.lowPoint = corner;\n }\n}\n\n/** This function gives the part of a ring to the left of the line from `p` to `q`. Two points at one position give the full ring. */\nfunction leftOf(ring: Ring, p: Point, q: Point): Ring {\n const length = Math.hypot(q.x - p.x, q.y - p.y);\n if (length <= SAME) return ring;\n const dx = (q.x - p.x) / length;\n const dy = (q.y - p.y) / length;\n return clipRing(ring, dy, 0 - dx, dy * p.x - dx * p.y);\n}\n\n/**\n * This function cuts the outline of a wall at one end. An end with no corner gets a square cut.\n * An end with a corner keeps the part between the two lines from the point of the corner to the points of the two faces.\n */\nfunction cut(ring: Ring, end: End): Ring {\n if (!end.joined) return leftOf(ring, end.highPoint, end.lowPoint);\n return leftOf(leftOf(ring, end.highPoint, end.point), end.point, end.lowPoint);\n}\n\n/** This function removes each corner of a convex outline that is flat or that is a copy of the corner before it. Fewer than 3 corners give an empty outline. */\nfunction withoutFlat(points: Ring): Ring {\n const ring = [...points];\n let changed = true;\n while (changed && ring.length >= 3) {\n changed = false;\n for (let i = 0; i < ring.length && ring.length >= 3; i++) {\n const [ax, ay] = ring[(i + ring.length - 1) % ring.length]!;\n const [bx, by] = ring[i]!;\n const [cx, cy] = ring[(i + 1) % ring.length]!;\n if ((bx - ax) * (cy - by) - (by - ay) * (cx - bx) > FLAT) continue;\n ring.splice(i, 1);\n changed = true;\n i--;\n }\n }\n return ring.length >= 3 ? ring : [];\n}\n\n/** This function gives the range of the distances along a wall of the corners of an outline that are on one face. */\nfunction faceRange(frame: WallFrame, ring: Ring, offset: number): readonly [number, number] {\n let from = Infinity;\n let to = -Infinity;\n for (const [x, y] of ring) {\n const dx = x - frame.start.x;\n const dy = y - frame.start.y;\n if (Math.abs(dx * frame.left.x + dy * frame.left.y - offset) > SAME) continue;\n const along = dx * frame.along.x + dy * frame.along.y;\n from = Math.min(from, along);\n to = Math.max(to, along);\n }\n return [from, to];\n}\n\n/**\n * This function gives the outline of each wall in the plan, in the sequence of the frames.\n *\n * Two or more ends of walls at one point make a corner. At a corner, the faces of the walls that are adjacent meet at a point.\n * Each wall ends at the lines from the corner to those points. Thus two walls make a miter, and the walls of a corner do not overlap.\n * An end with no other end at its point is square. An end on the face of a different wall is also square: the two walls touch.\n * A wall with no outline (`wallHasOutline`) gets an empty outline, and it makes no corner.\n */\nexport function wallFootprints(frames: readonly WallFrame[], options: JoinOptions = {}): readonly WallFootprint[] {\n const tolerance = finiteOr(options.tolerance, JOIN_TOLERANCE);\n const miterLimit = Math.max(finiteOr(options.miterLimit, MITER_LIMIT), 0);\n const pairs = frames.map((frame) => (wallHasOutline(frame) ? endsOf(frame) : undefined));\n const corners: End[][] = [];\n for (const pair of pairs) {\n for (const end of pair ?? []) {\n const corner = corners.find((ends) => Math.hypot(ends[0]!.point.x - end.point.x, ends[0]!.point.y - end.point.y) <= tolerance);\n if (corner === undefined) corners.push([end]);\n else corner.push(end);\n }\n }\n for (const ends of corners) {\n ends.sort((a, b) => Math.atan2(a.out.y, a.out.x) - Math.atan2(b.out.y, b.out.x));\n joinEnds(ends, miterLimit);\n }\n const thickest = frames.reduce((most, frame, index) => (pairs[index] === undefined ? most : Math.max(most, frame.thickness)), 0);\n const reach = (miterLimit + 1) * thickest;\n return frames.map((frame, index): WallFootprint => {\n const pair = pairs[index];\n if (pair === undefined) return { wall: frame.id, ring: [], clear: [0, 0] };\n const strip = [\n wallPoint(frame, 0 - reach, frame.rightOffset),\n wallPoint(frame, frame.length + reach, frame.rightOffset),\n wallPoint(frame, frame.length + reach, frame.leftOffset),\n wallPoint(frame, 0 - reach, frame.leftOffset),\n ].map((point) => [point.x, point.y] as const);\n const ring = withoutFlat(cut(cut(strip, pair[0]), pair[1]));\n // A very large limit of a sharp corner can make numbers that are not finite. Such an outline is no outline.\n if (!ring.every(([x, y]) => Number.isFinite(x) && Number.isFinite(y))) return { wall: frame.id, ring: [], clear: [0, 0] };\n const leftFace = faceRange(frame, ring, frame.leftOffset);\n const rightFace = faceRange(frame, ring, frame.rightOffset);\n const from = Math.max(leftFace[0], rightFace[0]);\n const to = Math.min(leftFace[1], rightFace[1]);\n return { wall: frame.id, ring, clear: from < to ? [from, to] : [0, 0] };\n });\n}\n","import {\n boundsOf3,\n box3Corners,\n box3Volume,\n clipRing,\n composeTransforms3,\n regionArea,\n rotationAbout,\n transformPoint3,\n type Box3,\n type Point3,\n type Ring,\n type Transform3,\n} from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallHasOutline, wallTransform, type WallFrame } from \"./frames.ts\";\nimport { wallFootprints, type JoinOptions, type WallFootprint } from \"./joins.ts\";\nimport type { OpeningKind, PlacedObject, Room, Scene } from \"./room.ts\";\nimport { LARGEST_LENGTH, lengthsInRange, metersPer } from \"./units.ts\";\n\n/** These are the kinds of a solid. */\nexport const SOLID_KINDS: readonly [\"floor\", \"wall\", \"glass\", \"outlet\", \"object\"] = [\"floor\", \"wall\", \"glass\", \"outlet\", \"object\"];\n\n/** A kind of solid. */\nexport type SolidKind = (typeof SOLID_KINDS)[number];\n\n/** A prism: an outline in the plan, from the height `z` up by `d`. The unit is the meter. */\nexport interface Prism {\n readonly kind: \"prism\";\n readonly ring: Ring;\n readonly z: number;\n readonly d: number;\n}\n\n/** A placed box: a box in its own frame, and the transform from that frame to the room. The unit is the meter. */\nexport interface PlacedBox {\n readonly kind: \"box\";\n readonly box: Box3;\n readonly transform: Transform3;\n}\n\n/** The shape of a solid. */\nexport type SolidShape = Prism | PlacedBox;\n\n/**\n * A solid: one part of the 3D model of a room. The x and y axes are the axes of the plan, and the z axis points up.\n * The floor is at the height 0, and each length is in meters. Each number of a solid is finite, and its volume is above 0.\n */\nexport interface Solid {\n /** The name of the solid. Each solid of a model has a different name. */\n readonly id: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from: a wall, a floor, an opening, an outlet or a placed object. */\n readonly source: string;\n readonly shape: SolidShape;\n}\n\n/** The options of the model of a room. */\nexport interface SolidOptions {\n /** The depth of the floor below the height 0, in meters. The walls go down by the same depth. The default is 0.1. A value that is not finite gives the default. */\n readonly floorDepth?: number | undefined;\n /** The options of the corners of the walls. */\n readonly joins?: JoinOptions | undefined;\n}\n\n/** The default depth of the floor, in meters. */\nexport const FLOOR_DEPTH = 0.1;\n\n/** The thickness of the glass of a window, in meters. */\nexport const GLASS_THICKNESS = 0.02;\n\n/** The size of the plate of an outlet, in meters. The plate of a duplex outlet in North America is 70 mm by 115 mm. */\nexport const OUTLET_PLATE: { readonly width: number; readonly height: number; readonly depth: number } = { width: 0.07, height: 0.115, depth: 0.012 };\n\n/**\n * The transform from the room, where the z axis points up, to a space where the y axis points up.\n * The glTF format and three.js have the y axis up. The x axis stays, and the y axis of the plan becomes the negative z axis.\n */\nexport const TO_Y_UP: Transform3 = { position: { x: 0, y: 0, z: 0 }, rotation: { x: -Math.SQRT1_2, y: 0, z: 0, w: Math.SQRT1_2 } };\n\n/** A length in meters at this value or less is empty: the model does not make a part of this size. */\nconst EMPTY = 1e-9;\n\n/** An area in square meters at this value or less is empty. */\nconst EMPTY_AREA = 1e-12;\n\n/** This function gives an outline, or an empty ring when the outline has no area or a number that is not finite. */\nfunction solidRing(ring: Ring): Ring {\n if (ring.length < 3 || !ring.every(([x, y]) => Number.isFinite(x) && Number.isFinite(y))) return [];\n return regionArea({ kind: \"polygon\", points: ring }) > EMPTY_AREA ? ring : [];\n}\n\n/** This function tells if the model makes a wall. Such a wall has an outline in the plan, and its height is above 0 and in the range of the model. */\nfunction isMade(frame: WallFrame): boolean {\n return wallHasOutline(frame) && frame.height > 0 && lengthsInRange(frame.height);\n}\n\n/** An opening of a wall, in meters, in the frame of the wall. */\ninterface Hole {\n readonly id: string;\n readonly kind: OpeningKind;\n readonly from: number;\n readonly to: number;\n readonly sill: number;\n readonly top: number;\n}\n\n/**\n * This function gives the openings of one wall that the model can make, in sequence along the wall.\n * It skips an opening with no size and an opening out of the straight part of the wall. It also skips an opening that overlaps the opening before it.\n */\nfunction holesOf(room: Room, frame: WallFrame, footprint: WallFootprint, scale: number): readonly Hole[] {\n const [clearFrom, clearTo] = footprint.clear;\n const holes = (room.openings ?? [])\n .filter((opening) => opening.wall === frame.id)\n .map((opening): Hole => {\n const sill = (opening.sill ?? 0) * scale;\n return {\n id: opening.id,\n kind: opening.kind,\n from: opening.offset * scale,\n to: (opening.offset + opening.width) * scale,\n sill,\n top: Math.min(sill + opening.height * scale, frame.height),\n };\n })\n .filter((hole) => hole.to - hole.from > EMPTY && hole.sill >= 0 && hole.top - hole.sill > EMPTY && hole.from >= clearFrom - EMPTY && hole.to <= clearTo + EMPTY)\n .sort((a, b) => a.from - b.from);\n const kept: Hole[] = [];\n let cursor = -Infinity;\n for (const hole of holes) {\n if (hole.from < cursor - EMPTY) continue;\n kept.push(hole);\n cursor = hole.to;\n }\n return kept;\n}\n\n/** This function removes each corner of a ring that is at the position of the corner before it. */\nfunction withoutRepeats(ring: Ring): Ring {\n return ring.filter(([x, y], index) => {\n const [px, py] = ring[(index + ring.length - 1) % ring.length]!;\n return ring.length === 1 || Math.hypot(x - px, y - py) > EMPTY;\n });\n}\n\n/** This function gives the part of the outline of a wall between two distances along the wall. An empty part gives an empty ring. */\nfunction slice(frame: WallFrame, ring: Ring, from: number, to: number): Ring {\n const base = frame.start.x * frame.along.x + frame.start.y * frame.along.y;\n let part = ring;\n if (Number.isFinite(from)) part = clipRing(part, 0 - frame.along.x, 0 - frame.along.y, 0 - (base + from));\n if (Number.isFinite(to)) part = clipRing(part, frame.along.x, frame.along.y, base + to);\n return solidRing(withoutRepeats(part));\n}\n\n/** This function gives the solids of one wall: the parts between, below and above its openings, and the glass of each window. */\nfunction wallSolids(room: Room, frame: WallFrame, footprint: WallFootprint, scale: number, depth: number): readonly Solid[] {\n if (footprint.ring.length < 3 || !isMade(frame)) return [];\n const walls: Solid[] = [];\n const glass: Solid[] = [];\n const add = (ring: Ring, z: number, top: number): void => {\n if (ring.length < 3 || top - z <= EMPTY) return;\n walls.push({ id: `wall:${frame.id}:${String(walls.length)}`, kind: \"wall\", source: frame.id, shape: { kind: \"prism\", ring, z, d: top - z } });\n };\n let cursor = -Infinity;\n for (const hole of holesOf(room, frame, footprint, scale)) {\n add(slice(frame, footprint.ring, cursor, hole.from), 0 - depth, frame.height);\n const part = slice(frame, footprint.ring, hole.from, hole.to);\n add(part, 0 - depth, hole.sill);\n add(part, hole.top, frame.height);\n cursor = hole.to;\n if (hole.kind !== \"window\") continue;\n glass.push({\n id: `glass:${hole.id}`,\n kind: \"glass\",\n source: hole.id,\n shape: {\n kind: \"box\",\n box: {\n x: hole.from,\n y: (frame.leftOffset + frame.rightOffset - GLASS_THICKNESS) / 2,\n z: hole.sill,\n w: hole.to - hole.from,\n h: GLASS_THICKNESS,\n d: hole.top - hole.sill,\n },\n transform: wallTransform(frame),\n },\n });\n }\n add(slice(frame, footprint.ring, cursor, Infinity), 0 - depth, frame.height);\n return [...walls, ...glass];\n}\n\n/**\n * This function gives the 3D model of a room as a list of solids.\n * The solids are the floors, the walls with their openings, the glass of the windows and the outlets.\n *\n * The function does not stop for a record with a fault. It skips each part that it cannot make.\n * One example is a wall with no length. A second example is an opening on a wall that the room does not have.\n * A third example is a part with a number that is not finite or not in the range of the model (`LARGEST_LENGTH`). `checkRoom` tells each fault.\n */\nexport function roomSolids(room: Room, options: SolidOptions = {}): readonly Solid[] {\n const scale = metersPer(room.unit);\n const given = options.floorDepth ?? FLOOR_DEPTH;\n const depth = Number.isFinite(given) ? Math.min(Math.max(given, 0), LARGEST_LENGTH) : FLOOR_DEPTH;\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n const solids: Solid[] = [];\n for (const floor of room.floors ?? []) {\n const ring = solidRing(floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n if (ring.length < 3 || depth <= EMPTY || !ring.every(([x, y]) => lengthsInRange(x, y))) continue;\n solids.push({ id: `floor:${floor.id}`, kind: \"floor\", source: floor.id, shape: { kind: \"prism\", ring, z: 0 - depth, d: depth } });\n }\n frames.forEach((frame, index) => {\n solids.push(...wallSolids(room, frame, footprints[index]!, scale, depth));\n });\n const byId = new Map(frames.map((frame) => [frame.id, frame] as const));\n for (const outlet of room.outlets ?? []) {\n const frame = byId.get(outlet.wall);\n if (frame === undefined || !isMade(frame)) continue;\n const along = outlet.offset * scale;\n const height = outlet.height * scale;\n if (!lengthsInRange(along, height)) continue;\n solids.push({\n id: `outlet:${outlet.id}`,\n kind: \"outlet\",\n source: outlet.id,\n shape: {\n kind: \"box\",\n box: {\n x: along - OUTLET_PLATE.width / 2,\n y: outlet.face === \"left\" ? frame.leftOffset : frame.rightOffset - OUTLET_PLATE.depth,\n z: height - OUTLET_PLATE.height / 2,\n w: OUTLET_PLATE.width,\n h: OUTLET_PLATE.depth,\n d: OUTLET_PLATE.height,\n },\n transform: wallTransform(frame),\n },\n });\n }\n return solids;\n}\n\n/**\n * This function gives the transform of each placed object of a scene, from the frame of the object to the room, in meters.\n * The origin of the frame of an object is the center of its bottom. An object with a parent gets the transform of the parent first.\n * An object has no transform when a parent is not in the scene, or when its parents make a loop.\n * An object also has no transform when one value of its place is not finite or not in the range of the model.\n */\nexport function objectTransforms(scene: Scene): ReadonlyMap<string, Transform3> {\n const scale = metersPer(scene.room.unit);\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n const done = new Map<string, Transform3>();\n const open = new Set<string>();\n const resolve = (object: PlacedObject): Transform3 | undefined => {\n const known = done.get(object.id);\n if (known !== undefined) return known;\n if (open.has(object.id)) return undefined;\n const turn = object.turn ?? 0;\n const position = { x: object.at[0] * scale, y: object.at[1] * scale, z: (object.lift ?? 0) * scale };\n if (!Number.isFinite(turn) || !lengthsInRange(position.x, position.y, position.z)) return undefined;\n // The remainder is exact. Thus a very large turn does not make an angle that is not finite.\n const local: Transform3 = { position, rotation: rotationAbout({ x: 0, y: 0, z: 1 }, ((turn % 360) * Math.PI) / 180) };\n let world: Transform3 | undefined = local;\n if (object.parent !== undefined) {\n open.add(object.id);\n const parent = objects.get(object.parent);\n const outer = parent === undefined ? undefined : resolve(parent);\n world = outer === undefined ? undefined : composeTransforms3(outer, local);\n open.delete(object.id);\n }\n if (world !== undefined) done.set(object.id, world);\n return world;\n };\n for (const object of scene.objects ?? []) resolve(object);\n return done;\n}\n\n/**\n * This function gives the 3D model of a scene: the solids of its room, then one box for each placed object.\n * It skips an object that has no transform, no size, or a size that is not in the range of the model. `checkScene` tells each fault.\n */\nexport function sceneSolids(scene: Scene, options: SolidOptions = {}): readonly Solid[] {\n const scale = metersPer(scene.room.unit);\n const transforms = objectTransforms(scene);\n const solids: Solid[] = [...roomSolids(scene.room, options)];\n for (const object of scene.objects ?? []) {\n const transform = transforms.get(object.id);\n const w = object.size[0] * scale;\n const h = object.size[1] * scale;\n const d = object.size[2] * scale;\n if (transform === undefined || ![w, h, d].every((size) => size > EMPTY && size <= LARGEST_LENGTH)) continue;\n solids.push({\n id: `object:${object.id}`,\n kind: \"object\",\n source: object.id,\n shape: { kind: \"box\", box: { x: 0 - w / 2, y: 0 - h / 2, z: 0, w, h, d }, transform },\n });\n }\n return solids;\n}\n\n/** This function gives the corners of a solid in the room. A box has 8, and a prism has 2 for each corner of its outline. */\nexport function solidCorners(solid: Solid): readonly Point3[] {\n const shape = solid.shape;\n if (shape.kind === \"box\") return box3Corners(shape.box).map((corner) => transformPoint3(shape.transform, corner));\n return shape.ring.flatMap(([x, y]) => [\n { x, y, z: shape.z },\n { x, y, z: shape.z + shape.d },\n ]);\n}\n\n/** This function gives the smallest box along the axes that holds each solid, or `undefined` for no solids. */\nexport function boundsOfSolids(solids: readonly Solid[]): Box3 | undefined {\n return boundsOf3(solids.flatMap((solid) => solidCorners(solid)));\n}\n\n/** This function gives the volume of a solid in cubic meters. */\nexport function solidVolume(solid: Solid): number {\n const shape = solid.shape;\n return shape.kind === \"box\" ? box3Volume(shape.box) : regionArea({ kind: \"polygon\", points: shape.ring }) * shape.d;\n}\n","import { convexOverlap, length3, pointInRing, regionArea, transformPoint3, type Ring, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport type { Anchor, SceneSpace } from \"./anchors.ts\";\nimport { wallFrames, wallHasOutline } from \"./frames.ts\";\nimport { wallFootprints, type JoinOptions } from \"./joins.ts\";\nimport type { PlacedObject, Room, Scene } from \"./room.ts\";\nimport { objectTransforms, type SolidKind } from \"./solids.ts\";\nimport { LARGEST_LENGTH, lengthsInRange, metersPer } from \"./units.ts\";\n\n/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */\nexport const FINDING_LEVELS: readonly [\"error\", \"warning\"] = [\"error\", \"warning\"];\n\n/** A level of a finding. */\nexport type FindingLevel = (typeof FINDING_LEVELS)[number];\n\n/** These are the kinds of the records that a finding can name. */\nexport const RECORD_KINDS: readonly [\"room\", \"wall\", \"opening\", \"floor\", \"outlet\", \"circuit\", \"object\", \"load\"] = [\n \"room\",\n \"wall\",\n \"opening\",\n \"floor\",\n \"outlet\",\n \"circuit\",\n \"object\",\n \"load\",\n];\n\n/** A kind of record. */\nexport type RecordKind = (typeof RECORD_KINDS)[number];\n\n/**\n * This function gives the name of a record: its kind, a colon and its `id`, for example `object:desk`.\n * The kind of a record of a layer is the name of the layer, for example `electrical/1`. A finding, a mark and the selection use this name.\n */\nexport function recordName(kind: string, id: string): string {\n return `${kind}:${id}`;\n}\n\n/**\n * This function gives the name of the record of a solid, as `recordName` gives it. `source` is the field `source` of the solid.\n * The glass of a window is a solid of its opening, so its name has the kind `opening`.\n */\nexport function solidRecord(kind: SolidKind, source: string): string {\n return recordName(kind === \"glass\" ? \"opening\" : kind, source);\n}\n\n/** This function gives the kind and the `id` of a record name, or `undefined` for a text with no kind. A kind has no colon, so the first colon ends it. */\nexport function parseRecordName(name: string): { readonly kind: string; readonly id: string } | undefined {\n const colon = name.indexOf(\":\");\n return colon < 1 ? undefined : { kind: name.slice(0, colon), id: name.slice(colon + 1) };\n}\n\n/** These are the codes of the findings. */\nexport const FINDING_CODES: readonly [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n] = [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n];\n\n/** A code of a finding. */\nexport type FindingCode = (typeof FINDING_CODES)[number];\n\n/** A finding: one fault of a room record or a scene record. */\nexport interface Finding {\n readonly level: FindingLevel;\n readonly code: FindingCode;\n /** The kind of the record with the fault. */\n readonly record: RecordKind;\n /** The `id` of the record with the fault. For a load, it is the `id` of the circuit. For the room record, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /**\n * The `id` of the second record of the fault. It is the other opening or the other object of an overlap, or the opening that an outlet is in.\n * It is also the wall that an object overlaps, or the parent or the outlet that an object names. A fault of one record has none.\n */\n readonly other?: string | undefined;\n}\n\n/** The options of the checks. Give the options that the model gets. */\nexport interface CheckOptions {\n /** The options of the corners of the walls. */\n readonly joins?: JoinOptions | undefined;\n}\n\n/** A length in meters at this value or less is 0 for the checks: a size must be above it. */\nconst SMALL = 1e-6;\n\n/** This function gives a number with 3 decimals at most. */\nfunction show(value: number): string {\n return String(Math.round(value * 1000) / 1000);\n}\n\n/** This function tells if a value is a number that is not finite, or if it holds such a number. */\nfunction holdsBadNumber(value: unknown): boolean {\n if (typeof value === \"number\") return !Number.isFinite(value);\n if (Array.isArray(value)) return value.some((item) => holdsBadNumber(item));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsBadNumber(item));\n return false;\n}\n\n/** This function tells if a value is a finite number with a size above a limit, or if it holds such a number. */\nfunction holdsLargeNumber(value: unknown, limit: number): boolean {\n if (typeof value === \"number\") return Number.isFinite(value) && Math.abs(value) > limit;\n if (Array.isArray(value)) return value.some((item) => holdsLargeNumber(item, limit));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsLargeNumber(item, limit));\n return false;\n}\n\n/** This function gives each value that a list has two or more times. */\nfunction repeated(ids: readonly string[]): readonly string[] {\n const seen = new Set<string>();\n const twice = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) twice.add(id);\n seen.add(id);\n }\n return [...twice];\n}\n\n/**\n * This function gives each fault of a room record. A room with no finding of the level `error` gives a full model.\n *\n * The function examines the meaning of the record: for example, an opening must be in its wall. The schema examines the form of the record.\n */\nexport function checkRoom(room: Room, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const scale = metersPer(room.unit);\n /** The largest length of the model, in the unit of the room. */\n const largest = LARGEST_LENGTH / scale;\n /** This function tells if a size of the record is 0 for the checks. */\n const none = (size: number): boolean => !(size * scale > SMALL);\n const openings = room.openings ?? [];\n const outlets = room.outlets ?? [];\n const circuits = room.circuits ?? [];\n const floors = room.floors ?? [];\n\n if (holdsBadNumber([room.height, room.wallThickness])) error(\"number-not-finite\", \"room\", \"\", \"The height or the wall thickness of the room is not a finite number.\");\n if (holdsLargeNumber([room.height, room.wallThickness], largest)) error(\"number-too-large\", \"room\", \"\", `The height or the wall thickness of the room is above 1 000 km, the largest length of the model.`);\n const lists: readonly (readonly [RecordKind, readonly { readonly id: string }[]])[] = [\n [\"wall\", room.walls],\n [\"opening\", openings],\n [\"floor\", floors],\n [\"outlet\", outlets],\n [\"circuit\", circuits],\n ];\n for (const [record, list] of lists) {\n for (const item of list) {\n if (holdsBadNumber(item)) error(\"number-not-finite\", record, item.id, `A number of the ${record} \"${item.id}\" is not finite.`);\n // The limit of a circuit is a power, not a length.\n if (record !== \"circuit\" && holdsLargeNumber(item, largest)) error(\"number-too-large\", record, item.id, `A length of the ${record} \"${item.id}\" is above 1 000 km, the largest length of the model.`);\n }\n for (const id of repeated(list.map((item) => item.id))) error(\"id-duplicate\", record, id, `Two or more records of the kind ${record} have the id \"${id}\".`);\n }\n\n if (none(room.height)) error(\"size-not-positive\", \"room\", \"\", `The height of the room is ${show(room.height)}. It must be above 0.`);\n if (none(room.wallThickness)) error(\"size-not-positive\", \"room\", \"\", `The wall thickness of the room is ${show(room.wallThickness)}. It must be above 0.`);\n\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n frames.forEach((frame, index) => {\n const wall = room.walls[index]!;\n if (wall.thickness !== undefined && none(wall.thickness)) error(\"size-not-positive\", \"wall\", wall.id, `The thickness of the wall \"${wall.id}\" is ${show(wall.thickness)}. It must be above 0.`);\n if (wall.height !== undefined && none(wall.height)) error(\"size-not-positive\", \"wall\", wall.id, `The height of the wall \"${wall.id}\" is ${show(wall.height)}. It must be above 0.`);\n const [clearFrom, clearTo] = footprints[index]!.clear;\n if (!(frame.length > SMALL)) error(\"wall-length\", \"wall\", wall.id, `The wall \"${wall.id}\" has the length 0: its two ends are one point.`);\n else if (wallHasOutline(frame) && !(clearTo - clearFrom > SMALL)) warning(\"wall-short\", \"wall\", wall.id, `The wall \"${wall.id}\" is too short for the corners at its ends: no part of it has its full thickness.`);\n });\n for (let i = 0; i < footprints.length; i++) {\n for (let j = i + 1; j < footprints.length; j++) {\n const a = footprints[i]!;\n const b = footprints[j]!;\n if (a.ring.length < 3 || b.ring.length < 3 || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"wall-overlap\", \"wall\", a.wall, `The walls \"${a.wall}\" and \"${b.wall}\" overlap. Walls connect only at their ends: divide a wall at the point where a different wall crosses it.`);\n }\n }\n\n const frameOf = new Map(frames.map((frame, index) => [frame.id, { frame, footprint: footprints[index]! }] as const));\n const holes = new Map<string, { id: string; from: number; to: number; sill: number; top: number }[]>();\n for (const opening of openings) {\n const found = frameOf.get(opening.wall);\n if (found === undefined) {\n error(\"opening-wall\", \"opening\", opening.id, `The opening \"${opening.id}\" is on the wall \"${opening.wall}\", which the room does not have.`);\n continue;\n }\n if (none(opening.width)) error(\"size-not-positive\", \"opening\", opening.id, `The width of the opening \"${opening.id}\" is ${show(opening.width)}. It must be above 0.`);\n if (none(opening.height)) error(\"size-not-positive\", \"opening\", opening.id, `The height of the opening \"${opening.id}\" is ${show(opening.height)}. It must be above 0.`);\n if (none(opening.width) || none(opening.height)) continue;\n const from = opening.offset * scale;\n const to = (opening.offset + opening.width) * scale;\n const sill = (opening.sill ?? 0) * scale;\n const top = sill + opening.height * scale;\n const [clearFrom, clearTo] = found.footprint.clear;\n if (from < clearFrom - SMALL || to > clearTo + SMALL) {\n error(\n \"opening-range\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from ${show(opening.offset)} to ${show(opening.offset + opening.width)} along the wall \"${opening.wall}\". The straight part of that wall is from ${show(clearFrom / scale)} to ${show(clearTo / scale)}.`,\n );\n }\n if (sill < 0 || top > found.frame.height + SMALL) {\n error(\n \"opening-height\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from the height ${show(sill / scale)} to ${show(top / scale)}. The wall \"${opening.wall}\" is from 0 to ${show(found.frame.height / scale)}.`,\n );\n }\n const list = holes.get(opening.wall) ?? [];\n list.push({ id: opening.id, from, to, sill, top });\n holes.set(opening.wall, list);\n }\n for (const [wall, list] of holes) {\n list.sort((a, b) => a.from - b.from);\n for (let i = 1; i < list.length; i++) {\n const before = list[i - 1]!;\n const hole = list[i]!;\n if (hole.from < before.to - SMALL) error(\"opening-overlap\", \"opening\", hole.id, `The openings \"${before.id}\" and \"${hole.id}\" of the wall \"${wall}\" overlap.`, before.id);\n }\n }\n\n const circuitIds = new Set(circuits.map((circuit) => circuit.id));\n for (const outlet of outlets) {\n if (outlet.circuit !== undefined && !circuitIds.has(outlet.circuit)) error(\"outlet-circuit\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the circuit \"${outlet.circuit}\", which the room does not have.`);\n const found = frameOf.get(outlet.wall);\n if (found === undefined) {\n error(\"outlet-wall\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the wall \"${outlet.wall}\", which the room does not have.`);\n continue;\n }\n const along = outlet.offset * scale;\n const height = outlet.height * scale;\n if (!(along >= 0 && along <= found.frame.length + SMALL && height >= 0 && height <= found.frame.height + SMALL)) {\n error(\n \"outlet-range\",\n \"outlet\",\n outlet.id,\n `The outlet \"${outlet.id}\" is at ${show(outlet.offset)} along the wall \"${outlet.wall}\" and at the height ${show(outlet.height)}. The wall has the length ${show(found.frame.length / scale)} and the height ${show(found.frame.height / scale)}.`,\n );\n continue;\n }\n const hole = (holes.get(outlet.wall) ?? []).find((item) => along > item.from && along < item.to && height > item.sill && height < item.top);\n if (hole !== undefined) warning(\"outlet-in-opening\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is in the opening \"${hole.id}\" of the wall \"${outlet.wall}\".`, hole.id);\n }\n\n for (const floor of floors) {\n if (floor.ring.length < 3 || !(regionArea({ kind: \"polygon\", points: floor.ring }) * scale * scale > SMALL * SMALL)) {\n error(\"floor-ring\", \"floor\", floor.id, `The floor \"${floor.id}\" has no area. Its ring must have 3 or more corners that are not on one line.`);\n }\n }\n for (const circuit of circuits) {\n if (!(circuit.limit > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The limit of the circuit \"${circuit.id}\" is ${show(circuit.limit)} W. It must be above 0.`);\n if (circuit.breaker !== undefined && !(circuit.breaker > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The breaker of the circuit \"${circuit.id}\" is ${show(circuit.breaker)} A. It must be above 0.`);\n if (circuit.voltage !== undefined && !(circuit.voltage > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The voltage of the circuit \"${circuit.id}\" is ${show(circuit.voltage)} V. It must be above 0.`);\n }\n return findings;\n}\n\n/** The outline in the plan and the range of heights of a placed object, in meters. */\ninterface Extent {\n readonly object: PlacedObject;\n readonly ring: Ring;\n readonly z: number;\n readonly top: number;\n}\n\n/** This function gives the extent of a placed object from its transform. The turn of each object is about the vertical axis, so the outline is a rectangle. */\nfunction extentOf(object: PlacedObject, transform: Transform3, scale: number): Extent {\n const w = (object.size[0] * scale) / 2;\n const h = (object.size[1] * scale) / 2;\n const corners: readonly (readonly [number, number])[] = [\n [0 - w, 0 - h],\n [w, 0 - h],\n [w, h],\n [0 - w, h],\n ];\n const ring = corners.map(([x, y]) => {\n const point = transformPoint3(transform, { x, y, z: 0 });\n return [point.x, point.y] as const;\n });\n return { object, ring, z: transform.position.z, top: transform.position.z + object.size[2] * scale };\n}\n\n/**\n * This function gives each fault of a scene record: the faults of its room, then the faults of its placed objects and its loads.\n * A scene with no finding of the level `error` gives a full model.\n */\nexport function checkScene(scene: Scene, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [...checkRoom(scene.room, options)];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const room = scene.room;\n const scale = metersPer(room.unit);\n const objects = scene.objects ?? [];\n const byId = new Map(objects.map((object) => [object.id, object] as const));\n const outletIds = new Set((room.outlets ?? []).map((outlet) => outlet.id));\n const circuitIds = new Set((room.circuits ?? []).map((circuit) => circuit.id));\n /** This function tells if each size of an object is above 0 for the checks. */\n const hasSize = (object: PlacedObject): boolean => object.size.every((size) => size * scale > SMALL);\n\n for (const id of repeated(objects.map((object) => object.id))) error(\"id-duplicate\", \"object\", id, `Two or more records of the kind object have the id \"${id}\".`);\n\n /** The objects that hold an object, from its parent up. A loop of parents gives `undefined`. */\n const holders = (object: PlacedObject): ReadonlySet<string> | undefined => {\n const seen = new Set<string>([object.id]);\n const above = new Set<string>();\n let parent = object.parent === undefined ? undefined : byId.get(object.parent);\n while (parent !== undefined) {\n if (seen.has(parent.id)) return undefined;\n seen.add(parent.id);\n above.add(parent.id);\n parent = parent.parent === undefined ? undefined : byId.get(parent.parent);\n }\n return above;\n };\n\n for (const object of objects) {\n if (holdsBadNumber(object)) error(\"number-not-finite\", \"object\", object.id, `A number of the object \"${object.id}\" is not finite.`);\n // The turn of an object is an angle, so it has no such limit.\n if (holdsLargeNumber([object.size, object.at, object.lift], LARGEST_LENGTH / scale)) error(\"number-too-large\", \"object\", object.id, `A length of the object \"${object.id}\" is above 1 000 km, the largest length of the model.`);\n if (!hasSize(object)) error(\"size-not-positive\", \"object\", object.id, `The size of the object \"${object.id}\" is ${object.size.map(show).join(\" by \")}. Each number must be above 0.`);\n if (object.parent !== undefined && !byId.has(object.parent)) error(\"object-parent\", \"object\", object.id, `The object \"${object.id}\" is on the object \"${object.parent}\", which the scene does not have.`, object.parent);\n else if (holders(object) === undefined) error(\"object-cycle\", \"object\", object.id, `The parents of the object \"${object.id}\" make a loop.`);\n if (object.outlet !== undefined && !outletIds.has(object.outlet)) error(\"object-outlet\", \"object\", object.id, `The object \"${object.id}\" uses the outlet \"${object.outlet}\", which the room does not have.`, object.outlet);\n }\n\n const transforms = objectTransforms(scene);\n const extents: Extent[] = [];\n for (const object of objects) {\n const transform = transforms.get(object.id);\n if (transform !== undefined && hasSize(object)) extents.push(extentOf(object, transform, scale));\n }\n\n const floors = (room.floors ?? []).filter((floor) => floor.ring.length >= 3).map((floor) => floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n for (const extent of extents) {\n const { object } = extent;\n const transform = transforms.get(object.id)!;\n if (object.parent === undefined && floors.length > 0 && !floors.some((ring) => pointInRing(transform.position.x, transform.position.y, ring))) {\n warning(\"object-outside\", \"object\", object.id, `The center of the object \"${object.id}\" is not on a floor of the room.`);\n }\n footprints.forEach((footprint, index) => {\n if (footprint.ring.length < 3 || !(extent.z < frames[index]!.height - SMALL) || !(convexOverlap(footprint.ring, extent.ring) > SMALL)) return;\n warning(\"object-in-wall\", \"object\", object.id, `The object \"${object.id}\" overlaps the wall \"${footprint.wall}\".`, footprint.wall);\n });\n }\n for (let i = 0; i < extents.length; i++) {\n for (let j = i + 1; j < extents.length; j++) {\n const a = extents[i]!;\n const b = extents[j]!;\n if (holders(a.object)?.has(b.object.id) === true || holders(b.object)?.has(a.object.id) === true) continue;\n if (!(Math.min(a.top, b.top) - Math.max(a.z, b.z) > SMALL) || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"object-overlap\", \"object\", a.object.id, `The objects \"${a.object.id}\" and \"${b.object.id}\" overlap.`, b.object.id);\n }\n }\n\n for (const load of scene.loads ?? []) {\n if (!circuitIds.has(load.circuit)) error(\"load-circuit\", \"load\", load.circuit, `A load is on the circuit \"${load.circuit}\", which the room does not have.`);\n if (!(load.watts >= 0 && Number.isFinite(load.watts))) error(\"load-watts\", \"load\", load.circuit, `A load of the circuit \"${load.circuit}\" is ${show(load.watts)} W. It must be a finite number, 0 or more.`);\n }\n return findings;\n}\n\n/** These are the codes of the faults of an anchor. */\nexport const ANCHOR_CODES: readonly [\n \"anchor-not-finite\",\n \"anchor-wall\",\n \"anchor-object\",\n \"anchor-floor\",\n \"anchor-range\",\n \"anchor-direction\",\n \"anchor-in-opening\",\n \"anchor-outside\",\n] = [\"anchor-not-finite\", \"anchor-wall\", \"anchor-object\", \"anchor-floor\", \"anchor-range\", \"anchor-direction\", \"anchor-in-opening\", \"anchor-outside\"];\n\n/** A code of a fault of an anchor. */\nexport type AnchorCode = (typeof ANCHOR_CODES)[number];\n\n/** A fault of an anchor. `checkLayers` gives it the layer and the key of the anchor. */\nexport interface AnchorFault {\n readonly level: FindingLevel;\n readonly code: AnchorCode;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault: the opening that the anchor is in. A different fault has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * This function gives the faults of an anchor in the space of a scene. `name` starts each message.\n * An error tells that the anchor has no position. A warning tells a fault that the model can show.\n */\nexport function checkAnchor(anchor: Anchor, space: SceneSpace, name: string = \"The anchor\"): readonly AnchorFault[] {\n const error = (code: AnchorCode, message: string): readonly AnchorFault[] => [{ level: \"error\", code, message: `${name} ${message}` }];\n const { scene, scale } = space;\n if (holdsBadNumber(anchor)) return error(\"anchor-not-finite\", \"has a number that is not finite.\");\n if (anchor.on === \"wall\") {\n const wall = space.wall(anchor.wall);\n if (wall === undefined) return error(\"anchor-wall\", `is on the wall \"${anchor.wall}\", which the room does not have.`);\n const along = anchor.offset * scale;\n const height = anchor.height * scale;\n if (!(along >= 0 && along <= wall.length + SMALL && height >= 0 && height <= wall.height + SMALL)) {\n return error(\n \"anchor-range\",\n `is at ${show(anchor.offset)} along the wall \"${anchor.wall}\" and at the height ${show(anchor.height)}. The wall has the length ${show(wall.length / scale)} and the height ${show(wall.height / scale)}.`,\n );\n }\n const hole = (scene.room.openings ?? []).find((opening) => {\n const sill = (opening.sill ?? 0) * scale;\n return opening.wall === anchor.wall && along > opening.offset * scale && along < (opening.offset + opening.width) * scale && height > sill && height < sill + opening.height * scale;\n });\n return hole === undefined ? [] : [{ level: \"warning\", code: \"anchor-in-opening\", message: `${name} is in the opening \"${hole.id}\" of the wall \"${anchor.wall}\".`, other: hole.id }];\n }\n if (anchor.on === \"object\") {\n const object = space.object(anchor.object);\n if (object === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which the scene does not have.`);\n // An object with no place has a fault of its own, which `checkScene` tells. Here, the anchor tells that it has no position.\n if (space.transform(anchor.object) === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which has no place in the room.`);\n const small = SMALL / scale;\n if (anchor.at !== undefined) {\n const [x, y, z] = anchor.at;\n const [width, depth, height] = object.size;\n if (!(Math.abs(x) <= width / 2 + small && Math.abs(y) <= depth / 2 + small && z >= -small && z <= height + small)) {\n return error(\"anchor-range\", `is at (${anchor.at.map(show).join(\", \")}) in the frame of the object \"${anchor.object}\". The object has the size ${object.size.map(show).join(\" by \")}.`);\n }\n }\n if (anchor.out !== undefined) {\n const [x, y, z] = anchor.out;\n if (!(length3({ x, y, z }) > 0)) return error(\"anchor-direction\", \"has a direction with the length 0. A direction must have a length above 0.\");\n }\n return [];\n }\n const [x, y] = anchor.at;\n if (!lengthsInRange(x * scale, y * scale)) return error(\"anchor-range\", \"is at a point above 1 000 km, the largest length of the model.\");\n const word = anchor.on === \"floor\" ? \"on\" : \"above\";\n const floors = scene.room.floors ?? [];\n if (anchor.floor !== undefined) {\n const floor = floors.find((item) => item.id === anchor.floor);\n if (floor === undefined) return error(\"anchor-floor\", `is ${word} the floor \"${anchor.floor}\", which the room does not have.`);\n return pointInRing(x, y, floor.ring) ? [] : [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} the floor \"${anchor.floor}\".` }];\n }\n if (floors.length === 0 || floors.some((floor) => pointInRing(x, y, floor.ring))) return [];\n return [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} a floor of the room.` }];\n}\n","import { length3, rotatePoint3, scalePoint3, transformPoint3, type Point3, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallPoint, type WallFrame } from \"./frames.ts\";\nimport type { PlacedObject, PlanPoint, Scene, WallFace } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { lengthsInRange, metersPer } from \"./units.ts\";\n\n// The anchors of the core: the places where an add-on puts its records. The core gives each anchor its position.\n// An anchor names no topic. An outlet, a tap and a lamp are records of add-ons, and each one is on an anchor.\n\n/** These are the surfaces that an anchor can be on. */\nexport const ANCHOR_SURFACES: readonly [\"wall\", \"floor\", \"ceiling\", \"object\"] = [\"wall\", \"floor\", \"ceiling\", \"object\"];\n\n/** A surface of an anchor. */\nexport type AnchorSurface = (typeof ANCHOR_SURFACES)[number];\n\n/** An anchor on a face of a wall. The lengths are in the unit of the room. */\nexport interface WallAnchor {\n readonly on: \"wall\";\n /** The `id` of the wall. */\n readonly wall: string;\n readonly face: WallFace;\n /** The distance along the line of the wall, from `from` to the anchor. */\n readonly offset: number;\n /** The height of the anchor above the floor. */\n readonly height: number;\n}\n\n/** An anchor on the floor, at a point of the plan. */\nexport interface FloorAnchor {\n readonly on: \"floor\";\n readonly at: PlanPoint;\n /** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */\nexport interface CeilingAnchor {\n readonly on: \"ceiling\";\n readonly at: PlanPoint;\n /** The `id` of the floor below the point. Without it, the point is above any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/**\n * An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.\n * The origin of that frame is the center of the bottom of the object.\n */\nexport interface ObjectAnchor {\n readonly on: \"object\";\n /** The `id` of the placed object. */\n readonly object: string;\n /** The point in the frame of the object. The default is the center of its top. */\n readonly at?: readonly [number, number, number] | undefined;\n /** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */\n readonly out?: readonly [number, number, number] | undefined;\n}\n\n/** An anchor: a place in the space of the core, for a record of an add-on. */\nexport type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;\n\n/** The position of an anchor in the room, in meters. */\nexport interface AnchorFrame {\n /** The point of the anchor. */\n readonly at: Point3;\n /** The unit vector out of the surface, into the space of the room. */\n readonly out: Point3;\n}\n\n/**\n * The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.\n * Make it once with `sceneSpace`, and give it to each add-on.\n */\nexport interface SceneSpace {\n readonly scene: Scene;\n /** The length of the unit of the room, in meters. */\n readonly scale: number;\n /** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */\n readonly wall: (id: string) => WallFrame | undefined;\n /** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */\n readonly object: (id: string) => PlacedObject | undefined;\n /** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */\n readonly transform: (id: string) => Transform3 | undefined;\n /** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */\n readonly frame: (anchor: Anchor) => AnchorFrame | undefined;\n}\n\nconst UP: Point3 = { x: 0, y: 0, z: 1 };\nconst DOWN: Point3 = { x: 0, y: 0, z: -1 };\n\n/** This function tells if each value of a point is a length in the range of the model. */\nfunction inRange(point: Point3): boolean {\n return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z) && lengthsInRange(point.x, point.y, point.z);\n}\n\n/** This function gives a point with no negative zero. JSON has no negative zero, so a frame goes through JSON with no change. */\nfunction plainPoint(point: Point3): Point3 {\n return { x: point.x + 0, y: point.y + 0, z: point.z + 0 };\n}\n\n/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */\nexport function sceneSpace(scene: Scene): SceneSpace {\n const scale = metersPer(scene.room.unit);\n const walls = new Map(wallFrames(scene.room).map((frame) => [frame.id, frame] as const));\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n let transforms: ReadonlyMap<string, Transform3> | undefined;\n const transform = (id: string): Transform3 | undefined => {\n transforms ??= objectTransforms(scene);\n return transforms.get(id);\n };\n const frame = (anchor: Anchor): AnchorFrame | undefined => {\n let found: AnchorFrame;\n if (anchor.on === \"wall\") {\n const wall = walls.get(anchor.wall);\n if (wall === undefined) return undefined;\n const point = wallPoint(wall, anchor.offset * scale, anchor.face === \"left\" ? wall.leftOffset : wall.rightOffset);\n const sign = anchor.face === \"left\" ? 1 : -1;\n found = { at: { x: point.x, y: point.y, z: anchor.height * scale }, out: { x: wall.left.x * sign, y: wall.left.y * sign, z: 0 } };\n } else if (anchor.on === \"floor\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: 0 }, out: UP };\n } else if (anchor.on === \"ceiling\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: scene.room.height * scale }, out: DOWN };\n } else {\n const object = objects.get(anchor.object);\n const place = transform(anchor.object);\n if (object === undefined || place === undefined) return undefined;\n const [x, y, z] = anchor.at ?? [0, 0, object.size[2]];\n const [ox, oy, oz] = anchor.out ?? [0, 0, 1];\n const out = { x: ox, y: oy, z: oz };\n const size = length3(out);\n if (!(size > 0) || !Number.isFinite(size)) return undefined;\n found = { at: transformPoint3(place, { x: x * scale, y: y * scale, z: z * scale }), out: rotatePoint3(place.rotation, scalePoint3(out, 1 / size)) };\n }\n const plain: AnchorFrame = { at: plainPoint(found.at), out: plainPoint(found.out) };\n return inRange(plain.at) && inRange(plain.out) ? plain : undefined;\n };\n return { scene, scale, wall: (id) => walls.get(id), object: (id) => objects.get(id), transform, frame };\n}\n"],"mappings":";;;;AA2BA,SAAS,QAAQ,MAAY,MAAY,OAA0B;CACjE,MAAM,QAAQ;EAAE,GAAG,KAAK,KAAK,KAAK;EAAO,GAAG,KAAK,KAAK,KAAK;CAAM;CACjE,MAAM,MAAM;EAAE,GAAG,KAAK,GAAG,KAAK;EAAO,GAAG,KAAK,GAAG,KAAK;CAAM;CAC3D,MAAM,SAAS,KAAK,MAAM,IAAI,IAAI,MAAM,GAAG,IAAI,IAAI,MAAM,CAAC;CAC1D,MAAM,QAAQ,SAAS,KAAK,OAAO,SAAS,MAAM,IAAI;EAAE,IAAI,IAAI,IAAI,MAAM,KAAK;EAAQ,IAAI,IAAI,IAAI,MAAM,KAAK;CAAO,IAAI;EAAE,GAAG;EAAG,GAAG;CAAE;CACtI,MAAM,aAAa,KAAK,aAAa,KAAK,iBAAiB;CAC3D,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,aAAa,SAAS,SAAS,YAAY,SAAS,UAAU,IAAI,YAAY;CACpF,OAAO;EACL,IAAI,KAAK;EACT;EACA;EACA;EACA,MAAM;GAAE,GAAG,IAAI,MAAM;GAAG,GAAG,MAAM;EAAE;EACnC;EACA;EACA,SAAS,KAAK,UAAU,KAAK,UAAU;EACvC;EACA,aAAa,aAAa;CAC5B;AACF;;AAGA,SAAgB,WAAW,MAAkC;CAC3D,MAAM,QAAQ,UAAU,KAAK,IAAI;CACjC,OAAO,KAAK,MAAM,KAAK,SAAS,QAAQ,MAAM,MAAM,KAAK,CAAC;AAC5D;;;;;AAMA,SAAgB,eAAe,OAA2B;CACxD,OAAO,eAAe,MAAM,MAAM,GAAG,MAAM,MAAM,GAAG,MAAM,IAAI,GAAG,MAAM,IAAI,GAAG,MAAM,SAAS,KAAK,MAAM,SAAS,KAAK,MAAM,YAAY;AAC1I;;AAGA,SAAgB,UAAU,OAAkB,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