@mark1russell7/room-view 0.2.0 → 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,567 +0,0 @@
1
- import { i as metersPer, r as lengthsInRange, t as LARGEST_LENGTH } from "./units-BZmvVyu4.js";
2
- import { boundsOf3, box3Corners, box3Volume, clipRing, composeTransforms3, regionArea, rotationAbout, transformPoint3 } from "@mark1russell7/layout-contract";
3
- // src/frames.ts
4
- /** This function gives the frame of one wall. `scale` is the length of the unit of the room in meters. */
5
- function frameOf(room, wall, scale) {
6
- const start = {
7
- x: wall.from[0] * scale,
8
- y: wall.from[1] * scale
9
- };
10
- const end = {
11
- x: wall.to[0] * scale,
12
- y: wall.to[1] * scale
13
- };
14
- const length = Math.hypot(end.x - start.x, end.y - start.y);
15
- const along = length > 0 && Number.isFinite(length) ? {
16
- x: (end.x - start.x) / length,
17
- y: (end.y - start.y) / length
18
- } : {
19
- x: 1,
20
- y: 0
21
- };
22
- const thickness = (wall.thickness ?? room.wallThickness) * scale;
23
- const side = wall.side ?? "center";
24
- const leftOffset = side === "left" ? thickness : side === "right" ? 0 : thickness / 2;
25
- return {
26
- id: wall.id,
27
- start,
28
- end,
29
- along,
30
- left: {
31
- x: 0 - along.y,
32
- y: along.x
33
- },
34
- length,
35
- thickness,
36
- height: (wall.height ?? room.height) * scale,
37
- leftOffset,
38
- rightOffset: leftOffset - thickness
39
- };
40
- }
41
- /** This function gives the frame of each wall of a room, in the sequence of the walls. */
42
- function wallFrames(room) {
43
- const scale = metersPer(room.unit);
44
- return room.walls.map((wall) => frameOf(room, wall, scale));
45
- }
46
- /**
47
- * This function tells if a wall has an outline in the plan. Its ends and its thickness must be lengths in the range of the model,
48
- * and its length and its thickness must be above 0. Only such a wall makes a corner, and the model makes only such a wall.
49
- */
50
- function wallHasOutline(frame) {
51
- return lengthsInRange(frame.start.x, frame.start.y, frame.end.x, frame.end.y, frame.thickness) && frame.length > 0 && frame.thickness > 0;
52
- }
53
- /** This function gives the point of the plan at a distance along a wall and a distance across it, in meters. */
54
- function wallPoint(frame, along, across) {
55
- return {
56
- x: frame.start.x + frame.along.x * along + frame.left.x * across,
57
- y: frame.start.y + frame.along.y * along + frame.left.y * across
58
- };
59
- }
60
- /**
61
- * This function gives the transform from the frame of a wall to the room.
62
- * In the frame of a wall, x is the distance along the wall and y is the distance across it. The height above the floor is z.
63
- */
64
- function wallTransform(frame) {
65
- return {
66
- position: {
67
- x: frame.start.x,
68
- y: frame.start.y,
69
- z: 0
70
- },
71
- rotation: rotationAbout({
72
- x: 0,
73
- y: 0,
74
- z: 1
75
- }, Math.atan2(frame.along.y, frame.along.x))
76
- };
77
- }
78
- // src/joins.ts
79
- /** The default distance in meters at which two ends of walls make one corner. */
80
- const JOIN_TOLERANCE = 1e-6;
81
- /** The default limit of a sharp corner, in thicknesses. */
82
- const MITER_LIMIT = 4;
83
- /** Two unit vectors with a cross product below this value are parallel. */
84
- const PARALLEL = 1e-9;
85
- /** A corner of an outline with a turn of this value or less is flat, so the outline does not need it. */
86
- const FLAT = 1e-12;
87
- /** Two points at this distance or less are one point. A point at this distance or less from a face of a wall is on the face. */
88
- const SAME = 1e-9;
89
- /** This function gives an option, or its default when the option has no value or a value that is not finite. */
90
- function finiteOr(value, fallback) {
91
- return value !== void 0 && Number.isFinite(value) ? value : fallback;
92
- }
93
- /** This function gives the point at a distance across from the point of an end. */
94
- function across(end, distance) {
95
- return {
96
- x: end.point.x + end.normal.x * distance,
97
- y: end.point.y + end.normal.y * distance
98
- };
99
- }
100
- /** This function makes the two ends of a wall, with square points. */
101
- function endsOf(frame) {
102
- const back = {
103
- x: 0 - frame.along.x,
104
- y: 0 - frame.along.y
105
- };
106
- const right = {
107
- x: 0 - frame.left.x,
108
- y: 0 - frame.left.y
109
- };
110
- const make = (point, out, normal, high, low) => {
111
- const end = {
112
- point,
113
- out,
114
- normal,
115
- high,
116
- low,
117
- thickness: frame.thickness,
118
- highPoint: point,
119
- lowPoint: point,
120
- joined: false
121
- };
122
- end.highPoint = across(end, high);
123
- end.lowPoint = across(end, low);
124
- return end;
125
- };
126
- return [make(frame.start, frame.along, frame.left, frame.leftOffset, frame.rightOffset), make(frame.end, back, right, 0 - frame.rightOffset, 0 - frame.leftOffset)];
127
- }
128
- /** This function gives the point where two lines meet, or `undefined` for parallel lines. Each line has a point and a unit direction. */
129
- function meet(p, d, q, e) {
130
- const cross = d.x * e.y - d.y * e.x;
131
- if (Math.abs(cross) < PARALLEL) return void 0;
132
- const t = ((q.x - p.x) * e.y - (q.y - p.y) * e.x) / cross;
133
- return {
134
- x: p.x + d.x * t,
135
- y: p.y + d.y * t
136
- };
137
- }
138
- /**
139
- * This function makes the corner of the ends at one point. The ends are in sequence counter-clockwise.
140
- * The left face of each end meets the right face of the next end.
141
- */
142
- function joinEnds(ends, miterLimit) {
143
- if (ends.length < 2) return;
144
- for (let i = 0; i < ends.length; i++) {
145
- const end = ends[i];
146
- const next = ends[(i + 1) % ends.length];
147
- end.joined = true;
148
- const corner = meet(across(end, end.high), end.out, across(next, next.low), next.out);
149
- if (corner === void 0) continue;
150
- if (Math.hypot(corner.x - end.point.x, corner.y - end.point.y) > miterLimit * Math.max(end.thickness, next.thickness)) continue;
151
- end.highPoint = corner;
152
- next.lowPoint = corner;
153
- }
154
- }
155
- /** This function gives the part of a ring to the left of the line from `p` to `q`. Two points at one position give the full ring. */
156
- function leftOf(ring, p, q) {
157
- const length = Math.hypot(q.x - p.x, q.y - p.y);
158
- if (length <= SAME) return ring;
159
- const dx = (q.x - p.x) / length;
160
- const dy = (q.y - p.y) / length;
161
- return clipRing(ring, dy, 0 - dx, dy * p.x - dx * p.y);
162
- }
163
- /**
164
- * This function cuts the outline of a wall at one end. An end with no corner gets a square cut.
165
- * An end with a corner keeps the part between the two lines from the point of the corner to the points of the two faces.
166
- */
167
- function cut(ring, end) {
168
- if (!end.joined) return leftOf(ring, end.highPoint, end.lowPoint);
169
- return leftOf(leftOf(ring, end.highPoint, end.point), end.point, end.lowPoint);
170
- }
171
- /** This function removes each corner of a convex outline that is flat or that is a copy of the corner before it. Fewer than 3 corners give an empty outline. */
172
- function withoutFlat(points) {
173
- const ring = [...points];
174
- let changed = true;
175
- while (changed && ring.length >= 3) {
176
- changed = false;
177
- for (let i = 0; i < ring.length && ring.length >= 3; i++) {
178
- const [ax, ay] = ring[(i + ring.length - 1) % ring.length];
179
- const [bx, by] = ring[i];
180
- const [cx, cy] = ring[(i + 1) % ring.length];
181
- if ((bx - ax) * (cy - by) - (by - ay) * (cx - bx) > FLAT) continue;
182
- ring.splice(i, 1);
183
- changed = true;
184
- i--;
185
- }
186
- }
187
- return ring.length >= 3 ? ring : [];
188
- }
189
- /** This function gives the range of the distances along a wall of the corners of an outline that are on one face. */
190
- function faceRange(frame, ring, offset) {
191
- let from = 1e400;
192
- let to = -1e400;
193
- for (const [x, y] of ring) {
194
- const dx = x - frame.start.x;
195
- const dy = y - frame.start.y;
196
- if (Math.abs(dx * frame.left.x + dy * frame.left.y - offset) > SAME) continue;
197
- const along = dx * frame.along.x + dy * frame.along.y;
198
- from = Math.min(from, along);
199
- to = Math.max(to, along);
200
- }
201
- return [from, to];
202
- }
203
- /**
204
- * This function gives the outline of each wall in the plan, in the sequence of the frames.
205
- *
206
- * 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.
207
- * 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.
208
- * 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.
209
- * A wall with no outline (`wallHasOutline`) gets an empty outline, and it makes no corner.
210
- */
211
- function wallFootprints(frames, options = {}) {
212
- const tolerance = finiteOr(options.tolerance, JOIN_TOLERANCE);
213
- const miterLimit = Math.max(finiteOr(options.miterLimit, 4), 0);
214
- const pairs = frames.map((frame) => wallHasOutline(frame) ? endsOf(frame) : void 0);
215
- const corners = [];
216
- for (const pair of pairs) for (const end of pair ?? []) {
217
- const corner = corners.find((ends) => Math.hypot(ends[0].point.x - end.point.x, ends[0].point.y - end.point.y) <= tolerance);
218
- if (corner === void 0) corners.push([end]);
219
- else corner.push(end);
220
- }
221
- for (const ends of corners) {
222
- ends.sort((a, b) => Math.atan2(a.out.y, a.out.x) - Math.atan2(b.out.y, b.out.x));
223
- joinEnds(ends, miterLimit);
224
- }
225
- const thickest = frames.reduce((most, frame, index) => pairs[index] === void 0 ? most : Math.max(most, frame.thickness), 0);
226
- const reach = (miterLimit + 1) * thickest;
227
- return frames.map((frame, index) => {
228
- const pair = pairs[index];
229
- if (pair === void 0) return {
230
- wall: frame.id,
231
- ring: [],
232
- clear: [0, 0]
233
- };
234
- const ring = withoutFlat(cut(cut([
235
- wallPoint(frame, 0 - reach, frame.rightOffset),
236
- wallPoint(frame, frame.length + reach, frame.rightOffset),
237
- wallPoint(frame, frame.length + reach, frame.leftOffset),
238
- wallPoint(frame, 0 - reach, frame.leftOffset)
239
- ].map((point) => [point.x, point.y]), pair[0]), pair[1]));
240
- if (!ring.every(([x, y]) => Number.isFinite(x) && Number.isFinite(y))) return {
241
- wall: frame.id,
242
- ring: [],
243
- clear: [0, 0]
244
- };
245
- const leftFace = faceRange(frame, ring, frame.leftOffset);
246
- const rightFace = faceRange(frame, ring, frame.rightOffset);
247
- const from = Math.max(leftFace[0], rightFace[0]);
248
- const to = Math.min(leftFace[1], rightFace[1]);
249
- return {
250
- wall: frame.id,
251
- ring,
252
- clear: from < to ? [from, to] : [0, 0]
253
- };
254
- });
255
- }
256
- // src/solids.ts
257
- /** These are the kinds of a solid. */
258
- const SOLID_KINDS = [
259
- "floor",
260
- "wall",
261
- "glass",
262
- "outlet",
263
- "object"
264
- ];
265
- /** The default depth of the floor, in meters. */
266
- const FLOOR_DEPTH = .1;
267
- /** The thickness of the glass of a window, in meters. */
268
- const GLASS_THICKNESS = .02;
269
- /** The size of the plate of an outlet, in meters. The plate of a duplex outlet in North America is 70 mm by 115 mm. */
270
- const OUTLET_PLATE = {
271
- width: .07,
272
- height: .115,
273
- depth: .012
274
- };
275
- /**
276
- * The transform from the room, where the z axis points up, to a space where the y axis points up.
277
- * The glTF format and three.js have the y axis up. The x axis stays, and the y axis of the plan becomes the negative z axis.
278
- */
279
- const TO_Y_UP = {
280
- position: {
281
- x: 0,
282
- y: 0,
283
- z: 0
284
- },
285
- rotation: {
286
- x: -Math.SQRT1_2,
287
- y: 0,
288
- z: 0,
289
- w: Math.SQRT1_2
290
- }
291
- };
292
- /** A length in meters at this value or less is empty: the model does not make a part of this size. */
293
- const EMPTY = 1e-9;
294
- /** An area in square meters at this value or less is empty. */
295
- const EMPTY_AREA = 1e-12;
296
- /** This function gives an outline, or an empty ring when the outline has no area or a number that is not finite. */
297
- function solidRing(ring) {
298
- if (ring.length < 3 || !ring.every(([x, y]) => Number.isFinite(x) && Number.isFinite(y))) return [];
299
- return regionArea({
300
- kind: "polygon",
301
- points: ring
302
- }) > EMPTY_AREA ? ring : [];
303
- }
304
- /** This function tells if the model makes a wall. Such a wall has an outline in the plan, and its height is above 0 and in the range of the model. */
305
- function isMade(frame) {
306
- return wallHasOutline(frame) && frame.height > 0 && lengthsInRange(frame.height);
307
- }
308
- /**
309
- * This function gives the openings of one wall that the model can make, in sequence along the wall.
310
- * It skips an opening with no size and an opening out of the straight part of the wall. It also skips an opening that overlaps the opening before it.
311
- */
312
- function holesOf(room, frame, footprint, scale) {
313
- const [clearFrom, clearTo] = footprint.clear;
314
- const holes = (room.openings ?? []).filter((opening) => opening.wall === frame.id).map((opening) => {
315
- const sill = (opening.sill ?? 0) * scale;
316
- return {
317
- id: opening.id,
318
- kind: opening.kind,
319
- from: opening.offset * scale,
320
- to: (opening.offset + opening.width) * scale,
321
- sill,
322
- top: Math.min(sill + opening.height * scale, frame.height)
323
- };
324
- }).filter((hole) => hole.to - hole.from > EMPTY && hole.sill >= 0 && hole.top - hole.sill > EMPTY && hole.from >= clearFrom - EMPTY && hole.to <= clearTo + EMPTY).sort((a, b) => a.from - b.from);
325
- const kept = [];
326
- let cursor = -1e400;
327
- for (const hole of holes) {
328
- if (hole.from < cursor - EMPTY) continue;
329
- kept.push(hole);
330
- cursor = hole.to;
331
- }
332
- return kept;
333
- }
334
- /** This function removes each corner of a ring that is at the position of the corner before it. */
335
- function withoutRepeats(ring) {
336
- return ring.filter(([x, y], index) => {
337
- const [px, py] = ring[(index + ring.length - 1) % ring.length];
338
- return ring.length === 1 || Math.hypot(x - px, y - py) > EMPTY;
339
- });
340
- }
341
- /** This function gives the part of the outline of a wall between two distances along the wall. An empty part gives an empty ring. */
342
- function slice(frame, ring, from, to) {
343
- const base = frame.start.x * frame.along.x + frame.start.y * frame.along.y;
344
- let part = ring;
345
- if (Number.isFinite(from)) part = clipRing(part, 0 - frame.along.x, 0 - frame.along.y, 0 - (base + from));
346
- if (Number.isFinite(to)) part = clipRing(part, frame.along.x, frame.along.y, base + to);
347
- return solidRing(withoutRepeats(part));
348
- }
349
- /** This function gives the solids of one wall: the parts between, below and above its openings, and the glass of each window. */
350
- function wallSolids(room, frame, footprint, scale, depth) {
351
- if (footprint.ring.length < 3 || !isMade(frame)) return [];
352
- const walls = [];
353
- const glass = [];
354
- const add = (ring, z, top) => {
355
- if (ring.length < 3 || top - z <= EMPTY) return;
356
- walls.push({
357
- id: `wall:${frame.id}:${String(walls.length)}`,
358
- kind: "wall",
359
- source: frame.id,
360
- shape: {
361
- kind: "prism",
362
- ring,
363
- z,
364
- d: top - z
365
- }
366
- });
367
- };
368
- let cursor = -1e400;
369
- for (const hole of holesOf(room, frame, footprint, scale)) {
370
- add(slice(frame, footprint.ring, cursor, hole.from), 0 - depth, frame.height);
371
- const part = slice(frame, footprint.ring, hole.from, hole.to);
372
- add(part, 0 - depth, hole.sill);
373
- add(part, hole.top, frame.height);
374
- cursor = hole.to;
375
- if (hole.kind !== "window") continue;
376
- glass.push({
377
- id: `glass:${hole.id}`,
378
- kind: "glass",
379
- source: hole.id,
380
- shape: {
381
- kind: "box",
382
- box: {
383
- x: hole.from,
384
- y: (frame.leftOffset + frame.rightOffset - GLASS_THICKNESS) / 2,
385
- z: hole.sill,
386
- w: hole.to - hole.from,
387
- h: GLASS_THICKNESS,
388
- d: hole.top - hole.sill
389
- },
390
- transform: wallTransform(frame)
391
- }
392
- });
393
- }
394
- add(slice(frame, footprint.ring, cursor, 1e400), 0 - depth, frame.height);
395
- return [...walls, ...glass];
396
- }
397
- /**
398
- * This function gives the 3D model of a room as a list of solids.
399
- * The solids are the floors, the walls with their openings, the glass of the windows and the outlets.
400
- *
401
- * The function does not stop for a record with a fault. It skips each part that it cannot make.
402
- * One example is a wall with no length. A second example is an opening on a wall that the room does not have.
403
- * A third example is a part with a number that is not finite or not in the range of the model (`LARGEST_LENGTH`). `checkRoom` tells each fault.
404
- */
405
- function roomSolids(room, options = {}) {
406
- const scale = metersPer(room.unit);
407
- const given = options.floorDepth ?? .1;
408
- const depth = Number.isFinite(given) ? Math.min(Math.max(given, 0), LARGEST_LENGTH) : FLOOR_DEPTH;
409
- const frames = wallFrames(room);
410
- const footprints = wallFootprints(frames, options.joins);
411
- const solids = [];
412
- for (const floor of room.floors ?? []) {
413
- const ring = solidRing(floor.ring.map(([x, y]) => [x * scale, y * scale]));
414
- if (ring.length < 3 || depth <= EMPTY || !ring.every(([x, y]) => lengthsInRange(x, y))) continue;
415
- solids.push({
416
- id: `floor:${floor.id}`,
417
- kind: "floor",
418
- source: floor.id,
419
- shape: {
420
- kind: "prism",
421
- ring,
422
- z: 0 - depth,
423
- d: depth
424
- }
425
- });
426
- }
427
- frames.forEach((frame, index) => {
428
- solids.push(...wallSolids(room, frame, footprints[index], scale, depth));
429
- });
430
- const byId = new Map(frames.map((frame) => [frame.id, frame]));
431
- for (const outlet of room.outlets ?? []) {
432
- const frame = byId.get(outlet.wall);
433
- if (frame === void 0 || !isMade(frame)) continue;
434
- const along = outlet.offset * scale;
435
- const height = outlet.height * scale;
436
- if (!lengthsInRange(along, height)) continue;
437
- solids.push({
438
- id: `outlet:${outlet.id}`,
439
- kind: "outlet",
440
- source: outlet.id,
441
- shape: {
442
- kind: "box",
443
- box: {
444
- x: along - OUTLET_PLATE.width / 2,
445
- y: outlet.face === "left" ? frame.leftOffset : frame.rightOffset - OUTLET_PLATE.depth,
446
- z: height - OUTLET_PLATE.height / 2,
447
- w: OUTLET_PLATE.width,
448
- h: OUTLET_PLATE.depth,
449
- d: OUTLET_PLATE.height
450
- },
451
- transform: wallTransform(frame)
452
- }
453
- });
454
- }
455
- return solids;
456
- }
457
- /**
458
- * This function gives the transform of each placed object of a scene, from the frame of the object to the room, in meters.
459
- * The origin of the frame of an object is the center of its bottom. An object with a parent gets the transform of the parent first.
460
- * An object has no transform when a parent is not in the scene, or when its parents make a loop.
461
- * An object also has no transform when one value of its place is not finite or not in the range of the model.
462
- */
463
- function objectTransforms(scene) {
464
- const scale = metersPer(scene.room.unit);
465
- const objects = new Map((scene.objects ?? []).map((object) => [object.id, object]));
466
- const done = /* @__PURE__ */ new Map();
467
- const open = /* @__PURE__ */ new Set();
468
- const resolve = (object) => {
469
- const known = done.get(object.id);
470
- if (known !== void 0) return known;
471
- if (open.has(object.id)) return void 0;
472
- const turn = object.turn ?? 0;
473
- const position = {
474
- x: object.at[0] * scale,
475
- y: object.at[1] * scale,
476
- z: (object.lift ?? 0) * scale
477
- };
478
- if (!Number.isFinite(turn) || !lengthsInRange(position.x, position.y, position.z)) return void 0;
479
- const local = {
480
- position,
481
- rotation: rotationAbout({
482
- x: 0,
483
- y: 0,
484
- z: 1
485
- }, turn % 360 * Math.PI / 180)
486
- };
487
- let world = local;
488
- if (object.parent !== void 0) {
489
- open.add(object.id);
490
- const parent = objects.get(object.parent);
491
- const outer = parent === void 0 ? void 0 : resolve(parent);
492
- world = outer === void 0 ? void 0 : composeTransforms3(outer, local);
493
- open.delete(object.id);
494
- }
495
- if (world !== void 0) done.set(object.id, world);
496
- return world;
497
- };
498
- for (const object of scene.objects ?? []) resolve(object);
499
- return done;
500
- }
501
- /**
502
- * This function gives the 3D model of a scene: the solids of its room, then one box for each placed object.
503
- * It skips an object that has no transform, no size, or a size that is not in the range of the model. `checkScene` tells each fault.
504
- */
505
- function sceneSolids(scene, options = {}) {
506
- const scale = metersPer(scene.room.unit);
507
- const transforms = objectTransforms(scene);
508
- const solids = [...roomSolids(scene.room, options)];
509
- for (const object of scene.objects ?? []) {
510
- const transform = transforms.get(object.id);
511
- const w = object.size[0] * scale;
512
- const h = object.size[1] * scale;
513
- const d = object.size[2] * scale;
514
- if (transform === void 0 || ![
515
- w,
516
- h,
517
- d
518
- ].every((size) => size > EMPTY && size <= 1e6)) continue;
519
- solids.push({
520
- id: `object:${object.id}`,
521
- kind: "object",
522
- source: object.id,
523
- shape: {
524
- kind: "box",
525
- box: {
526
- x: 0 - w / 2,
527
- y: 0 - h / 2,
528
- z: 0,
529
- w,
530
- h,
531
- d
532
- },
533
- transform
534
- }
535
- });
536
- }
537
- return solids;
538
- }
539
- /** This function gives the corners of a solid in the room. A box has 8, and a prism has 2 for each corner of its outline. */
540
- function solidCorners(solid) {
541
- const shape = solid.shape;
542
- if (shape.kind === "box") return box3Corners(shape.box).map((corner) => transformPoint3(shape.transform, corner));
543
- return shape.ring.flatMap(([x, y]) => [{
544
- x,
545
- y,
546
- z: shape.z
547
- }, {
548
- x,
549
- y,
550
- z: shape.z + shape.d
551
- }]);
552
- }
553
- /** This function gives the smallest box along the axes that holds each solid, or `undefined` for no solids. */
554
- function boundsOfSolids(solids) {
555
- return boundsOf3(solids.flatMap((solid) => solidCorners(solid)));
556
- }
557
- /** This function gives the volume of a solid in cubic meters. */
558
- function solidVolume(solid) {
559
- const shape = solid.shape;
560
- return shape.kind === "box" ? box3Volume(shape.box) : regionArea({
561
- kind: "polygon",
562
- points: shape.ring
563
- }) * shape.d;
564
- }
565
- export { wallPoint as _, TO_Y_UP as a, roomSolids as c, solidVolume as d, JOIN_TOLERANCE as f, wallHasOutline as g, wallFrames as h, SOLID_KINDS as i, sceneSolids as l, wallFootprints as m, GLASS_THICKNESS as n, boundsOfSolids as o, MITER_LIMIT as p, OUTLET_PLATE as r, objectTransforms as s, FLOOR_DEPTH as t, solidCorners as u, wallTransform as v };
566
-
567
- //# sourceMappingURL=solids-BKb-izIP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"solids-BKb-izIP.js","names":[],"sources":["../src/frames.ts","../src/joins.ts","../src/solids.ts"],"sourcesContent":["import { rotationAbout, type Point, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport type { Room, Wall } from \"./room.ts\";\nimport { lengthsInRange, metersPer } from \"./units.ts\";\n\n/**\n * The frame of a wall, in meters. A point of the wall has a distance along the line and a distance across it.\n * The distance across is positive to the left, for a person who looks from the start to the end.\n */\nexport interface WallFrame {\n /** The `id` of the wall. */\n readonly id: string;\n readonly start: Point;\n readonly end: Point;\n /** The unit vector from the start to the end. A wall with the length 0, or with a length that is not finite, has the vector (1, 0). */\n readonly along: Point;\n /** The unit vector to the left of `along`. */\n readonly left: Point;\n readonly length: number;\n readonly thickness: number;\n readonly height: number;\n /** The distance across of the left face. It is 0 or more. */\n readonly leftOffset: number;\n /** The distance across of the right face. It is 0 or less. */\n readonly rightOffset: number;\n}\n\n/** This function gives the frame of one wall. `scale` is the length of the unit of the room in meters. */\nfunction frameOf(room: Room, wall: Wall, scale: number): WallFrame {\n const start = { x: wall.from[0] * scale, y: wall.from[1] * scale };\n const end = { x: wall.to[0] * scale, y: wall.to[1] * scale };\n const length = Math.hypot(end.x - start.x, end.y - start.y);\n const along = length > 0 && Number.isFinite(length) ? { x: (end.x - start.x) / length, y: (end.y - start.y) / length } : { x: 1, y: 0 };\n const thickness = (wall.thickness ?? room.wallThickness) * scale;\n const side = wall.side ?? \"center\";\n const leftOffset = side === \"left\" ? thickness : side === \"right\" ? 0 : thickness / 2;\n return {\n id: wall.id,\n start,\n end,\n along,\n left: { x: 0 - along.y, y: along.x },\n length,\n thickness,\n height: (wall.height ?? room.height) * scale,\n leftOffset,\n rightOffset: leftOffset - thickness,\n };\n}\n\n/** This function gives the frame of each wall of a room, in the sequence of the walls. */\nexport function wallFrames(room: Room): readonly WallFrame[] {\n const scale = metersPer(room.unit);\n return room.walls.map((wall) => frameOf(room, wall, scale));\n}\n\n/**\n * This function tells if a wall has an outline in the plan. Its ends and its thickness must be lengths in the range of the model,\n * and its length and its thickness must be above 0. Only such a wall makes a corner, and the model makes only such a wall.\n */\nexport function wallHasOutline(frame: WallFrame): boolean {\n return lengthsInRange(frame.start.x, frame.start.y, frame.end.x, frame.end.y, frame.thickness) && frame.length > 0 && frame.thickness > 0;\n}\n\n/** This function gives the point of the plan at a distance along a wall and a distance across it, in meters. */\nexport function wallPoint(frame: WallFrame, along: number, across: number): Point {\n return {\n x: frame.start.x + frame.along.x * along + frame.left.x * across,\n y: frame.start.y + frame.along.y * along + frame.left.y * across,\n };\n}\n\n/**\n * This function gives the transform from the frame of a wall to the room.\n * In the frame of a wall, x is the distance along the wall and y is the distance across it. The height above the floor is z.\n */\nexport function wallTransform(frame: WallFrame): Transform3 {\n return {\n position: { x: frame.start.x, y: frame.start.y, z: 0 },\n rotation: rotationAbout({ x: 0, y: 0, z: 1 }, Math.atan2(frame.along.y, frame.along.x)),\n };\n}\n","import { clipRing, type Point, type Ring } from \"@mark1russell7/layout-contract\";\nimport { wallHasOutline, wallPoint, type WallFrame } from \"./frames.ts\";\n\n/** The outline of one wall in the plan, after its corners with the other walls. */\nexport interface WallFootprint {\n /** The `id` of the wall. */\n readonly wall: string;\n /** The outline in meters, counter-clockwise and convex. It is empty for a wall with no outline (`wallHasOutline`) and for a wall that its corners remove. */\n readonly ring: Ring;\n /**\n * The part of the wall that has its full thickness: two distances along the wall, in meters.\n * An opening must be in this part. A wall with no such part has the two distances 0.\n */\n readonly clear: readonly [number, number];\n}\n\n/** The options of the corners of the walls. */\nexport interface JoinOptions {\n /** Two ends of walls at this distance or less make one corner. The unit is the meter, and the default is 1e-6. A value that is not finite gives the default. */\n readonly tolerance?: number | undefined;\n /**\n * The limit of a sharp corner. The faces of two walls meet at a point. When that point is farther from the corner\n * than this number of thicknesses, the two walls get square ends. The default is 4. A value that is not finite gives the default.\n */\n readonly miterLimit?: number | undefined;\n}\n\n/** The default distance in meters at which two ends of walls make one corner. */\nexport const JOIN_TOLERANCE = 1e-6;\n\n/** The default limit of a sharp corner, in thicknesses. */\nexport const MITER_LIMIT = 4;\n\n/** Two unit vectors with a cross product below this value are parallel. */\nconst PARALLEL = 1e-9;\n\n/** A corner of an outline with a turn of this value or less is flat, so the outline does not need it. */\nconst FLAT = 1e-12;\n\n/** Two points at this distance or less are one point. A point at this distance or less from a face of a wall is on the face. */\nconst SAME = 1e-9;\n\n/**\n * One end of a wall, as a person at the end sees it who looks along the wall.\n * `high` and `low` are the distances of the two faces along `normal`, the unit vector to the left of `out`.\n */\ninterface End {\n readonly point: Point;\n readonly out: Point;\n readonly normal: Point;\n readonly high: number;\n readonly low: number;\n readonly thickness: number;\n /** The points of the two faces at this end. The corners of the walls replace the square points. */\n highPoint: Point;\n lowPoint: Point;\n /** This value tells if the end makes a corner with a different end. */\n joined: boolean;\n}\n\n/** This function gives an option, or its default when the option has no value or a value that is not finite. */\nfunction finiteOr(value: number | undefined, fallback: number): number {\n return value !== undefined && Number.isFinite(value) ? value : fallback;\n}\n\n/** This function gives the point at a distance across from the point of an end. */\nfunction across(end: End, distance: number): Point {\n return { x: end.point.x + end.normal.x * distance, y: end.point.y + end.normal.y * distance };\n}\n\n/** This function makes the two ends of a wall, with square points. */\nfunction endsOf(frame: WallFrame): readonly [End, End] {\n const back = { x: 0 - frame.along.x, y: 0 - frame.along.y };\n const right = { x: 0 - frame.left.x, y: 0 - frame.left.y };\n const make = (point: Point, out: Point, normal: Point, high: number, low: number): End => {\n const end: End = { point, out, normal, high, low, thickness: frame.thickness, highPoint: point, lowPoint: point, joined: false };\n end.highPoint = across(end, high);\n end.lowPoint = across(end, low);\n return end;\n };\n return [\n make(frame.start, frame.along, frame.left, frame.leftOffset, frame.rightOffset),\n make(frame.end, back, right, 0 - frame.rightOffset, 0 - frame.leftOffset),\n ];\n}\n\n/** This function gives the point where two lines meet, or `undefined` for parallel lines. Each line has a point and a unit direction. */\nfunction meet(p: Point, d: Point, q: Point, e: Point): Point | undefined {\n const cross = d.x * e.y - d.y * e.x;\n if (Math.abs(cross) < PARALLEL) return undefined;\n const t = ((q.x - p.x) * e.y - (q.y - p.y) * e.x) / cross;\n return { x: p.x + d.x * t, y: p.y + d.y * t };\n}\n\n/**\n * This function makes the corner of the ends at one point. The ends are in sequence counter-clockwise.\n * The left face of each end meets the right face of the next end.\n */\nfunction joinEnds(ends: readonly End[], miterLimit: number): void {\n if (ends.length < 2) return;\n for (let i = 0; i < ends.length; i++) {\n const end = ends[i]!;\n const next = ends[(i + 1) % ends.length]!;\n end.joined = true;\n const corner = meet(across(end, end.high), end.out, across(next, next.low), next.out);\n if (corner === undefined) continue;\n const reach = Math.hypot(corner.x - end.point.x, corner.y - end.point.y);\n if (reach > miterLimit * Math.max(end.thickness, next.thickness)) continue;\n end.highPoint = corner;\n next.lowPoint = corner;\n }\n}\n\n/** This function gives the part of a ring to the left of the line from `p` to `q`. Two points at one position give the full ring. */\nfunction leftOf(ring: Ring, p: Point, q: Point): Ring {\n const length = Math.hypot(q.x - p.x, q.y - p.y);\n if (length <= SAME) return ring;\n const dx = (q.x - p.x) / length;\n const dy = (q.y - p.y) / length;\n return clipRing(ring, dy, 0 - dx, dy * p.x - dx * p.y);\n}\n\n/**\n * This function cuts the outline of a wall at one end. An end with no corner gets a square cut.\n * An end with a corner keeps the part between the two lines from the point of the corner to the points of the two faces.\n */\nfunction cut(ring: Ring, end: End): Ring {\n if (!end.joined) return leftOf(ring, end.highPoint, end.lowPoint);\n return leftOf(leftOf(ring, end.highPoint, end.point), end.point, end.lowPoint);\n}\n\n/** This function removes each corner of a convex outline that is flat or that is a copy of the corner before it. Fewer than 3 corners give an empty outline. */\nfunction withoutFlat(points: Ring): Ring {\n const ring = [...points];\n let changed = true;\n while (changed && ring.length >= 3) {\n changed = false;\n for (let i = 0; i < ring.length && ring.length >= 3; i++) {\n const [ax, ay] = ring[(i + ring.length - 1) % ring.length]!;\n const [bx, by] = ring[i]!;\n const [cx, cy] = ring[(i + 1) % ring.length]!;\n if ((bx - ax) * (cy - by) - (by - ay) * (cx - bx) > FLAT) continue;\n ring.splice(i, 1);\n changed = true;\n i--;\n }\n }\n return ring.length >= 3 ? ring : [];\n}\n\n/** This function gives the range of the distances along a wall of the corners of an outline that are on one face. */\nfunction faceRange(frame: WallFrame, ring: Ring, offset: number): readonly [number, number] {\n let from = Infinity;\n let to = -Infinity;\n for (const [x, y] of ring) {\n const dx = x - frame.start.x;\n const dy = y - frame.start.y;\n if (Math.abs(dx * frame.left.x + dy * frame.left.y - offset) > SAME) continue;\n const along = dx * frame.along.x + dy * frame.along.y;\n from = Math.min(from, along);\n to = Math.max(to, along);\n }\n return [from, to];\n}\n\n/**\n * This function gives the outline of each wall in the plan, in the sequence of the frames.\n *\n * Two or more ends of walls at one point make a corner. At a corner, the faces of the walls that are adjacent meet at a point.\n * Each wall ends at the lines from the corner to those points. Thus two walls make a miter, and the walls of a corner do not overlap.\n * An end with no other end at its point is square. An end on the face of a different wall is also square: the two walls touch.\n * A wall with no outline (`wallHasOutline`) gets an empty outline, and it makes no corner.\n */\nexport function wallFootprints(frames: readonly WallFrame[], options: JoinOptions = {}): readonly WallFootprint[] {\n const tolerance = finiteOr(options.tolerance, JOIN_TOLERANCE);\n const miterLimit = Math.max(finiteOr(options.miterLimit, MITER_LIMIT), 0);\n const pairs = frames.map((frame) => (wallHasOutline(frame) ? endsOf(frame) : undefined));\n const corners: End[][] = [];\n for (const pair of pairs) {\n for (const end of pair ?? []) {\n const corner = corners.find((ends) => Math.hypot(ends[0]!.point.x - end.point.x, ends[0]!.point.y - end.point.y) <= tolerance);\n if (corner === undefined) corners.push([end]);\n else corner.push(end);\n }\n }\n for (const ends of corners) {\n ends.sort((a, b) => Math.atan2(a.out.y, a.out.x) - Math.atan2(b.out.y, b.out.x));\n joinEnds(ends, miterLimit);\n }\n const thickest = frames.reduce((most, frame, index) => (pairs[index] === undefined ? most : Math.max(most, frame.thickness)), 0);\n const reach = (miterLimit + 1) * thickest;\n return frames.map((frame, index): WallFootprint => {\n const pair = pairs[index];\n if (pair === undefined) return { wall: frame.id, ring: [], clear: [0, 0] };\n const strip = [\n wallPoint(frame, 0 - reach, frame.rightOffset),\n wallPoint(frame, frame.length + reach, frame.rightOffset),\n wallPoint(frame, frame.length + reach, frame.leftOffset),\n wallPoint(frame, 0 - reach, frame.leftOffset),\n ].map((point) => [point.x, point.y] as const);\n const ring = withoutFlat(cut(cut(strip, pair[0]), pair[1]));\n // A very large limit of a sharp corner can make numbers that are not finite. Such an outline is no outline.\n if (!ring.every(([x, y]) => Number.isFinite(x) && Number.isFinite(y))) return { wall: frame.id, ring: [], clear: [0, 0] };\n const leftFace = faceRange(frame, ring, frame.leftOffset);\n const rightFace = faceRange(frame, ring, frame.rightOffset);\n const from = Math.max(leftFace[0], rightFace[0]);\n const to = Math.min(leftFace[1], rightFace[1]);\n return { wall: frame.id, ring, clear: from < to ? [from, to] : [0, 0] };\n });\n}\n","import {\n boundsOf3,\n box3Corners,\n box3Volume,\n clipRing,\n composeTransforms3,\n regionArea,\n rotationAbout,\n transformPoint3,\n type Box3,\n type Point3,\n type Ring,\n type Transform3,\n} from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallHasOutline, wallTransform, type WallFrame } from \"./frames.ts\";\nimport { wallFootprints, type JoinOptions, type WallFootprint } from \"./joins.ts\";\nimport type { OpeningKind, PlacedObject, Room, Scene } from \"./room.ts\";\nimport { LARGEST_LENGTH, lengthsInRange, metersPer } from \"./units.ts\";\n\n/** These are the kinds of a solid. */\nexport const SOLID_KINDS: readonly [\"floor\", \"wall\", \"glass\", \"outlet\", \"object\"] = [\"floor\", \"wall\", \"glass\", \"outlet\", \"object\"];\n\n/** A kind of solid. */\nexport type SolidKind = (typeof SOLID_KINDS)[number];\n\n/** A prism: an outline in the plan, from the height `z` up by `d`. The unit is the meter. */\nexport interface Prism {\n readonly kind: \"prism\";\n readonly ring: Ring;\n readonly z: number;\n readonly d: number;\n}\n\n/** A placed box: a box in its own frame, and the transform from that frame to the room. The unit is the meter. */\nexport interface PlacedBox {\n readonly kind: \"box\";\n readonly box: Box3;\n readonly transform: Transform3;\n}\n\n/** The shape of a solid. */\nexport type SolidShape = Prism | PlacedBox;\n\n/**\n * A solid: one part of the 3D model of a room. The x and y axes are the axes of the plan, and the z axis points up.\n * The floor is at the height 0, and each length is in meters. Each number of a solid is finite, and its volume is above 0.\n */\nexport interface Solid {\n /** The name of the solid. Each solid of a model has a different name. */\n readonly id: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from: a wall, a floor, an opening, an outlet or a placed object. */\n readonly source: string;\n readonly shape: SolidShape;\n}\n\n/** The options of the model of a room. */\nexport interface SolidOptions {\n /** The depth of the floor below the height 0, in meters. The walls go down by the same depth. The default is 0.1. A value that is not finite gives the default. */\n readonly floorDepth?: number | undefined;\n /** The options of the corners of the walls. */\n readonly joins?: JoinOptions | undefined;\n}\n\n/** The default depth of the floor, in meters. */\nexport const FLOOR_DEPTH = 0.1;\n\n/** The thickness of the glass of a window, in meters. */\nexport const GLASS_THICKNESS = 0.02;\n\n/** The size of the plate of an outlet, in meters. The plate of a duplex outlet in North America is 70 mm by 115 mm. */\nexport const OUTLET_PLATE: { readonly width: number; readonly height: number; readonly depth: number } = { width: 0.07, height: 0.115, depth: 0.012 };\n\n/**\n * The transform from the room, where the z axis points up, to a space where the y axis points up.\n * The glTF format and three.js have the y axis up. The x axis stays, and the y axis of the plan becomes the negative z axis.\n */\nexport const TO_Y_UP: Transform3 = { position: { x: 0, y: 0, z: 0 }, rotation: { x: -Math.SQRT1_2, y: 0, z: 0, w: Math.SQRT1_2 } };\n\n/** A length in meters at this value or less is empty: the model does not make a part of this size. */\nconst EMPTY = 1e-9;\n\n/** An area in square meters at this value or less is empty. */\nconst EMPTY_AREA = 1e-12;\n\n/** This function gives an outline, or an empty ring when the outline has no area or a number that is not finite. */\nfunction solidRing(ring: Ring): Ring {\n if (ring.length < 3 || !ring.every(([x, y]) => Number.isFinite(x) && Number.isFinite(y))) return [];\n return regionArea({ kind: \"polygon\", points: ring }) > EMPTY_AREA ? ring : [];\n}\n\n/** This function tells if the model makes a wall. Such a wall has an outline in the plan, and its height is above 0 and in the range of the model. */\nfunction isMade(frame: WallFrame): boolean {\n return wallHasOutline(frame) && frame.height > 0 && lengthsInRange(frame.height);\n}\n\n/** An opening of a wall, in meters, in the frame of the wall. */\ninterface Hole {\n readonly id: string;\n readonly kind: OpeningKind;\n readonly from: number;\n readonly to: number;\n readonly sill: number;\n readonly top: number;\n}\n\n/**\n * This function gives the openings of one wall that the model can make, in sequence along the wall.\n * It skips an opening with no size and an opening out of the straight part of the wall. It also skips an opening that overlaps the opening before it.\n */\nfunction holesOf(room: Room, frame: WallFrame, footprint: WallFootprint, scale: number): readonly Hole[] {\n const [clearFrom, clearTo] = footprint.clear;\n const holes = (room.openings ?? [])\n .filter((opening) => opening.wall === frame.id)\n .map((opening): Hole => {\n const sill = (opening.sill ?? 0) * scale;\n return {\n id: opening.id,\n kind: opening.kind,\n from: opening.offset * scale,\n to: (opening.offset + opening.width) * scale,\n sill,\n top: Math.min(sill + opening.height * scale, frame.height),\n };\n })\n .filter((hole) => hole.to - hole.from > EMPTY && hole.sill >= 0 && hole.top - hole.sill > EMPTY && hole.from >= clearFrom - EMPTY && hole.to <= clearTo + EMPTY)\n .sort((a, b) => a.from - b.from);\n const kept: Hole[] = [];\n let cursor = -Infinity;\n for (const hole of holes) {\n if (hole.from < cursor - EMPTY) continue;\n kept.push(hole);\n cursor = hole.to;\n }\n return kept;\n}\n\n/** This function removes each corner of a ring that is at the position of the corner before it. */\nfunction withoutRepeats(ring: Ring): Ring {\n return ring.filter(([x, y], index) => {\n const [px, py] = ring[(index + ring.length - 1) % ring.length]!;\n return ring.length === 1 || Math.hypot(x - px, y - py) > EMPTY;\n });\n}\n\n/** This function gives the part of the outline of a wall between two distances along the wall. An empty part gives an empty ring. */\nfunction slice(frame: WallFrame, ring: Ring, from: number, to: number): Ring {\n const base = frame.start.x * frame.along.x + frame.start.y * frame.along.y;\n let part = ring;\n if (Number.isFinite(from)) part = clipRing(part, 0 - frame.along.x, 0 - frame.along.y, 0 - (base + from));\n if (Number.isFinite(to)) part = clipRing(part, frame.along.x, frame.along.y, base + to);\n return solidRing(withoutRepeats(part));\n}\n\n/** This function gives the solids of one wall: the parts between, below and above its openings, and the glass of each window. */\nfunction wallSolids(room: Room, frame: WallFrame, footprint: WallFootprint, scale: number, depth: number): readonly Solid[] {\n if (footprint.ring.length < 3 || !isMade(frame)) return [];\n const walls: Solid[] = [];\n const glass: Solid[] = [];\n const add = (ring: Ring, z: number, top: number): void => {\n if (ring.length < 3 || top - z <= EMPTY) return;\n walls.push({ id: `wall:${frame.id}:${String(walls.length)}`, kind: \"wall\", source: frame.id, shape: { kind: \"prism\", ring, z, d: top - z } });\n };\n let cursor = -Infinity;\n for (const hole of holesOf(room, frame, footprint, scale)) {\n add(slice(frame, footprint.ring, cursor, hole.from), 0 - depth, frame.height);\n const part = slice(frame, footprint.ring, hole.from, hole.to);\n add(part, 0 - depth, hole.sill);\n add(part, hole.top, frame.height);\n cursor = hole.to;\n if (hole.kind !== \"window\") continue;\n glass.push({\n id: `glass:${hole.id}`,\n kind: \"glass\",\n source: hole.id,\n shape: {\n kind: \"box\",\n box: {\n x: hole.from,\n y: (frame.leftOffset + frame.rightOffset - GLASS_THICKNESS) / 2,\n z: hole.sill,\n w: hole.to - hole.from,\n h: GLASS_THICKNESS,\n d: hole.top - hole.sill,\n },\n transform: wallTransform(frame),\n },\n });\n }\n add(slice(frame, footprint.ring, cursor, Infinity), 0 - depth, frame.height);\n return [...walls, ...glass];\n}\n\n/**\n * This function gives the 3D model of a room as a list of solids.\n * The solids are the floors, the walls with their openings, the glass of the windows and the outlets.\n *\n * The function does not stop for a record with a fault. It skips each part that it cannot make.\n * One example is a wall with no length. A second example is an opening on a wall that the room does not have.\n * A third example is a part with a number that is not finite or not in the range of the model (`LARGEST_LENGTH`). `checkRoom` tells each fault.\n */\nexport function roomSolids(room: Room, options: SolidOptions = {}): readonly Solid[] {\n const scale = metersPer(room.unit);\n const given = options.floorDepth ?? FLOOR_DEPTH;\n const depth = Number.isFinite(given) ? Math.min(Math.max(given, 0), LARGEST_LENGTH) : FLOOR_DEPTH;\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n const solids: Solid[] = [];\n for (const floor of room.floors ?? []) {\n const ring = solidRing(floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n if (ring.length < 3 || depth <= EMPTY || !ring.every(([x, y]) => lengthsInRange(x, y))) continue;\n solids.push({ id: `floor:${floor.id}`, kind: \"floor\", source: floor.id, shape: { kind: \"prism\", ring, z: 0 - depth, d: depth } });\n }\n frames.forEach((frame, index) => {\n solids.push(...wallSolids(room, frame, footprints[index]!, scale, depth));\n });\n const byId = new Map(frames.map((frame) => [frame.id, frame] as const));\n for (const outlet of room.outlets ?? []) {\n const frame = byId.get(outlet.wall);\n if (frame === undefined || !isMade(frame)) continue;\n const along = outlet.offset * scale;\n const height = outlet.height * scale;\n if (!lengthsInRange(along, height)) continue;\n solids.push({\n id: `outlet:${outlet.id}`,\n kind: \"outlet\",\n source: outlet.id,\n shape: {\n kind: \"box\",\n box: {\n x: along - OUTLET_PLATE.width / 2,\n y: outlet.face === \"left\" ? frame.leftOffset : frame.rightOffset - OUTLET_PLATE.depth,\n z: height - OUTLET_PLATE.height / 2,\n w: OUTLET_PLATE.width,\n h: OUTLET_PLATE.depth,\n d: OUTLET_PLATE.height,\n },\n transform: wallTransform(frame),\n },\n });\n }\n return solids;\n}\n\n/**\n * This function gives the transform of each placed object of a scene, from the frame of the object to the room, in meters.\n * The origin of the frame of an object is the center of its bottom. An object with a parent gets the transform of the parent first.\n * An object has no transform when a parent is not in the scene, or when its parents make a loop.\n * An object also has no transform when one value of its place is not finite or not in the range of the model.\n */\nexport function objectTransforms(scene: Scene): ReadonlyMap<string, Transform3> {\n const scale = metersPer(scene.room.unit);\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n const done = new Map<string, Transform3>();\n const open = new Set<string>();\n const resolve = (object: PlacedObject): Transform3 | undefined => {\n const known = done.get(object.id);\n if (known !== undefined) return known;\n if (open.has(object.id)) return undefined;\n const turn = object.turn ?? 0;\n const position = { x: object.at[0] * scale, y: object.at[1] * scale, z: (object.lift ?? 0) * scale };\n if (!Number.isFinite(turn) || !lengthsInRange(position.x, position.y, position.z)) return undefined;\n // The remainder is exact. Thus a very large turn does not make an angle that is not finite.\n const local: Transform3 = { position, rotation: rotationAbout({ x: 0, y: 0, z: 1 }, ((turn % 360) * Math.PI) / 180) };\n let world: Transform3 | undefined = local;\n if (object.parent !== undefined) {\n open.add(object.id);\n const parent = objects.get(object.parent);\n const outer = parent === undefined ? undefined : resolve(parent);\n world = outer === undefined ? undefined : composeTransforms3(outer, local);\n open.delete(object.id);\n }\n if (world !== undefined) done.set(object.id, world);\n return world;\n };\n for (const object of scene.objects ?? []) resolve(object);\n return done;\n}\n\n/**\n * This function gives the 3D model of a scene: the solids of its room, then one box for each placed object.\n * It skips an object that has no transform, no size, or a size that is not in the range of the model. `checkScene` tells each fault.\n */\nexport function sceneSolids(scene: Scene, options: SolidOptions = {}): readonly Solid[] {\n const scale = metersPer(scene.room.unit);\n const transforms = objectTransforms(scene);\n const solids: Solid[] = [...roomSolids(scene.room, options)];\n for (const object of scene.objects ?? []) {\n const transform = transforms.get(object.id);\n const w = object.size[0] * scale;\n const h = object.size[1] * scale;\n const d = object.size[2] * scale;\n if (transform === undefined || ![w, h, d].every((size) => size > EMPTY && size <= LARGEST_LENGTH)) continue;\n solids.push({\n id: `object:${object.id}`,\n kind: \"object\",\n source: object.id,\n shape: { kind: \"box\", box: { x: 0 - w / 2, y: 0 - h / 2, z: 0, w, h, d }, transform },\n });\n }\n return solids;\n}\n\n/** This function gives the corners of a solid in the room. A box has 8, and a prism has 2 for each corner of its outline. */\nexport function solidCorners(solid: Solid): readonly Point3[] {\n const shape = solid.shape;\n if (shape.kind === \"box\") return box3Corners(shape.box).map((corner) => transformPoint3(shape.transform, corner));\n return shape.ring.flatMap(([x, y]) => [\n { x, y, z: shape.z },\n { x, y, z: shape.z + shape.d },\n ]);\n}\n\n/** This function gives the smallest box along the axes that holds each solid, or `undefined` for no solids. */\nexport function boundsOfSolids(solids: readonly Solid[]): Box3 | undefined {\n return boundsOf3(solids.flatMap((solid) => solidCorners(solid)));\n}\n\n/** This function gives the volume of a solid in cubic meters. */\nexport function solidVolume(solid: Solid): number {\n const shape = solid.shape;\n return shape.kind === \"box\" ? box3Volume(shape.box) : regionArea({ kind: \"polygon\", points: shape.ring }) * shape.d;\n}\n"],"mappings":";;;;AA2BA,SAAS,QAAQ,MAAY,MAAY,OAA0B;CACjE,MAAM,QAAQ;EAAE,GAAG,KAAK,KAAK,KAAK;EAAO,GAAG,KAAK,KAAK,KAAK;CAAM;CACjE,MAAM,MAAM;EAAE,GAAG,KAAK,GAAG,KAAK;EAAO,GAAG,KAAK,GAAG,KAAK;CAAM;CAC3D,MAAM,SAAS,KAAK,MAAM,IAAI,IAAI,MAAM,GAAG,IAAI,IAAI,MAAM,CAAC;CAC1D,MAAM,QAAQ,SAAS,KAAK,OAAO,SAAS,MAAM,IAAI;EAAE,IAAI,IAAI,IAAI,MAAM,KAAK;EAAQ,IAAI,IAAI,IAAI,MAAM,KAAK;CAAO,IAAI;EAAE,GAAG;EAAG,GAAG;CAAE;CACtI,MAAM,aAAa,KAAK,aAAa,KAAK,iBAAiB;CAC3D,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,aAAa,SAAS,SAAS,YAAY,SAAS,UAAU,IAAI,YAAY;CACpF,OAAO;EACL,IAAI,KAAK;EACT;EACA;EACA;EACA,MAAM;GAAE,GAAG,IAAI,MAAM;GAAG,GAAG,MAAM;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