bimatter-viewer-react 0.6.2 → 0.6.4

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,17 +1,17 @@
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
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 ee, Line3 as te, LineBasicMaterial as ne, LineDashedMaterial as O, LineSegments as k, LinearFilter as A, MathUtils as re, Matrix4 as j, Mesh as M, MeshBasicMaterial as N, MeshLambertMaterial as P, 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";
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 ee, LineBasicMaterial as te, LineDashedMaterial as k, LineSegments as ne, LinearFilter as A, MathUtils as j, Matrix4 as M, Mesh as N, MeshBasicMaterial as P, MeshLambertMaterial as F, NearestFilter as re, Object3D as I, OrthographicCamera as ie, PerspectiveCamera as ae, Plane as L, RGBAFormat as oe, RepeatWrapping as se, SRGBColorSpace as ce, ShapeUtils as le, Sphere as ue, SphereGeometry as de, Sprite as fe, SpriteMaterial as pe, Uint32BufferAttribute as me, UnsignedByteType as he, Vector2 as R, Vector3 as z } from "three";
5
5
  import { useStore as ge } from "zustand";
6
6
  import { createStore as _e } from "zustand/vanilla";
7
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";
8
+ import { Fragment as Ce, jsx as B, jsxs as V } from "react/jsx-runtime";
9
9
  import we from "pako";
10
10
  //#region src/viewer/store/ViewerStoreContext.ts
11
11
  var Te = t(null);
12
12
  //#endregion
13
13
  //#region src/viewer/store/useViewerStore.ts
14
- function z(e) {
14
+ function H(e) {
15
15
  return ge(Ee(), e);
16
16
  }
17
17
  function Ee() {
@@ -121,8 +121,8 @@ function Ae() {
121
121
  }
122
122
  var je = 2;
123
123
  function Me() {
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, Pe(e, 1, new x(De)), e;
124
+ let e = new C(new Uint8Array(256 * 4), 256, 1, oe, he);
125
+ return e.magFilter = re, e.minFilter = re, e.generateMipmaps = !1, e.needsUpdate = !0, Pe(e, 1, new x(De)), e;
126
126
  }
127
127
  function Ne(e) {
128
128
  return `${e.r.toFixed(6)}:${e.g.toFixed(6)}:${e.b.toFixed(6)}`;
@@ -190,7 +190,7 @@ function We(e, t) {
190
190
  }), n;
191
191
  }
192
192
  function Ge(e) {
193
- let t = z((e) => e.selected), n = z((e) => e.selectionColor), r = c(() => Me(), []), a = l(/* @__PURE__ */ new Map()), s = l(je), u = l(/* @__PURE__ */ new Map()), d = l(t), f = l(/* @__PURE__ */ new Set()), p = l(/* @__PURE__ */ new WeakMap());
193
+ let t = H((e) => e.selected), n = H((e) => e.selectionColor), r = c(() => Me(), []), a = l(/* @__PURE__ */ new Map()), s = l(je), u = l(/* @__PURE__ */ new Map()), d = l(t), f = l(/* @__PURE__ */ new Set()), p = l(/* @__PURE__ */ new WeakMap());
194
194
  o(() => {
195
195
  d.current = t;
196
196
  }, [t]), o(() => () => r.dispose(), [r]), o(() => {
@@ -280,9 +280,9 @@ function Ge(e) {
280
280
  }
281
281
  //#endregion
282
282
  //#region src/viewer/SelectableMesh.tsx
283
- M.prototype.raycast = Se;
283
+ N.prototype.raycast = Se;
284
284
  var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n = "quality", data: r, isIfcSpace: i = !1, meshMatrix: a, useDoubleSideMaterial: s = !1 }) {
285
- let u = l(null), d = z((e) => e.preselectionColor), f = l(d);
285
+ let u = l(null), d = H((e) => e.preselectionColor), f = l(d);
286
286
  f.current = d;
287
287
  let p = c(() => {
288
288
  let r = {
@@ -292,7 +292,7 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
292
292
  }, i = s ? {
293
293
  ...r,
294
294
  side: w
295
- } : r, a = n === "performance" ? new N(i) : new P(i), o = a;
295
+ } : r, a = n === "performance" ? new P(i) : new F(i), o = a;
296
296
  return o.defaultAttributeValues = {
297
297
  ...o.defaultAttributeValues,
298
298
  colorIndex: [0]
@@ -308,7 +308,7 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
308
308
  elementColorPalette,
309
309
  vec2((vColorIndex + 0.5) / ${256 .toFixed(1)}, 0.5)
310
310
  );
311
- diffuseColor = vec4(elementColor.rgb, opacity);
311
+ diffuseColor = vec4(elementColor.rgb, 1.0);
312
312
  }
313
313
  else{
314
314
  diffuseColor = vec4(baseColor, opacity);
@@ -330,7 +330,7 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
330
330
  return Object.assign(e, { boundsTree: t }), () => {
331
331
  p.dispose(), Object.assign(e, { boundsTree: null });
332
332
  };
333
- }, [p]), /* @__PURE__ */ R("mesh", {
333
+ }, [p]), /* @__PURE__ */ V("mesh", {
334
334
  matrix: a,
335
335
  matrixAutoUpdate: !1,
336
336
  name: i ? "space" : void 0,
@@ -340,24 +340,24 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
340
340
  let t = e.object;
341
341
  t.preselected &&= !1;
342
342
  },
343
- children: [/* @__PURE__ */ R("bufferGeometry", { children: [
344
- /* @__PURE__ */ L("bufferAttribute", {
343
+ children: [/* @__PURE__ */ V("bufferGeometry", { children: [
344
+ /* @__PURE__ */ B("bufferAttribute", {
345
345
  attach: "attributes-position",
346
346
  args: [r.pos, 3]
347
347
  }),
348
- r.norm && /* @__PURE__ */ L("bufferAttribute", {
348
+ r.norm && /* @__PURE__ */ B("bufferAttribute", {
349
349
  attach: "attributes-normal",
350
350
  args: [r.norm, 3]
351
351
  }),
352
- /* @__PURE__ */ L("bufferAttribute", {
352
+ /* @__PURE__ */ B("bufferAttribute", {
353
353
  attach: "attributes-ids",
354
354
  args: [r.ids, 1]
355
355
  }),
356
- /* @__PURE__ */ L("bufferAttribute", {
356
+ /* @__PURE__ */ B("bufferAttribute", {
357
357
  attach: "index",
358
358
  args: [r.ind, 1]
359
359
  })
360
- ] }), /* @__PURE__ */ L("primitive", { object: p })]
360
+ ] }), /* @__PURE__ */ B("primitive", { object: p })]
361
361
  });
362
362
  }), qe = 10, Je = "#1d2733", Ye = 2, Xe = .05, Ze = "\0", Qe = /* @__PURE__ */ new Map();
363
363
  function $e() {
@@ -371,7 +371,7 @@ function et(e, t, n, r) {
371
371
  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));
372
372
  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);
373
373
  let h = new b(a);
374
- return h.colorSpace = ue, h.generateMipmaps = !1, h.magFilter = A, h.minFilter = A, h.needsUpdate = !0, {
374
+ return h.colorSpace = ce, h.generateMipmaps = !1, h.magFilter = A, h.minFilter = A, h.needsUpdate = !0, {
375
375
  disposeTimer: null,
376
376
  height: m,
377
377
  key: e,
@@ -408,18 +408,18 @@ function it(e, t) {
408
408
  let n = e[t];
409
409
  return n === void 0 ? 0 : Number.isFinite(n) ? n : null;
410
410
  }
411
- function B(e, t) {
411
+ function U(e, t) {
412
412
  return it(e, t) ?? 0;
413
413
  }
414
414
  function at(e) {
415
415
  let t = it(e, "x"), n = it(e, "y"), r = it(e, "z");
416
- return t === null || n === null || r === null ? null : new I(t, n, r);
416
+ return t === null || n === null || r === null ? null : new z(t, n, r);
417
417
  }
418
418
  function ot(e, t) {
419
419
  return [
420
- B(e, "x"),
421
- t !== void 0 && Number.isFinite(t) ? t : B(e, "y"),
422
- B(e, "z")
420
+ U(e, "x"),
421
+ t !== void 0 && Number.isFinite(t) ? t : U(e, "y"),
422
+ U(e, "z")
423
423
  ];
424
424
  }
425
425
  function st(e) {
@@ -471,8 +471,8 @@ function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight
471
471
  e.startSide,
472
472
  e.endSide,
473
473
  e.name,
474
- B(e.loc, "x"),
475
- B(e.loc, "z"),
474
+ U(e.loc, "x"),
475
+ U(e.loc, "z"),
476
476
  e.points[0].x,
477
477
  e.points[0].z,
478
478
  e.points[1].x,
@@ -482,7 +482,7 @@ function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight
482
482
  }), Array.from(c.values());
483
483
  }
484
484
  function dt(e, t) {
485
- return new I(...ot(e.loc, t));
485
+ return new z(...ot(e.loc, t));
486
486
  }
487
487
  function ft({ cameraPosition: e, floorY: t, line: n, showBottom: r, showLeft: i, showRight: a, showTop: o }) {
488
488
  let s = {
@@ -498,7 +498,7 @@ function pt({ endpoint: e, labelOffset: t, line: n }) {
498
498
  return i.y = 0, i.lengthSq() === 0 && i.set(1, 0, 0), i.normalize().multiplyScalar(t), e === "start" && i.negate(), r.add(i);
499
499
  }
500
500
  function mt(e, t) {
501
- let n = new I(), r = 0;
501
+ let n = new z(), r = 0;
502
502
  return e.forEach((e) => {
503
503
  let i = dt(e, t);
504
504
  e.points.forEach((e) => {
@@ -527,11 +527,11 @@ function gt({ color: e, fontSize: t, position: n, text: r }) {
527
527
  ]), f(({ camera: e, size: t }) => {
528
528
  let n = s.current;
529
529
  n && rt(n, c, e, t.height);
530
- }), /* @__PURE__ */ L("sprite", {
530
+ }), /* @__PURE__ */ B("sprite", {
531
531
  ref: s,
532
532
  position: n,
533
533
  renderOrder: 2,
534
- children: /* @__PURE__ */ L("spriteMaterial", {
534
+ children: /* @__PURE__ */ B("spriteMaterial", {
535
535
  alphaTest: .1,
536
536
  depthTest: !0,
537
537
  depthWrite: !1,
@@ -556,14 +556,14 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
556
556
  labelOffset: i,
557
557
  line: a
558
558
  }) : null;
559
- return o(() => () => f.dispose(), [f]), /* @__PURE__ */ R("lineSegments", {
559
+ return o(() => () => f.dispose(), [f]), /* @__PURE__ */ V("lineSegments", {
560
560
  geometry: f,
561
561
  position: ot(a.loc, n),
562
- children: [/* @__PURE__ */ L("lineBasicMaterial", {
562
+ children: [/* @__PURE__ */ B("lineBasicMaterial", {
563
563
  color: t,
564
564
  depthWrite: !1,
565
565
  linewidth: 2
566
- }), m && /* @__PURE__ */ L(gt, {
566
+ }), m && /* @__PURE__ */ B(gt, {
567
567
  color: t,
568
568
  fontSize: r,
569
569
  position: m,
@@ -572,7 +572,7 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
572
572
  });
573
573
  }
574
574
  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 }) {
575
- let h = p((e) => e.camera), g = l(null), [_, v] = u(() => new I()), y = ct(e), b = c(() => r ? ut({
575
+ let h = p((e) => e.camera), g = l(null), [_, v] = u(() => new z()), y = ct(e), b = c(() => r ? ut({
576
576
  flattenToFloor: t !== void 0,
577
577
  grids: r,
578
578
  showBottom: a,
@@ -597,10 +597,10 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
597
597
  if (!e) return;
598
598
  let t = h.position.clone();
599
599
  e.worldToLocal(t), !(t.distanceToSquared(_) < Xe) && v(t);
600
- }), !m || !b.length ? null : /* @__PURE__ */ L("group", {
600
+ }), !m || !b.length ? null : /* @__PURE__ */ B("group", {
601
601
  ref: g,
602
602
  userData: { modelGrids: !0 },
603
- children: b.map((e) => /* @__PURE__ */ L(_t, {
603
+ children: b.map((e) => /* @__PURE__ */ B(_t, {
604
604
  cameraPosition: _,
605
605
  color: y,
606
606
  floorY: t,
@@ -615,9 +615,9 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
615
615
  e.startSide,
616
616
  e.endSide,
617
617
  e.name,
618
- B(e.loc, "x"),
619
- t ?? B(e.loc, "y"),
620
- B(e.loc, "z"),
618
+ U(e.loc, "x"),
619
+ t ?? U(e.loc, "y"),
620
+ U(e.loc, "z"),
621
621
  e.points[0].x,
622
622
  e.points[0].y,
623
623
  e.points[0].z,
@@ -629,12 +629,12 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
629
629
  }
630
630
  //#endregion
631
631
  //#region src/viewer/Model.tsx
632
- var yt = new j();
632
+ var yt = new M();
633
633
  function bt(e) {
634
634
  if (!e) return null;
635
635
  try {
636
636
  let t = JSON.parse(e);
637
- return !Array.isArray(t) || t.length !== 16 ? null : new j().fromArray(t);
637
+ return !Array.isArray(t) || t.length !== 16 ? null : new M().fromArray(t);
638
638
  } catch (e) {
639
639
  return console.warn("Model matrix parsing error", e), null;
640
640
  }
@@ -646,16 +646,16 @@ function St(e) {
646
646
  return e.coordinationMatrix ?? Object.values(e.data)[0]?.matrix;
647
647
  }
648
648
  function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r, materialMode: i }) {
649
- let a = z((e) => e.gridAxesVisibility), o = c(() => {
649
+ let a = H((e) => e.gridAxesVisibility), o = c(() => {
650
650
  if (!r) return {
651
651
  data: [],
652
652
  coordinationMatrix: null,
653
653
  floorY: 0
654
654
  };
655
- let e = Object.values(r.data).some((e) => !!e.matrix) ? t?.clone() ?? xt(r) : null, i = Infinity, a = new I();
655
+ let e = Object.values(r.data).some((e) => !!e.matrix) ? t?.clone() ?? xt(r) : null, i = Infinity, a = new z();
656
656
  return {
657
657
  data: Object.values(r.data).map((e) => {
658
- let t = (bt(e.matrix) ?? new j()).clone().invert(), r = e.mat, o = e.pos;
658
+ let t = (bt(e.matrix) ?? new M()).clone().invert(), r = e.mat, o = e.pos;
659
659
  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));
660
660
  return {
661
661
  data: e,
@@ -673,13 +673,13 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
673
673
  r,
674
674
  n
675
675
  ]);
676
- if (!r) return /* @__PURE__ */ L(Ce, {});
676
+ if (!r) return /* @__PURE__ */ B(Ce, {});
677
677
  let s = i ?? r.renderSettings?.materialMode ?? "quality", l = r.renderSettings?.useDoubleSideMaterial === !0;
678
- return /* @__PURE__ */ R("group", {
678
+ return /* @__PURE__ */ V("group", {
679
679
  matrix: o.coordinationMatrix ?? yt,
680
680
  matrixAutoUpdate: !1,
681
681
  userData: { modelID: n },
682
- children: [o.data.map(({ data: t, isIfcSpace: n, key: r, material: i, meshMatrix: a }) => /* @__PURE__ */ L(Ke, {
682
+ children: [o.data.map(({ data: t, isIfcSpace: n, key: r, material: i, meshMatrix: a }) => /* @__PURE__ */ B(Ke, {
683
683
  colorPaletteTexture: e,
684
684
  material: i,
685
685
  materialMode: s,
@@ -687,7 +687,7 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
687
687
  isIfcSpace: n,
688
688
  meshMatrix: a,
689
689
  useDoubleSideMaterial: l
690
- }, r)), /* @__PURE__ */ L(vt, {
690
+ }, r)), /* @__PURE__ */ B(vt, {
691
691
  floorY: o.floorY,
692
692
  grids: r.grids,
693
693
  showBottom: a.bottom,
@@ -755,7 +755,7 @@ function Mt(e) {
755
755
  if (!n || r.indexedModel === n && r.records.size) return r;
756
756
  let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
757
757
  return n.traverse((e) => {
758
- if (!(e instanceof M)) return;
758
+ if (!(e instanceof N)) return;
759
759
  let t = e, n = t.geometry, o = n.index, s = n.attributes.ids;
760
760
  if (!o || !s) return;
761
761
  let c = At(t), l = jt(t), u = Et(o.array), d = {
@@ -832,10 +832,10 @@ function Vt(e, t) {
832
832
  function Ht(e, t, n) {
833
833
  e.hiddenIds.has(t) || (e.hiddenIds.add(t), n.add(e));
834
834
  }
835
- function V(e, t, n) {
835
+ function Ut(e, t, n) {
836
836
  e && console.log(`${t}:`, Date.now() - n, "ms");
837
837
  }
838
- function H(e, t, n, r) {
838
+ function W(e, t, n, r) {
839
839
  let { hiddenIds: i, originalIndex: a, triangleRanges: o } = e, s = zt(i, t, n, e.isIfcSpace);
840
840
  if (e.visibleStateKey === s) return;
841
841
  if (!i.size && !n) {
@@ -863,18 +863,18 @@ function H(e, t, n, r) {
863
863
  }
864
864
  r || (e.originalBoundsTree = null), Ft(e, u), e.visibleStateKey = s;
865
865
  }
866
- function U(e, t) {
866
+ function G(e, t) {
867
867
  return e.isolatedIdsByModel ? e.isolatedIdsByModel.get(t.modelID) ?? /* @__PURE__ */ new Set() : e.isolatedIds;
868
868
  }
869
- function Ut(e) {
870
- 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) => {
869
+ function Wt(e) {
870
+ let t = H((e) => e.selected), n = H((e) => e.resetSelected), r = H((e) => e.showStats), a = H((e) => e.userDevice) === "pc", o = e.buildIndex, s = i(() => Array.from(o().elementIndex.keys()), [o]), c = i(() => o().ifcSpacesVisible, [o]), l = i((e) => {
871
871
  let t = Date.now(), n = o(), i = /* @__PURE__ */ new Set();
872
872
  e.forEach((e) => {
873
873
  let t = n.elementIndex.get(e);
874
874
  t && t.forEach(({ record: t }) => {
875
875
  Ht(t, e, i);
876
876
  });
877
- }), i.forEach((e) => H(e, n.ifcSpacesVisible, U(n, e), a)), V(r, "hideByIds", t);
877
+ }), i.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Ut(r, "hideByIds", t);
878
878
  }, [
879
879
  o,
880
880
  a,
@@ -886,7 +886,7 @@ function Ut(e) {
886
886
  n && n.forEach(({ record: n }) => {
887
887
  n.modelID === e && Ht(n, t, s);
888
888
  });
889
- }), s.forEach((e) => H(e, i.ifcSpacesVisible, U(i, e), a)), n(), V(r, "hideSelected", e);
889
+ }), s.forEach((e) => W(e, i.ifcSpacesVisible, G(i, e), a)), n(), Ut(r, "hideSelected", e);
890
890
  }, [
891
891
  o,
892
892
  a,
@@ -900,14 +900,14 @@ function Ut(e) {
900
900
  t && t.forEach(({ record: t }) => {
901
901
  t.hiddenIds.delete(e) && i.add(t);
902
902
  });
903
- }), i.forEach((e) => H(e, n.ifcSpacesVisible, U(n, e), a)), V(r, "showByIds", t);
903
+ }), i.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Ut(r, "showByIds", t);
904
904
  }, [
905
905
  o,
906
906
  a,
907
907
  r
908
908
  ]), f = i((e) => {
909
909
  let t = Date.now(), n = o();
910
- n.isolatedIdsByModel = null, n.isolatedIds = new Set(e), n.records.forEach((e) => H(e, n.ifcSpacesVisible, U(n, e), a)), V(r, "isolateByIds", t);
910
+ n.isolatedIdsByModel = null, n.isolatedIds = new Set(e), n.records.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Ut(r, "isolateByIds", t);
911
911
  }, [
912
912
  o,
913
913
  a,
@@ -917,7 +917,7 @@ function Ut(e) {
917
917
  Vt(t, (e, t) => {
918
918
  let n = i.get(e);
919
919
  n || (n = /* @__PURE__ */ new Set(), i.set(e, n)), n.add(t);
920
- }), n.isolatedIdsByModel = i, n.isolatedIds = null, n.records.forEach((e) => H(e, n.ifcSpacesVisible, U(n, e), a)), V(r, "isolateSelected", e);
920
+ }), n.isolatedIdsByModel = i, n.isolatedIds = null, n.records.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Ut(r, "isolateSelected", e);
921
921
  }, [
922
922
  o,
923
923
  a,
@@ -925,7 +925,7 @@ function Ut(e) {
925
925
  r
926
926
  ]), m = i(() => {
927
927
  let e = Date.now(), t = o();
928
- t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => H(e, t.ifcSpacesVisible, U(t, e), a)), V(r, "resetIsolation", e);
928
+ t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => W(e, t.ifcSpacesVisible, G(t, e), a)), Ut(r, "resetIsolation", e);
929
929
  }, [
930
930
  o,
931
931
  a,
@@ -933,7 +933,7 @@ function Ut(e) {
933
933
  ]), h = i((e) => {
934
934
  let t = o();
935
935
  t.ifcSpacesVisible !== e && (t.ifcSpacesVisible = e, t.records.forEach((e) => {
936
- e.isIfcSpace && H(e, t.ifcSpacesVisible, U(t, e), a);
936
+ e.isIfcSpace && W(e, t.ifcSpacesVisible, G(t, e), a);
937
937
  }));
938
938
  }, [o, a]), g = i(() => {
939
939
  h(!c());
@@ -951,8 +951,8 @@ function Ut(e) {
951
951
  showAll: i(() => {
952
952
  let e = Date.now(), t = o();
953
953
  t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => {
954
- e.hiddenIds.clear(), H(e, t.ifcSpacesVisible, U(t, e), a);
955
- }), V(r, "showAll", e);
954
+ e.hiddenIds.clear(), W(e, t.ifcSpacesVisible, G(t, e), a);
955
+ }), Ut(r, "showAll", e);
956
956
  }, [
957
957
  o,
958
958
  a,
@@ -963,50 +963,372 @@ function Ut(e) {
963
963
  };
964
964
  }
965
965
  //#endregion
966
- //#region src/viewer/utils/ClippingUtils/ClippingEdges.ts
967
- var Wt = 1024, Gt = -1e-5;
968
- function Kt(e) {
966
+ //#region src/viewer/utils/ClippingUtils/ClippingCaps.ts
967
+ var Gt = "#ffffff", Kt = "#111111", qt = 1e-5, Jt = 1e-6, Yt = 2e-5, Xt = 50, Zt = 1e-6, Qt = 2, $t = .005, en = .15, tn = 128, nn = 6;
968
+ function rn(e) {
969
+ return !(!e.parent || !e.visible || !e.geometry.index?.count);
970
+ }
971
+ function an(e) {
972
+ let t = e;
973
+ for (; t;) {
974
+ let e = t.userData.modelID;
975
+ if (typeof e == "number") return e;
976
+ t = t.parent;
977
+ }
978
+ return 0;
979
+ }
980
+ function on(e) {
981
+ let t = (Math.abs(e.normal.y) < .9 ? new z(0, 1, 0) : new z(1, 0, 0)).cross(e.normal).normalize(), n = e.normal.clone().cross(t).normalize();
982
+ return {
983
+ origin: e.coplanarPoint(new z()),
984
+ u: t,
985
+ v: n
986
+ };
987
+ }
988
+ function sn(e, t) {
989
+ return `${Math.round(e.x / t)}:${Math.round(e.y / t)}`;
990
+ }
991
+ function cn(e, t) {
992
+ return e < t ? `${e}|${t}` : `${t}|${e}`;
993
+ }
994
+ function ln(e) {
995
+ let t = 0;
996
+ for (let n = 0; n < e.length; n++) {
997
+ let r = e[n], i = e[(n + 1) % e.length];
998
+ t += r.x * i.y - i.x * r.y;
999
+ }
1000
+ return t * .5;
1001
+ }
1002
+ function un() {
1003
+ let e = tn, t = document.createElement("canvas");
1004
+ t.width = e, t.height = e;
1005
+ let n = t.getContext("2d");
1006
+ if (n) {
1007
+ n.fillStyle = Gt, n.fillRect(0, 0, e, e), n.strokeStyle = Kt, n.lineWidth = nn, n.lineCap = "square", n.beginPath();
1008
+ for (let t of [
1009
+ -e,
1010
+ 0,
1011
+ e
1012
+ ]) n.moveTo(t, e), n.lineTo(t + e, 0);
1013
+ n.stroke();
1014
+ }
1015
+ let r = new b(t);
1016
+ return r.wrapS = se, r.wrapT = se, r.needsUpdate = !0, r;
1017
+ }
1018
+ var dn = class {
1019
+ active;
1020
+ plane;
1021
+ capMaterial;
1022
+ capMesh;
1023
+ capTexture;
1024
+ context;
1025
+ root = new D();
1026
+ box = new g();
1027
+ meshBox = new g();
1028
+ inverseMatrix = new M();
1029
+ localPlane = new L();
1030
+ tempLine = new ee();
1031
+ tempVector = new z();
1032
+ tempVector1 = new z();
1033
+ worldPoint = new z();
1034
+ capClippingPlanesKey = "";
1035
+ capShader = null;
1036
+ closeGapTolerance = qt;
1037
+ preselection = null;
1038
+ tolerance = qt;
1039
+ constructor(e, t) {
1040
+ this.context = e, this.plane = t, this.active = e.getActive() && e.getCapsActive(), this.capTexture = un(), this.capMaterial = new P({
1041
+ color: Gt,
1042
+ depthWrite: !1,
1043
+ map: this.capTexture,
1044
+ side: w
1045
+ }), this.capMaterial.defaultAttributeValues = {
1046
+ colorIndex: [0],
1047
+ ids: [0],
1048
+ modelID: [0]
1049
+ }, this.capMaterial.color.convertSRGBToLinear(), this.setupCapMaterialShader(), this.capMesh = new N(new y(), this.capMaterial), this.capMesh.frustumCulled = !1, this.capMesh.renderOrder = Qt, this.root.add(this.capMesh), this.root.visible = this.active, this.root.name = "clipping-caps", this.root.renderOrder = Qt, this.context.getScene().add(this.root), this.context.caps.push(this), this.update();
1050
+ }
1051
+ dispose() {
1052
+ this.root.removeFromParent(), this.capMesh.geometry.dispose(), this.capTexture.dispose(), this.capMaterial.dispose();
1053
+ }
1054
+ setVisible(e) {
1055
+ this.active = e, this.root.visible = e;
1056
+ }
1057
+ syncMeshes() {
1058
+ this.update();
1059
+ }
1060
+ getSelectableObject() {
1061
+ return this.capMesh;
1062
+ }
1063
+ setPreselection(e) {
1064
+ this.preselection = e, this.updatePreselectionUniforms();
1065
+ }
1066
+ updateVisualState() {
1067
+ this.updateColorUniforms(), this.updatePreselectionUniforms();
1068
+ let e = this.capMesh.geometry, t = e.getAttribute("ids"), n = e.getAttribute("modelID");
1069
+ if (!t || !n) return;
1070
+ let r = e.getAttribute("colorIndex");
1071
+ (!r || r.count !== t.count) && (r = new v(new Uint8Array(t.count), 1), e.setAttribute("colorIndex", r));
1072
+ let i = this.context.getSelected();
1073
+ for (let e = 0; e < t.count; e++) {
1074
+ let a = n.getX(e), o = t.getX(e), s = i[a]?.has(o) ?? !1;
1075
+ r.setX(e, +!!s);
1076
+ }
1077
+ r.needsUpdate = !0;
1078
+ }
1079
+ update() {
1080
+ if (!this.active) return;
1081
+ this.updateCapMaterial();
1082
+ let e = this.createCapGeometry();
1083
+ this.capMesh.geometry.dispose(), this.capMesh.geometry = e, this.updateVisualState(), this.capMesh.visible = (e.getAttribute("position")?.count ?? 0) >= 3;
1084
+ }
1085
+ setupCapMaterialShader() {
1086
+ this.capMaterial.onBeforeCompile = (e) => {
1087
+ e.uniforms.capPreSelectionColor = { value: new x(this.context.getPreselectionColor()) }, e.uniforms.capSelectionColor = { value: new x(this.context.getSelectionColor()) }, e.uniforms.capPreSelectionId = { value: -1 }, e.uniforms.capPreSelectionModelID = { value: -1 }, e.vertexShader = e.vertexShader.replace("#include <common>", "\n #include <common>\n attribute float colorIndex;\n attribute uint ids;\n attribute uint modelID;\n flat varying float vCapColorIndex;\n flat varying float vCapId;\n flat varying float vCapModelID;\n "), e.vertexShader = e.vertexShader.replace("#include <begin_vertex>", "\n #include <begin_vertex>\n vCapColorIndex = colorIndex;\n vCapId = float(ids);\n vCapModelID = float(modelID);\n "), e.fragmentShader = e.fragmentShader.replace("#include <common>", "\n #include <common>\n uniform vec3 capPreSelectionColor;\n uniform vec3 capSelectionColor;\n uniform float capPreSelectionId;\n uniform float capPreSelectionModelID;\n flat varying float vCapColorIndex;\n flat varying float vCapId;\n flat varying float vCapModelID;\n "), e.fragmentShader = e.fragmentShader.replace("#include <map_fragment>", "\n #include <map_fragment>\n if(\n capPreSelectionId == vCapId &&\n capPreSelectionModelID == vCapModelID &&\n abs(vCapColorIndex - 1.0) > 0.5\n ){\n diffuseColor.rgb = capPreSelectionColor;\n }\n else if(vCapColorIndex > 0.5){\n diffuseColor.rgb = capSelectionColor;\n }\n "), this.capShader = e, this.updateColorUniforms(), this.updatePreselectionUniforms();
1088
+ };
1089
+ }
1090
+ updateColorUniform(e, t) {
1091
+ let n = this.capShader?.uniforms[e];
1092
+ n && (n.value instanceof x ? n.value.set(t) : n.value = new x(t));
1093
+ }
1094
+ updateColorUniforms() {
1095
+ this.updateColorUniform("capPreSelectionColor", this.context.getPreselectionColor()), this.updateColorUniform("capSelectionColor", this.context.getSelectionColor());
1096
+ }
1097
+ updatePreselectionUniforms() {
1098
+ let e = this.capShader?.uniforms.capPreSelectionId, t = this.capShader?.uniforms.capPreSelectionModelID;
1099
+ !e || !t || (e.value = this.preselection?.elementID ?? -1, t.value = this.preselection?.modelID ?? -1);
1100
+ }
1101
+ updateCapMaterial() {
1102
+ let e = this.context.planes.map((e, t) => e === this.plane ? "self" : t).join("|");
1103
+ this.capClippingPlanesKey !== e && (this.capClippingPlanesKey = e, this.capMaterial.clippingPlanes = this.context.planes.filter((e) => e !== this.plane), this.capMaterial.needsUpdate = !0);
1104
+ }
1105
+ createCapGeometry() {
1106
+ let e = new y(), t = this.getModelWorldBox();
1107
+ if (!t) return e;
1108
+ let n = t.getSize(new z()).length();
1109
+ this.tolerance = Math.max(qt, n * Jt), this.closeGapTolerance = Math.max(this.tolerance * Xt, n * Yt);
1110
+ let r = on(this.plane), i = this.getCapSegments(r), a = this.getClosedContours(i), o = this.getHatchSpacing(n), { elementIDs: s, modelIDs: c, positions: l, uvs: u } = this.triangulateContours(a, r, o);
1111
+ if (e.setAttribute("position", new E(l, 3)), e.setAttribute("uv", new E(u, 2)), e.setAttribute("ids", new me(s, 1)), e.setAttribute("modelID", new me(c, 1)), e.setAttribute("colorIndex", new v(new Uint8Array(s.length), 1)), s.length) {
1112
+ let t = new Uint32Array(s.length);
1113
+ for (let e = 0; e < t.length; e++) t[e] = e;
1114
+ e.setIndex(new me(t, 1));
1115
+ }
1116
+ return l.length && (e.computeVertexNormals(), e.computeBoundingSphere()), e;
1117
+ }
1118
+ getCapSegments(e) {
1119
+ let t = [];
1120
+ return this.context.getMeshes().filter(rn).forEach((n) => {
1121
+ let r = n.geometry.boundsTree;
1122
+ if (!r) return;
1123
+ let i = an(n);
1124
+ n.updateWorldMatrix(!0, !1), this.inverseMatrix.copy(n.matrixWorld).invert(), this.localPlane.copy(this.plane).applyMatrix4(this.inverseMatrix), r.shapecast({
1125
+ intersectsBounds: (e) => this.localPlane.intersectsBox(e),
1126
+ intersectsTriangle: (r, a) => {
1127
+ let o = this.getTriangleElementID(n, a);
1128
+ if (o === null) return;
1129
+ let s = this.getTriangleIntersections(r);
1130
+ if (s.length !== 2) return;
1131
+ let c = this.getPlanePoint(s[0].applyMatrix4(n.matrixWorld), e), l = this.getPlanePoint(s[1].applyMatrix4(n.matrixWorld), e);
1132
+ c.distanceToSquared(l) <= this.tolerance ** 2 || t.push({
1133
+ a: c,
1134
+ b: l,
1135
+ elementID: o,
1136
+ modelID: i
1137
+ });
1138
+ }
1139
+ });
1140
+ }), t;
1141
+ }
1142
+ getTriangleElementID(e, t) {
1143
+ let n = e.geometry.index, r = e.geometry.attributes.ids, i = t * 3;
1144
+ if (!n || !r || i >= n.count) return null;
1145
+ let a = n.getX(i);
1146
+ return a >= r.count ? null : r.getX(a);
1147
+ }
1148
+ getTriangleIntersections(e) {
1149
+ let t = [], n = (e) => {
1150
+ e && (t.some((t) => t.distanceToSquared(e) <= this.tolerance ** 2) || t.push(e.clone()));
1151
+ };
1152
+ return this.tempLine.start.copy(e.a), this.tempLine.end.copy(e.b), n(this.localPlane.intersectLine(this.tempLine, this.tempVector)), this.tempLine.start.copy(e.b), this.tempLine.end.copy(e.c), n(this.localPlane.intersectLine(this.tempLine, this.tempVector)), this.tempLine.start.copy(e.c), this.tempLine.end.copy(e.a), n(this.localPlane.intersectLine(this.tempLine, this.tempVector)), t;
1153
+ }
1154
+ getPlanePoint(e, t) {
1155
+ return this.worldPoint.copy(e).sub(t.origin), new R(this.worldPoint.dot(t.u), this.worldPoint.dot(t.v));
1156
+ }
1157
+ getClosedContours(e) {
1158
+ let t = /* @__PURE__ */ new Map();
1159
+ e.forEach((e) => {
1160
+ let n = `${e.modelID}:${e.elementID}`, r = t.get(n);
1161
+ r || (r = {
1162
+ elementID: e.elementID,
1163
+ modelID: e.modelID,
1164
+ segments: []
1165
+ }, t.set(n, r)), r.segments.push(e);
1166
+ });
1167
+ let n = [];
1168
+ return t.forEach(({ elementID: e, modelID: t, segments: r }) => {
1169
+ this.getElementClosedContours(r).forEach((r) => {
1170
+ n.push({
1171
+ elementID: e,
1172
+ modelID: t,
1173
+ points: r
1174
+ });
1175
+ });
1176
+ }), n;
1177
+ }
1178
+ getElementClosedContours(e) {
1179
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = (e) => {
1180
+ let n = sn(e, this.tolerance), r = t.get(n);
1181
+ return r || (r = {
1182
+ edges: /* @__PURE__ */ new Set(),
1183
+ point: e.clone()
1184
+ }, t.set(n, r)), {
1185
+ key: n,
1186
+ node: r
1187
+ };
1188
+ };
1189
+ e.forEach(({ a: e, b: t }) => {
1190
+ let n = r(e), i = r(t);
1191
+ n.key !== i.key && (n.node.edges.add(i.key), i.node.edges.add(n.key));
1192
+ });
1193
+ let i = [];
1194
+ return t.forEach((e, r) => {
1195
+ e.edges.forEach((e) => {
1196
+ let a = cn(r, e);
1197
+ if (n.has(a)) return;
1198
+ let o = this.walkContour(r, e, t, n);
1199
+ if (!o) return;
1200
+ let s = this.cleanContour(o.contour);
1201
+ s.length < 3 || Math.abs(ln(s)) < Zt || (o.edges.forEach((e) => n.add(e)), i.push(s));
1202
+ });
1203
+ }), i;
1204
+ }
1205
+ walkContour(e, t, n, r) {
1206
+ let i = [], a = [], o = /* @__PURE__ */ new Set(), s = e, c = t, l = n.size + 1;
1207
+ for (let t = 0; t < l; t++) {
1208
+ let t = n.get(s);
1209
+ if (!t || !c) return null;
1210
+ i.push(t.point.clone());
1211
+ let l = cn(s, c);
1212
+ a.push(l), o.add(l);
1213
+ let u = s;
1214
+ if (s = c, s === e) return {
1215
+ contour: i,
1216
+ edges: a
1217
+ };
1218
+ let d = n.get(s);
1219
+ if (!d) return null;
1220
+ if (c = this.getNextContourKey(u, s, e, n, r, o), !c && i.length >= 3) {
1221
+ let t = n.get(e);
1222
+ if (t && d.point.distanceTo(t.point) <= this.closeGapTolerance) return i.push(d.point.clone()), {
1223
+ contour: i,
1224
+ edges: a
1225
+ };
1226
+ }
1227
+ }
1228
+ return null;
1229
+ }
1230
+ getNextContourKey(e, t, n, r, i, a) {
1231
+ let o = r.get(e), s = r.get(t);
1232
+ if (!o || !s) return null;
1233
+ let c = s.point.clone().sub(o.point), l = Array.from(s.edges).filter((n) => {
1234
+ if (n === e) return !1;
1235
+ let r = cn(t, n);
1236
+ return !(i.has(r) || a.has(r));
1237
+ });
1238
+ return l.length ? l.includes(n) ? n : l.map((e) => {
1239
+ let t = r.get(e);
1240
+ if (!t) return null;
1241
+ let n = t.point.clone().sub(s.point);
1242
+ return {
1243
+ key: e,
1244
+ score: c.lengthSq() > 0 && n.lengthSq() > 0 ? c.normalize().dot(n.normalize()) : -Infinity
1245
+ };
1246
+ }).filter((e) => !!e).sort((e, t) => t.score - e.score)[0]?.key ?? null : null;
1247
+ }
1248
+ cleanContour(e) {
1249
+ let t = e.filter((t, n) => {
1250
+ let r = e[n - 1] ?? e[e.length - 1];
1251
+ return t.distanceToSquared(r) > this.tolerance ** 2;
1252
+ }), n = !0;
1253
+ for (; n && t.length >= 3;) {
1254
+ n = !1;
1255
+ for (let e = 0; e < t.length; e++) {
1256
+ let r = t[(e - 1 + t.length) % t.length], i = t[e], a = t[(e + 1) % t.length], o = i.clone().sub(r), s = a.clone().sub(i), c = Math.abs(o.x * s.y - o.y * s.x), l = Math.max(o.length() + s.length(), this.tolerance);
1257
+ if (!(c > this.tolerance * l)) {
1258
+ t.splice(e, 1), n = !0;
1259
+ break;
1260
+ }
1261
+ }
1262
+ }
1263
+ return t;
1264
+ }
1265
+ triangulateContours(e, t, n) {
1266
+ let r = [], i = [], a = [], o = [];
1267
+ return e.forEach(({ elementID: e, modelID: s, points: c }) => {
1268
+ le.triangulateShape(c, []).forEach(([l, u, d]) => {
1269
+ this.pushContourVertex(a, r, i, o, c[l], t, n, e, s), this.pushContourVertex(a, r, i, o, c[u], t, n, e, s), this.pushContourVertex(a, r, i, o, c[d], t, n, e, s);
1270
+ });
1271
+ }), {
1272
+ elementIDs: r,
1273
+ modelIDs: i,
1274
+ positions: a,
1275
+ uvs: o
1276
+ };
1277
+ }
1278
+ pushContourVertex(e, t, n, r, i, a, o, s, c) {
1279
+ this.tempVector1.copy(a.origin).addScaledVector(a.u, i.x).addScaledVector(a.v, i.y), e.push(this.tempVector1.x, this.tempVector1.y, this.tempVector1.z), t.push(s), n.push(c), r.push(i.x / o, i.y / o);
1280
+ }
1281
+ getHatchSpacing(e) {
1282
+ return Math.max(en, e * $t);
1283
+ }
1284
+ getModelWorldBox() {
1285
+ return this.box.makeEmpty(), this.context.getMeshes().filter(rn).forEach((e) => {
1286
+ e.updateWorldMatrix(!0, !1), e.geometry.boundingBox || e.geometry.computeBoundingBox(), e.geometry.boundingBox && (this.meshBox.copy(e.geometry.boundingBox).applyMatrix4(e.matrixWorld), this.box.union(this.meshBox));
1287
+ }), this.box.isEmpty() ? null : this.box;
1288
+ }
1289
+ }, fn = 1024, pn = 1;
1290
+ function mn(e) {
969
1291
  let t = new v(new Float32Array(e * 3), 3, !1);
970
1292
  return t.setUsage(T), t;
971
1293
  }
972
- function qt(e) {
1294
+ function hn(e) {
973
1295
  return Math.max(1, Math.ceil((e.geometry.index?.count ?? 0) / 3));
974
1296
  }
975
- function Jt(e, t) {
976
- let n = new y(), r = Math.ceil(Math.min(Math.max(Wt, qt(t) * .05), 32768));
977
- n.setAttribute("position", Kt(r)), n.setDrawRange(0, 0);
978
- let i = new k(n, e);
979
- return i.frustumCulled = !1, i.renderOrder = 1, i.visible = !1, i;
1297
+ function gn(e, t) {
1298
+ let n = new y(), r = Math.ceil(Math.min(Math.max(fn, hn(t) * .05), 32768));
1299
+ n.setAttribute("position", mn(r)), n.setDrawRange(0, 0);
1300
+ let i = new ne(n, e);
1301
+ return i.frustumCulled = !1, i.renderOrder = pn, i.visible = !1, i;
980
1302
  }
981
- function Yt(e, t) {
1303
+ function _n(e, t) {
982
1304
  let n = e.geometry.getAttribute("position");
983
1305
  if (n.count > t) return n;
984
- let r = Kt(Math.max(n.count * 2, t + 1));
1306
+ let r = mn(Math.max(n.count * 2, t + 1));
985
1307
  return r.array.set(n.array), e.geometry.setAttribute("position", r), n = r, n;
986
1308
  }
987
- function Xt(e) {
1309
+ function vn(e) {
988
1310
  return e.filter((e) => e.parent && e.geometry.index?.count);
989
1311
  }
990
- var Zt = class {
1312
+ var yn = class {
991
1313
  active;
992
1314
  material;
993
1315
  plane;
994
1316
  context;
995
1317
  lines = /* @__PURE__ */ new Map();
996
- inverseMatrix = new j();
997
- localPlane = new ce();
998
- tempLine = new te();
999
- tempVector = new I();
1000
- tempVector1 = new I();
1001
- tempVector2 = new I();
1002
- tempVector3 = new I();
1318
+ inverseMatrix = new M();
1319
+ localPlane = new L();
1320
+ tempLine = new ee();
1321
+ tempVector = new z();
1322
+ tempVector1 = new z();
1323
+ tempVector2 = new z();
1324
+ tempVector3 = new z();
1003
1325
  constructor(e, t) {
1004
1326
  this.context = e, this.plane = t, this.active = e.getActive() && e.getEdgesActive(), e.edges.forEach((e) => {
1005
1327
  let n = e.material.clippingPlanes ?? [];
1006
1328
  e.plane === t || n.includes(t) || (e.material.clippingPlanes = [...n, t], e.material.needsUpdate = !0);
1007
1329
  });
1008
1330
  let n = e.planes.filter((e) => e !== t);
1009
- this.material = new ne({
1331
+ this.material = new te({
1010
1332
  clippingPlanes: n,
1011
1333
  color: "black",
1012
1334
  depthTest: !0,
@@ -1017,12 +1339,12 @@ var Zt = class {
1017
1339
  return this.syncMeshes(), Array.from(this.lines.values());
1018
1340
  }
1019
1341
  syncMeshes() {
1020
- let e = new Set(Xt(this.context.getMeshes()));
1342
+ let e = new Set(vn(this.context.getMeshes()));
1021
1343
  this.lines.forEach((t, n) => {
1022
1344
  e.has(n) || (t.removeFromParent(), t.geometry.dispose(), this.lines.delete(n));
1023
1345
  }), e.forEach((e) => {
1024
1346
  if (this.lines.has(e)) return;
1025
- let t = Jt(this.material, e);
1347
+ let t = gn(this.material, e);
1026
1348
  e.add(t), this.lines.set(e, t);
1027
1349
  }), this.setVisible(this.active);
1028
1350
  }
@@ -1048,7 +1370,7 @@ var Zt = class {
1048
1370
  }
1049
1371
  t.updateWorldMatrix(!0, !1), this.inverseMatrix.copy(t.matrixWorld).invert(), this.localPlane.copy(this.plane).applyMatrix4(this.inverseMatrix);
1050
1372
  let r = 0, i = e.geometry.getAttribute("position"), a = (t) => {
1051
- i = Yt(e, r), i.setXYZ(r, t.x, t.y, t.z), r++;
1373
+ i = _n(e, r), i.setXYZ(r, t.x, t.y, t.z), r++;
1052
1374
  };
1053
1375
  n.shapecast({
1054
1376
  intersectsBounds: (e) => this.localPlane.intersectsBox(e),
@@ -1056,19 +1378,19 @@ var Zt = class {
1056
1378
  let t = 0;
1057
1379
  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);
1058
1380
  }
1059
- }), e.geometry.setDrawRange(0, r), e.position.copy(this.localPlane.normal).multiplyScalar(Gt), i.needsUpdate = !0;
1381
+ }), e.geometry.setDrawRange(0, r), e.position.set(0, 0, 0), i.needsUpdate = !0;
1060
1382
  }));
1061
1383
  }
1062
- }, Qt = "#0b2f5f", $t = "#0b2f5f", en = 0, tn = "#1f7ae0", nn = .22, rn = .01, an = .025, on = .015, sn = .25, cn = .15, ln = .25, W = 1;
1063
- function un(e, t) {
1384
+ }, bn = "#0b2f5f", xn = "#0b2f5f", Sn = 0, Cn = "#1f7ae0", wn = .22, Tn = .01, En = .025, Dn = .015, On = .02, kn = 1e-7, An = .25, jn = .15, Mn = .25, Nn = 1e-5, Pn = .3, Fn = 4, K = 1;
1385
+ function In(e, t) {
1064
1386
  let n = t.getBoundingClientRect();
1065
- return new F((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
1387
+ return new R((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
1066
1388
  }
1067
- function dn(e) {
1068
- let t = e.getSize(new I());
1069
- return Math.max(ln, t.length() * rn);
1389
+ function Ln(e) {
1390
+ let t = e.getSize(new z());
1391
+ return Math.max(Mn, t.length() * Tn);
1070
1392
  }
1071
- var fn = class extends ae {
1393
+ var Rn = class extends I {
1072
1394
  helper = new D();
1073
1395
  borderMaterial;
1074
1396
  material;
@@ -1077,24 +1399,26 @@ var fn = class extends ae {
1077
1399
  border;
1078
1400
  context;
1079
1401
  location;
1402
+ localHitPoint = new z();
1080
1403
  normal;
1081
1404
  planeMesh;
1082
- pointer = new F();
1405
+ pointer = new R();
1083
1406
  layout;
1407
+ polygon = [];
1084
1408
  dragState = null;
1085
1409
  hovered = !1;
1086
1410
  listenersActive = !1;
1087
1411
  constructor(e, t, n, r) {
1088
- super(), this.context = e, this.plane = t, this.location = n.clone(), this.normal = r.clone().normalize(), this.material = new N({
1089
- color: $t,
1412
+ super(), this.context = e, this.plane = t, this.location = n.clone(), this.normal = r.clone().normalize(), this.material = new P({
1413
+ color: xn,
1090
1414
  depthWrite: !1,
1091
- opacity: en,
1415
+ opacity: Sn,
1092
1416
  side: w,
1093
1417
  transparent: !0
1094
1418
  }), this.helper.position.copy(this.location), this.applyPlaneOrientation(), this.layout = this.getHelperLayout();
1095
- 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);
1096
- this.borderMaterial = new O({
1097
- color: Qt,
1419
+ let i = Math.max(An, Math.min(this.layout.width, this.layout.height) * En), a = Math.max(jn, Math.min(this.layout.width, this.layout.height) * Dn);
1420
+ this.borderMaterial = new k({
1421
+ color: bn,
1098
1422
  dashSize: i,
1099
1423
  depthWrite: !1,
1100
1424
  gapSize: a
@@ -1121,21 +1445,27 @@ var fn = class extends ae {
1121
1445
  updateClipping() {
1122
1446
  this.layout = this.getHelperLayout(), this.updateBorderDash();
1123
1447
  let e = this.getClippedPolygon();
1124
- this.replaceGeometry(this.planeMesh, this.createFillGeometry(e)), this.replaceGeometry(this.border, this.createBorderGeometry(e)), this.border.computeLineDistances(), this.planeMesh.visible = e.length >= 3, this.border.visible = e.length >= 2;
1448
+ this.polygon = e, this.replaceGeometry(this.planeMesh, this.createFillGeometry(e)), this.replaceGeometry(this.border, this.createBorderGeometry(e)), this.border.computeLineDistances(), this.planeMesh.visible = e.length >= 3, this.border.visible = e.length >= 2;
1125
1449
  }
1126
1450
  updateBorderDash() {
1127
1451
  let e = Math.min(this.layout.width, this.layout.height);
1128
- this.borderMaterial.dashSize = Math.max(sn, e * an), this.borderMaterial.gapSize = Math.max(cn, e * on), this.borderMaterial.needsUpdate = !0;
1452
+ this.borderMaterial.dashSize = Math.max(An, e * En), this.borderMaterial.gapSize = Math.max(jn, e * Dn), this.borderMaterial.needsUpdate = !0;
1129
1453
  }
1130
1454
  addEventListeners() {
1131
1455
  if (this.listenersActive) return;
1132
1456
  let e = this.context.getDomElement();
1133
- e.addEventListener("pointerdown", this.onPointerDown), e.addEventListener("pointermove", this.onPointerMove), window.addEventListener("pointerup", this.onPointerUp), window.addEventListener("pointercancel", this.onPointerUp), this.listenersActive = !0;
1457
+ e.addEventListener("pointerdown", this.onPointerDown, !0), e.addEventListener("pointermove", this.onPointerMove, !0), window.addEventListener("pointerup", this.onPointerUp, !0), window.addEventListener("pointercancel", this.onPointerUp, !0), this.listenersActive = !0;
1134
1458
  }
1135
1459
  removeEventListeners() {
1136
1460
  if (!this.listenersActive) return;
1137
1461
  let e = this.context.getDomElement();
1138
- e.removeEventListener("pointerdown", this.onPointerDown), e.removeEventListener("pointermove", this.onPointerMove), window.removeEventListener("pointerup", this.onPointerUp), window.removeEventListener("pointercancel", this.onPointerUp), this.listenersActive = !1;
1462
+ e.removeEventListener("pointerdown", this.onPointerDown, !0), e.removeEventListener("pointermove", this.onPointerMove, !0), window.removeEventListener("pointerup", this.onPointerUp, !0), window.removeEventListener("pointercancel", this.onPointerUp, !0), this.listenersActive = !1;
1463
+ }
1464
+ hasHelperPriority(e) {
1465
+ return e.altKey;
1466
+ }
1467
+ stopHelperPriorityEvent(e) {
1468
+ e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
1139
1469
  }
1140
1470
  getPointerIntersection(e) {
1141
1471
  let t = this.getNearestHelperIntersection(e);
@@ -1144,48 +1474,76 @@ var fn = class extends ae {
1144
1474
  getNearestHelperIntersection(e) {
1145
1475
  let t = this.context.helpers.filter((e) => e.active && e.planeMesh.visible).map((e) => e.planeMesh);
1146
1476
  if (!t.length) return null;
1147
- let n = this.context.getCameraUtils().getIntersection(!0, {
1477
+ let n = this.context.getCameraUtils().getIntersection(!1, {
1148
1478
  event: e,
1149
1479
  object: t,
1150
1480
  recursive: !1,
1151
1481
  respectClipping: !1
1152
1482
  });
1153
- if (!n) return null;
1154
- let r = this.context.helpers.find((e) => e.planeMesh === n.object);
1155
- return r ? {
1156
- helper: r,
1157
- hit: n
1158
- } : null;
1159
- }
1160
- hasModelIntersection(e) {
1161
- return !!this.context.getCameraUtils().getIntersection(!0, {
1483
+ for (let t of n) {
1484
+ let n = this.context.helpers.find((e) => e.planeMesh === t.object);
1485
+ if (n && !(!this.hasHelperPriority(e) && !n.isPointerHitNearEdge(t.point)) && !(!this.hasHelperPriority(e) && this.hasCloserModelIntersection(e, t.distance))) return {
1486
+ helper: n,
1487
+ hit: t
1488
+ };
1489
+ }
1490
+ return null;
1491
+ }
1492
+ hasCloserModelIntersection(e, t) {
1493
+ let n = this.context.getCameraUtils().getIntersection(!0, {
1162
1494
  event: e,
1163
- filter: (e) => !(e.object instanceof M) || e.faceIndex === void 0 || e.faceIndex === null ? !1 : !!(e.object.geometry.index && e.object.geometry.attributes.ids),
1495
+ filter: (e) => !(e.object instanceof N) || e.faceIndex === void 0 || e.faceIndex === null ? !1 : !!(e.object.geometry.index && e.object.geometry.attributes.ids),
1164
1496
  object: this.context.getMeshes(),
1165
1497
  recursive: !1
1166
1498
  });
1499
+ return !!(n && n.distance < t);
1500
+ }
1501
+ isPointerHitNearEdge(e) {
1502
+ if (this.polygon.length < 2) return !1;
1503
+ this.localHitPoint.copy(e), this.planeMesh.worldToLocal(this.localHitPoint);
1504
+ let t = this.getEdgeInteractionWidth(), n = t * t, r = {
1505
+ x: this.localHitPoint.x,
1506
+ y: this.localHitPoint.y
1507
+ };
1508
+ for (let e = 0; e < this.polygon.length; e++) {
1509
+ let t = this.polygon[e], i = this.polygon[(e + 1) % this.polygon.length];
1510
+ if (this.getPointToSegmentDistanceSquared(r, t, i) <= n) return !0;
1511
+ }
1512
+ return !1;
1513
+ }
1514
+ getEdgeInteractionWidth() {
1515
+ return Math.min(Fn, Math.max(Pn, Math.min(this.layout.width, this.layout.height) * On));
1516
+ }
1517
+ getDragDistanceEpsilon() {
1518
+ return Math.max(Nn, Math.min(this.layout.width, this.layout.height) * kn);
1519
+ }
1520
+ getPointToSegmentDistanceSquared(e, t, n) {
1521
+ let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
1522
+ if (a === 0) {
1523
+ let n = e.x - t.x, r = e.y - t.y;
1524
+ return n * n + r * r;
1525
+ }
1526
+ let o = Math.min(1, Math.max(0, ((e.x - t.x) * r + (e.y - t.y) * i) / a)), s = t.x + r * o, c = t.y + i * o, l = e.x - s, u = e.y - c;
1527
+ return l * l + u * u;
1167
1528
  }
1168
1529
  getPointerPointOnPlane(e, t) {
1169
1530
  let n = this.context.getDomElement();
1170
- this.pointer.copy(un(e, n));
1171
- let r = this.context.getRaycaster(), i = new I();
1531
+ this.pointer.copy(In(e, n));
1532
+ let r = this.context.getRaycaster(), i = new z();
1172
1533
  return r.setFromCamera(this.pointer, this.context.getCamera()), r.ray.intersectPlane(t, i);
1173
1534
  }
1174
1535
  onPointerDown = (e) => {
1175
1536
  if (!this.active || e.button !== 0) return;
1176
- if (this.hasModelIntersection(e)) {
1177
- this.setHovered(!1);
1178
- return;
1179
- }
1180
1537
  let t = this.getPointerIntersection(e);
1181
1538
  if (!t) return;
1182
- e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), this.context.clearHelpersHover(this), this.setHovered(!0), this.context.setHelperDragActive(!0), this.context.setSelectionInteractionDisabled(!0);
1183
- let n = new I();
1539
+ this.stopHelperPriorityEvent(e), this.context.clearHelpersHover(this), this.setHovered(!0), this.context.setHelperDragActive(!0), this.context.setCapsDragActive(!0), this.context.requestCapsDragIdleUpdate(), this.context.setSelectionInteractionDisabled(!0);
1540
+ let n = new z();
1184
1541
  this.context.getCamera().getWorldDirection(n), n.normalize();
1185
- let r = new ce().setFromNormalAndCoplanarPoint(n, t.point);
1542
+ let r = new L().setFromNormalAndCoplanarPoint(n, t.point);
1186
1543
  this.dragState = {
1187
1544
  dragPlane: r,
1188
1545
  helperStart: this.helper.position.clone(),
1546
+ lastDistance: 0,
1189
1547
  planeStart: this.plane.clone(),
1190
1548
  pointStart: t.point.clone()
1191
1549
  }, this.context.setControlsEnabled(!1);
@@ -1198,12 +1556,15 @@ var fn = class extends ae {
1198
1556
  }
1199
1557
  let t = this.getPointerPointOnPlane(e, this.dragState.dragPlane);
1200
1558
  if (!t) return;
1201
- e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
1202
- let n = t.sub(this.dragState.pointStart).dot(this.plane.normal), r = this.plane.normal.clone().multiplyScalar(n);
1203
- this.plane.copy(this.dragState.planeStart).translate(r), this.helper.position.copy(this.dragState.helperStart).add(r), this.context.requestHelpersUpdate(), this.context.requestEdgesUpdate();
1559
+ this.stopHelperPriorityEvent(e);
1560
+ let n = t.sub(this.dragState.pointStart).dot(this.plane.normal);
1561
+ if (Math.abs(n - this.dragState.lastDistance) <= this.getDragDistanceEpsilon()) return;
1562
+ this.dragState.lastDistance = n;
1563
+ let r = this.plane.normal.clone().multiplyScalar(n);
1564
+ this.plane.copy(this.dragState.planeStart).translate(r), this.helper.position.copy(this.dragState.helperStart).add(r), this.context.requestHelpersUpdate(), this.context.requestEdgesUpdate(), this.context.requestCapsDragIdleUpdate();
1204
1565
  };
1205
1566
  onPointerUp = (e) => {
1206
- this.dragState && (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), this.dragState = null, this.context.setHelperDragActive(!1), this.context.setControlsEnabled(!0), this.context.updateHelpers(), this.context.updateEdges(), window.setTimeout(() => {
1567
+ this.dragState && (this.stopHelperPriorityEvent(e), this.dragState = null, this.context.setHelperDragActive(!1), this.context.setControlsEnabled(!0), this.context.setCapsDragActive(!1), this.context.updateHelpers(), this.context.flushEdgesUpdate(), window.setTimeout(() => {
1207
1568
  this.context.setSelectionInteractionDisabled(!1);
1208
1569
  }, 0));
1209
1570
  };
@@ -1216,22 +1577,18 @@ var fn = class extends ae {
1216
1577
  this.setHovered(!1);
1217
1578
  return;
1218
1579
  }
1219
- if (this.hasModelIntersection(e)) {
1220
- this.setHovered(!1);
1221
- return;
1222
- }
1223
1580
  let t = !!this.getPointerIntersection(e);
1224
- this.hovered !== t && this.setHovered(t);
1581
+ t && (this.context.clearHelpersHover(this), this.hasHelperPriority(e) && this.stopHelperPriorityEvent(e)), this.hovered !== t && this.setHovered(t);
1225
1582
  }
1226
1583
  setHovered(e) {
1227
- this.hovered = e, this.material.color.set(e ? tn : $t), this.material.opacity = e ? nn : en, this.material.needsUpdate = !0;
1584
+ this.hovered = e, this.material.color.set(e ? Cn : xn), this.material.opacity = e ? wn : Sn, this.material.needsUpdate = !0;
1228
1585
  }
1229
1586
  createPlaneMesh() {
1230
- let e = new M(new y(), this.material);
1587
+ let e = new N(new y(), this.material);
1231
1588
  return e.renderOrder = 2, e;
1232
1589
  }
1233
1590
  createBorder() {
1234
- let e = new k(new y(), this.borderMaterial);
1591
+ let e = new ne(new y(), this.borderMaterial);
1235
1592
  return e.renderOrder = 3, e;
1236
1593
  }
1237
1594
  replaceGeometry(e, t) {
@@ -1300,27 +1657,27 @@ var fn = class extends ae {
1300
1657
  getHelperLayout() {
1301
1658
  let e = this.getModelWorldBox();
1302
1659
  if (!e || e.isEmpty()) return {
1303
- height: W,
1304
- maxU: W / 2,
1305
- maxV: W / 2,
1306
- minU: -W / 2,
1307
- minV: -W / 2,
1308
- width: W
1660
+ height: K,
1661
+ maxU: K / 2,
1662
+ maxV: K / 2,
1663
+ minU: -K / 2,
1664
+ minV: -K / 2,
1665
+ width: K
1309
1666
  };
1310
- 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;
1667
+ let t = this.getPlaneBasis(), n = this.helper.position, r = this.getBoxCorners(e), i = new z(), a = new z(), o = Infinity, s = -Infinity, c = Infinity, l = -Infinity;
1311
1668
  if (r.forEach((e) => {
1312
1669
  this.plane.projectPoint(e, i), a.copy(i).sub(n);
1313
1670
  let r = a.dot(t.u), u = a.dot(t.v);
1314
1671
  o = Math.min(o, r), s = Math.max(s, r), c = Math.min(c, u), l = Math.max(l, u);
1315
1672
  }), !Number.isFinite(o) || !Number.isFinite(s) || !Number.isFinite(c) || !Number.isFinite(l)) return {
1316
- height: W,
1317
- maxU: W / 2,
1318
- maxV: W / 2,
1319
- minU: -W / 2,
1320
- minV: -W / 2,
1321
- width: W
1673
+ height: K,
1674
+ maxU: K / 2,
1675
+ maxV: K / 2,
1676
+ minU: -K / 2,
1677
+ minV: -K / 2,
1678
+ width: K
1322
1679
  };
1323
- let u = dn(e), d = o - u, f = s + u, p = c - u, m = l + u, h = Math.max(W, f - d), g = Math.max(W, m - p), _ = (d + f) / 2, v = (p + m) / 2;
1680
+ let u = Ln(e), d = o - u, f = s + u, p = c - u, m = l + u, h = Math.max(K, f - d), g = Math.max(K, m - p), _ = (d + f) / 2, v = (p + m) / 2;
1324
1681
  return {
1325
1682
  height: g,
1326
1683
  maxU: _ + h / 2,
@@ -1331,14 +1688,14 @@ var fn = class extends ae {
1331
1688
  };
1332
1689
  }
1333
1690
  getPlaneBasis() {
1334
- let e = (Math.abs(this.normal.y) < .9 ? new I(0, 1, 0) : new I(1, 0, 0)).cross(this.normal).normalize();
1691
+ let e = (Math.abs(this.normal.y) < .9 ? new z(0, 1, 0) : new z(1, 0, 0)).cross(this.normal).normalize();
1335
1692
  return {
1336
1693
  u: e,
1337
1694
  v: this.normal.clone().cross(e).normalize()
1338
1695
  };
1339
1696
  }
1340
1697
  applyPlaneOrientation() {
1341
- let e = this.getPlaneBasis(), t = new j().makeBasis(e.u, e.v, this.normal);
1698
+ let e = this.getPlaneBasis(), t = new M().makeBasis(e.u, e.v, this.normal);
1342
1699
  this.helper.quaternion.setFromRotationMatrix(t);
1343
1700
  }
1344
1701
  getModelWorldBox() {
@@ -1351,20 +1708,18 @@ var fn = class extends ae {
1351
1708
  }
1352
1709
  getBoxCorners(e) {
1353
1710
  return [
1354
- new I(e.min.x, e.min.y, e.min.z),
1355
- new I(e.min.x, e.min.y, e.max.z),
1356
- new I(e.min.x, e.max.y, e.min.z),
1357
- new I(e.min.x, e.max.y, e.max.z),
1358
- new I(e.max.x, e.min.y, e.min.z),
1359
- new I(e.max.x, e.min.y, e.max.z),
1360
- new I(e.max.x, e.max.y, e.min.z),
1361
- new I(e.max.x, e.max.y, e.max.z)
1711
+ new z(e.min.x, e.min.y, e.min.z),
1712
+ new z(e.min.x, e.min.y, e.max.z),
1713
+ new z(e.min.x, e.max.y, e.min.z),
1714
+ new z(e.min.x, e.max.y, e.max.z),
1715
+ new z(e.max.x, e.min.y, e.min.z),
1716
+ new z(e.max.x, e.min.y, e.max.z),
1717
+ new z(e.max.x, e.max.y, e.min.z),
1718
+ new z(e.max.x, e.max.y, e.max.z)
1362
1719
  ];
1363
1720
  }
1364
- };
1365
- //#endregion
1366
- //#region src/viewer/utils/ClippingUtils/ClippingUtils.ts
1367
- function pn(e, t) {
1721
+ }, zn = 250;
1722
+ function Bn(e, t) {
1368
1723
  if (Array.isArray(e)) {
1369
1724
  e.forEach((e) => {
1370
1725
  e.clippingPlanes = t, e.needsUpdate = !0;
@@ -1373,13 +1728,13 @@ function pn(e, t) {
1373
1728
  }
1374
1729
  e.clippingPlanes = t, e.needsUpdate = !0;
1375
1730
  }
1376
- function mn(e) {
1731
+ function Vn(e) {
1377
1732
  let t = [];
1378
1733
  return e?.traverse((e) => {
1379
- e instanceof M && (!e.geometry.index || !e.geometry.attributes.ids || t.push(e));
1734
+ e instanceof N && (!e.geometry.index || !e.geometry.attributes.ids || t.push(e));
1380
1735
  }), t;
1381
1736
  }
1382
- function hn(e) {
1737
+ function Hn(e) {
1383
1738
  let t = e;
1384
1739
  for (; t;) {
1385
1740
  let e = t.userData.modelID;
@@ -1388,19 +1743,23 @@ function hn(e) {
1388
1743
  }
1389
1744
  return 0;
1390
1745
  }
1391
- function gn(e, t) {
1746
+ function Un(e, t) {
1392
1747
  return t.clone().transformDirection(e.matrixWorld).normalize();
1393
1748
  }
1394
- var _n = class {
1749
+ var Wn = class {
1395
1750
  planes = [];
1751
+ caps = [];
1396
1752
  edges = [];
1397
1753
  helpers = [];
1398
1754
  active = !1;
1755
+ capsActive = !0;
1399
1756
  context;
1400
1757
  edgesActive = !0;
1401
1758
  helperDragActive = !1;
1402
1759
  helpersActive = !0;
1403
1760
  helperHoverMoveState = "end";
1761
+ capsDragActive = !1;
1762
+ capsDragIdleTimeout = null;
1404
1763
  updateEdgesFrame = null;
1405
1764
  updateHelpersFrame = null;
1406
1765
  constructor(e) {
@@ -1415,6 +1774,9 @@ var _n = class {
1415
1774
  getEdgesActive() {
1416
1775
  return this.edgesActive;
1417
1776
  }
1777
+ getCapsActive() {
1778
+ return this.capsActive;
1779
+ }
1418
1780
  getHelpersActive() {
1419
1781
  return this.helpersActive;
1420
1782
  }
@@ -1440,7 +1802,25 @@ var _n = class {
1440
1802
  return this.context.controlRef;
1441
1803
  }
1442
1804
  getMeshes() {
1443
- return mn(this.context.modelRef.current);
1805
+ return Vn(this.context.modelRef.current);
1806
+ }
1807
+ getSelectableObjects() {
1808
+ return this.caps.map((e) => e.getSelectableObject()).filter((e) => e.visible);
1809
+ }
1810
+ getSelected() {
1811
+ return this.context.viewerStore.getState().selected;
1812
+ }
1813
+ getPreselectionColor() {
1814
+ return this.context.viewerStore.getState().preselectionColor;
1815
+ }
1816
+ getSelectionColor() {
1817
+ return this.context.viewerStore.getState().selectionColor;
1818
+ }
1819
+ setCapsPreselection(e) {
1820
+ this.caps.forEach((t) => t.setPreselection(e));
1821
+ }
1822
+ updateCapsVisualState() {
1823
+ this.caps.forEach((e) => e.updateVisualState());
1444
1824
  }
1445
1825
  getHelperHoverIsMoving() {
1446
1826
  return this.helperHoverMoveState !== "end" && this.helperHoverMoveState !== "start";
@@ -1451,6 +1831,19 @@ var _n = class {
1451
1831
  setHelperDragActive(e) {
1452
1832
  this.helperDragActive = e;
1453
1833
  }
1834
+ setCapsDragActive(e) {
1835
+ this.capsDragActive !== e && (this.clearCapsDragIdleTimeout(), this.capsDragActive = e, this.caps.forEach((t) => t.setVisible(this.active && this.capsActive && !e)), !e && this.active && this.capsActive && this.updateCaps());
1836
+ }
1837
+ requestCapsDragIdleUpdate() {
1838
+ !this.active || !this.capsActive || !this.capsDragActive || !this.caps.length || (this.clearCapsDragIdleTimeout(), this.caps.forEach((e) => e.setVisible(!1)), this.capsDragIdleTimeout = window.setTimeout(() => {
1839
+ this.capsDragIdleTimeout = null, !(!this.active || !this.capsDragActive) && (this.caps.forEach((e) => {
1840
+ e.setVisible(!0), e.update();
1841
+ }), this.updateCapsVisualState());
1842
+ }, zn));
1843
+ }
1844
+ clearCapsDragIdleTimeout() {
1845
+ this.capsDragIdleTimeout !== null && (window.clearTimeout(this.capsDragIdleTimeout), this.capsDragIdleTimeout = null);
1846
+ }
1454
1847
  clearHelpersHover(e) {
1455
1848
  this.helpers.forEach((t) => {
1456
1849
  t !== e && t.clearHover();
@@ -1474,9 +1867,9 @@ var _n = class {
1474
1867
  }), e.isEmpty() ? null : e;
1475
1868
  }
1476
1869
  getSelectedWorldBox() {
1477
- let e = this.context.viewerStore.getState().selected, t = new g(), n = new I();
1870
+ let e = this.context.viewerStore.getState().selected, t = new g(), n = new z();
1478
1871
  return this.getMeshes().forEach((r) => {
1479
- let i = e[hn(r)];
1872
+ let i = e[Hn(r)];
1480
1873
  if (!i?.size) return;
1481
1874
  let a = r.geometry.attributes.ids, o = r.geometry.attributes.position;
1482
1875
  if (!a || !o) return;
@@ -1495,11 +1888,11 @@ var _n = class {
1495
1888
  updateMaterials() {
1496
1889
  let e = this.active ? this.planes : [];
1497
1890
  this.getMeshes().forEach((t) => {
1498
- pn(t.material, e);
1891
+ Bn(t.material, e);
1499
1892
  }), this.context.camera.updateMatrixWorld();
1500
1893
  }
1501
1894
  setActive(e) {
1502
- this.active !== e && (this.active = e, this.context.renderer.localClippingEnabled = e, this.updateMaterials(), this.helpers.forEach((t) => t.setVisible(e && this.helpersActive)), this.edges.forEach((t) => t.setVisible(e && this.edgesActive)), e && this.edgesActive && this.updateEdges());
1895
+ this.active !== e && (this.active = e, this.context.renderer.localClippingEnabled = e, this.updateMaterials(), this.helpers.forEach((t) => t.setVisible(e && this.helpersActive)), this.caps.forEach((t) => t.setVisible(e && this.capsActive && !this.capsDragActive)), this.edges.forEach((t) => t.setVisible(e && this.edgesActive)), e && this.edgesActive && this.updateEdges(), e && this.capsActive && !this.capsDragActive && this.updateCaps());
1503
1896
  }
1504
1897
  toggle() {
1505
1898
  this.setActive(!this.active);
@@ -1514,42 +1907,42 @@ var _n = class {
1514
1907
  recursive: !1
1515
1908
  });
1516
1909
  if (!n?.face) return null;
1517
- let r = n.point.clone(), i = gn(n.object, n.face.normal);
1910
+ let r = n.point.clone(), i = Un(n.object, n.face.normal);
1518
1911
  r.add(i.clone().multiplyScalar(.001));
1519
- let a = new ce().setFromNormalAndCoplanarPoint(i.clone().negate(), r);
1912
+ let a = new L().setFromNormalAndCoplanarPoint(i.clone().negate(), r);
1520
1913
  return this.addPlane(a, r, i), a.clone();
1521
1914
  }
1522
1915
  createClippingRectangle(e = !1) {
1523
1916
  let t = e ? this.getSelectedWorldBox() : this.getModelWorldBox();
1524
1917
  if (!t) return [];
1525
- let n = dn(t), r = t.min.clone().addScalar(-n), i = t.max.clone().addScalar(n), a = t.getCenter(new I()), o = [
1918
+ let n = Ln(t), r = t.min.clone().addScalar(-n), i = t.max.clone().addScalar(n), a = t.getCenter(new z()), o = [
1526
1919
  {
1527
- normal: new I(1, 0, 0),
1528
- point: new I(r.x, a.y, a.z)
1920
+ normal: new z(1, 0, 0),
1921
+ point: new z(r.x, a.y, a.z)
1529
1922
  },
1530
1923
  {
1531
- normal: new I(-1, 0, 0),
1532
- point: new I(i.x, a.y, a.z)
1924
+ normal: new z(-1, 0, 0),
1925
+ point: new z(i.x, a.y, a.z)
1533
1926
  },
1534
1927
  {
1535
- normal: new I(0, 1, 0),
1536
- point: new I(a.x, r.y, a.z)
1928
+ normal: new z(0, 1, 0),
1929
+ point: new z(a.x, r.y, a.z)
1537
1930
  },
1538
1931
  {
1539
- normal: new I(0, -1, 0),
1540
- point: new I(a.x, i.y, a.z)
1932
+ normal: new z(0, -1, 0),
1933
+ point: new z(a.x, i.y, a.z)
1541
1934
  },
1542
1935
  {
1543
- normal: new I(0, 0, 1),
1544
- point: new I(a.x, a.y, r.z)
1936
+ normal: new z(0, 0, 1),
1937
+ point: new z(a.x, a.y, r.z)
1545
1938
  },
1546
1939
  {
1547
- normal: new I(0, 0, -1),
1548
- point: new I(a.x, a.y, i.z)
1940
+ normal: new z(0, 0, -1),
1941
+ point: new z(a.x, a.y, i.z)
1549
1942
  }
1550
1943
  ].map(({ normal: e, point: t }) => ({
1551
1944
  normal: e,
1552
- plane: new ce().setFromNormalAndCoplanarPoint(e, t),
1945
+ plane: new L().setFromNormalAndCoplanarPoint(e, t),
1553
1946
  point: t
1554
1947
  }));
1555
1948
  return o.forEach(({ normal: e, plane: t, point: n }) => {
@@ -1557,26 +1950,35 @@ var _n = class {
1557
1950
  }), this.updateHelpers(), o.map(({ plane: e }) => e.clone());
1558
1951
  }
1559
1952
  addPlane(e, t, n) {
1560
- if (this.active || this.setActive(!0), this.planes.push(e), new fn(this, e, t, n), this.updateHelpers(), this.updateMaterials(), this.edgesActive) {
1561
- let t = new Zt(this, e);
1953
+ if (this.active || this.setActive(!0), this.planes.push(e), new Rn(this, e, t, n), new dn(this, e).setVisible(this.active && this.capsActive && !this.capsDragActive), this.updateHelpers(), this.updateCaps(), this.updateMaterials(), this.edgesActive) {
1954
+ let t = new yn(this, e);
1562
1955
  t.create(), t.update();
1563
1956
  }
1564
1957
  }
1565
1958
  deleteAllPlanes() {
1566
- this.active = !1, this.helperDragActive = !1, this.context.renderer.localClippingEnabled = !1, this.updateEdgesFrame !== null && (cancelAnimationFrame(this.updateEdgesFrame), this.updateEdgesFrame = null), this.updateHelpersFrame !== null && (cancelAnimationFrame(this.updateHelpersFrame), this.updateHelpersFrame = null), this.helpers.forEach((e) => e.dispose()), this.edges.forEach((e) => e.dispose()), this.helpers = [], this.edges = [], this.planes = [], this.updateMaterials();
1959
+ this.active = !1, this.capsDragActive = !1, this.helperDragActive = !1, this.clearCapsDragIdleTimeout(), this.context.renderer.localClippingEnabled = !1, this.updateEdgesFrame !== null && (cancelAnimationFrame(this.updateEdgesFrame), this.updateEdgesFrame = null), this.updateHelpersFrame !== null && (cancelAnimationFrame(this.updateHelpersFrame), this.updateHelpersFrame = null), this.helpers.forEach((e) => e.dispose()), this.caps.forEach((e) => e.dispose()), this.edges.forEach((e) => e.dispose()), this.helpers = [], this.caps = [], this.edges = [], this.planes = [], this.updateMaterials();
1567
1960
  }
1568
1961
  setHelpersActive(e) {
1569
1962
  this.helpersActive !== e && (this.helpersActive = e, this.helpers.forEach((e) => e.setVisible(this.active && this.helpersActive)));
1570
1963
  }
1964
+ setCapsActive(e) {
1965
+ this.capsActive !== e && (this.capsActive = e, this.caps.forEach((t) => t.setVisible(this.active && e && !this.capsDragActive)), this.active && e && !this.capsDragActive && this.updateCaps());
1966
+ }
1571
1967
  setEdgesActive(e) {
1572
1968
  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) => {
1573
- let t = new Zt(this, e);
1969
+ let t = new yn(this, e);
1574
1970
  t.create(), t.update();
1575
1971
  })), this.edges.forEach((t) => t.setVisible(this.active && e)));
1576
1972
  }
1577
1973
  updateEdges() {
1578
1974
  this.edgesActive && this.edges.forEach((e) => e.update());
1579
1975
  }
1976
+ flushEdgesUpdate() {
1977
+ this.updateEdgesFrame !== null && (cancelAnimationFrame(this.updateEdgesFrame), this.updateEdgesFrame = null), this.updateEdges();
1978
+ }
1979
+ updateCaps() {
1980
+ this.capsActive && (this.capsDragActive || this.caps.forEach((e) => e.update()));
1981
+ }
1580
1982
  updateHelpers() {
1581
1983
  this.helpers.forEach((e) => e.updateClipping());
1582
1984
  }
@@ -1591,14 +1993,14 @@ var _n = class {
1591
1993
  }));
1592
1994
  }
1593
1995
  syncWithModel() {
1594
- this.updateMaterials(), this.edges.forEach((e) => e.syncMeshes()), this.updateHelpers(), this.updateEdges();
1996
+ this.updateMaterials(), this.caps.forEach((e) => e.syncMeshes()), this.edges.forEach((e) => e.syncMeshes()), this.updateHelpers(), this.updateCaps(), this.updateEdges();
1595
1997
  }
1596
1998
  dispose() {
1597
- this.deleteAllPlanes();
1999
+ this.clearCapsDragIdleTimeout(), this.deleteAllPlanes();
1598
2000
  }
1599
2001
  };
1600
- function vn(e, t, n) {
1601
- let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.raycaster), s = p((e) => e.scene), l = Ee(), u = c(() => new _n({
2002
+ function Gn(e, t, n) {
2003
+ let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.raycaster), s = p((e) => e.scene), l = Ee(), u = c(() => new Wn({
1602
2004
  camera: r,
1603
2005
  cameraUtils: n,
1604
2006
  controlRef: t,
@@ -1640,7 +2042,9 @@ function vn(e, t, n) {
1640
2042
  a,
1641
2043
  s,
1642
2044
  l
1643
- ]), o(() => () => u.dispose(), [u]), o(() => {
2045
+ ]), o(() => () => u.dispose(), [u]), o(() => l.subscribe((e, t) => {
2046
+ e.selected === t.selected && e.preselectionColor === t.preselectionColor && e.selectionColor === t.selectionColor || u.updateCapsVisualState();
2047
+ }), [u, l]), o(() => {
1644
2048
  let e = i.domElement, n = t.current;
1645
2049
  return e.addEventListener("pointerdown", u.setHelperHoverMoveStart), window.addEventListener("pointerup", u.setHelperHoverMoveEnd), window.addEventListener("pointercancel", u.setHelperHoverMoveEnd), n?.addEventListener("update", u.setHelperHoverMoving), () => {
1646
2050
  e.removeEventListener("pointerdown", u.setHelperHoverMoveStart), window.removeEventListener("pointerup", u.setHelperHoverMoveEnd), window.removeEventListener("pointercancel", u.setHelperHoverMoveEnd), n?.removeEventListener("update", u.setHelperHoverMoving);
@@ -1654,42 +2058,46 @@ function vn(e, t, n) {
1654
2058
  createPlane: (e) => u.createPlane(e),
1655
2059
  deleteAllPlanes: () => u.deleteAllPlanes(),
1656
2060
  getActive: () => u.getActive(),
2061
+ getCapsActive: () => u.getCapsActive(),
1657
2062
  getEdgesActive: () => u.getEdgesActive(),
1658
2063
  getHelpersActive: () => u.getHelpersActive(),
1659
2064
  getPlanes: () => u.getPlanes(),
1660
2065
  setActive: (e) => u.setActive(e),
2066
+ setCapsActive: (e) => u.setCapsActive(e),
1661
2067
  setEdgesActive: (e) => u.setEdgesActive(e),
1662
2068
  setHelpersActive: (e) => u.setHelpersActive(e),
1663
2069
  syncWithModel: () => u.syncWithModel(),
1664
2070
  toggle: () => u.toggle(),
1665
2071
  updateEdges: () => u.updateEdges(),
1666
- updateMaterials: () => u.updateMaterials()
2072
+ updateMaterials: () => u.updateMaterials(),
2073
+ getSelectableObjects: () => u.getSelectableObjects(),
2074
+ setCapsPreselection: (e) => u.setCapsPreselection(e)
1667
2075
  }), [u]);
1668
2076
  }
1669
2077
  //#endregion
1670
2078
  //#region src/viewer/utils/DimentionsUtils/DimentionLine.ts
1671
- var yn = 12, bn = 6, xn = 4;
1672
- function Sn() {
2079
+ var Kn = 12, qn = 6, Jn = 4;
2080
+ function Yn() {
1673
2081
  return typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2);
1674
2082
  }
1675
- function Cn(e, t) {
1676
- 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);
2083
+ function Xn(e, t) {
2084
+ return e instanceof ie ? (e.top - e.bottom) / e.zoom : e instanceof ae ? 2 * Math.tan(e.fov * Math.PI / 360) * Math.max(t, .001) : Math.max(t, 1);
1677
2085
  }
1678
- function wn(e) {
1679
- let t = Sn(), n = document.createElement("canvas"), r = n.getContext("2d");
2086
+ function Zn(e) {
2087
+ let t = Yn(), n = document.createElement("canvas"), r = n.getContext("2d");
1680
2088
  if (!r) throw Error("Could not create dimension label canvas context");
1681
- let i = `600 ${yn}px system-ui, "Segoe UI", sans-serif`;
2089
+ let i = `600 ${Kn}px system-ui, "Segoe UI", sans-serif`;
1682
2090
  r.font = i;
1683
- let a = r.measureText(e), o = a.actualBoundingBoxAscent || yn * .8, s = a.actualBoundingBoxDescent || yn * .2, c = Math.max(1, Math.ceil(a.width + bn * 2)), l = Math.max(1, Math.ceil(o + s + xn * 2));
2091
+ let a = r.measureText(e), o = a.actualBoundingBoxAscent || Kn * .8, s = a.actualBoundingBoxDescent || Kn * .2, c = Math.max(1, Math.ceil(a.width + qn * 2)), l = Math.max(1, Math.ceil(o + s + Jn * 2));
1684
2092
  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);
1685
2093
  let u = new b(n);
1686
- return u.colorSpace = ue, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
2094
+ return u.colorSpace = ce, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
1687
2095
  height: l,
1688
2096
  texture: u,
1689
2097
  width: c
1690
2098
  };
1691
2099
  }
1692
- var Tn = class e {
2100
+ var Qn = class e {
1693
2101
  static scale = 1;
1694
2102
  static scaleFactor = .015;
1695
2103
  static units = "m";
@@ -1719,7 +2127,7 @@ var Tn = class e {
1719
2127
  this.end.x,
1720
2128
  this.end.y,
1721
2129
  this.end.z
1722
- ], 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);
2130
+ ], 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);
1723
2131
  }
1724
2132
  get length() {
1725
2133
  return this.start.distanceTo(this.end);
@@ -1761,11 +2169,11 @@ var Tn = class e {
1761
2169
  this.addEndpointMesh(this.start, this.end), this.addEndpointMesh(this.end, this.start);
1762
2170
  }
1763
2171
  addEndpointMesh(e, t) {
1764
- let n = new M(this.endpointGeometry, this.endpointMaterial);
2172
+ let n = new N(this.endpointGeometry, this.endpointMaterial);
1765
2173
  n.position.copy(e), n.scale.copy(this.endpointBaseScale), n.lookAt(t), n.renderOrder = 4, this.endpointMeshes.push(n), this.root.add(n);
1766
2174
  }
1767
2175
  createLabelSprite() {
1768
- let e = new pe(new me({
2176
+ let e = new fe(new pe({
1769
2177
  depthTest: !1,
1770
2178
  depthWrite: !1,
1771
2179
  transparent: !0
@@ -1773,7 +2181,7 @@ var Tn = class e {
1773
2181
  return e.renderOrder = 5, e;
1774
2182
  }
1775
2183
  createBoundingBoxMesh() {
1776
- let e = new M(new _(1, 1, Math.max(this.length, .001)), this.boundingMaterial);
2184
+ let e = new N(new _(1, 1, Math.max(this.length, .001)), this.boundingMaterial);
1777
2185
  return e.renderOrder = 3, e;
1778
2186
  }
1779
2187
  getTextContent() {
@@ -1784,7 +2192,7 @@ var Tn = class e {
1784
2192
  let e = this.getTextContent();
1785
2193
  if (this.labelText === e) return;
1786
2194
  this.labelText = e, this.labelTexture?.dispose();
1787
- let t = wn(e);
2195
+ let t = Zn(e);
1788
2196
  this.labelHeight = t.height, this.labelTexture = t.texture, this.labelWidth = t.width, this.labelSprite.material.map = t.texture, this.labelSprite.material.needsUpdate = !0;
1789
2197
  }
1790
2198
  updatePositions() {
@@ -1795,37 +2203,37 @@ var Tn = class e {
1795
2203
  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)));
1796
2204
  }
1797
2205
  rescaleMesh(t, n, r) {
1798
- let i = Cn(n, t.position.distanceTo(n.position)) / Math.max(1, r) * 12 * e.scaleFactor;
2206
+ let i = Xn(n, t.position.distanceTo(n.position)) / Math.max(1, r) * 12 * e.scaleFactor;
1799
2207
  t.scale.setScalar(i);
1800
2208
  }
1801
2209
  rescaleBoundingMesh(e, t) {
1802
2210
  if (!this.boundingMesh) return;
1803
- let n = Cn(e, this.boundingMesh.position.distanceTo(e.position)) / Math.max(1, t) * 8;
2211
+ let n = Xn(e, this.boundingMesh.position.distanceTo(e.position)) / Math.max(1, t) * 8;
1804
2212
  this.boundingMesh.scale.set(n, n, 1);
1805
2213
  }
1806
2214
  rescaleLabel(e, t) {
1807
- let n = Cn(e, this.labelSprite.position.distanceTo(e.position)), r = this.labelHeight / Math.max(1, t) * n, i = r * (this.labelWidth / this.labelHeight);
2215
+ let n = Xn(e, this.labelSprite.position.distanceTo(e.position)), r = this.labelHeight / Math.max(1, t) * n, i = r * (this.labelWidth / this.labelHeight);
1808
2216
  this.labelSprite.scale.set(i, r, 1);
1809
2217
  }
1810
- }, En = "#111827", Dn = 1, On = "x";
1811
- function kn(e) {
2218
+ }, $n = "#111827", er = 1, tr = "x";
2219
+ function nr(e) {
1812
2220
  let t = [];
1813
2221
  return e?.traverse((e) => {
1814
- e instanceof M && e.geometry.attributes.position && t.push(e);
2222
+ e instanceof N && e.geometry.attributes.position && t.push(e);
1815
2223
  }), t;
1816
2224
  }
1817
- function An(e, t, n) {
2225
+ function rr(e, t, n) {
1818
2226
  let r = e.clone();
1819
2227
  return r[n] = t[n], r;
1820
2228
  }
1821
- function jn(e, t) {
2229
+ function ir(e, t) {
1822
2230
  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);
1823
2231
  return a === n ? "x" : a === r ? "y" : "z";
1824
2232
  }
1825
- var Mn = class e {
2233
+ var ar = class e {
1826
2234
  active = !1;
1827
2235
  axis = null;
1828
- boundingMaterial = new N({
2236
+ boundingMaterial = new P({
1829
2237
  color: 0,
1830
2238
  depthTest: !1,
1831
2239
  depthWrite: !1,
@@ -1836,14 +2244,14 @@ var Mn = class e {
1836
2244
  currentDimension = null;
1837
2245
  dimensions = [];
1838
2246
  endpointGeometry = e.createEndpointGeometry();
1839
- endpointMaterial = new N({
1840
- color: En,
2247
+ endpointMaterial = new P({
2248
+ color: $n,
1841
2249
  depthTest: !1,
1842
2250
  depthWrite: !1
1843
2251
  });
1844
- endpointScale = new I(1, 1, 1);
1845
- lineMaterial = new O({
1846
- color: En,
2252
+ endpointScale = new z(1, 1, 1);
2253
+ lineMaterial = new k({
2254
+ color: $n,
1847
2255
  dashSize: .2,
1848
2256
  depthTest: !1,
1849
2257
  depthWrite: !1,
@@ -1851,14 +2259,14 @@ var Mn = class e {
1851
2259
  });
1852
2260
  measureInProcess = !1;
1853
2261
  moveState = "end";
1854
- previewMarker = new M(e.createPreviewGeometry(), new N({
2262
+ previewMarker = new N(e.createPreviewGeometry(), new P({
1855
2263
  color: 0,
1856
2264
  depthTest: !1,
1857
2265
  depthWrite: !1
1858
2266
  }));
1859
2267
  root = new D();
1860
- snapDistance = Dn;
1861
- startPoint = new I();
2268
+ snapDistance = er;
2269
+ startPoint = new z();
1862
2270
  unit = "m";
1863
2271
  constructor(e) {
1864
2272
  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);
@@ -1891,13 +2299,13 @@ var Mn = class e {
1891
2299
  });
1892
2300
  }
1893
2301
  setEndpointScaleFactor(e) {
1894
- !Number.isFinite(e) || e <= 0 || (Tn.scaleFactor = e);
2302
+ !Number.isFinite(e) || e <= 0 || (Qn.scaleFactor = e);
1895
2303
  }
1896
2304
  setSnapDistance(e) {
1897
2305
  !Number.isFinite(e) || e < 0 || (this.snapDistance = e);
1898
2306
  }
1899
2307
  setUnit(e) {
1900
- this.unit = e, Tn.units = e, Tn.scale = e === "mm" ? 1e3 : 1, this.dimensions.forEach((e) => {
2308
+ this.unit = e, Qn.units = e, Qn.scale = e === "mm" ? 1e3 : 1, this.dimensions.forEach((e) => {
1901
2309
  e.endPoint = e.end;
1902
2310
  }), this.currentDimension && (this.currentDimension.endPoint = this.currentDimension.end);
1903
2311
  }
@@ -1923,7 +2331,7 @@ var Mn = class e {
1923
2331
  changeAxes() {
1924
2332
  if (!this.measureInProcess || !this.currentDimension) return;
1925
2333
  let e = this.currentDimension.end, t = this.getNextAxis();
1926
- this.axis = t, this.currentDimension.endPoint = An(this.startPoint, e, t);
2334
+ this.axis = t, this.currentDimension.endPoint = rr(this.startPoint, e, t);
1927
2335
  }
1928
2336
  updateFrame() {
1929
2337
  if (!this.active) return;
@@ -1967,7 +2375,7 @@ var Mn = class e {
1967
2375
  this.currentDimension && (this.currentDimension.createBoundingBox(), this.dimensions.push(this.currentDimension), this.currentDimension = null, this.measureInProcess = !1, this.axis = null);
1968
2376
  }
1969
2377
  createDimension(e, t) {
1970
- return new Tn({
2378
+ return new Qn({
1971
2379
  boundingMaterial: this.boundingMaterial,
1972
2380
  endpointGeometry: this.endpointGeometry,
1973
2381
  endpointMaterial: this.endpointMaterial,
@@ -1978,8 +2386,14 @@ var Mn = class e {
1978
2386
  end: t
1979
2387
  });
1980
2388
  }
2389
+ getSnapObjects() {
2390
+ let e = nr(this.context.modelRef.current);
2391
+ return this.context.getExtraSnapObjects?.().forEach((t) => {
2392
+ t.visible && e.push(t);
2393
+ }), e;
2394
+ }
1981
2395
  getModelHit(e) {
1982
- let t = kn(this.context.modelRef.current);
2396
+ let t = this.getSnapObjects();
1983
2397
  return t.length ? this.context.cameraUtils.getIntersection(!0, {
1984
2398
  event: e,
1985
2399
  filter: (e) => !!e.face,
@@ -1991,7 +2405,7 @@ var Mn = class e {
1991
2405
  return this.dimensions.map((e) => e.boundingBox).filter((e) => !!e);
1992
2406
  }
1993
2407
  getClosestVertex(e) {
1994
- if (!(e.object instanceof M) || !e.face) return e.point.clone();
2408
+ if (!(e.object instanceof N) || !e.face) return e.point.clone();
1995
2409
  let t = e.object.geometry.attributes.position;
1996
2410
  if (!t) return e.point.clone();
1997
2411
  let n = [
@@ -1999,29 +2413,29 @@ var Mn = class e {
1999
2413
  e.face.b,
2000
2414
  e.face.c
2001
2415
  ].map((n) => {
2002
- let r = new I(t.getX(n), t.getY(n), t.getZ(n));
2416
+ let r = new z(t.getX(n), t.getY(n), t.getZ(n));
2003
2417
  return e.object.localToWorld(r);
2004
2418
  }).filter((t) => t.distanceTo(e.point) <= this.snapDistance);
2005
2419
  return n.length ? n.reduce((t, n) => n.distanceTo(e.point) < t.distanceTo(e.point) ? n : t) : e.point.clone();
2006
2420
  }
2007
2421
  getPreviewEndPoint(e, t) {
2008
2422
  if (!t) return this.axis = null, e.clone();
2009
- let n = this.axis ?? jn(this.startPoint, e);
2010
- return this.axis = n, An(this.startPoint, e, n);
2423
+ let n = this.axis ?? ir(this.startPoint, e);
2424
+ return this.axis = n, rr(this.startPoint, e, n);
2011
2425
  }
2012
2426
  getNextAxis() {
2013
2427
  switch (this.axis) {
2014
2428
  case "x": return "y";
2015
2429
  case "y": return "z";
2016
2430
  case "z": return "x";
2017
- default: return On;
2431
+ default: return tr;
2018
2432
  }
2019
2433
  }
2020
2434
  getIsMoving() {
2021
2435
  return this.moveState !== "end" && this.moveState !== "start";
2022
2436
  }
2023
2437
  rescalePreviewMarker() {
2024
- 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;
2438
+ let { camera: e, viewportHeight: t } = this.context, n = this.previewMarker.position.distanceTo(e.position), r = e instanceof ae ? 2 * Math.tan(e.fov * Math.PI / 360) * Math.max(n, .001) * 6.667 / Math.max(1, t) : .08;
2025
2439
  this.previewMarker.scale.setScalar(r);
2026
2440
  }
2027
2441
  setSelectionInteractionDisabled(e) {
@@ -2058,81 +2472,86 @@ var Mn = class e {
2058
2472
  return n.translate(0, -e / 2, 0), n.rotateX(-Math.PI / 2), n;
2059
2473
  }
2060
2474
  static createPreviewGeometry() {
2061
- return new fe(.5, 16, 12);
2475
+ return new de(.5, 16, 12);
2062
2476
  }
2063
2477
  };
2064
- function Nn(e, t, n) {
2065
- let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.scene), s = p((e) => e.size), l = Ee(), u = c(() => new Mn({
2066
- camera: r,
2478
+ function or(e, t, n, r) {
2479
+ let i = p((e) => e.camera), a = p((e) => e.gl), s = p((e) => e.scene), l = p((e) => e.size), u = Ee(), d = c(() => new ar({
2480
+ camera: i,
2067
2481
  cameraUtils: n,
2068
2482
  controlRef: t,
2069
- domElement: i.domElement,
2483
+ domElement: a.domElement,
2484
+ getExtraSnapObjects: r,
2070
2485
  modelRef: e,
2071
- scene: a,
2072
- viewerStore: l,
2073
- viewportHeight: s.height
2486
+ scene: s,
2487
+ viewerStore: u,
2488
+ viewportHeight: l.height
2074
2489
  }), [
2075
- r,
2490
+ i,
2076
2491
  n,
2077
2492
  t,
2078
- i,
2079
- e,
2493
+ r,
2080
2494
  a,
2081
- l
2495
+ e,
2496
+ s,
2497
+ l.height,
2498
+ u
2082
2499
  ]);
2083
2500
  return o(() => {
2084
- u.setContext({
2085
- camera: r,
2501
+ d.setContext({
2502
+ camera: i,
2086
2503
  cameraUtils: n,
2087
2504
  controlRef: t,
2088
- domElement: i.domElement,
2505
+ domElement: a.domElement,
2506
+ getExtraSnapObjects: r,
2089
2507
  modelRef: e,
2090
- scene: a,
2091
- viewerStore: l,
2092
- viewportHeight: s.height
2508
+ scene: s,
2509
+ viewerStore: u,
2510
+ viewportHeight: l.height
2093
2511
  });
2094
2512
  }, [
2095
- r,
2513
+ i,
2096
2514
  n,
2097
2515
  t,
2098
- u,
2099
- i,
2100
- e,
2516
+ d,
2517
+ r,
2101
2518
  a,
2102
- s.height,
2103
- l
2104
- ]), o(() => () => u.dispose(), [u]), f(() => {
2105
- u.updateFrame();
2519
+ e,
2520
+ s,
2521
+ l.height,
2522
+ u
2523
+ ]), o(() => () => d.dispose(), [d]), f(() => {
2524
+ d.updateFrame();
2106
2525
  }), c(() => ({
2107
- cancelDrawing: () => u.cancelDrawing(),
2108
- changeAxes: () => u.changeAxes(),
2109
- delete: () => u.delete(),
2110
- deleteAll: () => u.deleteAll(),
2111
- getActive: () => u.getActive(),
2112
- getDimensions: () => u.getDimensions(),
2113
- getSnapDistance: () => u.getSnapDistance(),
2114
- getUnit: () => u.getUnit(),
2115
- setActive: (e) => u.setActive(e),
2116
- setColor: (e) => u.setColor(e),
2117
- setEndpointScaleFactor: (e) => u.setEndpointScaleFactor(e),
2118
- setSnapDistance: (e) => u.setSnapDistance(e),
2119
- setUnit: (e) => u.setUnit(e),
2120
- setWidth: (e) => u.setWidth(e),
2121
- syncWithModel: () => u.syncWithModel(),
2122
- toggle: () => u.toggle()
2123
- }), [u]);
2526
+ cancelDrawing: () => d.cancelDrawing(),
2527
+ changeAxes: () => d.changeAxes(),
2528
+ delete: () => d.delete(),
2529
+ deleteAll: () => d.deleteAll(),
2530
+ getActive: () => d.getActive(),
2531
+ getDimensions: () => d.getDimensions(),
2532
+ getSnapDistance: () => d.getSnapDistance(),
2533
+ getUnit: () => d.getUnit(),
2534
+ setActive: (e) => d.setActive(e),
2535
+ setColor: (e) => d.setColor(e),
2536
+ setEndpointScaleFactor: (e) => d.setEndpointScaleFactor(e),
2537
+ setSnapDistance: (e) => d.setSnapDistance(e),
2538
+ setUnit: (e) => d.setUnit(e),
2539
+ setWidth: (e) => d.setWidth(e),
2540
+ syncWithModel: () => d.syncWithModel(),
2541
+ toggle: () => d.toggle()
2542
+ }), [d]);
2124
2543
  }
2125
2544
  //#endregion
2126
2545
  //#region src/viewer/utils/Hotkeys/useHotkeysUtils.tsx
2127
- function Pn(e) {
2546
+ function sr(e) {
2128
2547
  return e instanceof HTMLElement ? e.isContentEditable || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement : !1;
2129
2548
  }
2130
- function Fn() {
2131
- let e = z((e) => e.api), t = z((e) => e.defaultHotkeysEnabled);
2549
+ function cr() {
2550
+ let e = H((e) => e.api), t = H((e) => e.defaultHotkeysEnabled);
2132
2551
  o(() => {
2133
2552
  if (!t) return;
2134
2553
  let n = (t) => {
2135
- Pn(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());
2554
+ sr(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());
2136
2555
  };
2137
2556
  return window.addEventListener("keydown", n), () => {
2138
2557
  window.removeEventListener("keydown", n);
@@ -2141,15 +2560,15 @@ function Fn() {
2141
2560
  }
2142
2561
  //#endregion
2143
2562
  //#region src/viewer/Camera/useCameraUtils.ts
2144
- var In = 1e-6;
2145
- function Ln(e, t) {
2563
+ var lr = 1e-6;
2564
+ function ur(e, t) {
2146
2565
  let n = t.getBoundingClientRect();
2147
- 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);
2566
+ 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 R((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
2148
2567
  }
2149
- function Rn(e, t) {
2150
- return t.every((t) => t.distanceToPoint(e) >= -In);
2568
+ function dr(e, t) {
2569
+ return t.every((t) => t.distanceToPoint(e) >= -lr);
2151
2570
  }
2152
- function zn(e) {
2571
+ function fr(e) {
2153
2572
  let t = e;
2154
2573
  for (; t;) {
2155
2574
  if (!t.visible) return !1;
@@ -2157,8 +2576,8 @@ function zn(e) {
2157
2576
  }
2158
2577
  return !0;
2159
2578
  }
2160
- function Bn(e) {
2161
- 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) => {
2579
+ function pr(e) {
2580
+ 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 R()), d = i((e) => {
2162
2581
  a.current = e;
2163
2582
  }, []), f = i(() => {
2164
2583
  let e = a.current;
@@ -2166,7 +2585,7 @@ function Bn(e) {
2166
2585
  }, []);
2167
2586
  o(() => {
2168
2587
  let e = n.domElement, t = (t) => {
2169
- let n = Ln(t, e);
2588
+ let n = ur(t, e);
2170
2589
  n && (s.current = n);
2171
2590
  }, r = () => {
2172
2591
  s.current = null;
@@ -2176,11 +2595,11 @@ function Bn(e) {
2176
2595
  };
2177
2596
  }, [n]);
2178
2597
  let m = i((i = !1, { event: a, filter: o, object: c = e.current, recursive: l = !0, respectClipping: d = !0 } = {}) => {
2179
- let p = a ? Ln(a, n.domElement) : s.current;
2598
+ let p = a ? ur(a, n.domElement) : s.current;
2180
2599
  if (!p || !c) return i ? null : [];
2181
2600
  let m = d ? f() : [], h = Array.isArray(c) ? c : [c];
2182
2601
  t.updateMatrixWorld(), e.current?.updateMatrixWorld(!0), u.current.copy(p), r.setFromCamera(u.current, t);
2183
- let g = r.intersectObjects(h, l).filter((e) => zn(e.object) ? m.length ? Rn(e.point, m) : !0 : !1).filter((e) => o ? o(e) : !0);
2602
+ let g = r.intersectObjects(h, l).filter((e) => fr(e.object) ? m.length ? dr(e.point, m) : !0 : !1).filter((e) => o ? o(e) : !0);
2184
2603
  return i ? g[0] ?? null : g;
2185
2604
  }, [
2186
2605
  t,
@@ -2201,8 +2620,8 @@ function Bn(e) {
2201
2620
  }
2202
2621
  //#endregion
2203
2622
  //#region src/viewer/Selector/SelectionBox.ts
2204
- var Vn = new I(), Hn = new I(), G = new F(), Un = new I(), Wn = new I(), Gn = new I(), Kn = new I(), qn = new I(), Jn = new I(), Yn = new I();
2205
- function Xn(e) {
2623
+ var mr = new z(), hr = new z(), q = new R(), gr = new z(), _r = new z(), vr = new z(), yr = new z(), br = new z(), xr = new z(), Sr = new z();
2624
+ function Cr(e) {
2206
2625
  let t = e;
2207
2626
  for (; t;) {
2208
2627
  let e = t.modelID ?? t.userData.modelID;
@@ -2211,7 +2630,7 @@ function Xn(e) {
2211
2630
  }
2212
2631
  return 0;
2213
2632
  }
2214
- function Zn(e) {
2633
+ function wr(e) {
2215
2634
  let t = e;
2216
2635
  for (; t;) {
2217
2636
  if (!t.visible) return !1;
@@ -2219,16 +2638,16 @@ function Zn(e) {
2219
2638
  }
2220
2639
  return !0;
2221
2640
  }
2222
- function Qn(e, t, n) {
2223
- return n.length ? (Un.copy(t).applyMatrix4(e.matrixWorld), Rn(Un, n)) : !0;
2641
+ function Tr(e, t, n) {
2642
+ return n.length ? (gr.copy(t).applyMatrix4(e.matrixWorld), dr(gr, n)) : !0;
2224
2643
  }
2225
- function $n(e, t, n, r, i) {
2226
- return i.length ? (Wn.copy(t).applyMatrix4(e.matrixWorld), Gn.copy(n).applyMatrix4(e.matrixWorld), Kn.copy(r).applyMatrix4(e.matrixWorld), i.every((e) => {
2227
- let t = e.distanceToPoint(Wn), n = e.distanceToPoint(Gn), r = e.distanceToPoint(Kn);
2644
+ function Er(e, t, n, r, i) {
2645
+ return i.length ? (_r.copy(t).applyMatrix4(e.matrixWorld), vr.copy(n).applyMatrix4(e.matrixWorld), yr.copy(r).applyMatrix4(e.matrixWorld), i.every((e) => {
2646
+ let t = e.distanceToPoint(_r), n = e.distanceToPoint(vr), r = e.distanceToPoint(yr);
2228
2647
  return !(t < -1e-6 && n < -1e-6 && r < -1e-6);
2229
2648
  })) : !0;
2230
2649
  }
2231
- function er(e) {
2650
+ function Dr(e) {
2232
2651
  let t = e.getBoundingClientRect();
2233
2652
  return {
2234
2653
  height: t.height,
@@ -2237,7 +2656,7 @@ function er(e) {
2237
2656
  width: t.width
2238
2657
  };
2239
2658
  }
2240
- function tr(e) {
2659
+ function Or(e) {
2241
2660
  return {
2242
2661
  boundsCheckMs: 0,
2243
2662
  candidateIds: 0,
@@ -2263,7 +2682,7 @@ function tr(e) {
2263
2682
  triangleProjectionMs: 0
2264
2683
  };
2265
2684
  }
2266
- function nr(e, t) {
2685
+ function kr(e, t) {
2267
2686
  return {
2268
2687
  minX: Math.min(e.x, t.x),
2269
2688
  minY: Math.min(e.y, t.y),
@@ -2271,43 +2690,43 @@ function nr(e, t) {
2271
2690
  maxY: Math.max(e.y, t.y)
2272
2691
  };
2273
2692
  }
2274
- function rr(e, t) {
2693
+ function Ar(e, t) {
2275
2694
  return t.x >= e.x ? "contains" : "intersects";
2276
2695
  }
2277
- function ir(e, t) {
2278
- return ar(e.x, e.y, t);
2696
+ function jr(e, t) {
2697
+ return Mr(e.x, e.y, t);
2279
2698
  }
2280
- function ar(e, t, n) {
2699
+ function Mr(e, t, n) {
2281
2700
  return e >= n.minX && e <= n.maxX && t >= n.minY && t <= n.maxY;
2282
2701
  }
2283
- function or(e, t, n, r, i, a) {
2702
+ function Nr(e, t, n, r, i, a) {
2284
2703
  return (a - t) * (n - e) > (r - t) * (i - e);
2285
2704
  }
2286
- function sr(e, t, n, r, i, a, o, s) {
2287
- return or(e, t, i, a, o, s) !== or(n, r, i, a, o, s) && or(e, t, n, r, i, a) !== or(e, t, n, r, o, s);
2705
+ function Pr(e, t, n, r, i, a, o, s) {
2706
+ return Nr(e, t, i, a, o, s) !== Nr(n, r, i, a, o, s) && Nr(e, t, n, r, i, a) !== Nr(e, t, n, r, o, s);
2288
2707
  }
2289
- function cr(e, t, n, r, i) {
2708
+ function Fr(e, t, n, r, i) {
2290
2709
  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;
2291
2710
  return s >= 0 && c >= 0 && s + c <= 2 * a * o;
2292
2711
  }
2293
- function lr(e, t, n, r) {
2294
- return ir(e, r) || ir(t, r) || ir(n, r) || cr(r.minX, r.minY, e, t, n) || cr(r.maxX, r.minY, e, t, n) || cr(r.maxX, r.maxY, e, t, n) || cr(r.minX, r.maxY, e, t, n) ? !0 : ur(e, t, r) || ur(t, n, r) || ur(n, e, r);
2712
+ function Ir(e, t, n, r) {
2713
+ return jr(e, r) || jr(t, r) || jr(n, r) || Fr(r.minX, r.minY, e, t, n) || Fr(r.maxX, r.minY, e, t, n) || Fr(r.maxX, r.maxY, e, t, n) || Fr(r.minX, r.maxY, e, t, n) ? !0 : Lr(e, t, r) || Lr(t, n, r) || Lr(n, e, r);
2295
2714
  }
2296
- function ur(e, t, n) {
2297
- return sr(e.x, e.y, t.x, t.y, n.minX, n.minY, n.maxX, n.minY) || sr(e.x, e.y, t.x, t.y, n.maxX, n.minY, n.maxX, n.maxY) || sr(e.x, e.y, t.x, t.y, n.maxX, n.maxY, n.minX, n.maxY) || sr(e.x, e.y, t.x, t.y, n.minX, n.maxY, n.minX, n.minY);
2715
+ function Lr(e, t, n) {
2716
+ return Pr(e.x, e.y, t.x, t.y, n.minX, n.minY, n.maxX, n.minY) || Pr(e.x, e.y, t.x, t.y, n.maxX, n.minY, n.maxX, n.maxY) || Pr(e.x, e.y, t.x, t.y, n.maxX, n.maxY, n.minX, n.maxY) || Pr(e.x, e.y, t.x, t.y, n.minX, n.maxY, n.minX, n.minY);
2298
2717
  }
2299
- function dr(e, t, n, r, i = new F()) {
2300
- let a = Vn.copy(t).applyMatrix4(e.matrixWorld).project(n);
2718
+ function Rr(e, t, n, r, i = new R()) {
2719
+ let a = mr.copy(t).applyMatrix4(e.matrixWorld).project(n);
2301
2720
  return i.set((a.x + 1) / 2 * r.width + r.left, (-a.y + 1) / 2 * r.height + r.top);
2302
2721
  }
2303
- function fr(e, t, n, r, i) {
2722
+ function zr(e, t, n, r, i) {
2304
2723
  let a = Infinity, o = -Infinity, s = Infinity, c = -Infinity, l = 0;
2305
- for (let u = 0; u < 2; u++) for (let d = 0; d < 2; d++) for (let f = 0; f < 2; f++) Hn.set(u ? t.max.x : t.min.x, d ? t.max.y : t.min.y, f ? t.max.z : t.min.z), dr(e, Hn, r, i, G), a = Math.min(a, G.x), o = Math.max(o, G.x), s = Math.min(s, G.y), c = Math.max(c, G.y), ir(G, n) && (l += 1);
2724
+ for (let u = 0; u < 2; u++) for (let d = 0; d < 2; d++) for (let f = 0; f < 2; f++) hr.set(u ? t.max.x : t.min.x, d ? t.max.y : t.min.y, f ? t.max.z : t.min.z), Rr(e, hr, r, i, q), a = Math.min(a, q.x), o = Math.max(o, q.x), s = Math.min(s, q.y), c = Math.max(c, q.y), jr(q, n) && (l += 1);
2306
2725
  return o < n.minX || a > n.maxX || c < n.minY || s > n.maxY ? xe : l === 8 ? ve : ye;
2307
2726
  }
2308
- function pr(e, t, n, r) {
2727
+ function Br(e, t, n, r) {
2309
2728
  let i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
2310
- for (let c = 0; c < 2; c++) for (let l = 0; l < 2; l++) for (let u = 0; u < 2; u++) Hn.set(c ? t.max.x : t.min.x, l ? t.max.y : t.min.y, u ? t.max.z : t.min.z), dr(e, Hn, n, r, G), i = Math.min(i, G.x), a = Math.max(a, G.x), o = Math.min(o, G.y), s = Math.max(s, G.y);
2729
+ for (let c = 0; c < 2; c++) for (let l = 0; l < 2; l++) for (let u = 0; u < 2; u++) hr.set(c ? t.max.x : t.min.x, l ? t.max.y : t.min.y, u ? t.max.z : t.min.z), Rr(e, hr, n, r, q), i = Math.min(i, q.x), a = Math.max(a, q.x), o = Math.min(o, q.y), s = Math.max(s, q.y);
2311
2730
  return {
2312
2731
  minX: i,
2313
2732
  minY: o,
@@ -2315,41 +2734,41 @@ function pr(e, t, n, r) {
2315
2734
  maxY: s
2316
2735
  };
2317
2736
  }
2318
- function mr(e, t) {
2737
+ function Vr(e, t) {
2319
2738
  return !(e.maxX < t.minX || e.minX > t.maxX || e.maxY < t.minY || e.minY > t.maxY);
2320
2739
  }
2321
- function hr(e, t, n, r) {
2740
+ function Hr(e, t, n, r) {
2322
2741
  e.geometry.boundingBox || e.geometry.computeBoundingBox();
2323
2742
  let i = e.geometry.boundingBox;
2324
- return i ? mr(pr(e, i, n, r), t) : !0;
2743
+ return i ? Vr(Br(e, i, n, r), t) : !0;
2325
2744
  }
2326
- function gr(e, t, n) {
2745
+ function Ur(e, t, n) {
2327
2746
  let r = e.get(t);
2328
2747
  r || (r = /* @__PURE__ */ new Set(), e.set(t, r)), r.add(n);
2329
2748
  }
2330
- function _r(e) {
2749
+ function Wr(e) {
2331
2750
  let t = 0;
2332
2751
  return e.forEach((e) => {
2333
2752
  t += e.size;
2334
2753
  }), t;
2335
2754
  }
2336
- function vr(e, t, n, r = []) {
2755
+ function Gr(e, t, n, r = []) {
2337
2756
  let i = e.geometry, a = i.index, o = i.attributes.ids, s = i.attributes.position;
2338
2757
  if (!a || !o || !s) return;
2339
2758
  let c = t * 3;
2340
- r.length && (qn.fromBufferAttribute(s, a.getX(c)), Jn.fromBufferAttribute(s, a.getX(c + 1)), Yn.fromBufferAttribute(s, a.getX(c + 2)), !$n(e, qn, Jn, Yn, r)) || gr(n, Xn(e), o.getX(a.getX(c)));
2759
+ r.length && (br.fromBufferAttribute(s, a.getX(c)), xr.fromBufferAttribute(s, a.getX(c + 1)), Sr.fromBufferAttribute(s, a.getX(c + 2)), !Er(e, br, xr, Sr, r)) || Ur(n, Cr(e), o.getX(a.getX(c)));
2341
2760
  }
2342
- function yr({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i, clippingPlanes: a, profile: o }) {
2343
- let s = performance.now(), c = /* @__PURE__ */ new Map(), l = new I();
2761
+ function Kr({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i, clippingPlanes: a, profile: o }) {
2762
+ let s = performance.now(), c = /* @__PURE__ */ new Map(), l = new z();
2344
2763
  e.traverse((e) => {
2345
2764
  let s = e;
2346
- if (!s.isMesh || !Zn(s)) return;
2765
+ if (!s.isMesh || !wr(s)) return;
2347
2766
  let u = s.geometry.attributes.ids, d = s.geometry.attributes.position;
2348
2767
  if (!(!u || !d)) {
2349
2768
  o && (o.containedVerticesVisited += u.count);
2350
2769
  for (let e = 0; e < u.count; e++) {
2351
- let f = Xn(s), p = u.getX(e);
2352
- if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !Qn(s, l, a))) continue;
2770
+ let f = Cr(s), p = u.getX(e);
2771
+ if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !Tr(s, l, a))) continue;
2353
2772
  o && (o.containedCandidateVertices += 1);
2354
2773
  let m = `${f}:${p}`, h = c.get(m);
2355
2774
  h || (h = {
@@ -2357,23 +2776,23 @@ function yr({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i,
2357
2776
  inside: 0,
2358
2777
  modelID: f,
2359
2778
  total: 0
2360
- }, c.set(m, h)), h.total += 1, ir(dr(s, l, t, n), r) && (h.inside += 1);
2779
+ }, c.set(m, h)), h.total += 1, jr(Rr(s, l, t, n), r) && (h.inside += 1);
2361
2780
  }
2362
2781
  }
2363
2782
  });
2364
2783
  let u = /* @__PURE__ */ new Map();
2365
2784
  return c.forEach((e) => {
2366
- e.total > 0 && e.total === e.inside && gr(u, e.modelID, e.id);
2785
+ e.total > 0 && e.total === e.inside && Ur(u, e.modelID, e.id);
2367
2786
  }), o && (o.containedIdsMs += performance.now() - s), u;
2368
2787
  }
2369
- function br({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect: i, mode: a, profile: o }) {
2788
+ function qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect: i, mode: a, profile: o }) {
2370
2789
  let s = performance.now(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
2371
2790
  if (!e) return c;
2372
- let u = er(r), d = performance.now();
2791
+ let u = Dr(r), d = performance.now();
2373
2792
  e.updateMatrixWorld(!0), t.updateMatrixWorld(), o && (o.matrixUpdateMs += performance.now() - d), e.traverse((e) => {
2374
2793
  let r = e;
2375
2794
  if (!r.isMesh) return;
2376
- if (o && (o.meshCount += 1), !Zn(r)) {
2795
+ if (o && (o.meshCount += 1), !wr(r)) {
2377
2796
  o && (o.skippedMeshCount += 1);
2378
2797
  return;
2379
2798
  }
@@ -2382,7 +2801,7 @@ function br({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
2382
2801
  o && (o.skippedMeshCount += 1);
2383
2802
  return;
2384
2803
  }
2385
- let d = performance.now(), f = hr(r, i, t, u);
2804
+ let d = performance.now(), f = Hr(r, i, t, u);
2386
2805
  if (o && (o.boundsCheckMs += performance.now() - d), !f) {
2387
2806
  o && (o.skippedMeshCount += 1);
2388
2807
  return;
@@ -2390,26 +2809,26 @@ function br({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
2390
2809
  let p = performance.now();
2391
2810
  s.shapecast({
2392
2811
  intersectsBounds: (e) => {
2393
- let n = performance.now(), a = fr(r, e, i, t, u);
2812
+ let n = performance.now(), a = zr(r, e, i, t, u);
2394
2813
  return o && (o.intersectsBoundsCalls += 1, o.intersectsBoundsMs += performance.now() - n), a;
2395
2814
  },
2396
2815
  intersectsRange: (e, t, i) => {
2397
2816
  let u = performance.now();
2398
2817
  if (o && (o.intersectsRangeCalls += 1), !i) return o && (o.intersectsRangeMs += performance.now() - u), !1;
2399
- for (let i = e; i < e + t; i++) vr(r, s.resolveTriangleIndex(i), a === "contains" ? l : c, n);
2818
+ for (let i = e; i < e + t; i++) Gr(r, s.resolveTriangleIndex(i), a === "contains" ? l : c, n);
2400
2819
  return o && (o.intersectsRangeMs += performance.now() - u), !1;
2401
2820
  },
2402
2821
  intersectsTriangle: (e, s, d) => {
2403
2822
  let f = performance.now();
2404
2823
  if (o && (o.intersectsTriangleCalls += 1), !d) {
2405
- let n = performance.now(), a = dr(r, e.a, t, u), s = dr(r, e.b, t, u), c = dr(r, e.c, t, u);
2406
- if (o && (o.triangleProjectionMs += performance.now() - n), !lr(a, s, c, i)) return o && (o.intersectsTriangleMs += performance.now() - f), !1;
2824
+ let n = performance.now(), a = Rr(r, e.a, t, u), s = Rr(r, e.b, t, u), c = Rr(r, e.c, t, u);
2825
+ if (o && (o.triangleProjectionMs += performance.now() - n), !Ir(a, s, c, i)) return o && (o.intersectsTriangleMs += performance.now() - f), !1;
2407
2826
  }
2408
- return a === "contains" ? vr(r, s, l, n) : vr(r, s, c, n), o && (o.intersectsTriangleMs += performance.now() - f), !1;
2827
+ return a === "contains" ? Gr(r, s, l, n) : Gr(r, s, c, n), o && (o.intersectsTriangleMs += performance.now() - f), !1;
2409
2828
  }
2410
2829
  }), o && (o.shapecastMs += performance.now() - p);
2411
2830
  });
2412
- let f = a === "contains" ? yr({
2831
+ let f = a === "contains" ? Kr({
2413
2832
  model: e,
2414
2833
  camera: t,
2415
2834
  clippingPlanes: n,
@@ -2418,19 +2837,19 @@ function br({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
2418
2837
  candidateIdsByModel: l,
2419
2838
  profile: o
2420
2839
  }) : c;
2421
- return o && (o.candidateIds = _r(l), o.selectedIds = _r(f), o.totalMs = performance.now() - s), f;
2840
+ return o && (o.candidateIds = Wr(l), o.selectedIds = Wr(f), o.totalMs = performance.now() - s), f;
2422
2841
  }
2423
- function xr(e) {
2424
- let t = tr(e.mode);
2842
+ function Jr(e) {
2843
+ let t = Or(e.mode);
2425
2844
  return {
2426
- ids: br({
2845
+ ids: qr({
2427
2846
  ...e,
2428
2847
  profile: t
2429
2848
  }),
2430
2849
  profile: t
2431
2850
  };
2432
2851
  }
2433
- function Sr(e) {
2852
+ function Yr(e) {
2434
2853
  return e === "contains" ? {
2435
2854
  border: "rgb(37, 99, 235)",
2436
2855
  background: "rgba(37, 99, 235, 0.16)"
@@ -2439,32 +2858,32 @@ function Sr(e) {
2439
2858
  background: "rgba(22, 163, 74, 0.16)"
2440
2859
  };
2441
2860
  }
2442
- function Cr(e, t, n) {
2443
- let r = Sr(rr(t, n));
2861
+ function Xr(e, t, n) {
2862
+ let r = Yr(Ar(t, n));
2444
2863
  if (!e.current) {
2445
2864
  let t = document.createElement("div");
2446
2865
  t.style.position = "fixed", t.style.pointerEvents = "none", t.style.zIndex = "10", e.current = t, document.body.appendChild(t);
2447
2866
  }
2448
- let i = nr(t, n);
2867
+ let i = kr(t, n);
2449
2868
  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`;
2450
2869
  }
2451
- function wr(e) {
2870
+ function Zr(e) {
2452
2871
  e.current?.remove(), e.current = null;
2453
2872
  }
2454
2873
  //#endregion
2455
2874
  //#region src/viewer/Selector/useSelector.tsx
2456
- var Tr = 40;
2457
- function Er(e) {
2875
+ var Qr = 40;
2876
+ function $r(e) {
2458
2877
  if (!Array.isArray(e)) return e.userData.shader;
2459
2878
  }
2460
- function Dr(e, t) {
2461
- let n = Er(e)?.uniforms.preSelectionId;
2879
+ function ei(e, t) {
2880
+ let n = $r(e)?.uniforms.preSelectionId;
2462
2881
  n && (n.value = t);
2463
2882
  }
2464
- function Or(e) {
2883
+ function ti(e) {
2465
2884
  return Number(e.current?.modelID ?? 0);
2466
2885
  }
2467
- function kr(e) {
2886
+ function ni(e) {
2468
2887
  let t = e;
2469
2888
  for (; t;) {
2470
2889
  let e = t.modelID ?? t.userData.modelID;
@@ -2473,7 +2892,7 @@ function kr(e) {
2473
2892
  }
2474
2893
  return 0;
2475
2894
  }
2476
- function Ar(e) {
2895
+ function ri(e) {
2477
2896
  let t = e;
2478
2897
  for (; t;) {
2479
2898
  if (!t.visible) return !1;
@@ -2481,216 +2900,239 @@ function Ar(e) {
2481
2900
  }
2482
2901
  return !0;
2483
2902
  }
2484
- function jr(e) {
2485
- if (!Ar(e.object) || !(e.object instanceof M) || e.faceIndex === void 0 || e.faceIndex === null) return !1;
2903
+ function ii(e) {
2904
+ if (!ri(e.object) || !(e.object instanceof N) || e.faceIndex === void 0 || e.faceIndex === null) return !1;
2486
2905
  let t = e.object.geometry;
2487
2906
  return !!(t.index && t.attributes.ids);
2488
2907
  }
2489
- function Mr(e, t, n, r) {
2490
- let i = l("end"), a = z((e) => e.selected), s = z((e) => e.setSelected), c = z((e) => e.addSelected), u = z((e) => e.removeSelected), d = z((e) => e.showStats), f = Ee(), m = l(null), h = l(null), g = l(!1), _ = l(!1), v = l("add"), y = l(null), b = l(!1), x = l(0), S = l(null), C = l(null), w = () => f.getState().selectionInteractionDisabled, T = (e) => {
2908
+ function ai(e) {
2909
+ if (!ii(e)) return null;
2910
+ let t = e.object, n = t.geometry, r = n.index.getX(e.faceIndex * 3), i = n.attributes.ids;
2911
+ if (r >= i.count) return null;
2912
+ let a = n.attributes.modelID;
2913
+ return {
2914
+ elementID: i.getX(r),
2915
+ hit: e,
2916
+ modelID: a ? a.getX(r) : ni(t)
2917
+ };
2918
+ }
2919
+ function oi(e, t, n, r, i, a) {
2920
+ let s = l("end"), c = H((e) => e.selected), u = H((e) => e.setSelected), d = H((e) => e.addSelected), f = H((e) => e.removeSelected), m = H((e) => e.showStats), h = Ee(), g = l(null), _ = l(null), v = l(!1), y = l(!1), b = l("add"), x = l(null), S = l(!1), C = l(0), w = l(null), T = l(null), E = () => h.getState().selectionInteractionDisabled, D = (e) => {
2491
2921
  if (r) {
2492
2922
  r(e);
2493
2923
  return;
2494
2924
  }
2495
2925
  let n = t.current;
2496
2926
  n && (n.cancel(), n.setOrbitPoint(e.x, e.y, e.z));
2497
- }, E = () => {
2498
- e.current?.traverse((e) => {
2499
- if (!(e instanceof M)) return;
2927
+ }, O = () => {
2928
+ a?.(null), e.current?.traverse((e) => {
2929
+ if (!(e instanceof N)) return;
2500
2930
  let t = e;
2501
- t.preselected = !1, Dr(t.material, -1);
2931
+ t.preselected = !1, ei(t.material, -1);
2502
2932
  });
2503
- }, D = () => {
2504
- m.current = null, g.current = !1, wr(h), t.current && (t.current.enabled = !0);
2505
- }, ee = (t) => {
2506
- if (w()) {
2507
- E();
2933
+ }, ee = (t, n) => {
2934
+ a?.({
2935
+ elementID: n,
2936
+ modelID: t
2937
+ }), e.current?.traverse((e) => {
2938
+ if (!(e instanceof N) || ni(e) !== t) return;
2939
+ let r = e;
2940
+ r.preselected = !0, ei(r.material, n);
2941
+ });
2942
+ }, te = () => {
2943
+ g.current = null, v.current = !1, Zr(_), t.current && (t.current.enabled = !0);
2944
+ }, k = (e) => {
2945
+ if (E()) {
2946
+ O();
2508
2947
  return;
2509
2948
  }
2510
- if (m.current) {
2511
- E();
2949
+ if (g.current) {
2950
+ O();
2512
2951
  return;
2513
2952
  }
2514
- if (i.current !== "end" && i.current !== "start") {
2515
- E();
2953
+ if (s.current !== "end" && s.current !== "start") {
2954
+ O();
2516
2955
  return;
2517
2956
  }
2518
- let n = oe(t, e.current)[0], r;
2519
- n && (r = n.object), E(), !(!n || !r) && e.current?.traverse((e) => {
2520
- if (!(e instanceof M)) return;
2521
- let t = e;
2522
- if (t !== r) return;
2523
- let i = n.faceIndex * 3, a = t.geometry.index.getX(i), o = t.geometry.attributes.ids.getX(a);
2524
- t.preselected = !0, Dr(t.material, o);
2525
- });
2957
+ let t = ce(e);
2958
+ O(), t && ee(t.modelID, t.elementID);
2526
2959
  };
2527
- function te() {
2960
+ function ne() {
2528
2961
  return performance.now();
2529
2962
  }
2530
- let ne = (e) => {
2531
- if (w()) {
2532
- C.current = null, S.current !== null && (window.clearTimeout(S.current), S.current = null), E();
2963
+ let A = (e) => {
2964
+ if (E()) {
2965
+ T.current = null, w.current !== null && (window.clearTimeout(w.current), w.current = null), O();
2533
2966
  return;
2534
2967
  }
2535
- if (C.current = e, S.current !== null) return;
2536
- let t = te() - x.current, n = Math.max(0, Tr - t);
2537
- S.current = window.setTimeout(() => {
2538
- S.current = null;
2539
- let e = C.current;
2540
- C.current = null, e && (x.current = performance.now(), ee(e));
2968
+ if (T.current = e, w.current !== null) return;
2969
+ let t = ne() - C.current, n = Math.max(0, Qr - t);
2970
+ w.current = window.setTimeout(() => {
2971
+ w.current = null;
2972
+ let e = T.current;
2973
+ T.current = null, e && (C.current = performance.now(), k(e));
2541
2974
  }, n);
2542
- }, O = l(null);
2975
+ }, j = l(null);
2543
2976
  o(() => {
2544
- let e = y.current;
2977
+ let e = x.current;
2545
2978
  if (e) {
2546
- d && O.current !== null && console.log(`selection ${e.action}:`, Date.now() - O.current, "ms"), y.current = null, O.current = null;
2979
+ m && j.current !== null && console.log(`selection ${e.action}:`, Date.now() - j.current, "ms"), x.current = null, j.current = null;
2547
2980
  return;
2548
2981
  }
2549
- d && O.current !== null && (console.log("selection spend:", Date.now() - O.current, "ms"), O.current = null);
2550
- }, [a, d]);
2551
- let { camera: k, gl: A } = p();
2552
- function re() {
2982
+ m && j.current !== null && (console.log("selection spend:", Date.now() - j.current, "ms"), j.current = null);
2983
+ }, [c, m]);
2984
+ let { camera: M, gl: P } = p();
2985
+ function F() {
2553
2986
  return Date.now();
2554
2987
  }
2555
- let j = (e) => {
2556
- let t = A.domElement.getBoundingClientRect();
2988
+ let re = (e) => {
2989
+ let t = P.domElement.getBoundingClientRect();
2557
2990
  return e.clientX >= t.left && e.clientX <= t.right && e.clientY >= t.top && e.clientY <= t.bottom;
2558
- }, N = (t) => {
2559
- if (w()) {
2560
- b.current = !1, _.current = !1, E();
2991
+ }, I = (t) => {
2992
+ if (E()) {
2993
+ S.current = !1, y.current = !1, O();
2561
2994
  return;
2562
2995
  }
2563
- if (!b.current) return;
2564
- if (b.current = !1, _.current) {
2565
- _.current = !1;
2996
+ if (!S.current) return;
2997
+ if (S.current = !1, y.current) {
2998
+ y.current = !1;
2566
2999
  return;
2567
3000
  }
2568
- if (!j(t)) return;
2569
- if (O.current = re(), i.current !== "end" && i.current !== "start" && i.current > 15) {
2570
- i.current = "end";
3001
+ if (!re(t)) return;
3002
+ if (j.current = F(), s.current !== "end" && s.current !== "start" && s.current > 15) {
3003
+ s.current = "end";
2571
3004
  return;
2572
3005
  }
2573
- let n = t.shiftKey, r = t.ctrlKey, o = oe(t, e.current), l, d = Or(e), f = null;
2574
- if (o.length) {
2575
- let e = o[0], t = e.object;
2576
- d = kr(t), f = e.point;
2577
- let n = e.faceIndex * 3, r = t.geometry.index.getX(n);
2578
- l = t.geometry.attributes.ids.getX(r);
2579
- }
2580
- if (r) {
2581
- l !== void 0 && u(d, [l]);
3006
+ let n = t.shiftKey, r = t.ctrlKey, i = ce(t), a, o = ti(e), l = null;
3007
+ if (i && (o = i.modelID, l = i.hit.point, a = i.elementID), r) {
3008
+ a !== void 0 && f(o, [a]);
2582
3009
  return;
2583
3010
  } else if (n) {
2584
- l !== void 0 && (a[d]?.has(l) ?? !1 ? u(d, [l]) : (c(d, [l]), f && T(f)));
3011
+ a !== void 0 && (c[o]?.has(a) ?? !1 ? f(o, [a]) : (d(o, [a]), l && D(l)));
2585
3012
  return;
2586
3013
  }
2587
- s(d, l === void 0 ? [] : [l], !0), f && T(f);
2588
- }, P = (e) => {
2589
- w() || e.button !== 0 || !e.shiftKey && !e.ctrlKey || (m.current = new F(e.clientX, e.clientY), v.current = e.ctrlKey ? "remove" : "add", g.current = !1, t.current && (t.current.enabled = !1));
3014
+ u(o, a === void 0 ? [] : [a], !0), l && D(l);
2590
3015
  }, ie = (e) => {
2591
- if (w()) {
2592
- D();
3016
+ E() || e.button !== 0 || !e.shiftKey && !e.ctrlKey || (g.current = new R(e.clientX, e.clientY), b.current = e.ctrlKey ? "remove" : "add", v.current = !1, t.current && (t.current.enabled = !1));
3017
+ }, ae = (e) => {
3018
+ if (E()) {
3019
+ te();
2593
3020
  return;
2594
3021
  }
2595
- if (!m.current) return;
2596
- let t = new F(e.clientX, e.clientY), n = Math.abs(t.x - m.current.x), r = Math.abs(t.y - m.current.y);
2597
- n < 6 && r < 6 || (g.current ||= !0, e.preventDefault(), Cr(h, m.current, t));
2598
- }, ae = (r) => {
2599
- if (w()) {
2600
- D();
3022
+ if (!g.current) return;
3023
+ let t = new R(e.clientX, e.clientY), n = Math.abs(t.x - g.current.x), r = Math.abs(t.y - g.current.y);
3024
+ n < 6 && r < 6 || (v.current ||= !0, e.preventDefault(), Xr(_, g.current, t));
3025
+ }, L = (r) => {
3026
+ if (E()) {
3027
+ te();
2601
3028
  return;
2602
3029
  }
2603
- if (!m.current) return;
2604
- O.current = re();
2605
- let i = g.current, a = new F(r.clientX, r.clientY), o = nr(m.current, a), s = rr(m.current, a);
2606
- if (m.current = null, g.current = !1, wr(h), t.current && setTimeout(() => {
3030
+ if (!g.current) return;
3031
+ j.current = F();
3032
+ let i = v.current, a = new R(r.clientX, r.clientY), o = kr(g.current, a), s = Ar(g.current, a);
3033
+ if (g.current = null, v.current = !1, Zr(_), t.current && setTimeout(() => {
2607
3034
  t.current && (t.current.enabled = !0);
2608
3035
  }, 100), !i) return;
2609
- _.current = !0, r.preventDefault();
2610
- let { ids: l, profile: d } = xr({
3036
+ y.current = !0, r.preventDefault();
3037
+ let { ids: c, profile: l } = Jr({
2611
3038
  model: e.current,
2612
- camera: k,
3039
+ camera: M,
2613
3040
  clippingPlanes: n.getActiveClippingPlanes(),
2614
- domElement: A.domElement,
3041
+ domElement: P.domElement,
2615
3042
  rect: o,
2616
3043
  mode: s
2617
- }), f = Array.from(l.values()).reduce((e, t) => e + t.size, 0), p = {
2618
- action: v.current,
2619
- box: d,
2620
- ids: f
3044
+ }), u = Array.from(c.values()).reduce((e, t) => e + t.size, 0), p = {
3045
+ action: b.current,
3046
+ box: l,
3047
+ ids: u
2621
3048
  };
2622
- f && (y.current = p, l.forEach((e, t) => {
3049
+ u && (x.current = p, c.forEach((e, t) => {
2623
3050
  let n = Array.from(e);
2624
- v.current === "remove" ? u(t, n) : c(t, n);
3051
+ b.current === "remove" ? f(t, n) : d(t, n);
2625
3052
  }));
2626
- }, oe = (e, t) => t ? n.getIntersection(!1, {
2627
- event: e,
2628
- filter: jr,
2629
- object: t,
2630
- recursive: !0
2631
- }) : [];
3053
+ }, oe = (e, t) => {
3054
+ let r = Array.isArray(t) ? t.filter((e) => e.visible) : t ? [t] : [];
3055
+ return r.length ? n.getIntersection(!1, {
3056
+ event: e,
3057
+ filter: ii,
3058
+ object: r,
3059
+ recursive: !0
3060
+ }) : [];
3061
+ }, se = () => {
3062
+ let t = [];
3063
+ return e.current && t.push(e.current), i?.().forEach((e) => {
3064
+ e.visible && t.push(e);
3065
+ }), t;
3066
+ }, ce = (e) => {
3067
+ let t = oe(e, se());
3068
+ for (let e of t) {
3069
+ let t = ai(e);
3070
+ if (t) return t;
3071
+ }
3072
+ return null;
3073
+ };
2632
3074
  o(() => {
2633
3075
  let e = t.current;
2634
3076
  if (!e) return;
2635
- A.domElement.addEventListener("pointerdown", P), A.domElement.addEventListener("pointermove", ie), window.addEventListener("pointerup", ae), window.addEventListener("pointerup", N), A.domElement.addEventListener("contextmenu", o), A.domElement.addEventListener("pointerup", a), A.domElement.addEventListener("pointermove", ne), A.domElement.addEventListener("pointerleave", E), A.domElement.addEventListener("pointerdown", r), e.addEventListener("update", n);
3077
+ P.domElement.addEventListener("pointerdown", ie), P.domElement.addEventListener("pointermove", ae), window.addEventListener("pointerup", L), window.addEventListener("pointerup", I), P.domElement.addEventListener("contextmenu", a), P.domElement.addEventListener("pointerup", i), P.domElement.addEventListener("pointermove", A), P.domElement.addEventListener("pointerleave", O), P.domElement.addEventListener("pointerdown", r), e.addEventListener("update", n);
2636
3078
  function n() {
2637
- typeof i.current == "number" ? i.current += 1 : i.current === "start" && (i.current = 1);
3079
+ typeof s.current == "number" ? s.current += 1 : s.current === "start" && (s.current = 1);
2638
3080
  }
2639
3081
  function r(e) {
2640
- b.current = e.button === 0 || e.ctrlKey, i.current = "start";
3082
+ S.current = e.button === 0 || e.ctrlKey, s.current = "start";
2641
3083
  }
2642
- function a() {
3084
+ function i() {
2643
3085
  setTimeout(() => {
2644
- i.current = "end";
3086
+ s.current = "end";
2645
3087
  }, 100);
2646
3088
  }
2647
- function o(e) {
3089
+ function a(e) {
2648
3090
  e.ctrlKey && e.preventDefault();
2649
3091
  }
2650
3092
  return () => {
2651
- wr(h), S.current !== null && (window.clearTimeout(S.current), S.current = null), C.current = null, E(), e.removeEventListener("update", n), A.domElement.removeEventListener("pointerdown", P), A.domElement.removeEventListener("pointermove", ie), window.removeEventListener("pointerup", ae), window.removeEventListener("pointerup", N), A.domElement.removeEventListener("contextmenu", o), A.domElement.removeEventListener("pointerup", a), A.domElement.removeEventListener("pointerdown", r), A.domElement.removeEventListener("pointermove", ne), A.domElement.removeEventListener("pointerleave", E);
3093
+ Zr(_), w.current !== null && (window.clearTimeout(w.current), w.current = null), T.current = null, O(), e.removeEventListener("update", n), P.domElement.removeEventListener("pointerdown", ie), P.domElement.removeEventListener("pointermove", ae), window.removeEventListener("pointerup", L), window.removeEventListener("pointerup", I), P.domElement.removeEventListener("contextmenu", a), P.domElement.removeEventListener("pointerup", i), P.domElement.removeEventListener("pointerdown", r), P.domElement.removeEventListener("pointermove", A), P.domElement.removeEventListener("pointerleave", O);
2652
3094
  };
2653
3095
  });
2654
3096
  }
2655
3097
  //#endregion
2656
3098
  //#region src/viewer/Camera/useCameraFit.tsx
2657
- var Nr = new I(1, 1, 1).normalize(), Pr = 1.18;
2658
- function Fr() {
3099
+ var si = new z(1, 1, 1).normalize(), ci = 1.18;
3100
+ function li() {
2659
3101
  let { camera: e } = p();
2660
3102
  return i((t, n, r) => {
2661
- if (!t.current || !(e instanceof se)) return;
3103
+ if (!t.current || !(e instanceof ae)) return;
2662
3104
  let i = new g().setFromObject(t.current);
2663
3105
  if (i.isEmpty()) return;
2664
- let a = i.getCenter(new I()), o = i.getBoundingSphere(new de()), 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) * Pr;
2665
- e.position.copy(a).addScaledVector(Nr, u), e.up.set(0, 1, 0), e.lookAt(a), e.updateProjectionMatrix();
3106
+ let a = i.getCenter(new z()), o = i.getBoundingSphere(new ue()), s = j.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) * ci;
3107
+ e.position.copy(a).addScaledVector(si, u), e.up.set(0, 1, 0), e.lookAt(a), e.updateProjectionMatrix();
2666
3108
  let d = n.current;
2667
- 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(Nr, u * .8), r.current.lookAt(a));
3109
+ 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(si, u * .8), r.current.lookAt(a));
2668
3110
  }, [e]);
2669
3111
  }
2670
3112
  //#endregion
2671
3113
  //#region src/viewer/store/ViewerStoreProvider.tsx
2672
- function Ir({ children: e, store: t }) {
3114
+ function ui({ children: e, store: t }) {
2673
3115
  let [n] = u(() => t ?? Ae());
2674
- return /* @__PURE__ */ L(Te.Provider, {
3116
+ return /* @__PURE__ */ B(Te.Provider, {
2675
3117
  value: n,
2676
3118
  children: e
2677
3119
  });
2678
3120
  }
2679
3121
  //#endregion
2680
3122
  //#region src/viewer/utils/ExportUtils/ExportUtils.ts
2681
- var Lr = new TextEncoder(), Rr = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", zr = "Unknown", Br = ["elementID", "ifcguid"], Vr = 0, Hr = 33;
2682
- function Ur(e) {
3123
+ var di = new TextEncoder(), fi = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", pi = "Unknown", mi = ["elementID", "ifcguid"], hi = 0, gi = 33;
3124
+ function _i(e) {
2683
3125
  return !!e && typeof e == "object" && !Array.isArray(e);
2684
3126
  }
2685
- function Wr(e, t) {
2686
- 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 : Ur(e) && "value" in e ? Wr(e.value, t) : null;
3127
+ function vi(e, t) {
3128
+ 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 : _i(e) && "value" in e ? vi(e.value, t) : null;
2687
3129
  }
2688
- function Gr(e, t) {
2689
- let n = Wr(e, t);
3130
+ function yi(e, t) {
3131
+ let n = vi(e, t);
2690
3132
  if (n !== null) return n;
2691
3133
  if (Array.isArray(e)) {
2692
3134
  if (!e.length) return t;
2693
- let n = e.map((e) => Wr(e, t));
3135
+ let n = e.map((e) => vi(e, t));
2694
3136
  if (n.every((e) => e !== null)) {
2695
3137
  let e = n.join(", ");
2696
3138
  return e.trim() ? e : t;
@@ -2703,21 +3145,21 @@ function Gr(e, t) {
2703
3145
  return t;
2704
3146
  }
2705
3147
  }
2706
- function K(e) {
3148
+ function J(e) {
2707
3149
  return typeof e == "string" && e.trim() ? e : null;
2708
3150
  }
2709
- function Kr(e) {
2710
- let t = Ur(e.props) ? e.props : {};
2711
- return K(e.type ?? e.Type ?? t.type ?? t.Type) ?? zr;
3151
+ function bi(e) {
3152
+ let t = _i(e.props) ? e.props : {};
3153
+ return J(e.type ?? e.Type ?? t.type ?? t.Type) ?? pi;
2712
3154
  }
2713
- function qr(e) {
2714
- let t = Ur(e.props) ? e.props : {};
2715
- return K(e.guid ?? e.GlobalId ?? e.globalId ?? t.guid ?? t.GlobalId ?? t.globalId) ?? "";
3155
+ function xi(e) {
3156
+ let t = _i(e.props) ? e.props : {};
3157
+ return J(e.guid ?? e.GlobalId ?? e.globalId ?? t.guid ?? t.GlobalId ?? t.globalId) ?? "";
2716
3158
  }
2717
- function Jr(e, t) {
2718
- return K(e.Name) ?? K(e.name) ?? K(e.DisplayName) ?? K(e.displayName) ?? `Property ${t + 1}`;
3159
+ function Si(e, t) {
3160
+ return J(e.Name) ?? J(e.name) ?? J(e.DisplayName) ?? J(e.displayName) ?? `Property ${t + 1}`;
2719
3161
  }
2720
- function Yr(e) {
3162
+ function Ci(e) {
2721
3163
  for (let t of [
2722
3164
  "NominalValue",
2723
3165
  "nominalValue",
@@ -2740,18 +3182,18 @@ function Yr(e) {
2740
3182
  "description"
2741
3183
  ].includes(e)));
2742
3184
  }
2743
- function Xr(e, t) {
2744
- return K(e.name) ?? K(e.Name) ?? `Set ${t + 1}`;
3185
+ function wi(e, t) {
3186
+ return J(e.name) ?? J(e.Name) ?? `Set ${t + 1}`;
2745
3187
  }
2746
- function Zr(e) {
3188
+ function Ti(e) {
2747
3189
  let t = e.props;
2748
- return Array.isArray(t) ? t.map((e, t) => Ur(e) ? {
2749
- label: Jr(e, t),
2750
- value: Yr(e)
3190
+ return Array.isArray(t) ? t.map((e, t) => _i(e) ? {
3191
+ label: Si(e, t),
3192
+ value: Ci(e)
2751
3193
  } : {
2752
3194
  label: `Property ${t + 1}`,
2753
3195
  value: e
2754
- }) : Ur(t) ? Object.entries(t).map(([e, t]) => ({
3196
+ }) : _i(t) ? Object.entries(t).map(([e, t]) => ({
2755
3197
  label: e,
2756
3198
  value: t
2757
3199
  })) : Object.entries(e).filter(([e]) => ![
@@ -2765,14 +3207,14 @@ function Zr(e) {
2765
3207
  value: t
2766
3208
  }));
2767
3209
  }
2768
- function Qr(e, t) {
3210
+ function Ei(e, t) {
2769
3211
  e.columnSet.has(t) || (e.columnSet.add(t), e.columns.push(t));
2770
3212
  }
2771
- function $r(e, t, n, r, i) {
3213
+ function Di(e, t, n, r, i) {
2772
3214
  let a = n.trim();
2773
- a && (Qr(e, a), t[a] = Gr(r, i));
3215
+ a && (Ei(e, a), t[a] = yi(r, i));
2774
3216
  }
2775
- function ei(e, t, n) {
3217
+ function Oi(e, t, n) {
2776
3218
  let r = {};
2777
3219
  return Object.entries(t).forEach(([t, i]) => {
2778
3220
  [
@@ -2780,33 +3222,33 @@ function ei(e, t, n) {
2780
3222
  "guid",
2781
3223
  "props",
2782
3224
  "sets"
2783
- ].includes(t) || $r(e, r, t, i, n);
2784
- }), Ur(t.props) && Object.entries(t.props).forEach(([t, i]) => {
2785
- $r(e, r, t, i, n);
3225
+ ].includes(t) || Di(e, r, t, i, n);
3226
+ }), _i(t.props) && Object.entries(t.props).forEach(([t, i]) => {
3227
+ Di(e, r, t, i, n);
2786
3228
  }), Array.isArray(t.sets) && t.sets.forEach((t, i) => {
2787
- let a = Xr(t, i);
2788
- Zr(t).forEach((t) => {
2789
- $r(e, r, `${a}.${t.label}`, t.value, n);
3229
+ let a = wi(t, i);
3230
+ Ti(t).forEach((t) => {
3231
+ Di(e, r, `${a}.${t.label}`, t.value, n);
2790
3232
  });
2791
3233
  }), r;
2792
3234
  }
2793
- function ti(e, t, n) {
3235
+ function ki(e, t, n) {
2794
3236
  Object.entries(t).forEach(([t, r]) => {
2795
3237
  let i = Number(t);
2796
3238
  if (!Number.isFinite(i)) return;
2797
- let a = Kr(r), o = e.get(a);
3239
+ let a = bi(r), o = e.get(a);
2798
3240
  o || (o = {
2799
3241
  columns: [],
2800
3242
  columnSet: /* @__PURE__ */ new Set(),
2801
3243
  rows: []
2802
3244
  }, e.set(a, o)), o.rows.push({
2803
3245
  elementID: i,
2804
- ifcguid: qr(r),
2805
- values: ei(o, r, n)
3246
+ ifcguid: xi(r),
3247
+ values: Oi(o, r, n)
2806
3248
  });
2807
3249
  });
2808
3250
  }
2809
- function ni(e) {
3251
+ function Ai(e) {
2810
3252
  return e.replace(/[<>&'"]/g, (e) => {
2811
3253
  switch (e) {
2812
3254
  case "<": return "&lt;";
@@ -2818,7 +3260,7 @@ function ni(e) {
2818
3260
  }
2819
3261
  });
2820
3262
  }
2821
- function ri(e) {
3263
+ function ji(e) {
2822
3264
  let t = e, n = "";
2823
3265
  for (; t > 0;) {
2824
3266
  let e = (t - 1) % 26;
@@ -2826,45 +3268,45 @@ function ri(e) {
2826
3268
  }
2827
3269
  return n;
2828
3270
  }
2829
- function ii(e, t, n) {
2830
- return `<c r="${`${ri(n)}${t}`}" t="inlineStr"><is><t${/^\s|\s$/.test(e) ? " xml:space=\"preserve\"" : ""}>${ni(e)}</t></is></c>`;
3271
+ function Mi(e, t, n) {
3272
+ return `<c r="${`${ji(n)}${t}`}" t="inlineStr"><is><t${/^\s|\s$/.test(e) ? " xml:space=\"preserve\"" : ""}>${Ai(e)}</t></is></c>`;
2831
3273
  }
2832
- function ai(e) {
2833
- return `${Rr}<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${e.map((e, t) => {
3274
+ function Ni(e) {
3275
+ return `${fi}<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${e.map((e, t) => {
2834
3276
  let n = t + 1;
2835
- return `<row r="${n}">${e.map((e, t) => ii(e, n, t + 1)).join("")}</row>`;
3277
+ return `<row r="${n}">${e.map((e, t) => Mi(e, n, t + 1)).join("")}</row>`;
2836
3278
  }).join("")}</sheetData></worksheet>`;
2837
3279
  }
2838
- function oi(e) {
2839
- return e.replace(/[\\/?*[\]:]/g, " ").trim() || zr;
3280
+ function Pi(e) {
3281
+ return e.replace(/[\\/?*[\]:]/g, " ").trim() || pi;
2840
3282
  }
2841
- function si(e, t) {
2842
- let n = oi(e).slice(0, 31), r = n, i = 2;
3283
+ function Fi(e, t) {
3284
+ let n = Pi(e).slice(0, 31), r = n, i = 2;
2843
3285
  for (; t.has(r.toLowerCase());) {
2844
3286
  let e = ` (${i})`;
2845
3287
  r = `${n.slice(0, 31 - e.length)}${e}`, i += 1;
2846
3288
  }
2847
3289
  return t.add(r.toLowerCase()), r;
2848
3290
  }
2849
- function ci(e) {
2850
- return `${Rr}<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${e.map((e, t) => {
3291
+ function Ii(e) {
3292
+ return `${fi}<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${e.map((e, t) => {
2851
3293
  let n = t + 1;
2852
- return `<sheet name="${ni(e)}" sheetId="${n}" r:id="rId${n}"/>`;
3294
+ return `<sheet name="${Ai(e)}" sheetId="${n}" r:id="rId${n}"/>`;
2853
3295
  }).join("")}</sheets></workbook>`;
2854
3296
  }
2855
- function li(e) {
2856
- return `${Rr}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${e.map((e, t) => {
3297
+ function Li(e) {
3298
+ return `${fi}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${e.map((e, t) => {
2857
3299
  let n = t + 1;
2858
3300
  return `<Relationship Id="rId${n}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${n}.xml"/>`;
2859
3301
  }).join("")}</Relationships>`;
2860
3302
  }
2861
- function ui() {
2862
- return `${Rr}<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>`;
3303
+ function Ri() {
3304
+ return `${fi}<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>`;
2863
3305
  }
2864
- function di(e) {
2865
- return `${Rr}<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>`;
3306
+ function zi(e) {
3307
+ return `${fi}<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>`;
2866
3308
  }
2867
- function fi() {
3309
+ function Bi() {
2868
3310
  let e = new Uint32Array(256);
2869
3311
  for (let t = 0; t < 256; t++) {
2870
3312
  let n = t;
@@ -2873,121 +3315,121 @@ function fi() {
2873
3315
  }
2874
3316
  return e;
2875
3317
  }
2876
- var pi = fi();
2877
- function mi(e) {
3318
+ var Vi = Bi();
3319
+ function Hi(e) {
2878
3320
  let t = 4294967295;
2879
- for (let n of e) t = pi[(t ^ n) & 255] ^ t >>> 8;
3321
+ for (let n of e) t = Vi[(t ^ n) & 255] ^ t >>> 8;
2880
3322
  return (t ^ 4294967295) >>> 0;
2881
3323
  }
2882
- function hi(e) {
3324
+ function Ui(e) {
2883
3325
  let t = new Uint8Array(30 + e.nameBytes.length), n = new DataView(t.buffer);
2884
- return n.setUint32(0, 67324752, !0), n.setUint16(4, 20, !0), n.setUint16(6, 0, !0), n.setUint16(8, 0, !0), n.setUint16(10, Vr, !0), n.setUint16(12, Hr, !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;
3326
+ return n.setUint32(0, 67324752, !0), n.setUint16(4, 20, !0), n.setUint16(6, 0, !0), n.setUint16(8, 0, !0), n.setUint16(10, hi, !0), n.setUint16(12, gi, !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;
2885
3327
  }
2886
- function gi(e) {
3328
+ function Wi(e) {
2887
3329
  let t = new Uint8Array(46 + e.nameBytes.length), n = new DataView(t.buffer);
2888
- 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, Vr, !0), n.setUint16(14, Hr, !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;
3330
+ 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, hi, !0), n.setUint16(14, gi, !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;
2889
3331
  }
2890
- function _i(e, t, n) {
3332
+ function Gi(e, t, n) {
2891
3333
  let r = new Uint8Array(22), i = new DataView(r.buffer);
2892
3334
  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;
2893
3335
  }
2894
- function vi(e, t) {
3336
+ function Ki(e, t) {
2895
3337
  let n = new Uint8Array(t), r = 0;
2896
3338
  return e.forEach((e) => {
2897
3339
  n.set(e, r), r += e.length;
2898
3340
  }), n;
2899
3341
  }
2900
- function yi(e) {
3342
+ function qi(e) {
2901
3343
  let t = 0, n = e.map((e) => {
2902
3344
  let n = {
2903
3345
  ...e,
2904
- crc: mi(e.data),
2905
- nameBytes: Lr.encode(e.path),
3346
+ crc: Hi(e.data),
3347
+ nameBytes: di.encode(e.path),
2906
3348
  offset: t
2907
3349
  };
2908
3350
  return t += 30 + n.nameBytes.length + n.data.length, n;
2909
3351
  }), r = [];
2910
3352
  n.forEach((e) => {
2911
- r.push(hi(e), e.data);
3353
+ r.push(Ui(e), e.data);
2912
3354
  });
2913
3355
  let i = t, a = 0;
2914
3356
  return n.forEach((e) => {
2915
- let t = gi(e);
3357
+ let t = Wi(e);
2916
3358
  a += t.length, r.push(t);
2917
- }), r.push(_i(n.length, a, i)), vi(r, r.reduce((e, t) => e + t.length, 0));
3359
+ }), r.push(Gi(n.length, a, i)), Ki(r, r.reduce((e, t) => e + t.length, 0));
2918
3360
  }
2919
- function bi(e, t) {
3361
+ function Ji(e, t) {
2920
3362
  let n = /* @__PURE__ */ new Map();
2921
- e && ti(n, e.props, t);
3363
+ e && ki(n, e.props, t);
2922
3364
  let r = /* @__PURE__ */ new Set(), i = Array.from(n.entries()).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
2923
- let i = [...Br, ...n.columns], a = n.rows.sort((e, t) => e.elementID - t.elementID).map((e) => [
3365
+ let i = [...mi, ...n.columns], a = n.rows.sort((e, t) => e.elementID - t.elementID).map((e) => [
2924
3366
  String(e.elementID),
2925
3367
  e.ifcguid || t,
2926
3368
  ...n.columns.map((n) => e.values[n] ?? t)
2927
3369
  ]);
2928
3370
  return {
2929
- name: si(e, r),
3371
+ name: Fi(e, r),
2930
3372
  rows: [i, ...a]
2931
3373
  };
2932
3374
  });
2933
3375
  return i.length || i.push({
2934
- name: si(zr, r),
2935
- rows: [Br]
3376
+ name: Fi(pi, r),
3377
+ rows: [mi]
2936
3378
  }), i;
2937
3379
  }
2938
- function xi(e, t = {}) {
2939
- let n = bi(e, t.emptyValue ?? "-"), r = n.map((e) => e.name), i = [
3380
+ function Yi(e, t = {}) {
3381
+ let n = Ji(e, t.emptyValue ?? "-"), r = n.map((e) => e.name), i = [
2940
3382
  {
2941
3383
  path: "[Content_Types].xml",
2942
- data: Lr.encode(di(r))
3384
+ data: di.encode(zi(r))
2943
3385
  },
2944
3386
  {
2945
3387
  path: "_rels/.rels",
2946
- data: Lr.encode(ui())
3388
+ data: di.encode(Ri())
2947
3389
  },
2948
3390
  {
2949
3391
  path: "xl/workbook.xml",
2950
- data: Lr.encode(ci(r))
3392
+ data: di.encode(Ii(r))
2951
3393
  },
2952
3394
  {
2953
3395
  path: "xl/_rels/workbook.xml.rels",
2954
- data: Lr.encode(li(r))
3396
+ data: di.encode(Li(r))
2955
3397
  },
2956
3398
  ...n.map((e, t) => ({
2957
3399
  path: `xl/worksheets/sheet${t + 1}.xml`,
2958
- data: Lr.encode(ai(e.rows))
3400
+ data: di.encode(Ni(e.rows))
2959
3401
  }))
2960
3402
  ];
2961
- return new Blob([yi(i)], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
3403
+ return new Blob([qi(i)], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
2962
3404
  }
2963
- function Si(e) {
3405
+ function Xi(e) {
2964
3406
  return e.split(/[?#]/)[0].split(/[\\/]/).pop()?.replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "").trim() || "model";
2965
3407
  }
2966
- function Ci(e, t) {
2967
- let n = t.fileName?.trim() || `${Si(t.modelName ?? e?.name ?? "model")}_properties`;
3408
+ function Zi(e, t) {
3409
+ let n = t.fileName?.trim() || `${Xi(t.modelName ?? e?.name ?? "model")}_properties`;
2968
3410
  return n.toLowerCase().endsWith(".xlsx") ? n : `${n}.xlsx`;
2969
3411
  }
2970
- function wi(e, t = {}) {
3412
+ function Qi(e, t = {}) {
2971
3413
  return {
2972
- blob: xi(e, t),
2973
- name: Ci(e, t)
3414
+ blob: Yi(e, t),
3415
+ name: Zi(e, t)
2974
3416
  };
2975
3417
  }
2976
3418
  //#endregion
2977
3419
  //#region src/viewer/api/ViewerPropertiesApi.ts
2978
- function q(e) {
3420
+ function Y(e) {
2979
3421
  return !!e && typeof e == "object" && !Array.isArray(e);
2980
3422
  }
2981
- function Ti(e, t) {
3423
+ function $i(e, t) {
2982
3424
  return Object.prototype.hasOwnProperty.call(e, t);
2983
3425
  }
2984
- function Ei(e) {
2985
- return q(e);
3426
+ function ea(e) {
3427
+ return Y(e);
2986
3428
  }
2987
- function Di(e) {
2988
- return Array.isArray(e) ? e.filter(Ei) : q(e) ? Object.values(e).filter(Ei) : [];
3429
+ function ta(e) {
3430
+ return Array.isArray(e) ? e.filter(ea) : Y(e) ? Object.values(e).filter(ea) : [];
2989
3431
  }
2990
- function Oi(e) {
3432
+ function na(e) {
2991
3433
  if (typeof e == "number" && Number.isFinite(e)) return e;
2992
3434
  if (typeof e == "string") {
2993
3435
  let t = Number(e);
@@ -2995,10 +3437,10 @@ function Oi(e) {
2995
3437
  }
2996
3438
  return null;
2997
3439
  }
2998
- function ki(e) {
2999
- return Oi(e.id ?? e.expressID ?? e.expressId ?? e.elementID ?? e.elementId);
3440
+ function ra(e) {
3441
+ return na(e.id ?? e.expressID ?? e.expressId ?? e.elementID ?? e.elementId);
3000
3442
  }
3001
- function Ai(e) {
3443
+ function ia(e) {
3002
3444
  let t = [
3003
3445
  e.children,
3004
3446
  e.items,
@@ -3006,40 +3448,40 @@ function Ai(e) {
3006
3448
  e.childs
3007
3449
  ];
3008
3450
  for (let e of t) {
3009
- let t = Di(e);
3451
+ let t = ta(e);
3010
3452
  if (t.length) return t;
3011
3453
  }
3012
3454
  return [];
3013
3455
  }
3014
- function ji(e) {
3015
- let t = q(e.props) ? e.props : {}, n = e.type ?? e.Type ?? t.type ?? t.Type;
3456
+ function aa(e) {
3457
+ let t = Y(e.props) ? e.props : {}, n = e.type ?? e.Type ?? t.type ?? t.Type;
3016
3458
  return typeof n == "string" ? n : "";
3017
3459
  }
3018
- function Mi(e) {
3460
+ function oa(e) {
3019
3461
  return e.replace(/[^a-z0-9]/gi, "").toUpperCase();
3020
3462
  }
3021
- function Ni(e) {
3022
- return Mi(ji(e)) === "IFCBUILDINGSTOREY";
3463
+ function sa(e) {
3464
+ return oa(aa(e)) === "IFCBUILDINGSTOREY";
3023
3465
  }
3024
- var Pi = new Set([
3466
+ var ca = new Set([
3025
3467
  "children",
3026
3468
  "childs",
3027
3469
  "elements",
3028
3470
  "items"
3029
3471
  ]);
3030
- function Fi(e) {
3472
+ function la(e) {
3031
3473
  let t = {};
3032
3474
  return Object.entries(e).forEach(([e, n]) => {
3033
- Pi.has(e) || (t[e] = n);
3475
+ ca.has(e) || (t[e] = n);
3034
3476
  }), t;
3035
3477
  }
3036
- function Ii(e, t) {
3478
+ function ua(e, t) {
3037
3479
  return Array.isArray(t) ? {
3038
- children: Di(t),
3480
+ children: ta(t),
3039
3481
  name: `Model ${e}`,
3040
3482
  type: "Model"
3041
- } : q(t) ? ki(t) !== null || typeof t.name == "string" || typeof t.Name == "string" || typeof t.type == "string" || typeof t.Type == "string" || Array.isArray(t.children) ? t : {
3042
- children: Di(t),
3483
+ } : Y(t) ? ra(t) !== null || typeof t.name == "string" || typeof t.Name == "string" || typeof t.type == "string" || typeof t.Type == "string" || Array.isArray(t.children) ? t : {
3484
+ children: ta(t),
3043
3485
  name: `Model ${e}`,
3044
3486
  type: "Model"
3045
3487
  } : {
@@ -3048,46 +3490,46 @@ function Ii(e, t) {
3048
3490
  type: "Model"
3049
3491
  };
3050
3492
  }
3051
- function Li(e) {
3493
+ function da(e) {
3052
3494
  let t = [];
3053
- return Ai(e).forEach((e) => {
3054
- let n = ki(e);
3055
- n !== null && t.push(n), t.push(...Li(e));
3495
+ return ia(e).forEach((e) => {
3496
+ let n = ra(e);
3497
+ n !== null && t.push(n), t.push(...da(e));
3056
3498
  }), t;
3057
3499
  }
3058
- function Ri(e, t, n, r) {
3059
- let i = ki(t), a = i === null ? void 0 : n[e]?.[i], o = {
3060
- ...Fi(t),
3500
+ function fa(e, t, n, r) {
3501
+ let i = ra(t), a = i === null ? void 0 : n[e]?.[i], o = {
3502
+ ...la(t),
3061
3503
  ...a ?? {},
3062
3504
  modelID: e
3063
3505
  };
3064
- return r && (o.elements = Li(t)), o;
3506
+ return r && (o.elements = da(t)), o;
3065
3507
  }
3066
- function zi(e, t, n, r, i) {
3067
- Ni(t) && n.push(Ri(e, t, r, i)), Ai(t).forEach((t) => zi(e, t, n, r, i));
3508
+ function pa(e, t, n, r, i) {
3509
+ sa(t) && n.push(fa(e, t, r, i)), ia(t).forEach((t) => pa(e, t, n, r, i));
3068
3510
  }
3069
- function Bi(e, t, n = !1) {
3511
+ function ma(e, t, n = !1) {
3070
3512
  let r = {};
3071
3513
  return Object.entries(e).forEach(([e, i]) => {
3072
3514
  let a = Number(e), o = [];
3073
- zi(a, Ii(a, i), o, t, n), r[a] = o;
3515
+ pa(a, ua(a, i), o, t, n), r[a] = o;
3074
3516
  }), r;
3075
3517
  }
3076
- function Vi(e, t, n, r = !1) {
3518
+ function ha(e, t, n, r = !1) {
3077
3519
  let i = [], a = e[n];
3078
3520
  if (!a) throw Error(`Model with modelID ${n} not found`);
3079
- return zi(Number(n), Ii(Number(n), a), i, t, r), i;
3521
+ return pa(Number(n), ua(Number(n), a), i, t, r), i;
3080
3522
  }
3081
- function Hi(e, t, n) {
3523
+ function ga(e, t, n) {
3082
3524
  return e[t]?.[n];
3083
3525
  }
3084
- function Ui(e) {
3085
- return typeof e == "string" ? e : q(e) && typeof e.value == "string" ? e.value : "";
3526
+ function _a(e) {
3527
+ return typeof e == "string" ? e : Y(e) && typeof e.value == "string" ? e.value : "";
3086
3528
  }
3087
- function Wi(e, t) {
3088
- return Ui(e.Name) || Ui(e.name) || Ui(e.DisplayName) || Ui(e.displayName) || `Property ${t + 1}`;
3529
+ function va(e, t) {
3530
+ return _a(e.Name) || _a(e.name) || _a(e.DisplayName) || _a(e.displayName) || `Property ${t + 1}`;
3089
3531
  }
3090
- function Gi(e) {
3532
+ function ya(e) {
3091
3533
  for (let t of [
3092
3534
  "NominalValue",
3093
3535
  "nominalValue",
@@ -3110,44 +3552,44 @@ function Gi(e) {
3110
3552
  "description"
3111
3553
  ].includes(e)));
3112
3554
  }
3113
- function Ki(e) {
3114
- return Ui(e.name) || Ui(e.Name);
3555
+ function ba(e) {
3556
+ return _a(e.name) || _a(e.Name);
3115
3557
  }
3116
- function qi(e, t) {
3117
- return Ti(e, t) ? e[t] : void 0;
3558
+ function xa(e, t) {
3559
+ return $i(e, t) ? e[t] : void 0;
3118
3560
  }
3119
- function Ji(e, t) {
3561
+ function Sa(e, t) {
3120
3562
  let n = e.props;
3121
- if (q(n)) {
3122
- let e = qi(n, t);
3563
+ if (Y(n)) {
3564
+ let e = xa(n, t);
3123
3565
  if (e !== void 0) return e;
3124
3566
  }
3125
3567
  if (Array.isArray(n)) for (let e = 0; e < n.length; e += 1) {
3126
3568
  let r = n[e];
3127
- if (!q(r)) continue;
3569
+ if (!Y(r)) continue;
3128
3570
  let i = r;
3129
- if (Wi(i, e) === t) return Gi(i);
3571
+ if (va(i, e) === t) return ya(i);
3130
3572
  }
3131
- return qi(e, t);
3573
+ return xa(e, t);
3132
3574
  }
3133
- function Yi(e, t, n) {
3575
+ function Ca(e, t, n) {
3134
3576
  if (!e) return;
3135
3577
  if (n !== void 0) {
3136
- let r = e.sets?.find((e) => Ki(e) === n);
3137
- return r ? Ji(r, t) : void 0;
3578
+ let r = e.sets?.find((e) => ba(e) === n);
3579
+ return r ? Sa(r, t) : void 0;
3138
3580
  }
3139
- if (q(e.props)) {
3140
- let n = qi(e.props, t);
3581
+ if (Y(e.props)) {
3582
+ let n = xa(e.props, t);
3141
3583
  if (n !== void 0) return n;
3142
3584
  }
3143
- let r = qi(e, t);
3585
+ let r = xa(e, t);
3144
3586
  if (r !== void 0) return r;
3145
3587
  for (let n of e.sets ?? []) {
3146
- let e = Ji(n, t);
3588
+ let e = Sa(n, t);
3147
3589
  if (e !== void 0) return e;
3148
3590
  }
3149
3591
  }
3150
- function Xi(e, t, n, r) {
3592
+ function wa(e, t, n, r) {
3151
3593
  let i = t[e];
3152
3594
  return i ? {
3153
3595
  data: {},
@@ -3156,44 +3598,44 @@ function Xi(e, t, n, r) {
3156
3598
  structure: n[e] ?? {}
3157
3599
  } : null;
3158
3600
  }
3159
- function Zi(e) {
3601
+ function Ta(e) {
3160
3602
  return {
3161
3603
  exportAllExcel: (t) => {
3162
3604
  let n = e.getState();
3163
3605
  return Object.keys(n.modelProps).flatMap((e) => {
3164
- let r = Xi(Number(e), n.modelProps, n.modelStructure, n.modelNames);
3165
- return r ? [wi(r, t)] : [];
3606
+ let r = wa(Number(e), n.modelProps, n.modelStructure, n.modelNames);
3607
+ return r ? [Qi(r, t)] : [];
3166
3608
  });
3167
3609
  },
3168
3610
  exportExcel: (t, n) => {
3169
- let r = e.getState(), i = Xi(t, r.modelProps, r.modelStructure, r.modelNames);
3170
- return i ? wi(i, n) : null;
3611
+ let r = e.getState(), i = wa(t, r.modelProps, r.modelStructure, r.modelNames);
3612
+ return i ? Qi(i, n) : null;
3171
3613
  },
3172
3614
  getAllLevels: (t = !1) => {
3173
3615
  let n = e.getState();
3174
- return Bi(n.modelStructure, n.modelProps, t);
3616
+ return ma(n.modelStructure, n.modelProps, t);
3175
3617
  },
3176
3618
  getAllModelLevels: (t, n = !1) => {
3177
3619
  let r = e.getState();
3178
- return Vi(r.modelStructure, r.modelProps, t, n);
3620
+ return ha(r.modelStructure, r.modelProps, t, n);
3179
3621
  },
3180
3622
  getModelProps: () => e.getState().modelProps,
3181
3623
  getModelStructure: () => e.getState().modelStructure,
3182
- getParamsByElement: (t, n) => Hi(e.getState().modelProps, t, n),
3183
- getParamValueByName: Yi,
3184
- getParamValueByElement: (t, n, r, i) => Yi(Hi(e.getState().modelProps, t, n), r, i)
3624
+ getParamsByElement: (t, n) => ga(e.getState().modelProps, t, n),
3625
+ getParamValueByName: Ca,
3626
+ getParamValueByElement: (t, n, r, i) => Ca(ga(e.getState().modelProps, t, n), r, i)
3185
3627
  };
3186
3628
  }
3187
3629
  //#endregion
3188
3630
  //#region src/viewer/Loaders/BmtConverter.ts
3189
- var Qi = "BMT", $i = 1, J = {
3631
+ var Ea = "BMT", Da = 1, Oa = {
3190
3632
  PROP: 1,
3191
3633
  MESH: 2,
3192
3634
  STRUCTURE: 3,
3193
3635
  GRIDS: 4,
3194
3636
  MATRIX: 5,
3195
3637
  MESHSPACE: 6
3196
- }, ea = "application/json", ta = "application/octet-stream", na = class {
3638
+ }, ka = "application/json", Aa = "application/octet-stream", ja = class {
3197
3639
  chunks = [];
3198
3640
  length = 0;
3199
3641
  writeUint8(e) {
@@ -3213,7 +3655,7 @@ var Qi = "BMT", $i = 1, J = {
3213
3655
  e.set(n, t), t += n.byteLength;
3214
3656
  }), e;
3215
3657
  }
3216
- }, ra = class {
3658
+ }, Ma = class {
3217
3659
  textEncoder = new TextEncoder();
3218
3660
  ifcLoader = null;
3219
3661
  async ConvertIfcFileToBmt(e, t = {}) {
@@ -3315,7 +3757,7 @@ var Qi = "BMT", $i = 1, J = {
3315
3757
  progress: this.clampProgress(e.progress) * a
3316
3758
  });
3317
3759
  }), s = [{
3318
- blob: new Blob([o], { type: ta }),
3760
+ blob: new Blob([o], { type: Aa }),
3319
3761
  bytes: o,
3320
3762
  name: i,
3321
3763
  type: "bmt"
@@ -3335,7 +3777,7 @@ var Qi = "BMT", $i = 1, J = {
3335
3777
  phase: "metadata",
3336
3778
  progress: .95
3337
3779
  }), s.push({
3338
- blob: new Blob([n], { type: ea }),
3780
+ blob: new Blob([n], { type: ka }),
3339
3781
  bytes: n,
3340
3782
  name: `${t}_props.json`,
3341
3783
  type: "json"
@@ -3348,7 +3790,7 @@ var Qi = "BMT", $i = 1, J = {
3348
3790
  return s;
3349
3791
  }
3350
3792
  createBmtBytes(e, t, n) {
3351
- let r = new na(), i = e.grids !== void 0, a = t, o = !!e.coordinationMatrix && !this.hasMeshMatrices(e), s = t ? .45 : 0, c = i ? .05 : 0, l = a ? .12 : 0, u = o ? .03 : 0, d = Math.max(.1, 1 - s - c - l - u), f = 0, p = (e) => {
3793
+ let r = new ja(), i = e.grids !== void 0, a = t, o = !!e.coordinationMatrix && !this.hasMeshMatrices(e), s = t ? .45 : 0, c = i ? .05 : 0, l = a ? .12 : 0, u = o ? .03 : 0, d = Math.max(.1, 1 - s - c - l - u), f = 0, p = (e) => {
3352
3794
  n?.({
3353
3795
  ...e,
3354
3796
  progress: this.clampProgress(e.progress)
@@ -3365,19 +3807,19 @@ var Qi = "BMT", $i = 1, J = {
3365
3807
  progress: f
3366
3808
  });
3367
3809
  };
3368
- return r.writeBytes(this.textEncoder.encode(Qi)), r.writeUint8($i), t && (this.writeProps(r, e.props, (e) => m(s, e)), h(s, "properties", "Properties written")), e.grids !== void 0 && (p({
3810
+ return r.writeBytes(this.textEncoder.encode(Ea)), r.writeUint8(Da), t && (this.writeProps(r, e.props, (e) => m(s, e)), h(s, "properties", "Properties written")), e.grids !== void 0 && (p({
3369
3811
  message: "Writing grids",
3370
3812
  phase: "metadata",
3371
3813
  progress: f
3372
- }), this.writeJsonChunk(r, J.GRIDS, e.grids), h(c, "metadata", "Grids written")), this.writeMeshes(r, e, (e) => m(d, e)), h(d, "geometry", "Geometry written"), t && (p({
3814
+ }), this.writeJsonChunk(r, Oa.GRIDS, e.grids), h(c, "metadata", "Grids written")), this.writeMeshes(r, e, (e) => m(d, e)), h(d, "geometry", "Geometry written"), t && (p({
3373
3815
  message: "Writing structure",
3374
3816
  phase: "metadata",
3375
3817
  progress: f
3376
- }), this.writeJsonChunk(r, J.STRUCTURE, e.structure), h(l, "metadata", "Structure written")), o && e.coordinationMatrix && (p({
3818
+ }), this.writeJsonChunk(r, Oa.STRUCTURE, e.structure), h(l, "metadata", "Structure written")), o && e.coordinationMatrix && (p({
3377
3819
  message: "Writing coordination matrix",
3378
3820
  phase: "metadata",
3379
3821
  progress: f
3380
- }), this.writeTextChunk(r, J.MATRIX, e.coordinationMatrix), h(u, "metadata", "Coordination matrix written")), p({
3822
+ }), this.writeTextChunk(r, Oa.MATRIX, e.coordinationMatrix), h(u, "metadata", "Coordination matrix written")), p({
3381
3823
  message: "BMT bytes ready",
3382
3824
  phase: "writing",
3383
3825
  progress: 1
@@ -3396,7 +3838,7 @@ var Qi = "BMT", $i = 1, J = {
3396
3838
  ...o,
3397
3839
  id: s
3398
3840
  } : o;
3399
- this.writeJsonChunk(e, J.PROP, c);
3841
+ this.writeJsonChunk(e, Oa.PROP, c);
3400
3842
  let l = a + 1;
3401
3843
  this.shouldEmitItemProgress(l, i) && n?.({
3402
3844
  loaded: l,
@@ -3416,7 +3858,7 @@ var Qi = "BMT", $i = 1, J = {
3416
3858
  progress: a > 0 ? 0 : 1,
3417
3859
  total: a
3418
3860
  }), i.forEach((t, i) => {
3419
- t.matrix && t.matrix !== r && (this.writeTextChunk(e, J.MATRIX, t.matrix), r = t.matrix), this.writeChunk(e, t.isIfcSpace ? J.MESHSPACE : J.MESH, this.createMeshPayload(t));
3861
+ t.matrix && t.matrix !== r && (this.writeTextChunk(e, Oa.MATRIX, t.matrix), r = t.matrix), this.writeChunk(e, t.isIfcSpace ? Oa.MESHSPACE : Oa.MESH, this.createMeshPayload(t));
3420
3862
  let o = i + 1;
3421
3863
  this.shouldEmitItemProgress(o, a) && n?.({
3422
3864
  loaded: o,
@@ -3428,7 +3870,7 @@ var Qi = "BMT", $i = 1, J = {
3428
3870
  });
3429
3871
  }
3430
3872
  createMeshPayload(e) {
3431
- let t = new na(), n = this.deflateTypedArray(e.pos), r = this.deflateTypedArray(e.ids), i = this.deflateTypedArray(e.ind);
3873
+ let t = new ja(), n = this.deflateTypedArray(e.pos), r = this.deflateTypedArray(e.ids), i = this.deflateTypedArray(e.ind);
3432
3874
  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();
3433
3875
  }
3434
3876
  writeJsonChunk(e, t, n) {
@@ -3581,7 +4023,7 @@ var Qi = "BMT", $i = 1, J = {
3581
4023
  let t = /* @__PURE__ */ new Map();
3582
4024
  return (Array.isArray(e) ? e : [e]).forEach((e) => {
3583
4025
  e.traverse((e) => {
3584
- if (!(e instanceof M) || !this.isIfcSpaceObject(e)) return;
4026
+ if (!(e instanceof N) || !this.isIfcSpaceObject(e)) return;
3585
4027
  let n = this.getObjectModelID(e);
3586
4028
  if (n === null) return;
3587
4029
  let r = e.geometry.getAttribute("ids");
@@ -3595,7 +4037,7 @@ var Qi = "BMT", $i = 1, J = {
3595
4037
  addVisibleIdsFromObject3D(e, t) {
3596
4038
  (Array.isArray(e) ? e : [e]).forEach((e) => {
3597
4039
  e.traverse((e) => {
3598
- if (!(e instanceof M) || !this.isObjectVisible(e)) return;
4040
+ if (!(e instanceof N) || !this.isObjectVisible(e)) return;
3599
4041
  let n = this.getObjectModelID(e);
3600
4042
  if (n === null) return;
3601
4043
  let r = e.geometry.getAttribute("ids");
@@ -3664,43 +4106,43 @@ var Qi = "BMT", $i = 1, J = {
3664
4106
  isRecord(e) {
3665
4107
  return typeof e == "object" && !!e;
3666
4108
  }
3667
- }, ia = new ra();
3668
- async function aa(e, t) {
3669
- return ia.ConvertIfcFileToBmt(e, t);
4109
+ }, Na = new Ma();
4110
+ async function Pa(e, t) {
4111
+ return Na.ConvertIfcFileToBmt(e, t);
3670
4112
  }
3671
- function oa(e, t) {
3672
- return ia.ConvertToBmt(e, t);
4113
+ function Fa(e, t) {
4114
+ return Na.ConvertToBmt(e, t);
3673
4115
  }
3674
4116
  //#endregion
3675
4117
  //#region src/viewer/Selector/FilteredElementsCollector.ts
3676
- function Y(e) {
4118
+ function Ia(e) {
3677
4119
  return !!e && typeof e == "object" && !Array.isArray(e);
3678
4120
  }
3679
- function sa(e) {
4121
+ function La(e) {
3680
4122
  let t = Number(e);
3681
4123
  return Number.isFinite(t) ? t : null;
3682
4124
  }
3683
- function ca(e) {
3684
- return Y(e) && Y(e.data) && Y(e.props) && "structure" in e;
4125
+ function Ra(e) {
4126
+ return Ia(e) && Ia(e.data) && Ia(e.props) && "structure" in e;
3685
4127
  }
3686
- function la(e) {
3687
- return Y(e) && ("guid" in e || "id" in e || "props" in e || "sets" in e);
4128
+ function za(e) {
4129
+ return Ia(e) && ("guid" in e || "id" in e || "props" in e || "sets" in e);
3688
4130
  }
3689
- function ua(e) {
3690
- if (!Y(e)) return !1;
4131
+ function Ba(e) {
4132
+ if (!Ia(e)) return !1;
3691
4133
  let t = Object.entries(e);
3692
- return t.length ? t.every(([e, t]) => sa(e) !== null && la(t)) : !0;
4134
+ return t.length ? t.every(([e, t]) => La(e) !== null && za(t)) : !0;
3693
4135
  }
3694
- function da(e) {
4136
+ function Va(e) {
3695
4137
  return typeof e == "string" ? e : null;
3696
4138
  }
3697
- function fa(e) {
3698
- let t = Y(e.props.props) ? e.props.props : {};
3699
- return da(e.props.type ?? e.props.Type ?? t.type ?? t.Type);
4139
+ function Ha(e) {
4140
+ let t = Ia(e.props.props) ? e.props.props : {};
4141
+ return Va(e.props.type ?? e.props.Type ?? t.type ?? t.Type);
3700
4142
  }
3701
- function pa(e, t, n) {
4143
+ function Ua(e, t, n) {
3702
4144
  Object.entries(n).forEach(([n, r]) => {
3703
- let i = sa(n);
4145
+ let i = La(n);
3704
4146
  i !== null && e.push({
3705
4147
  elementID: i,
3706
4148
  modelID: t,
@@ -3708,29 +4150,29 @@ function pa(e, t, n) {
3708
4150
  });
3709
4151
  });
3710
4152
  }
3711
- function ma(e) {
3712
- if (!e || !Y(e)) return [];
3713
- if (ca(e)) {
4153
+ function Wa(e) {
4154
+ if (!e || !Ia(e)) return [];
4155
+ if (Ra(e)) {
3714
4156
  let t = [];
3715
- return pa(t, 0, e.props), t;
4157
+ return Ua(t, 0, e.props), t;
3716
4158
  }
3717
- if (ua(e)) {
4159
+ if (Ba(e)) {
3718
4160
  let t = [];
3719
- return pa(t, 0, e), t;
4161
+ return Ua(t, 0, e), t;
3720
4162
  }
3721
4163
  let t = [];
3722
4164
  return Object.entries(e).forEach(([e, n]) => {
3723
- let r = sa(e);
4165
+ let r = La(e);
3724
4166
  if (r !== null) {
3725
- if (ca(n)) {
3726
- pa(t, r, n.props);
4167
+ if (Ra(n)) {
4168
+ Ua(t, r, n.props);
3727
4169
  return;
3728
4170
  }
3729
- ua(n) && pa(t, r, n);
4171
+ Ba(n) && Ua(t, r, n);
3730
4172
  }
3731
4173
  }), t;
3732
4174
  }
3733
- function ha(e) {
4175
+ function Ga(e) {
3734
4176
  let t = {};
3735
4177
  return e.forEach(({ elementID: e, modelID: n, props: r }) => {
3736
4178
  t[n] ??= [], t[n].push({
@@ -3739,26 +4181,26 @@ function ha(e) {
3739
4181
  });
3740
4182
  }), t;
3741
4183
  }
3742
- function ga(e) {
4184
+ function Ka(e) {
3743
4185
  let t = {};
3744
4186
  return e.forEach(({ elementID: e, modelID: n }) => {
3745
4187
  t[n] ??= [], t[n].push(e);
3746
4188
  }), t;
3747
4189
  }
3748
- var _a = class {
4190
+ var qa = class {
3749
4191
  elements;
3750
4192
  filters = [];
3751
4193
  selectedModelIDs = null;
3752
4194
  constructor(e) {
3753
- this.elements = ma(e);
4195
+ this.elements = Wa(e);
3754
4196
  }
3755
4197
  from(e) {
3756
- return this.elements = ma(e), this.filters = [], this.selectedModelIDs = null, this;
4198
+ return this.elements = Wa(e), this.filters = [], this.selectedModelIDs = null, this;
3757
4199
  }
3758
4200
  ofType(e) {
3759
4201
  let t = new Set((Array.isArray(e) ? e : [e]).map((e) => e.toLowerCase()));
3760
4202
  return this.filters.push((e) => {
3761
- let n = fa(e);
4203
+ let n = Ha(e);
3762
4204
  return !!(n && t.has(n.toLowerCase()));
3763
4205
  }), this;
3764
4206
  }
@@ -3787,11 +4229,11 @@ var _a = class {
3787
4229
  return this.hasSingleSelectedModel() ? e.map(({ elementID: e, props: t }) => ({
3788
4230
  elementID: e,
3789
4231
  props: t
3790
- })) : ha(e);
4232
+ })) : Ga(e);
3791
4233
  }
3792
4234
  toElementsIds() {
3793
4235
  let e = this.getFilteredElements();
3794
- return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) : ga(e);
4236
+ return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) : Ka(e);
3795
4237
  }
3796
4238
  toElementIds() {
3797
4239
  return this.toElementsIds();
@@ -3799,20 +4241,20 @@ var _a = class {
3799
4241
  };
3800
4242
  //#endregion
3801
4243
  //#region src/viewer/api/ViewerApi.ts
3802
- function va(e) {
4244
+ function Ja(e) {
3803
4245
  let t = {};
3804
4246
  return Object.entries(e).forEach(([e, n]) => {
3805
4247
  t[Number(e)] = Array.from(n);
3806
4248
  }), t;
3807
4249
  }
3808
- function ya(e) {
4250
+ function Ya(e) {
3809
4251
  let t = {};
3810
4252
  return Object.entries(e).forEach(([e, n]) => {
3811
4253
  t[Number(e)] = new Set(n);
3812
4254
  }), t;
3813
4255
  }
3814
- function ba(e, t) {
3815
- let n = new ra();
4256
+ function Xa(e, t) {
4257
+ let n = new Ma();
3816
4258
  return {
3817
4259
  camera: {
3818
4260
  fitCamera: () => {
@@ -3830,12 +4272,16 @@ function ba(e, t) {
3830
4272
  t()?.clipping.deleteAllPlanes();
3831
4273
  },
3832
4274
  getActive: () => t()?.clipping.getActive() ?? !1,
4275
+ getCapsActive: () => t()?.clipping.getCapsActive() ?? !1,
3833
4276
  getEdgesActive: () => t()?.clipping.getEdgesActive() ?? !1,
3834
4277
  getHelpersActive: () => t()?.clipping.getHelpersActive() ?? !1,
3835
4278
  getPlanes: () => t()?.clipping.getPlanes() ?? [],
3836
4279
  setActive: (e) => {
3837
4280
  t()?.clipping.setActive(e);
3838
4281
  },
4282
+ setCapsActive: (e) => {
4283
+ t()?.clipping.setCapsActive(e);
4284
+ },
3839
4285
  setEdgesActive: (e) => {
3840
4286
  t()?.clipping.setEdgesActive(e);
3841
4287
  },
@@ -3954,16 +4400,16 @@ function ba(e, t) {
3954
4400
  t()?.geometryUtils.toggleIIfcSpacesVisibility();
3955
4401
  }
3956
4402
  },
3957
- properties: Zi(e),
4403
+ properties: Ta(e),
3958
4404
  selector: {
3959
4405
  addSelected: (n, r, i = !0, a = !1) => {
3960
4406
  let o = i || a;
3961
- e.getState().addSelected(n, r), o && t()?.selector.setTargetToSelection(va(e.getState().selected), a);
4407
+ e.getState().addSelected(n, r), o && t()?.selector.setTargetToSelection(Ja(e.getState().selected), a);
3962
4408
  },
3963
- collector: () => new _a(e.getState().modelProps),
4409
+ collector: () => new qa(e.getState().modelProps),
3964
4410
  getPreselectionColor: () => e.getState().preselectionColor,
3965
4411
  getSelectionColor: () => e.getState().selectionColor,
3966
- getSelected: () => va(e.getState().selected),
4412
+ getSelected: () => Ja(e.getState().selected),
3967
4413
  removeSelected: (t, n) => {
3968
4414
  e.getState().removeSelected(t, n);
3969
4415
  },
@@ -3978,7 +4424,7 @@ function ba(e, t) {
3978
4424
  },
3979
4425
  setSelected: (n, r, i = !1, a = !0, o = !1) => {
3980
4426
  let s = a || o;
3981
- e.getState().setSelected(n, r, i), s && t()?.selector.setTargetToSelection(va(e.getState().selected), o);
4427
+ e.getState().setSelected(n, r, i), s && t()?.selector.setTargetToSelection(Ja(e.getState().selected), o);
3982
4428
  }
3983
4429
  },
3984
4430
  utils: {
@@ -4023,7 +4469,7 @@ function ba(e, t) {
4023
4469
  }
4024
4470
  //#endregion
4025
4471
  //#region src/viewer/Loaders/BmtLoader.ts
4026
- var xa = class {
4472
+ var Za = class {
4027
4473
  view;
4028
4474
  offset = 0;
4029
4475
  constructor(e) {
@@ -4043,7 +4489,7 @@ var xa = class {
4043
4489
  eof() {
4044
4490
  return this.offset >= this.view.byteLength;
4045
4491
  }
4046
- }, Sa = class {
4492
+ }, Qa = class {
4047
4493
  decodeBuffer(e) {
4048
4494
  return this.textDecoder.decode(we.inflate(e));
4049
4495
  }
@@ -4116,7 +4562,7 @@ var xa = class {
4116
4562
  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;
4117
4563
  }
4118
4564
  parseBinaryFile(e, t = {}) {
4119
- let n = new xa(e);
4565
+ let n = new Za(e);
4120
4566
  if (new TextDecoder().decode(n.readBytes(3)) !== "BMT") throw Error("Invalid file");
4121
4567
  let r = n.readUint8();
4122
4568
  console.log(`model version: ${r}`);
@@ -4184,24 +4630,24 @@ var xa = class {
4184
4630
  };
4185
4631
  //#endregion
4186
4632
  //#region src/viewer/workers/BMTWorker.ts?worker
4187
- function Ca(e) {
4633
+ function $a(e) {
4188
4634
  return new Worker("" + new URL("assets/BMTWorker-yhSXOg2i.js", import.meta.url).href, { name: e?.name });
4189
4635
  }
4190
4636
  //#endregion
4191
4637
  //#region src/viewer/workers/BMTWorkerClient.ts
4192
- function wa() {
4638
+ function eo() {
4193
4639
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
4194
4640
  }
4195
- function Ta(e) {
4641
+ function to(e) {
4196
4642
  return Array.isArray(e) ? e : [e];
4197
4643
  }
4198
- function Ea(e) {
4644
+ function no(e) {
4199
4645
  return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.bmt";
4200
4646
  }
4201
- function Da(e) {
4647
+ function ro(e) {
4202
4648
  return typeof e == "string" ? {
4203
4649
  kind: "url",
4204
- name: Ea(e),
4650
+ name: no(e),
4205
4651
  url: new URL(e, globalThis.location.href).href
4206
4652
  } : e instanceof File ? {
4207
4653
  file: e,
@@ -4212,18 +4658,18 @@ function Da(e) {
4212
4658
  kind: "buffer"
4213
4659
  };
4214
4660
  }
4215
- function Oa(e) {
4661
+ function io(e) {
4216
4662
  return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
4217
4663
  }
4218
- function ka() {
4219
- return new Ca();
4664
+ function ao() {
4665
+ return new $a();
4220
4666
  }
4221
- function Aa(e) {
4667
+ function oo(e) {
4222
4668
  return { streamGeometryChunks: e.streamGeometryChunks ?? !!e.onChunk };
4223
4669
  }
4224
- function ja(e, t = {}) {
4225
- let n = t.worker ?? ka(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = Ta(e).map(Da), o = wa(), s = {}, c = {
4226
- options: Aa(t),
4670
+ function so(e, t = {}) {
4671
+ let n = t.worker ?? ao(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = to(e).map(ro), o = eo(), s = {}, c = {
4672
+ options: oo(t),
4227
4673
  sources: a,
4228
4674
  taskId: o,
4229
4675
  type: "load-bmt-model"
@@ -4261,39 +4707,39 @@ function ja(e, t = {}) {
4261
4707
  let a = Error(r.error.message);
4262
4708
  r.error.stack && (a.stack = r.error.stack), l(a);
4263
4709
  };
4264
- n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, Oa(a));
4710
+ n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, io(a));
4265
4711
  });
4266
4712
  }
4267
- function Ma() {
4268
- return ka();
4713
+ function co() {
4714
+ return ao();
4269
4715
  }
4270
4716
  //#endregion
4271
4717
  //#region src/viewer/workers/BmtConverterWorker.ts?worker
4272
- function Na(e) {
4718
+ function lo(e) {
4273
4719
  return new Worker("" + new URL("assets/BmtConverterWorker-BHhPlty_.js", import.meta.url).href, { name: e?.name });
4274
4720
  }
4275
4721
  //#endregion
4276
4722
  //#region src/viewer/workers/BmtConverterWorkerClient.ts
4277
- function Pa() {
4723
+ function uo() {
4278
4724
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
4279
4725
  }
4280
- function Fa(e) {
4726
+ function fo(e) {
4281
4727
  return Array.isArray(e) ? e : [e];
4282
4728
  }
4283
- function Ia(e) {
4729
+ function po(e) {
4284
4730
  return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
4285
4731
  }
4286
- function La() {
4732
+ function mo() {
4287
4733
  return globalThis.document?.baseURI ?? globalThis.location.href;
4288
4734
  }
4289
- function Ra(e) {
4735
+ function ho(e) {
4290
4736
  let t = e ?? "ifc-parser.wasm";
4291
- return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, La()).href;
4737
+ return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, mo()).href;
4292
4738
  }
4293
- function za(e) {
4739
+ function go(e) {
4294
4740
  return typeof e == "string" ? {
4295
4741
  kind: "url",
4296
- name: Ia(e),
4742
+ name: po(e),
4297
4743
  url: new URL(e, globalThis.location.href).href
4298
4744
  } : e instanceof File ? {
4299
4745
  file: e,
@@ -4304,13 +4750,13 @@ function za(e) {
4304
4750
  kind: "buffer"
4305
4751
  };
4306
4752
  }
4307
- function Ba(e) {
4753
+ function _o(e) {
4308
4754
  return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
4309
4755
  }
4310
- function Va() {
4311
- return new Na();
4756
+ function vo() {
4757
+ return new lo();
4312
4758
  }
4313
- function Ha(e) {
4759
+ function yo(e) {
4314
4760
  return {
4315
4761
  chunk: e.chunk,
4316
4762
  coordinationMatrix: e.coordinationMatrix,
@@ -4322,23 +4768,23 @@ function Ha(e) {
4322
4768
  useIfcSpace: e.useIfcSpace,
4323
4769
  useMinVersion: e.useMinVersion,
4324
4770
  visibleIdsByModel: e.visibleIdsByModel,
4325
- wasmPath: Ra(e.wasmPath)
4771
+ wasmPath: ho(e.wasmPath)
4326
4772
  };
4327
4773
  }
4328
- function Ua(e) {
4774
+ function bo(e) {
4329
4775
  let t = new Uint8Array(e.bytes.byteLength);
4330
4776
  return t.set(e.bytes), {
4331
4777
  ...e,
4332
4778
  blob: new Blob([t.buffer], { type: e.mimeType })
4333
4779
  };
4334
4780
  }
4335
- function Wa(e) {
4781
+ function xo(e) {
4336
4782
  return {
4337
- files: e.result.files.map(Ua),
4783
+ files: e.result.files.map(bo),
4338
4784
  models: e.result.models
4339
4785
  };
4340
4786
  }
4341
- function Ga(e) {
4787
+ function So(e) {
4342
4788
  if (e.error instanceof Error) return e.error;
4343
4789
  let t = [
4344
4790
  e.message || "Unknown worker error",
@@ -4348,12 +4794,12 @@ function Ga(e) {
4348
4794
  ].filter(Boolean);
4349
4795
  return /* @__PURE__ */ Error(`BMT converter worker failed: ${t.join(", ")}`);
4350
4796
  }
4351
- function Ka(e) {
4797
+ function Co(e) {
4352
4798
  return /* @__PURE__ */ Error(`BMT converter worker response could not be cloned: ${String(e.data ?? "unknown message error")}`);
4353
4799
  }
4354
- function qa(e, t = {}) {
4355
- let n = t.worker ?? Va(), r = t.terminateOnComplete ?? !t.worker, i = Fa(e).map(za), a = Pa(), o = {
4356
- options: Ha(t),
4800
+ function wo(e, t = {}) {
4801
+ let n = t.worker ?? vo(), r = t.terminateOnComplete ?? !t.worker, i = fo(e).map(go), a = uo(), o = {
4802
+ options: yo(t),
4357
4803
  sources: i,
4358
4804
  taskId: a,
4359
4805
  type: "convert-ifc-to-bmt"
@@ -4362,9 +4808,9 @@ function qa(e, t = {}) {
4362
4808
  let c = () => {
4363
4809
  n.removeEventListener("message", d), n.removeEventListener("error", l), n.removeEventListener("messageerror", u), r && n.terminate();
4364
4810
  }, l = (e) => {
4365
- c(), s(Ga(e));
4811
+ c(), s(So(e));
4366
4812
  }, u = (e) => {
4367
- c(), s(Ka(e));
4813
+ c(), s(Co(e));
4368
4814
  }, d = (n) => {
4369
4815
  let r = n.data;
4370
4816
  if (r.taskId !== a) return;
@@ -4373,35 +4819,35 @@ function qa(e, t = {}) {
4373
4819
  return;
4374
4820
  }
4375
4821
  if (c(), r.type === "complete") {
4376
- e(Wa(r));
4822
+ e(xo(r));
4377
4823
  return;
4378
4824
  }
4379
4825
  let i = Error(r.error.message);
4380
4826
  r.error.stack && (i.stack = r.error.stack), s(i);
4381
4827
  };
4382
- n.addEventListener("message", d), n.addEventListener("error", l), n.addEventListener("messageerror", u), n.postMessage(o, Ba(i));
4828
+ n.addEventListener("message", d), n.addEventListener("error", l), n.addEventListener("messageerror", u), n.postMessage(o, _o(i));
4383
4829
  });
4384
4830
  }
4385
- function Ja() {
4386
- return Va();
4831
+ function To() {
4832
+ return vo();
4387
4833
  }
4388
4834
  //#endregion
4389
4835
  //#region src/viewer/workers/IFCWorker.ts?worker
4390
- function Ya(e) {
4836
+ function Eo(e) {
4391
4837
  return new Worker("" + new URL("assets/IFCWorker-DipGoUKy.js", import.meta.url).href, { name: e?.name });
4392
4838
  }
4393
4839
  //#endregion
4394
4840
  //#region src/viewer/workers/IFCWorkerClient.ts
4395
- function Xa() {
4841
+ function Do() {
4396
4842
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
4397
4843
  }
4398
- function Za(e) {
4844
+ function Oo(e) {
4399
4845
  return Array.isArray(e) ? e : [e];
4400
4846
  }
4401
- function Qa(e) {
4847
+ function ko(e) {
4402
4848
  return typeof e == "string" ? {
4403
4849
  kind: "url",
4404
- name: $a(e),
4850
+ name: Ao(e),
4405
4851
  url: new URL(e, globalThis.location.href).href
4406
4852
  } : e instanceof File ? {
4407
4853
  file: e,
@@ -4412,23 +4858,23 @@ function Qa(e) {
4412
4858
  kind: "buffer"
4413
4859
  };
4414
4860
  }
4415
- function $a(e) {
4861
+ function Ao(e) {
4416
4862
  return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
4417
4863
  }
4418
- function eo() {
4864
+ function jo() {
4419
4865
  return globalThis.document?.baseURI ?? globalThis.location.href;
4420
4866
  }
4421
- function to(e) {
4867
+ function Mo(e) {
4422
4868
  let t = e ?? "ifc-parser.wasm";
4423
- return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, eo()).href;
4869
+ return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, jo()).href;
4424
4870
  }
4425
- function no(e) {
4871
+ function No(e) {
4426
4872
  return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
4427
4873
  }
4428
- function ro() {
4429
- return new Ya();
4874
+ function Po() {
4875
+ return new Eo();
4430
4876
  }
4431
- function io(e) {
4877
+ function Fo(e) {
4432
4878
  return {
4433
4879
  chunk: e.chunk,
4434
4880
  coordinationMatrix: e.coordinationMatrix,
@@ -4437,12 +4883,12 @@ function io(e) {
4437
4883
  useIfcColors: e.useIfcColors,
4438
4884
  useIfcElementAssembly: e.useIfcElementAssembly,
4439
4885
  useIfcSpace: e.useIfcSpace,
4440
- wasmPath: to(e.wasmPath)
4886
+ wasmPath: Mo(e.wasmPath)
4441
4887
  };
4442
4888
  }
4443
- function ao(e, t = {}) {
4444
- let n = t.worker ?? ro(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = Za(e).map(Qa), o = Xa(), s = {}, c = {
4445
- options: io(t),
4889
+ function Io(e, t = {}) {
4890
+ let n = t.worker ?? Po(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = Oo(e).map(ko), o = Do(), s = {}, c = {
4891
+ options: Fo(t),
4446
4892
  sources: a,
4447
4893
  taskId: o,
4448
4894
  type: "load-ifc-model"
@@ -4480,34 +4926,34 @@ function ao(e, t = {}) {
4480
4926
  let a = Error(r.error.message);
4481
4927
  r.error.stack && (a.stack = r.error.stack), l(a);
4482
4928
  };
4483
- n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, no(a));
4929
+ n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, No(a));
4484
4930
  });
4485
4931
  }
4486
- function oo() {
4487
- return ro();
4932
+ function Lo() {
4933
+ return Po();
4488
4934
  }
4489
4935
  //#endregion
4490
4936
  //#region src/viewer/api/loader.ts
4491
- function so(e) {
4937
+ function Ro(e) {
4492
4938
  return typeof e == "string" ? e : e.name;
4493
4939
  }
4494
- function co(e) {
4495
- return (so(e).split(/[?#]/)[0].split(/[\\/]/).pop() || "model").replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "") || "model";
4940
+ function zo(e) {
4941
+ return (Ro(e).split(/[?#]/)[0].split(/[\\/]/).pop() || "model").replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "") || "model";
4496
4942
  }
4497
- function lo(e) {
4498
- let t = so(e).split(/[?#]/)[0].toLowerCase(), n = t.lastIndexOf(".");
4943
+ function Bo(e) {
4944
+ let t = Ro(e).split(/[?#]/)[0].toLowerCase(), n = t.lastIndexOf(".");
4499
4945
  return n === -1 ? "" : t.slice(n + 1);
4500
4946
  }
4501
- function uo(e) {
4947
+ function Vo(e) {
4502
4948
  return /\.min\.bmt$/i.test(e.name) ? e.name.replace(/\.min\.bmt$/i, "_props.json") : null;
4503
4949
  }
4504
- function fo(e) {
4505
- return /_props\.json$/i.test(so(e).split(/[?#]/)[0]);
4950
+ function Ho(e) {
4951
+ return /_props\.json$/i.test(Ro(e).split(/[?#]/)[0]);
4506
4952
  }
4507
- function po(e) {
4953
+ function Uo(e) {
4508
4954
  return e.coordinationMatrix ? e.coordinationMatrix : Object.values(e.data)[0]?.matrix || void 0;
4509
4955
  }
4510
- var mo = new class {
4956
+ var Wo = new class {
4511
4957
  coordinationMatrix;
4512
4958
  useIfcSpace = !0;
4513
4959
  bmtLoader = null;
@@ -4518,7 +4964,7 @@ var mo = new class {
4518
4964
  this.getBmtLoader();
4519
4965
  }
4520
4966
  getBmtLoader() {
4521
- return this.bmtLoader ||= new Sa(), this.bmtLoader;
4967
+ return this.bmtLoader ||= new Qa(), this.bmtLoader;
4522
4968
  }
4523
4969
  async getIfcLoader(e = {}) {
4524
4970
  if (!this.ifcLoader) {
@@ -4546,7 +4992,7 @@ var mo = new class {
4546
4992
  async loadBmtModel(e, t) {
4547
4993
  let n = this.getBmtLoader();
4548
4994
  if (typeof e == "string") return n.loadModel(e);
4549
- let r = n.parseBinaryFile(await e.arrayBuffer()), i = uo(e), a = i ? t.get(i) : void 0;
4995
+ let r = n.parseBinaryFile(await e.arrayBuffer()), i = Vo(e), a = i ? t.get(i) : void 0;
4550
4996
  return this.applyBmtMetadata(r, a);
4551
4997
  }
4552
4998
  createWorkerProgressHandler(e, t, n, r) {
@@ -4569,7 +5015,7 @@ var mo = new class {
4569
5015
  };
4570
5016
  }
4571
5017
  async loadIfcModelInWorker(e, t, n, r, i) {
4572
- return (await ao(e, {
5018
+ return (await Io(e, {
4573
5019
  chunk: t.chunk,
4574
5020
  collectChunks: t.collectWorkerChunks,
4575
5021
  coordinationMatrix: this.coordinationMatrix,
@@ -4582,14 +5028,14 @@ var mo = new class {
4582
5028
  }))[0];
4583
5029
  }
4584
5030
  async loadBmtModelInWorker(e, t, n, r, i, a) {
4585
- let o = (await ja(e, {
5031
+ let o = (await so(e, {
4586
5032
  collectChunks: n.collectWorkerChunks,
4587
5033
  onChunk: this.createWorkerChunkHandler(n, r),
4588
5034
  onProgress: this.createWorkerProgressHandler(n, r, i, a),
4589
5035
  streamGeometryChunks: n.streamGeometryChunks ?? !!n.onChunk
4590
5036
  }))[0];
4591
5037
  if (e instanceof File) {
4592
- let n = uo(e), r = n ? t.get(n) : void 0;
5038
+ let n = Vo(e), r = n ? t.get(n) : void 0;
4593
5039
  return this.applyBmtMetadata(o, r);
4594
5040
  }
4595
5041
  return o;
@@ -4609,21 +5055,21 @@ var mo = new class {
4609
5055
  }
4610
5056
  async loadModel(e, t = {}) {
4611
5057
  this.initLoaders();
4612
- let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !fo(e)).length, o = 0;
5058
+ let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !Ho(e)).length, o = 0;
4613
5059
  this.loadedModelCount === 0 && this.resetCoordinationMatrixState();
4614
5060
  for (let e = 0; e < n.length; e++) {
4615
- let s = n[e], c = lo(s), l;
4616
- if (c === "json" && fo(s)) continue;
5061
+ let s = n[e], c = Bo(s), l;
5062
+ if (c === "json" && Ho(s)) continue;
4617
5063
  let u = this.nextModelID, d = o;
4618
5064
  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];
4619
5065
  else if (c === "bmt") l = t.useWorker ? await this.loadBmtModelInWorker(s, r, t, u, d, a) : await this.loadBmtModel(s, r);
4620
- else throw Error(`Unsupported model format: ${so(s)}`);
4621
- let f = po(l);
4622
- !this.coordinationMatrix && f && (this.coordinationMatrix = f), !l.coordinationMatrix && this.coordinationMatrix && (l.coordinationMatrix = this.coordinationMatrix), this.applyRenderSettings(l, t), l.name ??= co(s), this.nextModelID += 1, this.loadedModelCount += 1, i[u] = l;
5066
+ else throw Error(`Unsupported model format: ${Ro(s)}`);
5067
+ let f = Uo(l);
5068
+ !this.coordinationMatrix && f && (this.coordinationMatrix = f), !l.coordinationMatrix && this.coordinationMatrix && (l.coordinationMatrix = this.coordinationMatrix), this.applyRenderSettings(l, t), l.name ??= zo(s), this.nextModelID += 1, this.loadedModelCount += 1, i[u] = l;
4623
5069
  }
4624
5070
  return i;
4625
5071
  }
4626
- }(), ho = .5, X = .04, Z = .16, go = Z, Q = ho * 2 - Z * 2, _o = ho - X / 2, vo = ho - Z / 2, yo = ho - go / 2, bo = .63, xo = "#dfe6ec", So = 260, Co = 52, wo = .17, To = new g(), $ = new de(), Eo = [
5072
+ }(), Go = .5, Ko = .04, X = .16, qo = X, Z = Go * 2 - X * 2, Jo = Go - Ko / 2, Yo = Go - X / 2, Xo = Go - qo / 2, Zo = .63, Qo = "#dfe6ec", $o = 260, es = 52, ts = .17, ns = new g(), Q = new ue(), rs = [
4627
5073
  {
4628
5074
  direction: [
4629
5075
  0,
@@ -4634,12 +5080,12 @@ var mo = new class {
4634
5080
  position: [
4635
5081
  0,
4636
5082
  0,
4637
- _o
5083
+ Jo
4638
5084
  ],
4639
5085
  scale: [
4640
- Q,
4641
- Q,
4642
- X
5086
+ Z,
5087
+ Z,
5088
+ Ko
4643
5089
  ],
4644
5090
  title: "Front",
4645
5091
  type: "face"
@@ -4654,7 +5100,7 @@ var mo = new class {
4654
5100
  position: [
4655
5101
  0,
4656
5102
  0,
4657
- -_o
5103
+ -Jo
4658
5104
  ],
4659
5105
  rotation: [
4660
5106
  0,
@@ -4662,9 +5108,9 @@ var mo = new class {
4662
5108
  0
4663
5109
  ],
4664
5110
  scale: [
4665
- Q,
4666
- Q,
4667
- X
5111
+ Z,
5112
+ Z,
5113
+ Ko
4668
5114
  ],
4669
5115
  title: "Back",
4670
5116
  type: "face"
@@ -4677,7 +5123,7 @@ var mo = new class {
4677
5123
  ],
4678
5124
  label: "right",
4679
5125
  position: [
4680
- _o,
5126
+ Jo,
4681
5127
  0,
4682
5128
  0
4683
5129
  ],
@@ -4687,9 +5133,9 @@ var mo = new class {
4687
5133
  0
4688
5134
  ],
4689
5135
  scale: [
4690
- X,
4691
- Q,
4692
- Q
5136
+ Ko,
5137
+ Z,
5138
+ Z
4693
5139
  ],
4694
5140
  title: "Right",
4695
5141
  type: "face"
@@ -4702,7 +5148,7 @@ var mo = new class {
4702
5148
  ],
4703
5149
  label: "left",
4704
5150
  position: [
4705
- -_o,
5151
+ -Jo,
4706
5152
  0,
4707
5153
  0
4708
5154
  ],
@@ -4712,9 +5158,9 @@ var mo = new class {
4712
5158
  0
4713
5159
  ],
4714
5160
  scale: [
4715
- X,
4716
- Q,
4717
- Q
5161
+ Ko,
5162
+ Z,
5163
+ Z
4718
5164
  ],
4719
5165
  title: "Left",
4720
5166
  type: "face"
@@ -4728,7 +5174,7 @@ var mo = new class {
4728
5174
  label: "top",
4729
5175
  position: [
4730
5176
  0,
4731
- _o,
5177
+ Jo,
4732
5178
  0
4733
5179
  ],
4734
5180
  rotation: [
@@ -4737,9 +5183,9 @@ var mo = new class {
4737
5183
  0
4738
5184
  ],
4739
5185
  scale: [
4740
- Q,
4741
- X,
4742
- Q
5186
+ Z,
5187
+ Ko,
5188
+ Z
4743
5189
  ],
4744
5190
  title: "Top",
4745
5191
  type: "face"
@@ -4753,7 +5199,7 @@ var mo = new class {
4753
5199
  label: "bot",
4754
5200
  position: [
4755
5201
  0,
4756
- -_o,
5202
+ -Jo,
4757
5203
  0
4758
5204
  ],
4759
5205
  rotation: [
@@ -4762,15 +5208,15 @@ var mo = new class {
4762
5208
  0
4763
5209
  ],
4764
5210
  scale: [
4765
- Q,
4766
- X,
4767
- Q
5211
+ Z,
5212
+ Ko,
5213
+ Z
4768
5214
  ],
4769
5215
  title: "Bottom",
4770
5216
  type: "face"
4771
5217
  }
4772
5218
  ];
4773
- function Do() {
5219
+ function is() {
4774
5220
  let e = [], t = [-1, 1];
4775
5221
  return t.forEach((n) => {
4776
5222
  t.forEach((t) => {
@@ -4782,13 +5228,13 @@ function Do() {
4782
5228
  ],
4783
5229
  position: [
4784
5230
  0,
4785
- n * vo,
4786
- t * vo
5231
+ n * Yo,
5232
+ t * Yo
4787
5233
  ],
4788
5234
  scale: [
4789
- Q,
4790
5235
  Z,
4791
- Z
5236
+ X,
5237
+ X
4792
5238
  ],
4793
5239
  title: `${n > 0 ? "Top" : "Bottom"} ${t > 0 ? "Front" : "Back"}`,
4794
5240
  type: "edge"
@@ -4803,14 +5249,14 @@ function Do() {
4803
5249
  t
4804
5250
  ],
4805
5251
  position: [
4806
- n * vo,
5252
+ n * Yo,
4807
5253
  0,
4808
- t * vo
5254
+ t * Yo
4809
5255
  ],
4810
5256
  scale: [
5257
+ X,
4811
5258
  Z,
4812
- Q,
4813
- Z
5259
+ X
4814
5260
  ],
4815
5261
  title: `${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
4816
5262
  type: "edge"
@@ -4825,14 +5271,14 @@ function Do() {
4825
5271
  0
4826
5272
  ],
4827
5273
  position: [
4828
- n * vo,
4829
- t * vo,
5274
+ n * Yo,
5275
+ t * Yo,
4830
5276
  0
4831
5277
  ],
4832
5278
  scale: [
4833
- Z,
4834
- Z,
4835
- Q
5279
+ X,
5280
+ X,
5281
+ Z
4836
5282
  ],
4837
5283
  title: `${t > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"}`,
4838
5284
  type: "edge"
@@ -4840,7 +5286,7 @@ function Do() {
4840
5286
  });
4841
5287
  }), e;
4842
5288
  }
4843
- function Oo() {
5289
+ function as() {
4844
5290
  let e = [], t = [-1, 1];
4845
5291
  return t.forEach((n) => {
4846
5292
  t.forEach((r) => {
@@ -4852,14 +5298,14 @@ function Oo() {
4852
5298
  t
4853
5299
  ],
4854
5300
  position: [
4855
- n * yo,
4856
- r * yo,
4857
- t * yo
5301
+ n * Xo,
5302
+ r * Xo,
5303
+ t * Xo
4858
5304
  ],
4859
5305
  scale: [
4860
- go,
4861
- go,
4862
- go
5306
+ qo,
5307
+ qo,
5308
+ qo
4863
5309
  ],
4864
5310
  title: `${r > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
4865
5311
  type: "corner"
@@ -4868,34 +5314,34 @@ function Oo() {
4868
5314
  });
4869
5315
  }), e;
4870
5316
  }
4871
- function ko(e) {
5317
+ function os(e) {
4872
5318
  e.stopPropagation(), e.nativeEvent.stopPropagation(), e.nativeEvent.stopImmediatePropagation?.();
4873
5319
  }
4874
- function Ao(e) {
4875
- return e ? "#4f7fa3" : xo;
5320
+ function ss(e) {
5321
+ return e ? "#4f7fa3" : Qo;
4876
5322
  }
4877
- function jo(e) {
5323
+ function cs(e) {
4878
5324
  return e ? 1 : .96;
4879
5325
  }
4880
- function Mo(e, t) {
5326
+ function ls(e, t) {
4881
5327
  let n = document.createElement("canvas"), r = n.getContext("2d");
4882
5328
  if (!r) throw Error("Could not create navigation cube label context");
4883
- let i = `600 ${Co}px system-ui, "Segoe UI", sans-serif`;
5329
+ let i = `600 ${es}px system-ui, "Segoe UI", sans-serif`;
4884
5330
  r.font = i;
4885
- let a = r.measureText(e), o = a.actualBoundingBoxAscent || Co * .8, s = a.actualBoundingBoxDescent || Co * .2, c = Math.ceil(a.width + 36), l = Math.ceil(o + s + 20);
5331
+ let a = r.measureText(e), o = a.actualBoundingBoxAscent || es * .8, s = a.actualBoundingBoxDescent || es * .2, c = Math.ceil(a.width + 36), l = Math.ceil(o + s + 20);
4886
5332
  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);
4887
5333
  let u = new b(n);
4888
- return u.colorSpace = ue, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
5334
+ return u.colorSpace = ce, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
4889
5335
  aspect: c / l,
4890
5336
  texture: u
4891
5337
  };
4892
5338
  }
4893
- function No({ color: e, label: t, position: n, rotation: r }) {
4894
- let { aspect: i, texture: a } = c(() => Mo(t, e), [e, t]);
4895
- return o(() => () => a.dispose(), [a]), /* @__PURE__ */ R("mesh", {
5339
+ function us({ color: e, label: t, position: n, rotation: r }) {
5340
+ let { aspect: i, texture: a } = c(() => ls(t, e), [e, t]);
5341
+ return o(() => () => a.dispose(), [a]), /* @__PURE__ */ V("mesh", {
4896
5342
  position: n,
4897
5343
  rotation: r,
4898
- children: [/* @__PURE__ */ L("planeGeometry", { args: [wo * i, wo] }), /* @__PURE__ */ L("meshBasicMaterial", {
5344
+ children: [/* @__PURE__ */ B("planeGeometry", { args: [ts * i, ts] }), /* @__PURE__ */ B("meshBasicMaterial", {
4899
5345
  alphaTest: .1,
4900
5346
  depthWrite: !1,
4901
5347
  map: a,
@@ -4904,54 +5350,54 @@ function No({ color: e, label: t, position: n, rotation: r }) {
4904
5350
  })]
4905
5351
  });
4906
5352
  }
4907
- function Po(e) {
4908
- return Math.abs(e.y) > .9 ? new I(0, 0, e.y > 0 ? -1 : 1) : new I(0, 1, 0);
5353
+ function ds(e) {
5354
+ return Math.abs(e.y) > .9 ? new z(0, 0, e.y > 0 ? -1 : 1) : new z(0, 1, 0);
4909
5355
  }
4910
- function Fo(e, t) {
5356
+ function fs(e, t) {
4911
5357
  let n = e.current;
4912
- return !n || (n.updateWorldMatrix(!0, !0), To.setFromObject(n), To.isEmpty()) ? ($.center.copy(t), $.radius = 10, $) : (To.getBoundingSphere($), (!Number.isFinite($.radius) || $.radius <= 0) && ($.radius = 10), $);
5358
+ return !n || (n.updateWorldMatrix(!0, !0), ns.setFromObject(n), ns.isEmpty()) ? (Q.center.copy(t), Q.radius = 10, Q) : (ns.getBoundingSphere(Q), (!Number.isFinite(Q.radius) || Q.radius <= 0) && (Q.radius = 10), Q);
4913
5359
  }
4914
- function Io(e) {
4915
- return e.current?.getTarget(new I()) ?? new I();
5360
+ function ps(e) {
5361
+ return e.current?.getTarget(new z()) ?? new z();
4916
5362
  }
4917
- function Lo({ camera: e, controlRef: t, direction: n, modelRef: r, transitionRef: i }) {
4918
- let a = Io(t), o = Fo(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);
5363
+ function ms({ camera: e, controlRef: t, direction: n, modelRef: r, transitionRef: i }) {
5364
+ let a = ps(t), o = fs(r, a), s = o.center.clone(), c = new z(...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);
4919
5365
  t.current?.cancel(), t.current?.setFocalOffset(0, 0, 0, !1), i.current = {
4920
5366
  endPosition: d,
4921
5367
  endTarget: s,
4922
- endUp: Po(c),
5368
+ endUp: ds(c),
4923
5369
  startPosition: e.position.clone(),
4924
5370
  startTarget: a,
4925
5371
  startTime: performance.now(),
4926
5372
  startUp: e.up.clone()
4927
5373
  };
4928
5374
  }
4929
- function Ro({ action: e, onPick: t }) {
5375
+ function hs({ action: e, onPick: t }) {
4930
5376
  let [n, r] = u(!1);
4931
- return /* @__PURE__ */ R("group", {
5377
+ return /* @__PURE__ */ V("group", {
4932
5378
  position: e.position,
4933
- onClick: ko,
5379
+ onClick: os,
4934
5380
  onPointerDown: (n) => {
4935
- ko(n), t(e);
5381
+ os(n), t(e);
4936
5382
  },
4937
5383
  onPointerEnter: (e) => {
4938
- ko(e), r(!0);
5384
+ os(e), r(!0);
4939
5385
  },
4940
5386
  onPointerLeave: (e) => {
4941
- ko(e), r(!1);
5387
+ os(e), r(!1);
4942
5388
  },
4943
- children: [/* @__PURE__ */ R("mesh", {
5389
+ children: [/* @__PURE__ */ V("mesh", {
4944
5390
  scale: e.scale,
4945
- children: [/* @__PURE__ */ L("boxGeometry", { args: [
5391
+ children: [/* @__PURE__ */ B("boxGeometry", { args: [
4946
5392
  1,
4947
5393
  1,
4948
5394
  1
4949
- ] }), /* @__PURE__ */ L("meshBasicMaterial", {
4950
- color: Ao(n),
4951
- opacity: jo(n),
5395
+ ] }), /* @__PURE__ */ B("meshBasicMaterial", {
5396
+ color: ss(n),
5397
+ opacity: cs(n),
4952
5398
  transparent: !0
4953
5399
  })]
4954
- }), e.label && /* @__PURE__ */ L(No, {
5400
+ }), e.label && /* @__PURE__ */ B(us, {
4955
5401
  color: n ? "#ffffff" : "#50606f",
4956
5402
  label: e.label,
4957
5403
  position: [
@@ -4963,11 +5409,11 @@ function Ro({ action: e, onPick: t }) {
4963
5409
  })]
4964
5410
  });
4965
5411
  }
4966
- function zo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
5412
+ function gs({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4967
5413
  let i = l(null), a = l(null), o = c(() => [
4968
- ...Eo,
4969
- ...Do(),
4970
- ...Oo()
5414
+ ...rs,
5415
+ ...is(),
5416
+ ...as()
4971
5417
  ], []);
4972
5418
  return f(() => {
4973
5419
  if (!e) return;
@@ -4976,20 +5422,20 @@ function zo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4976
5422
  i.current && i.current.quaternion.copy(r.quaternion).invert();
4977
5423
  let o = a.current;
4978
5424
  if (!o) return;
4979
- let s = performance.now() - o.startTime, c = Math.min(s / So, 1), l = 1 - (1 - c) ** 3, u = n.current;
5425
+ let s = performance.now() - o.startTime, c = Math.min(s / $o, 1), l = 1 - (1 - c) ** 3, u = n.current;
4980
5426
  if (r.position.lerpVectors(o.startPosition, o.endPosition, l), r.up.lerpVectors(o.startUp, o.endUp, l), u) {
4981
- let e = new I().lerpVectors(o.startTarget, o.endTarget, l);
5427
+ let e = new z().lerpVectors(o.startTarget, o.endTarget, l);
4982
5428
  u.setLookAt(r.position.x, r.position.y, r.position.z, e.x, e.y, e.z, !1);
4983
5429
  } else r.lookAt(o.endTarget);
4984
5430
  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);
4985
- }), e ? /* @__PURE__ */ L("group", {
5431
+ }), e ? /* @__PURE__ */ B("group", {
4986
5432
  ref: i,
4987
- scale: bo,
4988
- children: o.map((e) => /* @__PURE__ */ L(Ro, {
5433
+ scale: Zo,
5434
+ children: o.map((e) => /* @__PURE__ */ B(hs, {
4989
5435
  action: e,
4990
5436
  onPick: (e) => {
4991
5437
  let i = t.current;
4992
- i && Lo({
5438
+ i && ms({
4993
5439
  camera: i,
4994
5440
  controlRef: n,
4995
5441
  direction: e.direction,
@@ -5002,13 +5448,13 @@ function zo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
5002
5448
  }
5003
5449
  //#endregion
5004
5450
  //#region src/viewer/Viewer.tsx
5005
- var Bo = class {
5451
+ var _s = class {
5006
5452
  sceneApi = null;
5007
5453
  get = () => this.sceneApi;
5008
5454
  set = (e) => {
5009
5455
  this.sceneApi = e;
5010
5456
  };
5011
- }, Vo = {
5457
+ }, vs = {
5012
5458
  bottom: 16,
5013
5459
  height: 96,
5014
5460
  pointerEvents: "auto",
@@ -5017,11 +5463,11 @@ var Bo = class {
5017
5463
  touchAction: "none",
5018
5464
  width: 96,
5019
5465
  zIndex: 2
5020
- }, Ho = {
5466
+ }, ys = {
5021
5467
  height: "100%",
5022
5468
  position: "relative",
5023
5469
  width: "100%"
5024
- }, Uo = {
5470
+ }, bs = {
5025
5471
  far: 50,
5026
5472
  near: .1,
5027
5473
  position: [
@@ -5030,49 +5476,49 @@ var Bo = class {
5030
5476
  10
5031
5477
  ],
5032
5478
  zoom: 72
5033
- }, Wo = {
5479
+ }, xs = {
5034
5480
  alpha: !0,
5035
5481
  antialias: !0
5036
- }, Go = {
5482
+ }, Ss = {
5037
5483
  alpha: !0,
5038
5484
  antialias: !1,
5039
5485
  powerPreference: "high-performance"
5040
- }, Ko = {
5486
+ }, Cs = {
5041
5487
  antialias: !1,
5042
5488
  powerPreference: "high-performance"
5043
- }, qo = .1, Jo = .02, Yo = 1e3, Xo = 50, Zo = .08, Qo = new g(), $o = new de(), es = new I();
5044
- function ts(e, t) {
5489
+ }, ws = .1, Ts = .02, Es = 1e3, Ds = 50, Os = 1.25, ks = .08, As = new g(), js = new ue(), $ = new z(), Ms = new z(), Ns = new z();
5490
+ function Ps(e, t) {
5045
5491
  return Array.isArray(e) ? [Math.min(e[0], t), Math.min(e[1], t)] : typeof e == "number" ? Math.min(e, t) : t;
5046
5492
  }
5047
- function ns() {
5493
+ function Fs() {
5048
5494
  let e = navigator, t = navigator.userAgent.toLowerCase(), n = navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, r = window.matchMedia?.("(pointer: coarse)").matches ?? !1;
5049
5495
  return e.userAgentData?.mobile || n || /android|iphone|ipad|ipod|mobile|tablet/.test(t) || navigator.maxTouchPoints > 1 && r ? "mobile" : "pc";
5050
5496
  }
5051
- function rs(e) {
5052
- let t = is(e);
5053
- return t ? Math.max(t.radius * Jo, qo) : qo;
5497
+ function Is(e) {
5498
+ let t = Ls(e);
5499
+ return t ? Math.max(t.radius * Ts, ws) : ws;
5054
5500
  }
5055
- function is(e) {
5056
- if (!e || (Qo.setFromObject(e), Qo.isEmpty())) return null;
5057
- let t = Qo.getBoundingSphere($o);
5501
+ function Ls(e) {
5502
+ if (!e || (As.setFromObject(e), As.isEmpty())) return null;
5503
+ let t = As.getBoundingSphere(js);
5058
5504
  return !Number.isFinite(t.radius) || t.radius <= 0 ? null : t;
5059
5505
  }
5060
- function as(e) {
5506
+ function Rs(e) {
5061
5507
  return e.type === "Group" && typeof e.userData.modelID == "number";
5062
5508
  }
5063
- function os(e) {
5064
- return e?.children.filter(as) ?? [];
5509
+ function zs(e) {
5510
+ return e?.children.filter(Rs) ?? [];
5065
5511
  }
5066
- function ss(e, t) {
5067
- return os(e).find((e) => e.userData.modelID === t) ?? null;
5512
+ function Bs(e, t) {
5513
+ return zs(e).find((e) => e.userData.modelID === t) ?? null;
5068
5514
  }
5069
- function cs(e, t) {
5070
- let n = is(t);
5515
+ function Vs(e, t) {
5516
+ let n = Ls(t);
5071
5517
  if (!n) return;
5072
- let r = Math.max(Yo, n.radius * Xo, e.near + 1);
5518
+ let r = Math.max(Es, n.radius * Ds, e.near + 1);
5073
5519
  Math.abs(e.far - r) < 1 || (e.far = r, e.updateProjectionMatrix());
5074
5520
  }
5075
- function ls(e, t, n, r, i) {
5521
+ function Hs(e, t, n, r, i) {
5076
5522
  let a = n.elementIndex.get(i);
5077
5523
  a && a.forEach((n) => {
5078
5524
  let { record: i, vertexRanges: a } = n;
@@ -5084,66 +5530,72 @@ function ls(e, t, n, r, i) {
5084
5530
  }));
5085
5531
  });
5086
5532
  }
5087
- function us(e, t) {
5088
- let n = new g(), r = new I();
5533
+ function Us(e, t) {
5534
+ let n = new g(), r = new z();
5089
5535
  return Object.entries(e).forEach(([e, i]) => {
5090
5536
  let a = Number(e);
5091
5537
  i.forEach((e) => {
5092
- ls(n, r, t, a, e);
5538
+ Hs(n, r, t, a, e);
5093
5539
  });
5094
5540
  }), n.isEmpty() ? null : n;
5095
5541
  }
5096
- function ds(e) {
5097
- let t = e.getSize(es), n = Math.max(t.x, t.y, t.z);
5098
- return Number.isFinite(n) && n > 0 ? n * Zo : qo;
5542
+ function Ws(e) {
5543
+ let t = e.getSize(Ns), n = Math.max(t.x, t.y, t.z);
5544
+ return Number.isFinite(n) && n > 0 ? n * ks : ws;
5099
5545
  }
5100
- function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, publicApi: f, setSceneApi: g }) {
5101
- let _ = p((e) => e.camera), v = p((e) => e.gl), y = Mt(s), b = Ut(y), { colorPaletteTexture: x, colorUtils: S } = Ge(y), C = Bn(s), w = vn(s, n, C), T = Nn(s, n, C), E = c(() => new ra(), []), D = b.buildIndex, ee = y.resetIndex, te = S.applyStoredColors, ne = Fr(), O = l(null), k = l(!1), A = z((e) => e.showStats), re = c(() => {
5546
+ function Gs(e, t, n) {
5547
+ let r = Math.max(ws, (Number.isFinite(n) ? n : ws) * Os), i = t.position.distanceTo(e);
5548
+ return Number.isFinite(i) && i >= r ? e : ($.copy(e).sub(t.position), (!Number.isFinite($.x + $.y + $.z) || $.lengthSq() === 0) && t.getWorldDirection($), $.lengthSq() === 0 && $.set(0, 0, -1), $.normalize(), Ms.copy(t.position).addScaledVector($, r));
5549
+ }
5550
+ function Ks({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, publicApi: f, setSceneApi: g }) {
5551
+ let _ = p((e) => e.camera), v = p((e) => e.gl), y = Mt(s), b = Wt(y), { colorPaletteTexture: x, colorUtils: S } = Ge(y), C = pr(s), w = Gn(s, n, C), T = or(s, n, C, w.getSelectableObjects), E = c(() => new Ma(), []), D = b.buildIndex, O = y.resetIndex, ee = S.applyStoredColors, te = li(), k = l(null), ne = l(!1), A = H((e) => e.showStats), j = c(() => {
5102
5552
  let e = Object.keys(u).sort((e, t) => Number(e) - Number(t));
5103
5553
  for (let t of e) {
5104
5554
  let e = St(u[Number(t)]);
5105
5555
  if (e) return e;
5106
5556
  }
5107
5557
  return null;
5108
- }, [u]), j = c(() => bt(re ?? void 0), [re]), M = c(() => Object.entries(u).map(([e, t]) => [Number(e), t]), [u]), N = i(() => {
5109
- n.current && (n.current.minDistance = rs(s.current));
5110
- }, [n, s]), P = i((e) => {
5111
- let t = n.current;
5112
- t && (t.cancel(), t.setOrbitPoint(e.x, e.y, e.z));
5113
- }, [n]), ie = i((e) => {
5114
- O.current = e.clone(), P(e);
5115
- }, [P]), ae = i(() => {
5116
- O.current = null, ne(s, n, r);
5558
+ }, [u]), M = c(() => bt(j ?? void 0), [j]), N = c(() => Object.entries(u).map(([e, t]) => [Number(e), t]), [u]), P = i(() => {
5559
+ n.current && (n.current.minDistance = Is(s.current));
5560
+ }, [n, s]), F = i((e, t = !1) => {
5561
+ let r = n.current;
5562
+ if (!r) return !1;
5563
+ let i = t ? Gs(e, _, r.minDistance) : e;
5564
+ return r.cancel(), r.setOrbitPoint(i.x, i.y, i.z), !0;
5565
+ }, [_, n]), re = i((e) => {
5566
+ k.current = e.clone(), F(e, !0);
5567
+ }, [F]), I = i(() => {
5568
+ k.current = null, te(s, n, r);
5117
5569
  }, [
5118
5570
  n,
5119
- ne,
5571
+ te,
5120
5572
  r,
5121
5573
  s
5122
- ]), ce = i((e, t = !1) => {
5574
+ ]), L = i((e, t = !1) => {
5123
5575
  let r = n.current;
5124
5576
  if (!r) return;
5125
- let i = us(e, y.buildIndex());
5577
+ let i = Us(e, y.buildIndex());
5126
5578
  if (!i) return;
5127
- let a = i.getCenter(new I());
5128
- if (O.current = a.clone(), r.cancel(), t) {
5129
- let e = ds(i);
5579
+ let a = i.getCenter(new z());
5580
+ if (k.current = a.clone(), r.cancel(), t) {
5581
+ let e = Ws(i);
5130
5582
  r.fitToBox(i, !0, {
5131
5583
  paddingBottom: e,
5132
5584
  paddingLeft: e,
5133
5585
  paddingRight: e,
5134
5586
  paddingTop: e
5135
5587
  }).then(() => {
5136
- let e = O.current;
5137
- e && r.setOrbitPoint(e.x, e.y, e.z);
5588
+ let e = k.current;
5589
+ e && F(e, !0);
5138
5590
  });
5139
5591
  return;
5140
5592
  }
5141
- P(a);
5593
+ F(a, !0);
5142
5594
  }, [
5143
- P,
5595
+ F,
5144
5596
  n,
5145
5597
  y
5146
- ]), le = c(() => {
5598
+ ]), oe = c(() => {
5147
5599
  let e = (e) => ({
5148
5600
  ...e,
5149
5601
  activeViewRoot: s.current
@@ -5157,47 +5609,47 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5157
5609
  s,
5158
5610
  u
5159
5611
  ]);
5160
- return Mr(s, n, C, ie), Fn(), o(() => {
5612
+ return oi(s, n, C, re, w.getSelectableObjects, w.setCapsPreselection), cr(), o(() => {
5161
5613
  let e = v.domElement, t = (e) => {
5162
- let t = O.current;
5163
- t && e.button === 0 && (e.ctrlKey || e.metaKey || e.shiftKey || P(t));
5614
+ let t = k.current;
5615
+ t && e.button === 0 && (e.ctrlKey || e.metaKey || e.shiftKey || F(t, !0));
5164
5616
  };
5165
5617
  return e.addEventListener("pointerdown", t, !0), () => {
5166
5618
  e.removeEventListener("pointerdown", t, !0);
5167
5619
  };
5168
- }, [P, v]), o(() => (C.setClippingSource(w), () => {
5620
+ }, [F, v]), o(() => (C.setClippingSource(w), () => {
5169
5621
  C.setClippingSource(null);
5170
5622
  }), [C, w]), o(() => (t.current = _, () => {
5171
5623
  t.current === _ && (t.current = null);
5172
5624
  }), [_, t]), o(() => {
5173
5625
  if (!s.current) return;
5174
5626
  let t = requestAnimationFrame(() => {
5175
- s.current?.updateMatrixWorld(!0), (_ instanceof se || _ instanceof oe) && cs(_, s.current), N(), ee(), D(), te(), w.syncWithModel(), T.syncWithModel(), e && ae();
5627
+ s.current?.updateMatrixWorld(!0), (_ instanceof ae || _ instanceof ie) && Vs(_, s.current), P(), O(), D(), ee(), w.syncWithModel(), T.syncWithModel(), e && I();
5176
5628
  });
5177
5629
  return () => cancelAnimationFrame(t);
5178
5630
  }, [
5179
- te,
5631
+ ee,
5180
5632
  e,
5181
5633
  D,
5182
5634
  _,
5183
5635
  w,
5184
5636
  n,
5185
5637
  T,
5186
- ae,
5638
+ I,
5187
5639
  r,
5188
5640
  s,
5189
5641
  u,
5190
- ee,
5191
- N
5642
+ O,
5643
+ P
5192
5644
  ]), o(() => {
5193
5645
  let e = () => {
5194
- !w.getActive() || !w.getEdgesActive() || w.updateEdges();
5646
+ w.getActive() && w.syncWithModel();
5195
5647
  }, t = (t) => {
5196
5648
  t(), e();
5197
5649
  };
5198
5650
  return g({
5199
5651
  camera: {
5200
- fitCamera: ae,
5652
+ fitCamera: I,
5201
5653
  getIntersection: C.getIntersection
5202
5654
  },
5203
5655
  clipping: {
@@ -5205,10 +5657,12 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5205
5657
  createPlane: w.createPlane,
5206
5658
  deleteAllPlanes: w.deleteAllPlanes,
5207
5659
  getActive: w.getActive,
5660
+ getCapsActive: w.getCapsActive,
5208
5661
  getEdgesActive: w.getEdgesActive,
5209
5662
  getHelpersActive: w.getHelpersActive,
5210
5663
  getPlanes: w.getPlanes,
5211
5664
  setActive: w.setActive,
5665
+ setCapsActive: w.setCapsActive,
5212
5666
  setEdgesActive: w.setEdgesActive,
5213
5667
  setHelpersActive: w.setHelpersActive,
5214
5668
  toggle: w.toggle,
@@ -5223,7 +5677,7 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5223
5677
  rebuildModelByColors: S.rebuildModelByColors,
5224
5678
  setColor: S.setColor
5225
5679
  },
5226
- converter: le,
5680
+ converter: oe,
5227
5681
  dimensions: {
5228
5682
  cancelDrawing: T.cancelDrawing,
5229
5683
  changeAxes: T.changeAxes,
@@ -5244,8 +5698,8 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5244
5698
  geometryUtils: {
5245
5699
  getAllIds: b.getAllIds,
5246
5700
  getIfcSpacesVisibility: b.getIfcSpacesVisibility,
5247
- getModelGeometry: (e) => ss(s.current, e),
5248
- getModelsGeometry: () => os(s.current),
5701
+ getModelGeometry: (e) => Bs(s.current, e),
5702
+ getModelsGeometry: () => zs(s.current),
5249
5703
  hideByIds: (e) => t(() => b.hideByIds(e)),
5250
5704
  hideSelected: () => t(b.hideSelected),
5251
5705
  isolateByIds: (e) => t(() => b.isolateByIds(e)),
@@ -5256,29 +5710,29 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5256
5710
  showByIds: (e) => t(() => b.showByIds(e)),
5257
5711
  toggleIIfcSpacesVisibility: () => t(b.toggleIIfcSpacesVisibility)
5258
5712
  },
5259
- selector: { setTargetToSelection: ce }
5260
- }), k.current || (k.current = !0, d?.(f)), () => g(null);
5713
+ selector: { setTargetToSelection: L }
5714
+ }), ne.current || (ne.current = !0, d?.(f)), () => g(null);
5261
5715
  }, [
5262
5716
  w,
5263
5717
  C,
5264
5718
  S,
5265
5719
  n,
5266
- le,
5720
+ oe,
5267
5721
  T,
5268
- ae,
5722
+ I,
5269
5723
  b,
5270
5724
  r,
5271
5725
  s,
5272
5726
  d,
5273
5727
  f,
5274
5728
  g,
5275
- ce
5276
- ]), /* @__PURE__ */ R(Ce, { children: [
5277
- /* @__PURE__ */ L("ambientLight", {
5729
+ L
5730
+ ]), /* @__PURE__ */ V(Ce, { children: [
5731
+ /* @__PURE__ */ B("ambientLight", {
5278
5732
  intensity: 1.2,
5279
5733
  color: "#ffffff"
5280
5734
  }),
5281
- /* @__PURE__ */ L("directionalLight", {
5735
+ /* @__PURE__ */ B("directionalLight", {
5282
5736
  ref: r,
5283
5737
  position: [
5284
5738
  10,
@@ -5288,28 +5742,28 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5288
5742
  color: "#ffffff",
5289
5743
  intensity: 2
5290
5744
  }),
5291
- A && /* @__PURE__ */ L(h, {}),
5292
- /* @__PURE__ */ L("group", {
5745
+ A && /* @__PURE__ */ B(h, {}),
5746
+ /* @__PURE__ */ B("group", {
5293
5747
  ref: s,
5294
- children: M.map(([e, t]) => /* @__PURE__ */ L(wt, {
5748
+ children: N.map(([e, t]) => /* @__PURE__ */ B(wt, {
5295
5749
  colorPaletteTexture: x,
5296
- coordinationMatrix: j,
5750
+ coordinationMatrix: M,
5297
5751
  data: t,
5298
5752
  materialMode: a,
5299
5753
  modelID: e
5300
5754
  }, e))
5301
5755
  }),
5302
- /* @__PURE__ */ L(m, {
5756
+ /* @__PURE__ */ B(m, {
5303
5757
  dollyToCursor: !0,
5304
5758
  draggingSmoothTime: .04,
5305
5759
  infinityDolly: !0,
5306
- minDistance: qo,
5760
+ minDistance: ws,
5307
5761
  ref: n,
5308
5762
  smoothTime: .12
5309
5763
  })
5310
5764
  ] });
5311
5765
  }
5312
- function ps({ autoFitCamera: e = !0, camera: t = {
5766
+ function qs({ autoFitCamera: e = !0, camera: t = {
5313
5767
  position: [
5314
5768
  10,
5315
5769
  10,
@@ -5317,21 +5771,21 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5317
5771
  ],
5318
5772
  fov: 50
5319
5773
  }, dpr: n = window.devicePixelRatio, modelUrls: r, modelSources: i, modelsData: a, materialMode: s, onReady: c, performanceMode: f = !1, publicApi: p, setSceneApi: m, showNavCube: h, showStats: g }) {
5320
- let _ = l(null), v = l(null), y = l(null), b = l(null), [x, S] = u(), C = Ee(), w = z((e) => e.setModelNames), T = z((e) => e.setModelProps), E = z((e) => e.setModelStructure), D = z((e) => e.setShowNavCube), ee = z((e) => e.setShowStats), te = z((e) => e.setUserDevice), ne = z((e) => e.showNavCube), O = a ?? x, k = f ? ts(n, 1) : n, A = s ?? (f ? "performance" : void 0);
5774
+ let _ = l(null), v = l(null), y = l(null), b = l(null), [x, S] = u(), C = Ee(), w = H((e) => e.setModelNames), T = H((e) => e.setModelProps), E = H((e) => e.setModelStructure), D = H((e) => e.setShowNavCube), O = H((e) => e.setShowStats), ee = H((e) => e.setUserDevice), te = H((e) => e.showNavCube), k = a ?? x, ne = f ? Ps(n, 1) : n, A = s ?? (f ? "performance" : void 0);
5321
5775
  return o(() => {
5322
- te(ns());
5323
- }, [te]), o(() => {
5324
- ee(!!g);
5325
- }, [ee, g]), o(() => {
5776
+ ee(Fs());
5777
+ }, [ee]), o(() => {
5778
+ O(!!g);
5779
+ }, [O, g]), o(() => {
5326
5780
  h !== void 0 && D(h);
5327
5781
  }, [D, h]), o(() => {
5328
5782
  let e = {}, t = {}, n = {};
5329
- O && Object.entries(O).forEach(([r, i]) => {
5783
+ k && Object.entries(k).forEach(([r, i]) => {
5330
5784
  let a = Number(r);
5331
5785
  i.name !== void 0 && (e[a] = i.name), i.props !== void 0 && (t[a] = i.props), i.structure !== void 0 && (n[a] = i.structure);
5332
5786
  }), w(e), T(t), E(n);
5333
5787
  }, [
5334
- O,
5788
+ k,
5335
5789
  w,
5336
5790
  T,
5337
5791
  E
@@ -5340,7 +5794,7 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5340
5794
  let e = i ?? r;
5341
5795
  if (!e?.length) return;
5342
5796
  let t = !0;
5343
- return mo.loadModel(e).then((e) => {
5797
+ return Wo.loadModel(e).then((e) => {
5344
5798
  t && S(e);
5345
5799
  }), () => {
5346
5800
  t = !1;
@@ -5349,35 +5803,35 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5349
5803
  a,
5350
5804
  i,
5351
5805
  r
5352
- ]), O ? /* @__PURE__ */ R("div", {
5353
- style: Ho,
5354
- children: [/* @__PURE__ */ L(d, {
5806
+ ]), k ? /* @__PURE__ */ V("div", {
5807
+ style: ys,
5808
+ children: [/* @__PURE__ */ B(d, {
5355
5809
  camera: t,
5356
- dpr: k,
5357
- gl: f ? Ko : void 0,
5358
- children: /* @__PURE__ */ L(Ir, {
5810
+ dpr: ne,
5811
+ gl: f ? Cs : void 0,
5812
+ children: /* @__PURE__ */ B(ui, {
5359
5813
  store: C,
5360
- children: /* @__PURE__ */ L(fs, {
5814
+ children: /* @__PURE__ */ B(Ks, {
5361
5815
  autoFitCamera: e,
5362
5816
  cameraRef: _,
5363
5817
  controlRef: v,
5364
5818
  lightRef: b,
5365
5819
  materialMode: A,
5366
5820
  modelRef: y,
5367
- modelsData: O,
5821
+ modelsData: k,
5368
5822
  onReady: c,
5369
5823
  publicApi: p,
5370
5824
  setSceneApi: m
5371
5825
  })
5372
5826
  })
5373
- }), ne && /* @__PURE__ */ L("div", {
5374
- style: Vo,
5375
- children: /* @__PURE__ */ L(d, {
5376
- camera: Uo,
5377
- dpr: k,
5378
- gl: f ? Go : Wo,
5827
+ }), te && /* @__PURE__ */ B("div", {
5828
+ style: vs,
5829
+ children: /* @__PURE__ */ B(d, {
5830
+ camera: bs,
5831
+ dpr: ne,
5832
+ gl: f ? Ss : xs,
5379
5833
  orthographic: !0,
5380
- children: /* @__PURE__ */ L(zo, {
5834
+ children: /* @__PURE__ */ B(gs, {
5381
5835
  active: !0,
5382
5836
  cameraRef: _,
5383
5837
  controlRef: v,
@@ -5385,35 +5839,35 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5385
5839
  })
5386
5840
  })
5387
5841
  })]
5388
- }) : /* @__PURE__ */ L(Ce, {});
5842
+ }) : /* @__PURE__ */ B(Ce, {});
5389
5843
  }
5390
- var ms = n(function(e, t) {
5391
- let [n] = u(Ae), r = l(!1), a = l(!1), d = c(() => new Bo(), []), { defaultSelected: f, onSelectedChange: p, selected: m } = e, h = i((e) => {
5844
+ var Js = n(function(e, t) {
5845
+ let [n] = u(Ae), r = l(!1), a = l(!1), d = c(() => new _s(), []), { defaultSelected: f, onSelectedChange: p, selected: m } = e, h = i((e) => {
5392
5846
  d.set(e);
5393
- }, [d]), g = c(() => ba(n, d.get), [d, n]);
5847
+ }, [d]), g = c(() => Xa(n, d.get), [d, n]);
5394
5848
  return s(t, () => g, [g]), o(() => (n.getState().setApi(g), () => {
5395
5849
  n.getState().api === g && n.getState().setApi(null);
5396
5850
  }), [g, n]), o(() => {
5397
- r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(ya(f)));
5851
+ r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(Ya(f)));
5398
5852
  }, [
5399
5853
  m,
5400
5854
  f,
5401
5855
  n
5402
5856
  ]), o(() => {
5403
- m !== void 0 && (a.current = !0, n.getState().setSelection(ya(m)), a.current = !1);
5857
+ m !== void 0 && (a.current = !0, n.getState().setSelection(Ya(m)), a.current = !1);
5404
5858
  }, [m, n]), o(() => {
5405
5859
  if (p) return n.subscribe((e, t) => {
5406
- e.selected !== t.selected && (a.current || p(va(e.selected)));
5860
+ e.selected !== t.selected && (a.current || p(Ja(e.selected)));
5407
5861
  });
5408
- }, [p, n]), /* @__PURE__ */ L(Ir, {
5862
+ }, [p, n]), /* @__PURE__ */ B(ui, {
5409
5863
  store: n,
5410
- children: /* @__PURE__ */ L(ps, {
5864
+ children: /* @__PURE__ */ B(qs, {
5411
5865
  ...e,
5412
5866
  publicApi: g,
5413
5867
  setSceneApi: h
5414
5868
  })
5415
5869
  });
5416
5870
  });
5417
- ms.displayName = "Viewer";
5871
+ Js.displayName = "Viewer";
5418
5872
  //#endregion
5419
- export { Sa as BMTLoader, ra as BmtConverter, aa as ConvertIfcFileToBmt, oa as ConvertToBmt, Tn as DimensionLine, Mn as DimensionsUtils, _a as FilteredElementsCollector, vt as ModelGrids, zo as NavigationCube, ms as Viewer, Ir as ViewerStoreProvider, ia as bmtConverter, qa as convertIfcFilesToBmtInWorker, Ja as createBmtConverterWorker, Ma as createBmtWorker, oo as createIfcWorker, Ae as createViewerStore, wi as exportExcel, xi as exportModelPropertiesToExcel, ja as loadBmtModelsInWorker, ao as loadIfcModelsInWorker, mo as loader, Nn as useDimensionsUtils, z as useViewerStore, Ee as useViewerStoreApi };
5873
+ export { Qa as BMTLoader, Ma as BmtConverter, Pa as ConvertIfcFileToBmt, Fa as ConvertToBmt, Qn as DimensionLine, ar as DimensionsUtils, qa as FilteredElementsCollector, vt as ModelGrids, gs as NavigationCube, Js as Viewer, ui as ViewerStoreProvider, Na as bmtConverter, wo as convertIfcFilesToBmtInWorker, To as createBmtConverterWorker, co as createBmtWorker, Lo as createIfcWorker, Ae as createViewerStore, Qi as exportExcel, Yi as exportModelPropertiesToExcel, so as loadBmtModelsInWorker, Io as loadIfcModelsInWorker, Wo as loader, or as useDimensionsUtils, H as useViewerStore, Ee as useViewerStoreApi };