@mark1russell7/room-view 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +297 -2
- package/build/index.d.ts +78 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +387 -0
- package/build/index.js.map +1 -0
- package/build/level-84nrw7oL.d.ts +344 -0
- package/build/level-84nrw7oL.d.ts.map +1 -0
- package/build/level-xTO7P1Fn.js +757 -0
- package/build/level-xTO7P1Fn.js.map +1 -0
- package/build/loads-Br73kIsQ.js +667 -0
- package/build/loads-Br73kIsQ.js.map +1 -0
- package/build/loads-H-VFEx6b.d.ts +223 -0
- package/build/loads-H-VFEx6b.d.ts.map +1 -0
- package/build/room-BUlXejkm.d.ts +149 -0
- package/build/room-BUlXejkm.d.ts.map +1 -0
- package/build/sample.d.ts +28 -0
- package/build/sample.d.ts.map +1 -0
- package/build/sample.js +863 -0
- package/build/sample.js.map +1 -0
- package/build/schema.d.ts +24 -0
- package/build/schema.d.ts.map +1 -0
- package/build/schema.js +167 -0
- package/build/schema.js.map +1 -0
- package/build/three.d.ts +117 -0
- package/build/three.d.ts.map +1 -0
- package/build/three.js +1069 -0
- package/build/three.js.map +1 -0
- package/build/units-BZmvVyu4.js +30 -0
- package/build/units-BZmvVyu4.js.map +1 -0
- package/package.json +89 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Russell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,298 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mark1russell7/room-view
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The room format, the scene format, the survey format and the 3D model of a room. A room is measurements, and the code makes the model from them.
|
|
4
|
+
|
|
5
|
+
The entry `/three` shows the model in a page with three.js. [The demo page](https://mark1russell7.github.io/room-view/) shows a sample room.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @mark1russell7/room-view
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The entry `/three` needs the package `three`, version 0.187.0 or later. The other entries do not need it.
|
|
14
|
+
|
|
15
|
+
## A room is measurements
|
|
16
|
+
|
|
17
|
+
A tape measure gives the length of each wall, the position of each door and the height of each window. The room record keeps these numbers, in the unit of the tape measure.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { checkRoom, roomSolids, type Room } from "@mark1russell7/room-view";
|
|
21
|
+
|
|
22
|
+
const room: Room = {
|
|
23
|
+
schema: "room/1",
|
|
24
|
+
unit: "ft",
|
|
25
|
+
height: 8,
|
|
26
|
+
wallThickness: 0.4,
|
|
27
|
+
walls: [
|
|
28
|
+
{ id: "south", from: [0, 0], to: [12, 0], side: "right" },
|
|
29
|
+
{ id: "east", from: [12, 0], to: [12, 10], side: "right" },
|
|
30
|
+
{ id: "north", from: [12, 10], to: [0, 10], side: "right" },
|
|
31
|
+
{ id: "west", from: [0, 10], to: [0, 0], side: "right" },
|
|
32
|
+
],
|
|
33
|
+
openings: [{ id: "door", wall: "south", kind: "door", offset: 1, width: 3, height: 6.8 }],
|
|
34
|
+
floors: [
|
|
35
|
+
{
|
|
36
|
+
id: "floor",
|
|
37
|
+
ring: [
|
|
38
|
+
[0, 0],
|
|
39
|
+
[12, 0],
|
|
40
|
+
[12, 10],
|
|
41
|
+
[0, 10],
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
checkRoom(room); // => []
|
|
48
|
+
roomSolids(room); // => the floor, and the parts of each wall around the door
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- A **wall** is a straight line in the plan, with a thickness and a height. The field `side` tells which side of the line has the wall.
|
|
52
|
+
- An **opening** is a door, a window or a gap in a wall.
|
|
53
|
+
- A **floor** is one area of the plan.
|
|
54
|
+
- An **outlet** is a point on a face of a wall. A **circuit** gives power to outlets, and it has a limit in watts.
|
|
55
|
+
|
|
56
|
+
A scene is one room with its placed objects and the loads of its circuits. A placed object is a box: a desk, a rack, a computer. An object can have a parent, and then its position is relative to the parent.
|
|
57
|
+
|
|
58
|
+
## A survey: the room from a tape measure
|
|
59
|
+
|
|
60
|
+
A person with a tape measure does not know the coordinates of a corner. The person knows the length of each wall and the turn at each corner. A survey record keeps these numbers, in the sequence of a walk around the room.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { checkRoom, expandSurvey, type Survey } from "@mark1russell7/room-view";
|
|
64
|
+
|
|
65
|
+
const survey: Survey = {
|
|
66
|
+
schema: "survey/1",
|
|
67
|
+
unit: "ft",
|
|
68
|
+
height: 8,
|
|
69
|
+
wallThickness: 0.4,
|
|
70
|
+
sides: [
|
|
71
|
+
{ id: "south", length: 12, turn: "left" },
|
|
72
|
+
{ id: "east", length: 10, turn: "left" },
|
|
73
|
+
{ id: "north", length: 12.1, turn: "left" },
|
|
74
|
+
{ id: "west", length: 10, turn: "left" },
|
|
75
|
+
],
|
|
76
|
+
checks: [{ id: "diagonal", from: "south", to: "north", length: 15.7 }],
|
|
77
|
+
openings: [{ id: "door", wall: "south", kind: "door", offset: 1, width: 3, height: 6.8 }],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { room, closure, checks } = expandSurvey(survey);
|
|
81
|
+
closure.closed; // => true: the walk ends 0.1 ft from its start, and the limit is 1 % of its length
|
|
82
|
+
room.walls[0]; // => { id: "south", from: [0, 0], to: [12.05, 0], side: "right" }, with rounded numbers
|
|
83
|
+
checks[0]?.difference; // => 0.04: the measured diagonal is 0.04 ft longer than the diagonal of the room record
|
|
84
|
+
checkRoom(room); // => []
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- A **side** is the inner face of one wall, from a corner to the next corner.
|
|
88
|
+
- A **turn** is `left` or `right` at a square corner, or a measured angle in degrees. The turns `left` and `right` are exact.
|
|
89
|
+
- A measured length has an error, so the walk does not end exactly at its start. `closure` tells the gap.
|
|
90
|
+
- `expandSurvey` shares a small gap between the sides. A room with square corners keeps its square corners.
|
|
91
|
+
- A walk with a mistake is not closed, for example a walk with a wrong turn. Its room has the walls of the walk and no floor, so a drawing shows the mistake.
|
|
92
|
+
- A **check** is a measured distance between two corners, for example a diagonal. The result has its difference from the room record.
|
|
93
|
+
- An opening and an outlet give their `offset` from the first corner of their side, as the tape measure shows it.
|
|
94
|
+
- A side that shares the gap changes its length. Its openings and its outlets keep their place: each `offset` and each `width` changes in the same proportion.
|
|
95
|
+
|
|
96
|
+
The walk goes along the inner faces, so each wall is on the outer side of its line. A survey has one room. A wall in the middle of a room is not a side of the walk, for example the short wall of a nook. Add such a wall to the room record.
|
|
97
|
+
|
|
98
|
+
### The objects of a survey
|
|
99
|
+
|
|
100
|
+
A person measures a desk or a rack from a wall. A survey can have these measurements as objects, and the result has a placed object for each of them.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { checkScene, expandSurvey, type Scene, type Survey } from "@mark1russell7/room-view";
|
|
104
|
+
|
|
105
|
+
const survey: Survey = {
|
|
106
|
+
schema: "survey/1",
|
|
107
|
+
unit: "m",
|
|
108
|
+
height: 2.5,
|
|
109
|
+
wallThickness: 0.15,
|
|
110
|
+
sides: [
|
|
111
|
+
{ id: "south", length: 4, turn: "left" },
|
|
112
|
+
{ id: "east", length: 3, turn: "left" },
|
|
113
|
+
{ id: "north", length: 4, turn: "left" },
|
|
114
|
+
{ id: "west", length: 3, turn: "left" },
|
|
115
|
+
],
|
|
116
|
+
objects: [
|
|
117
|
+
{ id: "desk", kind: "desk", wall: "north", offset: 1, width: 1.6, depth: 0.8, height: 0.75 },
|
|
118
|
+
{ id: "display", kind: "display", on: "desk", offset: 0.5, width: 0.6, depth: 0.2, height: 0.4, gap: 0.1 },
|
|
119
|
+
],
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const { room, objects } = expandSurvey(survey);
|
|
123
|
+
objects[0]; // => { id: "desk", kind: "desk", size: [1.6, 0.8, 0.75], at: [2.2, 2.6], turn: 180 }, with rounded numbers
|
|
124
|
+
objects[1]; // => { id: "display", kind: "display", size: [0.6, 0.2, 0.4], at: [0, -0.2], lift: 0.75, parent: "desk" }, with rounded numbers
|
|
125
|
+
const scene: Scene = { schema: "scene/1", room, objects };
|
|
126
|
+
checkScene(scene); // => []
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- An **object** is a box. `wall` names its side, and `offset` is the distance along the face from the first corner of the side to the object.
|
|
130
|
+
- `width` goes along the wall, and `depth` goes out from the wall. `gap` is the distance from the face to the back of the object.
|
|
131
|
+
- The back of an object is against its wall, so the object gets the turn of its wall.
|
|
132
|
+
- An object with `on` is on a different object or in it. That object is its **holder**: a desk for a display, a rack for a computer.
|
|
133
|
+
- With a holder, `offset` and `gap` start at the edge and the back of the holder. The holder becomes the parent of the placed object.
|
|
134
|
+
- `lift` is the height of the bottom above the floor. With a holder, the default is the top of the holder.
|
|
135
|
+
- `outlet` names the outlet that gives power to the object.
|
|
136
|
+
- An object keeps its size on a side that shares the gap. Only its place changes.
|
|
137
|
+
- An object with no place is not in the result. For example, its side is not in the survey, or a size is not above 0.
|
|
138
|
+
|
|
139
|
+
## A level: the rooms of an apartment
|
|
140
|
+
|
|
141
|
+
A survey has one room, with its own first corner. A level record has the survey of each room, and the connections between the rooms. A connection is one hole through a wall, for example a door. A person measures the hole in each of its two rooms, so each survey has it as an opening.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { checkRoom, expandLevel, type Level, type Survey } from "@mark1russell7/room-view";
|
|
145
|
+
|
|
146
|
+
const hall: Survey = {
|
|
147
|
+
schema: "survey/1",
|
|
148
|
+
name: "Hall",
|
|
149
|
+
unit: "m",
|
|
150
|
+
height: 2.5,
|
|
151
|
+
wallThickness: 0.15,
|
|
152
|
+
sides: [
|
|
153
|
+
{ id: "south", length: 4, turn: "left" },
|
|
154
|
+
{ id: "east", length: 1.2, turn: "left" },
|
|
155
|
+
{ id: "north", length: 4, turn: "left" },
|
|
156
|
+
{ id: "west", length: 1.2, turn: "left" },
|
|
157
|
+
],
|
|
158
|
+
openings: [{ id: "to-study", wall: "east", kind: "door", offset: 0.2, width: 0.8, height: 2.05 }],
|
|
159
|
+
};
|
|
160
|
+
const study: Survey = {
|
|
161
|
+
schema: "survey/1",
|
|
162
|
+
name: "Study",
|
|
163
|
+
unit: "m",
|
|
164
|
+
height: 2.5,
|
|
165
|
+
wallThickness: 0.15,
|
|
166
|
+
sides: [
|
|
167
|
+
{ id: "south", length: 3, turn: "left" },
|
|
168
|
+
{ id: "east", length: 3, turn: "left" },
|
|
169
|
+
{ id: "north", length: 3, turn: "left" },
|
|
170
|
+
{ id: "west", length: 3, turn: "left" },
|
|
171
|
+
],
|
|
172
|
+
openings: [{ id: "to-hall", wall: "west", kind: "door", offset: 1.1, width: 0.8, height: 2.05 }],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const level: Level = {
|
|
176
|
+
schema: "level/1",
|
|
177
|
+
unit: "m",
|
|
178
|
+
rooms: [
|
|
179
|
+
{ id: "hall", survey: hall },
|
|
180
|
+
{ id: "study", survey: study },
|
|
181
|
+
],
|
|
182
|
+
connections: [{ id: "door", from: { room: "hall", opening: "to-study" }, to: { room: "study", opening: "to-hall" }, thickness: 0.1 }],
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const { room, rooms, connections } = expandLevel(level);
|
|
186
|
+
rooms[1]?.survey.start; // => [4.1, -0.9]: the door gives the place of the study
|
|
187
|
+
connections[0]?.fits; // => true
|
|
188
|
+
room.walls[4]?.id; // => "study/south"
|
|
189
|
+
room.floors?.map((floor) => floor.name); // => ["Hall", "Study"]
|
|
190
|
+
checkRoom(room); // => []
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
- The first room keeps the `start` and the `heading` of its survey. Each other room gets its place from a connection.
|
|
194
|
+
- The two walls of a connection are back to back, and the centers of the two openings are opposite.
|
|
195
|
+
- `thickness` is the thickness of the wall at the hole, as a person measures it in the frame of a door. The default is the thickness of the wall of `from`.
|
|
196
|
+
- A connection between two rooms that have a place examines the measurements. Its `gap` and its `turn` tell a mistake, and `fits` tells if they are in the limits.
|
|
197
|
+
- A connection with a fault has the use `none` and a `fault`. For example, an end names an opening that its room does not have.
|
|
198
|
+
- A room with no path of connections to the first room has the place `apart`. Its place is not known, so its group goes to the right of the groups before it.
|
|
199
|
+
- The result has one room record with each room. The `id` of a wall, an opening or an outlet is the `id` of its room, then `/`, then its own `id`.
|
|
200
|
+
- `objects` has the objects of each survey, at the place of their room. The `id` of an object has the same form.
|
|
201
|
+
- Each closed room gives one floor, with the `id` and the name of the room.
|
|
202
|
+
- A survey can have a different unit than the level. `convertSurvey` changes the unit of a survey.
|
|
203
|
+
|
|
204
|
+
Two rooms have one wall between them, but each survey gives the full thickness to its own wall. Thus two walls that are back to back share the wall: each wall gets one half of the distance between the two faces. A wall that is in part an outer wall gets the same thickness along its full length. `checkRoom` examines the room record of a level, and it tells when two rooms overlap.
|
|
205
|
+
|
|
206
|
+
## The model
|
|
207
|
+
|
|
208
|
+
`roomSolids` and `sceneSolids` give the model as a list of solids. Each solid is a prism or a placed box, in meters, with the z axis up.
|
|
209
|
+
|
|
210
|
+
- Two walls with a common end make one corner. The corner has no overlap and no hole.
|
|
211
|
+
- A corner sharper than the option `miterLimit` keeps square ends.
|
|
212
|
+
- An opening removes its part of the wall. A window gets a pane of glass.
|
|
213
|
+
- Each solid has the `id` of the record that it comes from. Thus a viewer can show the record of a solid.
|
|
214
|
+
|
|
215
|
+
`TO_Y_UP` is the transform to a space with the y axis up, for glTF and three.js.
|
|
216
|
+
|
|
217
|
+
## The checks
|
|
218
|
+
|
|
219
|
+
`checkRoom` and `checkScene` give a list of findings. An empty list tells that the record has no fault. They do not throw.
|
|
220
|
+
|
|
221
|
+
| Level | Meaning | Examples |
|
|
222
|
+
| --- | --- | --- |
|
|
223
|
+
| `error` | The model cannot show the record correctly. | An opening that is longer than its wall, an outlet on a wall that the room does not have. |
|
|
224
|
+
| `warning` | The record is possible, but it is probably a mistake. | Two objects that overlap, an object in a wall, an outlet in a door. |
|
|
225
|
+
|
|
226
|
+
Each finding has a code, the kind and the `id` of the record, and a message with the values. `FINDING_CODES` has each code.
|
|
227
|
+
|
|
228
|
+
The model does not stop on a record with faults. It does not make the solids that it cannot make, and the checks tell why.
|
|
229
|
+
|
|
230
|
+
The model has a range of lengths. A size of 0.001 mm or less is 0 for the checks. A length above 1 000 km (`LARGEST_LENGTH`) is a fault, and the model does not make a part with such a length. Thus each number of the model is finite.
|
|
231
|
+
|
|
232
|
+
## The loads of the circuits
|
|
233
|
+
|
|
234
|
+
`circuitStates` gives the load of each circuit against its limit, with a level: `ok`, `near`, `over` or `unknown`. The loads are input data of the scene. This package does not calculate the power of a computer.
|
|
235
|
+
|
|
236
|
+
`outletLevels` gives the level of the circuit of each outlet. `levelShape` gives the shape of the sign of a level. The shapes are a disc for `ok`, a triangle for `near`, a square for `over` and a ring for `unknown`. Thus a person who does not see a color reads the level from the shape. `SHAPE_OUTLINES` and `shapeRing` give the outline of each sign, so each drawing shows the same signs.
|
|
237
|
+
|
|
238
|
+
## The viewer
|
|
239
|
+
|
|
240
|
+
The entry `@mark1russell7/room-view/three` shows a scene in a page with three.js. Install `three` 0.187 or later with this package. For the types, install `@types/three` too.
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import { SAMPLE_SCENE } from "@mark1russell7/room-view/sample";
|
|
244
|
+
import { createRoomViewer, DARK_THEME } from "@mark1russell7/room-view/three";
|
|
245
|
+
|
|
246
|
+
const viewer = createRoomViewer(container, {
|
|
247
|
+
scene: SAMPLE_SCENE,
|
|
248
|
+
onSelect: (pick) => console.log(pick?.kind, pick?.source),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
viewer?.setTheme(DARK_THEME);
|
|
252
|
+
viewer?.highlight([{ kind: "outlet", source: "nook-1" }]);
|
|
253
|
+
viewer?.setView("top");
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
- The viewer fills its container, so give the container a size.
|
|
257
|
+
- A drag turns the model. The wheel changes the distance only after a click in the picture, so the picture does not stop a page that scrolls.
|
|
258
|
+
- The walls between the camera and the room become almost clear.
|
|
259
|
+
- A click selects the record of a solid. `onSelect` gets the kind and the `id` of the record.
|
|
260
|
+
- With the keyboard, the arrow keys turn the model, and `+` and `-` change the distance. `Home` shows the first view, and `T` shows the plan.
|
|
261
|
+
- 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.
|
|
262
|
+
- A marker behind a wall or a machine stays in the picture, and it is less clear.
|
|
263
|
+
- `highlight` and `select` mark records from your page: the outlets of a circuit, or the row of a table.
|
|
264
|
+
- A marked outlet or object shows a line from the outlet to each object that takes its power from it.
|
|
265
|
+
- The option `loads` has the options of `circuitStates`, for example the part of the limit where the level `near` starts.
|
|
266
|
+
- The viewer draws a frame only after a change.
|
|
267
|
+
- `createRoomViewer` gives `undefined` in a browser with no WebGL 2. It does not throw.
|
|
268
|
+
|
|
269
|
+
`LIGHT_THEME` and `DARK_THEME` are the colors, and a theme is plain data. The field `levels` of a theme has the color of each level. `solidGeometry` gives the three.js geometry of one solid, for your own three.js scene.
|
|
270
|
+
|
|
271
|
+
## The plan
|
|
272
|
+
|
|
273
|
+
`planShapes` gives the outline of each solid, as a camera above the room sees it. The list goes from the lowest top to the highest top, so a drawing in this sequence is correct.
|
|
274
|
+
|
|
275
|
+
The option `cut` gives a floor plan: the plan keeps only the solids that start below the height of the cut. Thus a door becomes a gap in its wall. Use the plan for a drawing in SVG, or for a browser with no WebGL 2.
|
|
276
|
+
|
|
277
|
+
## The entries
|
|
278
|
+
|
|
279
|
+
| Entry | What it has |
|
|
280
|
+
| --- | --- |
|
|
281
|
+
| `@mark1russell7/room-view` | The record types, the model, the plan, the checks, the loads, the survey and the level. It has no schema library. |
|
|
282
|
+
| `@mark1russell7/room-view/schema` | `roomSchema`, `sceneSchema`, `surveySchema` and `levelSchema`: the zod schemas that examine the form of a JSON record. |
|
|
283
|
+
| `@mark1russell7/room-view/sample` | `SAMPLE_ROOM`, `SAMPLE_SCENE`, `SAMPLE_SURVEY` and `SAMPLE_LEVEL`: a room with a rack and an apartment of four rooms, for demos and tests. |
|
|
284
|
+
| `@mark1russell7/room-view/three` | `createRoomViewer`, the themes and `solidGeometry`: the viewer in a page. It needs the package `three`. |
|
|
285
|
+
|
|
286
|
+
The schemas examine the form of a record: the fields and their types. The checks examine its meaning. Use the two for a record from a file:
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
import { checkScene } from "@mark1russell7/room-view";
|
|
290
|
+
import { sceneSchema } from "@mark1russell7/room-view/schema";
|
|
291
|
+
|
|
292
|
+
const scene = sceneSchema.parse(JSON.parse(text));
|
|
293
|
+
const errors = checkScene(scene).filter((finding) => finding.level === "error");
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## The geometry
|
|
297
|
+
|
|
298
|
+
`@mark1russell7/layout-contract` gives the points, the boxes, the transforms and the polygon functions. `@mark1russell7/quantity` gives the length units. This package keeps only the room, the scene and their model.
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { C as metersPer, S as lengthsInRange, _ as WallFace, a as Opening, b as LENGTH_UNITS, c as PlacedObject, d as Room, f as SCENE_SCHEMA, g as Wall, h as WALL_SIDES, i as OPENING_KINDS, l as PlanPoint, m as WALL_FACES, n as CircuitLoad, o as OpeningKind, p as Scene, r as Floor, s as Outlet, t as Circuit, u as ROOM_SCHEMA, v as WallSide, w as unitsPer, x as LengthUnit, y as LARGEST_LENGTH } from "./room-BUlXejkm.js";
|
|
2
|
+
import { A as solidVolume, B as wallTransform, C as SolidShape, D as roomSolids, E as objectTransforms, F as wallFootprints, I as WallFrame, L as wallFrames, M as JoinOptions, N as MITER_LIMIT, O as sceneSolids, P as WallFootprint, R as wallHasOutline, S as SolidOptions, T as boundsOfSolids, _ as PlacedBox, a as LoadLevel, b as Solid, c as SHAPE_OUTLINES, d as levelShape, f as outletLevels, g as OUTLET_PLATE, h as GLASS_THICKNESS, i as LevelShape, j as JOIN_TOLERANCE, k as solidCorners, l as ShapeOutline, m as FLOOR_DEPTH, n as LEVEL_SHAPES, o as LoadOptions, p as shapeRing, r as LOAD_LEVELS, s as NEAR_LIMIT, t as CircuitState, u as circuitStates, v as Prism, w as TO_Y_UP, x as SolidKind, y as SOLID_KINDS, z as wallPoint } from "./loads-H-VFEx6b.js";
|
|
3
|
+
import { A as SurveyTurn, C as SurveyCheckResult, D as SurveyOutlet, E as SurveyOptions, M as expandSurvey, O as SurveyResult, S as SurveyCheck, T as SurveyObject, _ as expandLevel, a as ConnectionFault, b as SURVEY_SCHEMA, c as Level, d as LevelOptions, f as LevelResult, g as RoomPlace, h as ROOM_PLACES, i as ConnectionEnd, j as convertSurvey, k as SurveySide, l as LevelConnection, m as LevelRoomResult, n as CONNECTION_TURN_LIMIT, o as ConnectionUse, p as LevelRoom, r as CONNECTION_USES, s as LEVEL_SCHEMA, t as CONNECTION_FAULTS, u as LevelConnectionResult, v as CLOSURE_LIMIT, w as SurveyClosure, x as Survey, y as SQUARE_TURNS } from "./level-84nrw7oL.js";
|
|
4
|
+
import { Ring } from "@mark1russell7/layout-contract";
|
|
5
|
+
/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */
|
|
6
|
+
export interface PlanShape {
|
|
7
|
+
/** The `id` of the solid. */
|
|
8
|
+
readonly solid: string;
|
|
9
|
+
readonly kind: SolidKind;
|
|
10
|
+
/** The `id` of the record that the solid comes from. */
|
|
11
|
+
readonly source: string;
|
|
12
|
+
/** The outline in the plan, in meters. */
|
|
13
|
+
readonly ring: Ring;
|
|
14
|
+
/** The height of the bottom of the solid above the floor, in meters. */
|
|
15
|
+
readonly bottom: number;
|
|
16
|
+
/** The height of the top of the solid above the floor, in meters. */
|
|
17
|
+
readonly top: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* This function gives the outline of a solid in the plan.
|
|
21
|
+
* Each box of a model stands on its bottom face, so the outline of a box is that face.
|
|
22
|
+
*/
|
|
23
|
+
export declare function planShape(solid: Solid): PlanShape;
|
|
24
|
+
/** The options of a plan. */
|
|
25
|
+
export interface PlanOptions extends SolidOptions {
|
|
26
|
+
/**
|
|
27
|
+
* The height of the cut of the plan above the floor, in meters. The plan has only the solids with a bottom below the cut.
|
|
28
|
+
* Thus a cut below the top of a door shows the door as a gap in its wall. Without a cut, the plan has each solid.
|
|
29
|
+
*/
|
|
30
|
+
readonly cut?: number | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This function gives the plan of a scene: the outline of each solid of its model.
|
|
34
|
+
* The sequence goes from the solid with the lowest top to the solid with the highest top.
|
|
35
|
+
* Thus a drawing in this sequence shows the room as a camera above it sees the room.
|
|
36
|
+
*/
|
|
37
|
+
export declare function planShapes(scene: Scene, options?: PlanOptions): readonly PlanShape[];
|
|
38
|
+
/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */
|
|
39
|
+
export declare const FINDING_LEVELS: readonly ["error", "warning"];
|
|
40
|
+
/** A level of a finding. */
|
|
41
|
+
export type FindingLevel = (typeof FINDING_LEVELS)[number];
|
|
42
|
+
/** These are the kinds of the records that a finding can name. */
|
|
43
|
+
export declare const RECORD_KINDS: readonly ["room", "wall", "opening", "floor", "outlet", "circuit", "object", "load"];
|
|
44
|
+
/** A kind of record. */
|
|
45
|
+
export type RecordKind = (typeof RECORD_KINDS)[number];
|
|
46
|
+
/** These are the codes of the findings. */
|
|
47
|
+
export declare const FINDING_CODES: readonly ["number-not-finite", "number-too-large", "id-duplicate", "size-not-positive", "wall-length", "wall-short", "wall-overlap", "opening-wall", "opening-range", "opening-height", "opening-overlap", "outlet-wall", "outlet-circuit", "outlet-range", "outlet-in-opening", "floor-ring", "circuit-limit", "object-parent", "object-cycle", "object-outlet", "object-outside", "object-overlap", "object-in-wall", "load-circuit", "load-watts"];
|
|
48
|
+
/** A code of a finding. */
|
|
49
|
+
export type FindingCode = (typeof FINDING_CODES)[number];
|
|
50
|
+
/** A finding: one fault of a room record or a scene record. */
|
|
51
|
+
export interface Finding {
|
|
52
|
+
readonly level: FindingLevel;
|
|
53
|
+
readonly code: FindingCode;
|
|
54
|
+
/** The kind of the record with the fault. */
|
|
55
|
+
readonly record: RecordKind;
|
|
56
|
+
/** The `id` of the record with the fault. For a load, it is the `id` of the circuit. For the room record, it is empty. */
|
|
57
|
+
readonly at: string;
|
|
58
|
+
/** The fault in plain words, with the values. */
|
|
59
|
+
readonly message: string;
|
|
60
|
+
}
|
|
61
|
+
/** The options of the checks. Give the options that the model gets. */
|
|
62
|
+
export interface CheckOptions {
|
|
63
|
+
/** The options of the corners of the walls. */
|
|
64
|
+
readonly joins?: JoinOptions | undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* This function gives each fault of a room record. A room with no finding of the level `error` gives a full model.
|
|
68
|
+
*
|
|
69
|
+
* The function examines the meaning of the record: for example, an opening must be in its wall. The schema examines the form of the record.
|
|
70
|
+
*/
|
|
71
|
+
export declare function checkRoom(room: Room, options?: CheckOptions): readonly Finding[];
|
|
72
|
+
/**
|
|
73
|
+
* This function gives each fault of a scene record: the faults of its room, then the faults of its placed objects and its loads.
|
|
74
|
+
* A scene with no finding of the level `error` gives a full model.
|
|
75
|
+
*/
|
|
76
|
+
export declare function checkScene(scene: Scene, options?: CheckOptions): readonly Finding[];
|
|
77
|
+
export { CLOSURE_LIMIT, CONNECTION_FAULTS, CONNECTION_TURN_LIMIT, CONNECTION_USES, Circuit, CircuitLoad, CircuitState, ConnectionEnd, ConnectionFault, ConnectionUse, FLOOR_DEPTH, Floor, GLASS_THICKNESS, JOIN_TOLERANCE, JoinOptions, LARGEST_LENGTH, LENGTH_UNITS, LEVEL_SCHEMA, LEVEL_SHAPES, LOAD_LEVELS, LengthUnit, Level, LevelConnection, LevelConnectionResult, LevelOptions, LevelResult, LevelRoom, LevelRoomResult, LevelShape, LoadLevel, LoadOptions, MITER_LIMIT, NEAR_LIMIT, OPENING_KINDS, OUTLET_PLATE, Opening, OpeningKind, Outlet, PlacedBox, PlacedObject, PlanPoint, Prism, ROOM_PLACES, ROOM_SCHEMA, Room, RoomPlace, SCENE_SCHEMA, SHAPE_OUTLINES, SOLID_KINDS, SQUARE_TURNS, SURVEY_SCHEMA, Scene, ShapeOutline, Solid, SolidKind, SolidOptions, SolidShape, Survey, SurveyCheck, SurveyCheckResult, SurveyClosure, SurveyObject, SurveyOptions, SurveyOutlet, SurveyResult, SurveySide, SurveyTurn, TO_Y_UP, WALL_FACES, WALL_SIDES, Wall, WallFace, WallFootprint, WallFrame, WallSide, boundsOfSolids, circuitStates, convertSurvey, expandLevel, expandSurvey, lengthsInRange, levelShape, metersPer, objectTransforms, outletLevels, roomSolids, sceneSolids, shapeRing, solidCorners, solidVolume, unitsPer, wallFootprints, wallFrames, wallHasOutline, wallPoint, wallTransform };
|
|
78
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/plan.ts","../src/check.ts"],"mappings":";;;;;iBAKiB;;WAEN;WACA,MAAM;;WAEN;;WAEA,MAAM;;WAEN;;WAEA;;;;;;wBAOK,UAAU,OAAO,QAAQ;;iBAgBxB,oBAAoB;;;;;WAK1B;;;;;;;wBAQK,WAAW,OAAO,OAAO,UAAS,uBAA4B;;qBC5CjE;;YAGD,uBAAuB;;qBAGtB;;YAYD,qBAAqB;;qBAGpB;;YAuDD,sBAAsB;;iBAGjB;WACN,OAAO;WACP,MAAM;;WAEN,QAAQ;;WAER;;WAEA;;;iBAIM;;WAEN,QAAQ;;;;;;;wBA2CH,UAAU,MAAM,MAAM,UAAS,wBAA6B;;;;;wBAsK5D,WAAW,OAAO,OAAO,UAAS,wBAA6B"}
|