bimatter-viewer-react 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { ColorRepresentation } from "three";
1
+ import type { ColorRepresentation, Group } from "three";
2
2
  import type { SelectedStore, UserDevice, ViewerGridAxesVisibility, ViewerGridAxisSide, ViewerStoreApi } from "../store/ViewerStore";
3
3
  import { type ViewerPropertiesApi } from "./ViewerPropertiesApi";
4
4
  import type { ViewerClippingApi } from "../utils/ClippingUtils";
@@ -15,6 +15,8 @@ export type ViewerSelection = Record<number, number[]>;
15
15
  export type ViewerGeometryUtilsApi = {
16
16
  getAllIds: () => number[];
17
17
  getIfcSpacesVisibility: () => boolean;
18
+ getModelGeometry: (modelID: number) => Group | null;
19
+ getModelsGeometry: () => Group[];
18
20
  hideByIds: (ids: number[]) => void;
19
21
  hideSelected: () => void;
20
22
  isolateByIds: (ids: number[]) => void;
package/lib/index.js CHANGED
@@ -3924,6 +3924,8 @@ function ba(e, t) {
3924
3924
  geometryUtils: {
3925
3925
  getAllIds: () => t()?.geometryUtils.getAllIds() ?? [],
3926
3926
  getIfcSpacesVisibility: () => t()?.geometryUtils.getIfcSpacesVisibility() ?? !1,
3927
+ getModelGeometry: (e) => t()?.geometryUtils.getModelGeometry(e) ?? null,
3928
+ getModelsGeometry: () => t()?.geometryUtils.getModelsGeometry() ?? [],
3927
3929
  hideByIds: (e) => {
3928
3930
  t()?.geometryUtils.hideByIds(e);
3929
3931
  },
@@ -5055,13 +5057,22 @@ function is(e) {
5055
5057
  let t = Qo.getBoundingSphere($o);
5056
5058
  return !Number.isFinite(t.radius) || t.radius <= 0 ? null : t;
5057
5059
  }
5058
- function as(e, t) {
5060
+ function as(e) {
5061
+ return e.type === "Group" && typeof e.userData.modelID == "number";
5062
+ }
5063
+ function os(e) {
5064
+ return e?.children.filter(as) ?? [];
5065
+ }
5066
+ function ss(e, t) {
5067
+ return os(e).find((e) => e.userData.modelID === t) ?? null;
5068
+ }
5069
+ function cs(e, t) {
5059
5070
  let n = is(t);
5060
5071
  if (!n) return;
5061
5072
  let r = Math.max(Yo, n.radius * Xo, e.near + 1);
5062
5073
  Math.abs(e.far - r) < 1 || (e.far = r, e.updateProjectionMatrix());
5063
5074
  }
5064
- function os(e, t, n, r, i) {
5075
+ function ls(e, t, n, r, i) {
5065
5076
  let a = n.elementIndex.get(i);
5066
5077
  a && a.forEach((n) => {
5067
5078
  let { record: i, vertexRanges: a } = n;
@@ -5073,20 +5084,20 @@ function os(e, t, n, r, i) {
5073
5084
  }));
5074
5085
  });
5075
5086
  }
5076
- function ss(e, t) {
5087
+ function us(e, t) {
5077
5088
  let n = new g(), r = new I();
5078
5089
  return Object.entries(e).forEach(([e, i]) => {
5079
5090
  let a = Number(e);
5080
5091
  i.forEach((e) => {
5081
- os(n, r, t, a, e);
5092
+ ls(n, r, t, a, e);
5082
5093
  });
5083
5094
  }), n.isEmpty() ? null : n;
5084
5095
  }
5085
- function cs(e) {
5096
+ function ds(e) {
5086
5097
  let t = e.getSize(es), n = Math.max(t.x, t.y, t.z);
5087
5098
  return Number.isFinite(n) && n > 0 ? n * Zo : qo;
5088
5099
  }
5089
- function ls({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, publicApi: f, setSceneApi: g }) {
5100
+ function fs({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, publicApi: f, setSceneApi: g }) {
5090
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(() => {
5091
5102
  let e = Object.keys(u).sort((e, t) => Number(e) - Number(t));
5092
5103
  for (let t of e) {
@@ -5111,11 +5122,11 @@ function ls({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5111
5122
  ]), ce = i((e, t = !1) => {
5112
5123
  let r = n.current;
5113
5124
  if (!r) return;
5114
- let i = ss(e, y.buildIndex());
5125
+ let i = us(e, y.buildIndex());
5115
5126
  if (!i) return;
5116
5127
  let a = i.getCenter(new I());
5117
5128
  if (O.current = a.clone(), r.cancel(), t) {
5118
- let e = cs(i);
5129
+ let e = ds(i);
5119
5130
  r.fitToBox(i, !0, {
5120
5131
  paddingBottom: e,
5121
5132
  paddingLeft: e,
@@ -5161,7 +5172,7 @@ function ls({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5161
5172
  }), [_, t]), o(() => {
5162
5173
  if (!s.current) return;
5163
5174
  let t = requestAnimationFrame(() => {
5164
- s.current?.updateMatrixWorld(!0), (_ instanceof se || _ instanceof oe) && as(_, s.current), N(), ee(), D(), te(), w.syncWithModel(), T.syncWithModel(), e && ae();
5175
+ s.current?.updateMatrixWorld(!0), (_ instanceof se || _ instanceof oe) && cs(_, s.current), N(), ee(), D(), te(), w.syncWithModel(), T.syncWithModel(), e && ae();
5165
5176
  });
5166
5177
  return () => cancelAnimationFrame(t);
5167
5178
  }, [
@@ -5233,6 +5244,8 @@ function ls({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5233
5244
  geometryUtils: {
5234
5245
  getAllIds: b.getAllIds,
5235
5246
  getIfcSpacesVisibility: b.getIfcSpacesVisibility,
5247
+ getModelGeometry: (e) => ss(s.current, e),
5248
+ getModelsGeometry: () => os(s.current),
5236
5249
  hideByIds: (e) => t(() => b.hideByIds(e)),
5237
5250
  hideSelected: () => t(b.hideSelected),
5238
5251
  isolateByIds: (e) => t(() => b.isolateByIds(e)),
@@ -5296,7 +5309,7 @@ function ls({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
5296
5309
  })
5297
5310
  ] });
5298
5311
  }
5299
- function us({ autoFitCamera: e = !0, camera: t = {
5312
+ function ps({ autoFitCamera: e = !0, camera: t = {
5300
5313
  position: [
5301
5314
  10,
5302
5315
  10,
@@ -5344,7 +5357,7 @@ function us({ autoFitCamera: e = !0, camera: t = {
5344
5357
  gl: f ? Ko : void 0,
5345
5358
  children: /* @__PURE__ */ L(Ir, {
5346
5359
  store: C,
5347
- children: /* @__PURE__ */ L(ls, {
5360
+ children: /* @__PURE__ */ L(fs, {
5348
5361
  autoFitCamera: e,
5349
5362
  cameraRef: _,
5350
5363
  controlRef: v,
@@ -5374,7 +5387,7 @@ function us({ autoFitCamera: e = !0, camera: t = {
5374
5387
  })]
5375
5388
  }) : /* @__PURE__ */ L(Ce, {});
5376
5389
  }
5377
- var ds = n(function(e, t) {
5390
+ var ms = n(function(e, t) {
5378
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) => {
5379
5392
  d.set(e);
5380
5393
  }, [d]), g = c(() => ba(n, d.get), [d, n]);
@@ -5394,13 +5407,13 @@ var ds = n(function(e, t) {
5394
5407
  });
5395
5408
  }, [p, n]), /* @__PURE__ */ L(Ir, {
5396
5409
  store: n,
5397
- children: /* @__PURE__ */ L(us, {
5410
+ children: /* @__PURE__ */ L(ps, {
5398
5411
  ...e,
5399
5412
  publicApi: g,
5400
5413
  setSceneApi: h
5401
5414
  })
5402
5415
  });
5403
5416
  });
5404
- ds.displayName = "Viewer";
5417
+ ms.displayName = "Viewer";
5405
5418
  //#endregion
5406
- 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, ds 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 };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimatter-viewer-react",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",