@mark1russell7/room-view 0.3.0 → 0.3.2

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.
Files changed (42) hide show
  1. package/README.md +28 -0
  2. package/build/{check-DI_B57qy.js → check-lFfxIUS3.js} +3 -29
  3. package/build/check-lFfxIUS3.js.map +1 -0
  4. package/build/index.d.ts +4 -3
  5. package/build/index.d.ts.map +1 -1
  6. package/build/index.js +5 -3
  7. package/build/index.js.map +1 -1
  8. package/build/{layers-CYZwt1bH.d.ts → layers-BiiyFJwZ.d.ts} +3 -2
  9. package/build/layers-BiiyFJwZ.d.ts.map +1 -0
  10. package/build/{layers-CDNFVXds.js → layers-DmTro5Ny.js} +5 -29
  11. package/build/layers-DmTro5Ny.js.map +1 -0
  12. package/build/{level-BERjgyrT.js → level-CvbiwvhH.js} +4 -3
  13. package/build/{level-BERjgyrT.js.map → level-CvbiwvhH.js.map} +1 -1
  14. package/build/{level-m-mJ_3Ok.d.ts → level-DmEftWYn.d.ts} +3 -3
  15. package/build/{level-m-mJ_3Ok.d.ts.map → level-DmEftWYn.d.ts.map} +1 -1
  16. package/build/marks.d.ts +2 -2
  17. package/build/marks.js +1 -1
  18. package/build/plan-import.d.ts +329 -0
  19. package/build/plan-import.d.ts.map +1 -0
  20. package/build/plan-import.js +864 -0
  21. package/build/plan-import.js.map +1 -0
  22. package/build/room-BQua5eSs.d.ts +124 -0
  23. package/build/room-BQua5eSs.d.ts.map +1 -0
  24. package/build/room-CiVZ_07s.js +29 -0
  25. package/build/room-CiVZ_07s.js.map +1 -0
  26. package/build/sample.d.ts +2 -2
  27. package/build/schema.d.ts +3 -3
  28. package/build/schema.js +4 -3
  29. package/build/schema.js.map +1 -1
  30. package/build/{solids-OiTlb_Pm.d.ts → solids-CdJf0U39.d.ts} +3 -123
  31. package/build/solids-CdJf0U39.d.ts.map +1 -0
  32. package/build/three.d.ts +2 -1
  33. package/build/three.d.ts.map +1 -1
  34. package/build/three.js +2 -1
  35. package/build/three.js.map +1 -1
  36. package/build/units-BZmvVyu4.js +30 -0
  37. package/build/units-BZmvVyu4.js.map +1 -0
  38. package/package.json +7 -1
  39. package/build/check-DI_B57qy.js.map +0 -1
  40. package/build/layers-CDNFVXds.js.map +0 -1
  41. package/build/layers-CYZwt1bH.d.ts.map +0 -1
  42. package/build/solids-OiTlb_Pm.d.ts.map +0 -1
@@ -1,125 +1,5 @@
1
+ import { c as Room, u as Scene } from "./room-BQua5eSs.js";
1
2
  import { Box3, Point, Point3, Ring, Transform3 } from "@mark1russell7/layout-contract";
2
- /** These are the units of length that a room record can use. */
3
- declare const LENGTH_UNITS: readonly ["m", "cm", "mm", "ft", "in"];
4
- /** A unit of length of a room record. */
5
- type LengthUnit = (typeof LENGTH_UNITS)[number];
6
- /** This function gives the length of one unit in meters. The factor comes from `@mark1russell7/quantity`. */
7
- declare function metersPer(unit: LengthUnit): number;
8
- /** This function gives the length of one unit in a different unit. For example, one foot is 12 inches. */
9
- declare function unitsPer(unit: LengthUnit, other: LengthUnit): number;
10
- /**
11
- * The largest length in meters that the model can use: 1 000 km. A larger number in a room record is a mistake.
12
- * With this limit, each calculation of the model gives a finite number.
13
- */
14
- declare const LARGEST_LENGTH = 1e6;
15
- /** This function tells if the model can use each value as a length. Such a value is a finite number of meters, with a size of `LARGEST_LENGTH` or less. */
16
- declare function lengthsInRange(...meters: readonly number[]): boolean;
17
- /** A point of the plan: `[x, y]`. The plan is the view from above, and the z axis points up. */
18
- type PlanPoint = readonly [number, number];
19
- /** The name of the format of a room record. */
20
- declare const ROOM_SCHEMA = "room/2";
21
- /** The name of the format of a scene record. */
22
- declare const SCENE_SCHEMA = "scene/2";
23
- /**
24
- * This function tells if a text is the name of a layer: a word, a slash and a version, for example `electrical/1`.
25
- * The word has lowercase letters, digits and hyphens. Thus a layer name has no colon, and `recordName` gives each record one name.
26
- */
27
- declare function isLayerName(text: string): boolean;
28
- /** These are the sides of the line of a wall that can have the wall. */
29
- declare const WALL_SIDES: readonly ["center", "left", "right"];
30
- /**
31
- * The side of the line of a wall that has the wall, for a person who looks from `from` to `to`.
32
- * With `center`, the line is the middle of the wall. With `left` or `right`, the line is one face of the wall.
33
- */
34
- type WallSide = (typeof WALL_SIDES)[number];
35
- /** These are the faces of a wall, for a person who looks from `from` to `to`. */
36
- declare const WALL_FACES: readonly ["left", "right"];
37
- /** A face of a wall. */
38
- type WallFace = (typeof WALL_FACES)[number];
39
- /**
40
- * A wall: a straight line in the plan, with a thickness and a height.
41
- * A tape measure gives the faces of a wall, so `side` lets the line be a face. Two walls with a common end make a corner.
42
- */
43
- interface Wall {
44
- readonly id: string;
45
- readonly from: PlanPoint;
46
- readonly to: PlanPoint;
47
- /** The thickness of the wall. The default is `wallThickness` of the room. */
48
- readonly thickness?: number | undefined;
49
- /** The height of the wall. The default is `height` of the room. */
50
- readonly height?: number | undefined;
51
- /** The side of the line that has the wall. The default is `center`. */
52
- readonly side?: WallSide | undefined;
53
- }
54
- /** These are the kinds of an opening. A window has glass. A door and a gap are empty. */
55
- declare const OPENING_KINDS: readonly ["door", "window", "gap"];
56
- /** A kind of opening. */
57
- type OpeningKind = (typeof OPENING_KINDS)[number];
58
- /** An opening: a hole through a wall. */
59
- interface Opening {
60
- readonly id: string;
61
- /** The `id` of the wall. */
62
- readonly wall: string;
63
- readonly kind: OpeningKind;
64
- /** The distance along the line of the wall, from `from` to the near edge of the opening. */
65
- readonly offset: number;
66
- readonly width: number;
67
- /** The height of the bottom of the opening above the floor. The default is 0. */
68
- readonly sill?: number | undefined;
69
- readonly height: number;
70
- }
71
- /** A floor: one area of the plan, for example one room of an apartment. The ring is the line where the floor touches the walls. */
72
- interface Floor {
73
- readonly id: string;
74
- readonly name?: string | undefined;
75
- readonly ring: Ring;
76
- }
77
- /** A room: the walls, the openings and the floors of one room or one apartment. */
78
- interface Room {
79
- readonly schema: typeof ROOM_SCHEMA;
80
- readonly name?: string | undefined;
81
- /** The unit of each length of the record. */
82
- readonly unit: LengthUnit;
83
- /** The height of each wall that has no height of its own. */
84
- readonly height: number;
85
- /** The thickness of each wall that has no thickness of its own. */
86
- readonly wallThickness: number;
87
- readonly walls: readonly Wall[];
88
- readonly openings?: readonly Opening[] | undefined;
89
- readonly floors?: readonly Floor[] | undefined;
90
- }
91
- /**
92
- * A placed object: a box in the room, for example a desk, a rack or a computer.
93
- * With a `parent`, the position and the turn are relative to that object, whose origin is the center of its bottom.
94
- */
95
- interface PlacedObject {
96
- readonly id: string;
97
- /** The class of the object, for example `desk`, `rack` or `computer`. A viewer gives each class a color. */
98
- readonly kind: string;
99
- readonly name?: string | undefined;
100
- /** The size before the turn: along x, along y, and the height. */
101
- readonly size: readonly [number, number, number];
102
- /** The point of the plan below the center of the object. */
103
- readonly at: PlanPoint;
104
- /** The height of the bottom of the object above the floor, or above the bottom of its parent. The default is 0. */
105
- readonly lift?: number | undefined;
106
- /** The turn about the vertical axis in degrees, counter-clockwise from above. The default is 0. */
107
- readonly turn?: number | undefined;
108
- /** The `id` of the object that holds this object. */
109
- readonly parent?: string | undefined;
110
- }
111
- /** A scene: one room with its placed objects and the records of its add-ons. Two scenes of one room can be compared. */
112
- interface Scene {
113
- readonly schema: typeof SCENE_SCHEMA;
114
- readonly name?: string | undefined;
115
- readonly room: Room;
116
- readonly objects?: readonly PlacedObject[] | undefined;
117
- /**
118
- * The records of each add-on, by the name of its layer, for example `electrical/1`. `isLayerName` tells the form of a name.
119
- * The core keeps each layer and does not read it. `checkLayers` examines the layers with a list of add-ons.
120
- */
121
- readonly layers?: Readonly<Record<string, unknown>> | undefined;
122
- }
123
3
  /**
124
4
  * The frame of a wall, in meters. A point of the wall has a distance along the line and a distance across it.
125
5
  * The distance across is positive to the left, for a person who looks from the start to the end.
@@ -264,5 +144,5 @@ declare function solidCorners(solid: Solid): readonly Point3[];
264
144
  declare function boundsOfSolids(solids: readonly Solid[]): Box3 | undefined;
265
145
  /** This function gives the volume of a solid in cubic meters. */
266
146
  declare function solidVolume(solid: Solid): number;
267
- export { OpeningKind as A, WallFace as B, wallFrames as C, Floor as D, wallTransform as E, SCENE_SCHEMA as F, LengthUnit as G, isLayerName as H, Scene as I, unitsPer as J, lengthsInRange as K, WALL_FACES as L, PlanPoint as M, ROOM_SCHEMA as N, OPENING_KINDS as O, Room as P, WALL_SIDES as R, WallFrame as S, wallPoint as T, LARGEST_LENGTH as U, WallSide as V, LENGTH_UNITS as W, JOIN_TOLERANCE as _, SOLID_KINDS as a, WallFootprint as b, SolidOptions as c, boundsOfSolids as d, objectTransforms as f, solidVolume as g, solidCorners as h, Prism as i, PlacedObject as j, Opening as k, SolidShape as l, sceneSolids as m, GLASS_THICKNESS as n, Solid as o, roomSolids as p, metersPer as q, PlacedBox as r, SolidKind as s, FLOOR_DEPTH as t, TO_Y_UP as u, JoinOptions as v, wallHasOutline as w, wallFootprints as x, MITER_LIMIT as y, Wall as z };
268
- //# sourceMappingURL=solids-OiTlb_Pm.d.ts.map
147
+ export { wallFrames as C, wallTransform as E, WallFrame as S, wallPoint as T, JOIN_TOLERANCE as _, SOLID_KINDS as a, WallFootprint as b, SolidOptions as c, boundsOfSolids as d, objectTransforms as f, solidVolume as g, solidCorners as h, Prism as i, SolidShape as l, sceneSolids as m, GLASS_THICKNESS as n, Solid as o, roomSolids as p, PlacedBox as r, SolidKind as s, FLOOR_DEPTH as t, TO_Y_UP as u, JoinOptions as v, wallHasOutline as w, wallFootprints as x, MITER_LIMIT as y };
148
+ //# sourceMappingURL=solids-CdJf0U39.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solids-CdJf0U39.d.ts","names":[],"sources":["../src/frames.ts","../src/joins.ts","../src/solids.ts"],"mappings":";;;;;;UAQiB;;WAEN;WACA,OAAO;WACP,KAAK;;WAEL,OAAO;;WAEP,MAAM;WACN;WACA;WACA;;WAEA;;WAEA;;;iBA2BK,WAAW,MAAM,gBAAgB;;;;;iBASjC,eAAe,OAAO;;iBAKtB,UAAU,OAAO,WAAW,eAAe,iBAAiB;;;;;iBAW5D,cAAc,OAAO,YAAY;;UCvEhC;;WAEN;;WAEA,MAAM;;;;;WAKN;;;UAIM;;WAEN;;;;;WAKA;;;cAIE;;cAGA;;;;;;;;;iBA8IG,eAAe,iBAAiB,aAAa,UAAS,uBAA4B;;cCzJrF;;KAGD,oBAAoB;;UAGf;WACN;WACA,MAAM;WACN;WACA;;;UAIM;WACN;WACA,KAAK;WACL,WAAW;;;KAIV,aAAa,QAAQ;;;;;UAMhB;;WAEN;WACA,MAAM;;WAEN;WACA,OAAO;;;UAID;;WAEN;;WAEA,QAAQ;;;cAIN;;cAGA;;;;;cAMA,SAAS;;;;;;;;;iBA4HN,WAAW,MAAM,MAAM,UAAS,wBAA6B;;;;;;;iBAwB7D,iBAAiB,OAAO,QAAQ,oBAAoB;;;;;iBAiCpD,YAAY,OAAO,OAAO,UAAS,wBAA6B;;iBAqBhE,aAAa,OAAO,iBAAiB;;iBAUrC,eAAe,iBAAiB,UAAU;;iBAK1C,YAAY,OAAO"}
package/build/three.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { I as Scene, c as SolidOptions, o as Solid, s as SolidKind } from "./solids-OiTlb_Pm.js";
1
+ import { c as SolidOptions, o as Solid, s as SolidKind } from "./solids-CdJf0U39.js";
2
+ import { u as Scene } from "./room-BQua5eSs.js";
2
3
  import { Point3, Rotation3 } from "@mark1russell7/layout-contract";
3
4
  import { BufferGeometry } from "three";
4
5
  import { MarkersOptions } from "@mark1russell7/visuals/markers";
@@ -1 +1 @@
1
- {"version":3,"file":"three.d.ts","names":[],"sources":["../src/viewer/geometry.ts","../src/viewer/theme.ts","../src/viewer/content.ts","../src/viewer/viewer.ts"],"mappings":";;;;;;;;;;UAQiB;;WAEN,UAAU;;WAEV,UAAU;;WAEV,UAAU;;;;;;;;wBAYL,cAAc,OAAO,QAAQ;;;;;UCpB5B;;WAEN;;WAEA;WACA;WACA;WACA;;WAEA;;WAEA,QAAQ,SAAS,OAAO;;WAExB;;;;;WAKA;;WAEA;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;;;;;EAKd,UAAU,mBAAmB;;EAE7B,OAAO,QAAQ;;;;;EAKf,UAAU,OAAO,MAAM;;EAEvB;;;;;;;;;;;;;;wBAkGc,iBAAiB,WAAW,aAAa,SAAS,oBAAoB"}
package/build/three.js CHANGED
@@ -1,4 +1,5 @@
1
- import { E as wallPoint, T as wallHasOutline, h as boundsOfSolids, j as metersPer, m as TO_Y_UP, u as solidRecord, v as sceneSolids, w as wallFrames, y as solidCorners } from "./check-DI_B57qy.js";
1
+ import { E as wallPoint, T as wallHasOutline, h as boundsOfSolids, m as TO_Y_UP, u as solidRecord, v as sceneSolids, w as wallFrames, y as solidCorners } from "./check-lFfxIUS3.js";
2
+ import { i as metersPer } from "./units-BZmvVyu4.js";
2
3
  import { pointInRing, transformPoint3 } from "@mark1russell7/layout-contract";
3
4
  import { BoxGeometry, Color, EdgesGeometry, ExtrudeGeometry, Group, Mesh, MeshLambertMaterial, Shape, Vector2 } from "three";
4
5
  import { fitView } from "@mark1russell7/visuals";
@@ -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/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 { Level } from \"@mark1russell7/visuals/marks\";\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 the marks of each level. */\n readonly levels: Readonly<Record<Level, 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 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 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 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 or the wall of a window. */\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 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, 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 = {}): RoomModel {\n const solids = sceneSolids(scene, options);\n const wallOfOpening = new Map((scene.room.openings ?? []).map((opening) => [opening.id, opening.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) : undefined,\n holder: parent === undefined ? undefined : solidRecord(\"object\", parent),\n holds: solid.kind === \"object\" && holding.has(solid.source),\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 !== \"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 */\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\") {\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 { 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 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 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 = {}): RoomContent {\n const model = buildModel(scene, solids);\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 { 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 { Scene } from \"../room.ts\";\nimport { TO_Y_UP, type SolidOptions } from \"../solids.ts\";\nimport { createRoomContent, type ViewerPick, type ViewerRecord } from \"./content.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 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 picture has 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 /** This function shows a different scene, with its marks. The view stays if a person moved it. With no list, the picture has no mark. */\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 and of the picture of the marks. */\nexport type ViewerContentOptions = Pick<RoomViewerOptions, \"solids\" | \"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 content has no mark.\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);\n const given = marks ?? [];\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 * A link shows while its record, or the record of one of its ends, has a highlight. A sign that a solid hides is less clear.\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,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,KAAK,MAAM,CAAC,GAAG,MAAM,MAAM,MAAM;EAC/B,OAAO,KAAK,IAAI,MAAM,CAAC;EACvB,OAAO,KAAK,IAAI,MAAM,CAAC;EACvB,OAAO,KAAK,IAAI,MAAM,CAAC;EACv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U,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/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 { Level } from \"@mark1russell7/visuals/marks\";\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 the marks of each level. */\n readonly levels: Readonly<Record<Level, 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 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 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 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 or the wall of a window. */\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 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, 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 = {}): RoomModel {\n const solids = sceneSolids(scene, options);\n const wallOfOpening = new Map((scene.room.openings ?? []).map((opening) => [opening.id, opening.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) : undefined,\n holder: parent === undefined ? undefined : solidRecord(\"object\", parent),\n holds: solid.kind === \"object\" && holding.has(solid.source),\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 !== \"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 */\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\") {\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 { 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 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 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 = {}): RoomContent {\n const model = buildModel(scene, solids);\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 { 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 { Scene } from \"../room.ts\";\nimport { TO_Y_UP, type SolidOptions } from \"../solids.ts\";\nimport { createRoomContent, type ViewerPick, type ViewerRecord } from \"./content.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 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 picture has 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 /** This function shows a different scene, with its marks. The view stays if a person moved it. With no list, the picture has no mark. */\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 and of the picture of the marks. */\nexport type ViewerContentOptions = Pick<RoomViewerOptions, \"solids\" | \"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 content has no mark.\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);\n const given = marks ?? [];\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 * A link shows while its record, or the record of one of its ends, has a highlight. A sign that a solid hides is less clear.\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,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,KAAK,MAAM,CAAC,GAAG,MAAM,MAAM,MAAM;EAC/B,OAAO,KAAK,IAAI,MAAM,CAAC;EACvB,OAAO,KAAK,IAAI,MAAM,CAAC;EACvB,OAAO,KAAK,IAAI,MAAM,CAAC;EACvB,OAAO,KAAK,IAAI,MAAM,CAAC;CACzB;CACA,MAAM,WAAW,OAAO,QAAQ;CAChC,MAAM,WAAW,OAAO,QAAQ;CAChC,MAAM,UAAU,IAAI,MAAM,MAAM,KAAK,KAAK,CAAC,GAAG,OAAO,IAAI,QAAQ,IAAI,SAAS,IAAI,OAAO,CAAC,CAAC;CAC3F,MAAM,WAAW,IAAI,gBAAgB,SAAS;EAAE,OAAO,MAAM;EAAG,cAAc;EAAO,OAAO;EAAG,eAAe;CAAE,CAAC;CACjH,SAAS,UAAU,GAAG,GAAG,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+ /** These are the units of length that a room record can use. */
4
+ const LENGTH_UNITS = [
5
+ "m",
6
+ "cm",
7
+ "mm",
8
+ "ft",
9
+ "in"
10
+ ];
11
+ /** This function gives the length of one unit in meters. The factor comes from `@mark1russell7/quantity`. */
12
+ function metersPer(unit) {
13
+ return valueIn(quantity(1, unit), "m");
14
+ }
15
+ /** This function gives the length of one unit in a different unit. For example, one foot is 12 inches. */
16
+ function unitsPer(unit, other) {
17
+ return valueIn(quantity(1, unit), other);
18
+ }
19
+ /**
20
+ * The largest length in meters that the model can use: 1 000 km. A larger number in a room record is a mistake.
21
+ * With this limit, each calculation of the model gives a finite number.
22
+ */
23
+ const LARGEST_LENGTH = 1e6;
24
+ /** This function tells if the model can use each value as a length. Such a value is a finite number of meters, with a size of `LARGEST_LENGTH` or less. */
25
+ function lengthsInRange(...meters) {
26
+ return meters.every((value) => Math.abs(value) <= LARGEST_LENGTH);
27
+ }
28
+ export { unitsPer as a, metersPer as i, LENGTH_UNITS as n, lengthsInRange as r, LARGEST_LENGTH as t };
29
+
30
+ //# sourceMappingURL=units-BZmvVyu4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units-BZmvVyu4.js","names":[],"sources":["../src/units.ts"],"sourcesContent":["import { quantity, valueIn } from \"@mark1russell7/quantity\";\n\n/** These are the units of length that a room record can use. */\nexport const LENGTH_UNITS: readonly [\"m\", \"cm\", \"mm\", \"ft\", \"in\"] = [\"m\", \"cm\", \"mm\", \"ft\", \"in\"];\n\n/** A unit of length of a room record. */\nexport type LengthUnit = (typeof LENGTH_UNITS)[number];\n\n/** This function gives the length of one unit in meters. The factor comes from `@mark1russell7/quantity`. */\nexport function metersPer(unit: LengthUnit): number {\n return valueIn(quantity(1, unit), \"m\");\n}\n\n/** This function gives the length of one unit in a different unit. For example, one foot is 12 inches. */\nexport function unitsPer(unit: LengthUnit, other: LengthUnit): number {\n return valueIn(quantity(1, unit), other);\n}\n\n/**\n * The largest length in meters that the model can use: 1 000 km. A larger number in a room record is a mistake.\n * With this limit, each calculation of the model gives a finite number.\n */\nexport const LARGEST_LENGTH = 1e6;\n\n/** This function tells if the model can use each value as a length. Such a value is a finite number of meters, with a size of `LARGEST_LENGTH` or less. */\nexport function lengthsInRange(...meters: readonly number[]): boolean {\n return meters.every((value) => Math.abs(value) <= LARGEST_LENGTH);\n}\n"],"mappings":";;;AAGA,MAAa,eAAuD;CAAC;CAAK;CAAM;CAAM;CAAM;AAAI;;AAMhG,SAAgB,UAAU,MAA0B;CAClD,OAAO,QAAQ,SAAS,GAAG,IAAI,GAAG,GAAG;AACvC;;AAGA,SAAgB,SAAS,MAAkB,OAA2B;CACpE,OAAO,QAAQ,SAAS,GAAG,IAAI,GAAG,KAAK;AACzC;;;;;AAMA,MAAa,iBAAiB;;AAG9B,SAAgB,eAAe,GAAG,QAAoC;CACpE,OAAO,OAAO,OAAO,UAAU,KAAK,IAAI,KAAK,KAAK,cAAc;AAClE"}
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.3.0",
4
+ "version": "0.3.2",
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": {
@@ -52,6 +52,11 @@
52
52
  "import": "./build/marks.js",
53
53
  "default": "./build/marks.js"
54
54
  },
55
+ "./import": {
56
+ "types": "./build/plan-import.d.ts",
57
+ "import": "./build/plan-import.js",
58
+ "default": "./build/plan-import.js"
59
+ },
55
60
  "./package.json": "./package.json"
56
61
  },
57
62
  "files": [
@@ -60,6 +65,7 @@
60
65
  "dependencies": {
61
66
  "@mark1russell7/layout-contract": "^0.10.2",
62
67
  "@mark1russell7/quantity": "^0.4.1",
68
+ "@mark1russell7/rigor-statistics": "^0.2.5",
63
69
  "@mark1russell7/visuals": "^0.3.3",
64
70
  "zod": "^4.6.7"
65
71
  },