printbench 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/printbench.d.ts +4 -1
- package/dist/printbench.js +268 -267
- package/package.json +1 -1
package/dist/printbench.js
CHANGED
|
@@ -2355,18 +2355,18 @@ async function LC(C, A, B, g, I, Q = "none", o = 0) {
|
|
|
2355
2355
|
return D.meshes;
|
|
2356
2356
|
}
|
|
2357
2357
|
function sg(C, A, B = 1e-5, g, I) {
|
|
2358
|
-
const Q = /* @__PURE__ */ new Map(), o = [], D = [], i = [], G = [],
|
|
2358
|
+
const Q = /* @__PURE__ */ new Map(), o = [], D = [], i = [], G = [], K = 1 / B, a = 1e5, h = C.length / 3, Y = !!I && I.length >= h * 2, J = !!g && g.length >= h * 3;
|
|
2359
2359
|
for (let n = 0; n < h; n++) {
|
|
2360
|
-
const r = C[n * 3],
|
|
2361
|
-
let
|
|
2362
|
-
Y && I && (
|
|
2363
|
-
let e = Q.get(
|
|
2364
|
-
e === void 0 && (e = o.length / 3, Q.set(
|
|
2360
|
+
const r = C[n * 3], c = C[n * 3 + 1], F = C[n * 3 + 2];
|
|
2361
|
+
let M = `${Math.round(r * K)}_${Math.round(c * K)}_${Math.round(F * K)}`;
|
|
2362
|
+
Y && I && (M += `_${Math.round(I[n * 2] * a)}_${Math.round(I[n * 2 + 1] * a)}`);
|
|
2363
|
+
let e = Q.get(M);
|
|
2364
|
+
e === void 0 && (e = o.length / 3, Q.set(M, e), o.push(r, c, F), J && g && D.push(g[n * 3] ?? 1, g[n * 3 + 1] ?? 1, g[n * 3 + 2] ?? 1), Y && I && i.push(I[n * 2] ?? 0, I[n * 2 + 1] ?? 0)), G[n] = e;
|
|
2365
2365
|
}
|
|
2366
2366
|
const H = [];
|
|
2367
2367
|
for (let n = 0; n < A.length; n += 3) {
|
|
2368
|
-
const r = G[A[n]],
|
|
2369
|
-
r ===
|
|
2368
|
+
const r = G[A[n]], c = G[A[n + 1]], F = G[A[n + 2]];
|
|
2369
|
+
r === c || c === F || r === F || H.push(r, c, F);
|
|
2370
2370
|
}
|
|
2371
2371
|
return {
|
|
2372
2372
|
positions: new Float32Array(o),
|
|
@@ -2376,45 +2376,45 @@ function sg(C, A, B = 1e-5, g, I) {
|
|
|
2376
2376
|
};
|
|
2377
2377
|
}
|
|
2378
2378
|
function rC(C, A) {
|
|
2379
|
-
const B = /* @__PURE__ */ new Map(), g = (
|
|
2380
|
-
const h =
|
|
2381
|
-
Y.push(
|
|
2379
|
+
const B = /* @__PURE__ */ new Map(), g = (K, a) => {
|
|
2380
|
+
const h = K < a ? `${K}_${a}` : `${a}_${K}`, Y = B.get(h) ?? [];
|
|
2381
|
+
Y.push(K, a), B.set(h, Y);
|
|
2382
2382
|
};
|
|
2383
|
-
for (let
|
|
2384
|
-
g(A[
|
|
2383
|
+
for (let K = 0; K < A.length; K += 3)
|
|
2384
|
+
g(A[K], A[K + 1]), g(A[K + 1], A[K + 2]), g(A[K + 2], A[K]);
|
|
2385
2385
|
const I = /* @__PURE__ */ new Map();
|
|
2386
|
-
for (const [
|
|
2386
|
+
for (const [K, a] of B)
|
|
2387
2387
|
if (a.length === 2) {
|
|
2388
|
-
const [h, Y] =
|
|
2389
|
-
B.get(
|
|
2388
|
+
const [h, Y] = K.split("_").map(Number);
|
|
2389
|
+
B.get(K).length === 2 && I.set(h, Y);
|
|
2390
2390
|
}
|
|
2391
2391
|
const Q = [];
|
|
2392
|
-
for (const [,
|
|
2393
|
-
|
|
2392
|
+
for (const [, K] of B)
|
|
2393
|
+
K.length === 2 && Q.push([K[0], K[1]]);
|
|
2394
2394
|
const o = /* @__PURE__ */ new Map();
|
|
2395
|
-
for (const [
|
|
2396
|
-
const h = o.get(
|
|
2397
|
-
h.push(a), o.set(
|
|
2395
|
+
for (const [K, a] of Q) {
|
|
2396
|
+
const h = o.get(K) ?? [];
|
|
2397
|
+
h.push(a), o.set(K, h);
|
|
2398
2398
|
}
|
|
2399
2399
|
const D = /* @__PURE__ */ new Set(), i = [];
|
|
2400
|
-
for (const [
|
|
2400
|
+
for (const [K, a] of o)
|
|
2401
2401
|
for (const h of a) {
|
|
2402
|
-
const Y = `${
|
|
2402
|
+
const Y = `${K}_${h}`;
|
|
2403
2403
|
if (D.has(Y)) continue;
|
|
2404
|
-
const J = [
|
|
2405
|
-
let H = h, n =
|
|
2404
|
+
const J = [K];
|
|
2405
|
+
let H = h, n = K;
|
|
2406
2406
|
D.add(Y);
|
|
2407
2407
|
let r = 0;
|
|
2408
|
-
for (; H !==
|
|
2408
|
+
for (; H !== K && r++ < 1e4; ) {
|
|
2409
2409
|
J.push(H);
|
|
2410
|
-
const
|
|
2410
|
+
const c = o.get(H) ?? [], F = c.find((M) => M !== n) ?? c[0];
|
|
2411
2411
|
if (F === void 0) break;
|
|
2412
2412
|
D.add(`${H}_${F}`), n = H, H = F;
|
|
2413
2413
|
}
|
|
2414
2414
|
if (J.length >= 3) {
|
|
2415
|
-
const
|
|
2415
|
+
const c = J[0];
|
|
2416
2416
|
for (let F = 1; F < J.length - 1; F++)
|
|
2417
|
-
i.push(
|
|
2417
|
+
i.push(c, J[F], J[F + 1]);
|
|
2418
2418
|
}
|
|
2419
2419
|
}
|
|
2420
2420
|
if (!i.length) return { positions: C, indices: A };
|
|
@@ -2457,10 +2457,10 @@ function qC(C) {
|
|
|
2457
2457
|
[Y, J, H].every(Number.isFinite) && Q.push(Y, J, H);
|
|
2458
2458
|
}
|
|
2459
2459
|
const i = [], G = /<triangle\b([^>]*)\/?>/gi;
|
|
2460
|
-
let
|
|
2460
|
+
let K;
|
|
2461
2461
|
const a = Q.length / 3;
|
|
2462
|
-
for (;
|
|
2463
|
-
const Y = Number(bA(
|
|
2462
|
+
for (; K = G.exec(I); ) {
|
|
2463
|
+
const Y = Number(bA(K[1], "v1")), J = Number(bA(K[1], "v2")), H = Number(bA(K[1], "v3"));
|
|
2464
2464
|
[Y, J, H].every((n) => Number.isInteger(n) && n >= 0 && n < a) && i.push(Y, J, H);
|
|
2465
2465
|
}
|
|
2466
2466
|
if (a < 3 || i.length < 3) continue;
|
|
@@ -2481,10 +2481,10 @@ function lC(C, A, B) {
|
|
|
2481
2481
|
const i = [];
|
|
2482
2482
|
for (let h = 0; h < o.positions.length; h += 3)
|
|
2483
2483
|
i.push(` <vertex x="${o.positions[h]}" y="${o.positions[h + 1]}" z="${o.positions[h + 2]}" />`);
|
|
2484
|
-
const G = [],
|
|
2484
|
+
const G = [], K = o.positions.length / 3;
|
|
2485
2485
|
for (let h = 0; h < o.indices.length; h += 3) {
|
|
2486
2486
|
const Y = o.indices[h], J = o.indices[h + 1], H = o.indices[h + 2];
|
|
2487
|
-
Y >=
|
|
2487
|
+
Y >= K || J >= K || H >= K || G.push(` <triangle v1="${Y}" v2="${J}" v3="${H}" />`);
|
|
2488
2488
|
}
|
|
2489
2489
|
const a = PI(B?.[D] || `part_${D + 1}`);
|
|
2490
2490
|
return ` <object id="${D + 1}" name="${a}" type="model">
|
|
@@ -2547,8 +2547,8 @@ async function xC(C) {
|
|
|
2547
2547
|
let o, D = 0;
|
|
2548
2548
|
for (; o = Q.exec(g); ) {
|
|
2549
2549
|
D++;
|
|
2550
|
-
const i = Number(o[1]), G = Number(o[2]),
|
|
2551
|
-
if (i >= I || G >= I ||
|
|
2550
|
+
const i = Number(o[1]), G = Number(o[2]), K = Number(o[3]);
|
|
2551
|
+
if (i >= I || G >= I || K >= I || i < 0 || G < 0 || K < 0) return !1;
|
|
2552
2552
|
}
|
|
2553
2553
|
return D > 0;
|
|
2554
2554
|
}
|
|
@@ -2587,22 +2587,22 @@ function VC(C, A, B, g, I, Q) {
|
|
|
2587
2587
|
o.fill(1);
|
|
2588
2588
|
const D = Q.map((G) => {
|
|
2589
2589
|
if (!G) return;
|
|
2590
|
-
const
|
|
2591
|
-
if (
|
|
2592
|
-
return { data:
|
|
2590
|
+
const K = G.canvas.getContext("2d");
|
|
2591
|
+
if (K)
|
|
2592
|
+
return { data: K.getImageData(0, 0, G.canvas.width, G.canvas.height), flipY: G.flipY };
|
|
2593
2593
|
}), i = (G) => {
|
|
2594
|
-
for (const
|
|
2595
|
-
if (G >=
|
|
2594
|
+
for (const K of g)
|
|
2595
|
+
if (G >= K.start && G < K.start + K.count) return K.materialIndex ?? 0;
|
|
2596
2596
|
return 0;
|
|
2597
2597
|
};
|
|
2598
2598
|
for (let G = 0; G < A.length; G += 3) {
|
|
2599
|
-
const
|
|
2599
|
+
const K = I.length ? Math.max(0, Math.min(I.length - 1, i(G))) : 0, a = D[K], h = I[K] ? zI(I[K]) : [1, 1, 1];
|
|
2600
2600
|
for (let Y = 0; Y < 3; Y++) {
|
|
2601
2601
|
const J = A[G + Y];
|
|
2602
2602
|
let H = h[0], n = h[1], r = h[2];
|
|
2603
2603
|
if (a && B && J * 2 + 1 < B.length) {
|
|
2604
|
-
const
|
|
2605
|
-
H *=
|
|
2604
|
+
const c = mC(a.data, B[J * 2], B[J * 2 + 1], a.flipY);
|
|
2605
|
+
H *= c[0], n *= c[1], r *= c[2];
|
|
2606
2606
|
}
|
|
2607
2607
|
o[J * 3] = H, o[J * 3 + 1] = n, o[J * 3 + 2] = r;
|
|
2608
2608
|
}
|
|
@@ -2612,56 +2612,56 @@ function VC(C, A, B, g, I, Q) {
|
|
|
2612
2612
|
function yg(C, A, B, g) {
|
|
2613
2613
|
const I = C.index ? C.clone() : C.clone().toNonIndexed();
|
|
2614
2614
|
if (!I.index) {
|
|
2615
|
-
const
|
|
2616
|
-
for (let d = 0; d <
|
|
2615
|
+
const M = I.getAttribute("position").count, e = new Uint32Array(M);
|
|
2616
|
+
for (let d = 0; d < M; d++) e[d] = d;
|
|
2617
2617
|
I.setIndex(new oA(e, 1));
|
|
2618
2618
|
}
|
|
2619
2619
|
B && I.applyMatrix4(B);
|
|
2620
2620
|
const Q = I.getAttribute("position"), o = I.getIndex(), D = new Float32Array(Q.count * 3);
|
|
2621
|
-
for (let
|
|
2622
|
-
D[
|
|
2621
|
+
for (let M = 0; M < Q.count; M++)
|
|
2622
|
+
D[M * 3] = Q.getX(M), D[M * 3 + 1] = Q.getY(M), D[M * 3 + 2] = Q.getZ(M);
|
|
2623
2623
|
const i = new Uint32Array(o.array.length);
|
|
2624
|
-
for (let
|
|
2624
|
+
for (let M = 0; M < o.array.length; M++) i[M] = o.array[M];
|
|
2625
2625
|
const G = I.getAttribute("color");
|
|
2626
|
-
let
|
|
2626
|
+
let K;
|
|
2627
2627
|
if (G) {
|
|
2628
|
-
|
|
2629
|
-
for (let
|
|
2630
|
-
M
|
|
2628
|
+
K = new Float32Array(Q.count * 3);
|
|
2629
|
+
for (let M = 0; M < Q.count; M++)
|
|
2630
|
+
K[M * 3] = G.getX(M), K[M * 3 + 1] = G.getY(M), K[M * 3 + 2] = G.getZ(M);
|
|
2631
2631
|
}
|
|
2632
2632
|
const a = I.getAttribute("uv");
|
|
2633
2633
|
let h;
|
|
2634
2634
|
if (a) {
|
|
2635
2635
|
h = new Float32Array(Q.count * 2);
|
|
2636
|
-
for (let
|
|
2637
|
-
h[
|
|
2636
|
+
for (let M = 0; M < Q.count; M++)
|
|
2637
|
+
h[M * 2] = a.getX(M), h[M * 2 + 1] = a.getY(M);
|
|
2638
2638
|
}
|
|
2639
|
-
const Y = pC(g), J = Y.map((
|
|
2639
|
+
const Y = pC(g), J = Y.map((M) => bC(fC(M)));
|
|
2640
2640
|
let H, n, r;
|
|
2641
2641
|
if (Y.length <= 1) {
|
|
2642
2642
|
if (H = J[0]?.canvas, n = J[0]?.flipY, Y[0]) {
|
|
2643
|
-
const
|
|
2644
|
-
(!ig(
|
|
2643
|
+
const M = zI(Y[0]);
|
|
2644
|
+
(!ig(M) || H) && (r = M);
|
|
2645
2645
|
}
|
|
2646
2646
|
} else {
|
|
2647
|
-
const
|
|
2648
|
-
if (new Set(
|
|
2649
|
-
H =
|
|
2647
|
+
const M = J.map((d) => d?.canvas).filter((d) => !!d);
|
|
2648
|
+
if (new Set(M).size === 1 && M.length === Y.length) {
|
|
2649
|
+
H = M[0], n = J.find((Z) => Z)?.flipY;
|
|
2650
2650
|
const d = zI(Y[0]);
|
|
2651
2651
|
(!ig(d) || H) && (r = d);
|
|
2652
2652
|
} else
|
|
2653
|
-
|
|
2653
|
+
K = VC(Q.count, i, h, I.groups, Y, J);
|
|
2654
2654
|
}
|
|
2655
|
-
const
|
|
2656
|
-
const
|
|
2657
|
-
if (
|
|
2658
|
-
return
|
|
2655
|
+
const c = sg(D, i, 1e-5, K, h), F = (() => {
|
|
2656
|
+
const M = {};
|
|
2657
|
+
if (c.uvs && (M.uvs = c.uvs), c.colors && (M.colors = c.colors), r && (M.baseColor = r), H && (M.texture = H, M.flipY = n), !(!M.texture && !M.colors && !M.baseColor))
|
|
2658
|
+
return M;
|
|
2659
2659
|
})();
|
|
2660
2660
|
return {
|
|
2661
2661
|
id: mA("mesh"),
|
|
2662
2662
|
name: A,
|
|
2663
2663
|
visible: !0,
|
|
2664
|
-
buffers: { positions:
|
|
2664
|
+
buffers: { positions: c.positions, indices: c.indices, colors: c.colors },
|
|
2665
2665
|
appearance: F
|
|
2666
2666
|
};
|
|
2667
2667
|
}
|
|
@@ -2683,8 +2683,8 @@ function OI(C, A) {
|
|
|
2683
2683
|
o++, D = D.parent;
|
|
2684
2684
|
if (g = Math.max(g, o), Q.isMesh) {
|
|
2685
2685
|
const i = Q;
|
|
2686
|
-
(Array.isArray(i.geometry) ? i.geometry : [i.geometry]).forEach((
|
|
2687
|
-
|
|
2686
|
+
(Array.isArray(i.geometry) ? i.geometry : [i.geometry]).forEach((K, a) => {
|
|
2687
|
+
K && B.push(yg(K, `${A}_${B.length || a}`, i.matrixWorld, i.material));
|
|
2688
2688
|
}), i.material && (I = !0);
|
|
2689
2689
|
}
|
|
2690
2690
|
}), { meshes: B, depth: g, hasMat: I };
|
|
@@ -2695,7 +2695,7 @@ async function $I(C) {
|
|
|
2695
2695
|
if (A === "glb" || A === "gltf") {
|
|
2696
2696
|
const I = await new iC().parseAsync(B, ""), { meshes: Q, depth: o, hasMat: D } = OI(I.scene, C.name.replace(/\.[^.]+$/, ""));
|
|
2697
2697
|
if (!Q.length) throw new Error("该文件不包含网格,可能是纯灯光/相机场景");
|
|
2698
|
-
const i = Q.reduce((
|
|
2698
|
+
const i = Q.reduce((K, a) => K + a.buffers.indices.length / 3, 0), G = Q.reduce((K, a) => K + a.buffers.positions.length / 3, 0);
|
|
2699
2699
|
return {
|
|
2700
2700
|
meshes: Q,
|
|
2701
2701
|
summary: {
|
|
@@ -2727,14 +2727,14 @@ async function $I(C) {
|
|
|
2727
2727
|
if (A === "obj") {
|
|
2728
2728
|
const g = new TextDecoder().decode(B), Q = new wC().parse(g), { meshes: o, depth: D, hasMat: i } = OI(Q, C.name.replace(/\.[^.]+$/, ""));
|
|
2729
2729
|
if (!o.length) throw new Error("OBJ 中没有可用网格");
|
|
2730
|
-
const G = o.reduce((a, h) => a + h.buffers.indices.length / 3, 0),
|
|
2730
|
+
const G = o.reduce((a, h) => a + h.buffers.indices.length / 3, 0), K = o.reduce((a, h) => a + h.buffers.positions.length / 3, 0);
|
|
2731
2731
|
return {
|
|
2732
2732
|
meshes: o,
|
|
2733
2733
|
summary: {
|
|
2734
2734
|
fileName: C.name,
|
|
2735
2735
|
format: "obj",
|
|
2736
2736
|
triangleCount: G,
|
|
2737
|
-
vertexCount:
|
|
2737
|
+
vertexCount: K,
|
|
2738
2738
|
nodeDepth: D,
|
|
2739
2739
|
hasMaterials: i,
|
|
2740
2740
|
hasAnimations: !1
|
|
@@ -2743,14 +2743,14 @@ async function $I(C) {
|
|
|
2743
2743
|
}
|
|
2744
2744
|
if (A === "3mf") {
|
|
2745
2745
|
const g = await TC(B), Q = (await _A.loadAsync(B)).file(/3dmodel\.model$/i)[0], o = Q ? await Q.async("string") : "", D = o ? qC(o) : [];
|
|
2746
|
-
let i = [], G = 1,
|
|
2746
|
+
let i = [], G = 1, K = !1;
|
|
2747
2747
|
try {
|
|
2748
2748
|
const J = new NC().parse(B), H = OI(J, C.name.replace(/\.[^.]+$/, ""));
|
|
2749
|
-
i = H.meshes, G = H.depth,
|
|
2749
|
+
i = H.meshes, G = H.depth, K = H.hasMat;
|
|
2750
2750
|
} catch {
|
|
2751
2751
|
i = [];
|
|
2752
2752
|
}
|
|
2753
|
-
if (D.length > i.length && (i = D.map((Y) => uC(Y.name, Y.positions, Y.indices)),
|
|
2753
|
+
if (D.length > i.length && (i = D.map((Y) => uC(Y.name, Y.positions, Y.indices)), K = !1, G = 1), !i.length) throw new Error("3MF 中没有可用网格");
|
|
2754
2754
|
const a = i.reduce((Y, J) => Y + J.buffers.indices.length / 3, 0), h = i.reduce((Y, J) => Y + J.buffers.positions.length / 3, 0);
|
|
2755
2755
|
return {
|
|
2756
2756
|
meshes: i,
|
|
@@ -2761,7 +2761,7 @@ async function $I(C) {
|
|
|
2761
2761
|
triangleCount: a,
|
|
2762
2762
|
vertexCount: h,
|
|
2763
2763
|
nodeDepth: G,
|
|
2764
|
-
hasMaterials:
|
|
2764
|
+
hasMaterials: K,
|
|
2765
2765
|
hasAnimations: !1,
|
|
2766
2766
|
declaredUnit: g
|
|
2767
2767
|
}
|
|
@@ -2781,7 +2781,7 @@ async function jC(C, A) {
|
|
|
2781
2781
|
I.push(...J.meshes), Q = Q || J.summary.hasMaterials, o = o || J.summary.hasAnimations, D = Math.max(D, J.summary.nodeDepth), J.declaredUnit && !i && (i = J.declaredUnit);
|
|
2782
2782
|
}
|
|
2783
2783
|
if (!I.length) throw new Error("压缩包中没有可用网格");
|
|
2784
|
-
const G = I.reduce((a, h) => a + h.buffers.indices.length / 3, 0),
|
|
2784
|
+
const G = I.reduce((a, h) => a + h.buffers.indices.length / 3, 0), K = I.reduce((a, h) => a + h.buffers.positions.length / 3, 0);
|
|
2785
2785
|
return {
|
|
2786
2786
|
meshes: I,
|
|
2787
2787
|
declaredUnit: i,
|
|
@@ -2789,7 +2789,7 @@ async function jC(C, A) {
|
|
|
2789
2789
|
fileName: C.name,
|
|
2790
2790
|
format: "zip",
|
|
2791
2791
|
triangleCount: G,
|
|
2792
|
-
vertexCount:
|
|
2792
|
+
vertexCount: K,
|
|
2793
2793
|
nodeDepth: D,
|
|
2794
2794
|
hasMaterials: Q,
|
|
2795
2795
|
hasAnimations: o,
|
|
@@ -2926,22 +2926,22 @@ const sI = vI("printbench-settings", () => {
|
|
|
2926
2926
|
}), IA = vI("printbench-ui", () => {
|
|
2927
2927
|
const C = t([]), A = t(!1), B = t(""), g = t(null);
|
|
2928
2928
|
let I = 1;
|
|
2929
|
-
function Q(
|
|
2929
|
+
function Q(K, a) {
|
|
2930
2930
|
const h = I++;
|
|
2931
|
-
C.value.push({ id: h, type:
|
|
2931
|
+
C.value.push({ id: h, type: K, text: a }), setTimeout(() => {
|
|
2932
2932
|
C.value = C.value.filter((Y) => Y.id !== h);
|
|
2933
2933
|
}, 4200);
|
|
2934
2934
|
}
|
|
2935
|
-
async function o(
|
|
2935
|
+
async function o(K, a) {
|
|
2936
2936
|
return new Promise((h) => {
|
|
2937
|
-
g.value = { title:
|
|
2937
|
+
g.value = { title: K, body: a, resolve: h };
|
|
2938
2938
|
});
|
|
2939
2939
|
}
|
|
2940
|
-
function D(
|
|
2941
|
-
g.value?.resolve(
|
|
2940
|
+
function D(K) {
|
|
2941
|
+
g.value?.resolve(K), g.value = null;
|
|
2942
2942
|
}
|
|
2943
|
-
function i(
|
|
2944
|
-
A.value =
|
|
2943
|
+
function i(K, a = "") {
|
|
2944
|
+
A.value = K, B.value = a;
|
|
2945
2945
|
}
|
|
2946
2946
|
const G = wA(() => !!g.value);
|
|
2947
2947
|
return { toasts: C, busy: A, busyText: B, confirm: g, hasConfirm: G, toast: Q, ask: o, answer: D, setBusy: i };
|
|
@@ -3026,23 +3026,23 @@ function JI(C, A) {
|
|
|
3026
3026
|
let Q = 0, o = 0, D = 0;
|
|
3027
3027
|
const i = [1 / 0, 1 / 0, 1 / 0], G = [-1 / 0, -1 / 0, -1 / 0];
|
|
3028
3028
|
for (let r = 0; r < B; r++) {
|
|
3029
|
-
const
|
|
3030
|
-
|
|
3029
|
+
const c = C[r * 3], F = C[r * 3 + 1], M = C[r * 3 + 2];
|
|
3030
|
+
c < i[0] && (i[0] = c), F < i[1] && (i[1] = F), M < i[2] && (i[2] = M), c > G[0] && (G[0] = c), F > G[1] && (G[1] = F), M > G[2] && (G[2] = M);
|
|
3031
3031
|
}
|
|
3032
|
-
const
|
|
3033
|
-
for (let r = 0; r < B; r++)
|
|
3032
|
+
const K = new Int32Array(B);
|
|
3033
|
+
for (let r = 0; r < B; r++) K[r] = r;
|
|
3034
3034
|
const a = (r) => {
|
|
3035
|
-
for (;
|
|
3036
|
-
|
|
3035
|
+
for (; K[r] !== r; )
|
|
3036
|
+
K[r] = K[K[r]], r = K[r];
|
|
3037
3037
|
return r;
|
|
3038
|
-
}, h = (r,
|
|
3039
|
-
const F = a(r),
|
|
3040
|
-
F !==
|
|
3038
|
+
}, h = (r, c) => {
|
|
3039
|
+
const F = a(r), M = a(c);
|
|
3040
|
+
F !== M && (K[F] = M);
|
|
3041
3041
|
};
|
|
3042
3042
|
for (let r = 0; r < g; r++) {
|
|
3043
|
-
const
|
|
3043
|
+
const c = A[r * 3], F = A[r * 3 + 1], M = A[r * 3 + 2], e = C[c * 3], d = C[c * 3 + 1], Z = C[c * 3 + 2], BA = C[F * 3], AA = C[F * 3 + 1], cA = C[F * 3 + 2], NA = C[M * 3], JA = C[M * 3 + 1], z = C[M * 3 + 2], QA = BA - e, _ = AA - d, aA = cA - Z, b = NA - e, nA = JA - d, SA = z - Z, dA = _ * SA - aA * nA, xA = aA * b - QA * SA, tA = QA * nA - _ * b, gA = 0.5 * Math.hypot(dA, xA, tA);
|
|
3044
3044
|
gA < 1e-12 && D++, o += gA, Q += e * dA + d * xA + Z * tA;
|
|
3045
|
-
for (const [LA, rA] of [[
|
|
3045
|
+
for (const [LA, rA] of [[c, F], [F, M], [M, c]]) {
|
|
3046
3046
|
const CA = iB(LA, rA);
|
|
3047
3047
|
I.set(CA, (I.get(CA) ?? 0) + 1), h(LA, rA);
|
|
3048
3048
|
}
|
|
@@ -3082,14 +3082,14 @@ function oB(C, A, B, g) {
|
|
|
3082
3082
|
let o = 1 / 0, D = -1 / 0;
|
|
3083
3083
|
for (const i of [B[0], g[0]])
|
|
3084
3084
|
for (const G of [B[1], g[1]])
|
|
3085
|
-
for (const
|
|
3086
|
-
const a = I[0] * i + I[1] * G + I[2] *
|
|
3085
|
+
for (const K of [B[2], g[2]]) {
|
|
3086
|
+
const a = I[0] * i + I[1] * G + I[2] * K;
|
|
3087
3087
|
a < o && (o = a), a > D && (D = a);
|
|
3088
3088
|
}
|
|
3089
3089
|
return o <= Q && Q <= D;
|
|
3090
3090
|
}
|
|
3091
3091
|
const yA = vI("printbench-project", () => {
|
|
3092
|
-
const C = t("mm"), A = t("mm"), B = t(""), g = t([]), I = t([]), Q = t([]), o = t(-1), D = t(0), i = t([]), G = MI(),
|
|
3092
|
+
const C = t("mm"), A = t("mm"), B = t(""), g = t([]), I = t([]), Q = t([]), o = t(-1), D = t(0), i = t([]), G = MI(), K = t(null), a = t(null), h = MI([]), Y = MI(), J = t("solid"), H = t("translate"), n = t(!1), r = t("off"), c = t([]), F = t(!1), M = t(!1), e = t([]), d = wA(() => I.value[D.value]), Z = wA(
|
|
3093
3093
|
() => I.value.map((N, s) => N.kind === "primary" ? g.value.find((S) => S.id === N.meshId)?.name ?? `零件 ${s + 1}` : N.kind === "primitive" ? `${N.type} ${s + 1}` : N.kind === "boolean" ? `布尔 ${N.op}` : N.kind === "clean" ? `已修复 ${s + 1}` : N.kind === "sliceBase" ? `切底座 ${s + 1}` : N.kind === "trimPlane" ? `拆件 ${s + 1}` : N.kind === "simplify" ? `简化 ${s + 1}` : N.kind === "merge" ? `合并 ${s + 1}` : `零件 ${s + 1}`)
|
|
3094
3094
|
), BA = wA(
|
|
3095
3095
|
() => I.value.map((N) => {
|
|
@@ -3104,7 +3104,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3104
3104
|
}), NA = wA(() => o.value > 0), JA = wA(() => o.value >= 0 && o.value < Q.value.length - 1);
|
|
3105
3105
|
function z() {
|
|
3106
3106
|
const N = qA(I.value);
|
|
3107
|
-
Q.value = Q.value.slice(0, o.value + 1), Q.value.push(N), o.value = Q.value.length - 1,
|
|
3107
|
+
Q.value = Q.value.slice(0, o.value + 1), Q.value.push(N), o.value = Q.value.length - 1, M.value = !0;
|
|
3108
3108
|
}
|
|
3109
3109
|
function QA(N) {
|
|
3110
3110
|
I.value = qA(N);
|
|
@@ -3127,15 +3127,15 @@ const yA = vI("printbench-project", () => {
|
|
|
3127
3127
|
s.setBusy(!0, "几何内核计算中…");
|
|
3128
3128
|
try {
|
|
3129
3129
|
await _();
|
|
3130
|
-
const
|
|
3130
|
+
const U = await nC({
|
|
3131
3131
|
sources: aA(),
|
|
3132
3132
|
roots: I.value,
|
|
3133
3133
|
wallMinMm: S.state.wallThicknessMinMm,
|
|
3134
3134
|
wantThicknessColors: N
|
|
3135
3135
|
});
|
|
3136
|
-
h.value =
|
|
3137
|
-
} catch (
|
|
3138
|
-
s.toast("fail",
|
|
3136
|
+
h.value = U.meshes, a.value = U.diagnosis, Y.value = U.thicknessColors, G.value = U.defects, e.value = I.value.map((l) => l.kind === "primary" || l.kind === "primitive" || l.kind === "transform" ? Array.from(l.transform) : [...KA]);
|
|
3137
|
+
} catch (U) {
|
|
3138
|
+
s.toast("fail", U instanceof Error ? U.message : "内核计算失败");
|
|
3139
3139
|
} finally {
|
|
3140
3140
|
s.setBusy(!1);
|
|
3141
3141
|
}
|
|
@@ -3144,13 +3144,13 @@ const yA = vI("printbench-project", () => {
|
|
|
3144
3144
|
return s === 1 ? N : N.map((S) => ({
|
|
3145
3145
|
...S,
|
|
3146
3146
|
buffers: {
|
|
3147
|
-
positions: Float32Array.from(S.buffers.positions, (
|
|
3147
|
+
positions: Float32Array.from(S.buffers.positions, (U) => U * s),
|
|
3148
3148
|
indices: S.buffers.indices,
|
|
3149
3149
|
colors: S.buffers.colors
|
|
3150
3150
|
}
|
|
3151
3151
|
}));
|
|
3152
3152
|
}
|
|
3153
|
-
async function SA(N, s, S,
|
|
3153
|
+
async function SA(N, s, S, U, l) {
|
|
3154
3154
|
const m = XI[S];
|
|
3155
3155
|
g.value = nA(
|
|
3156
3156
|
N.map((u) => ({
|
|
@@ -3162,25 +3162,25 @@ const yA = vI("printbench-project", () => {
|
|
|
3162
3162
|
}
|
|
3163
3163
|
})),
|
|
3164
3164
|
m
|
|
3165
|
-
), C.value = "mm", A.value = S, B.value =
|
|
3165
|
+
), C.value = "mm", A.value = S, B.value = U, K.value = s, I.value = g.value.map((u) => ({
|
|
3166
3166
|
kind: "primary",
|
|
3167
3167
|
meshId: u.id,
|
|
3168
3168
|
transform: [...KA]
|
|
3169
|
-
})), Q.value = [qA(I.value)], o.value = 0, D.value = 0, i.value = [0],
|
|
3169
|
+
})), Q.value = [qA(I.value)], o.value = 0, D.value = 0, i.value = [0], c.value = [], await b(), OA();
|
|
3170
3170
|
}
|
|
3171
3171
|
async function dA(N, s) {
|
|
3172
3172
|
const S = IA();
|
|
3173
3173
|
S.setBusy(!0, "解析模型…");
|
|
3174
3174
|
try {
|
|
3175
3175
|
if (N.size > tI) throw new Error("文件过大,请先在外部简化后再导入");
|
|
3176
|
-
const
|
|
3177
|
-
g.value = nA(
|
|
3176
|
+
const U = await $I(N), l = U.declaredUnit ?? s, m = XI[l];
|
|
3177
|
+
g.value = nA(U.meshes, m), C.value = "mm", A.value = U.declaredUnit ?? s, B.value = N.name, K.value = U.summary, I.value = g.value.map((u) => ({
|
|
3178
3178
|
kind: "primary",
|
|
3179
3179
|
meshId: u.id,
|
|
3180
3180
|
transform: [...KA]
|
|
3181
|
-
})), Q.value = [qA(I.value)], o.value = 0, D.value = 0, i.value = [0],
|
|
3182
|
-
} catch (
|
|
3183
|
-
throw S.toast("fail",
|
|
3181
|
+
})), Q.value = [qA(I.value)], o.value = 0, D.value = 0, i.value = [0], c.value = [], await b(), S.toast("ok", `已导入 ${N.name}`), OA();
|
|
3182
|
+
} catch (U) {
|
|
3183
|
+
throw S.toast("fail", U instanceof Error ? U.message : "导入失败"), U;
|
|
3184
3184
|
} finally {
|
|
3185
3185
|
S.setBusy(!1);
|
|
3186
3186
|
}
|
|
@@ -3191,8 +3191,8 @@ const yA = vI("printbench-project", () => {
|
|
|
3191
3191
|
const N = a.value;
|
|
3192
3192
|
if (N && N.items.some((s) => s.level === "red")) {
|
|
3193
3193
|
const s = N.openEdgeCount, S = N.nonManifoldEdgeCount;
|
|
3194
|
-
let
|
|
3195
|
-
S > 200 ?
|
|
3194
|
+
let U = "内核未能完全水密化。";
|
|
3195
|
+
S > 200 ? U = "非流形边过多,建议先简化网格或拆分碎片后再修。" : s > 200 && (U = "破洞过多,建议拆分浮空碎片或回源建模工具补洞后再导入。"), IA().toast("fail", `修复未完全通过:${U}`);
|
|
3196
3196
|
} else
|
|
3197
3197
|
IA().toast("ok", "已应用一键修复,可撤销回退");
|
|
3198
3198
|
OA();
|
|
@@ -3206,15 +3206,15 @@ const yA = vI("printbench-project", () => {
|
|
|
3206
3206
|
function LA(N) {
|
|
3207
3207
|
const s = I.value[N];
|
|
3208
3208
|
if (s?.kind === "primary") {
|
|
3209
|
-
const S = g.value.find((
|
|
3209
|
+
const S = g.value.find((U) => U.id === s.meshId);
|
|
3210
3210
|
S && (S.visible = !S.visible);
|
|
3211
3211
|
}
|
|
3212
3212
|
}
|
|
3213
3213
|
function rA(N, s) {
|
|
3214
3214
|
const S = I.value[N];
|
|
3215
3215
|
if (S?.kind === "primary") {
|
|
3216
|
-
const
|
|
3217
|
-
|
|
3216
|
+
const U = g.value.find((l) => l.id === S.meshId);
|
|
3217
|
+
U && (U.name = s);
|
|
3218
3218
|
}
|
|
3219
3219
|
}
|
|
3220
3220
|
function CA(N) {
|
|
@@ -3224,9 +3224,9 @@ const yA = vI("printbench-project", () => {
|
|
|
3224
3224
|
z();
|
|
3225
3225
|
const s = UA(I.value[N]);
|
|
3226
3226
|
if (s.kind === "primary") {
|
|
3227
|
-
const S = g.value.find((
|
|
3227
|
+
const S = g.value.find((U) => U.id === s.meshId);
|
|
3228
3228
|
if (S) {
|
|
3229
|
-
const
|
|
3229
|
+
const U = {
|
|
3230
3230
|
...S,
|
|
3231
3231
|
id: mA("mesh"),
|
|
3232
3232
|
name: `${S.name} 副本`,
|
|
@@ -3237,7 +3237,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3237
3237
|
},
|
|
3238
3238
|
appearance: S.appearance
|
|
3239
3239
|
};
|
|
3240
|
-
g.value.push(
|
|
3240
|
+
g.value.push(U), s.meshId = U.id;
|
|
3241
3241
|
}
|
|
3242
3242
|
}
|
|
3243
3243
|
I.value.splice(N + 1, 0, s), D.value = N + 1, b();
|
|
@@ -3245,9 +3245,9 @@ const yA = vI("printbench-project", () => {
|
|
|
3245
3245
|
function MA(N, s, S) {
|
|
3246
3246
|
switch (N.kind) {
|
|
3247
3247
|
case "primary": {
|
|
3248
|
-
const
|
|
3249
|
-
|
|
3250
|
-
positions:
|
|
3248
|
+
const U = g.value.find((l) => l.id === N.meshId);
|
|
3249
|
+
U?.buffers.positions.length && S.push({
|
|
3250
|
+
positions: U.buffers.positions,
|
|
3251
3251
|
matrix: s.clone().multiply(new iA().fromArray(N.transform))
|
|
3252
3252
|
});
|
|
3253
3253
|
break;
|
|
@@ -3265,27 +3265,27 @@ const yA = vI("printbench-project", () => {
|
|
|
3265
3265
|
MA(N.node, s, S);
|
|
3266
3266
|
break;
|
|
3267
3267
|
case "merge":
|
|
3268
|
-
N.nodes.forEach((
|
|
3268
|
+
N.nodes.forEach((U) => MA(U, s, S));
|
|
3269
3269
|
break;
|
|
3270
3270
|
}
|
|
3271
3271
|
}
|
|
3272
3272
|
function yI() {
|
|
3273
3273
|
const N = [], s = I.value[D.value];
|
|
3274
3274
|
if (s && MA(s, new iA(), N), N.length || I.value.forEach((v) => MA(v, new iA(), N)), !N.length) return null;
|
|
3275
|
-
const S = new W(1 / 0, 1 / 0, 1 / 0),
|
|
3275
|
+
const S = new W(1 / 0, 1 / 0, 1 / 0), U = new W(-1 / 0, -1 / 0, -1 / 0), l = new W();
|
|
3276
3276
|
for (const { positions: v, matrix: O } of N)
|
|
3277
3277
|
for (let j = 0; j + 2 < v.length; j += 3)
|
|
3278
|
-
l.set(v[j], v[j + 1], v[j + 2]).applyMatrix4(O), S.min(l),
|
|
3278
|
+
l.set(v[j], v[j + 1], v[j + 2]).applyMatrix4(O), S.min(l), U.max(l);
|
|
3279
3279
|
if (!Number.isFinite(S.x)) return null;
|
|
3280
|
-
const m =
|
|
3280
|
+
const m = U.x - S.x, u = U.y - S.y, P = U.z - S.z;
|
|
3281
3281
|
return m <= 0 && u <= 0 && P <= 0 ? null : { x: m, y: u, z: P };
|
|
3282
3282
|
}
|
|
3283
3283
|
function FI(N) {
|
|
3284
3284
|
const s = yI();
|
|
3285
3285
|
if (!s)
|
|
3286
3286
|
return N === "box" ? [20, 20, 20] : N === "cylinder" ? [20 / 3, 20] : N === "sphere" ? [20 / 3] : [20 / 3, 20, 6];
|
|
3287
|
-
const S = (u) => Math.max(1, u / 2),
|
|
3288
|
-
return N === "box" ? [
|
|
3287
|
+
const S = (u) => Math.max(1, u / 2), U = S(s.x), l = S(s.y), m = S(s.z);
|
|
3288
|
+
return N === "box" ? [U, l, m] : N === "cylinder" ? [Math.max(1, Math.min(U, m) / 2), l] : N === "sphere" ? [Math.max(1, Math.max(U, l, m) / 2)] : [Math.max(1, Math.min(U, m) / 2), l, 6];
|
|
3289
3289
|
}
|
|
3290
3290
|
function AI(N) {
|
|
3291
3291
|
z();
|
|
@@ -3306,18 +3306,18 @@ const yA = vI("printbench-project", () => {
|
|
|
3306
3306
|
return;
|
|
3307
3307
|
}
|
|
3308
3308
|
z();
|
|
3309
|
-
const
|
|
3309
|
+
const U = {
|
|
3310
3310
|
kind: "boolean",
|
|
3311
3311
|
op: S,
|
|
3312
3312
|
a: UA(I.value[N]),
|
|
3313
3313
|
b: UA(I.value[s])
|
|
3314
3314
|
}, l = I.value.filter((m, u) => u !== N && u !== s);
|
|
3315
|
-
l.push(
|
|
3315
|
+
l.push(U), I.value = l, D.value = l.length - 1, await b();
|
|
3316
3316
|
}
|
|
3317
3317
|
async function II(N) {
|
|
3318
3318
|
if (N.length < 2) return;
|
|
3319
3319
|
z();
|
|
3320
|
-
const s = N.map((
|
|
3320
|
+
const s = N.map((U) => UA(I.value[U])), S = I.value.filter((U, l) => !N.includes(l));
|
|
3321
3321
|
S.push({ kind: "merge", nodes: s }), I.value = S, D.value = S.length - 1, await b();
|
|
3322
3322
|
}
|
|
3323
3323
|
async function aI() {
|
|
@@ -3329,12 +3329,12 @@ const yA = vI("printbench-project", () => {
|
|
|
3329
3329
|
IA().toast("info", "当前零件没有可拆分的连通分量");
|
|
3330
3330
|
return;
|
|
3331
3331
|
}
|
|
3332
|
-
z(), I.value.splice(N, 1), S.forEach((
|
|
3332
|
+
z(), I.value.splice(N, 1), S.forEach((U, l) => {
|
|
3333
3333
|
const m = {
|
|
3334
3334
|
id: mA("mesh"),
|
|
3335
3335
|
name: `分量 ${l + 1}`,
|
|
3336
3336
|
visible: !0,
|
|
3337
|
-
buffers:
|
|
3337
|
+
buffers: U
|
|
3338
3338
|
};
|
|
3339
3339
|
g.value.push(m), I.value.push({ kind: "primary", meshId: m.id, transform: [...KA] });
|
|
3340
3340
|
}), D.value = I.value.length - 1, await b();
|
|
@@ -3345,10 +3345,10 @@ const yA = vI("printbench-project", () => {
|
|
|
3345
3345
|
IA().toast("info", "请选择原始网格零件再做局部平滑");
|
|
3346
3346
|
return;
|
|
3347
3347
|
}
|
|
3348
|
-
const
|
|
3349
|
-
if (!
|
|
3348
|
+
const U = g.value.find((O) => O.id === S.meshId);
|
|
3349
|
+
if (!U) return;
|
|
3350
3350
|
z();
|
|
3351
|
-
const l = new Float32Array(
|
|
3351
|
+
const l = new Float32Array(U.buffers.positions), m = U.buffers.indices, u = l.length / 3, P = new Float32Array(u * 3), v = new Uint32Array(u);
|
|
3352
3352
|
for (let O = 0; O < m.length; O += 3) {
|
|
3353
3353
|
const j = m[O], pA = m[O + 1], HA = m[O + 2];
|
|
3354
3354
|
for (const [DA, kA] of [[j, pA], [pA, HA], [HA, j]])
|
|
@@ -3357,7 +3357,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3357
3357
|
for (let O = 0; O < N; O++)
|
|
3358
3358
|
for (let j = 0; j < u; j++)
|
|
3359
3359
|
v[j] && (l[j * 3] = l[j * 3] * 0.4 + P[j * 3] / v[j] * 0.6, l[j * 3 + 1] = l[j * 3 + 1] * 0.4 + P[j * 3 + 1] / v[j] * 0.6, l[j * 3 + 2] = l[j * 3 + 2] * 0.4 + P[j * 3 + 2] / v[j] * 0.6);
|
|
3360
|
-
|
|
3360
|
+
U.buffers = { ...U.buffers, positions: l }, b();
|
|
3361
3361
|
}
|
|
3362
3362
|
function lI() {
|
|
3363
3363
|
const N = D.value, s = I.value[N];
|
|
@@ -3368,14 +3368,14 @@ const yA = vI("printbench-project", () => {
|
|
|
3368
3368
|
const S = g.value.find((l) => l.id === s.meshId);
|
|
3369
3369
|
if (!S) return;
|
|
3370
3370
|
z();
|
|
3371
|
-
const
|
|
3372
|
-
S.buffers = { positions:
|
|
3371
|
+
const U = rC(S.buffers.positions, S.buffers.indices);
|
|
3372
|
+
S.buffers = { positions: U.positions, indices: U.indices }, b();
|
|
3373
3373
|
}
|
|
3374
3374
|
async function dI(N, s = "y") {
|
|
3375
3375
|
const S = D.value;
|
|
3376
3376
|
I.value[S] && (z(), I.value[S] = { kind: "sliceBase", node: UA(I.value[S]), height: N, axis: s }, await b());
|
|
3377
3377
|
}
|
|
3378
|
-
async function xI(N, s, S,
|
|
3378
|
+
async function xI(N, s, S, U, l, m = "none", u = 0) {
|
|
3379
3379
|
const P = IA(), v = I.value[N], O = h.value[N];
|
|
3380
3380
|
if (!v || !O)
|
|
3381
3381
|
return P.toast("fail", "请先选择要拆件的零件"), !1;
|
|
@@ -3391,7 +3391,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3391
3391
|
return P.toast("fail", "当前零件体积过小,无法拆件"), !1;
|
|
3392
3392
|
if (!oB(s, S, DA.bbox.min, DA.bbox.max))
|
|
3393
3393
|
return P.toast("fail", "切面未穿过当前零件"), !1;
|
|
3394
|
-
const { normal: mI, offset: VI } = Sg(s, S), QI = m !== "none" ? 0 :
|
|
3394
|
+
const { normal: mI, offset: VI } = Sg(s, S), QI = m !== "none" ? 0 : U;
|
|
3395
3395
|
await _();
|
|
3396
3396
|
let hA;
|
|
3397
3397
|
try {
|
|
@@ -3426,15 +3426,15 @@ const yA = vI("printbench-project", () => {
|
|
|
3426
3426
|
return !0;
|
|
3427
3427
|
}
|
|
3428
3428
|
function CI(N, s, S = !0) {
|
|
3429
|
-
const
|
|
3430
|
-
if (!
|
|
3431
|
-
const l =
|
|
3429
|
+
const U = I.value[N];
|
|
3430
|
+
if (!U) return;
|
|
3431
|
+
const l = U.kind === "primary" || U.kind === "primitive" || U.kind === "transform" ? [...U.transform] : null, m = new iA().fromArray(s);
|
|
3432
3432
|
if (S && gI(m)) return;
|
|
3433
3433
|
const u = e.value[N] ?? l ?? KA, P = new iA().fromArray(u), v = S ? new iA().multiplyMatrices(m, P) : m, O = Array.from(v.elements).slice(0, 16);
|
|
3434
|
-
z(),
|
|
3434
|
+
z(), U.kind === "primary" || U.kind === "primitive" || U.kind === "transform" ? U.transform = O : I.value[N] = { kind: "transform", node: UA(U), transform: O }, S || b();
|
|
3435
3435
|
}
|
|
3436
3436
|
function SI(N) {
|
|
3437
|
-
const s = I.value[N], S = s && (s.kind === "primary" || s.kind === "primitive" || s.kind === "transform") ? s.transform : KA,
|
|
3437
|
+
const s = I.value[N], S = s && (s.kind === "primary" || s.kind === "primitive" || s.kind === "transform") ? s.transform : KA, U = e.value[N] ?? KA, l = new iA().fromArray(S), m = new iA().fromArray(U), u = new iA().multiplyMatrices(l, m.clone().invert());
|
|
3438
3438
|
return gI(u) ? null : Array.from(u.elements);
|
|
3439
3439
|
}
|
|
3440
3440
|
function kI(N, s = !1) {
|
|
@@ -3442,8 +3442,8 @@ const yA = vI("printbench-project", () => {
|
|
|
3442
3442
|
i.value = S, S.length && (D.value = S[S.length - 1]);
|
|
3443
3443
|
}
|
|
3444
3444
|
function BI(N, s) {
|
|
3445
|
-
const S = new iA(),
|
|
3446
|
-
S.compose(new W(s.x, s.y, s.z), new Kg().setFromEuler(
|
|
3445
|
+
const S = new iA(), U = new jg(s.rx * Math.PI / 180, s.ry * Math.PI / 180, s.rz * Math.PI / 180, "XYZ");
|
|
3446
|
+
S.compose(new W(s.x, s.y, s.z), new Kg().setFromEuler(U), new W(s.sx, s.sy, s.sz)), CI(N, Array.from(S.elements), !1);
|
|
3447
3447
|
}
|
|
3448
3448
|
function PA() {
|
|
3449
3449
|
return {
|
|
@@ -3474,7 +3474,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3474
3474
|
})), I.value = qA(N.roots), Q.value = N.history.map(qA), o.value = N.historyIndex, await b();
|
|
3475
3475
|
}
|
|
3476
3476
|
function OA() {
|
|
3477
|
-
|
|
3477
|
+
M.value = !0, gB(PA());
|
|
3478
3478
|
}
|
|
3479
3479
|
async function fI() {
|
|
3480
3480
|
const N = await ag();
|
|
@@ -3492,7 +3492,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3492
3492
|
selected: D,
|
|
3493
3493
|
selectedIds: i,
|
|
3494
3494
|
defects: G,
|
|
3495
|
-
summary:
|
|
3495
|
+
summary: K,
|
|
3496
3496
|
diagnosis: a,
|
|
3497
3497
|
evaluated: h,
|
|
3498
3498
|
thicknessColors: Y,
|
|
@@ -3500,7 +3500,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3500
3500
|
transformMode: H,
|
|
3501
3501
|
showThickness: n,
|
|
3502
3502
|
measureMode: r,
|
|
3503
|
-
measurements:
|
|
3503
|
+
measurements: c,
|
|
3504
3504
|
selectedNode: d,
|
|
3505
3505
|
partNames: Z,
|
|
3506
3506
|
visibility: AA,
|
|
@@ -3509,7 +3509,7 @@ const yA = vI("printbench-project", () => {
|
|
|
3509
3509
|
canUndo: NA,
|
|
3510
3510
|
canRedo: JA,
|
|
3511
3511
|
kernelReady: F,
|
|
3512
|
-
dirty:
|
|
3512
|
+
dirty: M,
|
|
3513
3513
|
importFile: dA,
|
|
3514
3514
|
importParsed: SA,
|
|
3515
3515
|
evaluate: b,
|
|
@@ -3620,12 +3620,12 @@ class wB {
|
|
|
3620
3620
|
}
|
|
3621
3621
|
syncMeshes(A, B, g, I, Q, o, D = !1, i) {
|
|
3622
3622
|
this.clearModels();
|
|
3623
|
-
const G = new Set(Array.isArray(o) ? o : o === void 0 ? [] : [o]),
|
|
3623
|
+
const G = new Set(Array.isArray(o) ? o : o === void 0 ? [] : [o]), K = A.reduce((a, h) => a + h.indices.length / 3, 0) > 8e4;
|
|
3624
3624
|
if (A.forEach((a, h) => {
|
|
3625
3625
|
const Y = new vA();
|
|
3626
3626
|
Y.setAttribute("position", new oA(a.positions, 3)), Y.setIndex(new oA(a.indices, 1)), Y.computeVertexNormals(), Y.computeBoundingBox();
|
|
3627
3627
|
let J;
|
|
3628
|
-
const H = a.positions.length / 3, n = i?.[h], r = !!n?.uvs && n.uvs.length === H * 2,
|
|
3628
|
+
const H = a.positions.length / 3, n = i?.[h], r = !!n?.uvs && n.uvs.length === H * 2, c = !!n?.colors && n.colors.length === H * 3, F = r && !!n?.texture, M = c && !Q?.[h];
|
|
3629
3629
|
if (I === "normals")
|
|
3630
3630
|
J = new vg({ side: eA, flatShading: !0 });
|
|
3631
3631
|
else if (Q?.[h])
|
|
@@ -3635,8 +3635,8 @@ class wB {
|
|
|
3635
3635
|
roughness: 0.7,
|
|
3636
3636
|
side: eA
|
|
3637
3637
|
});
|
|
3638
|
-
else if (F ||
|
|
3639
|
-
|
|
3638
|
+
else if (F || M || n?.baseColor) {
|
|
3639
|
+
M && n?.colors && Y.setAttribute("color", new oA(n.colors, 3)), F && n?.uvs && Y.setAttribute("uv", new oA(n.uvs, 2));
|
|
3640
3640
|
const d = n?.texture, Z = F && d ? (() => {
|
|
3641
3641
|
const AA = new Cg(d);
|
|
3642
3642
|
return AA.colorSpace = $g, AA.flipY = n?.flipY ?? !1, AA.needsUpdate = !0, AA;
|
|
@@ -3644,14 +3644,14 @@ class wB {
|
|
|
3644
3644
|
J = new YA({
|
|
3645
3645
|
color: BA,
|
|
3646
3646
|
map: Z,
|
|
3647
|
-
vertexColors:
|
|
3647
|
+
vertexColors: M,
|
|
3648
3648
|
metalness: Z ? 0.04 : 0.08,
|
|
3649
3649
|
roughness: Z ? 0.72 : 0.55,
|
|
3650
3650
|
transparent: I === "transparent",
|
|
3651
3651
|
opacity: I === "transparent" ? 0.45 : 1,
|
|
3652
3652
|
wireframe: I === "wireframe",
|
|
3653
3653
|
side: eA,
|
|
3654
|
-
flatShading:
|
|
3654
|
+
flatShading: K && !Z
|
|
3655
3655
|
});
|
|
3656
3656
|
} else
|
|
3657
3657
|
J = new YA({
|
|
@@ -3662,7 +3662,7 @@ class wB {
|
|
|
3662
3662
|
opacity: I === "transparent" ? 0.45 : 1,
|
|
3663
3663
|
wireframe: I === "wireframe",
|
|
3664
3664
|
side: eA,
|
|
3665
|
-
flatShading:
|
|
3665
|
+
flatShading: K
|
|
3666
3666
|
});
|
|
3667
3667
|
this.clipping && (J.clippingPlanes = [this.clipPlane]);
|
|
3668
3668
|
const e = new NI(Y, J);
|
|
@@ -3711,13 +3711,13 @@ class wB {
|
|
|
3711
3711
|
const Q = I.geometry, o = Q.getAttribute("position"), D = Q.getIndex();
|
|
3712
3712
|
if (!o || g.faceIndex === void 0) return { ...g, kind: "face" };
|
|
3713
3713
|
I.updateMatrixWorld();
|
|
3714
|
-
const i = new W(), G = [],
|
|
3715
|
-
for (const
|
|
3716
|
-
i.set(o.getX(
|
|
3714
|
+
const i = new W(), G = [], K = D ? D.getX(g.faceIndex * 3) : g.faceIndex * 3, a = D ? D.getX(g.faceIndex * 3 + 1) : g.faceIndex * 3 + 1, h = D ? D.getX(g.faceIndex * 3 + 2) : g.faceIndex * 3 + 2;
|
|
3715
|
+
for (const M of [K, a, h])
|
|
3716
|
+
i.set(o.getX(M), o.getY(M), o.getZ(M)).applyMatrix4(I.matrixWorld), G.push(i.clone());
|
|
3717
3717
|
let Y = G[0], J = g.point.distanceTo(G[0]);
|
|
3718
|
-
for (const
|
|
3719
|
-
const e = g.point.distanceTo(
|
|
3720
|
-
e < J && (J = e, Y =
|
|
3718
|
+
for (const M of G) {
|
|
3719
|
+
const e = g.point.distanceTo(M);
|
|
3720
|
+
e < J && (J = e, Y = M);
|
|
3721
3721
|
}
|
|
3722
3722
|
const H = new fA().setFromObject(I).getSize(new W()).length() || 10;
|
|
3723
3723
|
if (J < H * 0.02) return { index: g.index, point: Y, kind: "vertex" };
|
|
@@ -3726,23 +3726,23 @@ class wB {
|
|
|
3726
3726
|
G[1].clone().add(G[2]).multiplyScalar(0.5),
|
|
3727
3727
|
G[2].clone().add(G[0]).multiplyScalar(0.5)
|
|
3728
3728
|
];
|
|
3729
|
-
let r = n[0],
|
|
3730
|
-
for (const
|
|
3731
|
-
const e = g.point.distanceTo(
|
|
3732
|
-
e <
|
|
3729
|
+
let r = n[0], c = g.point.distanceTo(n[0]);
|
|
3730
|
+
for (const M of n) {
|
|
3731
|
+
const e = g.point.distanceTo(M);
|
|
3732
|
+
e < c && (c = e, r = M);
|
|
3733
3733
|
}
|
|
3734
|
-
if (
|
|
3734
|
+
if (c < H * 0.025) return { index: g.index, point: r, kind: "edge" };
|
|
3735
3735
|
const F = G[0].clone().add(G[1]).add(G[2]).multiplyScalar(1 / 3);
|
|
3736
3736
|
return { index: g.index, point: F, kind: "face" };
|
|
3737
3737
|
}
|
|
3738
3738
|
partsInRect(A, B, g, I, Q, o) {
|
|
3739
|
-
const D = Math.min(A, g), i = Math.max(A, g), G = Math.min(B, I),
|
|
3739
|
+
const D = Math.min(A, g), i = Math.max(A, g), G = Math.min(B, I), K = Math.max(B, I), a = [], h = new W();
|
|
3740
3740
|
return this.meshes.forEach((Y, J) => {
|
|
3741
3741
|
const H = new fA().setFromObject(Y);
|
|
3742
3742
|
if (H.isEmpty()) return;
|
|
3743
3743
|
H.getCenter(h), h.project(this.camera);
|
|
3744
3744
|
const n = (h.x * 0.5 + 0.5) * Q, r = (-h.y * 0.5 + 0.5) * o;
|
|
3745
|
-
n >= D && n <= i && r >= G && r <=
|
|
3745
|
+
n >= D && n <= i && r >= G && r <= K && a.push(J);
|
|
3746
3746
|
}), a;
|
|
3747
3747
|
}
|
|
3748
3748
|
attachGizmo(A, B) {
|
|
@@ -3819,7 +3819,7 @@ class wB {
|
|
|
3819
3819
|
o.applyMatrix4(I.matrixWorld), D.applyMatrix4(Q.matrixWorld);
|
|
3820
3820
|
const i = new Qg(o), G = new Qg(D);
|
|
3821
3821
|
i.matrixAutoUpdate = !1, G.matrixAutoUpdate = !1, i.updateMatrixWorld(!0), G.updateMatrixWorld(!0);
|
|
3822
|
-
const
|
|
3822
|
+
const K = g === "union" ? sC : g === "difference" ? RC : yC, a = this.evaluator.evaluate(i, G, K);
|
|
3823
3823
|
a.matrixAutoUpdate = !1, a.matrix.identity(), a.updateMatrixWorld(!0);
|
|
3824
3824
|
const h = a.geometry.getAttribute("position");
|
|
3825
3825
|
return a.material = new YA({
|
|
@@ -3978,7 +3978,7 @@ function GB(C) {
|
|
|
3978
3978
|
}
|
|
3979
3979
|
const hg = /* @__PURE__ */ Symbol("printbench-upload-url"), Yg = /* @__PURE__ */ Symbol("printbench-model-url"), Ug = /* @__PURE__ */ Symbol("printbench-custom-export"), Ag = /* @__PURE__ */ Symbol("printbench-hooks");
|
|
3980
3980
|
function sB(C) {
|
|
3981
|
-
const A = yA(), B = sI(), g = IA(), I = t(!1), Q = t(!1), o = t(""), D = t(null), i = t("mm"), G = t(!1),
|
|
3981
|
+
const A = yA(), B = sI(), g = IA(), I = t(!1), Q = t(!1), o = t(""), D = t(null), i = t("mm"), G = t(!1), K = MI(null);
|
|
3982
3982
|
function a() {
|
|
3983
3983
|
Q.value = !0;
|
|
3984
3984
|
}
|
|
@@ -3986,15 +3986,15 @@ function sB(C) {
|
|
|
3986
3986
|
D.value = F, i.value = B.state.defaultUnit, I.value = !0, g.setBusy(!0, "解析模型…");
|
|
3987
3987
|
try {
|
|
3988
3988
|
if (F.size > tI) throw new Error("文件过大,请先在外部简化后再导入");
|
|
3989
|
-
const
|
|
3990
|
-
|
|
3991
|
-
meshes:
|
|
3992
|
-
summary:
|
|
3993
|
-
declared:
|
|
3989
|
+
const M = await $I(F);
|
|
3990
|
+
M.declaredUnit && (i.value = M.declaredUnit), K.value = {
|
|
3991
|
+
meshes: M.meshes,
|
|
3992
|
+
summary: M.summary,
|
|
3993
|
+
declared: M.declaredUnit,
|
|
3994
3994
|
name: F.name
|
|
3995
|
-
}, C.resetFit(), await A.importParsed(
|
|
3996
|
-
} catch (
|
|
3997
|
-
g.toast("fail",
|
|
3995
|
+
}, C.resetFit(), await A.importParsed(M.meshes, M.summary, "mm", F.name, M.declaredUnit), G.value = !0, C.onLoaded();
|
|
3996
|
+
} catch (M) {
|
|
3997
|
+
g.toast("fail", M instanceof Error ? M.message : "导入失败"), I.value = !1;
|
|
3998
3998
|
} finally {
|
|
3999
3999
|
g.setBusy(!1);
|
|
4000
4000
|
}
|
|
@@ -4002,8 +4002,8 @@ function sB(C) {
|
|
|
4002
4002
|
function Y() {
|
|
4003
4003
|
const F = document.createElement("input");
|
|
4004
4004
|
F.type = "file", F.accept = WC, F.onchange = () => {
|
|
4005
|
-
const
|
|
4006
|
-
|
|
4005
|
+
const M = F.files?.[0];
|
|
4006
|
+
M && (Q.value = !1, h(M));
|
|
4007
4007
|
}, F.click();
|
|
4008
4008
|
}
|
|
4009
4009
|
async function J() {
|
|
@@ -4014,35 +4014,35 @@ function sB(C) {
|
|
|
4014
4014
|
}
|
|
4015
4015
|
Q.value = !1, g.setBusy(!0, "正在下载模型…");
|
|
4016
4016
|
try {
|
|
4017
|
-
const
|
|
4018
|
-
await h(
|
|
4019
|
-
} catch (
|
|
4020
|
-
g.toast("fail",
|
|
4017
|
+
const M = await _C(F);
|
|
4018
|
+
await h(M);
|
|
4019
|
+
} catch (M) {
|
|
4020
|
+
g.toast("fail", M instanceof Error ? M.message : "导入失败");
|
|
4021
4021
|
} finally {
|
|
4022
4022
|
g.setBusy(!1);
|
|
4023
4023
|
}
|
|
4024
4024
|
}
|
|
4025
4025
|
async function H() {
|
|
4026
|
-
if (!
|
|
4026
|
+
if (!K.value) return;
|
|
4027
4027
|
I.value = !1, C.resetFit();
|
|
4028
|
-
const F =
|
|
4028
|
+
const F = K.value;
|
|
4029
4029
|
await A.importParsed(F.meshes, F.summary, i.value, F.name, F.declared), g.toast("ok", `已导入 ${F.name}`), C.onLoaded();
|
|
4030
4030
|
}
|
|
4031
4031
|
function n(F) {
|
|
4032
4032
|
F.preventDefault();
|
|
4033
|
-
const
|
|
4034
|
-
|
|
4033
|
+
const M = F.dataTransfer?.files?.[0];
|
|
4034
|
+
M && h(M);
|
|
4035
4035
|
}
|
|
4036
4036
|
function r(F) {
|
|
4037
|
-
const
|
|
4038
|
-
if (
|
|
4039
|
-
h(
|
|
4037
|
+
const M = F.clipboardData?.files?.[0];
|
|
4038
|
+
if (M) {
|
|
4039
|
+
h(M);
|
|
4040
4040
|
return;
|
|
4041
4041
|
}
|
|
4042
4042
|
const e = F.clipboardData?.getData("text")?.trim() ?? "";
|
|
4043
4043
|
(/^https?:\/\/\S+/i.test(e) || /\.(glb|gltf|stl|obj|3mf|zip)(\?|#|$)/i.test(e)) && (F.preventDefault(), o.value = e, Q.value = !0);
|
|
4044
4044
|
}
|
|
4045
|
-
async function
|
|
4045
|
+
async function c(F) {
|
|
4046
4046
|
o.value = F, await J();
|
|
4047
4047
|
}
|
|
4048
4048
|
return {
|
|
@@ -4052,7 +4052,7 @@ function sB(C) {
|
|
|
4052
4052
|
pendingFile: D,
|
|
4053
4053
|
chosenUnit: i,
|
|
4054
4054
|
summaryOpen: G,
|
|
4055
|
-
rawImport:
|
|
4055
|
+
rawImport: K,
|
|
4056
4056
|
openImportSource: a,
|
|
4057
4057
|
openPicker: Y,
|
|
4058
4058
|
importFromUrl: J,
|
|
@@ -4060,7 +4060,7 @@ function sB(C) {
|
|
|
4060
4060
|
beginImport: h,
|
|
4061
4061
|
onDrop: n,
|
|
4062
4062
|
onPaste: r,
|
|
4063
|
-
importAutoUrl:
|
|
4063
|
+
importAutoUrl: c
|
|
4064
4064
|
};
|
|
4065
4065
|
}
|
|
4066
4066
|
function RB(C, A) {
|
|
@@ -4099,11 +4099,11 @@ function cg(C) {
|
|
|
4099
4099
|
}
|
|
4100
4100
|
class Jg extends Error {
|
|
4101
4101
|
constructor() {
|
|
4102
|
-
super("
|
|
4102
|
+
super("尚未配置上传地址,请传入 uploadUrl"), this.name = "UploadEndpointReservedError";
|
|
4103
4103
|
}
|
|
4104
4104
|
}
|
|
4105
4105
|
function FB(C) {
|
|
4106
|
-
return (C ??
|
|
4106
|
+
return (C ?? "").trim();
|
|
4107
4107
|
}
|
|
4108
4108
|
async function aB(C, A, B) {
|
|
4109
4109
|
const g = FB(B?.endpoint);
|
|
@@ -4124,71 +4124,72 @@ async function aB(C, A, B) {
|
|
|
4124
4124
|
return (o.headers.get("content-type") ?? "").includes("application/json") ? { id: (await o.json()).id ?? null } : { id: null };
|
|
4125
4125
|
}
|
|
4126
4126
|
function SB(C) {
|
|
4127
|
-
const A = yA(), B = sI(), g = IA(), I = KI(hg, t(void 0)), Q = KI(Ug, t(!1)), o = KI(Ag, {}), D = t(!1), i = t("stl"), G = t("mm"),
|
|
4127
|
+
const A = yA(), B = sI(), g = IA(), I = KI(hg, t(void 0)), Q = KI(Ug, t(!1)), o = KI(Ag, {}), D = t(!1), i = t("stl"), G = t("mm"), K = t(0);
|
|
4128
4128
|
async function a() {
|
|
4129
4129
|
if (A.roots.length) {
|
|
4130
4130
|
if (LI(A.diagnosis)) {
|
|
4131
4131
|
g.toast("fail", "存在阻断打印的问题,已拦截导出。请先修复。");
|
|
4132
|
-
const
|
|
4133
|
-
|
|
4132
|
+
const c = A.diagnosis?.items.find((F) => F.level === "red");
|
|
4133
|
+
c && C.onBlocking(c.id);
|
|
4134
4134
|
return;
|
|
4135
4135
|
}
|
|
4136
|
-
NB(A.diagnosis) && !await g.ask("存在建议处理项", "仍有黄色警告。继续导出可能导致打印质量问题,是否继续?") || (i.value = B.state.defaultExport, G.value = "mm",
|
|
4136
|
+
NB(A.diagnosis) && !await g.ask("存在建议处理项", "仍有黄色警告。继续导出可能导致打印质量问题,是否继续?") || (i.value = B.state.defaultExport, G.value = "mm", K.value = 0, D.value = !0);
|
|
4137
4137
|
}
|
|
4138
4138
|
}
|
|
4139
|
-
function h(
|
|
4140
|
-
const e = new Blob([new Uint8Array(
|
|
4139
|
+
function h(c, F, M) {
|
|
4140
|
+
const e = new Blob([new Uint8Array(c)], { type: M }), d = document.createElement("a");
|
|
4141
4141
|
d.href = URL.createObjectURL(e), d.download = F, d.click(), URL.revokeObjectURL(d.href);
|
|
4142
4142
|
}
|
|
4143
4143
|
async function Y() {
|
|
4144
|
-
const
|
|
4144
|
+
const c = A.fileName.replace(/\.[^.]+$/, "") || "printbench", F = 1 / XI[G.value], M = A.evaluated.map((d, Z) => {
|
|
4145
4145
|
const BA = A.pendingDisplayMatrix(Z), AA = BA ? Rg(d.positions, BA) : d.positions;
|
|
4146
4146
|
return {
|
|
4147
4147
|
...d,
|
|
4148
4148
|
positions: F === 1 ? AA : Float32Array.from(AA, (cA) => cA * F)
|
|
4149
4149
|
};
|
|
4150
4150
|
});
|
|
4151
|
-
if (
|
|
4152
|
-
const d = await yB(
|
|
4151
|
+
if (K.value = 55, i.value === "stl") {
|
|
4152
|
+
const d = await yB(M, c, [...A.partNames]);
|
|
4153
4153
|
if (d.name.endsWith(".stl") && !cg(d.buf)) throw new Error("导出文件头校验失败");
|
|
4154
4154
|
return d;
|
|
4155
4155
|
}
|
|
4156
|
-
const e = await dC(
|
|
4156
|
+
const e = await dC(M, c, [...A.partNames]);
|
|
4157
4157
|
if (!await xC(e)) throw new Error("3MF 读回校验失败");
|
|
4158
|
-
return { buf: e, name: `${
|
|
4158
|
+
return { buf: e, name: `${c}.3mf`, mime: "model/3mf" };
|
|
4159
4159
|
}
|
|
4160
|
-
function J(
|
|
4161
|
-
const
|
|
4160
|
+
function J(c, F, M, e) {
|
|
4161
|
+
const d = new Blob([new Uint8Array(c)], { type: M });
|
|
4162
4162
|
return o.onExported?.({
|
|
4163
|
+
action: e,
|
|
4163
4164
|
format: i.value,
|
|
4164
4165
|
fileName: F,
|
|
4165
|
-
blob:
|
|
4166
|
+
blob: d,
|
|
4166
4167
|
unit: G.value
|
|
4167
|
-
}),
|
|
4168
|
+
}), d;
|
|
4168
4169
|
}
|
|
4169
|
-
async function H() {
|
|
4170
|
-
g.setBusy(!0, "正在导出…"),
|
|
4170
|
+
async function H(c) {
|
|
4171
|
+
g.setBusy(!0, "正在导出…"), K.value = 10;
|
|
4171
4172
|
try {
|
|
4172
|
-
const { buf:
|
|
4173
|
-
J(
|
|
4174
|
-
} catch (
|
|
4175
|
-
const
|
|
4176
|
-
g.toast("fail",
|
|
4173
|
+
const { buf: F, name: M, mime: e } = await Y();
|
|
4174
|
+
J(F, M, e, c), g.toast("ok", `已导出 ${M} · ${(F.byteLength / 1024).toFixed(1)} KB`), K.value = 100, D.value = !1;
|
|
4175
|
+
} catch (F) {
|
|
4176
|
+
const M = F instanceof Error ? F.message : "导出失败";
|
|
4177
|
+
g.toast("fail", M), o.onError?.(M);
|
|
4177
4178
|
} finally {
|
|
4178
4179
|
g.setBusy(!1);
|
|
4179
4180
|
}
|
|
4180
4181
|
}
|
|
4181
4182
|
async function n() {
|
|
4182
4183
|
if (Q.value) {
|
|
4183
|
-
await H();
|
|
4184
|
+
await H("download");
|
|
4184
4185
|
return;
|
|
4185
4186
|
}
|
|
4186
|
-
g.setBusy(!0, "正在导出…"),
|
|
4187
|
+
g.setBusy(!0, "正在导出…"), K.value = 10;
|
|
4187
4188
|
try {
|
|
4188
|
-
const { buf:
|
|
4189
|
-
h(
|
|
4190
|
-
} catch (
|
|
4191
|
-
const F =
|
|
4189
|
+
const { buf: c, name: F, mime: M } = await Y();
|
|
4190
|
+
h(c, F, M), J(c, F, M, "download"), g.toast("ok", `已导出 ${F} · ${(c.byteLength / 1024).toFixed(1)} KB`), K.value = 100, D.value = !1;
|
|
4191
|
+
} catch (c) {
|
|
4192
|
+
const F = c instanceof Error ? c.message : "导出失败";
|
|
4192
4193
|
g.toast("fail", F), o.onError?.(F);
|
|
4193
4194
|
} finally {
|
|
4194
4195
|
g.setBusy(!1);
|
|
@@ -4196,14 +4197,14 @@ function SB(C) {
|
|
|
4196
4197
|
}
|
|
4197
4198
|
async function r() {
|
|
4198
4199
|
if (Q.value) {
|
|
4199
|
-
await H();
|
|
4200
|
+
await H("upload");
|
|
4200
4201
|
return;
|
|
4201
4202
|
}
|
|
4202
|
-
g.setBusy(!0, "正在导出并上传…"),
|
|
4203
|
+
g.setBusy(!0, "正在导出并上传…"), K.value = 10;
|
|
4203
4204
|
try {
|
|
4204
|
-
const { buf:
|
|
4205
|
-
|
|
4206
|
-
const e = new Blob([new Uint8Array(
|
|
4205
|
+
const { buf: c, name: F, mime: M } = await Y();
|
|
4206
|
+
K.value = 80;
|
|
4207
|
+
const e = new Blob([new Uint8Array(c)], { type: M }), d = await aB(
|
|
4207
4208
|
e,
|
|
4208
4209
|
{
|
|
4209
4210
|
fileName: F,
|
|
@@ -4212,12 +4213,12 @@ function SB(C) {
|
|
|
4212
4213
|
},
|
|
4213
4214
|
{ endpoint: I.value }
|
|
4214
4215
|
);
|
|
4215
|
-
J(
|
|
4216
|
-
} catch (
|
|
4217
|
-
if (
|
|
4218
|
-
g.toast("info",
|
|
4216
|
+
J(c, F, M, "upload"), K.value = 100, D.value = !1, g.toast("ok", d.id ? `已上传 ${F} · ${d.id}` : `已上传 ${F}`);
|
|
4217
|
+
} catch (c) {
|
|
4218
|
+
if (c instanceof Jg)
|
|
4219
|
+
g.toast("info", c.message);
|
|
4219
4220
|
else {
|
|
4220
|
-
const F =
|
|
4221
|
+
const F = c instanceof Error ? c.message : "上传失败";
|
|
4221
4222
|
g.toast("fail", F), o.onError?.(F);
|
|
4222
4223
|
}
|
|
4223
4224
|
} finally {
|
|
@@ -4228,7 +4229,7 @@ function SB(C) {
|
|
|
4228
4229
|
exportOpen: D,
|
|
4229
4230
|
exportFmt: i,
|
|
4230
4231
|
exportUnit: G,
|
|
4231
|
-
exportProgress:
|
|
4232
|
+
exportProgress: K,
|
|
4232
4233
|
openExport: a,
|
|
4233
4234
|
confirmExport: n,
|
|
4234
4235
|
uploadExport: r
|
|
@@ -4245,12 +4246,12 @@ function kB() {
|
|
|
4245
4246
|
async function D() {
|
|
4246
4247
|
await BB(I.value || "未命名项目", C.snapshot()), await Q(), A.toast("ok", "已保存命名草稿");
|
|
4247
4248
|
}
|
|
4248
|
-
async function i(
|
|
4249
|
-
const a = await EB(
|
|
4249
|
+
async function i(K) {
|
|
4250
|
+
const a = await EB(K);
|
|
4250
4251
|
a && await C.restore(a), B.value = !1;
|
|
4251
4252
|
}
|
|
4252
|
-
async function G(
|
|
4253
|
-
await DB(
|
|
4253
|
+
async function G(K) {
|
|
4254
|
+
await DB(K), await Q();
|
|
4254
4255
|
}
|
|
4255
4256
|
return {
|
|
4256
4257
|
draftsOpen: B,
|
|
@@ -4642,7 +4643,7 @@ const FA = /* @__PURE__ */ $({
|
|
|
4642
4643
|
], -1)),
|
|
4643
4644
|
I[13] || (I[13] = E("p", null, [
|
|
4644
4645
|
E("b", null, "导出"),
|
|
4645
|
-
V(":红级拦截并定位缺陷;黄级可选择继续。STL 沿用当前导入/编辑后的轴向,可选导出单位(推荐毫米)。多个零件时 STL 导出为 zip、3MF 按对象分件,导入后零件数不变。一键上传 POST
|
|
4646
|
+
V(":红级拦截并定位缺陷;黄级可选择继续。STL 沿用当前导入/编辑后的轴向,可选导出单位(推荐毫米)。多个零件时 STL 导出为 zip、3MF 按对象分件,导入后零件数不变。一键上传 POST 至传入的 uploadUrl(multipart:file + meta)。")
|
|
4646
4647
|
], -1)),
|
|
4647
4648
|
I[14] || (I[14] = E("p", null, [
|
|
4648
4649
|
E("b", null, "审核与草稿"),
|
|
@@ -4953,14 +4954,14 @@ const FA = /* @__PURE__ */ $({
|
|
|
4953
4954
|
(L(!0), q(uA, null, jA(k(g).partNames, (i, G) => (L(), q("div", {
|
|
4954
4955
|
key: G,
|
|
4955
4956
|
class: VA(["item", { active: k(g).selectedIds.includes(G) || k(g).selected === G }]),
|
|
4956
|
-
onClick: (
|
|
4957
|
-
onContextmenu: GI((
|
|
4957
|
+
onClick: (K) => B("select", G, K),
|
|
4958
|
+
onContextmenu: GI((K) => B("part-menu", { x: K.clientX, y: K.clientY, i: G }), ["prevent"])
|
|
4958
4959
|
}, [
|
|
4959
4960
|
E("input", {
|
|
4960
4961
|
type: "checkbox",
|
|
4961
4962
|
checked: k(g).visibility[G],
|
|
4962
4963
|
title: "显示/隐藏",
|
|
4963
|
-
onClick: GI((
|
|
4964
|
+
onClick: GI((K) => k(g).toggleVisible(G), ["stop"])
|
|
4964
4965
|
}, null, 8, VQ),
|
|
4965
4966
|
E("span", uQ, p(G + 1), 1),
|
|
4966
4967
|
E("span", jQ, p(i), 1)
|
|
@@ -5376,9 +5377,9 @@ const FA = /* @__PURE__ */ $({
|
|
|
5376
5377
|
setup(C) {
|
|
5377
5378
|
const A = yA(), B = sI(), g = IA(), I = KI(Yg, t(void 0)), Q = KI(Ag, {}), o = t(null), D = t(null), i = MI(null);
|
|
5378
5379
|
let G = null;
|
|
5379
|
-
const
|
|
5380
|
+
const K = t(!1), a = t(!1), h = t(!1), Y = t(-1), J = t("difference"), H = t(1), n = t(!1), r = t(0);
|
|
5380
5381
|
t(0.5);
|
|
5381
|
-
const
|
|
5382
|
+
const c = t(""), F = t(null), M = t([]), e = t(""), d = t(null), Z = t(!1), BA = t(0), AA = t(null), cA = t({ x: 0, y: 0, z: 0, rx: 0, ry: 0, rz: 0, sx: 1, sy: 1, sz: 1 }), NA = t(!1), JA = t(!0), z = t(!0), QA = t(null), _ = t(null), aA = t(!1), b = t(!1), nA = t(0), SA = t("sphere"), dA = t(0), xA = t(0), tA = t(!1);
|
|
5382
5383
|
let gA = null, LA = null, rA = !1;
|
|
5383
5384
|
const CA = wA(() => A.roots.length > 0), RI = wA(() => A.diagnosis?.bbox.min[1] ?? 0), MA = wA(() => A.diagnosis?.bbox.max[1] ?? 10), {
|
|
5384
5385
|
importOpen: yI,
|
|
@@ -5406,7 +5407,7 @@ const FA = /* @__PURE__ */ $({
|
|
|
5406
5407
|
draftsOpen: N,
|
|
5407
5408
|
drafts: s,
|
|
5408
5409
|
draftName: S,
|
|
5409
|
-
openDrafts:
|
|
5410
|
+
openDrafts: U,
|
|
5410
5411
|
saveDraftNamed: l,
|
|
5411
5412
|
openDraft: m,
|
|
5412
5413
|
removeDraft: u
|
|
@@ -5510,7 +5511,7 @@ const FA = /* @__PURE__ */ $({
|
|
|
5510
5511
|
DA();
|
|
5511
5512
|
return;
|
|
5512
5513
|
}
|
|
5513
|
-
i.value?.detachGizmo(), i.value?.clearPreview(), n.value = !1, A.measureMode = "off",
|
|
5514
|
+
i.value?.detachGizmo(), i.value?.clearPreview(), n.value = !1, A.measureMode = "off", M.value = [], e.value = "", i.value?.setMeasureDraft([]), _.value = null, QA.value = null;
|
|
5514
5515
|
}
|
|
5515
5516
|
R.key.toLowerCase() === "f" && !R.ctrlKey && i.value?.fit(), i.value && CA.value && !b.value && i.value.attachGizmo(A.selected, A.transformMode);
|
|
5516
5517
|
}
|
|
@@ -5577,9 +5578,9 @@ const FA = /* @__PURE__ */ $({
|
|
|
5577
5578
|
if (A.measureMode !== "off") {
|
|
5578
5579
|
const x = i.value.snapPick(w.nx, w.ny);
|
|
5579
5580
|
if (!x) return;
|
|
5580
|
-
|
|
5581
|
+
M.value.push(x.point);
|
|
5581
5582
|
const T = A.measureMode === "length" ? 2 : 3;
|
|
5582
|
-
|
|
5583
|
+
M.value.length >= T && ZA();
|
|
5583
5584
|
return;
|
|
5584
5585
|
}
|
|
5585
5586
|
const y = i.value.pick(w.nx, w.ny);
|
|
@@ -5600,10 +5601,10 @@ const FA = /* @__PURE__ */ $({
|
|
|
5600
5601
|
if (A.measureMode === "off") return;
|
|
5601
5602
|
const w = P(R), y = i.value.snapPick(w.nx, w.ny);
|
|
5602
5603
|
if (!y) {
|
|
5603
|
-
e.value = "", i.value.setMeasureDraft(
|
|
5604
|
+
e.value = "", i.value.setMeasureDraft(M.value);
|
|
5604
5605
|
return;
|
|
5605
5606
|
}
|
|
5606
|
-
const x =
|
|
5607
|
+
const x = M.value;
|
|
5607
5608
|
if (A.measureMode === "length" && x.length === 1) {
|
|
5608
5609
|
const T = x[0].distanceTo(y.point);
|
|
5609
5610
|
e.value = d.value != null ? `${T.toFixed(2)} mm(目标 ${d.value},偏差 ${(T - d.value).toFixed(2)})` : `${T.toFixed(2)} mm`;
|
|
@@ -5630,7 +5631,7 @@ const FA = /* @__PURE__ */ $({
|
|
|
5630
5631
|
_.value = { x: R.clientX, y: R.clientY, i: x }, A.setSelection([x], R.ctrlKey);
|
|
5631
5632
|
}
|
|
5632
5633
|
function ZA() {
|
|
5633
|
-
const R =
|
|
5634
|
+
const R = M.value;
|
|
5634
5635
|
if (A.measureMode === "length" && R.length >= 2) {
|
|
5635
5636
|
const w = R[0].distanceTo(R[1]), y = d.value ?? void 0;
|
|
5636
5637
|
A.measurements.push({
|
|
@@ -5663,7 +5664,7 @@ const FA = /* @__PURE__ */ $({
|
|
|
5663
5664
|
points: R.slice(0, 3).map((y) => [y.x, y.y, y.z])
|
|
5664
5665
|
}), g.toast("info", `半径 ${w.toFixed(2)} mm`);
|
|
5665
5666
|
}
|
|
5666
|
-
|
|
5667
|
+
M.value = [], e.value = "", i.value?.setMeasureDraft([]);
|
|
5667
5668
|
}
|
|
5668
5669
|
function EI() {
|
|
5669
5670
|
A.applyNumericTransform(A.selected, { ...cA.value });
|
|
@@ -5733,7 +5734,7 @@ const FA = /* @__PURE__ */ $({
|
|
|
5733
5734
|
), UI(
|
|
5734
5735
|
() => A.measureMode,
|
|
5735
5736
|
() => {
|
|
5736
|
-
|
|
5737
|
+
M.value = [], e.value = "", i.value?.setMeasureDraft([]);
|
|
5737
5738
|
}
|
|
5738
5739
|
), (R, w) => (L(), q("div", {
|
|
5739
5740
|
class: VA(["workbench", { "no-left": !JA.value, "no-right": !z.value }]),
|
|
@@ -5755,8 +5756,8 @@ const FA = /* @__PURE__ */ $({
|
|
|
5755
5756
|
onRepair: pA,
|
|
5756
5757
|
onExport: k(OA),
|
|
5757
5758
|
onReview: w[3] || (w[3] = (y) => h.value = !0),
|
|
5758
|
-
onDrafts: k(
|
|
5759
|
-
onSettings: w[4] || (w[4] = (y) =>
|
|
5759
|
+
onDrafts: k(U),
|
|
5760
|
+
onSettings: w[4] || (w[4] = (y) => K.value = !0),
|
|
5760
5761
|
onHelp: w[5] || (w[5] = (y) => a.value = !0)
|
|
5761
5762
|
}, null, 8, ["has-model", "clip-on", "measure-target", "onImport", "onExport", "onDrafts"]),
|
|
5762
5763
|
zA(aE, {
|
|
@@ -5774,8 +5775,8 @@ const FA = /* @__PURE__ */ $({
|
|
|
5774
5775
|
"split-mode": b.value,
|
|
5775
5776
|
"split-connector": SA.value,
|
|
5776
5777
|
"onUpdate:splitConnector": w[10] || (w[10] = (y) => SA.value = y),
|
|
5777
|
-
"rename-buf":
|
|
5778
|
-
"onUpdate:renameBuf": w[11] || (w[11] = (y) =>
|
|
5778
|
+
"rename-buf": c.value,
|
|
5779
|
+
"onUpdate:renameBuf": w[11] || (w[11] = (y) => c.value = y),
|
|
5779
5780
|
onSelect: Hg,
|
|
5780
5781
|
onPartMenu: w[12] || (w[12] = (y) => _.value = y),
|
|
5781
5782
|
onApplyNumeric: EI,
|
|
@@ -5915,9 +5916,9 @@ const FA = /* @__PURE__ */ $({
|
|
|
5915
5916
|
onDownload: k(fI),
|
|
5916
5917
|
onUpload: k(bI)
|
|
5917
5918
|
}, null, 8, ["format", "unit", "progress", "onDownload", "onUpload"])) : f("", !0),
|
|
5918
|
-
|
|
5919
|
+
K.value ? (L(), X(CQ, {
|
|
5919
5920
|
key: 5,
|
|
5920
|
-
onClose: w[26] || (w[26] = (y) =>
|
|
5921
|
+
onClose: w[26] || (w[26] = (y) => K.value = !1)
|
|
5921
5922
|
})) : f("", !0),
|
|
5922
5923
|
a.value ? (L(), X(QQ, {
|
|
5923
5924
|
key: 6,
|