three-slicer-viewer 0.3.2 → 0.3.4
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/TOOLPATH_SPEC.md +8 -1
- package/VIEWER.md +24 -0
- package/data/config-schema-lean.json +1 -1
- package/dist/components.js +47 -43
- package/dist/gcode_parse.js +154 -111
- package/dist/index.js +4409 -4069
- package/dist/{model_loaders-DxlFNFOu.js → model_loaders-Dk9rqXFb.js} +27 -27
- package/dist/model_loaders.js +2 -2
- package/dist/parse_3mf-CpbA-6Iq.js +666 -0
- package/dist/parse_3mf.worker.js +67 -5
- package/dist/sl1_encode.worker.js +1 -1
- package/dist/sl1_write-B6nWmCUu.js +313 -0
- package/dist/sla_slice.worker.js +1 -1
- package/dist/toolpath.js +303 -177
- package/package.json +6 -1
- package/src/core/paint_tools.js +8 -0
- package/src/settings/bed_frame.js +28 -0
- package/src/settings/index.js +1 -0
- package/src/settings/kernel_setting_keys.js +79 -0
- package/src/settings/settings_core.js +194 -8
- package/types/gcode.d.ts +13 -0
- package/types/paint.d.ts +7 -0
- package/types/settings.d.ts +14 -1
- package/types/toolpath.d.ts +6 -0
- package/types/viewer.d.ts +1 -1
- package/dist/parse_3mf-BZISF3eW.js +0 -327
- package/dist/sl1_write-BovHbg3k.js +0 -303
package/dist/parse_3mf.worker.js
CHANGED
|
@@ -1,9 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { r as u, p } from "./parse_3mf-CpbA-6Iq.js";
|
|
2
|
+
function b(r) {
|
|
3
|
+
if (!r) return [];
|
|
4
|
+
const t = [r.tris.buffer, ...r.modifiers.map((s) => s.tris.buffer)];
|
|
5
|
+
return r.baked && t.push(r.baked.localPos.buffer, r.baked.normals.buffer), t;
|
|
6
|
+
}
|
|
7
|
+
const g = 8;
|
|
8
|
+
let i = null, h = 0;
|
|
9
|
+
const c = /* @__PURE__ */ new Map();
|
|
10
|
+
function w() {
|
|
11
|
+
if (i) return i;
|
|
12
|
+
i = [];
|
|
13
|
+
const r = Math.min(g, Math.max(1, (self.navigator?.hardwareConcurrency || 2) - 1));
|
|
4
14
|
try {
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
for (let t = 0; t < r; t++) {
|
|
16
|
+
const s = new Worker(self.location.href, { type: "module" }), n = { worker: s, failed: !1 };
|
|
17
|
+
s.onmessage = (o) => {
|
|
18
|
+
const { id: e, result: f, error: a } = o.data || {}, l = c.get(e);
|
|
19
|
+
l && (c.delete(e), a ? l.reject(new Error(a)) : l.resolve(f));
|
|
20
|
+
}, s.onerror = () => {
|
|
21
|
+
n.failed = !0;
|
|
22
|
+
for (const [o, e] of c) e.helper === n && (c.delete(o), e.reject(new Error("3MF helper failed")));
|
|
23
|
+
}, i.push(n);
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
for (const t of i) t.worker.terminate();
|
|
27
|
+
i = [];
|
|
28
|
+
}
|
|
29
|
+
return i;
|
|
30
|
+
}
|
|
31
|
+
function M(r, t) {
|
|
32
|
+
const s = ++h;
|
|
33
|
+
return new Promise((n, o) => {
|
|
34
|
+
c.set(s, { resolve: n, reject: o, helper: r }), r.worker.postMessage({ type: "item-job", id: s, job: t }, t.members.map((e) => e.data.buffer));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async function k(r) {
|
|
38
|
+
const t = w().filter((e) => !e.failed);
|
|
39
|
+
if (!t.length) return Promise.all(r.map(u));
|
|
40
|
+
const s = new Array(r.length);
|
|
41
|
+
let n = 0;
|
|
42
|
+
const o = async (e) => {
|
|
43
|
+
for (; n < r.length; ) {
|
|
44
|
+
const f = n++, a = r[f], l = a.members.map((m) => m.data.slice());
|
|
45
|
+
try {
|
|
46
|
+
s[f] = await M(e, a);
|
|
47
|
+
} catch {
|
|
48
|
+
s[f] = await u({ ...a, members: a.members.map((m, d) => ({ ...m, data: l[d] })) });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return await Promise.all(t.slice(0, r.length).map(o)), s;
|
|
53
|
+
}
|
|
54
|
+
self.onmessage = async (r) => {
|
|
55
|
+
const t = r.data || {};
|
|
56
|
+
if (t.type === "item-job") {
|
|
57
|
+
try {
|
|
58
|
+
const e = await u(t.job);
|
|
59
|
+
self.postMessage({ id: t.id, result: e }, e.items.flatMap((f) => b(f.built)));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
self.postMessage({ id: t.id, error: e && e.message || String(e) });
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const { id: s, buffer: n, baseName: o } = t;
|
|
66
|
+
try {
|
|
67
|
+
const { objects: e, project: f } = await p(n, o, { runJobs: k, bake: !0 });
|
|
68
|
+
self.postMessage({ id: s, objects: e, project: f }, e.flatMap((a) => [a.tris.buffer, a.baked.localPos.buffer, a.baked.normals.buffer]));
|
|
7
69
|
} catch (e) {
|
|
8
70
|
self.postMessage({ id: s, error: e && e.message || String(e) });
|
|
9
71
|
}
|
|
@@ -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-
|
|
2
|
+
import { s as m, r as l, e as g } from "./sl1_write-B6nWmCUu.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++) {
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { strToU8 as z, zipSync as j, zlibSync as X } from "three/examples/jsm/libs/fflate.module.js";
|
|
2
|
+
import { S as A, r as Y, R as C } from "./toolpath_encoding-BuYs95qZ.js";
|
|
3
|
+
let M = !0;
|
|
4
|
+
function ut(t) {
|
|
5
|
+
M = !!t;
|
|
6
|
+
}
|
|
7
|
+
const G = {
|
|
8
|
+
info: (...t) => {
|
|
9
|
+
M && console.info(...t);
|
|
10
|
+
},
|
|
11
|
+
warn: (...t) => {
|
|
12
|
+
M && console.warn(...t);
|
|
13
|
+
},
|
|
14
|
+
error: (...t) => {
|
|
15
|
+
M && console.error(...t);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function W(t) {
|
|
19
|
+
const n = [];
|
|
20
|
+
let e = null;
|
|
21
|
+
for (let o = 0; o < t.length; o += A) {
|
|
22
|
+
const a = t[o], f = t[o + 1], c = t[o + 4], s = t[o + 5];
|
|
23
|
+
e && Math.abs(e.lx - a) < 1e-6 && Math.abs(e.ly - f) < 1e-6 ? (e.pts.push(c, s), e.lx = c, e.ly = s) : (e = { pts: [a, f, c, s], lx: c, ly: s }, n.push(e));
|
|
24
|
+
}
|
|
25
|
+
return n.map((o) => o.pts);
|
|
26
|
+
}
|
|
27
|
+
function L(t, n, e, o, a, f) {
|
|
28
|
+
const c = new Array(e).fill(null);
|
|
29
|
+
for (const i of t) {
|
|
30
|
+
const l = i.length / 2;
|
|
31
|
+
for (let r = 0; r < l; r++) {
|
|
32
|
+
const d = (r + 1) % l;
|
|
33
|
+
let p = o(i[r * 2], i[r * 2 + 1]), u = a(i[r * 2], i[r * 2 + 1]), g = o(i[d * 2], i[d * 2 + 1]), y = a(i[d * 2], i[d * 2 + 1]);
|
|
34
|
+
if (u === y) continue;
|
|
35
|
+
if (u > y) {
|
|
36
|
+
const x = p;
|
|
37
|
+
p = g, g = x;
|
|
38
|
+
const _ = u;
|
|
39
|
+
u = y, y = _;
|
|
40
|
+
}
|
|
41
|
+
const b = Math.max(0, Math.ceil(u - 0.5));
|
|
42
|
+
if (b >= e || y < 0.5) continue;
|
|
43
|
+
const m = { x: p + (b + 0.5 - u) / (y - u) * (g - p), dx: (g - p) / (y - u), yEnd: y };
|
|
44
|
+
(c[b] ??= []).push(m);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const s = [];
|
|
48
|
+
for (let i = 0; i < e; i++) {
|
|
49
|
+
const l = i + 0.5;
|
|
50
|
+
c[i] && s.push(...c[i]);
|
|
51
|
+
for (let r = s.length - 1; r >= 0; r--) s[r].yEnd <= l && s.splice(r, 1);
|
|
52
|
+
s.sort((r, d) => r.x - d.x);
|
|
53
|
+
for (let r = 0; r + 1 < s.length; r += 2) {
|
|
54
|
+
const d = Math.max(0, Math.ceil(s[r].x - 0.5)), p = Math.min(n - 1, Math.floor(s[r + 1].x - 0.5));
|
|
55
|
+
p >= d && f(i, d, p);
|
|
56
|
+
}
|
|
57
|
+
for (const r of s) r.x += r.dx;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function H(t, n, e = 1) {
|
|
61
|
+
const { px: o, py: a } = n, f = W(t), c = new Uint8Array(o * a);
|
|
62
|
+
if (e <= 1)
|
|
63
|
+
return L(
|
|
64
|
+
f,
|
|
65
|
+
o,
|
|
66
|
+
a,
|
|
67
|
+
(l, r) => n.map(l, r)[0],
|
|
68
|
+
(l, r) => n.map(l, r)[1],
|
|
69
|
+
(l, r, d) => {
|
|
70
|
+
c.fill(255, l * o + r, l * o + d + 1);
|
|
71
|
+
}
|
|
72
|
+
), c;
|
|
73
|
+
const s = new Uint16Array(o * a);
|
|
74
|
+
L(
|
|
75
|
+
f,
|
|
76
|
+
o * e,
|
|
77
|
+
a * e,
|
|
78
|
+
(l, r) => n.map(l, r)[0] * e,
|
|
79
|
+
(l, r) => n.map(l, r)[1] * e,
|
|
80
|
+
(l, r, d) => {
|
|
81
|
+
const p = l / e | 0;
|
|
82
|
+
for (let u = r; u <= d; u++) s[p * o + (u / e | 0)]++;
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
const i = e * e;
|
|
86
|
+
for (let l = 0; l < s.length; l++) c[l] = Math.round(s[l] * 255 / i);
|
|
87
|
+
return c;
|
|
88
|
+
}
|
|
89
|
+
const Z = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), q = (() => {
|
|
90
|
+
const t = new Uint32Array(256);
|
|
91
|
+
for (let n = 0; n < 256; n++) {
|
|
92
|
+
let e = n;
|
|
93
|
+
for (let o = 0; o < 8; o++) e = e & 1 ? 3988292384 ^ e >>> 1 : e >>> 1;
|
|
94
|
+
t[n] = e >>> 0;
|
|
95
|
+
}
|
|
96
|
+
return t;
|
|
97
|
+
})(), J = (t) => {
|
|
98
|
+
let n = 4294967295;
|
|
99
|
+
for (let e = 0; e < t.length; e++) n = q[(n ^ t[e]) & 255] ^ n >>> 8;
|
|
100
|
+
return (n ^ 4294967295) >>> 0;
|
|
101
|
+
}, F = (t, n) => {
|
|
102
|
+
const e = new Uint8Array(12 + n.length), o = new DataView(e.buffer);
|
|
103
|
+
o.setUint32(0, n.length);
|
|
104
|
+
for (let f = 0; f < 4; f++) e[4 + f] = t.charCodeAt(f);
|
|
105
|
+
e.set(n, 8);
|
|
106
|
+
const a = e.subarray(4, 8 + n.length);
|
|
107
|
+
return o.setUint32(8 + n.length, J(a)), e;
|
|
108
|
+
}, K = async (t) => {
|
|
109
|
+
const n = new CompressionStream("deflate"), e = [], o = (async () => {
|
|
110
|
+
const i = n.readable.getReader();
|
|
111
|
+
for (; ; ) {
|
|
112
|
+
const { value: l, done: r } = await i.read();
|
|
113
|
+
if (r) break;
|
|
114
|
+
e.push(l);
|
|
115
|
+
}
|
|
116
|
+
})(), a = n.writable.getWriter();
|
|
117
|
+
await a.write(t), await a.close(), await o;
|
|
118
|
+
let f = 0;
|
|
119
|
+
for (const i of e) f += i.length;
|
|
120
|
+
const c = new Uint8Array(f);
|
|
121
|
+
let s = 0;
|
|
122
|
+
for (const i of e)
|
|
123
|
+
c.set(i, s), s += i.length;
|
|
124
|
+
return c;
|
|
125
|
+
};
|
|
126
|
+
async function P(t, n, e, o, a, f) {
|
|
127
|
+
const c = new Uint8Array(13), s = new DataView(c.buffer);
|
|
128
|
+
s.setUint32(0, n), s.setUint32(4, e), c[8] = 8, c[9] = o;
|
|
129
|
+
const i = n * a, l = new Uint8Array(e * (1 + i));
|
|
130
|
+
for (let y = 0; y < e; y++) l.set(t.subarray(y * i, (y + 1) * i), y * (1 + i) + 1);
|
|
131
|
+
let r;
|
|
132
|
+
if (typeof CompressionStream < "u") r = await K(l);
|
|
133
|
+
else if (f.deflate) r = f.deflate(l);
|
|
134
|
+
else throw new Error("png: no CompressionStream and no deflate fallback injected");
|
|
135
|
+
const d = [Z, F("IHDR", c), F("IDAT", r), F("IEND", new Uint8Array(0))];
|
|
136
|
+
let p = 0;
|
|
137
|
+
for (const y of d) p += y.length;
|
|
138
|
+
const u = new Uint8Array(p);
|
|
139
|
+
let g = 0;
|
|
140
|
+
for (const y of d)
|
|
141
|
+
u.set(y, g), g += y.length;
|
|
142
|
+
return u;
|
|
143
|
+
}
|
|
144
|
+
async function Q(t, n, e, o = {}) {
|
|
145
|
+
if (t.length !== n * e) throw new Error(`gray8: ${t.length} bytes for ${n}x${e}`);
|
|
146
|
+
return P(t, n, e, 0, 1, o);
|
|
147
|
+
}
|
|
148
|
+
async function dt(t, n, e, o = {}) {
|
|
149
|
+
if (t.length !== n * e * 4) throw new Error(`rgba8: ${t.length} bytes for ${n}x${e}`);
|
|
150
|
+
return P(t, n, e, 6, 4, o);
|
|
151
|
+
}
|
|
152
|
+
function tt(t) {
|
|
153
|
+
const n = Number(t.display_width) > 0 ? Number(t.display_width) : 120.96, e = Number(t.display_height) > 0 ? Number(t.display_height) : 68.04, o = 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", i = o / n, l = a / e, r = (p) => (f ? n / 2 - p : p + n / 2) * i, d = (p) => (c ? e / 2 - p : p + e / 2) * l;
|
|
154
|
+
return s ? {
|
|
155
|
+
px: a,
|
|
156
|
+
py: o,
|
|
157
|
+
mirrorX: f,
|
|
158
|
+
portrait: s,
|
|
159
|
+
// canvas columns run along the display's y axis, rows along the (mirrored) x axis
|
|
160
|
+
map: (p, u) => [d(u), r(p)]
|
|
161
|
+
} : {
|
|
162
|
+
px: o,
|
|
163
|
+
py: a,
|
|
164
|
+
mirrorX: f,
|
|
165
|
+
portrait: s,
|
|
166
|
+
map: (p, u) => [r(p), d(u)]
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function et(t, n, e) {
|
|
170
|
+
const o = n.length / 8;
|
|
171
|
+
if (!o) return 0;
|
|
172
|
+
let a = 0;
|
|
173
|
+
t.beginPath();
|
|
174
|
+
let f = NaN, c = NaN;
|
|
175
|
+
for (let s = 0; s < o; s++) {
|
|
176
|
+
const i = n[s * A], l = n[s * A + 1], r = n[s * A + 4], d = n[s * A + 5];
|
|
177
|
+
(i !== f || l !== c) && (t.moveTo(...e.map(i, l)), a++), t.lineTo(...e.map(r, d)), f = r, c = d;
|
|
178
|
+
}
|
|
179
|
+
return t.fill("evenodd"), a;
|
|
180
|
+
}
|
|
181
|
+
const nt = (t) => String(t ?? "");
|
|
182
|
+
function rt({ params: t, stats: n, jobName: e, timestamp: o }) {
|
|
183
|
+
const a = String(t.material_print_speed ?? "fast"), f = {
|
|
184
|
+
action: "print",
|
|
185
|
+
jobDir: e,
|
|
186
|
+
expTime: t.exposure_time,
|
|
187
|
+
expTimeFirst: t.initial_exposure_time,
|
|
188
|
+
expUserProfile: a === "slow" ? 1 : a === "fast" ? 0 : 2,
|
|
189
|
+
fileCreationTimestamp: o ?? "",
|
|
190
|
+
hollow: t.hollowing_enable ? 1 : 0,
|
|
191
|
+
layerHeight: t.layer_height,
|
|
192
|
+
materialName: t.sla_material_settings_id ?? "",
|
|
193
|
+
numFade: t.faded_layers,
|
|
194
|
+
numFast: n.layers,
|
|
195
|
+
numSlow: 0,
|
|
196
|
+
printProfile: t.sla_print_settings_id ?? "",
|
|
197
|
+
printTime: Number(n.time_estimate ?? 0).toFixed(6),
|
|
198
|
+
printerModel: t.printer_model ?? "",
|
|
199
|
+
printerProfile: t.printer_settings_id ?? "",
|
|
200
|
+
printerVariant: t.printer_variant ?? "",
|
|
201
|
+
prusaSlicerVersion: "three-slicer",
|
|
202
|
+
usedMaterial: Number(n.resin_ml ?? 0).toFixed(6)
|
|
203
|
+
};
|
|
204
|
+
return Object.keys(f).sort().map((c) => `${c} = ${nt(f[c])}`).join(`
|
|
205
|
+
`) + `
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
const B = (t, n) => `${t}${String(n).padStart(5, "0")}.png`, ot = "Metadata/threeslicer_roles.bin", st = "Metadata/threeslicer_scene.bin";
|
|
209
|
+
function it({ modelSTL: t, supportMesh: n, padMesh: e, lift: o = 0 }) {
|
|
210
|
+
const a = t instanceof Uint8Array ? t : new Uint8Array(t ?? 0), f = n instanceof Float32Array ? n : new Float32Array(n ?? 0), c = e instanceof Float32Array ? e : new Float32Array(e ?? 0), s = new Uint8Array(12 + a.length + 4 + f.length * 4 + 4 + c.length * 4), i = new DataView(s.buffer);
|
|
211
|
+
s.set([84, 83, 83, 49], 0), i.setFloat32(4, o, !0);
|
|
212
|
+
let l = 8;
|
|
213
|
+
i.setUint32(l, a.length, !0), l += 4, s.set(a, l), l += a.length;
|
|
214
|
+
for (const r of [f, c]) {
|
|
215
|
+
i.setUint32(l, r.length, !0), l += 4;
|
|
216
|
+
for (let d = 0; d < r.length; d++)
|
|
217
|
+
i.setFloat32(l, r[d], !0), l += 4;
|
|
218
|
+
}
|
|
219
|
+
return s;
|
|
220
|
+
}
|
|
221
|
+
function lt(t) {
|
|
222
|
+
const n = t.map(({ paths: c }) => {
|
|
223
|
+
const s = [];
|
|
224
|
+
for (let i = 0; i + A - 1 < c.length; i += A) {
|
|
225
|
+
const l = Y(c[i + 3]);
|
|
226
|
+
if (l === C.SUPPORT || l === C.RAFT) for (let r = 0; r < A; r++) s.push(c[i + r]);
|
|
227
|
+
}
|
|
228
|
+
return s;
|
|
229
|
+
}), e = 8 + n.reduce((c, s) => c + 4 + s.length * 4, 0), o = new Uint8Array(e), a = new DataView(o.buffer);
|
|
230
|
+
o.set([84, 83, 82, 49], 0), a.setUint32(4, n.length, !0);
|
|
231
|
+
let f = 8;
|
|
232
|
+
for (const c of n) {
|
|
233
|
+
a.setUint32(f, c.length, !0), f += 4;
|
|
234
|
+
for (const s of c)
|
|
235
|
+
a.setFloat32(f, s, !0), f += 4;
|
|
236
|
+
}
|
|
237
|
+
return o;
|
|
238
|
+
}
|
|
239
|
+
function ct({ layers: t, params: n, makeWorker: e, workerCount: o, onProgress: a, aa: f = 1 }) {
|
|
240
|
+
return new Promise((c, s) => {
|
|
241
|
+
const i = new Array(t.length), l = new Array(o).fill(0);
|
|
242
|
+
let r = 0, d = !1;
|
|
243
|
+
const p = [], u = (g) => {
|
|
244
|
+
d = !0, p.forEach((y) => y.terminate()), s(g);
|
|
245
|
+
};
|
|
246
|
+
for (let g = 0; g < o; g++) {
|
|
247
|
+
const y = [], b = [];
|
|
248
|
+
for (let x = g; x < t.length; x += o)
|
|
249
|
+
y.push(x), b.push(t[x].paths);
|
|
250
|
+
const m = e();
|
|
251
|
+
p.push(m), m.onerror = (x) => u(new Error("SL1 encode worker: " + (x?.message || "failed"))), m.onmessage = ({ data: x }) => {
|
|
252
|
+
if (!d) {
|
|
253
|
+
if (x.progress != null) {
|
|
254
|
+
l[g] = x.progress, a?.(l.reduce((_, U) => _ + U, 0), t.length);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
x.indices.forEach((_, U) => {
|
|
258
|
+
i[_] = x.pngs[U];
|
|
259
|
+
}), m.terminate(), ++r === o && c(i);
|
|
260
|
+
}
|
|
261
|
+
}, m.postMessage({ indices: y, paths: b, params: n, aa: f });
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
async function pt({ layers: t, params: n, stats: e, jobName: o = "plate", timestamp: a, makeCanvas: f, onProgress: c, scene: s = null, makeWorker: i = null, workerCount: l = 0, aa: r = 1, gpuRaster: d = null }) {
|
|
266
|
+
const p = f ?? null, u = tt(n), g = {}, y = i && typeof Worker < "u" && t.length > 1 ? {
|
|
267
|
+
makeWorker: i,
|
|
268
|
+
workerCount: Math.max(1, Math.min(l > 0 ? l : 4, t.length))
|
|
269
|
+
} : null, b = () => performance.now(), m = { canvas: 0, clear: 0, draw: 0, encode: 0, read: 0 }, x = (w, h) => {
|
|
270
|
+
const $ = b();
|
|
271
|
+
return m[w] += $ - h, $;
|
|
272
|
+
};
|
|
273
|
+
let _ = 0, U = 0;
|
|
274
|
+
const O = async (w) => {
|
|
275
|
+
let h = b();
|
|
276
|
+
if (!p) {
|
|
277
|
+
const V = d ? await d(t[w].paths, u, r, t[w], w) : H(t[w].paths, u, r);
|
|
278
|
+
h = x("draw", h);
|
|
279
|
+
const D = await Q(V, u.px, u.py, { deflate: X });
|
|
280
|
+
return x("encode", h), _ += D.length, D;
|
|
281
|
+
}
|
|
282
|
+
const $ = p(u.px, u.py), v = $.getContext("2d");
|
|
283
|
+
h = x("canvas", h), v.fillStyle = "#000", v.fillRect(0, 0, u.px, u.py), h = x("clear", h), v.fillStyle = "#fff", U += et(v, t[w].paths, u), h = x("draw", h);
|
|
284
|
+
const I = await $.convertToBlob({ type: "image/png" });
|
|
285
|
+
h = x("encode", h);
|
|
286
|
+
const T = new Uint8Array(await I.arrayBuffer());
|
|
287
|
+
return x("read", h), _ += T.length, T;
|
|
288
|
+
}, N = b();
|
|
289
|
+
if (y) {
|
|
290
|
+
const w = await ct({ layers: t, params: n, onProgress: c, aa: r, ...y });
|
|
291
|
+
for (let h = 0; h < t.length; h++)
|
|
292
|
+
g[B(o, h)] = [w[h], { level: 0 }], _ += w[h].length;
|
|
293
|
+
} else
|
|
294
|
+
for (let w = 0; w < t.length; w++)
|
|
295
|
+
g[B(o, w)] = [await O(w), { level: 0 }], w & 31 || c?.(w, t.length);
|
|
296
|
+
const E = b();
|
|
297
|
+
g["config.ini"] = z(rt({ params: n, stats: e, jobName: o, timestamp: a })), g[ot] = [lt(t), { level: 6 }], s && (g[st] = [it(s), { level: 6 }]);
|
|
298
|
+
const k = b(), R = j(g), S = (w) => w.toFixed(0);
|
|
299
|
+
return G.info(`[vp-prof] sl1 build: ${t.length} layers ${u.px}x${u.py},` + (y ? ` raster ${S(E - N)}ms (${y.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;
|
|
300
|
+
}
|
|
301
|
+
export {
|
|
302
|
+
st as S,
|
|
303
|
+
ot as a,
|
|
304
|
+
W as b,
|
|
305
|
+
dt as c,
|
|
306
|
+
et as d,
|
|
307
|
+
Q as e,
|
|
308
|
+
ut as f,
|
|
309
|
+
G as l,
|
|
310
|
+
pt as m,
|
|
311
|
+
H as r,
|
|
312
|
+
tt as s
|
|
313
|
+
};
|
package/dist/sla_slice.worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { f as q } from "./sla_reconstruct-CRZ3TrI1.js";
|
|
2
|
-
import { d as D } from "./sl1_write-
|
|
2
|
+
import { d as D } from "./sl1_write-B6nWmCUu.js";
|
|
3
3
|
import { R as H, S as T, r as E } from "./toolpath_encoding-BuYs95qZ.js";
|
|
4
4
|
let i = 6;
|
|
5
5
|
const M = (u, x) => {
|