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/COMPONENTS.md +4 -1
- package/README.md +7 -3
- package/TOOLPATH_SPEC.md +2 -2
- package/VIEWER.md +68 -1
- package/dist/components.js +102 -111
- package/dist/gcode_parse.js +148 -146
- package/dist/index.js +3615 -3619
- package/dist/model_loaders-aHV5ix50.js +188 -0
- package/dist/model_loaders.js +12 -181
- package/dist/{parse_3mf-CQ5rAX6P.js → parse_3mf-jEUAw8JM.js} +49 -48
- package/dist/parse_3mf.worker.js +1 -1
- package/dist/shadow_host-CQ3LirzD.js +16 -0
- package/dist/sl1_encode.worker.js +1 -1
- package/dist/{sl1_write-CvrNejbW.js → sl1_write-BovHbg3k.js} +66 -65
- package/dist/sla_reconstruct-CRZ3TrI1.js +178 -0
- package/dist/sla_reconstruct.worker.js +1 -1
- package/dist/sla_slice.worker.js +22 -21
- package/dist/theme-2oyfMuvf.js +97 -0
- package/dist/toolpath.js +132 -129
- package/dist/toolpath_encoding-BuYs95qZ.js +23 -0
- package/dist/viewer_defaults-B7UUZ582.js +28 -0
- package/package.json +37 -5
- package/src/settings/index.js +2 -0
- package/src/settings/kernel_defaults.js +144 -0
- package/src/settings/settings_core.js +114 -131
- package/types/loaders.d.ts +2 -2
- package/types/settings.d.ts +12 -0
- package/dist/sla_reconstruct-CXkYhux2.js +0 -176
package/dist/toolpath.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
52
|
+
function Lt(t) {
|
|
50
53
|
const e = /^#?([0-9a-f]{6})$/i.exec(String(t ?? "").trim());
|
|
51
|
-
if (!e) return
|
|
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
|
|
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
|
|
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
|
|
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],
|
|
78
|
-
return [l[0] + (
|
|
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
|
|
81
|
-
for (const t of Object.keys(
|
|
82
|
-
function
|
|
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 :
|
|
89
|
+
e[n] = i > 1e-6 ? i : kt;
|
|
87
90
|
}
|
|
88
91
|
return e;
|
|
89
92
|
}
|
|
90
|
-
const
|
|
91
|
-
const e =
|
|
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
|
|
95
|
-
const n = Array.isArray(t) ? t : [], r = n.length, o = Number(e) > 0 ? Number(e) :
|
|
96
|
-
let
|
|
97
|
-
for (let
|
|
98
|
-
const U =
|
|
99
|
-
for (let
|
|
100
|
-
U[
|
|
101
|
-
|
|
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
|
|
104
|
-
let A = !1,
|
|
105
|
-
for (let
|
|
106
|
-
const U = n[
|
|
107
|
-
for (let
|
|
108
|
-
const k =
|
|
109
|
-
if (Number.isFinite(
|
|
110
|
-
const d =
|
|
111
|
-
g[d] =
|
|
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 =
|
|
115
|
-
Number.isFinite(vt) && (
|
|
116
|
-
const
|
|
117
|
-
for (const [d,
|
|
118
|
-
const
|
|
119
|
-
b[
|
|
120
|
-
const
|
|
121
|
-
d < I && (I = d), d >
|
|
122
|
-
const
|
|
123
|
-
|
|
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
|
|
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:
|
|
132
|
-
segIndex:
|
|
133
|
-
nV:
|
|
134
|
-
nSeg:
|
|
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:
|
|
143
|
+
moveKind: s,
|
|
141
144
|
movePrefix: l,
|
|
142
145
|
layerCount: r,
|
|
143
|
-
maxAbs:
|
|
146
|
+
maxAbs: S,
|
|
144
147
|
hasNaN: A,
|
|
145
|
-
typeLengths:
|
|
146
|
-
bbox:
|
|
147
|
-
meta: { vType:
|
|
148
|
+
typeLengths: p,
|
|
149
|
+
bbox: Ct,
|
|
150
|
+
meta: { vType: _, vTool: F, vWidth: V, vHeight: M, vLayer: W }
|
|
148
151
|
};
|
|
149
152
|
}
|
|
150
|
-
function
|
|
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:
|
|
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
|
|
163
|
-
function
|
|
164
|
-
return
|
|
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
|
|
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 (
|
|
171
|
+
for (let o = r; o >= e; o--) if (at(t, o) > 0) return o;
|
|
169
172
|
return e;
|
|
170
173
|
}
|
|
171
|
-
function
|
|
172
|
-
const r =
|
|
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
|
|
175
|
-
t.moveKind[i +
|
|
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
|
|
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
|
|
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
|
|
215
|
-
const { meta: r, nV: o } = t, i = new Float32Array(o * 4), f =
|
|
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(
|
|
218
|
-
const b = r.vTool ? r.vTool[
|
|
219
|
-
return c[b] ||
|
|
220
|
-
} : (
|
|
221
|
-
for (let
|
|
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
|
|
228
|
+
const m = new Float32Array(o);
|
|
226
229
|
for (let c = 0; c < o; c++) {
|
|
227
|
-
const
|
|
228
|
-
|
|
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
|
|
233
|
-
i[c * 4] =
|
|
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
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
]),
|
|
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
|
|
341
|
-
const { nSeg: n, nV: r, position: o, hwa: i, travelPos: f, travelPrefix: u, layerCount: l, meta:
|
|
342
|
-
for (let
|
|
343
|
-
const
|
|
344
|
-
c[
|
|
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
|
|
347
|
-
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
vertexShader:
|
|
352
|
-
fragmentShader:
|
|
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
|
-
}),
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const
|
|
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 = (
|
|
363
|
-
const A = Math.max(0, l - 1),
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
|
|
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:
|
|
372
|
+
mesh: V,
|
|
370
373
|
travLines: g,
|
|
371
374
|
setLayerRange: C,
|
|
372
|
-
setVisibleLayers: (
|
|
373
|
-
setTravelVisible: (
|
|
374
|
-
g.visible = !!
|
|
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: (
|
|
379
|
-
if (!(!
|
|
380
|
-
for (let
|
|
381
|
-
|
|
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
|
-
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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.
|
|
4
|
-
"description": "The three-slicer viewer without the slicer
|
|
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
|
-
"
|
|
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
|
}
|
package/src/settings/index.js
CHANGED
|
@@ -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'
|