bimatter-viewer-react 0.6.4 → 0.6.6
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 +1290 -1182
- package/lib/utils/ClippingUtils/ClippingCaps.d.ts +5 -0
- package/lib/utils/ClippingUtils/ClippingEdges.d.ts +13 -0
- package/lib/utils/ClippingUtils/ClippingUtils.d.ts +5 -1
- 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,17 +1,17 @@
|
|
|
1
1
|
import e, { createContext as t, forwardRef as n, memo as r, useCallback as i, useContext as a, useEffect as o, useImperativeHandle as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
2
2
|
import { Canvas as d, useFrame as f, useThree as p } from "@react-three/fiber";
|
|
3
3
|
import { CameraControls as m, Stats as h } from "@react-three/drei";
|
|
4
|
-
import { Box3 as g, BoxGeometry as _, BufferAttribute as v, BufferGeometry as y, CanvasTexture as b, Color as x, ConeGeometry as S, DataTexture as C, DoubleSide as w, DynamicDrawUsage as T, Float32BufferAttribute as E, Group as D, Line as O, Line3 as ee, LineBasicMaterial as te, LineDashedMaterial as
|
|
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 L, RepeatWrapping as ce, SRGBColorSpace as R, ShapeUtils as le, Sphere as ue, SphereGeometry as de, Sprite as fe, SpriteMaterial as pe, Uint32BufferAttribute as me, UnsignedByteType as he, Vector2 as z, Vector3 as B } from "three";
|
|
5
5
|
import { useStore as ge } from "zustand";
|
|
6
6
|
import { createStore as _e } from "zustand/vanilla";
|
|
7
7
|
import { CONTAINED as ve, INTERSECTED as ye, MeshBVH as be, NOT_INTERSECTED as xe, acceleratedRaycast as Se } from "three-mesh-bvh";
|
|
8
|
-
import { Fragment as Ce, jsx as
|
|
8
|
+
import { Fragment as Ce, jsx as V, jsxs as H } from "react/jsx-runtime";
|
|
9
9
|
import we from "pako";
|
|
10
10
|
//#region src/viewer/store/ViewerStoreContext.ts
|
|
11
11
|
var Te = t(null);
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/viewer/store/useViewerStore.ts
|
|
14
|
-
function
|
|
14
|
+
function U(e) {
|
|
15
15
|
return ge(Ee(), e);
|
|
16
16
|
}
|
|
17
17
|
function Ee() {
|
|
@@ -121,8 +121,8 @@ function Ae() {
|
|
|
121
121
|
}
|
|
122
122
|
var je = 2;
|
|
123
123
|
function Me() {
|
|
124
|
-
let e = new C(new Uint8Array(256 * 4), 256, 1,
|
|
125
|
-
return e.magFilter =
|
|
124
|
+
let e = new C(new Uint8Array(256 * 4), 256, 1, L, he);
|
|
125
|
+
return e.magFilter = ie, e.minFilter = ie, e.generateMipmaps = !1, e.needsUpdate = !0, Pe(e, 1, new x(De)), e;
|
|
126
126
|
}
|
|
127
127
|
function Ne(e) {
|
|
128
128
|
return `${e.r.toFixed(6)}:${e.g.toFixed(6)}:${e.b.toFixed(6)}`;
|
|
@@ -190,7 +190,7 @@ function We(e, t) {
|
|
|
190
190
|
}), n;
|
|
191
191
|
}
|
|
192
192
|
function Ge(e) {
|
|
193
|
-
let t =
|
|
193
|
+
let t = U((e) => e.selected), n = U((e) => e.selectionColor), r = c(() => Me(), []), a = l(/* @__PURE__ */ new Map()), s = l(je), u = l(/* @__PURE__ */ new Map()), d = l(t), f = l(/* @__PURE__ */ new Set()), p = l(/* @__PURE__ */ new WeakMap());
|
|
194
194
|
o(() => {
|
|
195
195
|
d.current = t;
|
|
196
196
|
}, [t]), o(() => () => r.dispose(), [r]), o(() => {
|
|
@@ -280,25 +280,27 @@ function Ge(e) {
|
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/viewer/SelectableMesh.tsx
|
|
283
|
-
|
|
284
|
-
var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n = "quality", data: r, isIfcSpace: i = !1, meshMatrix: a, useDoubleSideMaterial: s = !1 }) {
|
|
285
|
-
let u = l(null), d =
|
|
283
|
+
P.prototype.raycast = Se;
|
|
284
|
+
var Ke = 1 / 1.5, qe = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n = "quality", data: r, isIfcSpace: i = !1, meshMatrix: a, useDoubleSideMaterial: s = !1 }) {
|
|
285
|
+
let u = l(null), d = U((e) => e.preselectionColor), f = l(d);
|
|
286
286
|
f.current = d;
|
|
287
287
|
let p = c(() => {
|
|
288
|
-
let r =
|
|
289
|
-
|
|
288
|
+
let r = new x(t.r, t.g, t.b);
|
|
289
|
+
n === "performance" && r.multiplyScalar(Ke);
|
|
290
|
+
let i = {
|
|
291
|
+
color: r.clone(),
|
|
290
292
|
transparent: !!(t.opacity && t.opacity != 1),
|
|
291
293
|
opacity: t.opacity ?? 1
|
|
292
|
-
},
|
|
293
|
-
...
|
|
294
|
+
}, a = s ? {
|
|
295
|
+
...i,
|
|
294
296
|
side: w
|
|
295
|
-
} :
|
|
296
|
-
return
|
|
297
|
-
...
|
|
297
|
+
} : i, o = n === "performance" ? new F(a) : new re(a), c = o;
|
|
298
|
+
return c.defaultAttributeValues = {
|
|
299
|
+
...c.defaultAttributeValues,
|
|
298
300
|
colorIndex: [0]
|
|
299
|
-
},
|
|
300
|
-
let
|
|
301
|
-
|
|
301
|
+
}, o.onBeforeCompile = (t) => {
|
|
302
|
+
let n = new x(f.current);
|
|
303
|
+
t.uniforms.baseColor = { value: r.clone() }, t.uniforms.preSelectionColor = { value: n }, t.uniforms.preSelectionId = { value: -1 }, t.uniforms.elementColorPalette = { value: e }, t.vertexShader = t.vertexShader.replace("#include <common>", "\n #include <common>\n attribute float colorIndex;\n attribute uint ids;\n flat varying float vColorIndex;\n flat varying float vPreselectId;\n "), t.vertexShader = t.vertexShader.replace("#include <begin_vertex>", "\n #include <begin_vertex>\n vColorIndex = colorIndex;\n vPreselectId = float(ids);\n "), t.fragmentShader = t.fragmentShader.replace("#include <common>", "\n #include <common>\n uniform vec3 baseColor;\n uniform vec3 preSelectionColor;\n uniform sampler2D elementColorPalette;\n flat varying float vPreselectId;\n flat varying float vColorIndex;\n uniform float preSelectionId;\n "), t.fragmentShader = t.fragmentShader.replace("vec4 diffuseColor = vec4( diffuse, opacity );", `
|
|
302
304
|
vec4 diffuseColor;
|
|
303
305
|
if(preSelectionId == vPreselectId && abs(vColorIndex - 1.0) > 0.5){
|
|
304
306
|
diffuseColor = vec4(preSelectionColor, 1.0);
|
|
@@ -313,8 +315,8 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
|
|
|
313
315
|
else{
|
|
314
316
|
diffuseColor = vec4(baseColor, opacity);
|
|
315
317
|
}
|
|
316
|
-
`),
|
|
317
|
-
},
|
|
318
|
+
`), o.userData.shader = t;
|
|
319
|
+
}, o;
|
|
318
320
|
}, [
|
|
319
321
|
e,
|
|
320
322
|
t,
|
|
@@ -330,7 +332,7 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
|
|
|
330
332
|
return Object.assign(e, { boundsTree: t }), () => {
|
|
331
333
|
p.dispose(), Object.assign(e, { boundsTree: null });
|
|
332
334
|
};
|
|
333
|
-
}, [p]), /* @__PURE__ */
|
|
335
|
+
}, [p]), /* @__PURE__ */ H("mesh", {
|
|
334
336
|
matrix: a,
|
|
335
337
|
matrixAutoUpdate: !1,
|
|
336
338
|
name: i ? "space" : void 0,
|
|
@@ -340,38 +342,38 @@ var Ke = e.memo(function({ colorPaletteTexture: e, material: t, materialMode: n
|
|
|
340
342
|
let t = e.object;
|
|
341
343
|
t.preselected &&= !1;
|
|
342
344
|
},
|
|
343
|
-
children: [/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
+
children: [/* @__PURE__ */ H("bufferGeometry", { children: [
|
|
346
|
+
/* @__PURE__ */ V("bufferAttribute", {
|
|
345
347
|
attach: "attributes-position",
|
|
346
348
|
args: [r.pos, 3]
|
|
347
349
|
}),
|
|
348
|
-
r.norm && /* @__PURE__ */
|
|
350
|
+
r.norm && /* @__PURE__ */ V("bufferAttribute", {
|
|
349
351
|
attach: "attributes-normal",
|
|
350
352
|
args: [r.norm, 3]
|
|
351
353
|
}),
|
|
352
|
-
/* @__PURE__ */
|
|
354
|
+
/* @__PURE__ */ V("bufferAttribute", {
|
|
353
355
|
attach: "attributes-ids",
|
|
354
356
|
args: [r.ids, 1]
|
|
355
357
|
}),
|
|
356
|
-
/* @__PURE__ */
|
|
358
|
+
/* @__PURE__ */ V("bufferAttribute", {
|
|
357
359
|
attach: "index",
|
|
358
360
|
args: [r.ind, 1]
|
|
359
361
|
})
|
|
360
|
-
] }), /* @__PURE__ */
|
|
362
|
+
] }), /* @__PURE__ */ V("primitive", { object: p })]
|
|
361
363
|
});
|
|
362
|
-
}),
|
|
363
|
-
function
|
|
364
|
+
}), Je = 10, Ye = "#1d2733", Xe = 2, Ze = .05, Qe = "\0", $e = /* @__PURE__ */ new Map();
|
|
365
|
+
function et() {
|
|
364
366
|
return typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2);
|
|
365
367
|
}
|
|
366
|
-
function
|
|
367
|
-
let i =
|
|
368
|
+
function tt(e, t, n, r) {
|
|
369
|
+
let i = et(), a = document.createElement("canvas"), o = a.getContext("2d");
|
|
368
370
|
if (!o) throw Error("Could not create grid label canvas context");
|
|
369
371
|
let s = `400 ${r}px system-ui, "Segoe UI", sans-serif`, c = Math.ceil(r * .5), l = Math.ceil(r * .35);
|
|
370
372
|
o.font = s;
|
|
371
373
|
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
374
|
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
375
|
let h = new b(a);
|
|
374
|
-
return h.colorSpace =
|
|
376
|
+
return h.colorSpace = R, h.generateMipmaps = !1, h.magFilter = A, h.minFilter = A, h.needsUpdate = !0, {
|
|
375
377
|
disposeTimer: null,
|
|
376
378
|
height: m,
|
|
377
379
|
key: e,
|
|
@@ -380,49 +382,49 @@ function et(e, t, n, r) {
|
|
|
380
382
|
width: p
|
|
381
383
|
};
|
|
382
384
|
}
|
|
383
|
-
function
|
|
385
|
+
function nt(e, t, n) {
|
|
384
386
|
let r = [
|
|
385
387
|
e,
|
|
386
388
|
t,
|
|
387
389
|
n
|
|
388
|
-
].join(
|
|
389
|
-
return i || (i =
|
|
390
|
+
].join(Qe), i = $e.get(r);
|
|
391
|
+
return i || (i = tt(r, e, t, n), $e.set(r, i)), i;
|
|
390
392
|
}
|
|
391
|
-
function
|
|
392
|
-
let r = c(() =>
|
|
393
|
+
function rt(e, t, n) {
|
|
394
|
+
let r = c(() => nt(e, t, n), [
|
|
393
395
|
t,
|
|
394
396
|
n,
|
|
395
397
|
e
|
|
396
398
|
]);
|
|
397
399
|
return o(() => (r.disposeTimer &&= (clearTimeout(r.disposeTimer), null), r.refs++, () => {
|
|
398
400
|
r.refs = Math.max(0, r.refs - 1), r.refs <= 0 && (r.disposeTimer = setTimeout(() => {
|
|
399
|
-
r.refs > 0 || (r.texture.dispose(),
|
|
401
|
+
r.refs > 0 || (r.texture.dispose(), $e.delete(r.key), r.disposeTimer = null);
|
|
400
402
|
}, 1e3));
|
|
401
403
|
}), [r]), r;
|
|
402
404
|
}
|
|
403
|
-
function
|
|
405
|
+
function it(e, t, n, r) {
|
|
404
406
|
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
407
|
e.scale.set(o, a, 1);
|
|
406
408
|
}
|
|
407
|
-
function
|
|
409
|
+
function at(e, t) {
|
|
408
410
|
let n = e[t];
|
|
409
411
|
return n === void 0 ? 0 : Number.isFinite(n) ? n : null;
|
|
410
412
|
}
|
|
411
|
-
function
|
|
412
|
-
return
|
|
413
|
+
function W(e, t) {
|
|
414
|
+
return at(e, t) ?? 0;
|
|
413
415
|
}
|
|
414
|
-
function
|
|
415
|
-
let t =
|
|
416
|
-
return t === null || n === null || r === null ? null : new
|
|
416
|
+
function ot(e) {
|
|
417
|
+
let t = at(e, "x"), n = at(e, "y"), r = at(e, "z");
|
|
418
|
+
return t === null || n === null || r === null ? null : new B(t, n, r);
|
|
417
419
|
}
|
|
418
|
-
function
|
|
420
|
+
function st(e, t) {
|
|
419
421
|
return [
|
|
420
|
-
|
|
421
|
-
t !== void 0 && Number.isFinite(t) ? t :
|
|
422
|
-
|
|
422
|
+
W(e, "x"),
|
|
423
|
+
t !== void 0 && Number.isFinite(t) ? t : W(e, "y"),
|
|
424
|
+
W(e, "z")
|
|
423
425
|
];
|
|
424
426
|
}
|
|
425
|
-
function
|
|
427
|
+
function ct(e) {
|
|
426
428
|
let { h: t, l: n } = e.getHSL({
|
|
427
429
|
h: 0,
|
|
428
430
|
s: 0,
|
|
@@ -430,14 +432,14 @@ function st(e) {
|
|
|
430
432
|
});
|
|
431
433
|
return t < .55 && n >= .5 || t >= .55 && n >= .75 ? "#000000" : "#ffffff";
|
|
432
434
|
}
|
|
433
|
-
function
|
|
435
|
+
function lt(e) {
|
|
434
436
|
let t = p((e) => e.scene.background);
|
|
435
|
-
return c(() => e || (t instanceof x ?
|
|
437
|
+
return c(() => e || (t instanceof x ? ct(t) : Ye), [t, e]);
|
|
436
438
|
}
|
|
437
|
-
function
|
|
439
|
+
function ut({ axis: e, grid: t, endSide: n, startSide: r }) {
|
|
438
440
|
return Object.entries(e).flatMap(([e, i]) => {
|
|
439
441
|
if (i.length < 2) return [];
|
|
440
|
-
let a =
|
|
442
|
+
let a = ot(i[0]), o = ot(i[1]);
|
|
441
443
|
return !a || !o ? [] : (a.y = 0, o.y = 0, [{
|
|
442
444
|
endSide: n,
|
|
443
445
|
loc: t.loc,
|
|
@@ -447,18 +449,18 @@ function lt({ axis: e, grid: t, endSide: n, startSide: r }) {
|
|
|
447
449
|
}]);
|
|
448
450
|
});
|
|
449
451
|
}
|
|
450
|
-
function
|
|
452
|
+
function dt({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight: i, showTop: a }) {
|
|
451
453
|
let o = {
|
|
452
454
|
bottom: n,
|
|
453
455
|
left: r,
|
|
454
456
|
right: i,
|
|
455
457
|
top: a
|
|
456
|
-
}, s = Object.values(t).flatMap((e) => [...
|
|
458
|
+
}, s = Object.values(t).flatMap((e) => [...ut({
|
|
457
459
|
axis: e.points.u,
|
|
458
460
|
endSide: "right",
|
|
459
461
|
grid: e,
|
|
460
462
|
startSide: "left"
|
|
461
|
-
}), ...
|
|
463
|
+
}), ...ut({
|
|
462
464
|
axis: e.points.v,
|
|
463
465
|
endSide: "bottom",
|
|
464
466
|
grid: e,
|
|
@@ -471,8 +473,8 @@ function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight
|
|
|
471
473
|
e.startSide,
|
|
472
474
|
e.endSide,
|
|
473
475
|
e.name,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
+
W(e.loc, "x"),
|
|
477
|
+
W(e.loc, "z"),
|
|
476
478
|
e.points[0].x,
|
|
477
479
|
e.points[0].z,
|
|
478
480
|
e.points[1].x,
|
|
@@ -481,57 +483,57 @@ function ut({ flattenToFloor: e, grids: t, showBottom: n, showLeft: r, showRight
|
|
|
481
483
|
c.has(t) || c.set(t, e);
|
|
482
484
|
}), Array.from(c.values());
|
|
483
485
|
}
|
|
484
|
-
function
|
|
485
|
-
return new
|
|
486
|
+
function ft(e, t) {
|
|
487
|
+
return new B(...st(e.loc, t));
|
|
486
488
|
}
|
|
487
|
-
function
|
|
489
|
+
function pt({ cameraPosition: e, floorY: t, line: n, showBottom: r, showLeft: i, showRight: a, showTop: o }) {
|
|
488
490
|
let s = {
|
|
489
491
|
bottom: r,
|
|
490
492
|
left: i,
|
|
491
493
|
right: a,
|
|
492
494
|
top: o
|
|
493
|
-
}, c =
|
|
495
|
+
}, 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
496
|
return p(d) ? d : p(f) ? f : null;
|
|
495
497
|
}
|
|
496
|
-
function
|
|
498
|
+
function mt({ endpoint: e, labelOffset: t, line: n }) {
|
|
497
499
|
let r = e === "start" ? n.points[0].clone() : n.points[1].clone(), i = n.points[1].clone().sub(n.points[0]);
|
|
498
500
|
return i.y = 0, i.lengthSq() === 0 && i.set(1, 0, 0), i.normalize().multiplyScalar(t), e === "start" && i.negate(), r.add(i);
|
|
499
501
|
}
|
|
500
|
-
function
|
|
501
|
-
let n = new
|
|
502
|
+
function ht(e, t) {
|
|
503
|
+
let n = new B(), r = 0;
|
|
502
504
|
return e.forEach((e) => {
|
|
503
|
-
let i =
|
|
505
|
+
let i = ft(e, t);
|
|
504
506
|
e.points.forEach((e) => {
|
|
505
507
|
n.add(e).add(i), r++;
|
|
506
508
|
});
|
|
507
509
|
}), r && n.divideScalar(r), n;
|
|
508
510
|
}
|
|
509
|
-
function
|
|
511
|
+
function gt(e, t, n) {
|
|
510
512
|
let r = 0;
|
|
511
513
|
return e.forEach((e) => {
|
|
512
|
-
let i =
|
|
514
|
+
let i = ft(e, n);
|
|
513
515
|
e.points.forEach((e) => {
|
|
514
516
|
r = Math.max(r, e.clone().add(i).distanceTo(t));
|
|
515
517
|
});
|
|
516
518
|
}), r;
|
|
517
519
|
}
|
|
518
|
-
function
|
|
519
|
-
let { camera: i, size: a } = p(), s = l(null), c =
|
|
520
|
+
function _t({ color: e, fontSize: t, position: n, text: r }) {
|
|
521
|
+
let { camera: i, size: a } = p(), s = l(null), c = rt(r, e, t);
|
|
520
522
|
return o(() => {
|
|
521
523
|
let e = s.current;
|
|
522
|
-
e &&
|
|
524
|
+
e && it(e, c, i, a.height);
|
|
523
525
|
}, [
|
|
524
526
|
i,
|
|
525
527
|
a.height,
|
|
526
528
|
c
|
|
527
529
|
]), f(({ camera: e, size: t }) => {
|
|
528
530
|
let n = s.current;
|
|
529
|
-
n &&
|
|
530
|
-
}), /* @__PURE__ */
|
|
531
|
+
n && it(n, c, e, t.height);
|
|
532
|
+
}), /* @__PURE__ */ V("sprite", {
|
|
531
533
|
ref: s,
|
|
532
534
|
position: n,
|
|
533
535
|
renderOrder: 2,
|
|
534
|
-
children: /* @__PURE__ */
|
|
536
|
+
children: /* @__PURE__ */ V("spriteMaterial", {
|
|
535
537
|
alphaTest: .1,
|
|
536
538
|
depthTest: !0,
|
|
537
539
|
depthWrite: !1,
|
|
@@ -542,8 +544,8 @@ function gt({ color: e, fontSize: t, position: n, text: r }) {
|
|
|
542
544
|
})
|
|
543
545
|
});
|
|
544
546
|
}
|
|
545
|
-
function
|
|
546
|
-
let f = c(() => new y().setFromPoints(a.points), [a.points]), p =
|
|
547
|
+
function vt({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset: i, line: a, showBottom: s, showLeft: l, showRight: u, showTop: d }) {
|
|
548
|
+
let f = c(() => new y().setFromPoints(a.points), [a.points]), p = pt({
|
|
547
549
|
cameraPosition: e,
|
|
548
550
|
floorY: n,
|
|
549
551
|
line: a,
|
|
@@ -551,19 +553,19 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
|
|
|
551
553
|
showLeft: l,
|
|
552
554
|
showRight: u,
|
|
553
555
|
showTop: d
|
|
554
|
-
}), m = p ?
|
|
556
|
+
}), m = p ? mt({
|
|
555
557
|
endpoint: p,
|
|
556
558
|
labelOffset: i,
|
|
557
559
|
line: a
|
|
558
560
|
}) : null;
|
|
559
|
-
return o(() => () => f.dispose(), [f]), /* @__PURE__ */
|
|
561
|
+
return o(() => () => f.dispose(), [f]), /* @__PURE__ */ H("lineSegments", {
|
|
560
562
|
geometry: f,
|
|
561
|
-
position:
|
|
562
|
-
children: [/* @__PURE__ */
|
|
563
|
+
position: st(a.loc, n),
|
|
564
|
+
children: [/* @__PURE__ */ V("lineBasicMaterial", {
|
|
563
565
|
color: t,
|
|
564
566
|
depthWrite: !1,
|
|
565
567
|
linewidth: 2
|
|
566
|
-
}), m && /* @__PURE__ */
|
|
568
|
+
}), m && /* @__PURE__ */ V(_t, {
|
|
567
569
|
color: t,
|
|
568
570
|
fontSize: r,
|
|
569
571
|
position: m,
|
|
@@ -571,8 +573,8 @@ function _t({ cameraPosition: e, color: t, floorY: n, fontSize: r, labelOffset:
|
|
|
571
573
|
})]
|
|
572
574
|
});
|
|
573
575
|
}
|
|
574
|
-
function
|
|
575
|
-
let h = p((e) => e.camera), g = l(null), [_, v] = u(() => new
|
|
576
|
+
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 }) {
|
|
577
|
+
let h = p((e) => e.camera), g = l(null), [_, v] = u(() => new B()), y = lt(e), b = c(() => r ? dt({
|
|
576
578
|
flattenToFloor: t !== void 0,
|
|
577
579
|
grids: r,
|
|
578
580
|
showBottom: a,
|
|
@@ -586,7 +588,7 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
|
|
|
586
588
|
o,
|
|
587
589
|
s,
|
|
588
590
|
d
|
|
589
|
-
]), x = c(() =>
|
|
591
|
+
]), x = c(() => ht(b, t), [t, b]), S = c(() => Math.max(i, gt(b, x, t) * .015), [
|
|
590
592
|
x,
|
|
591
593
|
t,
|
|
592
594
|
i,
|
|
@@ -596,11 +598,11 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
|
|
|
596
598
|
let e = g.current;
|
|
597
599
|
if (!e) return;
|
|
598
600
|
let t = h.position.clone();
|
|
599
|
-
e.worldToLocal(t), !(t.distanceToSquared(_) <
|
|
600
|
-
}), !m || !b.length ? null : /* @__PURE__ */
|
|
601
|
+
e.worldToLocal(t), !(t.distanceToSquared(_) < Ze) && v(t);
|
|
602
|
+
}), !m || !b.length ? null : /* @__PURE__ */ V("group", {
|
|
601
603
|
ref: g,
|
|
602
604
|
userData: { modelGrids: !0 },
|
|
603
|
-
children: b.map((e) => /* @__PURE__ */
|
|
605
|
+
children: b.map((e) => /* @__PURE__ */ V(vt, {
|
|
604
606
|
cameraPosition: _,
|
|
605
607
|
color: y,
|
|
606
608
|
floorY: t,
|
|
@@ -615,9 +617,9 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
|
|
|
615
617
|
e.startSide,
|
|
616
618
|
e.endSide,
|
|
617
619
|
e.name,
|
|
618
|
-
|
|
619
|
-
t ??
|
|
620
|
-
|
|
620
|
+
W(e.loc, "x"),
|
|
621
|
+
t ?? W(e.loc, "y"),
|
|
622
|
+
W(e.loc, "z"),
|
|
621
623
|
e.points[0].x,
|
|
622
624
|
e.points[0].y,
|
|
623
625
|
e.points[0].z,
|
|
@@ -629,33 +631,33 @@ function vt({ color: e, floorY: t, fontSize: n = qe, grids: r, labelOffset: i =
|
|
|
629
631
|
}
|
|
630
632
|
//#endregion
|
|
631
633
|
//#region src/viewer/Model.tsx
|
|
632
|
-
var
|
|
633
|
-
function
|
|
634
|
+
var bt = new N();
|
|
635
|
+
function xt(e) {
|
|
634
636
|
if (!e) return null;
|
|
635
637
|
try {
|
|
636
638
|
let t = JSON.parse(e);
|
|
637
|
-
return !Array.isArray(t) || t.length !== 16 ? null : new
|
|
639
|
+
return !Array.isArray(t) || t.length !== 16 ? null : new N().fromArray(t);
|
|
638
640
|
} catch (e) {
|
|
639
641
|
return console.warn("Model matrix parsing error", e), null;
|
|
640
642
|
}
|
|
641
643
|
}
|
|
642
|
-
function xt(e) {
|
|
643
|
-
return bt(St(e));
|
|
644
|
-
}
|
|
645
644
|
function St(e) {
|
|
645
|
+
return xt(Ct(e));
|
|
646
|
+
}
|
|
647
|
+
function Ct(e) {
|
|
646
648
|
return e.coordinationMatrix ?? Object.values(e.data)[0]?.matrix;
|
|
647
649
|
}
|
|
648
|
-
function
|
|
649
|
-
let a =
|
|
650
|
+
function wt({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r, materialMode: i }) {
|
|
651
|
+
let a = U((e) => e.gridAxesVisibility), o = c(() => {
|
|
650
652
|
if (!r) return {
|
|
651
653
|
data: [],
|
|
652
654
|
coordinationMatrix: null,
|
|
653
655
|
floorY: 0
|
|
654
656
|
};
|
|
655
|
-
let e = Object.values(r.data).some((e) => !!e.matrix) ? t?.clone() ??
|
|
657
|
+
let e = Object.values(r.data).some((e) => !!e.matrix) ? t?.clone() ?? St(r) : null, i = Infinity, a = new B();
|
|
656
658
|
return {
|
|
657
659
|
data: Object.values(r.data).map((e) => {
|
|
658
|
-
let t = (
|
|
660
|
+
let t = (xt(e.matrix) ?? new N()).clone().invert(), r = e.mat, o = e.pos;
|
|
659
661
|
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
662
|
return {
|
|
661
663
|
data: e,
|
|
@@ -673,13 +675,13 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
|
|
|
673
675
|
r,
|
|
674
676
|
n
|
|
675
677
|
]);
|
|
676
|
-
if (!r) return /* @__PURE__ */
|
|
678
|
+
if (!r) return /* @__PURE__ */ V(Ce, {});
|
|
677
679
|
let s = i ?? r.renderSettings?.materialMode ?? "quality", l = r.renderSettings?.useDoubleSideMaterial === !0;
|
|
678
|
-
return /* @__PURE__ */
|
|
679
|
-
matrix: o.coordinationMatrix ??
|
|
680
|
+
return /* @__PURE__ */ H("group", {
|
|
681
|
+
matrix: o.coordinationMatrix ?? bt,
|
|
680
682
|
matrixAutoUpdate: !1,
|
|
681
683
|
userData: { modelID: n },
|
|
682
|
-
children: [o.data.map(({ data: t, isIfcSpace: n, key: r, material: i, meshMatrix: a }) => /* @__PURE__ */
|
|
684
|
+
children: [o.data.map(({ data: t, isIfcSpace: n, key: r, material: i, meshMatrix: a }) => /* @__PURE__ */ V(qe, {
|
|
683
685
|
colorPaletteTexture: e,
|
|
684
686
|
material: i,
|
|
685
687
|
materialMode: s,
|
|
@@ -687,7 +689,7 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
|
|
|
687
689
|
isIfcSpace: n,
|
|
688
690
|
meshMatrix: a,
|
|
689
691
|
useDoubleSideMaterial: l
|
|
690
|
-
}, r)), /* @__PURE__ */
|
|
692
|
+
}, r)), /* @__PURE__ */ V(yt, {
|
|
691
693
|
floorY: o.floorY,
|
|
692
694
|
grids: r.grids,
|
|
693
695
|
showBottom: a.bottom,
|
|
@@ -698,10 +700,10 @@ function Ct({ colorPaletteTexture: e, coordinationMatrix: t, modelID: n, data: r
|
|
|
698
700
|
})]
|
|
699
701
|
});
|
|
700
702
|
}
|
|
701
|
-
var
|
|
703
|
+
var Tt = r(wt);
|
|
702
704
|
//#endregion
|
|
703
705
|
//#region src/viewer/utils/GeometryUtils/useGeometryIndex.ts
|
|
704
|
-
function
|
|
706
|
+
function Et() {
|
|
705
707
|
return {
|
|
706
708
|
elementIndex: /* @__PURE__ */ new Map(),
|
|
707
709
|
ifcSpacesVisible: !1,
|
|
@@ -711,10 +713,10 @@ function Tt() {
|
|
|
711
713
|
records: /* @__PURE__ */ new Set()
|
|
712
714
|
};
|
|
713
715
|
}
|
|
714
|
-
function
|
|
716
|
+
function Dt(e) {
|
|
715
717
|
return e instanceof Uint16Array || e instanceof Uint32Array ? e : e.length > 65535 ? new Uint32Array(e) : new Uint16Array(e);
|
|
716
718
|
}
|
|
717
|
-
function
|
|
719
|
+
function Ot(e, t, n, r) {
|
|
718
720
|
let i = n.get(e);
|
|
719
721
|
if (i) return i;
|
|
720
722
|
i = {
|
|
@@ -724,20 +726,20 @@ function Dt(e, t, n, r) {
|
|
|
724
726
|
let a = r.get(e);
|
|
725
727
|
return a || (a = [], r.set(e, a)), a.push(i), i;
|
|
726
728
|
}
|
|
727
|
-
function
|
|
728
|
-
n &&
|
|
729
|
+
function kt(e, t, n, r, i, a) {
|
|
730
|
+
n && Ot(e, r, i, a).vertexRanges.push({
|
|
729
731
|
count: n,
|
|
730
732
|
start: t
|
|
731
733
|
});
|
|
732
734
|
}
|
|
733
|
-
function
|
|
734
|
-
n && (
|
|
735
|
+
function At(e, t, n, r, i, a) {
|
|
736
|
+
n && (Ot(e, r, i, a), r.triangleRanges.push({
|
|
735
737
|
count: n,
|
|
736
738
|
id: e,
|
|
737
739
|
start: t
|
|
738
740
|
}));
|
|
739
741
|
}
|
|
740
|
-
function
|
|
742
|
+
function jt(e) {
|
|
741
743
|
let t = e;
|
|
742
744
|
for (; t;) {
|
|
743
745
|
let e = t.userData.modelID;
|
|
@@ -746,19 +748,19 @@ function At(e) {
|
|
|
746
748
|
}
|
|
747
749
|
return 0;
|
|
748
750
|
}
|
|
749
|
-
function
|
|
751
|
+
function Mt(e) {
|
|
750
752
|
return e.name === "space" || e.userData.isIfcSpace === !0;
|
|
751
753
|
}
|
|
752
|
-
function
|
|
753
|
-
let t = l(
|
|
754
|
+
function Nt(e) {
|
|
755
|
+
let t = l(Et()), n = i(() => {
|
|
754
756
|
let n = e.current, r = t.current;
|
|
755
757
|
if (!n || r.indexedModel === n && r.records.size) return r;
|
|
756
758
|
let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
|
|
757
759
|
return n.traverse((e) => {
|
|
758
|
-
if (!(e instanceof
|
|
760
|
+
if (!(e instanceof P)) return;
|
|
759
761
|
let t = e, n = t.geometry, o = n.index, s = n.attributes.ids;
|
|
760
762
|
if (!o || !s) return;
|
|
761
|
-
let c =
|
|
763
|
+
let c = jt(t), l = Mt(t), u = Dt(o.array), d = {
|
|
762
764
|
hiddenIds: /* @__PURE__ */ new Set(),
|
|
763
765
|
initialVisible: t.visible,
|
|
764
766
|
isIfcSpace: l,
|
|
@@ -771,15 +773,15 @@ function Mt(e) {
|
|
|
771
773
|
}, f = /* @__PURE__ */ new Map(), p = null, m = 0, h = u.length / 3;
|
|
772
774
|
for (let e = 0; e < h; e++) {
|
|
773
775
|
let t = s.getX(u[e * 3]);
|
|
774
|
-
p === null ? (p = t, m = e) : t !== p && (
|
|
776
|
+
p === null ? (p = t, m = e) : t !== p && (At(p, m, e - m, d, f, i), p = t, m = e);
|
|
775
777
|
}
|
|
776
|
-
p !== null &&
|
|
778
|
+
p !== null && At(p, m, h - m, d, f, i);
|
|
777
779
|
let g = null, _ = 0;
|
|
778
780
|
for (let e = 0; e < s.count; e++) {
|
|
779
781
|
let t = s.getX(e);
|
|
780
|
-
g === null ? (g = t, _ = e) : t !== g && (
|
|
782
|
+
g === null ? (g = t, _ = e) : t !== g && (kt(g, _, e - _, d, f, i), g = t, _ = e);
|
|
781
783
|
}
|
|
782
|
-
g !== null &&
|
|
784
|
+
g !== null && kt(g, _, s.count - _, d, f, i), a.add(d), l && !r.ifcSpacesVisible && (t.visible = !1);
|
|
783
785
|
}), t.current = {
|
|
784
786
|
elementIndex: i,
|
|
785
787
|
ifcSpacesVisible: r.ifcSpacesVisible,
|
|
@@ -789,7 +791,7 @@ function Mt(e) {
|
|
|
789
791
|
records: a
|
|
790
792
|
}, t.current;
|
|
791
793
|
}, [e]), r = i(() => {
|
|
792
|
-
t.current =
|
|
794
|
+
t.current = Et();
|
|
793
795
|
}, []);
|
|
794
796
|
return c(() => ({
|
|
795
797
|
buildIndex: n,
|
|
@@ -798,95 +800,95 @@ function Mt(e) {
|
|
|
798
800
|
}
|
|
799
801
|
//#endregion
|
|
800
802
|
//#region src/viewer/utils/GeometryUtils/useGeometryUtils.ts
|
|
801
|
-
function
|
|
803
|
+
function Pt(e, t) {
|
|
802
804
|
return e instanceof Uint32Array ? new Uint32Array(t) : new Uint16Array(t);
|
|
803
805
|
}
|
|
804
|
-
function
|
|
806
|
+
function Ft(e) {
|
|
805
807
|
let t = e.geometry;
|
|
806
808
|
Object.assign(t, { boundsTree: void 0 }), e.geometry.index?.count && Object.assign(t, { boundsTree: new be(e.geometry, { indirect: !0 }) });
|
|
807
809
|
}
|
|
808
|
-
function
|
|
809
|
-
e.mesh.geometry.setIndex(new v(t, 1)), n &&
|
|
810
|
+
function It(e, t, n = !0) {
|
|
811
|
+
e.mesh.geometry.setIndex(new v(t, 1)), n && Ft(e.mesh);
|
|
810
812
|
}
|
|
811
|
-
function
|
|
813
|
+
function Lt(e, t) {
|
|
812
814
|
return e.initialVisible && (!e.isIfcSpace || t);
|
|
813
815
|
}
|
|
814
|
-
function
|
|
816
|
+
function Rt(e, t) {
|
|
815
817
|
let n = e.mesh.geometry, r = n.index?.array;
|
|
816
|
-
e.mesh.visible =
|
|
818
|
+
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
819
|
}
|
|
818
|
-
function
|
|
820
|
+
function zt(e) {
|
|
819
821
|
return e === null ? "*" : e.size ? Array.from(e).sort((e, t) => e - t).join(",") : "";
|
|
820
822
|
}
|
|
821
|
-
function
|
|
822
|
-
return `h:${
|
|
823
|
+
function Bt(e, t, n, r) {
|
|
824
|
+
return `h:${zt(e)}|i:${zt(n)}|s:${r ? Number(t) : ""}`;
|
|
823
825
|
}
|
|
824
|
-
function
|
|
826
|
+
function Vt(e, t, n) {
|
|
825
827
|
return !t.has(e) && (!n || n.has(e));
|
|
826
828
|
}
|
|
827
|
-
function
|
|
829
|
+
function Ht(e, t) {
|
|
828
830
|
Object.entries(e).forEach(([e, n]) => {
|
|
829
831
|
n.forEach((n) => t(Number(e), n));
|
|
830
832
|
});
|
|
831
833
|
}
|
|
832
|
-
function
|
|
834
|
+
function Ut(e, t, n) {
|
|
833
835
|
e.hiddenIds.has(t) || (e.hiddenIds.add(t), n.add(e));
|
|
834
836
|
}
|
|
835
|
-
function
|
|
837
|
+
function Wt(e, t, n) {
|
|
836
838
|
e && console.log(`${t}:`, Date.now() - n, "ms");
|
|
837
839
|
}
|
|
838
|
-
function
|
|
839
|
-
let { hiddenIds: i, originalIndex: a, triangleRanges: o } = e, s =
|
|
840
|
+
function G(e, t, n, r) {
|
|
841
|
+
let { hiddenIds: i, originalIndex: a, triangleRanges: o } = e, s = Bt(i, t, n, e.isIfcSpace);
|
|
840
842
|
if (e.visibleStateKey === s) return;
|
|
841
843
|
if (!i.size && !n) {
|
|
842
|
-
|
|
844
|
+
Rt(e, t), e.visibleStateKey = s;
|
|
843
845
|
return;
|
|
844
846
|
}
|
|
845
847
|
let c = 0, l = 0;
|
|
846
848
|
if (o.forEach(({ count: e, id: t }) => {
|
|
847
|
-
|
|
849
|
+
Vt(t, i, n) ? c += e * 3 : l += e * 3;
|
|
848
850
|
}), !c) {
|
|
849
|
-
|
|
851
|
+
Rt(e, t), e.mesh.visible = !1, e.visibleStateKey = s;
|
|
850
852
|
return;
|
|
851
853
|
}
|
|
852
854
|
if (!l) {
|
|
853
|
-
|
|
855
|
+
Rt(e, t), e.visibleStateKey = s;
|
|
854
856
|
return;
|
|
855
857
|
}
|
|
856
|
-
e.mesh.visible =
|
|
857
|
-
let u =
|
|
858
|
+
e.mesh.visible = Lt(e, t);
|
|
859
|
+
let u = Pt(a, c), d = 0;
|
|
858
860
|
for (let e = 0; e < o.length; e++) {
|
|
859
861
|
let { count: t, id: r, start: s } = o[e];
|
|
860
|
-
if (!
|
|
862
|
+
if (!Vt(r, i, n)) continue;
|
|
861
863
|
let c = s * 3, l = c + t * 3;
|
|
862
864
|
u.set(a.subarray(c, l), d), d += t * 3;
|
|
863
865
|
}
|
|
864
|
-
r || (e.originalBoundsTree = null),
|
|
866
|
+
r || (e.originalBoundsTree = null), It(e, u), e.visibleStateKey = s;
|
|
865
867
|
}
|
|
866
|
-
function
|
|
868
|
+
function K(e, t) {
|
|
867
869
|
return e.isolatedIdsByModel ? e.isolatedIdsByModel.get(t.modelID) ?? /* @__PURE__ */ new Set() : e.isolatedIds;
|
|
868
870
|
}
|
|
869
|
-
function
|
|
870
|
-
let t =
|
|
871
|
+
function Gt(e) {
|
|
872
|
+
let t = U((e) => e.selected), n = U((e) => e.resetSelected), r = U((e) => e.showStats), a = U((e) => e.userDevice) === "pc", o = e.buildIndex, s = i(() => Array.from(o().elementIndex.keys()), [o]), c = i(() => o().ifcSpacesVisible, [o]), l = i((e) => {
|
|
871
873
|
let t = Date.now(), n = o(), i = /* @__PURE__ */ new Set();
|
|
872
874
|
e.forEach((e) => {
|
|
873
875
|
let t = n.elementIndex.get(e);
|
|
874
876
|
t && t.forEach(({ record: t }) => {
|
|
875
|
-
|
|
877
|
+
Ut(t, e, i);
|
|
876
878
|
});
|
|
877
|
-
}), i.forEach((e) =>
|
|
879
|
+
}), i.forEach((e) => G(e, n.ifcSpacesVisible, K(n, e), a)), Wt(r, "hideByIds", t);
|
|
878
880
|
}, [
|
|
879
881
|
o,
|
|
880
882
|
a,
|
|
881
883
|
r
|
|
882
884
|
]), u = i(() => {
|
|
883
885
|
let e = Date.now(), i = o(), s = /* @__PURE__ */ new Set();
|
|
884
|
-
|
|
886
|
+
Ht(t, (e, t) => {
|
|
885
887
|
let n = i.elementIndex.get(t);
|
|
886
888
|
n && n.forEach(({ record: n }) => {
|
|
887
|
-
n.modelID === e &&
|
|
889
|
+
n.modelID === e && Ut(n, t, s);
|
|
888
890
|
});
|
|
889
|
-
}), s.forEach((e) =>
|
|
891
|
+
}), s.forEach((e) => G(e, i.ifcSpacesVisible, K(i, e), a)), n(), Wt(r, "hideSelected", e);
|
|
890
892
|
}, [
|
|
891
893
|
o,
|
|
892
894
|
a,
|
|
@@ -900,24 +902,24 @@ function Wt(e) {
|
|
|
900
902
|
t && t.forEach(({ record: t }) => {
|
|
901
903
|
t.hiddenIds.delete(e) && i.add(t);
|
|
902
904
|
});
|
|
903
|
-
}), i.forEach((e) =>
|
|
905
|
+
}), i.forEach((e) => G(e, n.ifcSpacesVisible, K(n, e), a)), Wt(r, "showByIds", t);
|
|
904
906
|
}, [
|
|
905
907
|
o,
|
|
906
908
|
a,
|
|
907
909
|
r
|
|
908
910
|
]), f = i((e) => {
|
|
909
911
|
let t = Date.now(), n = o();
|
|
910
|
-
n.isolatedIdsByModel = null, n.isolatedIds = new Set(e), n.records.forEach((e) =>
|
|
912
|
+
n.isolatedIdsByModel = null, n.isolatedIds = new Set(e), n.records.forEach((e) => G(e, n.ifcSpacesVisible, K(n, e), a)), Wt(r, "isolateByIds", t);
|
|
911
913
|
}, [
|
|
912
914
|
o,
|
|
913
915
|
a,
|
|
914
916
|
r
|
|
915
917
|
]), p = i(() => {
|
|
916
918
|
let e = Date.now(), n = o(), i = /* @__PURE__ */ new Map();
|
|
917
|
-
|
|
919
|
+
Ht(t, (e, t) => {
|
|
918
920
|
let n = i.get(e);
|
|
919
921
|
n || (n = /* @__PURE__ */ new Set(), i.set(e, n)), n.add(t);
|
|
920
|
-
}), n.isolatedIdsByModel = i, n.isolatedIds = null, n.records.forEach((e) =>
|
|
922
|
+
}), n.isolatedIdsByModel = i, n.isolatedIds = null, n.records.forEach((e) => G(e, n.ifcSpacesVisible, K(n, e), a)), Wt(r, "isolateSelected", e);
|
|
921
923
|
}, [
|
|
922
924
|
o,
|
|
923
925
|
a,
|
|
@@ -925,7 +927,7 @@ function Wt(e) {
|
|
|
925
927
|
r
|
|
926
928
|
]), m = i(() => {
|
|
927
929
|
let e = Date.now(), t = o();
|
|
928
|
-
t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) =>
|
|
930
|
+
t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => G(e, t.ifcSpacesVisible, K(t, e), a)), Wt(r, "resetIsolation", e);
|
|
929
931
|
}, [
|
|
930
932
|
o,
|
|
931
933
|
a,
|
|
@@ -933,7 +935,7 @@ function Wt(e) {
|
|
|
933
935
|
]), h = i((e) => {
|
|
934
936
|
let t = o();
|
|
935
937
|
t.ifcSpacesVisible !== e && (t.ifcSpacesVisible = e, t.records.forEach((e) => {
|
|
936
|
-
e.isIfcSpace &&
|
|
938
|
+
e.isIfcSpace && G(e, t.ifcSpacesVisible, K(t, e), a);
|
|
937
939
|
}));
|
|
938
940
|
}, [o, a]), g = i(() => {
|
|
939
941
|
h(!c());
|
|
@@ -951,8 +953,8 @@ function Wt(e) {
|
|
|
951
953
|
showAll: i(() => {
|
|
952
954
|
let e = Date.now(), t = o();
|
|
953
955
|
t.isolatedIdsByModel = null, t.isolatedIds = null, t.records.forEach((e) => {
|
|
954
|
-
e.hiddenIds.clear(),
|
|
955
|
-
}),
|
|
956
|
+
e.hiddenIds.clear(), G(e, t.ifcSpacesVisible, K(t, e), a);
|
|
957
|
+
}), Wt(r, "showAll", e);
|
|
956
958
|
}, [
|
|
957
959
|
o,
|
|
958
960
|
a,
|
|
@@ -964,11 +966,11 @@ function Wt(e) {
|
|
|
964
966
|
}
|
|
965
967
|
//#endregion
|
|
966
968
|
//#region src/viewer/utils/ClippingUtils/ClippingCaps.ts
|
|
967
|
-
var
|
|
968
|
-
function
|
|
969
|
+
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;
|
|
970
|
+
function on(e) {
|
|
969
971
|
return !(!e.parent || !e.visible || !e.geometry.index?.count);
|
|
970
972
|
}
|
|
971
|
-
function
|
|
973
|
+
function sn(e) {
|
|
972
974
|
let t = e;
|
|
973
975
|
for (; t;) {
|
|
974
976
|
let e = t.userData.modelID;
|
|
@@ -977,21 +979,35 @@ function an(e) {
|
|
|
977
979
|
}
|
|
978
980
|
return 0;
|
|
979
981
|
}
|
|
980
|
-
function
|
|
981
|
-
let t =
|
|
982
|
+
function cn(e) {
|
|
983
|
+
let t = e;
|
|
984
|
+
for (; t;) {
|
|
985
|
+
if (typeof t.userData.modelID == "number") return t;
|
|
986
|
+
t = t.parent;
|
|
987
|
+
}
|
|
988
|
+
return e;
|
|
989
|
+
}
|
|
990
|
+
function ln(e) {
|
|
991
|
+
return Math.abs(e.normal.y) < .9 ? new B(0, 1, 0) : new B(1, 0, 0);
|
|
992
|
+
}
|
|
993
|
+
function un(e, t) {
|
|
994
|
+
return e.clone().addScaledVector(t.normal, -e.dot(t.normal));
|
|
995
|
+
}
|
|
996
|
+
function dn(e, t) {
|
|
997
|
+
let n = t ? un(t, e) : new B(), r = n.lengthSq() > an ? n.normalize() : ln(e).cross(e.normal).normalize(), i = e.normal.clone().cross(r).normalize();
|
|
982
998
|
return {
|
|
983
|
-
origin: e.coplanarPoint(new
|
|
984
|
-
u:
|
|
985
|
-
v:
|
|
999
|
+
origin: e.coplanarPoint(new B()),
|
|
1000
|
+
u: r,
|
|
1001
|
+
v: i
|
|
986
1002
|
};
|
|
987
1003
|
}
|
|
988
|
-
function
|
|
1004
|
+
function fn(e, t) {
|
|
989
1005
|
return `${Math.round(e.x / t)}:${Math.round(e.y / t)}`;
|
|
990
1006
|
}
|
|
991
|
-
function
|
|
1007
|
+
function pn(e, t) {
|
|
992
1008
|
return e < t ? `${e}|${t}` : `${t}|${e}`;
|
|
993
1009
|
}
|
|
994
|
-
function
|
|
1010
|
+
function mn(e) {
|
|
995
1011
|
let t = 0;
|
|
996
1012
|
for (let n = 0; n < e.length; n++) {
|
|
997
1013
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -999,23 +1015,23 @@ function ln(e) {
|
|
|
999
1015
|
}
|
|
1000
1016
|
return t * .5;
|
|
1001
1017
|
}
|
|
1002
|
-
function
|
|
1003
|
-
let
|
|
1004
|
-
|
|
1005
|
-
let
|
|
1006
|
-
if (
|
|
1007
|
-
|
|
1008
|
-
for (let
|
|
1009
|
-
-
|
|
1018
|
+
function hn(e) {
|
|
1019
|
+
let t = nn, n = document.createElement("canvas");
|
|
1020
|
+
n.width = t, n.height = t;
|
|
1021
|
+
let r = n.getContext("2d");
|
|
1022
|
+
if (r) {
|
|
1023
|
+
r.fillStyle = Kt, r.fillRect(0, 0, t, t), r.strokeStyle = qt, r.lineWidth = rn, r.lineCap = "square", r.beginPath();
|
|
1024
|
+
for (let e of [
|
|
1025
|
+
-t,
|
|
1010
1026
|
0,
|
|
1011
|
-
|
|
1012
|
-
])
|
|
1013
|
-
|
|
1027
|
+
t
|
|
1028
|
+
]) r.moveTo(e, t), r.lineTo(e + t, 0);
|
|
1029
|
+
r.stroke();
|
|
1014
1030
|
}
|
|
1015
|
-
let
|
|
1016
|
-
return
|
|
1031
|
+
let i = new b(n);
|
|
1032
|
+
return i.anisotropy = Math.max(1, e), i.magFilter = A, i.minFilter = j, i.wrapS = ce, i.wrapT = ce, i.needsUpdate = !0, i;
|
|
1017
1033
|
}
|
|
1018
|
-
var
|
|
1034
|
+
var gn = class {
|
|
1019
1035
|
active;
|
|
1020
1036
|
plane;
|
|
1021
1037
|
capMaterial;
|
|
@@ -1025,20 +1041,23 @@ var dn = class {
|
|
|
1025
1041
|
root = new D();
|
|
1026
1042
|
box = new g();
|
|
1027
1043
|
meshBox = new g();
|
|
1028
|
-
inverseMatrix = new
|
|
1029
|
-
localPlane = new
|
|
1044
|
+
inverseMatrix = new N();
|
|
1045
|
+
localPlane = new I();
|
|
1030
1046
|
tempLine = new ee();
|
|
1031
|
-
tempVector = new
|
|
1032
|
-
tempVector1 = new
|
|
1033
|
-
|
|
1047
|
+
tempVector = new B();
|
|
1048
|
+
tempVector1 = new B();
|
|
1049
|
+
tempAxisX = new B();
|
|
1050
|
+
tempAxisY = new B();
|
|
1051
|
+
tempAxisZ = new B();
|
|
1052
|
+
worldPoint = new B();
|
|
1034
1053
|
capClippingPlanesKey = "";
|
|
1035
1054
|
capShader = null;
|
|
1036
|
-
closeGapTolerance =
|
|
1055
|
+
closeGapTolerance = Jt;
|
|
1037
1056
|
preselection = null;
|
|
1038
|
-
tolerance =
|
|
1057
|
+
tolerance = Jt;
|
|
1039
1058
|
constructor(e, t) {
|
|
1040
|
-
this.context = e, this.plane = t, this.active = e.getActive() && e.getCapsActive(), this.capTexture =
|
|
1041
|
-
color:
|
|
1059
|
+
this.context = e, this.plane = t, this.active = e.getActive() && e.getCapsActive(), this.capTexture = hn(e.getMaxTextureAnisotropy()), this.capMaterial = new F({
|
|
1060
|
+
color: Kt,
|
|
1042
1061
|
depthWrite: !1,
|
|
1043
1062
|
map: this.capTexture,
|
|
1044
1063
|
side: w
|
|
@@ -1046,7 +1065,7 @@ var dn = class {
|
|
|
1046
1065
|
colorIndex: [0],
|
|
1047
1066
|
ids: [0],
|
|
1048
1067
|
modelID: [0]
|
|
1049
|
-
}, this.capMaterial.color.convertSRGBToLinear(), this.setupCapMaterialShader(), this.capMesh = new
|
|
1068
|
+
}, 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
1069
|
}
|
|
1051
1070
|
dispose() {
|
|
1052
1071
|
this.root.removeFromParent(), this.capMesh.geometry.dispose(), this.capTexture.dispose(), this.capMaterial.dispose();
|
|
@@ -1105,22 +1124,34 @@ var dn = class {
|
|
|
1105
1124
|
createCapGeometry() {
|
|
1106
1125
|
let e = new y(), t = this.getModelWorldBox();
|
|
1107
1126
|
if (!t) return e;
|
|
1108
|
-
let n = t.getSize(new
|
|
1109
|
-
this.tolerance = Math.max(
|
|
1110
|
-
let r =
|
|
1111
|
-
if (e.setAttribute("position", new E(
|
|
1112
|
-
let t = new Uint32Array(
|
|
1127
|
+
let n = t.getSize(new B()).length();
|
|
1128
|
+
this.tolerance = Math.max(Jt, n * Yt), this.closeGapTolerance = Math.max(this.tolerance * Zt, n * Xt);
|
|
1129
|
+
let r = dn(this.plane, this.getModelHatchReferenceDirection()), i = this.context.getEdgeSegmentsForPlane(this.plane), a = i ? this.getCapSegmentsFromEdgeSegments(i, r) : this.getCapSegments(r), o = this.getClosedContours(a), s = this.getHatchSpacing(n), { elementIDs: c, modelIDs: l, positions: u, uvs: d } = this.triangulateContours(o, r, s);
|
|
1130
|
+
if (e.setAttribute("position", new E(u, 3)), e.setAttribute("uv", new E(d, 2)), e.setAttribute("ids", new me(c, 1)), e.setAttribute("modelID", new me(l, 1)), e.setAttribute("colorIndex", new v(new Uint8Array(c.length), 1)), c.length) {
|
|
1131
|
+
let t = new Uint32Array(c.length);
|
|
1113
1132
|
for (let e = 0; e < t.length; e++) t[e] = e;
|
|
1114
1133
|
e.setIndex(new me(t, 1));
|
|
1115
1134
|
}
|
|
1116
|
-
return
|
|
1135
|
+
return u.length && (e.computeVertexNormals(), e.computeBoundingSphere()), e;
|
|
1136
|
+
}
|
|
1137
|
+
getCapSegmentsFromEdgeSegments(e, t) {
|
|
1138
|
+
let n = [];
|
|
1139
|
+
return e.forEach((e) => {
|
|
1140
|
+
let r = this.getPlanePoint(this.tempVector.set(e.ax, e.ay, e.az), t), i = this.getPlanePoint(this.tempVector.set(e.bx, e.by, e.bz), t);
|
|
1141
|
+
r.distanceToSquared(i) <= this.tolerance ** 2 || n.push({
|
|
1142
|
+
a: r,
|
|
1143
|
+
b: i,
|
|
1144
|
+
elementID: e.elementID,
|
|
1145
|
+
modelID: e.modelID
|
|
1146
|
+
});
|
|
1147
|
+
}), n;
|
|
1117
1148
|
}
|
|
1118
1149
|
getCapSegments(e) {
|
|
1119
1150
|
let t = [];
|
|
1120
|
-
return this.context.getMeshes().filter(
|
|
1151
|
+
return this.context.getMeshes().filter(on).forEach((n) => {
|
|
1121
1152
|
let r = n.geometry.boundsTree;
|
|
1122
1153
|
if (!r) return;
|
|
1123
|
-
let i =
|
|
1154
|
+
let i = sn(n);
|
|
1124
1155
|
n.updateWorldMatrix(!0, !1), this.inverseMatrix.copy(n.matrixWorld).invert(), this.localPlane.copy(this.plane).applyMatrix4(this.inverseMatrix), r.shapecast({
|
|
1125
1156
|
intersectsBounds: (e) => this.localPlane.intersectsBox(e),
|
|
1126
1157
|
intersectsTriangle: (r, a) => {
|
|
@@ -1152,7 +1183,7 @@ var dn = class {
|
|
|
1152
1183
|
return this.tempLine.start.copy(e.a), this.tempLine.end.copy(e.b), n(this.localPlane.intersectLine(this.tempLine, this.tempVector)), this.tempLine.start.copy(e.b), this.tempLine.end.copy(e.c), n(this.localPlane.intersectLine(this.tempLine, this.tempVector)), this.tempLine.start.copy(e.c), this.tempLine.end.copy(e.a), n(this.localPlane.intersectLine(this.tempLine, this.tempVector)), t;
|
|
1153
1184
|
}
|
|
1154
1185
|
getPlanePoint(e, t) {
|
|
1155
|
-
return this.worldPoint.copy(e).sub(t.origin), new
|
|
1186
|
+
return this.worldPoint.copy(e).sub(t.origin), new z(this.worldPoint.dot(t.u), this.worldPoint.dot(t.v));
|
|
1156
1187
|
}
|
|
1157
1188
|
getClosedContours(e) {
|
|
1158
1189
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -1177,7 +1208,7 @@ var dn = class {
|
|
|
1177
1208
|
}
|
|
1178
1209
|
getElementClosedContours(e) {
|
|
1179
1210
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
1180
|
-
let n =
|
|
1211
|
+
let n = fn(e, this.tolerance), r = t.get(n);
|
|
1181
1212
|
return r || (r = {
|
|
1182
1213
|
edges: /* @__PURE__ */ new Set(),
|
|
1183
1214
|
point: e.clone()
|
|
@@ -1193,12 +1224,12 @@ var dn = class {
|
|
|
1193
1224
|
let i = [];
|
|
1194
1225
|
return t.forEach((e, r) => {
|
|
1195
1226
|
e.edges.forEach((e) => {
|
|
1196
|
-
let a =
|
|
1227
|
+
let a = pn(r, e);
|
|
1197
1228
|
if (n.has(a)) return;
|
|
1198
1229
|
let o = this.walkContour(r, e, t, n);
|
|
1199
1230
|
if (!o) return;
|
|
1200
1231
|
let s = this.cleanContour(o.contour);
|
|
1201
|
-
s.length < 3 || Math.abs(
|
|
1232
|
+
s.length < 3 || Math.abs(mn(s)) < Qt || (o.edges.forEach((e) => n.add(e)), i.push(s));
|
|
1202
1233
|
});
|
|
1203
1234
|
}), i;
|
|
1204
1235
|
}
|
|
@@ -1208,7 +1239,7 @@ var dn = class {
|
|
|
1208
1239
|
let t = n.get(s);
|
|
1209
1240
|
if (!t || !c) return null;
|
|
1210
1241
|
i.push(t.point.clone());
|
|
1211
|
-
let l =
|
|
1242
|
+
let l = pn(s, c);
|
|
1212
1243
|
a.push(l), o.add(l);
|
|
1213
1244
|
let u = s;
|
|
1214
1245
|
if (s = c, s === e) return {
|
|
@@ -1232,7 +1263,7 @@ var dn = class {
|
|
|
1232
1263
|
if (!o || !s) return null;
|
|
1233
1264
|
let c = s.point.clone().sub(o.point), l = Array.from(s.edges).filter((n) => {
|
|
1234
1265
|
if (n === e) return !1;
|
|
1235
|
-
let r =
|
|
1266
|
+
let r = pn(t, n);
|
|
1236
1267
|
return !(i.has(r) || a.has(r));
|
|
1237
1268
|
});
|
|
1238
1269
|
return l.length ? l.includes(n) ? n : l.map((e) => {
|
|
@@ -1279,49 +1310,62 @@ var dn = class {
|
|
|
1279
1310
|
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
1311
|
}
|
|
1281
1312
|
getHatchSpacing(e) {
|
|
1282
|
-
return Math.max(
|
|
1313
|
+
return Math.max(tn, e * en);
|
|
1314
|
+
}
|
|
1315
|
+
getModelHatchReferenceDirection() {
|
|
1316
|
+
let e = this.context.getMeshes().filter(on)[0];
|
|
1317
|
+
if (!e) return null;
|
|
1318
|
+
let t = cn(e);
|
|
1319
|
+
t.updateWorldMatrix(!0, !1), t.matrixWorld.extractBasis(this.tempAxisX, this.tempAxisY, this.tempAxisZ);
|
|
1320
|
+
for (let e of [
|
|
1321
|
+
this.tempAxisX,
|
|
1322
|
+
this.tempAxisZ,
|
|
1323
|
+
this.tempAxisY
|
|
1324
|
+
]) if (!(e.lengthSq() <= an) && (e.normalize(), un(e, this.plane).lengthSq() > an)) return e.clone();
|
|
1325
|
+
return null;
|
|
1283
1326
|
}
|
|
1284
1327
|
getModelWorldBox() {
|
|
1285
|
-
return this.box.makeEmpty(), this.context.getMeshes().filter(
|
|
1328
|
+
return this.box.makeEmpty(), this.context.getMeshes().filter(on).forEach((e) => {
|
|
1286
1329
|
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
1330
|
}), this.box.isEmpty() ? null : this.box;
|
|
1288
1331
|
}
|
|
1289
|
-
},
|
|
1290
|
-
function
|
|
1332
|
+
}, _n = 1024, vn = 1;
|
|
1333
|
+
function yn(e) {
|
|
1291
1334
|
let t = new v(new Float32Array(e * 3), 3, !1);
|
|
1292
1335
|
return t.setUsage(T), t;
|
|
1293
1336
|
}
|
|
1294
|
-
function
|
|
1337
|
+
function bn(e) {
|
|
1295
1338
|
return Math.max(1, Math.ceil((e.geometry.index?.count ?? 0) / 3));
|
|
1296
1339
|
}
|
|
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 =
|
|
1340
|
+
function xn(e, t) {
|
|
1341
|
+
let n = new y(), r = Math.ceil(Math.min(Math.max(_n, bn(t) * .05), 32768));
|
|
1342
|
+
n.setAttribute("position", yn(r)), n.setDrawRange(0, 0);
|
|
1343
|
+
let i = new k(n, e);
|
|
1344
|
+
return i.frustumCulled = !1, i.renderOrder = vn, i.visible = !1, i;
|
|
1302
1345
|
}
|
|
1303
|
-
function
|
|
1346
|
+
function Sn(e, t) {
|
|
1304
1347
|
let n = e.geometry.getAttribute("position");
|
|
1305
1348
|
if (n.count > t) return n;
|
|
1306
|
-
let r =
|
|
1349
|
+
let r = yn(Math.max(n.count * 2, t + 1));
|
|
1307
1350
|
return r.array.set(n.array), e.geometry.setAttribute("position", r), n = r, n;
|
|
1308
1351
|
}
|
|
1309
|
-
function
|
|
1310
|
-
return e.filter((e) => e.parent && e.geometry.index?.count);
|
|
1352
|
+
function Cn(e) {
|
|
1353
|
+
return e.filter((e) => e.parent && e.visible && e.geometry.index?.count);
|
|
1311
1354
|
}
|
|
1312
|
-
var
|
|
1355
|
+
var wn = class {
|
|
1313
1356
|
active;
|
|
1314
1357
|
material;
|
|
1315
1358
|
plane;
|
|
1316
1359
|
context;
|
|
1317
1360
|
lines = /* @__PURE__ */ new Map();
|
|
1318
|
-
inverseMatrix = new
|
|
1319
|
-
localPlane = new
|
|
1361
|
+
inverseMatrix = new N();
|
|
1362
|
+
localPlane = new I();
|
|
1320
1363
|
tempLine = new ee();
|
|
1321
|
-
tempVector = new
|
|
1322
|
-
tempVector1 = new
|
|
1323
|
-
tempVector2 = new
|
|
1324
|
-
tempVector3 = new
|
|
1364
|
+
tempVector = new B();
|
|
1365
|
+
tempVector1 = new B();
|
|
1366
|
+
tempVector2 = new B();
|
|
1367
|
+
tempVector3 = new B();
|
|
1368
|
+
intersectionSegments = [];
|
|
1325
1369
|
constructor(e, t) {
|
|
1326
1370
|
this.context = e, this.plane = t, this.active = e.getActive() && e.getEdgesActive(), e.edges.forEach((e) => {
|
|
1327
1371
|
let n = e.material.clippingPlanes ?? [];
|
|
@@ -1339,12 +1383,12 @@ var yn = class {
|
|
|
1339
1383
|
return this.syncMeshes(), Array.from(this.lines.values());
|
|
1340
1384
|
}
|
|
1341
1385
|
syncMeshes() {
|
|
1342
|
-
let e = new Set(
|
|
1386
|
+
let e = new Set(Cn(this.context.getMeshes()));
|
|
1343
1387
|
this.lines.forEach((t, n) => {
|
|
1344
1388
|
e.has(n) || (t.removeFromParent(), t.geometry.dispose(), this.lines.delete(n));
|
|
1345
1389
|
}), e.forEach((e) => {
|
|
1346
1390
|
if (this.lines.has(e)) return;
|
|
1347
|
-
let t =
|
|
1391
|
+
let t = xn(this.material, e);
|
|
1348
1392
|
e.add(t), this.lines.set(e, t);
|
|
1349
1393
|
}), this.setVisible(this.active);
|
|
1350
1394
|
}
|
|
@@ -1361,8 +1405,11 @@ var yn = class {
|
|
|
1361
1405
|
toggle() {
|
|
1362
1406
|
this.setVisible(!this.active);
|
|
1363
1407
|
}
|
|
1408
|
+
getIntersectionSegments() {
|
|
1409
|
+
return this.intersectionSegments;
|
|
1410
|
+
}
|
|
1364
1411
|
update() {
|
|
1365
|
-
this.active && (this.syncMeshes(), this.lines.forEach((e, t) => {
|
|
1412
|
+
this.active && (this.syncMeshes(), this.intersectionSegments.length = 0, this.lines.forEach((e, t) => {
|
|
1366
1413
|
let n = t.geometry.boundsTree;
|
|
1367
1414
|
if (!n) {
|
|
1368
1415
|
e.geometry.setDrawRange(0, 0);
|
|
@@ -1370,27 +1417,49 @@ var yn = class {
|
|
|
1370
1417
|
}
|
|
1371
1418
|
t.updateWorldMatrix(!0, !1), this.inverseMatrix.copy(t.matrixWorld).invert(), this.localPlane.copy(this.plane).applyMatrix4(this.inverseMatrix);
|
|
1372
1419
|
let r = 0, i = e.geometry.getAttribute("position"), a = (t) => {
|
|
1373
|
-
i =
|
|
1420
|
+
i = Sn(e, r), i.setXYZ(r, t.x, t.y, t.z), r++;
|
|
1374
1421
|
};
|
|
1375
1422
|
n.shapecast({
|
|
1376
1423
|
intersectsBounds: (e) => this.localPlane.intersectsBox(e),
|
|
1377
|
-
intersectsTriangle: (e) => {
|
|
1378
|
-
let
|
|
1379
|
-
this.tempLine.start.copy(e.a), this.tempLine.end.copy(e.b), this.localPlane.intersectLine(this.tempLine, this.tempVector) && (a(this.tempVector),
|
|
1424
|
+
intersectsTriangle: (e, n) => {
|
|
1425
|
+
let o = 0;
|
|
1426
|
+
if (this.tempLine.start.copy(e.a), this.tempLine.end.copy(e.b), this.localPlane.intersectLine(this.tempLine, this.tempVector) && (a(this.tempVector), o++), this.tempLine.start.copy(e.b), this.tempLine.end.copy(e.c), this.localPlane.intersectLine(this.tempLine, this.tempVector) && (a(this.tempVector), o++), this.tempLine.start.copy(e.c), this.tempLine.end.copy(e.a), this.localPlane.intersectLine(this.tempLine, this.tempVector) && (a(this.tempVector), o++), o === 3 && (this.tempVector1.fromBufferAttribute(i, r - 3), this.tempVector2.fromBufferAttribute(i, r - 2), this.tempVector3.fromBufferAttribute(i, r - 1), this.tempVector3.equals(this.tempVector1) || this.tempVector3.equals(this.tempVector2) ? (o--, r--) : this.tempVector1.equals(this.tempVector2) && (i.setXYZ(r - 2, this.tempVector3.x, this.tempVector3.y, this.tempVector3.z), o--, r--)), o !== 2) {
|
|
1427
|
+
r -= o;
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
let s = this.getTriangleElementID(t, n);
|
|
1431
|
+
if (s === null) return;
|
|
1432
|
+
let c = this.context.getObjectModelID(t);
|
|
1433
|
+
this.tempVector1.fromBufferAttribute(i, r - 2), this.tempVector2.fromBufferAttribute(i, r - 1), this.tempVector1.applyMatrix4(t.matrixWorld), this.tempVector2.applyMatrix4(t.matrixWorld), this.intersectionSegments.push({
|
|
1434
|
+
ax: this.tempVector1.x,
|
|
1435
|
+
ay: this.tempVector1.y,
|
|
1436
|
+
az: this.tempVector1.z,
|
|
1437
|
+
bx: this.tempVector2.x,
|
|
1438
|
+
by: this.tempVector2.y,
|
|
1439
|
+
bz: this.tempVector2.z,
|
|
1440
|
+
elementID: s,
|
|
1441
|
+
modelID: c
|
|
1442
|
+
});
|
|
1380
1443
|
}
|
|
1381
1444
|
}), e.geometry.setDrawRange(0, r), e.position.set(0, 0, 0), i.needsUpdate = !0;
|
|
1382
1445
|
}));
|
|
1383
1446
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1447
|
+
getTriangleElementID(e, t) {
|
|
1448
|
+
let n = e.geometry.index, r = e.geometry.attributes.ids, i = t * 3;
|
|
1449
|
+
if (!n || !r || i >= n.count) return null;
|
|
1450
|
+
let a = n.getX(i);
|
|
1451
|
+
return a >= r.count ? null : r.getX(a);
|
|
1452
|
+
}
|
|
1453
|
+
}, 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, q = 1;
|
|
1454
|
+
function Vn(e, t) {
|
|
1386
1455
|
let n = t.getBoundingClientRect();
|
|
1387
|
-
return new
|
|
1456
|
+
return new z((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
|
|
1388
1457
|
}
|
|
1389
|
-
function
|
|
1390
|
-
let t = e.getSize(new
|
|
1391
|
-
return Math.max(
|
|
1458
|
+
function Hn(e) {
|
|
1459
|
+
let t = e.getSize(new B());
|
|
1460
|
+
return Math.max(Ln, t.length() * An);
|
|
1392
1461
|
}
|
|
1393
|
-
var
|
|
1462
|
+
var Un = class extends ae {
|
|
1394
1463
|
helper = new D();
|
|
1395
1464
|
borderMaterial;
|
|
1396
1465
|
material;
|
|
@@ -1399,26 +1468,26 @@ var Rn = class extends I {
|
|
|
1399
1468
|
border;
|
|
1400
1469
|
context;
|
|
1401
1470
|
location;
|
|
1402
|
-
localHitPoint = new
|
|
1471
|
+
localHitPoint = new B();
|
|
1403
1472
|
normal;
|
|
1404
1473
|
planeMesh;
|
|
1405
|
-
pointer = new
|
|
1474
|
+
pointer = new z();
|
|
1406
1475
|
layout;
|
|
1407
1476
|
polygon = [];
|
|
1408
1477
|
dragState = null;
|
|
1409
1478
|
hovered = !1;
|
|
1410
1479
|
listenersActive = !1;
|
|
1411
1480
|
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:
|
|
1481
|
+
super(), this.context = e, this.plane = t, this.location = n.clone(), this.normal = r.clone().normalize(), this.material = new F({
|
|
1482
|
+
color: En,
|
|
1414
1483
|
depthWrite: !1,
|
|
1415
|
-
opacity:
|
|
1484
|
+
opacity: Dn,
|
|
1416
1485
|
side: w,
|
|
1417
1486
|
transparent: !0
|
|
1418
1487
|
}), this.helper.position.copy(this.location), this.applyPlaneOrientation(), this.layout = this.getHelperLayout();
|
|
1419
|
-
let i = Math.max(
|
|
1420
|
-
this.borderMaterial = new
|
|
1421
|
-
color:
|
|
1488
|
+
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);
|
|
1489
|
+
this.borderMaterial = new ne({
|
|
1490
|
+
color: Tn,
|
|
1422
1491
|
dashSize: i,
|
|
1423
1492
|
depthWrite: !1,
|
|
1424
1493
|
gapSize: a
|
|
@@ -1449,7 +1518,7 @@ var Rn = class extends I {
|
|
|
1449
1518
|
}
|
|
1450
1519
|
updateBorderDash() {
|
|
1451
1520
|
let e = Math.min(this.layout.width, this.layout.height);
|
|
1452
|
-
this.borderMaterial.dashSize = Math.max(
|
|
1521
|
+
this.borderMaterial.dashSize = Math.max(Fn, e * jn), this.borderMaterial.gapSize = Math.max(In, e * Mn), this.borderMaterial.needsUpdate = !0;
|
|
1453
1522
|
}
|
|
1454
1523
|
addEventListeners() {
|
|
1455
1524
|
if (this.listenersActive) return;
|
|
@@ -1482,21 +1551,20 @@ var Rn = class extends I {
|
|
|
1482
1551
|
});
|
|
1483
1552
|
for (let t of n) {
|
|
1484
1553
|
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.
|
|
1554
|
+
if (n && !(!this.hasHelperPriority(e) && !n.isPointerHitNearEdge(t.point)) && !(!this.hasHelperPriority(e) && this.hasModelIntersection(e))) return {
|
|
1486
1555
|
helper: n,
|
|
1487
1556
|
hit: t
|
|
1488
1557
|
};
|
|
1489
1558
|
}
|
|
1490
1559
|
return null;
|
|
1491
1560
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1561
|
+
hasModelIntersection(e) {
|
|
1562
|
+
return !!this.context.getCameraUtils().getIntersection(!0, {
|
|
1494
1563
|
event: e,
|
|
1495
|
-
filter: (e) => !(e.object instanceof
|
|
1564
|
+
filter: (e) => !(e.object instanceof P) || e.faceIndex === void 0 || e.faceIndex === null ? !1 : !!(e.object.geometry.index && e.object.geometry.attributes.ids),
|
|
1496
1565
|
object: this.context.getMeshes(),
|
|
1497
1566
|
recursive: !1
|
|
1498
1567
|
});
|
|
1499
|
-
return !!(n && n.distance < t);
|
|
1500
1568
|
}
|
|
1501
1569
|
isPointerHitNearEdge(e) {
|
|
1502
1570
|
if (this.polygon.length < 2) return !1;
|
|
@@ -1512,10 +1580,10 @@ var Rn = class extends I {
|
|
|
1512
1580
|
return !1;
|
|
1513
1581
|
}
|
|
1514
1582
|
getEdgeInteractionWidth() {
|
|
1515
|
-
return Math.min(
|
|
1583
|
+
return Math.min(Bn, Math.max(zn, Math.min(this.layout.width, this.layout.height) * Nn));
|
|
1516
1584
|
}
|
|
1517
1585
|
getDragDistanceEpsilon() {
|
|
1518
|
-
return Math.max(
|
|
1586
|
+
return Math.max(Rn, Math.min(this.layout.width, this.layout.height) * Pn);
|
|
1519
1587
|
}
|
|
1520
1588
|
getPointToSegmentDistanceSquared(e, t, n) {
|
|
1521
1589
|
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
|
|
@@ -1528,8 +1596,8 @@ var Rn = class extends I {
|
|
|
1528
1596
|
}
|
|
1529
1597
|
getPointerPointOnPlane(e, t) {
|
|
1530
1598
|
let n = this.context.getDomElement();
|
|
1531
|
-
this.pointer.copy(
|
|
1532
|
-
let r = this.context.getRaycaster(), i = new
|
|
1599
|
+
this.pointer.copy(Vn(e, n));
|
|
1600
|
+
let r = this.context.getRaycaster(), i = new B();
|
|
1533
1601
|
return r.setFromCamera(this.pointer, this.context.getCamera()), r.ray.intersectPlane(t, i);
|
|
1534
1602
|
}
|
|
1535
1603
|
onPointerDown = (e) => {
|
|
@@ -1537,9 +1605,9 @@ var Rn = class extends I {
|
|
|
1537
1605
|
let t = this.getPointerIntersection(e);
|
|
1538
1606
|
if (!t) return;
|
|
1539
1607
|
this.stopHelperPriorityEvent(e), this.context.clearHelpersHover(this), this.setHovered(!0), this.context.setHelperDragActive(!0), this.context.setCapsDragActive(!0), this.context.requestCapsDragIdleUpdate(), this.context.setSelectionInteractionDisabled(!0);
|
|
1540
|
-
let n = new
|
|
1608
|
+
let n = new B();
|
|
1541
1609
|
this.context.getCamera().getWorldDirection(n), n.normalize();
|
|
1542
|
-
let r = new
|
|
1610
|
+
let r = new I().setFromNormalAndCoplanarPoint(n, t.point);
|
|
1543
1611
|
this.dragState = {
|
|
1544
1612
|
dragPlane: r,
|
|
1545
1613
|
helperStart: this.helper.position.clone(),
|
|
@@ -1564,7 +1632,7 @@ var Rn = class extends I {
|
|
|
1564
1632
|
this.plane.copy(this.dragState.planeStart).translate(r), this.helper.position.copy(this.dragState.helperStart).add(r), this.context.requestHelpersUpdate(), this.context.requestEdgesUpdate(), this.context.requestCapsDragIdleUpdate();
|
|
1565
1633
|
};
|
|
1566
1634
|
onPointerUp = (e) => {
|
|
1567
|
-
this.dragState && (this.stopHelperPriorityEvent(e), this.dragState = null, this.context.setHelperDragActive(!1), this.context.setControlsEnabled(!0), this.context.setCapsDragActive(!1), this.context.updateHelpers(),
|
|
1635
|
+
this.dragState && (this.stopHelperPriorityEvent(e), this.dragState = null, this.context.setHelperDragActive(!1), this.context.setControlsEnabled(!0), this.context.setCapsDragActive(!1), this.context.updateHelpers(), window.setTimeout(() => {
|
|
1568
1636
|
this.context.setSelectionInteractionDisabled(!1);
|
|
1569
1637
|
}, 0));
|
|
1570
1638
|
};
|
|
@@ -1581,14 +1649,14 @@ var Rn = class extends I {
|
|
|
1581
1649
|
t && (this.context.clearHelpersHover(this), this.hasHelperPriority(e) && this.stopHelperPriorityEvent(e)), this.hovered !== t && this.setHovered(t);
|
|
1582
1650
|
}
|
|
1583
1651
|
setHovered(e) {
|
|
1584
|
-
this.hovered = e, this.material.color.set(e ?
|
|
1652
|
+
this.hovered = e, this.material.color.set(e ? On : En), this.material.opacity = e ? kn : Dn, this.material.needsUpdate = !0;
|
|
1585
1653
|
}
|
|
1586
1654
|
createPlaneMesh() {
|
|
1587
|
-
let e = new
|
|
1655
|
+
let e = new P(new y(), this.material);
|
|
1588
1656
|
return e.renderOrder = 2, e;
|
|
1589
1657
|
}
|
|
1590
1658
|
createBorder() {
|
|
1591
|
-
let e = new
|
|
1659
|
+
let e = new k(new y(), this.borderMaterial);
|
|
1592
1660
|
return e.renderOrder = 3, e;
|
|
1593
1661
|
}
|
|
1594
1662
|
replaceGeometry(e, t) {
|
|
@@ -1657,27 +1725,27 @@ var Rn = class extends I {
|
|
|
1657
1725
|
getHelperLayout() {
|
|
1658
1726
|
let e = this.getModelWorldBox();
|
|
1659
1727
|
if (!e || e.isEmpty()) return {
|
|
1660
|
-
height:
|
|
1661
|
-
maxU:
|
|
1662
|
-
maxV:
|
|
1663
|
-
minU: -
|
|
1664
|
-
minV: -
|
|
1665
|
-
width:
|
|
1728
|
+
height: q,
|
|
1729
|
+
maxU: q / 2,
|
|
1730
|
+
maxV: q / 2,
|
|
1731
|
+
minU: -q / 2,
|
|
1732
|
+
minV: -q / 2,
|
|
1733
|
+
width: q
|
|
1666
1734
|
};
|
|
1667
|
-
let t = this.getPlaneBasis(), n = this.helper.position, r = this.getBoxCorners(e), i = new
|
|
1735
|
+
let t = this.getPlaneBasis(), n = this.helper.position, r = this.getBoxCorners(e), i = new B(), a = new B(), o = Infinity, s = -Infinity, c = Infinity, l = -Infinity;
|
|
1668
1736
|
if (r.forEach((e) => {
|
|
1669
1737
|
this.plane.projectPoint(e, i), a.copy(i).sub(n);
|
|
1670
1738
|
let r = a.dot(t.u), u = a.dot(t.v);
|
|
1671
1739
|
o = Math.min(o, r), s = Math.max(s, r), c = Math.min(c, u), l = Math.max(l, u);
|
|
1672
1740
|
}), !Number.isFinite(o) || !Number.isFinite(s) || !Number.isFinite(c) || !Number.isFinite(l)) return {
|
|
1673
|
-
height:
|
|
1674
|
-
maxU:
|
|
1675
|
-
maxV:
|
|
1676
|
-
minU: -
|
|
1677
|
-
minV: -
|
|
1678
|
-
width:
|
|
1741
|
+
height: q,
|
|
1742
|
+
maxU: q / 2,
|
|
1743
|
+
maxV: q / 2,
|
|
1744
|
+
minU: -q / 2,
|
|
1745
|
+
minV: -q / 2,
|
|
1746
|
+
width: q
|
|
1679
1747
|
};
|
|
1680
|
-
let u =
|
|
1748
|
+
let u = Hn(e), d = o - u, f = s + u, p = c - u, m = l + u, h = Math.max(q, f - d), g = Math.max(q, m - p), _ = (d + f) / 2, v = (p + m) / 2;
|
|
1681
1749
|
return {
|
|
1682
1750
|
height: g,
|
|
1683
1751
|
maxU: _ + h / 2,
|
|
@@ -1688,14 +1756,14 @@ var Rn = class extends I {
|
|
|
1688
1756
|
};
|
|
1689
1757
|
}
|
|
1690
1758
|
getPlaneBasis() {
|
|
1691
|
-
let e = (Math.abs(this.normal.y) < .9 ? new
|
|
1759
|
+
let e = (Math.abs(this.normal.y) < .9 ? new B(0, 1, 0) : new B(1, 0, 0)).cross(this.normal).normalize();
|
|
1692
1760
|
return {
|
|
1693
1761
|
u: e,
|
|
1694
1762
|
v: this.normal.clone().cross(e).normalize()
|
|
1695
1763
|
};
|
|
1696
1764
|
}
|
|
1697
1765
|
applyPlaneOrientation() {
|
|
1698
|
-
let e = this.getPlaneBasis(), t = new
|
|
1766
|
+
let e = this.getPlaneBasis(), t = new N().makeBasis(e.u, e.v, this.normal);
|
|
1699
1767
|
this.helper.quaternion.setFromRotationMatrix(t);
|
|
1700
1768
|
}
|
|
1701
1769
|
getModelWorldBox() {
|
|
@@ -1708,18 +1776,18 @@ var Rn = class extends I {
|
|
|
1708
1776
|
}
|
|
1709
1777
|
getBoxCorners(e) {
|
|
1710
1778
|
return [
|
|
1711
|
-
new
|
|
1712
|
-
new
|
|
1713
|
-
new
|
|
1714
|
-
new
|
|
1715
|
-
new
|
|
1716
|
-
new
|
|
1717
|
-
new
|
|
1718
|
-
new
|
|
1779
|
+
new B(e.min.x, e.min.y, e.min.z),
|
|
1780
|
+
new B(e.min.x, e.min.y, e.max.z),
|
|
1781
|
+
new B(e.min.x, e.max.y, e.min.z),
|
|
1782
|
+
new B(e.min.x, e.max.y, e.max.z),
|
|
1783
|
+
new B(e.max.x, e.min.y, e.min.z),
|
|
1784
|
+
new B(e.max.x, e.min.y, e.max.z),
|
|
1785
|
+
new B(e.max.x, e.max.y, e.min.z),
|
|
1786
|
+
new B(e.max.x, e.max.y, e.max.z)
|
|
1719
1787
|
];
|
|
1720
1788
|
}
|
|
1721
|
-
},
|
|
1722
|
-
function
|
|
1789
|
+
}, Wn = 250;
|
|
1790
|
+
function Gn(e, t) {
|
|
1723
1791
|
if (Array.isArray(e)) {
|
|
1724
1792
|
e.forEach((e) => {
|
|
1725
1793
|
e.clippingPlanes = t, e.needsUpdate = !0;
|
|
@@ -1728,13 +1796,13 @@ function Bn(e, t) {
|
|
|
1728
1796
|
}
|
|
1729
1797
|
e.clippingPlanes = t, e.needsUpdate = !0;
|
|
1730
1798
|
}
|
|
1731
|
-
function
|
|
1799
|
+
function Kn(e) {
|
|
1732
1800
|
let t = [];
|
|
1733
1801
|
return e?.traverse((e) => {
|
|
1734
|
-
e instanceof
|
|
1802
|
+
e instanceof P && (!e.geometry.index || !e.geometry.attributes.ids || t.push(e));
|
|
1735
1803
|
}), t;
|
|
1736
1804
|
}
|
|
1737
|
-
function
|
|
1805
|
+
function qn(e) {
|
|
1738
1806
|
let t = e;
|
|
1739
1807
|
for (; t;) {
|
|
1740
1808
|
let e = t.userData.modelID;
|
|
@@ -1743,10 +1811,10 @@ function Hn(e) {
|
|
|
1743
1811
|
}
|
|
1744
1812
|
return 0;
|
|
1745
1813
|
}
|
|
1746
|
-
function
|
|
1814
|
+
function Jn(e, t) {
|
|
1747
1815
|
return t.clone().transformDirection(e.matrixWorld).normalize();
|
|
1748
1816
|
}
|
|
1749
|
-
var
|
|
1817
|
+
var Yn = class {
|
|
1750
1818
|
planes = [];
|
|
1751
1819
|
caps = [];
|
|
1752
1820
|
edges = [];
|
|
@@ -1798,11 +1866,20 @@ var Wn = class {
|
|
|
1798
1866
|
getRaycaster() {
|
|
1799
1867
|
return this.context.raycaster;
|
|
1800
1868
|
}
|
|
1869
|
+
getMaxTextureAnisotropy() {
|
|
1870
|
+
return this.context.renderer.capabilities.getMaxAnisotropy();
|
|
1871
|
+
}
|
|
1801
1872
|
getControlRef() {
|
|
1802
1873
|
return this.context.controlRef;
|
|
1803
1874
|
}
|
|
1804
1875
|
getMeshes() {
|
|
1805
|
-
return
|
|
1876
|
+
return Kn(this.context.modelRef.current);
|
|
1877
|
+
}
|
|
1878
|
+
getObjectModelID(e) {
|
|
1879
|
+
return qn(e);
|
|
1880
|
+
}
|
|
1881
|
+
getEdgeSegmentsForPlane(e) {
|
|
1882
|
+
return this.edgesActive ? this.edges.find((t) => t.plane === e && t.active)?.getIntersectionSegments() ?? null : null;
|
|
1806
1883
|
}
|
|
1807
1884
|
getSelectableObjects() {
|
|
1808
1885
|
return this.caps.map((e) => e.getSelectableObject()).filter((e) => e.visible);
|
|
@@ -1832,14 +1909,14 @@ var Wn = class {
|
|
|
1832
1909
|
this.helperDragActive = e;
|
|
1833
1910
|
}
|
|
1834
1911
|
setCapsDragActive(e) {
|
|
1835
|
-
this.capsDragActive !== e && (this.clearCapsDragIdleTimeout(), this.capsDragActive = e, this.caps.forEach((t) => t.setVisible(this.active && this.capsActive && !e)), !e && this.active && this.capsActive && this.updateCaps());
|
|
1912
|
+
this.capsDragActive !== e && (this.clearCapsDragIdleTimeout(), this.capsDragActive = e, this.caps.forEach((t) => t.setVisible(this.active && this.capsActive && !e)), !e && this.active && this.capsActive && (this.flushEdgesUpdate(), this.updateCaps()));
|
|
1836
1913
|
}
|
|
1837
1914
|
requestCapsDragIdleUpdate() {
|
|
1838
1915
|
!this.active || !this.capsActive || !this.capsDragActive || !this.caps.length || (this.clearCapsDragIdleTimeout(), this.caps.forEach((e) => e.setVisible(!1)), this.capsDragIdleTimeout = window.setTimeout(() => {
|
|
1839
|
-
this.capsDragIdleTimeout = null, !(!this.active || !this.capsDragActive) && (this.caps.forEach((e) => {
|
|
1916
|
+
this.capsDragIdleTimeout = null, !(!this.active || !this.capsDragActive) && (this.flushEdgesUpdate(), this.caps.forEach((e) => {
|
|
1840
1917
|
e.setVisible(!0), e.update();
|
|
1841
1918
|
}), this.updateCapsVisualState());
|
|
1842
|
-
},
|
|
1919
|
+
}, Wn));
|
|
1843
1920
|
}
|
|
1844
1921
|
clearCapsDragIdleTimeout() {
|
|
1845
1922
|
this.capsDragIdleTimeout !== null && (window.clearTimeout(this.capsDragIdleTimeout), this.capsDragIdleTimeout = null);
|
|
@@ -1867,9 +1944,9 @@ var Wn = class {
|
|
|
1867
1944
|
}), e.isEmpty() ? null : e;
|
|
1868
1945
|
}
|
|
1869
1946
|
getSelectedWorldBox() {
|
|
1870
|
-
let e = this.context.viewerStore.getState().selected, t = new g(), n = new
|
|
1947
|
+
let e = this.context.viewerStore.getState().selected, t = new g(), n = new B();
|
|
1871
1948
|
return this.getMeshes().forEach((r) => {
|
|
1872
|
-
let i = e[
|
|
1949
|
+
let i = e[qn(r)];
|
|
1873
1950
|
if (!i?.size) return;
|
|
1874
1951
|
let a = r.geometry.attributes.ids, o = r.geometry.attributes.position;
|
|
1875
1952
|
if (!a || !o) return;
|
|
@@ -1888,7 +1965,7 @@ var Wn = class {
|
|
|
1888
1965
|
updateMaterials() {
|
|
1889
1966
|
let e = this.active ? this.planes : [];
|
|
1890
1967
|
this.getMeshes().forEach((t) => {
|
|
1891
|
-
|
|
1968
|
+
Gn(t.material, e);
|
|
1892
1969
|
}), this.context.camera.updateMatrixWorld();
|
|
1893
1970
|
}
|
|
1894
1971
|
setActive(e) {
|
|
@@ -1907,42 +1984,42 @@ var Wn = class {
|
|
|
1907
1984
|
recursive: !1
|
|
1908
1985
|
});
|
|
1909
1986
|
if (!n?.face) return null;
|
|
1910
|
-
let r = n.point.clone(), i =
|
|
1987
|
+
let r = n.point.clone(), i = Jn(n.object, n.face.normal);
|
|
1911
1988
|
r.add(i.clone().multiplyScalar(.001));
|
|
1912
|
-
let a = new
|
|
1989
|
+
let a = new I().setFromNormalAndCoplanarPoint(i.clone().negate(), r);
|
|
1913
1990
|
return this.addPlane(a, r, i), a.clone();
|
|
1914
1991
|
}
|
|
1915
1992
|
createClippingRectangle(e = !1) {
|
|
1916
1993
|
let t = e ? this.getSelectedWorldBox() : this.getModelWorldBox();
|
|
1917
1994
|
if (!t) return [];
|
|
1918
|
-
let n =
|
|
1995
|
+
let n = Hn(t), r = t.min.clone().addScalar(-n), i = t.max.clone().addScalar(n), a = t.getCenter(new B()), o = [
|
|
1919
1996
|
{
|
|
1920
|
-
normal: new
|
|
1921
|
-
point: new
|
|
1997
|
+
normal: new B(1, 0, 0),
|
|
1998
|
+
point: new B(r.x, a.y, a.z)
|
|
1922
1999
|
},
|
|
1923
2000
|
{
|
|
1924
|
-
normal: new
|
|
1925
|
-
point: new
|
|
2001
|
+
normal: new B(-1, 0, 0),
|
|
2002
|
+
point: new B(i.x, a.y, a.z)
|
|
1926
2003
|
},
|
|
1927
2004
|
{
|
|
1928
|
-
normal: new
|
|
1929
|
-
point: new
|
|
2005
|
+
normal: new B(0, 1, 0),
|
|
2006
|
+
point: new B(a.x, r.y, a.z)
|
|
1930
2007
|
},
|
|
1931
2008
|
{
|
|
1932
|
-
normal: new
|
|
1933
|
-
point: new
|
|
2009
|
+
normal: new B(0, -1, 0),
|
|
2010
|
+
point: new B(a.x, i.y, a.z)
|
|
1934
2011
|
},
|
|
1935
2012
|
{
|
|
1936
|
-
normal: new
|
|
1937
|
-
point: new
|
|
2013
|
+
normal: new B(0, 0, 1),
|
|
2014
|
+
point: new B(a.x, a.y, r.z)
|
|
1938
2015
|
},
|
|
1939
2016
|
{
|
|
1940
|
-
normal: new
|
|
1941
|
-
point: new
|
|
2017
|
+
normal: new B(0, 0, -1),
|
|
2018
|
+
point: new B(a.x, a.y, i.z)
|
|
1942
2019
|
}
|
|
1943
2020
|
].map(({ normal: e, point: t }) => ({
|
|
1944
2021
|
normal: e,
|
|
1945
|
-
plane: new
|
|
2022
|
+
plane: new I().setFromNormalAndCoplanarPoint(e, t),
|
|
1946
2023
|
point: t
|
|
1947
2024
|
}));
|
|
1948
2025
|
return o.forEach(({ normal: e, plane: t, point: n }) => {
|
|
@@ -1950,10 +2027,12 @@ var Wn = class {
|
|
|
1950
2027
|
}), this.updateHelpers(), o.map(({ plane: e }) => e.clone());
|
|
1951
2028
|
}
|
|
1952
2029
|
addPlane(e, t, n) {
|
|
1953
|
-
if (this.active || this.setActive(!0), this.planes.push(e), new
|
|
1954
|
-
let t = new
|
|
2030
|
+
if (this.active || this.setActive(!0), this.planes.push(e), new Un(this, e, t, n), this.edgesActive) {
|
|
2031
|
+
let t = new wn(this, e);
|
|
1955
2032
|
t.create(), t.update();
|
|
1956
2033
|
}
|
|
2034
|
+
let r = new gn(this, e);
|
|
2035
|
+
r.setVisible(this.active && this.capsActive && !this.capsDragActive), this.updateHelpers(), this.updateCaps(r), this.updateMaterials();
|
|
1957
2036
|
}
|
|
1958
2037
|
deleteAllPlanes() {
|
|
1959
2038
|
this.active = !1, this.capsDragActive = !1, this.helperDragActive = !1, this.clearCapsDragIdleTimeout(), this.context.renderer.localClippingEnabled = !1, this.updateEdgesFrame !== null && (cancelAnimationFrame(this.updateEdgesFrame), this.updateEdgesFrame = null), this.updateHelpersFrame !== null && (cancelAnimationFrame(this.updateHelpersFrame), this.updateHelpersFrame = null), this.helpers.forEach((e) => e.dispose()), this.caps.forEach((e) => e.dispose()), this.edges.forEach((e) => e.dispose()), this.helpers = [], this.caps = [], this.edges = [], this.planes = [], this.updateMaterials();
|
|
@@ -1962,13 +2041,16 @@ var Wn = class {
|
|
|
1962
2041
|
this.helpersActive !== e && (this.helpersActive = e, this.helpers.forEach((e) => e.setVisible(this.active && this.helpersActive)));
|
|
1963
2042
|
}
|
|
1964
2043
|
setCapsActive(e) {
|
|
1965
|
-
this.capsActive !== e && (this.capsActive = e, this.caps.forEach((t) => t.setVisible(this.active && e && !this.capsDragActive)), this.active && e && !this.capsDragActive && this.updateCaps());
|
|
2044
|
+
this.capsActive !== e && (this.capsActive = e, this.caps.forEach((t) => t.setVisible(this.active && e && !this.capsDragActive)), this.active && e && !this.capsDragActive && (this.flushEdgesUpdate(), this.updateCaps()));
|
|
1966
2045
|
}
|
|
1967
2046
|
setEdgesActive(e) {
|
|
1968
|
-
|
|
1969
|
-
|
|
2047
|
+
if (this.edgesActive === e) return;
|
|
2048
|
+
this.edgesActive = e;
|
|
2049
|
+
let t = !1;
|
|
2050
|
+
e && this.edges.length !== this.planes.length && (t = !0, this.edges.forEach((e) => e.dispose()), this.edges = [], this.planes.forEach((e) => {
|
|
2051
|
+
let t = new wn(this, e);
|
|
1970
2052
|
t.create(), t.update();
|
|
1971
|
-
})), this.edges.forEach((t) => t.setVisible(this.active && e)));
|
|
2053
|
+
})), this.edges.forEach((t) => t.setVisible(this.active && e)), this.active && e && (t || this.updateEdges(), this.capsActive && !this.capsDragActive && this.updateCaps());
|
|
1972
2054
|
}
|
|
1973
2055
|
updateEdges() {
|
|
1974
2056
|
this.edgesActive && this.edges.forEach((e) => e.update());
|
|
@@ -1976,8 +2058,10 @@ var Wn = class {
|
|
|
1976
2058
|
flushEdgesUpdate() {
|
|
1977
2059
|
this.updateEdgesFrame !== null && (cancelAnimationFrame(this.updateEdgesFrame), this.updateEdgesFrame = null), this.updateEdges();
|
|
1978
2060
|
}
|
|
1979
|
-
updateCaps() {
|
|
1980
|
-
this.capsActive && (this.capsDragActive || this.caps.forEach((
|
|
2061
|
+
updateCaps(e) {
|
|
2062
|
+
this.capsActive && (this.capsDragActive || this.caps.forEach((t) => {
|
|
2063
|
+
t !== e && t.update();
|
|
2064
|
+
}));
|
|
1981
2065
|
}
|
|
1982
2066
|
updateHelpers() {
|
|
1983
2067
|
this.helpers.forEach((e) => e.updateClipping());
|
|
@@ -1993,14 +2077,14 @@ var Wn = class {
|
|
|
1993
2077
|
}));
|
|
1994
2078
|
}
|
|
1995
2079
|
syncWithModel() {
|
|
1996
|
-
this.updateMaterials(), this.
|
|
2080
|
+
this.updateMaterials(), this.edges.forEach((e) => e.syncMeshes()), this.updateEdges(), this.caps.forEach((e) => e.syncMeshes()), this.updateHelpers();
|
|
1997
2081
|
}
|
|
1998
2082
|
dispose() {
|
|
1999
2083
|
this.clearCapsDragIdleTimeout(), this.deleteAllPlanes();
|
|
2000
2084
|
}
|
|
2001
2085
|
};
|
|
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 = Ee(), u = c(() => new
|
|
2086
|
+
function Xn(e, t, n) {
|
|
2087
|
+
let r = p((e) => e.camera), i = p((e) => e.gl), a = p((e) => e.raycaster), s = p((e) => e.scene), l = Ee(), u = c(() => new Yn({
|
|
2004
2088
|
camera: r,
|
|
2005
2089
|
cameraUtils: n,
|
|
2006
2090
|
controlRef: t,
|
|
@@ -2075,29 +2159,89 @@ function Gn(e, t, n) {
|
|
|
2075
2159
|
}), [u]);
|
|
2076
2160
|
}
|
|
2077
2161
|
//#endregion
|
|
2162
|
+
//#region src/viewer/Camera/useCameraUtils.ts
|
|
2163
|
+
var Zn = 1e-6;
|
|
2164
|
+
function Qn(e, t) {
|
|
2165
|
+
let n = t.getBoundingClientRect();
|
|
2166
|
+
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 z((e.clientX - n.left) / n.width * 2 - 1, -((e.clientY - n.top) / n.height) * 2 + 1);
|
|
2167
|
+
}
|
|
2168
|
+
function $n(e, t) {
|
|
2169
|
+
return t.every((t) => t.distanceToPoint(e) >= -Zn);
|
|
2170
|
+
}
|
|
2171
|
+
function er(e) {
|
|
2172
|
+
let t = e;
|
|
2173
|
+
for (; t;) {
|
|
2174
|
+
if (!t.visible) return !1;
|
|
2175
|
+
t = t.parent;
|
|
2176
|
+
}
|
|
2177
|
+
return !0;
|
|
2178
|
+
}
|
|
2179
|
+
function tr(e) {
|
|
2180
|
+
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 z()), d = i((e) => {
|
|
2181
|
+
a.current = e;
|
|
2182
|
+
}, []), f = i(() => {
|
|
2183
|
+
let e = a.current;
|
|
2184
|
+
return e?.getActive() ? e.getPlanes() : [];
|
|
2185
|
+
}, []);
|
|
2186
|
+
o(() => {
|
|
2187
|
+
let e = n.domElement, t = (t) => {
|
|
2188
|
+
let n = Qn(t, e);
|
|
2189
|
+
n && (s.current = n);
|
|
2190
|
+
}, r = () => {
|
|
2191
|
+
s.current = null;
|
|
2192
|
+
};
|
|
2193
|
+
return e.addEventListener("pointermove", t), e.addEventListener("pointerdown", t), e.addEventListener("pointerleave", r), () => {
|
|
2194
|
+
e.removeEventListener("pointermove", t), e.removeEventListener("pointerdown", t), e.removeEventListener("pointerleave", r);
|
|
2195
|
+
};
|
|
2196
|
+
}, [n]);
|
|
2197
|
+
let m = i((i = !1, { event: a, filter: o, object: c = e.current, recursive: l = !0, respectClipping: d = !0 } = {}) => {
|
|
2198
|
+
let p = a ? Qn(a, n.domElement) : s.current;
|
|
2199
|
+
if (!p || !c) return i ? null : [];
|
|
2200
|
+
let m = d ? f() : [], h = Array.isArray(c) ? c : [c];
|
|
2201
|
+
t.updateMatrixWorld(), e.current?.updateMatrixWorld(!0), u.current.copy(p), r.setFromCamera(u.current, t);
|
|
2202
|
+
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);
|
|
2203
|
+
return i ? g[0] ?? null : g;
|
|
2204
|
+
}, [
|
|
2205
|
+
t,
|
|
2206
|
+
f,
|
|
2207
|
+
n,
|
|
2208
|
+
e,
|
|
2209
|
+
r
|
|
2210
|
+
]);
|
|
2211
|
+
return c(() => ({
|
|
2212
|
+
getActiveClippingPlanes: f,
|
|
2213
|
+
getIntersection: m,
|
|
2214
|
+
setClippingSource: d
|
|
2215
|
+
}), [
|
|
2216
|
+
f,
|
|
2217
|
+
m,
|
|
2218
|
+
d
|
|
2219
|
+
]);
|
|
2220
|
+
}
|
|
2221
|
+
//#endregion
|
|
2078
2222
|
//#region src/viewer/utils/DimentionsUtils/DimentionLine.ts
|
|
2079
|
-
var
|
|
2080
|
-
function
|
|
2223
|
+
var nr = 12, rr = 6, ir = 4;
|
|
2224
|
+
function ar() {
|
|
2081
2225
|
return typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2);
|
|
2082
2226
|
}
|
|
2083
|
-
function
|
|
2084
|
-
return e instanceof
|
|
2227
|
+
function or(e, t) {
|
|
2228
|
+
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
2229
|
}
|
|
2086
|
-
function
|
|
2087
|
-
let t =
|
|
2230
|
+
function sr(e) {
|
|
2231
|
+
let t = ar(), n = document.createElement("canvas"), r = n.getContext("2d");
|
|
2088
2232
|
if (!r) throw Error("Could not create dimension label canvas context");
|
|
2089
|
-
let i = `600 ${
|
|
2233
|
+
let i = `600 ${nr}px system-ui, "Segoe UI", sans-serif`;
|
|
2090
2234
|
r.font = i;
|
|
2091
|
-
let a = r.measureText(e), o = a.actualBoundingBoxAscent ||
|
|
2235
|
+
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
2236
|
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
2237
|
let u = new b(n);
|
|
2094
|
-
return u.colorSpace =
|
|
2238
|
+
return u.colorSpace = R, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
|
|
2095
2239
|
height: l,
|
|
2096
2240
|
texture: u,
|
|
2097
2241
|
width: c
|
|
2098
2242
|
};
|
|
2099
2243
|
}
|
|
2100
|
-
var
|
|
2244
|
+
var cr = class e {
|
|
2101
2245
|
static scale = 1;
|
|
2102
2246
|
static scaleFactor = .015;
|
|
2103
2247
|
static units = "m";
|
|
@@ -2169,7 +2313,7 @@ var Qn = class e {
|
|
|
2169
2313
|
this.addEndpointMesh(this.start, this.end), this.addEndpointMesh(this.end, this.start);
|
|
2170
2314
|
}
|
|
2171
2315
|
addEndpointMesh(e, t) {
|
|
2172
|
-
let n = new
|
|
2316
|
+
let n = new P(this.endpointGeometry, this.endpointMaterial);
|
|
2173
2317
|
n.position.copy(e), n.scale.copy(this.endpointBaseScale), n.lookAt(t), n.renderOrder = 4, this.endpointMeshes.push(n), this.root.add(n);
|
|
2174
2318
|
}
|
|
2175
2319
|
createLabelSprite() {
|
|
@@ -2181,7 +2325,7 @@ var Qn = class e {
|
|
|
2181
2325
|
return e.renderOrder = 5, e;
|
|
2182
2326
|
}
|
|
2183
2327
|
createBoundingBoxMesh() {
|
|
2184
|
-
let e = new
|
|
2328
|
+
let e = new P(new _(1, 1, Math.max(this.length, .001)), this.boundingMaterial);
|
|
2185
2329
|
return e.renderOrder = 3, e;
|
|
2186
2330
|
}
|
|
2187
2331
|
getTextContent() {
|
|
@@ -2192,7 +2336,7 @@ var Qn = class e {
|
|
|
2192
2336
|
let e = this.getTextContent();
|
|
2193
2337
|
if (this.labelText === e) return;
|
|
2194
2338
|
this.labelText = e, this.labelTexture?.dispose();
|
|
2195
|
-
let t =
|
|
2339
|
+
let t = sr(e);
|
|
2196
2340
|
this.labelHeight = t.height, this.labelTexture = t.texture, this.labelWidth = t.width, this.labelSprite.material.map = t.texture, this.labelSprite.material.needsUpdate = !0;
|
|
2197
2341
|
}
|
|
2198
2342
|
updatePositions() {
|
|
@@ -2203,37 +2347,37 @@ var Qn = class e {
|
|
|
2203
2347
|
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
2348
|
}
|
|
2205
2349
|
rescaleMesh(t, n, r) {
|
|
2206
|
-
let i =
|
|
2350
|
+
let i = or(n, t.position.distanceTo(n.position)) / Math.max(1, r) * 12 * e.scaleFactor;
|
|
2207
2351
|
t.scale.setScalar(i);
|
|
2208
2352
|
}
|
|
2209
2353
|
rescaleBoundingMesh(e, t) {
|
|
2210
2354
|
if (!this.boundingMesh) return;
|
|
2211
|
-
let n =
|
|
2355
|
+
let n = or(e, this.boundingMesh.position.distanceTo(e.position)) / Math.max(1, t) * 8;
|
|
2212
2356
|
this.boundingMesh.scale.set(n, n, 1);
|
|
2213
2357
|
}
|
|
2214
2358
|
rescaleLabel(e, t) {
|
|
2215
|
-
let n =
|
|
2359
|
+
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
2360
|
this.labelSprite.scale.set(i, r, 1);
|
|
2217
2361
|
}
|
|
2218
|
-
},
|
|
2219
|
-
function
|
|
2362
|
+
}, lr = "#111827", ur = 1, dr = "x";
|
|
2363
|
+
function fr(e) {
|
|
2220
2364
|
let t = [];
|
|
2221
2365
|
return e?.traverse((e) => {
|
|
2222
|
-
e instanceof
|
|
2366
|
+
e instanceof P && e.geometry.attributes.position && t.push(e);
|
|
2223
2367
|
}), t;
|
|
2224
2368
|
}
|
|
2225
|
-
function
|
|
2369
|
+
function pr(e, t, n) {
|
|
2226
2370
|
let r = e.clone();
|
|
2227
2371
|
return r[n] = t[n], r;
|
|
2228
2372
|
}
|
|
2229
|
-
function
|
|
2373
|
+
function mr(e, t) {
|
|
2230
2374
|
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
2375
|
return a === n ? "x" : a === r ? "y" : "z";
|
|
2232
2376
|
}
|
|
2233
|
-
var
|
|
2377
|
+
var hr = class e {
|
|
2234
2378
|
active = !1;
|
|
2235
2379
|
axis = null;
|
|
2236
|
-
boundingMaterial = new
|
|
2380
|
+
boundingMaterial = new F({
|
|
2237
2381
|
color: 0,
|
|
2238
2382
|
depthTest: !1,
|
|
2239
2383
|
depthWrite: !1,
|
|
@@ -2244,14 +2388,14 @@ var ar = class e {
|
|
|
2244
2388
|
currentDimension = null;
|
|
2245
2389
|
dimensions = [];
|
|
2246
2390
|
endpointGeometry = e.createEndpointGeometry();
|
|
2247
|
-
endpointMaterial = new
|
|
2248
|
-
color:
|
|
2391
|
+
endpointMaterial = new F({
|
|
2392
|
+
color: lr,
|
|
2249
2393
|
depthTest: !1,
|
|
2250
2394
|
depthWrite: !1
|
|
2251
2395
|
});
|
|
2252
|
-
endpointScale = new
|
|
2253
|
-
lineMaterial = new
|
|
2254
|
-
color:
|
|
2396
|
+
endpointScale = new B(1, 1, 1);
|
|
2397
|
+
lineMaterial = new ne({
|
|
2398
|
+
color: lr,
|
|
2255
2399
|
dashSize: .2,
|
|
2256
2400
|
depthTest: !1,
|
|
2257
2401
|
depthWrite: !1,
|
|
@@ -2259,14 +2403,14 @@ var ar = class e {
|
|
|
2259
2403
|
});
|
|
2260
2404
|
measureInProcess = !1;
|
|
2261
2405
|
moveState = "end";
|
|
2262
|
-
previewMarker = new
|
|
2406
|
+
previewMarker = new P(e.createPreviewGeometry(), new F({
|
|
2263
2407
|
color: 0,
|
|
2264
2408
|
depthTest: !1,
|
|
2265
2409
|
depthWrite: !1
|
|
2266
2410
|
}));
|
|
2267
2411
|
root = new D();
|
|
2268
|
-
snapDistance =
|
|
2269
|
-
startPoint = new
|
|
2412
|
+
snapDistance = ur;
|
|
2413
|
+
startPoint = new B();
|
|
2270
2414
|
unit = "m";
|
|
2271
2415
|
constructor(e) {
|
|
2272
2416
|
this.context = e, this.root.name = "BimatterDimensions", this.previewMarker.renderOrder = 5, this.previewMarker.visible = !1, this.root.add(this.previewMarker), this.context.scene.add(this.root);
|
|
@@ -2299,13 +2443,13 @@ var ar = class e {
|
|
|
2299
2443
|
});
|
|
2300
2444
|
}
|
|
2301
2445
|
setEndpointScaleFactor(e) {
|
|
2302
|
-
!Number.isFinite(e) || e <= 0 || (
|
|
2446
|
+
!Number.isFinite(e) || e <= 0 || (cr.scaleFactor = e);
|
|
2303
2447
|
}
|
|
2304
2448
|
setSnapDistance(e) {
|
|
2305
2449
|
!Number.isFinite(e) || e < 0 || (this.snapDistance = e);
|
|
2306
2450
|
}
|
|
2307
2451
|
setUnit(e) {
|
|
2308
|
-
this.unit = e,
|
|
2452
|
+
this.unit = e, cr.units = e, cr.scale = e === "mm" ? 1e3 : 1, this.dimensions.forEach((e) => {
|
|
2309
2453
|
e.endPoint = e.end;
|
|
2310
2454
|
}), this.currentDimension && (this.currentDimension.endPoint = this.currentDimension.end);
|
|
2311
2455
|
}
|
|
@@ -2331,7 +2475,7 @@ var ar = class e {
|
|
|
2331
2475
|
changeAxes() {
|
|
2332
2476
|
if (!this.measureInProcess || !this.currentDimension) return;
|
|
2333
2477
|
let e = this.currentDimension.end, t = this.getNextAxis();
|
|
2334
|
-
this.axis = t, this.currentDimension.endPoint =
|
|
2478
|
+
this.axis = t, this.currentDimension.endPoint = pr(this.startPoint, e, t);
|
|
2335
2479
|
}
|
|
2336
2480
|
updateFrame() {
|
|
2337
2481
|
if (!this.active) return;
|
|
@@ -2375,7 +2519,7 @@ var ar = class e {
|
|
|
2375
2519
|
this.currentDimension && (this.currentDimension.createBoundingBox(), this.dimensions.push(this.currentDimension), this.currentDimension = null, this.measureInProcess = !1, this.axis = null);
|
|
2376
2520
|
}
|
|
2377
2521
|
createDimension(e, t) {
|
|
2378
|
-
return new
|
|
2522
|
+
return new cr({
|
|
2379
2523
|
boundingMaterial: this.boundingMaterial,
|
|
2380
2524
|
endpointGeometry: this.endpointGeometry,
|
|
2381
2525
|
endpointMaterial: this.endpointMaterial,
|
|
@@ -2387,7 +2531,7 @@ var ar = class e {
|
|
|
2387
2531
|
});
|
|
2388
2532
|
}
|
|
2389
2533
|
getSnapObjects() {
|
|
2390
|
-
let e =
|
|
2534
|
+
let e = fr(this.context.modelRef.current);
|
|
2391
2535
|
return this.context.getExtraSnapObjects?.().forEach((t) => {
|
|
2392
2536
|
t.visible && e.push(t);
|
|
2393
2537
|
}), e;
|
|
@@ -2405,37 +2549,37 @@ var ar = class e {
|
|
|
2405
2549
|
return this.dimensions.map((e) => e.boundingBox).filter((e) => !!e);
|
|
2406
2550
|
}
|
|
2407
2551
|
getClosestVertex(e) {
|
|
2408
|
-
if (!(e.object instanceof
|
|
2552
|
+
if (!(e.object instanceof P) || !e.face) return e.point.clone();
|
|
2409
2553
|
let t = e.object.geometry.attributes.position;
|
|
2410
2554
|
if (!t) return e.point.clone();
|
|
2411
|
-
let n = [
|
|
2555
|
+
let n = this.context.cameraUtils.getActiveClippingPlanes(), r = [
|
|
2412
2556
|
e.face.a,
|
|
2413
2557
|
e.face.b,
|
|
2414
2558
|
e.face.c
|
|
2415
2559
|
].map((n) => {
|
|
2416
|
-
let r = new
|
|
2560
|
+
let r = new B(t.getX(n), t.getY(n), t.getZ(n));
|
|
2417
2561
|
return e.object.localToWorld(r);
|
|
2418
|
-
}).filter((t) => t.distanceTo(e.point) <= this.snapDistance);
|
|
2419
|
-
return
|
|
2562
|
+
}).filter((t) => t.distanceTo(e.point) <= this.snapDistance && $n(t, n));
|
|
2563
|
+
return r.length ? r.reduce((t, n) => n.distanceTo(e.point) < t.distanceTo(e.point) ? n : t) : e.point.clone();
|
|
2420
2564
|
}
|
|
2421
2565
|
getPreviewEndPoint(e, t) {
|
|
2422
2566
|
if (!t) return this.axis = null, e.clone();
|
|
2423
|
-
let n = this.axis ??
|
|
2424
|
-
return this.axis = n,
|
|
2567
|
+
let n = this.axis ?? mr(this.startPoint, e);
|
|
2568
|
+
return this.axis = n, pr(this.startPoint, e, n);
|
|
2425
2569
|
}
|
|
2426
2570
|
getNextAxis() {
|
|
2427
2571
|
switch (this.axis) {
|
|
2428
2572
|
case "x": return "y";
|
|
2429
2573
|
case "y": return "z";
|
|
2430
2574
|
case "z": return "x";
|
|
2431
|
-
default: return
|
|
2575
|
+
default: return dr;
|
|
2432
2576
|
}
|
|
2433
2577
|
}
|
|
2434
2578
|
getIsMoving() {
|
|
2435
2579
|
return this.moveState !== "end" && this.moveState !== "start";
|
|
2436
2580
|
}
|
|
2437
2581
|
rescalePreviewMarker() {
|
|
2438
|
-
let { camera: e, viewportHeight: t } = this.context, n = this.previewMarker.position.distanceTo(e.position), r = e instanceof
|
|
2582
|
+
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
2583
|
this.previewMarker.scale.setScalar(r);
|
|
2440
2584
|
}
|
|
2441
2585
|
setSelectionInteractionDisabled(e) {
|
|
@@ -2475,8 +2619,8 @@ var ar = class e {
|
|
|
2475
2619
|
return new de(.5, 16, 12);
|
|
2476
2620
|
}
|
|
2477
2621
|
};
|
|
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 = Ee(), d = c(() => new
|
|
2622
|
+
function gr(e, t, n, r) {
|
|
2623
|
+
let i = p((e) => e.camera), a = p((e) => e.gl), s = p((e) => e.scene), l = p((e) => e.size), u = Ee(), d = c(() => new hr({
|
|
2480
2624
|
camera: i,
|
|
2481
2625
|
cameraUtils: n,
|
|
2482
2626
|
controlRef: t,
|
|
@@ -2543,15 +2687,15 @@ function or(e, t, n, r) {
|
|
|
2543
2687
|
}
|
|
2544
2688
|
//#endregion
|
|
2545
2689
|
//#region src/viewer/utils/Hotkeys/useHotkeysUtils.tsx
|
|
2546
|
-
function
|
|
2690
|
+
function _r(e) {
|
|
2547
2691
|
return e instanceof HTMLElement ? e.isContentEditable || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement : !1;
|
|
2548
2692
|
}
|
|
2549
|
-
function
|
|
2550
|
-
let e =
|
|
2693
|
+
function vr() {
|
|
2694
|
+
let e = U((e) => e.api), t = U((e) => e.defaultHotkeysEnabled);
|
|
2551
2695
|
o(() => {
|
|
2552
2696
|
if (!t) return;
|
|
2553
2697
|
let n = (t) => {
|
|
2554
|
-
|
|
2698
|
+
_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
2699
|
};
|
|
2556
2700
|
return window.addEventListener("keydown", n), () => {
|
|
2557
2701
|
window.removeEventListener("keydown", n);
|
|
@@ -2559,69 +2703,9 @@ function cr() {
|
|
|
2559
2703
|
}, [e, t]);
|
|
2560
2704
|
}
|
|
2561
2705
|
//#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
2706
|
//#region src/viewer/Selector/SelectionBox.ts
|
|
2623
|
-
var
|
|
2624
|
-
function
|
|
2707
|
+
var yr = new B(), br = new B(), J = new z(), xr = new B(), Sr = new B(), Cr = new B(), wr = new B(), Tr = new B(), Er = new B(), Dr = new B();
|
|
2708
|
+
function Or(e) {
|
|
2625
2709
|
let t = e;
|
|
2626
2710
|
for (; t;) {
|
|
2627
2711
|
let e = t.modelID ?? t.userData.modelID;
|
|
@@ -2630,7 +2714,7 @@ function Cr(e) {
|
|
|
2630
2714
|
}
|
|
2631
2715
|
return 0;
|
|
2632
2716
|
}
|
|
2633
|
-
function
|
|
2717
|
+
function kr(e) {
|
|
2634
2718
|
let t = e;
|
|
2635
2719
|
for (; t;) {
|
|
2636
2720
|
if (!t.visible) return !1;
|
|
@@ -2638,16 +2722,16 @@ function wr(e) {
|
|
|
2638
2722
|
}
|
|
2639
2723
|
return !0;
|
|
2640
2724
|
}
|
|
2641
|
-
function
|
|
2642
|
-
return n.length ? (
|
|
2725
|
+
function Ar(e, t, n) {
|
|
2726
|
+
return n.length ? (xr.copy(t).applyMatrix4(e.matrixWorld), $n(xr, n)) : !0;
|
|
2643
2727
|
}
|
|
2644
|
-
function
|
|
2645
|
-
return i.length ? (
|
|
2646
|
-
let t = e.distanceToPoint(
|
|
2728
|
+
function jr(e, t, n, r, i) {
|
|
2729
|
+
return i.length ? (Sr.copy(t).applyMatrix4(e.matrixWorld), Cr.copy(n).applyMatrix4(e.matrixWorld), wr.copy(r).applyMatrix4(e.matrixWorld), i.every((e) => {
|
|
2730
|
+
let t = e.distanceToPoint(Sr), n = e.distanceToPoint(Cr), r = e.distanceToPoint(wr);
|
|
2647
2731
|
return !(t < -1e-6 && n < -1e-6 && r < -1e-6);
|
|
2648
2732
|
})) : !0;
|
|
2649
2733
|
}
|
|
2650
|
-
function
|
|
2734
|
+
function Mr(e) {
|
|
2651
2735
|
let t = e.getBoundingClientRect();
|
|
2652
2736
|
return {
|
|
2653
2737
|
height: t.height,
|
|
@@ -2656,7 +2740,7 @@ function Dr(e) {
|
|
|
2656
2740
|
width: t.width
|
|
2657
2741
|
};
|
|
2658
2742
|
}
|
|
2659
|
-
function
|
|
2743
|
+
function Nr(e) {
|
|
2660
2744
|
return {
|
|
2661
2745
|
boundsCheckMs: 0,
|
|
2662
2746
|
candidateIds: 0,
|
|
@@ -2682,7 +2766,7 @@ function Or(e) {
|
|
|
2682
2766
|
triangleProjectionMs: 0
|
|
2683
2767
|
};
|
|
2684
2768
|
}
|
|
2685
|
-
function
|
|
2769
|
+
function Pr(e, t) {
|
|
2686
2770
|
return {
|
|
2687
2771
|
minX: Math.min(e.x, t.x),
|
|
2688
2772
|
minY: Math.min(e.y, t.y),
|
|
@@ -2690,43 +2774,43 @@ function kr(e, t) {
|
|
|
2690
2774
|
maxY: Math.max(e.y, t.y)
|
|
2691
2775
|
};
|
|
2692
2776
|
}
|
|
2693
|
-
function
|
|
2777
|
+
function Fr(e, t) {
|
|
2694
2778
|
return t.x >= e.x ? "contains" : "intersects";
|
|
2695
2779
|
}
|
|
2696
|
-
function
|
|
2697
|
-
return
|
|
2780
|
+
function Ir(e, t) {
|
|
2781
|
+
return Lr(e.x, e.y, t);
|
|
2698
2782
|
}
|
|
2699
|
-
function
|
|
2783
|
+
function Lr(e, t, n) {
|
|
2700
2784
|
return e >= n.minX && e <= n.maxX && t >= n.minY && t <= n.maxY;
|
|
2701
2785
|
}
|
|
2702
|
-
function
|
|
2786
|
+
function Rr(e, t, n, r, i, a) {
|
|
2703
2787
|
return (a - t) * (n - e) > (r - t) * (i - e);
|
|
2704
2788
|
}
|
|
2705
|
-
function
|
|
2706
|
-
return
|
|
2789
|
+
function zr(e, t, n, r, i, a, o, s) {
|
|
2790
|
+
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
2791
|
}
|
|
2708
|
-
function
|
|
2792
|
+
function Br(e, t, n, r, i) {
|
|
2709
2793
|
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
2794
|
return s >= 0 && c >= 0 && s + c <= 2 * a * o;
|
|
2711
2795
|
}
|
|
2712
|
-
function
|
|
2713
|
-
return
|
|
2796
|
+
function Vr(e, t, n, r) {
|
|
2797
|
+
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
2798
|
}
|
|
2715
|
-
function
|
|
2716
|
-
return
|
|
2799
|
+
function Hr(e, t, n) {
|
|
2800
|
+
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
2801
|
}
|
|
2718
|
-
function
|
|
2719
|
-
let a =
|
|
2802
|
+
function Ur(e, t, n, r, i = new z()) {
|
|
2803
|
+
let a = yr.copy(t).applyMatrix4(e.matrixWorld).project(n);
|
|
2720
2804
|
return i.set((a.x + 1) / 2 * r.width + r.left, (-a.y + 1) / 2 * r.height + r.top);
|
|
2721
2805
|
}
|
|
2722
|
-
function
|
|
2806
|
+
function Wr(e, t, n, r, i) {
|
|
2723
2807
|
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++)
|
|
2808
|
+
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, J), a = Math.min(a, J.x), o = Math.max(o, J.x), s = Math.min(s, J.y), c = Math.max(c, J.y), Ir(J, n) && (l += 1);
|
|
2725
2809
|
return o < n.minX || a > n.maxX || c < n.minY || s > n.maxY ? xe : l === 8 ? ve : ye;
|
|
2726
2810
|
}
|
|
2727
|
-
function
|
|
2811
|
+
function Gr(e, t, n, r) {
|
|
2728
2812
|
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++)
|
|
2813
|
+
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, J), i = Math.min(i, J.x), a = Math.max(a, J.x), o = Math.min(o, J.y), s = Math.max(s, J.y);
|
|
2730
2814
|
return {
|
|
2731
2815
|
minX: i,
|
|
2732
2816
|
minY: o,
|
|
@@ -2734,41 +2818,41 @@ function Br(e, t, n, r) {
|
|
|
2734
2818
|
maxY: s
|
|
2735
2819
|
};
|
|
2736
2820
|
}
|
|
2737
|
-
function
|
|
2821
|
+
function Kr(e, t) {
|
|
2738
2822
|
return !(e.maxX < t.minX || e.minX > t.maxX || e.maxY < t.minY || e.minY > t.maxY);
|
|
2739
2823
|
}
|
|
2740
|
-
function
|
|
2824
|
+
function qr(e, t, n, r) {
|
|
2741
2825
|
e.geometry.boundingBox || e.geometry.computeBoundingBox();
|
|
2742
2826
|
let i = e.geometry.boundingBox;
|
|
2743
|
-
return i ?
|
|
2827
|
+
return i ? Kr(Gr(e, i, n, r), t) : !0;
|
|
2744
2828
|
}
|
|
2745
|
-
function
|
|
2829
|
+
function Jr(e, t, n) {
|
|
2746
2830
|
let r = e.get(t);
|
|
2747
2831
|
r || (r = /* @__PURE__ */ new Set(), e.set(t, r)), r.add(n);
|
|
2748
2832
|
}
|
|
2749
|
-
function
|
|
2833
|
+
function Yr(e) {
|
|
2750
2834
|
let t = 0;
|
|
2751
2835
|
return e.forEach((e) => {
|
|
2752
2836
|
t += e.size;
|
|
2753
2837
|
}), t;
|
|
2754
2838
|
}
|
|
2755
|
-
function
|
|
2839
|
+
function Xr(e, t, n, r = []) {
|
|
2756
2840
|
let i = e.geometry, a = i.index, o = i.attributes.ids, s = i.attributes.position;
|
|
2757
2841
|
if (!a || !o || !s) return;
|
|
2758
2842
|
let c = t * 3;
|
|
2759
|
-
r.length && (
|
|
2843
|
+
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
2844
|
}
|
|
2761
|
-
function
|
|
2762
|
-
let s = performance.now(), c = /* @__PURE__ */ new Map(), l = new
|
|
2845
|
+
function Zr({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i, clippingPlanes: a, profile: o }) {
|
|
2846
|
+
let s = performance.now(), c = /* @__PURE__ */ new Map(), l = new B();
|
|
2763
2847
|
e.traverse((e) => {
|
|
2764
2848
|
let s = e;
|
|
2765
|
-
if (!s.isMesh || !
|
|
2849
|
+
if (!s.isMesh || !kr(s)) return;
|
|
2766
2850
|
let u = s.geometry.attributes.ids, d = s.geometry.attributes.position;
|
|
2767
2851
|
if (!(!u || !d)) {
|
|
2768
2852
|
o && (o.containedVerticesVisited += u.count);
|
|
2769
2853
|
for (let e = 0; e < u.count; e++) {
|
|
2770
|
-
let f =
|
|
2771
|
-
if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !
|
|
2854
|
+
let f = Or(s), p = u.getX(e);
|
|
2855
|
+
if (!i.get(f)?.has(p) || (l.fromBufferAttribute(d, e), !Ar(s, l, a))) continue;
|
|
2772
2856
|
o && (o.containedCandidateVertices += 1);
|
|
2773
2857
|
let m = `${f}:${p}`, h = c.get(m);
|
|
2774
2858
|
h || (h = {
|
|
@@ -2776,23 +2860,23 @@ function Kr({ model: e, camera: t, viewport: n, rect: r, candidateIdsByModel: i,
|
|
|
2776
2860
|
inside: 0,
|
|
2777
2861
|
modelID: f,
|
|
2778
2862
|
total: 0
|
|
2779
|
-
}, c.set(m, h)), h.total += 1,
|
|
2863
|
+
}, c.set(m, h)), h.total += 1, Ir(Ur(s, l, t, n), r) && (h.inside += 1);
|
|
2780
2864
|
}
|
|
2781
2865
|
}
|
|
2782
2866
|
});
|
|
2783
2867
|
let u = /* @__PURE__ */ new Map();
|
|
2784
2868
|
return c.forEach((e) => {
|
|
2785
|
-
e.total > 0 && e.total === e.inside &&
|
|
2869
|
+
e.total > 0 && e.total === e.inside && Jr(u, e.modelID, e.id);
|
|
2786
2870
|
}), o && (o.containedIdsMs += performance.now() - s), u;
|
|
2787
2871
|
}
|
|
2788
|
-
function
|
|
2872
|
+
function Qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect: i, mode: a, profile: o }) {
|
|
2789
2873
|
let s = performance.now(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
2790
2874
|
if (!e) return c;
|
|
2791
|
-
let u =
|
|
2875
|
+
let u = Mr(r), d = performance.now();
|
|
2792
2876
|
e.updateMatrixWorld(!0), t.updateMatrixWorld(), o && (o.matrixUpdateMs += performance.now() - d), e.traverse((e) => {
|
|
2793
2877
|
let r = e;
|
|
2794
2878
|
if (!r.isMesh) return;
|
|
2795
|
-
if (o && (o.meshCount += 1), !
|
|
2879
|
+
if (o && (o.meshCount += 1), !kr(r)) {
|
|
2796
2880
|
o && (o.skippedMeshCount += 1);
|
|
2797
2881
|
return;
|
|
2798
2882
|
}
|
|
@@ -2801,7 +2885,7 @@ function qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
|
|
|
2801
2885
|
o && (o.skippedMeshCount += 1);
|
|
2802
2886
|
return;
|
|
2803
2887
|
}
|
|
2804
|
-
let d = performance.now(), f =
|
|
2888
|
+
let d = performance.now(), f = qr(r, i, t, u);
|
|
2805
2889
|
if (o && (o.boundsCheckMs += performance.now() - d), !f) {
|
|
2806
2890
|
o && (o.skippedMeshCount += 1);
|
|
2807
2891
|
return;
|
|
@@ -2809,26 +2893,26 @@ function qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
|
|
|
2809
2893
|
let p = performance.now();
|
|
2810
2894
|
s.shapecast({
|
|
2811
2895
|
intersectsBounds: (e) => {
|
|
2812
|
-
let n = performance.now(), a =
|
|
2896
|
+
let n = performance.now(), a = Wr(r, e, i, t, u);
|
|
2813
2897
|
return o && (o.intersectsBoundsCalls += 1, o.intersectsBoundsMs += performance.now() - n), a;
|
|
2814
2898
|
},
|
|
2815
2899
|
intersectsRange: (e, t, i) => {
|
|
2816
2900
|
let u = performance.now();
|
|
2817
2901
|
if (o && (o.intersectsRangeCalls += 1), !i) return o && (o.intersectsRangeMs += performance.now() - u), !1;
|
|
2818
|
-
for (let i = e; i < e + t; i++)
|
|
2902
|
+
for (let i = e; i < e + t; i++) Xr(r, s.resolveTriangleIndex(i), a === "contains" ? l : c, n);
|
|
2819
2903
|
return o && (o.intersectsRangeMs += performance.now() - u), !1;
|
|
2820
2904
|
},
|
|
2821
2905
|
intersectsTriangle: (e, s, d) => {
|
|
2822
2906
|
let f = performance.now();
|
|
2823
2907
|
if (o && (o.intersectsTriangleCalls += 1), !d) {
|
|
2824
|
-
let n = performance.now(), a =
|
|
2825
|
-
if (o && (o.triangleProjectionMs += performance.now() - n), !
|
|
2908
|
+
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);
|
|
2909
|
+
if (o && (o.triangleProjectionMs += performance.now() - n), !Vr(a, s, c, i)) return o && (o.intersectsTriangleMs += performance.now() - f), !1;
|
|
2826
2910
|
}
|
|
2827
|
-
return a === "contains" ?
|
|
2911
|
+
return a === "contains" ? Xr(r, s, l, n) : Xr(r, s, c, n), o && (o.intersectsTriangleMs += performance.now() - f), !1;
|
|
2828
2912
|
}
|
|
2829
2913
|
}), o && (o.shapecastMs += performance.now() - p);
|
|
2830
2914
|
});
|
|
2831
|
-
let f = a === "contains" ?
|
|
2915
|
+
let f = a === "contains" ? Zr({
|
|
2832
2916
|
model: e,
|
|
2833
2917
|
camera: t,
|
|
2834
2918
|
clippingPlanes: n,
|
|
@@ -2837,19 +2921,19 @@ function qr({ model: e, camera: t, clippingPlanes: n = [], domElement: r, rect:
|
|
|
2837
2921
|
candidateIdsByModel: l,
|
|
2838
2922
|
profile: o
|
|
2839
2923
|
}) : c;
|
|
2840
|
-
return o && (o.candidateIds =
|
|
2924
|
+
return o && (o.candidateIds = Yr(l), o.selectedIds = Yr(f), o.totalMs = performance.now() - s), f;
|
|
2841
2925
|
}
|
|
2842
|
-
function
|
|
2843
|
-
let t =
|
|
2926
|
+
function $r(e) {
|
|
2927
|
+
let t = Nr(e.mode);
|
|
2844
2928
|
return {
|
|
2845
|
-
ids:
|
|
2929
|
+
ids: Qr({
|
|
2846
2930
|
...e,
|
|
2847
2931
|
profile: t
|
|
2848
2932
|
}),
|
|
2849
2933
|
profile: t
|
|
2850
2934
|
};
|
|
2851
2935
|
}
|
|
2852
|
-
function
|
|
2936
|
+
function ei(e) {
|
|
2853
2937
|
return e === "contains" ? {
|
|
2854
2938
|
border: "rgb(37, 99, 235)",
|
|
2855
2939
|
background: "rgba(37, 99, 235, 0.16)"
|
|
@@ -2858,32 +2942,32 @@ function Yr(e) {
|
|
|
2858
2942
|
background: "rgba(22, 163, 74, 0.16)"
|
|
2859
2943
|
};
|
|
2860
2944
|
}
|
|
2861
|
-
function
|
|
2862
|
-
let r =
|
|
2945
|
+
function ti(e, t, n) {
|
|
2946
|
+
let r = ei(Fr(t, n));
|
|
2863
2947
|
if (!e.current) {
|
|
2864
2948
|
let t = document.createElement("div");
|
|
2865
2949
|
t.style.position = "fixed", t.style.pointerEvents = "none", t.style.zIndex = "10", e.current = t, document.body.appendChild(t);
|
|
2866
2950
|
}
|
|
2867
|
-
let i =
|
|
2951
|
+
let i = Pr(t, n);
|
|
2868
2952
|
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
2953
|
}
|
|
2870
|
-
function
|
|
2954
|
+
function ni(e) {
|
|
2871
2955
|
e.current?.remove(), e.current = null;
|
|
2872
2956
|
}
|
|
2873
2957
|
//#endregion
|
|
2874
2958
|
//#region src/viewer/Selector/useSelector.tsx
|
|
2875
|
-
var
|
|
2876
|
-
function
|
|
2959
|
+
var ri = 40;
|
|
2960
|
+
function ii(e) {
|
|
2877
2961
|
if (!Array.isArray(e)) return e.userData.shader;
|
|
2878
2962
|
}
|
|
2879
|
-
function
|
|
2880
|
-
let n =
|
|
2963
|
+
function ai(e, t) {
|
|
2964
|
+
let n = ii(e)?.uniforms.preSelectionId;
|
|
2881
2965
|
n && (n.value = t);
|
|
2882
2966
|
}
|
|
2883
|
-
function
|
|
2967
|
+
function oi(e) {
|
|
2884
2968
|
return Number(e.current?.modelID ?? 0);
|
|
2885
2969
|
}
|
|
2886
|
-
function
|
|
2970
|
+
function si(e) {
|
|
2887
2971
|
let t = e;
|
|
2888
2972
|
for (; t;) {
|
|
2889
2973
|
let e = t.modelID ?? t.userData.modelID;
|
|
@@ -2892,7 +2976,7 @@ function ni(e) {
|
|
|
2892
2976
|
}
|
|
2893
2977
|
return 0;
|
|
2894
2978
|
}
|
|
2895
|
-
function
|
|
2979
|
+
function ci(e) {
|
|
2896
2980
|
let t = e;
|
|
2897
2981
|
for (; t;) {
|
|
2898
2982
|
if (!t.visible) return !1;
|
|
@@ -2900,24 +2984,24 @@ function ri(e) {
|
|
|
2900
2984
|
}
|
|
2901
2985
|
return !0;
|
|
2902
2986
|
}
|
|
2903
|
-
function
|
|
2904
|
-
if (!
|
|
2987
|
+
function li(e) {
|
|
2988
|
+
if (!ci(e.object) || !(e.object instanceof P) || e.faceIndex === void 0 || e.faceIndex === null) return !1;
|
|
2905
2989
|
let t = e.object.geometry;
|
|
2906
2990
|
return !!(t.index && t.attributes.ids);
|
|
2907
2991
|
}
|
|
2908
|
-
function
|
|
2909
|
-
if (!
|
|
2992
|
+
function ui(e) {
|
|
2993
|
+
if (!li(e)) return null;
|
|
2910
2994
|
let t = e.object, n = t.geometry, r = n.index.getX(e.faceIndex * 3), i = n.attributes.ids;
|
|
2911
2995
|
if (r >= i.count) return null;
|
|
2912
2996
|
let a = n.attributes.modelID;
|
|
2913
2997
|
return {
|
|
2914
2998
|
elementID: i.getX(r),
|
|
2915
2999
|
hit: e,
|
|
2916
|
-
modelID: a ? a.getX(r) :
|
|
3000
|
+
modelID: a ? a.getX(r) : si(t)
|
|
2917
3001
|
};
|
|
2918
3002
|
}
|
|
2919
|
-
function
|
|
2920
|
-
let s = l("end"), c =
|
|
3003
|
+
function di(e, t, n, r, i, a) {
|
|
3004
|
+
let s = l("end"), c = U((e) => e.selected), u = U((e) => e.setSelected), d = U((e) => e.addSelected), f = U((e) => e.removeSelected), m = U((e) => e.showStats), h = Ee(), g = l(null), _ = l(null), v = l(!1), y = l(!1), b = l("add"), x = l(null), S = l(!1), C = l(0), w = l(null), T = l(null), E = () => h.getState().selectionInteractionDisabled, D = (e) => {
|
|
2921
3005
|
if (r) {
|
|
2922
3006
|
r(e);
|
|
2923
3007
|
return;
|
|
@@ -2926,22 +3010,22 @@ function oi(e, t, n, r, i, a) {
|
|
|
2926
3010
|
n && (n.cancel(), n.setOrbitPoint(e.x, e.y, e.z));
|
|
2927
3011
|
}, O = () => {
|
|
2928
3012
|
a?.(null), e.current?.traverse((e) => {
|
|
2929
|
-
if (!(e instanceof
|
|
3013
|
+
if (!(e instanceof P)) return;
|
|
2930
3014
|
let t = e;
|
|
2931
|
-
t.preselected = !1,
|
|
3015
|
+
t.preselected = !1, ai(t.material, -1);
|
|
2932
3016
|
});
|
|
2933
3017
|
}, ee = (t, n) => {
|
|
2934
3018
|
a?.({
|
|
2935
3019
|
elementID: n,
|
|
2936
3020
|
modelID: t
|
|
2937
3021
|
}), e.current?.traverse((e) => {
|
|
2938
|
-
if (!(e instanceof
|
|
3022
|
+
if (!(e instanceof P) || si(e) !== t) return;
|
|
2939
3023
|
let r = e;
|
|
2940
|
-
r.preselected = !0,
|
|
3024
|
+
r.preselected = !0, ai(r.material, n);
|
|
2941
3025
|
});
|
|
2942
3026
|
}, te = () => {
|
|
2943
|
-
g.current = null, v.current = !1,
|
|
2944
|
-
},
|
|
3027
|
+
g.current = null, v.current = !1, ni(_), t.current && (t.current.enabled = !0);
|
|
3028
|
+
}, ne = (e) => {
|
|
2945
3029
|
if (E()) {
|
|
2946
3030
|
O();
|
|
2947
3031
|
return;
|
|
@@ -2954,10 +3038,10 @@ function oi(e, t, n, r, i, a) {
|
|
|
2954
3038
|
O();
|
|
2955
3039
|
return;
|
|
2956
3040
|
}
|
|
2957
|
-
let t =
|
|
3041
|
+
let t = R(e);
|
|
2958
3042
|
O(), t && ee(t.modelID, t.elementID);
|
|
2959
3043
|
};
|
|
2960
|
-
function
|
|
3044
|
+
function k() {
|
|
2961
3045
|
return performance.now();
|
|
2962
3046
|
}
|
|
2963
3047
|
let A = (e) => {
|
|
@@ -2966,11 +3050,11 @@ function oi(e, t, n, r, i, a) {
|
|
|
2966
3050
|
return;
|
|
2967
3051
|
}
|
|
2968
3052
|
if (T.current = e, w.current !== null) return;
|
|
2969
|
-
let t =
|
|
3053
|
+
let t = k() - C.current, n = Math.max(0, ri - t);
|
|
2970
3054
|
w.current = window.setTimeout(() => {
|
|
2971
3055
|
w.current = null;
|
|
2972
3056
|
let e = T.current;
|
|
2973
|
-
T.current = null, e && (C.current = performance.now(),
|
|
3057
|
+
T.current = null, e && (C.current = performance.now(), ne(e));
|
|
2974
3058
|
}, n);
|
|
2975
3059
|
}, j = l(null);
|
|
2976
3060
|
o(() => {
|
|
@@ -2981,14 +3065,14 @@ function oi(e, t, n, r, i, a) {
|
|
|
2981
3065
|
}
|
|
2982
3066
|
m && j.current !== null && (console.log("selection spend:", Date.now() - j.current, "ms"), j.current = null);
|
|
2983
3067
|
}, [c, m]);
|
|
2984
|
-
let { camera: M, gl:
|
|
3068
|
+
let { camera: M, gl: N } = p();
|
|
2985
3069
|
function F() {
|
|
2986
3070
|
return Date.now();
|
|
2987
3071
|
}
|
|
2988
3072
|
let re = (e) => {
|
|
2989
|
-
let t =
|
|
3073
|
+
let t = N.domElement.getBoundingClientRect();
|
|
2990
3074
|
return e.clientX >= t.left && e.clientX <= t.right && e.clientY >= t.top && e.clientY <= t.bottom;
|
|
2991
|
-
},
|
|
3075
|
+
}, ie = (t) => {
|
|
2992
3076
|
if (E()) {
|
|
2993
3077
|
S.current = !1, y.current = !1, O();
|
|
2994
3078
|
return;
|
|
@@ -3003,7 +3087,7 @@ function oi(e, t, n, r, i, a) {
|
|
|
3003
3087
|
s.current = "end";
|
|
3004
3088
|
return;
|
|
3005
3089
|
}
|
|
3006
|
-
let n = t.shiftKey, r = t.ctrlKey, i =
|
|
3090
|
+
let n = t.shiftKey, r = t.ctrlKey, i = R(t), a, o = oi(e), l = null;
|
|
3007
3091
|
if (i && (o = i.modelID, l = i.hit.point, a = i.elementID), r) {
|
|
3008
3092
|
a !== void 0 && f(o, [a]);
|
|
3009
3093
|
return;
|
|
@@ -3012,33 +3096,33 @@ function oi(e, t, n, r, i, a) {
|
|
|
3012
3096
|
return;
|
|
3013
3097
|
}
|
|
3014
3098
|
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
3099
|
}, ae = (e) => {
|
|
3100
|
+
E() || e.button !== 0 || !e.shiftKey && !e.ctrlKey || (g.current = new z(e.clientX, e.clientY), b.current = e.ctrlKey ? "remove" : "add", v.current = !1, t.current && (t.current.enabled = !1));
|
|
3101
|
+
}, oe = (e) => {
|
|
3018
3102
|
if (E()) {
|
|
3019
3103
|
te();
|
|
3020
3104
|
return;
|
|
3021
3105
|
}
|
|
3022
3106
|
if (!g.current) return;
|
|
3023
|
-
let t = new
|
|
3024
|
-
n < 6 && r < 6 || (v.current ||= !0, e.preventDefault(),
|
|
3025
|
-
},
|
|
3107
|
+
let t = new z(e.clientX, e.clientY), n = Math.abs(t.x - g.current.x), r = Math.abs(t.y - g.current.y);
|
|
3108
|
+
n < 6 && r < 6 || (v.current ||= !0, e.preventDefault(), ti(_, g.current, t));
|
|
3109
|
+
}, se = (r) => {
|
|
3026
3110
|
if (E()) {
|
|
3027
3111
|
te();
|
|
3028
3112
|
return;
|
|
3029
3113
|
}
|
|
3030
3114
|
if (!g.current) return;
|
|
3031
3115
|
j.current = F();
|
|
3032
|
-
let i = v.current, a = new
|
|
3033
|
-
if (g.current = null, v.current = !1,
|
|
3116
|
+
let i = v.current, a = new z(r.clientX, r.clientY), o = Pr(g.current, a), s = Fr(g.current, a);
|
|
3117
|
+
if (g.current = null, v.current = !1, ni(_), t.current && setTimeout(() => {
|
|
3034
3118
|
t.current && (t.current.enabled = !0);
|
|
3035
3119
|
}, 100), !i) return;
|
|
3036
3120
|
y.current = !0, r.preventDefault();
|
|
3037
|
-
let { ids: c, profile: l } =
|
|
3121
|
+
let { ids: c, profile: l } = $r({
|
|
3038
3122
|
model: e.current,
|
|
3039
3123
|
camera: M,
|
|
3040
3124
|
clippingPlanes: n.getActiveClippingPlanes(),
|
|
3041
|
-
domElement:
|
|
3125
|
+
domElement: N.domElement,
|
|
3042
3126
|
rect: o,
|
|
3043
3127
|
mode: s
|
|
3044
3128
|
}), u = Array.from(c.values()).reduce((e, t) => e + t.size, 0), p = {
|
|
@@ -3050,31 +3134,26 @@ function oi(e, t, n, r, i, a) {
|
|
|
3050
3134
|
let n = Array.from(e);
|
|
3051
3135
|
b.current === "remove" ? f(t, n) : d(t, n);
|
|
3052
3136
|
}));
|
|
3053
|
-
},
|
|
3137
|
+
}, I = (e, t) => {
|
|
3054
3138
|
let r = Array.isArray(t) ? t.filter((e) => e.visible) : t ? [t] : [];
|
|
3055
3139
|
return r.length ? n.getIntersection(!1, {
|
|
3056
3140
|
event: e,
|
|
3057
|
-
filter:
|
|
3141
|
+
filter: li,
|
|
3058
3142
|
object: r,
|
|
3059
3143
|
recursive: !0
|
|
3060
3144
|
}) : [];
|
|
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);
|
|
3145
|
+
}, L = () => i?.().filter((e) => e.visible) ?? [], ce = (e, t) => {
|
|
3146
|
+
let n = I(e, t);
|
|
3147
|
+
for (let e of n) {
|
|
3148
|
+
let t = ui(e);
|
|
3070
3149
|
if (t) return t;
|
|
3071
3150
|
}
|
|
3072
3151
|
return null;
|
|
3073
|
-
};
|
|
3152
|
+
}, R = (t) => ce(t, L()) || ce(t, e.current);
|
|
3074
3153
|
o(() => {
|
|
3075
3154
|
let e = t.current;
|
|
3076
3155
|
if (!e) return;
|
|
3077
|
-
|
|
3156
|
+
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
3157
|
function n() {
|
|
3079
3158
|
typeof s.current == "number" ? s.current += 1 : s.current === "start" && (s.current = 1);
|
|
3080
3159
|
}
|
|
@@ -3090,49 +3169,49 @@ function oi(e, t, n, r, i, a) {
|
|
|
3090
3169
|
e.ctrlKey && e.preventDefault();
|
|
3091
3170
|
}
|
|
3092
3171
|
return () => {
|
|
3093
|
-
|
|
3172
|
+
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
3173
|
};
|
|
3095
3174
|
});
|
|
3096
3175
|
}
|
|
3097
3176
|
//#endregion
|
|
3098
3177
|
//#region src/viewer/Camera/useCameraFit.tsx
|
|
3099
|
-
var
|
|
3100
|
-
function
|
|
3178
|
+
var fi = new B(1, 1, 1).normalize(), pi = 1.18;
|
|
3179
|
+
function mi() {
|
|
3101
3180
|
let { camera: e } = p();
|
|
3102
3181
|
return i((t, n, r) => {
|
|
3103
|
-
if (!t.current || !(e instanceof
|
|
3182
|
+
if (!t.current || !(e instanceof se)) return;
|
|
3104
3183
|
let i = new g().setFromObject(t.current);
|
|
3105
3184
|
if (i.isEmpty()) return;
|
|
3106
|
-
let a = i.getCenter(new
|
|
3107
|
-
e.position.copy(a).addScaledVector(
|
|
3185
|
+
let a = i.getCenter(new B()), o = i.getBoundingSphere(new ue()), 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;
|
|
3186
|
+
e.position.copy(a).addScaledVector(fi, u), e.up.set(0, 1, 0), e.lookAt(a), e.updateProjectionMatrix();
|
|
3108
3187
|
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(
|
|
3188
|
+
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
3189
|
}, [e]);
|
|
3111
3190
|
}
|
|
3112
3191
|
//#endregion
|
|
3113
3192
|
//#region src/viewer/store/ViewerStoreProvider.tsx
|
|
3114
|
-
function
|
|
3193
|
+
function hi({ children: e, store: t }) {
|
|
3115
3194
|
let [n] = u(() => t ?? Ae());
|
|
3116
|
-
return /* @__PURE__ */
|
|
3195
|
+
return /* @__PURE__ */ V(Te.Provider, {
|
|
3117
3196
|
value: n,
|
|
3118
3197
|
children: e
|
|
3119
3198
|
});
|
|
3120
3199
|
}
|
|
3121
3200
|
//#endregion
|
|
3122
3201
|
//#region src/viewer/utils/ExportUtils/ExportUtils.ts
|
|
3123
|
-
var
|
|
3124
|
-
function
|
|
3202
|
+
var gi = new TextEncoder(), _i = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", vi = "Unknown", yi = ["elementID", "ifcguid"], bi = 0, xi = 33;
|
|
3203
|
+
function Si(e) {
|
|
3125
3204
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3126
3205
|
}
|
|
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 :
|
|
3206
|
+
function Ci(e, t) {
|
|
3207
|
+
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
3208
|
}
|
|
3130
|
-
function
|
|
3131
|
-
let n =
|
|
3209
|
+
function wi(e, t) {
|
|
3210
|
+
let n = Ci(e, t);
|
|
3132
3211
|
if (n !== null) return n;
|
|
3133
3212
|
if (Array.isArray(e)) {
|
|
3134
3213
|
if (!e.length) return t;
|
|
3135
|
-
let n = e.map((e) =>
|
|
3214
|
+
let n = e.map((e) => Ci(e, t));
|
|
3136
3215
|
if (n.every((e) => e !== null)) {
|
|
3137
3216
|
let e = n.join(", ");
|
|
3138
3217
|
return e.trim() ? e : t;
|
|
@@ -3145,21 +3224,21 @@ function yi(e, t) {
|
|
|
3145
3224
|
return t;
|
|
3146
3225
|
}
|
|
3147
3226
|
}
|
|
3148
|
-
function
|
|
3227
|
+
function Y(e) {
|
|
3149
3228
|
return typeof e == "string" && e.trim() ? e : null;
|
|
3150
3229
|
}
|
|
3151
|
-
function
|
|
3152
|
-
let t =
|
|
3153
|
-
return
|
|
3230
|
+
function Ti(e) {
|
|
3231
|
+
let t = Si(e.props) ? e.props : {};
|
|
3232
|
+
return Y(e.type ?? e.Type ?? t.type ?? t.Type) ?? vi;
|
|
3154
3233
|
}
|
|
3155
|
-
function
|
|
3156
|
-
let t =
|
|
3157
|
-
return
|
|
3234
|
+
function Ei(e) {
|
|
3235
|
+
let t = Si(e.props) ? e.props : {};
|
|
3236
|
+
return Y(e.guid ?? e.GlobalId ?? e.globalId ?? t.guid ?? t.GlobalId ?? t.globalId) ?? "";
|
|
3158
3237
|
}
|
|
3159
|
-
function
|
|
3160
|
-
return
|
|
3238
|
+
function Di(e, t) {
|
|
3239
|
+
return Y(e.Name) ?? Y(e.name) ?? Y(e.DisplayName) ?? Y(e.displayName) ?? `Property ${t + 1}`;
|
|
3161
3240
|
}
|
|
3162
|
-
function
|
|
3241
|
+
function Oi(e) {
|
|
3163
3242
|
for (let t of [
|
|
3164
3243
|
"NominalValue",
|
|
3165
3244
|
"nominalValue",
|
|
@@ -3182,18 +3261,18 @@ function Ci(e) {
|
|
|
3182
3261
|
"description"
|
|
3183
3262
|
].includes(e)));
|
|
3184
3263
|
}
|
|
3185
|
-
function
|
|
3186
|
-
return
|
|
3264
|
+
function ki(e, t) {
|
|
3265
|
+
return Y(e.name) ?? Y(e.Name) ?? `Set ${t + 1}`;
|
|
3187
3266
|
}
|
|
3188
|
-
function
|
|
3267
|
+
function Ai(e) {
|
|
3189
3268
|
let t = e.props;
|
|
3190
|
-
return Array.isArray(t) ? t.map((e, t) =>
|
|
3191
|
-
label:
|
|
3192
|
-
value:
|
|
3269
|
+
return Array.isArray(t) ? t.map((e, t) => Si(e) ? {
|
|
3270
|
+
label: Di(e, t),
|
|
3271
|
+
value: Oi(e)
|
|
3193
3272
|
} : {
|
|
3194
3273
|
label: `Property ${t + 1}`,
|
|
3195
3274
|
value: e
|
|
3196
|
-
}) :
|
|
3275
|
+
}) : Si(t) ? Object.entries(t).map(([e, t]) => ({
|
|
3197
3276
|
label: e,
|
|
3198
3277
|
value: t
|
|
3199
3278
|
})) : Object.entries(e).filter(([e]) => ![
|
|
@@ -3207,14 +3286,14 @@ function Ti(e) {
|
|
|
3207
3286
|
value: t
|
|
3208
3287
|
}));
|
|
3209
3288
|
}
|
|
3210
|
-
function
|
|
3289
|
+
function ji(e, t) {
|
|
3211
3290
|
e.columnSet.has(t) || (e.columnSet.add(t), e.columns.push(t));
|
|
3212
3291
|
}
|
|
3213
|
-
function
|
|
3292
|
+
function Mi(e, t, n, r, i) {
|
|
3214
3293
|
let a = n.trim();
|
|
3215
|
-
a && (
|
|
3294
|
+
a && (ji(e, a), t[a] = wi(r, i));
|
|
3216
3295
|
}
|
|
3217
|
-
function
|
|
3296
|
+
function Ni(e, t, n) {
|
|
3218
3297
|
let r = {};
|
|
3219
3298
|
return Object.entries(t).forEach(([t, i]) => {
|
|
3220
3299
|
[
|
|
@@ -3222,33 +3301,33 @@ function Oi(e, t, n) {
|
|
|
3222
3301
|
"guid",
|
|
3223
3302
|
"props",
|
|
3224
3303
|
"sets"
|
|
3225
|
-
].includes(t) ||
|
|
3226
|
-
}),
|
|
3227
|
-
|
|
3304
|
+
].includes(t) || Mi(e, r, t, i, n);
|
|
3305
|
+
}), Si(t.props) && Object.entries(t.props).forEach(([t, i]) => {
|
|
3306
|
+
Mi(e, r, t, i, n);
|
|
3228
3307
|
}), Array.isArray(t.sets) && t.sets.forEach((t, i) => {
|
|
3229
|
-
let a =
|
|
3230
|
-
|
|
3231
|
-
|
|
3308
|
+
let a = ki(t, i);
|
|
3309
|
+
Ai(t).forEach((t) => {
|
|
3310
|
+
Mi(e, r, `${a}.${t.label}`, t.value, n);
|
|
3232
3311
|
});
|
|
3233
3312
|
}), r;
|
|
3234
3313
|
}
|
|
3235
|
-
function
|
|
3314
|
+
function Pi(e, t, n) {
|
|
3236
3315
|
Object.entries(t).forEach(([t, r]) => {
|
|
3237
3316
|
let i = Number(t);
|
|
3238
3317
|
if (!Number.isFinite(i)) return;
|
|
3239
|
-
let a =
|
|
3318
|
+
let a = Ti(r), o = e.get(a);
|
|
3240
3319
|
o || (o = {
|
|
3241
3320
|
columns: [],
|
|
3242
3321
|
columnSet: /* @__PURE__ */ new Set(),
|
|
3243
3322
|
rows: []
|
|
3244
3323
|
}, e.set(a, o)), o.rows.push({
|
|
3245
3324
|
elementID: i,
|
|
3246
|
-
ifcguid:
|
|
3247
|
-
values:
|
|
3325
|
+
ifcguid: Ei(r),
|
|
3326
|
+
values: Ni(o, r, n)
|
|
3248
3327
|
});
|
|
3249
3328
|
});
|
|
3250
3329
|
}
|
|
3251
|
-
function
|
|
3330
|
+
function Fi(e) {
|
|
3252
3331
|
return e.replace(/[<>&'"]/g, (e) => {
|
|
3253
3332
|
switch (e) {
|
|
3254
3333
|
case "<": return "<";
|
|
@@ -3260,7 +3339,7 @@ function Ai(e) {
|
|
|
3260
3339
|
}
|
|
3261
3340
|
});
|
|
3262
3341
|
}
|
|
3263
|
-
function
|
|
3342
|
+
function Ii(e) {
|
|
3264
3343
|
let t = e, n = "";
|
|
3265
3344
|
for (; t > 0;) {
|
|
3266
3345
|
let e = (t - 1) % 26;
|
|
@@ -3268,45 +3347,45 @@ function ji(e) {
|
|
|
3268
3347
|
}
|
|
3269
3348
|
return n;
|
|
3270
3349
|
}
|
|
3271
|
-
function
|
|
3272
|
-
return `<c r="${`${
|
|
3350
|
+
function Li(e, t, n) {
|
|
3351
|
+
return `<c r="${`${Ii(n)}${t}`}" t="inlineStr"><is><t${/^\s|\s$/.test(e) ? " xml:space=\"preserve\"" : ""}>${Fi(e)}</t></is></c>`;
|
|
3273
3352
|
}
|
|
3274
|
-
function
|
|
3275
|
-
return `${
|
|
3353
|
+
function Ri(e) {
|
|
3354
|
+
return `${_i}<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${e.map((e, t) => {
|
|
3276
3355
|
let n = t + 1;
|
|
3277
|
-
return `<row r="${n}">${e.map((e, t) =>
|
|
3356
|
+
return `<row r="${n}">${e.map((e, t) => Li(e, n, t + 1)).join("")}</row>`;
|
|
3278
3357
|
}).join("")}</sheetData></worksheet>`;
|
|
3279
3358
|
}
|
|
3280
|
-
function
|
|
3281
|
-
return e.replace(/[\\/?*[\]:]/g, " ").trim() ||
|
|
3359
|
+
function zi(e) {
|
|
3360
|
+
return e.replace(/[\\/?*[\]:]/g, " ").trim() || vi;
|
|
3282
3361
|
}
|
|
3283
|
-
function
|
|
3284
|
-
let n =
|
|
3362
|
+
function Bi(e, t) {
|
|
3363
|
+
let n = zi(e).slice(0, 31), r = n, i = 2;
|
|
3285
3364
|
for (; t.has(r.toLowerCase());) {
|
|
3286
3365
|
let e = ` (${i})`;
|
|
3287
3366
|
r = `${n.slice(0, 31 - e.length)}${e}`, i += 1;
|
|
3288
3367
|
}
|
|
3289
3368
|
return t.add(r.toLowerCase()), r;
|
|
3290
3369
|
}
|
|
3291
|
-
function
|
|
3292
|
-
return `${
|
|
3370
|
+
function Vi(e) {
|
|
3371
|
+
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
3372
|
let n = t + 1;
|
|
3294
|
-
return `<sheet name="${
|
|
3373
|
+
return `<sheet name="${Fi(e)}" sheetId="${n}" r:id="rId${n}"/>`;
|
|
3295
3374
|
}).join("")}</sheets></workbook>`;
|
|
3296
3375
|
}
|
|
3297
|
-
function
|
|
3298
|
-
return `${
|
|
3376
|
+
function Hi(e) {
|
|
3377
|
+
return `${_i}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${e.map((e, t) => {
|
|
3299
3378
|
let n = t + 1;
|
|
3300
3379
|
return `<Relationship Id="rId${n}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${n}.xml"/>`;
|
|
3301
3380
|
}).join("")}</Relationships>`;
|
|
3302
3381
|
}
|
|
3303
|
-
function
|
|
3304
|
-
return `${
|
|
3382
|
+
function Ui() {
|
|
3383
|
+
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
3384
|
}
|
|
3306
|
-
function
|
|
3307
|
-
return `${
|
|
3385
|
+
function Wi(e) {
|
|
3386
|
+
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
3387
|
}
|
|
3309
|
-
function
|
|
3388
|
+
function Gi() {
|
|
3310
3389
|
let e = new Uint32Array(256);
|
|
3311
3390
|
for (let t = 0; t < 256; t++) {
|
|
3312
3391
|
let n = t;
|
|
@@ -3315,121 +3394,121 @@ function Bi() {
|
|
|
3315
3394
|
}
|
|
3316
3395
|
return e;
|
|
3317
3396
|
}
|
|
3318
|
-
var
|
|
3319
|
-
function
|
|
3397
|
+
var Ki = Gi();
|
|
3398
|
+
function qi(e) {
|
|
3320
3399
|
let t = 4294967295;
|
|
3321
|
-
for (let n of e) t =
|
|
3400
|
+
for (let n of e) t = Ki[(t ^ n) & 255] ^ t >>> 8;
|
|
3322
3401
|
return (t ^ 4294967295) >>> 0;
|
|
3323
3402
|
}
|
|
3324
|
-
function
|
|
3403
|
+
function Ji(e) {
|
|
3325
3404
|
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,
|
|
3405
|
+
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
3406
|
}
|
|
3328
|
-
function
|
|
3407
|
+
function Yi(e) {
|
|
3329
3408
|
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,
|
|
3409
|
+
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
3410
|
}
|
|
3332
|
-
function
|
|
3411
|
+
function Xi(e, t, n) {
|
|
3333
3412
|
let r = new Uint8Array(22), i = new DataView(r.buffer);
|
|
3334
3413
|
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
3414
|
}
|
|
3336
|
-
function
|
|
3415
|
+
function Zi(e, t) {
|
|
3337
3416
|
let n = new Uint8Array(t), r = 0;
|
|
3338
3417
|
return e.forEach((e) => {
|
|
3339
3418
|
n.set(e, r), r += e.length;
|
|
3340
3419
|
}), n;
|
|
3341
3420
|
}
|
|
3342
|
-
function
|
|
3421
|
+
function Qi(e) {
|
|
3343
3422
|
let t = 0, n = e.map((e) => {
|
|
3344
3423
|
let n = {
|
|
3345
3424
|
...e,
|
|
3346
|
-
crc:
|
|
3347
|
-
nameBytes:
|
|
3425
|
+
crc: qi(e.data),
|
|
3426
|
+
nameBytes: gi.encode(e.path),
|
|
3348
3427
|
offset: t
|
|
3349
3428
|
};
|
|
3350
3429
|
return t += 30 + n.nameBytes.length + n.data.length, n;
|
|
3351
3430
|
}), r = [];
|
|
3352
3431
|
n.forEach((e) => {
|
|
3353
|
-
r.push(
|
|
3432
|
+
r.push(Ji(e), e.data);
|
|
3354
3433
|
});
|
|
3355
3434
|
let i = t, a = 0;
|
|
3356
3435
|
return n.forEach((e) => {
|
|
3357
|
-
let t =
|
|
3436
|
+
let t = Yi(e);
|
|
3358
3437
|
a += t.length, r.push(t);
|
|
3359
|
-
}), r.push(
|
|
3438
|
+
}), r.push(Xi(n.length, a, i)), Zi(r, r.reduce((e, t) => e + t.length, 0));
|
|
3360
3439
|
}
|
|
3361
|
-
function
|
|
3440
|
+
function $i(e, t) {
|
|
3362
3441
|
let n = /* @__PURE__ */ new Map();
|
|
3363
|
-
e &&
|
|
3442
|
+
e && Pi(n, e.props, t);
|
|
3364
3443
|
let r = /* @__PURE__ */ new Set(), i = Array.from(n.entries()).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
3365
|
-
let i = [...
|
|
3444
|
+
let i = [...yi, ...n.columns], a = n.rows.sort((e, t) => e.elementID - t.elementID).map((e) => [
|
|
3366
3445
|
String(e.elementID),
|
|
3367
3446
|
e.ifcguid || t,
|
|
3368
3447
|
...n.columns.map((n) => e.values[n] ?? t)
|
|
3369
3448
|
]);
|
|
3370
3449
|
return {
|
|
3371
|
-
name:
|
|
3450
|
+
name: Bi(e, r),
|
|
3372
3451
|
rows: [i, ...a]
|
|
3373
3452
|
};
|
|
3374
3453
|
});
|
|
3375
3454
|
return i.length || i.push({
|
|
3376
|
-
name:
|
|
3377
|
-
rows: [
|
|
3455
|
+
name: Bi(vi, r),
|
|
3456
|
+
rows: [yi]
|
|
3378
3457
|
}), i;
|
|
3379
3458
|
}
|
|
3380
|
-
function
|
|
3381
|
-
let n =
|
|
3459
|
+
function ea(e, t = {}) {
|
|
3460
|
+
let n = $i(e, t.emptyValue ?? "-"), r = n.map((e) => e.name), i = [
|
|
3382
3461
|
{
|
|
3383
3462
|
path: "[Content_Types].xml",
|
|
3384
|
-
data:
|
|
3463
|
+
data: gi.encode(Wi(r))
|
|
3385
3464
|
},
|
|
3386
3465
|
{
|
|
3387
3466
|
path: "_rels/.rels",
|
|
3388
|
-
data:
|
|
3467
|
+
data: gi.encode(Ui())
|
|
3389
3468
|
},
|
|
3390
3469
|
{
|
|
3391
3470
|
path: "xl/workbook.xml",
|
|
3392
|
-
data:
|
|
3471
|
+
data: gi.encode(Vi(r))
|
|
3393
3472
|
},
|
|
3394
3473
|
{
|
|
3395
3474
|
path: "xl/_rels/workbook.xml.rels",
|
|
3396
|
-
data:
|
|
3475
|
+
data: gi.encode(Hi(r))
|
|
3397
3476
|
},
|
|
3398
3477
|
...n.map((e, t) => ({
|
|
3399
3478
|
path: `xl/worksheets/sheet${t + 1}.xml`,
|
|
3400
|
-
data:
|
|
3479
|
+
data: gi.encode(Ri(e.rows))
|
|
3401
3480
|
}))
|
|
3402
3481
|
];
|
|
3403
|
-
return new Blob([
|
|
3482
|
+
return new Blob([Qi(i)], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
|
|
3404
3483
|
}
|
|
3405
|
-
function
|
|
3484
|
+
function ta(e) {
|
|
3406
3485
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop()?.replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "").trim() || "model";
|
|
3407
3486
|
}
|
|
3408
|
-
function
|
|
3409
|
-
let n = t.fileName?.trim() || `${
|
|
3487
|
+
function na(e, t) {
|
|
3488
|
+
let n = t.fileName?.trim() || `${ta(t.modelName ?? e?.name ?? "model")}_properties`;
|
|
3410
3489
|
return n.toLowerCase().endsWith(".xlsx") ? n : `${n}.xlsx`;
|
|
3411
3490
|
}
|
|
3412
|
-
function
|
|
3491
|
+
function ra(e, t = {}) {
|
|
3413
3492
|
return {
|
|
3414
|
-
blob:
|
|
3415
|
-
name:
|
|
3493
|
+
blob: ea(e, t),
|
|
3494
|
+
name: na(e, t)
|
|
3416
3495
|
};
|
|
3417
3496
|
}
|
|
3418
3497
|
//#endregion
|
|
3419
3498
|
//#region src/viewer/api/ViewerPropertiesApi.ts
|
|
3420
|
-
function
|
|
3499
|
+
function X(e) {
|
|
3421
3500
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3422
3501
|
}
|
|
3423
|
-
function
|
|
3502
|
+
function ia(e, t) {
|
|
3424
3503
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
3425
3504
|
}
|
|
3426
|
-
function
|
|
3427
|
-
return
|
|
3505
|
+
function aa(e) {
|
|
3506
|
+
return X(e);
|
|
3428
3507
|
}
|
|
3429
|
-
function
|
|
3430
|
-
return Array.isArray(e) ? e.filter(
|
|
3508
|
+
function oa(e) {
|
|
3509
|
+
return Array.isArray(e) ? e.filter(aa) : X(e) ? Object.values(e).filter(aa) : [];
|
|
3431
3510
|
}
|
|
3432
|
-
function
|
|
3511
|
+
function sa(e) {
|
|
3433
3512
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
3434
3513
|
if (typeof e == "string") {
|
|
3435
3514
|
let t = Number(e);
|
|
@@ -3437,10 +3516,10 @@ function na(e) {
|
|
|
3437
3516
|
}
|
|
3438
3517
|
return null;
|
|
3439
3518
|
}
|
|
3440
|
-
function
|
|
3441
|
-
return
|
|
3519
|
+
function ca(e) {
|
|
3520
|
+
return sa(e.id ?? e.expressID ?? e.expressId ?? e.elementID ?? e.elementId);
|
|
3442
3521
|
}
|
|
3443
|
-
function
|
|
3522
|
+
function la(e) {
|
|
3444
3523
|
let t = [
|
|
3445
3524
|
e.children,
|
|
3446
3525
|
e.items,
|
|
@@ -3448,40 +3527,40 @@ function ia(e) {
|
|
|
3448
3527
|
e.childs
|
|
3449
3528
|
];
|
|
3450
3529
|
for (let e of t) {
|
|
3451
|
-
let t =
|
|
3530
|
+
let t = oa(e);
|
|
3452
3531
|
if (t.length) return t;
|
|
3453
3532
|
}
|
|
3454
3533
|
return [];
|
|
3455
3534
|
}
|
|
3456
|
-
function
|
|
3457
|
-
let t =
|
|
3535
|
+
function ua(e) {
|
|
3536
|
+
let t = X(e.props) ? e.props : {}, n = e.type ?? e.Type ?? t.type ?? t.Type;
|
|
3458
3537
|
return typeof n == "string" ? n : "";
|
|
3459
3538
|
}
|
|
3460
|
-
function
|
|
3539
|
+
function da(e) {
|
|
3461
3540
|
return e.replace(/[^a-z0-9]/gi, "").toUpperCase();
|
|
3462
3541
|
}
|
|
3463
|
-
function
|
|
3464
|
-
return
|
|
3542
|
+
function fa(e) {
|
|
3543
|
+
return da(ua(e)) === "IFCBUILDINGSTOREY";
|
|
3465
3544
|
}
|
|
3466
|
-
var
|
|
3545
|
+
var pa = new Set([
|
|
3467
3546
|
"children",
|
|
3468
3547
|
"childs",
|
|
3469
3548
|
"elements",
|
|
3470
3549
|
"items"
|
|
3471
3550
|
]);
|
|
3472
|
-
function
|
|
3551
|
+
function ma(e) {
|
|
3473
3552
|
let t = {};
|
|
3474
3553
|
return Object.entries(e).forEach(([e, n]) => {
|
|
3475
|
-
|
|
3554
|
+
pa.has(e) || (t[e] = n);
|
|
3476
3555
|
}), t;
|
|
3477
3556
|
}
|
|
3478
|
-
function
|
|
3557
|
+
function ha(e, t) {
|
|
3479
3558
|
return Array.isArray(t) ? {
|
|
3480
|
-
children:
|
|
3559
|
+
children: oa(t),
|
|
3481
3560
|
name: `Model ${e}`,
|
|
3482
3561
|
type: "Model"
|
|
3483
|
-
} :
|
|
3484
|
-
children:
|
|
3562
|
+
} : X(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 : {
|
|
3563
|
+
children: oa(t),
|
|
3485
3564
|
name: `Model ${e}`,
|
|
3486
3565
|
type: "Model"
|
|
3487
3566
|
} : {
|
|
@@ -3490,46 +3569,46 @@ function ua(e, t) {
|
|
|
3490
3569
|
type: "Model"
|
|
3491
3570
|
};
|
|
3492
3571
|
}
|
|
3493
|
-
function
|
|
3572
|
+
function ga(e) {
|
|
3494
3573
|
let t = [];
|
|
3495
|
-
return
|
|
3496
|
-
let n =
|
|
3497
|
-
n !== null && t.push(n), t.push(...
|
|
3574
|
+
return la(e).forEach((e) => {
|
|
3575
|
+
let n = ca(e);
|
|
3576
|
+
n !== null && t.push(n), t.push(...ga(e));
|
|
3498
3577
|
}), t;
|
|
3499
3578
|
}
|
|
3500
|
-
function
|
|
3501
|
-
let i =
|
|
3502
|
-
...
|
|
3579
|
+
function _a(e, t, n, r) {
|
|
3580
|
+
let i = ca(t), a = i === null ? void 0 : n[e]?.[i], o = {
|
|
3581
|
+
...ma(t),
|
|
3503
3582
|
...a ?? {},
|
|
3504
3583
|
modelID: e
|
|
3505
3584
|
};
|
|
3506
|
-
return r && (o.elements =
|
|
3585
|
+
return r && (o.elements = ga(t)), o;
|
|
3507
3586
|
}
|
|
3508
|
-
function
|
|
3509
|
-
|
|
3587
|
+
function va(e, t, n, r, i) {
|
|
3588
|
+
fa(t) && n.push(_a(e, t, r, i)), la(t).forEach((t) => va(e, t, n, r, i));
|
|
3510
3589
|
}
|
|
3511
|
-
function
|
|
3590
|
+
function ya(e, t, n = !1) {
|
|
3512
3591
|
let r = {};
|
|
3513
3592
|
return Object.entries(e).forEach(([e, i]) => {
|
|
3514
3593
|
let a = Number(e), o = [];
|
|
3515
|
-
|
|
3594
|
+
va(a, ha(a, i), o, t, n), r[a] = o;
|
|
3516
3595
|
}), r;
|
|
3517
3596
|
}
|
|
3518
|
-
function
|
|
3597
|
+
function ba(e, t, n, r = !1) {
|
|
3519
3598
|
let i = [], a = e[n];
|
|
3520
3599
|
if (!a) throw Error(`Model with modelID ${n} not found`);
|
|
3521
|
-
return
|
|
3600
|
+
return va(Number(n), ha(Number(n), a), i, t, r), i;
|
|
3522
3601
|
}
|
|
3523
|
-
function
|
|
3602
|
+
function xa(e, t, n) {
|
|
3524
3603
|
return e[t]?.[n];
|
|
3525
3604
|
}
|
|
3526
|
-
function
|
|
3527
|
-
return typeof e == "string" ? e :
|
|
3605
|
+
function Sa(e) {
|
|
3606
|
+
return typeof e == "string" ? e : X(e) && typeof e.value == "string" ? e.value : "";
|
|
3528
3607
|
}
|
|
3529
|
-
function
|
|
3530
|
-
return
|
|
3608
|
+
function Ca(e, t) {
|
|
3609
|
+
return Sa(e.Name) || Sa(e.name) || Sa(e.DisplayName) || Sa(e.displayName) || `Property ${t + 1}`;
|
|
3531
3610
|
}
|
|
3532
|
-
function
|
|
3611
|
+
function wa(e) {
|
|
3533
3612
|
for (let t of [
|
|
3534
3613
|
"NominalValue",
|
|
3535
3614
|
"nominalValue",
|
|
@@ -3552,44 +3631,44 @@ function ya(e) {
|
|
|
3552
3631
|
"description"
|
|
3553
3632
|
].includes(e)));
|
|
3554
3633
|
}
|
|
3555
|
-
function
|
|
3556
|
-
return
|
|
3634
|
+
function Ta(e) {
|
|
3635
|
+
return Sa(e.name) || Sa(e.Name);
|
|
3557
3636
|
}
|
|
3558
|
-
function
|
|
3559
|
-
return
|
|
3637
|
+
function Ea(e, t) {
|
|
3638
|
+
return ia(e, t) ? e[t] : void 0;
|
|
3560
3639
|
}
|
|
3561
|
-
function
|
|
3640
|
+
function Da(e, t) {
|
|
3562
3641
|
let n = e.props;
|
|
3563
|
-
if (
|
|
3564
|
-
let e =
|
|
3642
|
+
if (X(n)) {
|
|
3643
|
+
let e = Ea(n, t);
|
|
3565
3644
|
if (e !== void 0) return e;
|
|
3566
3645
|
}
|
|
3567
3646
|
if (Array.isArray(n)) for (let e = 0; e < n.length; e += 1) {
|
|
3568
3647
|
let r = n[e];
|
|
3569
|
-
if (!
|
|
3648
|
+
if (!X(r)) continue;
|
|
3570
3649
|
let i = r;
|
|
3571
|
-
if (
|
|
3650
|
+
if (Ca(i, e) === t) return wa(i);
|
|
3572
3651
|
}
|
|
3573
|
-
return
|
|
3652
|
+
return Ea(e, t);
|
|
3574
3653
|
}
|
|
3575
|
-
function
|
|
3654
|
+
function Oa(e, t, n) {
|
|
3576
3655
|
if (!e) return;
|
|
3577
3656
|
if (n !== void 0) {
|
|
3578
|
-
let r = e.sets?.find((e) =>
|
|
3579
|
-
return r ?
|
|
3657
|
+
let r = e.sets?.find((e) => Ta(e) === n);
|
|
3658
|
+
return r ? Da(r, t) : void 0;
|
|
3580
3659
|
}
|
|
3581
|
-
if (
|
|
3582
|
-
let n =
|
|
3660
|
+
if (X(e.props)) {
|
|
3661
|
+
let n = Ea(e.props, t);
|
|
3583
3662
|
if (n !== void 0) return n;
|
|
3584
3663
|
}
|
|
3585
|
-
let r =
|
|
3664
|
+
let r = Ea(e, t);
|
|
3586
3665
|
if (r !== void 0) return r;
|
|
3587
3666
|
for (let n of e.sets ?? []) {
|
|
3588
|
-
let e =
|
|
3667
|
+
let e = Da(n, t);
|
|
3589
3668
|
if (e !== void 0) return e;
|
|
3590
3669
|
}
|
|
3591
3670
|
}
|
|
3592
|
-
function
|
|
3671
|
+
function ka(e, t, n, r) {
|
|
3593
3672
|
let i = t[e];
|
|
3594
3673
|
return i ? {
|
|
3595
3674
|
data: {},
|
|
@@ -3598,44 +3677,44 @@ function wa(e, t, n, r) {
|
|
|
3598
3677
|
structure: n[e] ?? {}
|
|
3599
3678
|
} : null;
|
|
3600
3679
|
}
|
|
3601
|
-
function
|
|
3680
|
+
function Aa(e) {
|
|
3602
3681
|
return {
|
|
3603
3682
|
exportAllExcel: (t) => {
|
|
3604
3683
|
let n = e.getState();
|
|
3605
3684
|
return Object.keys(n.modelProps).flatMap((e) => {
|
|
3606
|
-
let r =
|
|
3607
|
-
return r ? [
|
|
3685
|
+
let r = ka(Number(e), n.modelProps, n.modelStructure, n.modelNames);
|
|
3686
|
+
return r ? [ra(r, t)] : [];
|
|
3608
3687
|
});
|
|
3609
3688
|
},
|
|
3610
3689
|
exportExcel: (t, n) => {
|
|
3611
|
-
let r = e.getState(), i =
|
|
3612
|
-
return i ?
|
|
3690
|
+
let r = e.getState(), i = ka(t, r.modelProps, r.modelStructure, r.modelNames);
|
|
3691
|
+
return i ? ra(i, n) : null;
|
|
3613
3692
|
},
|
|
3614
3693
|
getAllLevels: (t = !1) => {
|
|
3615
3694
|
let n = e.getState();
|
|
3616
|
-
return
|
|
3695
|
+
return ya(n.modelStructure, n.modelProps, t);
|
|
3617
3696
|
},
|
|
3618
3697
|
getAllModelLevels: (t, n = !1) => {
|
|
3619
3698
|
let r = e.getState();
|
|
3620
|
-
return
|
|
3699
|
+
return ba(r.modelStructure, r.modelProps, t, n);
|
|
3621
3700
|
},
|
|
3622
3701
|
getModelProps: () => e.getState().modelProps,
|
|
3623
3702
|
getModelStructure: () => e.getState().modelStructure,
|
|
3624
|
-
getParamsByElement: (t, n) =>
|
|
3625
|
-
getParamValueByName:
|
|
3626
|
-
getParamValueByElement: (t, n, r, i) =>
|
|
3703
|
+
getParamsByElement: (t, n) => xa(e.getState().modelProps, t, n),
|
|
3704
|
+
getParamValueByName: Oa,
|
|
3705
|
+
getParamValueByElement: (t, n, r, i) => Oa(xa(e.getState().modelProps, t, n), r, i)
|
|
3627
3706
|
};
|
|
3628
3707
|
}
|
|
3629
3708
|
//#endregion
|
|
3630
3709
|
//#region src/viewer/Loaders/BmtConverter.ts
|
|
3631
|
-
var
|
|
3710
|
+
var ja = "BMT", Ma = 1, Na = {
|
|
3632
3711
|
PROP: 1,
|
|
3633
3712
|
MESH: 2,
|
|
3634
3713
|
STRUCTURE: 3,
|
|
3635
3714
|
GRIDS: 4,
|
|
3636
3715
|
MATRIX: 5,
|
|
3637
3716
|
MESHSPACE: 6
|
|
3638
|
-
},
|
|
3717
|
+
}, Pa = "application/json", Fa = "application/octet-stream", Ia = class {
|
|
3639
3718
|
chunks = [];
|
|
3640
3719
|
length = 0;
|
|
3641
3720
|
writeUint8(e) {
|
|
@@ -3655,7 +3734,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3655
3734
|
e.set(n, t), t += n.byteLength;
|
|
3656
3735
|
}), e;
|
|
3657
3736
|
}
|
|
3658
|
-
},
|
|
3737
|
+
}, La = class {
|
|
3659
3738
|
textEncoder = new TextEncoder();
|
|
3660
3739
|
ifcLoader = null;
|
|
3661
3740
|
async ConvertIfcFileToBmt(e, t = {}) {
|
|
@@ -3757,7 +3836,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3757
3836
|
progress: this.clampProgress(e.progress) * a
|
|
3758
3837
|
});
|
|
3759
3838
|
}), s = [{
|
|
3760
|
-
blob: new Blob([o], { type:
|
|
3839
|
+
blob: new Blob([o], { type: Fa }),
|
|
3761
3840
|
bytes: o,
|
|
3762
3841
|
name: i,
|
|
3763
3842
|
type: "bmt"
|
|
@@ -3777,7 +3856,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3777
3856
|
phase: "metadata",
|
|
3778
3857
|
progress: .95
|
|
3779
3858
|
}), s.push({
|
|
3780
|
-
blob: new Blob([n], { type:
|
|
3859
|
+
blob: new Blob([n], { type: Pa }),
|
|
3781
3860
|
bytes: n,
|
|
3782
3861
|
name: `${t}_props.json`,
|
|
3783
3862
|
type: "json"
|
|
@@ -3790,7 +3869,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3790
3869
|
return s;
|
|
3791
3870
|
}
|
|
3792
3871
|
createBmtBytes(e, t, n) {
|
|
3793
|
-
let r = new
|
|
3872
|
+
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
3873
|
n?.({
|
|
3795
3874
|
...e,
|
|
3796
3875
|
progress: this.clampProgress(e.progress)
|
|
@@ -3807,19 +3886,19 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3807
3886
|
progress: f
|
|
3808
3887
|
});
|
|
3809
3888
|
};
|
|
3810
|
-
return r.writeBytes(this.textEncoder.encode(
|
|
3889
|
+
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
3890
|
message: "Writing grids",
|
|
3812
3891
|
phase: "metadata",
|
|
3813
3892
|
progress: f
|
|
3814
|
-
}), this.writeJsonChunk(r,
|
|
3893
|
+
}), 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
3894
|
message: "Writing structure",
|
|
3816
3895
|
phase: "metadata",
|
|
3817
3896
|
progress: f
|
|
3818
|
-
}), this.writeJsonChunk(r,
|
|
3897
|
+
}), this.writeJsonChunk(r, Na.STRUCTURE, e.structure), h(l, "metadata", "Structure written")), o && e.coordinationMatrix && (p({
|
|
3819
3898
|
message: "Writing coordination matrix",
|
|
3820
3899
|
phase: "metadata",
|
|
3821
3900
|
progress: f
|
|
3822
|
-
}), this.writeTextChunk(r,
|
|
3901
|
+
}), this.writeTextChunk(r, Na.MATRIX, e.coordinationMatrix), h(u, "metadata", "Coordination matrix written")), p({
|
|
3823
3902
|
message: "BMT bytes ready",
|
|
3824
3903
|
phase: "writing",
|
|
3825
3904
|
progress: 1
|
|
@@ -3838,7 +3917,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3838
3917
|
...o,
|
|
3839
3918
|
id: s
|
|
3840
3919
|
} : o;
|
|
3841
|
-
this.writeJsonChunk(e,
|
|
3920
|
+
this.writeJsonChunk(e, Na.PROP, c);
|
|
3842
3921
|
let l = a + 1;
|
|
3843
3922
|
this.shouldEmitItemProgress(l, i) && n?.({
|
|
3844
3923
|
loaded: l,
|
|
@@ -3858,7 +3937,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3858
3937
|
progress: a > 0 ? 0 : 1,
|
|
3859
3938
|
total: a
|
|
3860
3939
|
}), i.forEach((t, i) => {
|
|
3861
|
-
t.matrix && t.matrix !== r && (this.writeTextChunk(e,
|
|
3940
|
+
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
3941
|
let o = i + 1;
|
|
3863
3942
|
this.shouldEmitItemProgress(o, a) && n?.({
|
|
3864
3943
|
loaded: o,
|
|
@@ -3870,7 +3949,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
3870
3949
|
});
|
|
3871
3950
|
}
|
|
3872
3951
|
createMeshPayload(e) {
|
|
3873
|
-
let t = new
|
|
3952
|
+
let t = new Ia(), n = this.deflateTypedArray(e.pos), r = this.deflateTypedArray(e.ids), i = this.deflateTypedArray(e.ind);
|
|
3874
3953
|
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
3954
|
}
|
|
3876
3955
|
writeJsonChunk(e, t, n) {
|
|
@@ -4023,7 +4102,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
4023
4102
|
let t = /* @__PURE__ */ new Map();
|
|
4024
4103
|
return (Array.isArray(e) ? e : [e]).forEach((e) => {
|
|
4025
4104
|
e.traverse((e) => {
|
|
4026
|
-
if (!(e instanceof
|
|
4105
|
+
if (!(e instanceof P) || !this.isIfcSpaceObject(e)) return;
|
|
4027
4106
|
let n = this.getObjectModelID(e);
|
|
4028
4107
|
if (n === null) return;
|
|
4029
4108
|
let r = e.geometry.getAttribute("ids");
|
|
@@ -4037,7 +4116,7 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
4037
4116
|
addVisibleIdsFromObject3D(e, t) {
|
|
4038
4117
|
(Array.isArray(e) ? e : [e]).forEach((e) => {
|
|
4039
4118
|
e.traverse((e) => {
|
|
4040
|
-
if (!(e instanceof
|
|
4119
|
+
if (!(e instanceof P) || !this.isObjectVisible(e)) return;
|
|
4041
4120
|
let n = this.getObjectModelID(e);
|
|
4042
4121
|
if (n === null) return;
|
|
4043
4122
|
let r = e.geometry.getAttribute("ids");
|
|
@@ -4106,43 +4185,43 @@ var Ea = "BMT", Da = 1, Oa = {
|
|
|
4106
4185
|
isRecord(e) {
|
|
4107
4186
|
return typeof e == "object" && !!e;
|
|
4108
4187
|
}
|
|
4109
|
-
},
|
|
4110
|
-
async function
|
|
4111
|
-
return
|
|
4188
|
+
}, Ra = new La();
|
|
4189
|
+
async function za(e, t) {
|
|
4190
|
+
return Ra.ConvertIfcFileToBmt(e, t);
|
|
4112
4191
|
}
|
|
4113
|
-
function
|
|
4114
|
-
return
|
|
4192
|
+
function Ba(e, t) {
|
|
4193
|
+
return Ra.ConvertToBmt(e, t);
|
|
4115
4194
|
}
|
|
4116
4195
|
//#endregion
|
|
4117
4196
|
//#region src/viewer/Selector/FilteredElementsCollector.ts
|
|
4118
|
-
function
|
|
4197
|
+
function Va(e) {
|
|
4119
4198
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
4120
4199
|
}
|
|
4121
|
-
function
|
|
4200
|
+
function Ha(e) {
|
|
4122
4201
|
let t = Number(e);
|
|
4123
4202
|
return Number.isFinite(t) ? t : null;
|
|
4124
4203
|
}
|
|
4125
|
-
function
|
|
4126
|
-
return
|
|
4204
|
+
function Ua(e) {
|
|
4205
|
+
return Va(e) && Va(e.data) && Va(e.props) && "structure" in e;
|
|
4127
4206
|
}
|
|
4128
|
-
function
|
|
4129
|
-
return
|
|
4207
|
+
function Wa(e) {
|
|
4208
|
+
return Va(e) && ("guid" in e || "id" in e || "props" in e || "sets" in e);
|
|
4130
4209
|
}
|
|
4131
|
-
function
|
|
4132
|
-
if (!
|
|
4210
|
+
function Ga(e) {
|
|
4211
|
+
if (!Va(e)) return !1;
|
|
4133
4212
|
let t = Object.entries(e);
|
|
4134
|
-
return t.length ? t.every(([e, t]) =>
|
|
4213
|
+
return t.length ? t.every(([e, t]) => Ha(e) !== null && Wa(t)) : !0;
|
|
4135
4214
|
}
|
|
4136
|
-
function
|
|
4215
|
+
function Ka(e) {
|
|
4137
4216
|
return typeof e == "string" ? e : null;
|
|
4138
4217
|
}
|
|
4139
|
-
function
|
|
4140
|
-
let t =
|
|
4141
|
-
return
|
|
4218
|
+
function qa(e) {
|
|
4219
|
+
let t = Va(e.props.props) ? e.props.props : {};
|
|
4220
|
+
return Ka(e.props.type ?? e.props.Type ?? t.type ?? t.Type);
|
|
4142
4221
|
}
|
|
4143
|
-
function
|
|
4222
|
+
function Ja(e, t, n) {
|
|
4144
4223
|
Object.entries(n).forEach(([n, r]) => {
|
|
4145
|
-
let i =
|
|
4224
|
+
let i = Ha(n);
|
|
4146
4225
|
i !== null && e.push({
|
|
4147
4226
|
elementID: i,
|
|
4148
4227
|
modelID: t,
|
|
@@ -4150,29 +4229,29 @@ function Ua(e, t, n) {
|
|
|
4150
4229
|
});
|
|
4151
4230
|
});
|
|
4152
4231
|
}
|
|
4153
|
-
function
|
|
4154
|
-
if (!e || !
|
|
4155
|
-
if (
|
|
4232
|
+
function Ya(e) {
|
|
4233
|
+
if (!e || !Va(e)) return [];
|
|
4234
|
+
if (Ua(e)) {
|
|
4156
4235
|
let t = [];
|
|
4157
|
-
return
|
|
4236
|
+
return Ja(t, 0, e.props), t;
|
|
4158
4237
|
}
|
|
4159
|
-
if (
|
|
4238
|
+
if (Ga(e)) {
|
|
4160
4239
|
let t = [];
|
|
4161
|
-
return
|
|
4240
|
+
return Ja(t, 0, e), t;
|
|
4162
4241
|
}
|
|
4163
4242
|
let t = [];
|
|
4164
4243
|
return Object.entries(e).forEach(([e, n]) => {
|
|
4165
|
-
let r =
|
|
4244
|
+
let r = Ha(e);
|
|
4166
4245
|
if (r !== null) {
|
|
4167
|
-
if (
|
|
4168
|
-
|
|
4246
|
+
if (Ua(n)) {
|
|
4247
|
+
Ja(t, r, n.props);
|
|
4169
4248
|
return;
|
|
4170
4249
|
}
|
|
4171
|
-
|
|
4250
|
+
Ga(n) && Ja(t, r, n);
|
|
4172
4251
|
}
|
|
4173
4252
|
}), t;
|
|
4174
4253
|
}
|
|
4175
|
-
function
|
|
4254
|
+
function Xa(e) {
|
|
4176
4255
|
let t = {};
|
|
4177
4256
|
return e.forEach(({ elementID: e, modelID: n, props: r }) => {
|
|
4178
4257
|
t[n] ??= [], t[n].push({
|
|
@@ -4181,26 +4260,26 @@ function Ga(e) {
|
|
|
4181
4260
|
});
|
|
4182
4261
|
}), t;
|
|
4183
4262
|
}
|
|
4184
|
-
function
|
|
4263
|
+
function Za(e) {
|
|
4185
4264
|
let t = {};
|
|
4186
4265
|
return e.forEach(({ elementID: e, modelID: n }) => {
|
|
4187
4266
|
t[n] ??= [], t[n].push(e);
|
|
4188
4267
|
}), t;
|
|
4189
4268
|
}
|
|
4190
|
-
var
|
|
4269
|
+
var Qa = class {
|
|
4191
4270
|
elements;
|
|
4192
4271
|
filters = [];
|
|
4193
4272
|
selectedModelIDs = null;
|
|
4194
4273
|
constructor(e) {
|
|
4195
|
-
this.elements =
|
|
4274
|
+
this.elements = Ya(e);
|
|
4196
4275
|
}
|
|
4197
4276
|
from(e) {
|
|
4198
|
-
return this.elements =
|
|
4277
|
+
return this.elements = Ya(e), this.filters = [], this.selectedModelIDs = null, this;
|
|
4199
4278
|
}
|
|
4200
4279
|
ofType(e) {
|
|
4201
4280
|
let t = new Set((Array.isArray(e) ? e : [e]).map((e) => e.toLowerCase()));
|
|
4202
4281
|
return this.filters.push((e) => {
|
|
4203
|
-
let n =
|
|
4282
|
+
let n = qa(e);
|
|
4204
4283
|
return !!(n && t.has(n.toLowerCase()));
|
|
4205
4284
|
}), this;
|
|
4206
4285
|
}
|
|
@@ -4229,11 +4308,11 @@ var qa = class {
|
|
|
4229
4308
|
return this.hasSingleSelectedModel() ? e.map(({ elementID: e, props: t }) => ({
|
|
4230
4309
|
elementID: e,
|
|
4231
4310
|
props: t
|
|
4232
|
-
})) :
|
|
4311
|
+
})) : Xa(e);
|
|
4233
4312
|
}
|
|
4234
4313
|
toElementsIds() {
|
|
4235
4314
|
let e = this.getFilteredElements();
|
|
4236
|
-
return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) :
|
|
4315
|
+
return this.hasSingleSelectedModel() ? e.map(({ elementID: e }) => e) : Za(e);
|
|
4237
4316
|
}
|
|
4238
4317
|
toElementIds() {
|
|
4239
4318
|
return this.toElementsIds();
|
|
@@ -4241,20 +4320,20 @@ var qa = class {
|
|
|
4241
4320
|
};
|
|
4242
4321
|
//#endregion
|
|
4243
4322
|
//#region src/viewer/api/ViewerApi.ts
|
|
4244
|
-
function
|
|
4323
|
+
function $a(e) {
|
|
4245
4324
|
let t = {};
|
|
4246
4325
|
return Object.entries(e).forEach(([e, n]) => {
|
|
4247
4326
|
t[Number(e)] = Array.from(n);
|
|
4248
4327
|
}), t;
|
|
4249
4328
|
}
|
|
4250
|
-
function
|
|
4329
|
+
function eo(e) {
|
|
4251
4330
|
let t = {};
|
|
4252
4331
|
return Object.entries(e).forEach(([e, n]) => {
|
|
4253
4332
|
t[Number(e)] = new Set(n);
|
|
4254
4333
|
}), t;
|
|
4255
4334
|
}
|
|
4256
|
-
function
|
|
4257
|
-
let n = new
|
|
4335
|
+
function to(e, t) {
|
|
4336
|
+
let n = new La();
|
|
4258
4337
|
return {
|
|
4259
4338
|
camera: {
|
|
4260
4339
|
fitCamera: () => {
|
|
@@ -4400,16 +4479,16 @@ function Xa(e, t) {
|
|
|
4400
4479
|
t()?.geometryUtils.toggleIIfcSpacesVisibility();
|
|
4401
4480
|
}
|
|
4402
4481
|
},
|
|
4403
|
-
properties:
|
|
4482
|
+
properties: Aa(e),
|
|
4404
4483
|
selector: {
|
|
4405
4484
|
addSelected: (n, r, i = !0, a = !1) => {
|
|
4406
4485
|
let o = i || a;
|
|
4407
|
-
e.getState().addSelected(n, r), o && t()?.selector.setTargetToSelection(
|
|
4486
|
+
e.getState().addSelected(n, r), o && t()?.selector.setTargetToSelection($a(e.getState().selected), a);
|
|
4408
4487
|
},
|
|
4409
|
-
collector: () => new
|
|
4488
|
+
collector: () => new Qa(e.getState().modelProps),
|
|
4410
4489
|
getPreselectionColor: () => e.getState().preselectionColor,
|
|
4411
4490
|
getSelectionColor: () => e.getState().selectionColor,
|
|
4412
|
-
getSelected: () =>
|
|
4491
|
+
getSelected: () => $a(e.getState().selected),
|
|
4413
4492
|
removeSelected: (t, n) => {
|
|
4414
4493
|
e.getState().removeSelected(t, n);
|
|
4415
4494
|
},
|
|
@@ -4424,7 +4503,7 @@ function Xa(e, t) {
|
|
|
4424
4503
|
},
|
|
4425
4504
|
setSelected: (n, r, i = !1, a = !0, o = !1) => {
|
|
4426
4505
|
let s = a || o;
|
|
4427
|
-
e.getState().setSelected(n, r, i), s && t()?.selector.setTargetToSelection(
|
|
4506
|
+
e.getState().setSelected(n, r, i), s && t()?.selector.setTargetToSelection($a(e.getState().selected), o);
|
|
4428
4507
|
}
|
|
4429
4508
|
},
|
|
4430
4509
|
utils: {
|
|
@@ -4469,7 +4548,7 @@ function Xa(e, t) {
|
|
|
4469
4548
|
}
|
|
4470
4549
|
//#endregion
|
|
4471
4550
|
//#region src/viewer/Loaders/BmtLoader.ts
|
|
4472
|
-
var
|
|
4551
|
+
var no = class {
|
|
4473
4552
|
view;
|
|
4474
4553
|
offset = 0;
|
|
4475
4554
|
constructor(e) {
|
|
@@ -4489,7 +4568,7 @@ var Za = class {
|
|
|
4489
4568
|
eof() {
|
|
4490
4569
|
return this.offset >= this.view.byteLength;
|
|
4491
4570
|
}
|
|
4492
|
-
},
|
|
4571
|
+
}, ro = class {
|
|
4493
4572
|
decodeBuffer(e) {
|
|
4494
4573
|
return this.textDecoder.decode(we.inflate(e));
|
|
4495
4574
|
}
|
|
@@ -4562,7 +4641,7 @@ var Za = class {
|
|
|
4562
4641
|
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
4642
|
}
|
|
4564
4643
|
parseBinaryFile(e, t = {}) {
|
|
4565
|
-
let n = new
|
|
4644
|
+
let n = new no(e);
|
|
4566
4645
|
if (new TextDecoder().decode(n.readBytes(3)) !== "BMT") throw Error("Invalid file");
|
|
4567
4646
|
let r = n.readUint8();
|
|
4568
4647
|
console.log(`model version: ${r}`);
|
|
@@ -4630,24 +4709,24 @@ var Za = class {
|
|
|
4630
4709
|
};
|
|
4631
4710
|
//#endregion
|
|
4632
4711
|
//#region src/viewer/workers/BMTWorker.ts?worker
|
|
4633
|
-
function
|
|
4712
|
+
function io(e) {
|
|
4634
4713
|
return new Worker("" + new URL("assets/BMTWorker-yhSXOg2i.js", import.meta.url).href, { name: e?.name });
|
|
4635
4714
|
}
|
|
4636
4715
|
//#endregion
|
|
4637
4716
|
//#region src/viewer/workers/BMTWorkerClient.ts
|
|
4638
|
-
function
|
|
4717
|
+
function ao() {
|
|
4639
4718
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
|
|
4640
4719
|
}
|
|
4641
|
-
function
|
|
4720
|
+
function oo(e) {
|
|
4642
4721
|
return Array.isArray(e) ? e : [e];
|
|
4643
4722
|
}
|
|
4644
|
-
function
|
|
4723
|
+
function so(e) {
|
|
4645
4724
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.bmt";
|
|
4646
4725
|
}
|
|
4647
|
-
function
|
|
4726
|
+
function co(e) {
|
|
4648
4727
|
return typeof e == "string" ? {
|
|
4649
4728
|
kind: "url",
|
|
4650
|
-
name:
|
|
4729
|
+
name: so(e),
|
|
4651
4730
|
url: new URL(e, globalThis.location.href).href
|
|
4652
4731
|
} : e instanceof File ? {
|
|
4653
4732
|
file: e,
|
|
@@ -4658,18 +4737,18 @@ function ro(e) {
|
|
|
4658
4737
|
kind: "buffer"
|
|
4659
4738
|
};
|
|
4660
4739
|
}
|
|
4661
|
-
function
|
|
4740
|
+
function lo(e) {
|
|
4662
4741
|
return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
|
|
4663
4742
|
}
|
|
4664
|
-
function
|
|
4665
|
-
return new
|
|
4743
|
+
function uo() {
|
|
4744
|
+
return new io();
|
|
4666
4745
|
}
|
|
4667
|
-
function
|
|
4746
|
+
function fo(e) {
|
|
4668
4747
|
return { streamGeometryChunks: e.streamGeometryChunks ?? !!e.onChunk };
|
|
4669
4748
|
}
|
|
4670
|
-
function
|
|
4671
|
-
let n = t.worker ??
|
|
4672
|
-
options:
|
|
4749
|
+
function po(e, t = {}) {
|
|
4750
|
+
let n = t.worker ?? uo(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = oo(e).map(co), o = ao(), s = {}, c = {
|
|
4751
|
+
options: fo(t),
|
|
4673
4752
|
sources: a,
|
|
4674
4753
|
taskId: o,
|
|
4675
4754
|
type: "load-bmt-model"
|
|
@@ -4707,39 +4786,39 @@ function so(e, t = {}) {
|
|
|
4707
4786
|
let a = Error(r.error.message);
|
|
4708
4787
|
r.error.stack && (a.stack = r.error.stack), l(a);
|
|
4709
4788
|
};
|
|
4710
|
-
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c,
|
|
4789
|
+
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, lo(a));
|
|
4711
4790
|
});
|
|
4712
4791
|
}
|
|
4713
|
-
function
|
|
4714
|
-
return
|
|
4792
|
+
function mo() {
|
|
4793
|
+
return uo();
|
|
4715
4794
|
}
|
|
4716
4795
|
//#endregion
|
|
4717
4796
|
//#region src/viewer/workers/BmtConverterWorker.ts?worker
|
|
4718
|
-
function
|
|
4797
|
+
function ho(e) {
|
|
4719
4798
|
return new Worker("" + new URL("assets/BmtConverterWorker-BHhPlty_.js", import.meta.url).href, { name: e?.name });
|
|
4720
4799
|
}
|
|
4721
4800
|
//#endregion
|
|
4722
4801
|
//#region src/viewer/workers/BmtConverterWorkerClient.ts
|
|
4723
|
-
function
|
|
4802
|
+
function go() {
|
|
4724
4803
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
|
|
4725
4804
|
}
|
|
4726
|
-
function
|
|
4805
|
+
function _o(e) {
|
|
4727
4806
|
return Array.isArray(e) ? e : [e];
|
|
4728
4807
|
}
|
|
4729
|
-
function
|
|
4808
|
+
function vo(e) {
|
|
4730
4809
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
|
|
4731
4810
|
}
|
|
4732
|
-
function
|
|
4811
|
+
function yo() {
|
|
4733
4812
|
return globalThis.document?.baseURI ?? globalThis.location.href;
|
|
4734
4813
|
}
|
|
4735
|
-
function
|
|
4814
|
+
function bo(e) {
|
|
4736
4815
|
let t = e ?? "ifc-parser.wasm";
|
|
4737
|
-
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t,
|
|
4816
|
+
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, yo()).href;
|
|
4738
4817
|
}
|
|
4739
|
-
function
|
|
4818
|
+
function xo(e) {
|
|
4740
4819
|
return typeof e == "string" ? {
|
|
4741
4820
|
kind: "url",
|
|
4742
|
-
name:
|
|
4821
|
+
name: vo(e),
|
|
4743
4822
|
url: new URL(e, globalThis.location.href).href
|
|
4744
4823
|
} : e instanceof File ? {
|
|
4745
4824
|
file: e,
|
|
@@ -4750,13 +4829,13 @@ function go(e) {
|
|
|
4750
4829
|
kind: "buffer"
|
|
4751
4830
|
};
|
|
4752
4831
|
}
|
|
4753
|
-
function
|
|
4832
|
+
function So(e) {
|
|
4754
4833
|
return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
|
|
4755
4834
|
}
|
|
4756
|
-
function
|
|
4757
|
-
return new
|
|
4835
|
+
function Co() {
|
|
4836
|
+
return new ho();
|
|
4758
4837
|
}
|
|
4759
|
-
function
|
|
4838
|
+
function wo(e) {
|
|
4760
4839
|
return {
|
|
4761
4840
|
chunk: e.chunk,
|
|
4762
4841
|
coordinationMatrix: e.coordinationMatrix,
|
|
@@ -4768,23 +4847,23 @@ function yo(e) {
|
|
|
4768
4847
|
useIfcSpace: e.useIfcSpace,
|
|
4769
4848
|
useMinVersion: e.useMinVersion,
|
|
4770
4849
|
visibleIdsByModel: e.visibleIdsByModel,
|
|
4771
|
-
wasmPath:
|
|
4850
|
+
wasmPath: bo(e.wasmPath)
|
|
4772
4851
|
};
|
|
4773
4852
|
}
|
|
4774
|
-
function
|
|
4853
|
+
function To(e) {
|
|
4775
4854
|
let t = new Uint8Array(e.bytes.byteLength);
|
|
4776
4855
|
return t.set(e.bytes), {
|
|
4777
4856
|
...e,
|
|
4778
4857
|
blob: new Blob([t.buffer], { type: e.mimeType })
|
|
4779
4858
|
};
|
|
4780
4859
|
}
|
|
4781
|
-
function
|
|
4860
|
+
function Eo(e) {
|
|
4782
4861
|
return {
|
|
4783
|
-
files: e.result.files.map(
|
|
4862
|
+
files: e.result.files.map(To),
|
|
4784
4863
|
models: e.result.models
|
|
4785
4864
|
};
|
|
4786
4865
|
}
|
|
4787
|
-
function
|
|
4866
|
+
function Do(e) {
|
|
4788
4867
|
if (e.error instanceof Error) return e.error;
|
|
4789
4868
|
let t = [
|
|
4790
4869
|
e.message || "Unknown worker error",
|
|
@@ -4794,12 +4873,12 @@ function So(e) {
|
|
|
4794
4873
|
].filter(Boolean);
|
|
4795
4874
|
return /* @__PURE__ */ Error(`BMT converter worker failed: ${t.join(", ")}`);
|
|
4796
4875
|
}
|
|
4797
|
-
function
|
|
4876
|
+
function Oo(e) {
|
|
4798
4877
|
return /* @__PURE__ */ Error(`BMT converter worker response could not be cloned: ${String(e.data ?? "unknown message error")}`);
|
|
4799
4878
|
}
|
|
4800
|
-
function
|
|
4801
|
-
let n = t.worker ??
|
|
4802
|
-
options:
|
|
4879
|
+
function ko(e, t = {}) {
|
|
4880
|
+
let n = t.worker ?? Co(), r = t.terminateOnComplete ?? !t.worker, i = _o(e).map(xo), a = go(), o = {
|
|
4881
|
+
options: wo(t),
|
|
4803
4882
|
sources: i,
|
|
4804
4883
|
taskId: a,
|
|
4805
4884
|
type: "convert-ifc-to-bmt"
|
|
@@ -4808,9 +4887,9 @@ function wo(e, t = {}) {
|
|
|
4808
4887
|
let c = () => {
|
|
4809
4888
|
n.removeEventListener("message", d), n.removeEventListener("error", l), n.removeEventListener("messageerror", u), r && n.terminate();
|
|
4810
4889
|
}, l = (e) => {
|
|
4811
|
-
c(), s(
|
|
4890
|
+
c(), s(Do(e));
|
|
4812
4891
|
}, u = (e) => {
|
|
4813
|
-
c(), s(
|
|
4892
|
+
c(), s(Oo(e));
|
|
4814
4893
|
}, d = (n) => {
|
|
4815
4894
|
let r = n.data;
|
|
4816
4895
|
if (r.taskId !== a) return;
|
|
@@ -4819,35 +4898,35 @@ function wo(e, t = {}) {
|
|
|
4819
4898
|
return;
|
|
4820
4899
|
}
|
|
4821
4900
|
if (c(), r.type === "complete") {
|
|
4822
|
-
e(
|
|
4901
|
+
e(Eo(r));
|
|
4823
4902
|
return;
|
|
4824
4903
|
}
|
|
4825
4904
|
let i = Error(r.error.message);
|
|
4826
4905
|
r.error.stack && (i.stack = r.error.stack), s(i);
|
|
4827
4906
|
};
|
|
4828
|
-
n.addEventListener("message", d), n.addEventListener("error", l), n.addEventListener("messageerror", u), n.postMessage(o,
|
|
4907
|
+
n.addEventListener("message", d), n.addEventListener("error", l), n.addEventListener("messageerror", u), n.postMessage(o, So(i));
|
|
4829
4908
|
});
|
|
4830
4909
|
}
|
|
4831
|
-
function
|
|
4832
|
-
return
|
|
4910
|
+
function Ao() {
|
|
4911
|
+
return Co();
|
|
4833
4912
|
}
|
|
4834
4913
|
//#endregion
|
|
4835
4914
|
//#region src/viewer/workers/IFCWorker.ts?worker
|
|
4836
|
-
function
|
|
4915
|
+
function jo(e) {
|
|
4837
4916
|
return new Worker("" + new URL("assets/IFCWorker-DipGoUKy.js", import.meta.url).href, { name: e?.name });
|
|
4838
4917
|
}
|
|
4839
4918
|
//#endregion
|
|
4840
4919
|
//#region src/viewer/workers/IFCWorkerClient.ts
|
|
4841
|
-
function
|
|
4920
|
+
function Mo() {
|
|
4842
4921
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
|
|
4843
4922
|
}
|
|
4844
|
-
function
|
|
4923
|
+
function No(e) {
|
|
4845
4924
|
return Array.isArray(e) ? e : [e];
|
|
4846
4925
|
}
|
|
4847
|
-
function
|
|
4926
|
+
function Po(e) {
|
|
4848
4927
|
return typeof e == "string" ? {
|
|
4849
4928
|
kind: "url",
|
|
4850
|
-
name:
|
|
4929
|
+
name: Fo(e),
|
|
4851
4930
|
url: new URL(e, globalThis.location.href).href
|
|
4852
4931
|
} : e instanceof File ? {
|
|
4853
4932
|
file: e,
|
|
@@ -4858,23 +4937,23 @@ function ko(e) {
|
|
|
4858
4937
|
kind: "buffer"
|
|
4859
4938
|
};
|
|
4860
4939
|
}
|
|
4861
|
-
function
|
|
4940
|
+
function Fo(e) {
|
|
4862
4941
|
return e.split(/[?#]/)[0].split(/[\\/]/).pop() || "model.ifc";
|
|
4863
4942
|
}
|
|
4864
|
-
function
|
|
4943
|
+
function Io() {
|
|
4865
4944
|
return globalThis.document?.baseURI ?? globalThis.location.href;
|
|
4866
4945
|
}
|
|
4867
|
-
function
|
|
4946
|
+
function Lo(e) {
|
|
4868
4947
|
let t = e ?? "ifc-parser.wasm";
|
|
4869
|
-
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t,
|
|
4948
|
+
return /^(https?:|blob:|data:)/i.test(t) ? t : new URL(t, Io()).href;
|
|
4870
4949
|
}
|
|
4871
|
-
function
|
|
4950
|
+
function Ro(e) {
|
|
4872
4951
|
return e.map((e) => e.kind === "buffer" ? e.buffer : null).filter((e) => e instanceof ArrayBuffer);
|
|
4873
4952
|
}
|
|
4874
|
-
function
|
|
4875
|
-
return new
|
|
4953
|
+
function zo() {
|
|
4954
|
+
return new jo();
|
|
4876
4955
|
}
|
|
4877
|
-
function
|
|
4956
|
+
function Bo(e) {
|
|
4878
4957
|
return {
|
|
4879
4958
|
chunk: e.chunk,
|
|
4880
4959
|
coordinationMatrix: e.coordinationMatrix,
|
|
@@ -4883,12 +4962,12 @@ function Fo(e) {
|
|
|
4883
4962
|
useIfcColors: e.useIfcColors,
|
|
4884
4963
|
useIfcElementAssembly: e.useIfcElementAssembly,
|
|
4885
4964
|
useIfcSpace: e.useIfcSpace,
|
|
4886
|
-
wasmPath:
|
|
4965
|
+
wasmPath: Lo(e.wasmPath)
|
|
4887
4966
|
};
|
|
4888
4967
|
}
|
|
4889
|
-
function
|
|
4890
|
-
let n = t.worker ??
|
|
4891
|
-
options:
|
|
4968
|
+
function Vo(e, t = {}) {
|
|
4969
|
+
let n = t.worker ?? zo(), r = t.terminateOnComplete ?? !t.worker, i = t.collectChunks ?? !0, a = No(e).map(Po), o = Mo(), s = {}, c = {
|
|
4970
|
+
options: Bo(t),
|
|
4892
4971
|
sources: a,
|
|
4893
4972
|
taskId: o,
|
|
4894
4973
|
type: "load-ifc-model"
|
|
@@ -4926,34 +5005,34 @@ function Io(e, t = {}) {
|
|
|
4926
5005
|
let a = Error(r.error.message);
|
|
4927
5006
|
r.error.stack && (a.stack = r.error.stack), l(a);
|
|
4928
5007
|
};
|
|
4929
|
-
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c,
|
|
5008
|
+
n.addEventListener("message", f), n.addEventListener("error", d), n.postMessage(c, Ro(a));
|
|
4930
5009
|
});
|
|
4931
5010
|
}
|
|
4932
|
-
function
|
|
4933
|
-
return
|
|
5011
|
+
function Ho() {
|
|
5012
|
+
return zo();
|
|
4934
5013
|
}
|
|
4935
5014
|
//#endregion
|
|
4936
5015
|
//#region src/viewer/api/loader.ts
|
|
4937
|
-
function
|
|
5016
|
+
function Uo(e) {
|
|
4938
5017
|
return typeof e == "string" ? e : e.name;
|
|
4939
5018
|
}
|
|
4940
|
-
function
|
|
4941
|
-
return (
|
|
5019
|
+
function Wo(e) {
|
|
5020
|
+
return (Uo(e).split(/[?#]/)[0].split(/[\\/]/).pop() || "model").replace(/\.min\.bmt$/i, "").replace(/\.[^.]+$/i, "") || "model";
|
|
4942
5021
|
}
|
|
4943
|
-
function
|
|
4944
|
-
let t =
|
|
5022
|
+
function Go(e) {
|
|
5023
|
+
let t = Uo(e).split(/[?#]/)[0].toLowerCase(), n = t.lastIndexOf(".");
|
|
4945
5024
|
return n === -1 ? "" : t.slice(n + 1);
|
|
4946
5025
|
}
|
|
4947
|
-
function
|
|
5026
|
+
function Ko(e) {
|
|
4948
5027
|
return /\.min\.bmt$/i.test(e.name) ? e.name.replace(/\.min\.bmt$/i, "_props.json") : null;
|
|
4949
5028
|
}
|
|
4950
|
-
function
|
|
4951
|
-
return /_props\.json$/i.test(
|
|
5029
|
+
function qo(e) {
|
|
5030
|
+
return /_props\.json$/i.test(Uo(e).split(/[?#]/)[0]);
|
|
4952
5031
|
}
|
|
4953
|
-
function
|
|
5032
|
+
function Jo(e) {
|
|
4954
5033
|
return e.coordinationMatrix ? e.coordinationMatrix : Object.values(e.data)[0]?.matrix || void 0;
|
|
4955
5034
|
}
|
|
4956
|
-
var
|
|
5035
|
+
var Yo = new class {
|
|
4957
5036
|
coordinationMatrix;
|
|
4958
5037
|
useIfcSpace = !0;
|
|
4959
5038
|
bmtLoader = null;
|
|
@@ -4964,7 +5043,7 @@ var Wo = new class {
|
|
|
4964
5043
|
this.getBmtLoader();
|
|
4965
5044
|
}
|
|
4966
5045
|
getBmtLoader() {
|
|
4967
|
-
return this.bmtLoader ||= new
|
|
5046
|
+
return this.bmtLoader ||= new ro(), this.bmtLoader;
|
|
4968
5047
|
}
|
|
4969
5048
|
async getIfcLoader(e = {}) {
|
|
4970
5049
|
if (!this.ifcLoader) {
|
|
@@ -4992,7 +5071,7 @@ var Wo = new class {
|
|
|
4992
5071
|
async loadBmtModel(e, t) {
|
|
4993
5072
|
let n = this.getBmtLoader();
|
|
4994
5073
|
if (typeof e == "string") return n.loadModel(e);
|
|
4995
|
-
let r = n.parseBinaryFile(await e.arrayBuffer()), i =
|
|
5074
|
+
let r = n.parseBinaryFile(await e.arrayBuffer()), i = Ko(e), a = i ? t.get(i) : void 0;
|
|
4996
5075
|
return this.applyBmtMetadata(r, a);
|
|
4997
5076
|
}
|
|
4998
5077
|
createWorkerProgressHandler(e, t, n, r) {
|
|
@@ -5015,7 +5094,7 @@ var Wo = new class {
|
|
|
5015
5094
|
};
|
|
5016
5095
|
}
|
|
5017
5096
|
async loadIfcModelInWorker(e, t, n, r, i) {
|
|
5018
|
-
return (await
|
|
5097
|
+
return (await Vo(e, {
|
|
5019
5098
|
chunk: t.chunk,
|
|
5020
5099
|
collectChunks: t.collectWorkerChunks,
|
|
5021
5100
|
coordinationMatrix: this.coordinationMatrix,
|
|
@@ -5028,14 +5107,14 @@ var Wo = new class {
|
|
|
5028
5107
|
}))[0];
|
|
5029
5108
|
}
|
|
5030
5109
|
async loadBmtModelInWorker(e, t, n, r, i, a) {
|
|
5031
|
-
let o = (await
|
|
5110
|
+
let o = (await po(e, {
|
|
5032
5111
|
collectChunks: n.collectWorkerChunks,
|
|
5033
5112
|
onChunk: this.createWorkerChunkHandler(n, r),
|
|
5034
5113
|
onProgress: this.createWorkerProgressHandler(n, r, i, a),
|
|
5035
5114
|
streamGeometryChunks: n.streamGeometryChunks ?? !!n.onChunk
|
|
5036
5115
|
}))[0];
|
|
5037
5116
|
if (e instanceof File) {
|
|
5038
|
-
let n =
|
|
5117
|
+
let n = Ko(e), r = n ? t.get(n) : void 0;
|
|
5039
5118
|
return this.applyBmtMetadata(o, r);
|
|
5040
5119
|
}
|
|
5041
5120
|
return o;
|
|
@@ -5055,21 +5134,21 @@ var Wo = new class {
|
|
|
5055
5134
|
}
|
|
5056
5135
|
async loadModel(e, t = {}) {
|
|
5057
5136
|
this.initLoaders();
|
|
5058
|
-
let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !
|
|
5137
|
+
let n = Array.isArray(e) ? e : [e], r = this.getFileSourceMap(n), i = {}, a = n.filter((e) => !qo(e)).length, o = 0;
|
|
5059
5138
|
this.loadedModelCount === 0 && this.resetCoordinationMatrixState();
|
|
5060
5139
|
for (let e = 0; e < n.length; e++) {
|
|
5061
|
-
let s = n[e], c =
|
|
5062
|
-
if (c === "json" &&
|
|
5140
|
+
let s = n[e], c = Go(s), l;
|
|
5141
|
+
if (c === "json" && qo(s)) continue;
|
|
5063
5142
|
let u = this.nextModelID, d = o;
|
|
5064
5143
|
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
5144
|
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 ??=
|
|
5145
|
+
else throw Error(`Unsupported model format: ${Uo(s)}`);
|
|
5146
|
+
let f = Jo(l);
|
|
5147
|
+
!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
5148
|
}
|
|
5070
5149
|
return i;
|
|
5071
5150
|
}
|
|
5072
|
-
}(),
|
|
5151
|
+
}(), Xo = .5, Zo = .04, Z = .16, Qo = Z, Q = Xo * 2 - Z * 2, $o = Xo - Zo / 2, es = Xo - Z / 2, ts = Xo - Qo / 2, ns = .63, rs = "#dfe6ec", is = 260, as = 52, os = .17, ss = new g(), cs = new ue(), ls = [
|
|
5073
5152
|
{
|
|
5074
5153
|
direction: [
|
|
5075
5154
|
0,
|
|
@@ -5080,12 +5159,12 @@ var Wo = new class {
|
|
|
5080
5159
|
position: [
|
|
5081
5160
|
0,
|
|
5082
5161
|
0,
|
|
5083
|
-
|
|
5162
|
+
$o
|
|
5084
5163
|
],
|
|
5085
5164
|
scale: [
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5165
|
+
Q,
|
|
5166
|
+
Q,
|
|
5167
|
+
Zo
|
|
5089
5168
|
],
|
|
5090
5169
|
title: "Front",
|
|
5091
5170
|
type: "face"
|
|
@@ -5100,7 +5179,7 @@ var Wo = new class {
|
|
|
5100
5179
|
position: [
|
|
5101
5180
|
0,
|
|
5102
5181
|
0,
|
|
5103
|
-
|
|
5182
|
+
-$o
|
|
5104
5183
|
],
|
|
5105
5184
|
rotation: [
|
|
5106
5185
|
0,
|
|
@@ -5108,9 +5187,9 @@ var Wo = new class {
|
|
|
5108
5187
|
0
|
|
5109
5188
|
],
|
|
5110
5189
|
scale: [
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5190
|
+
Q,
|
|
5191
|
+
Q,
|
|
5192
|
+
Zo
|
|
5114
5193
|
],
|
|
5115
5194
|
title: "Back",
|
|
5116
5195
|
type: "face"
|
|
@@ -5123,7 +5202,7 @@ var Wo = new class {
|
|
|
5123
5202
|
],
|
|
5124
5203
|
label: "right",
|
|
5125
5204
|
position: [
|
|
5126
|
-
|
|
5205
|
+
$o,
|
|
5127
5206
|
0,
|
|
5128
5207
|
0
|
|
5129
5208
|
],
|
|
@@ -5133,9 +5212,9 @@ var Wo = new class {
|
|
|
5133
5212
|
0
|
|
5134
5213
|
],
|
|
5135
5214
|
scale: [
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5215
|
+
Zo,
|
|
5216
|
+
Q,
|
|
5217
|
+
Q
|
|
5139
5218
|
],
|
|
5140
5219
|
title: "Right",
|
|
5141
5220
|
type: "face"
|
|
@@ -5148,7 +5227,7 @@ var Wo = new class {
|
|
|
5148
5227
|
],
|
|
5149
5228
|
label: "left",
|
|
5150
5229
|
position: [
|
|
5151
|
-
|
|
5230
|
+
-$o,
|
|
5152
5231
|
0,
|
|
5153
5232
|
0
|
|
5154
5233
|
],
|
|
@@ -5158,9 +5237,9 @@ var Wo = new class {
|
|
|
5158
5237
|
0
|
|
5159
5238
|
],
|
|
5160
5239
|
scale: [
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5240
|
+
Zo,
|
|
5241
|
+
Q,
|
|
5242
|
+
Q
|
|
5164
5243
|
],
|
|
5165
5244
|
title: "Left",
|
|
5166
5245
|
type: "face"
|
|
@@ -5174,7 +5253,7 @@ var Wo = new class {
|
|
|
5174
5253
|
label: "top",
|
|
5175
5254
|
position: [
|
|
5176
5255
|
0,
|
|
5177
|
-
|
|
5256
|
+
$o,
|
|
5178
5257
|
0
|
|
5179
5258
|
],
|
|
5180
5259
|
rotation: [
|
|
@@ -5183,9 +5262,9 @@ var Wo = new class {
|
|
|
5183
5262
|
0
|
|
5184
5263
|
],
|
|
5185
5264
|
scale: [
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5265
|
+
Q,
|
|
5266
|
+
Zo,
|
|
5267
|
+
Q
|
|
5189
5268
|
],
|
|
5190
5269
|
title: "Top",
|
|
5191
5270
|
type: "face"
|
|
@@ -5199,7 +5278,7 @@ var Wo = new class {
|
|
|
5199
5278
|
label: "bot",
|
|
5200
5279
|
position: [
|
|
5201
5280
|
0,
|
|
5202
|
-
|
|
5281
|
+
-$o,
|
|
5203
5282
|
0
|
|
5204
5283
|
],
|
|
5205
5284
|
rotation: [
|
|
@@ -5208,15 +5287,15 @@ var Wo = new class {
|
|
|
5208
5287
|
0
|
|
5209
5288
|
],
|
|
5210
5289
|
scale: [
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5290
|
+
Q,
|
|
5291
|
+
Zo,
|
|
5292
|
+
Q
|
|
5214
5293
|
],
|
|
5215
5294
|
title: "Bottom",
|
|
5216
5295
|
type: "face"
|
|
5217
5296
|
}
|
|
5218
5297
|
];
|
|
5219
|
-
function
|
|
5298
|
+
function us() {
|
|
5220
5299
|
let e = [], t = [-1, 1];
|
|
5221
5300
|
return t.forEach((n) => {
|
|
5222
5301
|
t.forEach((t) => {
|
|
@@ -5228,13 +5307,13 @@ function is() {
|
|
|
5228
5307
|
],
|
|
5229
5308
|
position: [
|
|
5230
5309
|
0,
|
|
5231
|
-
n *
|
|
5232
|
-
t *
|
|
5310
|
+
n * es,
|
|
5311
|
+
t * es
|
|
5233
5312
|
],
|
|
5234
5313
|
scale: [
|
|
5314
|
+
Q,
|
|
5235
5315
|
Z,
|
|
5236
|
-
|
|
5237
|
-
X
|
|
5316
|
+
Z
|
|
5238
5317
|
],
|
|
5239
5318
|
title: `${n > 0 ? "Top" : "Bottom"} ${t > 0 ? "Front" : "Back"}`,
|
|
5240
5319
|
type: "edge"
|
|
@@ -5249,14 +5328,14 @@ function is() {
|
|
|
5249
5328
|
t
|
|
5250
5329
|
],
|
|
5251
5330
|
position: [
|
|
5252
|
-
n *
|
|
5331
|
+
n * es,
|
|
5253
5332
|
0,
|
|
5254
|
-
t *
|
|
5333
|
+
t * es
|
|
5255
5334
|
],
|
|
5256
5335
|
scale: [
|
|
5257
|
-
X,
|
|
5258
5336
|
Z,
|
|
5259
|
-
|
|
5337
|
+
Q,
|
|
5338
|
+
Z
|
|
5260
5339
|
],
|
|
5261
5340
|
title: `${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
|
|
5262
5341
|
type: "edge"
|
|
@@ -5271,14 +5350,14 @@ function is() {
|
|
|
5271
5350
|
0
|
|
5272
5351
|
],
|
|
5273
5352
|
position: [
|
|
5274
|
-
n *
|
|
5275
|
-
t *
|
|
5353
|
+
n * es,
|
|
5354
|
+
t * es,
|
|
5276
5355
|
0
|
|
5277
5356
|
],
|
|
5278
5357
|
scale: [
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5358
|
+
Z,
|
|
5359
|
+
Z,
|
|
5360
|
+
Q
|
|
5282
5361
|
],
|
|
5283
5362
|
title: `${t > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"}`,
|
|
5284
5363
|
type: "edge"
|
|
@@ -5286,7 +5365,7 @@ function is() {
|
|
|
5286
5365
|
});
|
|
5287
5366
|
}), e;
|
|
5288
5367
|
}
|
|
5289
|
-
function
|
|
5368
|
+
function ds() {
|
|
5290
5369
|
let e = [], t = [-1, 1];
|
|
5291
5370
|
return t.forEach((n) => {
|
|
5292
5371
|
t.forEach((r) => {
|
|
@@ -5298,14 +5377,14 @@ function as() {
|
|
|
5298
5377
|
t
|
|
5299
5378
|
],
|
|
5300
5379
|
position: [
|
|
5301
|
-
n *
|
|
5302
|
-
r *
|
|
5303
|
-
t *
|
|
5380
|
+
n * ts,
|
|
5381
|
+
r * ts,
|
|
5382
|
+
t * ts
|
|
5304
5383
|
],
|
|
5305
5384
|
scale: [
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5385
|
+
Qo,
|
|
5386
|
+
Qo,
|
|
5387
|
+
Qo
|
|
5309
5388
|
],
|
|
5310
5389
|
title: `${r > 0 ? "Top" : "Bottom"} ${n > 0 ? "Right" : "Left"} ${t > 0 ? "Front" : "Back"}`,
|
|
5311
5390
|
type: "corner"
|
|
@@ -5314,34 +5393,34 @@ function as() {
|
|
|
5314
5393
|
});
|
|
5315
5394
|
}), e;
|
|
5316
5395
|
}
|
|
5317
|
-
function
|
|
5396
|
+
function fs(e) {
|
|
5318
5397
|
e.stopPropagation(), e.nativeEvent.stopPropagation(), e.nativeEvent.stopImmediatePropagation?.();
|
|
5319
5398
|
}
|
|
5320
|
-
function
|
|
5321
|
-
return e ? "#4f7fa3" :
|
|
5399
|
+
function ps(e) {
|
|
5400
|
+
return e ? "#4f7fa3" : rs;
|
|
5322
5401
|
}
|
|
5323
|
-
function
|
|
5402
|
+
function ms(e) {
|
|
5324
5403
|
return e ? 1 : .96;
|
|
5325
5404
|
}
|
|
5326
|
-
function
|
|
5405
|
+
function hs(e, t) {
|
|
5327
5406
|
let n = document.createElement("canvas"), r = n.getContext("2d");
|
|
5328
5407
|
if (!r) throw Error("Could not create navigation cube label context");
|
|
5329
|
-
let i = `600 ${
|
|
5408
|
+
let i = `600 ${as}px system-ui, "Segoe UI", sans-serif`;
|
|
5330
5409
|
r.font = i;
|
|
5331
|
-
let a = r.measureText(e), o = a.actualBoundingBoxAscent ||
|
|
5410
|
+
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
5411
|
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
5412
|
let u = new b(n);
|
|
5334
|
-
return u.colorSpace =
|
|
5413
|
+
return u.colorSpace = R, u.generateMipmaps = !1, u.magFilter = A, u.minFilter = A, u.needsUpdate = !0, {
|
|
5335
5414
|
aspect: c / l,
|
|
5336
5415
|
texture: u
|
|
5337
5416
|
};
|
|
5338
5417
|
}
|
|
5339
|
-
function
|
|
5340
|
-
let { aspect: i, texture: a } = c(() =>
|
|
5341
|
-
return o(() => () => a.dispose(), [a]), /* @__PURE__ */
|
|
5418
|
+
function gs({ color: e, label: t, position: n, rotation: r }) {
|
|
5419
|
+
let { aspect: i, texture: a } = c(() => hs(t, e), [e, t]);
|
|
5420
|
+
return o(() => () => a.dispose(), [a]), /* @__PURE__ */ H("mesh", {
|
|
5342
5421
|
position: n,
|
|
5343
5422
|
rotation: r,
|
|
5344
|
-
children: [/* @__PURE__ */
|
|
5423
|
+
children: [/* @__PURE__ */ V("planeGeometry", { args: [os * i, os] }), /* @__PURE__ */ V("meshBasicMaterial", {
|
|
5345
5424
|
alphaTest: .1,
|
|
5346
5425
|
depthWrite: !1,
|
|
5347
5426
|
map: a,
|
|
@@ -5350,54 +5429,54 @@ function us({ color: e, label: t, position: n, rotation: r }) {
|
|
|
5350
5429
|
})]
|
|
5351
5430
|
});
|
|
5352
5431
|
}
|
|
5353
|
-
function
|
|
5354
|
-
return Math.abs(e.y) > .9 ? new
|
|
5432
|
+
function _s(e) {
|
|
5433
|
+
return Math.abs(e.y) > .9 ? new B(0, 0, e.y > 0 ? -1 : 1) : new B(0, 1, 0);
|
|
5355
5434
|
}
|
|
5356
|
-
function
|
|
5435
|
+
function vs(e, t) {
|
|
5357
5436
|
let n = e.current;
|
|
5358
|
-
return !n || (n.updateWorldMatrix(!0, !0),
|
|
5437
|
+
return !n || (n.updateWorldMatrix(!0, !0), ss.setFromObject(n), ss.isEmpty()) ? (cs.center.copy(t), cs.radius = 10, cs) : (ss.getBoundingSphere(cs), (!Number.isFinite(cs.radius) || cs.radius <= 0) && (cs.radius = 10), cs);
|
|
5359
5438
|
}
|
|
5360
|
-
function
|
|
5361
|
-
return e.current?.getTarget(new
|
|
5439
|
+
function ys(e) {
|
|
5440
|
+
return e.current?.getTarget(new B()) ?? new B();
|
|
5362
5441
|
}
|
|
5363
|
-
function
|
|
5364
|
-
let a =
|
|
5442
|
+
function bs({ camera: e, controlRef: t, direction: n, modelRef: r, transitionRef: i }) {
|
|
5443
|
+
let a = ys(t), o = vs(r, a), s = o.center.clone(), c = new B(...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
5444
|
t.current?.cancel(), t.current?.setFocalOffset(0, 0, 0, !1), i.current = {
|
|
5366
5445
|
endPosition: d,
|
|
5367
5446
|
endTarget: s,
|
|
5368
|
-
endUp:
|
|
5447
|
+
endUp: _s(c),
|
|
5369
5448
|
startPosition: e.position.clone(),
|
|
5370
5449
|
startTarget: a,
|
|
5371
5450
|
startTime: performance.now(),
|
|
5372
5451
|
startUp: e.up.clone()
|
|
5373
5452
|
};
|
|
5374
5453
|
}
|
|
5375
|
-
function
|
|
5454
|
+
function xs({ action: e, onPick: t }) {
|
|
5376
5455
|
let [n, r] = u(!1);
|
|
5377
|
-
return /* @__PURE__ */
|
|
5456
|
+
return /* @__PURE__ */ H("group", {
|
|
5378
5457
|
position: e.position,
|
|
5379
|
-
onClick:
|
|
5458
|
+
onClick: fs,
|
|
5380
5459
|
onPointerDown: (n) => {
|
|
5381
|
-
|
|
5460
|
+
fs(n), t(e);
|
|
5382
5461
|
},
|
|
5383
5462
|
onPointerEnter: (e) => {
|
|
5384
|
-
|
|
5463
|
+
fs(e), r(!0);
|
|
5385
5464
|
},
|
|
5386
5465
|
onPointerLeave: (e) => {
|
|
5387
|
-
|
|
5466
|
+
fs(e), r(!1);
|
|
5388
5467
|
},
|
|
5389
|
-
children: [/* @__PURE__ */
|
|
5468
|
+
children: [/* @__PURE__ */ H("mesh", {
|
|
5390
5469
|
scale: e.scale,
|
|
5391
|
-
children: [/* @__PURE__ */
|
|
5470
|
+
children: [/* @__PURE__ */ V("boxGeometry", { args: [
|
|
5392
5471
|
1,
|
|
5393
5472
|
1,
|
|
5394
5473
|
1
|
|
5395
|
-
] }), /* @__PURE__ */
|
|
5396
|
-
color:
|
|
5397
|
-
opacity:
|
|
5474
|
+
] }), /* @__PURE__ */ V("meshBasicMaterial", {
|
|
5475
|
+
color: ps(n),
|
|
5476
|
+
opacity: ms(n),
|
|
5398
5477
|
transparent: !0
|
|
5399
5478
|
})]
|
|
5400
|
-
}), e.label && /* @__PURE__ */
|
|
5479
|
+
}), e.label && /* @__PURE__ */ V(gs, {
|
|
5401
5480
|
color: n ? "#ffffff" : "#50606f",
|
|
5402
5481
|
label: e.label,
|
|
5403
5482
|
position: [
|
|
@@ -5409,11 +5488,11 @@ function hs({ action: e, onPick: t }) {
|
|
|
5409
5488
|
})]
|
|
5410
5489
|
});
|
|
5411
5490
|
}
|
|
5412
|
-
function
|
|
5491
|
+
function Ss({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
|
|
5413
5492
|
let i = l(null), a = l(null), o = c(() => [
|
|
5414
|
-
...
|
|
5415
|
-
...
|
|
5416
|
-
...
|
|
5493
|
+
...ls,
|
|
5494
|
+
...us(),
|
|
5495
|
+
...ds()
|
|
5417
5496
|
], []);
|
|
5418
5497
|
return f(() => {
|
|
5419
5498
|
if (!e) return;
|
|
@@ -5422,20 +5501,20 @@ function gs({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
|
|
|
5422
5501
|
i.current && i.current.quaternion.copy(r.quaternion).invert();
|
|
5423
5502
|
let o = a.current;
|
|
5424
5503
|
if (!o) return;
|
|
5425
|
-
let s = performance.now() - o.startTime, c = Math.min(s /
|
|
5504
|
+
let s = performance.now() - o.startTime, c = Math.min(s / is, 1), l = 1 - (1 - c) ** 3, u = n.current;
|
|
5426
5505
|
if (r.position.lerpVectors(o.startPosition, o.endPosition, l), r.up.lerpVectors(o.startUp, o.endUp, l), u) {
|
|
5427
|
-
let e = new
|
|
5506
|
+
let e = new B().lerpVectors(o.startTarget, o.endTarget, l);
|
|
5428
5507
|
u.setLookAt(r.position.x, r.position.y, r.position.z, e.x, e.y, e.z, !1);
|
|
5429
5508
|
} else r.lookAt(o.endTarget);
|
|
5430
5509
|
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
|
-
}), e ? /* @__PURE__ */
|
|
5510
|
+
}), e ? /* @__PURE__ */ V("group", {
|
|
5432
5511
|
ref: i,
|
|
5433
|
-
scale:
|
|
5434
|
-
children: o.map((e) => /* @__PURE__ */
|
|
5512
|
+
scale: ns,
|
|
5513
|
+
children: o.map((e) => /* @__PURE__ */ V(xs, {
|
|
5435
5514
|
action: e,
|
|
5436
5515
|
onPick: (e) => {
|
|
5437
5516
|
let i = t.current;
|
|
5438
|
-
i &&
|
|
5517
|
+
i && bs({
|
|
5439
5518
|
camera: i,
|
|
5440
5519
|
controlRef: n,
|
|
5441
5520
|
direction: e.direction,
|
|
@@ -5448,13 +5527,13 @@ function gs({ active: e = !0, cameraRef: t, controlRef: n, modelRef: r }) {
|
|
|
5448
5527
|
}
|
|
5449
5528
|
//#endregion
|
|
5450
5529
|
//#region src/viewer/Viewer.tsx
|
|
5451
|
-
var
|
|
5530
|
+
var Cs = class {
|
|
5452
5531
|
sceneApi = null;
|
|
5453
5532
|
get = () => this.sceneApi;
|
|
5454
5533
|
set = (e) => {
|
|
5455
5534
|
this.sceneApi = e;
|
|
5456
5535
|
};
|
|
5457
|
-
},
|
|
5536
|
+
}, ws = {
|
|
5458
5537
|
bottom: 16,
|
|
5459
5538
|
height: 96,
|
|
5460
5539
|
pointerEvents: "auto",
|
|
@@ -5463,11 +5542,11 @@ var _s = class {
|
|
|
5463
5542
|
touchAction: "none",
|
|
5464
5543
|
width: 96,
|
|
5465
5544
|
zIndex: 2
|
|
5466
|
-
},
|
|
5545
|
+
}, Ts = {
|
|
5467
5546
|
height: "100%",
|
|
5468
5547
|
position: "relative",
|
|
5469
5548
|
width: "100%"
|
|
5470
|
-
},
|
|
5549
|
+
}, Es = {
|
|
5471
5550
|
far: 50,
|
|
5472
5551
|
near: .1,
|
|
5473
5552
|
position: [
|
|
@@ -5476,49 +5555,49 @@ var _s = class {
|
|
|
5476
5555
|
10
|
|
5477
5556
|
],
|
|
5478
5557
|
zoom: 72
|
|
5479
|
-
},
|
|
5558
|
+
}, Ds = {
|
|
5480
5559
|
alpha: !0,
|
|
5481
5560
|
antialias: !0
|
|
5482
|
-
},
|
|
5561
|
+
}, Os = {
|
|
5483
5562
|
alpha: !0,
|
|
5484
5563
|
antialias: !1,
|
|
5485
5564
|
powerPreference: "high-performance"
|
|
5486
|
-
},
|
|
5565
|
+
}, ks = {
|
|
5487
5566
|
antialias: !1,
|
|
5488
5567
|
powerPreference: "high-performance"
|
|
5489
|
-
},
|
|
5490
|
-
function
|
|
5568
|
+
}, As = .1, js = .02, Ms = 150, Ns = .75, Ps = .6, Fs = 1e3, Is = 50, Ls = 1.25, Rs = .08, zs = 1.2, Bs = 2, Vs = new g(), Hs = new ue(), $ = new B(), Us = new B(), Ws = new B();
|
|
5569
|
+
function Gs(e, t) {
|
|
5491
5570
|
return Array.isArray(e) ? [Math.min(e[0], t), Math.min(e[1], t)] : typeof e == "number" ? Math.min(e, t) : t;
|
|
5492
5571
|
}
|
|
5493
|
-
function
|
|
5572
|
+
function Ks() {
|
|
5494
5573
|
let e = navigator, t = navigator.userAgent.toLowerCase(), n = navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, r = window.matchMedia?.("(pointer: coarse)").matches ?? !1;
|
|
5495
5574
|
return e.userAgentData?.mobile || n || /android|iphone|ipad|ipod|mobile|tablet/.test(t) || navigator.maxTouchPoints > 1 && r ? "mobile" : "pc";
|
|
5496
5575
|
}
|
|
5497
|
-
function
|
|
5498
|
-
let t =
|
|
5499
|
-
return t ? Math.max(t.radius *
|
|
5576
|
+
function qs(e) {
|
|
5577
|
+
let t = Js(e);
|
|
5578
|
+
return t ? Math.max(t.radius * js, As) : As;
|
|
5500
5579
|
}
|
|
5501
|
-
function
|
|
5502
|
-
if (!e || (
|
|
5503
|
-
let t =
|
|
5580
|
+
function Js(e) {
|
|
5581
|
+
if (!e || (Vs.setFromObject(e), Vs.isEmpty())) return null;
|
|
5582
|
+
let t = Vs.getBoundingSphere(Hs);
|
|
5504
5583
|
return !Number.isFinite(t.radius) || t.radius <= 0 ? null : t;
|
|
5505
5584
|
}
|
|
5506
|
-
function
|
|
5585
|
+
function Ys(e) {
|
|
5507
5586
|
return e.type === "Group" && typeof e.userData.modelID == "number";
|
|
5508
5587
|
}
|
|
5509
|
-
function
|
|
5510
|
-
return e?.children.filter(
|
|
5588
|
+
function Xs(e) {
|
|
5589
|
+
return e?.children.filter(Ys) ?? [];
|
|
5511
5590
|
}
|
|
5512
|
-
function
|
|
5513
|
-
return
|
|
5591
|
+
function Zs(e, t) {
|
|
5592
|
+
return Xs(e).find((e) => e.userData.modelID === t) ?? null;
|
|
5514
5593
|
}
|
|
5515
|
-
function
|
|
5516
|
-
let n =
|
|
5594
|
+
function Qs(e, t) {
|
|
5595
|
+
let n = Js(t);
|
|
5517
5596
|
if (!n) return;
|
|
5518
|
-
let r = Math.max(
|
|
5597
|
+
let r = Math.max(Fs, n.radius * Is, e.near + 1);
|
|
5519
5598
|
Math.abs(e.far - r) < 1 || (e.far = r, e.updateProjectionMatrix());
|
|
5520
5599
|
}
|
|
5521
|
-
function
|
|
5600
|
+
function $s(e, t, n, r, i) {
|
|
5522
5601
|
let a = n.elementIndex.get(i);
|
|
5523
5602
|
a && a.forEach((n) => {
|
|
5524
5603
|
let { record: i, vertexRanges: a } = n;
|
|
@@ -5530,209 +5609,236 @@ function Hs(e, t, n, r, i) {
|
|
|
5530
5609
|
}));
|
|
5531
5610
|
});
|
|
5532
5611
|
}
|
|
5533
|
-
function
|
|
5534
|
-
let n = new g(), r = new
|
|
5612
|
+
function ec(e, t) {
|
|
5613
|
+
let n = new g(), r = new B();
|
|
5535
5614
|
return Object.entries(e).forEach(([e, i]) => {
|
|
5536
5615
|
let a = Number(e);
|
|
5537
5616
|
i.forEach((e) => {
|
|
5538
|
-
|
|
5617
|
+
$s(n, r, t, a, e);
|
|
5539
5618
|
});
|
|
5540
5619
|
}), n.isEmpty() ? null : n;
|
|
5541
5620
|
}
|
|
5542
|
-
function
|
|
5543
|
-
let t = e.getSize(
|
|
5544
|
-
return Number.isFinite(n) && n > 0 ? n *
|
|
5621
|
+
function tc(e) {
|
|
5622
|
+
let t = e.getSize(Ws), n = Math.max(t.x, t.y, t.z);
|
|
5623
|
+
return Number.isFinite(n) && n > 0 ? n * Rs : As;
|
|
5545
5624
|
}
|
|
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(),
|
|
5625
|
+
function nc(e, t, n) {
|
|
5626
|
+
let r = Math.max(As, (Number.isFinite(n) ? n : As) * Ls), i = t.position.distanceTo(e);
|
|
5627
|
+
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(), Us.copy(t.position).addScaledVector($, r));
|
|
5549
5628
|
}
|
|
5550
|
-
function
|
|
5551
|
-
let
|
|
5629
|
+
function rc({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materialMode: a, modelRef: s, modelsData: u, onReady: d, onCameraDprModeChange: f, publicApi: g, setSceneApi: _, usePerformanceMoving: v }) {
|
|
5630
|
+
let y = p((e) => e.camera), b = p((e) => e.gl), x = Nt(s), S = Gt(x), { colorPaletteTexture: C, colorUtils: w } = Ge(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 = U((e) => e.showStats), F = c(() => {
|
|
5552
5631
|
let e = Object.keys(u).sort((e, t) => Number(e) - Number(t));
|
|
5553
5632
|
for (let t of e) {
|
|
5554
|
-
let e =
|
|
5633
|
+
let e = Ct(u[Number(t)]);
|
|
5555
5634
|
if (e) return e;
|
|
5556
5635
|
}
|
|
5557
5636
|
return null;
|
|
5558
|
-
}, [u]),
|
|
5559
|
-
n.current && (n.current.minDistance =
|
|
5560
|
-
}, [n, s]),
|
|
5637
|
+
}, [u]), re = c(() => xt(F ?? void 0), [F]), ie = c(() => Object.entries(u).map(([e, t]) => [Number(e), t]), [u]), ae = a !== "performance", I = i(() => {
|
|
5638
|
+
n.current && (n.current.minDistance = qs(s.current));
|
|
5639
|
+
}, [n, s]), L = i((e, t = !1) => {
|
|
5561
5640
|
let r = n.current;
|
|
5562
5641
|
if (!r) return !1;
|
|
5563
|
-
let i = t ?
|
|
5642
|
+
let i = t ? nc(e, y, r.minDistance) : e;
|
|
5564
5643
|
return r.cancel(), r.setOrbitPoint(i.x, i.y, i.z), !0;
|
|
5565
|
-
}, [
|
|
5566
|
-
|
|
5567
|
-
}, [
|
|
5568
|
-
|
|
5644
|
+
}, [y, n]), ce = i((e) => {
|
|
5645
|
+
A.current = e.clone(), L(e, !0);
|
|
5646
|
+
}, [L]), R = i(() => {
|
|
5647
|
+
A.current = null, k(s, n, r);
|
|
5569
5648
|
}, [
|
|
5570
5649
|
n,
|
|
5571
|
-
|
|
5650
|
+
k,
|
|
5572
5651
|
r,
|
|
5573
5652
|
s
|
|
5574
|
-
]),
|
|
5653
|
+
]), le = i((e, t = !1) => {
|
|
5575
5654
|
let r = n.current;
|
|
5576
5655
|
if (!r) return;
|
|
5577
|
-
let i =
|
|
5656
|
+
let i = ec(e, x.buildIndex());
|
|
5578
5657
|
if (!i) return;
|
|
5579
|
-
let a = i.getCenter(new
|
|
5580
|
-
if (
|
|
5581
|
-
let e =
|
|
5658
|
+
let a = i.getCenter(new B());
|
|
5659
|
+
if (A.current = a.clone(), r.cancel(), t) {
|
|
5660
|
+
let e = tc(i);
|
|
5582
5661
|
r.fitToBox(i, !0, {
|
|
5583
5662
|
paddingBottom: e,
|
|
5584
5663
|
paddingLeft: e,
|
|
5585
5664
|
paddingRight: e,
|
|
5586
5665
|
paddingTop: e
|
|
5587
5666
|
}).then(() => {
|
|
5588
|
-
let e =
|
|
5589
|
-
e &&
|
|
5667
|
+
let e = A.current;
|
|
5668
|
+
e && L(e, !0);
|
|
5590
5669
|
});
|
|
5591
5670
|
return;
|
|
5592
5671
|
}
|
|
5593
|
-
|
|
5672
|
+
L(a, !0);
|
|
5594
5673
|
}, [
|
|
5595
|
-
|
|
5674
|
+
L,
|
|
5596
5675
|
n,
|
|
5597
|
-
|
|
5598
|
-
]),
|
|
5676
|
+
x
|
|
5677
|
+
]), ue = c(() => {
|
|
5599
5678
|
let e = (e) => ({
|
|
5600
5679
|
...e,
|
|
5601
5680
|
activeViewRoot: s.current
|
|
5602
5681
|
});
|
|
5603
5682
|
return {
|
|
5604
|
-
convertIfcFileToBmt: (e, t) =>
|
|
5605
|
-
convertToBmt: (t) =>
|
|
5683
|
+
convertIfcFileToBmt: (e, t) => O.ConvertIfcFileToBmt(e, t),
|
|
5684
|
+
convertToBmt: (t) => O.ConvertToBmt(u, e(t))
|
|
5606
5685
|
};
|
|
5607
5686
|
}, [
|
|
5608
|
-
|
|
5687
|
+
O,
|
|
5609
5688
|
s,
|
|
5610
5689
|
u
|
|
5611
5690
|
]);
|
|
5612
|
-
return
|
|
5613
|
-
let e =
|
|
5614
|
-
|
|
5615
|
-
|
|
5691
|
+
return o(() => {
|
|
5692
|
+
let e = () => {
|
|
5693
|
+
j.current !== null && (window.clearTimeout(j.current), j.current = null);
|
|
5694
|
+
}, t = () => {
|
|
5695
|
+
let e = M.current;
|
|
5696
|
+
e !== null && (M.current = null, E.setEdgesActive(e));
|
|
5697
|
+
};
|
|
5698
|
+
if (!v) {
|
|
5699
|
+
e(), t(), f("sleep");
|
|
5700
|
+
return;
|
|
5701
|
+
}
|
|
5702
|
+
let r = n.current;
|
|
5703
|
+
if (!r) return;
|
|
5704
|
+
let i = () => {
|
|
5705
|
+
e(), f("wake"), j.current = window.setTimeout(() => {
|
|
5706
|
+
j.current = null, f("move"), M.current === null && (M.current = E.getEdgesActive()), M.current && E.setEdgesActive(!1);
|
|
5707
|
+
}, Ms);
|
|
5708
|
+
}, a = () => {
|
|
5709
|
+
e(), t(), f("sleep");
|
|
5710
|
+
};
|
|
5711
|
+
return r.addEventListener("wake", i), r.addEventListener("sleep", a), () => {
|
|
5712
|
+
e(), r.removeEventListener("wake", i), r.removeEventListener("sleep", a), t(), f("sleep");
|
|
5713
|
+
};
|
|
5714
|
+
}, [
|
|
5715
|
+
E,
|
|
5716
|
+
n,
|
|
5717
|
+
f,
|
|
5718
|
+
v
|
|
5719
|
+
]), di(s, n, T, ce, E.getSelectableObjects, E.setCapsPreselection), vr(), o(() => {
|
|
5720
|
+
let e = b.domElement, t = (e) => {
|
|
5721
|
+
let t = A.current;
|
|
5722
|
+
t && e.button === 0 && (e.ctrlKey || e.metaKey || e.shiftKey || L(t, !0));
|
|
5616
5723
|
};
|
|
5617
5724
|
return e.addEventListener("pointerdown", t, !0), () => {
|
|
5618
5725
|
e.removeEventListener("pointerdown", t, !0);
|
|
5619
5726
|
};
|
|
5620
|
-
}, [
|
|
5621
|
-
|
|
5622
|
-
}), [
|
|
5623
|
-
t.current ===
|
|
5624
|
-
}), [
|
|
5727
|
+
}, [L, b]), o(() => (T.setClippingSource(E), () => {
|
|
5728
|
+
T.setClippingSource(null);
|
|
5729
|
+
}), [T, E]), o(() => (t.current = y, () => {
|
|
5730
|
+
t.current === y && (t.current = null);
|
|
5731
|
+
}), [y, t]), o(() => {
|
|
5625
5732
|
if (!s.current) return;
|
|
5626
5733
|
let t = requestAnimationFrame(() => {
|
|
5627
|
-
s.current?.updateMatrixWorld(!0), (
|
|
5734
|
+
s.current?.updateMatrixWorld(!0), (y instanceof se || y instanceof oe) && Qs(y, s.current), I(), te(), ee(), ne(), E.syncWithModel(), D.syncWithModel(), e && R();
|
|
5628
5735
|
});
|
|
5629
5736
|
return () => cancelAnimationFrame(t);
|
|
5630
5737
|
}, [
|
|
5631
|
-
|
|
5738
|
+
ne,
|
|
5632
5739
|
e,
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5740
|
+
ee,
|
|
5741
|
+
y,
|
|
5742
|
+
E,
|
|
5636
5743
|
n,
|
|
5637
|
-
|
|
5638
|
-
|
|
5744
|
+
D,
|
|
5745
|
+
R,
|
|
5639
5746
|
r,
|
|
5640
5747
|
s,
|
|
5641
5748
|
u,
|
|
5642
|
-
|
|
5643
|
-
|
|
5749
|
+
te,
|
|
5750
|
+
I
|
|
5644
5751
|
]), o(() => {
|
|
5645
5752
|
let e = () => {
|
|
5646
|
-
|
|
5753
|
+
E.getActive() && E.syncWithModel();
|
|
5647
5754
|
}, t = (t) => {
|
|
5648
5755
|
t(), e();
|
|
5649
5756
|
};
|
|
5650
|
-
return
|
|
5757
|
+
return _({
|
|
5651
5758
|
camera: {
|
|
5652
|
-
fitCamera:
|
|
5653
|
-
getIntersection:
|
|
5759
|
+
fitCamera: R,
|
|
5760
|
+
getIntersection: T.getIntersection
|
|
5654
5761
|
},
|
|
5655
5762
|
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:
|
|
5763
|
+
createClippingRectangle: E.createClippingRectangle,
|
|
5764
|
+
createPlane: E.createPlane,
|
|
5765
|
+
deleteAllPlanes: E.deleteAllPlanes,
|
|
5766
|
+
getActive: E.getActive,
|
|
5767
|
+
getCapsActive: E.getCapsActive,
|
|
5768
|
+
getEdgesActive: E.getEdgesActive,
|
|
5769
|
+
getHelpersActive: E.getHelpersActive,
|
|
5770
|
+
getPlanes: E.getPlanes,
|
|
5771
|
+
setActive: E.setActive,
|
|
5772
|
+
setCapsActive: E.setCapsActive,
|
|
5773
|
+
setEdgesActive: E.setEdgesActive,
|
|
5774
|
+
setHelpersActive: E.setHelpersActive,
|
|
5775
|
+
toggle: E.toggle,
|
|
5776
|
+
updateEdges: E.updateEdges,
|
|
5777
|
+
updateMaterials: E.updateMaterials
|
|
5671
5778
|
},
|
|
5672
5779
|
colors: {
|
|
5673
|
-
clearAllColors:
|
|
5674
|
-
clearColor:
|
|
5675
|
-
clearModelColors:
|
|
5676
|
-
rebuildByColors:
|
|
5677
|
-
rebuildModelByColors:
|
|
5678
|
-
setColor:
|
|
5780
|
+
clearAllColors: w.clearAllColors,
|
|
5781
|
+
clearColor: w.clearColor,
|
|
5782
|
+
clearModelColors: w.clearModelColors,
|
|
5783
|
+
rebuildByColors: w.rebuildByColors,
|
|
5784
|
+
rebuildModelByColors: w.rebuildModelByColors,
|
|
5785
|
+
setColor: w.setColor
|
|
5679
5786
|
},
|
|
5680
|
-
converter:
|
|
5787
|
+
converter: ue,
|
|
5681
5788
|
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:
|
|
5789
|
+
cancelDrawing: D.cancelDrawing,
|
|
5790
|
+
changeAxes: D.changeAxes,
|
|
5791
|
+
delete: D.delete,
|
|
5792
|
+
deleteAll: D.deleteAll,
|
|
5793
|
+
getActive: D.getActive,
|
|
5794
|
+
getDimensions: D.getDimensions,
|
|
5795
|
+
getSnapDistance: D.getSnapDistance,
|
|
5796
|
+
getUnit: D.getUnit,
|
|
5797
|
+
setActive: D.setActive,
|
|
5798
|
+
setColor: D.setColor,
|
|
5799
|
+
setEndpointScaleFactor: D.setEndpointScaleFactor,
|
|
5800
|
+
setSnapDistance: D.setSnapDistance,
|
|
5801
|
+
setUnit: D.setUnit,
|
|
5802
|
+
setWidth: D.setWidth,
|
|
5803
|
+
toggle: D.toggle
|
|
5697
5804
|
},
|
|
5698
5805
|
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(
|
|
5806
|
+
getAllIds: S.getAllIds,
|
|
5807
|
+
getIfcSpacesVisibility: S.getIfcSpacesVisibility,
|
|
5808
|
+
getModelGeometry: (e) => Zs(s.current, e),
|
|
5809
|
+
getModelsGeometry: () => Xs(s.current),
|
|
5810
|
+
hideByIds: (e) => t(() => S.hideByIds(e)),
|
|
5811
|
+
hideSelected: () => t(S.hideSelected),
|
|
5812
|
+
isolateByIds: (e) => t(() => S.isolateByIds(e)),
|
|
5813
|
+
isolateSelected: () => t(S.isolateSelected),
|
|
5814
|
+
resetIsolation: () => t(S.resetIsolation),
|
|
5815
|
+
setIfcSpacesVisibility: (e) => t(() => S.setIfcSpacesVisibility(e)),
|
|
5816
|
+
showAll: () => t(S.showAll),
|
|
5817
|
+
showByIds: (e) => t(() => S.showByIds(e)),
|
|
5818
|
+
toggleIIfcSpacesVisibility: () => t(S.toggleIIfcSpacesVisibility)
|
|
5712
5819
|
},
|
|
5713
|
-
selector: { setTargetToSelection:
|
|
5714
|
-
}),
|
|
5820
|
+
selector: { setTargetToSelection: le }
|
|
5821
|
+
}), N.current || (N.current = !0, d?.(g)), () => _(null);
|
|
5715
5822
|
}, [
|
|
5823
|
+
E,
|
|
5824
|
+
T,
|
|
5716
5825
|
w,
|
|
5717
|
-
C,
|
|
5718
|
-
S,
|
|
5719
5826
|
n,
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5827
|
+
ue,
|
|
5828
|
+
D,
|
|
5829
|
+
R,
|
|
5830
|
+
S,
|
|
5724
5831
|
r,
|
|
5725
5832
|
s,
|
|
5726
5833
|
d,
|
|
5727
|
-
f,
|
|
5728
5834
|
g,
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5835
|
+
_,
|
|
5836
|
+
le
|
|
5837
|
+
]), /* @__PURE__ */ H(Ce, { children: [
|
|
5838
|
+
ae && /* @__PURE__ */ H(Ce, { children: [/* @__PURE__ */ V("ambientLight", {
|
|
5839
|
+
intensity: zs,
|
|
5733
5840
|
color: "#ffffff"
|
|
5734
|
-
}),
|
|
5735
|
-
/* @__PURE__ */ B("directionalLight", {
|
|
5841
|
+
}), /* @__PURE__ */ V("directionalLight", {
|
|
5736
5842
|
ref: r,
|
|
5737
5843
|
position: [
|
|
5738
5844
|
10,
|
|
@@ -5740,62 +5846,62 @@ function Ks({ autoFitCamera: e, cameraRef: t, controlRef: n, lightRef: r, materi
|
|
|
5740
5846
|
10
|
|
5741
5847
|
],
|
|
5742
5848
|
color: "#ffffff",
|
|
5743
|
-
intensity:
|
|
5744
|
-
}),
|
|
5745
|
-
|
|
5746
|
-
/* @__PURE__ */
|
|
5849
|
+
intensity: Bs
|
|
5850
|
+
})] }),
|
|
5851
|
+
P && /* @__PURE__ */ V(h, {}),
|
|
5852
|
+
/* @__PURE__ */ V("group", {
|
|
5747
5853
|
ref: s,
|
|
5748
|
-
children:
|
|
5749
|
-
colorPaletteTexture:
|
|
5750
|
-
coordinationMatrix:
|
|
5854
|
+
children: ie.map(([e, t]) => /* @__PURE__ */ V(Tt, {
|
|
5855
|
+
colorPaletteTexture: C,
|
|
5856
|
+
coordinationMatrix: re,
|
|
5751
5857
|
data: t,
|
|
5752
5858
|
materialMode: a,
|
|
5753
5859
|
modelID: e
|
|
5754
5860
|
}, e))
|
|
5755
5861
|
}),
|
|
5756
|
-
/* @__PURE__ */
|
|
5862
|
+
/* @__PURE__ */ V(m, {
|
|
5757
5863
|
dollyToCursor: !0,
|
|
5758
|
-
draggingSmoothTime: .04,
|
|
5759
5864
|
infinityDolly: !0,
|
|
5760
|
-
minDistance:
|
|
5865
|
+
minDistance: As,
|
|
5761
5866
|
ref: n,
|
|
5762
|
-
|
|
5867
|
+
draggingSmoothTime: .03,
|
|
5868
|
+
smoothTime: .05
|
|
5763
5869
|
})
|
|
5764
5870
|
] });
|
|
5765
5871
|
}
|
|
5766
|
-
function
|
|
5872
|
+
function ic({ autoFitCamera: e = !0, camera: t = {
|
|
5767
5873
|
position: [
|
|
5768
5874
|
10,
|
|
5769
5875
|
10,
|
|
5770
5876
|
10
|
|
5771
5877
|
],
|
|
5772
5878
|
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
|
|
5879
|
+
}, 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 }) {
|
|
5880
|
+
let v = l(null), y = l(null), b = l(null), x = l(null), [S, C] = u(), w = Ee(), T = U((e) => e.setModelNames), E = U((e) => e.setModelProps), D = U((e) => e.setModelStructure), O = U((e) => e.setShowNavCube), ee = U((e) => e.setShowStats), te = U((e) => e.setUserDevice), ne = U((e) => e.showNavCube), k = a ?? S, A = f ? Gs(n, 1) : n, j = Gs(A, f ? Ps : Ns), M = s ?? (f ? "performance" : void 0), [N, P] = u("sleep");
|
|
5775
5881
|
return o(() => {
|
|
5776
|
-
|
|
5777
|
-
}, [
|
|
5778
|
-
|
|
5779
|
-
}, [
|
|
5780
|
-
h !== void 0 &&
|
|
5781
|
-
}, [
|
|
5882
|
+
te(Ks());
|
|
5883
|
+
}, [te]), o(() => {
|
|
5884
|
+
ee(!!g);
|
|
5885
|
+
}, [ee, g]), o(() => {
|
|
5886
|
+
h !== void 0 && O(h);
|
|
5887
|
+
}, [O, h]), o(() => {
|
|
5782
5888
|
let e = {}, t = {}, n = {};
|
|
5783
5889
|
k && Object.entries(k).forEach(([r, i]) => {
|
|
5784
5890
|
let a = Number(r);
|
|
5785
5891
|
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
|
-
}),
|
|
5892
|
+
}), T(e), E(t), D(n);
|
|
5787
5893
|
}, [
|
|
5788
5894
|
k,
|
|
5789
|
-
w,
|
|
5790
5895
|
T,
|
|
5791
|
-
E
|
|
5896
|
+
E,
|
|
5897
|
+
D
|
|
5792
5898
|
]), o(() => {
|
|
5793
5899
|
if (a) return;
|
|
5794
5900
|
let e = i ?? r;
|
|
5795
5901
|
if (!e?.length) return;
|
|
5796
5902
|
let t = !0;
|
|
5797
|
-
return
|
|
5798
|
-
t &&
|
|
5903
|
+
return Yo.loadModel(e).then((e) => {
|
|
5904
|
+
t && C(e);
|
|
5799
5905
|
}), () => {
|
|
5800
5906
|
t = !1;
|
|
5801
5907
|
};
|
|
@@ -5803,71 +5909,73 @@ function qs({ autoFitCamera: e = !0, camera: t = {
|
|
|
5803
5909
|
a,
|
|
5804
5910
|
i,
|
|
5805
5911
|
r
|
|
5806
|
-
]), k ? /* @__PURE__ */
|
|
5807
|
-
style:
|
|
5808
|
-
children: [/* @__PURE__ */
|
|
5912
|
+
]), k ? /* @__PURE__ */ H("div", {
|
|
5913
|
+
style: Ts,
|
|
5914
|
+
children: [/* @__PURE__ */ V(d, {
|
|
5809
5915
|
camera: t,
|
|
5810
|
-
dpr:
|
|
5811
|
-
gl: f ?
|
|
5812
|
-
children: /* @__PURE__ */
|
|
5813
|
-
store:
|
|
5814
|
-
children: /* @__PURE__ */
|
|
5916
|
+
dpr: _ && N === "move" ? j : A,
|
|
5917
|
+
gl: f ? ks : void 0,
|
|
5918
|
+
children: /* @__PURE__ */ V(hi, {
|
|
5919
|
+
store: w,
|
|
5920
|
+
children: /* @__PURE__ */ V(rc, {
|
|
5815
5921
|
autoFitCamera: e,
|
|
5816
|
-
cameraRef:
|
|
5817
|
-
controlRef:
|
|
5818
|
-
lightRef:
|
|
5819
|
-
materialMode:
|
|
5820
|
-
modelRef:
|
|
5922
|
+
cameraRef: v,
|
|
5923
|
+
controlRef: y,
|
|
5924
|
+
lightRef: x,
|
|
5925
|
+
materialMode: M,
|
|
5926
|
+
modelRef: b,
|
|
5821
5927
|
modelsData: k,
|
|
5822
5928
|
onReady: c,
|
|
5929
|
+
onCameraDprModeChange: P,
|
|
5823
5930
|
publicApi: p,
|
|
5824
|
-
setSceneApi: m
|
|
5931
|
+
setSceneApi: m,
|
|
5932
|
+
usePerformanceMoving: _
|
|
5825
5933
|
})
|
|
5826
5934
|
})
|
|
5827
|
-
}),
|
|
5828
|
-
style:
|
|
5829
|
-
children: /* @__PURE__ */
|
|
5830
|
-
camera:
|
|
5831
|
-
dpr:
|
|
5832
|
-
gl: f ?
|
|
5935
|
+
}), ne && /* @__PURE__ */ V("div", {
|
|
5936
|
+
style: ws,
|
|
5937
|
+
children: /* @__PURE__ */ V(d, {
|
|
5938
|
+
camera: Es,
|
|
5939
|
+
dpr: A,
|
|
5940
|
+
gl: f ? Os : Ds,
|
|
5833
5941
|
orthographic: !0,
|
|
5834
|
-
children: /* @__PURE__ */
|
|
5942
|
+
children: /* @__PURE__ */ V(Ss, {
|
|
5835
5943
|
active: !0,
|
|
5836
|
-
cameraRef:
|
|
5837
|
-
controlRef:
|
|
5838
|
-
modelRef:
|
|
5944
|
+
cameraRef: v,
|
|
5945
|
+
controlRef: y,
|
|
5946
|
+
modelRef: b
|
|
5839
5947
|
})
|
|
5840
5948
|
})
|
|
5841
5949
|
})]
|
|
5842
|
-
}) : /* @__PURE__ */
|
|
5950
|
+
}) : /* @__PURE__ */ V(Ce, {});
|
|
5843
5951
|
}
|
|
5844
|
-
var
|
|
5845
|
-
let [n] = u(Ae), r = l(!1), a = l(!1), d = c(() => new
|
|
5952
|
+
var ac = n(function(e, t) {
|
|
5953
|
+
let [n] = u(Ae), r = l(!1), a = l(!1), d = c(() => new Cs(), []), { defaultSelected: f, onSelectedChange: p, selected: m } = e, h = i((e) => {
|
|
5846
5954
|
d.set(e);
|
|
5847
|
-
}, [d]), g = c(() =>
|
|
5955
|
+
}, [d]), g = c(() => to(n, d.get), [d, n]);
|
|
5848
5956
|
return s(t, () => g, [g]), o(() => (n.getState().setApi(g), () => {
|
|
5849
5957
|
n.getState().api === g && n.getState().setApi(null);
|
|
5850
5958
|
}), [g, n]), o(() => {
|
|
5851
|
-
r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(
|
|
5959
|
+
r.current || !f || m !== void 0 || (r.current = !0, n.getState().setSelection(eo(f)));
|
|
5852
5960
|
}, [
|
|
5853
5961
|
m,
|
|
5854
5962
|
f,
|
|
5855
5963
|
n
|
|
5856
5964
|
]), o(() => {
|
|
5857
|
-
m !== void 0 && (a.current = !0, n.getState().setSelection(
|
|
5965
|
+
m !== void 0 && (a.current = !0, n.getState().setSelection(eo(m)), a.current = !1);
|
|
5858
5966
|
}, [m, n]), o(() => {
|
|
5859
5967
|
if (p) return n.subscribe((e, t) => {
|
|
5860
|
-
e.selected !== t.selected && (a.current || p(
|
|
5968
|
+
e.selected !== t.selected && (a.current || p($a(e.selected)));
|
|
5861
5969
|
});
|
|
5862
|
-
}, [p, n]), /* @__PURE__ */
|
|
5970
|
+
}, [p, n]), /* @__PURE__ */ V(hi, {
|
|
5863
5971
|
store: n,
|
|
5864
|
-
children: /* @__PURE__ */
|
|
5972
|
+
children: /* @__PURE__ */ V(ic, {
|
|
5865
5973
|
...e,
|
|
5866
5974
|
publicApi: g,
|
|
5867
5975
|
setSceneApi: h
|
|
5868
5976
|
})
|
|
5869
5977
|
});
|
|
5870
5978
|
});
|
|
5871
|
-
|
|
5979
|
+
ac.displayName = "Viewer";
|
|
5872
5980
|
//#endregion
|
|
5873
|
-
export {
|
|
5981
|
+
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, Ss as NavigationCube, ac as Viewer, hi as ViewerStoreProvider, Ra as bmtConverter, ko as convertIfcFilesToBmtInWorker, Ao as createBmtConverterWorker, mo as createBmtWorker, Ho as createIfcWorker, Ae as createViewerStore, ra as exportExcel, ea as exportModelPropertiesToExcel, po as loadBmtModelsInWorker, Vo as loadIfcModelsInWorker, Yo as loader, gr as useDimensionsUtils, U as useViewerStore, Ee as useViewerStoreApi };
|