three-slicer-viewer 0.2.5 → 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.
package/dist/toolpath.js CHANGED
@@ -1,4 +1,7 @@
1
- const _ = {
1
+ import { U as St, b as It, a as kt } from "./viewer_defaults-B7UUZ582.js";
2
+ import { r as bt, S as nt, R as et, t as Tt } from "./toolpath_encoding-BuYs95qZ.js";
3
+ import { T as Pt } from "./theme-2oyfMuvf.js";
4
+ const O = {
2
5
  0: [0.35, 0.38, 0.44],
3
6
  // travel
4
7
  1: [0.98, 0.45, 0.16],
@@ -23,7 +26,7 @@ const _ = {
23
26
  // ironing
24
27
  11: [0.58, 0.5, 0.88]
25
28
  // prime tower
26
- }, Mt = {
29
+ }, Ot = {
27
30
  0: "Travel",
28
31
  1: "Wall",
29
32
  2: "Sparse",
@@ -36,7 +39,7 @@ const _ = {
36
39
  9: "Bridge",
37
40
  10: "Ironing",
38
41
  11: "Prime"
39
- }, dt = [
42
+ }, gt = [
40
43
  [0.9, 0.26, 0.3],
41
44
  [0.27, 0.6, 0.93],
42
45
  [0.36, 0.78, 0.42],
@@ -46,17 +49,17 @@ const _ = {
46
49
  [0.95, 0.5, 0.72],
47
50
  [0.6, 0.6, 0.64]
48
51
  ];
49
- function St(t) {
52
+ function Lt(t) {
50
53
  const e = /^#?([0-9a-f]{6})$/i.exec(String(t ?? "").trim());
51
- if (!e) return [0.5, 0.5, 0.5];
54
+ if (!e) return Lt(St);
52
55
  const n = parseInt(e[1], 16);
53
56
  return [(n >> 16 & 255) / 255, (n >> 8 & 255) / 255, (n & 255) / 255];
54
57
  }
55
- function et(t) {
58
+ function ot(t) {
56
59
  const e = (n) => Math.max(0, Math.min(255, Math.round((Number(n) || 0) * 255)));
57
60
  return e(t?.[0]) * 65536 + e(t?.[1]) * 256 + e(t?.[2]);
58
61
  }
59
- const At = [
62
+ const xt = [
60
63
  [0.043, 0.173, 0.478],
61
64
  [0.055, 0.325, 0.639],
62
65
  [0.067, 0.478, 0.8],
@@ -69,85 +72,85 @@ const At = [
69
72
  [0.988, 0.663, 0.012],
70
73
  [0.58, 0.149, 0.086]
71
74
  ];
72
- function Nt(t, e, n, r = At) {
75
+ function _t(t, e, n, r = xt) {
73
76
  const o = r.length - 1;
74
77
  if (o < 0) return [0, 0, 0];
75
78
  if (!Number.isFinite(t) || !Number.isFinite(e) || !Number.isFinite(n) || n <= e || t <= e) return r[0];
76
79
  if (t >= n) return r[o];
77
- const i = (t - e) / (n - e) * o, f = Math.min(o - 1, Math.floor(i)), u = i - f, l = r[f], h = r[f + 1];
78
- return [l[0] + (h[0] - l[0]) * u, l[1] + (h[1] - l[1]) * u, l[2] + (h[2] - l[2]) * u];
80
+ const i = (t - e) / (n - e) * o, f = Math.min(o - 1, Math.floor(i)), u = i - f, l = r[f], m = r[f + 1];
81
+ return [l[0] + (m[0] - l[0]) * u, l[1] + (m[1] - l[1]) * u, l[2] + (m[2] - l[2]) * u];
79
82
  }
80
- const nt = 8, It = 0.2, bt = 15, kt = 4, ot = {};
81
- for (const t of Object.keys(_)) ot[t] = et(_[t]);
82
- function Pt(t) {
83
+ const rt = {};
84
+ for (const t of Object.keys(O)) rt[t] = ot(O[t]);
85
+ function Vt(t) {
83
86
  const e = new Float32Array(t.length);
84
87
  for (let n = 0; n < t.length; n++) {
85
88
  const r = Number(t[n]?.z) || 0, o = n > 0 && Number(t[n - 1]?.z) || 0, i = n > 0 ? r - o : r;
86
- e[n] = i > 1e-6 ? i : It;
89
+ e[n] = i > 1e-6 ? i : kt;
87
90
  }
88
91
  return e;
89
92
  }
90
- const rt = (t) => t?.paths?.length ? t.paths : null, gt = (t) => {
91
- const e = rt(t);
93
+ const it = (t) => t?.paths?.length ? t.paths : null, wt = (t) => {
94
+ const e = it(t);
92
95
  return e ? Math.floor(e.length / nt) : 0;
93
96
  };
94
- function Vt(t, e) {
95
- const n = Array.isArray(t) ? t : [], r = n.length, o = Number(e) > 0 ? Number(e) : 0.4, i = Pt(n), f = new Uint32Array(r + 1), u = new Uint32Array(r + 1), l = new Uint32Array(r + 1);
96
- let h = 0, c = 0, m = 0;
97
- for (let p = 0; p < r; p++) {
98
- const U = rt(n[p]), w = gt(n[p]);
99
- for (let G = 0; G < w; G++)
100
- U[G * nt + 3] & bt ? h++ : c++;
101
- m += w, f[p + 1] = h, u[p + 1] = c, l[p + 1] = m;
97
+ function Rt(t, e) {
98
+ const n = Array.isArray(t) ? t : [], r = n.length, o = Number(e) > 0 ? Number(e) : It, i = Vt(n), f = new Uint32Array(r + 1), u = new Uint32Array(r + 1), l = new Uint32Array(r + 1);
99
+ let m = 0, c = 0, h = 0;
100
+ for (let y = 0; y < r; y++) {
101
+ const U = it(n[y]), w = wt(n[y]);
102
+ for (let D = 0; D < w; D++)
103
+ bt(U[D * nt + 3]) === et.TRAVEL ? c++ : m++;
104
+ h += w, f[y + 1] = m, u[y + 1] = c, l[y + 1] = h;
102
105
  }
103
- const s = h * 2, b = new Float32Array(s * 4), L = new Float32Array(s * 4), y = new Uint32Array(s * 2), O = new Uint8Array(s), M = new Uint8Array(s), z = new Float32Array(s), S = new Float32Array(s), B = new Int32Array(s), g = new Float32Array(c * 6), C = new Float32Array(m * 3), a = new Uint8Array(m), v = new Float64Array(16);
104
- let A = !1, N = 0, I = 1 / 0, P = 1 / 0, V = 1 / 0, J = -1 / 0, Q = -1 / 0, R = -1 / 0, x = 0, st = 0, at = 0, W = 0;
105
- for (let p = 0; p < r; p++) {
106
- const U = n[p], w = rt(U), G = gt(U), lt = U?.widths, E = i[p], ct = E / 2;
107
- for (let X = 0; X < G; X++) {
108
- const k = X * nt, Z = w[k], q = w[k + 1], $ = w[k + 2], D = w[k + 4], Y = w[k + 5], H = w[k + 6], ft = w[k + 3] | 0, K = ft & bt, Lt = ft >>> kt;
109
- if (Number.isFinite(Z + q + $ + D + Y + H) || (A = !0), a[W] = K === 0 ? 0 : 1, C[W * 3] = D, C[W * 3 + 1] = Y, C[W * 3 + 2] = H, W++, K === 0) {
110
- const d = at * 6;
111
- g[d] = Z, g[d + 1] = q, g[d + 2] = $, g[d + 3] = D, g[d + 4] = Y, g[d + 5] = H, at++;
106
+ const a = m * 2, b = new Float32Array(a * 4), x = new Float32Array(a * 4), v = new Uint32Array(a * 2), _ = new Uint8Array(a), F = new Uint8Array(a), V = new Float32Array(a), M = new Float32Array(a), W = new Int32Array(a), g = new Float32Array(c * 6), C = new Float32Array(h * 3), s = new Uint8Array(h), p = new Float64Array(16);
107
+ let A = !1, S = 0, I = 1 / 0, T = 1 / 0, z = 1 / 0, $ = -1 / 0, J = -1 / 0, Q = -1 / 0, L = 0, st = 0, lt = 0, B = 0;
108
+ for (let y = 0; y < r; y++) {
109
+ const U = n[y], w = it(U), D = wt(U), ct = U?.widths, E = i[y], ft = E / 2;
110
+ for (let j = 0; j < D; j++) {
111
+ const k = j * nt, X = w[k], Z = w[k + 1], q = w[k + 2], G = w[k + 4], Y = w[k + 5], H = w[k + 6], ut = w[k + 3] | 0, R = bt(ut), Nt = Tt(ut);
112
+ if (Number.isFinite(X + Z + q + G + Y + H) || (A = !0), s[B] = R === et.TRAVEL ? 0 : 1, C[B * 3] = G, C[B * 3 + 1] = Y, C[B * 3 + 2] = H, B++, R === et.TRAVEL) {
113
+ const d = lt * 6;
114
+ g[d] = X, g[d + 1] = Z, g[d + 2] = q, g[d + 3] = G, g[d + 4] = Y, g[d + 5] = H, lt++;
112
115
  continue;
113
116
  }
114
- const tt = lt ? Number(lt[X]) : NaN, ut = Number.isFinite(tt) && tt > 0 ? tt : o, ht = D - Z, mt = Y - q, Ct = Math.atan2(mt, ht), vt = Math.hypot(ht, mt, H - $);
115
- Number.isFinite(vt) && (v[K] += vt);
116
- const Ft = ot[K] ?? ot[1];
117
- for (const [d, T, yt] of [[Z, q, $], [D, Y, H]]) {
118
- const F = x * 4;
119
- b[F] = d, b[F + 1] = T, b[F + 2] = yt - ct, b[F + 3] = 0, L[F] = E, L[F + 1] = ut, L[F + 2] = Ct, L[F + 3] = Ft, y[x * 2] = st, y[x * 2 + 1] = p, O[x] = K, M[x] = Lt, z[x] = ut, S[x] = E, B[x] = p, x++;
120
- const j = yt - ct;
121
- d < I && (I = d), d > J && (J = d), T < P && (P = T), T > Q && (Q = T), j < V && (V = j), j > R && (R = j);
122
- const pt = Math.max(Math.abs(d), Math.abs(T), Math.abs(j));
123
- pt > N && (N = pt);
117
+ const tt = ct ? Number(ct[j]) : NaN, mt = Number.isFinite(tt) && tt > 0 ? tt : o, ht = G - X, pt = Y - Z, Ft = Math.atan2(pt, ht), vt = Math.hypot(ht, pt, H - q);
118
+ Number.isFinite(vt) && (p[R] += vt);
119
+ const Mt = rt[R] ?? rt[1];
120
+ for (const [d, P, yt] of [[X, Z, q], [G, Y, H]]) {
121
+ const N = L * 4;
122
+ b[N] = d, b[N + 1] = P, b[N + 2] = yt - ft, b[N + 3] = 0, x[N] = E, x[N + 1] = mt, x[N + 2] = Ft, x[N + 3] = Mt, v[L * 2] = st, v[L * 2 + 1] = y, _[L] = R, F[L] = Nt, V[L] = mt, M[L] = E, W[L] = y, L++;
123
+ const K = yt - ft;
124
+ d < I && (I = d), d > $ && ($ = d), P < T && (T = P), P > J && (J = P), K < z && (z = K), K > Q && (Q = K);
125
+ const dt = Math.max(Math.abs(d), Math.abs(P), Math.abs(K));
126
+ dt > S && (S = dt);
124
127
  }
125
128
  st++;
126
129
  }
127
130
  }
128
- const xt = s > 0 && Number.isFinite(I) ? { min: [I, P, V], max: [J, Q, R] } : null;
131
+ const Ct = a > 0 && Number.isFinite(I) ? { min: [I, T, z], max: [$, J, Q] } : null;
129
132
  return {
130
133
  position: b,
131
- hwa: L,
132
- segIndex: y,
133
- nV: s,
134
- nSeg: h,
134
+ hwa: x,
135
+ segIndex: v,
136
+ nV: a,
137
+ nSeg: m,
135
138
  layerSegPrefix: f,
136
139
  travelPos: g,
137
140
  travelPrefix: u,
138
141
  nTrav: c,
139
142
  movePos: C,
140
- moveKind: a,
143
+ moveKind: s,
141
144
  movePrefix: l,
142
145
  layerCount: r,
143
- maxAbs: N,
146
+ maxAbs: S,
144
147
  hasNaN: A,
145
- typeLengths: v,
146
- bbox: xt,
147
- meta: { vType: O, vTool: M, vWidth: z, vHeight: S, vLayer: B }
148
+ typeLengths: p,
149
+ bbox: Ct,
150
+ meta: { vType: _, vTool: F, vWidth: V, vHeight: M, vLayer: W }
148
151
  };
149
152
  }
150
- function Wt(t) {
153
+ function Kt(t) {
151
154
  const e = t ?? [];
152
155
  let n = 0;
153
156
  for (let o = 0; o < 16; o++) n += Number(e[o]) || 0;
@@ -155,24 +158,24 @@ function Wt(t) {
155
158
  const r = [];
156
159
  for (let o = 0; o < 16; o++) {
157
160
  const i = Number(e[o]) || 0;
158
- i <= 0 || r.push({ type: o, label: Mt[o] ?? String(o), pct: i / n * 100, color: _[o] ?? _[1] });
161
+ i <= 0 || r.push({ type: o, label: Ot[o] ?? String(o), pct: i / n * 100, color: O[o] ?? O[1] });
159
162
  }
160
163
  return r.sort((o, i) => i.pct - o.pct);
161
164
  }
162
- const it = (t, e) => e >= 0 && e < t.layerCount ? t.movePrefix[e + 1] - t.movePrefix[e] : 0;
163
- function Ut(t, e) {
164
- return it(t, e);
165
+ const at = (t, e) => e >= 0 && e < t.layerCount ? t.movePrefix[e + 1] - t.movePrefix[e] : 0;
166
+ function jt(t, e) {
167
+ return at(t, e);
165
168
  }
166
- function Gt(t, e, n) {
169
+ function Xt(t, e, n) {
167
170
  const r = Math.min(n, t.layerCount - 1);
168
- for (let o = r; o >= e; o--) if (it(t, o) > 0) return o;
171
+ for (let o = r; o >= e; o--) if (at(t, o) > 0) return o;
169
172
  return e;
170
173
  }
171
- function Dt(t, e, n) {
172
- const r = it(t, e), o = Math.max(0, Math.min(Number(n) || 0, r)), i = e >= 0 && e < t.layerCount ? t.movePrefix[e] : 0;
174
+ function Zt(t, e, n) {
175
+ const r = at(t, e), o = Math.max(0, Math.min(Number(n) || 0, r)), i = e >= 0 && e < t.layerCount ? t.movePrefix[e] : 0;
173
176
  let f = 0, u = 0;
174
- for (let h = 0; h < o; h++)
175
- t.moveKind[i + h] === 0 ? u++ : f++;
177
+ for (let m = 0; m < o; m++)
178
+ t.moveKind[i + m] === 0 ? u++ : f++;
176
179
  if (o === 0) return { point: null, segCount: 0, travCount: 0, onTravel: !1 };
177
180
  const l = i + o - 1;
178
181
  return {
@@ -182,7 +185,7 @@ function Dt(t, e, n) {
182
185
  onTravel: t.moveKind[l] === 0
183
186
  };
184
187
  }
185
- const wt = [
188
+ const At = [
186
189
  { key: "feature", label: "Feature type", cont: !1, unit: "" },
187
190
  { key: "speed", label: "Speed", cont: !0, unit: "mm/s" },
188
191
  { key: "height", label: "Layer Height", cont: !0, unit: "mm" },
@@ -194,7 +197,7 @@ const wt = [
194
197
  // extruder index is a label, and a heatmap over it would imply tool 2 sits "between" tools 1 and 3.
195
198
  { key: "filament", label: "Filament", cont: !1, unit: "" }
196
199
  ];
197
- function Tt(t, e, n, r) {
200
+ function Wt(t, e, n, r) {
198
201
  const o = e.vType[n], i = e.vLayer[n], f = i === 0;
199
202
  switch (t) {
200
203
  case "height":
@@ -211,30 +214,30 @@ function Tt(t, e, n, r) {
211
214
  return 0;
212
215
  }
213
216
  }
214
- function Yt(t, e, n) {
215
- const { meta: r, nV: o } = t, i = new Float32Array(o * 4), f = wt.find((c) => c.key === e) || wt[0];
217
+ function qt(t, e, n) {
218
+ const { meta: r, nV: o } = t, i = new Float32Array(o * 4), f = At.find((c) => c.key === e) || At[0];
216
219
  if (!f.cont) {
217
- const c = (n?.toolColors ?? []).map(St), m = f.key === "filament" ? (s) => {
218
- const b = r.vTool ? r.vTool[s] : 0;
219
- return c[b] || dt[b % dt.length];
220
- } : (s) => _[r.vType[s]] || _[1];
221
- for (let s = 0; s < o; s++) i[s * 4] = et(m(s));
220
+ const c = (n?.toolColors ?? []).map(Lt), h = f.key === "filament" ? (a) => {
221
+ const b = r.vTool ? r.vTool[a] : 0;
222
+ return c[b] || gt[b % gt.length];
223
+ } : (a) => O[r.vType[a]] || O[1];
224
+ for (let a = 0; a < o; a++) i[a * 4] = ot(h(a));
222
225
  return { color: i, min: 0, max: 0, viewType: e, label: f.label, unit: f.unit, cont: !1 };
223
226
  }
224
227
  let u = 1 / 0, l = -1 / 0;
225
- const h = new Float32Array(o);
228
+ const m = new Float32Array(o);
226
229
  for (let c = 0; c < o; c++) {
227
- const m = Tt(e, r, c, n), s = Number.isFinite(m) ? m : 0;
228
- h[c] = s, s < u && (u = s), s > l && (l = s);
230
+ const h = Wt(e, r, c, n), a = Number.isFinite(h) ? h : 0;
231
+ m[c] = a, a < u && (u = a), a > l && (l = a);
229
232
  }
230
233
  Number.isFinite(u) || (u = 0, l = 1);
231
234
  for (let c = 0; c < o; c++) {
232
- const m = Nt(h[c], u, l, At);
233
- i[c * 4] = et(m);
235
+ const h = _t(m[c], u, l, xt);
236
+ i[c * 4] = ot(h);
234
237
  }
235
238
  return { color: i, min: u, max: l, viewType: e, label: f.label, unit: f.unit, cont: !0 };
236
239
  }
237
- const _t = `
240
+ const zt = `
238
241
  precision highp float;
239
242
 
240
243
  uniform mat4 projectionMatrix;
@@ -294,7 +297,7 @@ void main() {
294
297
  vColor = unpackColor(iColor);
295
298
  gl_Position = projectionMatrix * modelViewMatrix * vec4(world, 1.0);
296
299
  }
297
- `, Ot = `
300
+ `, Bt = `
298
301
  precision highp float;
299
302
 
300
303
  in vec3 vColor;
@@ -310,7 +313,7 @@ void main() {
310
313
  float lambert = max(dot(n, normalize(vec3(0.35, 0.35, 1.0))), 0.0);
311
314
  fragColor = vec4(vColor * (0.55 + 0.45 * lambert), 1.0);
312
315
  }
313
- `, zt = new Float32Array([
316
+ `, Ut = new Float32Array([
314
317
  0,
315
318
  0,
316
319
  0,
@@ -329,7 +332,7 @@ void main() {
329
332
  1,
330
333
  3
331
334
  // end ring
332
- ]), Bt = (() => {
335
+ ]), Dt = (() => {
333
336
  const t = [];
334
337
  for (let e = 0; e < 4; e++) {
335
338
  const n = e, r = (e + 1) % 4, o = 4 + (e + 1) % 4, i = 4 + e;
@@ -337,72 +340,72 @@ void main() {
337
340
  }
338
341
  return t;
339
342
  })();
340
- function Ht(t, e) {
341
- const { nSeg: n, nV: r, position: o, hwa: i, travelPos: f, travelPrefix: u, layerCount: l, meta: h } = e, c = new Float32Array(n * 3), m = new Float32Array(n * 3), s = new Float32Array(n * 2), b = new Float32Array(n), L = new Float32Array(n);
342
- for (let a = 0; a < n; a++) {
343
- const v = a * 2 * 4, A = (a * 2 + 1) * 4;
344
- c[a * 3] = o[v], c[a * 3 + 1] = o[v + 1], c[a * 3 + 2] = o[v + 2], m[a * 3] = o[A], m[a * 3 + 1] = o[A + 1], m[a * 3 + 2] = o[A + 2], s[a * 2] = i[v], s[a * 2 + 1] = i[v + 1], b[a] = i[v + 3], L[a] = h.vLayer[a * 2];
343
+ function $t(t, e) {
344
+ const { nSeg: n, nV: r, position: o, hwa: i, travelPos: f, travelPrefix: u, layerCount: l, meta: m } = e, c = new Float32Array(n * 3), h = new Float32Array(n * 3), a = new Float32Array(n * 2), b = new Float32Array(n), x = new Float32Array(n);
345
+ for (let s = 0; s < n; s++) {
346
+ const p = s * 2 * 4, A = (s * 2 + 1) * 4;
347
+ c[s * 3] = o[p], c[s * 3 + 1] = o[p + 1], c[s * 3 + 2] = o[p + 2], h[s * 3] = o[A], h[s * 3 + 1] = o[A + 1], h[s * 3 + 2] = o[A + 2], a[s * 2] = i[p], a[s * 2 + 1] = i[p + 1], b[s] = i[p + 3], x[s] = m.vLayer[s * 2];
345
348
  }
346
- const y = new t.InstancedBufferGeometry();
347
- y.setAttribute("tpl", new t.BufferAttribute(zt, 2)), y.setIndex(Bt), y.setAttribute("iStart", new t.InstancedBufferAttribute(c, 3)), y.setAttribute("iEnd", new t.InstancedBufferAttribute(m, 3)), y.setAttribute("iHW", new t.InstancedBufferAttribute(s, 2));
348
- const O = new t.InstancedBufferAttribute(b, 1);
349
- y.setAttribute("iColor", O), y.setAttribute("iLayer", new t.InstancedBufferAttribute(L, 1)), y.instanceCount = n, y.boundingSphere = new t.Sphere(new t.Vector3(0, 0, 0), (e.maxAbs || 1) * 2);
350
- const M = new t.RawShaderMaterial({
351
- vertexShader: _t,
352
- fragmentShader: Ot,
349
+ const v = new t.InstancedBufferGeometry();
350
+ v.setAttribute("tpl", new t.BufferAttribute(Ut, 2)), v.setIndex(Dt), v.setAttribute("iStart", new t.InstancedBufferAttribute(c, 3)), v.setAttribute("iEnd", new t.InstancedBufferAttribute(h, 3)), v.setAttribute("iHW", new t.InstancedBufferAttribute(a, 2));
351
+ const _ = new t.InstancedBufferAttribute(b, 1);
352
+ v.setAttribute("iColor", _), v.setAttribute("iLayer", new t.InstancedBufferAttribute(x, 1)), v.instanceCount = n, v.boundingSphere = new t.Sphere(new t.Vector3(0, 0, 0), (e.maxAbs || 1) * 2);
353
+ const F = new t.RawShaderMaterial({
354
+ vertexShader: zt,
355
+ fragmentShader: Bt,
353
356
  glslVersion: t.GLSL3,
354
357
  side: t.DoubleSide,
355
358
  uniforms: { uLayerLo: { value: 0 }, uLayerHi: { value: Math.max(0, l - 1) } }
356
- }), z = new t.Mesh(y, M);
357
- z.frustumCulled = !1;
358
- const S = new t.BufferGeometry();
359
- S.setAttribute("position", new t.BufferAttribute(f, 3));
360
- const B = new t.LineBasicMaterial({ color: 5923440, transparent: !0, opacity: 0.6 }), g = new t.LineSegments(S, B);
359
+ }), V = new t.Mesh(v, F);
360
+ V.frustumCulled = !1;
361
+ const M = new t.BufferGeometry();
362
+ M.setAttribute("position", new t.BufferAttribute(f, 3));
363
+ const W = new t.LineBasicMaterial({ color: Pt.travel, transparent: !0, opacity: 0.6 }), g = new t.LineSegments(M, W);
361
364
  g.visible = !1, g.frustumCulled = !1;
362
- const C = (a, v) => {
363
- const A = Math.max(0, l - 1), N = Math.max(0, Math.min(a | 0, A)), I = Math.max(N, Math.min(v | 0, A));
364
- M.uniforms.uLayerLo.value = N, M.uniforms.uLayerHi.value = I;
365
- const P = u[N] * 2, V = u[I + 1] * 2;
366
- S.setDrawRange(P, Math.max(0, V - P));
365
+ const C = (s, p) => {
366
+ const A = Math.max(0, l - 1), S = Math.max(0, Math.min(s | 0, A)), I = Math.max(S, Math.min(p | 0, A));
367
+ F.uniforms.uLayerLo.value = S, F.uniforms.uLayerHi.value = I;
368
+ const T = u[S] * 2, z = u[I + 1] * 2;
369
+ M.setDrawRange(T, Math.max(0, z - T));
367
370
  };
368
371
  return C(0, l - 1), {
369
- mesh: z,
372
+ mesh: V,
370
373
  travLines: g,
371
374
  setLayerRange: C,
372
- setVisibleLayers: (a) => C(0, (a | 0) - 1),
373
- setTravelVisible: (a) => {
374
- g.visible = !!a;
375
+ setVisibleLayers: (s) => C(0, (s | 0) - 1),
376
+ setTravelVisible: (s) => {
377
+ g.visible = !!s;
375
378
  },
376
379
  /** color is Float32Array(nV*4) with the packed value in .r — computeColors' output shape. One instance
377
380
  * takes the colour of its first vertex; the two agree, since a segment is one colour. */
378
- setColors: (a) => {
379
- if (!(!a || a.length < r * 4)) {
380
- for (let v = 0; v < n; v++) b[v] = a[v * 2 * 4];
381
- O.needsUpdate = !0;
381
+ setColors: (s) => {
382
+ if (!(!s || s.length < r * 4)) {
383
+ for (let p = 0; p < n; p++) b[p] = s[p * 2 * 4];
384
+ _.needsUpdate = !0;
382
385
  }
383
386
  },
384
387
  dispose: () => {
385
- y.dispose(), M.dispose(), S.dispose(), B.dispose();
388
+ v.dispose(), F.dispose(), M.dispose(), W.dispose();
386
389
  },
387
390
  nSeg: n,
388
391
  layerCount: l
389
392
  };
390
393
  }
391
394
  export {
392
- At as DEFAULT_RANGES_COLORS,
393
- dt as TOOL_COLOR,
394
- _ as TYPE_COLOR,
395
- Mt as TYPE_LABEL,
396
- Bt as VERTEX_DATA,
397
- wt as VIEW_TYPES,
398
- Vt as buildSegmentData,
399
- Yt as computeColors,
400
- St as hexToRgb,
401
- Ut as layerMoveCount,
402
- Ht as makeToolpath,
403
- Dt as moveCursor,
404
- et as packColor,
405
- Nt as rangeColorAt,
406
- Wt as roleRatios,
407
- Gt as topMoveLayer
395
+ xt as DEFAULT_RANGES_COLORS,
396
+ gt as TOOL_COLOR,
397
+ O as TYPE_COLOR,
398
+ Ot as TYPE_LABEL,
399
+ Dt as VERTEX_DATA,
400
+ At as VIEW_TYPES,
401
+ Rt as buildSegmentData,
402
+ qt as computeColors,
403
+ Lt as hexToRgb,
404
+ jt as layerMoveCount,
405
+ $t as makeToolpath,
406
+ Zt as moveCursor,
407
+ ot as packColor,
408
+ _t as rangeColorAt,
409
+ Kt as roleRatios,
410
+ Xt as topMoveLayer
408
411
  };
@@ -0,0 +1,23 @@
1
+ const o = 8;
2
+ const s = Object.freeze({
3
+ TRAVEL: 0,
4
+ WALL: 1,
5
+ SPARSE: 2,
6
+ SOLID: 3,
7
+ SKIRT: 4,
8
+ SUPPORT: 5,
9
+ RAFT: 6,
10
+ // the SLA stream puts its pad here, as it puts support trees on SUPPORT
11
+ GAP: 7,
12
+ THIN: 8,
13
+ BRIDGE: 9,
14
+ IRONING: 10,
15
+ PRIME: 11
16
+ }), S = (O, R) => O + (R << 4), T = (O) => O & 15, t = (O) => O >>> 4;
17
+ export {
18
+ s as R,
19
+ o as S,
20
+ S as e,
21
+ T as r,
22
+ t
23
+ };
@@ -0,0 +1,28 @@
1
+ const a = Object.freeze({ width: 200, depth: 200 }), d = 0.42, s = 0.2, E = 1.75, c = "#888888", _ = 0.4, e = 16, t = Object.freeze([
2
+ "#6aa0dc",
3
+ "#e08a2b",
4
+ "#e0473b",
5
+ "#3bb0e0",
6
+ "#7ad14a",
7
+ "#b06ad1",
8
+ "#d1c34a",
9
+ "#4ad1a8",
10
+ "#d16a9a",
11
+ "#6a7ad1",
12
+ "#8fd16a",
13
+ "#d18f6a",
14
+ "#6ad1d1",
15
+ "#c74ad1",
16
+ "#a8a8a8",
17
+ "#4a6ad1"
18
+ ]);
19
+ export {
20
+ E as D,
21
+ e as M,
22
+ _ as S,
23
+ c as U,
24
+ s as a,
25
+ d as b,
26
+ a as c,
27
+ t as d
28
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "three-slicer-viewer",
3
- "version": "0.2.5",
4
- "description": "The three-slicer viewer without the slicer \u2014 model loading, G-code parsing, GPU toolpath rendering and the settings transforms, under MIT. Plug a slicer in through the `slicer` prop.",
3
+ "version": "0.3.1",
4
+ "description": "The three-slicer viewer without the slicer — model loading, G-code parsing, GPU toolpath rendering and the settings transforms, under MIT. Plug a slicer in through the `slicer` prop.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -51,15 +51,40 @@
51
51
  "dist",
52
52
  "src/data.js",
53
53
  "src/settings",
54
- "types"
54
+ "types",
55
+ "!**/.omc"
55
56
  ],
56
57
  "keywords": [
57
58
  "3d-printing",
59
+ "3d-printer",
60
+ "viewer",
58
61
  "gcode",
62
+ "gcode-viewer",
59
63
  "toolpath",
64
+ "stl",
65
+ "obj",
66
+ "3mf",
67
+ "amf",
68
+ "ply",
69
+ "sl1",
70
+ "sla",
71
+ "resin",
60
72
  "three",
61
- "viewer"
73
+ "three.js",
74
+ "threejs",
75
+ "react",
76
+ "webgl",
77
+ "model-viewer",
78
+ "three-slicer"
62
79
  ],
80
+ "homepage": "https://slicer.kimgh06.com",
81
+ "repository": {
82
+ "type": "git",
83
+ "url": "git+https://github.com/kimgh06/three-slicer-viewer.git"
84
+ },
85
+ "bugs": {
86
+ "url": "https://github.com/kimgh06/three-slicer-viewer/issues"
87
+ },
63
88
  "peerDependencies": {
64
89
  "three": "^0.160.0",
65
90
  "react": ">=18",
@@ -76,8 +101,15 @@
76
101
  "optional": true
77
102
  }
78
103
  },
104
+ "devDependencies": {
105
+ "react": "^18.3.1",
106
+ "react-dom": "^18.3.1",
107
+ "three": "^0.160.0",
108
+ "vite": "^5.4.11"
109
+ },
79
110
  "scripts": {
80
111
  "build": "vite build && cp src/make_worker.js dist/make_worker.js",
81
- "prepublishOnly": "npm run build && node test_version_lockstep.mjs && node test_toolpath_contract.mjs"
112
+ "prepublishOnly": "npm run build && node tests/test_version_lockstep.mjs && node tests/test_toolpath_contract.mjs",
113
+ "test": "for f in tests/test_*.mjs; do node $f || exit 1; done"
82
114
  }
83
115
  }
@@ -1,2 +1,4 @@
1
1
  // three-slicer-viewer/settings — the catalog-free settings surface. See settings_core.js.
2
2
  export * from './settings_core.js'
3
+ // The derivation's own fallbacks, for callers that need the same numbers (frozen; see kernel_defaults.js).
4
+ export { FFF_FALLBACKS, SLA_FALLBACKS, AUTO_LINE_WIDTH, BED_FALLBACK, MACHINE_LIMITS } from './kernel_defaults.js'