three-slicer-viewer 0.2.5
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 +44 -0
- package/LICENSE +21 -0
- package/README.md +77 -0
- package/THIRD-PARTY-NOTICES.md +19 -0
- package/TOOLPATH_SPEC.md +173 -0
- package/VIEWER.md +423 -0
- package/data/config-schema-lean.json +1 -0
- package/data/preset-keys.json +1 -0
- package/data/ui-tree-keys.json +1 -0
- package/dist/components.js +206 -0
- package/dist/gcode_parse.js +190 -0
- package/dist/index.js +6416 -0
- package/dist/make_worker.js +26 -0
- package/dist/model_loaders.js +183 -0
- package/dist/parse_3mf-CQ5rAX6P.js +299 -0
- package/dist/parse_3mf.worker.js +10 -0
- package/dist/sl1_encode.worker.js +10 -0
- package/dist/sl1_write-CvrNejbW.js +302 -0
- package/dist/sla_reconstruct-CXkYhux2.js +176 -0
- package/dist/sla_reconstruct.worker.js +24 -0
- package/dist/sla_slice.worker.js +73 -0
- package/dist/toolpath.js +408 -0
- package/package.json +83 -0
- package/src/data.js +2 -0
- package/src/settings/data.js +6 -0
- package/src/settings/index.js +2 -0
- package/src/settings/kernel_setting_keys.js +132 -0
- package/src/settings/preset_file.js +99 -0
- package/src/settings/settings_core.js +638 -0
- package/src/settings/toggle_eval.js +90 -0
- package/types/components.d.ts +39 -0
- package/types/data.d.ts +3 -0
- package/types/gcode.d.ts +29 -0
- package/types/index.d.ts +7 -0
- package/types/loaders.d.ts +33 -0
- package/types/settings-keys.d.ts +1855 -0
- package/types/settings.d.ts +173 -0
- package/types/toggle.d.ts +30 -0
- package/types/toolpath.d.ts +138 -0
- package/types/viewer.d.ts +256 -0
package/dist/toolpath.js
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
const _ = {
|
|
2
|
+
0: [0.35, 0.38, 0.44],
|
|
3
|
+
// travel
|
|
4
|
+
1: [0.98, 0.45, 0.16],
|
|
5
|
+
// wall
|
|
6
|
+
2: [0.36, 0.72, 0.94],
|
|
7
|
+
// sparse infill
|
|
8
|
+
3: [0.2, 0.55, 0.86],
|
|
9
|
+
// solid infill
|
|
10
|
+
4: [0.62, 0.66, 0.72],
|
|
11
|
+
// skirt / brim
|
|
12
|
+
5: [0.5, 0.54, 0.6],
|
|
13
|
+
// support
|
|
14
|
+
6: [0.42, 0.46, 0.52],
|
|
15
|
+
// raft
|
|
16
|
+
7: [0.96, 0.76, 0.22],
|
|
17
|
+
// gap fill
|
|
18
|
+
8: [0.88, 0.55, 0.3],
|
|
19
|
+
// thin wall
|
|
20
|
+
9: [0.3, 0.8, 0.62],
|
|
21
|
+
// bridge
|
|
22
|
+
10: [0.8, 0.42, 0.72],
|
|
23
|
+
// ironing
|
|
24
|
+
11: [0.58, 0.5, 0.88]
|
|
25
|
+
// prime tower
|
|
26
|
+
}, Mt = {
|
|
27
|
+
0: "Travel",
|
|
28
|
+
1: "Wall",
|
|
29
|
+
2: "Sparse",
|
|
30
|
+
3: "Solid",
|
|
31
|
+
4: "Skirt",
|
|
32
|
+
5: "Support",
|
|
33
|
+
6: "Raft",
|
|
34
|
+
7: "Gap",
|
|
35
|
+
8: "Thin",
|
|
36
|
+
9: "Bridge",
|
|
37
|
+
10: "Ironing",
|
|
38
|
+
11: "Prime"
|
|
39
|
+
}, dt = [
|
|
40
|
+
[0.9, 0.26, 0.3],
|
|
41
|
+
[0.27, 0.6, 0.93],
|
|
42
|
+
[0.36, 0.78, 0.42],
|
|
43
|
+
[0.98, 0.72, 0.2],
|
|
44
|
+
[0.72, 0.42, 0.9],
|
|
45
|
+
[0.2, 0.78, 0.8],
|
|
46
|
+
[0.95, 0.5, 0.72],
|
|
47
|
+
[0.6, 0.6, 0.64]
|
|
48
|
+
];
|
|
49
|
+
function St(t) {
|
|
50
|
+
const e = /^#?([0-9a-f]{6})$/i.exec(String(t ?? "").trim());
|
|
51
|
+
if (!e) return [0.5, 0.5, 0.5];
|
|
52
|
+
const n = parseInt(e[1], 16);
|
|
53
|
+
return [(n >> 16 & 255) / 255, (n >> 8 & 255) / 255, (n & 255) / 255];
|
|
54
|
+
}
|
|
55
|
+
function et(t) {
|
|
56
|
+
const e = (n) => Math.max(0, Math.min(255, Math.round((Number(n) || 0) * 255)));
|
|
57
|
+
return e(t?.[0]) * 65536 + e(t?.[1]) * 256 + e(t?.[2]);
|
|
58
|
+
}
|
|
59
|
+
const At = [
|
|
60
|
+
[0.043, 0.173, 0.478],
|
|
61
|
+
[0.055, 0.325, 0.639],
|
|
62
|
+
[0.067, 0.478, 0.8],
|
|
63
|
+
[0.078, 0.631, 0.961],
|
|
64
|
+
[0.118, 0.749, 0.804],
|
|
65
|
+
[0.157, 0.867, 0.647],
|
|
66
|
+
[0.376, 0.902, 0.4],
|
|
67
|
+
[0.667, 0.898, 0.157],
|
|
68
|
+
[0.988, 0.976, 0.012],
|
|
69
|
+
[0.988, 0.663, 0.012],
|
|
70
|
+
[0.58, 0.149, 0.086]
|
|
71
|
+
];
|
|
72
|
+
function Nt(t, e, n, r = At) {
|
|
73
|
+
const o = r.length - 1;
|
|
74
|
+
if (o < 0) return [0, 0, 0];
|
|
75
|
+
if (!Number.isFinite(t) || !Number.isFinite(e) || !Number.isFinite(n) || n <= e || t <= e) return r[0];
|
|
76
|
+
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];
|
|
79
|
+
}
|
|
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 e = new Float32Array(t.length);
|
|
84
|
+
for (let n = 0; n < t.length; n++) {
|
|
85
|
+
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;
|
|
87
|
+
}
|
|
88
|
+
return e;
|
|
89
|
+
}
|
|
90
|
+
const rt = (t) => t?.paths?.length ? t.paths : null, gt = (t) => {
|
|
91
|
+
const e = rt(t);
|
|
92
|
+
return e ? Math.floor(e.length / nt) : 0;
|
|
93
|
+
};
|
|
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;
|
|
102
|
+
}
|
|
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++;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
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);
|
|
124
|
+
}
|
|
125
|
+
st++;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const xt = s > 0 && Number.isFinite(I) ? { min: [I, P, V], max: [J, Q, R] } : null;
|
|
129
|
+
return {
|
|
130
|
+
position: b,
|
|
131
|
+
hwa: L,
|
|
132
|
+
segIndex: y,
|
|
133
|
+
nV: s,
|
|
134
|
+
nSeg: h,
|
|
135
|
+
layerSegPrefix: f,
|
|
136
|
+
travelPos: g,
|
|
137
|
+
travelPrefix: u,
|
|
138
|
+
nTrav: c,
|
|
139
|
+
movePos: C,
|
|
140
|
+
moveKind: a,
|
|
141
|
+
movePrefix: l,
|
|
142
|
+
layerCount: r,
|
|
143
|
+
maxAbs: N,
|
|
144
|
+
hasNaN: A,
|
|
145
|
+
typeLengths: v,
|
|
146
|
+
bbox: xt,
|
|
147
|
+
meta: { vType: O, vTool: M, vWidth: z, vHeight: S, vLayer: B }
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function Wt(t) {
|
|
151
|
+
const e = t ?? [];
|
|
152
|
+
let n = 0;
|
|
153
|
+
for (let o = 0; o < 16; o++) n += Number(e[o]) || 0;
|
|
154
|
+
if (n <= 0) return [];
|
|
155
|
+
const r = [];
|
|
156
|
+
for (let o = 0; o < 16; o++) {
|
|
157
|
+
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] });
|
|
159
|
+
}
|
|
160
|
+
return r.sort((o, i) => i.pct - o.pct);
|
|
161
|
+
}
|
|
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
|
+
}
|
|
166
|
+
function Gt(t, e, n) {
|
|
167
|
+
const r = Math.min(n, t.layerCount - 1);
|
|
168
|
+
for (let o = r; o >= e; o--) if (it(t, o) > 0) return o;
|
|
169
|
+
return e;
|
|
170
|
+
}
|
|
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;
|
|
173
|
+
let f = 0, u = 0;
|
|
174
|
+
for (let h = 0; h < o; h++)
|
|
175
|
+
t.moveKind[i + h] === 0 ? u++ : f++;
|
|
176
|
+
if (o === 0) return { point: null, segCount: 0, travCount: 0, onTravel: !1 };
|
|
177
|
+
const l = i + o - 1;
|
|
178
|
+
return {
|
|
179
|
+
point: [t.movePos[l * 3], t.movePos[l * 3 + 1], t.movePos[l * 3 + 2]],
|
|
180
|
+
segCount: f,
|
|
181
|
+
travCount: u,
|
|
182
|
+
onTravel: t.moveKind[l] === 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const wt = [
|
|
186
|
+
{ key: "feature", label: "Feature type", cont: !1, unit: "" },
|
|
187
|
+
{ key: "speed", label: "Speed", cont: !0, unit: "mm/s" },
|
|
188
|
+
{ key: "height", label: "Layer Height", cont: !0, unit: "mm" },
|
|
189
|
+
{ key: "width", label: "Line Width", cont: !0, unit: "mm" },
|
|
190
|
+
{ key: "fan", label: "Fan Speed", cont: !0, unit: "%" },
|
|
191
|
+
{ key: "temp", label: "Temperature", cont: !0, unit: "°C" },
|
|
192
|
+
// Last, like upstream's EViewType::Tool: it answers "did my painted regions come out on the extruder I assigned?",
|
|
193
|
+
// which is a check you run after slicing, not a property you scrub through. Discrete like the feature view — an
|
|
194
|
+
// extruder index is a label, and a heatmap over it would imply tool 2 sits "between" tools 1 and 3.
|
|
195
|
+
{ key: "filament", label: "Filament", cont: !1, unit: "" }
|
|
196
|
+
];
|
|
197
|
+
function Tt(t, e, n, r) {
|
|
198
|
+
const o = e.vType[n], i = e.vLayer[n], f = i === 0;
|
|
199
|
+
switch (t) {
|
|
200
|
+
case "height":
|
|
201
|
+
return e.vHeight[n];
|
|
202
|
+
case "width":
|
|
203
|
+
return e.vWidth[n];
|
|
204
|
+
case "speed":
|
|
205
|
+
return f ? r.firstLayerSpeed : r.speedByType[o] ?? r.speedByType[1];
|
|
206
|
+
case "fan":
|
|
207
|
+
return i < r.closeFanLayers ? 0 : o === 9 ? 100 : r.fanNormal;
|
|
208
|
+
case "temp":
|
|
209
|
+
return f ? r.tempFirst : r.tempNormal;
|
|
210
|
+
default:
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
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];
|
|
216
|
+
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));
|
|
222
|
+
return { color: i, min: 0, max: 0, viewType: e, label: f.label, unit: f.unit, cont: !1 };
|
|
223
|
+
}
|
|
224
|
+
let u = 1 / 0, l = -1 / 0;
|
|
225
|
+
const h = new Float32Array(o);
|
|
226
|
+
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);
|
|
229
|
+
}
|
|
230
|
+
Number.isFinite(u) || (u = 0, l = 1);
|
|
231
|
+
for (let c = 0; c < o; c++) {
|
|
232
|
+
const m = Nt(h[c], u, l, At);
|
|
233
|
+
i[c * 4] = et(m);
|
|
234
|
+
}
|
|
235
|
+
return { color: i, min: u, max: l, viewType: e, label: f.label, unit: f.unit, cont: !0 };
|
|
236
|
+
}
|
|
237
|
+
const _t = `
|
|
238
|
+
precision highp float;
|
|
239
|
+
|
|
240
|
+
uniform mat4 projectionMatrix;
|
|
241
|
+
uniform mat4 modelViewMatrix;
|
|
242
|
+
uniform float uLayerLo;
|
|
243
|
+
uniform float uLayerHi;
|
|
244
|
+
|
|
245
|
+
in vec2 tpl; // [end 0|1, ring 0..3]
|
|
246
|
+
in vec3 iStart;
|
|
247
|
+
in vec3 iEnd;
|
|
248
|
+
in vec2 iHW; // [height, width]
|
|
249
|
+
in float iColor; // r<<16 | g<<8 | b
|
|
250
|
+
in float iLayer;
|
|
251
|
+
|
|
252
|
+
out vec3 vColor;
|
|
253
|
+
out vec3 vNormal;
|
|
254
|
+
|
|
255
|
+
// The colour rides in one float rather than three: it is swapped on every view-type change, and one
|
|
256
|
+
// attribute upload beats three. Exact below 2^24, which 0xffffff is.
|
|
257
|
+
vec3 unpackColor(float p) {
|
|
258
|
+
float r = floor(p / 65536.0);
|
|
259
|
+
float g = floor(mod(p / 256.0, 256.0));
|
|
260
|
+
float b = mod(p, 256.0);
|
|
261
|
+
return vec3(r, g, b) / 255.0;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
void main() {
|
|
265
|
+
// Out of range: collapse the whole instance to one point so it rasterizes nothing. A uniform does this
|
|
266
|
+
// without touching a buffer, which is what keeps dragging the layer slider smooth.
|
|
267
|
+
if (iLayer < uLayerLo - 0.5 || iLayer > uLayerHi + 0.5) {
|
|
268
|
+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
269
|
+
vColor = vec3(0.0);
|
|
270
|
+
vNormal = vec3(0.0, 0.0, 1.0);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
vec3 axis = iEnd - iStart;
|
|
275
|
+
// A zero-length segment has no direction to orient against; pick one rather than emitting NaN.
|
|
276
|
+
vec2 flat2 = axis.xy;
|
|
277
|
+
vec2 dir = length(flat2) > 1e-9 ? normalize(flat2) : vec2(1.0, 0.0);
|
|
278
|
+
vec3 side = vec3(-dir.y, dir.x, 0.0);
|
|
279
|
+
vec3 up = vec3(0.0, 0.0, 1.0);
|
|
280
|
+
|
|
281
|
+
float halfHeight = iHW.x * 0.5;
|
|
282
|
+
float halfWidth = iHW.y * 0.5;
|
|
283
|
+
|
|
284
|
+
float ring = tpl.y;
|
|
285
|
+
vec3 offset;
|
|
286
|
+
if (ring < 0.5) offset = side * halfWidth;
|
|
287
|
+
else if (ring < 1.5) offset = up * halfHeight;
|
|
288
|
+
else if (ring < 2.5) offset = -side * halfWidth;
|
|
289
|
+
else offset = -up * halfHeight;
|
|
290
|
+
|
|
291
|
+
vec3 world = mix(iStart, iEnd, tpl.x) + offset;
|
|
292
|
+
|
|
293
|
+
vNormal = normalize(mat3(modelViewMatrix) * normalize(offset));
|
|
294
|
+
vColor = unpackColor(iColor);
|
|
295
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(world, 1.0);
|
|
296
|
+
}
|
|
297
|
+
`, Ot = `
|
|
298
|
+
precision highp float;
|
|
299
|
+
|
|
300
|
+
in vec3 vColor;
|
|
301
|
+
in vec3 vNormal;
|
|
302
|
+
out vec4 fragColor;
|
|
303
|
+
|
|
304
|
+
void main() {
|
|
305
|
+
// Two-sided: the layer slider cuts the plate open, so back faces are seen and must not go black.
|
|
306
|
+
vec3 n = normalize(vNormal);
|
|
307
|
+
if (!gl_FrontFacing) n = -n;
|
|
308
|
+
// A single head-on light plus a generous ambient. The point is to read the bead's ROUNDING — which
|
|
309
|
+
// face is up, which is the side — not to look lit.
|
|
310
|
+
float lambert = max(dot(n, normalize(vec3(0.35, 0.35, 1.0))), 0.0);
|
|
311
|
+
fragColor = vec4(vColor * (0.55 + 0.45 * lambert), 1.0);
|
|
312
|
+
}
|
|
313
|
+
`, zt = new Float32Array([
|
|
314
|
+
0,
|
|
315
|
+
0,
|
|
316
|
+
0,
|
|
317
|
+
1,
|
|
318
|
+
0,
|
|
319
|
+
2,
|
|
320
|
+
0,
|
|
321
|
+
3,
|
|
322
|
+
// start ring
|
|
323
|
+
1,
|
|
324
|
+
0,
|
|
325
|
+
1,
|
|
326
|
+
1,
|
|
327
|
+
1,
|
|
328
|
+
2,
|
|
329
|
+
1,
|
|
330
|
+
3
|
|
331
|
+
// end ring
|
|
332
|
+
]), Bt = (() => {
|
|
333
|
+
const t = [];
|
|
334
|
+
for (let e = 0; e < 4; e++) {
|
|
335
|
+
const n = e, r = (e + 1) % 4, o = 4 + (e + 1) % 4, i = 4 + e;
|
|
336
|
+
t.push(n, r, o, n, o, i);
|
|
337
|
+
}
|
|
338
|
+
return t;
|
|
339
|
+
})();
|
|
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];
|
|
345
|
+
}
|
|
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,
|
|
353
|
+
glslVersion: t.GLSL3,
|
|
354
|
+
side: t.DoubleSide,
|
|
355
|
+
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);
|
|
361
|
+
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));
|
|
367
|
+
};
|
|
368
|
+
return C(0, l - 1), {
|
|
369
|
+
mesh: z,
|
|
370
|
+
travLines: g,
|
|
371
|
+
setLayerRange: C,
|
|
372
|
+
setVisibleLayers: (a) => C(0, (a | 0) - 1),
|
|
373
|
+
setTravelVisible: (a) => {
|
|
374
|
+
g.visible = !!a;
|
|
375
|
+
},
|
|
376
|
+
/** color is Float32Array(nV*4) with the packed value in .r — computeColors' output shape. One instance
|
|
377
|
+
* 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;
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
dispose: () => {
|
|
385
|
+
y.dispose(), M.dispose(), S.dispose(), B.dispose();
|
|
386
|
+
},
|
|
387
|
+
nSeg: n,
|
|
388
|
+
layerCount: l
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
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
|
|
408
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
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.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./types/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./toolpath": {
|
|
14
|
+
"types": "./types/toolpath.d.ts",
|
|
15
|
+
"default": "./dist/toolpath.js"
|
|
16
|
+
},
|
|
17
|
+
"./gcode": {
|
|
18
|
+
"types": "./types/gcode.d.ts",
|
|
19
|
+
"default": "./dist/gcode_parse.js"
|
|
20
|
+
},
|
|
21
|
+
"./loaders": {
|
|
22
|
+
"types": "./types/loaders.d.ts",
|
|
23
|
+
"default": "./dist/model_loaders.js"
|
|
24
|
+
},
|
|
25
|
+
"./settings": {
|
|
26
|
+
"types": "./types/settings.d.ts",
|
|
27
|
+
"default": "./src/settings/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./data": {
|
|
30
|
+
"types": "./types/data.d.ts",
|
|
31
|
+
"default": "./src/data.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json",
|
|
34
|
+
"./toggle": {
|
|
35
|
+
"types": "./types/toggle.d.ts",
|
|
36
|
+
"default": "./src/settings/toggle_eval.js"
|
|
37
|
+
},
|
|
38
|
+
"./components": {
|
|
39
|
+
"types": "./types/components.d.ts",
|
|
40
|
+
"default": "./dist/components.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"COMPONENTS.md",
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"README.md",
|
|
47
|
+
"THIRD-PARTY-NOTICES.md",
|
|
48
|
+
"TOOLPATH_SPEC.md",
|
|
49
|
+
"VIEWER.md",
|
|
50
|
+
"data",
|
|
51
|
+
"dist",
|
|
52
|
+
"src/data.js",
|
|
53
|
+
"src/settings",
|
|
54
|
+
"types"
|
|
55
|
+
],
|
|
56
|
+
"keywords": [
|
|
57
|
+
"3d-printing",
|
|
58
|
+
"gcode",
|
|
59
|
+
"toolpath",
|
|
60
|
+
"three",
|
|
61
|
+
"viewer"
|
|
62
|
+
],
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"three": "^0.160.0",
|
|
65
|
+
"react": ">=18",
|
|
66
|
+
"react-dom": ">=18"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"three": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"react": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"react-dom": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"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"
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/data.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The single import site for this package's JSON artifacts — the same funnel rule as three-slicer's
|
|
2
|
+
// engine/src/data.js: Vite strips `with { type: 'json' }` from bundles, so JSON may only be imported from a
|
|
3
|
+
// module that is shipped UNBUNDLED and that the viewer build treats as external. That module is this one.
|
|
4
|
+
export { default as leanSchema } from '../../data/config-schema-lean.json' with { type: 'json' }
|
|
5
|
+
export { default as uiTreeKeys } from '../../data/ui-tree-keys.json' with { type: 'json' }
|
|
6
|
+
export { default as presetKeys } from '../../data/preset-keys.json' with { type: 'json' }
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// AUTO-GENERATED by types/gen_kernel_params.mjs — DO NOT EDIT.
|
|
2
|
+
// The schema keys deriveKernelParams consumes (the distinct "From setting" column of engine/PARAMS.md).
|
|
3
|
+
export const KERNEL_SETTING_KEYS = [
|
|
4
|
+
"bottom_shell_layers",
|
|
5
|
+
"bottom_surface_filament_id",
|
|
6
|
+
"bridge_no_support",
|
|
7
|
+
"bridge_speed",
|
|
8
|
+
"brim_object_gap",
|
|
9
|
+
"brim_width",
|
|
10
|
+
"close_fan_the_first_x_layers",
|
|
11
|
+
"default_acceleration",
|
|
12
|
+
"enable_arc_fitting",
|
|
13
|
+
"enable_pressure_advance",
|
|
14
|
+
"enable_prime_tower",
|
|
15
|
+
"enable_support",
|
|
16
|
+
"fan_max_speed",
|
|
17
|
+
"filament_cost",
|
|
18
|
+
"filament_density",
|
|
19
|
+
"filament_diameter",
|
|
20
|
+
"filament_flow_ratio",
|
|
21
|
+
"filament_map",
|
|
22
|
+
"filament_retraction_length",
|
|
23
|
+
"filament_retraction_minimum_travel",
|
|
24
|
+
"filament_retraction_speed",
|
|
25
|
+
"filament_settings_id",
|
|
26
|
+
"filament_type",
|
|
27
|
+
"filament_z_hop",
|
|
28
|
+
"flush_into_infill",
|
|
29
|
+
"flush_multiplier",
|
|
30
|
+
"flush_volumes_matrix",
|
|
31
|
+
"full_fan_speed_layer",
|
|
32
|
+
"hot_plate_temp",
|
|
33
|
+
"independent_support_layer_height",
|
|
34
|
+
"infill_direction",
|
|
35
|
+
"initial_layer_line_width",
|
|
36
|
+
"initial_layer_print_height",
|
|
37
|
+
"initial_layer_speed",
|
|
38
|
+
"inner_wall_filament_id",
|
|
39
|
+
"inner_wall_line_width",
|
|
40
|
+
"internal_solid_filament_id",
|
|
41
|
+
"internal_solid_infill_line_width",
|
|
42
|
+
"ironing_flow",
|
|
43
|
+
"ironing_spacing",
|
|
44
|
+
"ironing_speed",
|
|
45
|
+
"ironing_type",
|
|
46
|
+
"layer_height",
|
|
47
|
+
"line_width",
|
|
48
|
+
"machine_end_gcode",
|
|
49
|
+
"machine_max_acceleration_e",
|
|
50
|
+
"machine_max_acceleration_retracting",
|
|
51
|
+
"machine_max_acceleration_x",
|
|
52
|
+
"machine_max_acceleration_z",
|
|
53
|
+
"machine_max_jerk_e",
|
|
54
|
+
"machine_max_jerk_x",
|
|
55
|
+
"machine_max_jerk_z",
|
|
56
|
+
"machine_max_speed_e",
|
|
57
|
+
"machine_max_speed_x",
|
|
58
|
+
"machine_max_speed_z",
|
|
59
|
+
"machine_start_gcode",
|
|
60
|
+
"max_volumetric_extrusion_rate_slope",
|
|
61
|
+
"nozzle_diameter",
|
|
62
|
+
"nozzle_temperature",
|
|
63
|
+
"outer_wall_filament_id",
|
|
64
|
+
"outer_wall_line_width",
|
|
65
|
+
"outer_wall_speed",
|
|
66
|
+
"pressure_advance",
|
|
67
|
+
"prime_tower_width",
|
|
68
|
+
"prime_volume",
|
|
69
|
+
"printable_area",
|
|
70
|
+
"printable_height",
|
|
71
|
+
"raft_contact_distance",
|
|
72
|
+
"raft_expansion",
|
|
73
|
+
"raft_layers",
|
|
74
|
+
"reduce_crossing_wall",
|
|
75
|
+
"resolution",
|
|
76
|
+
"retraction_length",
|
|
77
|
+
"retraction_minimum_travel",
|
|
78
|
+
"retraction_speed",
|
|
79
|
+
"seam_position",
|
|
80
|
+
"seam_slope_type",
|
|
81
|
+
"skirt_distance",
|
|
82
|
+
"skirt_height",
|
|
83
|
+
"skirt_loops",
|
|
84
|
+
"slow_down_layer_time",
|
|
85
|
+
"sparse_infill_density",
|
|
86
|
+
"sparse_infill_filament_id",
|
|
87
|
+
"sparse_infill_line_width",
|
|
88
|
+
"sparse_infill_pattern",
|
|
89
|
+
"spiral_mode",
|
|
90
|
+
"support_angle",
|
|
91
|
+
"support_base_pattern",
|
|
92
|
+
"support_base_pattern_spacing",
|
|
93
|
+
"support_bottom_z_distance",
|
|
94
|
+
"support_expansion",
|
|
95
|
+
"support_filament",
|
|
96
|
+
"support_interface_bottom_layers",
|
|
97
|
+
"support_interface_filament",
|
|
98
|
+
"support_interface_pattern",
|
|
99
|
+
"support_interface_spacing",
|
|
100
|
+
"support_interface_top_layers",
|
|
101
|
+
"support_line_width",
|
|
102
|
+
"support_object_first_layer_gap",
|
|
103
|
+
"support_object_xy_distance",
|
|
104
|
+
"support_on_build_plate_only",
|
|
105
|
+
"support_remove_small_overhang",
|
|
106
|
+
"support_style",
|
|
107
|
+
"support_threshold_angle",
|
|
108
|
+
"support_threshold_overlap",
|
|
109
|
+
"support_top_z_distance",
|
|
110
|
+
"support_type",
|
|
111
|
+
"top_shell_layers",
|
|
112
|
+
"top_surface_filament_id",
|
|
113
|
+
"top_surface_line_width",
|
|
114
|
+
"travel_acceleration",
|
|
115
|
+
"travel_speed",
|
|
116
|
+
"tree_support_angle_slow",
|
|
117
|
+
"tree_support_branch_angle",
|
|
118
|
+
"tree_support_branch_angle_organic",
|
|
119
|
+
"tree_support_branch_diameter",
|
|
120
|
+
"tree_support_branch_diameter_angle",
|
|
121
|
+
"tree_support_branch_diameter_organic",
|
|
122
|
+
"tree_support_branch_distance",
|
|
123
|
+
"tree_support_branch_distance_organic",
|
|
124
|
+
"tree_support_tip_diameter",
|
|
125
|
+
"tree_support_top_rate",
|
|
126
|
+
"tree_support_wall_count",
|
|
127
|
+
"wall_generator",
|
|
128
|
+
"wall_loops",
|
|
129
|
+
"wipe_tower_x",
|
|
130
|
+
"wipe_tower_y",
|
|
131
|
+
"z_hop",
|
|
132
|
+
]
|