bimatter-viewer-react 0.5.10 → 0.5.11

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/lib/index.js CHANGED
@@ -1,44 +1,44 @@
1
1
  import e, { createContext as t, forwardRef as n, memo as r, useCallback as i, useContext as a, useEffect as o, useImperativeHandle as s, useMemo as c, useRef as l, useState as u } from "react";
2
2
  import { Canvas as d, useFrame as f, useThree as p } from "@react-three/fiber";
3
- import { OrbitControls as m, Stats as h } from "@react-three/drei";
4
- import { Box3 as g, BoxGeometry as _, BufferAttribute as v, BufferGeometry as y, CanvasTexture as b, Color as x, ConeGeometry as S, DataTexture as C, DoubleSide as w, DynamicDrawUsage as T, Float32BufferAttribute as E, Group as D, Line as ee, Line3 as O, LineBasicMaterial as te, LineDashedMaterial as k, LineSegments as ne, LinearFilter as A, MathUtils as re, Matrix4 as j, Mesh as M, MeshBasicMaterial as ie, MeshLambertMaterial as ae, NearestFilter as oe, Object3D as se, OrthographicCamera as ce, PerspectiveCamera as le, Plane as ue, RGBAFormat as de, SRGBColorSpace as fe, Sphere as pe, SphereGeometry as me, Sprite as he, SpriteMaterial as ge, UnsignedByteType as _e, Vector2 as N, Vector3 as P } from "three";
5
- import { useStore as ve } from "zustand";
6
- import { createStore as ye } from "zustand/vanilla";
7
- import { CONTAINED as be, INTERSECTED as xe, MeshBVH as Se, NOT_INTERSECTED as Ce, acceleratedRaycast as we } from "three-mesh-bvh";
8
- import { Fragment as Te, jsx as F, jsxs as I } from "react/jsx-runtime";
9
- import Ee from "pako";
3
+ import { CameraControls as m, Stats as h } from "@react-three/drei";
4
+ import { Box3 as g, BoxGeometry as _, BufferAttribute as v, BufferGeometry as y, CanvasTexture as b, Color as x, ConeGeometry as S, DataTexture as C, DoubleSide as w, DynamicDrawUsage as T, Float32BufferAttribute as E, Group as D, Line as O, Line3 as k, LineBasicMaterial as A, LineDashedMaterial as ee, LineSegments as j, LinearFilter as M, MathUtils as te, Matrix4 as N, Mesh as P, MeshBasicMaterial as ne, MeshLambertMaterial as re, NearestFilter as ie, Object3D as ae, OrthographicCamera as oe, PerspectiveCamera as se, Plane as ce, RGBAFormat as le, SRGBColorSpace as ue, Sphere as de, SphereGeometry as fe, Sprite as pe, SpriteMaterial as me, UnsignedByteType as he, Vector2 as F, Vector3 as I } from "three";
5
+ import { useStore as ge } from "zustand";
6
+ import { createStore as _e } from "zustand/vanilla";
7
+ import { CONTAINED as ve, INTERSECTED as ye, MeshBVH as be, NOT_INTERSECTED as xe, acceleratedRaycast as Se } from "three-mesh-bvh";
8
+ import { Fragment as Ce, jsx as L, jsxs as R } from "react/jsx-runtime";
9
+ import we from "pako";
10
10
  //#region src/viewer/store/ViewerStoreContext.ts
11
- var De = t(null);
11
+ var Te = t(null);
12
12
  //#endregion
13
13
  //#region src/viewer/store/useViewerStore.ts
14
- function L(e) {
15
- return ve(R(), e);
14
+ function z(e) {
15
+ return ge(B(), e);
16
16
  }
17
- function R() {
18
- let e = a(De);
17
+ function B() {
18
+ let e = a(Te);
19
19
  if (!e) throw Error("useViewerStore must be used inside ViewerStoreProvider");
20
20
  return e;
21
21
  }
22
22
  //#endregion
23
23
  //#region src/viewer/store/ViewerStore.ts
24
- var Oe = "rgb(17, 148, 189)", ke = "rgb(104, 198, 227)", Ae = {
24
+ var Ee = "rgb(17, 148, 189)", De = "rgb(104, 198, 227)", Oe = {
25
25
  bottom: !0,
26
26
  left: !0,
27
27
  right: !0,
28
28
  top: !0,
29
29
  visible: !0
30
30
  };
31
- function je() {
32
- return ye((e) => ({
31
+ function ke() {
32
+ return _e((e) => ({
33
33
  api: null,
34
34
  defaultHotkeysEnabled: !0,
35
- gridAxesVisibility: Ae,
35
+ gridAxesVisibility: Oe,
36
36
  modelNames: {},
37
37
  modelProps: {},
38
38
  modelStructure: {},
39
- preselectionColor: ke,
39
+ preselectionColor: De,
40
40
  selected: {},
41
- selectionColor: Oe,
41
+ selectionColor: Ee,
42
42
  selectionInteractionDisabled: !1,
43
43
  showNavCube: !0,
44
44
  showStats: !1,
@@ -119,60 +119,60 @@ function je() {
119
119
  }
120
120
  }));
121
121
  }
122
- var Me = 2;
123
- function Ne() {
124
- let e = new C(new Uint8Array(256 * 4), 256, 1, de, _e);
125
- return e.magFilter = oe, e.minFilter = oe, e.generateMipmaps = !1, e.needsUpdate = !0, Fe(e, 1, new x(Oe)), e;
122
+ var Ae = 2;
123
+ function je() {
124
+ let e = new C(new Uint8Array(256 * 4), 256, 1, le, he);
125
+ return e.magFilter = ie, e.minFilter = ie, e.generateMipmaps = !1, e.needsUpdate = !0, Ne(e, 1, new x(Ee)), e;
126
126
  }
127
- function Pe(e) {
127
+ function Me(e) {
128
128
  return `${e.r.toFixed(6)}:${e.g.toFixed(6)}:${e.b.toFixed(6)}`;
129
129
  }
130
- function Fe(e, t, n) {
130
+ function Ne(e, t, n) {
131
131
  let r = e.image.data, i = t * 4;
132
132
  r[i] = Math.round(n.r * 255), r[i + 1] = Math.round(n.g * 255), r[i + 2] = Math.round(n.b * 255), r[i + 3] = 255, e.needsUpdate = !0;
133
133
  }
134
- function Ie(e) {
134
+ function Pe(e) {
135
135
  return e.mesh.geometry.attributes.colorIndex;
136
136
  }
137
- function Le(e) {
137
+ function Fe(e) {
138
138
  let t = e.mesh.geometry.attributes.ids;
139
139
  if (!t) return null;
140
140
  let n = new v(new Uint8Array(t.count), 1);
141
141
  return e.mesh.geometry.setAttribute("colorIndex", n), n;
142
142
  }
143
- function Re(e, t) {
144
- let n = Ie(e);
145
- return n || t === 0 ? n : Le(e);
143
+ function Ie(e, t) {
144
+ let n = Pe(e);
145
+ return n || t === 0 ? n : Fe(e);
146
146
  }
147
- function ze(e) {
148
- Ie(e) && e.mesh.geometry.deleteAttribute("colorIndex");
147
+ function Le(e) {
148
+ Pe(e) && e.mesh.geometry.deleteAttribute("colorIndex");
149
149
  }
150
- function Be(e, t, n) {
150
+ function Re(e, t, n) {
151
151
  let r = e.get(t);
152
152
  return !r && n && (r = /* @__PURE__ */ new Set(), e.set(t, r)), r;
153
153
  }
154
- function Ve(e, t) {
155
- let n = Re(e.record, t);
154
+ function ze(e, t) {
155
+ let n = Ie(e.record, t);
156
156
  if (!n) return !1;
157
157
  let r = n.array;
158
158
  return e.vertexRanges.forEach(({ count: e, start: n }) => {
159
159
  r.fill(t, n, n + e);
160
160
  }), n.needsUpdate = !0, !0;
161
161
  }
162
- function He(e, t, n, r, i) {
162
+ function Be(e, t, n, r, i) {
163
163
  e && e.forEach((e) => {
164
164
  if (e.record.modelID !== t) return;
165
- let a = Ve(e, r), o = Be(i, e.record, r !== 0 && a);
166
- r === 0 ? (o?.delete(n), o?.size || (i.delete(e.record), ze(e.record))) : a && o?.add(n);
165
+ let a = ze(e, r), o = Re(i, e.record, r !== 0 && a);
166
+ r === 0 ? (o?.delete(n), o?.size || (i.delete(e.record), Le(e.record))) : a && o?.add(n);
167
167
  });
168
168
  }
169
- function Ue(e) {
169
+ function Ve(e) {
170
170
  let t = /* @__PURE__ */ new Set();
171
171
  return Object.entries(e).forEach(([e, n]) => {
172
172
  n.forEach((n) => t.add(`${e}:${n}`));
173
173
  }), t;
174
174
  }
175
- function We(e, t) {
175
+ function He(e, t) {
176
176
  let n = /* @__PURE__ */ new Map(), r = (e) => {
177
177
  let [t, r] = e.split(":").map(Number), i = n.get(t);
178
178
  i || (i = /* @__PURE__ */ new Set(), n.set(t, i)), i.add(r);
@@ -183,28 +183,28 @@ function We(e, t) {
183
183
  t.has(e) || r(e);
184
184
  }), n;
185
185
  }
186
- function Ge(e) {
187
- let t = L((e) => e.selected), n = L((e) => e.selectionColor), r = c(Ne, []), a = l(/* @__PURE__ */ new Map()), s = l(Me), u = l(/* @__PURE__ */ new Map()), d = l(t), f = l(/* @__PURE__ */ new Set()), p = l(/* @__PURE__ */ new WeakMap());
186
+ function Ue(e) {
187
+ let t = z((e) => e.selected), n = z((e) => e.selectionColor), r = c(je, []), a = l(/* @__PURE__ */ new Map()), s = l(Ae), u = l(/* @__PURE__ */ new Map()), d = l(t), f = l(/* @__PURE__ */ new Set()), p = l(/* @__PURE__ */ new WeakMap());
188
188
  o(() => {
189
189
  d.current = t;
190
190
  }, [t]), o(() => () => r.dispose(), [r]), o(() => {
191
- Fe(r, 1, new x(n));
191
+ Ne(r, 1, new x(n));
192
192
  }, [r, n]);
193
193
  let m = i((e, t) => d.current[e]?.has(t) ? 1 : u.current.get(e)?.get(t) ?? 0, []), h = i((t, n) => {
194
194
  let r = e.buildIndex();
195
195
  n.forEach((e) => {
196
- He(r.elementIndex.get(e), t, e, m(t, e), p.current);
196
+ Be(r.elementIndex.get(e), t, e, m(t, e), p.current);
197
197
  });
198
198
  }, [e, m]), g = i((e) => {
199
- let t = new x(e), n = Pe(t), i = a.current.get(n);
199
+ let t = new x(e), n = Me(t), i = a.current.get(n);
200
200
  if (i !== void 0) return i;
201
201
  let o = s.current;
202
202
  if (o >= 256) throw Error("Element color palette is full. Maximum colors: 255.");
203
- return a.current.set(n, o), s.current += 1, Fe(r, o, t), o;
203
+ return a.current.set(n, o), s.current += 1, Ne(r, o, t), o;
204
204
  }, [r]);
205
205
  o(() => {
206
- let e = Ue(t);
207
- We(f.current, e).forEach((e, t) => {
206
+ let e = Ve(t);
207
+ He(f.current, e).forEach((e, t) => {
208
208
  h(t, Array.from(e));
209
209
  }), f.current = e;
210
210
  }, [h, t]);
@@ -232,12 +232,12 @@ function Ge(e) {
232
232
  t.forEach((t) => r(Number(e), t));
233
233
  }), n.forEach((e, n) => {
234
234
  e.forEach((e) => {
235
- He(t.elementIndex.get(e), n, e, m(n, e), p.current);
235
+ Be(t.elementIndex.get(e), n, e, m(n, e), p.current);
236
236
  });
237
237
  });
238
238
  }, [e, m]), S = i(() => {
239
239
  e.buildIndex().records.forEach((e) => {
240
- p.current.delete(e), ze(e);
240
+ p.current.delete(e), Le(e);
241
241
  }), p.current = /* @__PURE__ */ new WeakMap(), u.current.clear(), b();
242
242
  }, [b, e]);
243
243
  return {
@@ -259,12 +259,12 @@ function Ge(e) {
259
259
  }
260
260
  //#endregion
261
261
  //#region src/viewer/SelectableMesh.tsx
262
- M.prototype.raycast = we;
263
- var Ke = e.memo(function({ colorPaletteTexture: e, material: t, data: n, isIfcSpace: r = !1, meshMatrix: i }) {
264
- let a = l(null), s = L((e) => e.preselectionColor), u = l(s);
262
+ P.prototype.raycast = Se;
263
+ var We = e.memo(function({ colorPaletteTexture: e, material: t, data: n, isIfcSpace: r = !1, meshMatrix: i }) {
264
+ let a = l(null), s = z((e) => e.preselectionColor), u = l(s);
265
265
  u.current = s;
266
266
  let d = c(() => {
267
- let n = new ae({
267
+ let n = new re({
268
268
  color: new x(t.r, t.g, t.b),
269
269
  transparent: !!(t.opacity && t.opacity != 1),
270
270
  opacity: t.opacity ?? 1,
@@ -298,11 +298,11 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, data: n, isIfcSp
298
298
  e && (e.value instanceof x ? e.value.set(s) : e.value = new x(s));
299
299
  }, [d, s]), o(() => {
300
300
  if (!a.current) return;
301
- let e = a.current.geometry, t = new Se(e, { indirect: !0 });
301
+ let e = a.current.geometry, t = new be(e, { indirect: !0 });
302
302
  return Object.assign(e, { boundsTree: t }), () => {
303
303
  d.dispose(), Object.assign(e, { boundsTree: null });
304
304
  };
305
- }, [d]), /* @__PURE__ */ I("mesh", {
305
+ }, [d]), /* @__PURE__ */ R("mesh", {
306
306
  matrix: i,
307
307
  matrixAutoUpdate: !1,
308
308
  name: r ? "space" : void 0,
@@ -312,38 +312,38 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, data: n, isIfcSp
312
312
  let t = e.object;
313
313
  t.preselected &&= !1;
314
314
  },
315
- children: [/* @__PURE__ */ I("bufferGeometry", { children: [
316
- /* @__PURE__ */ F("bufferAttribute", {
315
+ children: [/* @__PURE__ */ R("bufferGeometry", { children: [
316
+ /* @__PURE__ */ L("bufferAttribute", {
317
317
  attach: "attributes-position",
318
318
  args: [n.pos, 3]
319
319
  }),
320
- n.norm && /* @__PURE__ */ F("bufferAttribute", {
320
+ n.norm && /* @__PURE__ */ L("bufferAttribute", {
321
321
  attach: "attributes-normal",
322
322
  args: [n.norm, 3]
323
323
  }),
324
- /* @__PURE__ */ F("bufferAttribute", {
324
+ /* @__PURE__ */ L("bufferAttribute", {
325
325
  attach: "attributes-ids",
326
326
  args: [n.ids, 1]
327
327
  }),
328
- /* @__PURE__ */ F("bufferAttribute", {
328
+ /* @__PURE__ */ L("bufferAttribute", {
329
329
  attach: "index",
330
330
  args: [n.ind, 1]
331
331
  })
332
- ] }), /* @__PURE__ */ F("primitive", { object: d })]
332
+ ] }), /* @__PURE__ */ L("primitive", { object: d })]
333
333
  });
334
- }), qe = 10, Je = "#1d2733", Ye = 2, Xe = .05, Ze = "\0", Qe = /* @__PURE__ */ new Map();
335
- function $e() {
334
+ }), Ge = 10, Ke = "#1d2733", qe = 2, Je = .05, Ye = "\0", Xe = /* @__PURE__ */ new Map();
335
+ function Ze() {
336
336
  return typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2);
337
337
  }
338
- function et(e, t, n, r) {
339
- let i = $e(), a = document.createElement("canvas"), o = a.getContext("2d");
338
+ function Qe(e, t, n, r) {
339
+ let i = Ze(), a = document.createElement("canvas"), o = a.getContext("2d");
340
340
  if (!o) throw Error("Could not create grid label canvas context");
341
341
  let s = `400 ${r}px system-ui, "Segoe UI", sans-serif`, c = Math.ceil(r * .5), l = Math.ceil(r * .35);
342
342
  o.font = s;
343
343
  let u = o.measureText(t), d = u.actualBoundingBoxAscent || r * .8, f = u.actualBoundingBoxDescent || r * .2, p = Math.max(1, Math.ceil(u.width + c * 2)), m = Math.max(1, Math.ceil(d + f + l * 2));
344
344
  a.width = Math.ceil(p * i), a.height = Math.ceil(m * i), o.scale(i, i), o.clearRect(0, 0, p, m), o.font = s, o.fillStyle = n, o.textAlign = "left", o.textBaseline = "alphabetic", o.fillText(t, c, l + d);
345
345
  let h = new b(a);
346
- return h.colorSpace = fe, h.generateMipmaps = !1, h.magFilter = A, h.minFilter = A, h.needsUpdate = !0, {
346
+ return h.colorSpace = ue, h.generateMipmaps = !1, h.magFilter = M, h.minFilter = M, h.needsUpdate = !0, {
347
347
  disposeTimer: null,
348
348
  height: m,
349
349
  key: e,
@@ -352,49 +352,49 @@ function et(e, t, n, r) {
352
352
  width: p
353
353
  };
354
354
  }
355
- function tt(e, t, n) {
355
+ function $e(e, t, n) {
356
356
  let r = [
357
357
  e,
358
358
  t,
359
359
  n
360
- ].join(Ze), i = Qe.get(r);
361
- return i || (i = et(r, e, t, n), Qe.set(r, i)), i;
360
+ ].join(Ye), i = Xe.get(r);
361
+ return i || (i = Qe(r, e, t, n), Xe.set(r, i)), i;
362
362
  }
363
- function nt(e, t, n) {
364
- let r = c(() => tt(e, t, n), [
363
+ function et(e, t, n) {
364
+ let r = c(() => $e(e, t, n), [
365
365
  t,
366
366
  n,
367
367
  e
368
368
  ]);
369
369
  return o(() => (r.disposeTimer &&= (clearTimeout(r.disposeTimer), null), r.refs++, () => {
370
370
  r.refs = Math.max(0, r.refs - 1), r.refs <= 0 && (r.disposeTimer = setTimeout(() => {
371
- r.refs > 0 || (r.texture.dispose(), Qe.delete(r.key), r.disposeTimer = null);
371
+ r.refs > 0 || (r.texture.dispose(), Xe.delete(r.key), r.disposeTimer = null);
372
372
  }, 1e3));
373
373
  }), [r]), r;
374
374
  }
375
- function rt(e, t, n, r) {
375
+ function tt(e, t, n, r) {
376
376
  let i = Math.abs(n.projectionMatrix.elements[5]) || 1, a = t.height * 2 / (Math.max(1, r) * i), o = a * (t.width / t.height);
377
377
  e.scale.set(o, a, 1);
378
378
  }
379
- function it(e, t) {
379
+ function nt(e, t) {
380
380
  let n = e[t];
381
381
  return n === void 0 ? 0 : Number.isFinite(n) ? n : null;
382
382
  }
383
- function z(e, t) {
384
- return it(e, t) ?? 0;
383
+ function V(e, t) {
384
+ return nt(e, t) ?? 0;
385
385
  }
386
- function at(e) {
387
- let t = it(e, "x"), n = it(e, "y"), r = it(e, "z");
388
- return t === null || n === null || r === null ? null : new P(t, n, r);
386
+ function rt(e) {
387
+ let t = nt(e, "x"), n = nt(e, "y"), r = nt(e, "z");
388
+ return t === null || n === null || r === null ? null : new I(t, n, r);
389
389
  }
390
- function ot(e, t) {
390
+ function it(e, t) {
391
391
  return [
392
- z(e, "x"),
393
- t !== void 0 && Number.isFinite(t) ? t : z(e, "y"),
394
- z(e, "z")
392
+ V(e, "x"),
393
+ t !== void 0 && Number.isFinite(t) ? t : V(e, "y"),
394
+ V(e, "z")
395
395
  ];
396
396
  }
397
- function st(e) {
397
+ function at(e) {
398
398
  let { h: t, l: n } = e.getHSL({
399
399
  h: 0,
400
400
  s: 0,
@@ -402,14 +402,14 @@ function st(e) {
402
402
  });
403
403
  return t < .55 && n >= .5 || t >= .55 && n >= .75 ? "#000000" : "#ffffff";
404
404
  }
405
- function ct(e) {
405
+ function ot(e) {
406
406
  let t = p((e) => e.scene.background);
407
- return c(() => e || (t instanceof x ? st(t) : Je), [t, e]);
407
+ return c(() => e || (t instanceof x ? at(t) : Ke), [t, e]);
408
408
  }
409
- function lt({ axis: e, grid: t, endSide: n, startSide: r }) {
409
+ function st({ axis: e, grid: t, endSide: n, startSide: r }) {
410
410
  return Object.entries(e).flatMap(([e, i]) => {
411
411
  if (i.length < 2) return [];
412
- let a = at(i[0]), o = at(i[1]);
412
+ let a = rt(i[0]), o = rt(i[1]);
413
413
  return !a || !o ? [] : (a.y = 0, o.y = 0, [{
414
414
  endSide: n,
415
415
  loc: t.loc,
@@ -419,18 +419,18 @@ function lt({ axis: e, grid: t, endSide: n, startSide: r }) {
419
419
  }]);
420
420
  });
421
421
  }
422
- function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight: i, showTop: a }) {
422
+ function ct({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight: i, showTop: a }) {
423
423
  let o = {
424
424
  bottom: n,
425
425
  left: r,
426
426
  right: i,
427
427
  top: a
428
- }, s = Object.values(t).flatMap((e) => [...lt({
428
+ }, s = Object.values(t).flatMap((e) => [...st({
429
429
  axis: e.points.u,
430
430
  endSide: "right",
431
431
  grid: e,
432
432
  startSide: "left"
433
- }), ...lt({
433
+ }), ...st({
434
434
  axis: e.points.v,
435
435
  endSide: "bottom",
436
436
  grid: e,
@@ -443,8 +443,8 @@ function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight
443
443
  e.startSide,
444
444
  e.endSide,
445
445
  e.name,
446
- z(e.loc, "x"),
447
- z(e.loc, "z"),
446
+ V(e.loc, "x"),
447
+ V(e.loc, "z"),
448
448
  e.points[0].x,
449
449
  e.points[0].z,
450
450
  e.points[1].x,
@@ -453,57 +453,57 @@ function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight
453
453
  c.has(t) || c.set(t, e);
454
454
  }), Array.from(c.values());
455
455
  }
456
- function dt(e, t) {
457
- return new P(...ot(e.loc, t));
456
+ function lt(e, t) {
457
+ return new I(...it(e.loc, t));
458
458
  }
459
- function ft({ cameraPosition: e, floorY: t, line: n, showBottom: r, showLeft: i, showRight: a, showTop: o }) {
459
+ function ut({ cameraPosition: e, floorY: t, line: n, showBottom: r, showLeft: i, showRight: a, showTop: o }) {
460
460
  let s = {
461
461
  bottom: r,
462
462
  left: i,
463
463
  right: a,
464
464
  top: o
465
- }, c = dt(n, t), l = n.points[0].clone().add(c), u = n.points[1].clone().add(c), d = l.distanceToSquared(e) > u.distanceToSquared(e) ? "start" : "end", f = d === "start" ? "end" : "start", p = (e) => s[e === "start" ? n.startSide : n.endSide];
465
+ }, c = lt(n, t), l = n.points[0].clone().add(c), u = n.points[1].clone().add(c), d = l.distanceToSquared(e) > u.distanceToSquared(e) ? "start" : "end", f = d === "start" ? "end" : "start", p = (e) => s[e === "start" ? n.startSide : n.endSide];
466
466
  return p(d) ? d : p(f) ? f : null;
467
467
  }
468
- function pt({ endpoint: e, labelOffset: t, line: n }) {
468
+ function dt({ endpoint: e, labelOffset: t, line: n }) {
469
469
  let r = e === "start" ? n.points[0].clone() : n.points[1].clone(), i = n.points[1].clone().sub(n.points[0]);
470
470
  return i.y = 0, i.lengthSq() === 0 && i.set(1, 0, 0), i.normalize().multiplyScalar(t), e === "start" && i.negate(), r.add(i);
471
471
  }
472
- function mt(e, t) {
473
- let n = new P(), r = 0;
472
+ function ft(e, t) {
473
+ let n = new I(), r = 0;
474
474
  return e.forEach((e) => {
475
- let i = dt(e, t);
475
+ let i = lt(e, t);
476
476
  e.points.forEach((e) => {
477
477
  n.add(e).add(i), r++;
478
478
  });
479
479
  }), r && n.divideScalar(r), n;
480
480
  }
481
- function ht(e, t, n) {
481
+ function pt(e, t, n) {
482
482
  let r = 0;
483
483
  return e.forEach((e) => {
484
- let i = dt(e, n);
484
+ let i = lt(e, n);
485
485
  e.points.forEach((e) => {
486
486
  r = Math.max(r, e.clone().add(i).distanceTo(t));
487
487
  });
488
488
  }), r;
489
489
  }
490
- function gt({ color: e, fontSize: t, position: n, text: r }) {
491
- let { camera: i, size: a } = p(), s = l(null), c = nt(r, e, t);
490
+ function mt({ color: e, fontSize: t, position: n, text: r }) {
491
+ let { camera: i, size: a } = p(), s = l(null), c = et(r, e, t);
492
492
  return o(() => {
493
493
  let e = s.current;
494
- e && rt(e, c, i, a.height);
494
+ e && tt(e, c, i, a.height);
495
495
  }, [
496
496
  i,
497
497
  a.height,
498
498
  c
499
499
  ]), f(({ camera: e, size: t }) => {
500
500
  let n = s.current;
501
- n && rt(n, c, e, t.height);
502
- }), /* @__PURE__ */ F("sprite", {
501
+ n && tt(n, c, e, t.height);
502
+ }), /* @__PURE__ */ L("sprite", {
503
503
  ref: s,
504
504
  position: n,
505
505
  renderOrder: 2,
506
- children: /* @__PURE__ */ F("spriteMaterial", {
506
+ children: /* @__PURE__ */ L("spriteMaterial", {
507
507
  alphaTest: .1,
508
508
  depthTest: !0,
509
509
  depthWrite: !1,
@@ -514,8 +514,8 @@ function gt({ color: e, fontSize: t, position: n, text: r }) {
514
514
  })
515
515
  });
516
516
  }
517
- function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset: i, line: a, showBottom: s, showLeft: l, showRight: u, showTop: d }) {
518
- let f = c(() => new y().setFromPoints(a.points), [a.points]), p = ft({
517
+ function ht({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset: i, line: a, showBottom: s, showLeft: l, showRight: u, showTop: d }) {
518
+ let f = c(() => new y().setFromPoints(a.points), [a.points]), p = ut({
519
519
  cameraPosition: e,
520
520
  floorY: n,
521
521
  line: a,
@@ -523,19 +523,19 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
523
523
  showLeft: l,
524
524
  showRight: u,
525
525
  showTop: d
526
- }), m = p ? pt({
526
+ }), m = p ? dt({
527
527
  endpoint: p,
528
528
  labelOffset: i,
529
529
  line: a
530
530
  }) : null;
531
- return o(() => () => f.dispose(), [f]), /* @__PURE__ */ I("lineSegments", {
531
+ return o(() => () => f.dispose(), [f]), /* @__PURE__ */ R("lineSegments", {
532
532
  geometry: f,
533
- position: ot(a.loc, n),
534
- children: [/* @__PURE__ */ F("lineBasicMaterial", {
533
+ position: it(a.loc, n),
534
+ children: [/* @__PURE__ */ L("lineBasicMaterial", {
535
535
  color: t,
536
536
  depthWrite: !1,
537
537
  linewidth: 2
538
- }), m && /* @__PURE__ */ F(gt, {
538
+ }), m && /* @__PURE__ */ L(mt, {
539
539
  color: t,
540
540
  fontSize: r,
541
541
  position: m,
@@ -543,8 +543,8 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
543
543
  })]
544
544
  });
545
545
  }
546
- function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i = Ye, showBottom: a = !0, showLeft: o = !0, showRight: s = !0, showTop: d = !0, visible: m = !0 }) {
547
- let h = p((e) => e.camera), g = l(null), [_, v] = u(() => new P()), y = ct(e), b = c(() => r ? ut({
546
+ function gt({ color: e, floorY: t, fontSize: n = Ge, grids: r, labelOffset: i = qe, showBottom: a = !0, showLeft: o = !0, showRight: s = !0, showTop: d = !0, visible: m = !0 }) {
547
+ let h = p((e) => e.camera), g = l(null), [_, v] = u(() => new I()), y = ot(e), b = c(() => r ? ct({
548
548
  flattenToFloor: t !== void 0,
549
549
  grids: r,
550
550
  showBottom: a,
@@ -558,7 +558,7 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
558
558
  o,
559
559
  s,
560
560
  d
561
- ]), x = c(() => mt(b, t), [t, b]), S = c(() => Math.max(i, ht(b, x, t) * .015), [
561
+ ]), x = c(() => ft(b, t), [t, b]), S = c(() => Math.max(i, pt(b, x, t) * .015), [
562
562
  x,
563
563
  t,
564
564
  i,
@@ -568,11 +568,11 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
568
568
  let e = g.current;
569
569
  if (!e) return;
570
570
  let t = h.position.clone();
571
- e.worldToLocal(t), !(t.distanceToSquared(_) < Xe) && v(t);
572
- }), !m || !b.length ? null : /* @__PURE__ */ F("group", {
571
+ e.worldToLocal(t), !(t.distanceToSquared(_) < Je) && v(t);
572
+ }), !m || !b.length ? null : /* @__PURE__ */ L("group", {
573
573
  ref: g,
574
574
  userData: { modelGrids: !0 },
575
- children: b.map((e) => /* @__PURE__ */ F(_t, {
575
+ children: b.map((e) => /* @__PURE__ */ L(ht, {
576
576
  cameraPosition: _,
577
577
  color: y,
578
578
  floorY: t,
@@ -587,9 +587,9 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
587
587
  e.startSide,
588
588
  e.endSide,
589
589
  e.name,
590
- z(e.loc, "x"),
591
- t ?? z(e.loc, "y"),
592
- z(e.loc, "z"),
590
+ V(e.loc, "x"),
591
+ t ?? V(e.loc, "y"),
592
+ V(e.loc, "z"),
593
593
  e.points[0].x,
594
594
  e.points[0].y,
595
595
  e.points[0].z,
@@ -601,33 +601,33 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
601
601
  }
602
602
  //#endregion
603
603
  //#region src/viewer/Model.tsx
604
- var yt = new j();
605
- function bt(e) {
604
+ var _t = new N();
605
+ function vt(e) {
606
606
  if (!e) return null;
607
607
  try {
608
608
  let t = JSON.parse(e);
609
- return !Array.isArray(t) || t.length !== 16 ? null : new j().fromArray(t);
609
+ return !Array.isArray(t) || t.length !== 16 ? null : new N().fromArray(t);
610
610
  } catch (e) {
611
611
  return console.warn("Model matrix parsing error", e), null;
612
612
  }
613
613
  }
614
- function xt(e) {
615
- return bt(St(e));
614
+ function yt(e) {
615
+ return vt(bt(e));
616
616
  }
617
- function St(e) {
617
+ function bt(e) {
618
618
  return e.coordinationMatrix ?? Object.values(e.data)[0]?.matrix;
619
619
  }
620
- function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r }) {
621
- let i = L((e) => e.gridAxesVisibility), a = c(() => {
620
+ function xt({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r }) {
621
+ let i = z((e) => e.gridAxesVisibility), a = c(() => {
622
622
  if (!r) return {
623
623
  data: [],
624
624
  coordinationMatrix: null,
625
625
  floorY: 0
626
626
  };
627
- let e = Object.values(r.data).some((e) => !!e.matrix) ? t?.clone() ?? xt(r) : null, i = Infinity, a = new P();
627
+ let e = Object.values(r.data).some((e) => !!e.matrix) ? t?.clone() ?? yt(r) : null, i = Infinity, a = new I();
628
628
  return {
629
629
  data: Object.values(r.data).map((e) => {
630
- let t = (bt(e.matrix) ?? new j()).clone().invert(), r = e.mat, o = e.pos;
630
+ let t = (vt(e.matrix) ?? new N()).clone().invert(), r = e.mat, o = e.pos;
631
631
  for (let e = 0; e < o.length; e += 3) a.set(o[e], o[e + 1], o[e + 2]).applyMatrix4(t), Number.isFinite(a.y) && (i = Math.min(i, a.y));
632
632
  return {
633
633
  data: e,
@@ -645,17 +645,17 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
645
645
  r,
646
646
  n
647
647
  ]);
648
- return r ? /* @__PURE__ */ I("group", {
649
- matrix: a.coordinationMatrix ?? yt,
648
+ return r ? /* @__PURE__ */ R("group", {
649
+ matrix: a.coordinationMatrix ?? _t,
650
650
  matrixAutoUpdate: !1,
651
651
  userData: { modelID: n },
652
- children: [a.data.map(({ data: t, isIfcSpace: n, key: r, material: i, meshMatrix: a }) => /* @__PURE__ */ F(Ke, {
652
+ children: [a.data.map(({ data: t, isIfcSpace: n, key: r, material: i, meshMatrix: a }) => /* @__PURE__ */ L(We, {
653
653
  colorPaletteTexture: e,
654
654
  material: i,
655
655
  data: t,
656
656
  isIfcSpace: n,
657
657
  meshMatrix: a
658
- }, r)), /* @__PURE__ */ F(vt, {
658
+ }, r)), /* @__PURE__ */ L(gt, {
659
659
  floorY: a.floorY,
660
660
  grids: r.grids,
661
661
  showBottom: i.bottom,
@@ -664,12 +664,12 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
664
664
  showTop: i.top,
665
665
  visible: i.visible
666
666
  })]
667
- }) : /* @__PURE__ */ F(Te, {});
667
+ }) : /* @__PURE__ */ L(Ce, {});
668
668
  }
669
- var wt = r(Ct);
669
+ var St = r(xt);
670
670
  //#endregion
671
671
  //#region src/viewer/utils/GeometryUtils/useGeometryIndex.ts
672
- function Tt() {
672
+ function Ct() {
673
673
  return {
674
674
  elementIndex: /* @__PURE__ */ new Map(),
675
675
  ifcSpacesVisible: !0,
@@ -679,10 +679,10 @@ function Tt() {
679
679
  records: /* @__PURE__ */ new Set()
680
680
  };
681
681
  }
682
- function Et(e) {
682
+ function wt(e) {
683
683
  return e instanceof Uint16Array || e instanceof Uint32Array ? e : e.length > 65535 ? new Uint32Array(e) : new Uint16Array(e);
684
684
  }
685
- function Dt(e, t, n, r) {
685
+ function Tt(e, t, n, r) {
686
686
  let i = n.get(e);
687
687
  if (i) return i;
688
688
  i = {
@@ -692,20 +692,20 @@ function Dt(e, t, n, r) {
692
692
  let a = r.get(e);
693
693
  return a || (a = [], r.set(e, a)), a.push(i), i;
694
694
  }
695
- function Ot(e, t, n, r, i, a) {
696
- n && Dt(e, r, i, a).vertexRanges.push({
695
+ function Et(e, t, n, r, i, a) {
696
+ n && Tt(e, r, i, a).vertexRanges.push({
697
697
  count: n,
698
698
  start: t
699
699
  });
700
700
  }
701
- function kt(e, t, n, r, i, a) {
702
- n && (Dt(e, r, i, a), r.triangleRanges.push({
701
+ function Dt(e, t, n, r, i, a) {
702
+ n && (Tt(e, r, i, a), r.triangleRanges.push({
703
703
  count: n,
704
704
  id: e,
705
705
  start: t
706
706
  }));
707
707
  }
708
- function At(e) {
708
+ function Ot(e) {
709
709
  let t = e;
710
710
  for (; t;) {
711
711
  let e = t.userData.modelID;
@@ -714,22 +714,22 @@ function At(e) {
714
714
  }
715
715
  return 0;
716
716
  }
717
- function jt(e) {
717
+ function kt(e) {
718
718
  return e.name === "space" || e.userData.isIfcSpace === !0;
719
719
  }
720
- function Mt(e) {
721
- let t = l(Tt()), n = i(() => {
720
+ function At(e) {
721
+ let t = l(Ct()), n = i(() => {
722
722
  let n = e.current, r = t.current;
723
723
  if (!n || r.indexedModel === n && r.records.size) return r;
724
724
  let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
725
725
  return n.traverse((e) => {
726
- if (!(e instanceof M)) return;
726
+ if (!(e instanceof P)) return;
727
727
  let t = e, n = t.geometry, r = n.index, o = n.attributes.ids;
728
728
  if (!r || !o) return;
729
- let s = At(t), c = Et(r.array), l = {
729
+ let s = Ot(t), c = wt(r.array), l = {
730
730
  hiddenIds: /* @__PURE__ */ new Set(),
731
731
  initialVisible: t.visible,
732
- isIfcSpace: jt(t),
732
+ isIfcSpace: kt(t),
733
733
  mesh: t,
734
734
  modelID: s,
735
735
  originalBoundsTree: n.boundsTree ?? null,
@@ -739,15 +739,15 @@ function Mt(e) {
739
739
  }, u = /* @__PURE__ */ new Map(), d = null, f = 0, p = c.length / 3;
740
740
  for (let e = 0; e < p; e++) {
741
741
  let t = o.getX(c[e * 3]);
742
- d === null ? (d = t, f = e) : t !== d && (kt(d, f, e - f, l, u, i), d = t, f = e);
742
+ d === null ? (d = t, f = e) : t !== d && (Dt(d, f, e - f, l, u, i), d = t, f = e);
743
743
  }
744
- d !== null && kt(d, f, p - f, l, u, i);
744
+ d !== null && Dt(d, f, p - f, l, u, i);
745
745
  let m = null, h = 0;
746
746
  for (let e = 0; e < o.count; e++) {
747
747
  let t = o.getX(e);
748
- m === null ? (m = t, h = e) : t !== m && (Ot(m, h, e - h, l, u, i), m = t, h = e);
748
+ m === null ? (m = t, h = e) : t !== m && (Et(m, h, e - h, l, u, i), m = t, h = e);
749
749
  }
750
- m !== null && Ot(m, h, o.count - h, l, u, i), a.add(l);
750
+ m !== null && Et(m, h, o.count - h, l, u, i), a.add(l);
751
751
  }), t.current = {
752
752
  elementIndex: i,
753
753
  ifcSpacesVisible: r.ifcSpacesVisible,
@@ -757,7 +757,7 @@ function Mt(e) {
757
757
  records: a
758
758
  }, t.current;
759
759
  }, [e]), r = i(() => {
760
- t.current = Tt();
760
+ t.current = Ct();
761
761
  }, []);
762
762
  return c(() => ({
763
763
  buildIndex: n,
@@ -766,95 +766,95 @@ function Mt(e) {
766
766
  }
767
767
  //#endregion
768
768
  //#region src/viewer/utils/GeometryUtils/useGeometryUtils.ts
769
- function Nt(e, t) {
769
+ function jt(e, t) {
770
770
  return e instanceof Uint32Array ? new Uint32Array(t) : new Uint16Array(t);
771
771
  }
772
- function Pt(e) {
772
+ function Mt(e) {
773
773
  let t = e.geometry;
774
- Object.assign(t, { boundsTree: void 0 }), e.geometry.index?.count && Object.assign(t, { boundsTree: new Se(e.geometry, { indirect: !0 }) });
774
+ Object.assign(t, { boundsTree: void 0 }), e.geometry.index?.count && Object.assign(t, { boundsTree: new be(e.geometry, { indirect: !0 }) });
775
775
  }
776
- function Ft(e, t, n = !0) {
777
- e.mesh.geometry.setIndex(new v(t, 1)), n && Pt(e.mesh);
776
+ function Nt(e, t, n = !0) {
777
+ e.mesh.geometry.setIndex(new v(t, 1)), n && Mt(e.mesh);
778
778
  }
779
- function It(e, t) {
779
+ function Pt(e, t) {
780
780
  return e.initialVisible && (!e.isIfcSpace || t);
781
781
  }
782
- function Lt(e, t) {
782
+ function Ft(e, t) {
783
783
  let n = e.mesh.geometry, r = n.index?.array;
784
- e.mesh.visible = It(e, t), r !== e.originalIndex && Ft(e, e.originalIndex, !1), e.originalBoundsTree ? Object.assign(n, { boundsTree: e.originalBoundsTree }) : (Pt(e.mesh), e.originalBoundsTree = e.mesh.geometry.boundsTree ?? null);
784
+ e.mesh.visible = Pt(e, t), r !== e.originalIndex && Nt(e, e.originalIndex, !1), e.originalBoundsTree ? Object.assign(n, { boundsTree: e.originalBoundsTree }) : (Mt(e.mesh), e.originalBoundsTree = e.mesh.geometry.boundsTree ?? null);
785
785
  }
786
- function Rt(e) {
786
+ function It(e) {
787
787
  return e === null ? "*" : e.size ? Array.from(e).sort((e, t) => e - t).join(",") : "";
788
788
  }
789
- function zt(e, t, n, r) {
790
- return `h:${Rt(e)}|i:${Rt(n)}|s:${r ? Number(t) : ""}`;
789
+ function Lt(e, t, n, r) {
790
+ return `h:${It(e)}|i:${It(n)}|s:${r ? Number(t) : ""}`;
791
791
  }
792
- function Bt(e, t, n) {
792
+ function Rt(e, t, n) {
793
793
  return !t.has(e) && (!n || n.has(e));
794
794
  }
795
- function Vt(e, t) {
795
+ function zt(e, t) {
796
796
  Object.entries(e).forEach(([e, n]) => {
797
797
  n.forEach((n) => t(Number(e), n));
798
798
  });
799
799
  }
800
- function Ht(e, t, n) {
800
+ function Bt(e, t, n) {
801
801
  e.hiddenIds.has(t) || (e.hiddenIds.add(t), n.add(e));
802
802
  }
803
- function B(e, t, n) {
803
+ function H(e, t, n) {
804
804
  e && console.log(`${t}:`, Date.now() - n, "ms");
805
805
  }
806
- function V(e, t, n, r) {
807
- let { hiddenIds: i, originalIndex: a, triangleRanges: o } = e, s = zt(i, t, n, e.isIfcSpace);
806
+ function U(e, t, n, r) {
807
+ let { hiddenIds: i, originalIndex: a, triangleRanges: o } = e, s = Lt(i, t, n, e.isIfcSpace);
808
808
  if (e.visibleStateKey === s) return;
809
809
  if (!i.size && !n) {
810
- Lt(e, t), e.visibleStateKey = s;
810
+ Ft(e, t), e.visibleStateKey = s;
811
811
  return;
812
812
  }
813
813
  let c = 0, l = 0;
814
814
  if (o.forEach(({ count: e, id: t }) => {
815
- Bt(t, i, n) ? c += e * 3 : l += e * 3;
815
+ Rt(t, i, n) ? c += e * 3 : l += e * 3;
816
816
  }), !c) {
817
- Lt(e, t), e.mesh.visible = !1, e.visibleStateKey = s;
817
+ Ft(e, t), e.mesh.visible = !1, e.visibleStateKey = s;
818
818
  return;
819
819
  }
820
820
  if (!l) {
821
- Lt(e, t), e.visibleStateKey = s;
821
+ Ft(e, t), e.visibleStateKey = s;
822
822
  return;
823
823
  }
824
- e.mesh.visible = It(e, t);
825
- let u = Nt(a, c), d = 0;
824
+ e.mesh.visible = Pt(e, t);
825
+ let u = jt(a, c), d = 0;
826
826
  for (let e = 0; e < o.length; e++) {
827
827
  let { count: t, id: r, start: s } = o[e];
828
- if (!Bt(r, i, n)) continue;
828
+ if (!Rt(r, i, n)) continue;
829
829
  let c = s * 3, l = c + t * 3;
830
830
  u.set(a.subarray(c, l), d), d += t * 3;
831
831
  }
832
- r || (e.originalBoundsTree = null), Ft(e, u), e.visibleStateKey = s;
832
+ r || (e.originalBoundsTree = null), Nt(e, u), e.visibleStateKey = s;
833
833
  }
834
- function H(e, t) {
834
+ function W(e, t) {
835
835
  return e.isolatedIdsByModel ? e.isolatedIdsByModel.get(t.modelID) ?? /* @__PURE__ */ new Set() : e.isolatedIds;
836
836
  }
837
- function Ut(e) {
838
- let t = L((e) => e.selected), n = L((e) => e.resetSelected), r = L((e) => e.showStats), a = L((e) => e.userDevice) === "pc", o = e.buildIndex, s = i(() => Array.from(o().elementIndex.keys()), [o]), c = i(() => o().ifcSpacesVisible, [o]), l = i((e) => {
837
+ function Vt(e) {
838
+ let t = z((e) => e.selected), n = z((e) => e.resetSelected), r = z((e) => e.showStats), a = z((e) => e.userDevice) === "pc", o = e.buildIndex, s = i(() => Array.from(o().elementIndex.keys()), [o]), c = i(() => o().ifcSpacesVisible, [o]), l = i((e) => {
839
839
  let t = Date.now(), n = o(), i = /* @__PURE__ */ new Set();
840
840
  e.forEach((e) => {
841
841
  let t = n.elementIndex.get(e);
842
842
  t && t.forEach(({ record: t }) => {
843
- Ht(t, e, i);
843
+ Bt(t, e, i);
844
844
  });
845
- }), i.forEach((e) => V(e, n.ifcSpacesVisible, H(n, e), a)), B(r, "hideByIds", t);
845
+ }), i.forEach((e) => U(e, n.ifcSpacesVisible, W(n, e), a)), H(r, "hideByIds", t);
846
846
  }, [
847
847
  o,
848
848
  a,
849
849
  r
850
850
  ]), u = i(() => {
851
851
  let e = Date.now(), i = o(), s = /* @__PURE__ */ new Set();
852
- Vt(t, (e, t) => {
852
+ zt(t, (e, t) => {
853
853
  let n = i.elementIndex.get(t);
854
854
  n && n.forEach(({ record: n }) => {
855
- n.modelID === e && Ht(n, t, s);
855
+ n.modelID === e && Bt(n, t, s);
856
856
  });
857
- }), s.forEach((e) => V(e, i.ifcSpacesVisible, H(i, e), a)), n(), B(r, "hideSelected", e);
857
+ }), s.forEach((e) => U(e, i.ifcSpacesVisible, W(i, e), a)), n(), H(r, "hideSelected", e);
858
858
  }, [
859
859
  o,
860
860
  a,
@@ -868,24 +868,24 @@ function Ut(e) {
868
868
  t && t.forEach(({ record: t }) => {
869
869
  t.hiddenIds.delete(e) && i.add(t);
870
870
  });
871
- }), i.forEach((e) => V(e, n.ifcSpacesVisible, H(n, e), a)), B(r, "showByIds", t);
871
+ }), i.forEach((e) => U(e, n.ifcSpacesVisible, W(n, e), a)), H(r, "showByIds", t);
872
872
  }, [
873
873
  o,
874
874
  a,
875
875
  r
876
876
  ]), f = i((e) => {
877
877
  let t = Date.now(), n = o();
878
- n.isolatedIdsByModel = null, n.isolatedIds = new Set(e), n.records.forEach((e) => V(e, n.ifcSpacesVisible, H(n, e), a)), B(r, "isolateByIds", t);
878
+ n.isolatedIdsByModel = null, n.isolatedIds = new Set(e), n.records.forEach((e) => U(e, n.ifcSpacesVisible, W(n, e), a)), H(r, "isolateByIds", t);
879
879
  }, [
880
880
  o,
881
881
  a,
882
882
  r
883
883
  ]), p = i(() => {
884
884
  let e = Date.now(), n = o(), i = /* @__PURE__ */ new Map();
885
- Vt(t, (e, t) => {
885
+ zt(t, (e, t) => {
886
886
  let n = i.get(e);
887
887
  n || (n = /* @__PURE__ */ new Set(), i.set(e, n)), n.add(t);
888
- }), n.isolatedIdsByModel = i, n.isolatedIds = null, n.records.forEach((e) => V(e, n.ifcSpacesVisible, H(n, e), a)), B(r, "isolateSelected", e);
888
+ }), n.isolatedIdsByModel = i, n.isolatedIds = null, n.records.forEach((e) => U(e, n.ifcSpacesVisible, W(n, e), a)), H(r, "isolateSelected", e);
889
889
  }, [
890
890
  o,
891
891
  a,
@@ -893,7 +893,7 @@ function Ut(e) {
893
893
  r
894
894
  ]), m = i(() => {
895
895
  let e = Date.now(), t = o();
896
- t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => V(e, t.ifcSpacesVisible, H(t, e), a)), B(r, "resetIsolation", e);
896
+ t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => U(e, t.ifcSpacesVisible, W(t, e), a)), H(r, "resetIsolation", e);
897
897
  }, [
898
898
  o,
899
899
  a,
@@ -901,7 +901,7 @@ function Ut(e) {
901
901
  ]), h = i((e) => {
902
902
  let t = o();
903
903
  t.ifcSpacesVisible !== e && (t.ifcSpacesVisible = e, t.records.forEach((e) => {
904
- e.isIfcSpace && V(e, t.ifcSpacesVisible, H(t, e), a);
904
+ e.isIfcSpace && U(e, t.ifcSpacesVisible, W(t, e), a);
905
905
  }));
906
906
  }, [o, a]), g = i(() => {
907
907
  h(!c());
@@ -919,8 +919,8 @@ function Ut(e) {
919
919
  showAll: i(() => {
920
920
  let e = Date.now(), t = o();
921
921
  t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => {
922
- e.hiddenIds.clear(), V(e, t.ifcSpacesVisible, H(t, e), a);
923
- }), B(r, "showAll", e);
922
+ e.hiddenIds.clear(), U(e, t.ifcSpacesVisible, W(t, e), a);
923
+ }), H(r, "showAll", e);
924
924
  }, [
925
925
  o,
926
926
  a,
@@ -932,49 +932,49 @@ function Ut(e) {
932
932
  }
933
933
  //#endregion
934
934
  //#region src/viewer/utils/ClippingUtils/ClippingEdges.ts
935
- var Wt = 1024, Gt = -1e-5;
936
- function Kt(e) {
935
+ var Ht = 1024, Ut = -1e-5;
936
+ function Wt(e) {
937
937
  let t = new v(new Float32Array(e * 3), 3, !1);
938
938
  return t.setUsage(T), t;
939
939
  }
940
- function qt(e) {
940
+ function Gt(e) {
941
941
  return Math.max(1, Math.ceil((e.geometry.index?.count ?? 0) / 3));
942
942
  }
943
- function Jt(e, t) {
944
- let n = new y(), r = Math.ceil(Math.min(Math.max(Wt, qt(t) * .05), 32768));
945
- n.setAttribute("position", Kt(r)), n.setDrawRange(0, 0);
946
- let i = new ne(n, e);
943
+ function Kt(e, t) {
944
+ let n = new y(), r = Math.ceil(Math.min(Math.max(Ht, Gt(t) * .05), 32768));
945
+ n.setAttribute("position", Wt(r)), n.setDrawRange(0, 0);
946
+ let i = new j(n, e);
947
947
  return i.frustumCulled = !1, i.renderOrder = 1, i.visible = !1, i;
948
948
  }
949
- function Yt(e, t) {
949
+ function qt(e, t) {
950
950
  let n = e.geometry.getAttribute("position");
951
951
  if (n.count > t) return n;
952
- let r = Kt(Math.max(n.count * 2, t + 1));
952
+ let r = Wt(Math.max(n.count * 2, t + 1));
953
953
  return r.array.set(n.array), e.geometry.setAttribute("position", r), n = r, n;
954
954
  }
955
- function Xt(e) {
955
+ function Jt(e) {
956
956
  return e.filter((e) => e.parent && e.geometry.index?.count);
957
957
  }
958
- var Zt = class {
958
+ var Yt = class {
959
959
  active;
960
960
  material;
961
961
  plane;
962
962
  context;
963
963
  lines = /* @__PURE__ */ new Map();
964
- inverseMatrix = new j();
965
- localPlane = new ue();
966
- tempLine = new O();
967
- tempVector = new P();
968
- tempVector1 = new P();
969
- tempVector2 = new P();
970
- tempVector3 = new P();
964
+ inverseMatrix = new N();
965
+ localPlane = new ce();
966
+ tempLine = new k();
967
+ tempVector = new I();
968
+ tempVector1 = new I();
969
+ tempVector2 = new I();
970
+ tempVector3 = new I();
971
971
  constructor(e, t) {
972
972
  this.context = e, this.plane = t, this.active = e.getActive() && e.getEdgesActive(), e.edges.forEach((e) => {
973
973
  let n = e.material.clippingPlanes ?? [];
974
974
  e.plane === t || n.includes(t) || (e.material.clippingPlanes = [...n, t], e.material.needsUpdate = !0);
975
975
  });
976
976
  let n = e.planes.filter((e) => e !== t);
977
- this.material = new te({
977
+ this.material = new A({
978
978
  clippingPlanes: n,
979
979
  color: "black",
980
980
  depthTest: !0,
@@ -985,12 +985,12 @@ var Zt = class {
985
985
  return this.syncMeshes(), Array.from(this.lines.values());
986
986
  }
987
987
  syncMeshes() {
988
- let e = new Set(Xt(this.context.getMeshes()));
988
+ let e = new Set(Jt(this.context.getMeshes()));
989
989
  this.lines.forEach((t, n) => {
990
990
  e.has(n) || (t.removeFromParent(), t.geometry.dispose(), this.lines.delete(n));
991
991
  }), e.forEach((e) => {
992
992
  if (this.lines.has(e)) return;
993
- let t = Jt(this.material, e);
993
+ let t = Kt(this.material, e);
994
994
  e.add(t), this.lines.set(e, t);
995
995
  }), this.setVisible(this.active);
996
996
  }
@@ -1016,7 +1016,7 @@ var Zt = class {
1016
1016
  }
1017
1017
  t.updateWorldMatrix(!0, !1), this.inverseMatrix.copy(t.matrixWorld).invert(), this.localPlane.copy(this.plane).applyMatrix4(this.inverseMatrix);
1018
1018
  let r = 0, i = e.geometry.getAttribute("position"), a = (t) => {
1019
- i = Yt(e, r), i.setXYZ(r, t.x, t.y, t.z), r++;
1019
+ i = qt(e, r), i.setXYZ(r, t.x, t.y, t.z), r++;
1020
1020
  };
1021
1021
  n.shapecast({
1022
1022
  intersectsBounds: (e) => this.localPlane.intersectsBox(e),
@@ -1024,19 +1024,19 @@ var Zt = class {
1024
1024
  let t = 0;
1025
1025
  this.tempLine.start.copy(e.a), this.tempLine.end.copy(e.b), this.localPlane.intersectLine(this.tempLine, this.tempVector) && (a(this.tempVector), t++), this.tempLine.start.copy(e.b), this.tempLine.end.copy(e.c), this.localPlane.intersectLine(this.tempLine, this.tempVector) && (a(this.tempVector), t++), this.tempLine.start.copy(e.c), this.tempLine.end.copy(e.a), this.localPlane.intersectLine(this.tempLine, this.tempVector) && (a(this.tempVector), t++), t === 3 && (this.tempVector1.fromBufferAttribute(i, r - 3), this.tempVector2.fromBufferAttribute(i, r - 2), this.tempVector3.fromBufferAttribute(i, r - 1), this.tempVector3.equals(this.tempVector1) || this.tempVector3.equals(this.tempVector2) ? (t--, r--) : this.tempVector1.equals(this.tempVector2) && (i.setXYZ(r - 2, this.tempVector3.x, this.tempVector3.y, this.tempVector3.z), t--, r--)), t !== 2 && (r -= t);
1026
1026
  }
1027
- }), e.geometry.setDrawRange(0, r), e.position.copy(this.localPlane.normal).multiplyScalar(Gt), i.needsUpdate = !0;
1027
+ }), e.geometry.setDrawRange(0, r), e.position.copy(this.localPlane.normal).multiplyScalar(Ut), i.needsUpdate = !0;
1028
1028
  }));
1029
1029
  }
1030
- }, Qt = "#0b2f5f", $t = "#0b2f5f", en = 0, tn = "#1f7ae0", nn = .22, rn = .01, an = .025, on = .015, sn = .25, cn = .15, ln = .25, U = 1;
1031
- function un(e, t) {
1030
+ }, Xt = "#0b2f5f", Zt = "#0b2f5f", Qt = 0, $t = "#1f7ae0", en = .22, tn = .01, nn = .025, rn = .015, an = .25, on = .15, sn = .25, G = 1;
1031
+ function cn(e, t) {
1032
1032
  let n = t.getBoundingClientRect();
1033
- return new N((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
1033
+ return new F((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
1034
1034
  }
1035
- function dn(e) {
1036
- let t = e.getSize(new P());
1037
- return Math.max(ln, t.length() * rn);
1035
+ function ln(e) {
1036
+ let t = e.getSize(new I());
1037
+ return Math.max(sn, t.length() * tn);
1038
1038
  }
1039
- var fn = class extends se {
1039
+ var un = class extends ae {
1040
1040
  helper = new D();
1041
1041
  borderMaterial;
1042
1042
  material;
@@ -1047,22 +1047,22 @@ var fn = class extends se {
1047
1047
  location;
1048
1048
  normal;
1049
1049
  planeMesh;
1050
- pointer = new N();
1050
+ pointer = new F();
1051
1051
  layout;
1052
1052
  dragState = null;
1053
1053
  hovered = !1;
1054
1054
  listenersActive = !1;
1055
1055
  constructor(e, t, n, r) {
1056
- super(), this.context = e, this.plane = t, this.location = n.clone(), this.normal = r.clone().normalize(), this.material = new ie({
1057
- color: $t,
1056
+ super(), this.context = e, this.plane = t, this.location = n.clone(), this.normal = r.clone().normalize(), this.material = new ne({
1057
+ color: Zt,
1058
1058
  depthWrite: !1,
1059
- opacity: en,
1059
+ opacity: Qt,
1060
1060
  side: w,
1061
1061
  transparent: !0
1062
1062
  }), this.helper.position.copy(this.location), this.applyPlaneOrientation(), this.layout = this.getHelperLayout();
1063
- let i = Math.max(sn, Math.min(this.layout.width, this.layout.height) * an), a = Math.max(cn, Math.min(this.layout.width, this.layout.height) * on);
1064
- this.borderMaterial = new k({
1065
- color: Qt,
1063
+ let i = Math.max(an, Math.min(this.layout.width, this.layout.height) * nn), a = Math.max(on, Math.min(this.layout.width, this.layout.height) * rn);
1064
+ this.borderMaterial = new ee({
1065
+ color: Xt,
1066
1066
  dashSize: i,
1067
1067
  depthWrite: !1,
1068
1068
  gapSize: a
@@ -1093,7 +1093,7 @@ var fn = class extends se {
1093
1093
  }
1094
1094
  updateBorderDash() {
1095
1095
  let e = Math.min(this.layout.width, this.layout.height);
1096
- this.borderMaterial.dashSize = Math.max(sn, e * an), this.borderMaterial.gapSize = Math.max(cn, e * on), this.borderMaterial.needsUpdate = !0;
1096
+ this.borderMaterial.dashSize = Math.max(an, e * nn), this.borderMaterial.gapSize = Math.max(on, e * rn), this.borderMaterial.needsUpdate = !0;
1097
1097
  }
1098
1098
  addEventListeners() {
1099
1099
  if (this.listenersActive) return;
@@ -1128,15 +1128,15 @@ var fn = class extends se {
1128
1128
  hasModelIntersection(e) {
1129
1129
  return !!this.context.getCameraUtils().getIntersection(!0, {
1130
1130
  event: e,
1131
- filter: (e) => !(e.object instanceof M) || e.faceIndex === void 0 || e.faceIndex === null ? !1 : !!(e.object.geometry.index && e.object.geometry.attributes.ids),
1131
+ filter: (e) => !(e.object instanceof P) || e.faceIndex === void 0 || e.faceIndex === null ? !1 : !!(e.object.geometry.index && e.object.geometry.attributes.ids),
1132
1132
  object: this.context.getMeshes(),
1133
1133
  recursive: !1
1134
1134
  });
1135
1135
  }
1136
1136
  getPointerPointOnPlane(e, t) {
1137
1137
  let n = this.context.getDomElement();
1138
- this.pointer.copy(un(e, n));
1139
- let r = this.context.getRaycaster(), i = new P();
1138
+ this.pointer.copy(cn(e, n));
1139
+ let r = this.context.getRaycaster(), i = new I();
1140
1140
  return r.setFromCamera(this.pointer, this.context.getCamera()), r.ray.intersectPlane(t, i);
1141
1141
  }
1142
1142
  onPointerDown = (e) => {
@@ -1148,9 +1148,9 @@ var fn = class extends se {
1148
1148
  let t = this.getPointerIntersection(e);
1149
1149
  if (!t) return;
1150
1150
  e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), this.context.clearHelpersHover(this), this.setHovered(!0), this.context.setHelperDragActive(!0), this.context.setSelectionInteractionDisabled(!0);
1151
- let n = new P();
1151
+ let n = new I();
1152
1152
  this.context.getCamera().getWorldDirection(n), n.normalize();
1153
- let r = new ue().setFromNormalAndCoplanarPoint(n, t.point);
1153
+ let r = new ce().setFromNormalAndCoplanarPoint(n, t.point);
1154
1154
  this.dragState = {
1155
1155
  dragPlane: r,
1156
1156
  helperStart: this.helper.position.clone(),
@@ -1192,14 +1192,14 @@ var fn = class extends se {
1192
1192
  this.hovered !== t && this.setHovered(t);
1193
1193
  }
1194
1194
  setHovered(e) {
1195
- this.hovered = e, this.material.color.set(e ? tn : $t), this.material.opacity = e ? nn : en, this.material.needsUpdate = !0;
1195
+ this.hovered = e, this.material.color.set(e ? $t : Zt), this.material.opacity = e ? en : Qt, this.material.needsUpdate = !0;
1196
1196
  }
1197
1197
  createPlaneMesh() {
1198
- let e = new M(new y(), this.material);
1198
+ let e = new P(new y(), this.material);
1199
1199
  return e.renderOrder = 2, e;
1200
1200
  }
1201
1201
  createBorder() {
1202
- let e = new ne(new y(), this.borderMaterial);
1202
+ let e = new j(new y(), this.borderMaterial);
1203
1203
  return e.renderOrder = 3, e;
1204
1204
  }
1205
1205
  replaceGeometry(e, t) {
@@ -1268,27 +1268,27 @@ var fn = class extends se {
1268
1268
  getHelperLayout() {
1269
1269
  let e = this.getModelWorldBox();
1270
1270
  if (!e || e.isEmpty()) return {
1271
- height: U,
1272
- maxU: U / 2,
1273
- maxV: U / 2,
1274
- minU: -U / 2,
1275
- minV: -U / 2,
1276
- width: U
1271
+ height: G,
1272
+ maxU: G / 2,
1273
+ maxV: G / 2,
1274
+ minU: -G / 2,
1275
+ minV: -G / 2,
1276
+ width: G
1277
1277
  };
1278
- let t = this.getPlaneBasis(), n = this.helper.position, r = this.getBoxCorners(e), i = new P(), a = new P(), o = Infinity, s = -Infinity, c = Infinity, l = -Infinity;
1278
+ let t = this.getPlaneBasis(), n = this.helper.position, r = this.getBoxCorners(e), i = new I(), a = new I(), o = Infinity, s = -Infinity, c = Infinity, l = -Infinity;
1279
1279
  if (r.forEach((e) => {
1280
1280
  this.plane.projectPoint(e, i), a.copy(i).sub(n);
1281
1281
  let r = a.dot(t.u), u = a.dot(t.v);
1282
1282
  o = Math.min(o, r), s = Math.max(s, r), c = Math.min(c, u), l = Math.max(l, u);
1283
1283
  }), !Number.isFinite(o) || !Number.isFinite(s) || !Number.isFinite(c) || !Number.isFinite(l)) return {
1284
- height: U,
1285
- maxU: U / 2,
1286
- maxV: U / 2,
1287
- minU: -U / 2,
1288
- minV: -U / 2,
1289
- width: U
1284
+ height: G,
1285
+ maxU: G / 2,
1286
+ maxV: G / 2,
1287
+ minU: -G / 2,
1288
+ minV: -G / 2,
1289
+ width: G
1290
1290
  };
1291
- let u = dn(e), d = o - u, f = s + u, p = c - u, m = l + u, h = Math.max(U, f - d), g = Math.max(U, m - p), _ = (d + f) / 2, v = (p + m) / 2;
1291
+ let u = ln(e), d = o - u, f = s + u, p = c - u, m = l + u, h = Math.max(G, f - d), g = Math.max(G, m - p), _ = (d + f) / 2, v = (p + m) / 2;
1292
1292
  return {
1293
1293
  height: g,
1294
1294
  maxU: _ + h / 2,
@@ -1299,14 +1299,14 @@ var fn = class extends se {
1299
1299
  };
1300
1300
  }
1301
1301
  getPlaneBasis() {
1302
- let e = (Math.abs(this.normal.y) < .9 ? new P(0, 1, 0) : new P(1, 0, 0)).cross(this.normal).normalize();
1302
+ let e = (Math.abs(this.normal.y) < .9 ? new I(0, 1, 0) : new I(1, 0, 0)).cross(this.normal).normalize();
1303
1303
  return {
1304
1304
  u: e,
1305
1305
  v: this.normal.clone().cross(e).normalize()
1306
1306
  };
1307
1307
  }
1308
1308
  applyPlaneOrientation() {
1309
- let e = this.getPlaneBasis(), t = new j().makeBasis(e.u, e.v, this.normal);
1309
+ let e = this.getPlaneBasis(), t = new N().makeBasis(e.u, e.v, this.normal);
1310
1310
  this.helper.quaternion.setFromRotationMatrix(t);
1311
1311
  }
1312
1312
  getModelWorldBox() {
@@ -1319,20 +1319,20 @@ var fn = class extends se {
1319
1319
  }
1320
1320
  getBoxCorners(e) {
1321
1321
  return [
1322
- new P(e.min.x, e.min.y, e.min.z),
1323
- new P(e.min.x, e.min.y, e.max.z),
1324
- new P(e.min.x, e.max.y, e.min.z),
1325
- new P(e.min.x, e.max.y, e.max.z),
1326
- new P(e.max.x, e.min.y, e.min.z),
1327
- new P(e.max.x, e.min.y, e.max.z),
1328
- new P(e.max.x, e.max.y, e.min.z),
1329
- new P(e.max.x, e.max.y, e.max.z)
1322
+ new I(e.min.x, e.min.y, e.min.z),
1323
+ new I(e.min.x, e.min.y, e.max.z),
1324
+ new I(e.min.x, e.max.y, e.min.z),
1325
+ new I(e.min.x, e.max.y, e.max.z),
1326
+ new I(e.max.x, e.min.y, e.min.z),
1327
+ new I(e.max.x, e.min.y, e.max.z),
1328
+ new I(e.max.x, e.max.y, e.min.z),
1329
+ new I(e.max.x, e.max.y, e.max.z)
1330
1330
  ];
1331
1331
  }
1332
1332
  };
1333
1333
  //#endregion
1334
1334
  //#region src/viewer/utils/ClippingUtils/ClippingUtils.ts
1335
- function pn(e, t) {
1335
+ function dn(e, t) {
1336
1336
  if (Array.isArray(e)) {
1337
1337
  e.forEach((e) => {
1338
1338
  e.clippingPlanes = t, e.needsUpdate = !0;
@@ -1341,16 +1341,25 @@ function pn(e, t) {
1341
1341
  }
1342
1342
  e.clippingPlanes = t, e.needsUpdate = !0;
1343
1343
  }
1344
- function mn(e) {
1344
+ function fn(e) {
1345
1345
  let t = [];
1346
1346
  return e?.traverse((e) => {
1347
- e instanceof M && (!e.geometry.index || !e.geometry.attributes.ids || t.push(e));
1347
+ e instanceof P && (!e.geometry.index || !e.geometry.attributes.ids || t.push(e));
1348
1348
  }), t;
1349
1349
  }
1350
- function hn(e, t) {
1350
+ function pn(e) {
1351
+ let t = e;
1352
+ for (; t;) {
1353
+ let e = t.userData.modelID;
1354
+ if (typeof e == "number") return e;
1355
+ t = t.parent;
1356
+ }
1357
+ return 0;
1358
+ }
1359
+ function mn(e, t) {
1351
1360
  return t.clone().transformDirection(e.matrixWorld).normalize();
1352
1361
  }
1353
- var gn = class {
1362
+ var hn = class {
1354
1363
  planes = [];
1355
1364
  edges = [];
1356
1365
  helpers = [];
@@ -1399,7 +1408,7 @@ var gn = class {
1399
1408
  return this.context.controlRef;
1400
1409
  }
1401
1410
  getMeshes() {
1402
- return mn(this.context.modelRef.current);
1411
+ return fn(this.context.modelRef.current);
1403
1412
  }
1404
1413
  getHelperHoverIsMoving() {
1405
1414
  return this.helperHoverMoveState !== "end" && this.helperHoverMoveState !== "start";
@@ -1432,6 +1441,18 @@ var gn = class {
1432
1441
  n.updateWorldMatrix(!0, !1), n.geometry.boundingBox || n.geometry.computeBoundingBox(), n.geometry.boundingBox && (t.copy(n.geometry.boundingBox).applyMatrix4(n.matrixWorld), e.union(t));
1433
1442
  }), e.isEmpty() ? null : e;
1434
1443
  }
1444
+ getSelectedWorldBox() {
1445
+ let e = this.context.viewerStore.getState().selected, t = new g(), n = new I();
1446
+ return this.getMeshes().forEach((r) => {
1447
+ let i = e[pn(r)];
1448
+ if (!i?.size) return;
1449
+ let a = r.geometry.attributes.ids, o = r.geometry.attributes.position;
1450
+ if (!a || !o) return;
1451
+ r.updateWorldMatrix(!0, !1);
1452
+ let s = Math.min(a.count, o.count);
1453
+ for (let e = 0; e < s; e++) i.has(a.getX(e)) && (n.set(o.getX(e), o.getY(e), o.getZ(e)).applyMatrix4(r.matrixWorld), Number.isFinite(n.x + n.y + n.z) && t.expandByPoint(n));
1454
+ }), t.isEmpty() ? null : t;
1455
+ }
1435
1456
  setControlsEnabled(e) {
1436
1457
  let t = this.context.controlRef.current;
1437
1458
  t && (t.enabled = e);
@@ -1442,7 +1463,7 @@ var gn = class {
1442
1463
  updateMaterials() {
1443
1464
  let e = this.active ? this.planes : [];
1444
1465
  this.getMeshes().forEach((t) => {
1445
- pn(t.material, e);
1466
+ dn(t.material, e);
1446
1467
  }), this.context.camera.updateMatrixWorld();
1447
1468
  }
1448
1469
  setActive(e) {
@@ -1461,51 +1482,51 @@ var gn = class {
1461
1482
  recursive: !1
1462
1483
  });
1463
1484
  if (!n?.face) return null;
1464
- let r = n.point.clone(), i = hn(n.object, n.face.normal);
1485
+ let r = n.point.clone(), i = mn(n.object, n.face.normal);
1465
1486
  r.add(i.clone().multiplyScalar(.001));
1466
- let a = new ue().setFromNormalAndCoplanarPoint(i.clone().negate(), r);
1487
+ let a = new ce().setFromNormalAndCoplanarPoint(i.clone().negate(), r);
1467
1488
  return this.addPlane(a, r, i), a.clone();
1468
1489
  }
1469
- createClippingRectangle() {
1470
- let e = this.getModelWorldBox();
1471
- if (!e) return [];
1472
- let t = dn(e), n = e.min.clone().addScalar(-t), r = e.max.clone().addScalar(t), i = e.getCenter(new P()), a = [
1490
+ createClippingRectangle(e = !1) {
1491
+ let t = e ? this.getSelectedWorldBox() : this.getModelWorldBox();
1492
+ if (!t) return [];
1493
+ let n = ln(t), r = t.min.clone().addScalar(-n), i = t.max.clone().addScalar(n), a = t.getCenter(new I()), o = [
1473
1494
  {
1474
- normal: new P(1, 0, 0),
1475
- point: new P(n.x, i.y, i.z)
1495
+ normal: new I(1, 0, 0),
1496
+ point: new I(r.x, a.y, a.z)
1476
1497
  },
1477
1498
  {
1478
- normal: new P(-1, 0, 0),
1479
- point: new P(r.x, i.y, i.z)
1499
+ normal: new I(-1, 0, 0),
1500
+ point: new I(i.x, a.y, a.z)
1480
1501
  },
1481
1502
  {
1482
- normal: new P(0, 1, 0),
1483
- point: new P(i.x, n.y, i.z)
1503
+ normal: new I(0, 1, 0),
1504
+ point: new I(a.x, r.y, a.z)
1484
1505
  },
1485
1506
  {
1486
- normal: new P(0, -1, 0),
1487
- point: new P(i.x, r.y, i.z)
1507
+ normal: new I(0, -1, 0),
1508
+ point: new I(a.x, i.y, a.z)
1488
1509
  },
1489
1510
  {
1490
- normal: new P(0, 0, 1),
1491
- point: new P(i.x, i.y, n.z)
1511
+ normal: new I(0, 0, 1),
1512
+ point: new I(a.x, a.y, r.z)
1492
1513
  },
1493
1514
  {
1494
- normal: new P(0, 0, -1),
1495
- point: new P(i.x, i.y, r.z)
1515
+ normal: new I(0, 0, -1),
1516
+ point: new I(a.x, a.y, i.z)
1496
1517
  }
1497
1518
  ].map(({ normal: e, point: t }) => ({
1498
1519
  normal: e,
1499
- plane: new ue().setFromNormalAndCoplanarPoint(e, t),
1520
+ plane: new ce().setFromNormalAndCoplanarPoint(e, t),
1500
1521
  point: t
1501
1522
  }));
1502
- return a.forEach(({ normal: e, plane: t, point: n }) => {
1523
+ return o.forEach(({ normal: e, plane: t, point: n }) => {
1503
1524
  this.addPlane(t, n, e);
1504
- }), this.updateHelpers(), a.map(({ plane: e }) => e.clone());
1525
+ }), this.updateHelpers(), o.map(({ plane: e }) => e.clone());
1505
1526
  }
1506
1527
  addPlane(e, t, n) {
1507
- if (this.active || this.setActive(!0), this.planes.push(e), new fn(this, e, t, n), this.updateHelpers(), this.updateMaterials(), this.edgesActive) {
1508
- let t = new Zt(this, e);
1528
+ if (this.active || this.setActive(!0), this.planes.push(e), new un(this, e, t, n), this.updateHelpers(), this.updateMaterials(), this.edgesActive) {
1529
+ let t = new Yt(this, e);
1509
1530
  t.create(), t.update();
1510
1531
  }
1511
1532
  }
@@ -1517,7 +1538,7 @@ var gn = class {
1517
1538
  }
1518
1539
  setEdgesActive(e) {
1519
1540
  this.edgesActive !== e && (this.edgesActive = e, e && this.edges.length !== this.planes.length && (this.edges.forEach((e) => e.dispose()), this.edges = [], this.planes.forEach((e) => {
1520
- let t = new Zt(this, e);
1541
+ let t = new Yt(this, e);
1521
1542
  t.create(), t.update();
1522
1543
  })), this.edges.forEach((t) => t.setVisible(this.active && e)));
1523
1544
  }
@@ -1544,8 +1565,8 @@ var gn = class {
1544
1565
  this.deleteAllPlanes();
1545
1566
  }
1546
1567
  };
1547
- function _n(e, t, n) {
1548
- let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.raycaster), s = p((e) => e.scene), l = R(), u = c(() => new gn({
1568
+ function gn(e, t, n) {
1569
+ let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.raycaster), s = p((e) => e.scene), l = B(), u = c(() => new hn({
1549
1570
  camera: r,
1550
1571
  cameraUtils: n,
1551
1572
  controlRef: t,
@@ -1589,15 +1610,15 @@ function _n(e, t, n) {
1589
1610
  l
1590
1611
  ]), o(() => () => u.dispose(), [u]), o(() => {
1591
1612
  let e = i.domElement, n = t.current;
1592
- return e.addEventListener("pointerdown", u.setHelperHoverMoveStart), window.addEventListener("pointerup", u.setHelperHoverMoveEnd), window.addEventListener("pointercancel", u.setHelperHoverMoveEnd), n?.addEventListener("change", u.setHelperHoverMoving), () => {
1593
- e.removeEventListener("pointerdown", u.setHelperHoverMoveStart), window.removeEventListener("pointerup", u.setHelperHoverMoveEnd), window.removeEventListener("pointercancel", u.setHelperHoverMoveEnd), n?.removeEventListener("change", u.setHelperHoverMoving);
1613
+ return e.addEventListener("pointerdown", u.setHelperHoverMoveStart), window.addEventListener("pointerup", u.setHelperHoverMoveEnd), window.addEventListener("pointercancel", u.setHelperHoverMoveEnd), n?.addEventListener("update", u.setHelperHoverMoving), () => {
1614
+ e.removeEventListener("pointerdown", u.setHelperHoverMoveStart), window.removeEventListener("pointerup", u.setHelperHoverMoveEnd), window.removeEventListener("pointercancel", u.setHelperHoverMoveEnd), n?.removeEventListener("update", u.setHelperHoverMoving);
1594
1615
  };
1595
1616
  }, [
1596
1617
  u,
1597
1618
  t,
1598
1619
  i
1599
1620
  ]), c(() => ({
1600
- createClippingRectangle: () => u.createClippingRectangle(),
1621
+ createClippingRectangle: (e = !1) => u.createClippingRectangle(e),
1601
1622
  createPlane: (e) => u.createPlane(e),
1602
1623
  deleteAllPlanes: () => u.deleteAllPlanes(),
1603
1624
  getActive: () => u.getActive(),
@@ -1615,28 +1636,28 @@ function _n(e, t, n) {
1615
1636
  }
1616
1637
  //#endregion
1617
1638
  //#region src/viewer/utils/DimentionsUtils/DimentionLine.ts
1618
- var vn = 12, yn = 6, bn = 4;
1619
- function xn() {
1639
+ var _n = 12, vn = 6, yn = 4;
1640
+ function bn() {
1620
1641
  return typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2);
1621
1642
  }
1622
- function Sn(e, t) {
1623
- return e instanceof ce ? (e.top - e.bottom) / e.zoom : e instanceof le ? 2 * Math.tan(e.fov * Math.PI / 360) * Math.max(t, .001) : Math.max(t, 1);
1643
+ function xn(e, t) {
1644
+ return e instanceof oe ? (e.top - e.bottom) / e.zoom : e instanceof se ? 2 * Math.tan(e.fov * Math.PI / 360) * Math.max(t, .001) : Math.max(t, 1);
1624
1645
  }
1625
- function Cn(e) {
1626
- let t = xn(), n = document.createElement("canvas"), r = n.getContext("2d");
1646
+ function Sn(e) {
1647
+ let t = bn(), n = document.createElement("canvas"), r = n.getContext("2d");
1627
1648
  if (!r) throw Error("Could not create dimension label canvas context");
1628
- let i = `600 ${vn}px system-ui, "Segoe UI", sans-serif`;
1649
+ let i = `600 ${_n}px system-ui, "Segoe UI", sans-serif`;
1629
1650
  r.font = i;
1630
- let a = r.measureText(e), o = a.actualBoundingBoxAscent || vn * .8, s = a.actualBoundingBoxDescent || vn * .2, c = Math.max(1, Math.ceil(a.width + yn * 2)), l = Math.max(1, Math.ceil(o + s + bn * 2));
1651
+ let a = r.measureText(e), o = a.actualBoundingBoxAscent || _n * .8, s = a.actualBoundingBoxDescent || _n * .2, c = Math.max(1, Math.ceil(a.width + vn * 2)), l = Math.max(1, Math.ceil(o + s + yn * 2));
1631
1652
  n.width = Math.ceil(c * t), n.height = Math.ceil(l * t), r.scale(t, t), r.clearRect(0, 0, c, l), r.fillStyle = "rgba(255, 255, 255, 0.86)", r.strokeStyle = "rgba(29, 39, 51, 0.22)", r.lineWidth = 1, r.beginPath(), r.roundRect(.5, .5, c - 1, l - 1, 4), r.fill(), r.stroke(), r.font = i, r.fillStyle = "#111827", r.textAlign = "center", r.textBaseline = "middle", r.fillText(e, c / 2, l / 2);
1632
1653
  let u = new b(n);
1633
- return u.colorSpace = fe, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
1654
+ return u.colorSpace = ue, u.generateMipmaps = !1, u.magFilter = M, u.minFilter = M, u.needsUpdate = !0, {
1634
1655
  height: l,
1635
1656
  texture: u,
1636
1657
  width: c
1637
1658
  };
1638
1659
  }
1639
- var wn = class e {
1660
+ var Cn = class e {
1640
1661
  static scale = 1;
1641
1662
  static scaleFactor = .015;
1642
1663
  static units = "m";
@@ -1666,7 +1687,7 @@ var wn = class e {
1666
1687
  this.end.x,
1667
1688
  this.end.y,
1668
1689
  this.end.z
1669
- ], 3)), this.line = new ee(this.lineGeometry, this.lineMaterial), this.line.renderOrder = 4, this.line.computeLineDistances(), this.root.add(this.line), this.addEndpointMeshes(), this.labelSprite = this.createLabelSprite(), this.root.add(this.labelSprite), this.updateLabel(), this.updatePositions(), this.ownerRoot.add(this.root);
1690
+ ], 3)), this.line = new O(this.lineGeometry, this.lineMaterial), this.line.renderOrder = 4, this.line.computeLineDistances(), this.root.add(this.line), this.addEndpointMeshes(), this.labelSprite = this.createLabelSprite(), this.root.add(this.labelSprite), this.updateLabel(), this.updatePositions(), this.ownerRoot.add(this.root);
1670
1691
  }
1671
1692
  get length() {
1672
1693
  return this.start.distanceTo(this.end);
@@ -1708,11 +1729,11 @@ var wn = class e {
1708
1729
  this.addEndpointMesh(this.start, this.end), this.addEndpointMesh(this.end, this.start);
1709
1730
  }
1710
1731
  addEndpointMesh(e, t) {
1711
- let n = new M(this.endpointGeometry, this.endpointMaterial);
1732
+ let n = new P(this.endpointGeometry, this.endpointMaterial);
1712
1733
  n.position.copy(e), n.scale.copy(this.endpointBaseScale), n.lookAt(t), n.renderOrder = 4, this.endpointMeshes.push(n), this.root.add(n);
1713
1734
  }
1714
1735
  createLabelSprite() {
1715
- let e = new he(new ge({
1736
+ let e = new pe(new me({
1716
1737
  depthTest: !1,
1717
1738
  depthWrite: !1,
1718
1739
  transparent: !0
@@ -1720,7 +1741,7 @@ var wn = class e {
1720
1741
  return e.renderOrder = 5, e;
1721
1742
  }
1722
1743
  createBoundingBoxMesh() {
1723
- let e = new M(new _(1, 1, Math.max(this.length, .001)), this.boundingMaterial);
1744
+ let e = new P(new _(1, 1, Math.max(this.length, .001)), this.boundingMaterial);
1724
1745
  return e.renderOrder = 3, e;
1725
1746
  }
1726
1747
  getTextContent() {
@@ -1731,7 +1752,7 @@ var wn = class e {
1731
1752
  let e = this.getTextContent();
1732
1753
  if (this.labelText === e) return;
1733
1754
  this.labelText = e, this.labelTexture?.dispose();
1734
- let t = Cn(e);
1755
+ let t = Sn(e);
1735
1756
  this.labelHeight = t.height, this.labelTexture = t.texture, this.labelWidth = t.width, this.labelSprite.material.map = t.texture, this.labelSprite.material.needsUpdate = !0;
1736
1757
  }
1737
1758
  updatePositions() {
@@ -1742,37 +1763,37 @@ var wn = class e {
1742
1763
  this.boundingMesh && (this.boundingMesh.position.copy(this.center), this.boundingMesh.lookAt(this.end), this.boundingMesh.geometry.dispose(), this.boundingMesh.geometry = new _(1, 1, Math.max(this.length, .001)));
1743
1764
  }
1744
1765
  rescaleMesh(t, n, r) {
1745
- let i = Sn(n, t.position.distanceTo(n.position)) / Math.max(1, r) * 12 * e.scaleFactor;
1766
+ let i = xn(n, t.position.distanceTo(n.position)) / Math.max(1, r) * 12 * e.scaleFactor;
1746
1767
  t.scale.setScalar(i);
1747
1768
  }
1748
1769
  rescaleBoundingMesh(e, t) {
1749
1770
  if (!this.boundingMesh) return;
1750
- let n = Sn(e, this.boundingMesh.position.distanceTo(e.position)) / Math.max(1, t) * 8;
1771
+ let n = xn(e, this.boundingMesh.position.distanceTo(e.position)) / Math.max(1, t) * 8;
1751
1772
  this.boundingMesh.scale.set(n, n, 1);
1752
1773
  }
1753
1774
  rescaleLabel(e, t) {
1754
- let n = Sn(e, this.labelSprite.position.distanceTo(e.position)), r = this.labelHeight / Math.max(1, t) * n, i = r * (this.labelWidth / this.labelHeight);
1775
+ let n = xn(e, this.labelSprite.position.distanceTo(e.position)), r = this.labelHeight / Math.max(1, t) * n, i = r * (this.labelWidth / this.labelHeight);
1755
1776
  this.labelSprite.scale.set(i, r, 1);
1756
1777
  }
1757
- }, Tn = "#111827", En = 1, Dn = "x";
1758
- function On(e) {
1778
+ }, wn = "#111827", Tn = 1, En = "x";
1779
+ function Dn(e) {
1759
1780
  let t = [];
1760
1781
  return e?.traverse((e) => {
1761
- e instanceof M && e.geometry.attributes.position && t.push(e);
1782
+ e instanceof P && e.geometry.attributes.position && t.push(e);
1762
1783
  }), t;
1763
1784
  }
1764
- function kn(e, t, n) {
1785
+ function On(e, t, n) {
1765
1786
  let r = e.clone();
1766
1787
  return r[n] = t[n], r;
1767
1788
  }
1768
- function An(e, t) {
1789
+ function kn(e, t) {
1769
1790
  let n = Math.hypot(t.y - e.y, t.z - e.z), r = Math.hypot(t.x - e.x, t.z - e.z), i = Math.hypot(t.x - e.x, t.y - e.y), a = Math.min(n, r, i);
1770
1791
  return a === n ? "x" : a === r ? "y" : "z";
1771
1792
  }
1772
- var jn = class e {
1793
+ var An = class e {
1773
1794
  active = !1;
1774
1795
  axis = null;
1775
- boundingMaterial = new ie({
1796
+ boundingMaterial = new ne({
1776
1797
  color: 0,
1777
1798
  depthTest: !1,
1778
1799
  depthWrite: !1,
@@ -1783,14 +1804,14 @@ var jn = class e {
1783
1804
  currentDimension = null;
1784
1805
  dimensions = [];
1785
1806
  endpointGeometry = e.createEndpointGeometry();
1786
- endpointMaterial = new ie({
1787
- color: Tn,
1807
+ endpointMaterial = new ne({
1808
+ color: wn,
1788
1809
  depthTest: !1,
1789
1810
  depthWrite: !1
1790
1811
  });
1791
- endpointScale = new P(1, 1, 1);
1792
- lineMaterial = new k({
1793
- color: Tn,
1812
+ endpointScale = new I(1, 1, 1);
1813
+ lineMaterial = new ee({
1814
+ color: wn,
1794
1815
  dashSize: .2,
1795
1816
  depthTest: !1,
1796
1817
  depthWrite: !1,
@@ -1798,14 +1819,14 @@ var jn = class e {
1798
1819
  });
1799
1820
  measureInProcess = !1;
1800
1821
  moveState = "end";
1801
- previewMarker = new M(e.createPreviewGeometry(), new ie({
1822
+ previewMarker = new P(e.createPreviewGeometry(), new ne({
1802
1823
  color: 0,
1803
1824
  depthTest: !1,
1804
1825
  depthWrite: !1
1805
1826
  }));
1806
1827
  root = new D();
1807
- snapDistance = En;
1808
- startPoint = new P();
1828
+ snapDistance = Tn;
1829
+ startPoint = new I();
1809
1830
  unit = "m";
1810
1831
  constructor(e) {
1811
1832
  this.context = e, this.root.name = "BimatterDimensions", this.previewMarker.renderOrder = 5, this.previewMarker.visible = !1, this.root.add(this.previewMarker), this.context.scene.add(this.root);
@@ -1838,13 +1859,13 @@ var jn = class e {
1838
1859
  });
1839
1860
  }
1840
1861
  setEndpointScaleFactor(e) {
1841
- !Number.isFinite(e) || e <= 0 || (wn.scaleFactor = e);
1862
+ !Number.isFinite(e) || e <= 0 || (Cn.scaleFactor = e);
1842
1863
  }
1843
1864
  setSnapDistance(e) {
1844
1865
  !Number.isFinite(e) || e < 0 || (this.snapDistance = e);
1845
1866
  }
1846
1867
  setUnit(e) {
1847
- this.unit = e, wn.units = e, wn.scale = e === "mm" ? 1e3 : 1, this.dimensions.forEach((e) => {
1868
+ this.unit = e, Cn.units = e, Cn.scale = e === "mm" ? 1e3 : 1, this.dimensions.forEach((e) => {
1848
1869
  e.endPoint = e.end;
1849
1870
  }), this.currentDimension && (this.currentDimension.endPoint = this.currentDimension.end);
1850
1871
  }
@@ -1870,7 +1891,7 @@ var jn = class e {
1870
1891
  changeAxes() {
1871
1892
  if (!this.measureInProcess || !this.currentDimension) return;
1872
1893
  let e = this.currentDimension.end, t = this.getNextAxis();
1873
- this.axis = t, this.currentDimension.endPoint = kn(this.startPoint, e, t);
1894
+ this.axis = t, this.currentDimension.endPoint = On(this.startPoint, e, t);
1874
1895
  }
1875
1896
  updateFrame() {
1876
1897
  if (!this.active) return;
@@ -1885,11 +1906,11 @@ var jn = class e {
1885
1906
  }
1886
1907
  addEventListeners() {
1887
1908
  let { controlRef: e, domElement: t } = this.context;
1888
- t.addEventListener("click", this.onClick), t.addEventListener("pointermove", this.onPointerMove), t.addEventListener("pointerdown", this.onPointerDown), window.addEventListener("pointerup", this.onPointerUp), window.addEventListener("pointercancel", this.onPointerUp), window.addEventListener("keydown", this.onKeyDown), e.current?.addEventListener("change", this.onControlsChange);
1909
+ t.addEventListener("click", this.onClick), t.addEventListener("pointermove", this.onPointerMove), t.addEventListener("pointerdown", this.onPointerDown), window.addEventListener("pointerup", this.onPointerUp), window.addEventListener("pointercancel", this.onPointerUp), window.addEventListener("keydown", this.onKeyDown), e.current?.addEventListener("update", this.onControlsChange);
1889
1910
  }
1890
1911
  removeEventListeners() {
1891
1912
  let { controlRef: e, domElement: t } = this.context;
1892
- t.removeEventListener("click", this.onClick), t.removeEventListener("pointermove", this.onPointerMove), t.removeEventListener("pointerdown", this.onPointerDown), window.removeEventListener("pointerup", this.onPointerUp), window.removeEventListener("pointercancel", this.onPointerUp), window.removeEventListener("keydown", this.onKeyDown), e.current?.removeEventListener("change", this.onControlsChange);
1913
+ t.removeEventListener("click", this.onClick), t.removeEventListener("pointermove", this.onPointerMove), t.removeEventListener("pointerdown", this.onPointerDown), window.removeEventListener("pointerup", this.onPointerUp), window.removeEventListener("pointercancel", this.onPointerUp), window.removeEventListener("keydown", this.onKeyDown), e.current?.removeEventListener("update", this.onControlsChange);
1893
1914
  }
1894
1915
  drawStart(e) {
1895
1916
  let t = this.getClosestVertex(e);
@@ -1914,7 +1935,7 @@ var jn = class e {
1914
1935
  this.currentDimension && (this.currentDimension.createBoundingBox(), this.dimensions.push(this.currentDimension), this.currentDimension = null, this.measureInProcess = !1, this.axis = null);
1915
1936
  }
1916
1937
  createDimension(e, t) {
1917
- return new wn({
1938
+ return new Cn({
1918
1939
  boundingMaterial: this.boundingMaterial,
1919
1940
  endpointGeometry: this.endpointGeometry,
1920
1941
  endpointMaterial: this.endpointMaterial,
@@ -1926,7 +1947,7 @@ var jn = class e {
1926
1947
  });
1927
1948
  }
1928
1949
  getModelHit(e) {
1929
- let t = On(this.context.modelRef.current);
1950
+ let t = Dn(this.context.modelRef.current);
1930
1951
  return t.length ? this.context.cameraUtils.getIntersection(!0, {
1931
1952
  event: e,
1932
1953
  filter: (e) => !!e.face,
@@ -1938,7 +1959,7 @@ var jn = class e {
1938
1959
  return this.dimensions.map((e) => e.boundingBox).filter((e) => !!e);
1939
1960
  }
1940
1961
  getClosestVertex(e) {
1941
- if (!(e.object instanceof M) || !e.face) return e.point.clone();
1962
+ if (!(e.object instanceof P) || !e.face) return e.point.clone();
1942
1963
  let t = e.object.geometry.attributes.position;
1943
1964
  if (!t) return e.point.clone();
1944
1965
  let n = [
@@ -1946,29 +1967,29 @@ var jn = class e {
1946
1967
  e.face.b,
1947
1968
  e.face.c
1948
1969
  ].map((n) => {
1949
- let r = new P(t.getX(n), t.getY(n), t.getZ(n));
1970
+ let r = new I(t.getX(n), t.getY(n), t.getZ(n));
1950
1971
  return e.object.localToWorld(r);
1951
1972
  }).filter((t) => t.distanceTo(e.point) <= this.snapDistance);
1952
1973
  return n.length ? n.reduce((t, n) => n.distanceTo(e.point) < t.distanceTo(e.point) ? n : t) : e.point.clone();
1953
1974
  }
1954
1975
  getPreviewEndPoint(e, t) {
1955
1976
  if (!t) return this.axis = null, e.clone();
1956
- let n = this.axis ?? An(this.startPoint, e);
1957
- return this.axis = n, kn(this.startPoint, e, n);
1977
+ let n = this.axis ?? kn(this.startPoint, e);
1978
+ return this.axis = n, On(this.startPoint, e, n);
1958
1979
  }
1959
1980
  getNextAxis() {
1960
1981
  switch (this.axis) {
1961
1982
  case "x": return "y";
1962
1983
  case "y": return "z";
1963
1984
  case "z": return "x";
1964
- default: return Dn;
1985
+ default: return En;
1965
1986
  }
1966
1987
  }
1967
1988
  getIsMoving() {
1968
1989
  return this.moveState !== "end" && this.moveState !== "start";
1969
1990
  }
1970
1991
  rescalePreviewMarker() {
1971
- let { camera: e, viewportHeight: t } = this.context, n = this.previewMarker.position.distanceTo(e.position), r = e instanceof le ? 2 * Math.tan(e.fov * Math.PI / 360) * Math.max(n, .001) * 6.667 / Math.max(1, t) : .08;
1992
+ let { camera: e, viewportHeight: t } = this.context, n = this.previewMarker.position.distanceTo(e.position), r = e instanceof se ? 2 * Math.tan(e.fov * Math.PI / 360) * Math.max(n, .001) * 6.667 / Math.max(1, t) : .08;
1972
1993
  this.previewMarker.scale.setScalar(r);
1973
1994
  }
1974
1995
  setSelectionInteractionDisabled(e) {
@@ -2005,11 +2026,11 @@ var jn = class e {
2005
2026
  return n.translate(0, -e / 2, 0), n.rotateX(-Math.PI / 2), n;
2006
2027
  }
2007
2028
  static createPreviewGeometry() {
2008
- return new me(.5, 16, 12);
2029
+ return new fe(.5, 16, 12);
2009
2030
  }
2010
2031
  };
2011
- function Mn(e, t, n) {
2012
- let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.scene), s = p((e) => e.size), l = R(), u = c(() => new jn({
2032
+ function jn(e, t, n) {
2033
+ let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.scene), s = p((e) => e.size), l = B(), u = c(() => new An({
2013
2034
  camera: r,
2014
2035
  cameraUtils: n,
2015
2036
  controlRef: t,
@@ -2071,15 +2092,15 @@ function Mn(e, t, n) {
2071
2092
  }
2072
2093
  //#endregion
2073
2094
  //#region src/viewer/utils/Hotkeys/useHotkeysUtils.tsx
2074
- function Nn(e) {
2095
+ function Mn(e) {
2075
2096
  return e instanceof HTMLElement ? e.isContentEditable || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement : !1;
2076
2097
  }
2077
- function Pn() {
2078
- let e = L((e) => e.api), t = L((e) => e.defaultHotkeysEnabled);
2098
+ function Nn() {
2099
+ let e = z((e) => e.api), t = z((e) => e.defaultHotkeysEnabled);
2079
2100
  o(() => {
2080
2101
  if (!t) return;
2081
2102
  let n = (t) => {
2082
- Nn(t.target) || (t.code === "KeyI" && e?.geometryUtils.isolateSelected(), t.code === "KeyH" && e?.geometryUtils.hideSelected(), t.code === "KeyC" && e?.geometryUtils.showAll(), t.code === "KeyP" && e?.clipping.createPlane(), t.code === "KeyM" && e?.dimensions.toggle());
2103
+ Mn(t.target) || (t.code === "KeyI" && e?.geometryUtils.isolateSelected(), t.code === "KeyH" && e?.geometryUtils.hideSelected(), t.code === "KeyC" && e?.geometryUtils.showAll(), t.code === "KeyP" && e?.clipping.createPlane(), t.code === "KeyM" && e?.dimensions.toggle());
2083
2104
  };
2084
2105
  return window.addEventListener("keydown", n), () => {
2085
2106
  window.removeEventListener("keydown", n);
@@ -2088,15 +2109,15 @@ function Pn() {
2088
2109
  }
2089
2110
  //#endregion
2090
2111
  //#region src/viewer/Camera/useCameraUtils.ts
2091
- var Fn = 1e-6;
2092
- function In(e, t) {
2112
+ var Pn = 1e-6;
2113
+ function Fn(e, t) {
2093
2114
  let n = t.getBoundingClientRect();
2094
- return n.width <= 0 || n.height <= 0 || e.clientX < n.left || e.clientX > n.right || e.clientY < n.top || e.clientY > n.bottom ? null : new N((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
2115
+ return n.width <= 0 || n.height <= 0 || e.clientX < n.left || e.clientX > n.right || e.clientY < n.top || e.clientY > n.bottom ? null : new F((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
2095
2116
  }
2096
- function Ln(e, t) {
2097
- return t.every((t) => t.distanceToPoint(e) >= -Fn);
2117
+ function In(e, t) {
2118
+ return t.every((t) => t.distanceToPoint(e) >= -Pn);
2098
2119
  }
2099
- function Rn(e) {
2120
+ function Ln(e) {
2100
2121
  let t = e;
2101
2122
  for (; t;) {
2102
2123
  if (!t.visible) return !1;
@@ -2104,8 +2125,8 @@ function Rn(e) {
2104
2125
  }
2105
2126
  return !0;
2106
2127
  }
2107
- function zn(e) {
2108
- let t = p((e) => e.camera), n = p((e) => e.gl), r = p((e) => e.raycaster), a = l(null), s = l(null), u = l(new N()), d = i((e) => {
2128
+ function Rn(e) {
2129
+ let t = p((e) => e.camera), n = p((e) => e.gl), r = p((e) => e.raycaster), a = l(null), s = l(null), u = l(new F()), d = i((e) => {
2109
2130
  a.current = e;
2110
2131
  }, []), f = i(() => {
2111
2132
  let e = a.current;
@@ -2113,7 +2134,7 @@ function zn(e) {
2113
2134
  }, []);
2114
2135
  o(() => {
2115
2136
  let e = n.domElement, t = (t) => {
2116
- let n = In(t, e);
2137
+ let n = Fn(t, e);
2117
2138
  n && (s.current = n);
2118
2139
  }, r = () => {
2119
2140
  s.current = null;
@@ -2123,11 +2144,11 @@ function zn(e) {
2123
2144
  };
2124
2145
  }, [n]);
2125
2146
  let m = i((i = !1, { event: a, filter: o, object: c = e.current, recursive: l = !0, respectClipping: d = !0 } = {}) => {
2126
- let p = a ? In(a, n.domElement) : s.current;
2147
+ let p = a ? Fn(a, n.domElement) : s.current;
2127
2148
  if (!p || !c) return i ? null : [];
2128
2149
  let m = d ? f() : [], h = Array.isArray(c) ? c : [c];
2129
2150
  t.updateMatrixWorld(), e.current?.updateMatrixWorld(!0), u.current.copy(p), r.setFromCamera(u.current, t);
2130
- let g = r.intersectObjects(h, l).filter((e) => Rn(e.object) ? m.length ? Ln(e.point, m) : !0 : !1).filter((e) => o ? o(e) : !0);
2151
+ let g = r.intersectObjects(h, l).filter((e) => Ln(e.object) ? m.length ? In(e.point, m) : !0 : !1).filter((e) => o ? o(e) : !0);
2131
2152
  return i ? g[0] ?? null : g;
2132
2153
  }, [
2133
2154
  t,
@@ -2148,8 +2169,8 @@ function zn(e) {
2148
2169
  }
2149
2170
  //#endregion
2150
2171
  //#region src/viewer/Selector/SelectionBox.ts
2151
- var Bn = new P(), Vn = new P(), W = new N(), Hn = new P(), Un = new P(), Wn = new P(), Gn = new P(), Kn = new P(), qn = new P(), Jn = new P();
2152
- function Yn(e) {
2172
+ var zn = new I(), Bn = new I(), K = new F(), Vn = new I(), Hn = new I(), Un = new I(), Wn = new I(), Gn = new I(), Kn = new I(), qn = new I();
2173
+ function Jn(e) {
2153
2174
  let t = e;
2154
2175
  for (; t;) {
2155
2176
  let e = t.modelID ?? t.userData.modelID;
@@ -2158,7 +2179,7 @@ function Yn(e) {
2158
2179
  }
2159
2180
  return 0;
2160
2181
  }
2161
- function Xn(e) {
2182
+ function Yn(e) {
2162
2183
  let t = e;
2163
2184
  for (; t;) {
2164
2185
  if (!t.visible) return !1;
@@ -2166,16 +2187,16 @@ function Xn(e) {
2166
2187
  }
2167
2188
  return !0;
2168
2189
  }
2169
- function Zn(e, t, n) {
2170
- return n.length ? (Hn.copy(t).applyMatrix4(e.matrixWorld), Ln(Hn, n)) : !0;
2190
+ function Xn(e, t, n) {
2191
+ return n.length ? (Vn.copy(t).applyMatrix4(e.matrixWorld), In(Vn, n)) : !0;
2171
2192
  }
2172
- function Qn(e, t, n, r, i) {
2173
- return i.length ? (Un.copy(t).applyMatrix4(e.matrixWorld), Wn.copy(n).applyMatrix4(e.matrixWorld), Gn.copy(r).applyMatrix4(e.matrixWorld), i.every((e) => {
2174
- let t = e.distanceToPoint(Un), n = e.distanceToPoint(Wn), r = e.distanceToPoint(Gn);
2193
+ function Zn(e, t, n, r, i) {
2194
+ return i.length ? (Hn.copy(t).applyMatrix4(e.matrixWorld), Un.copy(n).applyMatrix4(e.matrixWorld), Wn.copy(r).applyMatrix4(e.matrixWorld), i.every((e) => {
2195
+ let t = e.distanceToPoint(Hn), n = e.distanceToPoint(Un), r = e.distanceToPoint(Wn);
2175
2196
  return !(t < -1e-6 && n < -1e-6 && r < -1e-6);
2176
2197
  })) : !0;
2177
2198
  }
2178
- function $n(e) {
2199
+ function Qn(e) {
2179
2200
  let t = e.getBoundingClientRect();
2180
2201
  return {
2181
2202
  height: t.height,
@@ -2184,7 +2205,7 @@ function $n(e) {
2184
2205
  width: t.width
2185
2206
  };
2186
2207
  }
2187
- function er(e) {
2208
+ function $n(e) {
2188
2209
  return {
2189
2210
  boundsCheckMs: 0,
2190
2211
  candidateIds: 0,
@@ -2210,7 +2231,7 @@ function er(e) {
2210
2231
  triangleProjectionMs: 0
2211
2232
  };
2212
2233
  }
2213
- function tr(e, t) {
2234
+ function er(e, t) {
2214
2235
  return {
2215
2236
  minX: Math.min(e.x, t.x),
2216
2237
  minY: Math.min(e.y, t.y),
@@ -2218,43 +2239,43 @@ function tr(e, t) {
2218
2239
  maxY: Math.max(e.y, t.y)
2219
2240
  };
2220
2241
  }
2221
- function nr(e, t) {
2242
+ function tr(e, t) {
2222
2243
  return t.x >= e.x ? "contains" : "intersects";
2223
2244
  }
2224
- function rr(e, t) {
2225
- return ir(e.x, e.y, t);
2245
+ function nr(e, t) {
2246
+ return rr(e.x, e.y, t);
2226
2247
  }
2227
- function ir(e, t, n) {
2248
+ function rr(e, t, n) {
2228
2249
  return e >= n.minX && e <= n.maxX && t >= n.minY && t <= n.maxY;
2229
2250
  }
2230
- function ar(e, t, n, r, i, a) {
2251
+ function ir(e, t, n, r, i, a) {
2231
2252
  return (a - t) * (n - e) > (r - t) * (i - e);
2232
2253
  }
2233
- function or(e, t, n, r, i, a, o, s) {
2234
- return ar(e, t, i, a, o, s) !== ar(n, r, i, a, o, s) && ar(e, t, n, r, i, a) !== ar(e, t, n, r, o, s);
2254
+ function ar(e, t, n, r, i, a, o, s) {
2255
+ return ir(e, t, i, a, o, s) !== ir(n, r, i, a, o, s) && ir(e, t, n, r, i, a) !== ir(e, t, n, r, o, s);
2235
2256
  }
2236
- function sr(e, t, n, r, i) {
2257
+ function or(e, t, n, r, i) {
2237
2258
  let a = .5 * (-r.y * i.x + n.y * (-r.x + i.x) + n.x * (r.y - i.y) + r.x * i.y), o = a < 0 ? -1 : 1, s = (n.y * i.x - n.x * i.y + (i.y - n.y) * e + (n.x - i.x) * t) * o, c = (n.x * r.y - n.y * r.x + (n.y - r.y) * e + (r.x - n.x) * t) * o;
2238
2259
  return s >= 0 && c >= 0 && s + c <= 2 * a * o;
2239
2260
  }
2240
- function cr(e, t, n, r) {
2241
- return rr(e, r) || rr(t, r) || rr(n, r) || sr(r.minX, r.minY, e, t, n) || sr(r.maxX, r.minY, e, t, n) || sr(r.maxX, r.maxY, e, t, n) || sr(r.minX, r.maxY, e, t, n) ? !0 : lr(e, t, r) || lr(t, n, r) || lr(n, e, r);
2261
+ function sr(e, t, n, r) {
2262
+ return nr(e, r) || nr(t, r) || nr(n, r) || or(r.minX, r.minY, e, t, n) || or(r.maxX, r.minY, e, t, n) || or(r.maxX, r.maxY, e, t, n) || or(r.minX, r.maxY, e, t, n) ? !0 : cr(e, t, r) || cr(t, n, r) || cr(n, e, r);
2242
2263
  }
2243
- function lr(e, t, n) {
2244
- return or(e.x, e.y, t.x, t.y, n.minX, n.minY, n.maxX, n.minY) || or(e.x, e.y, t.x, t.y, n.maxX, n.minY, n.maxX, n.maxY) || or(e.x, e.y, t.x, t.y, n.maxX, n.maxY, n.minX, n.maxY) || or(e.x, e.y, t.x, t.y, n.minX, n.maxY, n.minX, n.minY);
2264
+ function cr(e, t, n) {
2265
+ return ar(e.x, e.y, t.x, t.y, n.minX, n.minY, n.maxX, n.minY) || ar(e.x, e.y, t.x, t.y, n.maxX, n.minY, n.maxX, n.maxY) || ar(e.x, e.y, t.x, t.y, n.maxX, n.maxY, n.minX, n.maxY) || ar(e.x, e.y, t.x, t.y, n.minX, n.maxY, n.minX, n.minY);
2245
2266
  }
2246
- function G(e, t, n, r, i = new N()) {
2247
- let a = Bn.copy(t).applyMatrix4(e.matrixWorld).project(n);
2267
+ function lr(e, t, n, r, i = new F()) {
2268
+ let a = zn.copy(t).applyMatrix4(e.matrixWorld).project(n);
2248
2269
  return i.set((a.x + 1) / 2 * r.width + r.left, (-a.y + 1) / 2 * r.height + r.top);
2249
2270
  }
2250
2271
  function ur(e, t, n, r, i) {
2251
2272
  let a = Infinity, o = -Infinity, s = Infinity, c = -Infinity, l = 0;
2252
- for (let u = 0; u < 2; u++) for (let d = 0; d < 2; d++) for (let f = 0; f < 2; f++) Vn.set(u ? t.max.x : t.min.x, d ? t.max.y : t.min.y, f ? t.max.z : t.min.z), G(e, Vn, r, i, W), a = Math.min(a, W.x), o = Math.max(o, W.x), s = Math.min(s, W.y), c = Math.max(c, W.y), rr(W, n) && (l += 1);
2253
- return o < n.minX || a > n.maxX || c < n.minY || s > n.maxY ? Ce : l === 8 ? be : xe;
2273
+ for (let u = 0; u < 2; u++) for (let d = 0; d < 2; d++) for (let f = 0; f < 2; f++) Bn.set(u ? t.max.x : t.min.x, d ? t.max.y : t.min.y, f ? t.max.z : t.min.z), lr(e, Bn, r, i, K), a = Math.min(a, K.x), o = Math.max(o, K.x), s = Math.min(s, K.y), c = Math.max(c, K.y), nr(K, n) && (l += 1);
2274
+ return o < n.minX || a > n.maxX || c < n.minY || s > n.maxY ? xe : l === 8 ? ve : ye;
2254
2275
  }
2255
2276
  function dr(e, t, n, r) {
2256
2277
  let i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
2257
- for (let c = 0; c < 2; c++) for (let l = 0; l < 2; l++) for (let u = 0; u < 2; u++) Vn.set(c ? t.max.x : t.min.x, l ? t.max.y : t.min.y, u ? t.max.z : t.min.z), G(e, Vn, n, r, W), i = Math.min(i, W.x), a = Math.max(a, W.x), o = Math.min(o, W.y), s = Math.max(s, W.y);
2278
+ for (let c = 0; c < 2; c++) for (let l = 0; l < 2; l++) for (let u = 0; u < 2; u++) Bn.set(c ? t.max.x : t.min.x, l ? t.max.y : t.min.y, u ? t.max.z : t.min.z), lr(e, Bn, n, r, K), i = Math.min(i, K.x), a = Math.max(a, K.x), o = Math.min(o, K.y), s = Math.max(s, K.y);
2258
2279
  return {
2259
2280
  minX: i,
2260
2281
  minY: o,
@@ -2284,19 +2305,19 @@ function gr(e, t, n, r = []) {
2284
2305
  let i = e.geometry, a = i.index, o = i.attributes.ids, s = i.attributes.position;
2285
2306
  if (!a || !o || !s) return;
2286
2307
  let c = t * 3;
2287
- r.length && (Kn.fromBufferAttribute(s, a.getX(c)), qn.fromBufferAttribute(s, a.getX(c + 1)), Jn.fromBufferAttribute(s, a.getX(c + 2)), !Qn(e, Kn, qn, Jn, r)) || mr(n, Yn(e), o.getX(a.getX(c)));
2308
+ r.length && (Gn.fromBufferAttribute(s, a.getX(c)), Kn.fromBufferAttribute(s, a.getX(c + 1)), qn.fromBufferAttribute(s, a.getX(c + 2)), !Zn(e, Gn, Kn, qn, r)) || mr(n, Jn(e), o.getX(a.getX(c)));
2288
2309
  }
2289
2310
  function _r({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i, clippingPlanes: a, profile: o }) {
2290
- let s = performance.now(), c = /* @__PURE__ */ new Map(), l = new P();
2311
+ let s = performance.now(), c = /* @__PURE__ */ new Map(), l = new I();
2291
2312
  e.traverse((e) => {
2292
2313
  let s = e;
2293
- if (!s.isMesh || !Xn(s)) return;
2314
+ if (!s.isMesh || !Yn(s)) return;
2294
2315
  let u = s.geometry.attributes.ids, d = s.geometry.attributes.position;
2295
2316
  if (!(!u || !d)) {
2296
2317
  o && (o.containedVerticesVisited += u.count);
2297
2318
  for (let e = 0; e < u.count; e++) {
2298
- let f = Yn(s), p = u.getX(e);
2299
- if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !Zn(s, l, a))) continue;
2319
+ let f = Jn(s), p = u.getX(e);
2320
+ if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !Xn(s, l, a))) continue;
2300
2321
  o && (o.containedCandidateVertices += 1);
2301
2322
  let m = `${f}:${p}`, h = c.get(m);
2302
2323
  h || (h = {
@@ -2304,7 +2325,7 @@ function _r({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i,
2304
2325
  inside: 0,
2305
2326
  modelID: f,
2306
2327
  total: 0
2307
- }, c.set(m, h)), h.total += 1, rr(G(s, l, t, n), r) && (h.inside += 1);
2328
+ }, c.set(m, h)), h.total += 1, nr(lr(s, l, t, n), r) && (h.inside += 1);
2308
2329
  }
2309
2330
  }
2310
2331
  });
@@ -2316,11 +2337,11 @@ function _r({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i,
2316
2337
  function vr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect: i, mode: a, profile: o }) {
2317
2338
  let s = performance.now(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
2318
2339
  if (!e) return c;
2319
- let u = $n(r), d = performance.now();
2340
+ let u = Qn(r), d = performance.now();
2320
2341
  e.updateMatrixWorld(!0), t.updateMatrixWorld(), o && (o.matrixUpdateMs += performance.now() - d), e.traverse((e) => {
2321
2342
  let r = e;
2322
2343
  if (!r.isMesh) return;
2323
- if (o && (o.meshCount += 1), !Xn(r)) {
2344
+ if (o && (o.meshCount += 1), !Yn(r)) {
2324
2345
  o && (o.skippedMeshCount += 1);
2325
2346
  return;
2326
2347
  }
@@ -2349,8 +2370,8 @@ function vr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
2349
2370
  intersectsTriangle: (e, s, d) => {
2350
2371
  let f = performance.now();
2351
2372
  if (o && (o.intersectsTriangleCalls += 1), !d) {
2352
- let n = performance.now(), a = G(r, e.a, t, u), s = G(r, e.b, t, u), c = G(r, e.c, t, u);
2353
- if (o && (o.triangleProjectionMs += performance.now() - n), !cr(a, s, c, i)) return o && (o.intersectsTriangleMs += performance.now() - f), !1;
2373
+ let n = performance.now(), a = lr(r, e.a, t, u), s = lr(r, e.b, t, u), c = lr(r, e.c, t, u);
2374
+ if (o && (o.triangleProjectionMs += performance.now() - n), !sr(a, s, c, i)) return o && (o.intersectsTriangleMs += performance.now() - f), !1;
2354
2375
  }
2355
2376
  return a === "contains" ? gr(r, s, l, n) : gr(r, s, c, n), o && (o.intersectsTriangleMs += performance.now() - f), !1;
2356
2377
  }
@@ -2368,7 +2389,7 @@ function vr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
2368
2389
  return o && (o.candidateIds = hr(l), o.selectedIds = hr(f), o.totalMs = performance.now() - s), f;
2369
2390
  }
2370
2391
  function yr(e) {
2371
- let t = er(e.mode);
2392
+ let t = $n(e.mode);
2372
2393
  return {
2373
2394
  ids: vr({
2374
2395
  ...e,
@@ -2387,12 +2408,12 @@ function br(e) {
2387
2408
  };
2388
2409
  }
2389
2410
  function xr(e, t, n) {
2390
- let r = br(nr(t, n));
2411
+ let r = br(tr(t, n));
2391
2412
  if (!e.current) {
2392
2413
  let t = document.createElement("div");
2393
2414
  t.style.position = "fixed", t.style.pointerEvents = "none", t.style.zIndex = "10", e.current = t, document.body.appendChild(t);
2394
2415
  }
2395
- let i = tr(t, n);
2416
+ let i = er(t, n);
2396
2417
  e.current.style.border = `1px solid ${r.border}`, e.current.style.background = r.background, e.current.style.left = `${i.minX}px`, e.current.style.top = `${i.minY}px`, e.current.style.width = `${i.maxX - i.minX}px`, e.current.style.height = `${i.maxY - i.minY}px`;
2397
2418
  }
2398
2419
  function Sr(e) {
@@ -2429,75 +2450,78 @@ function Or(e) {
2429
2450
  return !0;
2430
2451
  }
2431
2452
  function kr(e) {
2432
- if (!Or(e.object) || !(e.object instanceof M) || e.faceIndex === void 0 || e.faceIndex === null) return !1;
2453
+ if (!Or(e.object) || !(e.object instanceof P) || e.faceIndex === void 0 || e.faceIndex === null) return !1;
2433
2454
  let t = e.object.geometry;
2434
2455
  return !!(t.index && t.attributes.ids);
2435
2456
  }
2436
2457
  function Ar(e, t, n) {
2437
- let r = l("end"), i = L((e) => e.selected), a = L((e) => e.setSelected), s = L((e) => e.addSelected), c = L((e) => e.removeSelected), u = L((e) => e.showStats), d = R(), f = l(null), m = l(null), h = l(!1), g = l(!1), _ = l("add"), v = l(null), y = l(!1), b = l(0), x = l(null), S = l(null), C = () => d.getState().selectionInteractionDisabled, w = () => {
2458
+ let r = l("end"), i = z((e) => e.selected), a = z((e) => e.setSelected), s = z((e) => e.addSelected), c = z((e) => e.removeSelected), u = z((e) => e.showStats), d = B(), f = l(null), m = l(null), h = l(!1), g = l(!1), _ = l("add"), v = l(null), y = l(!1), b = l(0), x = l(null), S = l(null), C = () => d.getState().selectionInteractionDisabled, w = (e) => {
2459
+ let n = t.current;
2460
+ n && (n.cancel(), n.setOrbitPoint(e.x, e.y, e.z));
2461
+ }, T = () => {
2438
2462
  e.current?.traverse((e) => {
2439
- if (!(e instanceof M)) return;
2463
+ if (!(e instanceof P)) return;
2440
2464
  let t = e;
2441
2465
  t.preselected = !1, Tr(t.material, -1);
2442
2466
  });
2443
- }, T = () => {
2467
+ }, E = () => {
2444
2468
  f.current = null, h.current = !1, Sr(m), t.current && (t.current.enabled = !0);
2445
- }, E = (t) => {
2469
+ }, D = (t) => {
2446
2470
  if (C()) {
2447
- w();
2471
+ T();
2448
2472
  return;
2449
2473
  }
2450
2474
  if (f.current) {
2451
- w();
2475
+ T();
2452
2476
  return;
2453
2477
  }
2454
2478
  if (r.current !== "end" && r.current !== "start") {
2455
- w();
2479
+ T();
2456
2480
  return;
2457
2481
  }
2458
- let n = oe(t, e.current)[0], i;
2459
- n && (i = n.object), w(), !(!n || !i) && e.current?.traverse((e) => {
2460
- if (!(e instanceof M)) return;
2482
+ let n = ae(t, e.current)[0], i;
2483
+ n && (i = n.object), T(), !(!n || !i) && e.current?.traverse((e) => {
2484
+ if (!(e instanceof P)) return;
2461
2485
  let t = e;
2462
2486
  if (t !== i) return;
2463
2487
  let r = n.faceIndex * 3, a = t.geometry.index.getX(r), o = t.geometry.attributes.ids.getX(a);
2464
2488
  t.preselected = !0, Tr(t.material, o);
2465
2489
  });
2466
2490
  };
2467
- function D() {
2491
+ function O() {
2468
2492
  return performance.now();
2469
2493
  }
2470
- let ee = (e) => {
2494
+ let k = (e) => {
2471
2495
  if (C()) {
2472
- S.current = null, x.current !== null && (window.clearTimeout(x.current), x.current = null), w();
2496
+ S.current = null, x.current !== null && (window.clearTimeout(x.current), x.current = null), T();
2473
2497
  return;
2474
2498
  }
2475
2499
  if (S.current = e, x.current !== null) return;
2476
- let t = D() - b.current, n = Math.max(0, Cr - t);
2500
+ let t = O() - b.current, n = Math.max(0, Cr - t);
2477
2501
  x.current = window.setTimeout(() => {
2478
2502
  x.current = null;
2479
2503
  let e = S.current;
2480
- S.current = null, e && (b.current = performance.now(), E(e));
2504
+ S.current = null, e && (b.current = performance.now(), D(e));
2481
2505
  }, n);
2482
- }, O = l(null);
2506
+ }, A = l(null);
2483
2507
  o(() => {
2484
2508
  let e = v.current;
2485
2509
  if (e) {
2486
- u && O.current !== null && console.log(`selection ${e.action}:`, Date.now() - O.current, "ms"), v.current = null, O.current = null;
2510
+ u && A.current !== null && console.log(`selection ${e.action}:`, Date.now() - A.current, "ms"), v.current = null, A.current = null;
2487
2511
  return;
2488
2512
  }
2489
- u && O.current !== null && (console.log("selection spend:", Date.now() - O.current, "ms"), O.current = null);
2513
+ u && A.current !== null && (console.log("selection spend:", Date.now() - A.current, "ms"), A.current = null);
2490
2514
  }, [i, u]);
2491
- let { camera: te, gl: k } = p();
2492
- function ne() {
2515
+ let { camera: ee, gl: j } = p();
2516
+ function M() {
2493
2517
  return Date.now();
2494
2518
  }
2495
- let A = (e) => {
2496
- let t = k.domElement.getBoundingClientRect();
2519
+ let te = (e) => {
2520
+ let t = j.domElement.getBoundingClientRect();
2497
2521
  return e.clientX >= t.left && e.clientX <= t.right && e.clientY >= t.top && e.clientY <= t.bottom;
2498
- }, re = (t) => {
2522
+ }, N = (t) => {
2499
2523
  if (C()) {
2500
- y.current = !1, g.current = !1, w();
2524
+ y.current = !1, g.current = !1, T();
2501
2525
  return;
2502
2526
  }
2503
2527
  if (!y.current) return;
@@ -2505,15 +2529,15 @@ function Ar(e, t, n) {
2505
2529
  g.current = !1;
2506
2530
  return;
2507
2531
  }
2508
- if (!A(t)) return;
2509
- if (O.current = ne(), r.current !== "end" && r.current !== "start" && r.current > 15) {
2532
+ if (!te(t)) return;
2533
+ if (A.current = M(), r.current !== "end" && r.current !== "start" && r.current > 15) {
2510
2534
  r.current = "end";
2511
2535
  return;
2512
2536
  }
2513
- let n = t.shiftKey, o = t.ctrlKey, l = oe(t, e.current), u, d = Er(e);
2537
+ let n = t.shiftKey, o = t.ctrlKey, l = ae(t, e.current), u, d = Er(e), f = null;
2514
2538
  if (l.length) {
2515
2539
  let e = l[0], t = e.object;
2516
- d = Dr(t);
2540
+ d = Dr(t), f = e.point;
2517
2541
  let n = e.faceIndex * 3, r = t.geometry.index.getX(n);
2518
2542
  u = t.geometry.attributes.ids.getX(r);
2519
2543
  }
@@ -2521,37 +2545,37 @@ function Ar(e, t, n) {
2521
2545
  u !== void 0 && c(d, [u]);
2522
2546
  return;
2523
2547
  } else if (n) {
2524
- u !== void 0 && (i[d]?.has(u) ?? !1 ? c(d, [u]) : s(d, [u]));
2548
+ u !== void 0 && (i[d]?.has(u) ?? !1 ? c(d, [u]) : (s(d, [u]), f && w(f)));
2525
2549
  return;
2526
2550
  }
2527
- a(d, u === void 0 ? [] : [u], !0);
2528
- }, j = (e) => {
2529
- C() || e.button !== 0 || !e.shiftKey && !e.ctrlKey || (f.current = new N(e.clientX, e.clientY), _.current = e.ctrlKey ? "remove" : "add", h.current = !1, t.current && (t.current.enabled = !1));
2530
- }, ie = (e) => {
2551
+ a(d, u === void 0 ? [] : [u], !0), f && w(f);
2552
+ }, ne = (e) => {
2553
+ C() || e.button !== 0 || !e.shiftKey && !e.ctrlKey || (f.current = new F(e.clientX, e.clientY), _.current = e.ctrlKey ? "remove" : "add", h.current = !1, t.current && (t.current.enabled = !1));
2554
+ }, re = (e) => {
2531
2555
  if (C()) {
2532
- T();
2556
+ E();
2533
2557
  return;
2534
2558
  }
2535
2559
  if (!f.current) return;
2536
- let t = new N(e.clientX, e.clientY), n = Math.abs(t.x - f.current.x), r = Math.abs(t.y - f.current.y);
2560
+ let t = new F(e.clientX, e.clientY), n = Math.abs(t.x - f.current.x), r = Math.abs(t.y - f.current.y);
2537
2561
  n < 6 && r < 6 || (h.current ||= !0, e.preventDefault(), xr(m, f.current, t));
2538
- }, ae = (r) => {
2562
+ }, ie = (r) => {
2539
2563
  if (C()) {
2540
- T();
2564
+ E();
2541
2565
  return;
2542
2566
  }
2543
2567
  if (!f.current) return;
2544
- O.current = ne();
2545
- let i = h.current, a = new N(r.clientX, r.clientY), o = tr(f.current, a), l = nr(f.current, a);
2568
+ A.current = M();
2569
+ let i = h.current, a = new F(r.clientX, r.clientY), o = er(f.current, a), l = tr(f.current, a);
2546
2570
  if (f.current = null, h.current = !1, Sr(m), t.current && setTimeout(() => {
2547
2571
  t.current && (t.current.enabled = !0);
2548
2572
  }, 100), !i) return;
2549
2573
  g.current = !0, r.preventDefault();
2550
2574
  let { ids: u, profile: d } = yr({
2551
2575
  model: e.current,
2552
- camera: te,
2576
+ camera: ee,
2553
2577
  clippingPlanes: n.getActiveClippingPlanes(),
2554
- domElement: k.domElement,
2578
+ domElement: j.domElement,
2555
2579
  rect: o,
2556
2580
  mode: l
2557
2581
  }), p = Array.from(u.values()).reduce((e, t) => e + t.size, 0), y = {
@@ -2563,7 +2587,7 @@ function Ar(e, t, n) {
2563
2587
  let n = Array.from(e);
2564
2588
  _.current === "remove" ? c(t, n) : s(t, n);
2565
2589
  }));
2566
- }, oe = (e, t) => t ? n.getIntersection(!1, {
2590
+ }, ae = (e, t) => t ? n.getIntersection(!1, {
2567
2591
  event: e,
2568
2592
  filter: kr,
2569
2593
  object: t,
@@ -2572,7 +2596,7 @@ function Ar(e, t, n) {
2572
2596
  o(() => {
2573
2597
  let e = t.current;
2574
2598
  if (!e) return;
2575
- k.domElement.addEventListener("pointerdown", j), k.domElement.addEventListener("pointermove", ie), window.addEventListener("pointerup", ae), window.addEventListener("pointerup", re), k.domElement.addEventListener("contextmenu", o), k.domElement.addEventListener("pointerup", a), k.domElement.addEventListener("pointermove", ee), k.domElement.addEventListener("pointerleave", w), k.domElement.addEventListener("pointerdown", i), e.addEventListener("change", n);
2599
+ j.domElement.addEventListener("pointerdown", ne), j.domElement.addEventListener("pointermove", re), window.addEventListener("pointerup", ie), window.addEventListener("pointerup", N), j.domElement.addEventListener("contextmenu", o), j.domElement.addEventListener("pointerup", a), j.domElement.addEventListener("pointermove", k), j.domElement.addEventListener("pointerleave", T), j.domElement.addEventListener("pointerdown", i), e.addEventListener("update", n);
2576
2600
  function n() {
2577
2601
  typeof r.current == "number" ? r.current += 1 : r.current === "start" && (r.current = 1);
2578
2602
  }
@@ -2588,47 +2612,49 @@ function Ar(e, t, n) {
2588
2612
  e.ctrlKey && e.preventDefault();
2589
2613
  }
2590
2614
  return () => {
2591
- Sr(m), x.current !== null && (window.clearTimeout(x.current), x.current = null), S.current = null, w(), e.removeEventListener("change", n), k.domElement.removeEventListener("pointerdown", j), k.domElement.removeEventListener("pointermove", ie), window.removeEventListener("pointerup", ae), window.removeEventListener("pointerup", re), k.domElement.removeEventListener("contextmenu", o), k.domElement.removeEventListener("pointerup", a), k.domElement.removeEventListener("pointerdown", i), k.domElement.removeEventListener("pointermove", ee), k.domElement.removeEventListener("pointerleave", w);
2615
+ Sr(m), x.current !== null && (window.clearTimeout(x.current), x.current = null), S.current = null, T(), e.removeEventListener("update", n), j.domElement.removeEventListener("pointerdown", ne), j.domElement.removeEventListener("pointermove", re), window.removeEventListener("pointerup", ie), window.removeEventListener("pointerup", N), j.domElement.removeEventListener("contextmenu", o), j.domElement.removeEventListener("pointerup", a), j.domElement.removeEventListener("pointerdown", i), j.domElement.removeEventListener("pointermove", k), j.domElement.removeEventListener("pointerleave", T);
2592
2616
  };
2593
2617
  });
2594
2618
  }
2595
2619
  //#endregion
2596
2620
  //#region src/viewer/Camera/useCameraFit.tsx
2597
- var jr = new P(1, 1, 1).normalize(), Mr = 1.18;
2621
+ var jr = new I(1, 1, 1).normalize(), Mr = 1.18;
2598
2622
  function Nr() {
2599
2623
  let { camera: e } = p();
2600
2624
  return i((t, n, r) => {
2601
- if (!t.current || !(e instanceof le)) return;
2625
+ if (!t.current || !(e instanceof se)) return;
2602
2626
  let i = new g().setFromObject(t.current);
2603
2627
  if (i.isEmpty()) return;
2604
- let a = i.getCenter(new P()), o = i.getBoundingSphere(new pe()), s = re.degToRad(e.fov), c = 2 * Math.atan(Math.tan(s / 2) * e.aspect), l = Math.min(s, c), u = o.radius / Math.sin(l / 2) * Mr;
2605
- e.position.copy(a).addScaledVector(jr, u), e.up.set(0, 1, 0), e.lookAt(a), e.updateProjectionMatrix(), n.current && (n.current.target.copy(a), n.current.update()), r.current && (r.current.position.copy(a).addScaledVector(jr, u * .8), r.current.lookAt(a));
2628
+ let a = i.getCenter(new I()), o = i.getBoundingSphere(new de()), s = te.degToRad(e.fov), c = 2 * Math.atan(Math.tan(s / 2) * e.aspect), l = Math.min(s, c), u = o.radius / Math.sin(l / 2) * Mr;
2629
+ e.position.copy(a).addScaledVector(jr, u), e.up.set(0, 1, 0), e.lookAt(a), e.updateProjectionMatrix();
2630
+ let d = n.current;
2631
+ d && (d.cancel(), d.setFocalOffset(0, 0, 0, !1), d.setLookAt(e.position.x, e.position.y, e.position.z, a.x, a.y, a.z, !1)), r.current && (r.current.position.copy(a).addScaledVector(jr, u * .8), r.current.lookAt(a));
2606
2632
  }, [e]);
2607
2633
  }
2608
2634
  //#endregion
2609
2635
  //#region src/viewer/store/ViewerStoreProvider.tsx
2610
2636
  function Pr({ children: e, store: t }) {
2611
- let [n] = u(() => t ?? je());
2612
- return /* @__PURE__ */ F(De.Provider, {
2637
+ let [n] = u(() => t ?? ke());
2638
+ return /* @__PURE__ */ L(Te.Provider, {
2613
2639
  value: n,
2614
2640
  children: e
2615
2641
  });
2616
2642
  }
2617
2643
  //#endregion
2618
2644
  //#region src/viewer/utils/ExportUtils/ExportUtils.ts
2619
- var K = new TextEncoder(), Fr = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", Ir = "Unknown", Lr = ["elementID", "ifcguid"], Rr = 0, zr = 33;
2620
- function Br(e) {
2645
+ var Fr = new TextEncoder(), Ir = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", Lr = "Unknown", Rr = ["elementID", "ifcguid"], zr = 0, Br = 33;
2646
+ function Vr(e) {
2621
2647
  return !!e && typeof e == "object" && !Array.isArray(e);
2622
2648
  }
2623
- function Vr(e, t) {
2624
- return e == null ? t : typeof e == "boolean" ? e ? "true" : "false" : typeof e == "number" ? Number.isFinite(e) ? String(e) : t : typeof e == "string" ? e.trim() ? e : t : Br(e) && "value" in e ? Vr(e.value, t) : null;
2625
- }
2626
2649
  function Hr(e, t) {
2627
- let n = Vr(e, t);
2650
+ return e == null ? t : typeof e == "boolean" ? e ? "true" : "false" : typeof e == "number" ? Number.isFinite(e) ? String(e) : t : typeof e == "string" ? e.trim() ? e : t : Vr(e) && "value" in e ? Hr(e.value, t) : null;
2651
+ }
2652
+ function Ur(e, t) {
2653
+ let n = Hr(e, t);
2628
2654
  if (n !== null) return n;
2629
2655
  if (Array.isArray(e)) {
2630
2656
  if (!e.length) return t;
2631
- let n = e.map((e) => Vr(e, t));
2657
+ let n = e.map((e) => Hr(e, t));
2632
2658
  if (n.every((e) => e !== null)) {
2633
2659
  let e = n.join(", ");
2634
2660
  return e.trim() ? e : t;
@@ -2644,18 +2670,18 @@ function Hr(e, t) {
2644
2670
  function q(e) {
2645
2671
  return typeof e == "string" && e.trim() ? e : null;
2646
2672
  }
2647
- function Ur(e) {
2648
- let t = Br(e.props) ? e.props : {};
2649
- return q(e.type ?? e.Type ?? t.type ?? t.Type) ?? Ir;
2650
- }
2651
2673
  function Wr(e) {
2652
- let t = Br(e.props) ? e.props : {};
2674
+ let t = Vr(e.props) ? e.props : {};
2675
+ return q(e.type ?? e.Type ?? t.type ?? t.Type) ?? Lr;
2676
+ }
2677
+ function Gr(e) {
2678
+ let t = Vr(e.props) ? e.props : {};
2653
2679
  return q(e.guid ?? e.GlobalId ?? e.globalId ?? t.guid ?? t.GlobalId ?? t.globalId) ?? "";
2654
2680
  }
2655
- function Gr(e, t) {
2681
+ function Kr(e, t) {
2656
2682
  return q(e.Name) ?? q(e.name) ?? q(e.DisplayName) ?? q(e.displayName) ?? `Property ${t + 1}`;
2657
2683
  }
2658
- function Kr(e) {
2684
+ function qr(e) {
2659
2685
  for (let t of [
2660
2686
  "NominalValue",
2661
2687
  "nominalValue",
@@ -2678,18 +2704,18 @@ function Kr(e) {
2678
2704
  "description"
2679
2705
  ].includes(e)));
2680
2706
  }
2681
- function qr(e, t) {
2707
+ function Jr(e, t) {
2682
2708
  return q(e.name) ?? q(e.Name) ?? `Set ${t + 1}`;
2683
2709
  }
2684
- function Jr(e) {
2710
+ function Yr(e) {
2685
2711
  let t = e.props;
2686
- return Array.isArray(t) ? t.map((e, t) => Br(e) ? {
2687
- label: Gr(e, t),
2688
- value: Kr(e)
2712
+ return Array.isArray(t) ? t.map((e, t) => Vr(e) ? {
2713
+ label: Kr(e, t),
2714
+ value: qr(e)
2689
2715
  } : {
2690
2716
  label: `Property ${t + 1}`,
2691
2717
  value: e
2692
- }) : Br(t) ? Object.entries(t).map(([e, t]) => ({
2718
+ }) : Vr(t) ? Object.entries(t).map(([e, t]) => ({
2693
2719
  label: e,
2694
2720
  value: t
2695
2721
  })) : Object.entries(e).filter(([e]) => ![
@@ -2703,14 +2729,14 @@ function Jr(e) {
2703
2729
  value: t
2704
2730
  }));
2705
2731
  }
2706
- function Yr(e, t) {
2732
+ function Xr(e, t) {
2707
2733
  e.columnSet.has(t) || (e.columnSet.add(t), e.columns.push(t));
2708
2734
  }
2709
- function Xr(e, t, n, r, i) {
2735
+ function Zr(e, t, n, r, i) {
2710
2736
  let a = n.trim();
2711
- a && (Yr(e, a), t[a] = Hr(r, i));
2737
+ a && (Xr(e, a), t[a] = Ur(r, i));
2712
2738
  }
2713
- function Zr(e, t, n) {
2739
+ function Qr(e, t, n) {
2714
2740
  let r = {};
2715
2741
  return Object.entries(t).forEach(([t, i]) => {
2716
2742
  [
@@ -2718,33 +2744,33 @@ function Zr(e, t, n) {
2718
2744
  "guid",
2719
2745
  "props",
2720
2746
  "sets"
2721
- ].includes(t) || Xr(e, r, t, i, n);
2722
- }), Br(t.props) && Object.entries(t.props).forEach(([t, i]) => {
2723
- Xr(e, r, t, i, n);
2747
+ ].includes(t) || Zr(e, r, t, i, n);
2748
+ }), Vr(t.props) && Object.entries(t.props).forEach(([t, i]) => {
2749
+ Zr(e, r, t, i, n);
2724
2750
  }), Array.isArray(t.sets) && t.sets.forEach((t, i) => {
2725
- let a = qr(t, i);
2726
- Jr(t).forEach((t) => {
2727
- Xr(e, r, `${a}.${t.label}`, t.value, n);
2751
+ let a = Jr(t, i);
2752
+ Yr(t).forEach((t) => {
2753
+ Zr(e, r, `${a}.${t.label}`, t.value, n);
2728
2754
  });
2729
2755
  }), r;
2730
2756
  }
2731
- function Qr(e, t, n) {
2757
+ function $r(e, t, n) {
2732
2758
  Object.entries(t).forEach(([t, r]) => {
2733
2759
  let i = Number(t);
2734
2760
  if (!Number.isFinite(i)) return;
2735
- let a = Ur(r), o = e.get(a);
2761
+ let a = Wr(r), o = e.get(a);
2736
2762
  o || (o = {
2737
2763
  columns: [],
2738
2764
  columnSet: /* @__PURE__ */ new Set(),
2739
2765
  rows: []
2740
2766
  }, e.set(a, o)), o.rows.push({
2741
2767
  elementID: i,
2742
- ifcguid: Wr(r),
2743
- values: Zr(o, r, n)
2768
+ ifcguid: Gr(r),
2769
+ values: Qr(o, r, n)
2744
2770
  });
2745
2771
  });
2746
2772
  }
2747
- function $r(e) {
2773
+ function ei(e) {
2748
2774
  return e.replace(/[<>&'"]/g, (e) => {
2749
2775
  switch (e) {
2750
2776
  case "<": return "&lt;";
@@ -2756,7 +2782,7 @@ function $r(e) {
2756
2782
  }
2757
2783
  });
2758
2784
  }
2759
- function ei(e) {
2785
+ function ti(e) {
2760
2786
  let t = e, n = "";
2761
2787
  for (; t > 0;) {
2762
2788
  let e = (t - 1) % 26;
@@ -2764,45 +2790,45 @@ function ei(e) {
2764
2790
  }
2765
2791
  return n;
2766
2792
  }
2767
- function ti(e, t, n) {
2768
- return `<c r="${`${ei(n)}${t}`}" t="inlineStr"><is><t${/^\s|\s$/.test(e) ? " xml:space=\"preserve\"" : ""}>${$r(e)}</t></is></c>`;
2793
+ function ni(e, t, n) {
2794
+ return `<c r="${`${ti(n)}${t}`}" t="inlineStr"><is><t${/^\s|\s$/.test(e) ? " xml:space=\"preserve\"" : ""}>${ei(e)}</t></is></c>`;
2769
2795
  }
2770
- function ni(e) {
2771
- return `${Fr}<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${e.map((e, t) => {
2796
+ function ri(e) {
2797
+ return `${Ir}<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${e.map((e, t) => {
2772
2798
  let n = t + 1;
2773
- return `<row r="${n}">${e.map((e, t) => ti(e, n, t + 1)).join("")}</row>`;
2799
+ return `<row r="${n}">${e.map((e, t) => ni(e, n, t + 1)).join("")}</row>`;
2774
2800
  }).join("")}</sheetData></worksheet>`;
2775
2801
  }
2776
- function ri(e) {
2777
- return e.replace(/[\\/?*[\]:]/g, " ").trim() || Ir;
2802
+ function ii(e) {
2803
+ return e.replace(/[\\/?*[\]:]/g, " ").trim() || Lr;
2778
2804
  }
2779
- function ii(e, t) {
2780
- let n = ri(e).slice(0, 31), r = n, i = 2;
2805
+ function ai(e, t) {
2806
+ let n = ii(e).slice(0, 31), r = n, i = 2;
2781
2807
  for (; t.has(r.toLowerCase());) {
2782
2808
  let e = ` (${i})`;
2783
2809
  r = `${n.slice(0, 31 - e.length)}${e}`, i += 1;
2784
2810
  }
2785
2811
  return t.add(r.toLowerCase()), r;
2786
2812
  }
2787
- function ai(e) {
2788
- return `${Fr}<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${e.map((e, t) => {
2813
+ function oi(e) {
2814
+ return `${Ir}<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${e.map((e, t) => {
2789
2815
  let n = t + 1;
2790
- return `<sheet name="${$r(e)}" sheetId="${n}" r:id="rId${n}"/>`;
2816
+ return `<sheet name="${ei(e)}" sheetId="${n}" r:id="rId${n}"/>`;
2791
2817
  }).join("")}</sheets></workbook>`;
2792
2818
  }
2793
- function oi(e) {
2794
- return `${Fr}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${e.map((e, t) => {
2819
+ function si(e) {
2820
+ return `${Ir}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${e.map((e, t) => {
2795
2821
  let n = t + 1;
2796
2822
  return `<Relationship Id="rId${n}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${n}.xml"/>`;
2797
2823
  }).join("")}</Relationships>`;
2798
2824
  }
2799
- function si() {
2800
- return `${Fr}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`;
2825
+ function ci() {
2826
+ return `${Ir}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`;
2801
2827
  }
2802
- function ci(e) {
2803
- return `${Fr}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>${e.map((e, t) => `<Override PartName="/xl/worksheets/sheet${t + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")}</Types>`;
2828
+ function li(e) {
2829
+ return `${Ir}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>${e.map((e, t) => `<Override PartName="/xl/worksheets/sheet${t + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")}</Types>`;
2804
2830
  }
2805
- function li() {
2831
+ function ui() {
2806
2832
  let e = new Uint32Array(256);
2807
2833
  for (let t = 0; t < 256; t++) {
2808
2834
  let n = t;
@@ -2811,118 +2837,118 @@ function li() {
2811
2837
  }
2812
2838
  return e;
2813
2839
  }
2814
- var ui = li();
2815
- function di(e) {
2840
+ var di = ui();
2841
+ function fi(e) {
2816
2842
  let t = 4294967295;
2817
- for (let n of e) t = ui[(t ^ n) & 255] ^ t >>> 8;
2843
+ for (let n of e) t = di[(t ^ n) & 255] ^ t >>> 8;
2818
2844
  return (t ^ 4294967295) >>> 0;
2819
2845
  }
2820
- function fi(e) {
2846
+ function pi(e) {
2821
2847
  let t = new Uint8Array(30 + e.nameBytes.length), n = new DataView(t.buffer);
2822
- return n.setUint32(0, 67324752, !0), n.setUint16(4, 20, !0), n.setUint16(6, 0, !0), n.setUint16(8, 0, !0), n.setUint16(10, Rr, !0), n.setUint16(12, zr, !0), n.setUint32(14, e.crc, !0), n.setUint32(18, e.data.length, !0), n.setUint32(22, e.data.length, !0), n.setUint16(26, e.nameBytes.length, !0), n.setUint16(28, 0, !0), t.set(e.nameBytes, 30), t;
2848
+ return n.setUint32(0, 67324752, !0), n.setUint16(4, 20, !0), n.setUint16(6, 0, !0), n.setUint16(8, 0, !0), n.setUint16(10, zr, !0), n.setUint16(12, Br, !0), n.setUint32(14, e.crc, !0), n.setUint32(18, e.data.length, !0), n.setUint32(22, e.data.length, !0), n.setUint16(26, e.nameBytes.length, !0), n.setUint16(28, 0, !0), t.set(e.nameBytes, 30), t;
2823
2849
  }
2824
- function pi(e) {
2850
+ function mi(e) {
2825
2851
  let t = new Uint8Array(46 + e.nameBytes.length), n = new DataView(t.buffer);
2826
- return n.setUint32(0, 33639248, !0), n.setUint16(4, 20, !0), n.setUint16(6, 20, !0), n.setUint16(8, 0, !0), n.setUint16(10, 0, !0), n.setUint16(12, Rr, !0), n.setUint16(14, zr, !0), n.setUint32(16, e.crc, !0), n.setUint32(20, e.data.length, !0), n.setUint32(24, e.data.length, !0), n.setUint16(28, e.nameBytes.length, !0), n.setUint16(30, 0, !0), n.setUint16(32, 0, !0), n.setUint16(34, 0, !0), n.setUint16(36, 0, !0), n.setUint32(38, 0, !0), n.setUint32(42, e.offset, !0), t.set(e.nameBytes, 46), t;
2852
+ return n.setUint32(0, 33639248, !0), n.setUint16(4, 20, !0), n.setUint16(6, 20, !0), n.setUint16(8, 0, !0), n.setUint16(10, 0, !0), n.setUint16(12, zr, !0), n.setUint16(14, Br, !0), n.setUint32(16, e.crc, !0), n.setUint32(20, e.data.length, !0), n.setUint32(24, e.data.length, !0), n.setUint16(28, e.nameBytes.length, !0), n.setUint16(30, 0, !0), n.setUint16(32, 0, !0), n.setUint16(34, 0, !0), n.setUint16(36, 0, !0), n.setUint32(38, 0, !0), n.setUint32(42, e.offset, !0), t.set(e.nameBytes, 46), t;
2827
2853
  }
2828
- function mi(e, t, n) {
2854
+ function hi(e, t, n) {
2829
2855
  let r = new Uint8Array(22), i = new DataView(r.buffer);
2830
2856
  return i.setUint32(0, 101010256, !0), i.setUint16(4, 0, !0), i.setUint16(6, 0, !0), i.setUint16(8, e, !0), i.setUint16(10, e, !0), i.setUint32(12, t, !0), i.setUint32(16, n, !0), i.setUint16(20, 0, !0), r;
2831
2857
  }
2832
- function hi(e, t) {
2858
+ function gi(e, t) {
2833
2859
  let n = new Uint8Array(t), r = 0;
2834
2860
  return e.forEach((e) => {
2835
2861
  n.set(e, r), r += e.length;
2836
2862
  }), n;
2837
2863
  }
2838
- function gi(e) {
2864
+ function _i(e) {
2839
2865
  let t = 0, n = e.map((e) => {
2840
2866
  let n = {
2841
2867
  ...e,
2842
- crc: di(e.data),
2843
- nameBytes: K.encode(e.path),
2868
+ crc: fi(e.data),
2869
+ nameBytes: Fr.encode(e.path),
2844
2870
  offset: t
2845
2871
  };
2846
2872
  return t += 30 + n.nameBytes.length + n.data.length, n;
2847
2873
  }), r = [];
2848
2874
  n.forEach((e) => {
2849
- r.push(fi(e), e.data);
2875
+ r.push(pi(e), e.data);
2850
2876
  });
2851
2877
  let i = t, a = 0;
2852
2878
  return n.forEach((e) => {
2853
- let t = pi(e);
2879
+ let t = mi(e);
2854
2880
  a += t.length, r.push(t);
2855
- }), r.push(mi(n.length, a, i)), hi(r, r.reduce((e, t) => e + t.length, 0));
2881
+ }), r.push(hi(n.length, a, i)), gi(r, r.reduce((e, t) => e + t.length, 0));
2856
2882
  }
2857
- function _i(e, t) {
2883
+ function vi(e, t) {
2858
2884
  let n = /* @__PURE__ */ new Map();
2859
- e && Qr(n, e.props, t);
2885
+ e && $r(n, e.props, t);
2860
2886
  let r = /* @__PURE__ */ new Set(), i = Array.from(n.entries()).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
2861
- let i = [...Lr, ...n.columns], a = n.rows.sort((e, t) => e.elementID - t.elementID).map((e) => [
2887
+ let i = [...Rr, ...n.columns], a = n.rows.sort((e, t) => e.elementID - t.elementID).map((e) => [
2862
2888
  String(e.elementID),
2863
2889
  e.ifcguid || t,
2864
2890
  ...n.columns.map((n) => e.values[n] ?? t)
2865
2891
  ]);
2866
2892
  return {
2867
- name: ii(e, r),
2893
+ name: ai(e, r),
2868
2894
  rows: [i, ...a]
2869
2895
  };
2870
2896
  });
2871
2897
  return i.length || i.push({
2872
- name: ii(Ir, r),
2873
- rows: [Lr]
2898
+ name: ai(Lr, r),
2899
+ rows: [Rr]
2874
2900
  }), i;
2875
2901
  }
2876
- function vi(e, t = {}) {
2877
- let n = _i(e, t.emptyValue ?? "-"), r = n.map((e) => e.name), i = [
2902
+ function yi(e, t = {}) {
2903
+ let n = vi(e, t.emptyValue ?? "-"), r = n.map((e) => e.name), i = [
2878
2904
  {
2879
2905
  path: "[Content_Types].xml",
2880
- data: K.encode(ci(r))
2906
+ data: Fr.encode(li(r))
2881
2907
  },
2882
2908
  {
2883
2909
  path: "_rels/.rels",
2884
- data: K.encode(si())
2910
+ data: Fr.encode(ci())
2885
2911
  },
2886
2912
  {
2887
2913
  path: "xl/workbook.xml",
2888
- data: K.encode(ai(r))
2914
+ data: Fr.encode(oi(r))
2889
2915
  },
2890
2916
  {
2891
2917
  path: "xl/_rels/workbook.xml.rels",
2892
- data: K.encode(oi(r))
2918
+ data: Fr.encode(si(r))
2893
2919
  },
2894
2920
  ...n.map((e, t) => ({
2895
2921
  path: `xl/worksheets/sheet${t + 1}.xml`,
2896
- data: K.encode(ni(e.rows))
2922
+ data: Fr.encode(ri(e.rows))
2897
2923
  }))
2898
2924
  ];
2899
- return new Blob([gi(i)], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
2925
+ return new Blob([_i(i)], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
2900
2926
  }
2901
- function yi(e) {
2927
+ function bi(e) {
2902
2928
  return e.split(/[?#]/)[0].split(/[\\/]/).pop()?.replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "").trim() || "model";
2903
2929
  }
2904
- function bi(e, t) {
2905
- let n = t.fileName?.trim() || `${yi(t.modelName ?? e?.name ?? "model")}_properties`;
2930
+ function xi(e, t) {
2931
+ let n = t.fileName?.trim() || `${bi(t.modelName ?? e?.name ?? "model")}_properties`;
2906
2932
  return n.toLowerCase().endsWith(".xlsx") ? n : `${n}.xlsx`;
2907
2933
  }
2908
- function xi(e, t = {}) {
2934
+ function Si(e, t = {}) {
2909
2935
  return {
2910
- blob: vi(e, t),
2911
- name: bi(e, t)
2936
+ blob: yi(e, t),
2937
+ name: xi(e, t)
2912
2938
  };
2913
2939
  }
2914
2940
  //#endregion
2915
2941
  //#region src/viewer/api/ViewerPropertiesApi.ts
2916
- function Si(e) {
2917
- return !!e && typeof e == "object" && !Array.isArray(e);
2918
- }
2919
2942
  function Ci(e) {
2920
- return Si(e);
2943
+ return !!e && typeof e == "object" && !Array.isArray(e);
2921
2944
  }
2922
2945
  function wi(e) {
2923
- return Array.isArray(e) ? e.filter(Ci) : Si(e) ? Object.values(e).filter(Ci) : [];
2946
+ return Ci(e);
2924
2947
  }
2925
2948
  function Ti(e) {
2949
+ return Array.isArray(e) ? e.filter(wi) : Ci(e) ? Object.values(e).filter(wi) : [];
2950
+ }
2951
+ function Ei(e) {
2926
2952
  if (typeof e == "number" && Number.isFinite(e)) return e;
2927
2953
  if (typeof e == "string") {
2928
2954
  let t = Number(e);
@@ -2930,10 +2956,10 @@ function Ti(e) {
2930
2956
  }
2931
2957
  return null;
2932
2958
  }
2933
- function Ei(e) {
2934
- return Ti(e.id ?? e.expressID ?? e.expressId ?? e.elementID ?? e.elementId);
2935
- }
2936
2959
  function Di(e) {
2960
+ return Ei(e.id ?? e.expressID ?? e.expressId ?? e.elementID ?? e.elementId);
2961
+ }
2962
+ function Oi(e) {
2937
2963
  let t = [
2938
2964
  e.children,
2939
2965
  e.items,
@@ -2941,40 +2967,40 @@ function Di(e) {
2941
2967
  e.childs
2942
2968
  ];
2943
2969
  for (let e of t) {
2944
- let t = wi(e);
2970
+ let t = Ti(e);
2945
2971
  if (t.length) return t;
2946
2972
  }
2947
2973
  return [];
2948
2974
  }
2949
- function Oi(e) {
2950
- let t = Si(e.props) ? e.props : {}, n = e.type ?? e.Type ?? t.type ?? t.Type;
2975
+ function ki(e) {
2976
+ let t = Ci(e.props) ? e.props : {}, n = e.type ?? e.Type ?? t.type ?? t.Type;
2951
2977
  return typeof n == "string" ? n : "";
2952
2978
  }
2953
- function ki(e) {
2979
+ function Ai(e) {
2954
2980
  return e.replace(/[^a-z0-9]/gi, "").toUpperCase();
2955
2981
  }
2956
- function Ai(e) {
2957
- return ki(Oi(e)) === "IFCBUILDINGSTOREY";
2982
+ function ji(e) {
2983
+ return Ai(ki(e)) === "IFCBUILDINGSTOREY";
2958
2984
  }
2959
- var ji = new Set([
2985
+ var Mi = new Set([
2960
2986
  "children",
2961
2987
  "childs",
2962
2988
  "elements",
2963
2989
  "items"
2964
2990
  ]);
2965
- function Mi(e) {
2991
+ function Ni(e) {
2966
2992
  let t = {};
2967
2993
  return Object.entries(e).forEach(([e, n]) => {
2968
- ji.has(e) || (t[e] = n);
2994
+ Mi.has(e) || (t[e] = n);
2969
2995
  }), t;
2970
2996
  }
2971
- function Ni(e, t) {
2997
+ function Pi(e, t) {
2972
2998
  return Array.isArray(t) ? {
2973
- children: wi(t),
2999
+ children: Ti(t),
2974
3000
  name: `Model ${e}`,
2975
3001
  type: "Model"
2976
- } : Si(t) ? Ei(t) !== null || typeof t.name == "string" || typeof t.Name == "string" || typeof t.type == "string" || typeof t.Type == "string" || Array.isArray(t.children) ? t : {
2977
- children: wi(t),
3002
+ } : Ci(t) ? Di(t) !== null || typeof t.name == "string" || typeof t.Name == "string" || typeof t.type == "string" || typeof t.Type == "string" || Array.isArray(t.children) ? t : {
3003
+ children: Ti(t),
2978
3004
  name: `Model ${e}`,
2979
3005
  type: "Model"
2980
3006
  } : {
@@ -2983,37 +3009,37 @@ function Ni(e, t) {
2983
3009
  type: "Model"
2984
3010
  };
2985
3011
  }
2986
- function Pi(e) {
3012
+ function Fi(e) {
2987
3013
  let t = [];
2988
- return Di(e).forEach((e) => {
2989
- let n = Ei(e);
2990
- n !== null && t.push(n), t.push(...Pi(e));
3014
+ return Oi(e).forEach((e) => {
3015
+ let n = Di(e);
3016
+ n !== null && t.push(n), t.push(...Fi(e));
2991
3017
  }), t;
2992
3018
  }
2993
- function Fi(e, t, n, r) {
2994
- let i = Ei(t), a = i === null ? void 0 : n[e]?.[i], o = {
2995
- ...Mi(t),
3019
+ function Ii(e, t, n, r) {
3020
+ let i = Di(t), a = i === null ? void 0 : n[e]?.[i], o = {
3021
+ ...Ni(t),
2996
3022
  ...a ?? {},
2997
3023
  modelID: e
2998
3024
  };
2999
- return r && (o.elements = Pi(t)), o;
3025
+ return r && (o.elements = Fi(t)), o;
3000
3026
  }
3001
- function Ii(e, t, n, r, i) {
3002
- Ai(t) && n.push(Fi(e, t, r, i)), Di(t).forEach((t) => Ii(e, t, n, r, i));
3027
+ function Li(e, t, n, r, i) {
3028
+ ji(t) && n.push(Ii(e, t, r, i)), Oi(t).forEach((t) => Li(e, t, n, r, i));
3003
3029
  }
3004
- function Li(e, t, n = !1) {
3030
+ function Ri(e, t, n = !1) {
3005
3031
  let r = {};
3006
3032
  return Object.entries(e).forEach(([e, i]) => {
3007
3033
  let a = Number(e), o = [];
3008
- Ii(a, Ni(a, i), o, t, n), r[a] = o;
3034
+ Li(a, Pi(a, i), o, t, n), r[a] = o;
3009
3035
  }), r;
3010
3036
  }
3011
- function Ri(e, t, n, r = !1) {
3037
+ function zi(e, t, n, r = !1) {
3012
3038
  let i = [], a = e[n];
3013
3039
  if (!a) throw Error(`Model with modelID ${n} not found`);
3014
- return Ii(Number(n), Ni(Number(n), a), i, t, r), i;
3040
+ return Li(Number(n), Pi(Number(n), a), i, t, r), i;
3015
3041
  }
3016
- function zi(e, t, n, r) {
3042
+ function Bi(e, t, n, r) {
3017
3043
  let i = t[e];
3018
3044
  return i ? {
3019
3045
  data: {},
@@ -3022,26 +3048,26 @@ function zi(e, t, n, r) {
3022
3048
  structure: n[e] ?? {}
3023
3049
  } : null;
3024
3050
  }
3025
- function Bi(e) {
3051
+ function Vi(e) {
3026
3052
  return {
3027
3053
  exportAllExcel: (t) => {
3028
3054
  let n = e.getState();
3029
3055
  return Object.keys(n.modelProps).flatMap((e) => {
3030
- let r = zi(Number(e), n.modelProps, n.modelStructure, n.modelNames);
3031
- return r ? [xi(r, t)] : [];
3056
+ let r = Bi(Number(e), n.modelProps, n.modelStructure, n.modelNames);
3057
+ return r ? [Si(r, t)] : [];
3032
3058
  });
3033
3059
  },
3034
3060
  exportExcel: (t, n) => {
3035
- let r = e.getState(), i = zi(t, r.modelProps, r.modelStructure, r.modelNames);
3036
- return i ? xi(i, n) : null;
3061
+ let r = e.getState(), i = Bi(t, r.modelProps, r.modelStructure, r.modelNames);
3062
+ return i ? Si(i, n) : null;
3037
3063
  },
3038
3064
  getAllLevels: (t = !1) => {
3039
3065
  let n = e.getState();
3040
- return Li(n.modelStructure, n.modelProps, t);
3066
+ return Ri(n.modelStructure, n.modelProps, t);
3041
3067
  },
3042
3068
  getAllModelLevels: (t, n = !1) => {
3043
3069
  let r = e.getState();
3044
- return Ri(r.modelStructure, r.modelProps, t, n);
3070
+ return zi(r.modelStructure, r.modelProps, t, n);
3045
3071
  },
3046
3072
  getModelProps: () => e.getState().modelProps,
3047
3073
  getModelStructure: () => e.getState().modelStructure
@@ -3049,14 +3075,14 @@ function Bi(e) {
3049
3075
  }
3050
3076
  //#endregion
3051
3077
  //#region src/viewer/Loaders/BmtConverter.ts
3052
- var Vi = "BMT", Hi = 1, J = {
3078
+ var Hi = "BMT", Ui = 1, J = {
3053
3079
  PROP: 1,
3054
3080
  MESH: 2,
3055
3081
  STRUCTURE: 3,
3056
3082
  GRIDS: 4,
3057
3083
  MATRIX: 5,
3058
3084
  MESHSPACE: 6
3059
- }, Ui = "application/json", Wi = "application/octet-stream", Gi = class {
3085
+ }, Wi = "application/json", Gi = "application/octet-stream", Ki = class {
3060
3086
  chunks = [];
3061
3087
  length = 0;
3062
3088
  writeUint8(e) {
@@ -3076,7 +3102,7 @@ var Vi = "BMT", Hi = 1, J = {
3076
3102
  e.set(n, t), t += n.byteLength;
3077
3103
  }), e;
3078
3104
  }
3079
- }, Ki = class {
3105
+ }, qi = class {
3080
3106
  textEncoder = new TextEncoder();
3081
3107
  ifcLoader = null;
3082
3108
  async ConvertIfcFileToBmt(e, t = {}) {
@@ -3143,7 +3169,7 @@ var Vi = "BMT", Hi = 1, J = {
3143
3169
  }
3144
3170
  createModelFiles(e, t, n) {
3145
3171
  let r = n ? `${t}.min.bmt` : `${t}.bmt`, i = this.createBmtBytes(e, !n), a = [{
3146
- blob: new Blob([i], { type: Wi }),
3172
+ blob: new Blob([i], { type: Gi }),
3147
3173
  bytes: i,
3148
3174
  name: r,
3149
3175
  type: "bmt"
@@ -3154,7 +3180,7 @@ var Vi = "BMT", Hi = 1, J = {
3154
3180
  structure: e.structure
3155
3181
  });
3156
3182
  a.push({
3157
- blob: new Blob([n], { type: Ui }),
3183
+ blob: new Blob([n], { type: Wi }),
3158
3184
  bytes: n,
3159
3185
  name: `${t}_props.json`,
3160
3186
  type: "json"
@@ -3163,8 +3189,8 @@ var Vi = "BMT", Hi = 1, J = {
3163
3189
  return a;
3164
3190
  }
3165
3191
  createBmtBytes(e, t) {
3166
- let n = new Gi();
3167
- return n.writeBytes(this.textEncoder.encode(Vi)), n.writeUint8(Hi), t && this.writeProps(n, e.props), e.grids !== void 0 && this.writeJsonChunk(n, J.GRIDS, e.grids), this.writeMeshes(n, e), t && this.writeJsonChunk(n, J.STRUCTURE, e.structure), e.coordinationMatrix && !this.hasMeshMatrices(e) && this.writeTextChunk(n, J.MATRIX, e.coordinationMatrix), n.toUint8Array();
3192
+ let n = new Ki();
3193
+ return n.writeBytes(this.textEncoder.encode(Hi)), n.writeUint8(Ui), t && this.writeProps(n, e.props), e.grids !== void 0 && this.writeJsonChunk(n, J.GRIDS, e.grids), this.writeMeshes(n, e), t && this.writeJsonChunk(n, J.STRUCTURE, e.structure), e.coordinationMatrix && !this.hasMeshMatrices(e) && this.writeTextChunk(n, J.MATRIX, e.coordinationMatrix), n.toUint8Array();
3168
3194
  }
3169
3195
  writeProps(e, t) {
3170
3196
  Object.entries(t).forEach(([t, n]) => {
@@ -3182,7 +3208,7 @@ var Vi = "BMT", Hi = 1, J = {
3182
3208
  });
3183
3209
  }
3184
3210
  createMeshPayload(e) {
3185
- let t = new Gi(), n = this.deflateTypedArray(e.pos), r = this.deflateTypedArray(e.ids), i = this.deflateTypedArray(e.ind);
3211
+ let t = new Ki(), n = this.deflateTypedArray(e.pos), r = this.deflateTypedArray(e.ids), i = this.deflateTypedArray(e.ind);
3186
3212
  return t.writeUint32(n.byteLength), t.writeBytes(n), t.writeUint32(r.byteLength), t.writeBytes(r), t.writeUint32(i.byteLength), t.writeUint32(this.getIndexType(e.ind)), t.writeBytes(i), t.writeUint8(this.colorToByte(e.mat.r)), t.writeUint8(this.colorToByte(e.mat.g)), t.writeUint8(this.colorToByte(e.mat.b)), t.writeUint8(this.colorToByte(e.mat.opacity ?? 1)), t.writeUint32(e.mat.name), t.toUint8Array();
3187
3213
  }
3188
3214
  writeJsonChunk(e, t, n) {
@@ -3335,7 +3361,7 @@ var Vi = "BMT", Hi = 1, J = {
3335
3361
  let t = /* @__PURE__ */ new Map();
3336
3362
  return (Array.isArray(e) ? e : [e]).forEach((e) => {
3337
3363
  e.traverse((e) => {
3338
- if (!(e instanceof M) || !this.isIfcSpaceObject(e)) return;
3364
+ if (!(e instanceof P) || !this.isIfcSpaceObject(e)) return;
3339
3365
  let n = this.getObjectModelID(e);
3340
3366
  if (n === null) return;
3341
3367
  let r = e.geometry.getAttribute("ids");
@@ -3349,7 +3375,7 @@ var Vi = "BMT", Hi = 1, J = {
3349
3375
  addVisibleIdsFromObject3D(e, t) {
3350
3376
  (Array.isArray(e) ? e : [e]).forEach((e) => {
3351
3377
  e.traverse((e) => {
3352
- if (!(e instanceof M) || !this.isObjectVisible(e)) return;
3378
+ if (!(e instanceof P) || !this.isObjectVisible(e)) return;
3353
3379
  let n = this.getObjectModelID(e);
3354
3380
  if (n === null) return;
3355
3381
  let r = e.geometry.getAttribute("ids");
@@ -3401,7 +3427,7 @@ var Vi = "BMT", Hi = 1, J = {
3401
3427
  return this.deflateBytes(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
3402
3428
  }
3403
3429
  deflateBytes(e) {
3404
- return Ee.deflate(e);
3430
+ return we.deflate(e);
3405
3431
  }
3406
3432
  encodeText(e) {
3407
3433
  return this.textEncoder.encode(e);
@@ -3412,43 +3438,43 @@ var Vi = "BMT", Hi = 1, J = {
3412
3438
  isRecord(e) {
3413
3439
  return typeof e == "object" && !!e;
3414
3440
  }
3415
- }, qi = new Ki();
3416
- async function Ji(e, t) {
3417
- return qi.ConvertIfcFileToBmt(e, t);
3441
+ }, Ji = new qi();
3442
+ async function Yi(e, t) {
3443
+ return Ji.ConvertIfcFileToBmt(e, t);
3418
3444
  }
3419
- function Yi(e, t) {
3420
- return qi.ConvertToBmt(e, t);
3445
+ function Xi(e, t) {
3446
+ return Ji.ConvertToBmt(e, t);
3421
3447
  }
3422
3448
  //#endregion
3423
3449
  //#region src/viewer/Selector/FilteredElementsCollector.ts
3424
3450
  function Y(e) {
3425
3451
  return !!e && typeof e == "object" && !Array.isArray(e);
3426
3452
  }
3427
- function Xi(e) {
3453
+ function Zi(e) {
3428
3454
  let t = Number(e);
3429
3455
  return Number.isFinite(t) ? t : null;
3430
3456
  }
3431
- function Zi(e) {
3457
+ function Qi(e) {
3432
3458
  return Y(e) && Y(e.data) && Y(e.props) && "structure" in e;
3433
3459
  }
3434
- function Qi(e) {
3460
+ function $i(e) {
3435
3461
  return Y(e) && ("guid" in e || "id" in e || "props" in e || "sets" in e);
3436
3462
  }
3437
- function $i(e) {
3463
+ function ea(e) {
3438
3464
  if (!Y(e)) return !1;
3439
3465
  let t = Object.entries(e);
3440
- return t.length ? t.every(([e, t]) => Xi(e) !== null && Qi(t)) : !0;
3466
+ return t.length ? t.every(([e, t]) => Zi(e) !== null && $i(t)) : !0;
3441
3467
  }
3442
- function ea(e) {
3468
+ function ta(e) {
3443
3469
  return typeof e == "string" ? e : null;
3444
3470
  }
3445
- function ta(e) {
3471
+ function na(e) {
3446
3472
  let t = Y(e.props.props) ? e.props.props : {};
3447
- return ea(e.props.type ?? e.props.Type ?? t.type ?? t.Type);
3473
+ return ta(e.props.type ?? e.props.Type ?? t.type ?? t.Type);
3448
3474
  }
3449
- function na(e, t, n) {
3475
+ function ra(e, t, n) {
3450
3476
  Object.entries(n).forEach(([n, r]) => {
3451
- let i = Xi(n);
3477
+ let i = Zi(n);
3452
3478
  i !== null && e.push({
3453
3479
  elementID: i,
3454
3480
  modelID: t,
@@ -3456,29 +3482,29 @@ function na(e, t, n) {
3456
3482
  });
3457
3483
  });
3458
3484
  }
3459
- function ra(e) {
3485
+ function ia(e) {
3460
3486
  if (!e || !Y(e)) return [];
3461
- if (Zi(e)) {
3487
+ if (Qi(e)) {
3462
3488
  let t = [];
3463
- return na(t, 0, e.props), t;
3489
+ return ra(t, 0, e.props), t;
3464
3490
  }
3465
- if ($i(e)) {
3491
+ if (ea(e)) {
3466
3492
  let t = [];
3467
- return na(t, 0, e), t;
3493
+ return ra(t, 0, e), t;
3468
3494
  }
3469
3495
  let t = [];
3470
3496
  return Object.entries(e).forEach(([e, n]) => {
3471
- let r = Xi(e);
3497
+ let r = Zi(e);
3472
3498
  if (r !== null) {
3473
- if (Zi(n)) {
3474
- na(t, r, n.props);
3499
+ if (Qi(n)) {
3500
+ ra(t, r, n.props);
3475
3501
  return;
3476
3502
  }
3477
- $i(n) && na(t, r, n);
3503
+ ea(n) && ra(t, r, n);
3478
3504
  }
3479
3505
  }), t;
3480
3506
  }
3481
- function ia(e) {
3507
+ function aa(e) {
3482
3508
  let t = {};
3483
3509
  return e.forEach(({ elementID: e, modelID: n, props: r }) => {
3484
3510
  t[n] ??= [], t[n].push({
@@ -3487,26 +3513,26 @@ function ia(e) {
3487
3513
  });
3488
3514
  }), t;
3489
3515
  }
3490
- function aa(e) {
3516
+ function oa(e) {
3491
3517
  let t = {};
3492
3518
  return e.forEach(({ elementID: e, modelID: n }) => {
3493
3519
  t[n] ??= [], t[n].push(e);
3494
3520
  }), t;
3495
3521
  }
3496
- var oa = class {
3522
+ var sa = class {
3497
3523
  elements;
3498
3524
  filters = [];
3499
3525
  selectedModelIDs = null;
3500
3526
  constructor(e) {
3501
- this.elements = ra(e);
3527
+ this.elements = ia(e);
3502
3528
  }
3503
3529
  from(e) {
3504
- return this.elements = ra(e), this.filters = [], this.selectedModelIDs = null, this;
3530
+ return this.elements = ia(e), this.filters = [], this.selectedModelIDs = null, this;
3505
3531
  }
3506
3532
  ofType(e) {
3507
3533
  let t = new Set((Array.isArray(e) ? e : [e]).map((e) => e.toLowerCase()));
3508
3534
  return this.filters.push((e) => {
3509
- let n = ta(e);
3535
+ let n = na(e);
3510
3536
  return !!(n && t.has(n.toLowerCase()));
3511
3537
  }), this;
3512
3538
  }
@@ -3535,11 +3561,11 @@ var oa = class {
3535
3561
  return this.hasSingleSelectedModel() ? e.map(({ elementID: e, props: t }) => ({
3536
3562
  elementID: e,
3537
3563
  props: t
3538
- })) : ia(e);
3564
+ })) : aa(e);
3539
3565
  }
3540
3566
  toElementsIds() {
3541
3567
  let e = this.getFilteredElements();
3542
- return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) : aa(e);
3568
+ return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) : oa(e);
3543
3569
  }
3544
3570
  toElementIds() {
3545
3571
  return this.toElementsIds();
@@ -3547,20 +3573,20 @@ var oa = class {
3547
3573
  };
3548
3574
  //#endregion
3549
3575
  //#region src/viewer/api/ViewerApi.ts
3550
- function sa(e) {
3576
+ function ca(e) {
3551
3577
  let t = {};
3552
3578
  return Object.entries(e).forEach(([e, n]) => {
3553
3579
  t[Number(e)] = Array.from(n);
3554
3580
  }), t;
3555
3581
  }
3556
- function ca(e) {
3582
+ function la(e) {
3557
3583
  let t = {};
3558
3584
  return Object.entries(e).forEach(([e, n]) => {
3559
3585
  t[Number(e)] = new Set(n);
3560
3586
  }), t;
3561
3587
  }
3562
- function la(e, t) {
3563
- let n = new Ki();
3588
+ function ua(e, t) {
3589
+ let n = new qi();
3564
3590
  return {
3565
3591
  camera: {
3566
3592
  fitCamera: () => {
@@ -3572,7 +3598,7 @@ function la(e, t) {
3572
3598
  })
3573
3599
  },
3574
3600
  clipping: {
3575
- createClippingRectangle: () => t()?.clipping.createClippingRectangle() ?? [],
3601
+ createClippingRectangle: (e = !1) => t()?.clipping.createClippingRectangle(e) ?? [],
3576
3602
  createPlane: (e) => t()?.clipping.createPlane(e) ?? null,
3577
3603
  deleteAllPlanes: () => {
3578
3604
  t()?.clipping.deleteAllPlanes();
@@ -3694,15 +3720,16 @@ function la(e, t) {
3694
3720
  t()?.geometryUtils.toggleIIfcSpacesVisibility();
3695
3721
  }
3696
3722
  },
3697
- properties: Bi(e),
3723
+ properties: Vi(e),
3698
3724
  selector: {
3699
- addSelected: (t, n) => {
3700
- e.getState().addSelected(t, n);
3725
+ addSelected: (n, r, i = !0, a = !1) => {
3726
+ let o = i || a;
3727
+ e.getState().addSelected(n, r), o && t()?.selector.setTargetToSelection(ca(e.getState().selected), a);
3701
3728
  },
3702
- collector: () => new oa(e.getState().modelProps),
3729
+ collector: () => new sa(e.getState().modelProps),
3703
3730
  getPreselectionColor: () => e.getState().preselectionColor,
3704
3731
  getSelectionColor: () => e.getState().selectionColor,
3705
- getSelected: () => sa(e.getState().selected),
3732
+ getSelected: () => ca(e.getState().selected),
3706
3733
  removeSelected: (t, n) => {
3707
3734
  e.getState().removeSelected(t, n);
3708
3735
  },
@@ -3715,8 +3742,9 @@ function la(e, t) {
3715
3742
  setSelectionColor: (t) => {
3716
3743
  e.getState().setSelectionColor(t);
3717
3744
  },
3718
- setSelected: (t, n, r = !1) => {
3719
- e.getState().setSelected(t, n, r);
3745
+ setSelected: (n, r, i = !1, a = !0, o = !1) => {
3746
+ let s = a || o;
3747
+ e.getState().setSelected(n, r, i), s && t()?.selector.setTargetToSelection(ca(e.getState().selected), o);
3720
3748
  }
3721
3749
  },
3722
3750
  utils: {
@@ -3761,7 +3789,7 @@ function la(e, t) {
3761
3789
  }
3762
3790
  //#endregion
3763
3791
  //#region src/viewer/Loaders/BmtLoader.ts
3764
- var ua = class {
3792
+ var da = class {
3765
3793
  view;
3766
3794
  offset = 0;
3767
3795
  constructor(e) {
@@ -3781,11 +3809,11 @@ var ua = class {
3781
3809
  eof() {
3782
3810
  return this.offset >= this.view.byteLength;
3783
3811
  }
3784
- }, da = class {
3812
+ }, fa = class {
3785
3813
  decodeBuffer(e) {
3786
- return this.textDecoder.decode(Ee.inflate(e));
3814
+ return this.textDecoder.decode(we.inflate(e));
3787
3815
  }
3788
- decoder = Ee;
3816
+ decoder = we;
3789
3817
  textDecoder = new TextDecoder("utf-8");
3790
3818
  ChunkType = {
3791
3819
  PROP: 1,
@@ -3854,7 +3882,7 @@ var ua = class {
3854
3882
  return a?.props && (i.props = a.props), a?.grids && (i.grids = a.grids), a?.coordinationMatrix && (i.coordinationMatrix = a.coordinationMatrix), a?.structure !== void 0 && (i.structure = a.structure), i;
3855
3883
  }
3856
3884
  parseBinaryFile(e, t = {}) {
3857
- let n = new ua(e);
3885
+ let n = new da(e);
3858
3886
  if (new TextDecoder().decode(n.readBytes(3)) !== "BMT") throw Error("Invalid file");
3859
3887
  let r = n.readUint8();
3860
3888
  console.log(`model version: ${r}`);
@@ -3922,24 +3950,24 @@ var ua = class {
3922
3950
  };
3923
3951
  //#endregion
3924
3952
  //#region src/viewer/workers/BMTWorker.ts?worker
3925
- function fa(e) {
3953
+ function pa(e) {
3926
3954
  return new Worker("" + new URL("assets/BMTWorker-yhSXOg2i.js", import.meta.url).href, { name: e?.name });
3927
3955
  }
3928
3956
  //#endregion
3929
3957
  //#region src/viewer/workers/BMTWorkerClient.ts
3930
- function pa() {
3958
+ function ma() {
3931
3959
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
3932
3960
  }
3933
- function ma(e) {
3961
+ function ha(e) {
3934
3962
  return Array.isArray(e) ? e : [e];
3935
3963
  }
3936
- function ha(e) {
3964
+ function ga(e) {
3937
3965
  return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.bmt";
3938
3966
  }
3939
- function ga(e) {
3967
+ function _a(e) {
3940
3968
  return typeof e == "string" ? {
3941
3969
  kind: "url",
3942
- name: ha(e),
3970
+ name: ga(e),
3943
3971
  url: new URL(e, globalThis.location.href).href
3944
3972
  } : e instanceof File ? {
3945
3973
  file: e,
@@ -3950,18 +3978,18 @@ function ga(e) {
3950
3978
  kind: "buffer"
3951
3979
  };
3952
3980
  }
3953
- function _a(e) {
3981
+ function va(e) {
3954
3982
  return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
3955
3983
  }
3956
- function va() {
3957
- return new fa();
3984
+ function ya() {
3985
+ return new pa();
3958
3986
  }
3959
- function ya(e) {
3987
+ function ba(e) {
3960
3988
  return { streamGeometryChunks: e.streamGeometryChunks ?? !!e.onChunk };
3961
3989
  }
3962
- function ba(e, t = {}) {
3963
- let n = t.worker ?? va(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = ma(e).map(ga), o = pa(), s = {}, c = {
3964
- options: ya(t),
3990
+ function xa(e, t = {}) {
3991
+ let n = t.worker ?? ya(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = ha(e).map(_a), o = ma(), s = {}, c = {
3992
+ options: ba(t),
3965
3993
  sources: a,
3966
3994
  taskId: o,
3967
3995
  type: "load-bmt-model"
@@ -3999,29 +4027,147 @@ function ba(e, t = {}) {
3999
4027
  let a = Error(r.error.message);
4000
4028
  r.error.stack && (a.stack = r.error.stack), l(a);
4001
4029
  };
4002
- n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, _a(a));
4030
+ n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, va(a));
4003
4031
  });
4004
4032
  }
4005
- function xa() {
4006
- return va();
4033
+ function Sa() {
4034
+ return ya();
4035
+ }
4036
+ //#endregion
4037
+ //#region src/viewer/workers/BmtConverterWorker.ts?worker
4038
+ function Ca(e) {
4039
+ return new Worker("" + new URL("assets/BmtConverterWorker-D4BQ-hoH.js", import.meta.url).href, { name: e?.name });
4040
+ }
4041
+ //#endregion
4042
+ //#region src/viewer/workers/BmtConverterWorkerClient.ts
4043
+ function wa() {
4044
+ return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
4045
+ }
4046
+ function Ta(e) {
4047
+ return Array.isArray(e) ? e : [e];
4048
+ }
4049
+ function Ea(e) {
4050
+ return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
4051
+ }
4052
+ function Da() {
4053
+ return globalThis.document?.baseURI ?? globalThis.location.href;
4054
+ }
4055
+ function Oa(e) {
4056
+ let t = e ?? "ifc-parser.wasm";
4057
+ return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, Da()).href;
4058
+ }
4059
+ function ka(e) {
4060
+ return typeof e == "string" ? {
4061
+ kind: "url",
4062
+ name: Ea(e),
4063
+ url: new URL(e, globalThis.location.href).href
4064
+ } : e instanceof File ? {
4065
+ file: e,
4066
+ kind: "file",
4067
+ name: e.name
4068
+ } : {
4069
+ buffer: e,
4070
+ kind: "buffer"
4071
+ };
4072
+ }
4073
+ function Aa(e) {
4074
+ return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
4075
+ }
4076
+ function ja() {
4077
+ return new Ca();
4078
+ }
4079
+ function Ma(e) {
4080
+ return {
4081
+ chunk: e.chunk,
4082
+ coordinationMatrix: e.coordinationMatrix,
4083
+ fileName: e.fileName,
4084
+ fileNames: e.fileNames,
4085
+ maxMeshBytes: e.maxMeshBytes,
4086
+ useIfcColors: e.useIfcColors,
4087
+ useIfcElementAssembly: e.useIfcElementAssembly,
4088
+ useIfcSpace: e.useIfcSpace,
4089
+ useMinVersion: e.useMinVersion,
4090
+ visibleIdsByModel: e.visibleIdsByModel,
4091
+ wasmPath: Oa(e.wasmPath)
4092
+ };
4093
+ }
4094
+ function Na(e) {
4095
+ let t = new Uint8Array(e.bytes.byteLength);
4096
+ return t.set(e.bytes), {
4097
+ ...e,
4098
+ blob: new Blob([t.buffer], { type: e.mimeType })
4099
+ };
4100
+ }
4101
+ function Pa(e) {
4102
+ return {
4103
+ files: e.result.files.map(Na),
4104
+ models: e.result.models
4105
+ };
4106
+ }
4107
+ function Fa(e) {
4108
+ if (e.error instanceof Error) return e.error;
4109
+ let t = [
4110
+ e.message || "Unknown worker error",
4111
+ e.filename ? `file: ${e.filename}` : "",
4112
+ e.lineno ? `line: ${e.lineno}` : "",
4113
+ e.colno ? `column: ${e.colno}` : ""
4114
+ ].filter(Boolean);
4115
+ return /* @__PURE__ */ Error(`BMT converter worker failed: ${t.join(", ")}`);
4116
+ }
4117
+ function Ia(e) {
4118
+ return /* @__PURE__ */ Error(`BMT converter worker response could not be cloned: ${String(e.data ?? "unknown message error")}`);
4119
+ }
4120
+ function La(e, t = {}) {
4121
+ let n = t.worker ?? ja(), r = t.terminateOnComplete ?? !t.worker, i = Ta(e).map(ka), a = wa(), o = {
4122
+ options: Ma(t),
4123
+ sources: i,
4124
+ taskId: a,
4125
+ type: "convert-ifc-to-bmt"
4126
+ };
4127
+ return new Promise((e, s) => {
4128
+ let c = () => {
4129
+ n.removeEventListener("message", d), n.removeEventListener("error", l), n.removeEventListener("messageerror", u), r && n.terminate();
4130
+ }, l = (e) => {
4131
+ c(), s(Fa(e));
4132
+ }, u = (e) => {
4133
+ c(), s(Ia(e));
4134
+ }, d = (n) => {
4135
+ let r = n.data;
4136
+ if (r.taskId !== a) return;
4137
+ if (r.type === "progress") {
4138
+ t.onProgress?.(r.progress);
4139
+ return;
4140
+ }
4141
+ if (c(), r.type === "complete") {
4142
+ e(Pa(r));
4143
+ return;
4144
+ }
4145
+ let i = Error(r.error.message);
4146
+ r.error.stack && (i.stack = r.error.stack), s(i);
4147
+ };
4148
+ n.addEventListener("message", d), n.addEventListener("error", l), n.addEventListener("messageerror", u), n.postMessage(o, Aa(i));
4149
+ });
4150
+ }
4151
+ function Ra() {
4152
+ return ja();
4007
4153
  }
4008
4154
  //#endregion
4009
4155
  //#region src/viewer/workers/IFCWorker.ts?worker
4010
- function Sa(e) {
4156
+ function za(e) {
4011
4157
  return new Worker("" + new URL("assets/IFCWorker-Dgk5iwps.js", import.meta.url).href, { name: e?.name });
4012
4158
  }
4013
4159
  //#endregion
4014
4160
  //#region src/viewer/workers/IFCWorkerClient.ts
4015
- function Ca() {
4161
+ function Ba() {
4016
4162
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
4017
4163
  }
4018
- function wa(e) {
4164
+ function Va(e) {
4019
4165
  return Array.isArray(e) ? e : [e];
4020
4166
  }
4021
- function Ta(e) {
4167
+ function Ha(e) {
4022
4168
  return typeof e == "string" ? {
4023
4169
  kind: "url",
4024
- name: Ea(e),
4170
+ name: Ua(e),
4025
4171
  url: new URL(e, globalThis.location.href).href
4026
4172
  } : e instanceof File ? {
4027
4173
  file: e,
@@ -4032,23 +4178,23 @@ function Ta(e) {
4032
4178
  kind: "buffer"
4033
4179
  };
4034
4180
  }
4035
- function Ea(e) {
4181
+ function Ua(e) {
4036
4182
  return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
4037
4183
  }
4038
- function Da() {
4184
+ function Wa() {
4039
4185
  return globalThis.document?.baseURI ?? globalThis.location.href;
4040
4186
  }
4041
- function Oa(e) {
4187
+ function Ga(e) {
4042
4188
  let t = e ?? "ifc-parser.wasm";
4043
- return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, Da()).href;
4189
+ return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, Wa()).href;
4044
4190
  }
4045
- function ka(e) {
4191
+ function Ka(e) {
4046
4192
  return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
4047
4193
  }
4048
- function Aa() {
4049
- return new Sa();
4194
+ function qa() {
4195
+ return new za();
4050
4196
  }
4051
- function ja(e) {
4197
+ function Ja(e) {
4052
4198
  return {
4053
4199
  chunk: e.chunk,
4054
4200
  coordinationMatrix: e.coordinationMatrix,
@@ -4057,12 +4203,12 @@ function ja(e) {
4057
4203
  useIfcColors: e.useIfcColors,
4058
4204
  useIfcElementAssembly: e.useIfcElementAssembly,
4059
4205
  useIfcSpace: e.useIfcSpace,
4060
- wasmPath: Oa(e.wasmPath)
4206
+ wasmPath: Ga(e.wasmPath)
4061
4207
  };
4062
4208
  }
4063
- function Ma(e, t = {}) {
4064
- let n = t.worker ?? Aa(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = wa(e).map(Ta), o = Ca(), s = {}, c = {
4065
- options: ja(t),
4209
+ function Ya(e, t = {}) {
4210
+ let n = t.worker ?? qa(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = Va(e).map(Ha), o = Ba(), s = {}, c = {
4211
+ options: Ja(t),
4066
4212
  sources: a,
4067
4213
  taskId: o,
4068
4214
  type: "load-ifc-model"
@@ -4100,34 +4246,34 @@ function Ma(e, t = {}) {
4100
4246
  let a = Error(r.error.message);
4101
4247
  r.error.stack && (a.stack = r.error.stack), l(a);
4102
4248
  };
4103
- n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, ka(a));
4249
+ n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, Ka(a));
4104
4250
  });
4105
4251
  }
4106
- function Na() {
4107
- return Aa();
4252
+ function Xa() {
4253
+ return qa();
4108
4254
  }
4109
4255
  //#endregion
4110
4256
  //#region src/viewer/api/loader.ts
4111
- function Pa(e) {
4257
+ function Za(e) {
4112
4258
  return typeof e == "string" ? e : e.name;
4113
4259
  }
4114
- function Fa(e) {
4115
- return (Pa(e).split(/[?#]/)[0].split(/[\\/]/).pop() || "model").replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "") || "model";
4260
+ function Qa(e) {
4261
+ return (Za(e).split(/[?#]/)[0].split(/[\\/]/).pop() || "model").replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "") || "model";
4116
4262
  }
4117
- function Ia(e) {
4118
- let t = Pa(e).split(/[?#]/)[0].toLowerCase(), n = t.lastIndexOf(".");
4263
+ function $a(e) {
4264
+ let t = Za(e).split(/[?#]/)[0].toLowerCase(), n = t.lastIndexOf(".");
4119
4265
  return n === -1 ? "" : t.slice(n + 1);
4120
4266
  }
4121
- function La(e) {
4267
+ function eo(e) {
4122
4268
  return /\.min\.bmt$/i.test(e.name) ? e.name.replace(/\.min\.bmt$/i, "_props.json") : null;
4123
4269
  }
4124
- function Ra(e) {
4125
- return /_props\.json$/i.test(Pa(e).split(/[?#]/)[0]);
4270
+ function to(e) {
4271
+ return /_props\.json$/i.test(Za(e).split(/[?#]/)[0]);
4126
4272
  }
4127
- function za(e) {
4273
+ function no(e) {
4128
4274
  return e.coordinationMatrix ? e.coordinationMatrix : Object.values(e.data)[0]?.matrix || void 0;
4129
4275
  }
4130
- var Ba = new class {
4276
+ var ro = new class {
4131
4277
  coordinationMatrix;
4132
4278
  useIfcSpace = !1;
4133
4279
  bmtLoader = null;
@@ -4138,7 +4284,7 @@ var Ba = new class {
4138
4284
  this.getBmtLoader();
4139
4285
  }
4140
4286
  getBmtLoader() {
4141
- return this.bmtLoader ||= new da(), this.bmtLoader;
4287
+ return this.bmtLoader ||= new fa(), this.bmtLoader;
4142
4288
  }
4143
4289
  async getIfcLoader(e = {}) {
4144
4290
  if (!this.ifcLoader) {
@@ -4166,7 +4312,7 @@ var Ba = new class {
4166
4312
  async loadBmtModel(e, t) {
4167
4313
  let n = this.getBmtLoader();
4168
4314
  if (typeof e == "string") return n.loadModel(e);
4169
- let r = n.parseBinaryFile(await e.arrayBuffer()), i = La(e), a = i ? t.get(i) : void 0;
4315
+ let r = n.parseBinaryFile(await e.arrayBuffer()), i = eo(e), a = i ? t.get(i) : void 0;
4170
4316
  return this.applyBmtMetadata(r, a);
4171
4317
  }
4172
4318
  createWorkerProgressHandler(e, t, n, r) {
@@ -4189,7 +4335,7 @@ var Ba = new class {
4189
4335
  };
4190
4336
  }
4191
4337
  async loadIfcModelInWorker(e, t, n, r, i) {
4192
- return (await Ma(e, {
4338
+ return (await Ya(e, {
4193
4339
  chunk: t.chunk,
4194
4340
  collectChunks: t.collectWorkerChunks,
4195
4341
  coordinationMatrix: this.coordinationMatrix,
@@ -4202,14 +4348,14 @@ var Ba = new class {
4202
4348
  }))[0];
4203
4349
  }
4204
4350
  async loadBmtModelInWorker(e, t, n, r, i, a) {
4205
- let o = (await ba(e, {
4351
+ let o = (await xa(e, {
4206
4352
  collectChunks: n.collectWorkerChunks,
4207
4353
  onChunk: this.createWorkerChunkHandler(n, r),
4208
4354
  onProgress: this.createWorkerProgressHandler(n, r, i, a),
4209
4355
  streamGeometryChunks: n.streamGeometryChunks ?? !!n.onChunk
4210
4356
  }))[0];
4211
4357
  if (e instanceof File) {
4212
- let n = La(e), r = n ? t.get(n) : void 0;
4358
+ let n = eo(e), r = n ? t.get(n) : void 0;
4213
4359
  return this.applyBmtMetadata(o, r);
4214
4360
  }
4215
4361
  return o;
@@ -4222,21 +4368,21 @@ var Ba = new class {
4222
4368
  }
4223
4369
  async loadModel(e, t = {}) {
4224
4370
  this.initLoaders();
4225
- let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !Ra(e)).length, o = 0;
4371
+ let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !to(e)).length, o = 0;
4226
4372
  this.loadedModelCount === 0 && this.resetCoordinationMatrixState();
4227
4373
  for (let e = 0; e < n.length; e++) {
4228
- let s = n[e], c = Ia(s), l;
4229
- if (c === "json" && Ra(s)) continue;
4374
+ let s = n[e], c = $a(s), l;
4375
+ if (c === "json" && to(s)) continue;
4230
4376
  let u = this.nextModelID, d = o;
4231
4377
  if (o++, c === "ifc") l = t.useWorker ? await this.loadIfcModelInWorker(s, t, u, d, a) : (await (await this.getIfcLoader(t)).loadModel(s, this.coordinationMatrix))[0];
4232
4378
  else if (c === "bmt") l = t.useWorker ? await this.loadBmtModelInWorker(s, r, t, u, d, a) : await this.loadBmtModel(s, r);
4233
- else throw Error(`Unsupported model format: ${Pa(s)}`);
4234
- let f = za(l);
4235
- !this.coordinationMatrix && f && (this.coordinationMatrix = f), !l.coordinationMatrix && this.coordinationMatrix && (l.coordinationMatrix = this.coordinationMatrix), l.name ??= Fa(s), this.nextModelID += 1, this.loadedModelCount += 1, i[u] = l;
4379
+ else throw Error(`Unsupported model format: ${Za(s)}`);
4380
+ let f = no(l);
4381
+ !this.coordinationMatrix && f && (this.coordinationMatrix = f), !l.coordinationMatrix && this.coordinationMatrix && (l.coordinationMatrix = this.coordinationMatrix), l.name ??= Qa(s), this.nextModelID += 1, this.loadedModelCount += 1, i[u] = l;
4236
4382
  }
4237
4383
  return i;
4238
4384
  }
4239
- }(), Va = .5, X = .04, Z = .16, Ha = Z, Q = Va * 2 - Z * 2, Ua = Va - X / 2, Wa = Va - Z / 2, Ga = Va - Ha / 2, Ka = .63, qa = "#dfe6ec", Ja = 260, Ya = 52, Xa = .17, Za = new g(), $ = new pe(), Qa = [
4385
+ }(), io = .5, X = .04, Z = .16, ao = Z, Q = io * 2 - Z * 2, oo = io - X / 2, so = io - Z / 2, co = io - ao / 2, lo = .63, uo = "#dfe6ec", fo = 260, po = 52, mo = .17, ho = new g(), $ = new de(), go = [
4240
4386
  {
4241
4387
  direction: [
4242
4388
  0,
@@ -4247,7 +4393,7 @@ var Ba = new class {
4247
4393
  position: [
4248
4394
  0,
4249
4395
  0,
4250
- Ua
4396
+ oo
4251
4397
  ],
4252
4398
  scale: [
4253
4399
  Q,
@@ -4267,7 +4413,7 @@ var Ba = new class {
4267
4413
  position: [
4268
4414
  0,
4269
4415
  0,
4270
- -Ua
4416
+ -oo
4271
4417
  ],
4272
4418
  rotation: [
4273
4419
  0,
@@ -4290,7 +4436,7 @@ var Ba = new class {
4290
4436
  ],
4291
4437
  label: "right",
4292
4438
  position: [
4293
- Ua,
4439
+ oo,
4294
4440
  0,
4295
4441
  0
4296
4442
  ],
@@ -4315,7 +4461,7 @@ var Ba = new class {
4315
4461
  ],
4316
4462
  label: "left",
4317
4463
  position: [
4318
- -Ua,
4464
+ -oo,
4319
4465
  0,
4320
4466
  0
4321
4467
  ],
@@ -4341,7 +4487,7 @@ var Ba = new class {
4341
4487
  label: "top",
4342
4488
  position: [
4343
4489
  0,
4344
- Ua,
4490
+ oo,
4345
4491
  0
4346
4492
  ],
4347
4493
  rotation: [
@@ -4366,7 +4512,7 @@ var Ba = new class {
4366
4512
  label: "bot",
4367
4513
  position: [
4368
4514
  0,
4369
- -Ua,
4515
+ -oo,
4370
4516
  0
4371
4517
  ],
4372
4518
  rotation: [
@@ -4383,7 +4529,7 @@ var Ba = new class {
4383
4529
  type: "face"
4384
4530
  }
4385
4531
  ];
4386
- function $a() {
4532
+ function _o() {
4387
4533
  let e = [], t = [-1, 1];
4388
4534
  return t.forEach((n) => {
4389
4535
  t.forEach((t) => {
@@ -4395,8 +4541,8 @@ function $a() {
4395
4541
  ],
4396
4542
  position: [
4397
4543
  0,
4398
- n * Wa,
4399
- t * Wa
4544
+ n * so,
4545
+ t * so
4400
4546
  ],
4401
4547
  scale: [
4402
4548
  Q,
@@ -4416,9 +4562,9 @@ function $a() {
4416
4562
  t
4417
4563
  ],
4418
4564
  position: [
4419
- n * Wa,
4565
+ n * so,
4420
4566
  0,
4421
- t * Wa
4567
+ t * so
4422
4568
  ],
4423
4569
  scale: [
4424
4570
  Z,
@@ -4438,8 +4584,8 @@ function $a() {
4438
4584
  0
4439
4585
  ],
4440
4586
  position: [
4441
- n * Wa,
4442
- t * Wa,
4587
+ n * so,
4588
+ t * so,
4443
4589
  0
4444
4590
  ],
4445
4591
  scale: [
@@ -4453,7 +4599,7 @@ function $a() {
4453
4599
  });
4454
4600
  }), e;
4455
4601
  }
4456
- function eo() {
4602
+ function vo() {
4457
4603
  let e = [], t = [-1, 1];
4458
4604
  return t.forEach((n) => {
4459
4605
  t.forEach((r) => {
@@ -4465,14 +4611,14 @@ function eo() {
4465
4611
  t
4466
4612
  ],
4467
4613
  position: [
4468
- n * Ga,
4469
- r * Ga,
4470
- t * Ga
4614
+ n * co,
4615
+ r * co,
4616
+ t * co
4471
4617
  ],
4472
4618
  scale: [
4473
- Ha,
4474
- Ha,
4475
- Ha
4619
+ ao,
4620
+ ao,
4621
+ ao
4476
4622
  ],
4477
4623
  title: `${r > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
4478
4624
  type: "corner"
@@ -4481,34 +4627,34 @@ function eo() {
4481
4627
  });
4482
4628
  }), e;
4483
4629
  }
4484
- function to(e) {
4630
+ function yo(e) {
4485
4631
  e.stopPropagation(), e.nativeEvent.stopPropagation(), e.nativeEvent.stopImmediatePropagation?.();
4486
4632
  }
4487
- function no(e) {
4488
- return e ? "#4f7fa3" : qa;
4633
+ function bo(e) {
4634
+ return e ? "#4f7fa3" : uo;
4489
4635
  }
4490
- function ro(e) {
4636
+ function xo(e) {
4491
4637
  return e ? 1 : .96;
4492
4638
  }
4493
- function io(e, t) {
4639
+ function So(e, t) {
4494
4640
  let n = document.createElement("canvas"), r = n.getContext("2d");
4495
4641
  if (!r) throw Error("Could not create navigation cube label context");
4496
- let i = `600 ${Ya}px system-ui, "Segoe UI", sans-serif`;
4642
+ let i = `600 ${po}px system-ui, "Segoe UI", sans-serif`;
4497
4643
  r.font = i;
4498
- let a = r.measureText(e), o = a.actualBoundingBoxAscent || Ya * .8, s = a.actualBoundingBoxDescent || Ya * .2, c = Math.ceil(a.width + 36), l = Math.ceil(o + s + 20);
4644
+ let a = r.measureText(e), o = a.actualBoundingBoxAscent || po * .8, s = a.actualBoundingBoxDescent || po * .2, c = Math.ceil(a.width + 36), l = Math.ceil(o + s + 20);
4499
4645
  n.width = c, n.height = l, r.clearRect(0, 0, c, l), r.font = i, r.fillStyle = t, r.textAlign = "center", r.textBaseline = "alphabetic", r.fillText(e, c / 2, 10 + o);
4500
4646
  let u = new b(n);
4501
- return u.colorSpace = fe, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
4647
+ return u.colorSpace = ue, u.generateMipmaps = !1, u.magFilter = M, u.minFilter = M, u.needsUpdate = !0, {
4502
4648
  aspect: c / l,
4503
4649
  texture: u
4504
4650
  };
4505
4651
  }
4506
- function ao({ color: e, label: t, position: n, rotation: r }) {
4507
- let { aspect: i, texture: a } = c(() => io(t, e), [e, t]);
4508
- return o(() => () => a.dispose(), [a]), /* @__PURE__ */ I("mesh", {
4652
+ function Co({ color: e, label: t, position: n, rotation: r }) {
4653
+ let { aspect: i, texture: a } = c(() => So(t, e), [e, t]);
4654
+ return o(() => () => a.dispose(), [a]), /* @__PURE__ */ R("mesh", {
4509
4655
  position: n,
4510
4656
  rotation: r,
4511
- children: [/* @__PURE__ */ F("planeGeometry", { args: [Xa * i, Xa] }), /* @__PURE__ */ F("meshBasicMaterial", {
4657
+ children: [/* @__PURE__ */ L("planeGeometry", { args: [mo * i, mo] }), /* @__PURE__ */ L("meshBasicMaterial", {
4512
4658
  alphaTest: .1,
4513
4659
  depthWrite: !1,
4514
4660
  map: a,
@@ -4517,54 +4663,54 @@ function ao({ color: e, label: t, position: n, rotation: r }) {
4517
4663
  })]
4518
4664
  });
4519
4665
  }
4520
- function oo(e) {
4521
- return Math.abs(e.y) > .9 ? new P(0, 0, e.y > 0 ? -1 : 1) : new P(0, 1, 0);
4666
+ function wo(e) {
4667
+ return Math.abs(e.y) > .9 ? new I(0, 0, e.y > 0 ? -1 : 1) : new I(0, 1, 0);
4522
4668
  }
4523
- function so(e, t) {
4669
+ function To(e, t) {
4524
4670
  let n = e.current;
4525
- return !n || (n.updateWorldMatrix(!0, !0), Za.setFromObject(n), Za.isEmpty()) ? ($.center.copy(t), $.radius = 10, $) : (Za.getBoundingSphere($), (!Number.isFinite($.radius) || $.radius <= 0) && ($.radius = 10), $);
4671
+ return !n || (n.updateWorldMatrix(!0, !0), ho.setFromObject(n), ho.isEmpty()) ? ($.center.copy(t), $.radius = 10, $) : (ho.getBoundingSphere($), (!Number.isFinite($.radius) || $.radius <= 0) && ($.radius = 10), $);
4526
4672
  }
4527
- function co(e) {
4528
- return e.current?.target.clone() ?? new P();
4673
+ function Eo(e) {
4674
+ return e.current?.getTarget(new I()) ?? new I();
4529
4675
  }
4530
- function lo({ camera: e, controlRef: t, direction: n, modelRef: r, transitionRef: i }) {
4531
- let a = co(t), o = so(r, a), s = o.center.clone(), c = new P(...n).normalize(), l = e.position.distanceTo(a), u = Number.isFinite(l) && l > o.radius * .5 ? l : o.radius * 2.4;
4532
- i.current = {
4533
- endPosition: s.clone().addScaledVector(c, u),
4676
+ function Do({ camera: e, controlRef: t, direction: n, modelRef: r, transitionRef: i }) {
4677
+ let a = Eo(t), o = To(r, a), s = o.center.clone(), c = new I(...n).normalize(), l = e.position.distanceTo(a), u = Number.isFinite(l) && l > o.radius * .5 ? l : o.radius * 2.4, d = s.clone().addScaledVector(c, u);
4678
+ t.current?.cancel(), t.current?.setFocalOffset(0, 0, 0, !1), i.current = {
4679
+ endPosition: d,
4534
4680
  endTarget: s,
4535
- endUp: oo(c),
4681
+ endUp: wo(c),
4536
4682
  startPosition: e.position.clone(),
4537
4683
  startTarget: a,
4538
4684
  startTime: performance.now(),
4539
4685
  startUp: e.up.clone()
4540
4686
  };
4541
4687
  }
4542
- function uo({ action: e, onPick: t }) {
4688
+ function Oo({ action: e, onPick: t }) {
4543
4689
  let [n, r] = u(!1);
4544
- return /* @__PURE__ */ I("group", {
4690
+ return /* @__PURE__ */ R("group", {
4545
4691
  position: e.position,
4546
- onClick: to,
4692
+ onClick: yo,
4547
4693
  onPointerDown: (n) => {
4548
- to(n), t(e);
4694
+ yo(n), t(e);
4549
4695
  },
4550
4696
  onPointerEnter: (e) => {
4551
- to(e), r(!0);
4697
+ yo(e), r(!0);
4552
4698
  },
4553
4699
  onPointerLeave: (e) => {
4554
- to(e), r(!1);
4700
+ yo(e), r(!1);
4555
4701
  },
4556
- children: [/* @__PURE__ */ I("mesh", {
4702
+ children: [/* @__PURE__ */ R("mesh", {
4557
4703
  scale: e.scale,
4558
- children: [/* @__PURE__ */ F("boxGeometry", { args: [
4704
+ children: [/* @__PURE__ */ L("boxGeometry", { args: [
4559
4705
  1,
4560
4706
  1,
4561
4707
  1
4562
- ] }), /* @__PURE__ */ F("meshBasicMaterial", {
4563
- color: no(n),
4564
- opacity: ro(n),
4708
+ ] }), /* @__PURE__ */ L("meshBasicMaterial", {
4709
+ color: bo(n),
4710
+ opacity: xo(n),
4565
4711
  transparent: !0
4566
4712
  })]
4567
- }), e.label && /* @__PURE__ */ F(ao, {
4713
+ }), e.label && /* @__PURE__ */ L(Co, {
4568
4714
  color: n ? "#ffffff" : "#50606f",
4569
4715
  label: e.label,
4570
4716
  position: [
@@ -4576,11 +4722,11 @@ function uo({ action: e, onPick: t }) {
4576
4722
  })]
4577
4723
  });
4578
4724
  }
4579
- function fo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4725
+ function ko({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4580
4726
  let i = l(null), a = l(null), o = c(() => [
4581
- ...Qa,
4582
- ...$a(),
4583
- ...eo()
4727
+ ...go,
4728
+ ..._o(),
4729
+ ...vo()
4584
4730
  ], []);
4585
4731
  return f(() => {
4586
4732
  if (!e) return;
@@ -4589,16 +4735,20 @@ function fo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4589
4735
  i.current && i.current.quaternion.copy(r.quaternion).invert();
4590
4736
  let o = a.current;
4591
4737
  if (!o) return;
4592
- let s = performance.now() - o.startTime, c = Math.min(s / Ja, 1), l = 1 - (1 - c) ** 3, u = n.current;
4593
- r.position.lerpVectors(o.startPosition, o.endPosition, l), r.up.lerpVectors(o.startUp, o.endUp, l), u ? (u.target.lerpVectors(o.startTarget, o.endTarget, l), u.update()) : r.lookAt(o.endTarget), c >= 1 && (r.up.copy(o.endUp), u?.target.copy(o.endTarget), u?.update(), a.current = null);
4594
- }), e ? /* @__PURE__ */ F("group", {
4738
+ let s = performance.now() - o.startTime, c = Math.min(s / fo, 1), l = 1 - (1 - c) ** 3, u = n.current;
4739
+ if (r.position.lerpVectors(o.startPosition, o.endPosition, l), r.up.lerpVectors(o.startUp, o.endUp, l), u) {
4740
+ let e = new I().lerpVectors(o.startTarget, o.endTarget, l);
4741
+ u.setLookAt(r.position.x, r.position.y, r.position.z, e.x, e.y, e.z, !1);
4742
+ } else r.lookAt(o.endTarget);
4743
+ c >= 1 && (r.up.copy(o.endUp), u?.setLookAt(o.endPosition.x, o.endPosition.y, o.endPosition.z, o.endTarget.x, o.endTarget.y, o.endTarget.z, !1), a.current = null);
4744
+ }), e ? /* @__PURE__ */ L("group", {
4595
4745
  ref: i,
4596
- scale: Ka,
4597
- children: o.map((e) => /* @__PURE__ */ F(uo, {
4746
+ scale: lo,
4747
+ children: o.map((e) => /* @__PURE__ */ L(Oo, {
4598
4748
  action: e,
4599
4749
  onPick: (e) => {
4600
4750
  let i = t.current;
4601
- i && lo({
4751
+ i && Do({
4602
4752
  camera: i,
4603
4753
  controlRef: n,
4604
4754
  direction: e.direction,
@@ -4611,13 +4761,13 @@ function fo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4611
4761
  }
4612
4762
  //#endregion
4613
4763
  //#region src/viewer/Viewer.tsx
4614
- var po = class {
4764
+ var Ao = class {
4615
4765
  sceneApi = null;
4616
4766
  get = () => this.sceneApi;
4617
4767
  set = (e) => {
4618
4768
  this.sceneApi = e;
4619
4769
  };
4620
- }, mo = {
4770
+ }, jo = {
4621
4771
  bottom: 16,
4622
4772
  height: 96,
4623
4773
  pointerEvents: "auto",
@@ -4626,11 +4776,11 @@ var po = class {
4626
4776
  touchAction: "none",
4627
4777
  width: 96,
4628
4778
  zIndex: 2
4629
- }, ho = {
4779
+ }, Mo = {
4630
4780
  height: "100%",
4631
4781
  position: "relative",
4632
4782
  width: "100%"
4633
- }, go = {
4783
+ }, No = {
4634
4784
  far: 50,
4635
4785
  near: .1,
4636
4786
  position: [
@@ -4639,135 +4789,194 @@ var po = class {
4639
4789
  10
4640
4790
  ],
4641
4791
  zoom: 72
4642
- }, _o = {
4792
+ }, Po = {
4643
4793
  alpha: !0,
4644
4794
  antialias: !0
4645
- };
4646
- function vo() {
4795
+ }, Fo = .1, Io = .02, Lo = .08, Ro = new g(), zo = new de(), Bo = new I();
4796
+ function Vo() {
4647
4797
  let e = navigator, t = navigator.userAgent.toLowerCase(), n = navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, r = window.matchMedia?.("(pointer: coarse)").matches ?? !1;
4648
4798
  return e.userAgentData?.mobile || n || /android|iphone|ipad|ipod|mobile|tablet/.test(t) || navigator.maxTouchPoints > 1 && r ? "mobile" : "pc";
4649
4799
  }
4650
- function yo({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, modelRef: i, modelsData: a, onReady: s, publicApi: u, setSceneApi: d }) {
4651
- let f = p((e) => e.camera), g = Mt(i), _ = Ut(g), { colorPaletteTexture: v, colorUtils: y } = Ge(g), b = zn(i), x = _n(i, n, b), S = Mn(i, n, b), C = c(() => new Ki(), []), w = _.buildIndex, T = g.resetIndex, E = y.applyStoredColors, D = Nr(), ee = l(!1), O = L((e) => e.showStats), te = c(() => {
4652
- let e = Object.keys(a).sort((e, t) => Number(e) - Number(t));
4800
+ function Ho(e) {
4801
+ if (!e || (Ro.setFromObject(e), Ro.isEmpty())) return Fo;
4802
+ let t = Ro.getBoundingSphere(zo).radius;
4803
+ return !Number.isFinite(t) || t <= 0 ? Fo : Math.max(t * Io, Fo);
4804
+ }
4805
+ function Uo(e, t, n, r, i) {
4806
+ let a = n.elementIndex.get(i);
4807
+ a && a.forEach((n) => {
4808
+ let { record: i, vertexRanges: a } = n;
4809
+ if (i.modelID !== r) return;
4810
+ let o = i.mesh.geometry.attributes.position;
4811
+ o && (i.mesh.updateWorldMatrix(!0, !1), a.forEach((n) => {
4812
+ let r = n.start + n.count;
4813
+ for (let a = n.start; a < r; a++) t.set(o.getX(a), o.getY(a), o.getZ(a)).applyMatrix4(i.mesh.matrixWorld), Number.isFinite(t.x + t.y + t.z) && e.expandByPoint(t);
4814
+ }));
4815
+ });
4816
+ }
4817
+ function Wo(e, t) {
4818
+ let n = new g(), r = new I();
4819
+ return Object.entries(e).forEach(([e, i]) => {
4820
+ let a = Number(e);
4821
+ i.forEach((e) => {
4822
+ Uo(n, r, t, a, e);
4823
+ });
4824
+ }), n.isEmpty() ? null : n;
4825
+ }
4826
+ function Go(e) {
4827
+ let t = e.getSize(Bo), n = Math.max(t.x, t.y, t.z);
4828
+ return Number.isFinite(n) && n > 0 ? n * Lo : Fo;
4829
+ }
4830
+ function Ko({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, modelRef: a, modelsData: s, onReady: u, publicApi: d, setSceneApi: f }) {
4831
+ let g = p((e) => e.camera), _ = At(a), v = Vt(_), { colorPaletteTexture: y, colorUtils: b } = Ue(_), x = Rn(a), S = gn(a, n, x), C = jn(a, n, x), w = c(() => new qi(), []), T = v.buildIndex, E = _.resetIndex, D = b.applyStoredColors, O = Nr(), k = l(!1), A = z((e) => e.showStats), ee = c(() => {
4832
+ let e = Object.keys(s).sort((e, t) => Number(e) - Number(t));
4653
4833
  for (let t of e) {
4654
- let e = St(a[Number(t)]);
4834
+ let e = bt(s[Number(t)]);
4655
4835
  if (e) return e;
4656
4836
  }
4657
4837
  return null;
4658
- }, [a]), k = c(() => bt(te ?? void 0), [te]), ne = c(() => Object.entries(a).map(([e, t]) => [Number(e), t]), [a]), A = c(() => {
4838
+ }, [s]), j = c(() => vt(ee ?? void 0), [ee]), M = c(() => Object.entries(s).map(([e, t]) => [Number(e), t]), [s]), te = i(() => {
4839
+ n.current && (n.current.minDistance = Ho(a.current));
4840
+ }, [n, a]), N = i((e, t = !1) => {
4841
+ let r = n.current;
4842
+ if (!r) return;
4843
+ let i = Wo(e, _.buildIndex());
4844
+ if (!i) return;
4845
+ let a = i.getCenter(new I());
4846
+ if (r.cancel(), t) {
4847
+ let e = Go(i);
4848
+ r.fitToBox(i, !0, {
4849
+ paddingBottom: e,
4850
+ paddingLeft: e,
4851
+ paddingRight: e,
4852
+ paddingTop: e
4853
+ });
4854
+ return;
4855
+ }
4856
+ r.setOrbitPoint(a.x, a.y, a.z);
4857
+ }, [n, _]), P = c(() => {
4659
4858
  let e = (e) => ({
4660
4859
  ...e,
4661
- activeViewRoot: i.current
4860
+ activeViewRoot: a.current
4662
4861
  });
4663
4862
  return {
4664
- convertIfcFileToBmt: (e, t) => C.ConvertIfcFileToBmt(e, t),
4665
- convertToBmt: (t) => C.ConvertToBmt(a, e(t))
4863
+ convertIfcFileToBmt: (e, t) => w.ConvertIfcFileToBmt(e, t),
4864
+ convertToBmt: (t) => w.ConvertToBmt(s, e(t))
4666
4865
  };
4667
4866
  }, [
4668
- C,
4669
- i,
4670
- a
4867
+ w,
4868
+ a,
4869
+ s
4671
4870
  ]);
4672
- return Ar(i, n, b), Pn(), o(() => (b.setClippingSource(x), () => {
4673
- b.setClippingSource(null);
4674
- }), [b, x]), o(() => (t.current = f, () => {
4675
- t.current === f && (t.current = null);
4676
- }), [f, t]), o(() => {
4677
- if (!i.current) return;
4871
+ return Ar(a, n, x), Nn(), o(() => (x.setClippingSource(S), () => {
4872
+ x.setClippingSource(null);
4873
+ }), [x, S]), o(() => (t.current = g, () => {
4874
+ t.current === g && (t.current = null);
4875
+ }), [g, t]), o(() => {
4876
+ if (!a.current) return;
4678
4877
  let t = requestAnimationFrame(() => {
4679
- i.current?.updateMatrixWorld(!0), T(), w(), E(), x.syncWithModel(), S.syncWithModel(), e && D(i, n, r);
4878
+ a.current?.updateMatrixWorld(!0), te(), E(), T(), D(), S.syncWithModel(), C.syncWithModel(), e && O(a, n, r);
4680
4879
  });
4681
4880
  return () => cancelAnimationFrame(t);
4682
4881
  }, [
4683
- E,
4882
+ D,
4684
4883
  e,
4685
- w,
4686
- x,
4687
- n,
4884
+ T,
4688
4885
  S,
4689
- D,
4886
+ n,
4887
+ C,
4888
+ O,
4690
4889
  r,
4691
- i,
4692
4890
  a,
4693
- T
4694
- ]), o(() => (d({
4695
- camera: {
4696
- fitCamera: () => D(i, n, r),
4697
- getIntersection: b.getIntersection
4698
- },
4699
- clipping: {
4700
- createClippingRectangle: x.createClippingRectangle,
4701
- createPlane: x.createPlane,
4702
- deleteAllPlanes: x.deleteAllPlanes,
4703
- getActive: x.getActive,
4704
- getEdgesActive: x.getEdgesActive,
4705
- getHelpersActive: x.getHelpersActive,
4706
- getPlanes: x.getPlanes,
4707
- setActive: x.setActive,
4708
- setEdgesActive: x.setEdgesActive,
4709
- setHelpersActive: x.setHelpersActive,
4710
- toggle: x.toggle,
4711
- updateEdges: x.updateEdges,
4712
- updateMaterials: x.updateMaterials
4713
- },
4714
- colors: {
4715
- clearAllColors: y.clearAllColors,
4716
- clearColor: y.clearColor,
4717
- clearModelColors: y.clearModelColors,
4718
- setColor: y.setColor
4719
- },
4720
- converter: A,
4721
- dimensions: {
4722
- cancelDrawing: S.cancelDrawing,
4723
- changeAxes: S.changeAxes,
4724
- delete: S.delete,
4725
- deleteAll: S.deleteAll,
4726
- getActive: S.getActive,
4727
- getDimensions: S.getDimensions,
4728
- getSnapDistance: S.getSnapDistance,
4729
- getUnit: S.getUnit,
4730
- setActive: S.setActive,
4731
- setColor: S.setColor,
4732
- setEndpointScaleFactor: S.setEndpointScaleFactor,
4733
- setSnapDistance: S.setSnapDistance,
4734
- setUnit: S.setUnit,
4735
- setWidth: S.setWidth,
4736
- toggle: S.toggle
4737
- },
4738
- geometryUtils: {
4739
- getAllIds: _.getAllIds,
4740
- getIfcSpacesVisibility: _.getIfcSpacesVisibility,
4741
- hideByIds: _.hideByIds,
4742
- hideSelected: _.hideSelected,
4743
- isolateByIds: _.isolateByIds,
4744
- isolateSelected: _.isolateSelected,
4745
- resetIsolation: _.resetIsolation,
4746
- setIfcSpacesVisibility: _.setIfcSpacesVisibility,
4747
- showAll: _.showAll,
4748
- showByIds: _.showByIds,
4749
- toggleIIfcSpacesVisibility: _.toggleIIfcSpacesVisibility
4750
- }
4751
- }), ee.current || (ee.current = !0, s?.(u)), () => d(null)), [
4891
+ s,
4892
+ E,
4893
+ te
4894
+ ]), o(() => {
4895
+ let e = () => {
4896
+ !S.getActive() || !S.getEdgesActive() || S.updateEdges();
4897
+ }, t = (t) => {
4898
+ t(), e();
4899
+ };
4900
+ return f({
4901
+ camera: {
4902
+ fitCamera: () => O(a, n, r),
4903
+ getIntersection: x.getIntersection
4904
+ },
4905
+ clipping: {
4906
+ createClippingRectangle: S.createClippingRectangle,
4907
+ createPlane: S.createPlane,
4908
+ deleteAllPlanes: S.deleteAllPlanes,
4909
+ getActive: S.getActive,
4910
+ getEdgesActive: S.getEdgesActive,
4911
+ getHelpersActive: S.getHelpersActive,
4912
+ getPlanes: S.getPlanes,
4913
+ setActive: S.setActive,
4914
+ setEdgesActive: S.setEdgesActive,
4915
+ setHelpersActive: S.setHelpersActive,
4916
+ toggle: S.toggle,
4917
+ updateEdges: S.updateEdges,
4918
+ updateMaterials: S.updateMaterials
4919
+ },
4920
+ colors: {
4921
+ clearAllColors: b.clearAllColors,
4922
+ clearColor: b.clearColor,
4923
+ clearModelColors: b.clearModelColors,
4924
+ setColor: b.setColor
4925
+ },
4926
+ converter: P,
4927
+ dimensions: {
4928
+ cancelDrawing: C.cancelDrawing,
4929
+ changeAxes: C.changeAxes,
4930
+ delete: C.delete,
4931
+ deleteAll: C.deleteAll,
4932
+ getActive: C.getActive,
4933
+ getDimensions: C.getDimensions,
4934
+ getSnapDistance: C.getSnapDistance,
4935
+ getUnit: C.getUnit,
4936
+ setActive: C.setActive,
4937
+ setColor: C.setColor,
4938
+ setEndpointScaleFactor: C.setEndpointScaleFactor,
4939
+ setSnapDistance: C.setSnapDistance,
4940
+ setUnit: C.setUnit,
4941
+ setWidth: C.setWidth,
4942
+ toggle: C.toggle
4943
+ },
4944
+ geometryUtils: {
4945
+ getAllIds: v.getAllIds,
4946
+ getIfcSpacesVisibility: v.getIfcSpacesVisibility,
4947
+ hideByIds: (e) => t(() => v.hideByIds(e)),
4948
+ hideSelected: () => t(v.hideSelected),
4949
+ isolateByIds: (e) => t(() => v.isolateByIds(e)),
4950
+ isolateSelected: () => t(v.isolateSelected),
4951
+ resetIsolation: () => t(v.resetIsolation),
4952
+ setIfcSpacesVisibility: (e) => t(() => v.setIfcSpacesVisibility(e)),
4953
+ showAll: () => t(v.showAll),
4954
+ showByIds: (e) => t(() => v.showByIds(e)),
4955
+ toggleIIfcSpacesVisibility: () => t(v.toggleIIfcSpacesVisibility)
4956
+ },
4957
+ selector: { setTargetToSelection: N }
4958
+ }), k.current || (k.current = !0, u?.(d)), () => f(null);
4959
+ }, [
4960
+ S,
4752
4961
  x,
4753
4962
  b,
4754
- y,
4755
4963
  n,
4756
- A,
4757
- S,
4758
- D,
4759
- _,
4964
+ P,
4965
+ C,
4966
+ O,
4967
+ v,
4760
4968
  r,
4761
- i,
4762
- s,
4969
+ a,
4763
4970
  u,
4764
- d
4765
- ]), /* @__PURE__ */ I(Te, { children: [
4766
- /* @__PURE__ */ F("ambientLight", {
4971
+ d,
4972
+ f,
4973
+ N
4974
+ ]), /* @__PURE__ */ R(Ce, { children: [
4975
+ /* @__PURE__ */ L("ambientLight", {
4767
4976
  intensity: 1.2,
4768
4977
  color: "#ffffff"
4769
4978
  }),
4770
- /* @__PURE__ */ F("directionalLight", {
4979
+ /* @__PURE__ */ L("directionalLight", {
4771
4980
  ref: r,
4772
4981
  position: [
4773
4982
  10,
@@ -4777,24 +4986,27 @@ function yo({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, modelR
4777
4986
  color: "#ffffff",
4778
4987
  intensity: 2
4779
4988
  }),
4780
- O && /* @__PURE__ */ F(h, {}),
4781
- /* @__PURE__ */ F("group", {
4782
- ref: i,
4783
- children: ne.map(([e, t]) => /* @__PURE__ */ F(wt, {
4784
- colorPaletteTexture: v,
4785
- coordinationMatrix: k,
4989
+ A && /* @__PURE__ */ L(h, {}),
4990
+ /* @__PURE__ */ L("group", {
4991
+ ref: a,
4992
+ children: M.map(([e, t]) => /* @__PURE__ */ L(St, {
4993
+ colorPaletteTexture: y,
4994
+ coordinationMatrix: j,
4786
4995
  data: t,
4787
4996
  modelID: e
4788
4997
  }, e))
4789
4998
  }),
4790
- /* @__PURE__ */ F(m, {
4791
- dampingFactor: .15,
4792
- enableDamping: !0,
4793
- ref: n
4999
+ /* @__PURE__ */ L(m, {
5000
+ dollyToCursor: !0,
5001
+ draggingSmoothTime: .04,
5002
+ infinityDolly: !0,
5003
+ minDistance: Fo,
5004
+ ref: n,
5005
+ smoothTime: .12
4794
5006
  })
4795
5007
  ] });
4796
5008
  }
4797
- function bo({ autoFitCamera: e = !0, camera: t = {
5009
+ function qo({ autoFitCamera: e = !0, camera: t = {
4798
5010
  position: [
4799
5011
  10,
4800
5012
  10,
@@ -4802,21 +5014,21 @@ function bo({ autoFitCamera: e = !0, camera: t = {
4802
5014
  ],
4803
5015
  fov: 50
4804
5016
  }, dpr: n = window.devicePixelRatio, modelUrls: r, modelSources: i, modelsData: a, onReady: s, publicApi: c, setSceneApi: f, showNavCube: p, showStats: m }) {
4805
- let h = l(null), g = l(null), _ = l(null), v = l(null), [y, b] = u(), x = R(), S = L((e) => e.setModelNames), C = L((e) => e.setModelProps), w = L((e) => e.setModelStructure), T = L((e) => e.setShowNavCube), E = L((e) => e.setShowStats), D = L((e) => e.setUserDevice), ee = L((e) => e.showNavCube), O = a ?? y;
5017
+ let h = l(null), g = l(null), _ = l(null), v = l(null), [y, b] = u(), x = B(), S = z((e) => e.setModelNames), C = z((e) => e.setModelProps), w = z((e) => e.setModelStructure), T = z((e) => e.setShowNavCube), E = z((e) => e.setShowStats), D = z((e) => e.setUserDevice), O = z((e) => e.showNavCube), k = a ?? y;
4806
5018
  return o(() => {
4807
- D(vo());
5019
+ D(Vo());
4808
5020
  }, [D]), o(() => {
4809
5021
  E(!!m);
4810
5022
  }, [E, m]), o(() => {
4811
5023
  p !== void 0 && T(p);
4812
5024
  }, [T, p]), o(() => {
4813
5025
  let e = {}, t = {}, n = {};
4814
- O && Object.entries(O).forEach(([r, i]) => {
5026
+ k && Object.entries(k).forEach(([r, i]) => {
4815
5027
  let a = Number(r);
4816
5028
  i.name !== void 0 && (e[a] = i.name), i.props !== void 0 && (t[a] = i.props), i.structure !== void 0 && (n[a] = i.structure);
4817
5029
  }), S(e), C(t), w(n);
4818
5030
  }, [
4819
- O,
5031
+ k,
4820
5032
  S,
4821
5033
  C,
4822
5034
  w
@@ -4825,7 +5037,7 @@ function bo({ autoFitCamera: e = !0, camera: t = {
4825
5037
  let e = i ?? r;
4826
5038
  if (!e?.length) return;
4827
5039
  let t = !0;
4828
- return Ba.loadModel(e).then((e) => {
5040
+ return ro.loadModel(e).then((e) => {
4829
5041
  t && b(e);
4830
5042
  }), () => {
4831
5043
  t = !1;
@@ -4834,33 +5046,33 @@ function bo({ autoFitCamera: e = !0, camera: t = {
4834
5046
  a,
4835
5047
  i,
4836
5048
  r
4837
- ]), O ? /* @__PURE__ */ I("div", {
4838
- style: ho,
4839
- children: [/* @__PURE__ */ F(d, {
5049
+ ]), k ? /* @__PURE__ */ R("div", {
5050
+ style: Mo,
5051
+ children: [/* @__PURE__ */ L(d, {
4840
5052
  camera: t,
4841
5053
  dpr: n,
4842
- children: /* @__PURE__ */ F(Pr, {
5054
+ children: /* @__PURE__ */ L(Pr, {
4843
5055
  store: x,
4844
- children: /* @__PURE__ */ F(yo, {
5056
+ children: /* @__PURE__ */ L(Ko, {
4845
5057
  autoFitCamera: e,
4846
5058
  cameraRef: h,
4847
5059
  controlRef: g,
4848
5060
  lightRef: v,
4849
5061
  modelRef: _,
4850
- modelsData: O,
5062
+ modelsData: k,
4851
5063
  onReady: s,
4852
5064
  publicApi: c,
4853
5065
  setSceneApi: f
4854
5066
  })
4855
5067
  })
4856
- }), ee && /* @__PURE__ */ F("div", {
4857
- style: mo,
4858
- children: /* @__PURE__ */ F(d, {
4859
- camera: go,
5068
+ }), O && /* @__PURE__ */ L("div", {
5069
+ style: jo,
5070
+ children: /* @__PURE__ */ L(d, {
5071
+ camera: No,
4860
5072
  dpr: n,
4861
- gl: _o,
5073
+ gl: Po,
4862
5074
  orthographic: !0,
4863
- children: /* @__PURE__ */ F(fo, {
5075
+ children: /* @__PURE__ */ L(ko, {
4864
5076
  active: !0,
4865
5077
  cameraRef: h,
4866
5078
  controlRef: g,
@@ -4868,35 +5080,35 @@ function bo({ autoFitCamera: e = !0, camera: t = {
4868
5080
  })
4869
5081
  })
4870
5082
  })]
4871
- }) : /* @__PURE__ */ F(Te, {});
5083
+ }) : /* @__PURE__ */ L(Ce, {});
4872
5084
  }
4873
- var xo = n(function(e, t) {
4874
- let [n] = u(je), r = l(!1), a = l(!1), d = c(() => new po(), []), { defaultSelected: f, onSelectedChange: p, selected: m } = e, h = i((e) => {
5085
+ var Jo = n(function(e, t) {
5086
+ let [n] = u(ke), r = l(!1), a = l(!1), d = c(() => new Ao(), []), { defaultSelected: f, onSelectedChange: p, selected: m } = e, h = i((e) => {
4875
5087
  d.set(e);
4876
- }, [d]), g = c(() => la(n, d.get), [d, n]);
5088
+ }, [d]), g = c(() => ua(n, d.get), [d, n]);
4877
5089
  return s(t, () => g, [g]), o(() => (n.getState().setApi(g), () => {
4878
5090
  n.getState().api === g && n.getState().setApi(null);
4879
5091
  }), [g, n]), o(() => {
4880
- r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(ca(f)));
5092
+ r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(la(f)));
4881
5093
  }, [
4882
5094
  m,
4883
5095
  f,
4884
5096
  n
4885
5097
  ]), o(() => {
4886
- m !== void 0 && (a.current = !0, n.getState().setSelection(ca(m)), a.current = !1);
5098
+ m !== void 0 && (a.current = !0, n.getState().setSelection(la(m)), a.current = !1);
4887
5099
  }, [m, n]), o(() => {
4888
5100
  if (p) return n.subscribe((e, t) => {
4889
- e.selected !== t.selected && (a.current || p(sa(e.selected)));
5101
+ e.selected !== t.selected && (a.current || p(ca(e.selected)));
4890
5102
  });
4891
- }, [p, n]), /* @__PURE__ */ F(Pr, {
5103
+ }, [p, n]), /* @__PURE__ */ L(Pr, {
4892
5104
  store: n,
4893
- children: /* @__PURE__ */ F(bo, {
5105
+ children: /* @__PURE__ */ L(qo, {
4894
5106
  ...e,
4895
5107
  publicApi: g,
4896
5108
  setSceneApi: h
4897
5109
  })
4898
5110
  });
4899
5111
  });
4900
- xo.displayName = "Viewer";
5112
+ Jo.displayName = "Viewer";
4901
5113
  //#endregion
4902
- export { da as BMTLoader, Ki as BmtConverter, Ji as ConvertIfcFileToBmt, Yi as ConvertToBmt, wn as DimensionLine, jn as DimensionsUtils, oa as FilteredElementsCollector, vt as ModelGrids, fo as NavigationCube, xo as Viewer, Pr as ViewerStoreProvider, qi as bmtConverter, xa as createBmtWorker, Na as createIfcWorker, je as createViewerStore, xi as exportExcel, vi as exportModelPropertiesToExcel, ba as loadBmtModelsInWorker, Ma as loadIfcModelsInWorker, Ba as loader, Mn as useDimensionsUtils, L as useViewerStore, R as useViewerStoreApi };
5114
+ export { fa as BMTLoader, qi as BmtConverter, Yi as ConvertIfcFileToBmt, Xi as ConvertToBmt, Cn as DimensionLine, An as DimensionsUtils, sa as FilteredElementsCollector, gt as ModelGrids, ko as NavigationCube, Jo as Viewer, Pr as ViewerStoreProvider, Ji as bmtConverter, La as convertIfcFilesToBmtInWorker, Ra as createBmtConverterWorker, Sa as createBmtWorker, Xa as createIfcWorker, ke as createViewerStore, Si as exportExcel, yi as exportModelPropertiesToExcel, xa as loadBmtModelsInWorker, Ya as loadIfcModelsInWorker, ro as loader, jn as useDimensionsUtils, z as useViewerStore, B as useViewerStoreApi };