three-slicer-viewer 0.3.1 → 0.3.2

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.
@@ -0,0 +1,196 @@
1
+ import * as P from "three";
2
+ import { OBJLoader as k } from "three/examples/jsm/loaders/OBJLoader.js";
3
+ import { PLYLoader as x } from "three/examples/jsm/loaders/PLYLoader.js";
4
+ import { AMFLoader as S } from "three/examples/jsm/loaders/AMFLoader.js";
5
+ import { p as M } from "./parse_3mf-BZISF3eW.js";
6
+ import { makeParse3mfWorker as v } from "./make_worker.js";
7
+ const _ = 80, y = 84, B = 50, D = (t) => y + t * B;
8
+ let d = null, h = !1, W = 0;
9
+ const w = /* @__PURE__ */ new Map();
10
+ function $() {
11
+ if (h || typeof Worker > "u") return null;
12
+ if (d) return d;
13
+ try {
14
+ d = v(), d.onmessage = (t) => {
15
+ const { id: e, objects: s, project: r, error: n } = t.data || {}, c = w.get(e);
16
+ c && (w.delete(e), n ? c.reject(new Error(n)) : c.resolve({ objects: s, project: r }));
17
+ }, d.onerror = () => {
18
+ h = !0;
19
+ for (const [, t] of w) t.reject(new Error("3MF parse worker failed"));
20
+ w.clear(), d = null;
21
+ };
22
+ } catch {
23
+ h = !0, d = null;
24
+ }
25
+ return d;
26
+ }
27
+ async function b(t, e) {
28
+ const s = $();
29
+ if (!s) return M(t, e);
30
+ try {
31
+ const r = ++W, n = new Promise((c, i) => w.set(r, { resolve: c, reject: i }));
32
+ return s.postMessage({ id: r, buffer: t, baseName: e }), await n;
33
+ } catch {
34
+ return M(t, e);
35
+ }
36
+ }
37
+ const T = ["stl", "obj", "3mf", "amf", "ply"], X = ["gcode", "gco", "g"], A = /* @__PURE__ */ new Map();
38
+ function H(t, e) {
39
+ for (const s of (Array.isArray(t) ? t : String(t).split(",")).map((r) => r.trim().toLowerCase()))
40
+ A.set(s, e), T.includes(s) || T.push(s);
41
+ }
42
+ function C(t) {
43
+ const e = t.lastIndexOf(".");
44
+ return e < 0 ? "" : t.slice(e + 1).toLowerCase();
45
+ }
46
+ function O(t) {
47
+ const e = new DataView(t);
48
+ if (t.byteLength >= y) {
49
+ const i = e.getUint32(_, !0);
50
+ if (t.byteLength === D(i)) {
51
+ const l = new Float32Array(i * 9);
52
+ let f = y, u = 0;
53
+ for (let o = 0; o < i; o++) {
54
+ f += 12;
55
+ for (let a = 0; a < 3; a++)
56
+ l[u++] = e.getFloat32(f, !0), l[u++] = e.getFloat32(f + 4, !0), l[u++] = e.getFloat32(f + 8, !0), f += 12;
57
+ f += 2;
58
+ }
59
+ return l;
60
+ }
61
+ }
62
+ const s = new TextDecoder().decode(t), r = /vertex\s+([-\d.eE+]+)\s+([-\d.eE+]+)\s+([-\d.eE+]+)/g, n = [];
63
+ let c;
64
+ for (; c = r.exec(s); ) n.push(+c[1], +c[2], +c[3]);
65
+ return n.length < 9 ? null : new Float32Array(n);
66
+ }
67
+ function j(t, e) {
68
+ const s = t?.attributes?.position;
69
+ if (!s || s.count < 3) return null;
70
+ const r = t.index, n = new P.Vector3(), c = Math.floor((r ? r.count : s.count) / 3), i = new Float32Array(c * 9);
71
+ let l = 0;
72
+ const f = (u) => {
73
+ n.fromBufferAttribute(s, u), e && n.applyMatrix4(e), i[l++] = n.x, i[l++] = n.y, i[l++] = n.z;
74
+ };
75
+ if (r)
76
+ for (let u = 0; u < c * 3; u++) f(r.getX(u));
77
+ else
78
+ for (let u = 0; u < c * 3; u++) f(u);
79
+ return i;
80
+ }
81
+ function F(t) {
82
+ t.updateMatrixWorld(!0);
83
+ const e = [];
84
+ return t.traverse((s) => {
85
+ s.isMesh && s.geometry && e.push({ geometry: s.geometry, matrix: s.matrixWorld });
86
+ }), e;
87
+ }
88
+ function L(t, e, s) {
89
+ const r = e.map((l) => j(l.geometry, l.matrix)).filter(Boolean);
90
+ if (!r.length) return [];
91
+ if (s && r.length > 1)
92
+ return r.map((l, f) => ({ name: `${t}#${f + 1}`, modelPos: l }));
93
+ if (r.length === 1) return [{ name: t, modelPos: r[0] }];
94
+ let n = 0;
95
+ for (const l of r) n += l.length;
96
+ const c = new Float32Array(n);
97
+ let i = 0;
98
+ for (const l of r)
99
+ c.set(l, i), i += l.length;
100
+ return [{ name: t, modelPos: c }];
101
+ }
102
+ async function V(t, e) {
103
+ const s = C(t);
104
+ switch (s) {
105
+ case "stl": {
106
+ const r = O(e);
107
+ if (!r) throw new Error("Failed to parse STL");
108
+ return [{ name: t, modelPos: r }];
109
+ }
110
+ case "obj": {
111
+ const r = new k().parse(new TextDecoder().decode(e));
112
+ return L(t, F(r), !1);
113
+ }
114
+ case "ply": {
115
+ const r = new x().parse(e), n = j(r, null);
116
+ if (!n) throw new Error("No PLY geometry");
117
+ return [{ name: t, modelPos: n }];
118
+ }
119
+ case "3mf": {
120
+ const { objects: r, project: n } = await b(e, t), c = r.map((i) => ({ name: i.name, modelPos: i.tris, objectid: i.objectid, paint: i.paint, bbox: i.bbox, project: n }));
121
+ if (!c.length && n.gcodePlates) return [{ name: t, gcodePlates: n.gcodePlates, project: n }];
122
+ if (!c.length) throw new Error("No mesh in 3MF");
123
+ return c;
124
+ }
125
+ case "amf": {
126
+ const r = new S().parse(e), n = L(t, F(r), !0);
127
+ if (!n.length) throw new Error("No mesh in AMF");
128
+ return n;
129
+ }
130
+ default: {
131
+ const r = A.get(s);
132
+ if (!r) throw new Error(`Unsupported format: .${s}`);
133
+ const n = await r(e, t);
134
+ if (!n?.length) throw new Error(`No mesh in .${s}`);
135
+ return n;
136
+ }
137
+ }
138
+ }
139
+ function q(t) {
140
+ return R(t)?.map((e) => I(t, e)) ?? null;
141
+ }
142
+ function I(t, e) {
143
+ const s = new Float32Array(e.length * 9);
144
+ let r = 0;
145
+ for (const n of e) {
146
+ const c = n * 9;
147
+ for (let i = 0; i < 9; i++) s[r++] = t[c + i];
148
+ }
149
+ return s;
150
+ }
151
+ function R(t) {
152
+ const e = Math.floor(t.length / 9);
153
+ if (e < 2) return null;
154
+ const s = 1e4, r = /* @__PURE__ */ new Map(), n = new Int32Array(e * 3);
155
+ for (let o = 0; o < e; o++)
156
+ for (let a = 0; a < 3; a++) {
157
+ const p = o * 9 + a * 3, m = `${Math.round(t[p] * s)},${Math.round(t[p + 1] * s)},${Math.round(t[p + 2] * s)}`;
158
+ let g = r.get(m);
159
+ g === void 0 && (g = r.size, r.set(m, g)), n[o * 3 + a] = g;
160
+ }
161
+ const c = new Int32Array(e);
162
+ for (let o = 0; o < e; o++) c[o] = o;
163
+ const i = (o) => {
164
+ for (; c[o] !== o; )
165
+ c[o] = c[c[o]], o = c[o];
166
+ return o;
167
+ }, l = (o, a) => {
168
+ o = i(o), a = i(a), o !== a && (c[a] = o);
169
+ }, f = /* @__PURE__ */ new Map();
170
+ for (let o = 0; o < e; o++)
171
+ for (let a = 0; a < 3; a++) {
172
+ const p = n[o * 3 + a], m = n[o * 3 + (a + 1) % 3], g = p < m ? p * 4294967296 + m : m * 4294967296 + p, E = f.get(g);
173
+ E === void 0 ? f.set(g, o) : l(o, E);
174
+ }
175
+ const u = /* @__PURE__ */ new Map();
176
+ for (let o = 0; o < e; o++) {
177
+ const a = i(o);
178
+ let p = u.get(a);
179
+ p || (p = [], u.set(a, p)), p.push(o);
180
+ }
181
+ return u.size < 2 ? null : [...u.values()].sort((o, a) => a.length - o.length);
182
+ }
183
+ export {
184
+ X as G,
185
+ _ as S,
186
+ y as a,
187
+ B as b,
188
+ T as c,
189
+ R as d,
190
+ I as e,
191
+ C as f,
192
+ q as g,
193
+ V as l,
194
+ H as r,
195
+ D as s
196
+ };
@@ -2,13 +2,16 @@ import "three";
2
2
  import "three/examples/jsm/loaders/OBJLoader.js";
3
3
  import "three/examples/jsm/loaders/PLYLoader.js";
4
4
  import "three/examples/jsm/loaders/AMFLoader.js";
5
- import "./parse_3mf-jEUAw8JM.js";
5
+ import "./parse_3mf-BZISF3eW.js";
6
6
  import "./make_worker.js";
7
- import { c as a, f as d, l, r as n, d as f } from "./model_loaders-aHV5ix50.js";
7
+ import { G as m, c as n, e as l, f as d, l as E, r as c, d as f, g as C } from "./model_loaders-DxlFNFOu.js";
8
8
  export {
9
- a as SUPPORTED_EXT,
9
+ m as GCODE_EXTS,
10
+ n as SUPPORTED_EXT,
11
+ l as facetPositions,
10
12
  d as fileExt,
11
- l as loadModel,
12
- n as registerLoader,
13
- f as splitConnectedComponents
13
+ E as loadModel,
14
+ c as registerLoader,
15
+ f as splitComponentFacets,
16
+ C as splitConnectedComponents
14
17
  };
@@ -0,0 +1,327 @@
1
+ import { unzip as Y, unzipSync as H } from "three/examples/jsm/libs/fflate.module.js";
2
+ import { S as W } from "./viewer_defaults-B7UUZ582.js";
3
+ function q(t) {
4
+ return new Promise((o) => {
5
+ let s = !1;
6
+ const e = (r) => {
7
+ s || (s = !0, o(r));
8
+ };
9
+ try {
10
+ Y(t, (r, i) => e(r ? H(t) : i));
11
+ } catch {
12
+ e(H(t));
13
+ }
14
+ });
15
+ }
16
+ const L = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0];
17
+ function K(t, o) {
18
+ const s = new Array(12);
19
+ for (let e = 0; e < 4; e++)
20
+ for (let r = 0; r < 3; r++)
21
+ s[e * 3 + r] = t[e * 3] * o[r] + t[e * 3 + 1] * o[3 + r] + t[e * 3 + 2] * o[6 + r] + (e === 3 ? o[9 + r] : 0);
22
+ return s;
23
+ }
24
+ function U(t) {
25
+ if (!t) return L;
26
+ const o = t.trim().split(/\s+/).map(Number);
27
+ return o.length === 12 && o.every(Number.isFinite) ? o : L;
28
+ }
29
+ const x = {};
30
+ function f(t, o) {
31
+ const e = (x[o] || (x[o] = new RegExp(`\\b${o}\\s*=\\s*"([^"]*)"`))).exec(t);
32
+ return e ? e[1] : null;
33
+ }
34
+ const B = /<vertex\s+x="([^"]*)"\s+y="([^"]*)"\s+z="([^"]*)"/g, D = /<triangle\s+v1="([^"]*)"\s+v2="([^"]*)"\s+v3="([^"]*)"([^>]*)/g, C = [
35
+ ["paint_color", "color"],
36
+ // multi-material: state 1..16 == Extruder1..16
37
+ ["paint_supports", "supports"],
38
+ // support enforcer/blocker: states 1 and 2
39
+ ["paint_seam", "seam"],
40
+ // unsupported by the kernel — collected for the warning only
41
+ ["paint_fuzzy_skin", "fuzzy"]
42
+ // ditto
43
+ ];
44
+ function G() {
45
+ return { color: /* @__PURE__ */ new Map(), supports: /* @__PURE__ */ new Map(), seam: /* @__PURE__ */ new Map(), fuzzy: /* @__PURE__ */ new Map() };
46
+ }
47
+ function Q(t) {
48
+ return !t || C.every(([, o]) => t[o].size === 0);
49
+ }
50
+ function J(t, o, s) {
51
+ for (const [e, r] of C) {
52
+ if (!t.includes(e)) continue;
53
+ const i = f(t, e);
54
+ i && s[r].set(o, i);
55
+ }
56
+ }
57
+ function Z(t) {
58
+ const o = [];
59
+ B.lastIndex = 0;
60
+ let s;
61
+ for (; s = B.exec(t); ) o.push(+s[1], +s[2], +s[3]);
62
+ if (!o.length)
63
+ for (const i of t.match(/<vertex\b[^>]*>/g) || []) o.push(+f(i, "x"), +f(i, "y"), +f(i, "z"));
64
+ if (o.length < 9) return null;
65
+ const e = [], r = G();
66
+ for (D.lastIndex = 0; s = D.exec(t); ) {
67
+ const i = e.length / 3;
68
+ e.push(+s[1], +s[2], +s[3]), s[4].length > 2 && J(s[4], i, r);
69
+ }
70
+ if (!e.length)
71
+ for (const i of t.match(/<triangle\b[^>]*>/g) || []) {
72
+ const p = e.length / 3;
73
+ e.push(+f(i, "v1"), +f(i, "v2"), +f(i, "v3")), J(i, p, r);
74
+ }
75
+ return e.length ? { verts: o, tris: e, paint: r } : null;
76
+ }
77
+ function tt(t) {
78
+ const o = /* @__PURE__ */ new Map(), s = /<object\b([^>]*)>([\s\S]*?)<\/object>/g;
79
+ let e;
80
+ for (; e = s.exec(t); ) {
81
+ const p = f(e[1], "id");
82
+ if (!p) continue;
83
+ const u = e[2], n = [];
84
+ for (const a of u.match(/<component\b[^>]*>/g) || []) {
85
+ const c = f(a, "objectid");
86
+ c && n.push({ objectid: c, path: f(a, "p:path") || f(a, "path"), transform: U(f(a, "transform")) });
87
+ }
88
+ o.set(p, n.length ? { components: n } : { mesh: Z(u) });
89
+ }
90
+ const r = [], i = /<build\b[^>]*>([\s\S]*?)<\/build>/.exec(t);
91
+ if (i)
92
+ for (const p of i[1].match(/<item\b[^>]*>/g) || []) {
93
+ const u = f(p, "objectid");
94
+ u && r.push({ objectid: u, path: f(p, "p:path") || f(p, "path"), transform: U(f(p, "transform")) });
95
+ }
96
+ return { objects: o, items: r };
97
+ }
98
+ function k(t) {
99
+ const o = String(t).replace(/^\/+/, "");
100
+ return o.includes("%") ? decodeURIComponent(o) : o;
101
+ }
102
+ function R(t) {
103
+ const o = {};
104
+ for (const s of t.match(/<metadata\b[^>]*>/g) || []) {
105
+ const e = f(s, "key");
106
+ e && (o[e] = f(s, "value") ?? "");
107
+ }
108
+ return o;
109
+ }
110
+ function et(t) {
111
+ const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), e = /<object\b([^>]*)>([\s\S]*?)<\/object>/g;
112
+ let r;
113
+ for (; r = e.exec(t); ) {
114
+ const u = f(r[1], "id");
115
+ if (u) {
116
+ const n = r[2];
117
+ o.set(u, R(n.replace(/<(?:part|volume)\b[\s\S]*?<\/(?:part|volume)>/g, "")));
118
+ const a = [];
119
+ for (const c of n.match(/<volume\b[\s\S]*?<\/volume>/g) || []) {
120
+ const d = R(c).volume_type, y = d === "SupportBlocker" ? "blocker" : d === "SupportEnforcer" ? "enforcer" : null, _ = Number(f(c, "firstid")), S = Number(f(c, "lastid"));
121
+ y && Number.isInteger(_) && Number.isInteger(S) && _ >= 0 && S >= _ && a.push({ firstTriangle: _, lastTriangle: S, kind: y });
122
+ }
123
+ a.length && s.set(u, a);
124
+ }
125
+ }
126
+ const i = [], p = /<plate\b[^>]*>([\s\S]*?)<\/plate>/g;
127
+ for (; r = p.exec(t); ) {
128
+ const u = r[1], n = R(u.replace(/<model_instance\b[\s\S]*?<\/model_instance>/g, "")), a = [];
129
+ for (const c of u.match(/<model_instance\b[\s\S]*?<\/model_instance>/g) || []) {
130
+ const d = R(c).object_id;
131
+ d && a.push(d);
132
+ }
133
+ i.push({ index: Math.max(0, (Number(n.plater_id) || i.length + 1) - 1), objectIds: a, gcodeFile: n.gcode_file || null });
134
+ }
135
+ return { objects: o, plates: i, volumes: s };
136
+ }
137
+ const nt = Object.freeze({
138
+ manualSupportPoints: "prepared-roundtrip",
139
+ drainHoles: "preserved-unsupported",
140
+ modifierVolumes: "prepared-mask-filtering",
141
+ uiEditing: "unavailable"
142
+ });
143
+ function V(t, o, s, e, r) {
144
+ const i = /* @__PURE__ */ new Map();
145
+ if (!t?.trim()) return i;
146
+ const p = t.trim().split(/\r?\n/), u = new RegExp(`^${o}_format_version=(\\d+)$`).exec(p[0]), n = u ? Number(u[1]) : 0;
147
+ for (const a of p.slice(u ? 1 : 0)) {
148
+ const c = /^object_id=(\d+)\|(.*)$/.exec(a);
149
+ if (!c || i.has(Number(c?.[1]))) continue;
150
+ const d = Number(c[1]), y = c[2].trim() ? c[2].trim().split(/\s+/).map(Number) : [], _ = s(n);
151
+ if (!_ || y.length % _ !== 0 || y.some((l) => !Number.isFinite(l))) {
152
+ e.push({ code: o === "support_points" ? "SLA_SUPPORT_POINT_COUNT" : "SLA_DRAIN_HOLE_COUNT", object: d }), i.set(d, []);
153
+ continue;
154
+ }
155
+ const S = [];
156
+ for (let l = 0; l < y.length; l += _) S.push(r(y.slice(l, l + _), n));
157
+ i.set(d, S);
158
+ }
159
+ return i;
160
+ }
161
+ function X(t, o) {
162
+ const [s, e, r] = o;
163
+ return [s * t[0] + e * t[3] + r * t[6] + t[9], s * t[1] + e * t[4] + r * t[7] + t[10], s * t[2] + e * t[5] + r * t[8] + t[11]];
164
+ }
165
+ function ot(t, o) {
166
+ const [s, e, r] = o, i = [s * t[0] + e * t[3] + r * t[6], s * t[1] + e * t[4] + r * t[7], s * t[2] + e * t[5] + r * t[8]], p = Math.hypot(...i);
167
+ return p ? i.map((u) => u / p) : i;
168
+ }
169
+ function st(t, o) {
170
+ const s = (n) => {
171
+ const a = t.get(n);
172
+ return a ? o.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: { ...nt }, issues: [], supportPoints: /* @__PURE__ */ new Map(), drainHoles: /* @__PURE__ */ new Map() },
184
+ viewerSettings: null,
185
+ // Metadata/three_slicer_settings.json — this package's own member (write_3mf.js)
186
+ plateSettings: null,
187
+ // ...its two halves: global viewer knobs, and per-plate overrides keyed by plate index
188
+ plateCount: null,
189
+ // ...and the plate count it was saved with (empty plates hold no <plate> record)
190
+ gcodePlates: null
191
+ // a .gcode.3mf's sliced plates: [{index, gcode}] (write_3mf.js writeGcode3MF), else null
192
+ }, r = s("Metadata/project_settings.config");
193
+ if (r)
194
+ try {
195
+ e.settings = JSON.parse(r);
196
+ } catch {
197
+ e.settings = null;
198
+ }
199
+ const i = s("Metadata/three_slicer_settings.json");
200
+ if (i) {
201
+ let n = null;
202
+ try {
203
+ n = JSON.parse(i);
204
+ } catch {
205
+ n = null;
206
+ }
207
+ const a = (c) => c && typeof c == "object" && !Array.isArray(c);
208
+ if (a(n)) {
209
+ a(n.viewer) && Object.keys(n.viewer).length && (e.viewerSettings = n.viewer);
210
+ let c = [];
211
+ a(n.plates) && (c = Object.entries(n.plates));
212
+ const d = c.filter(([y, _]) => /^\d+$/.test(y) && a(_) && Object.keys(_).length);
213
+ d.length && (e.plateSettings = Object.fromEntries(d.map(([y, _]) => [Number(y), _]))), Number.isInteger(n.plateCount) && n.plateCount >= 1 && (e.plateCount = n.plateCount);
214
+ }
215
+ }
216
+ const p = s("Metadata/model_settings.config");
217
+ if (p) {
218
+ const n = et(p);
219
+ e.objectMeta = n.objects, e.plates = n.plates, e.volumeMeta = n.volumes;
220
+ }
221
+ const u = e.plates.map((n) => ({ index: n.index, gcode: n.gcodeFile && s(k(n.gcodeFile)) })).filter((n) => n.gcode);
222
+ return u.length && (e.gcodePlates = u), e.sla.supportPoints = V(
223
+ s("Metadata/Slic3r_PE_sla_support_points.txt"),
224
+ "support_points",
225
+ (n) => n === 0 ? 3 : n === 1 ? 5 : 0,
226
+ e.sla.issues,
227
+ (n, a) => ({
228
+ position: n.slice(0, 3),
229
+ radius: a === 0 ? W : n[3],
230
+ type: a === 0 || n[4] === 2 ? "manual" : n[4] === 1 ? "island" : "slope"
231
+ })
232
+ ), e.sla.drainHoles = V(
233
+ s("Metadata/Slic3r_PE_sla_drain_holes.txt"),
234
+ "drain_holes",
235
+ (n) => n === 1 ? 8 : 0,
236
+ e.sla.issues,
237
+ (n) => {
238
+ const a = Math.hypot(n[3], n[4], n[5]), c = a ? n.slice(3, 6).map((d) => d / a) : n.slice(3, 6);
239
+ return { position: n.slice(0, 3).map((d, y) => d + c[y]), normal: c, radius: n[6], height: n[7] - 1 };
240
+ }
241
+ ), e.hasLayerHeightProfile = !!s("Metadata/layer_heights_profile.txt")?.trim(), e.hasCustomGcodePerLayer = !!s("Metadata/custom_gcode_per_layer.xml")?.trim(), e;
242
+ }
243
+ async function ct(t, o = "model") {
244
+ const s = ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t), e = await q(s), r = /* @__PURE__ */ new Map();
245
+ for (const l of Object.keys(e)) r.set(k(l), e[l]);
246
+ const i = new TextDecoder(), p = /* @__PURE__ */ new Map(), u = (l) => {
247
+ const w = k(l);
248
+ if (p.has(w)) return p.get(w);
249
+ const m = r.get(w), M = m ? tt(i.decode(m)) : null;
250
+ return p.set(w, M), M;
251
+ };
252
+ let n = "3D/3dmodel.model";
253
+ const a = r.get("_rels/.rels");
254
+ if (a) {
255
+ for (const l of i.decode(a).match(/<Relationship\b[^>]*>/g) || [])
256
+ if ((f(l, "Type") || "").endsWith("/3dmodel")) {
257
+ n = k(f(l, "Target"));
258
+ break;
259
+ }
260
+ }
261
+ const c = st(r, i), d = u(n);
262
+ if (!d && c.gcodePlates) return { objects: [], project: c };
263
+ if (!d) throw new Error(`3MF root model not found: ${n}`);
264
+ const y = [], _ = (l, w, m, M, P, N) => {
265
+ if (N > 16) return;
266
+ const T = u(w)?.objects.get(l);
267
+ if (!T) return;
268
+ if (T.components) {
269
+ for (const j of T.components) _(j.objectid, j.path || w, K(j.transform, m), M, P, N + 1);
270
+ return;
271
+ }
272
+ if (!T.mesh) return;
273
+ const { verts: E, tris: I, paint: v } = T.mesh, z = M.length / 9;
274
+ for (let j = 0; j < I.length; j++) {
275
+ const h = I[j] * 3, b = E[h], g = E[h + 1], A = E[h + 2];
276
+ M.push(
277
+ b * m[0] + g * m[3] + A * m[6] + m[9],
278
+ b * m[1] + g * m[4] + A * m[7] + m[10],
279
+ b * m[2] + g * m[5] + A * m[8] + m[11]
280
+ );
281
+ }
282
+ if (v) for (const [, j] of C)
283
+ for (const [h, b] of v[j]) P[j].set(z + h, b);
284
+ }, S = d.items.length ? d.items : [...d.objects.keys()].filter((l) => d.objects.get(l).mesh).map((l) => ({ objectid: l, path: n, transform: L }));
285
+ return S.forEach((l, w) => {
286
+ const m = [], M = G();
287
+ if (_(l.objectid, l.path || n, l.transform, m, M, 0), m.length < 9) return;
288
+ let P = new Float32Array(m);
289
+ const N = [], O = c.volumeMeta.get(l.objectid) || [];
290
+ if (O.length) {
291
+ const h = /* @__PURE__ */ new Set();
292
+ for (let b = 0; b < O.length; b++) {
293
+ const g = O[b], A = g.firstTriangle * 9, $ = Math.min(m.length, (g.lastTriangle + 1) * 9);
294
+ if (!(A >= $)) {
295
+ for (let F = g.firstTriangle; F <= g.lastTriangle; F++) h.add(F);
296
+ N.push({ id: `${l.objectid}:modifier:${b}`, kind: g.kind, tris: new Float32Array(m.slice(A, $)) });
297
+ }
298
+ }
299
+ if (h.size) {
300
+ const b = [];
301
+ for (let g = 0; g < m.length / 9; g++) h.has(g) || b.push(...m.slice(g * 9, g * 9 + 9));
302
+ P = new Float32Array(b);
303
+ }
304
+ }
305
+ const T = (c.sla.supportPoints.get(w + 1) || []).map((h) => ({ ...h, position: X(l.transform, h.position) })), E = (c.sla.drainHoles.get(w + 1) || []).map((h) => ({
306
+ ...h,
307
+ position: X(l.transform, h.position),
308
+ normal: ot(l.transform, h.normal)
309
+ }));
310
+ let I = 1 / 0, v = 1 / 0, z = -1 / 0, j = -1 / 0;
311
+ for (let h = 0; h < P.length; h += 3) {
312
+ const b = P[h], g = P[h + 1];
313
+ b < I && (I = b), b > z && (z = b), g < v && (v = g), g > j && (j = g);
314
+ }
315
+ y.push({
316
+ name: S.length > 1 ? `${o}#${w + 1}` : o,
317
+ tris: P,
318
+ objectid: l.objectid,
319
+ paint: Q(M) ? null : M,
320
+ sla: { supportPoints: T, drainHoles: E, modifierVolumes: N },
321
+ bbox: { minX: I, minY: v, maxX: z, maxY: j }
322
+ });
323
+ }), { objects: y, project: c };
324
+ }
325
+ export {
326
+ ct as p
327
+ };
@@ -1,4 +1,4 @@
1
- import { p as f } from "./parse_3mf-jEUAw8JM.js";
1
+ import { p as f } from "./parse_3mf-BZISF3eW.js";
2
2
  self.onmessage = async (a) => {
3
3
  const { id: s, buffer: r, baseName: t } = a.data || {};
4
4
  try {