@solid-labs/fab-one-widget 0.1.5 → 0.1.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as W, jsx as d, Fragment as He } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as tn, useCallback as Fe, useMemo as de, useState as
|
|
3
|
-
import { useFrame as
|
|
2
|
+
import { createContext as tn, useCallback as Fe, useMemo as de, useState as Q, memo as nn, useEffect as Se, useRef as Ie } from "react";
|
|
3
|
+
import { useFrame as Pt, useThree as on, Canvas as sn } from "@react-three/fiber";
|
|
4
4
|
import { Html as Ke, Line as ge, OrbitControls as Dt } from "@react-three/drei";
|
|
5
5
|
import * as J from "three";
|
|
6
6
|
import { Plane as it, Vector3 as h, Box3 as Tt, Line3 as ht, Quaternion as Oe, Matrix4 as kt } from "three";
|
|
@@ -8,7 +8,7 @@ import { create as rn } from "zustand";
|
|
|
8
8
|
import { OBJLoader as ln } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
9
9
|
import { STLLoader as an } from "three/examples/jsm/loaders/STLLoader.js";
|
|
10
10
|
import { MeshBVH as $e } from "three-mesh-bvh";
|
|
11
|
-
let bo, dt, ao,
|
|
11
|
+
let bo, dt, ao, jt;
|
|
12
12
|
let __tla = (async () => {
|
|
13
13
|
const cn = {
|
|
14
14
|
showDragDrop: true,
|
|
@@ -28,37 +28,37 @@ let __tla = (async () => {
|
|
|
28
28
|
showAmputationModal: false,
|
|
29
29
|
showNavigation: false,
|
|
30
30
|
showToolbar: false
|
|
31
|
-
}, dn = tn(cn), gt = rn((e,
|
|
31
|
+
}, dn = tn(cn), gt = rn((e, r) => ({
|
|
32
32
|
landmarkPoints: [],
|
|
33
33
|
isAligned: false,
|
|
34
34
|
isCut: false,
|
|
35
|
-
addLandmarkPoint: (
|
|
35
|
+
addLandmarkPoint: (n) => e((t) => t.landmarkPoints.length >= 3 ? t : {
|
|
36
36
|
landmarkPoints: [
|
|
37
37
|
...t.landmarkPoints,
|
|
38
|
-
|
|
38
|
+
n
|
|
39
39
|
]
|
|
40
40
|
}),
|
|
41
|
-
removeLandmarkPoint: (
|
|
42
|
-
landmarkPoints: t.landmarkPoints.filter((
|
|
41
|
+
removeLandmarkPoint: (n) => e((t) => ({
|
|
42
|
+
landmarkPoints: t.landmarkPoints.filter((i, a) => a !== n)
|
|
43
43
|
})),
|
|
44
44
|
clearLandmarkPoints: () => e({
|
|
45
45
|
landmarkPoints: [],
|
|
46
46
|
isAligned: false,
|
|
47
47
|
isCut: false
|
|
48
48
|
}),
|
|
49
|
-
updateLandmarkPositions: (
|
|
50
|
-
landmarkPoints: t.landmarkPoints.map((
|
|
51
|
-
...
|
|
52
|
-
position:
|
|
49
|
+
updateLandmarkPositions: (n) => e((t) => ({
|
|
50
|
+
landmarkPoints: t.landmarkPoints.map((i, a) => ({
|
|
51
|
+
...i,
|
|
52
|
+
position: n[a] ?? i.position
|
|
53
53
|
}))
|
|
54
54
|
})),
|
|
55
|
-
setAligned: (
|
|
56
|
-
isAligned:
|
|
55
|
+
setAligned: (n) => e({
|
|
56
|
+
isAligned: n
|
|
57
57
|
}),
|
|
58
|
-
setCut: (
|
|
59
|
-
isCut:
|
|
58
|
+
setCut: (n) => e({
|
|
59
|
+
isCut: n
|
|
60
60
|
}),
|
|
61
|
-
isSelectionComplete: () =>
|
|
61
|
+
isSelectionComplete: () => r().landmarkPoints.length === 3
|
|
62
62
|
})), un = 0.45, Ye = 3, ut = 1e-3, We = 25.4, pn = 5, hn = [
|
|
63
63
|
0.25,
|
|
64
64
|
-0.25,
|
|
@@ -66,52 +66,52 @@ let __tla = (async () => {
|
|
|
66
66
|
-0.5
|
|
67
67
|
];
|
|
68
68
|
function gn(e) {
|
|
69
|
-
const
|
|
70
|
-
`),
|
|
71
|
-
let
|
|
72
|
-
for (const a of
|
|
69
|
+
const r = e.split(`
|
|
70
|
+
`), n = [], t = [];
|
|
71
|
+
let i = false;
|
|
72
|
+
for (const a of r) if (a.startsWith("v ")) {
|
|
73
73
|
const c = a.trim().split(/\s+/);
|
|
74
74
|
if (c.length >= 7) {
|
|
75
|
-
|
|
76
|
-
let u = parseFloat(c[4]),
|
|
77
|
-
(u > 1 ||
|
|
78
|
-
} else c.length >= 4 && (
|
|
75
|
+
n.push(parseFloat(c[1]), parseFloat(c[2]), parseFloat(c[3]));
|
|
76
|
+
let u = parseFloat(c[4]), s = parseFloat(c[5]), l = parseFloat(c[6]);
|
|
77
|
+
(u > 1 || s > 1 || l > 1) && (u /= 255, s /= 255, l /= 255), t.push(u, s, l), i = true;
|
|
78
|
+
} else c.length >= 4 && (n.push(parseFloat(c[1]), parseFloat(c[2]), parseFloat(c[3])), t.push(0, 0, 0));
|
|
79
79
|
}
|
|
80
|
-
return
|
|
81
|
-
positions: new Float32Array(
|
|
80
|
+
return i ? {
|
|
81
|
+
positions: new Float32Array(n),
|
|
82
82
|
colors: new Float32Array(t)
|
|
83
83
|
} : null;
|
|
84
84
|
}
|
|
85
|
-
function mn(e,
|
|
86
|
-
const
|
|
87
|
-
let
|
|
85
|
+
function mn(e, r, n, t) {
|
|
86
|
+
const i = e.getAttribute("position"), a = i.count, c = new Float32Array(a * 3), u = r.length / 3;
|
|
87
|
+
let s = 1 / 0, l = 1 / 0, o = 1 / 0, f = -1 / 0, y = -1 / 0, p = -1 / 0;
|
|
88
88
|
for (let b = 0; b < u; b++) {
|
|
89
|
-
const S =
|
|
90
|
-
S <
|
|
89
|
+
const S = r[b * 3] * t, C = r[b * 3 + 1] * t, M = r[b * 3 + 2] * t;
|
|
90
|
+
S < s && (s = S), S > f && (f = S), C < l && (l = C), C > y && (y = C), M < o && (o = M), M > p && (p = M);
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const x = Math.min(128, Math.max(16, Math.round(Math.cbrt(u)))), g = (f - s + 1e-6) / x, w = (y - l + 1e-6) / x, v = (p - o + 1e-6) / x, m = /* @__PURE__ */ new Map();
|
|
93
93
|
for (let b = 0; b < u; b++) {
|
|
94
|
-
const S = Math.min(
|
|
95
|
-
let
|
|
96
|
-
|
|
94
|
+
const S = Math.min(x - 1, Math.floor((r[b * 3] * t - s) / g)), C = Math.min(x - 1, Math.floor((r[b * 3 + 1] * t - l) / w)), M = Math.min(x - 1, Math.floor((r[b * 3 + 2] * t - o) / v)), P = S * x * x + C * x + M;
|
|
95
|
+
let L = m.get(P);
|
|
96
|
+
L || (L = [], m.set(P, L)), L.push(b);
|
|
97
97
|
}
|
|
98
98
|
for (let b = 0; b < a; b++) {
|
|
99
|
-
const S =
|
|
99
|
+
const S = i.getX(b), C = i.getY(b), M = i.getZ(b), P = Math.min(x - 1, Math.max(0, Math.floor((S - s) / g))), L = Math.min(x - 1, Math.max(0, Math.floor((C - l) / w))), H = Math.min(x - 1, Math.max(0, Math.floor((M - o) / v)));
|
|
100
100
|
let O = 1 / 0, $ = 0;
|
|
101
|
-
for (let R = 0; R <=
|
|
102
|
-
for (let Y = -R; Y <= R; Y++) for (let
|
|
103
|
-
if (R > 0 && Math.abs(Y) < R && Math.abs(
|
|
104
|
-
const oe =
|
|
105
|
-
if (oe < 0 || oe >=
|
|
106
|
-
const D =
|
|
101
|
+
for (let R = 0; R <= x && O > 0; R++) {
|
|
102
|
+
for (let Y = -R; Y <= R; Y++) for (let j = -R; j <= R; j++) for (let ne = -R; ne <= R; ne++) {
|
|
103
|
+
if (R > 0 && Math.abs(Y) < R && Math.abs(j) < R && Math.abs(ne) < R) continue;
|
|
104
|
+
const oe = P + Y, le = L + j, ee = H + ne;
|
|
105
|
+
if (oe < 0 || oe >= x || le < 0 || le >= x || ee < 0 || ee >= x) continue;
|
|
106
|
+
const D = m.get(oe * x * x + le * x + ee);
|
|
107
107
|
if (D) for (const z of D) {
|
|
108
|
-
const F =
|
|
108
|
+
const F = r[z * 3] * t, V = r[z * 3 + 1] * t, B = r[z * 3 + 2] * t, T = (S - F) ** 2 + (C - V) ** 2 + (M - B) ** 2;
|
|
109
109
|
T < O && (O = T, $ = z);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
if (O < 1 / 0) break;
|
|
113
113
|
}
|
|
114
|
-
c[b * 3] =
|
|
114
|
+
c[b * 3] = n[$ * 3], c[b * 3 + 1] = n[$ * 3 + 1], c[b * 3 + 2] = n[$ * 3 + 2];
|
|
115
115
|
}
|
|
116
116
|
e.setAttribute("color", new J.Float32BufferAttribute(c, 3));
|
|
117
117
|
}
|
|
@@ -123,57 +123,57 @@ let __tla = (async () => {
|
|
|
123
123
|
"#cc44ff",
|
|
124
124
|
"#44ffcc"
|
|
125
125
|
];
|
|
126
|
-
function yn(e,
|
|
127
|
-
const
|
|
128
|
-
for (let
|
|
129
|
-
const f =
|
|
130
|
-
a.has(f) || a.set(f, []), a.get(f).push(
|
|
126
|
+
function yn(e, r) {
|
|
127
|
+
const n = e.getVertices(), t = e.getFaces(), i = e.getComponentLabels(), a = /* @__PURE__ */ new Map();
|
|
128
|
+
for (let o = 0; o < i.length; o++) {
|
|
129
|
+
const f = i[o];
|
|
130
|
+
a.has(f) || a.set(f, []), a.get(f).push(o);
|
|
131
131
|
}
|
|
132
132
|
const c = [
|
|
133
133
|
...a.keys()
|
|
134
|
-
].sort((
|
|
135
|
-
for (const
|
|
136
|
-
const f = a.get(
|
|
137
|
-
for (const
|
|
138
|
-
const S = t[
|
|
134
|
+
].sort((o, f) => o - f), u = [], s = [], l = [];
|
|
135
|
+
for (const o of c) {
|
|
136
|
+
const f = a.get(o), y = /* @__PURE__ */ new Map(), p = [], x = [];
|
|
137
|
+
for (const m of f) for (let b = 0; b < 3; b++) {
|
|
138
|
+
const S = t[m * 3 + b];
|
|
139
139
|
if (!y.has(S)) {
|
|
140
|
-
const
|
|
141
|
-
p.push(
|
|
140
|
+
const C = p.length / 3;
|
|
141
|
+
p.push(n[S * 3], n[S * 3 + 1], n[S * 3 + 2]), y.set(S, C);
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
x.push(y.get(S));
|
|
144
144
|
}
|
|
145
145
|
const g = new J.BufferGeometry();
|
|
146
|
-
g.setAttribute("position", new J.Float32BufferAttribute(p, 3)), g.setIndex(
|
|
147
|
-
const
|
|
148
|
-
|
|
146
|
+
g.setAttribute("position", new J.Float32BufferAttribute(p, 3)), g.setIndex(x), g.computeVertexNormals(), u.push(g);
|
|
147
|
+
const v = o === r ? `#${o} inner` : o === 0 ? `#${o} outer` : `#${o} (${f.length} faces)`;
|
|
148
|
+
s.push(v), l.push(zt[o % zt.length]);
|
|
149
149
|
}
|
|
150
150
|
return {
|
|
151
151
|
geometries: u,
|
|
152
|
-
labels:
|
|
153
|
-
colors:
|
|
154
|
-
innerIdx:
|
|
152
|
+
labels: s,
|
|
153
|
+
colors: l,
|
|
154
|
+
innerIdx: r
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
async function bn(e,
|
|
157
|
+
async function bn(e, r, n) {
|
|
158
158
|
let t = null;
|
|
159
159
|
try {
|
|
160
|
-
const
|
|
161
|
-
|
|
160
|
+
const i = gn(e);
|
|
161
|
+
n == null ? void 0 : n("Loading mesh..."), t = new r.WasmMeshSet(), t.loadObjString(e), n == null ? void 0 : n("Detecting units...");
|
|
162
162
|
const a = t.autoScaleToMm(pn);
|
|
163
|
-
|
|
163
|
+
n == null ? void 0 : n("Merging close vertices..."), t.applyMergeCloseVertices(1e-4), n == null ? void 0 : n("Analyzing mesh components...");
|
|
164
164
|
let c = false, u = null;
|
|
165
165
|
if (t.getComponentCount() >= 2) {
|
|
166
|
-
|
|
166
|
+
n == null ? void 0 : n("Building component debug info...");
|
|
167
167
|
const y = yn(t, null);
|
|
168
|
-
|
|
169
|
-
} else
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
168
|
+
n == null ? void 0 : n("Extracting inner shell..."), c = t.extractInnerShell(xn), c ? (console.log("Inner shell extracted from double-shell mesh"), y.innerIdx = 1, y.labels[1] = "#1 inner (extracted)", y.labels[0] && (y.labels[0] = "#0 outer (discarded)"), u = y) : (n == null ? void 0 : n("Removing floating artifacts..."), t.splitAndKeepLargest(), u = y);
|
|
169
|
+
} else n == null ? void 0 : n("Removing floating artifacts..."), t.splitAndKeepLargest();
|
|
170
|
+
n == null ? void 0 : n("Closing holes..."), t.applyCloseHoles(30), t.applyMergeCloseVertices(1e-4), n == null ? void 0 : n("Extracting geometry...");
|
|
171
|
+
const l = t.getVertices(), o = t.getFaces();
|
|
172
|
+
if (l.length === 0) return null;
|
|
173
173
|
const f = new J.BufferGeometry();
|
|
174
|
-
if (f.setAttribute("position", new J.Float32BufferAttribute(
|
|
174
|
+
if (f.setAttribute("position", new J.Float32BufferAttribute(l, 3)), f.setIndex(Array.from(o)), f.computeVertexNormals(), i) {
|
|
175
175
|
const y = a ? 1e3 : 1;
|
|
176
|
-
mn(f,
|
|
176
|
+
mn(f, i.positions, i.colors, y);
|
|
177
177
|
}
|
|
178
178
|
return {
|
|
179
179
|
geometry: f,
|
|
@@ -181,8 +181,8 @@ let __tla = (async () => {
|
|
|
181
181
|
innerShellExtracted: c,
|
|
182
182
|
componentDebug: u
|
|
183
183
|
};
|
|
184
|
-
} catch (
|
|
185
|
-
return console.error("WASM processing failed:",
|
|
184
|
+
} catch (i) {
|
|
185
|
+
return console.error("WASM processing failed:", i), null;
|
|
186
186
|
} finally {
|
|
187
187
|
if (t) try {
|
|
188
188
|
t.free();
|
|
@@ -191,312 +191,312 @@ let __tla = (async () => {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
function wn(e) {
|
|
194
|
-
const
|
|
194
|
+
const n = new ln().parse(e);
|
|
195
195
|
let t = null;
|
|
196
|
-
return
|
|
197
|
-
|
|
196
|
+
return n.traverse((i) => {
|
|
197
|
+
i.isMesh && !t && (t = i.geometry);
|
|
198
198
|
}), t;
|
|
199
199
|
}
|
|
200
200
|
async function ft(e) {
|
|
201
|
-
const
|
|
202
|
-
if (!
|
|
201
|
+
const r = await e.arrayBuffer(), i = new an().parse(r).getAttribute("position");
|
|
202
|
+
if (!i || i.count === 0) throw new Error("Empty STL geometry");
|
|
203
203
|
const a = [];
|
|
204
|
-
for (let c = 0; c <
|
|
205
|
-
for (let c = 0; c <
|
|
204
|
+
for (let c = 0; c < i.count; c++) a.push(`v ${i.getX(c)} ${i.getY(c)} ${i.getZ(c)}`);
|
|
205
|
+
for (let c = 0; c < i.count; c += 3) a.push(`f ${c + 1} ${c + 2} ${c + 3}`);
|
|
206
206
|
return a.join(`
|
|
207
207
|
`);
|
|
208
208
|
}
|
|
209
|
-
function Bt(e,
|
|
210
|
-
const
|
|
211
|
-
return `${Math.round(e.x *
|
|
209
|
+
function Bt(e, r) {
|
|
210
|
+
const n = 1 / r;
|
|
211
|
+
return `${Math.round(e.x * n)}_${Math.round(e.y * n)}_${Math.round(e.z * n)}`;
|
|
212
212
|
}
|
|
213
|
-
function Rt(e,
|
|
213
|
+
function Rt(e, r) {
|
|
214
214
|
if (!e.length) return [];
|
|
215
|
-
const
|
|
216
|
-
for (const t of e) (
|
|
217
|
-
return
|
|
215
|
+
const n = [];
|
|
216
|
+
for (const t of e) (n.length === 0 || n[n.length - 1].distanceTo(t) > r) && n.push(t.clone());
|
|
217
|
+
return n.length > 2 && n[0].distanceTo(n[n.length - 1]) > r && n.push(n[0].clone()), n;
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
let
|
|
221
|
-
for (let
|
|
222
|
-
return
|
|
219
|
+
function Ne(e) {
|
|
220
|
+
let r = 0;
|
|
221
|
+
for (let n = 0; n < e.length - 1; n++) r += e[n].distanceTo(e[n + 1]);
|
|
222
|
+
return r;
|
|
223
223
|
}
|
|
224
|
-
function Et(e,
|
|
224
|
+
function Et(e, r = 1e-3, n = false) {
|
|
225
225
|
if (!e.length) return [];
|
|
226
|
-
const t = /* @__PURE__ */ new Map(),
|
|
227
|
-
const
|
|
228
|
-
let f = t.get(
|
|
229
|
-
return f || (f =
|
|
230
|
-
}, a = e.map((
|
|
231
|
-
a: l
|
|
232
|
-
b: l
|
|
226
|
+
const t = /* @__PURE__ */ new Map(), i = (l) => {
|
|
227
|
+
const o = Bt(l, r);
|
|
228
|
+
let f = t.get(o);
|
|
229
|
+
return f || (f = l.clone(), t.set(o, f)), f;
|
|
230
|
+
}, a = e.map((l) => ({
|
|
231
|
+
a: i(l.a),
|
|
232
|
+
b: i(l.b)
|
|
233
233
|
})), c = [];
|
|
234
234
|
for (; a.length; ) {
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
const l = a.pop(), o = [
|
|
236
|
+
l.a,
|
|
237
|
+
l.b
|
|
238
238
|
];
|
|
239
239
|
let f = true;
|
|
240
240
|
for (; f; ) {
|
|
241
241
|
f = false;
|
|
242
242
|
for (let p = a.length - 1; p >= 0; p--) {
|
|
243
|
-
const { a:
|
|
244
|
-
if (
|
|
245
|
-
else if (g.equals(
|
|
246
|
-
else if (
|
|
247
|
-
else if (g.equals(
|
|
243
|
+
const { a: x, b: g } = a[p];
|
|
244
|
+
if (x.equals(o[o.length - 1])) o.push(g);
|
|
245
|
+
else if (g.equals(o[o.length - 1])) o.push(x);
|
|
246
|
+
else if (x.equals(o[0])) o.unshift(g);
|
|
247
|
+
else if (g.equals(o[0])) o.unshift(x);
|
|
248
248
|
else continue;
|
|
249
249
|
a.splice(p, 1), f = true;
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
const y = Rt(
|
|
252
|
+
const y = Rt(o, r);
|
|
253
253
|
y.length > 1 && c.push(y);
|
|
254
254
|
}
|
|
255
255
|
if (!c.length) return [];
|
|
256
|
-
if (c.sort((
|
|
257
|
-
const u =
|
|
258
|
-
return
|
|
256
|
+
if (c.sort((l, o) => Ne(o) - Ne(l)), !n) return c[0] ?? [];
|
|
257
|
+
const u = Ne(c[0]), s = c.filter((l) => Ne(l) >= u * 0.3);
|
|
258
|
+
return s[s.length - 1] ?? c[0];
|
|
259
259
|
}
|
|
260
|
-
function Ct(e,
|
|
261
|
-
const
|
|
262
|
-
c.setFromBufferAttribute(
|
|
260
|
+
function Ct(e, r, n, t = false) {
|
|
261
|
+
const i = new it(new h(0, 1, 0), -n), a = [], c = new Tt();
|
|
262
|
+
c.setFromBufferAttribute(r.getAttribute("position"));
|
|
263
263
|
const u = {
|
|
264
264
|
linePoints: [],
|
|
265
265
|
lineLength: 0,
|
|
266
|
-
rightmostPoint: new h(0,
|
|
266
|
+
rightmostPoint: new h(0, n, 0)
|
|
267
267
|
};
|
|
268
|
-
if (!
|
|
269
|
-
const
|
|
268
|
+
if (!i.intersectsBox(c)) return u;
|
|
269
|
+
const s = new ht(), l = new h();
|
|
270
270
|
e.shapecast({
|
|
271
|
-
intersectsBounds: (g) =>
|
|
271
|
+
intersectsBounds: (g) => i.intersectsBox(g),
|
|
272
272
|
intersectsTriangle: (g) => {
|
|
273
273
|
const w = [];
|
|
274
|
-
|
|
274
|
+
s.set(g.a, g.b), i.intersectLine(s, l) && w.push(l.clone()), s.set(g.b, g.c), i.intersectLine(s, l) && w.push(l.clone()), s.set(g.c, g.a), i.intersectLine(s, l) && w.push(l.clone()), w.length === 2 && a.push({
|
|
275
275
|
a: w[0],
|
|
276
276
|
b: w[1]
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
279
|
});
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
let y = -1 / 0, p = new h(0,
|
|
283
|
-
for (const g of
|
|
284
|
-
const
|
|
280
|
+
const o = Et(a, ut, t), f = Ne(o);
|
|
281
|
+
if (o.length < 2) return u;
|
|
282
|
+
let y = -1 / 0, p = new h(0, n, 0);
|
|
283
|
+
for (const g of o) g.x > y && (y = g.x, p = g.clone());
|
|
284
|
+
const x = o.length > 2 && o[0].distanceTo(o[o.length - 1]) < ut * 10;
|
|
285
285
|
return {
|
|
286
|
-
linePoints:
|
|
286
|
+
linePoints: o,
|
|
287
287
|
lineLength: f,
|
|
288
288
|
rightmostPoint: p,
|
|
289
|
-
isClosed:
|
|
289
|
+
isClosed: x
|
|
290
290
|
};
|
|
291
291
|
}
|
|
292
|
-
function Ze(e,
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
295
|
-
console.warn(`[slice] y=${
|
|
296
|
-
let a =
|
|
292
|
+
function Ze(e, r, n, t = false) {
|
|
293
|
+
const i = Ct(e, r, n, t);
|
|
294
|
+
if (i.isClosed && i.linePoints.length >= 3) return i;
|
|
295
|
+
console.warn(`[slice] y=${n.toFixed(2)} failed (pts=${i.linePoints.length}, closed=${i.isClosed}), retrying...`);
|
|
296
|
+
let a = i;
|
|
297
297
|
for (const c of hn) {
|
|
298
|
-
const u = Ct(e,
|
|
299
|
-
if (u.isClosed && u.linePoints.length >= 3) return console.log(`[slice] y=${
|
|
298
|
+
const u = Ct(e, r, n + c, t);
|
|
299
|
+
if (u.isClosed && u.linePoints.length >= 3) return console.log(`[slice] y=${n.toFixed(2)} recovered with offset ${c > 0 ? "+" : ""}${c}mm (pts=${u.linePoints.length}, len=${u.lineLength.toFixed(1)}mm)`), u;
|
|
300
300
|
u.linePoints.length > a.linePoints.length && (a = u);
|
|
301
301
|
}
|
|
302
|
-
return console.warn(`[slice] y=${
|
|
302
|
+
return console.warn(`[slice] y=${n.toFixed(2)} all retries exhausted (pts=${a.linePoints.length}, closed=${a.isClosed})`), a;
|
|
303
303
|
}
|
|
304
|
-
function pt(e,
|
|
305
|
-
const
|
|
306
|
-
if (a.setFromBufferAttribute(
|
|
307
|
-
const c = [], u = new ht(),
|
|
304
|
+
function pt(e, r, n, t) {
|
|
305
|
+
const i = new it().setFromNormalAndCoplanarPoint(t.clone().normalize(), n), a = new Tt();
|
|
306
|
+
if (a.setFromBufferAttribute(r.getAttribute("position")), !i.intersectsBox(a)) return 0;
|
|
307
|
+
const c = [], u = new ht(), s = new h();
|
|
308
308
|
e.shapecast({
|
|
309
|
-
intersectsBounds: (
|
|
310
|
-
intersectsTriangle: (
|
|
309
|
+
intersectsBounds: (o) => i.intersectsBox(o),
|
|
310
|
+
intersectsTriangle: (o) => {
|
|
311
311
|
const f = [];
|
|
312
|
-
u.set(
|
|
312
|
+
u.set(o.a, o.b), i.intersectLine(u, s) && f.push(s.clone()), u.set(o.b, o.c), i.intersectLine(u, s) && f.push(s.clone()), u.set(o.c, o.a), i.intersectLine(u, s) && f.push(s.clone()), f.length === 2 && c.push({
|
|
313
313
|
a: f[0],
|
|
314
314
|
b: f[1]
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
});
|
|
318
|
-
const
|
|
319
|
-
return
|
|
318
|
+
const l = Et(c, ut);
|
|
319
|
+
return Ne(l);
|
|
320
320
|
}
|
|
321
321
|
function ot(e) {
|
|
322
322
|
return new $e(e, {
|
|
323
323
|
maxLeafTris: Ye
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
|
-
function vt(e,
|
|
326
|
+
function vt(e, r, n) {
|
|
327
327
|
const t = e instanceof $e ? e : new $e(e, {
|
|
328
328
|
maxLeafTris: Ye
|
|
329
|
-
}),
|
|
329
|
+
}), i = new it().setFromNormalAndCoplanarPoint(n.clone().normalize(), r), a = [], c = new ht(), u = new h();
|
|
330
330
|
return t.shapecast({
|
|
331
|
-
intersectsBounds: (
|
|
332
|
-
intersectsTriangle: (
|
|
333
|
-
const
|
|
334
|
-
c.set(
|
|
335
|
-
a:
|
|
336
|
-
b:
|
|
331
|
+
intersectsBounds: (s) => i.intersectsBox(s),
|
|
332
|
+
intersectsTriangle: (s) => {
|
|
333
|
+
const l = [];
|
|
334
|
+
c.set(s.a, s.b), i.intersectLine(c, u) && l.push(u.clone()), c.set(s.b, s.c), i.intersectLine(c, u) && l.push(u.clone()), c.set(s.c, s.a), i.intersectLine(c, u) && l.push(u.clone()), l.length === 2 && a.push({
|
|
335
|
+
a: l[0],
|
|
336
|
+
b: l[1]
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
}), a;
|
|
340
340
|
}
|
|
341
|
-
function Mt(e,
|
|
341
|
+
function Mt(e, r, n = 1e-3) {
|
|
342
342
|
if (!e.length) return [];
|
|
343
|
-
const t = /* @__PURE__ */ new Map(),
|
|
344
|
-
const
|
|
345
|
-
let f = t.get(
|
|
346
|
-
return f || (f =
|
|
347
|
-
}, a = e.map((
|
|
348
|
-
a: l
|
|
349
|
-
b: l
|
|
343
|
+
const t = /* @__PURE__ */ new Map(), i = (l) => {
|
|
344
|
+
const o = Bt(l, n);
|
|
345
|
+
let f = t.get(o);
|
|
346
|
+
return f || (f = l.clone(), t.set(o, f)), f;
|
|
347
|
+
}, a = e.map((l) => ({
|
|
348
|
+
a: i(l.a),
|
|
349
|
+
b: i(l.b)
|
|
350
350
|
})), c = [];
|
|
351
351
|
for (; a.length; ) {
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
352
|
+
const l = a.pop(), o = [
|
|
353
|
+
l.a,
|
|
354
|
+
l.b
|
|
355
355
|
];
|
|
356
356
|
let f = true;
|
|
357
357
|
for (; f; ) {
|
|
358
358
|
f = false;
|
|
359
359
|
for (let p = a.length - 1; p >= 0; p--) {
|
|
360
|
-
const { a:
|
|
361
|
-
if (
|
|
362
|
-
else if (g.equals(
|
|
363
|
-
else if (
|
|
364
|
-
else if (g.equals(
|
|
360
|
+
const { a: x, b: g } = a[p];
|
|
361
|
+
if (x.equals(o[o.length - 1])) o.push(g);
|
|
362
|
+
else if (g.equals(o[o.length - 1])) o.push(x);
|
|
363
|
+
else if (x.equals(o[0])) o.unshift(g);
|
|
364
|
+
else if (g.equals(o[0])) o.unshift(x);
|
|
365
365
|
else continue;
|
|
366
366
|
a.splice(p, 1), f = true;
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
const y = Rt(
|
|
369
|
+
const y = Rt(o, n);
|
|
370
370
|
y.length > 1 && c.push(y);
|
|
371
371
|
}
|
|
372
372
|
if (!c.length) return [];
|
|
373
|
-
let u = [],
|
|
374
|
-
for (const
|
|
375
|
-
if (
|
|
373
|
+
let u = [], s = 1 / 0;
|
|
374
|
+
for (const l of c) {
|
|
375
|
+
if (l.length < 3 || !(l[0].distanceTo(l[l.length - 1]) < 2)) continue;
|
|
376
376
|
const f = new h();
|
|
377
|
-
for (const p of
|
|
378
|
-
f.divideScalar(
|
|
379
|
-
const y = f.distanceTo(
|
|
380
|
-
y <
|
|
377
|
+
for (const p of l) f.add(p);
|
|
378
|
+
f.divideScalar(l.length);
|
|
379
|
+
const y = f.distanceTo(r);
|
|
380
|
+
y < s && (s = y, u = l);
|
|
381
381
|
}
|
|
382
|
-
if (u.length === 0) for (const
|
|
383
|
-
if (
|
|
384
|
-
const
|
|
385
|
-
for (const y of
|
|
386
|
-
|
|
387
|
-
const f =
|
|
388
|
-
f <
|
|
382
|
+
if (u.length === 0) for (const l of c) {
|
|
383
|
+
if (l.length < 3) continue;
|
|
384
|
+
const o = new h();
|
|
385
|
+
for (const y of l) o.add(y);
|
|
386
|
+
o.divideScalar(l.length);
|
|
387
|
+
const f = o.distanceTo(r);
|
|
388
|
+
f < s && (s = f, u = l);
|
|
389
389
|
}
|
|
390
390
|
return u;
|
|
391
391
|
}
|
|
392
392
|
function Sn(e) {
|
|
393
|
-
const
|
|
394
|
-
for (const
|
|
395
|
-
return
|
|
393
|
+
const r = new h();
|
|
394
|
+
for (const n of e) r.add(n);
|
|
395
|
+
return r.divideScalar(e.length);
|
|
396
396
|
}
|
|
397
|
-
function zn(e,
|
|
397
|
+
function zn(e, r, n) {
|
|
398
398
|
const t = new $e(e, {
|
|
399
399
|
maxLeafTris: Ye
|
|
400
|
-
}),
|
|
401
|
-
let u =
|
|
402
|
-
const
|
|
403
|
-
const
|
|
400
|
+
}), i = new h().subVectors(r, n).normalize(), c = r.distanceTo(n) * 0.05;
|
|
401
|
+
let u = i.clone();
|
|
402
|
+
const s = (v) => {
|
|
403
|
+
const m = [];
|
|
404
404
|
for (let $ = -10; $ <= 0; $++) {
|
|
405
|
-
const R =
|
|
406
|
-
|
|
405
|
+
const R = r.clone().addScaledVector(v, $ * c), Y = vt(t, R, v), j = Mt(Y, R, 1);
|
|
406
|
+
j.length >= 3 && j[0].distanceTo(j[j.length - 1]) < 1 && m.push(Sn(j));
|
|
407
407
|
}
|
|
408
|
-
if (
|
|
408
|
+
if (m.length < 3) return null;
|
|
409
409
|
const b = new h();
|
|
410
|
-
for (const $ of
|
|
411
|
-
b.divideScalar(
|
|
412
|
-
let S = 0,
|
|
413
|
-
for (const $ of
|
|
414
|
-
const R = $.x - b.x, Y = $.y - b.y,
|
|
415
|
-
S += R * R,
|
|
410
|
+
for (const $ of m) b.add($);
|
|
411
|
+
b.divideScalar(m.length);
|
|
412
|
+
let S = 0, C = 0, M = 0, P = 0, L = 0, H = 0;
|
|
413
|
+
for (const $ of m) {
|
|
414
|
+
const R = $.x - b.x, Y = $.y - b.y, j = $.z - b.z;
|
|
415
|
+
S += R * R, C += R * Y, M += R * j, P += Y * Y, L += Y * j, H += j * j;
|
|
416
416
|
}
|
|
417
|
-
let O =
|
|
417
|
+
let O = v.clone();
|
|
418
418
|
for (let $ = 0; $ < 30; $++) {
|
|
419
|
-
const R = S * O.x +
|
|
419
|
+
const R = S * O.x + C * O.y + M * O.z, Y = C * O.x + P * O.y + L * O.z, j = M * O.x + L * O.y + H * O.z, ne = new h(R, Y, j), oe = ne.length();
|
|
420
420
|
if (oe < 1e-10 || (ne.divideScalar(oe), O.distanceTo(ne) < 1e-8)) break;
|
|
421
421
|
O = ne;
|
|
422
422
|
}
|
|
423
|
-
return O.dot(
|
|
423
|
+
return O.dot(i) < 0 && O.negate(), O;
|
|
424
424
|
};
|
|
425
|
-
for (let
|
|
426
|
-
const
|
|
427
|
-
if (!
|
|
428
|
-
const b = u.angleTo(
|
|
429
|
-
if (u =
|
|
425
|
+
for (let v = 0; v < 3; v++) {
|
|
426
|
+
const m = s(u);
|
|
427
|
+
if (!m) break;
|
|
428
|
+
const b = u.angleTo(m);
|
|
429
|
+
if (u = m, b < 1e-3) break;
|
|
430
430
|
}
|
|
431
|
-
const
|
|
432
|
-
Math.abs(u.x) < 0.9 ?
|
|
433
|
-
const
|
|
434
|
-
const
|
|
431
|
+
const l = new h();
|
|
432
|
+
Math.abs(u.x) < 0.9 ? l.set(1, 0, 0) : l.set(0, 1, 0), l.crossVectors(u, l).normalize();
|
|
433
|
+
const o = new h().crossVectors(u, l).normalize(), f = (v) => {
|
|
434
|
+
const m = vt(t, r, v), b = Mt(m, r, 1);
|
|
435
435
|
if (b.length < 3) return {
|
|
436
436
|
circumference: 1 / 0,
|
|
437
437
|
closed: false
|
|
438
438
|
};
|
|
439
439
|
const S = b[0].distanceTo(b[b.length - 1]) < 1;
|
|
440
440
|
return {
|
|
441
|
-
circumference:
|
|
441
|
+
circumference: Ne(b),
|
|
442
442
|
closed: S
|
|
443
443
|
};
|
|
444
444
|
};
|
|
445
445
|
let y = u.clone(), p = 1 / 0;
|
|
446
|
-
for (let
|
|
447
|
-
const b =
|
|
448
|
-
M.closed && M.circumference < p && (p = M.circumference, y =
|
|
446
|
+
for (let v = -3; v <= 3; v += 1) for (let m = -3; m <= 3; m += 1) {
|
|
447
|
+
const b = v * Math.PI / 180, S = m * Math.PI / 180, C = u.clone().applyQuaternion(new Oe().setFromAxisAngle(l, b)).applyQuaternion(new Oe().setFromAxisAngle(o, S)).normalize(), M = f(C);
|
|
448
|
+
M.closed && M.circumference < p && (p = M.circumference, y = C);
|
|
449
449
|
}
|
|
450
|
-
const
|
|
451
|
-
Math.abs(
|
|
452
|
-
const w = new h().crossVectors(
|
|
453
|
-
for (let
|
|
454
|
-
const b =
|
|
455
|
-
M.closed && M.circumference < p && (p = M.circumference, y =
|
|
450
|
+
const x = y.clone(), g = new h();
|
|
451
|
+
Math.abs(x.x) < 0.9 ? g.set(1, 0, 0) : g.set(0, 1, 0), g.crossVectors(x, g).normalize();
|
|
452
|
+
const w = new h().crossVectors(x, g).normalize();
|
|
453
|
+
for (let v = -5; v <= 5; v += 1) for (let m = -5; m <= 5; m += 1) {
|
|
454
|
+
const b = v * 0.1 * Math.PI / 180, S = m * 0.1 * Math.PI / 180, C = x.clone().applyQuaternion(new Oe().setFromAxisAngle(g, b)).applyQuaternion(new Oe().setFromAxisAngle(w, S)).normalize(), M = f(C);
|
|
455
|
+
M.closed && M.circumference < p && (p = M.circumference, y = C);
|
|
456
456
|
}
|
|
457
457
|
return p === 1 / 0 && (p = f(u).circumference, y = u), {
|
|
458
458
|
normal: y,
|
|
459
459
|
circumference: p
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
|
-
function Cn(e,
|
|
463
|
-
const t = e.getAttribute("position"),
|
|
464
|
-
if (!
|
|
462
|
+
function Cn(e, r, n) {
|
|
463
|
+
const t = e.getAttribute("position"), i = e.getIndex();
|
|
464
|
+
if (!i) return {
|
|
465
465
|
isDoubleShell: false,
|
|
466
466
|
sampledFaces: 0,
|
|
467
467
|
opposingPairs: 0,
|
|
468
468
|
confidence: 0
|
|
469
469
|
};
|
|
470
|
-
const a =
|
|
470
|
+
const a = i.array, c = t.array, u = new h().subVectors(n, r).normalize(), s = n.distanceTo(r), l = Math.min(s * 0.06, 15), o = new $e(e, {
|
|
471
471
|
maxLeafTris: Ye
|
|
472
472
|
});
|
|
473
473
|
let f = new h(1, 0, 0);
|
|
474
474
|
Math.abs(u.dot(f)) > 0.9 && (f = new h(0, 1, 0)), f.sub(u.clone().multiplyScalar(u.dot(f))).normalize();
|
|
475
|
-
const y = new h().crossVectors(u, f).normalize(), p = 12,
|
|
476
|
-
let g = 0, w = 0,
|
|
475
|
+
const y = new h().crossVectors(u, f).normalize(), p = 12, x = new h();
|
|
476
|
+
let g = 0, w = 0, v = 0;
|
|
477
477
|
for (const S of [
|
|
478
478
|
0.65,
|
|
479
479
|
0.78,
|
|
480
480
|
0.9
|
|
481
481
|
]) {
|
|
482
|
-
const
|
|
483
|
-
let M = 0,
|
|
482
|
+
const C = new h().lerpVectors(r, n, S);
|
|
483
|
+
let M = 0, P = 0, L = 0, H = 0;
|
|
484
484
|
for (let Y = 0; Y < a.length; Y += 3) {
|
|
485
|
-
const
|
|
486
|
-
Math.abs(z * u.x + F * u.y + V * u.z) >
|
|
485
|
+
const j = a[Y], ne = a[Y + 1], oe = a[Y + 2], le = (c[j * 3] + c[ne * 3] + c[oe * 3]) / 3, ee = (c[j * 3 + 1] + c[ne * 3 + 1] + c[oe * 3 + 1]) / 3, D = (c[j * 3 + 2] + c[ne * 3 + 2] + c[oe * 3 + 2]) / 3, z = le - C.x, F = ee - C.y, V = D - C.z;
|
|
486
|
+
Math.abs(z * u.x + F * u.y + V * u.z) > l || (M += le, P += ee, L += D, H++);
|
|
487
487
|
}
|
|
488
488
|
if (H < 8) continue;
|
|
489
|
-
const O = new h(M / H,
|
|
489
|
+
const O = new h(M / H, P / H, L / H);
|
|
490
490
|
let $ = 0;
|
|
491
491
|
for (let Y = 0; Y < p; Y++) {
|
|
492
|
-
const
|
|
492
|
+
const j = Y / p * Math.PI * 2, ne = new h().addScaledVector(f, Math.cos(j)).addScaledVector(y, Math.sin(j)), oe = new J.Ray(O, ne);
|
|
493
493
|
let le = 0;
|
|
494
|
-
|
|
494
|
+
o.shapecast({
|
|
495
495
|
intersectsBounds: (ee) => oe.intersectsBox(ee),
|
|
496
|
-
intersectsTriangle: (ee) => (oe.intersectTriangle(ee.a, ee.b, ee.c, false,
|
|
496
|
+
intersectsTriangle: (ee) => (oe.intersectTriangle(ee.a, ee.b, ee.c, false, x) && le++, false)
|
|
497
497
|
}), $ += le, w++;
|
|
498
498
|
}
|
|
499
|
-
g += $, $ / p > 1.5 &&
|
|
499
|
+
g += $, $ / p > 1.5 && v++;
|
|
500
500
|
}
|
|
501
501
|
if (w === 0) return {
|
|
502
502
|
isDoubleShell: false,
|
|
@@ -504,87 +504,87 @@ let __tla = (async () => {
|
|
|
504
504
|
opposingPairs: 0,
|
|
505
505
|
confidence: 0
|
|
506
506
|
};
|
|
507
|
-
const
|
|
507
|
+
const m = g / w;
|
|
508
508
|
return {
|
|
509
|
-
isDoubleShell:
|
|
509
|
+
isDoubleShell: v >= 2,
|
|
510
510
|
sampledFaces: w,
|
|
511
511
|
opposingPairs: g,
|
|
512
|
-
confidence:
|
|
512
|
+
confidence: m
|
|
513
513
|
};
|
|
514
514
|
}
|
|
515
|
-
function vn(e,
|
|
516
|
-
const
|
|
515
|
+
function vn(e, r, n, t) {
|
|
516
|
+
const i = new h().subVectors(n, r), a = new h().subVectors(t, r), c = new h().subVectors(e, r), u = i.dot(i), s = i.dot(a), l = i.dot(c), o = a.dot(a), f = a.dot(c), y = 1 / (u * o - s * s), p = (o * l - s * f) * y, x = (u * f - s * l) * y;
|
|
517
517
|
return {
|
|
518
|
-
u: 1 - p -
|
|
518
|
+
u: 1 - p - x,
|
|
519
519
|
v: p,
|
|
520
|
-
w:
|
|
520
|
+
w: x
|
|
521
521
|
};
|
|
522
522
|
}
|
|
523
|
-
function st(e,
|
|
524
|
-
const a =
|
|
523
|
+
function st(e, r, n, t, i = false) {
|
|
524
|
+
const a = n.clone().normalize(), c = e.getAttribute("position"), u = e.getIndex();
|
|
525
525
|
if (!u) throw new Error("No index buffer");
|
|
526
|
-
const
|
|
527
|
-
const V =
|
|
528
|
-
return
|
|
529
|
-
},
|
|
530
|
-
const F = new h().subVectors(D,
|
|
526
|
+
const s = new h().subVectors(t, r).dot(a), l = Math.abs(s) < 1e-6 ? 1 : Math.sign(s), o = c.array, f = u.array, y = e.getAttribute("color"), p = y ? y.array : null, x = [], g = [], w = [], v = (D, z, F) => {
|
|
527
|
+
const V = x.length / 3;
|
|
528
|
+
return x.push(D, z, F), V;
|
|
529
|
+
}, m = (D) => new h(o[D * 3], o[D * 3 + 1], o[D * 3 + 2]), b = (D, z) => {
|
|
530
|
+
const F = new h().subVectors(D, r).dot(a), V = new h().subVectors(z, r).dot(a), B = F / (F - V);
|
|
531
531
|
return new h().lerpVectors(D, z, B);
|
|
532
|
-
}, S = /* @__PURE__ */ new Map(),
|
|
532
|
+
}, S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), P = (D) => {
|
|
533
533
|
let z = M.get(D);
|
|
534
|
-
return z === void 0 && (z = new h().subVectors(
|
|
535
|
-
},
|
|
534
|
+
return z === void 0 && (z = new h().subVectors(m(D), r).dot(a), M.set(D, z)), z;
|
|
535
|
+
}, L = (D) => {
|
|
536
536
|
if (S.has(D)) return S.get(D);
|
|
537
|
-
const z =
|
|
537
|
+
const z = m(D), F = v(z.x, z.y, z.z);
|
|
538
538
|
return p && g.push(p[D * 3], p[D * 3 + 1], p[D * 3 + 2]), S.set(D, F), F;
|
|
539
539
|
}, H = (D, z) => {
|
|
540
540
|
const F = D < z ? `${D}_${z}` : `${z}_${D}`;
|
|
541
|
-
if (
|
|
542
|
-
const V = b(
|
|
541
|
+
if (C.has(F)) return C.get(F);
|
|
542
|
+
const V = b(m(D), m(z)), B = v(V.x, V.y, V.z);
|
|
543
543
|
if (p) {
|
|
544
|
-
const T =
|
|
545
|
-
g.push(p[D * 3] +
|
|
544
|
+
const T = P(D), E = P(z), N = T / (T - E);
|
|
545
|
+
g.push(p[D * 3] + N * (p[z * 3] - p[D * 3]), p[D * 3 + 1] + N * (p[z * 3 + 1] - p[D * 3 + 1]), p[D * 3 + 2] + N * (p[z * 3 + 2] - p[D * 3 + 2]));
|
|
546
546
|
}
|
|
547
|
-
return
|
|
547
|
+
return C.set(F, B), B;
|
|
548
548
|
}, O = (D) => {
|
|
549
|
-
const z =
|
|
550
|
-
return Math.sign(z) ===
|
|
549
|
+
const z = P(D);
|
|
550
|
+
return Math.sign(z) === l || Math.abs(z) < 1e-6;
|
|
551
551
|
};
|
|
552
552
|
for (let D = 0; D < f.length; D += 3) {
|
|
553
|
-
const z = f[D], F = f[D + 1], V = f[D + 2], B = O(z), T = O(F), E = O(V),
|
|
554
|
-
if (
|
|
555
|
-
else if (
|
|
556
|
-
let X,
|
|
557
|
-
B ? (X = z,
|
|
553
|
+
const z = f[D], F = f[D + 1], V = f[D + 2], B = O(z), T = O(F), E = O(V), N = (B ? 1 : 0) + (T ? 1 : 0) + (E ? 1 : 0);
|
|
554
|
+
if (N !== 0) if (N === 3) w.push(L(z), L(F), L(V));
|
|
555
|
+
else if (N === 1) {
|
|
556
|
+
let X, q, ie;
|
|
557
|
+
B ? (X = z, q = F, ie = V) : T ? (X = F, q = V, ie = z) : (X = V, q = z, ie = F), w.push(L(X), H(X, q), H(X, ie));
|
|
558
558
|
} else {
|
|
559
|
-
let X,
|
|
560
|
-
B ? T ? (X = V,
|
|
561
|
-
const se =
|
|
559
|
+
let X, q, ie;
|
|
560
|
+
B ? T ? (X = V, q = z, ie = F) : (X = F, q = V, ie = z) : (X = z, q = F, ie = V);
|
|
561
|
+
const se = L(q), A = L(ie), I = H(q, X), k = H(ie, X);
|
|
562
562
|
w.push(se, I, A), w.push(A, I, k);
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
const $ = w.length / 3;
|
|
566
566
|
let R;
|
|
567
|
-
if (
|
|
567
|
+
if (i) R = Array.from({
|
|
568
568
|
length: $
|
|
569
569
|
}, (D, z) => z);
|
|
570
570
|
else {
|
|
571
571
|
const D = /* @__PURE__ */ new Map();
|
|
572
572
|
for (let T = 0; T < $; T++) for (let E = 0; E < 3; E++) {
|
|
573
|
-
const
|
|
574
|
-
D.has(
|
|
573
|
+
const N = w[T * 3 + E];
|
|
574
|
+
D.has(N) || D.set(N, []), D.get(N).push(T);
|
|
575
575
|
}
|
|
576
576
|
const z = /* @__PURE__ */ new Set(), F = [];
|
|
577
577
|
for (let T = 0; T < $; T++) {
|
|
578
578
|
if (z.has(T)) continue;
|
|
579
|
-
const E = [],
|
|
579
|
+
const E = [], N = [
|
|
580
580
|
T
|
|
581
581
|
];
|
|
582
|
-
for (z.add(T);
|
|
583
|
-
const X =
|
|
582
|
+
for (z.add(T); N.length > 0; ) {
|
|
583
|
+
const X = N.shift();
|
|
584
584
|
E.push(X);
|
|
585
|
-
for (let
|
|
586
|
-
const ie = w[X * 3 +
|
|
587
|
-
for (const se of D.get(ie)) z.has(se) || (z.add(se),
|
|
585
|
+
for (let q = 0; q < 3; q++) {
|
|
586
|
+
const ie = w[X * 3 + q];
|
|
587
|
+
for (const se of D.get(ie)) z.has(se) || (z.add(se), N.push(se));
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
590
|
F.push(E);
|
|
@@ -592,9 +592,9 @@ let __tla = (async () => {
|
|
|
592
592
|
let V = F[0] || [], B = 1 / 0;
|
|
593
593
|
for (const T of F) {
|
|
594
594
|
let E = 1 / 0;
|
|
595
|
-
for (const
|
|
595
|
+
for (const N of T) {
|
|
596
596
|
for (let X = 0; X < 3; X++) {
|
|
597
|
-
const
|
|
597
|
+
const q = w[N * 3 + X], ie = x[q * 3] - t.x, se = x[q * 3 + 1] - t.y, A = x[q * 3 + 2] - t.z, I = ie * ie + se * se + A * A;
|
|
598
598
|
I < E && (E = I);
|
|
599
599
|
}
|
|
600
600
|
if (E < B) break;
|
|
@@ -603,52 +603,52 @@ let __tla = (async () => {
|
|
|
603
603
|
}
|
|
604
604
|
R = V;
|
|
605
605
|
}
|
|
606
|
-
const Y = /* @__PURE__ */ new Map(),
|
|
606
|
+
const Y = /* @__PURE__ */ new Map(), j = [], ne = [], oe = [];
|
|
607
607
|
let le = 0;
|
|
608
608
|
for (const D of R) for (let z = 0; z < 3; z++) {
|
|
609
609
|
const F = w[D * 3 + z];
|
|
610
|
-
Y.has(F) || (
|
|
610
|
+
Y.has(F) || (j.push(x[F * 3], x[F * 3 + 1], x[F * 3 + 2]), p && ne.push(g[F * 3], g[F * 3 + 1], g[F * 3 + 2]), Y.set(F, le++)), oe.push(Y.get(F));
|
|
611
611
|
}
|
|
612
612
|
const ee = new J.BufferGeometry();
|
|
613
|
-
return ee.setAttribute("position", new J.Float32BufferAttribute(
|
|
613
|
+
return ee.setAttribute("position", new J.Float32BufferAttribute(j, 3)), p && ne.length > 0 && ee.setAttribute("color", new J.Float32BufferAttribute(ne, 3)), ee.setIndex(oe), ee.computeVertexNormals(), ee.computeBoundingBox(), ee;
|
|
614
614
|
}
|
|
615
|
-
function rt(e,
|
|
616
|
-
const t = e.getAttribute("position"),
|
|
617
|
-
if (
|
|
618
|
-
const a = 30, c =
|
|
615
|
+
function rt(e, r, n) {
|
|
616
|
+
const t = e.getAttribute("position"), i = n - r;
|
|
617
|
+
if (i < 1) return null;
|
|
618
|
+
const a = 30, c = i / a, u = [];
|
|
619
619
|
for (let w = 0; w < a; w++) {
|
|
620
|
-
const
|
|
621
|
-
let b = 0, S = 0,
|
|
622
|
-
for (let
|
|
623
|
-
const
|
|
624
|
-
|
|
620
|
+
const v = r + w * c, m = r + (w + 1) * c;
|
|
621
|
+
let b = 0, S = 0, C = 0, M = 0;
|
|
622
|
+
for (let P = 0; P < t.count; P++) {
|
|
623
|
+
const L = t.getY(P);
|
|
624
|
+
L >= v && L < m && (b += t.getX(P), S += L, C += t.getZ(P), M++);
|
|
625
625
|
}
|
|
626
|
-
M > 20 && u.push(new h(b / M, S / M,
|
|
626
|
+
M > 20 && u.push(new h(b / M, S / M, C / M));
|
|
627
627
|
}
|
|
628
628
|
if (u.length < 5) return null;
|
|
629
|
-
const
|
|
630
|
-
for (const w of u)
|
|
631
|
-
|
|
632
|
-
let
|
|
629
|
+
const s = new h();
|
|
630
|
+
for (const w of u) s.add(w);
|
|
631
|
+
s.divideScalar(u.length);
|
|
632
|
+
let l = 0, o = 0, f = 0, y = 0, p = 0, x = 0;
|
|
633
633
|
for (const w of u) {
|
|
634
|
-
const
|
|
635
|
-
|
|
634
|
+
const v = w.x - s.x, m = w.y - s.y, b = w.z - s.z;
|
|
635
|
+
l += v * v, o += v * m, f += v * b, y += m * m, p += m * b, x += b * b;
|
|
636
636
|
}
|
|
637
637
|
let g = new h(0.01, 1, 0.01).normalize();
|
|
638
638
|
for (let w = 0; w < 30; w++) {
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
639
|
+
const v = l * g.x + o * g.y + f * g.z, m = o * g.x + y * g.y + p * g.z, b = f * g.x + p * g.y + x * g.z, S = new h(v, m, b), C = S.length();
|
|
640
|
+
if (C < 1e-10 || (S.divideScalar(C), g.distanceTo(S) < 1e-8)) break;
|
|
641
641
|
g = S;
|
|
642
642
|
}
|
|
643
643
|
return g.y < 0 && g.negate(), g;
|
|
644
644
|
}
|
|
645
|
-
function Wt(e,
|
|
646
|
-
const
|
|
645
|
+
function Wt(e, r, n, t) {
|
|
646
|
+
const i = e.getIndex(), a = i ? i.count / 3 : 0;
|
|
647
647
|
if (a < 10) return {
|
|
648
648
|
valid: false,
|
|
649
649
|
reason: `Geometry is empty or degenerate (${a} faces)`
|
|
650
650
|
};
|
|
651
|
-
const c =
|
|
651
|
+
const c = r - n;
|
|
652
652
|
if (c < 4) return {
|
|
653
653
|
valid: false,
|
|
654
654
|
reason: `Height too small (${c.toFixed(1)}mm < 4mm)`
|
|
@@ -659,29 +659,29 @@ let __tla = (async () => {
|
|
|
659
659
|
};
|
|
660
660
|
const u = new $e(e, {
|
|
661
661
|
maxLeafTris: Ye
|
|
662
|
-
}),
|
|
663
|
-
if (
|
|
662
|
+
}), s = Ze(u, e, r);
|
|
663
|
+
if (s.lineLength === 0) return {
|
|
664
664
|
valid: false,
|
|
665
665
|
reason: "No circumference at green point \u2014 mesh may be empty at that height"
|
|
666
666
|
};
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
667
|
+
const l = r - t;
|
|
668
|
+
if (l <= n) return {
|
|
669
669
|
valid: true,
|
|
670
670
|
reason: ""
|
|
671
671
|
};
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
const y =
|
|
672
|
+
const o = Ze(u, e, l);
|
|
673
|
+
if (s.lineLength > 0 && o.lineLength > 0) {
|
|
674
|
+
const y = s.lineLength / o.lineLength;
|
|
675
675
|
if (y < 0.5) return {
|
|
676
676
|
valid: false,
|
|
677
677
|
reason: `First circumference is too small relative to second (ratio ${y.toFixed(2)} < 0.5) \u2014 possible trimmed angle`
|
|
678
678
|
};
|
|
679
679
|
}
|
|
680
|
-
const f =
|
|
681
|
-
if (f >
|
|
680
|
+
const f = r - t * 2;
|
|
681
|
+
if (f > n) {
|
|
682
682
|
const y = Ze(u, e, f);
|
|
683
|
-
if (
|
|
684
|
-
const p =
|
|
683
|
+
if (o.lineLength > 0 && y.lineLength > 0) {
|
|
684
|
+
const p = o.lineLength / y.lineLength;
|
|
685
685
|
if (p < 0.5) return {
|
|
686
686
|
valid: false,
|
|
687
687
|
reason: `Second circumference is too small relative to third (ratio ${p.toFixed(2)} < 0.5) \u2014 possible trimmed angle`
|
|
@@ -715,68 +715,68 @@ let __tla = (async () => {
|
|
|
715
715
|
cutOffset: 6
|
|
716
716
|
}
|
|
717
717
|
], nt = 5;
|
|
718
|
-
function Vt(e,
|
|
719
|
-
const
|
|
720
|
-
return e.applyMatrix4(new kt().makeRotationFromQuaternion(
|
|
718
|
+
function Vt(e, r, n, t) {
|
|
719
|
+
const i = new Oe().setFromAxisAngle(n, t);
|
|
720
|
+
return e.applyMatrix4(new kt().makeRotationFromQuaternion(i)), r.map((a) => a.clone().applyQuaternion(i));
|
|
721
721
|
}
|
|
722
|
-
function _t(e,
|
|
723
|
-
const t = new Oe().setFromAxisAngle(
|
|
722
|
+
function _t(e, r, n) {
|
|
723
|
+
const t = new Oe().setFromAxisAngle(r, n);
|
|
724
724
|
e.applyMatrix4(new kt().makeRotationFromQuaternion(t));
|
|
725
725
|
}
|
|
726
|
-
function An(e,
|
|
727
|
-
const c =
|
|
728
|
-
if (!u) return
|
|
729
|
-
const
|
|
730
|
-
const G =
|
|
731
|
-
return
|
|
732
|
-
},
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
726
|
+
function An(e, r, n, t, i, a) {
|
|
727
|
+
const c = n.getAttribute("position"), u = n.getIndex();
|
|
728
|
+
if (!u) return r;
|
|
729
|
+
const l = r[1].y + t * We, o = c.array, f = u.array, y = n.getAttribute("color"), p = y ? y.array : null, x = [], g = [], w = [], v = (A, I, k) => {
|
|
730
|
+
const G = x.length / 3;
|
|
731
|
+
return x.push(A, I, k), G;
|
|
732
|
+
}, m = (A) => [
|
|
733
|
+
o[A * 3],
|
|
734
|
+
o[A * 3 + 1],
|
|
735
|
+
o[A * 3 + 2]
|
|
736
736
|
], b = (A, I) => {
|
|
737
|
-
const k = (
|
|
737
|
+
const k = (l - A[1]) / (I[1] - A[1]);
|
|
738
738
|
return [
|
|
739
739
|
A[0] + k * (I[0] - A[0]),
|
|
740
|
-
|
|
740
|
+
l,
|
|
741
741
|
A[2] + k * (I[2] - A[2])
|
|
742
742
|
];
|
|
743
|
-
}, S = /* @__PURE__ */ new Map(),
|
|
743
|
+
}, S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), M = (A) => {
|
|
744
744
|
if (S.has(A)) return S.get(A);
|
|
745
|
-
const [I, k, G] =
|
|
745
|
+
const [I, k, G] = m(A), U = v(I, k, G);
|
|
746
746
|
return p && g.push(p[A * 3], p[A * 3 + 1], p[A * 3 + 2]), S.set(A, U), U;
|
|
747
|
-
},
|
|
747
|
+
}, P = (A, I) => {
|
|
748
748
|
const k = A < I ? `${A}_${I}` : `${I}_${A}`;
|
|
749
|
-
if (
|
|
750
|
-
const G =
|
|
749
|
+
if (C.has(k)) return C.get(k);
|
|
750
|
+
const G = m(A), U = m(I), [re, Le, me] = b(G, U), ae = v(re, Le, me);
|
|
751
751
|
if (p) {
|
|
752
|
-
const xe = (
|
|
752
|
+
const xe = (l - G[1]) / (U[1] - G[1]);
|
|
753
753
|
g.push(p[A * 3] + xe * (p[I * 3] - p[A * 3]), p[A * 3 + 1] + xe * (p[I * 3 + 1] - p[A * 3 + 1]), p[A * 3 + 2] + xe * (p[I * 3 + 2] - p[A * 3 + 2]));
|
|
754
754
|
}
|
|
755
|
-
return
|
|
755
|
+
return C.set(k, ae), ae;
|
|
756
756
|
};
|
|
757
757
|
for (let A = 0; A < f.length; A += 3) {
|
|
758
|
-
const I = f[A], k = f[A + 1], G = f[A + 2], U =
|
|
758
|
+
const I = f[A], k = f[A + 1], G = f[A + 2], U = m(I), re = m(k), Le = m(G), me = U[1] < l, ae = re[1] < l, xe = Le[1] < l, Re = (me ? 1 : 0) + (ae ? 1 : 0) + (xe ? 1 : 0);
|
|
759
759
|
if (Re !== 0) if (Re === 3) w.push(M(I), M(k), M(G));
|
|
760
760
|
else if (Re === 1) {
|
|
761
761
|
let pe, we, he;
|
|
762
|
-
me ? (pe = I, we = k, he = G) : ae ? (pe = k, we = G, he = I) : (pe = G, we = I, he = k), w.push(M(pe),
|
|
762
|
+
me ? (pe = I, we = k, he = G) : ae ? (pe = k, we = G, he = I) : (pe = G, we = I, he = k), w.push(M(pe), P(pe, we), P(pe, he));
|
|
763
763
|
} else {
|
|
764
764
|
let pe, we, he;
|
|
765
765
|
me ? ae ? (pe = G, we = I, he = k) : (pe = k, we = G, he = I) : (pe = I, we = k, he = G);
|
|
766
|
-
const Ge = M(we), fe = M(he),
|
|
767
|
-
w.push(Ge,
|
|
766
|
+
const Ge = M(we), fe = M(he), je = P(we, pe), Pe = P(he, pe);
|
|
767
|
+
w.push(Ge, je, fe), w.push(fe, je, Pe);
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
const
|
|
771
|
-
for (let A = 0; A <
|
|
770
|
+
const L = w.length / 3, H = /* @__PURE__ */ new Map();
|
|
771
|
+
for (let A = 0; A < L; A++) for (let I = 0; I < 3; I++) {
|
|
772
772
|
const k = w[A * 3 + I];
|
|
773
773
|
H.has(k) || H.set(k, []), H.get(k).push(A);
|
|
774
774
|
}
|
|
775
775
|
const O = /* @__PURE__ */ new Map();
|
|
776
|
-
for (let A = 0; A <
|
|
776
|
+
for (let A = 0; A < L; A++) O.set(A, /* @__PURE__ */ new Set());
|
|
777
777
|
for (const [, A] of H) for (const I of A) for (const k of A) I !== k && O.get(I).add(k);
|
|
778
778
|
const $ = /* @__PURE__ */ new Set(), R = [];
|
|
779
|
-
for (let A = 0; A <
|
|
779
|
+
for (let A = 0; A < L; A++) {
|
|
780
780
|
if ($.has(A)) continue;
|
|
781
781
|
const I = [], k = [
|
|
782
782
|
A
|
|
@@ -788,30 +788,30 @@ let __tla = (async () => {
|
|
|
788
788
|
}
|
|
789
789
|
R.push(I);
|
|
790
790
|
}
|
|
791
|
-
const Y =
|
|
792
|
-
let
|
|
791
|
+
const Y = r[0];
|
|
792
|
+
let j = R[0] || [], ne = 1 / 0;
|
|
793
793
|
for (const A of R) {
|
|
794
794
|
let I = 1 / 0;
|
|
795
795
|
for (const k of A) {
|
|
796
796
|
for (let G = 0; G < 3; G++) {
|
|
797
|
-
const U = w[k * 3 + G], re =
|
|
797
|
+
const U = w[k * 3 + G], re = x[U * 3] - Y.x, Le = x[U * 3 + 1] - Y.y, me = x[U * 3 + 2] - Y.z, ae = re * re + Le * Le + me * me;
|
|
798
798
|
ae < I && (I = ae);
|
|
799
799
|
}
|
|
800
800
|
if (I < ne) break;
|
|
801
801
|
}
|
|
802
|
-
I < ne && (ne = I,
|
|
802
|
+
I < ne && (ne = I, j = A);
|
|
803
803
|
}
|
|
804
804
|
const oe = /* @__PURE__ */ new Map(), le = [], ee = [], D = [];
|
|
805
805
|
let z = 0;
|
|
806
|
-
for (const A of
|
|
806
|
+
for (const A of j) for (let I = 0; I < 3; I++) {
|
|
807
807
|
const k = w[A * 3 + I];
|
|
808
|
-
oe.has(k) || (le.push(
|
|
808
|
+
oe.has(k) || (le.push(x[k * 3], x[k * 3 + 1], x[k * 3 + 2]), p && ee.push(g[k * 3], g[k * 3 + 1], g[k * 3 + 2]), oe.set(k, z++)), D.push(oe.get(k));
|
|
809
809
|
}
|
|
810
810
|
const F = new J.BufferGeometry();
|
|
811
|
-
F.setAttribute("position", new J.Float32BufferAttribute(le, 3)), p && ee.length > 0 && F.setAttribute("color", new J.Float32BufferAttribute(ee, 3)), F.setIndex(D), F.computeVertexNormals(), F.computeBoundingBox(), e.geometry.dispose(), e.geometry = F,
|
|
811
|
+
F.setAttribute("position", new J.Float32BufferAttribute(le, 3)), p && ee.length > 0 && F.setAttribute("color", new J.Float32BufferAttribute(ee, 3)), F.setIndex(D), F.computeVertexNormals(), F.computeBoundingBox(), e.geometry.dispose(), e.geometry = F, i.onStatus("Refining alignment...");
|
|
812
812
|
const V = new h(0, 1, 0);
|
|
813
813
|
let B = [
|
|
814
|
-
...
|
|
814
|
+
...r
|
|
815
815
|
];
|
|
816
816
|
const T = (A, I) => {
|
|
817
817
|
B = Vt(F, B, A, I), a && _t(a, A, I);
|
|
@@ -819,9 +819,9 @@ let __tla = (async () => {
|
|
|
819
819
|
for (let A = 0; A < 5; A++) {
|
|
820
820
|
const I = F.getAttribute("position"), k = Math.min(B[0].y, B[1].y), U = Math.max(B[0].y, B[1].y) - k;
|
|
821
821
|
if (U < 1) break;
|
|
822
|
-
const re = 30,
|
|
822
|
+
const re = 30, Le = U / re, me = [];
|
|
823
823
|
for (let ye = 0; ye < re; ye++) {
|
|
824
|
-
const Te = k + ye *
|
|
824
|
+
const Te = k + ye * Le, Me = k + (ye + 1) * Le;
|
|
825
825
|
let Ae = 0, De = 0, ze = 0, Ee = 0;
|
|
826
826
|
for (let ke = 0; ke < I.count; ke++) {
|
|
827
827
|
const Ue = I.getY(ke);
|
|
@@ -845,28 +845,28 @@ let __tla = (async () => {
|
|
|
845
845
|
fe = De;
|
|
846
846
|
}
|
|
847
847
|
fe.y < 0 && fe.negate();
|
|
848
|
-
const
|
|
849
|
-
if (Math.acos(Math.min(1, Math.abs(
|
|
850
|
-
const
|
|
851
|
-
|
|
848
|
+
const je = fe.dot(V);
|
|
849
|
+
if (Math.acos(Math.min(1, Math.abs(je))) * 180 / Math.PI < 0.1) break;
|
|
850
|
+
const Pe = new h().crossVectors(fe, V);
|
|
851
|
+
Pe.length() > 1e-4 && (Pe.normalize(), T(Pe, Math.acos(Math.min(1, Math.max(-1, je)))));
|
|
852
852
|
}
|
|
853
853
|
B[0].y > B[1].y && T(new h(1, 0, 0), Math.PI);
|
|
854
854
|
const E = B[0];
|
|
855
855
|
F.translate(-E.x, -E.y, -E.z), a && a.translate(-E.x, -E.y, -E.z), B = B.map((A) => new h(A.x - E.x, A.y - E.y, A.z - E.z));
|
|
856
|
-
const X = B[1].y + 5 * We,
|
|
857
|
-
e.geometry.dispose(), e.geometry =
|
|
856
|
+
const X = B[1].y + 5 * We, q = st(F, new h(0, X, 0), new h(0, 1, 0), B[0]);
|
|
857
|
+
e.geometry.dispose(), e.geometry = q, q.computeVertexNormals(), q.computeBoundingBox(), i.updateLandmarkPositions(B.map((A) => ({
|
|
858
858
|
x: A.x,
|
|
859
859
|
y: A.y,
|
|
860
860
|
z: A.z
|
|
861
861
|
})));
|
|
862
|
-
const ie =
|
|
863
|
-
return ie.getSize(se),
|
|
862
|
+
const ie = q.boundingBox, se = new h();
|
|
863
|
+
return ie.getSize(se), i.setModelSize(Math.max(se.x, se.y, se.z)), i.setCut(true), i.setAdjustedStartY(null), i.setAdjustedEndY(null), i.setOriginalEndY(B[1].y + 2 * We), B;
|
|
864
864
|
}
|
|
865
|
-
function Fn(e,
|
|
866
|
-
const
|
|
865
|
+
function Fn(e, r, n, t) {
|
|
866
|
+
const i = r.map((x) => new h(x.position.x, x.position.y, x.position.z)), a = i[0], c = i[1];
|
|
867
867
|
t.onStatus("Cutting double shell above green point...");
|
|
868
|
-
const u = c.y + 2 * We,
|
|
869
|
-
|
|
868
|
+
const u = c.y + 2 * We, s = new h(c.x, u, c.z), l = e.geometry, o = st(l, s, new h(0, 1, 0), a, true);
|
|
869
|
+
l.dispose(), e.geometry = o, o.computeVertexNormals(), o.computeBoundingBox(), t.onStatus("Setting blue point..."), t.addLandmarkPoint({
|
|
870
870
|
faceIndex: -1,
|
|
871
871
|
vertexIndices: [
|
|
872
872
|
0,
|
|
@@ -883,118 +883,118 @@ let __tla = (async () => {
|
|
|
883
883
|
v: 0.33,
|
|
884
884
|
w: 0.34
|
|
885
885
|
}
|
|
886
|
-
}),
|
|
887
|
-
x:
|
|
888
|
-
y:
|
|
889
|
-
z:
|
|
886
|
+
}), i.push(a.clone()), t.updateLandmarkPositions(i.map((x) => ({
|
|
887
|
+
x: x.x,
|
|
888
|
+
y: x.y,
|
|
889
|
+
z: x.z
|
|
890
890
|
}))), t.setAligned(true), t.setCut(true), t.setAdjustedStartY(null), t.setAdjustedEndY(null), t.setOriginalEndY(c.y);
|
|
891
|
-
const f =
|
|
891
|
+
const f = o.boundingBox, y = new h();
|
|
892
892
|
f.getSize(y), t.setModelSize(Math.max(y.x, y.y, y.z)), t.onStatus("Validating results...");
|
|
893
|
-
const p = Wt(
|
|
893
|
+
const p = Wt(o, c.y, a.y, n);
|
|
894
894
|
p.valid || console.warn(`Double shell validation warning: ${p.reason}`);
|
|
895
895
|
}
|
|
896
|
-
function In(e,
|
|
896
|
+
function In(e, r, n, t) {
|
|
897
897
|
var _a, _b;
|
|
898
|
-
const
|
|
899
|
-
...
|
|
898
|
+
const i = e.geometry.clone(), a = r.map((s) => ({
|
|
899
|
+
...s
|
|
900
900
|
})), c = new h(0, 1, 0);
|
|
901
901
|
if (t.skipDoubleShellDetection) console.log("Skipping double-shell detection: inner shell already extracted");
|
|
902
902
|
else {
|
|
903
|
-
const
|
|
903
|
+
const s = new h(r[0].position.x, r[0].position.y, r[0].position.z), l = new h(r[1].position.x, r[1].position.y, r[1].position.z);
|
|
904
904
|
t.onStatus("Detecting shell type...");
|
|
905
|
-
const
|
|
906
|
-
if (console.log(`Shell detection: ${
|
|
907
|
-
(_a = t.setDoubleShell) == null ? void 0 : _a.call(t, true), Fn(e, a,
|
|
905
|
+
const o = Cn(e.geometry, s, l);
|
|
906
|
+
if (console.log(`Shell detection: ${o.isDoubleShell ? "DOUBLE" : "SINGLE"} shell (${o.opposingPairs} inward/${o.sampledFaces} total faces, confidence ${(o.confidence * 100).toFixed(0)}%)`), o.isDoubleShell) {
|
|
907
|
+
(_a = t.setDoubleShell) == null ? void 0 : _a.call(t, true), Fn(e, a, n, t), t.setClippedReferenceGeometry ? (i.computeVertexNormals(), t.setClippedReferenceGeometry(i)) : i.dispose();
|
|
908
908
|
return;
|
|
909
909
|
}
|
|
910
910
|
(_b = t.setDoubleShell) == null ? void 0 : _b.call(t, false);
|
|
911
911
|
}
|
|
912
912
|
let u = "";
|
|
913
|
-
for (let
|
|
914
|
-
|
|
915
|
-
let
|
|
916
|
-
const f = t.setClippedReferenceGeometry ?
|
|
913
|
+
for (let s = 0; s < nt; s++) try {
|
|
914
|
+
s > 0 && (t.onStatus(`Retry ${s}/${nt - 1} \u2014 ${u}`), e.geometry.dispose(), e.geometry = i.clone(), t.removeLandmarkPoint(2), t.setAligned(false), t.setCut(false));
|
|
915
|
+
let l = e.geometry, o = a.map((z) => new h(z.position.x, z.position.y, z.position.z));
|
|
916
|
+
const f = t.setClippedReferenceGeometry ? i.clone() : null;
|
|
917
917
|
let y = 5;
|
|
918
|
-
if (
|
|
919
|
-
const z = Mn[
|
|
918
|
+
if (s > 0) {
|
|
919
|
+
const z = Mn[s - 1];
|
|
920
920
|
y = z.cutOffset;
|
|
921
|
-
const F = new h().subVectors(
|
|
922
|
-
if (z.nudge < 0)
|
|
921
|
+
const F = new h().subVectors(o[1], o[0]).normalize();
|
|
922
|
+
if (z.nudge < 0) o[1].addScaledVector(F, z.nudge);
|
|
923
923
|
else {
|
|
924
924
|
const E = new h();
|
|
925
|
-
Math.abs(F.x) < 0.9 ? E.crossVectors(F, new h(1, 0, 0)).normalize() : E.crossVectors(F, new h(0, 0, 1)).normalize(), E.applyAxisAngle(F, z.angle),
|
|
925
|
+
Math.abs(F.x) < 0.9 ? E.crossVectors(F, new h(1, 0, 0)).normalize() : E.crossVectors(F, new h(0, 0, 1)).normalize(), E.applyAxisAngle(F, z.angle), o[1].addScaledVector(E, z.nudge);
|
|
926
926
|
}
|
|
927
|
-
const V =
|
|
927
|
+
const V = l.getAttribute("position");
|
|
928
928
|
let B = 1 / 0, T = 0;
|
|
929
929
|
for (let E = 0; E < V.count; E++) {
|
|
930
|
-
const
|
|
930
|
+
const N = V.getX(E) - o[1].x, X = V.getY(E) - o[1].y, q = V.getZ(E) - o[1].z, ie = N * N + X * X + q * q;
|
|
931
931
|
ie < B && (B = ie, T = E);
|
|
932
932
|
}
|
|
933
|
-
|
|
933
|
+
o[1].set(V.getX(T), V.getY(T), V.getZ(T)), console.log(`Retry ${s}: nudge=${z.nudge}mm angle=${(z.angle * 180 / Math.PI).toFixed(0)}\xB0 cutOffset=${z.cutOffset}" \u2192 green=(${o[1].x.toFixed(1)}, ${o[1].y.toFixed(1)}, ${o[1].z.toFixed(1)})`);
|
|
934
934
|
}
|
|
935
935
|
const p = (z, F) => {
|
|
936
|
-
|
|
937
|
-
},
|
|
938
|
-
t.onStatus(
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
let M =
|
|
943
|
-
|
|
944
|
-
const
|
|
945
|
-
|
|
936
|
+
o = Vt(l, o, z, F), f && _t(f, z, F);
|
|
937
|
+
}, x = o[0], g = o[1], { normal: w } = zn(l, g, x);
|
|
938
|
+
t.onStatus(s > 0 ? `Retry ${s}: Slicing mesh...` : "Slicing mesh at cut plane...");
|
|
939
|
+
const v = new h().subVectors(g, x).normalize(), m = Math.sign(v.dot(w)), b = g.clone().addScaledVector(w, m * y * We), S = st(l, b, w, x);
|
|
940
|
+
l.dispose(), l = S, e.geometry = l, t.onStatus(s > 0 ? `Retry ${s}: Rough alignment...` : "Rough alignment...");
|
|
941
|
+
const C = new h().subVectors(o[1], o[0]).normalize();
|
|
942
|
+
let M = C.dot(c), P = new h().crossVectors(C, c);
|
|
943
|
+
P.length() > 1e-4 && (P.normalize(), p(P, Math.acos(Math.min(1, Math.max(-1, M))))), o[0].y > o[1].y && p(new h(1, 0, 0), Math.PI), l.computeVertexNormals(), t.onStatus(s > 0 ? `Retry ${s}: Translating...` : "Translating to origin...");
|
|
944
|
+
const L = o[0].clone();
|
|
945
|
+
l.translate(-L.x, -L.y, -L.z), f && f.translate(-L.x, -L.y, -L.z), o = o.map((z) => new h(z.x - L.x, z.y - L.y, z.z - L.z)), t.onStatus(s > 0 ? `Retry ${s}: Isolating limb...` : "Isolating limb region...");
|
|
946
946
|
{
|
|
947
|
-
const z = ot(
|
|
948
|
-
|
|
949
|
-
const E =
|
|
947
|
+
const z = ot(l), F = o[0].y, V = o[1].y, B = new h(0, 1, 0), T = 5;
|
|
948
|
+
l.computeBoundingBox();
|
|
949
|
+
const E = l.boundingBox.max.y, N = [];
|
|
950
950
|
for (let X = F + T; X < E; X += T) {
|
|
951
|
-
const
|
|
952
|
-
|
|
951
|
+
const q = pt(z, l, new h(0, X, 0), B);
|
|
952
|
+
q > 0 && N.push({
|
|
953
953
|
y: X,
|
|
954
|
-
circ:
|
|
954
|
+
circ: q
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
|
-
if (
|
|
958
|
-
const X = V - F,
|
|
957
|
+
if (N.length > 5) {
|
|
958
|
+
const X = V - F, q = F + X * 0.3, ie = F + X * 0.7, se = N.filter((A) => A.y >= q && A.y <= ie);
|
|
959
959
|
if (se.length >= 3) {
|
|
960
960
|
const A = se.map((U) => U.circ).sort((U, re) => U - re), I = A[Math.floor(A.length / 2)], k = 1.6;
|
|
961
961
|
let G = null;
|
|
962
|
-
for (const U of
|
|
962
|
+
for (const U of N) if (!(U.y < V - T * 2) && U.circ > I * k) {
|
|
963
963
|
G = U.y - T;
|
|
964
964
|
break;
|
|
965
965
|
}
|
|
966
966
|
if (G === null) {
|
|
967
|
-
const U =
|
|
967
|
+
const U = N.find((re) => Math.abs(re.y - V) < T);
|
|
968
968
|
if (U && U.circ > I * k) {
|
|
969
|
-
for (let re =
|
|
970
|
-
G =
|
|
969
|
+
for (let re = N.length - 1; re >= 0; re--) if (!(N[re].y > V + T) && N[re].circ <= I * k) {
|
|
970
|
+
G = N[re].y + T;
|
|
971
971
|
break;
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
975
|
if (G !== null && G > F + X * 0.5) {
|
|
976
976
|
console.log(`Limb isolation: cutting at Y=${G.toFixed(1)}mm (baseline circ=${I.toFixed(1)}mm, threshold=${(I * k).toFixed(1)}mm)`);
|
|
977
|
-
const U = st(
|
|
978
|
-
|
|
977
|
+
const U = st(l, new h(0, G, 0), B, o[0]);
|
|
978
|
+
l.dispose(), l = U, e.geometry = l, l.computeVertexNormals(), l.computeBoundingBox();
|
|
979
979
|
} else console.log(`Limb isolation: no anomaly detected (baseline=${I.toFixed(1)}mm)`);
|
|
980
980
|
}
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
|
-
t.onStatus(
|
|
984
|
-
const H = 10, O = 80, $ =
|
|
983
|
+
t.onStatus(s > 0 ? `Retry ${s}: PCA alignment...` : "Iterative PCA alignment...");
|
|
984
|
+
const H = 10, O = 80, $ = o[0].y, R = o[1].y;
|
|
985
985
|
let Y = R - H;
|
|
986
986
|
for (let z = 0; z < O; z++) {
|
|
987
|
-
const F = Math.min(Y, R), V = Math.max(Y, R), B = rt(
|
|
988
|
-
if (B && (M = B.dot(c), Math.acos(Math.min(1, Math.abs(M))) * 180 / Math.PI > 0.1 && (
|
|
989
|
-
|
|
990
|
-
const E =
|
|
991
|
-
|
|
987
|
+
const F = Math.min(Y, R), V = Math.max(Y, R), B = rt(l, F, V);
|
|
988
|
+
if (B && (M = B.dot(c), Math.acos(Math.min(1, Math.abs(M))) * 180 / Math.PI > 0.1 && (P = new h().crossVectors(B, c), P.length() > 1e-4))) {
|
|
989
|
+
P.normalize(), p(P, Math.acos(Math.min(1, Math.max(-1, M))));
|
|
990
|
+
const E = o[0].clone();
|
|
991
|
+
l.translate(-E.x, -E.y, -E.z), f && f.translate(-E.x, -E.y, -E.z), o = o.map((N) => new h(N.x - E.x, N.y - E.y, N.z - E.z));
|
|
992
992
|
}
|
|
993
993
|
if (Y -= H, Y <= $) break;
|
|
994
994
|
}
|
|
995
|
-
|
|
996
|
-
const
|
|
997
|
-
|
|
995
|
+
l.computeVertexNormals(), t.onStatus(s > 0 ? `Retry ${s}: Setting blue point...` : "Setting blue point...");
|
|
996
|
+
const j = new h(o[0].x, o[0].y, o[0].z);
|
|
997
|
+
o.push(j), t.addLandmarkPoint({
|
|
998
998
|
faceIndex: -1,
|
|
999
999
|
vertexIndices: [
|
|
1000
1000
|
0,
|
|
@@ -1002,35 +1002,35 @@ let __tla = (async () => {
|
|
|
1002
1002
|
2
|
|
1003
1003
|
],
|
|
1004
1004
|
position: {
|
|
1005
|
-
x:
|
|
1006
|
-
y:
|
|
1007
|
-
z:
|
|
1005
|
+
x: j.x,
|
|
1006
|
+
y: j.y,
|
|
1007
|
+
z: j.z
|
|
1008
1008
|
},
|
|
1009
1009
|
barycentricCoords: {
|
|
1010
1010
|
u: 0.33,
|
|
1011
1011
|
v: 0.33,
|
|
1012
1012
|
w: 0.34
|
|
1013
1013
|
}
|
|
1014
|
-
}), t.onStatus(
|
|
1014
|
+
}), t.onStatus(s > 0 ? `Retry ${s}: Final PCA...` : "Final PCA refinement...");
|
|
1015
1015
|
for (let z = 0; z < 3; z++) {
|
|
1016
|
-
const F = rt(
|
|
1016
|
+
const F = rt(l, 0, o[1].y);
|
|
1017
1017
|
if (F) {
|
|
1018
1018
|
if (M = F.dot(c), Math.acos(Math.min(1, Math.abs(M))) * 180 / Math.PI < 0.1) break;
|
|
1019
|
-
if (
|
|
1020
|
-
|
|
1021
|
-
const B =
|
|
1022
|
-
|
|
1019
|
+
if (P = new h().crossVectors(F, c), P.length() > 1e-4) {
|
|
1020
|
+
P.normalize(), p(P, Math.acos(Math.min(1, Math.max(-1, M))));
|
|
1021
|
+
const B = o[0].clone();
|
|
1022
|
+
l.translate(-B.x, -B.y, -B.z), f && f.translate(-B.x, -B.y, -B.z), o = o.map((T) => new h(T.x - B.x, T.y - B.y, T.z - B.z));
|
|
1023
1023
|
}
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
|
-
if (
|
|
1026
|
+
if (o[1].y < o[0].y) {
|
|
1027
1027
|
p(new h(1, 0, 0), Math.PI);
|
|
1028
|
-
const z =
|
|
1029
|
-
|
|
1028
|
+
const z = o[0].clone();
|
|
1029
|
+
l.translate(-z.x, -z.y, -z.z), f && f.translate(-z.x, -z.y, -z.z), o = o.map((F) => new h(F.x - z.x, F.y - z.y, F.z - z.z));
|
|
1030
1030
|
}
|
|
1031
|
-
|
|
1031
|
+
l.computeVertexNormals(), l.computeBoundingBox(), t.onStatus(s > 0 ? `Retry ${s}: Circumference refinement...` : "Circumference refinement...");
|
|
1032
1032
|
{
|
|
1033
|
-
const z = ot(
|
|
1033
|
+
const z = ot(l), F = o[1].y, V = o[0].y, B = [
|
|
1034
1034
|
F - We,
|
|
1035
1035
|
F - 2 * We,
|
|
1036
1036
|
F - 3 * We
|
|
@@ -1040,46 +1040,46 @@ let __tla = (async () => {
|
|
|
1040
1040
|
const G = new h(0, 1, 0);
|
|
1041
1041
|
Math.abs(I) > 1e-10 && G.applyQuaternion(new Oe().setFromAxisAngle(new h(1, 0, 0), I)), Math.abs(k) > 1e-10 && G.applyQuaternion(new Oe().setFromAxisAngle(new h(0, 0, 1), k));
|
|
1042
1042
|
let U = 0;
|
|
1043
|
-
for (const re of B) U += pt(z,
|
|
1043
|
+
for (const re of B) U += pt(z, l, new h(0, re, 0), G);
|
|
1044
1044
|
return U;
|
|
1045
1045
|
};
|
|
1046
|
-
let
|
|
1046
|
+
let N = 0, X = 0, q = E(0, 0);
|
|
1047
1047
|
for (let I = -3; I <= 3; I += 0.5) for (let k = -3; k <= 3; k += 0.5) {
|
|
1048
1048
|
const G = E(I * T, k * T);
|
|
1049
|
-
G > 0 && G <
|
|
1049
|
+
G > 0 && G < q && (q = G, N = I * T, X = k * T);
|
|
1050
1050
|
}
|
|
1051
|
-
const ie =
|
|
1051
|
+
const ie = N, se = X;
|
|
1052
1052
|
for (let I = -5; I <= 5; I++) for (let k = -5; k <= 5; k++) {
|
|
1053
1053
|
const G = ie + I * 0.1 * T, U = se + k * 0.1 * T, re = E(G, U);
|
|
1054
|
-
re > 0 && re <
|
|
1054
|
+
re > 0 && re < q && (q = re, N = G, X = U);
|
|
1055
1055
|
}
|
|
1056
|
-
const A = Math.sqrt(
|
|
1056
|
+
const A = Math.sqrt(N * N + X * X);
|
|
1057
1057
|
if (A > 0.05 * T) {
|
|
1058
|
-
console.log(`Circumference refinement: rotating ${(-
|
|
1059
|
-
const I =
|
|
1060
|
-
|
|
1058
|
+
console.log(`Circumference refinement: rotating ${(-N / T).toFixed(2)}\xB0X ${(-X / T).toFixed(2)}\xB0Z`), Math.abs(N) > 0.01 * T && p(new h(1, 0, 0), -N), Math.abs(X) > 0.01 * T && p(new h(0, 0, 1), -X);
|
|
1059
|
+
const I = o[0].clone();
|
|
1060
|
+
l.translate(-I.x, -I.y, -I.z), f && f.translate(-I.x, -I.y, -I.z), o = o.map((k) => new h(k.x - I.x, k.y - I.y, k.z - I.z)), l.computeVertexNormals();
|
|
1061
1061
|
} else console.log(`Circumference refinement: already optimal (${(A / T).toFixed(3)}\xB0)`);
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
const ne =
|
|
1064
|
+
const ne = o.map((z) => ({
|
|
1065
1065
|
x: z.x,
|
|
1066
1066
|
y: z.y,
|
|
1067
1067
|
z: z.z
|
|
1068
1068
|
}));
|
|
1069
|
-
t.updateLandmarkPositions(ne), t.setAligned(true), t.onStatus(
|
|
1070
|
-
const oe = e.geometry, le =
|
|
1069
|
+
t.updateLandmarkPositions(ne), t.setAligned(true), t.onStatus(s > 0 ? `Retry ${s}: Cutting mesh...` : 'Cutting mesh 2" above green...'), o = An(e, o, l, 5, t, f), t.onStatus("Validating results...");
|
|
1070
|
+
const oe = e.geometry, le = o[1].y, ee = o[0].y, D = Wt(oe, le, ee, n);
|
|
1071
1071
|
if (D.valid) {
|
|
1072
|
-
console.log(`Processing succeeded on attempt ${
|
|
1072
|
+
console.log(`Processing succeeded on attempt ${s + 1}`), f && t.setClippedReferenceGeometry && (f.computeVertexNormals(), t.setClippedReferenceGeometry(f));
|
|
1073
1073
|
break;
|
|
1074
1074
|
}
|
|
1075
|
-
console.warn(`Attempt ${
|
|
1076
|
-
} catch (
|
|
1077
|
-
console.error("Processing failed:",
|
|
1075
|
+
console.warn(`Attempt ${s + 1} failed validation: ${D.reason}`), u = D.reason, f && f.dispose(), s === nt - 1 && (t.setError(`Processing produced unusual results after ${nt} attempts: ${D.reason}`), e.geometry.dispose(), e.geometry = i.clone(), t.removeLandmarkPoint(2), t.setAligned(false), t.setCut(false));
|
|
1076
|
+
} catch (l) {
|
|
1077
|
+
console.error("Processing failed:", l), t.setError(l instanceof Error ? l.message : "Failed to process mesh.");
|
|
1078
1078
|
break;
|
|
1079
1079
|
}
|
|
1080
|
-
|
|
1080
|
+
i.dispose();
|
|
1081
1081
|
}
|
|
1082
|
-
const
|
|
1082
|
+
const Ln = ({ message: e, onDismiss: r }) => W("div", {
|
|
1083
1083
|
style: {
|
|
1084
1084
|
position: "absolute",
|
|
1085
1085
|
top: 16,
|
|
@@ -1118,7 +1118,7 @@ let __tla = (async () => {
|
|
|
1118
1118
|
]
|
|
1119
1119
|
}),
|
|
1120
1120
|
d("button", {
|
|
1121
|
-
onClick:
|
|
1121
|
+
onClick: r,
|
|
1122
1122
|
style: {
|
|
1123
1123
|
background: "none",
|
|
1124
1124
|
border: "none",
|
|
@@ -1169,28 +1169,28 @@ let __tla = (async () => {
|
|
|
1169
1169
|
children: "@keyframes spin { to { transform: rotate(360deg); } }"
|
|
1170
1170
|
})
|
|
1171
1171
|
]
|
|
1172
|
-
}),
|
|
1173
|
-
const { addLandmarkPoint:
|
|
1174
|
-
if (a.length >=
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
if (!
|
|
1172
|
+
}), Pn = ({ mesh: e, maxPoints: r = 2, meshColor: n = "#c8c8c8", meshOpacity: t = 1 }) => {
|
|
1173
|
+
const { addLandmarkPoint: i, landmarkPoints: a } = gt(), c = Fe((l) => {
|
|
1174
|
+
if (a.length >= r) return;
|
|
1175
|
+
l.stopPropagation();
|
|
1176
|
+
const o = l.intersections[0], f = o == null ? void 0 : o.faceIndex;
|
|
1177
|
+
if (!o || f == null) return;
|
|
1178
1178
|
const y = e.geometry, p = y.index;
|
|
1179
|
-
let
|
|
1180
|
-
p ?
|
|
1179
|
+
let x;
|
|
1180
|
+
p ? x = [
|
|
1181
1181
|
p.getX(f * 3),
|
|
1182
1182
|
p.getX(f * 3 + 1),
|
|
1183
1183
|
p.getX(f * 3 + 2)
|
|
1184
|
-
] :
|
|
1184
|
+
] : x = [
|
|
1185
1185
|
f * 3,
|
|
1186
1186
|
f * 3 + 1,
|
|
1187
1187
|
f * 3 + 2
|
|
1188
1188
|
];
|
|
1189
|
-
const g = y.getAttribute("position"), w = new h().fromBufferAttribute(g,
|
|
1190
|
-
w.applyMatrix4(e.matrixWorld),
|
|
1191
|
-
const b =
|
|
1189
|
+
const g = y.getAttribute("position"), w = new h().fromBufferAttribute(g, x[0]), v = new h().fromBufferAttribute(g, x[1]), m = new h().fromBufferAttribute(g, x[2]);
|
|
1190
|
+
w.applyMatrix4(e.matrixWorld), v.applyMatrix4(e.matrixWorld), m.applyMatrix4(e.matrixWorld);
|
|
1191
|
+
const b = o.point, S = vn(b, w, v, m), C = {
|
|
1192
1192
|
faceIndex: f,
|
|
1193
|
-
vertexIndices:
|
|
1193
|
+
vertexIndices: x,
|
|
1194
1194
|
position: {
|
|
1195
1195
|
x: b.x,
|
|
1196
1196
|
y: b.y,
|
|
@@ -1198,16 +1198,16 @@ let __tla = (async () => {
|
|
|
1198
1198
|
},
|
|
1199
1199
|
barycentricCoords: S
|
|
1200
1200
|
};
|
|
1201
|
-
|
|
1201
|
+
i(C);
|
|
1202
1202
|
}, [
|
|
1203
1203
|
e,
|
|
1204
|
-
|
|
1204
|
+
i,
|
|
1205
1205
|
a.length,
|
|
1206
|
-
|
|
1206
|
+
r
|
|
1207
1207
|
]), u = de(() => !!e.geometry.getAttribute("color"), [
|
|
1208
1208
|
e
|
|
1209
|
-
]),
|
|
1210
|
-
color: u ? "#ffffff" :
|
|
1209
|
+
]), s = de(() => new J.MeshStandardMaterial({
|
|
1210
|
+
color: u ? "#ffffff" : n,
|
|
1211
1211
|
side: J.DoubleSide,
|
|
1212
1212
|
roughness: 0.6,
|
|
1213
1213
|
metalness: 0.1,
|
|
@@ -1215,17 +1215,17 @@ let __tla = (async () => {
|
|
|
1215
1215
|
opacity: t,
|
|
1216
1216
|
vertexColors: u
|
|
1217
1217
|
}), [
|
|
1218
|
-
|
|
1218
|
+
n,
|
|
1219
1219
|
t,
|
|
1220
1220
|
u
|
|
1221
1221
|
]);
|
|
1222
1222
|
return d("primitive", {
|
|
1223
1223
|
object: e,
|
|
1224
1224
|
onClick: c,
|
|
1225
|
-
material:
|
|
1225
|
+
material: s
|
|
1226
1226
|
});
|
|
1227
|
-
}, Dn = ({ point: e, index:
|
|
1228
|
-
const [a, c] =
|
|
1227
|
+
}, Dn = ({ point: e, index: r, markerSize: n, color: t, label: i }) => {
|
|
1228
|
+
const [a, c] = Q(false);
|
|
1229
1229
|
return W("mesh", {
|
|
1230
1230
|
position: [
|
|
1231
1231
|
e.position.x,
|
|
@@ -1237,7 +1237,7 @@ let __tla = (async () => {
|
|
|
1237
1237
|
children: [
|
|
1238
1238
|
d("sphereGeometry", {
|
|
1239
1239
|
args: [
|
|
1240
|
-
|
|
1240
|
+
n,
|
|
1241
1241
|
16,
|
|
1242
1242
|
16
|
|
1243
1243
|
]
|
|
@@ -1261,29 +1261,29 @@ let __tla = (async () => {
|
|
|
1261
1261
|
whiteSpace: "nowrap",
|
|
1262
1262
|
transform: "translateY(-24px)"
|
|
1263
1263
|
},
|
|
1264
|
-
children:
|
|
1264
|
+
children: i
|
|
1265
1265
|
})
|
|
1266
1266
|
})
|
|
1267
1267
|
]
|
|
1268
|
-
},
|
|
1269
|
-
}, Tn = ({ modelSize: e, labels:
|
|
1270
|
-
const { landmarkPoints:
|
|
1268
|
+
}, r);
|
|
1269
|
+
}, Tn = ({ modelSize: e, labels: r }) => {
|
|
1270
|
+
const { landmarkPoints: n } = gt(), t = e * 0.02, i = [
|
|
1271
1271
|
"#ff4444",
|
|
1272
1272
|
"#44ff44",
|
|
1273
1273
|
"#4444ff"
|
|
1274
|
-
], c =
|
|
1274
|
+
], c = r ?? [
|
|
1275
1275
|
"Origin",
|
|
1276
1276
|
"MPT",
|
|
1277
1277
|
"Cut Plane"
|
|
1278
1278
|
];
|
|
1279
1279
|
return d(He, {
|
|
1280
|
-
children:
|
|
1280
|
+
children: n.map((u, s) => d(Dn, {
|
|
1281
1281
|
point: u,
|
|
1282
|
-
index:
|
|
1282
|
+
index: s,
|
|
1283
1283
|
markerSize: t,
|
|
1284
|
-
color:
|
|
1285
|
-
label: c[
|
|
1286
|
-
},
|
|
1284
|
+
color: i[s],
|
|
1285
|
+
label: c[s]
|
|
1286
|
+
}, s))
|
|
1287
1287
|
});
|
|
1288
1288
|
};
|
|
1289
1289
|
function kn(e) {
|
|
@@ -1293,28 +1293,28 @@ let __tla = (async () => {
|
|
|
1293
1293
|
e
|
|
1294
1294
|
]);
|
|
1295
1295
|
}
|
|
1296
|
-
const Ft = (e,
|
|
1297
|
-
const
|
|
1298
|
-
return
|
|
1299
|
-
}, It = new J.Color("#8BC34A"),
|
|
1296
|
+
const Ft = (e, r) => {
|
|
1297
|
+
const n = Math.abs(e - r);
|
|
1298
|
+
return n < 1 ? "#8BC34A" : n < 5 ? "#FFC107" : "#FF5722";
|
|
1299
|
+
}, It = new J.Color("#8BC34A"), Lt = new J.Color("#FFC107"), Bn = new J.Color("#FF5722"), Rn = (e) => {
|
|
1300
1300
|
if (e < 1) return It.clone();
|
|
1301
1301
|
if (e < 5) {
|
|
1302
|
-
const
|
|
1303
|
-
return It.clone().lerp(
|
|
1302
|
+
const n = (e - 1) / 4;
|
|
1303
|
+
return It.clone().lerp(Lt, n);
|
|
1304
1304
|
}
|
|
1305
|
-
const
|
|
1306
|
-
return
|
|
1307
|
-
}, En = (e,
|
|
1308
|
-
const
|
|
1309
|
-
for (let
|
|
1310
|
-
const
|
|
1311
|
-
if (t[
|
|
1312
|
-
const p =
|
|
1313
|
-
a.push(p,
|
|
1305
|
+
const r = Math.min((e - 5) / 5, 1);
|
|
1306
|
+
return Lt.clone().lerp(Bn, r);
|
|
1307
|
+
}, En = (e, r) => {
|
|
1308
|
+
const n = e.length, t = new Float32Array(n * 2 * 3), i = new Float32Array(n * 2 * 3), a = [];
|
|
1309
|
+
for (let s = 0; s < n; s++) {
|
|
1310
|
+
const l = e[s], o = r[s], f = l.distanceTo(o), y = Rn(f);
|
|
1311
|
+
if (t[s * 6] = l.x, t[s * 6 + 1] = l.y, t[s * 6 + 2] = l.z, i[s * 6] = y.r, i[s * 6 + 1] = y.g, i[s * 6 + 2] = y.b, t[s * 6 + 3] = o.x, t[s * 6 + 4] = o.y, t[s * 6 + 5] = o.z, i[s * 6 + 3] = y.r, i[s * 6 + 4] = y.g, i[s * 6 + 5] = y.b, s < n - 1) {
|
|
1312
|
+
const p = s * 2, x = p + 1, g = (s + 1) * 2, w = g + 1;
|
|
1313
|
+
a.push(p, x, g, x, w, g);
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
1316
|
const c = new J.BufferGeometry();
|
|
1317
|
-
c.setAttribute("position", new J.Float32BufferAttribute(t, 3)), c.setAttribute("color", new J.Float32BufferAttribute(
|
|
1317
|
+
c.setAttribute("position", new J.Float32BufferAttribute(t, 3)), c.setAttribute("color", new J.Float32BufferAttribute(i, 3)), c.setIndex(a);
|
|
1318
1318
|
const u = new J.MeshBasicMaterial({
|
|
1319
1319
|
vertexColors: true,
|
|
1320
1320
|
transparent: true,
|
|
@@ -1324,39 +1324,39 @@ let __tla = (async () => {
|
|
|
1324
1324
|
depthWrite: false
|
|
1325
1325
|
});
|
|
1326
1326
|
return new J.Mesh(c, u);
|
|
1327
|
-
}, Wn = ({ bvh: e, geometry:
|
|
1328
|
-
const
|
|
1327
|
+
}, Wn = ({ bvh: e, geometry: r, yPosition: n, color: t = "#00ff00", labelX: i, onDataChange: a, displayUnit: c = "mm", useInnerSurface: u = false, formValue: s, lineWidth: l = 1.5 }) => {
|
|
1328
|
+
const o = de(() => Ze(e, r, n, u), [
|
|
1329
1329
|
e,
|
|
1330
|
-
|
|
1331
|
-
|
|
1330
|
+
r,
|
|
1331
|
+
n,
|
|
1332
1332
|
u
|
|
1333
|
-
]), { linePoints: f, lineLength: y } =
|
|
1334
|
-
if (
|
|
1335
|
-
const
|
|
1336
|
-
return f.map((S) => new h(
|
|
1333
|
+
]), { linePoints: f, lineLength: y } = o, p = de(() => {
|
|
1334
|
+
if (s == null || y <= 0 || f.length < 2) return null;
|
|
1335
|
+
const v = s / y, m = f.reduce((S, C) => S + C.x, 0) / f.length, b = f.reduce((S, C) => S + C.z, 0) / f.length;
|
|
1336
|
+
return f.map((S) => new h(m + (S.x - m) * v, S.y, b + (S.z - b) * v));
|
|
1337
1337
|
}, [
|
|
1338
1338
|
f,
|
|
1339
1339
|
y,
|
|
1340
|
-
|
|
1341
|
-
]),
|
|
1340
|
+
s
|
|
1341
|
+
]), x = de(() => !p || f.length < 2 ? null : En(f, p), [
|
|
1342
1342
|
f,
|
|
1343
1343
|
p
|
|
1344
1344
|
]);
|
|
1345
1345
|
Se(() => () => {
|
|
1346
|
-
|
|
1346
|
+
x && (x.geometry.dispose(), x.material.dispose());
|
|
1347
1347
|
}, [
|
|
1348
|
-
|
|
1348
|
+
x
|
|
1349
1349
|
]);
|
|
1350
1350
|
const g = Ie(null), w = de(() => {
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1353
|
-
const
|
|
1351
|
+
const v = new J.BufferGeometry();
|
|
1352
|
+
v.setAttribute("position", new J.Float32BufferAttribute(new Float32Array(6), 3));
|
|
1353
|
+
const m = new J.LineBasicMaterial({
|
|
1354
1354
|
color: 6710886,
|
|
1355
1355
|
depthTest: false,
|
|
1356
1356
|
depthWrite: false,
|
|
1357
1357
|
transparent: true
|
|
1358
1358
|
});
|
|
1359
|
-
return new J.Line(
|
|
1359
|
+
return new J.Line(v, m);
|
|
1360
1360
|
}, []);
|
|
1361
1361
|
return Se(() => () => {
|
|
1362
1362
|
w.geometry.dispose(), w.material.dispose();
|
|
@@ -1364,47 +1364,47 @@ let __tla = (async () => {
|
|
|
1364
1364
|
w
|
|
1365
1365
|
]), Se(() => {
|
|
1366
1366
|
y > 0 && (a == null ? void 0 : a({
|
|
1367
|
-
yPosition:
|
|
1367
|
+
yPosition: n,
|
|
1368
1368
|
originalValue: y,
|
|
1369
1369
|
modifiedValue: null
|
|
1370
1370
|
}));
|
|
1371
1371
|
}, [
|
|
1372
1372
|
y,
|
|
1373
|
-
|
|
1373
|
+
n,
|
|
1374
1374
|
a
|
|
1375
|
-
]),
|
|
1375
|
+
]), Pt(({ camera: v }) => {
|
|
1376
1376
|
if (!g.current || f.length < 2) return;
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
const b = new h(
|
|
1377
|
+
const m = new h();
|
|
1378
|
+
v.getWorldDirection(m);
|
|
1379
|
+
const b = new h(m.x, 0, m.z);
|
|
1380
1380
|
if (b.lengthSq() < 1e-8) return;
|
|
1381
1381
|
b.normalize();
|
|
1382
1382
|
const S = new h().crossVectors(b, new h(0, 1, 0)).normalize();
|
|
1383
|
-
let
|
|
1383
|
+
let C = -1 / 0, M = f[0];
|
|
1384
1384
|
for (const O of f) {
|
|
1385
1385
|
const $ = S.x * O.x + S.z * O.z;
|
|
1386
|
-
$ >
|
|
1386
|
+
$ > C && (C = $, M = O);
|
|
1387
1387
|
}
|
|
1388
|
-
const
|
|
1389
|
-
g.current.position.copy(
|
|
1388
|
+
const P = i * 0.35, L = new h(M.x + S.x * P, n, M.z + S.z * P);
|
|
1389
|
+
g.current.position.copy(L);
|
|
1390
1390
|
const H = w.geometry.getAttribute("position");
|
|
1391
|
-
H.setXYZ(0, M.x, M.y, M.z), H.setXYZ(1,
|
|
1391
|
+
H.setXYZ(0, M.x, M.y, M.z), H.setXYZ(1, L.x, L.y, L.z), H.needsUpdate = true;
|
|
1392
1392
|
}), f.length < 2 ? null : W("group", {
|
|
1393
1393
|
children: [
|
|
1394
1394
|
d(ge, {
|
|
1395
1395
|
points: f,
|
|
1396
1396
|
color: t,
|
|
1397
|
-
lineWidth:
|
|
1397
|
+
lineWidth: l,
|
|
1398
1398
|
depthTest: false,
|
|
1399
1399
|
depthWrite: false,
|
|
1400
1400
|
transparent: true
|
|
1401
1401
|
}),
|
|
1402
|
-
|
|
1403
|
-
object:
|
|
1402
|
+
x && d("primitive", {
|
|
1403
|
+
object: x
|
|
1404
1404
|
}),
|
|
1405
|
-
p &&
|
|
1405
|
+
p && s != null && d(ge, {
|
|
1406
1406
|
points: p,
|
|
1407
|
-
color: Ft(y,
|
|
1407
|
+
color: Ft(y, s),
|
|
1408
1408
|
lineWidth: 2.5,
|
|
1409
1409
|
dashed: true,
|
|
1410
1410
|
dashSize: 2,
|
|
@@ -1445,7 +1445,7 @@ let __tla = (async () => {
|
|
|
1445
1445
|
gap: 4,
|
|
1446
1446
|
padding: "5px 10px",
|
|
1447
1447
|
backgroundColor: "rgba(0, 0, 0, 0.75)",
|
|
1448
|
-
borderRadius:
|
|
1448
|
+
borderRadius: s != null ? "4px 0 0 4px" : 4
|
|
1449
1449
|
},
|
|
1450
1450
|
children: [
|
|
1451
1451
|
d("span", {
|
|
@@ -1468,8 +1468,8 @@ let __tla = (async () => {
|
|
|
1468
1468
|
})
|
|
1469
1469
|
]
|
|
1470
1470
|
}),
|
|
1471
|
-
|
|
1472
|
-
const
|
|
1471
|
+
s != null && y > 0 && (() => {
|
|
1472
|
+
const v = y - s, m = v > 0.5 ? "\u25B2" : v < -0.5 ? "\u25BC" : "", b = Ft(y, s);
|
|
1473
1473
|
return W("div", {
|
|
1474
1474
|
style: {
|
|
1475
1475
|
display: "flex",
|
|
@@ -1481,13 +1481,13 @@ let __tla = (async () => {
|
|
|
1481
1481
|
borderLeft: "1px solid rgba(255,255,255,0.12)"
|
|
1482
1482
|
},
|
|
1483
1483
|
children: [
|
|
1484
|
-
|
|
1484
|
+
m && d("span", {
|
|
1485
1485
|
style: {
|
|
1486
1486
|
fontSize: 10,
|
|
1487
1487
|
color: b,
|
|
1488
1488
|
lineHeight: 1
|
|
1489
1489
|
},
|
|
1490
|
-
children:
|
|
1490
|
+
children: m
|
|
1491
1491
|
}),
|
|
1492
1492
|
W("span", {
|
|
1493
1493
|
style: {
|
|
@@ -1497,8 +1497,8 @@ let __tla = (async () => {
|
|
|
1497
1497
|
fontWeight: 600
|
|
1498
1498
|
},
|
|
1499
1499
|
children: [
|
|
1500
|
-
|
|
1501
|
-
c === "inch" ? (
|
|
1500
|
+
v > 0 ? "+" : "",
|
|
1501
|
+
c === "inch" ? (v / 25.4).toFixed(2) : v.toFixed(1)
|
|
1502
1502
|
]
|
|
1503
1503
|
}),
|
|
1504
1504
|
W("span", {
|
|
@@ -1509,7 +1509,7 @@ let __tla = (async () => {
|
|
|
1509
1509
|
},
|
|
1510
1510
|
children: [
|
|
1511
1511
|
"form ",
|
|
1512
|
-
c === "inch" ? (
|
|
1512
|
+
c === "inch" ? (s / 25.4).toFixed(2) : s.toFixed(0)
|
|
1513
1513
|
]
|
|
1514
1514
|
})
|
|
1515
1515
|
]
|
|
@@ -1521,71 +1521,71 @@ let __tla = (async () => {
|
|
|
1521
1521
|
})
|
|
1522
1522
|
]
|
|
1523
1523
|
});
|
|
1524
|
-
}, Vn = nn(Wn), _n = ({ mesh: e, startY:
|
|
1525
|
-
const f = Ie(/* @__PURE__ */ new Map()), y = e.geometry, p = kn(y),
|
|
1526
|
-
const
|
|
1527
|
-
if (c) for (let b =
|
|
1528
|
-
else for (let b =
|
|
1529
|
-
return
|
|
1524
|
+
}, Vn = nn(Wn), _n = ({ mesh: e, startY: r, endY: n, spacing: t, modelSize: i, onMeasurementsChange: a, reverseOrder: c = false, displayUnit: u = "mm", useInnerSurface: s = false, formMeasurements: l, originY: o }) => {
|
|
1525
|
+
const f = Ie(/* @__PURE__ */ new Map()), y = e.geometry, p = kn(y), x = de(() => {
|
|
1526
|
+
const m = [];
|
|
1527
|
+
if (c) for (let b = n; b >= r; b -= t) m.push(b);
|
|
1528
|
+
else for (let b = r; b <= n; b += t) m.push(b);
|
|
1529
|
+
return m;
|
|
1530
1530
|
}, [
|
|
1531
|
-
|
|
1532
|
-
|
|
1531
|
+
r,
|
|
1532
|
+
n,
|
|
1533
1533
|
t,
|
|
1534
1534
|
c
|
|
1535
1535
|
]);
|
|
1536
1536
|
Se(() => {
|
|
1537
1537
|
f.current.clear();
|
|
1538
1538
|
}, [
|
|
1539
|
-
|
|
1539
|
+
x
|
|
1540
1540
|
]);
|
|
1541
1541
|
const g = [
|
|
1542
1542
|
"#5B9BD5"
|
|
1543
|
-
], w =
|
|
1544
|
-
f.current.set(
|
|
1545
|
-
const b = Array.from(f.current.values()).sort((S,
|
|
1543
|
+
], w = i * un, v = Fe((m) => {
|
|
1544
|
+
f.current.set(m.yPosition, m);
|
|
1545
|
+
const b = Array.from(f.current.values()).sort((S, C) => c ? C.yPosition - S.yPosition : S.yPosition - C.yPosition);
|
|
1546
1546
|
a == null ? void 0 : a(b);
|
|
1547
1547
|
}, [
|
|
1548
1548
|
a,
|
|
1549
1549
|
c
|
|
1550
1550
|
]);
|
|
1551
1551
|
return p ? d(He, {
|
|
1552
|
-
children:
|
|
1552
|
+
children: x.map((m, b) => d(Vn, {
|
|
1553
1553
|
bvh: p,
|
|
1554
1554
|
geometry: y,
|
|
1555
|
-
yPosition:
|
|
1556
|
-
color:
|
|
1555
|
+
yPosition: m,
|
|
1556
|
+
color: o != null && Math.abs(m - o) < t * 0.5 ? "#44ff44" : g[b % g.length],
|
|
1557
1557
|
labelX: w,
|
|
1558
|
-
onDataChange:
|
|
1558
|
+
onDataChange: v,
|
|
1559
1559
|
displayUnit: u,
|
|
1560
|
-
useInnerSurface:
|
|
1561
|
-
formValue:
|
|
1562
|
-
lineWidth:
|
|
1563
|
-
},
|
|
1560
|
+
useInnerSurface: s,
|
|
1561
|
+
formValue: l == null ? void 0 : l[b],
|
|
1562
|
+
lineWidth: o != null && Math.abs(m - o) < t * 0.5 ? 4 : 1.5
|
|
1563
|
+
}, m))
|
|
1564
1564
|
}) : null;
|
|
1565
|
-
}, On = ({ mesh: e, greenY:
|
|
1565
|
+
}, On = ({ mesh: e, greenY: r, modelSize: n, displayUnit: t = "mm" }) => {
|
|
1566
1566
|
var _a;
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
const a = ((_a =
|
|
1570
|
-
|
|
1571
|
-
if (!
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1574
|
-
const b = new h(
|
|
1567
|
+
const i = e.geometry;
|
|
1568
|
+
i.computeBoundingBox();
|
|
1569
|
+
const a = ((_a = i.boundingBox) == null ? void 0 : _a.min.y) ?? 0, c = r - a, u = n * 0.4, s = n * 0.03, l = Ie(null);
|
|
1570
|
+
Pt(({ camera: v }) => {
|
|
1571
|
+
if (!l.current) return;
|
|
1572
|
+
const m = new h();
|
|
1573
|
+
v.getWorldDirection(m);
|
|
1574
|
+
const b = new h(m.x, 0, m.z);
|
|
1575
1575
|
if (b.lengthSq() < 1e-8) return;
|
|
1576
1576
|
b.normalize();
|
|
1577
1577
|
const S = new h().crossVectors(new h(0, 1, 0), b).normalize();
|
|
1578
|
-
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1578
|
+
l.current.position.set(S.x * u, 0, S.z * u);
|
|
1579
|
+
const C = v.position.x - l.current.position.x, M = v.position.z - l.current.position.z;
|
|
1580
|
+
l.current.rotation.y = Math.atan2(C, M);
|
|
1581
1581
|
});
|
|
1582
|
-
const
|
|
1582
|
+
const o = new h(0, r, 0), f = new h(0, a, 0), y = new h(0, (r + a) / 2, 0), p = new h(-s, r, 0), x = new h(s, r, 0), g = new h(-s, a, 0), w = new h(s, a, 0);
|
|
1583
1583
|
return W("group", {
|
|
1584
|
-
ref:
|
|
1584
|
+
ref: l,
|
|
1585
1585
|
children: [
|
|
1586
1586
|
d(ge, {
|
|
1587
1587
|
points: [
|
|
1588
|
-
|
|
1588
|
+
o,
|
|
1589
1589
|
f
|
|
1590
1590
|
],
|
|
1591
1591
|
color: "#888888",
|
|
@@ -1595,7 +1595,7 @@ let __tla = (async () => {
|
|
|
1595
1595
|
d(ge, {
|
|
1596
1596
|
points: [
|
|
1597
1597
|
p,
|
|
1598
|
-
|
|
1598
|
+
x
|
|
1599
1599
|
],
|
|
1600
1600
|
color: "#888888",
|
|
1601
1601
|
lineWidth: 1.5,
|
|
@@ -1640,147 +1640,147 @@ let __tla = (async () => {
|
|
|
1640
1640
|
})
|
|
1641
1641
|
]
|
|
1642
1642
|
});
|
|
1643
|
-
}, $n = ({ modelSize: e, isAligned:
|
|
1644
|
-
const { set: u, size:
|
|
1643
|
+
}, $n = ({ modelSize: e, isAligned: r, isCut: n, mesh: t, viewMode: i, sliceY: a, landmarkCount: c = 0 }) => {
|
|
1644
|
+
const { set: u, size: s, camera: l, invalidate: o } = on(), f = Ie(false), y = Ie(r), p = Ie(n), x = Ie(i), g = Ie(new h()), w = Ie(null), v = Ie(c), m = Fe(() => {
|
|
1645
1645
|
if (!t || e <= 0) return;
|
|
1646
1646
|
const S = t.geometry;
|
|
1647
1647
|
S.computeBoundingBox();
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
const
|
|
1648
|
+
const C = S.boundingBox, M = new h();
|
|
1649
|
+
C.getCenter(M);
|
|
1650
|
+
const P = new h();
|
|
1651
|
+
C.getSize(P), g.current.copy(P);
|
|
1652
|
+
const L = s.width / s.height, H = Math.max(P.y, P.x / L) * 1.2, O = H * L, $ = new J.OrthographicCamera(-O / 2, O / 2, H / 2, -H / 2, 0.1, e * 10);
|
|
1653
1653
|
$.position.set(0, M.y, e * 2), $.lookAt(0, M.y, 0), u({
|
|
1654
1654
|
camera: $
|
|
1655
1655
|
});
|
|
1656
1656
|
}, [
|
|
1657
1657
|
t,
|
|
1658
1658
|
e,
|
|
1659
|
-
|
|
1659
|
+
s,
|
|
1660
1660
|
u
|
|
1661
1661
|
]), b = Fe((S) => {
|
|
1662
|
-
const
|
|
1663
|
-
S.position.set(M * Math.sin(
|
|
1662
|
+
const C = S.position.clone(), M = C.length(), P = Math.atan2(C.x, C.z), L = Math.acos(C.y / M), O = P + 0.02;
|
|
1663
|
+
S.position.set(M * Math.sin(L) * Math.sin(O), M * Math.cos(L), M * Math.sin(L) * Math.cos(O)), S.lookAt(0, 0, 0), S.updateMatrixWorld(true), o();
|
|
1664
1664
|
}, [
|
|
1665
|
-
|
|
1665
|
+
o
|
|
1666
1666
|
]);
|
|
1667
1667
|
return Se(() => {
|
|
1668
|
-
if (e > 0 && !f.current && !
|
|
1668
|
+
if (e > 0 && !f.current && !r) {
|
|
1669
1669
|
f.current = true;
|
|
1670
|
-
const S = new J.PerspectiveCamera(50,
|
|
1670
|
+
const S = new J.PerspectiveCamera(50, s.width / s.height, 0.1, e * 10);
|
|
1671
1671
|
S.position.set(e * 0.3, e * 0.2, e * 1.5), S.lookAt(0, 0, 0), u({
|
|
1672
1672
|
camera: S
|
|
1673
1673
|
}), requestAnimationFrame(() => b(S));
|
|
1674
1674
|
}
|
|
1675
1675
|
}, [
|
|
1676
1676
|
e,
|
|
1677
|
-
n,
|
|
1678
|
-
u,
|
|
1679
1677
|
s,
|
|
1678
|
+
u,
|
|
1679
|
+
r,
|
|
1680
1680
|
b
|
|
1681
1681
|
]), Se(() => {
|
|
1682
|
-
const S =
|
|
1683
|
-
|
|
1682
|
+
const S = v.current;
|
|
1683
|
+
v.current = c, S === 0 && c === 1 && !r && requestAnimationFrame(() => b(l));
|
|
1684
1684
|
}, [
|
|
1685
1685
|
c,
|
|
1686
|
-
|
|
1687
|
-
|
|
1686
|
+
r,
|
|
1687
|
+
l,
|
|
1688
1688
|
b
|
|
1689
1689
|
]), Se(() => {
|
|
1690
|
-
y.current ===
|
|
1690
|
+
y.current === r && p.current === n || (y.current = r, p.current = n, r && i === "3D" && m());
|
|
1691
1691
|
}, [
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1692
|
+
r,
|
|
1693
|
+
n,
|
|
1694
|
+
i,
|
|
1695
|
+
m
|
|
1696
1696
|
]), Se(() => {
|
|
1697
|
-
if (
|
|
1698
|
-
const S =
|
|
1699
|
-
if (
|
|
1700
|
-
w.current =
|
|
1701
|
-
const
|
|
1697
|
+
if (x.current === i) return;
|
|
1698
|
+
const S = x.current;
|
|
1699
|
+
if (x.current = i, !(!r || !t || e <= 0)) if (i === "2D" && a != null) {
|
|
1700
|
+
w.current = l;
|
|
1701
|
+
const C = t.geometry, M = C.getAttribute("position"), P = M.array, L = e * 0.15;
|
|
1702
1702
|
let H = 1 / 0, O = -1 / 0, $ = 1 / 0, R = -1 / 0, Y = false;
|
|
1703
|
-
for (let B = 0; B < M.count; B++) if (Math.abs(
|
|
1704
|
-
const T =
|
|
1703
|
+
for (let B = 0; B < M.count; B++) if (Math.abs(P[B * 3 + 1] - a) < L) {
|
|
1704
|
+
const T = P[B * 3], E = P[B * 3 + 2];
|
|
1705
1705
|
T < H && (H = T), T > O && (O = T), E < $ && ($ = E), E > R && (R = E), Y = true;
|
|
1706
1706
|
}
|
|
1707
1707
|
if (!Y) {
|
|
1708
|
-
|
|
1709
|
-
const B =
|
|
1708
|
+
C.computeBoundingBox();
|
|
1709
|
+
const B = C.boundingBox;
|
|
1710
1710
|
H = B.min.x, O = B.max.x, $ = B.min.z, R = B.max.z;
|
|
1711
1711
|
}
|
|
1712
|
-
const
|
|
1712
|
+
const j = (H + O) / 2, ne = ($ + R) / 2, oe = s.width / s.height, le = 1.4, ee = (O - H) * le, D = (R - $) * le;
|
|
1713
1713
|
let z, F;
|
|
1714
1714
|
ee / D > oe ? (z = ee, F = ee / oe) : (F = D, z = D * oe);
|
|
1715
1715
|
const V = new J.OrthographicCamera(-z / 2, z / 2, F / 2, -F / 2, 0.1, e * 10);
|
|
1716
|
-
V.position.set(
|
|
1716
|
+
V.position.set(j, a + e * 2, ne), V.up.set(0, 0, -1), V.lookAt(j, a, ne), u({
|
|
1717
1717
|
camera: V
|
|
1718
1718
|
});
|
|
1719
1719
|
} else S === "2D" && (w.current ? (u({
|
|
1720
1720
|
camera: w.current
|
|
1721
|
-
}), w.current = null) :
|
|
1721
|
+
}), w.current = null) : m());
|
|
1722
1722
|
}, [
|
|
1723
|
-
|
|
1723
|
+
i,
|
|
1724
1724
|
a,
|
|
1725
|
-
|
|
1725
|
+
r,
|
|
1726
1726
|
t,
|
|
1727
1727
|
e,
|
|
1728
|
-
|
|
1728
|
+
s,
|
|
1729
1729
|
u,
|
|
1730
|
-
|
|
1731
|
-
|
|
1730
|
+
l,
|
|
1731
|
+
m
|
|
1732
1732
|
]), Se(() => {
|
|
1733
|
-
if (!
|
|
1734
|
-
const S =
|
|
1735
|
-
if (
|
|
1733
|
+
if (!r || !l || !l.isOrthographicCamera) return;
|
|
1734
|
+
const S = l;
|
|
1735
|
+
if (i === "2D") {
|
|
1736
1736
|
if (!t || a == null) return;
|
|
1737
|
-
const
|
|
1737
|
+
const C = t.geometry, M = C.getAttribute("position"), P = M.array, L = e * 0.15;
|
|
1738
1738
|
let H = 1 / 0, O = -1 / 0, $ = 1 / 0, R = -1 / 0, Y = false;
|
|
1739
|
-
for (let z = 0; z < M.count; z++) if (Math.abs(
|
|
1740
|
-
const F =
|
|
1739
|
+
for (let z = 0; z < M.count; z++) if (Math.abs(P[z * 3 + 1] - a) < L) {
|
|
1740
|
+
const F = P[z * 3], V = P[z * 3 + 2];
|
|
1741
1741
|
F < H && (H = F), F > O && (O = F), V < $ && ($ = V), V > R && (R = V), Y = true;
|
|
1742
1742
|
}
|
|
1743
1743
|
if (!Y) {
|
|
1744
|
-
|
|
1745
|
-
const z =
|
|
1744
|
+
C.computeBoundingBox();
|
|
1745
|
+
const z = C.boundingBox;
|
|
1746
1746
|
H = z.min.x, O = z.max.x, $ = z.min.z, R = z.max.z;
|
|
1747
1747
|
}
|
|
1748
|
-
const
|
|
1748
|
+
const j = s.width / s.height, ne = 1.4, oe = (O - H) * ne, le = (R - $) * ne;
|
|
1749
1749
|
let ee, D;
|
|
1750
|
-
oe / le >
|
|
1750
|
+
oe / le > j ? (ee = oe, D = oe / j) : (D = le, ee = le * j), S.left = -ee / 2, S.right = ee / 2, S.top = D / 2, S.bottom = -D / 2;
|
|
1751
1751
|
} else {
|
|
1752
|
-
const
|
|
1753
|
-
S.left = -
|
|
1752
|
+
const C = g.current, M = s.width / s.height, P = Math.max(C.y, C.x / M) * 1.2, L = P * M;
|
|
1753
|
+
S.left = -L / 2, S.right = L / 2, S.top = P / 2, S.bottom = -P / 2;
|
|
1754
1754
|
}
|
|
1755
1755
|
S.updateProjectionMatrix();
|
|
1756
1756
|
}, [
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
i,
|
|
1757
|
+
s.width,
|
|
1758
|
+
s.height,
|
|
1759
|
+
r,
|
|
1761
1760
|
l,
|
|
1761
|
+
i,
|
|
1762
1762
|
t
|
|
1763
1763
|
]), null;
|
|
1764
|
-
},
|
|
1764
|
+
}, jn = ({ mesh: e, isDragging: r }) => {
|
|
1765
1765
|
var _a;
|
|
1766
|
-
const
|
|
1767
|
-
|
|
1766
|
+
const n = e.geometry;
|
|
1767
|
+
n.computeBoundingBox();
|
|
1768
1768
|
const t = new h();
|
|
1769
|
-
return (_a =
|
|
1769
|
+
return (_a = n.boundingBox) == null ? void 0 : _a.getCenter(t), d(Dt, {
|
|
1770
1770
|
enableDamping: false,
|
|
1771
1771
|
enablePan: false,
|
|
1772
1772
|
minPolarAngle: Math.PI * 0.15,
|
|
1773
1773
|
maxPolarAngle: Math.PI * 0.85,
|
|
1774
1774
|
minZoom: 0.5,
|
|
1775
1775
|
maxZoom: 3,
|
|
1776
|
-
enabled: !
|
|
1776
|
+
enabled: !r,
|
|
1777
1777
|
target: [
|
|
1778
1778
|
t.x,
|
|
1779
1779
|
t.y,
|
|
1780
1780
|
t.z
|
|
1781
1781
|
]
|
|
1782
1782
|
});
|
|
1783
|
-
},
|
|
1783
|
+
}, Nn = ({ wasAutoScaled: e, onDismiss: r }) => W("div", {
|
|
1784
1784
|
style: {
|
|
1785
1785
|
position: "absolute",
|
|
1786
1786
|
bottom: 16,
|
|
@@ -1806,7 +1806,7 @@ let __tla = (async () => {
|
|
|
1806
1806
|
children: e ? "Units detected as meters - converted to mm" : "Units detected as mm"
|
|
1807
1807
|
}),
|
|
1808
1808
|
d("button", {
|
|
1809
|
-
onClick:
|
|
1809
|
+
onClick: r,
|
|
1810
1810
|
style: {
|
|
1811
1811
|
background: "none",
|
|
1812
1812
|
border: "none",
|
|
@@ -1821,7 +1821,7 @@ let __tla = (async () => {
|
|
|
1821
1821
|
children: "X"
|
|
1822
1822
|
})
|
|
1823
1823
|
]
|
|
1824
|
-
}), Hn = ({ isDoubleShell: e, onDismiss:
|
|
1824
|
+
}), Hn = ({ isDoubleShell: e, onDismiss: r }) => W("div", {
|
|
1825
1825
|
style: {
|
|
1826
1826
|
position: "absolute",
|
|
1827
1827
|
bottom: 68,
|
|
@@ -1847,7 +1847,7 @@ let __tla = (async () => {
|
|
|
1847
1847
|
children: e ? "Double shell scan detected" : "Single shell scan detected"
|
|
1848
1848
|
}),
|
|
1849
1849
|
d("button", {
|
|
1850
|
-
onClick:
|
|
1850
|
+
onClick: r,
|
|
1851
1851
|
style: {
|
|
1852
1852
|
background: "none",
|
|
1853
1853
|
border: "none",
|
|
@@ -1862,7 +1862,7 @@ let __tla = (async () => {
|
|
|
1862
1862
|
children: "X"
|
|
1863
1863
|
})
|
|
1864
1864
|
]
|
|
1865
|
-
}), Yn = ({ steps: e, currentStep:
|
|
1865
|
+
}), Yn = ({ steps: e, currentStep: r, accentColor: n = "rgb(12, 67, 173)" }) => d("div", {
|
|
1866
1866
|
style: {
|
|
1867
1867
|
backgroundColor: "#fff",
|
|
1868
1868
|
borderBottom: "1px solid #e0e0e0",
|
|
@@ -1871,8 +1871,8 @@ let __tla = (async () => {
|
|
|
1871
1871
|
padding: "24px 24px",
|
|
1872
1872
|
flexShrink: 0
|
|
1873
1873
|
},
|
|
1874
|
-
children: e.map((t,
|
|
1875
|
-
const a = t.number <
|
|
1874
|
+
children: e.map((t, i) => {
|
|
1875
|
+
const a = t.number < r, c = t.number === r;
|
|
1876
1876
|
return W("div", {
|
|
1877
1877
|
style: {
|
|
1878
1878
|
display: "contents"
|
|
@@ -1893,7 +1893,7 @@ let __tla = (async () => {
|
|
|
1893
1893
|
width: 24,
|
|
1894
1894
|
height: 24,
|
|
1895
1895
|
borderRadius: "50%",
|
|
1896
|
-
backgroundColor: a || c ?
|
|
1896
|
+
backgroundColor: a || c ? n : "rgba(0, 0, 0, 0.38)",
|
|
1897
1897
|
color: "#fff",
|
|
1898
1898
|
display: "flex",
|
|
1899
1899
|
alignItems: "center",
|
|
@@ -1916,7 +1916,7 @@ let __tla = (async () => {
|
|
|
1916
1916
|
})
|
|
1917
1917
|
]
|
|
1918
1918
|
}),
|
|
1919
|
-
|
|
1919
|
+
i < e.length - 1 && d("div", {
|
|
1920
1920
|
style: {
|
|
1921
1921
|
flex: "auto",
|
|
1922
1922
|
borderTop: "1px solid #bdbdbd",
|
|
@@ -1926,67 +1926,67 @@ let __tla = (async () => {
|
|
|
1926
1926
|
]
|
|
1927
1927
|
}, t.number);
|
|
1928
1928
|
})
|
|
1929
|
-
}), Gn = ({ mesh: e, upperY:
|
|
1929
|
+
}), Gn = ({ mesh: e, upperY: r, originY: n, modelSize: t, meshColor: i = "#c8c8c8", displayUnit: a = "mm" }) => {
|
|
1930
1930
|
const c = e.geometry, u = de(() => new $e(c, {
|
|
1931
1931
|
maxLeafTris: Ye
|
|
1932
1932
|
}), [
|
|
1933
1933
|
c
|
|
1934
|
-
]),
|
|
1934
|
+
]), s = de(() => Ze(u, c, n), [
|
|
1935
1935
|
u,
|
|
1936
1936
|
c,
|
|
1937
|
-
|
|
1938
|
-
]),
|
|
1939
|
-
|
|
1940
|
-
]), { mlLine:
|
|
1941
|
-
let w = null,
|
|
1942
|
-
if (
|
|
1943
|
-
let S =
|
|
1944
|
-
for (const
|
|
1937
|
+
n
|
|
1938
|
+
]), l = de(() => new it(new h(0, -1, 0), r), [
|
|
1939
|
+
r
|
|
1940
|
+
]), { mlLine: o, apLine: f, mlWidth: y, apWidth: p } = de(() => {
|
|
1941
|
+
let w = null, v = null, m = 0, b = 0;
|
|
1942
|
+
if (s.linePoints.length >= 2) {
|
|
1943
|
+
let S = s.linePoints[0], C = s.linePoints[0], M = s.linePoints[0], P = s.linePoints[0];
|
|
1944
|
+
for (const L of s.linePoints) L.x < S.x && (S = L), L.x > C.x && (C = L), L.z < M.z && (M = L), L.z > P.z && (P = L);
|
|
1945
1945
|
w = [
|
|
1946
|
-
new h(S.x,
|
|
1947
|
-
new h(
|
|
1948
|
-
],
|
|
1949
|
-
new h(M.x,
|
|
1950
|
-
new h(
|
|
1951
|
-
],
|
|
1946
|
+
new h(S.x, n, S.z),
|
|
1947
|
+
new h(C.x, n, C.z)
|
|
1948
|
+
], v = [
|
|
1949
|
+
new h(M.x, n, M.z),
|
|
1950
|
+
new h(P.x, n, P.z)
|
|
1951
|
+
], m = w[0].distanceTo(w[1]), b = v[0].distanceTo(v[1]);
|
|
1952
1952
|
}
|
|
1953
1953
|
return {
|
|
1954
1954
|
mlLine: w,
|
|
1955
|
-
apLine:
|
|
1956
|
-
mlWidth:
|
|
1955
|
+
apLine: v,
|
|
1956
|
+
mlWidth: m,
|
|
1957
1957
|
apWidth: b
|
|
1958
1958
|
};
|
|
1959
1959
|
}, [
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
]),
|
|
1960
|
+
s,
|
|
1961
|
+
n
|
|
1962
|
+
]), x = (w) => a === "inch" ? (w / 25.4).toFixed(2) : w.toFixed(1), g = a === "inch" ? "in" : "mm";
|
|
1963
1963
|
return W(He, {
|
|
1964
1964
|
children: [
|
|
1965
1965
|
d("mesh", {
|
|
1966
1966
|
geometry: e.geometry,
|
|
1967
1967
|
children: d("meshStandardMaterial", {
|
|
1968
|
-
color:
|
|
1968
|
+
color: i,
|
|
1969
1969
|
side: J.DoubleSide,
|
|
1970
1970
|
transparent: true,
|
|
1971
1971
|
opacity: 0.15,
|
|
1972
1972
|
depthWrite: false,
|
|
1973
1973
|
clippingPlanes: [
|
|
1974
|
-
|
|
1974
|
+
l
|
|
1975
1975
|
]
|
|
1976
1976
|
})
|
|
1977
1977
|
}),
|
|
1978
|
-
|
|
1979
|
-
points:
|
|
1978
|
+
s.linePoints.length >= 2 && d(ge, {
|
|
1979
|
+
points: s.linePoints,
|
|
1980
1980
|
color: "#00ff00",
|
|
1981
1981
|
lineWidth: 3,
|
|
1982
1982
|
depthTest: false,
|
|
1983
1983
|
depthWrite: false,
|
|
1984
1984
|
transparent: true
|
|
1985
1985
|
}),
|
|
1986
|
-
|
|
1986
|
+
o && W(He, {
|
|
1987
1987
|
children: [
|
|
1988
1988
|
d(ge, {
|
|
1989
|
-
points:
|
|
1989
|
+
points: o,
|
|
1990
1990
|
color: "#ff8800",
|
|
1991
1991
|
lineWidth: 2,
|
|
1992
1992
|
depthTest: false,
|
|
@@ -1995,9 +1995,9 @@ let __tla = (async () => {
|
|
|
1995
1995
|
}),
|
|
1996
1996
|
d(Ke, {
|
|
1997
1997
|
position: [
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
1998
|
+
o[0].x,
|
|
1999
|
+
n,
|
|
2000
|
+
o[0].z - t * 0.02
|
|
2001
2001
|
],
|
|
2002
2002
|
center: true,
|
|
2003
2003
|
style: {
|
|
@@ -2018,7 +2018,7 @@ let __tla = (async () => {
|
|
|
2018
2018
|
},
|
|
2019
2019
|
children: [
|
|
2020
2020
|
"ML ",
|
|
2021
|
-
|
|
2021
|
+
x(y),
|
|
2022
2022
|
" ",
|
|
2023
2023
|
g
|
|
2024
2024
|
]
|
|
@@ -2040,7 +2040,7 @@ let __tla = (async () => {
|
|
|
2040
2040
|
d(Ke, {
|
|
2041
2041
|
position: [
|
|
2042
2042
|
Math.max(f[0].x, f[1].x) + t * 0.02,
|
|
2043
|
-
|
|
2043
|
+
n,
|
|
2044
2044
|
f[0].z > f[1].z ? f[0].z : f[1].z
|
|
2045
2045
|
],
|
|
2046
2046
|
center: true,
|
|
@@ -2062,7 +2062,7 @@ let __tla = (async () => {
|
|
|
2062
2062
|
},
|
|
2063
2063
|
children: [
|
|
2064
2064
|
"AP ",
|
|
2065
|
-
|
|
2065
|
+
x(p),
|
|
2066
2066
|
" ",
|
|
2067
2067
|
g
|
|
2068
2068
|
]
|
|
@@ -2088,100 +2088,100 @@ let __tla = (async () => {
|
|
|
2088
2088
|
"#4488ff"
|
|
2089
2089
|
];
|
|
2090
2090
|
function Ot(e) {
|
|
2091
|
-
const
|
|
2092
|
-
for (let g = 0; g <
|
|
2093
|
-
t.divideScalar(
|
|
2094
|
-
let
|
|
2095
|
-
for (let g = 0; g <
|
|
2096
|
-
const w =
|
|
2097
|
-
|
|
2091
|
+
const r = e.getAttribute("position"), n = r.count, t = new h();
|
|
2092
|
+
for (let g = 0; g < n; g++) t.x += r.getX(g), t.y += r.getY(g), t.z += r.getZ(g);
|
|
2093
|
+
t.divideScalar(n);
|
|
2094
|
+
let i = 0, a = 0, c = 0, u = 0, s = 0, l = 0;
|
|
2095
|
+
for (let g = 0; g < n; g++) {
|
|
2096
|
+
const w = r.getX(g) - t.x, v = r.getY(g) - t.y, m = r.getZ(g) - t.z;
|
|
2097
|
+
i += w * w, a += w * v, c += w * m, u += v * v, s += v * m, l += m * m;
|
|
2098
2098
|
}
|
|
2099
|
-
|
|
2100
|
-
const
|
|
2099
|
+
i /= n, a /= n, c /= n, u /= n, s /= n, l /= n;
|
|
2100
|
+
const o = [], f = [], y = [
|
|
2101
2101
|
[
|
|
2102
|
-
|
|
2102
|
+
i,
|
|
2103
2103
|
a,
|
|
2104
2104
|
c
|
|
2105
2105
|
],
|
|
2106
2106
|
[
|
|
2107
2107
|
a,
|
|
2108
2108
|
u,
|
|
2109
|
-
|
|
2109
|
+
s
|
|
2110
2110
|
],
|
|
2111
2111
|
[
|
|
2112
2112
|
c,
|
|
2113
|
-
|
|
2114
|
-
|
|
2113
|
+
s,
|
|
2114
|
+
l
|
|
2115
2115
|
]
|
|
2116
2116
|
];
|
|
2117
2117
|
for (let g = 0; g < 3; g++) {
|
|
2118
|
-
let w = new h(1 + g * 0.1, 1 - g * 0.1, 0.5 + g * 0.3).normalize(),
|
|
2119
|
-
for (let
|
|
2120
|
-
const b = y[0][0] * w.x + y[0][1] * w.y + y[0][2] * w.z, S = y[1][0] * w.x + y[1][1] * w.y + y[1][2] * w.z,
|
|
2121
|
-
if (
|
|
2122
|
-
if (M.divideScalar(
|
|
2118
|
+
let w = new h(1 + g * 0.1, 1 - g * 0.1, 0.5 + g * 0.3).normalize(), v = 0;
|
|
2119
|
+
for (let m = 0; m < 100; m++) {
|
|
2120
|
+
const b = y[0][0] * w.x + y[0][1] * w.y + y[0][2] * w.z, S = y[1][0] * w.x + y[1][1] * w.y + y[1][2] * w.z, C = y[2][0] * w.x + y[2][1] * w.y + y[2][2] * w.z, M = new h(b, S, C);
|
|
2121
|
+
if (v = M.length(), v < 1e-12) break;
|
|
2122
|
+
if (M.divideScalar(v), w.distanceTo(M) < 1e-10) {
|
|
2123
2123
|
w = M;
|
|
2124
2124
|
break;
|
|
2125
2125
|
}
|
|
2126
2126
|
w = M;
|
|
2127
2127
|
}
|
|
2128
|
-
|
|
2129
|
-
for (let
|
|
2128
|
+
o.push(w.clone()), f.push(v);
|
|
2129
|
+
for (let m = 0; m < 3; m++) for (let b = 0; b < 3; b++) {
|
|
2130
2130
|
const S = [
|
|
2131
2131
|
w.x,
|
|
2132
2132
|
w.y,
|
|
2133
2133
|
w.z
|
|
2134
|
-
][
|
|
2134
|
+
][m], C = [
|
|
2135
2135
|
w.x,
|
|
2136
2136
|
w.y,
|
|
2137
2137
|
w.z
|
|
2138
2138
|
][b];
|
|
2139
|
-
y[
|
|
2139
|
+
y[m][b] -= v * S * C;
|
|
2140
2140
|
}
|
|
2141
2141
|
}
|
|
2142
2142
|
const p = new h();
|
|
2143
|
-
for (let g = 0; g <
|
|
2144
|
-
p.divideScalar(
|
|
2145
|
-
const
|
|
2143
|
+
for (let g = 0; g < n; g++) p.x += r.getX(g), p.y += r.getY(g), p.z += r.getZ(g);
|
|
2144
|
+
p.divideScalar(n);
|
|
2145
|
+
const x = [
|
|
2146
2146
|
0,
|
|
2147
2147
|
0,
|
|
2148
2148
|
0
|
|
2149
2149
|
];
|
|
2150
2150
|
for (let g = 0; g < 3; g++) {
|
|
2151
|
-
let w = 1 / 0,
|
|
2152
|
-
const
|
|
2153
|
-
for (let b = 0; b <
|
|
2154
|
-
const S =
|
|
2155
|
-
|
|
2151
|
+
let w = 1 / 0, v = -1 / 0;
|
|
2152
|
+
const m = o[g];
|
|
2153
|
+
for (let b = 0; b < n; b++) {
|
|
2154
|
+
const S = r.getX(b) - p.x, C = r.getY(b) - p.y, M = r.getZ(b) - p.z, P = S * m.x + C * m.y + M * m.z;
|
|
2155
|
+
P < w && (w = P), P > v && (v = P);
|
|
2156
2156
|
}
|
|
2157
|
-
|
|
2157
|
+
x[g] = (v - w) / 2;
|
|
2158
2158
|
}
|
|
2159
2159
|
return {
|
|
2160
|
-
axes:
|
|
2160
|
+
axes: o,
|
|
2161
2161
|
eigenvalues: f,
|
|
2162
2162
|
center: p,
|
|
2163
|
-
halfExtents:
|
|
2163
|
+
halfExtents: x
|
|
2164
2164
|
};
|
|
2165
2165
|
}
|
|
2166
2166
|
function Kn({ pca: e }) {
|
|
2167
2167
|
return d("group", {
|
|
2168
|
-
children: e.axes.map((
|
|
2169
|
-
const t = e.center.clone().addScaledVector(
|
|
2168
|
+
children: e.axes.map((r, n) => {
|
|
2169
|
+
const t = e.center.clone().addScaledVector(r, e.halfExtents[n]), i = e.center.clone().addScaledVector(r, -e.halfExtents[n]);
|
|
2170
2170
|
return d(ge, {
|
|
2171
2171
|
points: [
|
|
2172
|
-
|
|
2172
|
+
i,
|
|
2173
2173
|
t
|
|
2174
2174
|
],
|
|
2175
|
-
color: Zn[
|
|
2175
|
+
color: Zn[n],
|
|
2176
2176
|
lineWidth: 2
|
|
2177
|
-
},
|
|
2177
|
+
}, n);
|
|
2178
2178
|
})
|
|
2179
2179
|
});
|
|
2180
2180
|
}
|
|
2181
2181
|
function Un({ pca: e }) {
|
|
2182
|
-
const
|
|
2183
|
-
const { center:
|
|
2184
|
-
for (let u = -1; u <= 1; u += 2) for (let
|
|
2182
|
+
const r = de(() => {
|
|
2183
|
+
const { center: n, axes: t, halfExtents: i } = e, a = [];
|
|
2184
|
+
for (let u = -1; u <= 1; u += 2) for (let s = -1; s <= 1; s += 2) for (let l = -1; l <= 1; l += 2) a.push(n.clone().addScaledVector(t[0], u * i[0]).addScaledVector(t[1], s * i[1]).addScaledVector(t[2], l * i[2]));
|
|
2185
2185
|
return [
|
|
2186
2186
|
[
|
|
2187
2187
|
0,
|
|
@@ -2231,16 +2231,16 @@ let __tla = (async () => {
|
|
|
2231
2231
|
3,
|
|
2232
2232
|
7
|
|
2233
2233
|
]
|
|
2234
|
-
].map(([u,
|
|
2234
|
+
].map(([u, s]) => [
|
|
2235
2235
|
a[u],
|
|
2236
|
-
a[
|
|
2236
|
+
a[s]
|
|
2237
2237
|
]);
|
|
2238
2238
|
}, [
|
|
2239
2239
|
e
|
|
2240
2240
|
]);
|
|
2241
2241
|
return d("group", {
|
|
2242
|
-
children:
|
|
2243
|
-
points:
|
|
2242
|
+
children: r.map((n, t) => d(ge, {
|
|
2243
|
+
points: n,
|
|
2244
2244
|
color: "#ffaa00",
|
|
2245
2245
|
lineWidth: 1,
|
|
2246
2246
|
transparent: true,
|
|
@@ -2248,24 +2248,24 @@ let __tla = (async () => {
|
|
|
2248
2248
|
}, t))
|
|
2249
2249
|
});
|
|
2250
2250
|
}
|
|
2251
|
-
function Qn({ redPoint: e, greenPoint:
|
|
2252
|
-
const
|
|
2251
|
+
function Qn({ redPoint: e, greenPoint: r }) {
|
|
2252
|
+
const n = de(() => new h().subVectors(r, e).normalize(), [
|
|
2253
2253
|
e,
|
|
2254
|
-
|
|
2254
|
+
r
|
|
2255
2255
|
]), t = de(() => {
|
|
2256
|
-
const a =
|
|
2256
|
+
const a = n.dot(new h(0, 1, 0));
|
|
2257
2257
|
return Math.acos(Math.min(1, Math.abs(a))) * 180 / Math.PI;
|
|
2258
2258
|
}, [
|
|
2259
|
-
|
|
2260
|
-
]),
|
|
2259
|
+
n
|
|
2260
|
+
]), i = t < 1 ? "#44ff44" : t < 5 ? "#ffcc00" : "#ff4444";
|
|
2261
2261
|
return W("group", {
|
|
2262
2262
|
children: [
|
|
2263
2263
|
d(ge, {
|
|
2264
2264
|
points: [
|
|
2265
2265
|
e,
|
|
2266
|
-
|
|
2266
|
+
r
|
|
2267
2267
|
],
|
|
2268
|
-
color:
|
|
2268
|
+
color: i,
|
|
2269
2269
|
lineWidth: 3
|
|
2270
2270
|
}),
|
|
2271
2271
|
W("mesh", {
|
|
@@ -2284,7 +2284,7 @@ let __tla = (async () => {
|
|
|
2284
2284
|
]
|
|
2285
2285
|
}),
|
|
2286
2286
|
W("mesh", {
|
|
2287
|
-
position:
|
|
2287
|
+
position: r,
|
|
2288
2288
|
children: [
|
|
2289
2289
|
d("sphereGeometry", {
|
|
2290
2290
|
args: [
|
|
@@ -2301,33 +2301,33 @@ let __tla = (async () => {
|
|
|
2301
2301
|
]
|
|
2302
2302
|
});
|
|
2303
2303
|
}
|
|
2304
|
-
function qn({ geometry: e, redY:
|
|
2304
|
+
function qn({ geometry: e, redY: r, greenY: n, modelSize: t }) {
|
|
2305
2305
|
const a = t * 0.15, c = de(() => {
|
|
2306
2306
|
const u = [];
|
|
2307
|
-
let
|
|
2308
|
-
const
|
|
2309
|
-
for (;
|
|
2310
|
-
const
|
|
2307
|
+
let s = n - 10;
|
|
2308
|
+
const l = new h(0, 1, 0);
|
|
2309
|
+
for (; s > r; ) {
|
|
2310
|
+
const o = Math.min(s, n), f = Math.max(s, n), y = rt(e, o, f);
|
|
2311
2311
|
if (y) {
|
|
2312
|
-
const p = y.dot(
|
|
2312
|
+
const p = y.dot(l), x = Math.acos(Math.min(1, Math.abs(p))) * 180 / Math.PI;
|
|
2313
2313
|
u.push({
|
|
2314
2314
|
axis: y,
|
|
2315
|
-
regionMin:
|
|
2315
|
+
regionMin: o,
|
|
2316
2316
|
regionMax: f,
|
|
2317
|
-
angleDeg:
|
|
2317
|
+
angleDeg: x
|
|
2318
2318
|
});
|
|
2319
2319
|
}
|
|
2320
|
-
|
|
2320
|
+
s -= 10;
|
|
2321
2321
|
}
|
|
2322
2322
|
return u;
|
|
2323
2323
|
}, [
|
|
2324
2324
|
e,
|
|
2325
|
-
|
|
2326
|
-
|
|
2325
|
+
r,
|
|
2326
|
+
n
|
|
2327
2327
|
]);
|
|
2328
2328
|
return d("group", {
|
|
2329
|
-
children: c.map((u,
|
|
2330
|
-
const
|
|
2329
|
+
children: c.map((u, s) => {
|
|
2330
|
+
const l = (u.regionMin + u.regionMax) / 2, o = new h(0, l, 0), f = o.clone().addScaledVector(u.axis, a), y = o.clone().addScaledVector(u.axis, -a), p = s / Math.max(1, c.length - 1), x = u.angleDeg < 0.5 ? `hsl(${120 - p * 120}, 80%, 60%)` : `hsl(${40 - u.angleDeg * 2}, 90%, 55%)`;
|
|
2331
2331
|
return W("group", {
|
|
2332
2332
|
children: [
|
|
2333
2333
|
d(ge, {
|
|
@@ -2335,7 +2335,7 @@ let __tla = (async () => {
|
|
|
2335
2335
|
y,
|
|
2336
2336
|
f
|
|
2337
2337
|
],
|
|
2338
|
-
color:
|
|
2338
|
+
color: x,
|
|
2339
2339
|
lineWidth: 1.5,
|
|
2340
2340
|
transparent: true,
|
|
2341
2341
|
opacity: 0.7
|
|
@@ -2345,19 +2345,19 @@ let __tla = (async () => {
|
|
|
2345
2345
|
new h(-a * 0.3, u.regionMin, 0),
|
|
2346
2346
|
new h(a * 0.3, u.regionMin, 0)
|
|
2347
2347
|
],
|
|
2348
|
-
color:
|
|
2348
|
+
color: x,
|
|
2349
2349
|
lineWidth: 0.5,
|
|
2350
2350
|
transparent: true,
|
|
2351
2351
|
opacity: 0.3
|
|
2352
2352
|
})
|
|
2353
2353
|
]
|
|
2354
|
-
},
|
|
2354
|
+
}, s);
|
|
2355
2355
|
})
|
|
2356
2356
|
});
|
|
2357
2357
|
}
|
|
2358
|
-
function Jn({ geometry: e, redY:
|
|
2359
|
-
const
|
|
2360
|
-
const f = rt(e,
|
|
2358
|
+
function Jn({ geometry: e, redY: r, greenY: n, modelSize: t }) {
|
|
2359
|
+
const i = de(() => {
|
|
2360
|
+
const f = rt(e, r, n);
|
|
2361
2361
|
if (!f) return null;
|
|
2362
2362
|
const y = f.dot(new h(0, 1, 0)), p = Math.acos(Math.min(1, Math.abs(y))) * 180 / Math.PI;
|
|
2363
2363
|
return {
|
|
@@ -2366,18 +2366,18 @@ let __tla = (async () => {
|
|
|
2366
2366
|
};
|
|
2367
2367
|
}, [
|
|
2368
2368
|
e,
|
|
2369
|
-
|
|
2370
|
-
|
|
2369
|
+
r,
|
|
2370
|
+
n
|
|
2371
2371
|
]);
|
|
2372
|
-
if (!
|
|
2373
|
-
const a = (
|
|
2372
|
+
if (!i) return null;
|
|
2373
|
+
const a = (r + n) / 2, c = new h(0, a, 0), u = t * 0.4, s = c.clone().addScaledVector(i.axis, u), l = c.clone().addScaledVector(i.axis, -u), o = i.angleDeg < 0.5 ? "#00ffff" : i.angleDeg < 2 ? "#ffcc00" : "#ff6600";
|
|
2374
2374
|
return d("group", {
|
|
2375
2375
|
children: d(ge, {
|
|
2376
2376
|
points: [
|
|
2377
|
-
|
|
2378
|
-
|
|
2377
|
+
l,
|
|
2378
|
+
s
|
|
2379
2379
|
],
|
|
2380
|
-
color:
|
|
2380
|
+
color: o,
|
|
2381
2381
|
lineWidth: 3,
|
|
2382
2382
|
dashed: true,
|
|
2383
2383
|
dashSize: 3,
|
|
@@ -2385,12 +2385,12 @@ let __tla = (async () => {
|
|
|
2385
2385
|
})
|
|
2386
2386
|
});
|
|
2387
2387
|
}
|
|
2388
|
-
function eo({ pca: e, modelSize:
|
|
2389
|
-
const
|
|
2388
|
+
function eo({ pca: e, modelSize: r }) {
|
|
2389
|
+
const n = e.axes[0], t = r * 0.6, i = e.center.clone().addScaledVector(n, t), a = e.center.clone().addScaledVector(n, -t);
|
|
2390
2390
|
return d(ge, {
|
|
2391
2391
|
points: [
|
|
2392
2392
|
a,
|
|
2393
|
-
|
|
2393
|
+
i
|
|
2394
2394
|
],
|
|
2395
2395
|
color: "#ff8800",
|
|
2396
2396
|
lineWidth: 2,
|
|
@@ -2399,22 +2399,22 @@ let __tla = (async () => {
|
|
|
2399
2399
|
gapSize: 2
|
|
2400
2400
|
});
|
|
2401
2401
|
}
|
|
2402
|
-
function to({ geometry: e, redY:
|
|
2403
|
-
const
|
|
2404
|
-
const
|
|
2402
|
+
function to({ geometry: e, redY: r, greenY: n, modelSize: t }) {
|
|
2403
|
+
const i = de(() => {
|
|
2404
|
+
const l = ot(e), o = new h(0, 1, 0), f = 5;
|
|
2405
2405
|
e.computeBoundingBox();
|
|
2406
2406
|
const y = e.boundingBox.max.y, p = [];
|
|
2407
|
-
for (let
|
|
2408
|
-
const M = pt(
|
|
2407
|
+
for (let C = r + f; C < y; C += f) {
|
|
2408
|
+
const M = pt(l, e, new h(0, C, 0), o);
|
|
2409
2409
|
M > 0 && p.push({
|
|
2410
|
-
y:
|
|
2410
|
+
y: C,
|
|
2411
2411
|
circ: M
|
|
2412
2412
|
});
|
|
2413
2413
|
}
|
|
2414
2414
|
if (p.length < 5) return null;
|
|
2415
|
-
const
|
|
2416
|
-
if (
|
|
2417
|
-
const
|
|
2415
|
+
const x = n - r, g = r + x * 0.3, w = r + x * 0.7, v = p.filter((C) => C.y >= g && C.y <= w);
|
|
2416
|
+
if (v.length < 3) return null;
|
|
2417
|
+
const m = v.map((C) => C.circ).sort((C, M) => C - M), b = m[Math.floor(m.length / 2)], S = Math.max(...p.map((C) => C.circ));
|
|
2418
2418
|
return {
|
|
2419
2419
|
circumferences: p,
|
|
2420
2420
|
baseline: b,
|
|
@@ -2422,19 +2422,19 @@ let __tla = (async () => {
|
|
|
2422
2422
|
};
|
|
2423
2423
|
}, [
|
|
2424
2424
|
e,
|
|
2425
|
-
|
|
2426
|
-
|
|
2425
|
+
r,
|
|
2426
|
+
n
|
|
2427
2427
|
]);
|
|
2428
|
-
if (!
|
|
2429
|
-
const { circumferences: a, baseline: c, maxCirc: u } =
|
|
2428
|
+
if (!i) return null;
|
|
2429
|
+
const { circumferences: a, baseline: c, maxCirc: u } = i, s = t * 0.3 / u;
|
|
2430
2430
|
return W("group", {
|
|
2431
2431
|
children: [
|
|
2432
|
-
a.map(({ y:
|
|
2433
|
-
const y =
|
|
2432
|
+
a.map(({ y: l, circ: o }, f) => {
|
|
2433
|
+
const y = o / c, p = y > 1.6 ? "#ff4444" : y > 1.3 ? "#ffcc00" : "#22cc66", x = o * s;
|
|
2434
2434
|
return d(ge, {
|
|
2435
2435
|
points: [
|
|
2436
|
-
new h(-
|
|
2437
|
-
new h(
|
|
2436
|
+
new h(-x, l, 0),
|
|
2437
|
+
new h(x, l, 0)
|
|
2438
2438
|
],
|
|
2439
2439
|
color: p,
|
|
2440
2440
|
lineWidth: 1.5,
|
|
@@ -2443,13 +2443,13 @@ let __tla = (async () => {
|
|
|
2443
2443
|
}, f);
|
|
2444
2444
|
}),
|
|
2445
2445
|
(() => {
|
|
2446
|
-
const
|
|
2446
|
+
const l = c * 1.6 * s, o = a[0].y, f = a[a.length - 1].y;
|
|
2447
2447
|
return W(He, {
|
|
2448
2448
|
children: [
|
|
2449
2449
|
d(ge, {
|
|
2450
2450
|
points: [
|
|
2451
|
-
new h(-
|
|
2452
|
-
new h(-
|
|
2451
|
+
new h(-l, o, 0),
|
|
2452
|
+
new h(-l, f, 0)
|
|
2453
2453
|
],
|
|
2454
2454
|
color: "#ff4444",
|
|
2455
2455
|
lineWidth: 1,
|
|
@@ -2461,8 +2461,8 @@ let __tla = (async () => {
|
|
|
2461
2461
|
}),
|
|
2462
2462
|
d(ge, {
|
|
2463
2463
|
points: [
|
|
2464
|
-
new h(
|
|
2465
|
-
new h(
|
|
2464
|
+
new h(l, o, 0),
|
|
2465
|
+
new h(l, f, 0)
|
|
2466
2466
|
],
|
|
2467
2467
|
color: "#ff4444",
|
|
2468
2468
|
lineWidth: 1,
|
|
@@ -2480,19 +2480,19 @@ let __tla = (async () => {
|
|
|
2480
2480
|
}
|
|
2481
2481
|
function no({ componentDebug: e }) {
|
|
2482
2482
|
return d("group", {
|
|
2483
|
-
children: e.geometries.map((
|
|
2484
|
-
const t = e.colors[
|
|
2485
|
-
|
|
2483
|
+
children: e.geometries.map((r, n) => {
|
|
2484
|
+
const t = e.colors[n] ?? "#888888", i = n === e.innerIdx;
|
|
2485
|
+
r.computeBoundingBox();
|
|
2486
2486
|
const a = new h();
|
|
2487
|
-
return
|
|
2487
|
+
return r.boundingBox.getCenter(a), W("group", {
|
|
2488
2488
|
children: [
|
|
2489
2489
|
d("mesh", {
|
|
2490
|
-
geometry:
|
|
2491
|
-
renderOrder:
|
|
2490
|
+
geometry: r,
|
|
2491
|
+
renderOrder: i ? 2 : 1,
|
|
2492
2492
|
children: d("meshStandardMaterial", {
|
|
2493
2493
|
color: t,
|
|
2494
2494
|
transparent: true,
|
|
2495
|
-
opacity:
|
|
2495
|
+
opacity: i ? 0.5 : 0.2,
|
|
2496
2496
|
side: J.DoubleSide,
|
|
2497
2497
|
depthWrite: false,
|
|
2498
2498
|
polygonOffset: true,
|
|
@@ -2501,13 +2501,13 @@ let __tla = (async () => {
|
|
|
2501
2501
|
})
|
|
2502
2502
|
}),
|
|
2503
2503
|
d("mesh", {
|
|
2504
|
-
geometry:
|
|
2505
|
-
renderOrder:
|
|
2504
|
+
geometry: r,
|
|
2505
|
+
renderOrder: i ? 2 : 1,
|
|
2506
2506
|
children: d("meshBasicMaterial", {
|
|
2507
2507
|
color: t,
|
|
2508
2508
|
wireframe: true,
|
|
2509
2509
|
transparent: true,
|
|
2510
|
-
opacity:
|
|
2510
|
+
opacity: i ? 0.4 : 0.15
|
|
2511
2511
|
})
|
|
2512
2512
|
}),
|
|
2513
2513
|
d("group", {
|
|
@@ -2530,60 +2530,60 @@ let __tla = (async () => {
|
|
|
2530
2530
|
fontSize: 11,
|
|
2531
2531
|
color: t,
|
|
2532
2532
|
fontFamily: "monospace",
|
|
2533
|
-
fontWeight:
|
|
2533
|
+
fontWeight: i ? 700 : 400
|
|
2534
2534
|
},
|
|
2535
|
-
children: e.labels[
|
|
2535
|
+
children: e.labels[n]
|
|
2536
2536
|
})
|
|
2537
2537
|
})
|
|
2538
2538
|
})
|
|
2539
2539
|
})
|
|
2540
2540
|
]
|
|
2541
|
-
},
|
|
2541
|
+
}, n);
|
|
2542
2542
|
})
|
|
2543
2543
|
});
|
|
2544
2544
|
}
|
|
2545
|
-
function oo({ mesh: e, layers:
|
|
2546
|
-
const
|
|
2547
|
-
|
|
2548
|
-
]), c = de(() => !
|
|
2549
|
-
red: new h(
|
|
2550
|
-
green: new h(
|
|
2545
|
+
function oo({ mesh: e, layers: r, landmarkPoints: n, componentDebug: t }) {
|
|
2546
|
+
const i = e.geometry, a = de(() => i.getAttribute("position") ? Ot(i) : null, [
|
|
2547
|
+
i
|
|
2548
|
+
]), c = de(() => !n || n.length < 2 ? null : {
|
|
2549
|
+
red: new h(n[0].position.x, n[0].position.y, n[0].position.z),
|
|
2550
|
+
green: new h(n[1].position.x, n[1].position.y, n[1].position.z)
|
|
2551
2551
|
}, [
|
|
2552
|
-
|
|
2552
|
+
n
|
|
2553
2553
|
]);
|
|
2554
2554
|
return W("group", {
|
|
2555
2555
|
children: [
|
|
2556
|
-
|
|
2556
|
+
r.pcaAxes && a && d(Kn, {
|
|
2557
2557
|
pca: a
|
|
2558
2558
|
}),
|
|
2559
|
-
|
|
2559
|
+
r.obb && a && d(Un, {
|
|
2560
2560
|
pca: a
|
|
2561
2561
|
}),
|
|
2562
|
-
|
|
2562
|
+
r.obbAxis && a && d(eo, {
|
|
2563
2563
|
pca: a,
|
|
2564
2564
|
modelSize: a.halfExtents[0] ? Math.max(...a.halfExtents) * 2 : 100
|
|
2565
2565
|
}),
|
|
2566
|
-
|
|
2566
|
+
r.shellComponents && t && d(no, {
|
|
2567
2567
|
componentDebug: t
|
|
2568
2568
|
}),
|
|
2569
|
-
|
|
2570
|
-
geometry:
|
|
2569
|
+
r.circumferenceScan && c && d(to, {
|
|
2570
|
+
geometry: i,
|
|
2571
2571
|
redY: c.red.y,
|
|
2572
2572
|
greenY: c.green.y,
|
|
2573
2573
|
modelSize: (a == null ? void 0 : a.halfExtents[0]) ? Math.max(...a.halfExtents) * 2 : 100
|
|
2574
2574
|
}),
|
|
2575
|
-
|
|
2575
|
+
r.landmarkAxis && c && d(Qn, {
|
|
2576
2576
|
redPoint: c.red,
|
|
2577
2577
|
greenPoint: c.green
|
|
2578
2578
|
}),
|
|
2579
|
-
|
|
2580
|
-
geometry:
|
|
2579
|
+
r.iterativePCA && c && d(qn, {
|
|
2580
|
+
geometry: i,
|
|
2581
2581
|
redY: c.red.y,
|
|
2582
2582
|
greenY: c.green.y,
|
|
2583
2583
|
modelSize: (a == null ? void 0 : a.halfExtents[0]) ? Math.max(...a.halfExtents) * 2 : 100
|
|
2584
2584
|
}),
|
|
2585
|
-
|
|
2586
|
-
geometry:
|
|
2585
|
+
r.fullRegionPCA && c && d(Jn, {
|
|
2586
|
+
geometry: i,
|
|
2587
2587
|
redY: c.red.y,
|
|
2588
2588
|
greenY: c.green.y,
|
|
2589
2589
|
modelSize: (a == null ? void 0 : a.halfExtents[0]) ? Math.max(...a.halfExtents) * 2 : 100
|
|
@@ -2592,22 +2592,22 @@ let __tla = (async () => {
|
|
|
2592
2592
|
});
|
|
2593
2593
|
}
|
|
2594
2594
|
function so({ mesh: e }) {
|
|
2595
|
-
const
|
|
2596
|
-
if (!
|
|
2597
|
-
const a = Ot(
|
|
2595
|
+
const r = e.geometry, n = de(() => {
|
|
2596
|
+
if (!r.getAttribute("position")) return null;
|
|
2597
|
+
const a = Ot(r), c = a.axes[0], u = a.halfExtents[0] * 1.3;
|
|
2598
2598
|
return {
|
|
2599
2599
|
axis: c,
|
|
2600
2600
|
center: a.center,
|
|
2601
2601
|
halfLen: u
|
|
2602
2602
|
};
|
|
2603
2603
|
}, [
|
|
2604
|
-
|
|
2604
|
+
r
|
|
2605
2605
|
]);
|
|
2606
|
-
if (!
|
|
2607
|
-
const t =
|
|
2606
|
+
if (!n) return null;
|
|
2607
|
+
const t = n.center.clone().addScaledVector(n.axis, n.halfLen), i = n.center.clone().addScaledVector(n.axis, -n.halfLen);
|
|
2608
2608
|
return d(ge, {
|
|
2609
2609
|
points: [
|
|
2610
|
-
|
|
2610
|
+
i,
|
|
2611
2611
|
t
|
|
2612
2612
|
],
|
|
2613
2613
|
color: "#666",
|
|
@@ -2673,7 +2673,7 @@ let __tla = (async () => {
|
|
|
2673
2673
|
], ro = [
|
|
2674
2674
|
...new Set($t.map((e) => e.group))
|
|
2675
2675
|
];
|
|
2676
|
-
function io({ layers: e, onToggleLayer:
|
|
2676
|
+
function io({ layers: e, onToggleLayer: r }) {
|
|
2677
2677
|
return W("div", {
|
|
2678
2678
|
style: {
|
|
2679
2679
|
position: "absolute",
|
|
@@ -2702,7 +2702,7 @@ let __tla = (async () => {
|
|
|
2702
2702
|
},
|
|
2703
2703
|
children: "Debug Layers"
|
|
2704
2704
|
}),
|
|
2705
|
-
ro.map((
|
|
2705
|
+
ro.map((n) => W("div", {
|
|
2706
2706
|
children: [
|
|
2707
2707
|
d("div", {
|
|
2708
2708
|
style: {
|
|
@@ -2714,9 +2714,9 @@ let __tla = (async () => {
|
|
|
2714
2714
|
marginTop: 6,
|
|
2715
2715
|
marginBottom: 4
|
|
2716
2716
|
},
|
|
2717
|
-
children:
|
|
2717
|
+
children: n
|
|
2718
2718
|
}),
|
|
2719
|
-
$t.filter((t) => t.group ===
|
|
2719
|
+
$t.filter((t) => t.group === n).map(({ key: t, label: i, color: a }) => W("label", {
|
|
2720
2720
|
style: {
|
|
2721
2721
|
display: "flex",
|
|
2722
2722
|
alignItems: "center",
|
|
@@ -2729,7 +2729,7 @@ let __tla = (async () => {
|
|
|
2729
2729
|
d("input", {
|
|
2730
2730
|
type: "checkbox",
|
|
2731
2731
|
checked: e[t],
|
|
2732
|
-
onChange: () =>
|
|
2732
|
+
onChange: () => r(t),
|
|
2733
2733
|
style: {
|
|
2734
2734
|
accentColor: a,
|
|
2735
2735
|
width: 14,
|
|
@@ -2751,17 +2751,17 @@ let __tla = (async () => {
|
|
|
2751
2751
|
style: {
|
|
2752
2752
|
opacity: e[t] ? 1 : 0.5
|
|
2753
2753
|
},
|
|
2754
|
-
children:
|
|
2754
|
+
children: i
|
|
2755
2755
|
})
|
|
2756
2756
|
]
|
|
2757
2757
|
}, t))
|
|
2758
2758
|
]
|
|
2759
|
-
},
|
|
2759
|
+
}, n))
|
|
2760
2760
|
]
|
|
2761
2761
|
});
|
|
2762
2762
|
}
|
|
2763
|
-
const lo = ({ config: e, spacingType:
|
|
2764
|
-
const [
|
|
2763
|
+
const lo = ({ config: e, spacingType: r, scanUrl: n, formMeasurements: t, onComplete: i, isDebugUser: a = false, onAnalyticsEvent: c, wasmModule: u }) => {
|
|
2764
|
+
const [s, l] = Q(null), [o, f] = Q(0), [y, p] = Q(false), [x, g] = Q(false), [w, v] = Q(""), [m, b] = Q("3D"), [S, C] = Q(r === "AK" ? 2 : 1), [M, P] = Q(false), [L, H] = Q(null), [O, $] = Q(null), [R, Y] = Q(r ?? null), [j, ne] = Q("mm"), [oe, le] = Q(false), [ee, D] = Q(""), [z, F] = Q(false), [V, B] = Q(false), [T, E] = Q(false), [N, X] = Q(false), [q, ie] = Q(false), [se, A] = Q([]), [I, k] = Q(null), [G, U] = Q(null), [re, Le] = Q(null), [me, ae] = Q(null), [xe, Re] = Q(false), [pe, we] = Q(Xn), [he, Ge] = Q(false), [fe, je] = Q(null), [Pe, ye] = Q("obj"), [Te, Me] = Q(false), [Ae, De] = Q({}), [ze, Ee] = Q(t), [ke, Ue] = Q(true), [mt] = Q("#c8c8c8"), [Nt] = Q(1), [Xe, Ht] = Q(false), lt = Ie(null), { landmarkPoints: ce, clearLandmarkPoints: Yt, addLandmarkPoint: xt, removeLandmarkPoint: yt, updateLandmarkPositions: bt, setAligned: wt, isAligned: be, setCut: St, isCut: Gt } = gt(), at = S * We;
|
|
2765
2765
|
Se(() => {
|
|
2766
2766
|
t && Ee(t);
|
|
2767
2767
|
}, [
|
|
@@ -2779,7 +2779,7 @@ let __tla = (async () => {
|
|
|
2779
2779
|
c("dimensions_calculated", {
|
|
2780
2780
|
spacing_type: R,
|
|
2781
2781
|
source_unit: "mm",
|
|
2782
|
-
file_format:
|
|
2782
|
+
file_format: Pe,
|
|
2783
2783
|
measurement_source: "scan_derived",
|
|
2784
2784
|
is_double_wall: T,
|
|
2785
2785
|
is_unit_converted: false,
|
|
@@ -2809,7 +2809,7 @@ let __tla = (async () => {
|
|
|
2809
2809
|
color: 8947848,
|
|
2810
2810
|
side: J.DoubleSide
|
|
2811
2811
|
}));
|
|
2812
|
-
|
|
2812
|
+
l(ve), F(K), B(true);
|
|
2813
2813
|
}, []), qe = Fe(async (_, K) => {
|
|
2814
2814
|
ae(null);
|
|
2815
2815
|
const ue = K.toLowerCase(), Z = ue.endsWith(".stl");
|
|
@@ -2817,10 +2817,10 @@ let __tla = (async () => {
|
|
|
2817
2817
|
ae("Unsupported file format. Please use OBJ or STL.");
|
|
2818
2818
|
return;
|
|
2819
2819
|
}
|
|
2820
|
-
ye(Z ? "stl" : "obj"), g(true),
|
|
2820
|
+
ye(Z ? "stl" : "obj"), g(true), v("Processing file...");
|
|
2821
2821
|
try {
|
|
2822
2822
|
let te;
|
|
2823
|
-
if (Z) if (
|
|
2823
|
+
if (Z) if (v("Converting STL..."), _ instanceof ArrayBuffer) {
|
|
2824
2824
|
const Ce = new Blob([
|
|
2825
2825
|
_
|
|
2826
2826
|
]), Ve = new File([
|
|
@@ -2836,36 +2836,36 @@ let __tla = (async () => {
|
|
|
2836
2836
|
te = await ft(Ve);
|
|
2837
2837
|
}
|
|
2838
2838
|
else te = typeof _ == "string" ? _ : new TextDecoder().decode(_);
|
|
2839
|
-
const ve = lt.current ? await bn(te, lt.current,
|
|
2840
|
-
if (ve) e.showAmputationModal && !
|
|
2839
|
+
const ve = lt.current ? await bn(te, lt.current, v) : null;
|
|
2840
|
+
if (ve) e.showAmputationModal && !r ? (H(ve), P(true)) : (Qe(ve.geometry, ve.wasScaled), ve.innerShellExtracted && (X(true), E(true)), ve.componentDebug && $(ve.componentDebug));
|
|
2841
2841
|
else {
|
|
2842
|
-
|
|
2842
|
+
v("Using fallback loader...");
|
|
2843
2843
|
const Ce = wn(te);
|
|
2844
|
-
Ce ? e.showAmputationModal && !
|
|
2844
|
+
Ce ? e.showAmputationModal && !r ? (H({
|
|
2845
2845
|
geometry: Ce,
|
|
2846
2846
|
wasScaled: false,
|
|
2847
2847
|
innerShellExtracted: false
|
|
2848
|
-
}),
|
|
2848
|
+
}), P(true)) : Qe(Ce, false) : ae("Failed to parse the mesh.");
|
|
2849
2849
|
}
|
|
2850
2850
|
} catch (te) {
|
|
2851
2851
|
ae(te instanceof Error ? te.message : "Failed to process the mesh file.");
|
|
2852
2852
|
} finally {
|
|
2853
|
-
g(false),
|
|
2853
|
+
g(false), v("");
|
|
2854
2854
|
}
|
|
2855
2855
|
}, [
|
|
2856
2856
|
Xe,
|
|
2857
2857
|
e.showAmputationModal,
|
|
2858
|
-
|
|
2858
|
+
r,
|
|
2859
2859
|
Qe
|
|
2860
2860
|
]);
|
|
2861
2861
|
Se(() => {
|
|
2862
|
-
if (!
|
|
2862
|
+
if (!n || !Xe) return;
|
|
2863
2863
|
(async () => {
|
|
2864
|
-
g(true),
|
|
2864
|
+
g(true), v("Downloading scan...");
|
|
2865
2865
|
try {
|
|
2866
|
-
const K = await fetch(
|
|
2866
|
+
const K = await fetch(n);
|
|
2867
2867
|
if (!K.ok) throw new Error(`Failed to download scan: ${K.status}`);
|
|
2868
|
-
const Z = new URL(
|
|
2868
|
+
const Z = new URL(n).pathname.split("/").pop() || "scan.obj";
|
|
2869
2869
|
if (Z.toLowerCase().endsWith(".stl")) {
|
|
2870
2870
|
const te = await K.arrayBuffer();
|
|
2871
2871
|
await qe(te, Z);
|
|
@@ -2874,11 +2874,11 @@ let __tla = (async () => {
|
|
|
2874
2874
|
await qe(te, Z);
|
|
2875
2875
|
}
|
|
2876
2876
|
} catch (K) {
|
|
2877
|
-
ae(K instanceof Error ? K.message : "Failed to load scan from URL."), g(false),
|
|
2877
|
+
ae(K instanceof Error ? K.message : "Failed to load scan from URL."), g(false), v("");
|
|
2878
2878
|
}
|
|
2879
2879
|
})();
|
|
2880
2880
|
}, [
|
|
2881
|
-
|
|
2881
|
+
n,
|
|
2882
2882
|
Xe
|
|
2883
2883
|
]);
|
|
2884
2884
|
const Xt = Fe((_) => {
|
|
@@ -2898,12 +2898,12 @@ let __tla = (async () => {
|
|
|
2898
2898
|
return;
|
|
2899
2899
|
}
|
|
2900
2900
|
if (ue.endsWith(".stl")) {
|
|
2901
|
-
ye("stl"), g(true),
|
|
2901
|
+
ye("stl"), g(true), v("Converting STL...");
|
|
2902
2902
|
try {
|
|
2903
2903
|
const Z = await ft(K);
|
|
2904
2904
|
await qe(Z, K.name);
|
|
2905
2905
|
} catch (Z) {
|
|
2906
|
-
ae(Z instanceof Error ? Z.message : "Failed to process STL file."), g(false),
|
|
2906
|
+
ae(Z instanceof Error ? Z.message : "Failed to process STL file."), g(false), v("");
|
|
2907
2907
|
}
|
|
2908
2908
|
} else {
|
|
2909
2909
|
const Z = await K.text();
|
|
@@ -2913,19 +2913,19 @@ let __tla = (async () => {
|
|
|
2913
2913
|
Xe,
|
|
2914
2914
|
qe
|
|
2915
2915
|
]), Ut = Fe((_) => {
|
|
2916
|
-
Y(_),
|
|
2916
|
+
Y(_), C(_ === "AK" ? 2 : 1), P(false), L && (Qe(L.geometry, L.wasScaled), L.innerShellExtracted && (X(true), E(true)), L.componentDebug && $(L.componentDebug), H(null)), c == null ? void 0 : c("file_loaded", {
|
|
2917
2917
|
spacing_type: _,
|
|
2918
|
-
file_format:
|
|
2919
|
-
is_double_wall: (
|
|
2918
|
+
file_format: Pe,
|
|
2919
|
+
is_double_wall: (L == null ? void 0 : L.innerShellExtracted) ?? false
|
|
2920
2920
|
});
|
|
2921
2921
|
}, [
|
|
2922
|
-
|
|
2922
|
+
L,
|
|
2923
2923
|
Qe,
|
|
2924
2924
|
c,
|
|
2925
|
-
|
|
2925
|
+
Pe
|
|
2926
2926
|
]), Qt = Fe(() => {
|
|
2927
|
-
!
|
|
2928
|
-
In(
|
|
2927
|
+
!s || ce.length < 2 || (le(true), D("Please wait..."), setTimeout(() => {
|
|
2928
|
+
In(s, ce, at, {
|
|
2929
2929
|
onStatus: D,
|
|
2930
2930
|
addLandmarkPoint: xt,
|
|
2931
2931
|
removeLandmarkPoint: yt,
|
|
@@ -2933,19 +2933,19 @@ let __tla = (async () => {
|
|
|
2933
2933
|
setAligned: wt,
|
|
2934
2934
|
setCut: St,
|
|
2935
2935
|
setModelSize: f,
|
|
2936
|
-
setOriginalEndY:
|
|
2936
|
+
setOriginalEndY: Le,
|
|
2937
2937
|
setAdjustedStartY: k,
|
|
2938
2938
|
setAdjustedEndY: U,
|
|
2939
2939
|
setError: ae,
|
|
2940
2940
|
setDoubleShell: (_) => {
|
|
2941
2941
|
E(_), ie(true);
|
|
2942
2942
|
},
|
|
2943
|
-
setClippedReferenceGeometry:
|
|
2944
|
-
skipDoubleShellDetection:
|
|
2943
|
+
setClippedReferenceGeometry: je,
|
|
2944
|
+
skipDoubleShellDetection: N
|
|
2945
2945
|
}), ct.current = false, le(false);
|
|
2946
2946
|
}, 50));
|
|
2947
2947
|
}, [
|
|
2948
|
-
|
|
2948
|
+
s,
|
|
2949
2949
|
ce,
|
|
2950
2950
|
bt,
|
|
2951
2951
|
wt,
|
|
@@ -2953,13 +2953,13 @@ let __tla = (async () => {
|
|
|
2953
2953
|
yt,
|
|
2954
2954
|
St,
|
|
2955
2955
|
at,
|
|
2956
|
-
|
|
2956
|
+
N
|
|
2957
2957
|
]), qt = Fe(() => {
|
|
2958
|
-
if (!
|
|
2958
|
+
if (!i || !s || se.length === 0 || !R) return;
|
|
2959
2959
|
let _ = 0, K = 0;
|
|
2960
2960
|
const ue = ce.length >= 3 ? Math.abs(ce[2].position.y - ce[1].position.y) : 0;
|
|
2961
2961
|
if (ce.length >= 2) {
|
|
2962
|
-
const Z =
|
|
2962
|
+
const Z = s.geometry, te = ce[1].position.y;
|
|
2963
2963
|
try {
|
|
2964
2964
|
const ve = ot(Z), Ce = Ze(ve, Z, te);
|
|
2965
2965
|
if (Ce.linePoints.length >= 2) {
|
|
@@ -2970,10 +2970,10 @@ let __tla = (async () => {
|
|
|
2970
2970
|
} catch {
|
|
2971
2971
|
}
|
|
2972
2972
|
}
|
|
2973
|
-
|
|
2973
|
+
i({
|
|
2974
2974
|
spacingType: R,
|
|
2975
2975
|
sourceUnit: "mm",
|
|
2976
|
-
fileFormat:
|
|
2976
|
+
fileFormat: Pe,
|
|
2977
2977
|
measurementSource: ze ? "form_provided" : "scan_derived",
|
|
2978
2978
|
isDoubleWall: T,
|
|
2979
2979
|
isUnitConverted: false,
|
|
@@ -2982,19 +2982,19 @@ let __tla = (async () => {
|
|
|
2982
2982
|
frontalHeight: ue,
|
|
2983
2983
|
transverseML: _,
|
|
2984
2984
|
transverseAP: K,
|
|
2985
|
-
scanUrl:
|
|
2985
|
+
scanUrl: n
|
|
2986
2986
|
});
|
|
2987
2987
|
}, [
|
|
2988
|
-
|
|
2989
|
-
|
|
2988
|
+
i,
|
|
2989
|
+
s,
|
|
2990
2990
|
se,
|
|
2991
2991
|
R,
|
|
2992
2992
|
ce,
|
|
2993
|
-
|
|
2993
|
+
Pe,
|
|
2994
2994
|
T,
|
|
2995
2995
|
ze,
|
|
2996
|
-
|
|
2997
|
-
]), Jt = be ? 4 :
|
|
2996
|
+
n
|
|
2997
|
+
]), Jt = be ? 4 : s ? ce.length === 0 ? 2 : 3 : 1, en = [
|
|
2998
2998
|
{
|
|
2999
2999
|
label: "Load File",
|
|
3000
3000
|
number: 1
|
|
@@ -3067,7 +3067,7 @@ let __tla = (async () => {
|
|
|
3067
3067
|
onDragLeave: e.showDragDrop ? Zt : void 0,
|
|
3068
3068
|
onDrop: e.showDragDrop ? Kt : void 0,
|
|
3069
3069
|
children: [
|
|
3070
|
-
e.showDragDrop && !
|
|
3070
|
+
e.showDragDrop && !s && !x && d("div", {
|
|
3071
3071
|
style: {
|
|
3072
3072
|
position: "absolute",
|
|
3073
3073
|
inset: 16,
|
|
@@ -3116,7 +3116,7 @@ let __tla = (async () => {
|
|
|
3116
3116
|
]
|
|
3117
3117
|
})
|
|
3118
3118
|
}),
|
|
3119
|
-
!e.showDragDrop && !
|
|
3119
|
+
!e.showDragDrop && !s && !x && !me && d("div", {
|
|
3120
3120
|
style: {
|
|
3121
3121
|
position: "absolute",
|
|
3122
3122
|
inset: 0,
|
|
@@ -3154,7 +3154,7 @@ let __tla = (async () => {
|
|
|
3154
3154
|
]
|
|
3155
3155
|
})
|
|
3156
3156
|
}),
|
|
3157
|
-
|
|
3157
|
+
s && !be && ce.length === 0 && W("div", {
|
|
3158
3158
|
style: {
|
|
3159
3159
|
position: "absolute",
|
|
3160
3160
|
top: 16,
|
|
@@ -3185,7 +3185,7 @@ let __tla = (async () => {
|
|
|
3185
3185
|
"Click mesh to set Origin"
|
|
3186
3186
|
]
|
|
3187
3187
|
}),
|
|
3188
|
-
|
|
3188
|
+
s && !be && ce.length === 1 && W("div", {
|
|
3189
3189
|
style: {
|
|
3190
3190
|
position: "absolute",
|
|
3191
3191
|
top: 16,
|
|
@@ -3217,13 +3217,13 @@ let __tla = (async () => {
|
|
|
3217
3217
|
R === "AK" ? "IT/Perineum" : "MPT"
|
|
3218
3218
|
]
|
|
3219
3219
|
}),
|
|
3220
|
-
|
|
3220
|
+
x && d(At, {
|
|
3221
3221
|
message: w || "Processing mesh..."
|
|
3222
3222
|
}),
|
|
3223
3223
|
oe && d(At, {
|
|
3224
3224
|
message: ee
|
|
3225
3225
|
}),
|
|
3226
|
-
me && d(
|
|
3226
|
+
me && d(Ln, {
|
|
3227
3227
|
message: me,
|
|
3228
3228
|
onDismiss: () => ae(null)
|
|
3229
3229
|
}),
|
|
@@ -3338,7 +3338,7 @@ let __tla = (async () => {
|
|
|
3338
3338
|
children: [
|
|
3339
3339
|
d("button", {
|
|
3340
3340
|
onClick: () => {
|
|
3341
|
-
|
|
3341
|
+
P(false), H(null);
|
|
3342
3342
|
},
|
|
3343
3343
|
style: {
|
|
3344
3344
|
padding: "6px 16px",
|
|
@@ -3397,7 +3397,7 @@ let __tla = (async () => {
|
|
|
3397
3397
|
]
|
|
3398
3398
|
},
|
|
3399
3399
|
style: {
|
|
3400
|
-
display:
|
|
3400
|
+
display: s ? "block" : "none",
|
|
3401
3401
|
backgroundColor: xe ? "#070611" : void 0
|
|
3402
3402
|
},
|
|
3403
3403
|
gl: {
|
|
@@ -3434,13 +3434,13 @@ let __tla = (async () => {
|
|
|
3434
3434
|
],
|
|
3435
3435
|
intensity: 0.2
|
|
3436
3436
|
}),
|
|
3437
|
-
|
|
3438
|
-
mesh:
|
|
3437
|
+
s && m === "3D" && d(Pn, {
|
|
3438
|
+
mesh: s,
|
|
3439
3439
|
maxPoints: 2,
|
|
3440
3440
|
meshColor: mt,
|
|
3441
|
-
meshOpacity: xe ? 0.3 :
|
|
3441
|
+
meshOpacity: xe ? 0.3 : Nt
|
|
3442
3442
|
}),
|
|
3443
|
-
he && fe &&
|
|
3443
|
+
he && fe && m === "3D" && d("mesh", {
|
|
3444
3444
|
geometry: fe,
|
|
3445
3445
|
renderOrder: 1,
|
|
3446
3446
|
children: d("meshStandardMaterial", {
|
|
@@ -3454,8 +3454,8 @@ let __tla = (async () => {
|
|
|
3454
3454
|
polygonOffsetUnits: 1
|
|
3455
3455
|
})
|
|
3456
3456
|
}),
|
|
3457
|
-
|
|
3458
|
-
modelSize:
|
|
3457
|
+
s && m === "3D" && d(Tn, {
|
|
3458
|
+
modelSize: o,
|
|
3459
3459
|
labels: [
|
|
3460
3460
|
"Origin",
|
|
3461
3461
|
R === "AK" ? "IT/Perineum" : "MPT",
|
|
@@ -3463,69 +3463,69 @@ let __tla = (async () => {
|
|
|
3463
3463
|
]
|
|
3464
3464
|
}),
|
|
3465
3465
|
d($n, {
|
|
3466
|
-
modelSize:
|
|
3466
|
+
modelSize: o,
|
|
3467
3467
|
isAligned: be,
|
|
3468
3468
|
isCut: Gt,
|
|
3469
|
-
mesh:
|
|
3470
|
-
viewMode:
|
|
3469
|
+
mesh: s,
|
|
3470
|
+
viewMode: m,
|
|
3471
3471
|
sliceY: be && ce.length >= 2 ? G ?? re ?? ce[1].position.y : void 0,
|
|
3472
3472
|
landmarkCount: ce.length
|
|
3473
3473
|
}),
|
|
3474
3474
|
!be && d(Dt, {
|
|
3475
3475
|
enableDamping: false
|
|
3476
3476
|
}),
|
|
3477
|
-
be && se.length > 0 &&
|
|
3478
|
-
mesh:
|
|
3477
|
+
be && se.length > 0 && s && m === "3D" && d(jn, {
|
|
3478
|
+
mesh: s,
|
|
3479
3479
|
isDragging: false
|
|
3480
3480
|
}),
|
|
3481
|
-
|
|
3482
|
-
const K =
|
|
3481
|
+
s && be && ce.length >= 3 && (() => {
|
|
3482
|
+
const K = s.geometry.getIndex();
|
|
3483
3483
|
if (!K || K.count < 30) return null;
|
|
3484
3484
|
const ue = ce[2], Z = ce[1], Be = I ?? ue.position.y, te = G ?? re ?? Z.position.y;
|
|
3485
|
-
return
|
|
3486
|
-
mesh:
|
|
3485
|
+
return m === "2D" ? d(Gn, {
|
|
3486
|
+
mesh: s,
|
|
3487
3487
|
upperY: te,
|
|
3488
3488
|
originY: Z.position.y,
|
|
3489
|
-
modelSize:
|
|
3489
|
+
modelSize: o,
|
|
3490
3490
|
meshColor: mt,
|
|
3491
|
-
displayUnit:
|
|
3491
|
+
displayUnit: j
|
|
3492
3492
|
}) : W(He, {
|
|
3493
3493
|
children: [
|
|
3494
3494
|
d(_n, {
|
|
3495
|
-
mesh:
|
|
3495
|
+
mesh: s,
|
|
3496
3496
|
startY: Be,
|
|
3497
3497
|
endY: te,
|
|
3498
3498
|
spacing: at,
|
|
3499
|
-
modelSize:
|
|
3499
|
+
modelSize: o,
|
|
3500
3500
|
onMeasurementsChange: A,
|
|
3501
3501
|
reverseOrder: true,
|
|
3502
|
-
displayUnit:
|
|
3503
|
-
useInnerSurface: T && !
|
|
3502
|
+
displayUnit: j,
|
|
3503
|
+
useInnerSurface: T && !N,
|
|
3504
3504
|
formMeasurements: ke ? ze : void 0,
|
|
3505
3505
|
originY: Z.position.y
|
|
3506
3506
|
}),
|
|
3507
|
-
(!T ||
|
|
3508
|
-
mesh:
|
|
3507
|
+
(!T || N) && d(On, {
|
|
3508
|
+
mesh: s,
|
|
3509
3509
|
greenY: Z.position.y,
|
|
3510
|
-
modelSize:
|
|
3511
|
-
displayUnit:
|
|
3510
|
+
modelSize: o,
|
|
3511
|
+
displayUnit: j
|
|
3512
3512
|
})
|
|
3513
3513
|
]
|
|
3514
3514
|
});
|
|
3515
3515
|
})(),
|
|
3516
|
-
|
|
3517
|
-
mesh:
|
|
3516
|
+
s && be && m === "3D" && d(so, {
|
|
3517
|
+
mesh: s
|
|
3518
3518
|
}),
|
|
3519
|
-
|
|
3520
|
-
mesh:
|
|
3521
|
-
modelSize:
|
|
3519
|
+
s && e.showDebug && xe && m === "3D" && d(oo, {
|
|
3520
|
+
mesh: s,
|
|
3521
|
+
modelSize: o,
|
|
3522
3522
|
layers: pe,
|
|
3523
3523
|
landmarkPoints: ce,
|
|
3524
3524
|
componentDebug: O
|
|
3525
3525
|
})
|
|
3526
3526
|
]
|
|
3527
3527
|
}),
|
|
3528
|
-
|
|
3528
|
+
s && (e.showStartOver || e.showInsertMeasurement) && W("div", {
|
|
3529
3529
|
style: {
|
|
3530
3530
|
position: "absolute",
|
|
3531
3531
|
top: 16,
|
|
@@ -3571,7 +3571,7 @@ let __tla = (async () => {
|
|
|
3571
3571
|
})
|
|
3572
3572
|
]
|
|
3573
3573
|
}),
|
|
3574
|
-
e.showDebug && xe &&
|
|
3574
|
+
e.showDebug && xe && s && m === "3D" && d(io, {
|
|
3575
3575
|
layers: pe,
|
|
3576
3576
|
onToggleLayer: (_) => we((K) => ({
|
|
3577
3577
|
...K,
|
|
@@ -3602,9 +3602,9 @@ let __tla = (async () => {
|
|
|
3602
3602
|
style: {
|
|
3603
3603
|
padding: "6px 14px",
|
|
3604
3604
|
fontSize: 13,
|
|
3605
|
-
fontWeight:
|
|
3606
|
-
backgroundColor:
|
|
3607
|
-
color:
|
|
3605
|
+
fontWeight: m === "3D" ? 600 : 400,
|
|
3606
|
+
backgroundColor: m === "3D" ? "rgb(12, 67, 173)" : "#fff",
|
|
3607
|
+
color: m === "3D" ? "#fff" : "#666",
|
|
3608
3608
|
border: "none",
|
|
3609
3609
|
cursor: "pointer",
|
|
3610
3610
|
fontFamily: "system-ui, sans-serif"
|
|
@@ -3616,9 +3616,9 @@ let __tla = (async () => {
|
|
|
3616
3616
|
style: {
|
|
3617
3617
|
padding: "6px 14px",
|
|
3618
3618
|
fontSize: 13,
|
|
3619
|
-
fontWeight:
|
|
3620
|
-
backgroundColor:
|
|
3621
|
-
color:
|
|
3619
|
+
fontWeight: m === "2D" ? 600 : 400,
|
|
3620
|
+
backgroundColor: m === "2D" ? "rgb(12, 67, 173)" : "#fff",
|
|
3621
|
+
color: m === "2D" ? "#fff" : "#666",
|
|
3622
3622
|
border: "none",
|
|
3623
3623
|
borderLeft: "1px solid #ccc",
|
|
3624
3624
|
cursor: "pointer",
|
|
@@ -3642,9 +3642,9 @@ let __tla = (async () => {
|
|
|
3642
3642
|
style: {
|
|
3643
3643
|
padding: "6px 14px",
|
|
3644
3644
|
fontSize: 13,
|
|
3645
|
-
fontWeight:
|
|
3646
|
-
backgroundColor:
|
|
3647
|
-
color:
|
|
3645
|
+
fontWeight: j === "mm" ? 600 : 400,
|
|
3646
|
+
backgroundColor: j === "mm" ? "rgb(12, 67, 173)" : "#fff",
|
|
3647
|
+
color: j === "mm" ? "#fff" : "#666",
|
|
3648
3648
|
border: "none",
|
|
3649
3649
|
cursor: "pointer",
|
|
3650
3650
|
fontFamily: "system-ui, sans-serif"
|
|
@@ -3656,9 +3656,9 @@ let __tla = (async () => {
|
|
|
3656
3656
|
style: {
|
|
3657
3657
|
padding: "6px 14px",
|
|
3658
3658
|
fontSize: 13,
|
|
3659
|
-
fontWeight:
|
|
3660
|
-
backgroundColor:
|
|
3661
|
-
color:
|
|
3659
|
+
fontWeight: j === "inch" ? 600 : 400,
|
|
3660
|
+
backgroundColor: j === "inch" ? "rgb(12, 67, 173)" : "#fff",
|
|
3661
|
+
color: j === "inch" ? "#fff" : "#666",
|
|
3662
3662
|
border: "none",
|
|
3663
3663
|
borderLeft: "1px solid #ccc",
|
|
3664
3664
|
cursor: "pointer",
|
|
@@ -3668,7 +3668,7 @@ let __tla = (async () => {
|
|
|
3668
3668
|
})
|
|
3669
3669
|
]
|
|
3670
3670
|
}),
|
|
3671
|
-
e.showSpacingToggle &&
|
|
3671
|
+
e.showSpacingToggle && m === "3D" && W("div", {
|
|
3672
3672
|
style: {
|
|
3673
3673
|
display: "flex",
|
|
3674
3674
|
borderRadius: 6,
|
|
@@ -3678,7 +3678,7 @@ let __tla = (async () => {
|
|
|
3678
3678
|
},
|
|
3679
3679
|
children: [
|
|
3680
3680
|
d("button", {
|
|
3681
|
-
onClick: () =>
|
|
3681
|
+
onClick: () => C(1),
|
|
3682
3682
|
style: {
|
|
3683
3683
|
padding: "6px 14px",
|
|
3684
3684
|
fontSize: 13,
|
|
@@ -3692,7 +3692,7 @@ let __tla = (async () => {
|
|
|
3692
3692
|
children: '1"'
|
|
3693
3693
|
}),
|
|
3694
3694
|
d("button", {
|
|
3695
|
-
onClick: () =>
|
|
3695
|
+
onClick: () => C(2),
|
|
3696
3696
|
style: {
|
|
3697
3697
|
padding: "6px 14px",
|
|
3698
3698
|
fontSize: 13,
|
|
@@ -3708,7 +3708,7 @@ let __tla = (async () => {
|
|
|
3708
3708
|
})
|
|
3709
3709
|
]
|
|
3710
3710
|
}),
|
|
3711
|
-
|
|
3711
|
+
m === "3D" && fe && d("div", {
|
|
3712
3712
|
style: {
|
|
3713
3713
|
display: "flex",
|
|
3714
3714
|
borderRadius: 6,
|
|
@@ -3731,7 +3731,7 @@ let __tla = (async () => {
|
|
|
3731
3731
|
children: "Show Full Scan"
|
|
3732
3732
|
})
|
|
3733
3733
|
}),
|
|
3734
|
-
|
|
3734
|
+
m === "3D" && ze && d("div", {
|
|
3735
3735
|
style: {
|
|
3736
3736
|
display: "flex",
|
|
3737
3737
|
borderRadius: 6,
|
|
@@ -3779,11 +3779,11 @@ let __tla = (async () => {
|
|
|
3779
3779
|
})
|
|
3780
3780
|
]
|
|
3781
3781
|
}),
|
|
3782
|
-
|
|
3782
|
+
s && V && d(Nn, {
|
|
3783
3783
|
wasAutoScaled: z,
|
|
3784
3784
|
onDismiss: () => B(false)
|
|
3785
3785
|
}),
|
|
3786
|
-
|
|
3786
|
+
s && q && be && d(Hn, {
|
|
3787
3787
|
isDoubleShell: T,
|
|
3788
3788
|
onDismiss: () => ie(false)
|
|
3789
3789
|
})
|
|
@@ -3801,7 +3801,7 @@ let __tla = (async () => {
|
|
|
3801
3801
|
flexShrink: 0
|
|
3802
3802
|
},
|
|
3803
3803
|
children: [
|
|
3804
|
-
|
|
3804
|
+
s && !be && ce.length >= 2 && d("button", {
|
|
3805
3805
|
onClick: Qt,
|
|
3806
3806
|
style: {
|
|
3807
3807
|
padding: "6px 16px",
|
|
@@ -3818,7 +3818,7 @@ let __tla = (async () => {
|
|
|
3818
3818
|
},
|
|
3819
3819
|
children: "Next \xBB"
|
|
3820
3820
|
}),
|
|
3821
|
-
|
|
3821
|
+
s && !be && ce.length >= 1 && d("button", {
|
|
3822
3822
|
onClick: Yt,
|
|
3823
3823
|
style: {
|
|
3824
3824
|
padding: "6px 16px",
|
|
@@ -4027,76 +4027,80 @@ let __tla = (async () => {
|
|
|
4027
4027
|
]
|
|
4028
4028
|
});
|
|
4029
4029
|
};
|
|
4030
|
-
|
|
4031
|
-
const
|
|
4032
|
-
for (let t = 2; t >= 1; t -=
|
|
4033
|
-
|
|
4034
|
-
for (let t =
|
|
4035
|
-
return
|
|
4030
|
+
jt = function(e) {
|
|
4031
|
+
const r = e === "AK" ? 2 : 1, n = [];
|
|
4032
|
+
for (let t = 2; t >= 1; t -= r) n.push(`${t}_above`);
|
|
4033
|
+
n.push("at_ref");
|
|
4034
|
+
for (let t = r; t <= 9; t += r) n.push(`${t}_below`);
|
|
4035
|
+
return n;
|
|
4036
4036
|
};
|
|
4037
|
-
dt = function(e,
|
|
4038
|
-
const
|
|
4039
|
-
for (let
|
|
4040
|
-
const a = e[
|
|
4041
|
-
a != null && !isNaN(a) && (t[
|
|
4037
|
+
dt = function(e, r) {
|
|
4038
|
+
const n = jt(r), t = {};
|
|
4039
|
+
for (let i = 0; i < Math.min(e.length, n.length); i++) {
|
|
4040
|
+
const a = e[i];
|
|
4041
|
+
a != null && !isNaN(a) && (t[n[i]] = a);
|
|
4042
4042
|
}
|
|
4043
4043
|
return t;
|
|
4044
4044
|
};
|
|
4045
|
-
ao = function(e,
|
|
4045
|
+
ao = function(e, r) {
|
|
4046
4046
|
if (!e) return;
|
|
4047
|
-
const t =
|
|
4048
|
-
const a = e[
|
|
4047
|
+
const t = jt(r).map((i) => {
|
|
4048
|
+
const a = e[i];
|
|
4049
4049
|
return a ?? void 0;
|
|
4050
4050
|
});
|
|
4051
|
-
if (!t.every((
|
|
4051
|
+
if (!t.every((i) => i == null)) return t;
|
|
4052
4052
|
};
|
|
4053
|
-
bo = ({ request: e, onComplete:
|
|
4054
|
-
const [t,
|
|
4053
|
+
bo = ({ request: e, onComplete: r, wasmModule: n }) => {
|
|
4054
|
+
const [t, i] = Q(null), [a, c] = Q(n !== void 0);
|
|
4055
4055
|
Se(() => {
|
|
4056
|
-
if (
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4056
|
+
if (n !== void 0) {
|
|
4057
|
+
c(true);
|
|
4058
|
+
return;
|
|
4059
|
+
}
|
|
4060
|
+
let o = false;
|
|
4061
|
+
return import("./galileo_core_geo-DFVJmkI7.js").then(async (f) => {
|
|
4062
|
+
await f.default(), o || (i(f), c(true));
|
|
4060
4063
|
}).catch(() => {
|
|
4064
|
+
o || c(true);
|
|
4061
4065
|
}), () => {
|
|
4062
|
-
|
|
4066
|
+
o = true;
|
|
4063
4067
|
};
|
|
4064
4068
|
}, [
|
|
4065
|
-
|
|
4069
|
+
n
|
|
4066
4070
|
]);
|
|
4067
|
-
const
|
|
4071
|
+
const u = n !== void 0 ? n : t, s = de(() => ao(e.form_measurements, e.spacing_type), [
|
|
4068
4072
|
e.form_measurements,
|
|
4069
4073
|
e.spacing_type
|
|
4070
|
-
]),
|
|
4071
|
-
const
|
|
4072
|
-
let
|
|
4073
|
-
if (
|
|
4074
|
-
|
|
4075
|
-
const
|
|
4074
|
+
]), l = (o) => {
|
|
4075
|
+
const f = o.scanMeasurements.map((w) => +(w.modifiedValue ?? w.originalValue).toFixed(1)), y = dt(f, e.spacing_type);
|
|
4076
|
+
let p, x;
|
|
4077
|
+
if (o.formMeasurements) {
|
|
4078
|
+
p = dt(o.formMeasurements, e.spacing_type);
|
|
4079
|
+
const w = o.scanMeasurements.map((v, m) => {
|
|
4076
4080
|
var _a;
|
|
4077
|
-
const
|
|
4078
|
-
return
|
|
4081
|
+
const b = (_a = o.formMeasurements) == null ? void 0 : _a[m];
|
|
4082
|
+
return b == null || isNaN(b) ? null : +((v.modifiedValue ?? v.originalValue) - b).toFixed(1);
|
|
4079
4083
|
});
|
|
4080
|
-
|
|
4084
|
+
x = dt(w, e.spacing_type);
|
|
4081
4085
|
}
|
|
4082
|
-
const
|
|
4086
|
+
const g = {
|
|
4083
4087
|
spacing_type: e.spacing_type,
|
|
4084
4088
|
source_unit: "mm",
|
|
4085
|
-
file_format:
|
|
4086
|
-
measurement_source:
|
|
4087
|
-
is_double_wall:
|
|
4089
|
+
file_format: o.fileFormat,
|
|
4090
|
+
measurement_source: o.formMeasurements ? "form_provided" : "scan_derived",
|
|
4091
|
+
is_double_wall: o.isDoubleWall,
|
|
4088
4092
|
is_unit_converted: false,
|
|
4089
|
-
form_measurements:
|
|
4090
|
-
scan_measurements:
|
|
4091
|
-
measurement_variance:
|
|
4093
|
+
form_measurements: p,
|
|
4094
|
+
scan_measurements: y,
|
|
4095
|
+
measurement_variance: x,
|
|
4092
4096
|
scan_url: e.scan_url,
|
|
4093
|
-
frontal_height: +
|
|
4094
|
-
transverse_ml: +
|
|
4095
|
-
transverse_ap: +
|
|
4097
|
+
frontal_height: +o.frontalHeight.toFixed(1),
|
|
4098
|
+
transverse_ml: +o.transverseML.toFixed(1),
|
|
4099
|
+
transverse_ap: +o.transverseAP.toFixed(1)
|
|
4096
4100
|
};
|
|
4097
|
-
console.log("[GirthManagerWidget] WidgetResponse:", JSON.stringify(
|
|
4101
|
+
console.log("[GirthManagerWidget] WidgetResponse:", JSON.stringify(g, null, 2)), r == null ? void 0 : r(g);
|
|
4098
4102
|
};
|
|
4099
|
-
return d("div", {
|
|
4103
|
+
return a ? d("div", {
|
|
4100
4104
|
style: {
|
|
4101
4105
|
width: "100%",
|
|
4102
4106
|
height: "100%",
|
|
@@ -4106,9 +4110,20 @@ let __tla = (async () => {
|
|
|
4106
4110
|
config: fn,
|
|
4107
4111
|
spacingType: e.spacing_type,
|
|
4108
4112
|
scanUrl: e.scan_url,
|
|
4109
|
-
formMeasurements:
|
|
4110
|
-
onComplete:
|
|
4111
|
-
wasmModule:
|
|
4113
|
+
formMeasurements: s,
|
|
4114
|
+
onComplete: l,
|
|
4115
|
+
wasmModule: u
|
|
4116
|
+
})
|
|
4117
|
+
}) : d("div", {
|
|
4118
|
+
style: {
|
|
4119
|
+
width: "100%",
|
|
4120
|
+
height: "100%",
|
|
4121
|
+
display: "flex",
|
|
4122
|
+
alignItems: "center",
|
|
4123
|
+
justifyContent: "center"
|
|
4124
|
+
},
|
|
4125
|
+
children: d("span", {
|
|
4126
|
+
children: "Initializing..."
|
|
4112
4127
|
})
|
|
4113
4128
|
});
|
|
4114
4129
|
};
|
|
@@ -4118,5 +4133,5 @@ export {
|
|
|
4118
4133
|
__tla,
|
|
4119
4134
|
dt as a,
|
|
4120
4135
|
ao as c,
|
|
4121
|
-
|
|
4136
|
+
jt as g
|
|
4122
4137
|
};
|