three-slicer-viewer 0.3.0 → 0.3.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.
@@ -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
+ };