bimatter-viewer-react 0.6.4 → 0.6.5
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/README.md +2 -0
- package/lib/Viewer.d.ts +1 -0
- package/lib/index.js +1123 -1067
- package/lib/utils/ClippingUtils/ClippingCaps.d.ts +4 -0
- package/lib/utils/ClippingUtils/ClippingUtils.d.ts +1 -0
- package/lib/utils/ClippingUtils/PlaneHelper.d.ts +1 -1
- package/lib/utils/DimentionsUtils/DimentionsUtils.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import e, { createContext as t, forwardRef as n, memo as r, useCallback as i, useContext as a, useEffect as o, useImperativeHandle as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
2
2
|
import { Canvas as d, useFrame as f, useThree as p } from "@react-three/fiber";
|
|
3
3
|
import { CameraControls as m, Stats as h } from "@react-three/drei";
|
|
4
|
-
import { Box3 as g, BoxGeometry as _, BufferAttribute as v, BufferGeometry as y, CanvasTexture as b, Color as x, ConeGeometry as S, DataTexture as C, DoubleSide as w, DynamicDrawUsage as T, Float32BufferAttribute as E, Group as D, Line as O, Line3 as ee, LineBasicMaterial as te, LineDashedMaterial as
|
|
5
|
-
import { useStore as
|
|
6
|
-
import { createStore as
|
|
7
|
-
import { CONTAINED as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import
|
|
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 ne, LineSegments as k, LinearFilter as A, LinearMipmapLinearFilter as j, MathUtils as M, Matrix4 as N, Mesh as P, MeshBasicMaterial as F, MeshLambertMaterial as re, NearestFilter as ie, Object3D as ae, OrthographicCamera as oe, PerspectiveCamera as se, Plane as I, RGBAFormat as ce, RepeatWrapping as L, SRGBColorSpace as le, ShapeUtils as ue, Sphere as de, SphereGeometry as fe, Sprite as pe, SpriteMaterial as me, Uint32BufferAttribute as he, UnsignedByteType as ge, Vector2 as R, Vector3 as z } from "three";
|
|
5
|
+
import { useStore as _e } from "zustand";
|
|
6
|
+
import { createStore as ve } from "zustand/vanilla";
|
|
7
|
+
import { CONTAINED as ye, INTERSECTED as be, MeshBVH as xe, NOT_INTERSECTED as Se, acceleratedRaycast as Ce } from "three-mesh-bvh";
|
|
8
|
+
import { Fragment as we, jsx as B, jsxs as V } from "react/jsx-runtime";
|
|
9
|
+
import Te from "pako";
|
|
10
10
|
//#region src/viewer/store/ViewerStoreContext.ts
|
|
11
|
-
var
|
|
11
|
+
var Ee = t(null);
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/viewer/store/useViewerStore.ts
|
|
14
14
|
function H(e) {
|
|
15
|
-
return
|
|
15
|
+
return _e(De(), e);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
let e = a(
|
|
17
|
+
function De() {
|
|
18
|
+
let e = a(Ee);
|
|
19
19
|
if (!e) throw Error("useViewerStore must be used inside ViewerStoreProvider");
|
|
20
20
|
return e;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/viewer/store/ViewerStore.ts
|
|
24
|
-
var
|
|
24
|
+
var Oe = "rgb(17, 148, 189)", ke = "rgb(104, 198, 227)", Ae = {
|
|
25
25
|
bottom: !0,
|
|
26
26
|
left: !0,
|
|
27
27
|
right: !0,
|
|
28
28
|
top: !0,
|
|
29
29
|
visible: !0
|
|
30
30
|
};
|
|
31
|
-
function
|
|
32
|
-
return
|
|
31
|
+
function je() {
|
|
32
|
+
return ve((e) => ({
|
|
33
33
|
api: null,
|
|
34
34
|
defaultHotkeysEnabled: !0,
|
|
35
|
-
gridAxesVisibility:
|
|
35
|
+
gridAxesVisibility: Ae,
|
|
36
36
|
modelNames: {},
|
|
37
37
|
modelProps: {},
|
|
38
38
|
modelStructure: {},
|
|
39
|
-
preselectionColor:
|
|
39
|
+
preselectionColor: ke,
|
|
40
40
|
selected: {},
|
|
41
|
-
selectionColor:
|
|
41
|
+
selectionColor: Oe,
|
|
42
42
|
selectionInteractionDisabled: !1,
|
|
43
43
|
showNavCube: !0,
|
|
44
44
|
showStats: !1,
|
|
@@ -119,66 +119,66 @@ function Ae() {
|
|
|
119
119
|
}
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
122
|
-
var
|
|
123
|
-
function
|
|
124
|
-
let e = new C(new Uint8Array(256 * 4), 256, 1,
|
|
125
|
-
return e.magFilter =
|
|
122
|
+
var Me = 2;
|
|
123
|
+
function Ne() {
|
|
124
|
+
let e = new C(new Uint8Array(256 * 4), 256, 1, ce, ge);
|
|
125
|
+
return e.magFilter = ie, e.minFilter = ie, e.generateMipmaps = !1, e.needsUpdate = !0, Fe(e, 1, new x(Oe)), e;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function Pe(e) {
|
|
128
128
|
return `${e.r.toFixed(6)}:${e.g.toFixed(6)}:${e.b.toFixed(6)}`;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Fe(e, t, n) {
|
|
131
131
|
let r = e.image.data, i = t * 4;
|
|
132
132
|
r[i] = Math.round(n.r * 255), r[i + 1] = Math.round(n.g * 255), r[i + 2] = Math.round(n.b * 255), r[i + 3] = 255, e.needsUpdate = !0;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function Ie(e) {
|
|
135
135
|
return e.mesh.geometry.attributes.colorIndex;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Le(e) {
|
|
138
138
|
let t = e.mesh.geometry.attributes.ids;
|
|
139
139
|
if (!t) return null;
|
|
140
140
|
let n = new v(new Uint8Array(t.count), 1);
|
|
141
141
|
return e.mesh.geometry.setAttribute("colorIndex", n), n;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
let n =
|
|
145
|
-
return n || t === 0 ? n :
|
|
143
|
+
function Re(e, t) {
|
|
144
|
+
let n = Ie(e);
|
|
145
|
+
return n || t === 0 ? n : Le(e);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
|
|
147
|
+
function ze(e) {
|
|
148
|
+
Ie(e) && e.mesh.geometry.deleteAttribute("colorIndex");
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function Be(e, t, n) {
|
|
151
151
|
let r = e.get(t);
|
|
152
152
|
return !r && n && (r = /* @__PURE__ */ new Set(), e.set(t, r)), r;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
let n =
|
|
154
|
+
function Ve(e, t) {
|
|
155
|
+
let n = Re(e.record, t);
|
|
156
156
|
if (!n) return !1;
|
|
157
157
|
let r = n.array;
|
|
158
158
|
return e.vertexRanges.forEach(({ count: e, start: n }) => {
|
|
159
159
|
r.fill(t, n, n + e);
|
|
160
160
|
}), n.needsUpdate = !0, !0;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function He(e, t, n, r, i) {
|
|
163
163
|
e && e.forEach((e) => {
|
|
164
164
|
if (e.record.modelID !== t) return;
|
|
165
|
-
let a =
|
|
166
|
-
r === 0 ? (o?.delete(n), o?.size || (i.delete(e.record),
|
|
165
|
+
let a = Ve(e, r), o = Be(i, e.record, r !== 0 && a);
|
|
166
|
+
r === 0 ? (o?.delete(n), o?.size || (i.delete(e.record), ze(e.record))) : a && o?.add(n);
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function Ue(e, t, n) {
|
|
170
170
|
let r = /* @__PURE__ */ new Set();
|
|
171
171
|
return e.elementIndex.forEach((e, i) => {
|
|
172
172
|
n.has(i) || e.some((e) => e.record.modelID === t) && r.add(i);
|
|
173
173
|
}), r;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function We(e) {
|
|
176
176
|
let t = /* @__PURE__ */ new Set();
|
|
177
177
|
return Object.entries(e).forEach(([e, n]) => {
|
|
178
178
|
n.forEach((n) => t.add(`${e}:${n}`));
|
|
179
179
|
}), t;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function Ge(e, t) {
|
|
182
182
|
let n = /* @__PURE__ */ new Map(), r = (e) => {
|
|
183
183
|
let [t, r] = e.split(":").map(Number), i = n.get(t);
|
|
184
184
|
i || (i = /* @__PURE__ */ new Set(), n.set(t, i)), i.add(r);
|
|
@@ -189,28 +189,28 @@ function We(e, t) {
|
|
|
189
189
|
t.has(e) || r(e);
|
|
190
190
|
}), n;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
193
|
-
let t = H((e) => e.selected), n = H((e) => e.selectionColor), r = c(() =>
|
|
192
|
+
function Ke(e) {
|
|
193
|
+
let t = H((e) => e.selected), n = H((e) => e.selectionColor), r = c(() => Ne(), []), a = l(/* @__PURE__ */ new Map()), s = l(Me), u = l(/* @__PURE__ */ new Map()), d = l(t), f = l(/* @__PURE__ */ new Set()), p = l(/* @__PURE__ */ new WeakMap());
|
|
194
194
|
o(() => {
|
|
195
195
|
d.current = t;
|
|
196
196
|
}, [t]), o(() => () => r.dispose(), [r]), o(() => {
|
|
197
|
-
|
|
197
|
+
Fe(r, 1, new x(n));
|
|
198
198
|
}, [r, n]);
|
|
199
199
|
let m = i((e, t) => d.current[e]?.has(t) ? 1 : u.current.get(e)?.get(t) ?? 0, []), h = i((t, n) => {
|
|
200
200
|
let r = e.buildIndex();
|
|
201
201
|
n.forEach((e) => {
|
|
202
|
-
|
|
202
|
+
He(r.elementIndex.get(e), t, e, m(t, e), p.current);
|
|
203
203
|
});
|
|
204
204
|
}, [e, m]), g = i((e) => {
|
|
205
|
-
let t = new x(e), n =
|
|
205
|
+
let t = new x(e), n = Pe(t), i = a.current.get(n);
|
|
206
206
|
if (i !== void 0) return i;
|
|
207
207
|
let o = s.current;
|
|
208
208
|
if (o >= 256) throw Error("Element color palette is full. Maximum colors: 255.");
|
|
209
|
-
return a.current.set(n, o), s.current += 1,
|
|
209
|
+
return a.current.set(n, o), s.current += 1, Fe(r, o, t), o;
|
|
210
210
|
}, [r]);
|
|
211
211
|
o(() => {
|
|
212
|
-
let e =
|
|
213
|
-
|
|
212
|
+
let e = We(t);
|
|
213
|
+
Ge(f.current, e).forEach((e, t) => {
|
|
214
214
|
h(t, Array.from(e));
|
|
215
215
|
}), f.current = e;
|
|
216
216
|
}, [h, t]);
|
|
@@ -221,7 +221,7 @@ function Ge(e) {
|
|
|
221
221
|
let i = e.buildIndex(), a = /* @__PURE__ */ new Set(), o = Object.entries(n);
|
|
222
222
|
o.forEach(([, e]) => {
|
|
223
223
|
e.forEach((e) => a.add(e));
|
|
224
|
-
}), r !== void 0 && _(t, Array.from(
|
|
224
|
+
}), r !== void 0 && _(t, Array.from(Ue(i, t, a)), r), o.forEach(([e, n]) => {
|
|
225
225
|
_(t, n, e);
|
|
226
226
|
});
|
|
227
227
|
}, [e, _]), y = i((e, t) => {
|
|
@@ -249,12 +249,12 @@ function Ge(e) {
|
|
|
249
249
|
t.forEach((t) => r(Number(e), t));
|
|
250
250
|
}), n.forEach((e, n) => {
|
|
251
251
|
e.forEach((e) => {
|
|
252
|
-
|
|
252
|
+
He(t.elementIndex.get(e), n, e, m(n, e), p.current);
|
|
253
253
|
});
|
|
254
254
|
});
|
|
255
255
|
}, [e, m]), w = i(() => {
|
|
256
256
|
e.buildIndex().records.forEach((e) => {
|
|
257
|
-
p.current.delete(e),
|
|
257
|
+
p.current.delete(e), ze(e);
|
|
258
258
|
}), p.current = /* @__PURE__ */ new WeakMap(), u.current.clear(), C();
|
|
259
259
|
}, [C, e]);
|
|
260
260
|
return {
|
|
@@ -280,8 +280,8 @@ function Ge(e) {
|
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/viewer/SelectableMesh.tsx
|
|
283
|
-
|
|
284
|
-
var
|
|
283
|
+
P.prototype.raycast = Ce;
|
|
284
|
+
var qe = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n = "quality", data: r, isIfcSpace: i = !1, meshMatrix: a, useDoubleSideMaterial: s = !1 }) {
|
|
285
285
|
let u = l(null), d = H((e) => e.preselectionColor), f = l(d);
|
|
286
286
|
f.current = d;
|
|
287
287
|
let p = c(() => {
|
|
@@ -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
|
|
295
|
+
} : r, a = n === "performance" ? new F(i) : new re(i), o = a;
|
|
296
296
|
return o.defaultAttributeValues = {
|
|
297
297
|
...o.defaultAttributeValues,
|
|
298
298
|
colorIndex: [0]
|
|
@@ -326,7 +326,7 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
|
|
|
326
326
|
e && (e.value instanceof x ? e.value.set(d) : e.value = new x(d));
|
|
327
327
|
}, [p, d]), o(() => {
|
|
328
328
|
if (!u.current) return;
|
|
329
|
-
let e = u.current.geometry, t = new
|
|
329
|
+
let e = u.current.geometry, t = new xe(e, { indirect: !0 });
|
|
330
330
|
return Object.assign(e, { boundsTree: t }), () => {
|
|
331
331
|
p.dispose(), Object.assign(e, { boundsTree: null });
|
|
332
332
|
};
|
|
@@ -359,19 +359,19 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
|
|
|
359
359
|
})
|
|
360
360
|
] }), /* @__PURE__ */ B("primitive", { object: p })]
|
|
361
361
|
});
|
|
362
|
-
}),
|
|
363
|
-
function
|
|
362
|
+
}), Je = 10, Ye = "#1d2733", Xe = 2, Ze = .05, Qe = "\0", $e = /* @__PURE__ */ new Map();
|
|
363
|
+
function et() {
|
|
364
364
|
return typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2);
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
let i =
|
|
366
|
+
function tt(e, t, n, r) {
|
|
367
|
+
let i = et(), a = document.createElement("canvas"), o = a.getContext("2d");
|
|
368
368
|
if (!o) throw Error("Could not create grid label canvas context");
|
|
369
369
|
let s = `400 ${r}px system-ui, "Segoe UI", sans-serif`, c = Math.ceil(r * .5), l = Math.ceil(r * .35);
|
|
370
370
|
o.font = s;
|
|
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 =
|
|
374
|
+
return h.colorSpace = le, h.generateMipmaps = !1, h.magFilter = A, h.minFilter = A, h.needsUpdate = !0, {
|
|
375
375
|
disposeTimer: null,
|
|
376
376
|
height: m,
|
|
377
377
|
key: e,
|
|
@@ -380,49 +380,49 @@ function et(e, t, n, r) {
|
|
|
380
380
|
width: p
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function nt(e, t, n) {
|
|
384
384
|
let r = [
|
|
385
385
|
e,
|
|
386
386
|
t,
|
|
387
387
|
n
|
|
388
|
-
].join(
|
|
389
|
-
return i || (i =
|
|
388
|
+
].join(Qe), i = $e.get(r);
|
|
389
|
+
return i || (i = tt(r, e, t, n), $e.set(r, i)), i;
|
|
390
390
|
}
|
|
391
|
-
function
|
|
392
|
-
let r = c(() =>
|
|
391
|
+
function rt(e, t, n) {
|
|
392
|
+
let r = c(() => nt(e, t, n), [
|
|
393
393
|
t,
|
|
394
394
|
n,
|
|
395
395
|
e
|
|
396
396
|
]);
|
|
397
397
|
return o(() => (r.disposeTimer &&= (clearTimeout(r.disposeTimer), null), r.refs++, () => {
|
|
398
398
|
r.refs = Math.max(0, r.refs - 1), r.refs <= 0 && (r.disposeTimer = setTimeout(() => {
|
|
399
|
-
r.refs > 0 || (r.texture.dispose(),
|
|
399
|
+
r.refs > 0 || (r.texture.dispose(), $e.delete(r.key), r.disposeTimer = null);
|
|
400
400
|
}, 1e3));
|
|
401
401
|
}), [r]), r;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function it(e, t, n, r) {
|
|
404
404
|
let i = Math.abs(n.projectionMatrix.elements[5]) || 1, a = t.height * 2 / (Math.max(1, r) * i), o = a * (t.width / t.height);
|
|
405
405
|
e.scale.set(o, a, 1);
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function at(e, t) {
|
|
408
408
|
let n = e[t];
|
|
409
409
|
return n === void 0 ? 0 : Number.isFinite(n) ? n : null;
|
|
410
410
|
}
|
|
411
411
|
function U(e, t) {
|
|
412
|
-
return
|
|
412
|
+
return at(e, t) ?? 0;
|
|
413
413
|
}
|
|
414
|
-
function
|
|
415
|
-
let t =
|
|
414
|
+
function ot(e) {
|
|
415
|
+
let t = at(e, "x"), n = at(e, "y"), r = at(e, "z");
|
|
416
416
|
return t === null || n === null || r === null ? null : new z(t, n, r);
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function st(e, t) {
|
|
419
419
|
return [
|
|
420
420
|
U(e, "x"),
|
|
421
421
|
t !== void 0 && Number.isFinite(t) ? t : U(e, "y"),
|
|
422
422
|
U(e, "z")
|
|
423
423
|
];
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function ct(e) {
|
|
426
426
|
let { h: t, l: n } = e.getHSL({
|
|
427
427
|
h: 0,
|
|
428
428
|
s: 0,
|
|
@@ -430,14 +430,14 @@ function st(e) {
|
|
|
430
430
|
});
|
|
431
431
|
return t < .55 && n >= .5 || t >= .55 && n >= .75 ? "#000000" : "#ffffff";
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function lt(e) {
|
|
434
434
|
let t = p((e) => e.scene.background);
|
|
435
|
-
return c(() => e || (t instanceof x ?
|
|
435
|
+
return c(() => e || (t instanceof x ? ct(t) : Ye), [t, e]);
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function ut({ axis: e, grid: t, endSide: n, startSide: r }) {
|
|
438
438
|
return Object.entries(e).flatMap(([e, i]) => {
|
|
439
439
|
if (i.length < 2) return [];
|
|
440
|
-
let a =
|
|
440
|
+
let a = ot(i[0]), o = ot(i[1]);
|
|
441
441
|
return !a || !o ? [] : (a.y = 0, o.y = 0, [{
|
|
442
442
|
endSide: n,
|
|
443
443
|
loc: t.loc,
|
|
@@ -447,18 +447,18 @@ function lt({ axis: e, grid: t, endSide: n, startSide: r }) {
|
|
|
447
447
|
}]);
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function dt({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight: i, showTop: a }) {
|
|
451
451
|
let o = {
|
|
452
452
|
bottom: n,
|
|
453
453
|
left: r,
|
|
454
454
|
right: i,
|
|
455
455
|
top: a
|
|
456
|
-
}, s = Object.values(t).flatMap((e) => [...
|
|
456
|
+
}, s = Object.values(t).flatMap((e) => [...ut({
|
|
457
457
|
axis: e.points.u,
|
|
458
458
|
endSide: "right",
|
|
459
459
|
grid: e,
|
|
460
460
|
startSide: "left"
|
|
461
|
-
}), ...
|
|
461
|
+
}), ...ut({
|
|
462
462
|
axis: e.points.v,
|
|
463
463
|
endSide: "bottom",
|
|
464
464
|
grid: e,
|
|
@@ -481,52 +481,52 @@ function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight
|
|
|
481
481
|
c.has(t) || c.set(t, e);
|
|
482
482
|
}), Array.from(c.values());
|
|
483
483
|
}
|
|
484
|
-
function
|
|
485
|
-
return new z(...
|
|
484
|
+
function ft(e, t) {
|
|
485
|
+
return new z(...st(e.loc, t));
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function pt({ cameraPosition: e, floorY: t, line: n, showBottom: r, showLeft: i, showRight: a, showTop: o }) {
|
|
488
488
|
let s = {
|
|
489
489
|
bottom: r,
|
|
490
490
|
left: i,
|
|
491
491
|
right: a,
|
|
492
492
|
top: o
|
|
493
|
-
}, c =
|
|
493
|
+
}, c = ft(n, t), l = n.points[0].clone().add(c), u = n.points[1].clone().add(c), d = l.distanceToSquared(e) > u.distanceToSquared(e) ? "start" : "end", f = d === "start" ? "end" : "start", p = (e) => s[e === "start" ? n.startSide : n.endSide];
|
|
494
494
|
return p(d) ? d : p(f) ? f : null;
|
|
495
495
|
}
|
|
496
|
-
function
|
|
496
|
+
function mt({ endpoint: e, labelOffset: t, line: n }) {
|
|
497
497
|
let r = e === "start" ? n.points[0].clone() : n.points[1].clone(), i = n.points[1].clone().sub(n.points[0]);
|
|
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
|
-
function
|
|
500
|
+
function ht(e, t) {
|
|
501
501
|
let n = new z(), r = 0;
|
|
502
502
|
return e.forEach((e) => {
|
|
503
|
-
let i =
|
|
503
|
+
let i = ft(e, t);
|
|
504
504
|
e.points.forEach((e) => {
|
|
505
505
|
n.add(e).add(i), r++;
|
|
506
506
|
});
|
|
507
507
|
}), r && n.divideScalar(r), n;
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function gt(e, t, n) {
|
|
510
510
|
let r = 0;
|
|
511
511
|
return e.forEach((e) => {
|
|
512
|
-
let i =
|
|
512
|
+
let i = ft(e, n);
|
|
513
513
|
e.points.forEach((e) => {
|
|
514
514
|
r = Math.max(r, e.clone().add(i).distanceTo(t));
|
|
515
515
|
});
|
|
516
516
|
}), r;
|
|
517
517
|
}
|
|
518
|
-
function
|
|
519
|
-
let { camera: i, size: a } = p(), s = l(null), c =
|
|
518
|
+
function _t({ color: e, fontSize: t, position: n, text: r }) {
|
|
519
|
+
let { camera: i, size: a } = p(), s = l(null), c = rt(r, e, t);
|
|
520
520
|
return o(() => {
|
|
521
521
|
let e = s.current;
|
|
522
|
-
e &&
|
|
522
|
+
e && it(e, c, i, a.height);
|
|
523
523
|
}, [
|
|
524
524
|
i,
|
|
525
525
|
a.height,
|
|
526
526
|
c
|
|
527
527
|
]), f(({ camera: e, size: t }) => {
|
|
528
528
|
let n = s.current;
|
|
529
|
-
n &&
|
|
529
|
+
n && it(n, c, e, t.height);
|
|
530
530
|
}), /* @__PURE__ */ B("sprite", {
|
|
531
531
|
ref: s,
|
|
532
532
|
position: n,
|
|
@@ -542,8 +542,8 @@ function gt({ color: e, fontSize: t, position: n, text: r }) {
|
|
|
542
542
|
})
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
|
-
function
|
|
546
|
-
let f = c(() => new y().setFromPoints(a.points), [a.points]), p =
|
|
545
|
+
function vt({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset: i, line: a, showBottom: s, showLeft: l, showRight: u, showTop: d }) {
|
|
546
|
+
let f = c(() => new y().setFromPoints(a.points), [a.points]), p = pt({
|
|
547
547
|
cameraPosition: e,
|
|
548
548
|
floorY: n,
|
|
549
549
|
line: a,
|
|
@@ -551,19 +551,19 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
|
|
|
551
551
|
showLeft: l,
|
|
552
552
|
showRight: u,
|
|
553
553
|
showTop: d
|
|
554
|
-
}), m = p ?
|
|
554
|
+
}), m = p ? mt({
|
|
555
555
|
endpoint: p,
|
|
556
556
|
labelOffset: i,
|
|
557
557
|
line: a
|
|
558
558
|
}) : null;
|
|
559
559
|
return o(() => () => f.dispose(), [f]), /* @__PURE__ */ V("lineSegments", {
|
|
560
560
|
geometry: f,
|
|
561
|
-
position:
|
|
561
|
+
position: st(a.loc, n),
|
|
562
562
|
children: [/* @__PURE__ */ B("lineBasicMaterial", {
|
|
563
563
|
color: t,
|
|
564
564
|
depthWrite: !1,
|
|
565
565
|
linewidth: 2
|
|
566
|
-
}), m && /* @__PURE__ */ B(
|
|
566
|
+
}), m && /* @__PURE__ */ B(_t, {
|
|
567
567
|
color: t,
|
|
568
568
|
fontSize: r,
|
|
569
569
|
position: m,
|
|
@@ -571,8 +571,8 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
|
|
|
571
571
|
})]
|
|
572
572
|
});
|
|
573
573
|
}
|
|
574
|
-
function
|
|
575
|
-
let h = p((e) => e.camera), g = l(null), [_, v] = u(() => new z()), y =
|
|
574
|
+
function yt({ color: e, floorY: t, fontSize: n = Je, grids: r, labelOffset: i = Xe, 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 z()), y = lt(e), b = c(() => r ? dt({
|
|
576
576
|
flattenToFloor: t !== void 0,
|
|
577
577
|
grids: r,
|
|
578
578
|
showBottom: a,
|
|
@@ -586,7 +586,7 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
|
|
|
586
586
|
o,
|
|
587
587
|
s,
|
|
588
588
|
d
|
|
589
|
-
]), x = c(() =>
|
|
589
|
+
]), x = c(() => ht(b, t), [t, b]), S = c(() => Math.max(i, gt(b, x, t) * .015), [
|
|
590
590
|
x,
|
|
591
591
|
t,
|
|
592
592
|
i,
|
|
@@ -596,11 +596,11 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
|
|
|
596
596
|
let e = g.current;
|
|
597
597
|
if (!e) return;
|
|
598
598
|
let t = h.position.clone();
|
|
599
|
-
e.worldToLocal(t), !(t.distanceToSquared(_) <
|
|
599
|
+
e.worldToLocal(t), !(t.distanceToSquared(_) < Ze) && v(t);
|
|
600
600
|
}), !m || !b.length ? null : /* @__PURE__ */ B("group", {
|
|
601
601
|
ref: g,
|
|
602
602
|
userData: { modelGrids: !0 },
|
|
603
|
-
children: b.map((e) => /* @__PURE__ */ B(
|
|
603
|
+
children: b.map((e) => /* @__PURE__ */ B(vt, {
|
|
604
604
|
cameraPosition: _,
|
|
605
605
|
color: y,
|
|
606
606
|
floorY: t,
|
|
@@ -629,33 +629,33 @@ 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
|
|
633
|
-
function
|
|
632
|
+
var bt = new N();
|
|
633
|
+
function xt(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
|
|
637
|
+
return !Array.isArray(t) || t.length !== 16 ? null : new N().fromArray(t);
|
|
638
638
|
} catch (e) {
|
|
639
639
|
return console.warn("Model matrix parsing error", e), null;
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
function xt(e) {
|
|
643
|
-
return bt(St(e));
|
|
644
|
-
}
|
|
645
642
|
function St(e) {
|
|
643
|
+
return xt(Ct(e));
|
|
644
|
+
}
|
|
645
|
+
function Ct(e) {
|
|
646
646
|
return e.coordinationMatrix ?? Object.values(e.data)[0]?.matrix;
|
|
647
647
|
}
|
|
648
|
-
function
|
|
648
|
+
function wt({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r, materialMode: i }) {
|
|
649
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() ??
|
|
655
|
+
let e = Object.values(r.data).some((e) => !!e.matrix) ? t?.clone() ?? St(r) : null, i = Infinity, a = new z();
|
|
656
656
|
return {
|
|
657
657
|
data: Object.values(r.data).map((e) => {
|
|
658
|
-
let t = (
|
|
658
|
+
let t = (xt(e.matrix) ?? new N()).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__ */ B(
|
|
676
|
+
if (!r) return /* @__PURE__ */ B(we, {});
|
|
677
677
|
let s = i ?? r.renderSettings?.materialMode ?? "quality", l = r.renderSettings?.useDoubleSideMaterial === !0;
|
|
678
678
|
return /* @__PURE__ */ V("group", {
|
|
679
|
-
matrix: o.coordinationMatrix ??
|
|
679
|
+
matrix: o.coordinationMatrix ?? bt,
|
|
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__ */ B(
|
|
682
|
+
children: [o.data.map(({ data: t, isIfcSpace: n, key: r, material: i, meshMatrix: a }) => /* @__PURE__ */ B(qe, {
|
|
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__ */ B(
|
|
690
|
+
}, r)), /* @__PURE__ */ B(yt, {
|
|
691
691
|
floorY: o.floorY,
|
|
692
692
|
grids: r.grids,
|
|
693
693
|
showBottom: a.bottom,
|
|
@@ -698,10 +698,10 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
|
|
|
698
698
|
})]
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
|
-
var
|
|
701
|
+
var Tt = r(wt);
|
|
702
702
|
//#endregion
|
|
703
703
|
//#region src/viewer/utils/GeometryUtils/useGeometryIndex.ts
|
|
704
|
-
function
|
|
704
|
+
function Et() {
|
|
705
705
|
return {
|
|
706
706
|
elementIndex: /* @__PURE__ */ new Map(),
|
|
707
707
|
ifcSpacesVisible: !1,
|
|
@@ -711,10 +711,10 @@ function Tt() {
|
|
|
711
711
|
records: /* @__PURE__ */ new Set()
|
|
712
712
|
};
|
|
713
713
|
}
|
|
714
|
-
function
|
|
714
|
+
function Dt(e) {
|
|
715
715
|
return e instanceof Uint16Array || e instanceof Uint32Array ? e : e.length > 65535 ? new Uint32Array(e) : new Uint16Array(e);
|
|
716
716
|
}
|
|
717
|
-
function
|
|
717
|
+
function Ot(e, t, n, r) {
|
|
718
718
|
let i = n.get(e);
|
|
719
719
|
if (i) return i;
|
|
720
720
|
i = {
|
|
@@ -724,20 +724,20 @@ function Dt(e, t, n, r) {
|
|
|
724
724
|
let a = r.get(e);
|
|
725
725
|
return a || (a = [], r.set(e, a)), a.push(i), i;
|
|
726
726
|
}
|
|
727
|
-
function
|
|
728
|
-
n &&
|
|
727
|
+
function kt(e, t, n, r, i, a) {
|
|
728
|
+
n && Ot(e, r, i, a).vertexRanges.push({
|
|
729
729
|
count: n,
|
|
730
730
|
start: t
|
|
731
731
|
});
|
|
732
732
|
}
|
|
733
|
-
function
|
|
734
|
-
n && (
|
|
733
|
+
function At(e, t, n, r, i, a) {
|
|
734
|
+
n && (Ot(e, r, i, a), r.triangleRanges.push({
|
|
735
735
|
count: n,
|
|
736
736
|
id: e,
|
|
737
737
|
start: t
|
|
738
738
|
}));
|
|
739
739
|
}
|
|
740
|
-
function
|
|
740
|
+
function jt(e) {
|
|
741
741
|
let t = e;
|
|
742
742
|
for (; t;) {
|
|
743
743
|
let e = t.userData.modelID;
|
|
@@ -746,19 +746,19 @@ function At(e) {
|
|
|
746
746
|
}
|
|
747
747
|
return 0;
|
|
748
748
|
}
|
|
749
|
-
function
|
|
749
|
+
function Mt(e) {
|
|
750
750
|
return e.name === "space" || e.userData.isIfcSpace === !0;
|
|
751
751
|
}
|
|
752
|
-
function
|
|
753
|
-
let t = l(
|
|
752
|
+
function Nt(e) {
|
|
753
|
+
let t = l(Et()), n = i(() => {
|
|
754
754
|
let n = e.current, r = t.current;
|
|
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
|
|
758
|
+
if (!(e instanceof P)) return;
|
|
759
759
|
let t = e, n = t.geometry, o = n.index, s = n.attributes.ids;
|
|
760
760
|
if (!o || !s) return;
|
|
761
|
-
let c =
|
|
761
|
+
let c = jt(t), l = Mt(t), u = Dt(o.array), d = {
|
|
762
762
|
hiddenIds: /* @__PURE__ */ new Set(),
|
|
763
763
|
initialVisible: t.visible,
|
|
764
764
|
isIfcSpace: l,
|
|
@@ -771,15 +771,15 @@ function Mt(e) {
|
|
|
771
771
|
}, f = /* @__PURE__ */ new Map(), p = null, m = 0, h = u.length / 3;
|
|
772
772
|
for (let e = 0; e < h; e++) {
|
|
773
773
|
let t = s.getX(u[e * 3]);
|
|
774
|
-
p === null ? (p = t, m = e) : t !== p && (
|
|
774
|
+
p === null ? (p = t, m = e) : t !== p && (At(p, m, e - m, d, f, i), p = t, m = e);
|
|
775
775
|
}
|
|
776
|
-
p !== null &&
|
|
776
|
+
p !== null && At(p, m, h - m, d, f, i);
|
|
777
777
|
let g = null, _ = 0;
|
|
778
778
|
for (let e = 0; e < s.count; e++) {
|
|
779
779
|
let t = s.getX(e);
|
|
780
|
-
g === null ? (g = t, _ = e) : t !== g && (
|
|
780
|
+
g === null ? (g = t, _ = e) : t !== g && (kt(g, _, e - _, d, f, i), g = t, _ = e);
|
|
781
781
|
}
|
|
782
|
-
g !== null &&
|
|
782
|
+
g !== null && kt(g, _, s.count - _, d, f, i), a.add(d), l && !r.ifcSpacesVisible && (t.visible = !1);
|
|
783
783
|
}), t.current = {
|
|
784
784
|
elementIndex: i,
|
|
785
785
|
ifcSpacesVisible: r.ifcSpacesVisible,
|
|
@@ -789,7 +789,7 @@ function Mt(e) {
|
|
|
789
789
|
records: a
|
|
790
790
|
}, t.current;
|
|
791
791
|
}, [e]), r = i(() => {
|
|
792
|
-
t.current =
|
|
792
|
+
t.current = Et();
|
|
793
793
|
}, []);
|
|
794
794
|
return c(() => ({
|
|
795
795
|
buildIndex: n,
|
|
@@ -798,95 +798,95 @@ function Mt(e) {
|
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
800
|
//#region src/viewer/utils/GeometryUtils/useGeometryUtils.ts
|
|
801
|
-
function
|
|
801
|
+
function Pt(e, t) {
|
|
802
802
|
return e instanceof Uint32Array ? new Uint32Array(t) : new Uint16Array(t);
|
|
803
803
|
}
|
|
804
|
-
function
|
|
804
|
+
function Ft(e) {
|
|
805
805
|
let t = e.geometry;
|
|
806
|
-
Object.assign(t, { boundsTree: void 0 }), e.geometry.index?.count && Object.assign(t, { boundsTree: new
|
|
806
|
+
Object.assign(t, { boundsTree: void 0 }), e.geometry.index?.count && Object.assign(t, { boundsTree: new xe(e.geometry, { indirect: !0 }) });
|
|
807
807
|
}
|
|
808
|
-
function
|
|
809
|
-
e.mesh.geometry.setIndex(new v(t, 1)), n &&
|
|
808
|
+
function It(e, t, n = !0) {
|
|
809
|
+
e.mesh.geometry.setIndex(new v(t, 1)), n && Ft(e.mesh);
|
|
810
810
|
}
|
|
811
|
-
function
|
|
811
|
+
function Lt(e, t) {
|
|
812
812
|
return e.initialVisible && (!e.isIfcSpace || t);
|
|
813
813
|
}
|
|
814
|
-
function
|
|
814
|
+
function Rt(e, t) {
|
|
815
815
|
let n = e.mesh.geometry, r = n.index?.array;
|
|
816
|
-
e.mesh.visible =
|
|
816
|
+
e.mesh.visible = Lt(e, t), r !== e.originalIndex && It(e, e.originalIndex, !1), e.originalBoundsTree ? Object.assign(n, { boundsTree: e.originalBoundsTree }) : (Ft(e.mesh), e.originalBoundsTree = e.mesh.geometry.boundsTree ?? null);
|
|
817
817
|
}
|
|
818
|
-
function
|
|
818
|
+
function zt(e) {
|
|
819
819
|
return e === null ? "*" : e.size ? Array.from(e).sort((e, t) => e - t).join(",") : "";
|
|
820
820
|
}
|
|
821
|
-
function
|
|
822
|
-
return `h:${
|
|
821
|
+
function Bt(e, t, n, r) {
|
|
822
|
+
return `h:${zt(e)}|i:${zt(n)}|s:${r ? Number(t) : ""}`;
|
|
823
823
|
}
|
|
824
|
-
function
|
|
824
|
+
function Vt(e, t, n) {
|
|
825
825
|
return !t.has(e) && (!n || n.has(e));
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function Ht(e, t) {
|
|
828
828
|
Object.entries(e).forEach(([e, n]) => {
|
|
829
829
|
n.forEach((n) => t(Number(e), n));
|
|
830
830
|
});
|
|
831
831
|
}
|
|
832
|
-
function
|
|
832
|
+
function Ut(e, t, n) {
|
|
833
833
|
e.hiddenIds.has(t) || (e.hiddenIds.add(t), n.add(e));
|
|
834
834
|
}
|
|
835
|
-
function
|
|
835
|
+
function Wt(e, t, n) {
|
|
836
836
|
e && console.log(`${t}:`, Date.now() - n, "ms");
|
|
837
837
|
}
|
|
838
838
|
function W(e, t, n, r) {
|
|
839
|
-
let { hiddenIds: i, originalIndex: a, triangleRanges: o } = e, s =
|
|
839
|
+
let { hiddenIds: i, originalIndex: a, triangleRanges: o } = e, s = Bt(i, t, n, e.isIfcSpace);
|
|
840
840
|
if (e.visibleStateKey === s) return;
|
|
841
841
|
if (!i.size && !n) {
|
|
842
|
-
|
|
842
|
+
Rt(e, t), e.visibleStateKey = s;
|
|
843
843
|
return;
|
|
844
844
|
}
|
|
845
845
|
let c = 0, l = 0;
|
|
846
846
|
if (o.forEach(({ count: e, id: t }) => {
|
|
847
|
-
|
|
847
|
+
Vt(t, i, n) ? c += e * 3 : l += e * 3;
|
|
848
848
|
}), !c) {
|
|
849
|
-
|
|
849
|
+
Rt(e, t), e.mesh.visible = !1, e.visibleStateKey = s;
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
852
|
if (!l) {
|
|
853
|
-
|
|
853
|
+
Rt(e, t), e.visibleStateKey = s;
|
|
854
854
|
return;
|
|
855
855
|
}
|
|
856
|
-
e.mesh.visible =
|
|
857
|
-
let u =
|
|
856
|
+
e.mesh.visible = Lt(e, t);
|
|
857
|
+
let u = Pt(a, c), d = 0;
|
|
858
858
|
for (let e = 0; e < o.length; e++) {
|
|
859
859
|
let { count: t, id: r, start: s } = o[e];
|
|
860
|
-
if (!
|
|
860
|
+
if (!Vt(r, i, n)) continue;
|
|
861
861
|
let c = s * 3, l = c + t * 3;
|
|
862
862
|
u.set(a.subarray(c, l), d), d += t * 3;
|
|
863
863
|
}
|
|
864
|
-
r || (e.originalBoundsTree = null),
|
|
864
|
+
r || (e.originalBoundsTree = null), It(e, u), e.visibleStateKey = s;
|
|
865
865
|
}
|
|
866
866
|
function G(e, t) {
|
|
867
867
|
return e.isolatedIdsByModel ? e.isolatedIdsByModel.get(t.modelID) ?? /* @__PURE__ */ new Set() : e.isolatedIds;
|
|
868
868
|
}
|
|
869
|
-
function
|
|
869
|
+
function Gt(e) {
|
|
870
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
|
+
Ut(t, e, i);
|
|
876
876
|
});
|
|
877
|
-
}), i.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)),
|
|
877
|
+
}), i.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Wt(r, "hideByIds", t);
|
|
878
878
|
}, [
|
|
879
879
|
o,
|
|
880
880
|
a,
|
|
881
881
|
r
|
|
882
882
|
]), u = i(() => {
|
|
883
883
|
let e = Date.now(), i = o(), s = /* @__PURE__ */ new Set();
|
|
884
|
-
|
|
884
|
+
Ht(t, (e, t) => {
|
|
885
885
|
let n = i.elementIndex.get(t);
|
|
886
886
|
n && n.forEach(({ record: n }) => {
|
|
887
|
-
n.modelID === e &&
|
|
887
|
+
n.modelID === e && Ut(n, t, s);
|
|
888
888
|
});
|
|
889
|
-
}), s.forEach((e) => W(e, i.ifcSpacesVisible, G(i, e), a)), n(),
|
|
889
|
+
}), s.forEach((e) => W(e, i.ifcSpacesVisible, G(i, e), a)), n(), Wt(r, "hideSelected", e);
|
|
890
890
|
}, [
|
|
891
891
|
o,
|
|
892
892
|
a,
|
|
@@ -900,24 +900,24 @@ function Wt(e) {
|
|
|
900
900
|
t && t.forEach(({ record: t }) => {
|
|
901
901
|
t.hiddenIds.delete(e) && i.add(t);
|
|
902
902
|
});
|
|
903
|
-
}), i.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)),
|
|
903
|
+
}), i.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Wt(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) => W(e, n.ifcSpacesVisible, G(n, e), a)),
|
|
910
|
+
n.isolatedIdsByModel = null, n.isolatedIds = new Set(e), n.records.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Wt(r, "isolateByIds", t);
|
|
911
911
|
}, [
|
|
912
912
|
o,
|
|
913
913
|
a,
|
|
914
914
|
r
|
|
915
915
|
]), p = i(() => {
|
|
916
916
|
let e = Date.now(), n = o(), i = /* @__PURE__ */ new Map();
|
|
917
|
-
|
|
917
|
+
Ht(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) => W(e, n.ifcSpacesVisible, G(n, e), a)),
|
|
920
|
+
}), n.isolatedIdsByModel = i, n.isolatedIds = null, n.records.forEach((e) => W(e, n.ifcSpacesVisible, G(n, e), a)), Wt(r, "isolateSelected", e);
|
|
921
921
|
}, [
|
|
922
922
|
o,
|
|
923
923
|
a,
|
|
@@ -925,7 +925,7 @@ function Wt(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) => W(e, t.ifcSpacesVisible, G(t, e), a)),
|
|
928
|
+
t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => W(e, t.ifcSpacesVisible, G(t, e), a)), Wt(r, "resetIsolation", e);
|
|
929
929
|
}, [
|
|
930
930
|
o,
|
|
931
931
|
a,
|
|
@@ -952,7 +952,7 @@ function Wt(e) {
|
|
|
952
952
|
let e = Date.now(), t = o();
|
|
953
953
|
t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => {
|
|
954
954
|
e.hiddenIds.clear(), W(e, t.ifcSpacesVisible, G(t, e), a);
|
|
955
|
-
}),
|
|
955
|
+
}), Wt(r, "showAll", e);
|
|
956
956
|
}, [
|
|
957
957
|
o,
|
|
958
958
|
a,
|
|
@@ -964,11 +964,11 @@ function Wt(e) {
|
|
|
964
964
|
}
|
|
965
965
|
//#endregion
|
|
966
966
|
//#region src/viewer/utils/ClippingUtils/ClippingCaps.ts
|
|
967
|
-
var
|
|
968
|
-
function
|
|
967
|
+
var Kt = "#ffffff", qt = "#111111", Jt = 1e-5, Yt = 1e-6, Xt = 2e-5, Zt = 50, Qt = 1e-6, $t = 2, en = .005 / 3, tn = .15 / 3, nn = 128, rn = 24, an = 1e-8;
|
|
968
|
+
function on(e) {
|
|
969
969
|
return !(!e.parent || !e.visible || !e.geometry.index?.count);
|
|
970
970
|
}
|
|
971
|
-
function
|
|
971
|
+
function sn(e) {
|
|
972
972
|
let t = e;
|
|
973
973
|
for (; t;) {
|
|
974
974
|
let e = t.userData.modelID;
|
|
@@ -977,21 +977,35 @@ function an(e) {
|
|
|
977
977
|
}
|
|
978
978
|
return 0;
|
|
979
979
|
}
|
|
980
|
-
function
|
|
981
|
-
let t =
|
|
980
|
+
function cn(e) {
|
|
981
|
+
let t = e;
|
|
982
|
+
for (; t;) {
|
|
983
|
+
if (typeof t.userData.modelID == "number") return t;
|
|
984
|
+
t = t.parent;
|
|
985
|
+
}
|
|
986
|
+
return e;
|
|
987
|
+
}
|
|
988
|
+
function ln(e) {
|
|
989
|
+
return Math.abs(e.normal.y) < .9 ? new z(0, 1, 0) : new z(1, 0, 0);
|
|
990
|
+
}
|
|
991
|
+
function un(e, t) {
|
|
992
|
+
return e.clone().addScaledVector(t.normal, -e.dot(t.normal));
|
|
993
|
+
}
|
|
994
|
+
function dn(e, t) {
|
|
995
|
+
let n = t ? un(t, e) : new z(), r = n.lengthSq() > an ? n.normalize() : ln(e).cross(e.normal).normalize(), i = e.normal.clone().cross(r).normalize();
|
|
982
996
|
return {
|
|
983
997
|
origin: e.coplanarPoint(new z()),
|
|
984
|
-
u:
|
|
985
|
-
v:
|
|
998
|
+
u: r,
|
|
999
|
+
v: i
|
|
986
1000
|
};
|
|
987
1001
|
}
|
|
988
|
-
function
|
|
1002
|
+
function fn(e, t) {
|
|
989
1003
|
return `${Math.round(e.x / t)}:${Math.round(e.y / t)}`;
|
|
990
1004
|
}
|
|
991
|
-
function
|
|
1005
|
+
function pn(e, t) {
|
|
992
1006
|
return e < t ? `${e}|${t}` : `${t}|${e}`;
|
|
993
1007
|
}
|
|
994
|
-
function
|
|
1008
|
+
function mn(e) {
|
|
995
1009
|
let t = 0;
|
|
996
1010
|
for (let n = 0; n < e.length; n++) {
|
|
997
1011
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -999,23 +1013,23 @@ function ln(e) {
|
|
|
999
1013
|
}
|
|
1000
1014
|
return t * .5;
|
|
1001
1015
|
}
|
|
1002
|
-
function
|
|
1003
|
-
let
|
|
1004
|
-
|
|
1005
|
-
let
|
|
1006
|
-
if (
|
|
1007
|
-
|
|
1008
|
-
for (let
|
|
1009
|
-
-
|
|
1016
|
+
function hn(e) {
|
|
1017
|
+
let t = nn, n = document.createElement("canvas");
|
|
1018
|
+
n.width = t, n.height = t;
|
|
1019
|
+
let r = n.getContext("2d");
|
|
1020
|
+
if (r) {
|
|
1021
|
+
r.fillStyle = Kt, r.fillRect(0, 0, t, t), r.strokeStyle = qt, r.lineWidth = rn, r.lineCap = "square", r.beginPath();
|
|
1022
|
+
for (let e of [
|
|
1023
|
+
-t,
|
|
1010
1024
|
0,
|
|
1011
|
-
|
|
1012
|
-
])
|
|
1013
|
-
|
|
1025
|
+
t
|
|
1026
|
+
]) r.moveTo(e, t), r.lineTo(e + t, 0);
|
|
1027
|
+
r.stroke();
|
|
1014
1028
|
}
|
|
1015
|
-
let
|
|
1016
|
-
return
|
|
1029
|
+
let i = new b(n);
|
|
1030
|
+
return i.anisotropy = Math.max(1, e), i.magFilter = A, i.minFilter = j, i.wrapS = L, i.wrapT = L, i.needsUpdate = !0, i;
|
|
1017
1031
|
}
|
|
1018
|
-
var
|
|
1032
|
+
var gn = class {
|
|
1019
1033
|
active;
|
|
1020
1034
|
plane;
|
|
1021
1035
|
capMaterial;
|
|
@@ -1025,20 +1039,23 @@ var dn = class {
|
|
|
1025
1039
|
root = new D();
|
|
1026
1040
|
box = new g();
|
|
1027
1041
|
meshBox = new g();
|
|
1028
|
-
inverseMatrix = new
|
|
1029
|
-
localPlane = new
|
|
1042
|
+
inverseMatrix = new N();
|
|
1043
|
+
localPlane = new I();
|
|
1030
1044
|
tempLine = new ee();
|
|
1031
1045
|
tempVector = new z();
|
|
1032
1046
|
tempVector1 = new z();
|
|
1047
|
+
tempAxisX = new z();
|
|
1048
|
+
tempAxisY = new z();
|
|
1049
|
+
tempAxisZ = new z();
|
|
1033
1050
|
worldPoint = new z();
|
|
1034
1051
|
capClippingPlanesKey = "";
|
|
1035
1052
|
capShader = null;
|
|
1036
|
-
closeGapTolerance =
|
|
1053
|
+
closeGapTolerance = Jt;
|
|
1037
1054
|
preselection = null;
|
|
1038
|
-
tolerance =
|
|
1055
|
+
tolerance = Jt;
|
|
1039
1056
|
constructor(e, t) {
|
|
1040
|
-
this.context = e, this.plane = t, this.active = e.getActive() && e.getCapsActive(), this.capTexture =
|
|
1041
|
-
color:
|
|
1057
|
+
this.context = e, this.plane = t, this.active = e.getActive() && e.getCapsActive(), this.capTexture = hn(e.getMaxTextureAnisotropy()), this.capMaterial = new F({
|
|
1058
|
+
color: Kt,
|
|
1042
1059
|
depthWrite: !1,
|
|
1043
1060
|
map: this.capTexture,
|
|
1044
1061
|
side: w
|
|
@@ -1046,7 +1063,7 @@ var dn = class {
|
|
|
1046
1063
|
colorIndex: [0],
|
|
1047
1064
|
ids: [0],
|
|
1048
1065
|
modelID: [0]
|
|
1049
|
-
}, this.capMaterial.color.convertSRGBToLinear(), this.setupCapMaterialShader(), this.capMesh = new
|
|
1066
|
+
}, this.capMaterial.color.convertSRGBToLinear(), this.setupCapMaterialShader(), this.capMesh = new P(new y(), this.capMaterial), this.capMesh.frustumCulled = !1, this.capMesh.renderOrder = $t, this.root.add(this.capMesh), this.root.visible = this.active, this.root.name = "clipping-caps", this.root.renderOrder = $t, this.context.getScene().add(this.root), this.context.caps.push(this), this.update();
|
|
1050
1067
|
}
|
|
1051
1068
|
dispose() {
|
|
1052
1069
|
this.root.removeFromParent(), this.capMesh.geometry.dispose(), this.capTexture.dispose(), this.capMaterial.dispose();
|
|
@@ -1106,21 +1123,21 @@ var dn = class {
|
|
|
1106
1123
|
let e = new y(), t = this.getModelWorldBox();
|
|
1107
1124
|
if (!t) return e;
|
|
1108
1125
|
let n = t.getSize(new z()).length();
|
|
1109
|
-
this.tolerance = Math.max(
|
|
1110
|
-
let r =
|
|
1111
|
-
if (e.setAttribute("position", new E(l, 3)), e.setAttribute("uv", new E(u, 2)), e.setAttribute("ids", new
|
|
1126
|
+
this.tolerance = Math.max(Jt, n * Yt), this.closeGapTolerance = Math.max(this.tolerance * Zt, n * Xt);
|
|
1127
|
+
let r = dn(this.plane, this.getModelHatchReferenceDirection()), 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);
|
|
1128
|
+
if (e.setAttribute("position", new E(l, 3)), e.setAttribute("uv", new E(u, 2)), e.setAttribute("ids", new he(s, 1)), e.setAttribute("modelID", new he(c, 1)), e.setAttribute("colorIndex", new v(new Uint8Array(s.length), 1)), s.length) {
|
|
1112
1129
|
let t = new Uint32Array(s.length);
|
|
1113
1130
|
for (let e = 0; e < t.length; e++) t[e] = e;
|
|
1114
|
-
e.setIndex(new
|
|
1131
|
+
e.setIndex(new he(t, 1));
|
|
1115
1132
|
}
|
|
1116
1133
|
return l.length && (e.computeVertexNormals(), e.computeBoundingSphere()), e;
|
|
1117
1134
|
}
|
|
1118
1135
|
getCapSegments(e) {
|
|
1119
1136
|
let t = [];
|
|
1120
|
-
return this.context.getMeshes().filter(
|
|
1137
|
+
return this.context.getMeshes().filter(on).forEach((n) => {
|
|
1121
1138
|
let r = n.geometry.boundsTree;
|
|
1122
1139
|
if (!r) return;
|
|
1123
|
-
let i =
|
|
1140
|
+
let i = sn(n);
|
|
1124
1141
|
n.updateWorldMatrix(!0, !1), this.inverseMatrix.copy(n.matrixWorld).invert(), this.localPlane.copy(this.plane).applyMatrix4(this.inverseMatrix), r.shapecast({
|
|
1125
1142
|
intersectsBounds: (e) => this.localPlane.intersectsBox(e),
|
|
1126
1143
|
intersectsTriangle: (r, a) => {
|
|
@@ -1177,7 +1194,7 @@ var dn = class {
|
|
|
1177
1194
|
}
|
|
1178
1195
|
getElementClosedContours(e) {
|
|
1179
1196
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
1180
|
-
let n =
|
|
1197
|
+
let n = fn(e, this.tolerance), r = t.get(n);
|
|
1181
1198
|
return r || (r = {
|
|
1182
1199
|
edges: /* @__PURE__ */ new Set(),
|
|
1183
1200
|
point: e.clone()
|
|
@@ -1193,12 +1210,12 @@ var dn = class {
|
|
|
1193
1210
|
let i = [];
|
|
1194
1211
|
return t.forEach((e, r) => {
|
|
1195
1212
|
e.edges.forEach((e) => {
|
|
1196
|
-
let a =
|
|
1213
|
+
let a = pn(r, e);
|
|
1197
1214
|
if (n.has(a)) return;
|
|
1198
1215
|
let o = this.walkContour(r, e, t, n);
|
|
1199
1216
|
if (!o) return;
|
|
1200
1217
|
let s = this.cleanContour(o.contour);
|
|
1201
|
-
s.length < 3 || Math.abs(
|
|
1218
|
+
s.length < 3 || Math.abs(mn(s)) < Qt || (o.edges.forEach((e) => n.add(e)), i.push(s));
|
|
1202
1219
|
});
|
|
1203
1220
|
}), i;
|
|
1204
1221
|
}
|
|
@@ -1208,7 +1225,7 @@ var dn = class {
|
|
|
1208
1225
|
let t = n.get(s);
|
|
1209
1226
|
if (!t || !c) return null;
|
|
1210
1227
|
i.push(t.point.clone());
|
|
1211
|
-
let l =
|
|
1228
|
+
let l = pn(s, c);
|
|
1212
1229
|
a.push(l), o.add(l);
|
|
1213
1230
|
let u = s;
|
|
1214
1231
|
if (s = c, s === e) return {
|
|
@@ -1232,7 +1249,7 @@ var dn = class {
|
|
|
1232
1249
|
if (!o || !s) return null;
|
|
1233
1250
|
let c = s.point.clone().sub(o.point), l = Array.from(s.edges).filter((n) => {
|
|
1234
1251
|
if (n === e) return !1;
|
|
1235
|
-
let r =
|
|
1252
|
+
let r = pn(t, n);
|
|
1236
1253
|
return !(i.has(r) || a.has(r));
|
|
1237
1254
|
});
|
|
1238
1255
|
return l.length ? l.includes(n) ? n : l.map((e) => {
|
|
@@ -1265,7 +1282,7 @@ var dn = class {
|
|
|
1265
1282
|
triangulateContours(e, t, n) {
|
|
1266
1283
|
let r = [], i = [], a = [], o = [];
|
|
1267
1284
|
return e.forEach(({ elementID: e, modelID: s, points: c }) => {
|
|
1268
|
-
|
|
1285
|
+
ue.triangulateShape(c, []).forEach(([l, u, d]) => {
|
|
1269
1286
|
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
1287
|
});
|
|
1271
1288
|
}), {
|
|
@@ -1279,44 +1296,56 @@ var dn = class {
|
|
|
1279
1296
|
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
1297
|
}
|
|
1281
1298
|
getHatchSpacing(e) {
|
|
1282
|
-
return Math.max(
|
|
1299
|
+
return Math.max(tn, e * en);
|
|
1300
|
+
}
|
|
1301
|
+
getModelHatchReferenceDirection() {
|
|
1302
|
+
let e = this.context.getMeshes().filter(on)[0];
|
|
1303
|
+
if (!e) return null;
|
|
1304
|
+
let t = cn(e);
|
|
1305
|
+
t.updateWorldMatrix(!0, !1), t.matrixWorld.extractBasis(this.tempAxisX, this.tempAxisY, this.tempAxisZ);
|
|
1306
|
+
for (let e of [
|
|
1307
|
+
this.tempAxisX,
|
|
1308
|
+
this.tempAxisZ,
|
|
1309
|
+
this.tempAxisY
|
|
1310
|
+
]) if (!(e.lengthSq() <= an) && (e.normalize(), un(e, this.plane).lengthSq() > an)) return e.clone();
|
|
1311
|
+
return null;
|
|
1283
1312
|
}
|
|
1284
1313
|
getModelWorldBox() {
|
|
1285
|
-
return this.box.makeEmpty(), this.context.getMeshes().filter(
|
|
1314
|
+
return this.box.makeEmpty(), this.context.getMeshes().filter(on).forEach((e) => {
|
|
1286
1315
|
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
1316
|
}), this.box.isEmpty() ? null : this.box;
|
|
1288
1317
|
}
|
|
1289
|
-
},
|
|
1290
|
-
function
|
|
1318
|
+
}, _n = 1024, vn = 1;
|
|
1319
|
+
function yn(e) {
|
|
1291
1320
|
let t = new v(new Float32Array(e * 3), 3, !1);
|
|
1292
1321
|
return t.setUsage(T), t;
|
|
1293
1322
|
}
|
|
1294
|
-
function
|
|
1323
|
+
function bn(e) {
|
|
1295
1324
|
return Math.max(1, Math.ceil((e.geometry.index?.count ?? 0) / 3));
|
|
1296
1325
|
}
|
|
1297
|
-
function
|
|
1298
|
-
let n = new y(), r = Math.ceil(Math.min(Math.max(
|
|
1299
|
-
n.setAttribute("position",
|
|
1300
|
-
let i = new
|
|
1301
|
-
return i.frustumCulled = !1, i.renderOrder =
|
|
1326
|
+
function xn(e, t) {
|
|
1327
|
+
let n = new y(), r = Math.ceil(Math.min(Math.max(_n, bn(t) * .05), 32768));
|
|
1328
|
+
n.setAttribute("position", yn(r)), n.setDrawRange(0, 0);
|
|
1329
|
+
let i = new k(n, e);
|
|
1330
|
+
return i.frustumCulled = !1, i.renderOrder = vn, i.visible = !1, i;
|
|
1302
1331
|
}
|
|
1303
|
-
function
|
|
1332
|
+
function Sn(e, t) {
|
|
1304
1333
|
let n = e.geometry.getAttribute("position");
|
|
1305
1334
|
if (n.count > t) return n;
|
|
1306
|
-
let r =
|
|
1335
|
+
let r = yn(Math.max(n.count * 2, t + 1));
|
|
1307
1336
|
return r.array.set(n.array), e.geometry.setAttribute("position", r), n = r, n;
|
|
1308
1337
|
}
|
|
1309
|
-
function
|
|
1338
|
+
function Cn(e) {
|
|
1310
1339
|
return e.filter((e) => e.parent && e.geometry.index?.count);
|
|
1311
1340
|
}
|
|
1312
|
-
var
|
|
1341
|
+
var wn = class {
|
|
1313
1342
|
active;
|
|
1314
1343
|
material;
|
|
1315
1344
|
plane;
|
|
1316
1345
|
context;
|
|
1317
1346
|
lines = /* @__PURE__ */ new Map();
|
|
1318
|
-
inverseMatrix = new
|
|
1319
|
-
localPlane = new
|
|
1347
|
+
inverseMatrix = new N();
|
|
1348
|
+
localPlane = new I();
|
|
1320
1349
|
tempLine = new ee();
|
|
1321
1350
|
tempVector = new z();
|
|
1322
1351
|
tempVector1 = new z();
|
|
@@ -1339,12 +1368,12 @@ var yn = class {
|
|
|
1339
1368
|
return this.syncMeshes(), Array.from(this.lines.values());
|
|
1340
1369
|
}
|
|
1341
1370
|
syncMeshes() {
|
|
1342
|
-
let e = new Set(
|
|
1371
|
+
let e = new Set(Cn(this.context.getMeshes()));
|
|
1343
1372
|
this.lines.forEach((t, n) => {
|
|
1344
1373
|
e.has(n) || (t.removeFromParent(), t.geometry.dispose(), this.lines.delete(n));
|
|
1345
1374
|
}), e.forEach((e) => {
|
|
1346
1375
|
if (this.lines.has(e)) return;
|
|
1347
|
-
let t =
|
|
1376
|
+
let t = xn(this.material, e);
|
|
1348
1377
|
e.add(t), this.lines.set(e, t);
|
|
1349
1378
|
}), this.setVisible(this.active);
|
|
1350
1379
|
}
|
|
@@ -1370,7 +1399,7 @@ var yn = class {
|
|
|
1370
1399
|
}
|
|
1371
1400
|
t.updateWorldMatrix(!0, !1), this.inverseMatrix.copy(t.matrixWorld).invert(), this.localPlane.copy(this.plane).applyMatrix4(this.inverseMatrix);
|
|
1372
1401
|
let r = 0, i = e.geometry.getAttribute("position"), a = (t) => {
|
|
1373
|
-
i =
|
|
1402
|
+
i = Sn(e, r), i.setXYZ(r, t.x, t.y, t.z), r++;
|
|
1374
1403
|
};
|
|
1375
1404
|
n.shapecast({
|
|
1376
1405
|
intersectsBounds: (e) => this.localPlane.intersectsBox(e),
|
|
@@ -1381,16 +1410,16 @@ var yn = class {
|
|
|
1381
1410
|
}), e.geometry.setDrawRange(0, r), e.position.set(0, 0, 0), i.needsUpdate = !0;
|
|
1382
1411
|
}));
|
|
1383
1412
|
}
|
|
1384
|
-
},
|
|
1385
|
-
function
|
|
1413
|
+
}, Tn = "#0b2f5f", En = "#0b2f5f", Dn = 0, On = "#1f7ae0", kn = .22, An = .01, jn = .025, Mn = .015, Nn = .02, Pn = 1e-7, Fn = .25, In = .15, Ln = .25, Rn = 1e-5, zn = .2, Bn = 1, K = 1;
|
|
1414
|
+
function Vn(e, t) {
|
|
1386
1415
|
let n = t.getBoundingClientRect();
|
|
1387
1416
|
return new R((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
|
|
1388
1417
|
}
|
|
1389
|
-
function
|
|
1418
|
+
function Hn(e) {
|
|
1390
1419
|
let t = e.getSize(new z());
|
|
1391
|
-
return Math.max(
|
|
1420
|
+
return Math.max(Ln, t.length() * An);
|
|
1392
1421
|
}
|
|
1393
|
-
var
|
|
1422
|
+
var Un = class extends ae {
|
|
1394
1423
|
helper = new D();
|
|
1395
1424
|
borderMaterial;
|
|
1396
1425
|
material;
|
|
@@ -1409,16 +1438,16 @@ var Rn = class extends I {
|
|
|
1409
1438
|
hovered = !1;
|
|
1410
1439
|
listenersActive = !1;
|
|
1411
1440
|
constructor(e, t, n, r) {
|
|
1412
|
-
super(), this.context = e, this.plane = t, this.location = n.clone(), this.normal = r.clone().normalize(), this.material = new
|
|
1413
|
-
color:
|
|
1441
|
+
super(), this.context = e, this.plane = t, this.location = n.clone(), this.normal = r.clone().normalize(), this.material = new F({
|
|
1442
|
+
color: En,
|
|
1414
1443
|
depthWrite: !1,
|
|
1415
|
-
opacity:
|
|
1444
|
+
opacity: Dn,
|
|
1416
1445
|
side: w,
|
|
1417
1446
|
transparent: !0
|
|
1418
1447
|
}), this.helper.position.copy(this.location), this.applyPlaneOrientation(), this.layout = this.getHelperLayout();
|
|
1419
|
-
let i = Math.max(
|
|
1420
|
-
this.borderMaterial = new
|
|
1421
|
-
color:
|
|
1448
|
+
let i = Math.max(Fn, Math.min(this.layout.width, this.layout.height) * jn), a = Math.max(In, Math.min(this.layout.width, this.layout.height) * Mn);
|
|
1449
|
+
this.borderMaterial = new ne({
|
|
1450
|
+
color: Tn,
|
|
1422
1451
|
dashSize: i,
|
|
1423
1452
|
depthWrite: !1,
|
|
1424
1453
|
gapSize: a
|
|
@@ -1449,7 +1478,7 @@ var Rn = class extends I {
|
|
|
1449
1478
|
}
|
|
1450
1479
|
updateBorderDash() {
|
|
1451
1480
|
let e = Math.min(this.layout.width, this.layout.height);
|
|
1452
|
-
this.borderMaterial.dashSize = Math.max(
|
|
1481
|
+
this.borderMaterial.dashSize = Math.max(Fn, e * jn), this.borderMaterial.gapSize = Math.max(In, e * Mn), this.borderMaterial.needsUpdate = !0;
|
|
1453
1482
|
}
|
|
1454
1483
|
addEventListeners() {
|
|
1455
1484
|
if (this.listenersActive) return;
|
|
@@ -1482,21 +1511,20 @@ var Rn = class extends I {
|
|
|
1482
1511
|
});
|
|
1483
1512
|
for (let t of n) {
|
|
1484
1513
|
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.
|
|
1514
|
+
if (n && !(!this.hasHelperPriority(e) && !n.isPointerHitNearEdge(t.point)) && !(!this.hasHelperPriority(e) && this.hasModelIntersection(e))) return {
|
|
1486
1515
|
helper: n,
|
|
1487
1516
|
hit: t
|
|
1488
1517
|
};
|
|
1489
1518
|
}
|
|
1490
1519
|
return null;
|
|
1491
1520
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1521
|
+
hasModelIntersection(e) {
|
|
1522
|
+
return !!this.context.getCameraUtils().getIntersection(!0, {
|
|
1494
1523
|
event: e,
|
|
1495
|
-
filter: (e) => !(e.object instanceof
|
|
1524
|
+
filter: (e) => !(e.object instanceof P) || e.faceIndex === void 0 || e.faceIndex === null ? !1 : !!(e.object.geometry.index && e.object.geometry.attributes.ids),
|
|
1496
1525
|
object: this.context.getMeshes(),
|
|
1497
1526
|
recursive: !1
|
|
1498
1527
|
});
|
|
1499
|
-
return !!(n && n.distance < t);
|
|
1500
1528
|
}
|
|
1501
1529
|
isPointerHitNearEdge(e) {
|
|
1502
1530
|
if (this.polygon.length < 2) return !1;
|
|
@@ -1512,10 +1540,10 @@ var Rn = class extends I {
|
|
|
1512
1540
|
return !1;
|
|
1513
1541
|
}
|
|
1514
1542
|
getEdgeInteractionWidth() {
|
|
1515
|
-
return Math.min(
|
|
1543
|
+
return Math.min(Bn, Math.max(zn, Math.min(this.layout.width, this.layout.height) * Nn));
|
|
1516
1544
|
}
|
|
1517
1545
|
getDragDistanceEpsilon() {
|
|
1518
|
-
return Math.max(
|
|
1546
|
+
return Math.max(Rn, Math.min(this.layout.width, this.layout.height) * Pn);
|
|
1519
1547
|
}
|
|
1520
1548
|
getPointToSegmentDistanceSquared(e, t, n) {
|
|
1521
1549
|
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
|
|
@@ -1528,7 +1556,7 @@ var Rn = class extends I {
|
|
|
1528
1556
|
}
|
|
1529
1557
|
getPointerPointOnPlane(e, t) {
|
|
1530
1558
|
let n = this.context.getDomElement();
|
|
1531
|
-
this.pointer.copy(
|
|
1559
|
+
this.pointer.copy(Vn(e, n));
|
|
1532
1560
|
let r = this.context.getRaycaster(), i = new z();
|
|
1533
1561
|
return r.setFromCamera(this.pointer, this.context.getCamera()), r.ray.intersectPlane(t, i);
|
|
1534
1562
|
}
|
|
@@ -1539,7 +1567,7 @@ var Rn = class extends I {
|
|
|
1539
1567
|
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
1568
|
let n = new z();
|
|
1541
1569
|
this.context.getCamera().getWorldDirection(n), n.normalize();
|
|
1542
|
-
let r = new
|
|
1570
|
+
let r = new I().setFromNormalAndCoplanarPoint(n, t.point);
|
|
1543
1571
|
this.dragState = {
|
|
1544
1572
|
dragPlane: r,
|
|
1545
1573
|
helperStart: this.helper.position.clone(),
|
|
@@ -1581,14 +1609,14 @@ var Rn = class extends I {
|
|
|
1581
1609
|
t && (this.context.clearHelpersHover(this), this.hasHelperPriority(e) && this.stopHelperPriorityEvent(e)), this.hovered !== t && this.setHovered(t);
|
|
1582
1610
|
}
|
|
1583
1611
|
setHovered(e) {
|
|
1584
|
-
this.hovered = e, this.material.color.set(e ?
|
|
1612
|
+
this.hovered = e, this.material.color.set(e ? On : En), this.material.opacity = e ? kn : Dn, this.material.needsUpdate = !0;
|
|
1585
1613
|
}
|
|
1586
1614
|
createPlaneMesh() {
|
|
1587
|
-
let e = new
|
|
1615
|
+
let e = new P(new y(), this.material);
|
|
1588
1616
|
return e.renderOrder = 2, e;
|
|
1589
1617
|
}
|
|
1590
1618
|
createBorder() {
|
|
1591
|
-
let e = new
|
|
1619
|
+
let e = new k(new y(), this.borderMaterial);
|
|
1592
1620
|
return e.renderOrder = 3, e;
|
|
1593
1621
|
}
|
|
1594
1622
|
replaceGeometry(e, t) {
|
|
@@ -1677,7 +1705,7 @@ var Rn = class extends I {
|
|
|
1677
1705
|
minV: -K / 2,
|
|
1678
1706
|
width: K
|
|
1679
1707
|
};
|
|
1680
|
-
let u =
|
|
1708
|
+
let u = Hn(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;
|
|
1681
1709
|
return {
|
|
1682
1710
|
height: g,
|
|
1683
1711
|
maxU: _ + h / 2,
|
|
@@ -1695,7 +1723,7 @@ var Rn = class extends I {
|
|
|
1695
1723
|
};
|
|
1696
1724
|
}
|
|
1697
1725
|
applyPlaneOrientation() {
|
|
1698
|
-
let e = this.getPlaneBasis(), t = new
|
|
1726
|
+
let e = this.getPlaneBasis(), t = new N().makeBasis(e.u, e.v, this.normal);
|
|
1699
1727
|
this.helper.quaternion.setFromRotationMatrix(t);
|
|
1700
1728
|
}
|
|
1701
1729
|
getModelWorldBox() {
|
|
@@ -1718,8 +1746,8 @@ var Rn = class extends I {
|
|
|
1718
1746
|
new z(e.max.x, e.max.y, e.max.z)
|
|
1719
1747
|
];
|
|
1720
1748
|
}
|
|
1721
|
-
},
|
|
1722
|
-
function
|
|
1749
|
+
}, Wn = 250;
|
|
1750
|
+
function Gn(e, t) {
|
|
1723
1751
|
if (Array.isArray(e)) {
|
|
1724
1752
|
e.forEach((e) => {
|
|
1725
1753
|
e.clippingPlanes = t, e.needsUpdate = !0;
|
|
@@ -1728,13 +1756,13 @@ function Bn(e, t) {
|
|
|
1728
1756
|
}
|
|
1729
1757
|
e.clippingPlanes = t, e.needsUpdate = !0;
|
|
1730
1758
|
}
|
|
1731
|
-
function
|
|
1759
|
+
function Kn(e) {
|
|
1732
1760
|
let t = [];
|
|
1733
1761
|
return e?.traverse((e) => {
|
|
1734
|
-
e instanceof
|
|
1762
|
+
e instanceof P && (!e.geometry.index || !e.geometry.attributes.ids || t.push(e));
|
|
1735
1763
|
}), t;
|
|
1736
1764
|
}
|
|
1737
|
-
function
|
|
1765
|
+
function qn(e) {
|
|
1738
1766
|
let t = e;
|
|
1739
1767
|
for (; t;) {
|
|
1740
1768
|
let e = t.userData.modelID;
|
|
@@ -1743,10 +1771,10 @@ function Hn(e) {
|
|
|
1743
1771
|
}
|
|
1744
1772
|
return 0;
|
|
1745
1773
|
}
|
|
1746
|
-
function
|
|
1774
|
+
function Jn(e, t) {
|
|
1747
1775
|
return t.clone().transformDirection(e.matrixWorld).normalize();
|
|
1748
1776
|
}
|
|
1749
|
-
var
|
|
1777
|
+
var Yn = class {
|
|
1750
1778
|
planes = [];
|
|
1751
1779
|
caps = [];
|
|
1752
1780
|
edges = [];
|
|
@@ -1798,11 +1826,14 @@ var Wn = class {
|
|
|
1798
1826
|
getRaycaster() {
|
|
1799
1827
|
return this.context.raycaster;
|
|
1800
1828
|
}
|
|
1829
|
+
getMaxTextureAnisotropy() {
|
|
1830
|
+
return this.context.renderer.capabilities.getMaxAnisotropy();
|
|
1831
|
+
}
|
|
1801
1832
|
getControlRef() {
|
|
1802
1833
|
return this.context.controlRef;
|
|
1803
1834
|
}
|
|
1804
1835
|
getMeshes() {
|
|
1805
|
-
return
|
|
1836
|
+
return Kn(this.context.modelRef.current);
|
|
1806
1837
|
}
|
|
1807
1838
|
getSelectableObjects() {
|
|
1808
1839
|
return this.caps.map((e) => e.getSelectableObject()).filter((e) => e.visible);
|
|
@@ -1839,7 +1870,7 @@ var Wn = class {
|
|
|
1839
1870
|
this.capsDragIdleTimeout = null, !(!this.active || !this.capsDragActive) && (this.caps.forEach((e) => {
|
|
1840
1871
|
e.setVisible(!0), e.update();
|
|
1841
1872
|
}), this.updateCapsVisualState());
|
|
1842
|
-
},
|
|
1873
|
+
}, Wn));
|
|
1843
1874
|
}
|
|
1844
1875
|
clearCapsDragIdleTimeout() {
|
|
1845
1876
|
this.capsDragIdleTimeout !== null && (window.clearTimeout(this.capsDragIdleTimeout), this.capsDragIdleTimeout = null);
|
|
@@ -1869,7 +1900,7 @@ var Wn = class {
|
|
|
1869
1900
|
getSelectedWorldBox() {
|
|
1870
1901
|
let e = this.context.viewerStore.getState().selected, t = new g(), n = new z();
|
|
1871
1902
|
return this.getMeshes().forEach((r) => {
|
|
1872
|
-
let i = e[
|
|
1903
|
+
let i = e[qn(r)];
|
|
1873
1904
|
if (!i?.size) return;
|
|
1874
1905
|
let a = r.geometry.attributes.ids, o = r.geometry.attributes.position;
|
|
1875
1906
|
if (!a || !o) return;
|
|
@@ -1888,7 +1919,7 @@ var Wn = class {
|
|
|
1888
1919
|
updateMaterials() {
|
|
1889
1920
|
let e = this.active ? this.planes : [];
|
|
1890
1921
|
this.getMeshes().forEach((t) => {
|
|
1891
|
-
|
|
1922
|
+
Gn(t.material, e);
|
|
1892
1923
|
}), this.context.camera.updateMatrixWorld();
|
|
1893
1924
|
}
|
|
1894
1925
|
setActive(e) {
|
|
@@ -1907,15 +1938,15 @@ var Wn = class {
|
|
|
1907
1938
|
recursive: !1
|
|
1908
1939
|
});
|
|
1909
1940
|
if (!n?.face) return null;
|
|
1910
|
-
let r = n.point.clone(), i =
|
|
1941
|
+
let r = n.point.clone(), i = Jn(n.object, n.face.normal);
|
|
1911
1942
|
r.add(i.clone().multiplyScalar(.001));
|
|
1912
|
-
let a = new
|
|
1943
|
+
let a = new I().setFromNormalAndCoplanarPoint(i.clone().negate(), r);
|
|
1913
1944
|
return this.addPlane(a, r, i), a.clone();
|
|
1914
1945
|
}
|
|
1915
1946
|
createClippingRectangle(e = !1) {
|
|
1916
1947
|
let t = e ? this.getSelectedWorldBox() : this.getModelWorldBox();
|
|
1917
1948
|
if (!t) return [];
|
|
1918
|
-
let n =
|
|
1949
|
+
let n = Hn(t), r = t.min.clone().addScalar(-n), i = t.max.clone().addScalar(n), a = t.getCenter(new z()), o = [
|
|
1919
1950
|
{
|
|
1920
1951
|
normal: new z(1, 0, 0),
|
|
1921
1952
|
point: new z(r.x, a.y, a.z)
|
|
@@ -1942,7 +1973,7 @@ var Wn = class {
|
|
|
1942
1973
|
}
|
|
1943
1974
|
].map(({ normal: e, point: t }) => ({
|
|
1944
1975
|
normal: e,
|
|
1945
|
-
plane: new
|
|
1976
|
+
plane: new I().setFromNormalAndCoplanarPoint(e, t),
|
|
1946
1977
|
point: t
|
|
1947
1978
|
}));
|
|
1948
1979
|
return o.forEach(({ normal: e, plane: t, point: n }) => {
|
|
@@ -1950,8 +1981,8 @@ var Wn = class {
|
|
|
1950
1981
|
}), this.updateHelpers(), o.map(({ plane: e }) => e.clone());
|
|
1951
1982
|
}
|
|
1952
1983
|
addPlane(e, t, n) {
|
|
1953
|
-
if (this.active || this.setActive(!0), this.planes.push(e), new
|
|
1954
|
-
let t = new
|
|
1984
|
+
if (this.active || this.setActive(!0), this.planes.push(e), new Un(this, e, t, n), new gn(this, e).setVisible(this.active && this.capsActive && !this.capsDragActive), this.updateHelpers(), this.updateCaps(), this.updateMaterials(), this.edgesActive) {
|
|
1985
|
+
let t = new wn(this, e);
|
|
1955
1986
|
t.create(), t.update();
|
|
1956
1987
|
}
|
|
1957
1988
|
}
|
|
@@ -1966,7 +1997,7 @@ var Wn = class {
|
|
|
1966
1997
|
}
|
|
1967
1998
|
setEdgesActive(e) {
|
|
1968
1999
|
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) => {
|
|
1969
|
-
let t = new
|
|
2000
|
+
let t = new wn(this, e);
|
|
1970
2001
|
t.create(), t.update();
|
|
1971
2002
|
})), this.edges.forEach((t) => t.setVisible(this.active && e)));
|
|
1972
2003
|
}
|
|
@@ -1999,8 +2030,8 @@ var Wn = class {
|
|
|
1999
2030
|
this.clearCapsDragIdleTimeout(), this.deleteAllPlanes();
|
|
2000
2031
|
}
|
|
2001
2032
|
};
|
|
2002
|
-
function
|
|
2003
|
-
let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.raycaster), s = p((e) => e.scene), l =
|
|
2033
|
+
function Xn(e, t, n) {
|
|
2034
|
+
let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.raycaster), s = p((e) => e.scene), l = De(), u = c(() => new Yn({
|
|
2004
2035
|
camera: r,
|
|
2005
2036
|
cameraUtils: n,
|
|
2006
2037
|
controlRef: t,
|
|
@@ -2075,29 +2106,89 @@ function Gn(e, t, n) {
|
|
|
2075
2106
|
}), [u]);
|
|
2076
2107
|
}
|
|
2077
2108
|
//#endregion
|
|
2109
|
+
//#region src/viewer/Camera/useCameraUtils.ts
|
|
2110
|
+
var Zn = 1e-6;
|
|
2111
|
+
function Qn(e, t) {
|
|
2112
|
+
let n = t.getBoundingClientRect();
|
|
2113
|
+
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);
|
|
2114
|
+
}
|
|
2115
|
+
function $n(e, t) {
|
|
2116
|
+
return t.every((t) => t.distanceToPoint(e) >= -Zn);
|
|
2117
|
+
}
|
|
2118
|
+
function er(e) {
|
|
2119
|
+
let t = e;
|
|
2120
|
+
for (; t;) {
|
|
2121
|
+
if (!t.visible) return !1;
|
|
2122
|
+
t = t.parent;
|
|
2123
|
+
}
|
|
2124
|
+
return !0;
|
|
2125
|
+
}
|
|
2126
|
+
function tr(e) {
|
|
2127
|
+
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) => {
|
|
2128
|
+
a.current = e;
|
|
2129
|
+
}, []), f = i(() => {
|
|
2130
|
+
let e = a.current;
|
|
2131
|
+
return e?.getActive() ? e.getPlanes() : [];
|
|
2132
|
+
}, []);
|
|
2133
|
+
o(() => {
|
|
2134
|
+
let e = n.domElement, t = (t) => {
|
|
2135
|
+
let n = Qn(t, e);
|
|
2136
|
+
n && (s.current = n);
|
|
2137
|
+
}, r = () => {
|
|
2138
|
+
s.current = null;
|
|
2139
|
+
};
|
|
2140
|
+
return e.addEventListener("pointermove", t), e.addEventListener("pointerdown", t), e.addEventListener("pointerleave", r), () => {
|
|
2141
|
+
e.removeEventListener("pointermove", t), e.removeEventListener("pointerdown", t), e.removeEventListener("pointerleave", r);
|
|
2142
|
+
};
|
|
2143
|
+
}, [n]);
|
|
2144
|
+
let m = i((i = !1, { event: a, filter: o, object: c = e.current, recursive: l = !0, respectClipping: d = !0 } = {}) => {
|
|
2145
|
+
let p = a ? Qn(a, n.domElement) : s.current;
|
|
2146
|
+
if (!p || !c) return i ? null : [];
|
|
2147
|
+
let m = d ? f() : [], h = Array.isArray(c) ? c : [c];
|
|
2148
|
+
t.updateMatrixWorld(), e.current?.updateMatrixWorld(!0), u.current.copy(p), r.setFromCamera(u.current, t);
|
|
2149
|
+
let g = r.intersectObjects(h, l).filter((e) => er(e.object) ? m.length ? $n(e.point, m) : !0 : !1).filter((e) => o ? o(e) : !0);
|
|
2150
|
+
return i ? g[0] ?? null : g;
|
|
2151
|
+
}, [
|
|
2152
|
+
t,
|
|
2153
|
+
f,
|
|
2154
|
+
n,
|
|
2155
|
+
e,
|
|
2156
|
+
r
|
|
2157
|
+
]);
|
|
2158
|
+
return c(() => ({
|
|
2159
|
+
getActiveClippingPlanes: f,
|
|
2160
|
+
getIntersection: m,
|
|
2161
|
+
setClippingSource: d
|
|
2162
|
+
}), [
|
|
2163
|
+
f,
|
|
2164
|
+
m,
|
|
2165
|
+
d
|
|
2166
|
+
]);
|
|
2167
|
+
}
|
|
2168
|
+
//#endregion
|
|
2078
2169
|
//#region src/viewer/utils/DimentionsUtils/DimentionLine.ts
|
|
2079
|
-
var
|
|
2080
|
-
function
|
|
2170
|
+
var nr = 12, rr = 6, ir = 4;
|
|
2171
|
+
function ar() {
|
|
2081
2172
|
return typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2);
|
|
2082
2173
|
}
|
|
2083
|
-
function
|
|
2084
|
-
return e instanceof
|
|
2174
|
+
function or(e, t) {
|
|
2175
|
+
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);
|
|
2085
2176
|
}
|
|
2086
|
-
function
|
|
2087
|
-
let t =
|
|
2177
|
+
function sr(e) {
|
|
2178
|
+
let t = ar(), n = document.createElement("canvas"), r = n.getContext("2d");
|
|
2088
2179
|
if (!r) throw Error("Could not create dimension label canvas context");
|
|
2089
|
-
let i = `600 ${
|
|
2180
|
+
let i = `600 ${nr}px system-ui, "Segoe UI", sans-serif`;
|
|
2090
2181
|
r.font = i;
|
|
2091
|
-
let a = r.measureText(e), o = a.actualBoundingBoxAscent ||
|
|
2182
|
+
let a = r.measureText(e), o = a.actualBoundingBoxAscent || nr * .8, s = a.actualBoundingBoxDescent || nr * .2, c = Math.max(1, Math.ceil(a.width + rr * 2)), l = Math.max(1, Math.ceil(o + s + ir * 2));
|
|
2092
2183
|
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);
|
|
2093
2184
|
let u = new b(n);
|
|
2094
|
-
return u.colorSpace =
|
|
2185
|
+
return u.colorSpace = le, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
|
|
2095
2186
|
height: l,
|
|
2096
2187
|
texture: u,
|
|
2097
2188
|
width: c
|
|
2098
2189
|
};
|
|
2099
2190
|
}
|
|
2100
|
-
var
|
|
2191
|
+
var cr = class e {
|
|
2101
2192
|
static scale = 1;
|
|
2102
2193
|
static scaleFactor = .015;
|
|
2103
2194
|
static units = "m";
|
|
@@ -2169,11 +2260,11 @@ var Qn = class e {
|
|
|
2169
2260
|
this.addEndpointMesh(this.start, this.end), this.addEndpointMesh(this.end, this.start);
|
|
2170
2261
|
}
|
|
2171
2262
|
addEndpointMesh(e, t) {
|
|
2172
|
-
let n = new
|
|
2263
|
+
let n = new P(this.endpointGeometry, this.endpointMaterial);
|
|
2173
2264
|
n.position.copy(e), n.scale.copy(this.endpointBaseScale), n.lookAt(t), n.renderOrder = 4, this.endpointMeshes.push(n), this.root.add(n);
|
|
2174
2265
|
}
|
|
2175
2266
|
createLabelSprite() {
|
|
2176
|
-
let e = new
|
|
2267
|
+
let e = new pe(new me({
|
|
2177
2268
|
depthTest: !1,
|
|
2178
2269
|
depthWrite: !1,
|
|
2179
2270
|
transparent: !0
|
|
@@ -2181,7 +2272,7 @@ var Qn = class e {
|
|
|
2181
2272
|
return e.renderOrder = 5, e;
|
|
2182
2273
|
}
|
|
2183
2274
|
createBoundingBoxMesh() {
|
|
2184
|
-
let e = new
|
|
2275
|
+
let e = new P(new _(1, 1, Math.max(this.length, .001)), this.boundingMaterial);
|
|
2185
2276
|
return e.renderOrder = 3, e;
|
|
2186
2277
|
}
|
|
2187
2278
|
getTextContent() {
|
|
@@ -2192,7 +2283,7 @@ var Qn = class e {
|
|
|
2192
2283
|
let e = this.getTextContent();
|
|
2193
2284
|
if (this.labelText === e) return;
|
|
2194
2285
|
this.labelText = e, this.labelTexture?.dispose();
|
|
2195
|
-
let t =
|
|
2286
|
+
let t = sr(e);
|
|
2196
2287
|
this.labelHeight = t.height, this.labelTexture = t.texture, this.labelWidth = t.width, this.labelSprite.material.map = t.texture, this.labelSprite.material.needsUpdate = !0;
|
|
2197
2288
|
}
|
|
2198
2289
|
updatePositions() {
|
|
@@ -2203,37 +2294,37 @@ var Qn = class e {
|
|
|
2203
2294
|
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)));
|
|
2204
2295
|
}
|
|
2205
2296
|
rescaleMesh(t, n, r) {
|
|
2206
|
-
let i =
|
|
2297
|
+
let i = or(n, t.position.distanceTo(n.position)) / Math.max(1, r) * 12 * e.scaleFactor;
|
|
2207
2298
|
t.scale.setScalar(i);
|
|
2208
2299
|
}
|
|
2209
2300
|
rescaleBoundingMesh(e, t) {
|
|
2210
2301
|
if (!this.boundingMesh) return;
|
|
2211
|
-
let n =
|
|
2302
|
+
let n = or(e, this.boundingMesh.position.distanceTo(e.position)) / Math.max(1, t) * 8;
|
|
2212
2303
|
this.boundingMesh.scale.set(n, n, 1);
|
|
2213
2304
|
}
|
|
2214
2305
|
rescaleLabel(e, t) {
|
|
2215
|
-
let n =
|
|
2306
|
+
let n = or(e, this.labelSprite.position.distanceTo(e.position)), r = this.labelHeight / Math.max(1, t) * n, i = r * (this.labelWidth / this.labelHeight);
|
|
2216
2307
|
this.labelSprite.scale.set(i, r, 1);
|
|
2217
2308
|
}
|
|
2218
|
-
},
|
|
2219
|
-
function
|
|
2309
|
+
}, lr = "#111827", ur = 1, dr = "x";
|
|
2310
|
+
function fr(e) {
|
|
2220
2311
|
let t = [];
|
|
2221
2312
|
return e?.traverse((e) => {
|
|
2222
|
-
e instanceof
|
|
2313
|
+
e instanceof P && e.geometry.attributes.position && t.push(e);
|
|
2223
2314
|
}), t;
|
|
2224
2315
|
}
|
|
2225
|
-
function
|
|
2316
|
+
function pr(e, t, n) {
|
|
2226
2317
|
let r = e.clone();
|
|
2227
2318
|
return r[n] = t[n], r;
|
|
2228
2319
|
}
|
|
2229
|
-
function
|
|
2320
|
+
function mr(e, t) {
|
|
2230
2321
|
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);
|
|
2231
2322
|
return a === n ? "x" : a === r ? "y" : "z";
|
|
2232
2323
|
}
|
|
2233
|
-
var
|
|
2324
|
+
var hr = class e {
|
|
2234
2325
|
active = !1;
|
|
2235
2326
|
axis = null;
|
|
2236
|
-
boundingMaterial = new
|
|
2327
|
+
boundingMaterial = new F({
|
|
2237
2328
|
color: 0,
|
|
2238
2329
|
depthTest: !1,
|
|
2239
2330
|
depthWrite: !1,
|
|
@@ -2244,14 +2335,14 @@ var ar = class e {
|
|
|
2244
2335
|
currentDimension = null;
|
|
2245
2336
|
dimensions = [];
|
|
2246
2337
|
endpointGeometry = e.createEndpointGeometry();
|
|
2247
|
-
endpointMaterial = new
|
|
2248
|
-
color:
|
|
2338
|
+
endpointMaterial = new F({
|
|
2339
|
+
color: lr,
|
|
2249
2340
|
depthTest: !1,
|
|
2250
2341
|
depthWrite: !1
|
|
2251
2342
|
});
|
|
2252
2343
|
endpointScale = new z(1, 1, 1);
|
|
2253
|
-
lineMaterial = new
|
|
2254
|
-
color:
|
|
2344
|
+
lineMaterial = new ne({
|
|
2345
|
+
color: lr,
|
|
2255
2346
|
dashSize: .2,
|
|
2256
2347
|
depthTest: !1,
|
|
2257
2348
|
depthWrite: !1,
|
|
@@ -2259,13 +2350,13 @@ var ar = class e {
|
|
|
2259
2350
|
});
|
|
2260
2351
|
measureInProcess = !1;
|
|
2261
2352
|
moveState = "end";
|
|
2262
|
-
previewMarker = new
|
|
2353
|
+
previewMarker = new P(e.createPreviewGeometry(), new F({
|
|
2263
2354
|
color: 0,
|
|
2264
2355
|
depthTest: !1,
|
|
2265
2356
|
depthWrite: !1
|
|
2266
2357
|
}));
|
|
2267
2358
|
root = new D();
|
|
2268
|
-
snapDistance =
|
|
2359
|
+
snapDistance = ur;
|
|
2269
2360
|
startPoint = new z();
|
|
2270
2361
|
unit = "m";
|
|
2271
2362
|
constructor(e) {
|
|
@@ -2299,13 +2390,13 @@ var ar = class e {
|
|
|
2299
2390
|
});
|
|
2300
2391
|
}
|
|
2301
2392
|
setEndpointScaleFactor(e) {
|
|
2302
|
-
!Number.isFinite(e) || e <= 0 || (
|
|
2393
|
+
!Number.isFinite(e) || e <= 0 || (cr.scaleFactor = e);
|
|
2303
2394
|
}
|
|
2304
2395
|
setSnapDistance(e) {
|
|
2305
2396
|
!Number.isFinite(e) || e < 0 || (this.snapDistance = e);
|
|
2306
2397
|
}
|
|
2307
2398
|
setUnit(e) {
|
|
2308
|
-
this.unit = e,
|
|
2399
|
+
this.unit = e, cr.units = e, cr.scale = e === "mm" ? 1e3 : 1, this.dimensions.forEach((e) => {
|
|
2309
2400
|
e.endPoint = e.end;
|
|
2310
2401
|
}), this.currentDimension && (this.currentDimension.endPoint = this.currentDimension.end);
|
|
2311
2402
|
}
|
|
@@ -2331,7 +2422,7 @@ var ar = class e {
|
|
|
2331
2422
|
changeAxes() {
|
|
2332
2423
|
if (!this.measureInProcess || !this.currentDimension) return;
|
|
2333
2424
|
let e = this.currentDimension.end, t = this.getNextAxis();
|
|
2334
|
-
this.axis = t, this.currentDimension.endPoint =
|
|
2425
|
+
this.axis = t, this.currentDimension.endPoint = pr(this.startPoint, e, t);
|
|
2335
2426
|
}
|
|
2336
2427
|
updateFrame() {
|
|
2337
2428
|
if (!this.active) return;
|
|
@@ -2375,7 +2466,7 @@ var ar = class e {
|
|
|
2375
2466
|
this.currentDimension && (this.currentDimension.createBoundingBox(), this.dimensions.push(this.currentDimension), this.currentDimension = null, this.measureInProcess = !1, this.axis = null);
|
|
2376
2467
|
}
|
|
2377
2468
|
createDimension(e, t) {
|
|
2378
|
-
return new
|
|
2469
|
+
return new cr({
|
|
2379
2470
|
boundingMaterial: this.boundingMaterial,
|
|
2380
2471
|
endpointGeometry: this.endpointGeometry,
|
|
2381
2472
|
endpointMaterial: this.endpointMaterial,
|
|
@@ -2387,7 +2478,7 @@ var ar = class e {
|
|
|
2387
2478
|
});
|
|
2388
2479
|
}
|
|
2389
2480
|
getSnapObjects() {
|
|
2390
|
-
let e =
|
|
2481
|
+
let e = fr(this.context.modelRef.current);
|
|
2391
2482
|
return this.context.getExtraSnapObjects?.().forEach((t) => {
|
|
2392
2483
|
t.visible && e.push(t);
|
|
2393
2484
|
}), e;
|
|
@@ -2405,37 +2496,37 @@ var ar = class e {
|
|
|
2405
2496
|
return this.dimensions.map((e) => e.boundingBox).filter((e) => !!e);
|
|
2406
2497
|
}
|
|
2407
2498
|
getClosestVertex(e) {
|
|
2408
|
-
if (!(e.object instanceof
|
|
2499
|
+
if (!(e.object instanceof P) || !e.face) return e.point.clone();
|
|
2409
2500
|
let t = e.object.geometry.attributes.position;
|
|
2410
2501
|
if (!t) return e.point.clone();
|
|
2411
|
-
let n = [
|
|
2502
|
+
let n = this.context.cameraUtils.getActiveClippingPlanes(), r = [
|
|
2412
2503
|
e.face.a,
|
|
2413
2504
|
e.face.b,
|
|
2414
2505
|
e.face.c
|
|
2415
2506
|
].map((n) => {
|
|
2416
2507
|
let r = new z(t.getX(n), t.getY(n), t.getZ(n));
|
|
2417
2508
|
return e.object.localToWorld(r);
|
|
2418
|
-
}).filter((t) => t.distanceTo(e.point) <= this.snapDistance);
|
|
2419
|
-
return
|
|
2509
|
+
}).filter((t) => t.distanceTo(e.point) <= this.snapDistance && $n(t, n));
|
|
2510
|
+
return r.length ? r.reduce((t, n) => n.distanceTo(e.point) < t.distanceTo(e.point) ? n : t) : e.point.clone();
|
|
2420
2511
|
}
|
|
2421
2512
|
getPreviewEndPoint(e, t) {
|
|
2422
2513
|
if (!t) return this.axis = null, e.clone();
|
|
2423
|
-
let n = this.axis ??
|
|
2424
|
-
return this.axis = n,
|
|
2514
|
+
let n = this.axis ?? mr(this.startPoint, e);
|
|
2515
|
+
return this.axis = n, pr(this.startPoint, e, n);
|
|
2425
2516
|
}
|
|
2426
2517
|
getNextAxis() {
|
|
2427
2518
|
switch (this.axis) {
|
|
2428
2519
|
case "x": return "y";
|
|
2429
2520
|
case "y": return "z";
|
|
2430
2521
|
case "z": return "x";
|
|
2431
|
-
default: return
|
|
2522
|
+
default: return dr;
|
|
2432
2523
|
}
|
|
2433
2524
|
}
|
|
2434
2525
|
getIsMoving() {
|
|
2435
2526
|
return this.moveState !== "end" && this.moveState !== "start";
|
|
2436
2527
|
}
|
|
2437
2528
|
rescalePreviewMarker() {
|
|
2438
|
-
let { camera: e, viewportHeight: t } = this.context, n = this.previewMarker.position.distanceTo(e.position), r = e instanceof
|
|
2529
|
+
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;
|
|
2439
2530
|
this.previewMarker.scale.setScalar(r);
|
|
2440
2531
|
}
|
|
2441
2532
|
setSelectionInteractionDisabled(e) {
|
|
@@ -2472,11 +2563,11 @@ var ar = class e {
|
|
|
2472
2563
|
return n.translate(0, -e / 2, 0), n.rotateX(-Math.PI / 2), n;
|
|
2473
2564
|
}
|
|
2474
2565
|
static createPreviewGeometry() {
|
|
2475
|
-
return new
|
|
2566
|
+
return new fe(.5, 16, 12);
|
|
2476
2567
|
}
|
|
2477
2568
|
};
|
|
2478
|
-
function
|
|
2479
|
-
let i = p((e) => e.camera), a = p((e) => e.gl), s = p((e) => e.scene), l = p((e) => e.size), u =
|
|
2569
|
+
function gr(e, t, n, r) {
|
|
2570
|
+
let i = p((e) => e.camera), a = p((e) => e.gl), s = p((e) => e.scene), l = p((e) => e.size), u = De(), d = c(() => new hr({
|
|
2480
2571
|
camera: i,
|
|
2481
2572
|
cameraUtils: n,
|
|
2482
2573
|
controlRef: t,
|
|
@@ -2543,15 +2634,15 @@ function or(e, t, n, r) {
|
|
|
2543
2634
|
}
|
|
2544
2635
|
//#endregion
|
|
2545
2636
|
//#region src/viewer/utils/Hotkeys/useHotkeysUtils.tsx
|
|
2546
|
-
function
|
|
2637
|
+
function _r(e) {
|
|
2547
2638
|
return e instanceof HTMLElement ? e.isContentEditable || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement : !1;
|
|
2548
2639
|
}
|
|
2549
|
-
function
|
|
2640
|
+
function vr() {
|
|
2550
2641
|
let e = H((e) => e.api), t = H((e) => e.defaultHotkeysEnabled);
|
|
2551
2642
|
o(() => {
|
|
2552
2643
|
if (!t) return;
|
|
2553
2644
|
let n = (t) => {
|
|
2554
|
-
|
|
2645
|
+
_r(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());
|
|
2555
2646
|
};
|
|
2556
2647
|
return window.addEventListener("keydown", n), () => {
|
|
2557
2648
|
window.removeEventListener("keydown", n);
|
|
@@ -2559,69 +2650,9 @@ function cr() {
|
|
|
2559
2650
|
}, [e, t]);
|
|
2560
2651
|
}
|
|
2561
2652
|
//#endregion
|
|
2562
|
-
//#region src/viewer/Camera/useCameraUtils.ts
|
|
2563
|
-
var lr = 1e-6;
|
|
2564
|
-
function ur(e, t) {
|
|
2565
|
-
let n = t.getBoundingClientRect();
|
|
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);
|
|
2567
|
-
}
|
|
2568
|
-
function dr(e, t) {
|
|
2569
|
-
return t.every((t) => t.distanceToPoint(e) >= -lr);
|
|
2570
|
-
}
|
|
2571
|
-
function fr(e) {
|
|
2572
|
-
let t = e;
|
|
2573
|
-
for (; t;) {
|
|
2574
|
-
if (!t.visible) return !1;
|
|
2575
|
-
t = t.parent;
|
|
2576
|
-
}
|
|
2577
|
-
return !0;
|
|
2578
|
-
}
|
|
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) => {
|
|
2581
|
-
a.current = e;
|
|
2582
|
-
}, []), f = i(() => {
|
|
2583
|
-
let e = a.current;
|
|
2584
|
-
return e?.getActive() ? e.getPlanes() : [];
|
|
2585
|
-
}, []);
|
|
2586
|
-
o(() => {
|
|
2587
|
-
let e = n.domElement, t = (t) => {
|
|
2588
|
-
let n = ur(t, e);
|
|
2589
|
-
n && (s.current = n);
|
|
2590
|
-
}, r = () => {
|
|
2591
|
-
s.current = null;
|
|
2592
|
-
};
|
|
2593
|
-
return e.addEventListener("pointermove", t), e.addEventListener("pointerdown", t), e.addEventListener("pointerleave", r), () => {
|
|
2594
|
-
e.removeEventListener("pointermove", t), e.removeEventListener("pointerdown", t), e.removeEventListener("pointerleave", r);
|
|
2595
|
-
};
|
|
2596
|
-
}, [n]);
|
|
2597
|
-
let m = i((i = !1, { event: a, filter: o, object: c = e.current, recursive: l = !0, respectClipping: d = !0 } = {}) => {
|
|
2598
|
-
let p = a ? ur(a, n.domElement) : s.current;
|
|
2599
|
-
if (!p || !c) return i ? null : [];
|
|
2600
|
-
let m = d ? f() : [], h = Array.isArray(c) ? c : [c];
|
|
2601
|
-
t.updateMatrixWorld(), e.current?.updateMatrixWorld(!0), u.current.copy(p), r.setFromCamera(u.current, t);
|
|
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);
|
|
2603
|
-
return i ? g[0] ?? null : g;
|
|
2604
|
-
}, [
|
|
2605
|
-
t,
|
|
2606
|
-
f,
|
|
2607
|
-
n,
|
|
2608
|
-
e,
|
|
2609
|
-
r
|
|
2610
|
-
]);
|
|
2611
|
-
return c(() => ({
|
|
2612
|
-
getActiveClippingPlanes: f,
|
|
2613
|
-
getIntersection: m,
|
|
2614
|
-
setClippingSource: d
|
|
2615
|
-
}), [
|
|
2616
|
-
f,
|
|
2617
|
-
m,
|
|
2618
|
-
d
|
|
2619
|
-
]);
|
|
2620
|
-
}
|
|
2621
|
-
//#endregion
|
|
2622
2653
|
//#region src/viewer/Selector/SelectionBox.ts
|
|
2623
|
-
var
|
|
2624
|
-
function
|
|
2654
|
+
var yr = new z(), br = new z(), q = new R(), xr = new z(), Sr = new z(), Cr = new z(), wr = new z(), Tr = new z(), Er = new z(), Dr = new z();
|
|
2655
|
+
function Or(e) {
|
|
2625
2656
|
let t = e;
|
|
2626
2657
|
for (; t;) {
|
|
2627
2658
|
let e = t.modelID ?? t.userData.modelID;
|
|
@@ -2630,7 +2661,7 @@ function Cr(e) {
|
|
|
2630
2661
|
}
|
|
2631
2662
|
return 0;
|
|
2632
2663
|
}
|
|
2633
|
-
function
|
|
2664
|
+
function kr(e) {
|
|
2634
2665
|
let t = e;
|
|
2635
2666
|
for (; t;) {
|
|
2636
2667
|
if (!t.visible) return !1;
|
|
@@ -2638,16 +2669,16 @@ function wr(e) {
|
|
|
2638
2669
|
}
|
|
2639
2670
|
return !0;
|
|
2640
2671
|
}
|
|
2641
|
-
function
|
|
2642
|
-
return n.length ? (
|
|
2672
|
+
function Ar(e, t, n) {
|
|
2673
|
+
return n.length ? (xr.copy(t).applyMatrix4(e.matrixWorld), $n(xr, n)) : !0;
|
|
2643
2674
|
}
|
|
2644
|
-
function
|
|
2645
|
-
return i.length ? (
|
|
2646
|
-
let t = e.distanceToPoint(
|
|
2675
|
+
function jr(e, t, n, r, i) {
|
|
2676
|
+
return i.length ? (Sr.copy(t).applyMatrix4(e.matrixWorld), Cr.copy(n).applyMatrix4(e.matrixWorld), wr.copy(r).applyMatrix4(e.matrixWorld), i.every((e) => {
|
|
2677
|
+
let t = e.distanceToPoint(Sr), n = e.distanceToPoint(Cr), r = e.distanceToPoint(wr);
|
|
2647
2678
|
return !(t < -1e-6 && n < -1e-6 && r < -1e-6);
|
|
2648
2679
|
})) : !0;
|
|
2649
2680
|
}
|
|
2650
|
-
function
|
|
2681
|
+
function Mr(e) {
|
|
2651
2682
|
let t = e.getBoundingClientRect();
|
|
2652
2683
|
return {
|
|
2653
2684
|
height: t.height,
|
|
@@ -2656,7 +2687,7 @@ function Dr(e) {
|
|
|
2656
2687
|
width: t.width
|
|
2657
2688
|
};
|
|
2658
2689
|
}
|
|
2659
|
-
function
|
|
2690
|
+
function Nr(e) {
|
|
2660
2691
|
return {
|
|
2661
2692
|
boundsCheckMs: 0,
|
|
2662
2693
|
candidateIds: 0,
|
|
@@ -2682,7 +2713,7 @@ function Or(e) {
|
|
|
2682
2713
|
triangleProjectionMs: 0
|
|
2683
2714
|
};
|
|
2684
2715
|
}
|
|
2685
|
-
function
|
|
2716
|
+
function Pr(e, t) {
|
|
2686
2717
|
return {
|
|
2687
2718
|
minX: Math.min(e.x, t.x),
|
|
2688
2719
|
minY: Math.min(e.y, t.y),
|
|
@@ -2690,43 +2721,43 @@ function kr(e, t) {
|
|
|
2690
2721
|
maxY: Math.max(e.y, t.y)
|
|
2691
2722
|
};
|
|
2692
2723
|
}
|
|
2693
|
-
function
|
|
2724
|
+
function Fr(e, t) {
|
|
2694
2725
|
return t.x >= e.x ? "contains" : "intersects";
|
|
2695
2726
|
}
|
|
2696
|
-
function
|
|
2697
|
-
return
|
|
2727
|
+
function Ir(e, t) {
|
|
2728
|
+
return Lr(e.x, e.y, t);
|
|
2698
2729
|
}
|
|
2699
|
-
function
|
|
2730
|
+
function Lr(e, t, n) {
|
|
2700
2731
|
return e >= n.minX && e <= n.maxX && t >= n.minY && t <= n.maxY;
|
|
2701
2732
|
}
|
|
2702
|
-
function
|
|
2733
|
+
function Rr(e, t, n, r, i, a) {
|
|
2703
2734
|
return (a - t) * (n - e) > (r - t) * (i - e);
|
|
2704
2735
|
}
|
|
2705
|
-
function
|
|
2706
|
-
return
|
|
2736
|
+
function zr(e, t, n, r, i, a, o, s) {
|
|
2737
|
+
return Rr(e, t, i, a, o, s) !== Rr(n, r, i, a, o, s) && Rr(e, t, n, r, i, a) !== Rr(e, t, n, r, o, s);
|
|
2707
2738
|
}
|
|
2708
|
-
function
|
|
2739
|
+
function Br(e, t, n, r, i) {
|
|
2709
2740
|
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;
|
|
2710
2741
|
return s >= 0 && c >= 0 && s + c <= 2 * a * o;
|
|
2711
2742
|
}
|
|
2712
|
-
function
|
|
2713
|
-
return
|
|
2743
|
+
function Vr(e, t, n, r) {
|
|
2744
|
+
return Ir(e, r) || Ir(t, r) || Ir(n, r) || Br(r.minX, r.minY, e, t, n) || Br(r.maxX, r.minY, e, t, n) || Br(r.maxX, r.maxY, e, t, n) || Br(r.minX, r.maxY, e, t, n) ? !0 : Hr(e, t, r) || Hr(t, n, r) || Hr(n, e, r);
|
|
2714
2745
|
}
|
|
2715
|
-
function
|
|
2716
|
-
return
|
|
2746
|
+
function Hr(e, t, n) {
|
|
2747
|
+
return zr(e.x, e.y, t.x, t.y, n.minX, n.minY, n.maxX, n.minY) || zr(e.x, e.y, t.x, t.y, n.maxX, n.minY, n.maxX, n.maxY) || zr(e.x, e.y, t.x, t.y, n.maxX, n.maxY, n.minX, n.maxY) || zr(e.x, e.y, t.x, t.y, n.minX, n.maxY, n.minX, n.minY);
|
|
2717
2748
|
}
|
|
2718
|
-
function
|
|
2719
|
-
let a =
|
|
2749
|
+
function Ur(e, t, n, r, i = new R()) {
|
|
2750
|
+
let a = yr.copy(t).applyMatrix4(e.matrixWorld).project(n);
|
|
2720
2751
|
return i.set((a.x + 1) / 2 * r.width + r.left, (-a.y + 1) / 2 * r.height + r.top);
|
|
2721
2752
|
}
|
|
2722
|
-
function
|
|
2753
|
+
function Wr(e, t, n, r, i) {
|
|
2723
2754
|
let a = Infinity, o = -Infinity, s = Infinity, c = -Infinity, l = 0;
|
|
2724
|
-
for (let u = 0; u < 2; u++) for (let d = 0; d < 2; d++) for (let f = 0; f < 2; f++)
|
|
2725
|
-
return o < n.minX || a > n.maxX || c < n.minY || s > n.maxY ?
|
|
2755
|
+
for (let u = 0; u < 2; u++) for (let d = 0; d < 2; d++) for (let f = 0; f < 2; f++) br.set(u ? t.max.x : t.min.x, d ? t.max.y : t.min.y, f ? t.max.z : t.min.z), Ur(e, br, 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), Ir(q, n) && (l += 1);
|
|
2756
|
+
return o < n.minX || a > n.maxX || c < n.minY || s > n.maxY ? Se : l === 8 ? ye : be;
|
|
2726
2757
|
}
|
|
2727
|
-
function
|
|
2758
|
+
function Gr(e, t, n, r) {
|
|
2728
2759
|
let i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
2729
|
-
for (let c = 0; c < 2; c++) for (let l = 0; l < 2; l++) for (let u = 0; u < 2; u++)
|
|
2760
|
+
for (let c = 0; c < 2; c++) for (let l = 0; l < 2; l++) for (let u = 0; u < 2; u++) br.set(c ? t.max.x : t.min.x, l ? t.max.y : t.min.y, u ? t.max.z : t.min.z), Ur(e, br, 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);
|
|
2730
2761
|
return {
|
|
2731
2762
|
minX: i,
|
|
2732
2763
|
minY: o,
|
|
@@ -2734,41 +2765,41 @@ function Br(e, t, n, r) {
|
|
|
2734
2765
|
maxY: s
|
|
2735
2766
|
};
|
|
2736
2767
|
}
|
|
2737
|
-
function
|
|
2768
|
+
function Kr(e, t) {
|
|
2738
2769
|
return !(e.maxX < t.minX || e.minX > t.maxX || e.maxY < t.minY || e.minY > t.maxY);
|
|
2739
2770
|
}
|
|
2740
|
-
function
|
|
2771
|
+
function qr(e, t, n, r) {
|
|
2741
2772
|
e.geometry.boundingBox || e.geometry.computeBoundingBox();
|
|
2742
2773
|
let i = e.geometry.boundingBox;
|
|
2743
|
-
return i ?
|
|
2774
|
+
return i ? Kr(Gr(e, i, n, r), t) : !0;
|
|
2744
2775
|
}
|
|
2745
|
-
function
|
|
2776
|
+
function Jr(e, t, n) {
|
|
2746
2777
|
let r = e.get(t);
|
|
2747
2778
|
r || (r = /* @__PURE__ */ new Set(), e.set(t, r)), r.add(n);
|
|
2748
2779
|
}
|
|
2749
|
-
function
|
|
2780
|
+
function Yr(e) {
|
|
2750
2781
|
let t = 0;
|
|
2751
2782
|
return e.forEach((e) => {
|
|
2752
2783
|
t += e.size;
|
|
2753
2784
|
}), t;
|
|
2754
2785
|
}
|
|
2755
|
-
function
|
|
2786
|
+
function Xr(e, t, n, r = []) {
|
|
2756
2787
|
let i = e.geometry, a = i.index, o = i.attributes.ids, s = i.attributes.position;
|
|
2757
2788
|
if (!a || !o || !s) return;
|
|
2758
2789
|
let c = t * 3;
|
|
2759
|
-
r.length && (
|
|
2790
|
+
r.length && (Tr.fromBufferAttribute(s, a.getX(c)), Er.fromBufferAttribute(s, a.getX(c + 1)), Dr.fromBufferAttribute(s, a.getX(c + 2)), !jr(e, Tr, Er, Dr, r)) || Jr(n, Or(e), o.getX(a.getX(c)));
|
|
2760
2791
|
}
|
|
2761
|
-
function
|
|
2792
|
+
function Zr({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i, clippingPlanes: a, profile: o }) {
|
|
2762
2793
|
let s = performance.now(), c = /* @__PURE__ */ new Map(), l = new z();
|
|
2763
2794
|
e.traverse((e) => {
|
|
2764
2795
|
let s = e;
|
|
2765
|
-
if (!s.isMesh || !
|
|
2796
|
+
if (!s.isMesh || !kr(s)) return;
|
|
2766
2797
|
let u = s.geometry.attributes.ids, d = s.geometry.attributes.position;
|
|
2767
2798
|
if (!(!u || !d)) {
|
|
2768
2799
|
o && (o.containedVerticesVisited += u.count);
|
|
2769
2800
|
for (let e = 0; e < u.count; e++) {
|
|
2770
|
-
let f =
|
|
2771
|
-
if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !
|
|
2801
|
+
let f = Or(s), p = u.getX(e);
|
|
2802
|
+
if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !Ar(s, l, a))) continue;
|
|
2772
2803
|
o && (o.containedCandidateVertices += 1);
|
|
2773
2804
|
let m = `${f}:${p}`, h = c.get(m);
|
|
2774
2805
|
h || (h = {
|
|
@@ -2776,23 +2807,23 @@ function Kr({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i,
|
|
|
2776
2807
|
inside: 0,
|
|
2777
2808
|
modelID: f,
|
|
2778
2809
|
total: 0
|
|
2779
|
-
}, c.set(m, h)), h.total += 1,
|
|
2810
|
+
}, c.set(m, h)), h.total += 1, Ir(Ur(s, l, t, n), r) && (h.inside += 1);
|
|
2780
2811
|
}
|
|
2781
2812
|
}
|
|
2782
2813
|
});
|
|
2783
2814
|
let u = /* @__PURE__ */ new Map();
|
|
2784
2815
|
return c.forEach((e) => {
|
|
2785
|
-
e.total > 0 && e.total === e.inside &&
|
|
2816
|
+
e.total > 0 && e.total === e.inside && Jr(u, e.modelID, e.id);
|
|
2786
2817
|
}), o && (o.containedIdsMs += performance.now() - s), u;
|
|
2787
2818
|
}
|
|
2788
|
-
function
|
|
2819
|
+
function Qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect: i, mode: a, profile: o }) {
|
|
2789
2820
|
let s = performance.now(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
2790
2821
|
if (!e) return c;
|
|
2791
|
-
let u =
|
|
2822
|
+
let u = Mr(r), d = performance.now();
|
|
2792
2823
|
e.updateMatrixWorld(!0), t.updateMatrixWorld(), o && (o.matrixUpdateMs += performance.now() - d), e.traverse((e) => {
|
|
2793
2824
|
let r = e;
|
|
2794
2825
|
if (!r.isMesh) return;
|
|
2795
|
-
if (o && (o.meshCount += 1), !
|
|
2826
|
+
if (o && (o.meshCount += 1), !kr(r)) {
|
|
2796
2827
|
o && (o.skippedMeshCount += 1);
|
|
2797
2828
|
return;
|
|
2798
2829
|
}
|
|
@@ -2801,7 +2832,7 @@ function qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
|
|
|
2801
2832
|
o && (o.skippedMeshCount += 1);
|
|
2802
2833
|
return;
|
|
2803
2834
|
}
|
|
2804
|
-
let d = performance.now(), f =
|
|
2835
|
+
let d = performance.now(), f = qr(r, i, t, u);
|
|
2805
2836
|
if (o && (o.boundsCheckMs += performance.now() - d), !f) {
|
|
2806
2837
|
o && (o.skippedMeshCount += 1);
|
|
2807
2838
|
return;
|
|
@@ -2809,26 +2840,26 @@ function qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
|
|
|
2809
2840
|
let p = performance.now();
|
|
2810
2841
|
s.shapecast({
|
|
2811
2842
|
intersectsBounds: (e) => {
|
|
2812
|
-
let n = performance.now(), a =
|
|
2843
|
+
let n = performance.now(), a = Wr(r, e, i, t, u);
|
|
2813
2844
|
return o && (o.intersectsBoundsCalls += 1, o.intersectsBoundsMs += performance.now() - n), a;
|
|
2814
2845
|
},
|
|
2815
2846
|
intersectsRange: (e, t, i) => {
|
|
2816
2847
|
let u = performance.now();
|
|
2817
2848
|
if (o && (o.intersectsRangeCalls += 1), !i) return o && (o.intersectsRangeMs += performance.now() - u), !1;
|
|
2818
|
-
for (let i = e; i < e + t; i++)
|
|
2849
|
+
for (let i = e; i < e + t; i++) Xr(r, s.resolveTriangleIndex(i), a === "contains" ? l : c, n);
|
|
2819
2850
|
return o && (o.intersectsRangeMs += performance.now() - u), !1;
|
|
2820
2851
|
},
|
|
2821
2852
|
intersectsTriangle: (e, s, d) => {
|
|
2822
2853
|
let f = performance.now();
|
|
2823
2854
|
if (o && (o.intersectsTriangleCalls += 1), !d) {
|
|
2824
|
-
let n = performance.now(), a =
|
|
2825
|
-
if (o && (o.triangleProjectionMs += performance.now() - n), !
|
|
2855
|
+
let n = performance.now(), a = Ur(r, e.a, t, u), s = Ur(r, e.b, t, u), c = Ur(r, e.c, t, u);
|
|
2856
|
+
if (o && (o.triangleProjectionMs += performance.now() - n), !Vr(a, s, c, i)) return o && (o.intersectsTriangleMs += performance.now() - f), !1;
|
|
2826
2857
|
}
|
|
2827
|
-
return a === "contains" ?
|
|
2858
|
+
return a === "contains" ? Xr(r, s, l, n) : Xr(r, s, c, n), o && (o.intersectsTriangleMs += performance.now() - f), !1;
|
|
2828
2859
|
}
|
|
2829
2860
|
}), o && (o.shapecastMs += performance.now() - p);
|
|
2830
2861
|
});
|
|
2831
|
-
let f = a === "contains" ?
|
|
2862
|
+
let f = a === "contains" ? Zr({
|
|
2832
2863
|
model: e,
|
|
2833
2864
|
camera: t,
|
|
2834
2865
|
clippingPlanes: n,
|
|
@@ -2837,19 +2868,19 @@ function qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
|
|
|
2837
2868
|
candidateIdsByModel: l,
|
|
2838
2869
|
profile: o
|
|
2839
2870
|
}) : c;
|
|
2840
|
-
return o && (o.candidateIds =
|
|
2871
|
+
return o && (o.candidateIds = Yr(l), o.selectedIds = Yr(f), o.totalMs = performance.now() - s), f;
|
|
2841
2872
|
}
|
|
2842
|
-
function
|
|
2843
|
-
let t =
|
|
2873
|
+
function $r(e) {
|
|
2874
|
+
let t = Nr(e.mode);
|
|
2844
2875
|
return {
|
|
2845
|
-
ids:
|
|
2876
|
+
ids: Qr({
|
|
2846
2877
|
...e,
|
|
2847
2878
|
profile: t
|
|
2848
2879
|
}),
|
|
2849
2880
|
profile: t
|
|
2850
2881
|
};
|
|
2851
2882
|
}
|
|
2852
|
-
function
|
|
2883
|
+
function ei(e) {
|
|
2853
2884
|
return e === "contains" ? {
|
|
2854
2885
|
border: "rgb(37, 99, 235)",
|
|
2855
2886
|
background: "rgba(37, 99, 235, 0.16)"
|
|
@@ -2858,32 +2889,32 @@ function Yr(e) {
|
|
|
2858
2889
|
background: "rgba(22, 163, 74, 0.16)"
|
|
2859
2890
|
};
|
|
2860
2891
|
}
|
|
2861
|
-
function
|
|
2862
|
-
let r =
|
|
2892
|
+
function ti(e, t, n) {
|
|
2893
|
+
let r = ei(Fr(t, n));
|
|
2863
2894
|
if (!e.current) {
|
|
2864
2895
|
let t = document.createElement("div");
|
|
2865
2896
|
t.style.position = "fixed", t.style.pointerEvents = "none", t.style.zIndex = "10", e.current = t, document.body.appendChild(t);
|
|
2866
2897
|
}
|
|
2867
|
-
let i =
|
|
2898
|
+
let i = Pr(t, n);
|
|
2868
2899
|
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`;
|
|
2869
2900
|
}
|
|
2870
|
-
function
|
|
2901
|
+
function ni(e) {
|
|
2871
2902
|
e.current?.remove(), e.current = null;
|
|
2872
2903
|
}
|
|
2873
2904
|
//#endregion
|
|
2874
2905
|
//#region src/viewer/Selector/useSelector.tsx
|
|
2875
|
-
var
|
|
2876
|
-
function
|
|
2906
|
+
var ri = 40;
|
|
2907
|
+
function ii(e) {
|
|
2877
2908
|
if (!Array.isArray(e)) return e.userData.shader;
|
|
2878
2909
|
}
|
|
2879
|
-
function
|
|
2880
|
-
let n =
|
|
2910
|
+
function ai(e, t) {
|
|
2911
|
+
let n = ii(e)?.uniforms.preSelectionId;
|
|
2881
2912
|
n && (n.value = t);
|
|
2882
2913
|
}
|
|
2883
|
-
function
|
|
2914
|
+
function oi(e) {
|
|
2884
2915
|
return Number(e.current?.modelID ?? 0);
|
|
2885
2916
|
}
|
|
2886
|
-
function
|
|
2917
|
+
function si(e) {
|
|
2887
2918
|
let t = e;
|
|
2888
2919
|
for (; t;) {
|
|
2889
2920
|
let e = t.modelID ?? t.userData.modelID;
|
|
@@ -2892,7 +2923,7 @@ function ni(e) {
|
|
|
2892
2923
|
}
|
|
2893
2924
|
return 0;
|
|
2894
2925
|
}
|
|
2895
|
-
function
|
|
2926
|
+
function ci(e) {
|
|
2896
2927
|
let t = e;
|
|
2897
2928
|
for (; t;) {
|
|
2898
2929
|
if (!t.visible) return !1;
|
|
@@ -2900,24 +2931,24 @@ function ri(e) {
|
|
|
2900
2931
|
}
|
|
2901
2932
|
return !0;
|
|
2902
2933
|
}
|
|
2903
|
-
function
|
|
2904
|
-
if (!
|
|
2934
|
+
function li(e) {
|
|
2935
|
+
if (!ci(e.object) || !(e.object instanceof P) || e.faceIndex === void 0 || e.faceIndex === null) return !1;
|
|
2905
2936
|
let t = e.object.geometry;
|
|
2906
2937
|
return !!(t.index && t.attributes.ids);
|
|
2907
2938
|
}
|
|
2908
|
-
function
|
|
2909
|
-
if (!
|
|
2939
|
+
function ui(e) {
|
|
2940
|
+
if (!li(e)) return null;
|
|
2910
2941
|
let t = e.object, n = t.geometry, r = n.index.getX(e.faceIndex * 3), i = n.attributes.ids;
|
|
2911
2942
|
if (r >= i.count) return null;
|
|
2912
2943
|
let a = n.attributes.modelID;
|
|
2913
2944
|
return {
|
|
2914
2945
|
elementID: i.getX(r),
|
|
2915
2946
|
hit: e,
|
|
2916
|
-
modelID: a ? a.getX(r) :
|
|
2947
|
+
modelID: a ? a.getX(r) : si(t)
|
|
2917
2948
|
};
|
|
2918
2949
|
}
|
|
2919
|
-
function
|
|
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 =
|
|
2950
|
+
function di(e, t, n, r, i, a) {
|
|
2951
|
+
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 = De(), 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) => {
|
|
2921
2952
|
if (r) {
|
|
2922
2953
|
r(e);
|
|
2923
2954
|
return;
|
|
@@ -2926,22 +2957,22 @@ function oi(e, t, n, r, i, a) {
|
|
|
2926
2957
|
n && (n.cancel(), n.setOrbitPoint(e.x, e.y, e.z));
|
|
2927
2958
|
}, O = () => {
|
|
2928
2959
|
a?.(null), e.current?.traverse((e) => {
|
|
2929
|
-
if (!(e instanceof
|
|
2960
|
+
if (!(e instanceof P)) return;
|
|
2930
2961
|
let t = e;
|
|
2931
|
-
t.preselected = !1,
|
|
2962
|
+
t.preselected = !1, ai(t.material, -1);
|
|
2932
2963
|
});
|
|
2933
2964
|
}, ee = (t, n) => {
|
|
2934
2965
|
a?.({
|
|
2935
2966
|
elementID: n,
|
|
2936
2967
|
modelID: t
|
|
2937
2968
|
}), e.current?.traverse((e) => {
|
|
2938
|
-
if (!(e instanceof
|
|
2969
|
+
if (!(e instanceof P) || si(e) !== t) return;
|
|
2939
2970
|
let r = e;
|
|
2940
|
-
r.preselected = !0,
|
|
2971
|
+
r.preselected = !0, ai(r.material, n);
|
|
2941
2972
|
});
|
|
2942
2973
|
}, te = () => {
|
|
2943
|
-
g.current = null, v.current = !1,
|
|
2944
|
-
},
|
|
2974
|
+
g.current = null, v.current = !1, ni(_), t.current && (t.current.enabled = !0);
|
|
2975
|
+
}, ne = (e) => {
|
|
2945
2976
|
if (E()) {
|
|
2946
2977
|
O();
|
|
2947
2978
|
return;
|
|
@@ -2954,10 +2985,10 @@ function oi(e, t, n, r, i, a) {
|
|
|
2954
2985
|
O();
|
|
2955
2986
|
return;
|
|
2956
2987
|
}
|
|
2957
|
-
let t =
|
|
2988
|
+
let t = le(e);
|
|
2958
2989
|
O(), t && ee(t.modelID, t.elementID);
|
|
2959
2990
|
};
|
|
2960
|
-
function
|
|
2991
|
+
function k() {
|
|
2961
2992
|
return performance.now();
|
|
2962
2993
|
}
|
|
2963
2994
|
let A = (e) => {
|
|
@@ -2966,11 +2997,11 @@ function oi(e, t, n, r, i, a) {
|
|
|
2966
2997
|
return;
|
|
2967
2998
|
}
|
|
2968
2999
|
if (T.current = e, w.current !== null) return;
|
|
2969
|
-
let t =
|
|
3000
|
+
let t = k() - C.current, n = Math.max(0, ri - t);
|
|
2970
3001
|
w.current = window.setTimeout(() => {
|
|
2971
3002
|
w.current = null;
|
|
2972
3003
|
let e = T.current;
|
|
2973
|
-
T.current = null, e && (C.current = performance.now(),
|
|
3004
|
+
T.current = null, e && (C.current = performance.now(), ne(e));
|
|
2974
3005
|
}, n);
|
|
2975
3006
|
}, j = l(null);
|
|
2976
3007
|
o(() => {
|
|
@@ -2981,14 +3012,14 @@ function oi(e, t, n, r, i, a) {
|
|
|
2981
3012
|
}
|
|
2982
3013
|
m && j.current !== null && (console.log("selection spend:", Date.now() - j.current, "ms"), j.current = null);
|
|
2983
3014
|
}, [c, m]);
|
|
2984
|
-
let { camera: M, gl:
|
|
3015
|
+
let { camera: M, gl: N } = p();
|
|
2985
3016
|
function F() {
|
|
2986
3017
|
return Date.now();
|
|
2987
3018
|
}
|
|
2988
3019
|
let re = (e) => {
|
|
2989
|
-
let t =
|
|
3020
|
+
let t = N.domElement.getBoundingClientRect();
|
|
2990
3021
|
return e.clientX >= t.left && e.clientX <= t.right && e.clientY >= t.top && e.clientY <= t.bottom;
|
|
2991
|
-
},
|
|
3022
|
+
}, ie = (t) => {
|
|
2992
3023
|
if (E()) {
|
|
2993
3024
|
S.current = !1, y.current = !1, O();
|
|
2994
3025
|
return;
|
|
@@ -3003,7 +3034,7 @@ function oi(e, t, n, r, i, a) {
|
|
|
3003
3034
|
s.current = "end";
|
|
3004
3035
|
return;
|
|
3005
3036
|
}
|
|
3006
|
-
let n = t.shiftKey, r = t.ctrlKey, i =
|
|
3037
|
+
let n = t.shiftKey, r = t.ctrlKey, i = le(t), a, o = oi(e), l = null;
|
|
3007
3038
|
if (i && (o = i.modelID, l = i.hit.point, a = i.elementID), r) {
|
|
3008
3039
|
a !== void 0 && f(o, [a]);
|
|
3009
3040
|
return;
|
|
@@ -3012,33 +3043,33 @@ function oi(e, t, n, r, i, a) {
|
|
|
3012
3043
|
return;
|
|
3013
3044
|
}
|
|
3014
3045
|
u(o, a === void 0 ? [] : [a], !0), l && D(l);
|
|
3015
|
-
}, ie = (e) => {
|
|
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
3046
|
}, ae = (e) => {
|
|
3047
|
+
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));
|
|
3048
|
+
}, oe = (e) => {
|
|
3018
3049
|
if (E()) {
|
|
3019
3050
|
te();
|
|
3020
3051
|
return;
|
|
3021
3052
|
}
|
|
3022
3053
|
if (!g.current) return;
|
|
3023
3054
|
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(),
|
|
3025
|
-
},
|
|
3055
|
+
n < 6 && r < 6 || (v.current ||= !0, e.preventDefault(), ti(_, g.current, t));
|
|
3056
|
+
}, se = (r) => {
|
|
3026
3057
|
if (E()) {
|
|
3027
3058
|
te();
|
|
3028
3059
|
return;
|
|
3029
3060
|
}
|
|
3030
3061
|
if (!g.current) return;
|
|
3031
3062
|
j.current = F();
|
|
3032
|
-
let i = v.current, a = new R(r.clientX, r.clientY), o =
|
|
3033
|
-
if (g.current = null, v.current = !1,
|
|
3063
|
+
let i = v.current, a = new R(r.clientX, r.clientY), o = Pr(g.current, a), s = Fr(g.current, a);
|
|
3064
|
+
if (g.current = null, v.current = !1, ni(_), t.current && setTimeout(() => {
|
|
3034
3065
|
t.current && (t.current.enabled = !0);
|
|
3035
3066
|
}, 100), !i) return;
|
|
3036
3067
|
y.current = !0, r.preventDefault();
|
|
3037
|
-
let { ids: c, profile: l } =
|
|
3068
|
+
let { ids: c, profile: l } = $r({
|
|
3038
3069
|
model: e.current,
|
|
3039
3070
|
camera: M,
|
|
3040
3071
|
clippingPlanes: n.getActiveClippingPlanes(),
|
|
3041
|
-
domElement:
|
|
3072
|
+
domElement: N.domElement,
|
|
3042
3073
|
rect: o,
|
|
3043
3074
|
mode: s
|
|
3044
3075
|
}), u = Array.from(c.values()).reduce((e, t) => e + t.size, 0), p = {
|
|
@@ -3050,31 +3081,26 @@ function oi(e, t, n, r, i, a) {
|
|
|
3050
3081
|
let n = Array.from(e);
|
|
3051
3082
|
b.current === "remove" ? f(t, n) : d(t, n);
|
|
3052
3083
|
}));
|
|
3053
|
-
},
|
|
3084
|
+
}, I = (e, t) => {
|
|
3054
3085
|
let r = Array.isArray(t) ? t.filter((e) => e.visible) : t ? [t] : [];
|
|
3055
3086
|
return r.length ? n.getIntersection(!1, {
|
|
3056
3087
|
event: e,
|
|
3057
|
-
filter:
|
|
3088
|
+
filter: li,
|
|
3058
3089
|
object: r,
|
|
3059
3090
|
recursive: !0
|
|
3060
3091
|
}) : [];
|
|
3061
|
-
},
|
|
3062
|
-
let
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
}), t;
|
|
3066
|
-
}, ce = (e) => {
|
|
3067
|
-
let t = oe(e, se());
|
|
3068
|
-
for (let e of t) {
|
|
3069
|
-
let t = ai(e);
|
|
3092
|
+
}, ce = () => i?.().filter((e) => e.visible) ?? [], L = (e, t) => {
|
|
3093
|
+
let n = I(e, t);
|
|
3094
|
+
for (let e of n) {
|
|
3095
|
+
let t = ui(e);
|
|
3070
3096
|
if (t) return t;
|
|
3071
3097
|
}
|
|
3072
3098
|
return null;
|
|
3073
|
-
};
|
|
3099
|
+
}, le = (t) => L(t, ce()) || L(t, e.current);
|
|
3074
3100
|
o(() => {
|
|
3075
3101
|
let e = t.current;
|
|
3076
3102
|
if (!e) return;
|
|
3077
|
-
|
|
3103
|
+
N.domElement.addEventListener("pointerdown", ae), N.domElement.addEventListener("pointermove", oe), window.addEventListener("pointerup", se), window.addEventListener("pointerup", ie), N.domElement.addEventListener("contextmenu", a), N.domElement.addEventListener("pointerup", i), N.domElement.addEventListener("pointermove", A), N.domElement.addEventListener("pointerleave", O), N.domElement.addEventListener("pointerdown", r), e.addEventListener("update", n);
|
|
3078
3104
|
function n() {
|
|
3079
3105
|
typeof s.current == "number" ? s.current += 1 : s.current === "start" && (s.current = 1);
|
|
3080
3106
|
}
|
|
@@ -3090,49 +3116,49 @@ function oi(e, t, n, r, i, a) {
|
|
|
3090
3116
|
e.ctrlKey && e.preventDefault();
|
|
3091
3117
|
}
|
|
3092
3118
|
return () => {
|
|
3093
|
-
|
|
3119
|
+
ni(_), w.current !== null && (window.clearTimeout(w.current), w.current = null), T.current = null, O(), e.removeEventListener("update", n), N.domElement.removeEventListener("pointerdown", ae), N.domElement.removeEventListener("pointermove", oe), window.removeEventListener("pointerup", se), window.removeEventListener("pointerup", ie), N.domElement.removeEventListener("contextmenu", a), N.domElement.removeEventListener("pointerup", i), N.domElement.removeEventListener("pointerdown", r), N.domElement.removeEventListener("pointermove", A), N.domElement.removeEventListener("pointerleave", O);
|
|
3094
3120
|
};
|
|
3095
3121
|
});
|
|
3096
3122
|
}
|
|
3097
3123
|
//#endregion
|
|
3098
3124
|
//#region src/viewer/Camera/useCameraFit.tsx
|
|
3099
|
-
var
|
|
3100
|
-
function
|
|
3125
|
+
var fi = new z(1, 1, 1).normalize(), pi = 1.18;
|
|
3126
|
+
function mi() {
|
|
3101
3127
|
let { camera: e } = p();
|
|
3102
3128
|
return i((t, n, r) => {
|
|
3103
|
-
if (!t.current || !(e instanceof
|
|
3129
|
+
if (!t.current || !(e instanceof se)) return;
|
|
3104
3130
|
let i = new g().setFromObject(t.current);
|
|
3105
3131
|
if (i.isEmpty()) return;
|
|
3106
|
-
let a = i.getCenter(new z()), o = i.getBoundingSphere(new
|
|
3107
|
-
e.position.copy(a).addScaledVector(
|
|
3132
|
+
let a = i.getCenter(new z()), o = i.getBoundingSphere(new de()), s = M.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) * pi;
|
|
3133
|
+
e.position.copy(a).addScaledVector(fi, u), e.up.set(0, 1, 0), e.lookAt(a), e.updateProjectionMatrix();
|
|
3108
3134
|
let d = n.current;
|
|
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(
|
|
3135
|
+
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(fi, u * .8), r.current.lookAt(a));
|
|
3110
3136
|
}, [e]);
|
|
3111
3137
|
}
|
|
3112
3138
|
//#endregion
|
|
3113
3139
|
//#region src/viewer/store/ViewerStoreProvider.tsx
|
|
3114
|
-
function
|
|
3115
|
-
let [n] = u(() => t ??
|
|
3116
|
-
return /* @__PURE__ */ B(
|
|
3140
|
+
function hi({ children: e, store: t }) {
|
|
3141
|
+
let [n] = u(() => t ?? je());
|
|
3142
|
+
return /* @__PURE__ */ B(Ee.Provider, {
|
|
3117
3143
|
value: n,
|
|
3118
3144
|
children: e
|
|
3119
3145
|
});
|
|
3120
3146
|
}
|
|
3121
3147
|
//#endregion
|
|
3122
3148
|
//#region src/viewer/utils/ExportUtils/ExportUtils.ts
|
|
3123
|
-
var
|
|
3124
|
-
function
|
|
3149
|
+
var gi = new TextEncoder(), _i = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", vi = "Unknown", yi = ["elementID", "ifcguid"], bi = 0, xi = 33;
|
|
3150
|
+
function Si(e) {
|
|
3125
3151
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3126
3152
|
}
|
|
3127
|
-
function
|
|
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 :
|
|
3153
|
+
function Ci(e, t) {
|
|
3154
|
+
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 : Si(e) && "value" in e ? Ci(e.value, t) : null;
|
|
3129
3155
|
}
|
|
3130
|
-
function
|
|
3131
|
-
let n =
|
|
3156
|
+
function wi(e, t) {
|
|
3157
|
+
let n = Ci(e, t);
|
|
3132
3158
|
if (n !== null) return n;
|
|
3133
3159
|
if (Array.isArray(e)) {
|
|
3134
3160
|
if (!e.length) return t;
|
|
3135
|
-
let n = e.map((e) =>
|
|
3161
|
+
let n = e.map((e) => Ci(e, t));
|
|
3136
3162
|
if (n.every((e) => e !== null)) {
|
|
3137
3163
|
let e = n.join(", ");
|
|
3138
3164
|
return e.trim() ? e : t;
|
|
@@ -3148,18 +3174,18 @@ function yi(e, t) {
|
|
|
3148
3174
|
function J(e) {
|
|
3149
3175
|
return typeof e == "string" && e.trim() ? e : null;
|
|
3150
3176
|
}
|
|
3151
|
-
function
|
|
3152
|
-
let t =
|
|
3153
|
-
return J(e.type ?? e.Type ?? t.type ?? t.Type) ??
|
|
3177
|
+
function Ti(e) {
|
|
3178
|
+
let t = Si(e.props) ? e.props : {};
|
|
3179
|
+
return J(e.type ?? e.Type ?? t.type ?? t.Type) ?? vi;
|
|
3154
3180
|
}
|
|
3155
|
-
function
|
|
3156
|
-
let t =
|
|
3181
|
+
function Ei(e) {
|
|
3182
|
+
let t = Si(e.props) ? e.props : {};
|
|
3157
3183
|
return J(e.guid ?? e.GlobalId ?? e.globalId ?? t.guid ?? t.GlobalId ?? t.globalId) ?? "";
|
|
3158
3184
|
}
|
|
3159
|
-
function
|
|
3185
|
+
function Di(e, t) {
|
|
3160
3186
|
return J(e.Name) ?? J(e.name) ?? J(e.DisplayName) ?? J(e.displayName) ?? `Property ${t + 1}`;
|
|
3161
3187
|
}
|
|
3162
|
-
function
|
|
3188
|
+
function Oi(e) {
|
|
3163
3189
|
for (let t of [
|
|
3164
3190
|
"NominalValue",
|
|
3165
3191
|
"nominalValue",
|
|
@@ -3182,18 +3208,18 @@ function Ci(e) {
|
|
|
3182
3208
|
"description"
|
|
3183
3209
|
].includes(e)));
|
|
3184
3210
|
}
|
|
3185
|
-
function
|
|
3211
|
+
function ki(e, t) {
|
|
3186
3212
|
return J(e.name) ?? J(e.Name) ?? `Set ${t + 1}`;
|
|
3187
3213
|
}
|
|
3188
|
-
function
|
|
3214
|
+
function Ai(e) {
|
|
3189
3215
|
let t = e.props;
|
|
3190
|
-
return Array.isArray(t) ? t.map((e, t) =>
|
|
3191
|
-
label:
|
|
3192
|
-
value:
|
|
3216
|
+
return Array.isArray(t) ? t.map((e, t) => Si(e) ? {
|
|
3217
|
+
label: Di(e, t),
|
|
3218
|
+
value: Oi(e)
|
|
3193
3219
|
} : {
|
|
3194
3220
|
label: `Property ${t + 1}`,
|
|
3195
3221
|
value: e
|
|
3196
|
-
}) :
|
|
3222
|
+
}) : Si(t) ? Object.entries(t).map(([e, t]) => ({
|
|
3197
3223
|
label: e,
|
|
3198
3224
|
value: t
|
|
3199
3225
|
})) : Object.entries(e).filter(([e]) => ![
|
|
@@ -3207,14 +3233,14 @@ function Ti(e) {
|
|
|
3207
3233
|
value: t
|
|
3208
3234
|
}));
|
|
3209
3235
|
}
|
|
3210
|
-
function
|
|
3236
|
+
function ji(e, t) {
|
|
3211
3237
|
e.columnSet.has(t) || (e.columnSet.add(t), e.columns.push(t));
|
|
3212
3238
|
}
|
|
3213
|
-
function
|
|
3239
|
+
function Mi(e, t, n, r, i) {
|
|
3214
3240
|
let a = n.trim();
|
|
3215
|
-
a && (
|
|
3241
|
+
a && (ji(e, a), t[a] = wi(r, i));
|
|
3216
3242
|
}
|
|
3217
|
-
function
|
|
3243
|
+
function Ni(e, t, n) {
|
|
3218
3244
|
let r = {};
|
|
3219
3245
|
return Object.entries(t).forEach(([t, i]) => {
|
|
3220
3246
|
[
|
|
@@ -3222,33 +3248,33 @@ function Oi(e, t, n) {
|
|
|
3222
3248
|
"guid",
|
|
3223
3249
|
"props",
|
|
3224
3250
|
"sets"
|
|
3225
|
-
].includes(t) ||
|
|
3226
|
-
}),
|
|
3227
|
-
|
|
3251
|
+
].includes(t) || Mi(e, r, t, i, n);
|
|
3252
|
+
}), Si(t.props) && Object.entries(t.props).forEach(([t, i]) => {
|
|
3253
|
+
Mi(e, r, t, i, n);
|
|
3228
3254
|
}), Array.isArray(t.sets) && t.sets.forEach((t, i) => {
|
|
3229
|
-
let a =
|
|
3230
|
-
|
|
3231
|
-
|
|
3255
|
+
let a = ki(t, i);
|
|
3256
|
+
Ai(t).forEach((t) => {
|
|
3257
|
+
Mi(e, r, `${a}.${t.label}`, t.value, n);
|
|
3232
3258
|
});
|
|
3233
3259
|
}), r;
|
|
3234
3260
|
}
|
|
3235
|
-
function
|
|
3261
|
+
function Pi(e, t, n) {
|
|
3236
3262
|
Object.entries(t).forEach(([t, r]) => {
|
|
3237
3263
|
let i = Number(t);
|
|
3238
3264
|
if (!Number.isFinite(i)) return;
|
|
3239
|
-
let a =
|
|
3265
|
+
let a = Ti(r), o = e.get(a);
|
|
3240
3266
|
o || (o = {
|
|
3241
3267
|
columns: [],
|
|
3242
3268
|
columnSet: /* @__PURE__ */ new Set(),
|
|
3243
3269
|
rows: []
|
|
3244
3270
|
}, e.set(a, o)), o.rows.push({
|
|
3245
3271
|
elementID: i,
|
|
3246
|
-
ifcguid:
|
|
3247
|
-
values:
|
|
3272
|
+
ifcguid: Ei(r),
|
|
3273
|
+
values: Ni(o, r, n)
|
|
3248
3274
|
});
|
|
3249
3275
|
});
|
|
3250
3276
|
}
|
|
3251
|
-
function
|
|
3277
|
+
function Fi(e) {
|
|
3252
3278
|
return e.replace(/[<>&'"]/g, (e) => {
|
|
3253
3279
|
switch (e) {
|
|
3254
3280
|
case "<": return "<";
|
|
@@ -3260,7 +3286,7 @@ function Ai(e) {
|
|
|
3260
3286
|
}
|
|
3261
3287
|
});
|
|
3262
3288
|
}
|
|
3263
|
-
function
|
|
3289
|
+
function Ii(e) {
|
|
3264
3290
|
let t = e, n = "";
|
|
3265
3291
|
for (; t > 0;) {
|
|
3266
3292
|
let e = (t - 1) % 26;
|
|
@@ -3268,45 +3294,45 @@ function ji(e) {
|
|
|
3268
3294
|
}
|
|
3269
3295
|
return n;
|
|
3270
3296
|
}
|
|
3271
|
-
function
|
|
3272
|
-
return `<c r="${`${
|
|
3297
|
+
function Li(e, t, n) {
|
|
3298
|
+
return `<c r="${`${Ii(n)}${t}`}" t="inlineStr"><is><t${/^\s|\s$/.test(e) ? " xml:space=\"preserve\"" : ""}>${Fi(e)}</t></is></c>`;
|
|
3273
3299
|
}
|
|
3274
|
-
function
|
|
3275
|
-
return `${
|
|
3300
|
+
function Ri(e) {
|
|
3301
|
+
return `${_i}<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${e.map((e, t) => {
|
|
3276
3302
|
let n = t + 1;
|
|
3277
|
-
return `<row r="${n}">${e.map((e, t) =>
|
|
3303
|
+
return `<row r="${n}">${e.map((e, t) => Li(e, n, t + 1)).join("")}</row>`;
|
|
3278
3304
|
}).join("")}</sheetData></worksheet>`;
|
|
3279
3305
|
}
|
|
3280
|
-
function
|
|
3281
|
-
return e.replace(/[\\/?*[\]:]/g, " ").trim() ||
|
|
3306
|
+
function zi(e) {
|
|
3307
|
+
return e.replace(/[\\/?*[\]:]/g, " ").trim() || vi;
|
|
3282
3308
|
}
|
|
3283
|
-
function
|
|
3284
|
-
let n =
|
|
3309
|
+
function Bi(e, t) {
|
|
3310
|
+
let n = zi(e).slice(0, 31), r = n, i = 2;
|
|
3285
3311
|
for (; t.has(r.toLowerCase());) {
|
|
3286
3312
|
let e = ` (${i})`;
|
|
3287
3313
|
r = `${n.slice(0, 31 - e.length)}${e}`, i += 1;
|
|
3288
3314
|
}
|
|
3289
3315
|
return t.add(r.toLowerCase()), r;
|
|
3290
3316
|
}
|
|
3291
|
-
function
|
|
3292
|
-
return `${
|
|
3317
|
+
function Vi(e) {
|
|
3318
|
+
return `${_i}<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${e.map((e, t) => {
|
|
3293
3319
|
let n = t + 1;
|
|
3294
|
-
return `<sheet name="${
|
|
3320
|
+
return `<sheet name="${Fi(e)}" sheetId="${n}" r:id="rId${n}"/>`;
|
|
3295
3321
|
}).join("")}</sheets></workbook>`;
|
|
3296
3322
|
}
|
|
3297
|
-
function
|
|
3298
|
-
return `${
|
|
3323
|
+
function Hi(e) {
|
|
3324
|
+
return `${_i}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${e.map((e, t) => {
|
|
3299
3325
|
let n = t + 1;
|
|
3300
3326
|
return `<Relationship Id="rId${n}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${n}.xml"/>`;
|
|
3301
3327
|
}).join("")}</Relationships>`;
|
|
3302
3328
|
}
|
|
3303
|
-
function
|
|
3304
|
-
return `${
|
|
3329
|
+
function Ui() {
|
|
3330
|
+
return `${_i}<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>`;
|
|
3305
3331
|
}
|
|
3306
|
-
function
|
|
3307
|
-
return `${
|
|
3332
|
+
function Wi(e) {
|
|
3333
|
+
return `${_i}<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>`;
|
|
3308
3334
|
}
|
|
3309
|
-
function
|
|
3335
|
+
function Gi() {
|
|
3310
3336
|
let e = new Uint32Array(256);
|
|
3311
3337
|
for (let t = 0; t < 256; t++) {
|
|
3312
3338
|
let n = t;
|
|
@@ -3315,104 +3341,104 @@ function Bi() {
|
|
|
3315
3341
|
}
|
|
3316
3342
|
return e;
|
|
3317
3343
|
}
|
|
3318
|
-
var
|
|
3319
|
-
function
|
|
3344
|
+
var Ki = Gi();
|
|
3345
|
+
function qi(e) {
|
|
3320
3346
|
let t = 4294967295;
|
|
3321
|
-
for (let n of e) t =
|
|
3347
|
+
for (let n of e) t = Ki[(t ^ n) & 255] ^ t >>> 8;
|
|
3322
3348
|
return (t ^ 4294967295) >>> 0;
|
|
3323
3349
|
}
|
|
3324
|
-
function
|
|
3350
|
+
function Ji(e) {
|
|
3325
3351
|
let t = new Uint8Array(30 + e.nameBytes.length), n = new DataView(t.buffer);
|
|
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,
|
|
3352
|
+
return n.setUint32(0, 67324752, !0), n.setUint16(4, 20, !0), n.setUint16(6, 0, !0), n.setUint16(8, 0, !0), n.setUint16(10, bi, !0), n.setUint16(12, xi, !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;
|
|
3327
3353
|
}
|
|
3328
|
-
function
|
|
3354
|
+
function Yi(e) {
|
|
3329
3355
|
let t = new Uint8Array(46 + e.nameBytes.length), n = new DataView(t.buffer);
|
|
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,
|
|
3356
|
+
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, bi, !0), n.setUint16(14, xi, !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;
|
|
3331
3357
|
}
|
|
3332
|
-
function
|
|
3358
|
+
function Xi(e, t, n) {
|
|
3333
3359
|
let r = new Uint8Array(22), i = new DataView(r.buffer);
|
|
3334
3360
|
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;
|
|
3335
3361
|
}
|
|
3336
|
-
function
|
|
3362
|
+
function Zi(e, t) {
|
|
3337
3363
|
let n = new Uint8Array(t), r = 0;
|
|
3338
3364
|
return e.forEach((e) => {
|
|
3339
3365
|
n.set(e, r), r += e.length;
|
|
3340
3366
|
}), n;
|
|
3341
3367
|
}
|
|
3342
|
-
function
|
|
3368
|
+
function Qi(e) {
|
|
3343
3369
|
let t = 0, n = e.map((e) => {
|
|
3344
3370
|
let n = {
|
|
3345
3371
|
...e,
|
|
3346
|
-
crc:
|
|
3347
|
-
nameBytes:
|
|
3372
|
+
crc: qi(e.data),
|
|
3373
|
+
nameBytes: gi.encode(e.path),
|
|
3348
3374
|
offset: t
|
|
3349
3375
|
};
|
|
3350
3376
|
return t += 30 + n.nameBytes.length + n.data.length, n;
|
|
3351
3377
|
}), r = [];
|
|
3352
3378
|
n.forEach((e) => {
|
|
3353
|
-
r.push(
|
|
3379
|
+
r.push(Ji(e), e.data);
|
|
3354
3380
|
});
|
|
3355
3381
|
let i = t, a = 0;
|
|
3356
3382
|
return n.forEach((e) => {
|
|
3357
|
-
let t =
|
|
3383
|
+
let t = Yi(e);
|
|
3358
3384
|
a += t.length, r.push(t);
|
|
3359
|
-
}), r.push(
|
|
3385
|
+
}), r.push(Xi(n.length, a, i)), Zi(r, r.reduce((e, t) => e + t.length, 0));
|
|
3360
3386
|
}
|
|
3361
|
-
function
|
|
3387
|
+
function $i(e, t) {
|
|
3362
3388
|
let n = /* @__PURE__ */ new Map();
|
|
3363
|
-
e &&
|
|
3389
|
+
e && Pi(n, e.props, t);
|
|
3364
3390
|
let r = /* @__PURE__ */ new Set(), i = Array.from(n.entries()).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
3365
|
-
let i = [...
|
|
3391
|
+
let i = [...yi, ...n.columns], a = n.rows.sort((e, t) => e.elementID - t.elementID).map((e) => [
|
|
3366
3392
|
String(e.elementID),
|
|
3367
3393
|
e.ifcguid || t,
|
|
3368
3394
|
...n.columns.map((n) => e.values[n] ?? t)
|
|
3369
3395
|
]);
|
|
3370
3396
|
return {
|
|
3371
|
-
name:
|
|
3397
|
+
name: Bi(e, r),
|
|
3372
3398
|
rows: [i, ...a]
|
|
3373
3399
|
};
|
|
3374
3400
|
});
|
|
3375
3401
|
return i.length || i.push({
|
|
3376
|
-
name:
|
|
3377
|
-
rows: [
|
|
3402
|
+
name: Bi(vi, r),
|
|
3403
|
+
rows: [yi]
|
|
3378
3404
|
}), i;
|
|
3379
3405
|
}
|
|
3380
|
-
function
|
|
3381
|
-
let n =
|
|
3406
|
+
function ea(e, t = {}) {
|
|
3407
|
+
let n = $i(e, t.emptyValue ?? "-"), r = n.map((e) => e.name), i = [
|
|
3382
3408
|
{
|
|
3383
3409
|
path: "[Content_Types].xml",
|
|
3384
|
-
data:
|
|
3410
|
+
data: gi.encode(Wi(r))
|
|
3385
3411
|
},
|
|
3386
3412
|
{
|
|
3387
3413
|
path: "_rels/.rels",
|
|
3388
|
-
data:
|
|
3414
|
+
data: gi.encode(Ui())
|
|
3389
3415
|
},
|
|
3390
3416
|
{
|
|
3391
3417
|
path: "xl/workbook.xml",
|
|
3392
|
-
data:
|
|
3418
|
+
data: gi.encode(Vi(r))
|
|
3393
3419
|
},
|
|
3394
3420
|
{
|
|
3395
3421
|
path: "xl/_rels/workbook.xml.rels",
|
|
3396
|
-
data:
|
|
3422
|
+
data: gi.encode(Hi(r))
|
|
3397
3423
|
},
|
|
3398
3424
|
...n.map((e, t) => ({
|
|
3399
3425
|
path: `xl/worksheets/sheet${t + 1}.xml`,
|
|
3400
|
-
data:
|
|
3426
|
+
data: gi.encode(Ri(e.rows))
|
|
3401
3427
|
}))
|
|
3402
3428
|
];
|
|
3403
|
-
return new Blob([
|
|
3429
|
+
return new Blob([Qi(i)], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
|
|
3404
3430
|
}
|
|
3405
|
-
function
|
|
3431
|
+
function ta(e) {
|
|
3406
3432
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop()?.replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "").trim() || "model";
|
|
3407
3433
|
}
|
|
3408
|
-
function
|
|
3409
|
-
let n = t.fileName?.trim() || `${
|
|
3434
|
+
function na(e, t) {
|
|
3435
|
+
let n = t.fileName?.trim() || `${ta(t.modelName ?? e?.name ?? "model")}_properties`;
|
|
3410
3436
|
return n.toLowerCase().endsWith(".xlsx") ? n : `${n}.xlsx`;
|
|
3411
3437
|
}
|
|
3412
|
-
function
|
|
3438
|
+
function ra(e, t = {}) {
|
|
3413
3439
|
return {
|
|
3414
|
-
blob:
|
|
3415
|
-
name:
|
|
3440
|
+
blob: ea(e, t),
|
|
3441
|
+
name: na(e, t)
|
|
3416
3442
|
};
|
|
3417
3443
|
}
|
|
3418
3444
|
//#endregion
|
|
@@ -3420,16 +3446,16 @@ function Qi(e, t = {}) {
|
|
|
3420
3446
|
function Y(e) {
|
|
3421
3447
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3422
3448
|
}
|
|
3423
|
-
function
|
|
3449
|
+
function ia(e, t) {
|
|
3424
3450
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
3425
3451
|
}
|
|
3426
|
-
function
|
|
3452
|
+
function aa(e) {
|
|
3427
3453
|
return Y(e);
|
|
3428
3454
|
}
|
|
3429
|
-
function
|
|
3430
|
-
return Array.isArray(e) ? e.filter(
|
|
3455
|
+
function oa(e) {
|
|
3456
|
+
return Array.isArray(e) ? e.filter(aa) : Y(e) ? Object.values(e).filter(aa) : [];
|
|
3431
3457
|
}
|
|
3432
|
-
function
|
|
3458
|
+
function sa(e) {
|
|
3433
3459
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
3434
3460
|
if (typeof e == "string") {
|
|
3435
3461
|
let t = Number(e);
|
|
@@ -3437,10 +3463,10 @@ function na(e) {
|
|
|
3437
3463
|
}
|
|
3438
3464
|
return null;
|
|
3439
3465
|
}
|
|
3440
|
-
function
|
|
3441
|
-
return
|
|
3466
|
+
function ca(e) {
|
|
3467
|
+
return sa(e.id ?? e.expressID ?? e.expressId ?? e.elementID ?? e.elementId);
|
|
3442
3468
|
}
|
|
3443
|
-
function
|
|
3469
|
+
function la(e) {
|
|
3444
3470
|
let t = [
|
|
3445
3471
|
e.children,
|
|
3446
3472
|
e.items,
|
|
@@ -3448,40 +3474,40 @@ function ia(e) {
|
|
|
3448
3474
|
e.childs
|
|
3449
3475
|
];
|
|
3450
3476
|
for (let e of t) {
|
|
3451
|
-
let t =
|
|
3477
|
+
let t = oa(e);
|
|
3452
3478
|
if (t.length) return t;
|
|
3453
3479
|
}
|
|
3454
3480
|
return [];
|
|
3455
3481
|
}
|
|
3456
|
-
function
|
|
3482
|
+
function ua(e) {
|
|
3457
3483
|
let t = Y(e.props) ? e.props : {}, n = e.type ?? e.Type ?? t.type ?? t.Type;
|
|
3458
3484
|
return typeof n == "string" ? n : "";
|
|
3459
3485
|
}
|
|
3460
|
-
function
|
|
3486
|
+
function da(e) {
|
|
3461
3487
|
return e.replace(/[^a-z0-9]/gi, "").toUpperCase();
|
|
3462
3488
|
}
|
|
3463
|
-
function
|
|
3464
|
-
return
|
|
3489
|
+
function fa(e) {
|
|
3490
|
+
return da(ua(e)) === "IFCBUILDINGSTOREY";
|
|
3465
3491
|
}
|
|
3466
|
-
var
|
|
3492
|
+
var pa = new Set([
|
|
3467
3493
|
"children",
|
|
3468
3494
|
"childs",
|
|
3469
3495
|
"elements",
|
|
3470
3496
|
"items"
|
|
3471
3497
|
]);
|
|
3472
|
-
function
|
|
3498
|
+
function ma(e) {
|
|
3473
3499
|
let t = {};
|
|
3474
3500
|
return Object.entries(e).forEach(([e, n]) => {
|
|
3475
|
-
|
|
3501
|
+
pa.has(e) || (t[e] = n);
|
|
3476
3502
|
}), t;
|
|
3477
3503
|
}
|
|
3478
|
-
function
|
|
3504
|
+
function ha(e, t) {
|
|
3479
3505
|
return Array.isArray(t) ? {
|
|
3480
|
-
children:
|
|
3506
|
+
children: oa(t),
|
|
3481
3507
|
name: `Model ${e}`,
|
|
3482
3508
|
type: "Model"
|
|
3483
|
-
} : Y(t) ?
|
|
3484
|
-
children:
|
|
3509
|
+
} : Y(t) ? ca(t) !== null || typeof t.name == "string" || typeof t.Name == "string" || typeof t.type == "string" || typeof t.Type == "string" || Array.isArray(t.children) ? t : {
|
|
3510
|
+
children: oa(t),
|
|
3485
3511
|
name: `Model ${e}`,
|
|
3486
3512
|
type: "Model"
|
|
3487
3513
|
} : {
|
|
@@ -3490,46 +3516,46 @@ function ua(e, t) {
|
|
|
3490
3516
|
type: "Model"
|
|
3491
3517
|
};
|
|
3492
3518
|
}
|
|
3493
|
-
function
|
|
3519
|
+
function ga(e) {
|
|
3494
3520
|
let t = [];
|
|
3495
|
-
return
|
|
3496
|
-
let n =
|
|
3497
|
-
n !== null && t.push(n), t.push(...
|
|
3521
|
+
return la(e).forEach((e) => {
|
|
3522
|
+
let n = ca(e);
|
|
3523
|
+
n !== null && t.push(n), t.push(...ga(e));
|
|
3498
3524
|
}), t;
|
|
3499
3525
|
}
|
|
3500
|
-
function
|
|
3501
|
-
let i =
|
|
3502
|
-
...
|
|
3526
|
+
function _a(e, t, n, r) {
|
|
3527
|
+
let i = ca(t), a = i === null ? void 0 : n[e]?.[i], o = {
|
|
3528
|
+
...ma(t),
|
|
3503
3529
|
...a ?? {},
|
|
3504
3530
|
modelID: e
|
|
3505
3531
|
};
|
|
3506
|
-
return r && (o.elements =
|
|
3532
|
+
return r && (o.elements = ga(t)), o;
|
|
3507
3533
|
}
|
|
3508
|
-
function
|
|
3509
|
-
|
|
3534
|
+
function va(e, t, n, r, i) {
|
|
3535
|
+
fa(t) && n.push(_a(e, t, r, i)), la(t).forEach((t) => va(e, t, n, r, i));
|
|
3510
3536
|
}
|
|
3511
|
-
function
|
|
3537
|
+
function ya(e, t, n = !1) {
|
|
3512
3538
|
let r = {};
|
|
3513
3539
|
return Object.entries(e).forEach(([e, i]) => {
|
|
3514
3540
|
let a = Number(e), o = [];
|
|
3515
|
-
|
|
3541
|
+
va(a, ha(a, i), o, t, n), r[a] = o;
|
|
3516
3542
|
}), r;
|
|
3517
3543
|
}
|
|
3518
|
-
function
|
|
3544
|
+
function ba(e, t, n, r = !1) {
|
|
3519
3545
|
let i = [], a = e[n];
|
|
3520
3546
|
if (!a) throw Error(`Model with modelID ${n} not found`);
|
|
3521
|
-
return
|
|
3547
|
+
return va(Number(n), ha(Number(n), a), i, t, r), i;
|
|
3522
3548
|
}
|
|
3523
|
-
function
|
|
3549
|
+
function xa(e, t, n) {
|
|
3524
3550
|
return e[t]?.[n];
|
|
3525
3551
|
}
|
|
3526
|
-
function
|
|
3552
|
+
function Sa(e) {
|
|
3527
3553
|
return typeof e == "string" ? e : Y(e) && typeof e.value == "string" ? e.value : "";
|
|
3528
3554
|
}
|
|
3529
|
-
function
|
|
3530
|
-
return
|
|
3555
|
+
function Ca(e, t) {
|
|
3556
|
+
return Sa(e.Name) || Sa(e.name) || Sa(e.DisplayName) || Sa(e.displayName) || `Property ${t + 1}`;
|
|
3531
3557
|
}
|
|
3532
|
-
function
|
|
3558
|
+
function wa(e) {
|
|
3533
3559
|
for (let t of [
|
|
3534
3560
|
"NominalValue",
|
|
3535
3561
|
"nominalValue",
|
|
@@ -3552,44 +3578,44 @@ function ya(e) {
|
|
|
3552
3578
|
"description"
|
|
3553
3579
|
].includes(e)));
|
|
3554
3580
|
}
|
|
3555
|
-
function
|
|
3556
|
-
return
|
|
3581
|
+
function Ta(e) {
|
|
3582
|
+
return Sa(e.name) || Sa(e.Name);
|
|
3557
3583
|
}
|
|
3558
|
-
function
|
|
3559
|
-
return
|
|
3584
|
+
function Ea(e, t) {
|
|
3585
|
+
return ia(e, t) ? e[t] : void 0;
|
|
3560
3586
|
}
|
|
3561
|
-
function
|
|
3587
|
+
function Da(e, t) {
|
|
3562
3588
|
let n = e.props;
|
|
3563
3589
|
if (Y(n)) {
|
|
3564
|
-
let e =
|
|
3590
|
+
let e = Ea(n, t);
|
|
3565
3591
|
if (e !== void 0) return e;
|
|
3566
3592
|
}
|
|
3567
3593
|
if (Array.isArray(n)) for (let e = 0; e < n.length; e += 1) {
|
|
3568
3594
|
let r = n[e];
|
|
3569
3595
|
if (!Y(r)) continue;
|
|
3570
3596
|
let i = r;
|
|
3571
|
-
if (
|
|
3597
|
+
if (Ca(i, e) === t) return wa(i);
|
|
3572
3598
|
}
|
|
3573
|
-
return
|
|
3599
|
+
return Ea(e, t);
|
|
3574
3600
|
}
|
|
3575
|
-
function
|
|
3601
|
+
function Oa(e, t, n) {
|
|
3576
3602
|
if (!e) return;
|
|
3577
3603
|
if (n !== void 0) {
|
|
3578
|
-
let r = e.sets?.find((e) =>
|
|
3579
|
-
return r ?
|
|
3604
|
+
let r = e.sets?.find((e) => Ta(e) === n);
|
|
3605
|
+
return r ? Da(r, t) : void 0;
|
|
3580
3606
|
}
|
|
3581
3607
|
if (Y(e.props)) {
|
|
3582
|
-
let n =
|
|
3608
|
+
let n = Ea(e.props, t);
|
|
3583
3609
|
if (n !== void 0) return n;
|
|
3584
3610
|
}
|
|
3585
|
-
let r =
|
|
3611
|
+
let r = Ea(e, t);
|
|
3586
3612
|
if (r !== void 0) return r;
|
|
3587
3613
|
for (let n of e.sets ?? []) {
|
|
3588
|
-
let e =
|
|
3614
|
+
let e = Da(n, t);
|
|
3589
3615
|
if (e !== void 0) return e;
|
|
3590
3616
|
}
|
|
3591
3617
|
}
|
|
3592
|
-
function
|
|
3618
|
+
function ka(e, t, n, r) {
|
|
3593
3619
|
let i = t[e];
|
|
3594
3620
|
return i ? {
|
|
3595
3621
|
data: {},
|
|
@@ -3598,44 +3624,44 @@ function wa(e, t, n, r) {
|
|
|
3598
3624
|
structure: n[e] ?? {}
|
|
3599
3625
|
} : null;
|
|
3600
3626
|
}
|
|
3601
|
-
function
|
|
3627
|
+
function Aa(e) {
|
|
3602
3628
|
return {
|
|
3603
3629
|
exportAllExcel: (t) => {
|
|
3604
3630
|
let n = e.getState();
|
|
3605
3631
|
return Object.keys(n.modelProps).flatMap((e) => {
|
|
3606
|
-
let r =
|
|
3607
|
-
return r ? [
|
|
3632
|
+
let r = ka(Number(e), n.modelProps, n.modelStructure, n.modelNames);
|
|
3633
|
+
return r ? [ra(r, t)] : [];
|
|
3608
3634
|
});
|
|
3609
3635
|
},
|
|
3610
3636
|
exportExcel: (t, n) => {
|
|
3611
|
-
let r = e.getState(), i =
|
|
3612
|
-
return i ?
|
|
3637
|
+
let r = e.getState(), i = ka(t, r.modelProps, r.modelStructure, r.modelNames);
|
|
3638
|
+
return i ? ra(i, n) : null;
|
|
3613
3639
|
},
|
|
3614
3640
|
getAllLevels: (t = !1) => {
|
|
3615
3641
|
let n = e.getState();
|
|
3616
|
-
return
|
|
3642
|
+
return ya(n.modelStructure, n.modelProps, t);
|
|
3617
3643
|
},
|
|
3618
3644
|
getAllModelLevels: (t, n = !1) => {
|
|
3619
3645
|
let r = e.getState();
|
|
3620
|
-
return
|
|
3646
|
+
return ba(r.modelStructure, r.modelProps, t, n);
|
|
3621
3647
|
},
|
|
3622
3648
|
getModelProps: () => e.getState().modelProps,
|
|
3623
3649
|
getModelStructure: () => e.getState().modelStructure,
|
|
3624
|
-
getParamsByElement: (t, n) =>
|
|
3625
|
-
getParamValueByName:
|
|
3626
|
-
getParamValueByElement: (t, n, r, i) =>
|
|
3650
|
+
getParamsByElement: (t, n) => xa(e.getState().modelProps, t, n),
|
|
3651
|
+
getParamValueByName: Oa,
|
|
3652
|
+
getParamValueByElement: (t, n, r, i) => Oa(xa(e.getState().modelProps, t, n), r, i)
|
|
3627
3653
|
};
|
|
3628
3654
|
}
|
|
3629
3655
|
//#endregion
|
|
3630
3656
|
//#region src/viewer/Loaders/BmtConverter.ts
|
|
3631
|
-
var
|
|
3657
|
+
var ja = "BMT", Ma = 1, Na = {
|
|
3632
3658
|
PROP: 1,
|
|
3633
3659
|
MESH: 2,
|
|
3634
3660
|
STRUCTURE: 3,
|
|
3635
3661
|
GRIDS: 4,
|
|
3636
3662
|
MATRIX: 5,
|
|
3637
3663
|
MESHSPACE: 6
|
|
3638
|
-
},
|
|
3664
|
+
}, Pa = "application/json", Fa = "application/octet-stream", Ia = class {
|
|
3639
3665
|
chunks = [];
|
|
3640
3666
|
length = 0;
|
|
3641
3667
|
writeUint8(e) {
|
|
@@ -3655,7 +3681,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3655
3681
|
e.set(n, t), t += n.byteLength;
|
|
3656
3682
|
}), e;
|
|
3657
3683
|
}
|
|
3658
|
-
},
|
|
3684
|
+
}, La = class {
|
|
3659
3685
|
textEncoder = new TextEncoder();
|
|
3660
3686
|
ifcLoader = null;
|
|
3661
3687
|
async ConvertIfcFileToBmt(e, t = {}) {
|
|
@@ -3757,7 +3783,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3757
3783
|
progress: this.clampProgress(e.progress) * a
|
|
3758
3784
|
});
|
|
3759
3785
|
}), s = [{
|
|
3760
|
-
blob: new Blob([o], { type:
|
|
3786
|
+
blob: new Blob([o], { type: Fa }),
|
|
3761
3787
|
bytes: o,
|
|
3762
3788
|
name: i,
|
|
3763
3789
|
type: "bmt"
|
|
@@ -3777,7 +3803,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3777
3803
|
phase: "metadata",
|
|
3778
3804
|
progress: .95
|
|
3779
3805
|
}), s.push({
|
|
3780
|
-
blob: new Blob([n], { type:
|
|
3806
|
+
blob: new Blob([n], { type: Pa }),
|
|
3781
3807
|
bytes: n,
|
|
3782
3808
|
name: `${t}_props.json`,
|
|
3783
3809
|
type: "json"
|
|
@@ -3790,7 +3816,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3790
3816
|
return s;
|
|
3791
3817
|
}
|
|
3792
3818
|
createBmtBytes(e, t, n) {
|
|
3793
|
-
let r = new
|
|
3819
|
+
let r = new Ia(), 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) => {
|
|
3794
3820
|
n?.({
|
|
3795
3821
|
...e,
|
|
3796
3822
|
progress: this.clampProgress(e.progress)
|
|
@@ -3807,19 +3833,19 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3807
3833
|
progress: f
|
|
3808
3834
|
});
|
|
3809
3835
|
};
|
|
3810
|
-
return r.writeBytes(this.textEncoder.encode(
|
|
3836
|
+
return r.writeBytes(this.textEncoder.encode(ja)), r.writeUint8(Ma), t && (this.writeProps(r, e.props, (e) => m(s, e)), h(s, "properties", "Properties written")), e.grids !== void 0 && (p({
|
|
3811
3837
|
message: "Writing grids",
|
|
3812
3838
|
phase: "metadata",
|
|
3813
3839
|
progress: f
|
|
3814
|
-
}), this.writeJsonChunk(r,
|
|
3840
|
+
}), this.writeJsonChunk(r, Na.GRIDS, e.grids), h(c, "metadata", "Grids written")), this.writeMeshes(r, e, (e) => m(d, e)), h(d, "geometry", "Geometry written"), t && (p({
|
|
3815
3841
|
message: "Writing structure",
|
|
3816
3842
|
phase: "metadata",
|
|
3817
3843
|
progress: f
|
|
3818
|
-
}), this.writeJsonChunk(r,
|
|
3844
|
+
}), this.writeJsonChunk(r, Na.STRUCTURE, e.structure), h(l, "metadata", "Structure written")), o && e.coordinationMatrix && (p({
|
|
3819
3845
|
message: "Writing coordination matrix",
|
|
3820
3846
|
phase: "metadata",
|
|
3821
3847
|
progress: f
|
|
3822
|
-
}), this.writeTextChunk(r,
|
|
3848
|
+
}), this.writeTextChunk(r, Na.MATRIX, e.coordinationMatrix), h(u, "metadata", "Coordination matrix written")), p({
|
|
3823
3849
|
message: "BMT bytes ready",
|
|
3824
3850
|
phase: "writing",
|
|
3825
3851
|
progress: 1
|
|
@@ -3838,7 +3864,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3838
3864
|
...o,
|
|
3839
3865
|
id: s
|
|
3840
3866
|
} : o;
|
|
3841
|
-
this.writeJsonChunk(e,
|
|
3867
|
+
this.writeJsonChunk(e, Na.PROP, c);
|
|
3842
3868
|
let l = a + 1;
|
|
3843
3869
|
this.shouldEmitItemProgress(l, i) && n?.({
|
|
3844
3870
|
loaded: l,
|
|
@@ -3858,7 +3884,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3858
3884
|
progress: a > 0 ? 0 : 1,
|
|
3859
3885
|
total: a
|
|
3860
3886
|
}), i.forEach((t, i) => {
|
|
3861
|
-
t.matrix && t.matrix !== r && (this.writeTextChunk(e,
|
|
3887
|
+
t.matrix && t.matrix !== r && (this.writeTextChunk(e, Na.MATRIX, t.matrix), r = t.matrix), this.writeChunk(e, t.isIfcSpace ? Na.MESHSPACE : Na.MESH, this.createMeshPayload(t));
|
|
3862
3888
|
let o = i + 1;
|
|
3863
3889
|
this.shouldEmitItemProgress(o, a) && n?.({
|
|
3864
3890
|
loaded: o,
|
|
@@ -3870,7 +3896,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3870
3896
|
});
|
|
3871
3897
|
}
|
|
3872
3898
|
createMeshPayload(e) {
|
|
3873
|
-
let t = new
|
|
3899
|
+
let t = new Ia(), n = this.deflateTypedArray(e.pos), r = this.deflateTypedArray(e.ids), i = this.deflateTypedArray(e.ind);
|
|
3874
3900
|
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();
|
|
3875
3901
|
}
|
|
3876
3902
|
writeJsonChunk(e, t, n) {
|
|
@@ -4023,7 +4049,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
4023
4049
|
let t = /* @__PURE__ */ new Map();
|
|
4024
4050
|
return (Array.isArray(e) ? e : [e]).forEach((e) => {
|
|
4025
4051
|
e.traverse((e) => {
|
|
4026
|
-
if (!(e instanceof
|
|
4052
|
+
if (!(e instanceof P) || !this.isIfcSpaceObject(e)) return;
|
|
4027
4053
|
let n = this.getObjectModelID(e);
|
|
4028
4054
|
if (n === null) return;
|
|
4029
4055
|
let r = e.geometry.getAttribute("ids");
|
|
@@ -4037,7 +4063,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
4037
4063
|
addVisibleIdsFromObject3D(e, t) {
|
|
4038
4064
|
(Array.isArray(e) ? e : [e]).forEach((e) => {
|
|
4039
4065
|
e.traverse((e) => {
|
|
4040
|
-
if (!(e instanceof
|
|
4066
|
+
if (!(e instanceof P) || !this.isObjectVisible(e)) return;
|
|
4041
4067
|
let n = this.getObjectModelID(e);
|
|
4042
4068
|
if (n === null) return;
|
|
4043
4069
|
let r = e.geometry.getAttribute("ids");
|
|
@@ -4089,7 +4115,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
4089
4115
|
return this.deflateBytes(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
4090
4116
|
}
|
|
4091
4117
|
deflateBytes(e) {
|
|
4092
|
-
return
|
|
4118
|
+
return Te.deflate(e);
|
|
4093
4119
|
}
|
|
4094
4120
|
encodeText(e) {
|
|
4095
4121
|
return this.textEncoder.encode(e);
|
|
@@ -4106,43 +4132,43 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
4106
4132
|
isRecord(e) {
|
|
4107
4133
|
return typeof e == "object" && !!e;
|
|
4108
4134
|
}
|
|
4109
|
-
},
|
|
4110
|
-
async function
|
|
4111
|
-
return
|
|
4135
|
+
}, Ra = new La();
|
|
4136
|
+
async function za(e, t) {
|
|
4137
|
+
return Ra.ConvertIfcFileToBmt(e, t);
|
|
4112
4138
|
}
|
|
4113
|
-
function
|
|
4114
|
-
return
|
|
4139
|
+
function Ba(e, t) {
|
|
4140
|
+
return Ra.ConvertToBmt(e, t);
|
|
4115
4141
|
}
|
|
4116
4142
|
//#endregion
|
|
4117
4143
|
//#region src/viewer/Selector/FilteredElementsCollector.ts
|
|
4118
|
-
function
|
|
4144
|
+
function Va(e) {
|
|
4119
4145
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
4120
4146
|
}
|
|
4121
|
-
function
|
|
4147
|
+
function Ha(e) {
|
|
4122
4148
|
let t = Number(e);
|
|
4123
4149
|
return Number.isFinite(t) ? t : null;
|
|
4124
4150
|
}
|
|
4125
|
-
function
|
|
4126
|
-
return
|
|
4151
|
+
function Ua(e) {
|
|
4152
|
+
return Va(e) && Va(e.data) && Va(e.props) && "structure" in e;
|
|
4127
4153
|
}
|
|
4128
|
-
function
|
|
4129
|
-
return
|
|
4154
|
+
function Wa(e) {
|
|
4155
|
+
return Va(e) && ("guid" in e || "id" in e || "props" in e || "sets" in e);
|
|
4130
4156
|
}
|
|
4131
|
-
function
|
|
4132
|
-
if (!
|
|
4157
|
+
function Ga(e) {
|
|
4158
|
+
if (!Va(e)) return !1;
|
|
4133
4159
|
let t = Object.entries(e);
|
|
4134
|
-
return t.length ? t.every(([e, t]) =>
|
|
4160
|
+
return t.length ? t.every(([e, t]) => Ha(e) !== null && Wa(t)) : !0;
|
|
4135
4161
|
}
|
|
4136
|
-
function
|
|
4162
|
+
function Ka(e) {
|
|
4137
4163
|
return typeof e == "string" ? e : null;
|
|
4138
4164
|
}
|
|
4139
|
-
function
|
|
4140
|
-
let t =
|
|
4141
|
-
return
|
|
4165
|
+
function qa(e) {
|
|
4166
|
+
let t = Va(e.props.props) ? e.props.props : {};
|
|
4167
|
+
return Ka(e.props.type ?? e.props.Type ?? t.type ?? t.Type);
|
|
4142
4168
|
}
|
|
4143
|
-
function
|
|
4169
|
+
function Ja(e, t, n) {
|
|
4144
4170
|
Object.entries(n).forEach(([n, r]) => {
|
|
4145
|
-
let i =
|
|
4171
|
+
let i = Ha(n);
|
|
4146
4172
|
i !== null && e.push({
|
|
4147
4173
|
elementID: i,
|
|
4148
4174
|
modelID: t,
|
|
@@ -4150,29 +4176,29 @@ function Ua(e, t, n) {
|
|
|
4150
4176
|
});
|
|
4151
4177
|
});
|
|
4152
4178
|
}
|
|
4153
|
-
function
|
|
4154
|
-
if (!e || !
|
|
4155
|
-
if (
|
|
4179
|
+
function Ya(e) {
|
|
4180
|
+
if (!e || !Va(e)) return [];
|
|
4181
|
+
if (Ua(e)) {
|
|
4156
4182
|
let t = [];
|
|
4157
|
-
return
|
|
4183
|
+
return Ja(t, 0, e.props), t;
|
|
4158
4184
|
}
|
|
4159
|
-
if (
|
|
4185
|
+
if (Ga(e)) {
|
|
4160
4186
|
let t = [];
|
|
4161
|
-
return
|
|
4187
|
+
return Ja(t, 0, e), t;
|
|
4162
4188
|
}
|
|
4163
4189
|
let t = [];
|
|
4164
4190
|
return Object.entries(e).forEach(([e, n]) => {
|
|
4165
|
-
let r =
|
|
4191
|
+
let r = Ha(e);
|
|
4166
4192
|
if (r !== null) {
|
|
4167
|
-
if (
|
|
4168
|
-
|
|
4193
|
+
if (Ua(n)) {
|
|
4194
|
+
Ja(t, r, n.props);
|
|
4169
4195
|
return;
|
|
4170
4196
|
}
|
|
4171
|
-
|
|
4197
|
+
Ga(n) && Ja(t, r, n);
|
|
4172
4198
|
}
|
|
4173
4199
|
}), t;
|
|
4174
4200
|
}
|
|
4175
|
-
function
|
|
4201
|
+
function Xa(e) {
|
|
4176
4202
|
let t = {};
|
|
4177
4203
|
return e.forEach(({ elementID: e, modelID: n, props: r }) => {
|
|
4178
4204
|
t[n] ??= [], t[n].push({
|
|
@@ -4181,26 +4207,26 @@ function Ga(e) {
|
|
|
4181
4207
|
});
|
|
4182
4208
|
}), t;
|
|
4183
4209
|
}
|
|
4184
|
-
function
|
|
4210
|
+
function Za(e) {
|
|
4185
4211
|
let t = {};
|
|
4186
4212
|
return e.forEach(({ elementID: e, modelID: n }) => {
|
|
4187
4213
|
t[n] ??= [], t[n].push(e);
|
|
4188
4214
|
}), t;
|
|
4189
4215
|
}
|
|
4190
|
-
var
|
|
4216
|
+
var Qa = class {
|
|
4191
4217
|
elements;
|
|
4192
4218
|
filters = [];
|
|
4193
4219
|
selectedModelIDs = null;
|
|
4194
4220
|
constructor(e) {
|
|
4195
|
-
this.elements =
|
|
4221
|
+
this.elements = Ya(e);
|
|
4196
4222
|
}
|
|
4197
4223
|
from(e) {
|
|
4198
|
-
return this.elements =
|
|
4224
|
+
return this.elements = Ya(e), this.filters = [], this.selectedModelIDs = null, this;
|
|
4199
4225
|
}
|
|
4200
4226
|
ofType(e) {
|
|
4201
4227
|
let t = new Set((Array.isArray(e) ? e : [e]).map((e) => e.toLowerCase()));
|
|
4202
4228
|
return this.filters.push((e) => {
|
|
4203
|
-
let n =
|
|
4229
|
+
let n = qa(e);
|
|
4204
4230
|
return !!(n && t.has(n.toLowerCase()));
|
|
4205
4231
|
}), this;
|
|
4206
4232
|
}
|
|
@@ -4229,11 +4255,11 @@ var qa = class {
|
|
|
4229
4255
|
return this.hasSingleSelectedModel() ? e.map(({ elementID: e, props: t }) => ({
|
|
4230
4256
|
elementID: e,
|
|
4231
4257
|
props: t
|
|
4232
|
-
})) :
|
|
4258
|
+
})) : Xa(e);
|
|
4233
4259
|
}
|
|
4234
4260
|
toElementsIds() {
|
|
4235
4261
|
let e = this.getFilteredElements();
|
|
4236
|
-
return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) :
|
|
4262
|
+
return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) : Za(e);
|
|
4237
4263
|
}
|
|
4238
4264
|
toElementIds() {
|
|
4239
4265
|
return this.toElementsIds();
|
|
@@ -4241,20 +4267,20 @@ var qa = class {
|
|
|
4241
4267
|
};
|
|
4242
4268
|
//#endregion
|
|
4243
4269
|
//#region src/viewer/api/ViewerApi.ts
|
|
4244
|
-
function
|
|
4270
|
+
function $a(e) {
|
|
4245
4271
|
let t = {};
|
|
4246
4272
|
return Object.entries(e).forEach(([e, n]) => {
|
|
4247
4273
|
t[Number(e)] = Array.from(n);
|
|
4248
4274
|
}), t;
|
|
4249
4275
|
}
|
|
4250
|
-
function
|
|
4276
|
+
function eo(e) {
|
|
4251
4277
|
let t = {};
|
|
4252
4278
|
return Object.entries(e).forEach(([e, n]) => {
|
|
4253
4279
|
t[Number(e)] = new Set(n);
|
|
4254
4280
|
}), t;
|
|
4255
4281
|
}
|
|
4256
|
-
function
|
|
4257
|
-
let n = new
|
|
4282
|
+
function to(e, t) {
|
|
4283
|
+
let n = new La();
|
|
4258
4284
|
return {
|
|
4259
4285
|
camera: {
|
|
4260
4286
|
fitCamera: () => {
|
|
@@ -4400,16 +4426,16 @@ function Xa(e, t) {
|
|
|
4400
4426
|
t()?.geometryUtils.toggleIIfcSpacesVisibility();
|
|
4401
4427
|
}
|
|
4402
4428
|
},
|
|
4403
|
-
properties:
|
|
4429
|
+
properties: Aa(e),
|
|
4404
4430
|
selector: {
|
|
4405
4431
|
addSelected: (n, r, i = !0, a = !1) => {
|
|
4406
4432
|
let o = i || a;
|
|
4407
|
-
e.getState().addSelected(n, r), o && t()?.selector.setTargetToSelection(
|
|
4433
|
+
e.getState().addSelected(n, r), o && t()?.selector.setTargetToSelection($a(e.getState().selected), a);
|
|
4408
4434
|
},
|
|
4409
|
-
collector: () => new
|
|
4435
|
+
collector: () => new Qa(e.getState().modelProps),
|
|
4410
4436
|
getPreselectionColor: () => e.getState().preselectionColor,
|
|
4411
4437
|
getSelectionColor: () => e.getState().selectionColor,
|
|
4412
|
-
getSelected: () =>
|
|
4438
|
+
getSelected: () => $a(e.getState().selected),
|
|
4413
4439
|
removeSelected: (t, n) => {
|
|
4414
4440
|
e.getState().removeSelected(t, n);
|
|
4415
4441
|
},
|
|
@@ -4424,7 +4450,7 @@ function Xa(e, t) {
|
|
|
4424
4450
|
},
|
|
4425
4451
|
setSelected: (n, r, i = !1, a = !0, o = !1) => {
|
|
4426
4452
|
let s = a || o;
|
|
4427
|
-
e.getState().setSelected(n, r, i), s && t()?.selector.setTargetToSelection(
|
|
4453
|
+
e.getState().setSelected(n, r, i), s && t()?.selector.setTargetToSelection($a(e.getState().selected), o);
|
|
4428
4454
|
}
|
|
4429
4455
|
},
|
|
4430
4456
|
utils: {
|
|
@@ -4469,7 +4495,7 @@ function Xa(e, t) {
|
|
|
4469
4495
|
}
|
|
4470
4496
|
//#endregion
|
|
4471
4497
|
//#region src/viewer/Loaders/BmtLoader.ts
|
|
4472
|
-
var
|
|
4498
|
+
var no = class {
|
|
4473
4499
|
view;
|
|
4474
4500
|
offset = 0;
|
|
4475
4501
|
constructor(e) {
|
|
@@ -4489,11 +4515,11 @@ var Za = class {
|
|
|
4489
4515
|
eof() {
|
|
4490
4516
|
return this.offset >= this.view.byteLength;
|
|
4491
4517
|
}
|
|
4492
|
-
},
|
|
4518
|
+
}, ro = class {
|
|
4493
4519
|
decodeBuffer(e) {
|
|
4494
|
-
return this.textDecoder.decode(
|
|
4520
|
+
return this.textDecoder.decode(Te.inflate(e));
|
|
4495
4521
|
}
|
|
4496
|
-
decoder =
|
|
4522
|
+
decoder = Te;
|
|
4497
4523
|
textDecoder = new TextDecoder("utf-8");
|
|
4498
4524
|
ChunkType = {
|
|
4499
4525
|
PROP: 1,
|
|
@@ -4562,7 +4588,7 @@ var Za = class {
|
|
|
4562
4588
|
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;
|
|
4563
4589
|
}
|
|
4564
4590
|
parseBinaryFile(e, t = {}) {
|
|
4565
|
-
let n = new
|
|
4591
|
+
let n = new no(e);
|
|
4566
4592
|
if (new TextDecoder().decode(n.readBytes(3)) !== "BMT") throw Error("Invalid file");
|
|
4567
4593
|
let r = n.readUint8();
|
|
4568
4594
|
console.log(`model version: ${r}`);
|
|
@@ -4630,24 +4656,24 @@ var Za = class {
|
|
|
4630
4656
|
};
|
|
4631
4657
|
//#endregion
|
|
4632
4658
|
//#region src/viewer/workers/BMTWorker.ts?worker
|
|
4633
|
-
function
|
|
4659
|
+
function io(e) {
|
|
4634
4660
|
return new Worker("" + new URL("assets/BMTWorker-yhSXOg2i.js", import.meta.url).href, { name: e?.name });
|
|
4635
4661
|
}
|
|
4636
4662
|
//#endregion
|
|
4637
4663
|
//#region src/viewer/workers/BMTWorkerClient.ts
|
|
4638
|
-
function
|
|
4664
|
+
function ao() {
|
|
4639
4665
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
|
|
4640
4666
|
}
|
|
4641
|
-
function
|
|
4667
|
+
function oo(e) {
|
|
4642
4668
|
return Array.isArray(e) ? e : [e];
|
|
4643
4669
|
}
|
|
4644
|
-
function
|
|
4670
|
+
function so(e) {
|
|
4645
4671
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.bmt";
|
|
4646
4672
|
}
|
|
4647
|
-
function
|
|
4673
|
+
function co(e) {
|
|
4648
4674
|
return typeof e == "string" ? {
|
|
4649
4675
|
kind: "url",
|
|
4650
|
-
name:
|
|
4676
|
+
name: so(e),
|
|
4651
4677
|
url: new URL(e, globalThis.location.href).href
|
|
4652
4678
|
} : e instanceof File ? {
|
|
4653
4679
|
file: e,
|
|
@@ -4658,18 +4684,18 @@ function ro(e) {
|
|
|
4658
4684
|
kind: "buffer"
|
|
4659
4685
|
};
|
|
4660
4686
|
}
|
|
4661
|
-
function
|
|
4687
|
+
function lo(e) {
|
|
4662
4688
|
return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
|
|
4663
4689
|
}
|
|
4664
|
-
function
|
|
4665
|
-
return new
|
|
4690
|
+
function uo() {
|
|
4691
|
+
return new io();
|
|
4666
4692
|
}
|
|
4667
|
-
function
|
|
4693
|
+
function fo(e) {
|
|
4668
4694
|
return { streamGeometryChunks: e.streamGeometryChunks ?? !!e.onChunk };
|
|
4669
4695
|
}
|
|
4670
|
-
function
|
|
4671
|
-
let n = t.worker ??
|
|
4672
|
-
options:
|
|
4696
|
+
function po(e, t = {}) {
|
|
4697
|
+
let n = t.worker ?? uo(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = oo(e).map(co), o = ao(), s = {}, c = {
|
|
4698
|
+
options: fo(t),
|
|
4673
4699
|
sources: a,
|
|
4674
4700
|
taskId: o,
|
|
4675
4701
|
type: "load-bmt-model"
|
|
@@ -4707,39 +4733,39 @@ function so(e, t = {}) {
|
|
|
4707
4733
|
let a = Error(r.error.message);
|
|
4708
4734
|
r.error.stack && (a.stack = r.error.stack), l(a);
|
|
4709
4735
|
};
|
|
4710
|
-
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c,
|
|
4736
|
+
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, lo(a));
|
|
4711
4737
|
});
|
|
4712
4738
|
}
|
|
4713
|
-
function
|
|
4714
|
-
return
|
|
4739
|
+
function mo() {
|
|
4740
|
+
return uo();
|
|
4715
4741
|
}
|
|
4716
4742
|
//#endregion
|
|
4717
4743
|
//#region src/viewer/workers/BmtConverterWorker.ts?worker
|
|
4718
|
-
function
|
|
4744
|
+
function ho(e) {
|
|
4719
4745
|
return new Worker("" + new URL("assets/BmtConverterWorker-BHhPlty_.js", import.meta.url).href, { name: e?.name });
|
|
4720
4746
|
}
|
|
4721
4747
|
//#endregion
|
|
4722
4748
|
//#region src/viewer/workers/BmtConverterWorkerClient.ts
|
|
4723
|
-
function
|
|
4749
|
+
function go() {
|
|
4724
4750
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
|
|
4725
4751
|
}
|
|
4726
|
-
function
|
|
4752
|
+
function _o(e) {
|
|
4727
4753
|
return Array.isArray(e) ? e : [e];
|
|
4728
4754
|
}
|
|
4729
|
-
function
|
|
4755
|
+
function vo(e) {
|
|
4730
4756
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
|
|
4731
4757
|
}
|
|
4732
|
-
function
|
|
4758
|
+
function yo() {
|
|
4733
4759
|
return globalThis.document?.baseURI ?? globalThis.location.href;
|
|
4734
4760
|
}
|
|
4735
|
-
function
|
|
4761
|
+
function bo(e) {
|
|
4736
4762
|
let t = e ?? "ifc-parser.wasm";
|
|
4737
|
-
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t,
|
|
4763
|
+
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, yo()).href;
|
|
4738
4764
|
}
|
|
4739
|
-
function
|
|
4765
|
+
function xo(e) {
|
|
4740
4766
|
return typeof e == "string" ? {
|
|
4741
4767
|
kind: "url",
|
|
4742
|
-
name:
|
|
4768
|
+
name: vo(e),
|
|
4743
4769
|
url: new URL(e, globalThis.location.href).href
|
|
4744
4770
|
} : e instanceof File ? {
|
|
4745
4771
|
file: e,
|
|
@@ -4750,13 +4776,13 @@ function go(e) {
|
|
|
4750
4776
|
kind: "buffer"
|
|
4751
4777
|
};
|
|
4752
4778
|
}
|
|
4753
|
-
function
|
|
4779
|
+
function So(e) {
|
|
4754
4780
|
return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
|
|
4755
4781
|
}
|
|
4756
|
-
function
|
|
4757
|
-
return new
|
|
4782
|
+
function Co() {
|
|
4783
|
+
return new ho();
|
|
4758
4784
|
}
|
|
4759
|
-
function
|
|
4785
|
+
function wo(e) {
|
|
4760
4786
|
return {
|
|
4761
4787
|
chunk: e.chunk,
|
|
4762
4788
|
coordinationMatrix: e.coordinationMatrix,
|
|
@@ -4768,23 +4794,23 @@ function yo(e) {
|
|
|
4768
4794
|
useIfcSpace: e.useIfcSpace,
|
|
4769
4795
|
useMinVersion: e.useMinVersion,
|
|
4770
4796
|
visibleIdsByModel: e.visibleIdsByModel,
|
|
4771
|
-
wasmPath:
|
|
4797
|
+
wasmPath: bo(e.wasmPath)
|
|
4772
4798
|
};
|
|
4773
4799
|
}
|
|
4774
|
-
function
|
|
4800
|
+
function To(e) {
|
|
4775
4801
|
let t = new Uint8Array(e.bytes.byteLength);
|
|
4776
4802
|
return t.set(e.bytes), {
|
|
4777
4803
|
...e,
|
|
4778
4804
|
blob: new Blob([t.buffer], { type: e.mimeType })
|
|
4779
4805
|
};
|
|
4780
4806
|
}
|
|
4781
|
-
function
|
|
4807
|
+
function Eo(e) {
|
|
4782
4808
|
return {
|
|
4783
|
-
files: e.result.files.map(
|
|
4809
|
+
files: e.result.files.map(To),
|
|
4784
4810
|
models: e.result.models
|
|
4785
4811
|
};
|
|
4786
4812
|
}
|
|
4787
|
-
function
|
|
4813
|
+
function Do(e) {
|
|
4788
4814
|
if (e.error instanceof Error) return e.error;
|
|
4789
4815
|
let t = [
|
|
4790
4816
|
e.message || "Unknown worker error",
|
|
@@ -4794,12 +4820,12 @@ function So(e) {
|
|
|
4794
4820
|
].filter(Boolean);
|
|
4795
4821
|
return /* @__PURE__ */ Error(`BMT converter worker failed: ${t.join(", ")}`);
|
|
4796
4822
|
}
|
|
4797
|
-
function
|
|
4823
|
+
function Oo(e) {
|
|
4798
4824
|
return /* @__PURE__ */ Error(`BMT converter worker response could not be cloned: ${String(e.data ?? "unknown message error")}`);
|
|
4799
4825
|
}
|
|
4800
|
-
function
|
|
4801
|
-
let n = t.worker ??
|
|
4802
|
-
options:
|
|
4826
|
+
function ko(e, t = {}) {
|
|
4827
|
+
let n = t.worker ?? Co(), r = t.terminateOnComplete ?? !t.worker, i = _o(e).map(xo), a = go(), o = {
|
|
4828
|
+
options: wo(t),
|
|
4803
4829
|
sources: i,
|
|
4804
4830
|
taskId: a,
|
|
4805
4831
|
type: "convert-ifc-to-bmt"
|
|
@@ -4808,9 +4834,9 @@ function wo(e, t = {}) {
|
|
|
4808
4834
|
let c = () => {
|
|
4809
4835
|
n.removeEventListener("message", d), n.removeEventListener("error", l), n.removeEventListener("messageerror", u), r && n.terminate();
|
|
4810
4836
|
}, l = (e) => {
|
|
4811
|
-
c(), s(
|
|
4837
|
+
c(), s(Do(e));
|
|
4812
4838
|
}, u = (e) => {
|
|
4813
|
-
c(), s(
|
|
4839
|
+
c(), s(Oo(e));
|
|
4814
4840
|
}, d = (n) => {
|
|
4815
4841
|
let r = n.data;
|
|
4816
4842
|
if (r.taskId !== a) return;
|
|
@@ -4819,35 +4845,35 @@ function wo(e, t = {}) {
|
|
|
4819
4845
|
return;
|
|
4820
4846
|
}
|
|
4821
4847
|
if (c(), r.type === "complete") {
|
|
4822
|
-
e(
|
|
4848
|
+
e(Eo(r));
|
|
4823
4849
|
return;
|
|
4824
4850
|
}
|
|
4825
4851
|
let i = Error(r.error.message);
|
|
4826
4852
|
r.error.stack && (i.stack = r.error.stack), s(i);
|
|
4827
4853
|
};
|
|
4828
|
-
n.addEventListener("message", d), n.addEventListener("error", l), n.addEventListener("messageerror", u), n.postMessage(o,
|
|
4854
|
+
n.addEventListener("message", d), n.addEventListener("error", l), n.addEventListener("messageerror", u), n.postMessage(o, So(i));
|
|
4829
4855
|
});
|
|
4830
4856
|
}
|
|
4831
|
-
function
|
|
4832
|
-
return
|
|
4857
|
+
function Ao() {
|
|
4858
|
+
return Co();
|
|
4833
4859
|
}
|
|
4834
4860
|
//#endregion
|
|
4835
4861
|
//#region src/viewer/workers/IFCWorker.ts?worker
|
|
4836
|
-
function
|
|
4862
|
+
function jo(e) {
|
|
4837
4863
|
return new Worker("" + new URL("assets/IFCWorker-DipGoUKy.js", import.meta.url).href, { name: e?.name });
|
|
4838
4864
|
}
|
|
4839
4865
|
//#endregion
|
|
4840
4866
|
//#region src/viewer/workers/IFCWorkerClient.ts
|
|
4841
|
-
function
|
|
4867
|
+
function Mo() {
|
|
4842
4868
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
|
|
4843
4869
|
}
|
|
4844
|
-
function
|
|
4870
|
+
function No(e) {
|
|
4845
4871
|
return Array.isArray(e) ? e : [e];
|
|
4846
4872
|
}
|
|
4847
|
-
function
|
|
4873
|
+
function Po(e) {
|
|
4848
4874
|
return typeof e == "string" ? {
|
|
4849
4875
|
kind: "url",
|
|
4850
|
-
name:
|
|
4876
|
+
name: Fo(e),
|
|
4851
4877
|
url: new URL(e, globalThis.location.href).href
|
|
4852
4878
|
} : e instanceof File ? {
|
|
4853
4879
|
file: e,
|
|
@@ -4858,23 +4884,23 @@ function ko(e) {
|
|
|
4858
4884
|
kind: "buffer"
|
|
4859
4885
|
};
|
|
4860
4886
|
}
|
|
4861
|
-
function
|
|
4887
|
+
function Fo(e) {
|
|
4862
4888
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
|
|
4863
4889
|
}
|
|
4864
|
-
function
|
|
4890
|
+
function Io() {
|
|
4865
4891
|
return globalThis.document?.baseURI ?? globalThis.location.href;
|
|
4866
4892
|
}
|
|
4867
|
-
function
|
|
4893
|
+
function Lo(e) {
|
|
4868
4894
|
let t = e ?? "ifc-parser.wasm";
|
|
4869
|
-
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t,
|
|
4895
|
+
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, Io()).href;
|
|
4870
4896
|
}
|
|
4871
|
-
function
|
|
4897
|
+
function Ro(e) {
|
|
4872
4898
|
return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
|
|
4873
4899
|
}
|
|
4874
|
-
function
|
|
4875
|
-
return new
|
|
4900
|
+
function zo() {
|
|
4901
|
+
return new jo();
|
|
4876
4902
|
}
|
|
4877
|
-
function
|
|
4903
|
+
function Bo(e) {
|
|
4878
4904
|
return {
|
|
4879
4905
|
chunk: e.chunk,
|
|
4880
4906
|
coordinationMatrix: e.coordinationMatrix,
|
|
@@ -4883,12 +4909,12 @@ function Fo(e) {
|
|
|
4883
4909
|
useIfcColors: e.useIfcColors,
|
|
4884
4910
|
useIfcElementAssembly: e.useIfcElementAssembly,
|
|
4885
4911
|
useIfcSpace: e.useIfcSpace,
|
|
4886
|
-
wasmPath:
|
|
4912
|
+
wasmPath: Lo(e.wasmPath)
|
|
4887
4913
|
};
|
|
4888
4914
|
}
|
|
4889
|
-
function
|
|
4890
|
-
let n = t.worker ??
|
|
4891
|
-
options:
|
|
4915
|
+
function Vo(e, t = {}) {
|
|
4916
|
+
let n = t.worker ?? zo(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = No(e).map(Po), o = Mo(), s = {}, c = {
|
|
4917
|
+
options: Bo(t),
|
|
4892
4918
|
sources: a,
|
|
4893
4919
|
taskId: o,
|
|
4894
4920
|
type: "load-ifc-model"
|
|
@@ -4926,34 +4952,34 @@ function Io(e, t = {}) {
|
|
|
4926
4952
|
let a = Error(r.error.message);
|
|
4927
4953
|
r.error.stack && (a.stack = r.error.stack), l(a);
|
|
4928
4954
|
};
|
|
4929
|
-
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c,
|
|
4955
|
+
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, Ro(a));
|
|
4930
4956
|
});
|
|
4931
4957
|
}
|
|
4932
|
-
function
|
|
4933
|
-
return
|
|
4958
|
+
function Ho() {
|
|
4959
|
+
return zo();
|
|
4934
4960
|
}
|
|
4935
4961
|
//#endregion
|
|
4936
4962
|
//#region src/viewer/api/loader.ts
|
|
4937
|
-
function
|
|
4963
|
+
function Uo(e) {
|
|
4938
4964
|
return typeof e == "string" ? e : e.name;
|
|
4939
4965
|
}
|
|
4940
|
-
function
|
|
4941
|
-
return (
|
|
4966
|
+
function Wo(e) {
|
|
4967
|
+
return (Uo(e).split(/[?#]/)[0].split(/[\\/]/).pop() || "model").replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "") || "model";
|
|
4942
4968
|
}
|
|
4943
|
-
function
|
|
4944
|
-
let t =
|
|
4969
|
+
function Go(e) {
|
|
4970
|
+
let t = Uo(e).split(/[?#]/)[0].toLowerCase(), n = t.lastIndexOf(".");
|
|
4945
4971
|
return n === -1 ? "" : t.slice(n + 1);
|
|
4946
4972
|
}
|
|
4947
|
-
function
|
|
4973
|
+
function Ko(e) {
|
|
4948
4974
|
return /\.min\.bmt$/i.test(e.name) ? e.name.replace(/\.min\.bmt$/i, "_props.json") : null;
|
|
4949
4975
|
}
|
|
4950
|
-
function
|
|
4951
|
-
return /_props\.json$/i.test(
|
|
4976
|
+
function qo(e) {
|
|
4977
|
+
return /_props\.json$/i.test(Uo(e).split(/[?#]/)[0]);
|
|
4952
4978
|
}
|
|
4953
|
-
function
|
|
4979
|
+
function Jo(e) {
|
|
4954
4980
|
return e.coordinationMatrix ? e.coordinationMatrix : Object.values(e.data)[0]?.matrix || void 0;
|
|
4955
4981
|
}
|
|
4956
|
-
var
|
|
4982
|
+
var Yo = new class {
|
|
4957
4983
|
coordinationMatrix;
|
|
4958
4984
|
useIfcSpace = !0;
|
|
4959
4985
|
bmtLoader = null;
|
|
@@ -4964,7 +4990,7 @@ var Wo = new class {
|
|
|
4964
4990
|
this.getBmtLoader();
|
|
4965
4991
|
}
|
|
4966
4992
|
getBmtLoader() {
|
|
4967
|
-
return this.bmtLoader ||= new
|
|
4993
|
+
return this.bmtLoader ||= new ro(), this.bmtLoader;
|
|
4968
4994
|
}
|
|
4969
4995
|
async getIfcLoader(e = {}) {
|
|
4970
4996
|
if (!this.ifcLoader) {
|
|
@@ -4992,7 +5018,7 @@ var Wo = new class {
|
|
|
4992
5018
|
async loadBmtModel(e, t) {
|
|
4993
5019
|
let n = this.getBmtLoader();
|
|
4994
5020
|
if (typeof e == "string") return n.loadModel(e);
|
|
4995
|
-
let r = n.parseBinaryFile(await e.arrayBuffer()), i =
|
|
5021
|
+
let r = n.parseBinaryFile(await e.arrayBuffer()), i = Ko(e), a = i ? t.get(i) : void 0;
|
|
4996
5022
|
return this.applyBmtMetadata(r, a);
|
|
4997
5023
|
}
|
|
4998
5024
|
createWorkerProgressHandler(e, t, n, r) {
|
|
@@ -5015,7 +5041,7 @@ var Wo = new class {
|
|
|
5015
5041
|
};
|
|
5016
5042
|
}
|
|
5017
5043
|
async loadIfcModelInWorker(e, t, n, r, i) {
|
|
5018
|
-
return (await
|
|
5044
|
+
return (await Vo(e, {
|
|
5019
5045
|
chunk: t.chunk,
|
|
5020
5046
|
collectChunks: t.collectWorkerChunks,
|
|
5021
5047
|
coordinationMatrix: this.coordinationMatrix,
|
|
@@ -5028,14 +5054,14 @@ var Wo = new class {
|
|
|
5028
5054
|
}))[0];
|
|
5029
5055
|
}
|
|
5030
5056
|
async loadBmtModelInWorker(e, t, n, r, i, a) {
|
|
5031
|
-
let o = (await
|
|
5057
|
+
let o = (await po(e, {
|
|
5032
5058
|
collectChunks: n.collectWorkerChunks,
|
|
5033
5059
|
onChunk: this.createWorkerChunkHandler(n, r),
|
|
5034
5060
|
onProgress: this.createWorkerProgressHandler(n, r, i, a),
|
|
5035
5061
|
streamGeometryChunks: n.streamGeometryChunks ?? !!n.onChunk
|
|
5036
5062
|
}))[0];
|
|
5037
5063
|
if (e instanceof File) {
|
|
5038
|
-
let n =
|
|
5064
|
+
let n = Ko(e), r = n ? t.get(n) : void 0;
|
|
5039
5065
|
return this.applyBmtMetadata(o, r);
|
|
5040
5066
|
}
|
|
5041
5067
|
return o;
|
|
@@ -5055,21 +5081,21 @@ var Wo = new class {
|
|
|
5055
5081
|
}
|
|
5056
5082
|
async loadModel(e, t = {}) {
|
|
5057
5083
|
this.initLoaders();
|
|
5058
|
-
let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !
|
|
5084
|
+
let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !qo(e)).length, o = 0;
|
|
5059
5085
|
this.loadedModelCount === 0 && this.resetCoordinationMatrixState();
|
|
5060
5086
|
for (let e = 0; e < n.length; e++) {
|
|
5061
|
-
let s = n[e], c =
|
|
5062
|
-
if (c === "json" &&
|
|
5087
|
+
let s = n[e], c = Go(s), l;
|
|
5088
|
+
if (c === "json" && qo(s)) continue;
|
|
5063
5089
|
let u = this.nextModelID, d = o;
|
|
5064
5090
|
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];
|
|
5065
5091
|
else if (c === "bmt") l = t.useWorker ? await this.loadBmtModelInWorker(s, r, t, u, d, a) : await this.loadBmtModel(s, r);
|
|
5066
|
-
else throw Error(`Unsupported model format: ${
|
|
5067
|
-
let f =
|
|
5068
|
-
!this.coordinationMatrix && f && (this.coordinationMatrix = f), !l.coordinationMatrix && this.coordinationMatrix && (l.coordinationMatrix = this.coordinationMatrix), this.applyRenderSettings(l, t), l.name ??=
|
|
5092
|
+
else throw Error(`Unsupported model format: ${Uo(s)}`);
|
|
5093
|
+
let f = Jo(l);
|
|
5094
|
+
!this.coordinationMatrix && f && (this.coordinationMatrix = f), !l.coordinationMatrix && this.coordinationMatrix && (l.coordinationMatrix = this.coordinationMatrix), this.applyRenderSettings(l, t), l.name ??= Wo(s), this.nextModelID += 1, this.loadedModelCount += 1, i[u] = l;
|
|
5069
5095
|
}
|
|
5070
5096
|
return i;
|
|
5071
5097
|
}
|
|
5072
|
-
}(),
|
|
5098
|
+
}(), Xo = .5, Zo = .04, X = .16, Qo = X, Z = Xo * 2 - X * 2, $o = Xo - Zo / 2, es = Xo - X / 2, ts = Xo - Qo / 2, ns = .63, rs = "#dfe6ec", is = 260, as = 52, os = .17, ss = new g(), Q = new de(), cs = [
|
|
5073
5099
|
{
|
|
5074
5100
|
direction: [
|
|
5075
5101
|
0,
|
|
@@ -5080,12 +5106,12 @@ var Wo = new class {
|
|
|
5080
5106
|
position: [
|
|
5081
5107
|
0,
|
|
5082
5108
|
0,
|
|
5083
|
-
|
|
5109
|
+
$o
|
|
5084
5110
|
],
|
|
5085
5111
|
scale: [
|
|
5086
5112
|
Z,
|
|
5087
5113
|
Z,
|
|
5088
|
-
|
|
5114
|
+
Zo
|
|
5089
5115
|
],
|
|
5090
5116
|
title: "Front",
|
|
5091
5117
|
type: "face"
|
|
@@ -5100,7 +5126,7 @@ var Wo = new class {
|
|
|
5100
5126
|
position: [
|
|
5101
5127
|
0,
|
|
5102
5128
|
0,
|
|
5103
|
-
|
|
5129
|
+
-$o
|
|
5104
5130
|
],
|
|
5105
5131
|
rotation: [
|
|
5106
5132
|
0,
|
|
@@ -5110,7 +5136,7 @@ var Wo = new class {
|
|
|
5110
5136
|
scale: [
|
|
5111
5137
|
Z,
|
|
5112
5138
|
Z,
|
|
5113
|
-
|
|
5139
|
+
Zo
|
|
5114
5140
|
],
|
|
5115
5141
|
title: "Back",
|
|
5116
5142
|
type: "face"
|
|
@@ -5123,7 +5149,7 @@ var Wo = new class {
|
|
|
5123
5149
|
],
|
|
5124
5150
|
label: "right",
|
|
5125
5151
|
position: [
|
|
5126
|
-
|
|
5152
|
+
$o,
|
|
5127
5153
|
0,
|
|
5128
5154
|
0
|
|
5129
5155
|
],
|
|
@@ -5133,7 +5159,7 @@ var Wo = new class {
|
|
|
5133
5159
|
0
|
|
5134
5160
|
],
|
|
5135
5161
|
scale: [
|
|
5136
|
-
|
|
5162
|
+
Zo,
|
|
5137
5163
|
Z,
|
|
5138
5164
|
Z
|
|
5139
5165
|
],
|
|
@@ -5148,7 +5174,7 @@ var Wo = new class {
|
|
|
5148
5174
|
],
|
|
5149
5175
|
label: "left",
|
|
5150
5176
|
position: [
|
|
5151
|
-
|
|
5177
|
+
-$o,
|
|
5152
5178
|
0,
|
|
5153
5179
|
0
|
|
5154
5180
|
],
|
|
@@ -5158,7 +5184,7 @@ var Wo = new class {
|
|
|
5158
5184
|
0
|
|
5159
5185
|
],
|
|
5160
5186
|
scale: [
|
|
5161
|
-
|
|
5187
|
+
Zo,
|
|
5162
5188
|
Z,
|
|
5163
5189
|
Z
|
|
5164
5190
|
],
|
|
@@ -5174,7 +5200,7 @@ var Wo = new class {
|
|
|
5174
5200
|
label: "top",
|
|
5175
5201
|
position: [
|
|
5176
5202
|
0,
|
|
5177
|
-
|
|
5203
|
+
$o,
|
|
5178
5204
|
0
|
|
5179
5205
|
],
|
|
5180
5206
|
rotation: [
|
|
@@ -5184,7 +5210,7 @@ var Wo = new class {
|
|
|
5184
5210
|
],
|
|
5185
5211
|
scale: [
|
|
5186
5212
|
Z,
|
|
5187
|
-
|
|
5213
|
+
Zo,
|
|
5188
5214
|
Z
|
|
5189
5215
|
],
|
|
5190
5216
|
title: "Top",
|
|
@@ -5199,7 +5225,7 @@ var Wo = new class {
|
|
|
5199
5225
|
label: "bot",
|
|
5200
5226
|
position: [
|
|
5201
5227
|
0,
|
|
5202
|
-
|
|
5228
|
+
-$o,
|
|
5203
5229
|
0
|
|
5204
5230
|
],
|
|
5205
5231
|
rotation: [
|
|
@@ -5209,14 +5235,14 @@ var Wo = new class {
|
|
|
5209
5235
|
],
|
|
5210
5236
|
scale: [
|
|
5211
5237
|
Z,
|
|
5212
|
-
|
|
5238
|
+
Zo,
|
|
5213
5239
|
Z
|
|
5214
5240
|
],
|
|
5215
5241
|
title: "Bottom",
|
|
5216
5242
|
type: "face"
|
|
5217
5243
|
}
|
|
5218
5244
|
];
|
|
5219
|
-
function
|
|
5245
|
+
function ls() {
|
|
5220
5246
|
let e = [], t = [-1, 1];
|
|
5221
5247
|
return t.forEach((n) => {
|
|
5222
5248
|
t.forEach((t) => {
|
|
@@ -5228,8 +5254,8 @@ function is() {
|
|
|
5228
5254
|
],
|
|
5229
5255
|
position: [
|
|
5230
5256
|
0,
|
|
5231
|
-
n *
|
|
5232
|
-
t *
|
|
5257
|
+
n * es,
|
|
5258
|
+
t * es
|
|
5233
5259
|
],
|
|
5234
5260
|
scale: [
|
|
5235
5261
|
Z,
|
|
@@ -5249,9 +5275,9 @@ function is() {
|
|
|
5249
5275
|
t
|
|
5250
5276
|
],
|
|
5251
5277
|
position: [
|
|
5252
|
-
n *
|
|
5278
|
+
n * es,
|
|
5253
5279
|
0,
|
|
5254
|
-
t *
|
|
5280
|
+
t * es
|
|
5255
5281
|
],
|
|
5256
5282
|
scale: [
|
|
5257
5283
|
X,
|
|
@@ -5271,8 +5297,8 @@ function is() {
|
|
|
5271
5297
|
0
|
|
5272
5298
|
],
|
|
5273
5299
|
position: [
|
|
5274
|
-
n *
|
|
5275
|
-
t *
|
|
5300
|
+
n * es,
|
|
5301
|
+
t * es,
|
|
5276
5302
|
0
|
|
5277
5303
|
],
|
|
5278
5304
|
scale: [
|
|
@@ -5286,7 +5312,7 @@ function is() {
|
|
|
5286
5312
|
});
|
|
5287
5313
|
}), e;
|
|
5288
5314
|
}
|
|
5289
|
-
function
|
|
5315
|
+
function us() {
|
|
5290
5316
|
let e = [], t = [-1, 1];
|
|
5291
5317
|
return t.forEach((n) => {
|
|
5292
5318
|
t.forEach((r) => {
|
|
@@ -5298,14 +5324,14 @@ function as() {
|
|
|
5298
5324
|
t
|
|
5299
5325
|
],
|
|
5300
5326
|
position: [
|
|
5301
|
-
n *
|
|
5302
|
-
r *
|
|
5303
|
-
t *
|
|
5327
|
+
n * ts,
|
|
5328
|
+
r * ts,
|
|
5329
|
+
t * ts
|
|
5304
5330
|
],
|
|
5305
5331
|
scale: [
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5332
|
+
Qo,
|
|
5333
|
+
Qo,
|
|
5334
|
+
Qo
|
|
5309
5335
|
],
|
|
5310
5336
|
title: `${r > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
|
|
5311
5337
|
type: "corner"
|
|
@@ -5314,34 +5340,34 @@ function as() {
|
|
|
5314
5340
|
});
|
|
5315
5341
|
}), e;
|
|
5316
5342
|
}
|
|
5317
|
-
function
|
|
5343
|
+
function ds(e) {
|
|
5318
5344
|
e.stopPropagation(), e.nativeEvent.stopPropagation(), e.nativeEvent.stopImmediatePropagation?.();
|
|
5319
5345
|
}
|
|
5320
|
-
function
|
|
5321
|
-
return e ? "#4f7fa3" :
|
|
5346
|
+
function fs(e) {
|
|
5347
|
+
return e ? "#4f7fa3" : rs;
|
|
5322
5348
|
}
|
|
5323
|
-
function
|
|
5349
|
+
function ps(e) {
|
|
5324
5350
|
return e ? 1 : .96;
|
|
5325
5351
|
}
|
|
5326
|
-
function
|
|
5352
|
+
function ms(e, t) {
|
|
5327
5353
|
let n = document.createElement("canvas"), r = n.getContext("2d");
|
|
5328
5354
|
if (!r) throw Error("Could not create navigation cube label context");
|
|
5329
|
-
let i = `600 ${
|
|
5355
|
+
let i = `600 ${as}px system-ui, "Segoe UI", sans-serif`;
|
|
5330
5356
|
r.font = i;
|
|
5331
|
-
let a = r.measureText(e), o = a.actualBoundingBoxAscent ||
|
|
5357
|
+
let a = r.measureText(e), o = a.actualBoundingBoxAscent || as * .8, s = a.actualBoundingBoxDescent || as * .2, c = Math.ceil(a.width + 36), l = Math.ceil(o + s + 20);
|
|
5332
5358
|
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);
|
|
5333
5359
|
let u = new b(n);
|
|
5334
|
-
return u.colorSpace =
|
|
5360
|
+
return u.colorSpace = le, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
|
|
5335
5361
|
aspect: c / l,
|
|
5336
5362
|
texture: u
|
|
5337
5363
|
};
|
|
5338
5364
|
}
|
|
5339
|
-
function
|
|
5340
|
-
let { aspect: i, texture: a } = c(() =>
|
|
5365
|
+
function hs({ color: e, label: t, position: n, rotation: r }) {
|
|
5366
|
+
let { aspect: i, texture: a } = c(() => ms(t, e), [e, t]);
|
|
5341
5367
|
return o(() => () => a.dispose(), [a]), /* @__PURE__ */ V("mesh", {
|
|
5342
5368
|
position: n,
|
|
5343
5369
|
rotation: r,
|
|
5344
|
-
children: [/* @__PURE__ */ B("planeGeometry", { args: [
|
|
5370
|
+
children: [/* @__PURE__ */ B("planeGeometry", { args: [os * i, os] }), /* @__PURE__ */ B("meshBasicMaterial", {
|
|
5345
5371
|
alphaTest: .1,
|
|
5346
5372
|
depthWrite: !1,
|
|
5347
5373
|
map: a,
|
|
@@ -5350,41 +5376,41 @@ function us({ color: e, label: t, position: n, rotation: r }) {
|
|
|
5350
5376
|
})]
|
|
5351
5377
|
});
|
|
5352
5378
|
}
|
|
5353
|
-
function
|
|
5379
|
+
function gs(e) {
|
|
5354
5380
|
return Math.abs(e.y) > .9 ? new z(0, 0, e.y > 0 ? -1 : 1) : new z(0, 1, 0);
|
|
5355
5381
|
}
|
|
5356
|
-
function
|
|
5382
|
+
function _s(e, t) {
|
|
5357
5383
|
let n = e.current;
|
|
5358
|
-
return !n || (n.updateWorldMatrix(!0, !0),
|
|
5384
|
+
return !n || (n.updateWorldMatrix(!0, !0), ss.setFromObject(n), ss.isEmpty()) ? (Q.center.copy(t), Q.radius = 10, Q) : (ss.getBoundingSphere(Q), (!Number.isFinite(Q.radius) || Q.radius <= 0) && (Q.radius = 10), Q);
|
|
5359
5385
|
}
|
|
5360
|
-
function
|
|
5386
|
+
function vs(e) {
|
|
5361
5387
|
return e.current?.getTarget(new z()) ?? new z();
|
|
5362
5388
|
}
|
|
5363
|
-
function
|
|
5364
|
-
let a =
|
|
5389
|
+
function ys({ camera: e, controlRef: t, direction: n, modelRef: r, transitionRef: i }) {
|
|
5390
|
+
let a = vs(t), o = _s(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);
|
|
5365
5391
|
t.current?.cancel(), t.current?.setFocalOffset(0, 0, 0, !1), i.current = {
|
|
5366
5392
|
endPosition: d,
|
|
5367
5393
|
endTarget: s,
|
|
5368
|
-
endUp:
|
|
5394
|
+
endUp: gs(c),
|
|
5369
5395
|
startPosition: e.position.clone(),
|
|
5370
5396
|
startTarget: a,
|
|
5371
5397
|
startTime: performance.now(),
|
|
5372
5398
|
startUp: e.up.clone()
|
|
5373
5399
|
};
|
|
5374
5400
|
}
|
|
5375
|
-
function
|
|
5401
|
+
function bs({ action: e, onPick: t }) {
|
|
5376
5402
|
let [n, r] = u(!1);
|
|
5377
5403
|
return /* @__PURE__ */ V("group", {
|
|
5378
5404
|
position: e.position,
|
|
5379
|
-
onClick:
|
|
5405
|
+
onClick: ds,
|
|
5380
5406
|
onPointerDown: (n) => {
|
|
5381
|
-
|
|
5407
|
+
ds(n), t(e);
|
|
5382
5408
|
},
|
|
5383
5409
|
onPointerEnter: (e) => {
|
|
5384
|
-
|
|
5410
|
+
ds(e), r(!0);
|
|
5385
5411
|
},
|
|
5386
5412
|
onPointerLeave: (e) => {
|
|
5387
|
-
|
|
5413
|
+
ds(e), r(!1);
|
|
5388
5414
|
},
|
|
5389
5415
|
children: [/* @__PURE__ */ V("mesh", {
|
|
5390
5416
|
scale: e.scale,
|
|
@@ -5393,11 +5419,11 @@ function hs({ action: e, onPick: t }) {
|
|
|
5393
5419
|
1,
|
|
5394
5420
|
1
|
|
5395
5421
|
] }), /* @__PURE__ */ B("meshBasicMaterial", {
|
|
5396
|
-
color:
|
|
5397
|
-
opacity:
|
|
5422
|
+
color: fs(n),
|
|
5423
|
+
opacity: ps(n),
|
|
5398
5424
|
transparent: !0
|
|
5399
5425
|
})]
|
|
5400
|
-
}), e.label && /* @__PURE__ */ B(
|
|
5426
|
+
}), e.label && /* @__PURE__ */ B(hs, {
|
|
5401
5427
|
color: n ? "#ffffff" : "#50606f",
|
|
5402
5428
|
label: e.label,
|
|
5403
5429
|
position: [
|
|
@@ -5409,11 +5435,11 @@ function hs({ action: e, onPick: t }) {
|
|
|
5409
5435
|
})]
|
|
5410
5436
|
});
|
|
5411
5437
|
}
|
|
5412
|
-
function
|
|
5438
|
+
function xs({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
|
|
5413
5439
|
let i = l(null), a = l(null), o = c(() => [
|
|
5414
|
-
...
|
|
5415
|
-
...
|
|
5416
|
-
...
|
|
5440
|
+
...cs,
|
|
5441
|
+
...ls(),
|
|
5442
|
+
...us()
|
|
5417
5443
|
], []);
|
|
5418
5444
|
return f(() => {
|
|
5419
5445
|
if (!e) return;
|
|
@@ -5422,7 +5448,7 @@ function gs({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
|
|
|
5422
5448
|
i.current && i.current.quaternion.copy(r.quaternion).invert();
|
|
5423
5449
|
let o = a.current;
|
|
5424
5450
|
if (!o) return;
|
|
5425
|
-
let s = performance.now() - o.startTime, c = Math.min(s /
|
|
5451
|
+
let s = performance.now() - o.startTime, c = Math.min(s / is, 1), l = 1 - (1 - c) ** 3, u = n.current;
|
|
5426
5452
|
if (r.position.lerpVectors(o.startPosition, o.endPosition, l), r.up.lerpVectors(o.startUp, o.endUp, l), u) {
|
|
5427
5453
|
let e = new z().lerpVectors(o.startTarget, o.endTarget, l);
|
|
5428
5454
|
u.setLookAt(r.position.x, r.position.y, r.position.z, e.x, e.y, e.z, !1);
|
|
@@ -5430,12 +5456,12 @@ function gs({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
|
|
|
5430
5456
|
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);
|
|
5431
5457
|
}), e ? /* @__PURE__ */ B("group", {
|
|
5432
5458
|
ref: i,
|
|
5433
|
-
scale:
|
|
5434
|
-
children: o.map((e) => /* @__PURE__ */ B(
|
|
5459
|
+
scale: ns,
|
|
5460
|
+
children: o.map((e) => /* @__PURE__ */ B(bs, {
|
|
5435
5461
|
action: e,
|
|
5436
5462
|
onPick: (e) => {
|
|
5437
5463
|
let i = t.current;
|
|
5438
|
-
i &&
|
|
5464
|
+
i && ys({
|
|
5439
5465
|
camera: i,
|
|
5440
5466
|
controlRef: n,
|
|
5441
5467
|
direction: e.direction,
|
|
@@ -5448,13 +5474,13 @@ function gs({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
|
|
|
5448
5474
|
}
|
|
5449
5475
|
//#endregion
|
|
5450
5476
|
//#region src/viewer/Viewer.tsx
|
|
5451
|
-
var
|
|
5477
|
+
var Ss = class {
|
|
5452
5478
|
sceneApi = null;
|
|
5453
5479
|
get = () => this.sceneApi;
|
|
5454
5480
|
set = (e) => {
|
|
5455
5481
|
this.sceneApi = e;
|
|
5456
5482
|
};
|
|
5457
|
-
},
|
|
5483
|
+
}, Cs = {
|
|
5458
5484
|
bottom: 16,
|
|
5459
5485
|
height: 96,
|
|
5460
5486
|
pointerEvents: "auto",
|
|
@@ -5463,11 +5489,11 @@ var _s = class {
|
|
|
5463
5489
|
touchAction: "none",
|
|
5464
5490
|
width: 96,
|
|
5465
5491
|
zIndex: 2
|
|
5466
|
-
},
|
|
5492
|
+
}, ws = {
|
|
5467
5493
|
height: "100%",
|
|
5468
5494
|
position: "relative",
|
|
5469
5495
|
width: "100%"
|
|
5470
|
-
},
|
|
5496
|
+
}, Ts = {
|
|
5471
5497
|
far: 50,
|
|
5472
5498
|
near: .1,
|
|
5473
5499
|
position: [
|
|
@@ -5476,49 +5502,49 @@ var _s = class {
|
|
|
5476
5502
|
10
|
|
5477
5503
|
],
|
|
5478
5504
|
zoom: 72
|
|
5479
|
-
},
|
|
5505
|
+
}, Es = {
|
|
5480
5506
|
alpha: !0,
|
|
5481
5507
|
antialias: !0
|
|
5482
|
-
},
|
|
5508
|
+
}, Ds = {
|
|
5483
5509
|
alpha: !0,
|
|
5484
5510
|
antialias: !1,
|
|
5485
5511
|
powerPreference: "high-performance"
|
|
5486
|
-
},
|
|
5512
|
+
}, Os = {
|
|
5487
5513
|
antialias: !1,
|
|
5488
5514
|
powerPreference: "high-performance"
|
|
5489
|
-
},
|
|
5490
|
-
function
|
|
5515
|
+
}, ks = .1, As = .02, js = 150, Ms = .75, Ns = .6, Ps = 1e3, Fs = 50, Is = 1.25, Ls = .08, Rs = new g(), zs = new de(), $ = new z(), Bs = new z(), Vs = new z();
|
|
5516
|
+
function Hs(e, t) {
|
|
5491
5517
|
return Array.isArray(e) ? [Math.min(e[0], t), Math.min(e[1], t)] : typeof e == "number" ? Math.min(e, t) : t;
|
|
5492
5518
|
}
|
|
5493
|
-
function
|
|
5519
|
+
function Us() {
|
|
5494
5520
|
let e = navigator, t = navigator.userAgent.toLowerCase(), n = navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, r = window.matchMedia?.("(pointer: coarse)").matches ?? !1;
|
|
5495
5521
|
return e.userAgentData?.mobile || n || /android|iphone|ipad|ipod|mobile|tablet/.test(t) || navigator.maxTouchPoints > 1 && r ? "mobile" : "pc";
|
|
5496
5522
|
}
|
|
5497
|
-
function
|
|
5498
|
-
let t =
|
|
5499
|
-
return t ? Math.max(t.radius *
|
|
5523
|
+
function Ws(e) {
|
|
5524
|
+
let t = Gs(e);
|
|
5525
|
+
return t ? Math.max(t.radius * As, ks) : ks;
|
|
5500
5526
|
}
|
|
5501
|
-
function
|
|
5502
|
-
if (!e || (
|
|
5503
|
-
let t =
|
|
5527
|
+
function Gs(e) {
|
|
5528
|
+
if (!e || (Rs.setFromObject(e), Rs.isEmpty())) return null;
|
|
5529
|
+
let t = Rs.getBoundingSphere(zs);
|
|
5504
5530
|
return !Number.isFinite(t.radius) || t.radius <= 0 ? null : t;
|
|
5505
5531
|
}
|
|
5506
|
-
function
|
|
5532
|
+
function Ks(e) {
|
|
5507
5533
|
return e.type === "Group" && typeof e.userData.modelID == "number";
|
|
5508
5534
|
}
|
|
5509
|
-
function
|
|
5510
|
-
return e?.children.filter(
|
|
5535
|
+
function qs(e) {
|
|
5536
|
+
return e?.children.filter(Ks) ?? [];
|
|
5511
5537
|
}
|
|
5512
|
-
function
|
|
5513
|
-
return
|
|
5538
|
+
function Js(e, t) {
|
|
5539
|
+
return qs(e).find((e) => e.userData.modelID === t) ?? null;
|
|
5514
5540
|
}
|
|
5515
|
-
function
|
|
5516
|
-
let n =
|
|
5541
|
+
function Ys(e, t) {
|
|
5542
|
+
let n = Gs(t);
|
|
5517
5543
|
if (!n) return;
|
|
5518
|
-
let r = Math.max(
|
|
5544
|
+
let r = Math.max(Ps, n.radius * Fs, e.near + 1);
|
|
5519
5545
|
Math.abs(e.far - r) < 1 || (e.far = r, e.updateProjectionMatrix());
|
|
5520
5546
|
}
|
|
5521
|
-
function
|
|
5547
|
+
function Xs(e, t, n, r, i) {
|
|
5522
5548
|
let a = n.elementIndex.get(i);
|
|
5523
5549
|
a && a.forEach((n) => {
|
|
5524
5550
|
let { record: i, vertexRanges: a } = n;
|
|
@@ -5530,204 +5556,232 @@ function Hs(e, t, n, r, i) {
|
|
|
5530
5556
|
}));
|
|
5531
5557
|
});
|
|
5532
5558
|
}
|
|
5533
|
-
function
|
|
5559
|
+
function Zs(e, t) {
|
|
5534
5560
|
let n = new g(), r = new z();
|
|
5535
5561
|
return Object.entries(e).forEach(([e, i]) => {
|
|
5536
5562
|
let a = Number(e);
|
|
5537
5563
|
i.forEach((e) => {
|
|
5538
|
-
|
|
5564
|
+
Xs(n, r, t, a, e);
|
|
5539
5565
|
});
|
|
5540
5566
|
}), n.isEmpty() ? null : n;
|
|
5541
5567
|
}
|
|
5542
|
-
function
|
|
5543
|
-
let t = e.getSize(
|
|
5544
|
-
return Number.isFinite(n) && n > 0 ? n *
|
|
5568
|
+
function Qs(e) {
|
|
5569
|
+
let t = e.getSize(Vs), n = Math.max(t.x, t.y, t.z);
|
|
5570
|
+
return Number.isFinite(n) && n > 0 ? n * Ls : ks;
|
|
5545
5571
|
}
|
|
5546
|
-
function
|
|
5547
|
-
let r = Math.max(
|
|
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(),
|
|
5572
|
+
function $s(e, t, n) {
|
|
5573
|
+
let r = Math.max(ks, (Number.isFinite(n) ? n : ks) * Is), i = t.position.distanceTo(e);
|
|
5574
|
+
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(), Bs.copy(t.position).addScaledVector($, r));
|
|
5549
5575
|
}
|
|
5550
|
-
function
|
|
5551
|
-
let
|
|
5576
|
+
function ec({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, onCameraDprModeChange: f, publicApi: g, setSceneApi: _, usePerformanceMoving: v }) {
|
|
5577
|
+
let y = p((e) => e.camera), b = p((e) => e.gl), x = Nt(s), S = Gt(x), { colorPaletteTexture: C, colorUtils: w } = Ke(x), T = tr(s), E = Xn(s, n, T), D = gr(s, n, T, E.getSelectableObjects), O = c(() => new La(), []), ee = S.buildIndex, te = x.resetIndex, ne = w.applyStoredColors, k = mi(), A = l(null), j = l(null), M = l(null), N = l(!1), P = H((e) => e.showStats), F = c(() => {
|
|
5552
5578
|
let e = Object.keys(u).sort((e, t) => Number(e) - Number(t));
|
|
5553
5579
|
for (let t of e) {
|
|
5554
|
-
let e =
|
|
5580
|
+
let e = Ct(u[Number(t)]);
|
|
5555
5581
|
if (e) return e;
|
|
5556
5582
|
}
|
|
5557
5583
|
return null;
|
|
5558
|
-
}, [u]),
|
|
5559
|
-
n.current && (n.current.minDistance =
|
|
5560
|
-
}, [n, s]),
|
|
5584
|
+
}, [u]), re = c(() => xt(F ?? void 0), [F]), ie = c(() => Object.entries(u).map(([e, t]) => [Number(e), t]), [u]), ae = i(() => {
|
|
5585
|
+
n.current && (n.current.minDistance = Ws(s.current));
|
|
5586
|
+
}, [n, s]), I = i((e, t = !1) => {
|
|
5561
5587
|
let r = n.current;
|
|
5562
5588
|
if (!r) return !1;
|
|
5563
|
-
let i = t ?
|
|
5589
|
+
let i = t ? $s(e, y, r.minDistance) : e;
|
|
5564
5590
|
return r.cancel(), r.setOrbitPoint(i.x, i.y, i.z), !0;
|
|
5565
|
-
}, [
|
|
5566
|
-
|
|
5567
|
-
}, [
|
|
5568
|
-
|
|
5591
|
+
}, [y, n]), ce = i((e) => {
|
|
5592
|
+
A.current = e.clone(), I(e, !0);
|
|
5593
|
+
}, [I]), L = i(() => {
|
|
5594
|
+
A.current = null, k(s, n, r);
|
|
5569
5595
|
}, [
|
|
5570
5596
|
n,
|
|
5571
|
-
|
|
5597
|
+
k,
|
|
5572
5598
|
r,
|
|
5573
5599
|
s
|
|
5574
|
-
]),
|
|
5600
|
+
]), le = i((e, t = !1) => {
|
|
5575
5601
|
let r = n.current;
|
|
5576
5602
|
if (!r) return;
|
|
5577
|
-
let i =
|
|
5603
|
+
let i = Zs(e, x.buildIndex());
|
|
5578
5604
|
if (!i) return;
|
|
5579
5605
|
let a = i.getCenter(new z());
|
|
5580
|
-
if (
|
|
5581
|
-
let e =
|
|
5606
|
+
if (A.current = a.clone(), r.cancel(), t) {
|
|
5607
|
+
let e = Qs(i);
|
|
5582
5608
|
r.fitToBox(i, !0, {
|
|
5583
5609
|
paddingBottom: e,
|
|
5584
5610
|
paddingLeft: e,
|
|
5585
5611
|
paddingRight: e,
|
|
5586
5612
|
paddingTop: e
|
|
5587
5613
|
}).then(() => {
|
|
5588
|
-
let e =
|
|
5589
|
-
e &&
|
|
5614
|
+
let e = A.current;
|
|
5615
|
+
e && I(e, !0);
|
|
5590
5616
|
});
|
|
5591
5617
|
return;
|
|
5592
5618
|
}
|
|
5593
|
-
|
|
5619
|
+
I(a, !0);
|
|
5594
5620
|
}, [
|
|
5595
|
-
|
|
5621
|
+
I,
|
|
5596
5622
|
n,
|
|
5597
|
-
|
|
5598
|
-
]),
|
|
5623
|
+
x
|
|
5624
|
+
]), ue = c(() => {
|
|
5599
5625
|
let e = (e) => ({
|
|
5600
5626
|
...e,
|
|
5601
5627
|
activeViewRoot: s.current
|
|
5602
5628
|
});
|
|
5603
5629
|
return {
|
|
5604
|
-
convertIfcFileToBmt: (e, t) =>
|
|
5605
|
-
convertToBmt: (t) =>
|
|
5630
|
+
convertIfcFileToBmt: (e, t) => O.ConvertIfcFileToBmt(e, t),
|
|
5631
|
+
convertToBmt: (t) => O.ConvertToBmt(u, e(t))
|
|
5606
5632
|
};
|
|
5607
5633
|
}, [
|
|
5608
|
-
|
|
5634
|
+
O,
|
|
5609
5635
|
s,
|
|
5610
5636
|
u
|
|
5611
5637
|
]);
|
|
5612
|
-
return
|
|
5613
|
-
let e =
|
|
5614
|
-
|
|
5615
|
-
|
|
5638
|
+
return o(() => {
|
|
5639
|
+
let e = () => {
|
|
5640
|
+
j.current !== null && (window.clearTimeout(j.current), j.current = null);
|
|
5641
|
+
}, t = () => {
|
|
5642
|
+
let e = M.current;
|
|
5643
|
+
e !== null && (M.current = null, E.setEdgesActive(e));
|
|
5644
|
+
};
|
|
5645
|
+
if (!v) {
|
|
5646
|
+
e(), t(), f("sleep");
|
|
5647
|
+
return;
|
|
5648
|
+
}
|
|
5649
|
+
let r = n.current;
|
|
5650
|
+
if (!r) return;
|
|
5651
|
+
let i = () => {
|
|
5652
|
+
e(), f("wake"), j.current = window.setTimeout(() => {
|
|
5653
|
+
j.current = null, f("move"), M.current === null && (M.current = E.getEdgesActive()), M.current && E.setEdgesActive(!1);
|
|
5654
|
+
}, js);
|
|
5655
|
+
}, a = () => {
|
|
5656
|
+
e(), t(), f("sleep");
|
|
5657
|
+
};
|
|
5658
|
+
return r.addEventListener("wake", i), r.addEventListener("sleep", a), () => {
|
|
5659
|
+
e(), r.removeEventListener("wake", i), r.removeEventListener("sleep", a), t(), f("sleep");
|
|
5660
|
+
};
|
|
5661
|
+
}, [
|
|
5662
|
+
E,
|
|
5663
|
+
n,
|
|
5664
|
+
f,
|
|
5665
|
+
v
|
|
5666
|
+
]), di(s, n, T, ce, E.getSelectableObjects, E.setCapsPreselection), vr(), o(() => {
|
|
5667
|
+
let e = b.domElement, t = (e) => {
|
|
5668
|
+
let t = A.current;
|
|
5669
|
+
t && e.button === 0 && (e.ctrlKey || e.metaKey || e.shiftKey || I(t, !0));
|
|
5616
5670
|
};
|
|
5617
5671
|
return e.addEventListener("pointerdown", t, !0), () => {
|
|
5618
5672
|
e.removeEventListener("pointerdown", t, !0);
|
|
5619
5673
|
};
|
|
5620
|
-
}, [
|
|
5621
|
-
|
|
5622
|
-
}), [
|
|
5623
|
-
t.current ===
|
|
5624
|
-
}), [
|
|
5674
|
+
}, [I, b]), o(() => (T.setClippingSource(E), () => {
|
|
5675
|
+
T.setClippingSource(null);
|
|
5676
|
+
}), [T, E]), o(() => (t.current = y, () => {
|
|
5677
|
+
t.current === y && (t.current = null);
|
|
5678
|
+
}), [y, t]), o(() => {
|
|
5625
5679
|
if (!s.current) return;
|
|
5626
5680
|
let t = requestAnimationFrame(() => {
|
|
5627
|
-
s.current?.updateMatrixWorld(!0), (
|
|
5681
|
+
s.current?.updateMatrixWorld(!0), (y instanceof se || y instanceof oe) && Ys(y, s.current), ae(), te(), ee(), ne(), E.syncWithModel(), D.syncWithModel(), e && L();
|
|
5628
5682
|
});
|
|
5629
5683
|
return () => cancelAnimationFrame(t);
|
|
5630
5684
|
}, [
|
|
5631
|
-
|
|
5685
|
+
ne,
|
|
5632
5686
|
e,
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5687
|
+
ee,
|
|
5688
|
+
y,
|
|
5689
|
+
E,
|
|
5636
5690
|
n,
|
|
5637
|
-
|
|
5638
|
-
|
|
5691
|
+
D,
|
|
5692
|
+
L,
|
|
5639
5693
|
r,
|
|
5640
5694
|
s,
|
|
5641
5695
|
u,
|
|
5642
|
-
|
|
5643
|
-
|
|
5696
|
+
te,
|
|
5697
|
+
ae
|
|
5644
5698
|
]), o(() => {
|
|
5645
5699
|
let e = () => {
|
|
5646
|
-
|
|
5700
|
+
E.getActive() && E.syncWithModel();
|
|
5647
5701
|
}, t = (t) => {
|
|
5648
5702
|
t(), e();
|
|
5649
5703
|
};
|
|
5650
|
-
return
|
|
5704
|
+
return _({
|
|
5651
5705
|
camera: {
|
|
5652
|
-
fitCamera:
|
|
5653
|
-
getIntersection:
|
|
5706
|
+
fitCamera: L,
|
|
5707
|
+
getIntersection: T.getIntersection
|
|
5654
5708
|
},
|
|
5655
5709
|
clipping: {
|
|
5656
|
-
createClippingRectangle:
|
|
5657
|
-
createPlane:
|
|
5658
|
-
deleteAllPlanes:
|
|
5659
|
-
getActive:
|
|
5660
|
-
getCapsActive:
|
|
5661
|
-
getEdgesActive:
|
|
5662
|
-
getHelpersActive:
|
|
5663
|
-
getPlanes:
|
|
5664
|
-
setActive:
|
|
5665
|
-
setCapsActive:
|
|
5666
|
-
setEdgesActive:
|
|
5667
|
-
setHelpersActive:
|
|
5668
|
-
toggle:
|
|
5669
|
-
updateEdges:
|
|
5670
|
-
updateMaterials:
|
|
5710
|
+
createClippingRectangle: E.createClippingRectangle,
|
|
5711
|
+
createPlane: E.createPlane,
|
|
5712
|
+
deleteAllPlanes: E.deleteAllPlanes,
|
|
5713
|
+
getActive: E.getActive,
|
|
5714
|
+
getCapsActive: E.getCapsActive,
|
|
5715
|
+
getEdgesActive: E.getEdgesActive,
|
|
5716
|
+
getHelpersActive: E.getHelpersActive,
|
|
5717
|
+
getPlanes: E.getPlanes,
|
|
5718
|
+
setActive: E.setActive,
|
|
5719
|
+
setCapsActive: E.setCapsActive,
|
|
5720
|
+
setEdgesActive: E.setEdgesActive,
|
|
5721
|
+
setHelpersActive: E.setHelpersActive,
|
|
5722
|
+
toggle: E.toggle,
|
|
5723
|
+
updateEdges: E.updateEdges,
|
|
5724
|
+
updateMaterials: E.updateMaterials
|
|
5671
5725
|
},
|
|
5672
5726
|
colors: {
|
|
5673
|
-
clearAllColors:
|
|
5674
|
-
clearColor:
|
|
5675
|
-
clearModelColors:
|
|
5676
|
-
rebuildByColors:
|
|
5677
|
-
rebuildModelByColors:
|
|
5678
|
-
setColor:
|
|
5727
|
+
clearAllColors: w.clearAllColors,
|
|
5728
|
+
clearColor: w.clearColor,
|
|
5729
|
+
clearModelColors: w.clearModelColors,
|
|
5730
|
+
rebuildByColors: w.rebuildByColors,
|
|
5731
|
+
rebuildModelByColors: w.rebuildModelByColors,
|
|
5732
|
+
setColor: w.setColor
|
|
5679
5733
|
},
|
|
5680
|
-
converter:
|
|
5734
|
+
converter: ue,
|
|
5681
5735
|
dimensions: {
|
|
5682
|
-
cancelDrawing:
|
|
5683
|
-
changeAxes:
|
|
5684
|
-
delete:
|
|
5685
|
-
deleteAll:
|
|
5686
|
-
getActive:
|
|
5687
|
-
getDimensions:
|
|
5688
|
-
getSnapDistance:
|
|
5689
|
-
getUnit:
|
|
5690
|
-
setActive:
|
|
5691
|
-
setColor:
|
|
5692
|
-
setEndpointScaleFactor:
|
|
5693
|
-
setSnapDistance:
|
|
5694
|
-
setUnit:
|
|
5695
|
-
setWidth:
|
|
5696
|
-
toggle:
|
|
5736
|
+
cancelDrawing: D.cancelDrawing,
|
|
5737
|
+
changeAxes: D.changeAxes,
|
|
5738
|
+
delete: D.delete,
|
|
5739
|
+
deleteAll: D.deleteAll,
|
|
5740
|
+
getActive: D.getActive,
|
|
5741
|
+
getDimensions: D.getDimensions,
|
|
5742
|
+
getSnapDistance: D.getSnapDistance,
|
|
5743
|
+
getUnit: D.getUnit,
|
|
5744
|
+
setActive: D.setActive,
|
|
5745
|
+
setColor: D.setColor,
|
|
5746
|
+
setEndpointScaleFactor: D.setEndpointScaleFactor,
|
|
5747
|
+
setSnapDistance: D.setSnapDistance,
|
|
5748
|
+
setUnit: D.setUnit,
|
|
5749
|
+
setWidth: D.setWidth,
|
|
5750
|
+
toggle: D.toggle
|
|
5697
5751
|
},
|
|
5698
5752
|
geometryUtils: {
|
|
5699
|
-
getAllIds:
|
|
5700
|
-
getIfcSpacesVisibility:
|
|
5701
|
-
getModelGeometry: (e) =>
|
|
5702
|
-
getModelsGeometry: () =>
|
|
5703
|
-
hideByIds: (e) => t(() =>
|
|
5704
|
-
hideSelected: () => t(
|
|
5705
|
-
isolateByIds: (e) => t(() =>
|
|
5706
|
-
isolateSelected: () => t(
|
|
5707
|
-
resetIsolation: () => t(
|
|
5708
|
-
setIfcSpacesVisibility: (e) => t(() =>
|
|
5709
|
-
showAll: () => t(
|
|
5710
|
-
showByIds: (e) => t(() =>
|
|
5711
|
-
toggleIIfcSpacesVisibility: () => t(
|
|
5753
|
+
getAllIds: S.getAllIds,
|
|
5754
|
+
getIfcSpacesVisibility: S.getIfcSpacesVisibility,
|
|
5755
|
+
getModelGeometry: (e) => Js(s.current, e),
|
|
5756
|
+
getModelsGeometry: () => qs(s.current),
|
|
5757
|
+
hideByIds: (e) => t(() => S.hideByIds(e)),
|
|
5758
|
+
hideSelected: () => t(S.hideSelected),
|
|
5759
|
+
isolateByIds: (e) => t(() => S.isolateByIds(e)),
|
|
5760
|
+
isolateSelected: () => t(S.isolateSelected),
|
|
5761
|
+
resetIsolation: () => t(S.resetIsolation),
|
|
5762
|
+
setIfcSpacesVisibility: (e) => t(() => S.setIfcSpacesVisibility(e)),
|
|
5763
|
+
showAll: () => t(S.showAll),
|
|
5764
|
+
showByIds: (e) => t(() => S.showByIds(e)),
|
|
5765
|
+
toggleIIfcSpacesVisibility: () => t(S.toggleIIfcSpacesVisibility)
|
|
5712
5766
|
},
|
|
5713
|
-
selector: { setTargetToSelection:
|
|
5714
|
-
}),
|
|
5767
|
+
selector: { setTargetToSelection: le }
|
|
5768
|
+
}), N.current || (N.current = !0, d?.(g)), () => _(null);
|
|
5715
5769
|
}, [
|
|
5770
|
+
E,
|
|
5771
|
+
T,
|
|
5716
5772
|
w,
|
|
5717
|
-
C,
|
|
5718
|
-
S,
|
|
5719
5773
|
n,
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5774
|
+
ue,
|
|
5775
|
+
D,
|
|
5776
|
+
L,
|
|
5777
|
+
S,
|
|
5724
5778
|
r,
|
|
5725
5779
|
s,
|
|
5726
5780
|
d,
|
|
5727
|
-
f,
|
|
5728
5781
|
g,
|
|
5729
|
-
|
|
5730
|
-
|
|
5782
|
+
_,
|
|
5783
|
+
le
|
|
5784
|
+
]), /* @__PURE__ */ V(we, { children: [
|
|
5731
5785
|
/* @__PURE__ */ B("ambientLight", {
|
|
5732
5786
|
intensity: 1.2,
|
|
5733
5787
|
color: "#ffffff"
|
|
@@ -5742,12 +5796,12 @@ function Ks({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
|
|
|
5742
5796
|
color: "#ffffff",
|
|
5743
5797
|
intensity: 2
|
|
5744
5798
|
}),
|
|
5745
|
-
|
|
5799
|
+
P && /* @__PURE__ */ B(h, {}),
|
|
5746
5800
|
/* @__PURE__ */ B("group", {
|
|
5747
5801
|
ref: s,
|
|
5748
|
-
children:
|
|
5749
|
-
colorPaletteTexture:
|
|
5750
|
-
coordinationMatrix:
|
|
5802
|
+
children: ie.map(([e, t]) => /* @__PURE__ */ B(Tt, {
|
|
5803
|
+
colorPaletteTexture: C,
|
|
5804
|
+
coordinationMatrix: re,
|
|
5751
5805
|
data: t,
|
|
5752
5806
|
materialMode: a,
|
|
5753
5807
|
modelID: e
|
|
@@ -5757,45 +5811,45 @@ function Ks({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
|
|
|
5757
5811
|
dollyToCursor: !0,
|
|
5758
5812
|
draggingSmoothTime: .04,
|
|
5759
5813
|
infinityDolly: !0,
|
|
5760
|
-
minDistance:
|
|
5814
|
+
minDistance: ks,
|
|
5761
5815
|
ref: n,
|
|
5762
5816
|
smoothTime: .12
|
|
5763
5817
|
})
|
|
5764
5818
|
] });
|
|
5765
5819
|
}
|
|
5766
|
-
function
|
|
5820
|
+
function tc({ autoFitCamera: e = !0, camera: t = {
|
|
5767
5821
|
position: [
|
|
5768
5822
|
10,
|
|
5769
5823
|
10,
|
|
5770
5824
|
10
|
|
5771
5825
|
],
|
|
5772
5826
|
fov: 50
|
|
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 }) {
|
|
5774
|
-
let
|
|
5827
|
+
}, 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, usePerformanceMoving: _ = !1 }) {
|
|
5828
|
+
let v = l(null), y = l(null), b = l(null), x = l(null), [S, C] = u(), w = De(), T = H((e) => e.setModelNames), E = H((e) => e.setModelProps), D = H((e) => e.setModelStructure), O = H((e) => e.setShowNavCube), ee = H((e) => e.setShowStats), te = H((e) => e.setUserDevice), ne = H((e) => e.showNavCube), k = a ?? S, A = f ? Hs(n, 1) : n, j = Hs(A, f ? Ns : Ms), M = s ?? (f ? "performance" : void 0), [N, P] = u("sleep");
|
|
5775
5829
|
return o(() => {
|
|
5776
|
-
|
|
5777
|
-
}, [
|
|
5778
|
-
|
|
5779
|
-
}, [
|
|
5780
|
-
h !== void 0 &&
|
|
5781
|
-
}, [
|
|
5830
|
+
te(Us());
|
|
5831
|
+
}, [te]), o(() => {
|
|
5832
|
+
ee(!!g);
|
|
5833
|
+
}, [ee, g]), o(() => {
|
|
5834
|
+
h !== void 0 && O(h);
|
|
5835
|
+
}, [O, h]), o(() => {
|
|
5782
5836
|
let e = {}, t = {}, n = {};
|
|
5783
5837
|
k && Object.entries(k).forEach(([r, i]) => {
|
|
5784
5838
|
let a = Number(r);
|
|
5785
5839
|
i.name !== void 0 && (e[a] = i.name), i.props !== void 0 && (t[a] = i.props), i.structure !== void 0 && (n[a] = i.structure);
|
|
5786
|
-
}),
|
|
5840
|
+
}), T(e), E(t), D(n);
|
|
5787
5841
|
}, [
|
|
5788
5842
|
k,
|
|
5789
|
-
w,
|
|
5790
5843
|
T,
|
|
5791
|
-
E
|
|
5844
|
+
E,
|
|
5845
|
+
D
|
|
5792
5846
|
]), o(() => {
|
|
5793
5847
|
if (a) return;
|
|
5794
5848
|
let e = i ?? r;
|
|
5795
5849
|
if (!e?.length) return;
|
|
5796
5850
|
let t = !0;
|
|
5797
|
-
return
|
|
5798
|
-
t &&
|
|
5851
|
+
return Yo.loadModel(e).then((e) => {
|
|
5852
|
+
t && C(e);
|
|
5799
5853
|
}), () => {
|
|
5800
5854
|
t = !1;
|
|
5801
5855
|
};
|
|
@@ -5804,70 +5858,72 @@ function qs({ autoFitCamera: e = !0, camera: t = {
|
|
|
5804
5858
|
i,
|
|
5805
5859
|
r
|
|
5806
5860
|
]), k ? /* @__PURE__ */ V("div", {
|
|
5807
|
-
style:
|
|
5861
|
+
style: ws,
|
|
5808
5862
|
children: [/* @__PURE__ */ B(d, {
|
|
5809
5863
|
camera: t,
|
|
5810
|
-
dpr:
|
|
5811
|
-
gl: f ?
|
|
5812
|
-
children: /* @__PURE__ */ B(
|
|
5813
|
-
store:
|
|
5814
|
-
children: /* @__PURE__ */ B(
|
|
5864
|
+
dpr: _ && N === "move" ? j : A,
|
|
5865
|
+
gl: f ? Os : void 0,
|
|
5866
|
+
children: /* @__PURE__ */ B(hi, {
|
|
5867
|
+
store: w,
|
|
5868
|
+
children: /* @__PURE__ */ B(ec, {
|
|
5815
5869
|
autoFitCamera: e,
|
|
5816
|
-
cameraRef:
|
|
5817
|
-
controlRef:
|
|
5818
|
-
lightRef:
|
|
5819
|
-
materialMode:
|
|
5820
|
-
modelRef:
|
|
5870
|
+
cameraRef: v,
|
|
5871
|
+
controlRef: y,
|
|
5872
|
+
lightRef: x,
|
|
5873
|
+
materialMode: M,
|
|
5874
|
+
modelRef: b,
|
|
5821
5875
|
modelsData: k,
|
|
5822
5876
|
onReady: c,
|
|
5877
|
+
onCameraDprModeChange: P,
|
|
5823
5878
|
publicApi: p,
|
|
5824
|
-
setSceneApi: m
|
|
5879
|
+
setSceneApi: m,
|
|
5880
|
+
usePerformanceMoving: _
|
|
5825
5881
|
})
|
|
5826
5882
|
})
|
|
5827
|
-
}),
|
|
5828
|
-
style:
|
|
5883
|
+
}), ne && /* @__PURE__ */ B("div", {
|
|
5884
|
+
style: Cs,
|
|
5829
5885
|
children: /* @__PURE__ */ B(d, {
|
|
5830
|
-
camera:
|
|
5831
|
-
dpr:
|
|
5832
|
-
gl: f ?
|
|
5886
|
+
camera: Ts,
|
|
5887
|
+
dpr: A,
|
|
5888
|
+
gl: f ? Ds : Es,
|
|
5833
5889
|
orthographic: !0,
|
|
5834
|
-
children: /* @__PURE__ */ B(
|
|
5890
|
+
children: /* @__PURE__ */ B(xs, {
|
|
5835
5891
|
active: !0,
|
|
5836
|
-
cameraRef:
|
|
5837
|
-
controlRef:
|
|
5838
|
-
modelRef:
|
|
5892
|
+
cameraRef: v,
|
|
5893
|
+
controlRef: y,
|
|
5894
|
+
modelRef: b
|
|
5839
5895
|
})
|
|
5840
5896
|
})
|
|
5841
5897
|
})]
|
|
5842
|
-
}) : /* @__PURE__ */ B(
|
|
5898
|
+
}) : /* @__PURE__ */ B(we, {});
|
|
5843
5899
|
}
|
|
5844
|
-
var
|
|
5845
|
-
let [n] = u(
|
|
5900
|
+
var nc = n(function(e, t) {
|
|
5901
|
+
let [n] = u(je), r = l(!1), a = l(!1), d = c(() => new Ss(), []), { defaultSelected: f, onSelectedChange: p, selected: m } = e, h = i((e) => {
|
|
5846
5902
|
d.set(e);
|
|
5847
|
-
}, [d]), g = c(() =>
|
|
5903
|
+
}, [d]), g = c(() => to(n, d.get), [d, n]);
|
|
5848
5904
|
return s(t, () => g, [g]), o(() => (n.getState().setApi(g), () => {
|
|
5849
5905
|
n.getState().api === g && n.getState().setApi(null);
|
|
5850
5906
|
}), [g, n]), o(() => {
|
|
5851
|
-
r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(
|
|
5907
|
+
r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(eo(f)));
|
|
5852
5908
|
}, [
|
|
5853
5909
|
m,
|
|
5854
5910
|
f,
|
|
5855
5911
|
n
|
|
5856
5912
|
]), o(() => {
|
|
5857
|
-
m !== void 0 && (a.current = !0, n.getState().setSelection(
|
|
5913
|
+
m !== void 0 && (a.current = !0, n.getState().setSelection(eo(m)), a.current = !1);
|
|
5858
5914
|
}, [m, n]), o(() => {
|
|
5859
5915
|
if (p) return n.subscribe((e, t) => {
|
|
5860
|
-
e.selected !== t.selected && (a.current || p(
|
|
5916
|
+
e.selected !== t.selected && (a.current || p($a(e.selected)));
|
|
5861
5917
|
});
|
|
5862
|
-
}, [p, n]), /* @__PURE__ */ B(
|
|
5918
|
+
}, [p, n]), /* @__PURE__ */ B(hi, {
|
|
5863
5919
|
store: n,
|
|
5864
|
-
children: /* @__PURE__ */ B(
|
|
5920
|
+
children: /* @__PURE__ */ B(tc, {
|
|
5865
5921
|
...e,
|
|
5866
5922
|
publicApi: g,
|
|
5867
5923
|
setSceneApi: h
|
|
5868
5924
|
})
|
|
5869
5925
|
});
|
|
5870
5926
|
});
|
|
5871
|
-
|
|
5927
|
+
nc.displayName = "Viewer";
|
|
5872
5928
|
//#endregion
|
|
5873
|
-
export {
|
|
5929
|
+
export { ro as BMTLoader, La as BmtConverter, za as ConvertIfcFileToBmt, Ba as ConvertToBmt, cr as DimensionLine, hr as DimensionsUtils, Qa as FilteredElementsCollector, yt as ModelGrids, xs as NavigationCube, nc as Viewer, hi as ViewerStoreProvider, Ra as bmtConverter, ko as convertIfcFilesToBmtInWorker, Ao as createBmtConverterWorker, mo as createBmtWorker, Ho as createIfcWorker, je as createViewerStore, ra as exportExcel, ea as exportModelPropertiesToExcel, po as loadBmtModelsInWorker, Vo as loadIfcModelsInWorker, Yo as loader, gr as useDimensionsUtils, H as useViewerStore, De as useViewerStoreApi };
|