bimatter-viewer-react 0.6.2 → 0.6.3

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.
Files changed (2) hide show
  1. package/lib/index.js +146 -140
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -4623,7 +4623,7 @@ var mo = new class {
4623
4623
  }
4624
4624
  return i;
4625
4625
  }
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 = [
4626
+ }(), ho = .5, go = .04, X = .16, _o = X, Z = ho * 2 - X * 2, vo = ho - go / 2, yo = ho - X / 2, bo = ho - _o / 2, xo = .63, So = "#dfe6ec", Co = 260, wo = 52, To = .17, Eo = new g(), Q = new de(), Do = [
4627
4627
  {
4628
4628
  direction: [
4629
4629
  0,
@@ -4634,12 +4634,12 @@ var mo = new class {
4634
4634
  position: [
4635
4635
  0,
4636
4636
  0,
4637
- _o
4637
+ vo
4638
4638
  ],
4639
4639
  scale: [
4640
- Q,
4641
- Q,
4642
- X
4640
+ Z,
4641
+ Z,
4642
+ go
4643
4643
  ],
4644
4644
  title: "Front",
4645
4645
  type: "face"
@@ -4654,7 +4654,7 @@ var mo = new class {
4654
4654
  position: [
4655
4655
  0,
4656
4656
  0,
4657
- -_o
4657
+ -vo
4658
4658
  ],
4659
4659
  rotation: [
4660
4660
  0,
@@ -4662,9 +4662,9 @@ var mo = new class {
4662
4662
  0
4663
4663
  ],
4664
4664
  scale: [
4665
- Q,
4666
- Q,
4667
- X
4665
+ Z,
4666
+ Z,
4667
+ go
4668
4668
  ],
4669
4669
  title: "Back",
4670
4670
  type: "face"
@@ -4677,7 +4677,7 @@ var mo = new class {
4677
4677
  ],
4678
4678
  label: "right",
4679
4679
  position: [
4680
- _o,
4680
+ vo,
4681
4681
  0,
4682
4682
  0
4683
4683
  ],
@@ -4687,9 +4687,9 @@ var mo = new class {
4687
4687
  0
4688
4688
  ],
4689
4689
  scale: [
4690
- X,
4691
- Q,
4692
- Q
4690
+ go,
4691
+ Z,
4692
+ Z
4693
4693
  ],
4694
4694
  title: "Right",
4695
4695
  type: "face"
@@ -4702,7 +4702,7 @@ var mo = new class {
4702
4702
  ],
4703
4703
  label: "left",
4704
4704
  position: [
4705
- -_o,
4705
+ -vo,
4706
4706
  0,
4707
4707
  0
4708
4708
  ],
@@ -4712,9 +4712,9 @@ var mo = new class {
4712
4712
  0
4713
4713
  ],
4714
4714
  scale: [
4715
- X,
4716
- Q,
4717
- Q
4715
+ go,
4716
+ Z,
4717
+ Z
4718
4718
  ],
4719
4719
  title: "Left",
4720
4720
  type: "face"
@@ -4728,7 +4728,7 @@ var mo = new class {
4728
4728
  label: "top",
4729
4729
  position: [
4730
4730
  0,
4731
- _o,
4731
+ vo,
4732
4732
  0
4733
4733
  ],
4734
4734
  rotation: [
@@ -4737,9 +4737,9 @@ var mo = new class {
4737
4737
  0
4738
4738
  ],
4739
4739
  scale: [
4740
- Q,
4741
- X,
4742
- Q
4740
+ Z,
4741
+ go,
4742
+ Z
4743
4743
  ],
4744
4744
  title: "Top",
4745
4745
  type: "face"
@@ -4753,7 +4753,7 @@ var mo = new class {
4753
4753
  label: "bot",
4754
4754
  position: [
4755
4755
  0,
4756
- -_o,
4756
+ -vo,
4757
4757
  0
4758
4758
  ],
4759
4759
  rotation: [
@@ -4762,15 +4762,15 @@ var mo = new class {
4762
4762
  0
4763
4763
  ],
4764
4764
  scale: [
4765
- Q,
4766
- X,
4767
- Q
4765
+ Z,
4766
+ go,
4767
+ Z
4768
4768
  ],
4769
4769
  title: "Bottom",
4770
4770
  type: "face"
4771
4771
  }
4772
4772
  ];
4773
- function Do() {
4773
+ function Oo() {
4774
4774
  let e = [], t = [-1, 1];
4775
4775
  return t.forEach((n) => {
4776
4776
  t.forEach((t) => {
@@ -4782,13 +4782,13 @@ function Do() {
4782
4782
  ],
4783
4783
  position: [
4784
4784
  0,
4785
- n * vo,
4786
- t * vo
4785
+ n * yo,
4786
+ t * yo
4787
4787
  ],
4788
4788
  scale: [
4789
- Q,
4790
4789
  Z,
4791
- Z
4790
+ X,
4791
+ X
4792
4792
  ],
4793
4793
  title: `${n > 0 ? "Top" : "Bottom"} ${t > 0 ? "Front" : "Back"}`,
4794
4794
  type: "edge"
@@ -4803,14 +4803,14 @@ function Do() {
4803
4803
  t
4804
4804
  ],
4805
4805
  position: [
4806
- n * vo,
4806
+ n * yo,
4807
4807
  0,
4808
- t * vo
4808
+ t * yo
4809
4809
  ],
4810
4810
  scale: [
4811
+ X,
4811
4812
  Z,
4812
- Q,
4813
- Z
4813
+ X
4814
4814
  ],
4815
4815
  title: `${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
4816
4816
  type: "edge"
@@ -4825,14 +4825,14 @@ function Do() {
4825
4825
  0
4826
4826
  ],
4827
4827
  position: [
4828
- n * vo,
4829
- t * vo,
4828
+ n * yo,
4829
+ t * yo,
4830
4830
  0
4831
4831
  ],
4832
4832
  scale: [
4833
- Z,
4834
- Z,
4835
- Q
4833
+ X,
4834
+ X,
4835
+ Z
4836
4836
  ],
4837
4837
  title: `${t > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"}`,
4838
4838
  type: "edge"
@@ -4840,7 +4840,7 @@ function Do() {
4840
4840
  });
4841
4841
  }), e;
4842
4842
  }
4843
- function Oo() {
4843
+ function ko() {
4844
4844
  let e = [], t = [-1, 1];
4845
4845
  return t.forEach((n) => {
4846
4846
  t.forEach((r) => {
@@ -4852,14 +4852,14 @@ function Oo() {
4852
4852
  t
4853
4853
  ],
4854
4854
  position: [
4855
- n * yo,
4856
- r * yo,
4857
- t * yo
4855
+ n * bo,
4856
+ r * bo,
4857
+ t * bo
4858
4858
  ],
4859
4859
  scale: [
4860
- go,
4861
- go,
4862
- go
4860
+ _o,
4861
+ _o,
4862
+ _o
4863
4863
  ],
4864
4864
  title: `${r > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
4865
4865
  type: "corner"
@@ -4868,21 +4868,21 @@ function Oo() {
4868
4868
  });
4869
4869
  }), e;
4870
4870
  }
4871
- function ko(e) {
4872
- e.stopPropagation(), e.nativeEvent.stopPropagation(), e.nativeEvent.stopImmediatePropagation?.();
4873
- }
4874
4871
  function Ao(e) {
4875
- return e ? "#4f7fa3" : xo;
4872
+ e.stopPropagation(), e.nativeEvent.stopPropagation(), e.nativeEvent.stopImmediatePropagation?.();
4876
4873
  }
4877
4874
  function jo(e) {
4875
+ return e ? "#4f7fa3" : So;
4876
+ }
4877
+ function Mo(e) {
4878
4878
  return e ? 1 : .96;
4879
4879
  }
4880
- function Mo(e, t) {
4880
+ function No(e, t) {
4881
4881
  let n = document.createElement("canvas"), r = n.getContext("2d");
4882
4882
  if (!r) throw Error("Could not create navigation cube label context");
4883
- let i = `600 ${Co}px system-ui, "Segoe UI", sans-serif`;
4883
+ let i = `600 ${wo}px system-ui, "Segoe UI", sans-serif`;
4884
4884
  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);
4885
+ let a = r.measureText(e), o = a.actualBoundingBoxAscent || wo * .8, s = a.actualBoundingBoxDescent || wo * .2, c = Math.ceil(a.width + 36), l = Math.ceil(o + s + 20);
4886
4886
  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
4887
  let u = new b(n);
4888
4888
  return u.colorSpace = ue, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
@@ -4890,12 +4890,12 @@ function Mo(e, t) {
4890
4890
  texture: u
4891
4891
  };
4892
4892
  }
4893
- function No({ color: e, label: t, position: n, rotation: r }) {
4894
- let { aspect: i, texture: a } = c(() => Mo(t, e), [e, t]);
4893
+ function Po({ color: e, label: t, position: n, rotation: r }) {
4894
+ let { aspect: i, texture: a } = c(() => No(t, e), [e, t]);
4895
4895
  return o(() => () => a.dispose(), [a]), /* @__PURE__ */ R("mesh", {
4896
4896
  position: n,
4897
4897
  rotation: r,
4898
- children: [/* @__PURE__ */ L("planeGeometry", { args: [wo * i, wo] }), /* @__PURE__ */ L("meshBasicMaterial", {
4898
+ children: [/* @__PURE__ */ L("planeGeometry", { args: [To * i, To] }), /* @__PURE__ */ L("meshBasicMaterial", {
4899
4899
  alphaTest: .1,
4900
4900
  depthWrite: !1,
4901
4901
  map: a,
@@ -4904,41 +4904,41 @@ function No({ color: e, label: t, position: n, rotation: r }) {
4904
4904
  })]
4905
4905
  });
4906
4906
  }
4907
- function Po(e) {
4907
+ function Fo(e) {
4908
4908
  return Math.abs(e.y) > .9 ? new I(0, 0, e.y > 0 ? -1 : 1) : new I(0, 1, 0);
4909
4909
  }
4910
- function Fo(e, t) {
4910
+ function Io(e, t) {
4911
4911
  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), $);
4912
+ return !n || (n.updateWorldMatrix(!0, !0), Eo.setFromObject(n), Eo.isEmpty()) ? (Q.center.copy(t), Q.radius = 10, Q) : (Eo.getBoundingSphere(Q), (!Number.isFinite(Q.radius) || Q.radius <= 0) && (Q.radius = 10), Q);
4913
4913
  }
4914
- function Io(e) {
4914
+ function Lo(e) {
4915
4915
  return e.current?.getTarget(new I()) ?? new I();
4916
4916
  }
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);
4917
+ function Ro({ camera: e, controlRef: t, direction: n, modelRef: r, transitionRef: i }) {
4918
+ let a = Lo(t), o = Io(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);
4919
4919
  t.current?.cancel(), t.current?.setFocalOffset(0, 0, 0, !1), i.current = {
4920
4920
  endPosition: d,
4921
4921
  endTarget: s,
4922
- endUp: Po(c),
4922
+ endUp: Fo(c),
4923
4923
  startPosition: e.position.clone(),
4924
4924
  startTarget: a,
4925
4925
  startTime: performance.now(),
4926
4926
  startUp: e.up.clone()
4927
4927
  };
4928
4928
  }
4929
- function Ro({ action: e, onPick: t }) {
4929
+ function zo({ action: e, onPick: t }) {
4930
4930
  let [n, r] = u(!1);
4931
4931
  return /* @__PURE__ */ R("group", {
4932
4932
  position: e.position,
4933
- onClick: ko,
4933
+ onClick: Ao,
4934
4934
  onPointerDown: (n) => {
4935
- ko(n), t(e);
4935
+ Ao(n), t(e);
4936
4936
  },
4937
4937
  onPointerEnter: (e) => {
4938
- ko(e), r(!0);
4938
+ Ao(e), r(!0);
4939
4939
  },
4940
4940
  onPointerLeave: (e) => {
4941
- ko(e), r(!1);
4941
+ Ao(e), r(!1);
4942
4942
  },
4943
4943
  children: [/* @__PURE__ */ R("mesh", {
4944
4944
  scale: e.scale,
@@ -4947,11 +4947,11 @@ function Ro({ action: e, onPick: t }) {
4947
4947
  1,
4948
4948
  1
4949
4949
  ] }), /* @__PURE__ */ L("meshBasicMaterial", {
4950
- color: Ao(n),
4951
- opacity: jo(n),
4950
+ color: jo(n),
4951
+ opacity: Mo(n),
4952
4952
  transparent: !0
4953
4953
  })]
4954
- }), e.label && /* @__PURE__ */ L(No, {
4954
+ }), e.label && /* @__PURE__ */ L(Po, {
4955
4955
  color: n ? "#ffffff" : "#50606f",
4956
4956
  label: e.label,
4957
4957
  position: [
@@ -4963,11 +4963,11 @@ function Ro({ action: e, onPick: t }) {
4963
4963
  })]
4964
4964
  });
4965
4965
  }
4966
- function zo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4966
+ function Bo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4967
4967
  let i = l(null), a = l(null), o = c(() => [
4968
- ...Eo,
4969
- ...Do(),
4970
- ...Oo()
4968
+ ...Do,
4969
+ ...Oo(),
4970
+ ...ko()
4971
4971
  ], []);
4972
4972
  return f(() => {
4973
4973
  if (!e) return;
@@ -4976,7 +4976,7 @@ function zo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4976
4976
  i.current && i.current.quaternion.copy(r.quaternion).invert();
4977
4977
  let o = a.current;
4978
4978
  if (!o) return;
4979
- let s = performance.now() - o.startTime, c = Math.min(s / So, 1), l = 1 - (1 - c) ** 3, u = n.current;
4979
+ let s = performance.now() - o.startTime, c = Math.min(s / Co, 1), l = 1 - (1 - c) ** 3, u = n.current;
4980
4980
  if (r.position.lerpVectors(o.startPosition, o.endPosition, l), r.up.lerpVectors(o.startUp, o.endUp, l), u) {
4981
4981
  let e = new I().lerpVectors(o.startTarget, o.endTarget, l);
4982
4982
  u.setLookAt(r.position.x, r.position.y, r.position.z, e.x, e.y, e.z, !1);
@@ -4984,12 +4984,12 @@ function zo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
4984
4984
  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
4985
  }), e ? /* @__PURE__ */ L("group", {
4986
4986
  ref: i,
4987
- scale: bo,
4988
- children: o.map((e) => /* @__PURE__ */ L(Ro, {
4987
+ scale: xo,
4988
+ children: o.map((e) => /* @__PURE__ */ L(zo, {
4989
4989
  action: e,
4990
4990
  onPick: (e) => {
4991
4991
  let i = t.current;
4992
- i && Lo({
4992
+ i && Ro({
4993
4993
  camera: i,
4994
4994
  controlRef: n,
4995
4995
  direction: e.direction,
@@ -5002,13 +5002,13 @@ function zo({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
5002
5002
  }
5003
5003
  //#endregion
5004
5004
  //#region src/viewer/Viewer.tsx
5005
- var Bo = class {
5005
+ var Vo = class {
5006
5006
  sceneApi = null;
5007
5007
  get = () => this.sceneApi;
5008
5008
  set = (e) => {
5009
5009
  this.sceneApi = e;
5010
5010
  };
5011
- }, Vo = {
5011
+ }, Ho = {
5012
5012
  bottom: 16,
5013
5013
  height: 96,
5014
5014
  pointerEvents: "auto",
@@ -5017,11 +5017,11 @@ var Bo = class {
5017
5017
  touchAction: "none",
5018
5018
  width: 96,
5019
5019
  zIndex: 2
5020
- }, Ho = {
5020
+ }, Uo = {
5021
5021
  height: "100%",
5022
5022
  position: "relative",
5023
5023
  width: "100%"
5024
- }, Uo = {
5024
+ }, Wo = {
5025
5025
  far: 50,
5026
5026
  near: .1,
5027
5027
  position: [
@@ -5030,49 +5030,49 @@ var Bo = class {
5030
5030
  10
5031
5031
  ],
5032
5032
  zoom: 72
5033
- }, Wo = {
5033
+ }, Go = {
5034
5034
  alpha: !0,
5035
5035
  antialias: !0
5036
- }, Go = {
5036
+ }, Ko = {
5037
5037
  alpha: !0,
5038
5038
  antialias: !1,
5039
5039
  powerPreference: "high-performance"
5040
- }, Ko = {
5040
+ }, qo = {
5041
5041
  antialias: !1,
5042
5042
  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) {
5043
+ }, Jo = .1, Yo = .02, Xo = 1e3, Zo = 50, Qo = 1.25, $o = .08, es = new g(), ts = new de(), $ = new I(), ns = new I(), rs = new I();
5044
+ function is(e, t) {
5045
5045
  return Array.isArray(e) ? [Math.min(e[0], t), Math.min(e[1], t)] : typeof e == "number" ? Math.min(e, t) : t;
5046
5046
  }
5047
- function ns() {
5047
+ function as() {
5048
5048
  let e = navigator, t = navigator.userAgent.toLowerCase(), n = navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, r = window.matchMedia?.("(pointer: coarse)").matches ?? !1;
5049
5049
  return e.userAgentData?.mobile || n || /android|iphone|ipad|ipod|mobile|tablet/.test(t) || navigator.maxTouchPoints > 1 && r ? "mobile" : "pc";
5050
5050
  }
5051
- function rs(e) {
5052
- let t = is(e);
5053
- return t ? Math.max(t.radius * Jo, qo) : qo;
5051
+ function os(e) {
5052
+ let t = ss(e);
5053
+ return t ? Math.max(t.radius * Yo, Jo) : Jo;
5054
5054
  }
5055
- function is(e) {
5056
- if (!e || (Qo.setFromObject(e), Qo.isEmpty())) return null;
5057
- let t = Qo.getBoundingSphere($o);
5055
+ function ss(e) {
5056
+ if (!e || (es.setFromObject(e), es.isEmpty())) return null;
5057
+ let t = es.getBoundingSphere(ts);
5058
5058
  return !Number.isFinite(t.radius) || t.radius <= 0 ? null : t;
5059
5059
  }
5060
- function as(e) {
5060
+ function cs(e) {
5061
5061
  return e.type === "Group" && typeof e.userData.modelID == "number";
5062
5062
  }
5063
- function os(e) {
5064
- return e?.children.filter(as) ?? [];
5063
+ function ls(e) {
5064
+ return e?.children.filter(cs) ?? [];
5065
5065
  }
5066
- function ss(e, t) {
5067
- return os(e).find((e) => e.userData.modelID === t) ?? null;
5066
+ function us(e, t) {
5067
+ return ls(e).find((e) => e.userData.modelID === t) ?? null;
5068
5068
  }
5069
- function cs(e, t) {
5070
- let n = is(t);
5069
+ function ds(e, t) {
5070
+ let n = ss(t);
5071
5071
  if (!n) return;
5072
- let r = Math.max(Yo, n.radius * Xo, e.near + 1);
5072
+ let r = Math.max(Xo, n.radius * Zo, e.near + 1);
5073
5073
  Math.abs(e.far - r) < 1 || (e.far = r, e.updateProjectionMatrix());
5074
5074
  }
5075
- function ls(e, t, n, r, i) {
5075
+ function fs(e, t, n, r, i) {
5076
5076
  let a = n.elementIndex.get(i);
5077
5077
  a && a.forEach((n) => {
5078
5078
  let { record: i, vertexRanges: a } = n;
@@ -5084,20 +5084,24 @@ function ls(e, t, n, r, i) {
5084
5084
  }));
5085
5085
  });
5086
5086
  }
5087
- function us(e, t) {
5087
+ function ps(e, t) {
5088
5088
  let n = new g(), r = new I();
5089
5089
  return Object.entries(e).forEach(([e, i]) => {
5090
5090
  let a = Number(e);
5091
5091
  i.forEach((e) => {
5092
- ls(n, r, t, a, e);
5092
+ fs(n, r, t, a, e);
5093
5093
  });
5094
5094
  }), n.isEmpty() ? null : n;
5095
5095
  }
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;
5096
+ function ms(e) {
5097
+ let t = e.getSize(rs), n = Math.max(t.x, t.y, t.z);
5098
+ return Number.isFinite(n) && n > 0 ? n * $o : Jo;
5099
+ }
5100
+ function hs(e, t, n) {
5101
+ let r = Math.max(Jo, (Number.isFinite(n) ? n : Jo) * Qo), i = t.position.distanceTo(e);
5102
+ 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(), ns.copy(t.position).addScaledVector($, r));
5099
5103
  }
5100
- function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, publicApi: f, setSceneApi: g }) {
5104
+ function gs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, publicApi: f, setSceneApi: g }) {
5101
5105
  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(() => {
5102
5106
  let e = Object.keys(u).sort((e, t) => Number(e) - Number(t));
5103
5107
  for (let t of e) {
@@ -5106,12 +5110,14 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5106
5110
  }
5107
5111
  return null;
5108
5112
  }, [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);
5113
+ n.current && (n.current.minDistance = os(s.current));
5114
+ }, [n, s]), P = i((e, t = !1) => {
5115
+ let r = n.current;
5116
+ if (!r) return !1;
5117
+ let i = t ? hs(e, _, r.minDistance) : e;
5118
+ return r.cancel(), r.setOrbitPoint(i.x, i.y, i.z), !0;
5119
+ }, [_, n]), ie = i((e) => {
5120
+ O.current = e.clone(), P(e, !0);
5115
5121
  }, [P]), ae = i(() => {
5116
5122
  O.current = null, ne(s, n, r);
5117
5123
  }, [
@@ -5122,11 +5128,11 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5122
5128
  ]), ce = i((e, t = !1) => {
5123
5129
  let r = n.current;
5124
5130
  if (!r) return;
5125
- let i = us(e, y.buildIndex());
5131
+ let i = ps(e, y.buildIndex());
5126
5132
  if (!i) return;
5127
5133
  let a = i.getCenter(new I());
5128
5134
  if (O.current = a.clone(), r.cancel(), t) {
5129
- let e = ds(i);
5135
+ let e = ms(i);
5130
5136
  r.fitToBox(i, !0, {
5131
5137
  paddingBottom: e,
5132
5138
  paddingLeft: e,
@@ -5134,11 +5140,11 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5134
5140
  paddingTop: e
5135
5141
  }).then(() => {
5136
5142
  let e = O.current;
5137
- e && r.setOrbitPoint(e.x, e.y, e.z);
5143
+ e && P(e, !0);
5138
5144
  });
5139
5145
  return;
5140
5146
  }
5141
- P(a);
5147
+ P(a, !0);
5142
5148
  }, [
5143
5149
  P,
5144
5150
  n,
@@ -5160,7 +5166,7 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5160
5166
  return Mr(s, n, C, ie), Fn(), o(() => {
5161
5167
  let e = v.domElement, t = (e) => {
5162
5168
  let t = O.current;
5163
- t && e.button === 0 && (e.ctrlKey || e.metaKey || e.shiftKey || P(t));
5169
+ t && e.button === 0 && (e.ctrlKey || e.metaKey || e.shiftKey || P(t, !0));
5164
5170
  };
5165
5171
  return e.addEventListener("pointerdown", t, !0), () => {
5166
5172
  e.removeEventListener("pointerdown", t, !0);
@@ -5172,7 +5178,7 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5172
5178
  }), [_, t]), o(() => {
5173
5179
  if (!s.current) return;
5174
5180
  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();
5181
+ s.current?.updateMatrixWorld(!0), (_ instanceof se || _ instanceof oe) && ds(_, s.current), N(), ee(), D(), te(), w.syncWithModel(), T.syncWithModel(), e && ae();
5176
5182
  });
5177
5183
  return () => cancelAnimationFrame(t);
5178
5184
  }, [
@@ -5244,8 +5250,8 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5244
5250
  geometryUtils: {
5245
5251
  getAllIds: b.getAllIds,
5246
5252
  getIfcSpacesVisibility: b.getIfcSpacesVisibility,
5247
- getModelGeometry: (e) => ss(s.current, e),
5248
- getModelsGeometry: () => os(s.current),
5253
+ getModelGeometry: (e) => us(s.current, e),
5254
+ getModelsGeometry: () => ls(s.current),
5249
5255
  hideByIds: (e) => t(() => b.hideByIds(e)),
5250
5256
  hideSelected: () => t(b.hideSelected),
5251
5257
  isolateByIds: (e) => t(() => b.isolateByIds(e)),
@@ -5303,13 +5309,13 @@ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5303
5309
  dollyToCursor: !0,
5304
5310
  draggingSmoothTime: .04,
5305
5311
  infinityDolly: !0,
5306
- minDistance: qo,
5312
+ minDistance: Jo,
5307
5313
  ref: n,
5308
5314
  smoothTime: .12
5309
5315
  })
5310
5316
  ] });
5311
5317
  }
5312
- function ps({ autoFitCamera: e = !0, camera: t = {
5318
+ function _s({ autoFitCamera: e = !0, camera: t = {
5313
5319
  position: [
5314
5320
  10,
5315
5321
  10,
@@ -5317,9 +5323,9 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5317
5323
  ],
5318
5324
  fov: 50
5319
5325
  }, 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);
5326
+ 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 ? is(n, 1) : n, A = s ?? (f ? "performance" : void 0);
5321
5327
  return o(() => {
5322
- te(ns());
5328
+ te(as());
5323
5329
  }, [te]), o(() => {
5324
5330
  ee(!!g);
5325
5331
  }, [ee, g]), o(() => {
@@ -5350,14 +5356,14 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5350
5356
  i,
5351
5357
  r
5352
5358
  ]), O ? /* @__PURE__ */ R("div", {
5353
- style: Ho,
5359
+ style: Uo,
5354
5360
  children: [/* @__PURE__ */ L(d, {
5355
5361
  camera: t,
5356
5362
  dpr: k,
5357
- gl: f ? Ko : void 0,
5363
+ gl: f ? qo : void 0,
5358
5364
  children: /* @__PURE__ */ L(Ir, {
5359
5365
  store: C,
5360
- children: /* @__PURE__ */ L(fs, {
5366
+ children: /* @__PURE__ */ L(gs, {
5361
5367
  autoFitCamera: e,
5362
5368
  cameraRef: _,
5363
5369
  controlRef: v,
@@ -5371,13 +5377,13 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5371
5377
  })
5372
5378
  })
5373
5379
  }), ne && /* @__PURE__ */ L("div", {
5374
- style: Vo,
5380
+ style: Ho,
5375
5381
  children: /* @__PURE__ */ L(d, {
5376
- camera: Uo,
5382
+ camera: Wo,
5377
5383
  dpr: k,
5378
- gl: f ? Go : Wo,
5384
+ gl: f ? Ko : Go,
5379
5385
  orthographic: !0,
5380
- children: /* @__PURE__ */ L(zo, {
5386
+ children: /* @__PURE__ */ L(Bo, {
5381
5387
  active: !0,
5382
5388
  cameraRef: _,
5383
5389
  controlRef: v,
@@ -5387,8 +5393,8 @@ function ps({ autoFitCamera: e = !0, camera: t = {
5387
5393
  })]
5388
5394
  }) : /* @__PURE__ */ L(Ce, {});
5389
5395
  }
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) => {
5396
+ var vs = n(function(e, t) {
5397
+ let [n] = u(Ae), r = l(!1), a = l(!1), d = c(() => new Vo(), []), { defaultSelected: f, onSelectedChange: p, selected: m } = e, h = i((e) => {
5392
5398
  d.set(e);
5393
5399
  }, [d]), g = c(() => ba(n, d.get), [d, n]);
5394
5400
  return s(t, () => g, [g]), o(() => (n.getState().setApi(g), () => {
@@ -5407,13 +5413,13 @@ var ms = n(function(e, t) {
5407
5413
  });
5408
5414
  }, [p, n]), /* @__PURE__ */ L(Ir, {
5409
5415
  store: n,
5410
- children: /* @__PURE__ */ L(ps, {
5416
+ children: /* @__PURE__ */ L(_s, {
5411
5417
  ...e,
5412
5418
  publicApi: g,
5413
5419
  setSceneApi: h
5414
5420
  })
5415
5421
  });
5416
5422
  });
5417
- ms.displayName = "Viewer";
5423
+ vs.displayName = "Viewer";
5418
5424
  //#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 };
5425
+ 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, Bo as NavigationCube, vs 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimatter-viewer-react",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",