@mark1russell7/room-view 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +36 -34
  2. package/build/{anchors-Ba3OUmhF.js → check-DI_B57qy.js} +10 -233
  3. package/build/check-DI_B57qy.js.map +1 -0
  4. package/build/index.d.ts +4 -5
  5. package/build/index.d.ts.map +1 -1
  6. package/build/index.js +4 -5
  7. package/build/index.js.map +1 -1
  8. package/build/{layers-B5nL_lVW.js → layers-CDNFVXds.js} +161 -5
  9. package/build/layers-CDNFVXds.js.map +1 -0
  10. package/build/{layers-BO_MMtQJ.d.ts → layers-CYZwt1bH.d.ts} +34 -9
  11. package/build/layers-CYZwt1bH.d.ts.map +1 -0
  12. package/build/{level-CXCIX08K.js → level-BERjgyrT.js} +11 -37
  13. package/build/level-BERjgyrT.js.map +1 -0
  14. package/build/{level-Cjcf3u20.d.ts → level-m-mJ_3Ok.d.ts} +11 -19
  15. package/build/level-m-mJ_3Ok.d.ts.map +1 -0
  16. package/build/marks.d.ts +2 -2
  17. package/build/marks.js +1 -2
  18. package/build/marks.js.map +1 -1
  19. package/build/sample.d.ts +4 -4
  20. package/build/sample.d.ts.map +1 -1
  21. package/build/sample.js +21 -217
  22. package/build/sample.js.map +1 -1
  23. package/build/schema.d.ts +59 -9
  24. package/build/schema.d.ts.map +1 -1
  25. package/build/schema.js +250 -91
  26. package/build/schema.js.map +1 -1
  27. package/build/{solids-S_j17vFJ.d.ts → solids-OiTlb_Pm.d.ts} +9 -54
  28. package/build/solids-OiTlb_Pm.d.ts.map +1 -0
  29. package/build/three.d.ts +8 -16
  30. package/build/three.d.ts.map +1 -1
  31. package/build/three.js +12 -106
  32. package/build/three.js.map +1 -1
  33. package/package.json +1 -1
  34. package/build/anchors-Ba3OUmhF.js.map +0 -1
  35. package/build/layers-B5nL_lVW.js.map +0 -1
  36. package/build/layers-BO_MMtQJ.d.ts.map +0 -1
  37. package/build/level-CXCIX08K.js.map +0 -1
  38. package/build/level-Cjcf3u20.d.ts.map +0 -1
  39. package/build/loads-CtHa4EHo.js +0 -103
  40. package/build/loads-CtHa4EHo.js.map +0 -1
  41. package/build/loads-Diy6-Ekz.d.ts +0 -73
  42. package/build/loads-Diy6-Ekz.d.ts.map +0 -1
  43. package/build/solids-S_j17vFJ.d.ts.map +0 -1
package/build/three.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { B as Scene, c as SolidKind, l as SolidOptions, s as Solid } from "./solids-S_j17vFJ.js";
2
- import { a as LoadLevel, o as LoadOptions } from "./loads-Diy6-Ekz.js";
1
+ import { I as Scene, c as SolidOptions, o as Solid, s as SolidKind } from "./solids-OiTlb_Pm.js";
3
2
  import { Point3, Rotation3 } from "@mark1russell7/layout-contract";
4
3
  import { BufferGeometry } from "three";
5
4
  import { MarkersOptions } from "@mark1russell7/visuals/markers";
6
- import { Mark } from "@mark1russell7/visuals/marks";
5
+ import { Level, Mark } from "@mark1russell7/visuals/marks";
7
6
  import "@mark1russell7/visuals/three";
8
7
  /**
9
8
  * The three.js geometry of a solid, and its place in the room.
@@ -38,10 +37,8 @@ interface ViewerTheme {
38
37
  readonly glass: string;
39
38
  /** The part of the glass that is not clear, from 0 to 1. */
40
39
  readonly glassOpacity: number;
41
- /** The color of an outlet with no circuit. */
42
- readonly outlet: string;
43
- /** The color of the marks of each level, and of the plates of the outlets of a circuit at each level of its load. */
44
- readonly levels: Readonly<Record<LoadLevel, string>>;
40
+ /** The color of the marks of each level. */
41
+ readonly levels: Readonly<Record<Level, string>>;
45
42
  /** 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. */
46
43
  readonly halo: string;
47
44
  /**
@@ -64,7 +61,7 @@ interface ViewerTheme {
64
61
  export declare const LIGHT_THEME: ViewerTheme;
65
62
  /** The colors of a blueprint, for a dark page. */
66
63
  export declare const DARK_THEME: ViewerTheme;
67
- /** A record of a scene that the viewer shows: a floor, a wall, a window, an outlet or a placed object. */
64
+ /** A record of a scene that the viewer shows: a floor, a wall, a window or a placed object. */
68
65
  interface ViewerRecord {
69
66
  /** The kind of the solids of the record. A window has the kind `glass`. */
70
67
  readonly kind: SolidKind;
@@ -85,13 +82,11 @@ interface RoomViewerOptions {
85
82
  readonly theme?: ViewerTheme | undefined;
86
83
  /** The options of the model. */
87
84
  readonly solids?: SolidOptions | undefined;
88
- /** The options of the levels of the circuits. */
89
- readonly loads?: LoadOptions | undefined;
90
85
  /** The options of the picture of the marks, for example the radius of a sign. */
91
86
  readonly markers?: MarkersOptions | undefined;
92
87
  /**
93
88
  * The marks of the scene, in the space of the scene: meters, with the z axis up. `layerMarks` of the entry `/marks` gives them.
94
- * With no list, the viewer makes the marks of the outlets of the scene. An empty list gives a picture with no mark.
89
+ * With no list, the picture has no mark.
95
90
  * The viewer draws no mark with a fault. `checkMarks` of `@mark1russell7/visuals/marks` tells each fault.
96
91
  */
97
92
  readonly marks?: readonly Mark[] | undefined;
@@ -109,10 +104,7 @@ interface RoomViewerOptions {
109
104
  interface RoomViewer {
110
105
  /** The canvas of the viewer. It is in the container. */
111
106
  readonly canvas: HTMLCanvasElement;
112
- /**
113
- * This function shows a different scene, with its marks. The view stays if a person moved it.
114
- * With no list of marks, the viewer makes the marks of the outlets of the scene.
115
- */
107
+ /** 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. */
116
108
  setScene(scene: Scene, marks?: readonly Mark[]): void;
117
109
  /** This function changes the colors. */
118
110
  setTheme(theme: ViewerTheme): void;
@@ -141,7 +133,7 @@ interface RoomViewer {
141
133
  * With the keyboard, the arrow keys turn the model, `+` and `-` change the distance, `Home` shows the first view and `T` shows the plan.
142
134
  *
143
135
  * 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.
144
- * 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.
136
+ * 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.
145
137
  *
146
138
  * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.
147
139
  */
@@ -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;;WAEA,QAAQ,SAAS,OAAO;;WAExB;;;;;WAKA;;WAEA;;WAEA;;WAEA,SAAS,SAAS;;WAElB;;WAEA;;;qBAIE,aAAa;;qBAiBb,YAAY;;UC7CR;;WAEN,MAAM;;WAEN;;;UAIM,mBAAmB;;WAEzB;;;KCNC;;UAGK;WACN,OAAO;;WAEP,QAAQ;;WAER,SAAS;;WAET,QAAQ;;WAER,UAAU;;;;;;WAMV,iBAAiB;;WAEjB;;;;;WAKA,YAAY,MAAM,wBAAwB,OAAO;;WAEjD,aAAa,MAAM,wBAAwB,OAAO;;;UAI5C;;WAEN,QAAQ;;;;;EAKjB,SAAS,OAAO,OAAO,iBAAiB;;EAExC,SAAS,OAAO;;EAEhB,QAAQ,MAAM;;;;;EAKd,UAAU,mBAAmB;;EAE7B,OAAO,QAAQ;;;;;EAKf,UAAU,OAAO,MAAM;;EAEvB;;;;;;;;;;;;;;wBAkGc,iBAAiB,WAAW,aAAa,SAAS,oBAAoB"}
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;;WAEA;;WAEA,SAAS,SAAS;;WAElB;;WAEA;;;qBAIE,aAAa;;qBAgBb,YAAY;;UC3CR;;WAEN,MAAM;;WAEN;;;UAIM,mBAAmB;;WAEzB;;;KCPC;;UAGK;WACN,OAAO;;WAEP,QAAQ;;WAER,SAAS;;WAET,UAAU;;;;;;WAMV,iBAAiB;;WAEjB;;;;;WAKA,YAAY,MAAM,wBAAwB,OAAO;;WAEjD,aAAa,MAAM,wBAAwB,OAAO;;;UAI5C;;WAEN,QAAQ;;EAEjB,SAAS,OAAO,OAAO,iBAAiB;;EAExC,SAAS,OAAO;;EAEhB,QAAQ,MAAM;;;;;EAKd,UAAU,mBAAmB;;EAE7B,OAAO,QAAQ;;;;;EAKf,UAAU,OAAO,MAAM;;EAEvB;;;;;;;;;;;;;;wBAkGc,iBAAiB,WAAW,aAAa,SAAS,oBAAoB"}
package/build/three.js CHANGED
@@ -1,6 +1,5 @@
1
- import { A as wallPoint, C as solidCorners, F as metersPer, O as wallFrames, S as sceneSolids, f as recordName, g as OUTLET_PLATE, k as wallHasOutline, p as solidRecord, r as sceneSpace, v as TO_Y_UP, y as boundsOfSolids } from "./anchors-Ba3OUmhF.js";
2
- import { s as outletLevels } from "./loads-CtHa4EHo.js";
3
- import { addPoints3, pointInRing, scalePoint3, transformPoint3 } from "@mark1russell7/layout-contract";
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";
2
+ import { pointInRing, transformPoint3 } from "@mark1russell7/layout-contract";
4
3
  import { BoxGeometry, Color, EdgesGeometry, ExtrudeGeometry, Group, Mesh, MeshLambertMaterial, Shape, Vector2 } from "three";
5
4
  import { fitView } from "@mark1russell7/visuals";
6
5
  import { createMarkers } from "@mark1russell7/visuals/markers";
@@ -77,7 +76,6 @@ const LIGHT_THEME = {
77
76
  wall: "#fcfcfb",
78
77
  glass: "#8fc4e8",
79
78
  glassOpacity: .35,
80
- outlet: "#55677a",
81
79
  levels: {
82
80
  unknown: "#55677a",
83
81
  ok: "#1f5fa8",
@@ -104,7 +102,6 @@ const DARK_THEME = {
104
102
  wall: "#1f4a73",
105
103
  glass: "#9fd0ff",
106
104
  glassOpacity: .25,
107
- outlet: "#a9bfd4",
108
105
  levels: {
109
106
  unknown: "#a9bfd4",
110
107
  ok: "#6fb3f2",
@@ -231,7 +228,6 @@ const EDGE_WIDTH = {
231
228
  floor: 1.25,
232
229
  wall: 1.25,
233
230
  glass: 1,
234
- outlet: 1,
235
231
  object: 1.25
236
232
  };
237
233
  /** The part of a clear box of objects that is not clear. */
@@ -262,11 +258,9 @@ function holders(scene) {
262
258
  * This function makes the three.js objects of a scene: one mesh with its edges for each solid.
263
259
  * The parts have no colors until `paintPart` gives them. The caller disposes the model with `disposeModel`.
264
260
  */
265
- function buildModel(scene, options = {}, loads = {}) {
261
+ function buildModel(scene, options = {}) {
266
262
  const solids = sceneSolids(scene, options);
267
- const levels = outletLevels(scene, loads);
268
263
  const wallOfOpening = new Map((scene.room.openings ?? []).map((opening) => [opening.id, opening.wall]));
269
- const wallOfOutlet = new Map((scene.room.outlets ?? []).map((outlet) => [outlet.id, outlet.wall]));
270
264
  const parentOf = new Map((scene.objects ?? []).map((object) => [object.id, object.parent]));
271
265
  const holding = holders(scene);
272
266
  const group = new Group();
@@ -289,10 +283,9 @@ function buildModel(scene, options = {}, loads = {}) {
289
283
  return {
290
284
  solid,
291
285
  record: solidRecord(solid.kind, solid.source),
292
- wall: solid.kind === "wall" ? solid.source : solid.kind === "glass" ? wallOfOpening.get(solid.source) : solid.kind === "outlet" ? wallOfOutlet.get(solid.source) : void 0,
286
+ wall: solid.kind === "wall" ? solid.source : solid.kind === "glass" ? wallOfOpening.get(solid.source) : void 0,
293
287
  holder: parent === void 0 ? void 0 : solidRecord("object", parent),
294
288
  holds: solid.kind === "object" && holding.has(solid.source),
295
- level: solid.kind === "outlet" ? levels.get(solid.source) : void 0,
296
289
  mesh,
297
290
  lines,
298
291
  fade: 0
@@ -330,7 +323,6 @@ function setOpacity(material, opacity) {
330
323
  /** This function gives the color of a part in a theme, before a mark. */
331
324
  function baseColor(part, scene, theme) {
332
325
  const kind = part.solid.kind;
333
- if (kind === "outlet") return part.level === void 0 ? theme.outlet : theme.levels[part.level];
334
326
  if (kind !== "object") return theme[kind];
335
327
  const object = (scene.objects ?? []).find((candidate) => candidate.id === part.solid.source);
336
328
  return (object === void 0 ? void 0 : theme.objects[object.kind]) ?? theme.object;
@@ -338,7 +330,6 @@ function baseColor(part, scene, theme) {
338
330
  /**
339
331
  * This function gives a part its colors: the colors of the theme, the fade of the part and its highlight.
340
332
  * A part with a highlight has some of the color `accent` of the theme, and a selected part has wide edges.
341
- * An outlet has the color of the level of its circuit.
342
333
  */
343
334
  function paintPart(part, scene, theme, mark) {
344
335
  const kind = part.solid.kind;
@@ -355,7 +346,7 @@ function paintPart(part, scene, theme, mark) {
355
346
  if (kind === "wall") {
356
347
  opacity *= .08 + .92 * still;
357
348
  edge = .3 + .7 * still;
358
- } else if (kind === "glass" || kind === "outlet") {
349
+ } else if (kind === "glass") {
359
350
  opacity *= .35 + .65 * still;
360
351
  edge = .35 + .65 * still;
361
352
  }
@@ -377,14 +368,14 @@ function disposeModel(model) {
377
368
  const FADE_TIME = .11;
378
369
  /**
379
370
  * This function makes the content of a stage that shows the solids of a scene.
380
- * The solids are the floors, the walls, the windows, the plates of the outlets and the placed objects.
371
+ * The solids are the floors, the walls, the windows and the placed objects.
381
372
  *
382
373
  * The walls between the camera and the room become almost clear, and the pointer goes through them.
383
374
  * 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.
384
375
  * The space of the content has the y axis up: the z axis of the scene becomes the y axis.
385
376
  */
386
- function createRoomContent(scene, solids = {}, loads = {}) {
387
- const model = buildModel(scene, solids, loads);
377
+ function createRoomContent(scene, solids = {}) {
378
+ const model = buildModel(scene, solids);
388
379
  const first = /* @__PURE__ */ new Map();
389
380
  for (const part of model.parts) if (!first.has(part.record)) first.set(part.record, part);
390
381
  const byMesh = new Map(model.parts.map((part) => [part.mesh, part]));
@@ -457,91 +448,6 @@ function createRoomContent(scene, solids = {}, loads = {}) {
457
448
  }
458
449
  };
459
450
  }
460
- // src/viewer/outlets.ts
461
- /** This function gives the center of a solid, in the space of the scene: the mean of its corners. */
462
- function centerOf(solid) {
463
- const corners = solidCorners(solid);
464
- const sum = corners.reduce((total, corner) => addPoints3(total, corner), {
465
- x: 0,
466
- y: 0,
467
- z: 0
468
- });
469
- return scalePoint3(sum, 1 / Math.max(corners.length, 1));
470
- }
471
- /**
472
- * This function gives the marks of the outlets of a scene, in the space of the scene: meters, with the z axis up.
473
- *
474
- * - 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.
475
- * - A placed object with an outlet gives a link from that outlet to the center of the object.
476
- *
477
- * The record name of a point is the name of the record of its outlet, so the sign and the plate are one record.
478
- * The record name of a link is the name of the record of its object: that record has the outlet.
479
- * `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.
480
- */
481
- function outletMarks(scene, solids, loads = {}) {
482
- const space = sceneSpace(scene);
483
- const levels = outletLevels(scene, loads);
484
- /** The first solid of each outlet and of each placed object, by the name of its record. */
485
- const made = /* @__PURE__ */ new Map();
486
- for (const solid of solids) {
487
- const name = recordName(solid.kind, solid.source);
488
- if ((solid.kind === "outlet" || solid.kind === "object") && !made.has(name)) made.set(name, solid);
489
- }
490
- const circuits = new Map((scene.room.circuits ?? []).map((circuit) => [circuit.id, circuit.name ?? circuit.id]));
491
- const marks = [];
492
- const fronts = /* @__PURE__ */ new Map();
493
- for (const outlet of scene.room.outlets ?? []) {
494
- if (fronts.has(outlet.id) || !made.has(recordName("outlet", outlet.id))) continue;
495
- const frame = space.frame({
496
- on: "wall",
497
- wall: outlet.wall,
498
- face: outlet.face,
499
- offset: outlet.offset,
500
- height: outlet.height
501
- });
502
- if (frame === void 0) continue;
503
- const front = addPoints3(frame.at, scalePoint3(frame.out, OUTLET_PLATE.depth));
504
- fronts.set(outlet.id, front);
505
- const level = levels.get(outlet.id);
506
- const circuit = level === void 0 || outlet.circuit === void 0 ? "" : `, circuit ${circuits.get(outlet.circuit) ?? outlet.circuit}`;
507
- const point = {
508
- type: "point",
509
- record: recordName("outlet", outlet.id),
510
- kind: "outlet",
511
- level: level ?? "unknown",
512
- label: `Outlet ${outlet.id}${circuit}`.replace(/\s+/g, " ").trim(),
513
- frame: {
514
- at: front,
515
- out: frame.out
516
- }
517
- };
518
- marks.push(point);
519
- }
520
- const linked = /* @__PURE__ */ new Set();
521
- for (const object of scene.objects ?? []) {
522
- const from = object.outlet === void 0 ? void 0 : fronts.get(object.outlet);
523
- const solid = made.get(recordName("object", object.id));
524
- if (object.outlet === void 0 || from === void 0 || solid === void 0 || linked.has(object.id)) continue;
525
- linked.add(object.id);
526
- const link = {
527
- type: "link",
528
- record: recordName("object", object.id),
529
- kind: "feed",
530
- level: levels.get(object.outlet) ?? "unknown",
531
- label: `Outlet ${object.outlet} to ${object.name ?? object.id}`.replace(/\s+/g, " ").trim(),
532
- from: {
533
- record: recordName("outlet", object.outlet),
534
- at: from
535
- },
536
- to: {
537
- record: recordName("object", object.id),
538
- at: centerOf(solid)
539
- }
540
- };
541
- marks.push(link);
542
- }
543
- return marks;
544
- }
545
451
  // src/viewer/viewer.ts
546
452
  /** This function gives the name of a record for the stage. */
547
453
  function nameOf(record) {
@@ -572,12 +478,12 @@ function marksThemes() {
572
478
  /**
573
479
  * This function makes the content of a viewer for a scene: the solids, and the marks above them.
574
480
  *
575
- * `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.
481
+ * `marks` are in the space of the scene: meters, with the z axis up. With no list, the content has no mark.
576
482
  * A mark with a fault is not in the content. The space of the content has the y axis up.
577
483
  */
578
484
  function createViewerContent(scene, marks, options = {}) {
579
- const room = createRoomContent(scene, options.solids, options.loads);
580
- const given = marks ?? outletMarks(scene, room.solids, options.loads);
485
+ const room = createRoomContent(scene, options.solids);
486
+ const given = marks ?? [];
581
487
  const faulty = new Set(checkMarks(given).map((fault) => fault.index));
582
488
  const good = given.filter((_, index) => !faulty.has(index));
583
489
  const onStage = transformMarks(good, TO_Y_UP);
@@ -618,7 +524,7 @@ function createViewerContent(scene, marks, options = {}) {
618
524
  * With the keyboard, the arrow keys turn the model, `+` and `-` change the distance, `Home` shows the first view and `T` shows the plan.
619
525
  *
620
526
  * 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.
621
- * 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.
527
+ * 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.
622
528
  *
623
529
  * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.
624
530
  */
@@ -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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AO,KAAA,GAAW;EACtB,MAAM,CAAC,MAAM,QAAQ,QAAQ,KAAK,KAAK;EACvC,IAAI,SAAS,KAAA,GAAW,GAAG,IAAI;OAC1B,GAAG,MAAM,IAAI;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/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,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M;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"}
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",
4
+ "version": "0.3.0",
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": {