three-slicer 0.2.4 → 0.3.0
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/CHANGELOG.md +94 -0
- package/README.md +9 -4
- package/THIRD-PARTY-NOTICES.md +7 -2
- package/components/dist/SettingsPanel.js +12 -176
- package/data/config-schema-lean.json +1 -0
- package/data/ui-tree-keys.json +1 -0
- package/engine/src/client.js +12 -2
- package/engine/src/data.js +6 -0
- package/engine/src/settings.js +12 -627
- package/engine/src/slicer.worker.js +6 -1
- package/engine/src/slicer_core.js +0 -0
- package/engine/src/slicer_core.mt.js +0 -0
- package/engine/src/toggle_eval.js +9 -77
- package/package.json +20 -10
- package/types/client.d.ts +5 -2
- package/types/components.d.ts +3 -29
- package/types/settings.d.ts +3 -0
- package/types/toggle.d.ts +2 -22
- package/types/viewer-gcode.d.ts +2 -29
- package/types/viewer-loaders.d.ts +1 -33
- package/types/viewer-toolpath.d.ts +3 -113
- package/types/viewer.d.ts +6 -174
- package/types/worker.d.ts +2 -1
- package/viewer/dist/Viewport.js +9 -5489
- package/viewer/dist/gcode_reexport.js +1 -0
- package/viewer/dist/loaders_reexport.js +1 -0
- package/viewer/dist/toolpath_reexport.js +1 -0
- package/components/README.md +0 -44
- package/components/styles.css +0 -84
- package/engine/src/kernel_setting_keys.js +0 -132
- package/engine/src/preset_file.js +0 -99
- package/viewer/README.md +0 -375
- package/viewer/dist/gcode_parse.js +0 -190
- package/viewer/dist/make_worker.js +0 -31
- package/viewer/dist/model_loaders.js +0 -184
- package/viewer/dist/parse_3mf-C2X_W442.js +0 -300
- package/viewer/dist/parse_3mf.worker.js +0 -10
- package/viewer/dist/sl1_encode.worker.js +0 -10
- package/viewer/dist/sl1_write-UHmQ_itC.js +0 -170
- package/viewer/dist/sla_reconstruct-CXkYhux2.js +0 -176
- package/viewer/dist/sla_reconstruct.worker.js +0 -24
- package/viewer/dist/sla_slice.worker.js +0 -74
- package/viewer/dist/toolpath_gpu-4foc4FaU.js +0 -482
- package/viewer/dist/toolpath_gpu.js +0 -13
- package/viewer/styles.css +0 -353
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import * as L from "three";
|
|
2
|
-
import { OBJLoader as T } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
3
|
-
import { PLYLoader as v } from "three/examples/jsm/loaders/PLYLoader.js";
|
|
4
|
-
import { AMFLoader as P } from "three/examples/jsm/loaders/AMFLoader.js";
|
|
5
|
-
import { p as E } from "./parse_3mf-C2X_W442.js";
|
|
6
|
-
import { makeParse3mfWorker as W } from "./make_worker.js";
|
|
7
|
-
let h = null, M = !1, $ = 0;
|
|
8
|
-
const y = /* @__PURE__ */ new Map();
|
|
9
|
-
function B() {
|
|
10
|
-
if (M || typeof Worker > "u") return null;
|
|
11
|
-
if (h) return h;
|
|
12
|
-
try {
|
|
13
|
-
h = W(), h.onmessage = (t) => {
|
|
14
|
-
const { id: r, objects: s, project: o, error: n } = t.data || {}, i = y.get(r);
|
|
15
|
-
i && (y.delete(r), n ? i.reject(new Error(n)) : i.resolve({ objects: s, project: o }));
|
|
16
|
-
}, h.onerror = () => {
|
|
17
|
-
M = !0;
|
|
18
|
-
for (const [, t] of y) t.reject(new Error("3MF parse worker failed"));
|
|
19
|
-
y.clear(), h = null;
|
|
20
|
-
};
|
|
21
|
-
} catch {
|
|
22
|
-
M = !0, h = null;
|
|
23
|
-
}
|
|
24
|
-
return h;
|
|
25
|
-
}
|
|
26
|
-
async function C(t, r) {
|
|
27
|
-
const s = B();
|
|
28
|
-
if (!s) return E(t, r);
|
|
29
|
-
try {
|
|
30
|
-
const o = ++$, n = new Promise((i, c) => y.set(o, { resolve: i, reject: c }));
|
|
31
|
-
return s.postMessage({ id: o, buffer: t, baseName: r }), await n;
|
|
32
|
-
} catch {
|
|
33
|
-
return E(t, r);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const F = ["stl", "obj", "3mf", "amf", "ply"], x = /* @__PURE__ */ new Map();
|
|
37
|
-
function R(t, r) {
|
|
38
|
-
for (const s of (Array.isArray(t) ? t : String(t).split(",")).map((o) => o.trim().toLowerCase()))
|
|
39
|
-
x.set(s, r), F.includes(s) || F.push(s);
|
|
40
|
-
}
|
|
41
|
-
function D(t) {
|
|
42
|
-
const r = t.lastIndexOf(".");
|
|
43
|
-
return r < 0 ? "" : t.slice(r + 1).toLowerCase();
|
|
44
|
-
}
|
|
45
|
-
function I(t) {
|
|
46
|
-
const r = new DataView(t);
|
|
47
|
-
if (t.byteLength >= 84) {
|
|
48
|
-
const c = r.getUint32(80, !0);
|
|
49
|
-
if (t.byteLength === 84 + c * 50) {
|
|
50
|
-
const a = new Float32Array(c * 9);
|
|
51
|
-
let u = 84, d = 0;
|
|
52
|
-
for (let p = 0; p < c; p++) {
|
|
53
|
-
u += 12;
|
|
54
|
-
for (let e = 0; e < 3; e++)
|
|
55
|
-
a[d++] = r.getFloat32(u, !0), a[d++] = r.getFloat32(u + 4, !0), a[d++] = r.getFloat32(u + 8, !0), u += 12;
|
|
56
|
-
u += 2;
|
|
57
|
-
}
|
|
58
|
-
return a;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const s = new TextDecoder().decode(t), o = /vertex\s+([-\d.eE+]+)\s+([-\d.eE+]+)\s+([-\d.eE+]+)/g, n = [];
|
|
62
|
-
let i;
|
|
63
|
-
for (; i = o.exec(s); ) n.push(+i[1], +i[2], +i[3]);
|
|
64
|
-
return n.length < 9 ? null : new Float32Array(n);
|
|
65
|
-
}
|
|
66
|
-
function A(t, r) {
|
|
67
|
-
var d;
|
|
68
|
-
const s = (d = t == null ? void 0 : t.attributes) == null ? void 0 : d.position;
|
|
69
|
-
if (!s || s.count < 3) return null;
|
|
70
|
-
const o = t.index, n = new L.Vector3(), i = Math.floor((o ? o.count : s.count) / 3), c = new Float32Array(i * 9);
|
|
71
|
-
let a = 0;
|
|
72
|
-
const u = (p) => {
|
|
73
|
-
n.fromBufferAttribute(s, p), r && n.applyMatrix4(r), c[a++] = n.x, c[a++] = n.y, c[a++] = n.z;
|
|
74
|
-
};
|
|
75
|
-
if (o)
|
|
76
|
-
for (let p = 0; p < i * 3; p++) u(o.getX(p));
|
|
77
|
-
else
|
|
78
|
-
for (let p = 0; p < i * 3; p++) u(p);
|
|
79
|
-
return c;
|
|
80
|
-
}
|
|
81
|
-
function j(t) {
|
|
82
|
-
t.updateMatrixWorld(!0);
|
|
83
|
-
const r = [];
|
|
84
|
-
return t.traverse((s) => {
|
|
85
|
-
s.isMesh && s.geometry && r.push({ geometry: s.geometry, matrix: s.matrixWorld });
|
|
86
|
-
}), r;
|
|
87
|
-
}
|
|
88
|
-
function k(t, r, s) {
|
|
89
|
-
const o = r.map((a) => A(a.geometry, a.matrix)).filter(Boolean);
|
|
90
|
-
if (!o.length) return [];
|
|
91
|
-
if (s && o.length > 1)
|
|
92
|
-
return o.map((a, u) => ({ name: `${t}#${u + 1}`, modelPos: a }));
|
|
93
|
-
if (o.length === 1) return [{ name: t, modelPos: o[0] }];
|
|
94
|
-
let n = 0;
|
|
95
|
-
for (const a of o) n += a.length;
|
|
96
|
-
const i = new Float32Array(n);
|
|
97
|
-
let c = 0;
|
|
98
|
-
for (const a of o)
|
|
99
|
-
i.set(a, c), c += a.length;
|
|
100
|
-
return [{ name: t, modelPos: i }];
|
|
101
|
-
}
|
|
102
|
-
async function U(t, r) {
|
|
103
|
-
const s = D(t);
|
|
104
|
-
switch (s) {
|
|
105
|
-
case "stl": {
|
|
106
|
-
const o = I(r);
|
|
107
|
-
if (!o) throw new Error("Failed to parse STL");
|
|
108
|
-
return [{ name: t, modelPos: o }];
|
|
109
|
-
}
|
|
110
|
-
case "obj": {
|
|
111
|
-
const o = new T().parse(new TextDecoder().decode(r));
|
|
112
|
-
return k(t, j(o), !1);
|
|
113
|
-
}
|
|
114
|
-
case "ply": {
|
|
115
|
-
const o = new v().parse(r), n = A(o, null);
|
|
116
|
-
if (!n) throw new Error("No PLY geometry");
|
|
117
|
-
return [{ name: t, modelPos: n }];
|
|
118
|
-
}
|
|
119
|
-
case "3mf": {
|
|
120
|
-
const { objects: o, project: n } = await C(r, t), i = o.map((c) => ({ name: c.name, modelPos: c.tris, objectid: c.objectid, paint: c.paint, bbox: c.bbox, project: n }));
|
|
121
|
-
if (!i.length) throw new Error("No mesh in 3MF");
|
|
122
|
-
return i;
|
|
123
|
-
}
|
|
124
|
-
case "amf": {
|
|
125
|
-
const o = new P().parse(r), n = k(t, j(o), !0);
|
|
126
|
-
if (!n.length) throw new Error("No mesh in AMF");
|
|
127
|
-
return n;
|
|
128
|
-
}
|
|
129
|
-
default: {
|
|
130
|
-
const o = x.get(s);
|
|
131
|
-
if (!o) throw new Error(`Unsupported format: .${s}`);
|
|
132
|
-
const n = await o(r, t);
|
|
133
|
-
if (!(n != null && n.length)) throw new Error(`No mesh in .${s}`);
|
|
134
|
-
return n;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function V(t) {
|
|
139
|
-
const r = Math.floor(t.length / 9);
|
|
140
|
-
if (r < 2) return null;
|
|
141
|
-
const s = 1e4, o = /* @__PURE__ */ new Map(), n = new Int32Array(r * 3);
|
|
142
|
-
for (let e = 0; e < r; e++)
|
|
143
|
-
for (let l = 0; l < 3; l++) {
|
|
144
|
-
const f = e * 9 + l * 3, m = `${Math.round(t[f] * s)},${Math.round(t[f + 1] * s)},${Math.round(t[f + 2] * s)}`;
|
|
145
|
-
let w = o.get(m);
|
|
146
|
-
w === void 0 && (w = o.size, o.set(m, w)), n[e * 3 + l] = w;
|
|
147
|
-
}
|
|
148
|
-
const i = new Int32Array(r);
|
|
149
|
-
for (let e = 0; e < r; e++) i[e] = e;
|
|
150
|
-
const c = (e) => {
|
|
151
|
-
for (; i[e] !== e; )
|
|
152
|
-
i[e] = i[i[e]], e = i[e];
|
|
153
|
-
return e;
|
|
154
|
-
}, a = (e, l) => {
|
|
155
|
-
e = c(e), l = c(l), e !== l && (i[l] = e);
|
|
156
|
-
}, u = /* @__PURE__ */ new Map();
|
|
157
|
-
for (let e = 0; e < r; e++)
|
|
158
|
-
for (let l = 0; l < 3; l++) {
|
|
159
|
-
const f = n[e * 3 + l], m = n[e * 3 + (l + 1) % 3], w = f < m ? f * 4294967296 + m : m * 4294967296 + f, g = u.get(w);
|
|
160
|
-
g === void 0 ? u.set(w, e) : a(e, g);
|
|
161
|
-
}
|
|
162
|
-
const d = /* @__PURE__ */ new Map();
|
|
163
|
-
for (let e = 0; e < r; e++) {
|
|
164
|
-
const l = c(e);
|
|
165
|
-
let f = d.get(l);
|
|
166
|
-
f || (f = [], d.set(l, f)), f.push(e);
|
|
167
|
-
}
|
|
168
|
-
return d.size < 2 ? null : [...d.values()].sort((e, l) => l.length - e.length).map((e) => {
|
|
169
|
-
const l = new Float32Array(e.length * 9);
|
|
170
|
-
let f = 0;
|
|
171
|
-
for (const m of e) {
|
|
172
|
-
const w = m * 9;
|
|
173
|
-
for (let g = 0; g < 9; g++) l[f++] = t[w + g];
|
|
174
|
-
}
|
|
175
|
-
return l;
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
export {
|
|
179
|
-
F as SUPPORTED_EXT,
|
|
180
|
-
D as fileExt,
|
|
181
|
-
U as loadModel,
|
|
182
|
-
R as registerLoader,
|
|
183
|
-
V as splitConnectedComponents
|
|
184
|
-
};
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import { unzip as W, unzipSync as B } from "three/examples/jsm/libs/fflate.module.js";
|
|
2
|
-
function q(t) {
|
|
3
|
-
return new Promise((n) => {
|
|
4
|
-
let o = !1;
|
|
5
|
-
const e = (s) => {
|
|
6
|
-
o || (o = !0, n(s));
|
|
7
|
-
};
|
|
8
|
-
try {
|
|
9
|
-
W(t, (s, i) => e(s ? B(t) : i));
|
|
10
|
-
} catch {
|
|
11
|
-
e(B(t));
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
const F = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0];
|
|
16
|
-
function K(t, n) {
|
|
17
|
-
const o = new Array(12);
|
|
18
|
-
for (let e = 0; e < 4; e++)
|
|
19
|
-
for (let s = 0; s < 3; s++)
|
|
20
|
-
o[e * 3 + s] = t[e * 3] * n[s] + t[e * 3 + 1] * n[3 + s] + t[e * 3 + 2] * n[6 + s] + (e === 3 ? n[9 + s] : 0);
|
|
21
|
-
return o;
|
|
22
|
-
}
|
|
23
|
-
function C(t) {
|
|
24
|
-
if (!t) return F;
|
|
25
|
-
const n = t.trim().split(/\s+/).map(Number);
|
|
26
|
-
return n.length === 12 && n.every(Number.isFinite) ? n : F;
|
|
27
|
-
}
|
|
28
|
-
const U = {};
|
|
29
|
-
function d(t, n) {
|
|
30
|
-
const e = (U[n] || (U[n] = new RegExp(`\\b${n}\\s*=\\s*"([^"]*)"`))).exec(t);
|
|
31
|
-
return e ? e[1] : null;
|
|
32
|
-
}
|
|
33
|
-
const D = /<vertex\s+x="([^"]*)"\s+y="([^"]*)"\s+z="([^"]*)"/g, V = /<triangle\s+v1="([^"]*)"\s+v2="([^"]*)"\s+v3="([^"]*)"([^>]*)/g, $ = [
|
|
34
|
-
["paint_color", "color"],
|
|
35
|
-
// multi-material: state 1..16 == Extruder1..16
|
|
36
|
-
["paint_supports", "supports"],
|
|
37
|
-
// support enforcer/blocker: states 1 and 2
|
|
38
|
-
["paint_seam", "seam"],
|
|
39
|
-
// unsupported by the kernel — collected for the warning only
|
|
40
|
-
["paint_fuzzy_skin", "fuzzy"]
|
|
41
|
-
// ditto
|
|
42
|
-
];
|
|
43
|
-
function Y() {
|
|
44
|
-
return { color: /* @__PURE__ */ new Map(), supports: /* @__PURE__ */ new Map(), seam: /* @__PURE__ */ new Map(), fuzzy: /* @__PURE__ */ new Map() };
|
|
45
|
-
}
|
|
46
|
-
function Q(t) {
|
|
47
|
-
return !t || $.every(([, n]) => t[n].size === 0);
|
|
48
|
-
}
|
|
49
|
-
function J(t, n, o) {
|
|
50
|
-
for (const [e, s] of $) {
|
|
51
|
-
if (!t.includes(e)) continue;
|
|
52
|
-
const i = d(t, e);
|
|
53
|
-
i && o[s].set(n, i);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function Z(t) {
|
|
57
|
-
const n = [];
|
|
58
|
-
D.lastIndex = 0;
|
|
59
|
-
let o;
|
|
60
|
-
for (; o = D.exec(t); ) n.push(+o[1], +o[2], +o[3]);
|
|
61
|
-
if (!n.length)
|
|
62
|
-
for (const i of t.match(/<vertex\b[^>]*>/g) || []) n.push(+d(i, "x"), +d(i, "y"), +d(i, "z"));
|
|
63
|
-
if (n.length < 9) return null;
|
|
64
|
-
const e = [], s = Y();
|
|
65
|
-
for (V.lastIndex = 0; o = V.exec(t); ) {
|
|
66
|
-
const i = e.length / 3;
|
|
67
|
-
e.push(+o[1], +o[2], +o[3]), o[4].length > 2 && J(o[4], i, s);
|
|
68
|
-
}
|
|
69
|
-
if (!e.length)
|
|
70
|
-
for (const i of t.match(/<triangle\b[^>]*>/g) || []) {
|
|
71
|
-
const p = e.length / 3;
|
|
72
|
-
e.push(+d(i, "v1"), +d(i, "v2"), +d(i, "v3")), J(i, p, s);
|
|
73
|
-
}
|
|
74
|
-
return e.length ? { verts: n, tris: e, paint: s } : null;
|
|
75
|
-
}
|
|
76
|
-
function x(t) {
|
|
77
|
-
const n = /* @__PURE__ */ new Map(), o = /<object\b([^>]*)>([\s\S]*?)<\/object>/g;
|
|
78
|
-
let e;
|
|
79
|
-
for (; e = o.exec(t); ) {
|
|
80
|
-
const p = d(e[1], "id");
|
|
81
|
-
if (!p) continue;
|
|
82
|
-
const u = e[2], r = [];
|
|
83
|
-
for (const a of u.match(/<component\b[^>]*>/g) || []) {
|
|
84
|
-
const l = d(a, "objectid");
|
|
85
|
-
l && r.push({ objectid: l, path: d(a, "p:path") || d(a, "path"), transform: C(d(a, "transform")) });
|
|
86
|
-
}
|
|
87
|
-
n.set(p, r.length ? { components: r } : { mesh: Z(u) });
|
|
88
|
-
}
|
|
89
|
-
const s = [], i = /<build\b[^>]*>([\s\S]*?)<\/build>/.exec(t);
|
|
90
|
-
if (i)
|
|
91
|
-
for (const p of i[1].match(/<item\b[^>]*>/g) || []) {
|
|
92
|
-
const u = d(p, "objectid");
|
|
93
|
-
u && s.push({ objectid: u, path: d(p, "p:path") || d(p, "path"), transform: C(d(p, "transform")) });
|
|
94
|
-
}
|
|
95
|
-
return { objects: n, items: s };
|
|
96
|
-
}
|
|
97
|
-
function O(t) {
|
|
98
|
-
const n = String(t).replace(/^\/+/, "");
|
|
99
|
-
return n.includes("%") ? decodeURIComponent(n) : n;
|
|
100
|
-
}
|
|
101
|
-
function k(t) {
|
|
102
|
-
const n = {};
|
|
103
|
-
for (const o of t.match(/<metadata\b[^>]*>/g) || []) {
|
|
104
|
-
const e = d(o, "key");
|
|
105
|
-
e && (n[e] = d(o, "value") ?? "");
|
|
106
|
-
}
|
|
107
|
-
return n;
|
|
108
|
-
}
|
|
109
|
-
function tt(t) {
|
|
110
|
-
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), e = /<object\b([^>]*)>([\s\S]*?)<\/object>/g;
|
|
111
|
-
let s;
|
|
112
|
-
for (; s = e.exec(t); ) {
|
|
113
|
-
const u = d(s[1], "id");
|
|
114
|
-
if (u) {
|
|
115
|
-
const r = s[2];
|
|
116
|
-
n.set(u, k(r.replace(/<(?:part|volume)\b[\s\S]*?<\/(?:part|volume)>/g, "")));
|
|
117
|
-
const a = [];
|
|
118
|
-
for (const l of r.match(/<volume\b[\s\S]*?<\/volume>/g) || []) {
|
|
119
|
-
const b = k(l).volume_type, _ = b === "SupportBlocker" ? "blocker" : b === "SupportEnforcer" ? "enforcer" : null, j = Number(d(l, "firstid")), S = Number(d(l, "lastid"));
|
|
120
|
-
_ && Number.isInteger(j) && Number.isInteger(S) && j >= 0 && S >= j && a.push({ firstTriangle: j, lastTriangle: S, kind: _ });
|
|
121
|
-
}
|
|
122
|
-
a.length && o.set(u, a);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const i = [], p = /<plate\b[^>]*>([\s\S]*?)<\/plate>/g;
|
|
126
|
-
for (; s = p.exec(t); ) {
|
|
127
|
-
const u = s[1], r = k(u.replace(/<model_instance\b[\s\S]*?<\/model_instance>/g, "")), a = [];
|
|
128
|
-
for (const l of u.match(/<model_instance\b[\s\S]*?<\/model_instance>/g) || []) {
|
|
129
|
-
const b = k(l).object_id;
|
|
130
|
-
b && a.push(b);
|
|
131
|
-
}
|
|
132
|
-
i.push({ index: Math.max(0, (Number(r.plater_id) || i.length + 1) - 1), objectIds: a });
|
|
133
|
-
}
|
|
134
|
-
return { objects: n, plates: i, volumes: o };
|
|
135
|
-
}
|
|
136
|
-
const et = Object.freeze({
|
|
137
|
-
manualSupportPoints: "prepared-roundtrip",
|
|
138
|
-
drainHoles: "preserved-unsupported",
|
|
139
|
-
modifierVolumes: "prepared-mask-filtering",
|
|
140
|
-
uiEditing: "unavailable"
|
|
141
|
-
});
|
|
142
|
-
function X(t, n, o, e, s) {
|
|
143
|
-
const i = /* @__PURE__ */ new Map();
|
|
144
|
-
if (!(t != null && t.trim())) return i;
|
|
145
|
-
const p = t.trim().split(/\r?\n/), u = new RegExp(`^${n}_format_version=(\\d+)$`).exec(p[0]), r = u ? Number(u[1]) : 0;
|
|
146
|
-
for (const a of p.slice(u ? 1 : 0)) {
|
|
147
|
-
const l = /^object_id=(\d+)\|(.*)$/.exec(a);
|
|
148
|
-
if (!l || i.has(Number(l == null ? void 0 : l[1]))) continue;
|
|
149
|
-
const b = Number(l[1]), _ = l[2].trim() ? l[2].trim().split(/\s+/).map(Number) : [], j = o(r);
|
|
150
|
-
if (!j || _.length % j !== 0 || _.some((c) => !Number.isFinite(c))) {
|
|
151
|
-
e.push({ code: n === "support_points" ? "SLA_SUPPORT_POINT_COUNT" : "SLA_DRAIN_HOLE_COUNT", object: b }), i.set(b, []);
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
const S = [];
|
|
155
|
-
for (let c = 0; c < _.length; c += j) S.push(s(_.slice(c, c + j), r));
|
|
156
|
-
i.set(b, S);
|
|
157
|
-
}
|
|
158
|
-
return i;
|
|
159
|
-
}
|
|
160
|
-
function G(t, n) {
|
|
161
|
-
const [o, e, s] = n;
|
|
162
|
-
return [o * t[0] + e * t[3] + s * t[6] + t[9], o * t[1] + e * t[4] + s * t[7] + t[10], o * t[2] + e * t[5] + s * t[8] + t[11]];
|
|
163
|
-
}
|
|
164
|
-
function nt(t, n) {
|
|
165
|
-
const [o, e, s] = n, i = [o * t[0] + e * t[3] + s * t[6], o * t[1] + e * t[4] + s * t[7], o * t[2] + e * t[5] + s * t[8]], p = Math.hypot(...i);
|
|
166
|
-
return p ? i.map((u) => u / p) : i;
|
|
167
|
-
}
|
|
168
|
-
function ot(t, n) {
|
|
169
|
-
var p, u;
|
|
170
|
-
const o = (r) => {
|
|
171
|
-
const a = t.get(r);
|
|
172
|
-
return a ? n.decode(a) : null;
|
|
173
|
-
}, e = {
|
|
174
|
-
settings: null,
|
|
175
|
-
// Metadata/project_settings.config — the flattened preset (raw upstream strings)
|
|
176
|
-
objectMeta: /* @__PURE__ */ new Map(),
|
|
177
|
-
// 3mf object id -> per-object metadata (name, extruder, per-object overrides)
|
|
178
|
-
plates: [],
|
|
179
|
-
// [{index, objectIds}]
|
|
180
|
-
hasLayerHeightProfile: !1,
|
|
181
|
-
hasCustomGcodePerLayer: !1,
|
|
182
|
-
volumeMeta: /* @__PURE__ */ new Map(),
|
|
183
|
-
sla: { capabilities: { ...et }, issues: [], supportPoints: /* @__PURE__ */ new Map(), drainHoles: /* @__PURE__ */ new Map() }
|
|
184
|
-
}, s = o("Metadata/project_settings.config");
|
|
185
|
-
if (s)
|
|
186
|
-
try {
|
|
187
|
-
e.settings = JSON.parse(s);
|
|
188
|
-
} catch {
|
|
189
|
-
e.settings = null;
|
|
190
|
-
}
|
|
191
|
-
const i = o("Metadata/model_settings.config");
|
|
192
|
-
if (i) {
|
|
193
|
-
const r = tt(i);
|
|
194
|
-
e.objectMeta = r.objects, e.plates = r.plates, e.volumeMeta = r.volumes;
|
|
195
|
-
}
|
|
196
|
-
return e.sla.supportPoints = X(
|
|
197
|
-
o("Metadata/Slic3r_PE_sla_support_points.txt"),
|
|
198
|
-
"support_points",
|
|
199
|
-
(r) => r === 0 ? 3 : r === 1 ? 5 : 0,
|
|
200
|
-
e.sla.issues,
|
|
201
|
-
(r, a) => ({
|
|
202
|
-
position: r.slice(0, 3),
|
|
203
|
-
radius: a === 0 ? 0.4 : r[3],
|
|
204
|
-
type: a === 0 || r[4] === 2 ? "manual" : r[4] === 1 ? "island" : "slope"
|
|
205
|
-
})
|
|
206
|
-
), e.sla.drainHoles = X(
|
|
207
|
-
o("Metadata/Slic3r_PE_sla_drain_holes.txt"),
|
|
208
|
-
"drain_holes",
|
|
209
|
-
(r) => r === 1 ? 8 : 0,
|
|
210
|
-
e.sla.issues,
|
|
211
|
-
(r) => {
|
|
212
|
-
const a = Math.hypot(r[3], r[4], r[5]), l = a ? r.slice(3, 6).map((b) => b / a) : r.slice(3, 6);
|
|
213
|
-
return { position: r.slice(0, 3).map((b, _) => b + l[_]), normal: l, radius: r[6], height: r[7] - 1 };
|
|
214
|
-
}
|
|
215
|
-
), e.hasLayerHeightProfile = !!((p = o("Metadata/layer_heights_profile.txt")) != null && p.trim()), e.hasCustomGcodePerLayer = !!((u = o("Metadata/custom_gcode_per_layer.xml")) != null && u.trim()), e;
|
|
216
|
-
}
|
|
217
|
-
async function rt(t, n = "model") {
|
|
218
|
-
const o = ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t), e = await q(o), s = /* @__PURE__ */ new Map();
|
|
219
|
-
for (const c of Object.keys(e)) s.set(O(c), e[c]);
|
|
220
|
-
const i = new TextDecoder(), p = /* @__PURE__ */ new Map(), u = (c) => {
|
|
221
|
-
const w = O(c);
|
|
222
|
-
if (p.has(w)) return p.get(w);
|
|
223
|
-
const m = s.get(w), M = m ? x(i.decode(m)) : null;
|
|
224
|
-
return p.set(w, M), M;
|
|
225
|
-
};
|
|
226
|
-
let r = "3D/3dmodel.model";
|
|
227
|
-
const a = s.get("_rels/.rels");
|
|
228
|
-
if (a) {
|
|
229
|
-
for (const c of i.decode(a).match(/<Relationship\b[^>]*>/g) || [])
|
|
230
|
-
if ((d(c, "Type") || "").endsWith("/3dmodel")) {
|
|
231
|
-
r = O(d(c, "Target"));
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
const l = u(r);
|
|
236
|
-
if (!l) throw new Error(`3MF root model not found: ${r}`);
|
|
237
|
-
const b = [], _ = ot(s, i), j = (c, w, m, M, P, z) => {
|
|
238
|
-
if (z > 16) return;
|
|
239
|
-
const T = u(w), I = T == null ? void 0 : T.objects.get(c);
|
|
240
|
-
if (!I) return;
|
|
241
|
-
if (I.components) {
|
|
242
|
-
for (const y of I.components) j(y.objectid, y.path || w, K(y.transform, m), M, P, z + 1);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (!I.mesh) return;
|
|
246
|
-
const { verts: E, tris: v, paint: A } = I.mesh, R = M.length / 9;
|
|
247
|
-
for (let y = 0; y < v.length; y++) {
|
|
248
|
-
const f = v[y] * 3, g = E[f], h = E[f + 1], N = E[f + 2];
|
|
249
|
-
M.push(
|
|
250
|
-
g * m[0] + h * m[3] + N * m[6] + m[9],
|
|
251
|
-
g * m[1] + h * m[4] + N * m[7] + m[10],
|
|
252
|
-
g * m[2] + h * m[5] + N * m[8] + m[11]
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
if (A) for (const [, y] of $)
|
|
256
|
-
for (const [f, g] of A[y]) P[y].set(R + f, g);
|
|
257
|
-
}, S = l.items.length ? l.items : [...l.objects.keys()].filter((c) => l.objects.get(c).mesh).map((c) => ({ objectid: c, path: r, transform: F }));
|
|
258
|
-
return S.forEach((c, w) => {
|
|
259
|
-
const m = [], M = Y();
|
|
260
|
-
if (j(c.objectid, c.path || r, c.transform, m, M, 0), m.length < 9) return;
|
|
261
|
-
let P = new Float32Array(m);
|
|
262
|
-
const z = [], T = _.volumeMeta.get(c.objectid) || [];
|
|
263
|
-
if (T.length) {
|
|
264
|
-
const f = /* @__PURE__ */ new Set();
|
|
265
|
-
for (let g = 0; g < T.length; g++) {
|
|
266
|
-
const h = T[g], N = h.firstTriangle * 9, H = Math.min(m.length, (h.lastTriangle + 1) * 9);
|
|
267
|
-
if (!(N >= H)) {
|
|
268
|
-
for (let L = h.firstTriangle; L <= h.lastTriangle; L++) f.add(L);
|
|
269
|
-
z.push({ id: `${c.objectid}:modifier:${g}`, kind: h.kind, tris: new Float32Array(m.slice(N, H)) });
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (f.size) {
|
|
273
|
-
const g = [];
|
|
274
|
-
for (let h = 0; h < m.length / 9; h++) f.has(h) || g.push(...m.slice(h * 9, h * 9 + 9));
|
|
275
|
-
P = new Float32Array(g);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
const I = (_.sla.supportPoints.get(w + 1) || []).map((f) => ({ ...f, position: G(c.transform, f.position) })), E = (_.sla.drainHoles.get(w + 1) || []).map((f) => ({
|
|
279
|
-
...f,
|
|
280
|
-
position: G(c.transform, f.position),
|
|
281
|
-
normal: nt(c.transform, f.normal)
|
|
282
|
-
}));
|
|
283
|
-
let v = 1 / 0, A = 1 / 0, R = -1 / 0, y = -1 / 0;
|
|
284
|
-
for (let f = 0; f < P.length; f += 3) {
|
|
285
|
-
const g = P[f], h = P[f + 1];
|
|
286
|
-
g < v && (v = g), g > R && (R = g), h < A && (A = h), h > y && (y = h);
|
|
287
|
-
}
|
|
288
|
-
b.push({
|
|
289
|
-
name: S.length > 1 ? `${n}#${w + 1}` : n,
|
|
290
|
-
tris: P,
|
|
291
|
-
objectid: c.objectid,
|
|
292
|
-
paint: Q(M) ? null : M,
|
|
293
|
-
sla: { supportPoints: I, drainHoles: E, modifierVolumes: z },
|
|
294
|
-
bbox: { minX: v, minY: A, maxX: R, maxY: y }
|
|
295
|
-
});
|
|
296
|
-
}), { objects: b, project: _ };
|
|
297
|
-
}
|
|
298
|
-
export {
|
|
299
|
-
rt as p
|
|
300
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { p as f } from "./parse_3mf-C2X_W442.js";
|
|
2
|
-
self.onmessage = async (a) => {
|
|
3
|
-
const { id: s, buffer: r, baseName: t } = a.data || {};
|
|
4
|
-
try {
|
|
5
|
-
const { objects: e, project: o } = await f(r, t);
|
|
6
|
-
self.postMessage({ id: s, objects: e, project: o }, e.map((c) => c.tris.buffer));
|
|
7
|
-
} catch (e) {
|
|
8
|
-
self.postMessage({ id: s, error: e && e.message || String(e) });
|
|
9
|
-
}
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { s as p, d as c } from "./sl1_write-UHmQ_itC.js";
|
|
2
|
-
self.onmessage = async ({ data: { indices: f, paths: n, params: o } }) => {
|
|
3
|
-
const a = p(o), r = new OffscreenCanvas(a.px, a.py), e = r.getContext("2d"), t = [];
|
|
4
|
-
for (let s = 0; s < f.length; s++) {
|
|
5
|
-
e.fillStyle = "#000", e.fillRect(0, 0, a.px, a.py), e.fillStyle = "#fff", c(e, n[s], a);
|
|
6
|
-
const l = await r.convertToBlob({ type: "image/png" });
|
|
7
|
-
t.push(new Uint8Array(await l.arrayBuffer())), (s & 7) === 7 && self.postMessage({ progress: s + 1 });
|
|
8
|
-
}
|
|
9
|
-
self.postMessage({ indices: f, pngs: t }, t.map((s) => s.buffer));
|
|
10
|
-
};
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { strToU8 as R, zipSync as T } from "three/examples/jsm/libs/fflate.module.js";
|
|
2
|
-
let F = !0;
|
|
3
|
-
function Z(e) {
|
|
4
|
-
F = !!e;
|
|
5
|
-
}
|
|
6
|
-
const C = {
|
|
7
|
-
info: (...e) => {
|
|
8
|
-
F && console.info(...e);
|
|
9
|
-
},
|
|
10
|
-
warn: (...e) => {
|
|
11
|
-
F && console.warn(...e);
|
|
12
|
-
},
|
|
13
|
-
error: (...e) => {
|
|
14
|
-
F && console.error(...e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
function O(e) {
|
|
18
|
-
const t = Number(e.display_width) > 0 ? Number(e.display_width) : 120.96, u = Number(e.display_height) > 0 ? Number(e.display_height) : 68.04, o = Number(e.display_pixels_x) > 0 ? Math.round(Number(e.display_pixels_x)) : 2560, i = Number(e.display_pixels_y) > 0 ? Math.round(Number(e.display_pixels_y)) : 1440, s = e.display_mirror_x !== !1, r = e.display_mirror_y === !0, n = (e.display_orientation ?? "portrait") !== "landscape", a = o / t, l = i / u, f = (p) => (s ? t / 2 - p : p + t / 2) * a, c = (p) => (r ? u / 2 - p : p + u / 2) * l;
|
|
19
|
-
return n ? {
|
|
20
|
-
px: i,
|
|
21
|
-
py: o,
|
|
22
|
-
mirrorX: s,
|
|
23
|
-
portrait: n,
|
|
24
|
-
// canvas columns run along the display's y axis, rows along the (mirrored) x axis
|
|
25
|
-
map: (p, y) => [c(y), f(p)]
|
|
26
|
-
} : {
|
|
27
|
-
px: o,
|
|
28
|
-
py: i,
|
|
29
|
-
mirrorX: s,
|
|
30
|
-
portrait: n,
|
|
31
|
-
map: (p, y) => [f(p), c(y)]
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function k(e, t, u) {
|
|
35
|
-
const o = t.length / 8;
|
|
36
|
-
if (!o) return 0;
|
|
37
|
-
let i = 0;
|
|
38
|
-
e.beginPath();
|
|
39
|
-
let s = NaN, r = NaN;
|
|
40
|
-
for (let n = 0; n < o; n++) {
|
|
41
|
-
const a = t[n * 8], l = t[n * 8 + 1], f = t[n * 8 + 4], c = t[n * 8 + 5];
|
|
42
|
-
(a !== s || l !== r) && (e.moveTo(...u.map(a, l)), i++), e.lineTo(...u.map(f, c)), s = f, r = c;
|
|
43
|
-
}
|
|
44
|
-
return e.fill("evenodd"), i;
|
|
45
|
-
}
|
|
46
|
-
const V = (e) => String(e ?? "");
|
|
47
|
-
function X({ params: e, stats: t, jobName: u, timestamp: o }) {
|
|
48
|
-
const i = String(e.material_print_speed ?? "fast"), s = {
|
|
49
|
-
action: "print",
|
|
50
|
-
jobDir: u,
|
|
51
|
-
expTime: e.exposure_time,
|
|
52
|
-
expTimeFirst: e.initial_exposure_time,
|
|
53
|
-
expUserProfile: i === "slow" ? 1 : i === "fast" ? 0 : 2,
|
|
54
|
-
fileCreationTimestamp: o ?? "",
|
|
55
|
-
hollow: e.hollowing_enable ? 1 : 0,
|
|
56
|
-
layerHeight: e.layer_height,
|
|
57
|
-
materialName: e.sla_material_settings_id ?? "",
|
|
58
|
-
numFade: e.faded_layers,
|
|
59
|
-
numFast: t.layers,
|
|
60
|
-
numSlow: 0,
|
|
61
|
-
printProfile: e.sla_print_settings_id ?? "",
|
|
62
|
-
printTime: Number(t.time_estimate ?? 0).toFixed(6),
|
|
63
|
-
printerModel: e.printer_model ?? "",
|
|
64
|
-
printerProfile: e.printer_settings_id ?? "",
|
|
65
|
-
printerVariant: e.printer_variant ?? "",
|
|
66
|
-
prusaSlicerVersion: "three-slicer",
|
|
67
|
-
usedMaterial: Number(t.resin_ml ?? 0).toFixed(6)
|
|
68
|
-
};
|
|
69
|
-
return Object.keys(s).sort().map((r) => `${r} = ${V(s[r])}`).join(`
|
|
70
|
-
`) + `
|
|
71
|
-
`;
|
|
72
|
-
}
|
|
73
|
-
const L = (e, t) => `${e}${String(t).padStart(5, "0")}.png`, Y = "Metadata/threeslicer_roles.bin", D = "Metadata/threeslicer_scene.bin";
|
|
74
|
-
function j({ modelSTL: e, supportMesh: t, padMesh: u, lift: o = 0 }) {
|
|
75
|
-
const i = e instanceof Uint8Array ? e : new Uint8Array(e ?? 0), s = t instanceof Float32Array ? t : new Float32Array(t ?? 0), r = u instanceof Float32Array ? u : new Float32Array(u ?? 0), n = new Uint8Array(12 + i.length + 4 + s.length * 4 + 4 + r.length * 4), a = new DataView(n.buffer);
|
|
76
|
-
n.set([84, 83, 83, 49], 0), a.setFloat32(4, o, !0);
|
|
77
|
-
let l = 8;
|
|
78
|
-
a.setUint32(l, i.length, !0), l += 4, n.set(i, l), l += i.length;
|
|
79
|
-
for (const f of [s, r]) {
|
|
80
|
-
a.setUint32(l, f.length, !0), l += 4;
|
|
81
|
-
for (let c = 0; c < f.length; c++)
|
|
82
|
-
a.setFloat32(l, f[c], !0), l += 4;
|
|
83
|
-
}
|
|
84
|
-
return n;
|
|
85
|
-
}
|
|
86
|
-
function z(e) {
|
|
87
|
-
const t = e.map(({ paths: r }) => {
|
|
88
|
-
const n = [];
|
|
89
|
-
for (let a = 0; a + 7 < r.length; a += 8) {
|
|
90
|
-
const l = r[a + 3] & 15;
|
|
91
|
-
if (l === 5 || l === 6) for (let f = 0; f < 8; f++) n.push(r[a + f]);
|
|
92
|
-
}
|
|
93
|
-
return n;
|
|
94
|
-
}), u = 8 + t.reduce((r, n) => r + 4 + n.length * 4, 0), o = new Uint8Array(u), i = new DataView(o.buffer);
|
|
95
|
-
o.set([84, 83, 82, 49], 0), i.setUint32(4, t.length, !0);
|
|
96
|
-
let s = 8;
|
|
97
|
-
for (const r of t) {
|
|
98
|
-
i.setUint32(s, r.length, !0), s += 4;
|
|
99
|
-
for (const n of r)
|
|
100
|
-
i.setFloat32(s, n, !0), s += 4;
|
|
101
|
-
}
|
|
102
|
-
return o;
|
|
103
|
-
}
|
|
104
|
-
function H({ layers: e, params: t, makeWorker: u, workerCount: o, onProgress: i }) {
|
|
105
|
-
return new Promise((s, r) => {
|
|
106
|
-
const n = new Array(e.length), a = new Array(o).fill(0);
|
|
107
|
-
let l = 0, f = !1;
|
|
108
|
-
const c = [], p = (y) => {
|
|
109
|
-
f = !0, c.forEach((_) => _.terminate()), r(y);
|
|
110
|
-
};
|
|
111
|
-
for (let y = 0; y < o; y++) {
|
|
112
|
-
const _ = [], m = [];
|
|
113
|
-
for (let g = y; g < e.length; g += o)
|
|
114
|
-
_.push(g), m.push(e[g].paths);
|
|
115
|
-
const w = u();
|
|
116
|
-
c.push(w), w.onerror = (g) => p(new Error("SL1 encode worker: " + ((g == null ? void 0 : g.message) || "failed"))), w.onmessage = ({ data: g }) => {
|
|
117
|
-
if (!f) {
|
|
118
|
-
if (g.progress != null) {
|
|
119
|
-
a[y] = g.progress, i == null || i(a.reduce((b, $) => b + $, 0), e.length);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
g.indices.forEach((b, $) => {
|
|
123
|
-
n[b] = g.pngs[$];
|
|
124
|
-
}), w.terminate(), ++l === o && s(n);
|
|
125
|
-
}
|
|
126
|
-
}, w.postMessage({ indices: _, paths: m, params: t });
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
async function q({ layers: e, params: t, stats: u, jobName: o = "plate", timestamp: i, makeCanvas: s, onProgress: r, scene: n = null, makeWorker: a = null, workerCount: l = 0 }) {
|
|
131
|
-
const f = s ?? (typeof OffscreenCanvas < "u" ? (h, d) => new OffscreenCanvas(h, d) : null), c = O(t), p = {}, y = a && typeof Worker < "u" && e.length > 1 ? {
|
|
132
|
-
makeWorker: a,
|
|
133
|
-
workerCount: Math.max(1, Math.min(l > 0 ? l : 4, e.length))
|
|
134
|
-
} : null;
|
|
135
|
-
if (!y && !f) throw new Error("SL1 export needs a canvas (OffscreenCanvas or an injected factory)");
|
|
136
|
-
const _ = () => performance.now(), m = { canvas: 0, clear: 0, draw: 0, encode: 0, read: 0 }, w = (h, d) => {
|
|
137
|
-
const S = _();
|
|
138
|
-
return m[h] += S - d, S;
|
|
139
|
-
};
|
|
140
|
-
let g = 0, b = 0;
|
|
141
|
-
const $ = async (h) => {
|
|
142
|
-
let d = _();
|
|
143
|
-
const S = f(c.px, c.py), v = S.getContext("2d");
|
|
144
|
-
d = w("canvas", d), v.fillStyle = "#000", v.fillRect(0, 0, c.px, c.py), d = w("clear", d), v.fillStyle = "#fff", b += k(v, e[h].paths, c), d = w("draw", d);
|
|
145
|
-
const B = await S.convertToBlob({ type: "image/png" });
|
|
146
|
-
d = w("encode", d);
|
|
147
|
-
const U = new Uint8Array(await B.arrayBuffer());
|
|
148
|
-
return w("read", d), g += U.length, U;
|
|
149
|
-
}, E = _();
|
|
150
|
-
if (y) {
|
|
151
|
-
const h = await H({ layers: e, params: t, onProgress: r, ...y });
|
|
152
|
-
for (let d = 0; d < e.length; d++)
|
|
153
|
-
p[L(o, d)] = [h[d], { level: 0 }], g += h[d].length;
|
|
154
|
-
} else
|
|
155
|
-
for (let h = 0; h < e.length; h++)
|
|
156
|
-
p[L(o, h)] = [await $(h), { level: 0 }], h & 31 || r == null || r(h, e.length);
|
|
157
|
-
const N = _();
|
|
158
|
-
p["config.ini"] = R(X({ params: t, stats: u, jobName: o, timestamp: i })), p[Y] = [z(e), { level: 6 }], n && (p[D] = [j(n), { level: 6 }]);
|
|
159
|
-
const A = _(), M = T(p), x = (h) => h.toFixed(0);
|
|
160
|
-
return C.info(`[vp-prof] sl1 build: ${e.length} layers ${c.px}x${c.py},` + (y ? ` raster ${x(N - E)}ms (${y.workerCount} workers),` : ` ${b} loops, raster ${x(N - E)}ms (canvas ${x(m.canvas)} + clear ${x(m.clear)} + draw ${x(m.draw)} + encode ${x(m.encode)} + read ${x(m.read)}),`) + ` sidecar ${x(A - N)}ms, zip ${x(_() - A)}ms -> ${(M.byteLength / 1e6).toFixed(1)}MB (png ${(g / 1e6).toFixed(1)}MB)`), M;
|
|
161
|
-
}
|
|
162
|
-
export {
|
|
163
|
-
D as S,
|
|
164
|
-
Y as a,
|
|
165
|
-
Z as b,
|
|
166
|
-
k as d,
|
|
167
|
-
C as l,
|
|
168
|
-
q as m,
|
|
169
|
-
O as s
|
|
170
|
-
};
|