three-slicer 0.2.0 → 0.2.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 +0 -1
- package/engine/README.md +2 -2
- package/engine/src/settings.js +7 -0
- package/engine/src/slicer_core.js +0 -0
- package/engine/src/slicer_core.mt.js +0 -0
- package/package.json +1 -1
- package/viewer/README.md +2 -2
- package/viewer/dist/Viewport.js +3649 -3167
- package/viewer/dist/make_worker.js +15 -0
- package/viewer/dist/sl1_encode.worker.js +10 -0
- package/viewer/dist/sl1_write-UHmQ_itC.js +170 -0
- package/viewer/dist/sla_reconstruct-CXkYhux2.js +176 -0
- package/viewer/dist/sla_reconstruct.worker.js +24 -0
- package/viewer/dist/sla_slice.worker.js +74 -0
- package/viewer/dist/toolpath_gpu-4foc4FaU.js +482 -0
- package/viewer/dist/toolpath_gpu.js +11 -408
|
@@ -14,3 +14,18 @@ export function makeSlicerWorker() {
|
|
|
14
14
|
export function makeParse3mfWorker() {
|
|
15
15
|
return new Worker(new URL('./parse_3mf.worker.js', import.meta.url), { type: 'module' })
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
// SL1 mesh-reconstruction workers — same dist-relative story as the 3mf parser above. The pipeline is N slice
|
|
19
|
+
// producers (PNG -> occupancy) feeding one nets consumer; see sla_slice.worker.js for why it splits there.
|
|
20
|
+
export function makeSlaReconstructWorker() {
|
|
21
|
+
return new Worker(new URL('./sla_reconstruct.worker.js', import.meta.url), { type: 'module' })
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function makeSlaSliceWorker() {
|
|
25
|
+
return new Worker(new URL('./sla_slice.worker.js', import.meta.url), { type: 'module' })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// SL1 export encoder — the write-side counterpart of the slice workers above, same dist-relative story.
|
|
29
|
+
export function makeSl1EncodeWorker() {
|
|
30
|
+
return new Worker(new URL('./sl1_encode.worker.js', import.meta.url), { type: 'module' })
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { s as p, d as c } from "./sl1_write-UHmQ_itC.js";
|
|
2
|
+
self.onmessage = async ({ data: { indices: f, paths: n, params: o } }) => {
|
|
3
|
+
const a = p(o), r = new OffscreenCanvas(a.px, a.py), e = r.getContext("2d"), t = [];
|
|
4
|
+
for (let s = 0; s < f.length; s++) {
|
|
5
|
+
e.fillStyle = "#000", e.fillRect(0, 0, a.px, a.py), e.fillStyle = "#fff", c(e, n[s], a);
|
|
6
|
+
const l = await r.convertToBlob({ type: "image/png" });
|
|
7
|
+
t.push(new Uint8Array(await l.arrayBuffer())), (s & 7) === 7 && self.postMessage({ progress: s + 1 });
|
|
8
|
+
}
|
|
9
|
+
self.postMessage({ indices: f, pngs: t }, t.map((s) => s.buffer));
|
|
10
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { strToU8 as R, zipSync as T } from "three/examples/jsm/libs/fflate.module.js";
|
|
2
|
+
let F = !0;
|
|
3
|
+
function Z(e) {
|
|
4
|
+
F = !!e;
|
|
5
|
+
}
|
|
6
|
+
const C = {
|
|
7
|
+
info: (...e) => {
|
|
8
|
+
F && console.info(...e);
|
|
9
|
+
},
|
|
10
|
+
warn: (...e) => {
|
|
11
|
+
F && console.warn(...e);
|
|
12
|
+
},
|
|
13
|
+
error: (...e) => {
|
|
14
|
+
F && console.error(...e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
function O(e) {
|
|
18
|
+
const t = Number(e.display_width) > 0 ? Number(e.display_width) : 120.96, u = Number(e.display_height) > 0 ? Number(e.display_height) : 68.04, o = Number(e.display_pixels_x) > 0 ? Math.round(Number(e.display_pixels_x)) : 2560, i = Number(e.display_pixels_y) > 0 ? Math.round(Number(e.display_pixels_y)) : 1440, s = e.display_mirror_x !== !1, r = e.display_mirror_y === !0, n = (e.display_orientation ?? "portrait") !== "landscape", a = o / t, l = i / u, f = (p) => (s ? t / 2 - p : p + t / 2) * a, c = (p) => (r ? u / 2 - p : p + u / 2) * l;
|
|
19
|
+
return n ? {
|
|
20
|
+
px: i,
|
|
21
|
+
py: o,
|
|
22
|
+
mirrorX: s,
|
|
23
|
+
portrait: n,
|
|
24
|
+
// canvas columns run along the display's y axis, rows along the (mirrored) x axis
|
|
25
|
+
map: (p, y) => [c(y), f(p)]
|
|
26
|
+
} : {
|
|
27
|
+
px: o,
|
|
28
|
+
py: i,
|
|
29
|
+
mirrorX: s,
|
|
30
|
+
portrait: n,
|
|
31
|
+
map: (p, y) => [f(p), c(y)]
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function k(e, t, u) {
|
|
35
|
+
const o = t.length / 8;
|
|
36
|
+
if (!o) return 0;
|
|
37
|
+
let i = 0;
|
|
38
|
+
e.beginPath();
|
|
39
|
+
let s = NaN, r = NaN;
|
|
40
|
+
for (let n = 0; n < o; n++) {
|
|
41
|
+
const a = t[n * 8], l = t[n * 8 + 1], f = t[n * 8 + 4], c = t[n * 8 + 5];
|
|
42
|
+
(a !== s || l !== r) && (e.moveTo(...u.map(a, l)), i++), e.lineTo(...u.map(f, c)), s = f, r = c;
|
|
43
|
+
}
|
|
44
|
+
return e.fill("evenodd"), i;
|
|
45
|
+
}
|
|
46
|
+
const V = (e) => String(e ?? "");
|
|
47
|
+
function X({ params: e, stats: t, jobName: u, timestamp: o }) {
|
|
48
|
+
const i = String(e.material_print_speed ?? "fast"), s = {
|
|
49
|
+
action: "print",
|
|
50
|
+
jobDir: u,
|
|
51
|
+
expTime: e.exposure_time,
|
|
52
|
+
expTimeFirst: e.initial_exposure_time,
|
|
53
|
+
expUserProfile: i === "slow" ? 1 : i === "fast" ? 0 : 2,
|
|
54
|
+
fileCreationTimestamp: o ?? "",
|
|
55
|
+
hollow: e.hollowing_enable ? 1 : 0,
|
|
56
|
+
layerHeight: e.layer_height,
|
|
57
|
+
materialName: e.sla_material_settings_id ?? "",
|
|
58
|
+
numFade: e.faded_layers,
|
|
59
|
+
numFast: t.layers,
|
|
60
|
+
numSlow: 0,
|
|
61
|
+
printProfile: e.sla_print_settings_id ?? "",
|
|
62
|
+
printTime: Number(t.time_estimate ?? 0).toFixed(6),
|
|
63
|
+
printerModel: e.printer_model ?? "",
|
|
64
|
+
printerProfile: e.printer_settings_id ?? "",
|
|
65
|
+
printerVariant: e.printer_variant ?? "",
|
|
66
|
+
prusaSlicerVersion: "three-slicer",
|
|
67
|
+
usedMaterial: Number(t.resin_ml ?? 0).toFixed(6)
|
|
68
|
+
};
|
|
69
|
+
return Object.keys(s).sort().map((r) => `${r} = ${V(s[r])}`).join(`
|
|
70
|
+
`) + `
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
const L = (e, t) => `${e}${String(t).padStart(5, "0")}.png`, Y = "Metadata/threeslicer_roles.bin", D = "Metadata/threeslicer_scene.bin";
|
|
74
|
+
function j({ modelSTL: e, supportMesh: t, padMesh: u, lift: o = 0 }) {
|
|
75
|
+
const i = e instanceof Uint8Array ? e : new Uint8Array(e ?? 0), s = t instanceof Float32Array ? t : new Float32Array(t ?? 0), r = u instanceof Float32Array ? u : new Float32Array(u ?? 0), n = new Uint8Array(12 + i.length + 4 + s.length * 4 + 4 + r.length * 4), a = new DataView(n.buffer);
|
|
76
|
+
n.set([84, 83, 83, 49], 0), a.setFloat32(4, o, !0);
|
|
77
|
+
let l = 8;
|
|
78
|
+
a.setUint32(l, i.length, !0), l += 4, n.set(i, l), l += i.length;
|
|
79
|
+
for (const f of [s, r]) {
|
|
80
|
+
a.setUint32(l, f.length, !0), l += 4;
|
|
81
|
+
for (let c = 0; c < f.length; c++)
|
|
82
|
+
a.setFloat32(l, f[c], !0), l += 4;
|
|
83
|
+
}
|
|
84
|
+
return n;
|
|
85
|
+
}
|
|
86
|
+
function z(e) {
|
|
87
|
+
const t = e.map(({ paths: r }) => {
|
|
88
|
+
const n = [];
|
|
89
|
+
for (let a = 0; a + 7 < r.length; a += 8) {
|
|
90
|
+
const l = r[a + 3] & 15;
|
|
91
|
+
if (l === 5 || l === 6) for (let f = 0; f < 8; f++) n.push(r[a + f]);
|
|
92
|
+
}
|
|
93
|
+
return n;
|
|
94
|
+
}), u = 8 + t.reduce((r, n) => r + 4 + n.length * 4, 0), o = new Uint8Array(u), i = new DataView(o.buffer);
|
|
95
|
+
o.set([84, 83, 82, 49], 0), i.setUint32(4, t.length, !0);
|
|
96
|
+
let s = 8;
|
|
97
|
+
for (const r of t) {
|
|
98
|
+
i.setUint32(s, r.length, !0), s += 4;
|
|
99
|
+
for (const n of r)
|
|
100
|
+
i.setFloat32(s, n, !0), s += 4;
|
|
101
|
+
}
|
|
102
|
+
return o;
|
|
103
|
+
}
|
|
104
|
+
function H({ layers: e, params: t, makeWorker: u, workerCount: o, onProgress: i }) {
|
|
105
|
+
return new Promise((s, r) => {
|
|
106
|
+
const n = new Array(e.length), a = new Array(o).fill(0);
|
|
107
|
+
let l = 0, f = !1;
|
|
108
|
+
const c = [], p = (y) => {
|
|
109
|
+
f = !0, c.forEach((_) => _.terminate()), r(y);
|
|
110
|
+
};
|
|
111
|
+
for (let y = 0; y < o; y++) {
|
|
112
|
+
const _ = [], m = [];
|
|
113
|
+
for (let g = y; g < e.length; g += o)
|
|
114
|
+
_.push(g), m.push(e[g].paths);
|
|
115
|
+
const w = u();
|
|
116
|
+
c.push(w), w.onerror = (g) => p(new Error("SL1 encode worker: " + ((g == null ? void 0 : g.message) || "failed"))), w.onmessage = ({ data: g }) => {
|
|
117
|
+
if (!f) {
|
|
118
|
+
if (g.progress != null) {
|
|
119
|
+
a[y] = g.progress, i == null || i(a.reduce((b, $) => b + $, 0), e.length);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
g.indices.forEach((b, $) => {
|
|
123
|
+
n[b] = g.pngs[$];
|
|
124
|
+
}), w.terminate(), ++l === o && s(n);
|
|
125
|
+
}
|
|
126
|
+
}, w.postMessage({ indices: _, paths: m, params: t });
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async function q({ layers: e, params: t, stats: u, jobName: o = "plate", timestamp: i, makeCanvas: s, onProgress: r, scene: n = null, makeWorker: a = null, workerCount: l = 0 }) {
|
|
131
|
+
const f = s ?? (typeof OffscreenCanvas < "u" ? (h, d) => new OffscreenCanvas(h, d) : null), c = O(t), p = {}, y = a && typeof Worker < "u" && e.length > 1 ? {
|
|
132
|
+
makeWorker: a,
|
|
133
|
+
workerCount: Math.max(1, Math.min(l > 0 ? l : 4, e.length))
|
|
134
|
+
} : null;
|
|
135
|
+
if (!y && !f) throw new Error("SL1 export needs a canvas (OffscreenCanvas or an injected factory)");
|
|
136
|
+
const _ = () => performance.now(), m = { canvas: 0, clear: 0, draw: 0, encode: 0, read: 0 }, w = (h, d) => {
|
|
137
|
+
const S = _();
|
|
138
|
+
return m[h] += S - d, S;
|
|
139
|
+
};
|
|
140
|
+
let g = 0, b = 0;
|
|
141
|
+
const $ = async (h) => {
|
|
142
|
+
let d = _();
|
|
143
|
+
const S = f(c.px, c.py), v = S.getContext("2d");
|
|
144
|
+
d = w("canvas", d), v.fillStyle = "#000", v.fillRect(0, 0, c.px, c.py), d = w("clear", d), v.fillStyle = "#fff", b += k(v, e[h].paths, c), d = w("draw", d);
|
|
145
|
+
const B = await S.convertToBlob({ type: "image/png" });
|
|
146
|
+
d = w("encode", d);
|
|
147
|
+
const U = new Uint8Array(await B.arrayBuffer());
|
|
148
|
+
return w("read", d), g += U.length, U;
|
|
149
|
+
}, E = _();
|
|
150
|
+
if (y) {
|
|
151
|
+
const h = await H({ layers: e, params: t, onProgress: r, ...y });
|
|
152
|
+
for (let d = 0; d < e.length; d++)
|
|
153
|
+
p[L(o, d)] = [h[d], { level: 0 }], g += h[d].length;
|
|
154
|
+
} else
|
|
155
|
+
for (let h = 0; h < e.length; h++)
|
|
156
|
+
p[L(o, h)] = [await $(h), { level: 0 }], h & 31 || r == null || r(h, e.length);
|
|
157
|
+
const N = _();
|
|
158
|
+
p["config.ini"] = R(X({ params: t, stats: u, jobName: o, timestamp: i })), p[Y] = [z(e), { level: 6 }], n && (p[D] = [j(n), { level: 6 }]);
|
|
159
|
+
const A = _(), M = T(p), x = (h) => h.toFixed(0);
|
|
160
|
+
return C.info(`[vp-prof] sl1 build: ${e.length} layers ${c.px}x${c.py},` + (y ? ` raster ${x(N - E)}ms (${y.workerCount} workers),` : ` ${b} loops, raster ${x(N - E)}ms (canvas ${x(m.canvas)} + clear ${x(m.clear)} + draw ${x(m.draw)} + encode ${x(m.encode)} + read ${x(m.read)}),`) + ` sidecar ${x(A - N)}ms, zip ${x(_() - A)}ms -> ${(M.byteLength / 1e6).toFixed(1)}MB (png ${(g / 1e6).toFixed(1)}MB)`), M;
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
D as S,
|
|
164
|
+
Y as a,
|
|
165
|
+
Z as b,
|
|
166
|
+
k as d,
|
|
167
|
+
C as l,
|
|
168
|
+
q as m,
|
|
169
|
+
O as s
|
|
170
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const U = new Int8Array(8), W = new Int8Array(8), G = new Int8Array(8);
|
|
2
|
+
for (let t = 0; t < 8; t++)
|
|
3
|
+
U[t] = t & 1, W[t] = t >> 1 & 1, G[t] = t >> 2 & 1;
|
|
4
|
+
const T = [], rt = [];
|
|
5
|
+
for (let t = 0; t < 8; t++) for (let l = t + 1; l < 8; l++)
|
|
6
|
+
Math.abs(U[t] - U[l]) + Math.abs(W[t] - W[l]) + Math.abs(G[t] - G[l]) === 1 && (T.push(t), rt.push(l));
|
|
7
|
+
const ot = 127.5, q = (t) => t > ot, x = (t) => {
|
|
8
|
+
const l = [];
|
|
9
|
+
let A = new t(1048576), r = 0, m = 0;
|
|
10
|
+
return {
|
|
11
|
+
push3(u, C, h) {
|
|
12
|
+
r + 3 > A.length && (l.push(A.subarray(0, r)), m += r, A = new t(1 << 20), r = 0), A[r++] = u, A[r++] = C, A[r++] = h;
|
|
13
|
+
},
|
|
14
|
+
concat() {
|
|
15
|
+
l.push(A.subarray(0, r)), m += r;
|
|
16
|
+
const u = new t(m);
|
|
17
|
+
let C = 0;
|
|
18
|
+
for (const h of l)
|
|
19
|
+
u.set(h, C), C += h.length;
|
|
20
|
+
return u;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, ct = { 0: [0.68, 0.238, 0.023], 5: [0.328, 0.188, 0.687], 6: [0.434, 0.352, 0.144] };
|
|
24
|
+
function ht(t, l, A, r, m, u, C, h) {
|
|
25
|
+
const b = t + 1, a = l + 1;
|
|
26
|
+
let o = new Int32Array(b * a).fill(-1), i = new Int32Array(b * a).fill(-1);
|
|
27
|
+
const N = null;
|
|
28
|
+
let F = N, w = N, H = null, P = null, J = null, d = null, at = 0;
|
|
29
|
+
const tt = x(Float32Array), Y = x(Uint32Array), et = x(Float32Array);
|
|
30
|
+
let nt = 0, Q = !1;
|
|
31
|
+
const S = (g, c, n) => !g || c < 0 || n < 0 || c >= t || n >= l ? 0 : g[c + t * n], O = new Float64Array(8);
|
|
32
|
+
function lt(g, c, n, R, s, k, y, p) {
|
|
33
|
+
const e = c + 1 + b * (n + 1), M = g[e];
|
|
34
|
+
if (M >= 0) return M;
|
|
35
|
+
O[0] = S(s, c, n), O[1] = S(s, c + 1, n), O[2] = S(s, c, n + 1), O[3] = S(s, c + 1, n + 1), O[4] = S(k, c, n), O[5] = S(k, c + 1, n), O[6] = S(k, c, n + 1), O[7] = S(k, c + 1, n + 1);
|
|
36
|
+
let z = 0, f = 0, I = 0, v = 0;
|
|
37
|
+
for (let E = 0; E < T.length; E++) {
|
|
38
|
+
const B = T[E], L = rt[E];
|
|
39
|
+
if (q(O[B]) === q(O[L])) continue;
|
|
40
|
+
const X = Math.min(1, Math.max(0, (ot - O[B]) / (O[L] - O[B])));
|
|
41
|
+
z += U[B] + X * (U[L] - U[B]), f += W[B] + X * (W[L] - W[B]), I += G[B] + X * (G[L] - G[B]), v++;
|
|
42
|
+
}
|
|
43
|
+
const K = v ? z / v : 0.5, j = v ? f / v : 0.5, D = v ? I / v : 0.5;
|
|
44
|
+
if (tt.push3(u + (c + K + 0.5) * A, C + (n + j + 0.5) * r, h + (R + D + 0.5) * m), Q) {
|
|
45
|
+
let E = 0;
|
|
46
|
+
for (let L = 0; L < 8; L++) {
|
|
47
|
+
if (!q(O[L])) continue;
|
|
48
|
+
const X = S(G[L] ? p : y, c + U[L], n + W[L]);
|
|
49
|
+
if (X === 5) {
|
|
50
|
+
E = 5;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
X === 6 && (E = 6);
|
|
54
|
+
}
|
|
55
|
+
const B = ct[E];
|
|
56
|
+
et.push3(B[0], B[1], B[2]);
|
|
57
|
+
}
|
|
58
|
+
return g[e] = nt, nt++;
|
|
59
|
+
}
|
|
60
|
+
const Z = (g, c, n) => c === N || n < 0 || n >= l ? t : g ? g[n * 2] : 0, _ = (g, c, n) => c === N || n < 0 || n >= l ? -1 : g ? g[n * 2 + 1] : t - 1;
|
|
61
|
+
function V(g, c, n) {
|
|
62
|
+
const R = at++, s = (e, M) => lt(o, e, M, R - 1, F, w, H, P), k = (e, M) => lt(i, e, M, R, w, g, P, c), y = (e, M, z, f, I) => {
|
|
63
|
+
I ? (Y.push3(f, z, M), Y.push3(f, M, e)) : (Y.push3(e, M, z), Y.push3(e, z, f));
|
|
64
|
+
};
|
|
65
|
+
for (let e = 0; e < l; e++) {
|
|
66
|
+
const M = Math.min(Z(J, F, e), Z(d, w, e)), z = Math.max(_(J, F, e), _(d, w, e));
|
|
67
|
+
for (let f = M; f <= z; f++) {
|
|
68
|
+
const I = q(S(F, f, e)), v = q(S(w, f, e));
|
|
69
|
+
I !== v && y(s(f - 1, e - 1), s(f, e - 1), s(f, e), s(f - 1, e), !I);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (let e = 0; e < l; e++) {
|
|
73
|
+
const M = Z(d, w, e), z = _(d, w, e);
|
|
74
|
+
for (let f = M - 1; f <= z; f++) {
|
|
75
|
+
const I = q(S(w, f, e)), v = q(S(w, f + 1, e));
|
|
76
|
+
I !== v && y(s(f, e - 1), s(f, e), k(f, e), k(f, e - 1), !I);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (let e = -1; e < l; e++) {
|
|
80
|
+
const M = Math.min(Z(d, w, e), Z(d, w, e + 1)), z = Math.max(_(d, w, e), _(d, w, e + 1));
|
|
81
|
+
for (let f = M; f <= z; f++) {
|
|
82
|
+
const I = q(S(w, f, e)), v = q(S(w, f, e + 1));
|
|
83
|
+
I !== v && y(s(f - 1, e), k(f - 1, e), k(f, e), s(f, e), !I);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const p = o;
|
|
87
|
+
o = i, i = p.fill(-1);
|
|
88
|
+
}
|
|
89
|
+
let $ = !1;
|
|
90
|
+
return {
|
|
91
|
+
// Slices arrive bottom-up. Layer s can only be processed once s+1 is known (its cells' upper corners live
|
|
92
|
+
// there), so the first slice just primes the window and every later push runs the step one layer behind.
|
|
93
|
+
// `roles` is an optional parallel Uint8Array (0=model, 5=support, 6=pad) that turns on vertex colours;
|
|
94
|
+
// `ranges` the per-row occupancy spans fillSliceFromRGBA returns, which confine the sweep to the model.
|
|
95
|
+
pushSlice(g, c = null, n = null) {
|
|
96
|
+
if (c && (Q = !0), !$) {
|
|
97
|
+
$ = !0, w = g, P = c, d = n;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
V(g, c), F = w, w = g, H = P, P = c, J = d, d = n;
|
|
101
|
+
},
|
|
102
|
+
finish({ smoothRounds: g = 0, normalRounds: c = 0 } = {}) {
|
|
103
|
+
$ && (V(N, null), F = w, w = N, H = P, P = null, J = d, d = null), V(N, null);
|
|
104
|
+
const n = tt.concat(), R = Y.concat();
|
|
105
|
+
g > 0 && st(n, R, g);
|
|
106
|
+
const s = new Float32Array(n.length);
|
|
107
|
+
for (let k = 0; k < R.length; k += 3) {
|
|
108
|
+
const y = R[k] * 3, p = R[k + 1] * 3, e = R[k + 2] * 3, M = n[p] - n[y], z = n[p + 1] - n[y + 1], f = n[p + 2] - n[y + 2], I = n[e] - n[y], v = n[e + 1] - n[y + 1], K = n[e + 2] - n[y + 2], j = z * K - f * v, D = f * I - M * K, E = M * v - z * I;
|
|
109
|
+
s[y] += j, s[y + 1] += D, s[y + 2] += E, s[p] += j, s[p + 1] += D, s[p + 2] += E, s[e] += j, s[e + 1] += D, s[e + 2] += E;
|
|
110
|
+
}
|
|
111
|
+
return ft(s), c > 0 && ut(s, R, c), { positions: n, indices: R, normals: s, colors: Q ? et.concat() : null };
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function ft(t) {
|
|
116
|
+
for (let l = 0; l < t.length; l += 3) {
|
|
117
|
+
const A = Math.hypot(t[l], t[l + 1], t[l + 2]) || 1;
|
|
118
|
+
t[l] /= A, t[l + 1] /= A, t[l + 2] /= A;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function ut(t, l, A = 2) {
|
|
122
|
+
const r = new Float32Array(t.length);
|
|
123
|
+
for (let m = 0; m < A; m++) {
|
|
124
|
+
r.fill(0);
|
|
125
|
+
for (let u = 0; u < l.length; u += 3) {
|
|
126
|
+
const C = l[u] * 3, h = l[u + 1] * 3, b = l[u + 2] * 3;
|
|
127
|
+
for (const [a, o] of [[C, h], [h, b], [b, C]])
|
|
128
|
+
r[a] += t[o], r[a + 1] += t[o + 1], r[a + 2] += t[o + 2], r[o] += t[a], r[o + 1] += t[a + 1], r[o + 2] += t[a + 2];
|
|
129
|
+
}
|
|
130
|
+
for (let u = 0; u < t.length; u += 3)
|
|
131
|
+
t[u] += 0.5 * r[u], t[u + 1] += 0.5 * r[u + 1], t[u + 2] += 0.5 * r[u + 2];
|
|
132
|
+
ft(t);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function st(t, l, A = 4) {
|
|
136
|
+
const r = new Float32Array(t.length), m = new Float32Array(t.length / 3), u = (h, b) => {
|
|
137
|
+
const a = h * 3, o = b * 3, i = Math.abs(t[o + 2] - t[a + 2]) + 0.05 * (Math.abs(t[o] - t[a]) + Math.abs(t[o + 1] - t[a + 1])) + 1e-6;
|
|
138
|
+
r[a] += i * t[o], r[a + 1] += i * t[o + 1], r[a + 2] += i * t[o + 2], r[o] += i * t[a], r[o + 1] += i * t[a + 1], r[o + 2] += i * t[a + 2], m[h] += i, m[b] += i;
|
|
139
|
+
}, C = (h) => {
|
|
140
|
+
r.fill(0), m.fill(0);
|
|
141
|
+
for (let b = 0; b < l.length; b += 3) {
|
|
142
|
+
const a = l[b], o = l[b + 1], i = l[b + 2];
|
|
143
|
+
u(a, o), u(o, i), u(i, a);
|
|
144
|
+
}
|
|
145
|
+
for (let b = 0; b < m.length; b++) {
|
|
146
|
+
const a = m[b];
|
|
147
|
+
if (!a) continue;
|
|
148
|
+
const o = b * 3;
|
|
149
|
+
t[o] += h * (r[o] / a - t[o]), t[o + 1] += h * (r[o + 1] / a - t[o + 1]), t[o + 2] += h * (r[o + 2] / a - t[o + 2]);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
for (let h = 0; h < A; h++)
|
|
153
|
+
C(0.5), C(-0.53);
|
|
154
|
+
}
|
|
155
|
+
function bt(t, l, A, r, m) {
|
|
156
|
+
const u = new Uint32Array(l.buffer, l.byteOffset, l.byteLength >> 2), C = new Int32Array(r * 2);
|
|
157
|
+
for (let h = 0; h < r; h++) {
|
|
158
|
+
const b = r - 1 - h, a = h * A * 4 >> 2, o = A * (b + r * m);
|
|
159
|
+
let i = A, N = -1;
|
|
160
|
+
for (let F = 0; F < A; F++) {
|
|
161
|
+
const w = u[a + F];
|
|
162
|
+
if (w === 0) {
|
|
163
|
+
t[o + F] = 0;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const H = w >> 8 & 255;
|
|
167
|
+
t[o + F] = H, H && (F < i && (i = F), F > N && (N = F));
|
|
168
|
+
}
|
|
169
|
+
C[b * 2] = i, C[b * 2 + 1] = N;
|
|
170
|
+
}
|
|
171
|
+
return C;
|
|
172
|
+
}
|
|
173
|
+
export {
|
|
174
|
+
bt as f,
|
|
175
|
+
ht as m
|
|
176
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { m as c } from "./sla_reconstruct-CXkYhux2.js";
|
|
2
|
+
let e = null, o = { nets: 0, finish: 0 };
|
|
3
|
+
self.onmessage = (m) => {
|
|
4
|
+
const s = m.data;
|
|
5
|
+
try {
|
|
6
|
+
if (s.init) {
|
|
7
|
+
e = c(s.nx, s.ny, s.sx, s.sy, s.sz, s.ox, s.oy, s.oz), o = { nets: 0, finish: 0 };
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (s.slice) {
|
|
11
|
+
const n = performance.now();
|
|
12
|
+
e.pushSlice(s.slice, s.roles, s.ranges), o.nets += performance.now() - n;
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (s.finish) {
|
|
16
|
+
const n = performance.now(), { positions: i, indices: t, normals: f, colors: r } = e.finish({ smoothRounds: s.smoothRounds ?? 2, normalRounds: s.normalRounds ?? 0 });
|
|
17
|
+
o.finish = performance.now() - n, e = null;
|
|
18
|
+
const a = [i.buffer, t.buffer, f.buffer];
|
|
19
|
+
r && a.push(r.buffer), self.postMessage({ positions: i, indices: t, normals: f, colors: r, timings: o, producerTimings: s.producerTimings, spin: s.spin }, a);
|
|
20
|
+
}
|
|
21
|
+
} catch (n) {
|
|
22
|
+
self.postMessage({ error: String((n == null ? void 0 : n.message) || n) });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { f as U } from "./sla_reconstruct-CXkYhux2.js";
|
|
2
|
+
import { d as q } from "./sl1_write-UHmQ_itC.js";
|
|
3
|
+
let i = 6;
|
|
4
|
+
const D = (u, B) => {
|
|
5
|
+
const m = [];
|
|
6
|
+
for (let l = 0; l + 7 < u.length; l += 8) if ((u[l + 3] & 15) === B) for (let e = 0; e < 8; e++) m.push(u[l + e]);
|
|
7
|
+
return m;
|
|
8
|
+
};
|
|
9
|
+
self.onmessage = async (u) => {
|
|
10
|
+
var S, T;
|
|
11
|
+
const { indices: B, pngs: m, rolePaths: l, nx: e, ny: r, matrix: w, scale: d, width: C, height: F, batch: I } = u.data;
|
|
12
|
+
I > 0 && (i = I);
|
|
13
|
+
try {
|
|
14
|
+
const n = { decode: 0, draw: 0, read: 0, roles: 0, fill: 0 };
|
|
15
|
+
let o = 0;
|
|
16
|
+
const y = new OffscreenCanvas(e, r * i).getContext("2d", { willReadFrequently: !0 }), O = l ? new OffscreenCanvas(e, r * i) : null, f = O == null ? void 0 : O.getContext("2d", { willReadFrequently: !0 }), v = (s) => {
|
|
17
|
+
const a = [];
|
|
18
|
+
for (let p = 0; p < i && s + p < m.length; p++) {
|
|
19
|
+
const g = s + p;
|
|
20
|
+
a.push(createImageBitmap(new Blob([m[g]], { type: "image/png" })).then((M) => (m[g] = null, M)));
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
let H = v(0);
|
|
25
|
+
for (let s = 0; s < m.length; s += i) {
|
|
26
|
+
o = performance.now();
|
|
27
|
+
const a = await Promise.all(H);
|
|
28
|
+
n.decode += performance.now() - o, H = v(s + i), o = performance.now(), y.setTransform(1, 0, 0, 1, 0, 0), y.clearRect(0, 0, e, r * i);
|
|
29
|
+
for (let t = 0; t < a.length; t++)
|
|
30
|
+
y.setTransform(
|
|
31
|
+
w[0] * d,
|
|
32
|
+
w[1] * d,
|
|
33
|
+
w[2] * d,
|
|
34
|
+
w[3] * d,
|
|
35
|
+
w[4] * d,
|
|
36
|
+
w[5] * d + t * r
|
|
37
|
+
), y.drawImage(a[t], 0, 0), (T = (S = a[t]).close) == null || T.call(S);
|
|
38
|
+
n.draw += performance.now() - o, o = performance.now();
|
|
39
|
+
const p = y.getImageData(0, 0, e, r * a.length).data;
|
|
40
|
+
n.read += performance.now() - o, o = performance.now();
|
|
41
|
+
let g = null;
|
|
42
|
+
if (f && l.slice(s, s + a.length).some((t) => t && t.length)) {
|
|
43
|
+
f.setTransform(1, 0, 0, 1, 0, 0), f.clearRect(0, 0, e, r * i);
|
|
44
|
+
for (let t = 0; t < a.length; t++) {
|
|
45
|
+
const h = l[s + t] ?? new Float32Array(0), b = t * r, c = { map: (R, A) => [(R + C / 2) / C * e, (F / 2 - A) / F * r + b] };
|
|
46
|
+
f.fillStyle = "#00f", q(f, D(h, 6), c), f.fillStyle = "#f00", q(f, D(h, 5), c);
|
|
47
|
+
}
|
|
48
|
+
g = f.getImageData(0, 0, e, r * a.length).data, n.roles += performance.now() - o, o = performance.now();
|
|
49
|
+
}
|
|
50
|
+
o = performance.now();
|
|
51
|
+
for (let t = 0; t < a.length; t++) {
|
|
52
|
+
const h = new Uint8Array(e * r), b = U(h, p.subarray(t * e * r * 4, (t + 1) * e * r * 4), e, r, 0);
|
|
53
|
+
let c = null;
|
|
54
|
+
if (g) {
|
|
55
|
+
c = new Uint8Array(e * r);
|
|
56
|
+
const A = t * e * r * 4;
|
|
57
|
+
for (let x = 0; x < r; x++) {
|
|
58
|
+
const G = A + x * e * 4, P = e * (r - 1 - x);
|
|
59
|
+
for (let k = 0; k < e; k++) {
|
|
60
|
+
const j = G + k * 4;
|
|
61
|
+
c[P + k] = g[j] > 127 ? 5 : g[j + 2] > 127 ? 6 : 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const R = [h.buffer, b.buffer];
|
|
66
|
+
c && R.push(c.buffer), self.postMessage({ index: B[s + t], slice: h, ranges: b, roles: c }, R);
|
|
67
|
+
}
|
|
68
|
+
n.fill += performance.now() - o;
|
|
69
|
+
}
|
|
70
|
+
self.postMessage({ done: !0, timings: n });
|
|
71
|
+
} catch (n) {
|
|
72
|
+
self.postMessage({ error: String((n == null ? void 0 : n.message) || n) });
|
|
73
|
+
}
|
|
74
|
+
};
|