@mark1russell7/room-view 0.1.5 → 0.2.1

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.
@@ -1,6 +1,41 @@
1
+ import { t as WallFrame } from "./frames-BYMK5ZId.js";
1
2
  import { d as Room, p as Scene } from "./room-NREa6vXr.js";
2
- import { n as JoinOptions } from "./joins-2p01wnr_.js";
3
3
  import { Box3, Point3, Ring, Transform3 } from "@mark1russell7/layout-contract";
4
+ /** The outline of one wall in the plan, after its corners with the other walls. */
5
+ interface WallFootprint {
6
+ /** The `id` of the wall. */
7
+ readonly wall: string;
8
+ /** The outline in meters, counter-clockwise and convex. It is empty for a wall with no outline (`wallHasOutline`) and for a wall that its corners remove. */
9
+ readonly ring: Ring;
10
+ /**
11
+ * The part of the wall that has its full thickness: two distances along the wall, in meters.
12
+ * An opening must be in this part. A wall with no such part has the two distances 0.
13
+ */
14
+ readonly clear: readonly [number, number];
15
+ }
16
+ /** The options of the corners of the walls. */
17
+ interface JoinOptions {
18
+ /** Two ends of walls at this distance or less make one corner. The unit is the meter, and the default is 1e-6. A value that is not finite gives the default. */
19
+ readonly tolerance?: number | undefined;
20
+ /**
21
+ * The limit of a sharp corner. The faces of two walls meet at a point. When that point is farther from the corner
22
+ * than this number of thicknesses, the two walls get square ends. The default is 4. A value that is not finite gives the default.
23
+ */
24
+ readonly miterLimit?: number | undefined;
25
+ }
26
+ /** The default distance in meters at which two ends of walls make one corner. */
27
+ declare const JOIN_TOLERANCE = 1e-6;
28
+ /** The default limit of a sharp corner, in thicknesses. */
29
+ declare const MITER_LIMIT = 4;
30
+ /**
31
+ * This function gives the outline of each wall in the plan, in the sequence of the frames.
32
+ *
33
+ * Two or more ends of walls at one point make a corner. At a corner, the faces of the walls that are adjacent meet at a point.
34
+ * Each wall ends at the lines from the corner to those points. Thus two walls make a miter, and the walls of a corner do not overlap.
35
+ * An end with no other end at its point is square. An end on the face of a different wall is also square: the two walls touch.
36
+ * A wall with no outline (`wallHasOutline`) gets an empty outline, and it makes no corner.
37
+ */
38
+ declare function wallFootprints(frames: readonly WallFrame[], options?: JoinOptions): readonly WallFootprint[];
4
39
  /** These are the kinds of a solid. */
5
40
  declare const SOLID_KINDS: readonly ["floor", "wall", "glass", "outlet", "object"];
6
41
  /** A kind of solid. */
@@ -81,74 +116,5 @@ declare function solidCorners(solid: Solid): readonly Point3[];
81
116
  declare function boundsOfSolids(solids: readonly Solid[]): Box3 | undefined;
82
117
  /** This function gives the volume of a solid in cubic meters. */
83
118
  declare function solidVolume(solid: Solid): number;
84
- /** These are the levels of the load of a circuit. */
85
- declare const LOAD_LEVELS: readonly ["unknown", "ok", "near", "over"];
86
- /** A level of the load of a circuit. A viewer gives each level a color. */
87
- type LoadLevel = (typeof LOAD_LEVELS)[number];
88
- /** The state of one circuit of a scene. */
89
- interface CircuitState {
90
- /** The `id` of the circuit. */
91
- readonly circuit: string;
92
- /** The sum of the loads of the circuit, in watts. */
93
- readonly watts: number;
94
- /** The limit of the circuit, in watts. */
95
- readonly limit: number;
96
- /** The load as a part of the limit. It is 0 for a limit that is not above 0. */
97
- readonly ratio: number;
98
- readonly level: LoadLevel;
99
- /** The `id` of each outlet of the circuit. */
100
- readonly outlets: readonly string[];
101
- /** The `id` of each placed object with an outlet of the circuit. */
102
- readonly objects: readonly string[];
103
- }
104
- /** The options of the levels. */
105
- interface LoadOptions {
106
- /** A circuit with this part of its limit, or more, has the level `near`. The default is 0.8. */
107
- readonly near?: number | undefined;
108
- }
109
- /** The default part of the limit at which a circuit has the level `near`. */
110
- declare const NEAR_LIMIT = .8;
111
- /**
112
- * This function gives the state of each circuit of a scene, in the sequence of the circuits.
113
- *
114
- * The loads are input data: a calculation or a meter gives them. A circuit that no load record names has the level `unknown`,
115
- * and so has a circuit with a limit that is not above 0. A load above the limit has the level `over`.
116
- */
117
- declare function circuitStates(scene: Scene, options?: LoadOptions): readonly CircuitState[];
118
- /**
119
- * This function gives the level of each outlet of a scene: the level of its circuit. The key is the `id` of the outlet.
120
- * An outlet with no circuit of the room has no level, and the map does not have it.
121
- */
122
- declare function outletLevels(scene: Scene, options?: LoadOptions): ReadonlyMap<string, LoadLevel>;
123
- /** These are the shapes of the sign of a level. */
124
- declare const LEVEL_SHAPES: readonly ["ring", "disc", "triangle", "square"];
125
- /** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */
126
- type LevelShape = (typeof LEVEL_SHAPES)[number];
127
- /**
128
- * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.
129
- * The level `unknown` has a ring, and so has an outlet with no level.
130
- */
131
- declare function levelShape(level: LoadLevel | undefined): LevelShape;
132
- /** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */
133
- interface ShapeOutline {
134
- /** The radius of the circle through the corners, for a disc with the radius 1. */
135
- readonly radius: number;
136
- /** The number of the sides. */
137
- readonly sides: number;
138
- /** The angle of the first corner, in radians, counter-clockwise from the x axis. */
139
- readonly start: number;
140
- /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */
141
- readonly hole: number;
142
- }
143
- /**
144
- * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.
145
- * A triangle and a square with the radius of the disc look small, so they are larger.
146
- */
147
- declare const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>>;
148
- /**
149
- * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.
150
- * The center of the sign is the origin, and `radius` is the radius of a disc.
151
- */
152
- declare function shapeRing(shape: LevelShape, radius?: number): Ring;
153
- export { solidVolume as A, SolidShape as C, roomSolids as D, objectTransforms as E, sceneSolids as O, SolidOptions as S, boundsOfSolids as T, PlacedBox as _, LoadLevel as a, Solid as b, SHAPE_OUTLINES as c, levelShape as d, outletLevels as f, OUTLET_PLATE as g, GLASS_THICKNESS as h, LevelShape as i, solidCorners as k, ShapeOutline as l, FLOOR_DEPTH as m, LEVEL_SHAPES as n, LoadOptions as o, shapeRing as p, LOAD_LEVELS as r, NEAR_LIMIT as s, CircuitState as t, circuitStates as u, Prism as v, TO_Y_UP as w, SolidKind as x, SOLID_KINDS as y };
154
- //# sourceMappingURL=loads-CriZuwcu.d.ts.map
119
+ export { wallFootprints as S, solidVolume as _, Prism as a, MITER_LIMIT as b, SolidKind as c, TO_Y_UP as d, boundsOfSolids as f, solidCorners as g, sceneSolids as h, PlacedBox as i, SolidOptions as l, roomSolids as m, GLASS_THICKNESS as n, SOLID_KINDS as o, objectTransforms as p, OUTLET_PLATE as r, Solid as s, FLOOR_DEPTH as t, SolidShape as u, JOIN_TOLERANCE as v, WallFootprint as x, JoinOptions as y };
120
+ //# sourceMappingURL=solids-BHLnvDVu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solids-BHLnvDVu.d.ts","names":[],"sources":["../src/joins.ts","../src/solids.ts"],"mappings":";;;;UAIiB;;WAEN;;WAEA,MAAM;;;;;WAKN;;;UAIM;;WAEN;;;;;WAKA;;;cAIE;;cAGA;;;;;;;;;iBA8IG,eAAe,iBAAiB,aAAa,UAAS,uBAA4B;;cCzJrF;;KAGD,oBAAoB;;UAGf;WACN;WACA,MAAM;WACN;WACA;;;UAIM;WACN;WACA,KAAK;WACL,WAAW;;;KAIV,aAAa,QAAQ;;;;;UAMhB;;WAEN;WACA,MAAM;;WAEN;WACA,OAAO;;;UAID;;WAEN;;WAEA,QAAQ;;;cAIN;;cAGA;;cAGA;WAAyB;WAAwB;WAAyB;;;;;;cAM1E,SAAS;;;;;;;;;iBA4HN,WAAW,MAAM,MAAM,UAAS,wBAA6B;;;;;;;iBAiD7D,iBAAiB,OAAO,QAAQ,oBAAoB;;;;;iBAiCpD,YAAY,OAAO,OAAO,UAAS,wBAA6B;;iBAqBhE,aAAa,OAAO,iBAAiB;;iBAUrC,eAAe,iBAAiB,UAAU;;iBAK1C,YAAY,OAAO"}
package/build/three.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { S as SolidOptions, a as LoadLevel, b as Solid, o as LoadOptions, x as SolidKind } from "./loads-CriZuwcu.js";
2
- import { p as Scene$1 } from "./room-NREa6vXr.js";
1
+ import { c as SolidKind, l as SolidOptions, s as Solid } from "./solids-BHLnvDVu.js";
2
+ import { a as LoadLevel, o as LoadOptions } from "./loads-Bp8aH2HJ.js";
3
+ import { p as Scene } from "./room-NREa6vXr.js";
3
4
  import { Point3, Rotation3 } from "@mark1russell7/layout-contract";
4
5
  import { BufferGeometry } from "three";
6
+ import { MarkersOptions } from "@mark1russell7/visuals/markers";
7
+ import { Mark } from "@mark1russell7/visuals/marks";
8
+ import "@mark1russell7/visuals/three";
5
9
  /**
6
10
  * The three.js geometry of a solid, and its place in the room.
7
11
  * The origin of the geometry is the center of the solid. Thus three.js puts clear solids in the correct sequence.
@@ -37,10 +41,17 @@ interface ViewerTheme {
37
41
  readonly glassOpacity: number;
38
42
  /** The color of an outlet with no circuit. */
39
43
  readonly outlet: string;
40
- /** The color of the outlets of a circuit at each level of its load. */
44
+ /** The color of the marks of each level, and of the plates of the outlets of a circuit at each level of its load. */
41
45
  readonly levels: Readonly<Record<LoadLevel, string>>;
42
- /** The color of the line around the marker of an outlet. It is the color of the page, so a marker is clear on each solid. */
46
+ /** 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. */
43
47
  readonly halo: string;
48
+ /**
49
+ * The colors of a field mark, from the value `min` of its scale to the value `max`.
50
+ * A theme with no such list gives a field the color of its level.
51
+ */
52
+ readonly field?: readonly string[] | undefined;
53
+ /** The part of a field mark that is not clear, from 0 to 1. The default is 0.8. */
54
+ readonly fieldOpacity?: number | undefined;
44
55
  /** The color of a placed object whose kind has no color in `objects`. */
45
56
  readonly object: string;
46
57
  /** The color of the placed objects of each kind. The key is the field `kind` of a placed object. */
@@ -70,34 +81,56 @@ interface ViewerPick extends ViewerRecord {
70
81
  type ViewName = "home" | "top";
71
82
  /** The options of a viewer. */
72
83
  interface RoomViewerOptions {
73
- readonly scene: Scene$1;
84
+ readonly scene: Scene;
74
85
  /** The colors. The default is `LIGHT_THEME`. */
75
86
  readonly theme?: ViewerTheme | undefined;
76
87
  /** The options of the model. */
77
88
  readonly solids?: SolidOptions | undefined;
78
89
  /** The options of the levels of the circuits. */
79
90
  readonly loads?: LoadOptions | undefined;
91
+ /** The options of the picture of the marks, for example the radius of a sign. */
92
+ readonly markers?: MarkersOptions | undefined;
93
+ /**
94
+ * The marks of the scene, in the space of the scene: meters, with the z axis up. `layerMarks` of the entry `/marks` gives them.
95
+ * With no list, the viewer makes the marks of the outlets of the scene. An empty list gives a picture with no mark.
96
+ * The viewer draws no mark with a fault. `checkMarks` of `@mark1russell7/visuals/marks` tells each fault.
97
+ */
98
+ readonly marks?: readonly Mark[] | undefined;
80
99
  /** The name of the picture for a screen reader. */
81
100
  readonly label?: string | undefined;
82
- /** The viewer starts this function when the pointer goes to a different record, or to no record. */
83
- readonly onHover?: ((pick: ViewerPick | undefined) => void) | undefined;
84
- /** The viewer starts this function when a person selects a record with the pointer, or selects no record. */
85
- readonly onSelect?: ((pick: ViewerPick | undefined) => void) | undefined;
101
+ /**
102
+ * The viewer starts this function when the pointer goes to a different record, or to no record.
103
+ * `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.
104
+ */
105
+ readonly onHover?: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined;
106
+ /** The viewer starts this function when a person selects a record with the pointer, or selects no record. The parameters are those of `onHover`. */
107
+ readonly onSelect?: ((pick: ViewerPick | undefined, mark?: Mark) => void) | undefined;
86
108
  }
87
109
  /** A viewer of one scene in a page. */
88
110
  interface RoomViewer {
89
111
  /** The canvas of the viewer. It is in the container. */
90
112
  readonly canvas: HTMLCanvasElement;
91
- /** This function shows a different scene. The view stays if a person moved it. */
92
- setScene(scene: Scene$1): void;
113
+ /**
114
+ * This function shows a different scene, with its marks. The view stays if a person moved it.
115
+ * With no list of marks, the viewer makes the marks of the outlets of the scene.
116
+ */
117
+ setScene(scene: Scene, marks?: readonly Mark[]): void;
93
118
  /** This function changes the colors. */
94
119
  setTheme(theme: ViewerTheme): void;
95
120
  /** This function moves the camera to a view that shows all of the model. */
96
121
  setView(view: ViewName): void;
97
- /** This function marks records, as the pointer does. An empty list removes the marks. */
98
- highlight(records: readonly ViewerRecord[]): void;
122
+ /**
123
+ * This function highlights records, as the pointer does. An empty list removes the highlights.
124
+ * A record is a record of a solid, or the record name of a mark, for example `electrical/1:nook-2`.
125
+ */
126
+ highlight(records: readonly (ViewerRecord | string)[]): void;
99
127
  /** This function selects one record, or no record. It does not start `onSelect`. */
100
- select(record: ViewerRecord | undefined): void;
128
+ select(record: ViewerRecord | string | undefined): void;
129
+ /**
130
+ * 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.
131
+ * The test stays for each subsequent scene. A test that accepts each mark shows all of them again.
132
+ */
133
+ showMarks(test: (mark: Mark) => boolean): void;
101
134
  /** This function removes the canvas and releases the memory of the graphics card. */
102
135
  dispose(): void;
103
136
  }
@@ -105,11 +138,12 @@ interface RoomViewer {
105
138
  * 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.
106
139
  *
107
140
  * A person turns the model with a drag, and moves nearer with the wheel after a click in the picture.
108
- * The walls between the camera and the room become almost clear. A click selects the record of a solid.
109
- * Each outlet has a marker with the color and the shape of the level of its circuit. A marker keeps its size in the picture.
110
- * A marked outlet or object shows a line from the outlet to each object that takes its power from it.
141
+ * The walls between the camera and the room become almost clear. A click selects the record of a solid or of a mark.
111
142
  * With the keyboard, the arrow keys turn the model, `+` and `-` change the distance, `Home` shows the first view and `T` shows the plan.
112
143
  *
144
+ * 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.
145
+ * 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.
146
+ *
113
147
  * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.
114
148
  */
115
149
  export declare function createRoomViewer(container: HTMLElement, options: RoomViewerOptions): RoomViewer | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"three.d.ts","names":["Scene"],"sources":["../src/viewer/geometry.ts","../src/viewer/theme.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;;WAEA;;WAEA,SAAS,SAAS;;WAElB;;WAEA;;;qBAIE,aAAa;;qBAiBb,YAAY;;UCtCR;;WAEN,MAAM;;WAEN;;;UAIM,mBAAmB;;WAEzB;;;KAIC;;UAGK;WACN,OAAOA;;WAEP,QAAQ;;WAER,SAAS;;WAET,QAAQ;;WAER;;WAEA,YAAY,MAAM;;WAElB,aAAa,MAAM;;;UAIb;;WAEN,QAAQ;;EAEjB,SAAS,OAAOA;;EAEhB,SAAS,OAAO;;EAEhB,QAAQ,MAAM;;EAEd,UAAU,kBAAkB;;EAE5B,OAAO,QAAQ;;EAEf;;;;;;;;;;;;;wBA2Dc,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;;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"}