three-slicer-viewer 0.3.0 → 0.3.1

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,5 +1,5 @@
1
1
  import { zlibSync as p } from "three/examples/jsm/libs/fflate.module.js";
2
- import { s as m, r as l, e as g } from "./sl1_write-CvrNejbW.js";
2
+ import { s as m, r as l, e as g } from "./sl1_write-BovHbg3k.js";
3
3
  self.onmessage = async ({ data: { indices: r, paths: o, params: t, aa: f } }) => {
4
4
  const a = m(t), e = [];
5
5
  for (let s = 0; s < r.length; s++) {
@@ -1,29 +1,30 @@
1
- import { strToU8 as V, zipSync as I, zlibSync as z } from "three/examples/jsm/libs/fflate.module.js";
2
- let $ = !0;
3
- function it(t) {
4
- $ = !!t;
1
+ import { strToU8 as V, zipSync as z, zlibSync as j } from "three/examples/jsm/libs/fflate.module.js";
2
+ import { S as A, r as X, R as C } from "./toolpath_encoding-BuYs95qZ.js";
3
+ let M = !0;
4
+ function ft(t) {
5
+ M = !!t;
5
6
  }
6
- const O = {
7
+ const Y = {
7
8
  info: (...t) => {
8
- $ && console.info(...t);
9
+ M && console.info(...t);
9
10
  },
10
11
  warn: (...t) => {
11
- $ && console.warn(...t);
12
+ M && console.warn(...t);
12
13
  },
13
14
  error: (...t) => {
14
- $ && console.error(...t);
15
+ M && console.error(...t);
15
16
  }
16
17
  };
17
- function j(t) {
18
+ function G(t) {
18
19
  const e = [];
19
20
  let n = null;
20
- for (let r = 0; r < t.length; r += 8) {
21
+ for (let r = 0; r < t.length; r += A) {
21
22
  const a = t[r], f = t[r + 1], c = t[r + 4], s = t[r + 5];
22
23
  n && Math.abs(n.lx - a) < 1e-6 && Math.abs(n.ly - f) < 1e-6 ? (n.pts.push(c, s), n.lx = c, n.ly = s) : (n = { pts: [a, f, c, s], lx: c, ly: s }, e.push(n));
23
24
  }
24
25
  return e.map((r) => r.pts);
25
26
  }
26
- function R(t, e, n, r, a, f) {
27
+ function L(t, e, n, r, a, f) {
27
28
  const c = new Array(n).fill(null);
28
29
  for (const l of t) {
29
30
  const i = l.length / 2;
@@ -56,10 +57,10 @@ function R(t, e, n, r, a, f) {
56
57
  for (const o of s) o.x += o.dx;
57
58
  }
58
59
  }
59
- function X(t, e, n = 1) {
60
- const { px: r, py: a } = e, f = j(t), c = new Uint8Array(r * a);
60
+ function W(t, e, n = 1) {
61
+ const { px: r, py: a } = e, f = G(t), c = new Uint8Array(r * a);
61
62
  if (n <= 1)
62
- return R(
63
+ return L(
63
64
  f,
64
65
  r,
65
66
  a,
@@ -70,7 +71,7 @@ function X(t, e, n = 1) {
70
71
  }
71
72
  ), c;
72
73
  const s = new Uint16Array(r * a);
73
- R(
74
+ L(
74
75
  f,
75
76
  r * n,
76
77
  a * n,
@@ -85,7 +86,7 @@ function X(t, e, n = 1) {
85
86
  for (let i = 0; i < s.length; i++) c[i] = Math.round(s[i] * 255 / l);
86
87
  return c;
87
88
  }
88
- const Y = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), G = (() => {
89
+ const H = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), Z = (() => {
89
90
  const t = new Uint32Array(256);
90
91
  for (let e = 0; e < 256; e++) {
91
92
  let n = e;
@@ -93,18 +94,18 @@ const Y = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), G = (() => {
93
94
  t[e] = n >>> 0;
94
95
  }
95
96
  return t;
96
- })(), W = (t) => {
97
+ })(), q = (t) => {
97
98
  let e = 4294967295;
98
- for (let n = 0; n < t.length; n++) e = G[(e ^ t[n]) & 255] ^ e >>> 8;
99
+ for (let n = 0; n < t.length; n++) e = Z[(e ^ t[n]) & 255] ^ e >>> 8;
99
100
  return (e ^ 4294967295) >>> 0;
100
- }, E = (t, e) => {
101
+ }, F = (t, e) => {
101
102
  const n = new Uint8Array(12 + e.length), r = new DataView(n.buffer);
102
103
  r.setUint32(0, e.length);
103
104
  for (let f = 0; f < 4; f++) n[4 + f] = t.charCodeAt(f);
104
105
  n.set(e, 8);
105
106
  const a = n.subarray(4, 8 + e.length);
106
- return r.setUint32(8 + e.length, W(a)), n;
107
- }, H = async (t) => {
107
+ return r.setUint32(8 + e.length, q(a)), n;
108
+ }, J = async (t) => {
108
109
  const e = new CompressionStream("deflate"), n = [], r = (async () => {
109
110
  const l = e.readable.getReader();
110
111
  for (; ; ) {
@@ -122,15 +123,15 @@ const Y = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), G = (() => {
122
123
  c.set(l, s), s += l.length;
123
124
  return c;
124
125
  };
125
- async function Z(t, e, n, r = {}) {
126
+ async function K(t, e, n, r = {}) {
126
127
  if (t.length !== e * n) throw new Error(`gray8: ${t.length} bytes for ${e}x${n}`);
127
128
  const a = new Uint8Array(13), f = new DataView(a.buffer);
128
129
  f.setUint32(0, e), f.setUint32(4, n), a[8] = 8, a[9] = 0;
129
130
  const c = new Uint8Array(n * (1 + e));
130
131
  for (let u = 0; u < n; u++) c.set(t.subarray(u * e, (u + 1) * e), u * (1 + e) + 1);
131
- const s = typeof CompressionStream < "u" ? await H(c) : r.deflate ? r.deflate(c) : (() => {
132
+ const s = typeof CompressionStream < "u" ? await J(c) : r.deflate ? r.deflate(c) : (() => {
132
133
  throw new Error("gray8: no CompressionStream and no deflate fallback injected");
133
- })(), l = [Y, E("IHDR", a), E("IDAT", s), E("IEND", new Uint8Array(0))];
134
+ })(), l = [H, F("IHDR", a), F("IDAT", s), F("IEND", new Uint8Array(0))];
134
135
  let i = 0;
135
136
  for (const u of l) i += u.length;
136
137
  const o = new Uint8Array(i);
@@ -139,7 +140,7 @@ async function Z(t, e, n, r = {}) {
139
140
  o.set(u, d), d += u.length;
140
141
  return o;
141
142
  }
142
- function q(t) {
143
+ function Q(t) {
143
144
  const e = Number(t.display_width) > 0 ? Number(t.display_width) : 120.96, n = Number(t.display_height) > 0 ? Number(t.display_height) : 68.04, r = Number(t.display_pixels_x) > 0 ? Math.round(Number(t.display_pixels_x)) : 2560, a = Number(t.display_pixels_y) > 0 ? Math.round(Number(t.display_pixels_y)) : 1440, f = t.display_mirror_x !== !1, c = t.display_mirror_y === !0, s = (t.display_orientation ?? "portrait") !== "landscape", l = r / e, i = a / n, o = (u) => (f ? e / 2 - u : u + e / 2) * l, d = (u) => (c ? n / 2 - u : u + n / 2) * i;
144
145
  return s ? {
145
146
  px: a,
@@ -156,20 +157,20 @@ function q(t) {
156
157
  map: (u, p) => [o(u), d(p)]
157
158
  };
158
159
  }
159
- function J(t, e, n) {
160
+ function tt(t, e, n) {
160
161
  const r = e.length / 8;
161
162
  if (!r) return 0;
162
163
  let a = 0;
163
164
  t.beginPath();
164
165
  let f = NaN, c = NaN;
165
166
  for (let s = 0; s < r; s++) {
166
- const l = e[s * 8], i = e[s * 8 + 1], o = e[s * 8 + 4], d = e[s * 8 + 5];
167
+ const l = e[s * A], i = e[s * A + 1], o = e[s * A + 4], d = e[s * A + 5];
167
168
  (l !== f || i !== c) && (t.moveTo(...n.map(l, i)), a++), t.lineTo(...n.map(o, d)), f = o, c = d;
168
169
  }
169
170
  return t.fill("evenodd"), a;
170
171
  }
171
- const K = (t) => String(t ?? "");
172
- function Q({ params: t, stats: e, jobName: n, timestamp: r }) {
172
+ const et = (t) => String(t ?? "");
173
+ function nt({ params: t, stats: e, jobName: n, timestamp: r }) {
173
174
  const a = String(t.material_print_speed ?? "fast"), f = {
174
175
  action: "print",
175
176
  jobDir: n,
@@ -191,12 +192,12 @@ function Q({ params: t, stats: e, jobName: n, timestamp: r }) {
191
192
  prusaSlicerVersion: "three-slicer",
192
193
  usedMaterial: Number(e.resin_ml ?? 0).toFixed(6)
193
194
  };
194
- return Object.keys(f).sort().map((c) => `${c} = ${K(f[c])}`).join(`
195
+ return Object.keys(f).sort().map((c) => `${c} = ${et(f[c])}`).join(`
195
196
  `) + `
196
197
  `;
197
198
  }
198
- const T = (t, e) => `${t}${String(e).padStart(5, "0")}.png`, tt = "Metadata/threeslicer_roles.bin", et = "Metadata/threeslicer_scene.bin";
199
- function nt({ modelSTL: t, supportMesh: e, padMesh: n, lift: r = 0 }) {
199
+ const B = (t, e) => `${t}${String(e).padStart(5, "0")}.png`, ot = "Metadata/threeslicer_roles.bin", rt = "Metadata/threeslicer_scene.bin";
200
+ function st({ modelSTL: t, supportMesh: e, padMesh: n, lift: r = 0 }) {
200
201
  const a = t instanceof Uint8Array ? t : new Uint8Array(t ?? 0), f = e instanceof Float32Array ? e : new Float32Array(e ?? 0), c = n instanceof Float32Array ? n : new Float32Array(n ?? 0), s = new Uint8Array(12 + a.length + 4 + f.length * 4 + 4 + c.length * 4), l = new DataView(s.buffer);
201
202
  s.set([84, 83, 83, 49], 0), l.setFloat32(4, r, !0);
202
203
  let i = 8;
@@ -208,12 +209,12 @@ function nt({ modelSTL: t, supportMesh: e, padMesh: n, lift: r = 0 }) {
208
209
  }
209
210
  return s;
210
211
  }
211
- function ot(t) {
212
+ function it(t) {
212
213
  const e = t.map(({ paths: c }) => {
213
214
  const s = [];
214
- for (let l = 0; l + 7 < c.length; l += 8) {
215
- const i = c[l + 3] & 15;
216
- if (i === 5 || i === 6) for (let o = 0; o < 8; o++) s.push(c[l + o]);
215
+ for (let l = 0; l + A - 1 < c.length; l += A) {
216
+ const i = X(c[l + 3]);
217
+ if (i === C.SUPPORT || i === C.RAFT) for (let o = 0; o < A; o++) s.push(c[l + o]);
217
218
  }
218
219
  return s;
219
220
  }), n = 8 + e.reduce((c, s) => c + 4 + s.length * 4, 0), r = new Uint8Array(n), a = new DataView(r.buffer);
@@ -226,7 +227,7 @@ function ot(t) {
226
227
  }
227
228
  return r;
228
229
  }
229
- function rt({ layers: t, params: e, makeWorker: n, workerCount: r, onProgress: a, aa: f = 1 }) {
230
+ function lt({ layers: t, params: e, makeWorker: n, workerCount: r, onProgress: a, aa: f = 1 }) {
230
231
  return new Promise((c, s) => {
231
232
  const l = new Array(t.length), i = new Array(r).fill(0);
232
233
  let o = 0, d = !1;
@@ -252,8 +253,8 @@ function rt({ layers: t, params: e, makeWorker: n, workerCount: r, onProgress: a
252
253
  }
253
254
  });
254
255
  }
255
- async function lt({ layers: t, params: e, stats: n, jobName: r = "plate", timestamp: a, makeCanvas: f, onProgress: c, scene: s = null, makeWorker: l = null, workerCount: i = 0, aa: o = 1, gpuRaster: d = null }) {
256
- const u = f ?? null, p = q(e), x = {}, w = l && typeof Worker < "u" && t.length > 1 ? {
256
+ async function ut({ layers: t, params: e, stats: n, jobName: r = "plate", timestamp: a, makeCanvas: f, onProgress: c, scene: s = null, makeWorker: l = null, workerCount: i = 0, aa: o = 1, gpuRaster: d = null }) {
257
+ const u = f ?? null, p = Q(e), x = {}, w = l && typeof Worker < "u" && t.length > 1 ? {
257
258
  makeWorker: l,
258
259
  workerCount: Math.max(1, Math.min(i > 0 ? i : 4, t.length))
259
260
  } : null, b = () => performance.now(), m = { canvas: 0, clear: 0, draw: 0, encode: 0, read: 0 }, y = (h, g) => {
@@ -261,42 +262,42 @@ async function lt({ layers: t, params: e, stats: n, jobName: r = "plate", timest
261
262
  return m[h] += v - g, v;
262
263
  };
263
264
  let _ = 0, U = 0;
264
- const B = async (h) => {
265
+ const P = async (h) => {
265
266
  let g = b();
266
267
  if (!u) {
267
- const P = d ? await d(t[h].paths, p, o, t[h], h) : X(t[h].paths, p, o);
268
+ const I = d ? await d(t[h].paths, p, o, t[h], h) : W(t[h].paths, p, o);
268
269
  g = y("draw", g);
269
- const D = await Z(P, p.px, p.py, { deflate: z });
270
+ const D = await K(I, p.px, p.py, { deflate: j });
270
271
  return y("encode", g), _ += D.length, D;
271
272
  }
272
- const v = u(p.px, p.py), S = v.getContext("2d");
273
- g = y("canvas", g), S.fillStyle = "#000", S.fillRect(0, 0, p.px, p.py), g = y("clear", g), S.fillStyle = "#fff", U += J(S, t[h].paths, p), g = y("draw", g);
274
- const L = await v.convertToBlob({ type: "image/png" });
273
+ const v = u(p.px, p.py), $ = v.getContext("2d");
274
+ g = y("canvas", g), $.fillStyle = "#000", $.fillRect(0, 0, p.px, p.py), g = y("clear", g), $.fillStyle = "#fff", U += tt($, t[h].paths, p), g = y("draw", g);
275
+ const O = await v.convertToBlob({ type: "image/png" });
275
276
  g = y("encode", g);
276
- const C = new Uint8Array(await L.arrayBuffer());
277
- return y("read", g), _ += C.length, C;
278
- }, F = b();
277
+ const T = new Uint8Array(await O.arrayBuffer());
278
+ return y("read", g), _ += T.length, T;
279
+ }, N = b();
279
280
  if (w) {
280
- const h = await rt({ layers: t, params: e, onProgress: c, aa: o, ...w });
281
+ const h = await lt({ layers: t, params: e, onProgress: c, aa: o, ...w });
281
282
  for (let g = 0; g < t.length; g++)
282
- x[T(r, g)] = [h[g], { level: 0 }], _ += h[g].length;
283
+ x[B(r, g)] = [h[g], { level: 0 }], _ += h[g].length;
283
284
  } else
284
285
  for (let h = 0; h < t.length; h++)
285
- x[T(r, h)] = [await B(h), { level: 0 }], h & 31 || c?.(h, t.length);
286
- const M = b();
287
- x["config.ini"] = V(Q({ params: e, stats: n, jobName: r, timestamp: a })), x[tt] = [ot(t), { level: 6 }], s && (x[et] = [nt(s), { level: 6 }]);
288
- const N = b(), k = I(x), A = (h) => h.toFixed(0);
289
- return O.info(`[vp-prof] sl1 build: ${t.length} layers ${p.px}x${p.py},` + (w ? ` raster ${A(M - F)}ms (${w.workerCount} workers),` : ` ${U} loops, raster ${A(M - F)}ms (canvas ${A(m.canvas)} + clear ${A(m.clear)} + draw ${A(m.draw)} + encode ${A(m.encode)} + read ${A(m.read)}),`) + ` sidecar ${A(N - M)}ms, zip ${A(b() - N)}ms -> ${(k.byteLength / 1e6).toFixed(1)}MB (png ${(_ / 1e6).toFixed(1)}MB)`), k;
286
+ x[B(r, h)] = [await P(h), { level: 0 }], h & 31 || c?.(h, t.length);
287
+ const E = b();
288
+ x["config.ini"] = V(nt({ params: e, stats: n, jobName: r, timestamp: a })), x[ot] = [it(t), { level: 6 }], s && (x[rt] = [st(s), { level: 6 }]);
289
+ const k = b(), R = z(x), S = (h) => h.toFixed(0);
290
+ return Y.info(`[vp-prof] sl1 build: ${t.length} layers ${p.px}x${p.py},` + (w ? ` raster ${S(E - N)}ms (${w.workerCount} workers),` : ` ${U} loops, raster ${S(E - N)}ms (canvas ${S(m.canvas)} + clear ${S(m.clear)} + draw ${S(m.draw)} + encode ${S(m.encode)} + read ${S(m.read)}),`) + ` sidecar ${S(k - E)}ms, zip ${S(b() - k)}ms -> ${(R.byteLength / 1e6).toFixed(1)}MB (png ${(_ / 1e6).toFixed(1)}MB)`), R;
290
291
  }
291
292
  export {
292
- et as S,
293
- tt as a,
294
- j as b,
295
- it as c,
296
- J as d,
297
- Z as e,
298
- O as l,
299
- lt as m,
300
- X as r,
301
- q as s
293
+ rt as S,
294
+ ot as a,
295
+ G as b,
296
+ ft as c,
297
+ tt as d,
298
+ K as e,
299
+ Y as l,
300
+ ut as m,
301
+ W as r,
302
+ Q as s
302
303
  };
@@ -0,0 +1,178 @@
1
+ import { T as V, h as ht } from "./theme-2oyfMuvf.js";
2
+ import { R as at } from "./toolpath_encoding-BuYs95qZ.js";
3
+ const U = new Int8Array(8), q = new Int8Array(8), H = new Int8Array(8);
4
+ for (let t = 0; t < 8; t++)
5
+ U[t] = t & 1, q[t] = t >> 1 & 1, H[t] = t >> 2 & 1;
6
+ const et = [], ft = [];
7
+ for (let t = 0; t < 8; t++) for (let n = t + 1; n < 8; n++)
8
+ Math.abs(U[t] - U[n]) + Math.abs(q[t] - q[n]) + Math.abs(H[t] - H[n]) === 1 && (et.push(t), ft.push(n));
9
+ const ct = 127.5, N = (t) => t > ct, $ = (t) => {
10
+ const n = [];
11
+ let i = new t(1048576), r = 0, m = 0;
12
+ return {
13
+ push3(u, C, h) {
14
+ r + 3 > i.length && (n.push(i.subarray(0, r)), m += r, i = new t(1 << 20), r = 0), i[r++] = u, i[r++] = C, i[r++] = h;
15
+ },
16
+ concat() {
17
+ n.push(i.subarray(0, r)), m += r;
18
+ const u = new t(m);
19
+ let C = 0;
20
+ for (const h of n)
21
+ u.set(h, C), C += h.length;
22
+ return u;
23
+ }
24
+ };
25
+ }, tt = (t) => ht(t).map((n) => Math.round(n * 1e3) / 1e3), bt = { 0: tt(V.slaModel), [at.SUPPORT]: tt(V.slaSupport), [at.RAFT]: tt(V.slaPad) };
26
+ function gt(t, n, i, r, m, u, C, h) {
27
+ const b = t + 1, f = n + 1;
28
+ let o = new Int32Array(b * f).fill(-1), M = new Int32Array(b * f).fill(-1);
29
+ const P = null;
30
+ let F = P, w = P, W = null, T = null, x = null, k = null, st = 0;
31
+ const nt = $(Float32Array), X = $(Uint32Array), lt = $(Float32Array);
32
+ let rt = 0, J = !1;
33
+ const O = (A, c, l) => !A || c < 0 || l < 0 || c >= t || l >= n ? 0 : A[c + t * l], v = new Float64Array(8);
34
+ function ot(A, c, l, z, s, R, d, B) {
35
+ const e = c + 1 + b * (l + 1), g = A[e];
36
+ if (g >= 0) return g;
37
+ v[0] = O(s, c, l), v[1] = O(s, c + 1, l), v[2] = O(s, c, l + 1), v[3] = O(s, c + 1, l + 1), v[4] = O(R, c, l), v[5] = O(R, c + 1, l), v[6] = O(R, c, l + 1), v[7] = O(R, c + 1, l + 1);
38
+ let p = 0, a = 0, S = 0, I = 0;
39
+ for (let E = 0; E < et.length; E++) {
40
+ const y = et[E], L = ft[E];
41
+ if (N(v[y]) === N(v[L])) continue;
42
+ const G = Math.min(1, Math.max(0, (ct - v[y]) / (v[L] - v[y])));
43
+ p += U[y] + G * (U[L] - U[y]), a += q[y] + G * (q[L] - q[y]), S += H[y] + G * (H[L] - H[y]), I++;
44
+ }
45
+ const D = I ? p / I : 0.5, _ = I ? a / I : 0.5, j = I ? S / I : 0.5;
46
+ if (nt.push3(u + (c + D + 0.5) * i, C + (l + _ + 0.5) * r, h + (z + j + 0.5) * m), J) {
47
+ let E = 0;
48
+ for (let L = 0; L < 8; L++) {
49
+ if (!N(v[L])) continue;
50
+ const G = O(H[L] ? B : d, c + U[L], l + q[L]);
51
+ if (G === 5) {
52
+ E = 5;
53
+ break;
54
+ }
55
+ G === 6 && (E = 6);
56
+ }
57
+ const y = bt[E];
58
+ lt.push3(y[0], y[1], y[2]);
59
+ }
60
+ return A[e] = rt, rt++;
61
+ }
62
+ const Y = (A, c, l) => c === P || l < 0 || l >= n ? t : A ? A[l * 2] : 0, Z = (A, c, l) => c === P || l < 0 || l >= n ? -1 : A ? A[l * 2 + 1] : t - 1;
63
+ function K(A, c, l) {
64
+ const z = st++, s = (e, g) => ot(o, e, g, z - 1, F, w, W, T), R = (e, g) => ot(M, e, g, z, w, A, T, c), d = (e, g, p, a, S) => {
65
+ S ? (X.push3(a, p, g), X.push3(a, g, e)) : (X.push3(e, g, p), X.push3(e, p, a));
66
+ };
67
+ for (let e = 0; e < n; e++) {
68
+ const g = Math.min(Y(x, F, e), Y(k, w, e)), p = Math.max(Z(x, F, e), Z(k, w, e));
69
+ for (let a = g; a <= p; a++) {
70
+ const S = N(O(F, a, e)), I = N(O(w, a, e));
71
+ S !== I && d(s(a - 1, e - 1), s(a, e - 1), s(a, e), s(a - 1, e), !S);
72
+ }
73
+ }
74
+ for (let e = 0; e < n; e++) {
75
+ const g = Y(k, w, e), p = Z(k, w, e);
76
+ for (let a = g - 1; a <= p; a++) {
77
+ const S = N(O(w, a, e)), I = N(O(w, a + 1, e));
78
+ S !== I && d(s(a, e - 1), s(a, e), R(a, e), R(a, e - 1), !S);
79
+ }
80
+ }
81
+ for (let e = -1; e < n; e++) {
82
+ const g = Math.min(Y(k, w, e), Y(k, w, e + 1)), p = Math.max(Z(k, w, e), Z(k, w, e + 1));
83
+ for (let a = g; a <= p; a++) {
84
+ const S = N(O(w, a, e)), I = N(O(w, a, e + 1));
85
+ S !== I && d(s(a - 1, e), R(a - 1, e), R(a, e), s(a, e), !S);
86
+ }
87
+ }
88
+ const B = o;
89
+ o = M, M = B.fill(-1);
90
+ }
91
+ let Q = !1;
92
+ return {
93
+ // Slices arrive bottom-up. Layer s can only be processed once s+1 is known (its cells' upper corners live
94
+ // there), so the first slice just primes the window and every later push runs the step one layer behind.
95
+ // `roles` is an optional parallel Uint8Array (0=model, 5=support, 6=pad) that turns on vertex colours;
96
+ // `ranges` the per-row occupancy spans fillSliceFromRGBA returns, which confine the sweep to the model.
97
+ pushSlice(A, c = null, l = null) {
98
+ if (c && (J = !0), !Q) {
99
+ Q = !0, w = A, T = c, k = l;
100
+ return;
101
+ }
102
+ K(A, c), F = w, w = A, W = T, T = c, x = k, k = l;
103
+ },
104
+ finish({ smoothRounds: A = 0, normalRounds: c = 0 } = {}) {
105
+ Q && (K(P, null), F = w, w = P, W = T, T = null, x = k, k = null), K(P, null);
106
+ const l = nt.concat(), z = X.concat();
107
+ A > 0 && it(l, z, A);
108
+ const s = new Float32Array(l.length);
109
+ for (let R = 0; R < z.length; R += 3) {
110
+ const d = z[R] * 3, B = z[R + 1] * 3, e = z[R + 2] * 3, g = l[B] - l[d], p = l[B + 1] - l[d + 1], a = l[B + 2] - l[d + 2], S = l[e] - l[d], I = l[e + 1] - l[d + 1], D = l[e + 2] - l[d + 2], _ = p * D - a * I, j = a * S - g * D, E = g * I - p * S;
111
+ s[d] += _, s[d + 1] += j, s[d + 2] += E, s[B] += _, s[B + 1] += j, s[B + 2] += E, s[e] += _, s[e + 1] += j, s[e + 2] += E;
112
+ }
113
+ return ut(s), c > 0 && wt(s, z, c), { positions: l, indices: z, normals: s, colors: J ? lt.concat() : null };
114
+ }
115
+ };
116
+ }
117
+ function ut(t) {
118
+ for (let n = 0; n < t.length; n += 3) {
119
+ const i = Math.hypot(t[n], t[n + 1], t[n + 2]) || 1;
120
+ t[n] /= i, t[n + 1] /= i, t[n + 2] /= i;
121
+ }
122
+ }
123
+ function wt(t, n, i = 2) {
124
+ const r = new Float32Array(t.length);
125
+ for (let m = 0; m < i; m++) {
126
+ r.fill(0);
127
+ for (let u = 0; u < n.length; u += 3) {
128
+ const C = n[u] * 3, h = n[u + 1] * 3, b = n[u + 2] * 3;
129
+ for (const [f, o] of [[C, h], [h, b], [b, C]])
130
+ r[f] += t[o], r[f + 1] += t[o + 1], r[f + 2] += t[o + 2], r[o] += t[f], r[o + 1] += t[f + 1], r[o + 2] += t[f + 2];
131
+ }
132
+ for (let u = 0; u < t.length; u += 3)
133
+ t[u] += 0.5 * r[u], t[u + 1] += 0.5 * r[u + 1], t[u + 2] += 0.5 * r[u + 2];
134
+ ut(t);
135
+ }
136
+ }
137
+ function it(t, n, i = 4) {
138
+ const r = new Float32Array(t.length), m = new Float32Array(t.length / 3), u = (h, b) => {
139
+ const f = h * 3, o = b * 3, M = Math.abs(t[o + 2] - t[f + 2]) + 0.05 * (Math.abs(t[o] - t[f]) + Math.abs(t[o + 1] - t[f + 1])) + 1e-6;
140
+ r[f] += M * t[o], r[f + 1] += M * t[o + 1], r[f + 2] += M * t[o + 2], r[o] += M * t[f], r[o + 1] += M * t[f + 1], r[o + 2] += M * t[f + 2], m[h] += M, m[b] += M;
141
+ }, C = (h) => {
142
+ r.fill(0), m.fill(0);
143
+ for (let b = 0; b < n.length; b += 3) {
144
+ const f = n[b], o = n[b + 1], M = n[b + 2];
145
+ u(f, o), u(o, M), u(M, f);
146
+ }
147
+ for (let b = 0; b < m.length; b++) {
148
+ const f = m[b];
149
+ if (!f) continue;
150
+ const o = b * 3;
151
+ t[o] += h * (r[o] / f - t[o]), t[o + 1] += h * (r[o + 1] / f - t[o + 1]), t[o + 2] += h * (r[o + 2] / f - t[o + 2]);
152
+ }
153
+ };
154
+ for (let h = 0; h < i; h++)
155
+ C(0.5), C(-0.53);
156
+ }
157
+ function mt(t, n, i, r, m) {
158
+ const u = new Uint32Array(n.buffer, n.byteOffset, n.byteLength >> 2), C = new Int32Array(r * 2);
159
+ for (let h = 0; h < r; h++) {
160
+ const b = r - 1 - h, f = h * i * 4 >> 2, o = i * (b + r * m);
161
+ let M = i, P = -1;
162
+ for (let F = 0; F < i; F++) {
163
+ const w = u[f + F];
164
+ if (w === 0) {
165
+ t[o + F] = 0;
166
+ continue;
167
+ }
168
+ const W = w >> 8 & 255;
169
+ t[o + F] = W, W && (F < M && (M = F), F > P && (P = F));
170
+ }
171
+ C[b * 2] = M, C[b * 2 + 1] = P;
172
+ }
173
+ return C;
174
+ }
175
+ export {
176
+ mt as f,
177
+ gt as m
178
+ };
@@ -1,4 +1,4 @@
1
- import { m as c } from "./sla_reconstruct-CXkYhux2.js";
1
+ import { m as c } from "./sla_reconstruct-CRZ3TrI1.js";
2
2
  let e = null, o = { nets: 0, finish: 0 };
3
3
  self.onmessage = (m) => {
4
4
  const s = m.data;
@@ -1,30 +1,31 @@
1
- import { f as D } from "./sla_reconstruct-CXkYhux2.js";
2
- import { d as H } from "./sl1_write-CvrNejbW.js";
1
+ import { f as q } from "./sla_reconstruct-CRZ3TrI1.js";
2
+ import { d as D } from "./sl1_write-BovHbg3k.js";
3
+ import { R as H, S as T, r as E } from "./toolpath_encoding-BuYs95qZ.js";
3
4
  let i = 6;
4
- const M = (u, k) => {
5
+ const M = (u, x) => {
5
6
  const m = [];
6
- for (let l = 0; l + 7 < u.length; l += 8) if ((u[l + 3] & 15) === k) for (let e = 0; e < 8; e++) m.push(u[l + e]);
7
+ for (let l = 0; l + T - 1 < u.length; l += T) if (E(u[l + 3]) === x) for (let e = 0; e < T; e++) m.push(u[l + e]);
7
8
  return m;
8
9
  };
9
10
  self.onmessage = async (u) => {
10
- const { indices: k, pngs: m, rolePaths: l, nx: e, ny: r, matrix: w, scale: d, width: B, height: O, batch: A } = u.data;
11
+ const { indices: x, pngs: m, rolePaths: l, nx: e, ny: r, matrix: w, scale: d, width: k, height: v, batch: A } = u.data;
11
12
  A > 0 && (i = A);
12
13
  try {
13
14
  const s = { decode: 0, draw: 0, read: 0, roles: 0, fill: 0 };
14
15
  let n = 0;
15
- const y = new OffscreenCanvas(e, r * i).getContext("2d", { willReadFrequently: !0 }), f = (l ? new OffscreenCanvas(e, r * i) : null)?.getContext("2d", { willReadFrequently: !0 }), F = (a) => {
16
+ const y = new OffscreenCanvas(e, r * i).getContext("2d", { willReadFrequently: !0 }), f = (l ? new OffscreenCanvas(e, r * i) : null)?.getContext("2d", { willReadFrequently: !0 }), B = (a) => {
16
17
  const o = [];
17
18
  for (let p = 0; p < i && a + p < m.length; p++) {
18
19
  const g = a + p;
19
- o.push(createImageBitmap(new Blob([m[g]], { type: "image/png" })).then((S) => (m[g] = null, S)));
20
+ o.push(createImageBitmap(new Blob([m[g]], { type: "image/png" })).then((I) => (m[g] = null, I)));
20
21
  }
21
22
  return o;
22
23
  };
23
- let I = F(0);
24
+ let F = B(0);
24
25
  for (let a = 0; a < m.length; a += i) {
25
26
  n = performance.now();
26
- const o = await Promise.all(I);
27
- s.decode += performance.now() - n, I = F(a + i), n = performance.now(), y.setTransform(1, 0, 0, 1, 0, 0), y.clearRect(0, 0, e, r * i);
27
+ const o = await Promise.all(F);
28
+ s.decode += performance.now() - n, F = B(a + i), n = performance.now(), y.setTransform(1, 0, 0, 1, 0, 0), y.clearRect(0, 0, e, r * i);
28
29
  for (let t = 0; t < o.length; t++)
29
30
  y.setTransform(
30
31
  w[0] * d,
@@ -41,28 +42,28 @@ self.onmessage = async (u) => {
41
42
  if (f && l.slice(a, a + o.length).some((t) => t && t.length)) {
42
43
  f.setTransform(1, 0, 0, 1, 0, 0), f.clearRect(0, 0, e, r * i);
43
44
  for (let t = 0; t < o.length; t++) {
44
- const h = l[a + t] ?? new Float32Array(0), b = t * r, c = { map: (C, v) => [(C + B / 2) / B * e, (O / 2 - v) / O * r + b] };
45
- f.fillStyle = "#00f", H(f, M(h, 6), c), f.fillStyle = "#f00", H(f, M(h, 5), c);
45
+ const h = l[a + t] ?? new Float32Array(0), R = t * r, c = { map: (b, S) => [(b + k / 2) / k * e, (v / 2 - S) / v * r + R] };
46
+ f.fillStyle = "#00f", D(f, M(h, H.RAFT), c), f.fillStyle = "#f00", D(f, M(h, H.SUPPORT), c);
46
47
  }
47
48
  g = f.getImageData(0, 0, e, r * o.length).data, s.roles += performance.now() - n, n = performance.now();
48
49
  }
49
50
  n = performance.now();
50
51
  for (let t = 0; t < o.length; t++) {
51
- const h = new Uint8Array(e * r), b = D(h, p.subarray(t * e * r * 4, (t + 1) * e * r * 4), e, r, 0);
52
+ const h = new Uint8Array(e * r), R = q(h, p.subarray(t * e * r * 4, (t + 1) * e * r * 4), e, r, 0);
52
53
  let c = null;
53
54
  if (g) {
54
55
  c = new Uint8Array(e * r);
55
- const v = t * e * r * 4;
56
- for (let R = 0; R < r; R++) {
57
- const j = v + R * e * 4, q = e * (r - 1 - R);
58
- for (let x = 0; x < e; x++) {
59
- const T = j + x * 4;
60
- c[q + x] = g[T] > 127 ? 5 : g[T + 2] > 127 ? 6 : 0;
56
+ const S = t * e * r * 4;
57
+ for (let O = 0; O < r; O++) {
58
+ const U = S + O * e * 4, j = e * (r - 1 - O);
59
+ for (let C = 0; C < e; C++) {
60
+ const P = U + C * 4;
61
+ c[j + C] = g[P] > 127 ? 5 : g[P + 2] > 127 ? 6 : 0;
61
62
  }
62
63
  }
63
64
  }
64
- const C = [h.buffer, b.buffer];
65
- c && C.push(c.buffer), self.postMessage({ index: k[a + t], slice: h, ranges: b, roles: c }, C);
65
+ const b = [h.buffer, R.buffer];
66
+ c && b.push(c.buffer), self.postMessage({ index: x[a + t], slice: h, ranges: R, roles: c }, b);
66
67
  }
67
68
  s.fill += performance.now() - n;
68
69
  }
@@ -0,0 +1,97 @@
1
+ const t = Object.freeze({
2
+ accent: "#00ae42",
3
+ // selection: the object, the selected plate, the scale handles, the box-select band
4
+ accentHover: "#1f5c34",
5
+ // emissive tint of the object under the pointer
6
+ sceneBackground: "#161a1e",
7
+ lightSky: "#ffffff",
8
+ lightGround: "#2a2f36",
9
+ gridMinor: "#232a31",
10
+ gridMajor: "#39434d",
11
+ plateBorder: "#4a5560",
12
+ plateLabel: "#5a6570",
13
+ travel: "#5a6270",
14
+ // travel moves in the toolpath preview
15
+ nozzle: "#ff7a1a",
16
+ overhang: "#ff4433",
17
+ // the brush's overhang-limit overlay
18
+ primeTower: "#4fd1c5",
19
+ slaModel: "#d7862a",
20
+ slaSupport: "#9b78d8",
21
+ slaPad: "#b0a06a",
22
+ inkOnLight: "#10141a",
23
+ // label text on a light swatch
24
+ inkOnDark: "#ffffff"
25
+ });
26
+ function i(r) {
27
+ const e = (a) => a <= 0.04045 ? a / 12.92 : ((a + 0.055) / 1.055) ** 2.4;
28
+ return [1, 3, 5].map((a) => e(parseInt(r.slice(a, a + 2), 16) / 255));
29
+ }
30
+ const c = Object.freeze({
31
+ // the brand green and its family
32
+ accent: t.accent,
33
+ accentHover: "#06c04d",
34
+ accentDeep: "#23402c",
35
+ // the busy pulse on a dark control
36
+ accentInk: "#167a3a",
37
+ // green text on a light surface
38
+ accentOnDark: "#9fe3bd",
39
+ // green text on a dark surface
40
+ accentSoft: "#e3f6ea",
41
+ // selected row / active tab on a light surface
42
+ accentSoftBorder: "#9adfb6",
43
+ onAccent: "#ffffff",
44
+ // text and marks on any filled status colour
45
+ // the dark chrome: top bar, rail, viewport overlays, menus
46
+ darkBase: "#0e1216",
47
+ darkSurface: "#161b21",
48
+ darkControl: "#1a2027",
49
+ darkControlHover: "#28313a",
50
+ darkBorder: "#2c353d",
51
+ darkBorderStrong: "#3a4550",
52
+ darkText: "#cdd6dd",
53
+ darkTextMuted: "#aebcc6",
54
+ darkTextFaint: "#8b98a2",
55
+ darkTextDisabled: t.plateLabel,
56
+ // the light sidebar and the settings panel
57
+ lightBg: "#eef0f2",
58
+ lightSurface: "#ffffff",
59
+ lightSubtle: "#f6f7f8",
60
+ lightControl: "#dfe6ea",
61
+ lightControlHover: "#d3dee4",
62
+ lightBorder: "#d5d8dd",
63
+ lightDivider: "#e3e6ea",
64
+ lightText: "#24282e",
65
+ lightTextMuted: "#5a6069",
66
+ lightTextFaint: "#8a9099",
67
+ // status
68
+ info: "#2b6cff",
69
+ infoInk: "#2563eb",
70
+ // the info blue as a filled badge under white text (4.5:1)
71
+ infoSoft: "#e6efff",
72
+ techBadge: "#6d7ce0",
73
+ // the resin marker on an object-list plate header
74
+ danger: "#e23b3b",
75
+ dangerInk: "#a33b37",
76
+ dangerSoft: "#fbeaea",
77
+ dangerOnDark: "#ff8b8b",
78
+ dangerDeep: "#4a2229",
79
+ warn: "#f0a542",
80
+ warnInk: "#a86a12",
81
+ warnSoft: "#fdf4e3",
82
+ warnSoftHover: "#f3e2cb",
83
+ warnBorder: "#d8b48a",
84
+ warnOnDark: "#f0c060",
85
+ warnDeep: "#3a2a10",
86
+ warnDeepBorder: "#7a5a1e"
87
+ }), o = (r) => r.replace(/[A-Z]/g, (e) => "-" + e.toLowerCase()), d = ["accent", "darkBase", "darkSurface", "warnDeep"], f = (r) => [1, 3, 5].map((e) => parseInt(r.slice(e, e + 2), 16)).join(", "), l = (r, e) => `rgba(${f(r)}, ${e})`, b = `:host{${Object.entries(c).map(([r, e]) => {
88
+ const a = o(r), n = `--_${a}:var(--vp-${a},${e});`;
89
+ return d.includes(r) ? n + `--_${a}-rgb:var(--vp-${a}-rgb,${f(e)});` : n;
90
+ }).join("")}}
91
+ `;
92
+ export {
93
+ t as T,
94
+ b as a,
95
+ i as h,
96
+ l as w
97
+ };