three-slicer-viewer 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,188 @@
1
+ import * as x from "three";
2
+ import { OBJLoader as S } 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 T } from "./parse_3mf-jEUAw8JM.js";
6
+ import { makeParse3mfWorker as B } from "./make_worker.js";
7
+ const W = 80, M = 84, _ = 50, $ = (t) => M + t * _;
8
+ let g = null, E = !1, b = 0;
9
+ const h = /* @__PURE__ */ new Map();
10
+ function D() {
11
+ if (E || typeof Worker > "u") return null;
12
+ if (g) return g;
13
+ try {
14
+ g = B(), g.onmessage = (t) => {
15
+ const { id: r, objects: s, project: o, error: n } = t.data || {}, i = h.get(r);
16
+ i && (h.delete(r), n ? i.reject(new Error(n)) : i.resolve({ objects: s, project: o }));
17
+ }, g.onerror = () => {
18
+ E = !0;
19
+ for (const [, t] of h) t.reject(new Error("3MF parse worker failed"));
20
+ h.clear(), g = null;
21
+ };
22
+ } catch {
23
+ E = !0, g = null;
24
+ }
25
+ return g;
26
+ }
27
+ async function I(t, r) {
28
+ const s = D();
29
+ if (!s) return T(t, r);
30
+ try {
31
+ const o = ++b, n = new Promise((i, c) => h.set(o, { resolve: i, reject: c }));
32
+ return s.postMessage({ id: o, buffer: t, baseName: r }), await n;
33
+ } catch {
34
+ return T(t, r);
35
+ }
36
+ }
37
+ const L = ["stl", "obj", "3mf", "amf", "ply"], j = /* @__PURE__ */ new Map();
38
+ function H(t, r) {
39
+ for (const s of (Array.isArray(t) ? t : String(t).split(",")).map((o) => o.trim().toLowerCase()))
40
+ j.set(s, r), L.includes(s) || L.push(s);
41
+ }
42
+ function O(t) {
43
+ const r = t.lastIndexOf(".");
44
+ return r < 0 ? "" : t.slice(r + 1).toLowerCase();
45
+ }
46
+ function R(t) {
47
+ const r = new DataView(t);
48
+ if (t.byteLength >= M) {
49
+ const c = r.getUint32(W, !0);
50
+ if (t.byteLength === $(c)) {
51
+ const l = new Float32Array(c * 9);
52
+ let f = M, u = 0;
53
+ for (let y = 0; y < c; y++) {
54
+ f += 12;
55
+ for (let e = 0; e < 3; e++)
56
+ l[u++] = r.getFloat32(f, !0), l[u++] = r.getFloat32(f + 4, !0), l[u++] = r.getFloat32(f + 8, !0), f += 12;
57
+ f += 2;
58
+ }
59
+ return l;
60
+ }
61
+ }
62
+ const s = new TextDecoder().decode(t), o = /vertex\s+([-\d.eE+]+)\s+([-\d.eE+]+)\s+([-\d.eE+]+)/g, n = [];
63
+ let i;
64
+ for (; i = o.exec(s); ) n.push(+i[1], +i[2], +i[3]);
65
+ return n.length < 9 ? null : new Float32Array(n);
66
+ }
67
+ function k(t, r) {
68
+ const s = t?.attributes?.position;
69
+ if (!s || s.count < 3) return null;
70
+ const o = t.index, n = new x.Vector3(), i = Math.floor((o ? o.count : s.count) / 3), c = new Float32Array(i * 9);
71
+ let l = 0;
72
+ const f = (u) => {
73
+ n.fromBufferAttribute(s, u), r && n.applyMatrix4(r), c[l++] = n.x, c[l++] = n.y, c[l++] = n.z;
74
+ };
75
+ if (o)
76
+ for (let u = 0; u < i * 3; u++) f(o.getX(u));
77
+ else
78
+ for (let u = 0; u < i * 3; u++) f(u);
79
+ return c;
80
+ }
81
+ function A(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 F(t, r, s) {
89
+ const o = r.map((l) => k(l.geometry, l.matrix)).filter(Boolean);
90
+ if (!o.length) return [];
91
+ if (s && o.length > 1)
92
+ return o.map((l, f) => ({ name: `${t}#${f + 1}`, modelPos: l }));
93
+ if (o.length === 1) return [{ name: t, modelPos: o[0] }];
94
+ let n = 0;
95
+ for (const l of o) n += l.length;
96
+ const i = new Float32Array(n);
97
+ let c = 0;
98
+ for (const l of o)
99
+ i.set(l, c), c += l.length;
100
+ return [{ name: t, modelPos: i }];
101
+ }
102
+ async function V(t, r) {
103
+ const s = O(t);
104
+ switch (s) {
105
+ case "stl": {
106
+ const o = R(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 S().parse(new TextDecoder().decode(r));
112
+ return F(t, A(o), !1);
113
+ }
114
+ case "ply": {
115
+ const o = new v().parse(r), n = k(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 I(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 = F(t, A(o), !0);
126
+ if (!n.length) throw new Error("No mesh in AMF");
127
+ return n;
128
+ }
129
+ default: {
130
+ const o = j.get(s);
131
+ if (!o) throw new Error(`Unsupported format: .${s}`);
132
+ const n = await o(r, t);
133
+ if (!n?.length) throw new Error(`No mesh in .${s}`);
134
+ return n;
135
+ }
136
+ }
137
+ }
138
+ function X(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 a = 0; a < 3; a++) {
144
+ const p = e * 9 + a * 3, m = `${Math.round(t[p] * s)},${Math.round(t[p + 1] * s)},${Math.round(t[p + 2] * s)}`;
145
+ let d = o.get(m);
146
+ d === void 0 && (d = o.size, o.set(m, d)), n[e * 3 + a] = d;
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
+ }, l = (e, a) => {
155
+ e = c(e), a = c(a), e !== a && (i[a] = e);
156
+ }, f = /* @__PURE__ */ new Map();
157
+ for (let e = 0; e < r; e++)
158
+ for (let a = 0; a < 3; a++) {
159
+ const p = n[e * 3 + a], m = n[e * 3 + (a + 1) % 3], d = p < m ? p * 4294967296 + m : m * 4294967296 + p, w = f.get(d);
160
+ w === void 0 ? f.set(d, e) : l(e, w);
161
+ }
162
+ const u = /* @__PURE__ */ new Map();
163
+ for (let e = 0; e < r; e++) {
164
+ const a = c(e);
165
+ let p = u.get(a);
166
+ p || (p = [], u.set(a, p)), p.push(e);
167
+ }
168
+ return u.size < 2 ? null : [...u.values()].sort((e, a) => a.length - e.length).map((e) => {
169
+ const a = new Float32Array(e.length * 9);
170
+ let p = 0;
171
+ for (const m of e) {
172
+ const d = m * 9;
173
+ for (let w = 0; w < 9; w++) a[p++] = t[d + w];
174
+ }
175
+ return a;
176
+ });
177
+ }
178
+ export {
179
+ W as S,
180
+ M as a,
181
+ _ as b,
182
+ L as c,
183
+ X as d,
184
+ O as f,
185
+ V as l,
186
+ H as r,
187
+ $ as s
188
+ };
@@ -1,183 +1,14 @@
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-CQ5rAX6P.js";
6
- import { makeParse3mfWorker as W } from "./make_worker.js";
7
- let w = null, M = !1, $ = 0;
8
- const h = /* @__PURE__ */ new Map();
9
- function b() {
10
- if (M || typeof Worker > "u") return null;
11
- if (w) return w;
12
- try {
13
- w = W(), w.onmessage = (t) => {
14
- const { id: r, objects: s, project: o, error: n } = t.data || {}, i = h.get(r);
15
- i && (h.delete(r), n ? i.reject(new Error(n)) : i.resolve({ objects: s, project: o }));
16
- }, w.onerror = () => {
17
- M = !0;
18
- for (const [, t] of h) t.reject(new Error("3MF parse worker failed"));
19
- h.clear(), w = null;
20
- };
21
- } catch {
22
- M = !0, w = null;
23
- }
24
- return w;
25
- }
26
- async function B(t, r) {
27
- const s = b();
28
- if (!s) return E(t, r);
29
- try {
30
- const o = ++$, n = new Promise((i, c) => h.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 j = ["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), j.includes(s) || j.push(s);
40
- }
41
- function C(t) {
42
- const r = t.lastIndexOf(".");
43
- return r < 0 ? "" : t.slice(r + 1).toLowerCase();
44
- }
45
- function D(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 f = 84, u = 0;
52
- for (let y = 0; y < c; y++) {
53
- f += 12;
54
- for (let e = 0; e < 3; e++)
55
- a[u++] = r.getFloat32(f, !0), a[u++] = r.getFloat32(f + 4, !0), a[u++] = r.getFloat32(f + 8, !0), f += 12;
56
- f += 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
- const s = t?.attributes?.position;
68
- if (!s || s.count < 3) return null;
69
- const o = t.index, n = new L.Vector3(), i = Math.floor((o ? o.count : s.count) / 3), c = new Float32Array(i * 9);
70
- let a = 0;
71
- const f = (u) => {
72
- n.fromBufferAttribute(s, u), r && n.applyMatrix4(r), c[a++] = n.x, c[a++] = n.y, c[a++] = n.z;
73
- };
74
- if (o)
75
- for (let u = 0; u < i * 3; u++) f(o.getX(u));
76
- else
77
- for (let u = 0; u < i * 3; u++) f(u);
78
- return c;
79
- }
80
- function F(t) {
81
- t.updateMatrixWorld(!0);
82
- const r = [];
83
- return t.traverse((s) => {
84
- s.isMesh && s.geometry && r.push({ geometry: s.geometry, matrix: s.matrixWorld });
85
- }), r;
86
- }
87
- function k(t, r, s) {
88
- const o = r.map((a) => A(a.geometry, a.matrix)).filter(Boolean);
89
- if (!o.length) return [];
90
- if (s && o.length > 1)
91
- return o.map((a, f) => ({ name: `${t}#${f + 1}`, modelPos: a }));
92
- if (o.length === 1) return [{ name: t, modelPos: o[0] }];
93
- let n = 0;
94
- for (const a of o) n += a.length;
95
- const i = new Float32Array(n);
96
- let c = 0;
97
- for (const a of o)
98
- i.set(a, c), c += a.length;
99
- return [{ name: t, modelPos: i }];
100
- }
101
- async function U(t, r) {
102
- const s = C(t);
103
- switch (s) {
104
- case "stl": {
105
- const o = D(r);
106
- if (!o) throw new Error("Failed to parse STL");
107
- return [{ name: t, modelPos: o }];
108
- }
109
- case "obj": {
110
- const o = new T().parse(new TextDecoder().decode(r));
111
- return k(t, F(o), !1);
112
- }
113
- case "ply": {
114
- const o = new v().parse(r), n = A(o, null);
115
- if (!n) throw new Error("No PLY geometry");
116
- return [{ name: t, modelPos: n }];
117
- }
118
- case "3mf": {
119
- const { objects: o, project: n } = await B(r, t), i = o.map((c) => ({ name: c.name, modelPos: c.tris, objectid: c.objectid, paint: c.paint, bbox: c.bbox, project: n }));
120
- if (!i.length) throw new Error("No mesh in 3MF");
121
- return i;
122
- }
123
- case "amf": {
124
- const o = new P().parse(r), n = k(t, F(o), !0);
125
- if (!n.length) throw new Error("No mesh in AMF");
126
- return n;
127
- }
128
- default: {
129
- const o = x.get(s);
130
- if (!o) throw new Error(`Unsupported format: .${s}`);
131
- const n = await o(r, t);
132
- if (!n?.length) throw new Error(`No mesh in .${s}`);
133
- return n;
134
- }
135
- }
136
- }
137
- function V(t) {
138
- const r = Math.floor(t.length / 9);
139
- if (r < 2) return null;
140
- const s = 1e4, o = /* @__PURE__ */ new Map(), n = new Int32Array(r * 3);
141
- for (let e = 0; e < r; e++)
142
- for (let l = 0; l < 3; l++) {
143
- const p = e * 9 + l * 3, m = `${Math.round(t[p] * s)},${Math.round(t[p + 1] * s)},${Math.round(t[p + 2] * s)}`;
144
- let d = o.get(m);
145
- d === void 0 && (d = o.size, o.set(m, d)), n[e * 3 + l] = d;
146
- }
147
- const i = new Int32Array(r);
148
- for (let e = 0; e < r; e++) i[e] = e;
149
- const c = (e) => {
150
- for (; i[e] !== e; )
151
- i[e] = i[i[e]], e = i[e];
152
- return e;
153
- }, a = (e, l) => {
154
- e = c(e), l = c(l), e !== l && (i[l] = e);
155
- }, f = /* @__PURE__ */ new Map();
156
- for (let e = 0; e < r; e++)
157
- for (let l = 0; l < 3; l++) {
158
- const p = n[e * 3 + l], m = n[e * 3 + (l + 1) % 3], d = p < m ? p * 4294967296 + m : m * 4294967296 + p, g = f.get(d);
159
- g === void 0 ? f.set(d, e) : a(e, g);
160
- }
161
- const u = /* @__PURE__ */ new Map();
162
- for (let e = 0; e < r; e++) {
163
- const l = c(e);
164
- let p = u.get(l);
165
- p || (p = [], u.set(l, p)), p.push(e);
166
- }
167
- return u.size < 2 ? null : [...u.values()].sort((e, l) => l.length - e.length).map((e) => {
168
- const l = new Float32Array(e.length * 9);
169
- let p = 0;
170
- for (const m of e) {
171
- const d = m * 9;
172
- for (let g = 0; g < 9; g++) l[p++] = t[d + g];
173
- }
174
- return l;
175
- });
176
- }
1
+ import "three";
2
+ import "three/examples/jsm/loaders/OBJLoader.js";
3
+ import "three/examples/jsm/loaders/PLYLoader.js";
4
+ import "three/examples/jsm/loaders/AMFLoader.js";
5
+ import "./parse_3mf-jEUAw8JM.js";
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";
177
8
  export {
178
- j as SUPPORTED_EXT,
179
- C as fileExt,
180
- U as loadModel,
181
- R as registerLoader,
182
- V as splitConnectedComponents
9
+ a as SUPPORTED_EXT,
10
+ d as fileExt,
11
+ l as loadModel,
12
+ n as registerLoader,
13
+ f as splitConnectedComponents
183
14
  };
@@ -1,33 +1,34 @@
1
- import { unzip as Y, unzipSync as B } from "three/examples/jsm/libs/fflate.module.js";
2
- function W(t) {
1
+ import { unzip as Y, unzipSync as U } from "three/examples/jsm/libs/fflate.module.js";
2
+ import { S as W } from "./viewer_defaults-B7UUZ582.js";
3
+ function q(t) {
3
4
  return new Promise((n) => {
4
5
  let o = !1;
5
6
  const e = (r) => {
6
7
  o || (o = !0, n(r));
7
8
  };
8
9
  try {
9
- Y(t, (r, i) => e(r ? B(t) : i));
10
+ Y(t, (r, i) => e(r ? U(t) : i));
10
11
  } catch {
11
- e(B(t));
12
+ e(U(t));
12
13
  }
13
14
  });
14
15
  }
15
16
  const F = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0];
16
- function q(t, n) {
17
+ function K(t, n) {
17
18
  const o = new Array(12);
18
19
  for (let e = 0; e < 4; e++)
19
20
  for (let r = 0; r < 3; r++)
20
21
  o[e * 3 + r] = t[e * 3] * n[r] + t[e * 3 + 1] * n[3 + r] + t[e * 3 + 2] * n[6 + r] + (e === 3 ? n[9 + r] : 0);
21
22
  return o;
22
23
  }
23
- function C(t) {
24
+ function B(t) {
24
25
  if (!t) return F;
25
26
  const n = t.trim().split(/\s+/).map(Number);
26
27
  return n.length === 12 && n.every(Number.isFinite) ? n : F;
27
28
  }
28
- const U = {};
29
+ const C = {};
29
30
  function p(t, n) {
30
- const e = (U[n] || (U[n] = new RegExp(`\\b${n}\\s*=\\s*"([^"]*)"`))).exec(t);
31
+ const e = (C[n] || (C[n] = new RegExp(`\\b${n}\\s*=\\s*"([^"]*)"`))).exec(t);
31
32
  return e ? e[1] : null;
32
33
  }
33
34
  const D = /<vertex\s+x="([^"]*)"\s+y="([^"]*)"\s+z="([^"]*)"/g, V = /<triangle\s+v1="([^"]*)"\s+v2="([^"]*)"\s+v3="([^"]*)"([^>]*)/g, $ = [
@@ -43,7 +44,7 @@ const D = /<vertex\s+x="([^"]*)"\s+y="([^"]*)"\s+z="([^"]*)"/g, V = /<triangle\s
43
44
  function G() {
44
45
  return { color: /* @__PURE__ */ new Map(), supports: /* @__PURE__ */ new Map(), seam: /* @__PURE__ */ new Map(), fuzzy: /* @__PURE__ */ new Map() };
45
46
  }
46
- function K(t) {
47
+ function Q(t) {
47
48
  return !t || $.every(([, n]) => t[n].size === 0);
48
49
  }
49
50
  function x(t, n, o) {
@@ -53,7 +54,7 @@ function x(t, n, o) {
53
54
  i && o[r].set(n, i);
54
55
  }
55
56
  }
56
- function Q(t) {
57
+ function Z(t) {
57
58
  const n = [];
58
59
  D.lastIndex = 0;
59
60
  let o;
@@ -73,7 +74,7 @@ function Q(t) {
73
74
  }
74
75
  return e.length ? { verts: n, tris: e, paint: r } : null;
75
76
  }
76
- function Z(t) {
77
+ function tt(t) {
77
78
  const n = /* @__PURE__ */ new Map(), o = /<object\b([^>]*)>([\s\S]*?)<\/object>/g;
78
79
  let e;
79
80
  for (; e = o.exec(t); ) {
@@ -82,15 +83,15 @@ function Z(t) {
82
83
  const c = e[2], d = [];
83
84
  for (const f of c.match(/<component\b[^>]*>/g) || []) {
84
85
  const u = p(f, "objectid");
85
- u && d.push({ objectid: u, path: p(f, "p:path") || p(f, "path"), transform: C(p(f, "transform")) });
86
+ u && d.push({ objectid: u, path: p(f, "p:path") || p(f, "path"), transform: B(p(f, "transform")) });
86
87
  }
87
- n.set(s, d.length ? { components: d } : { mesh: Q(c) });
88
+ n.set(s, d.length ? { components: d } : { mesh: Z(c) });
88
89
  }
89
90
  const r = [], i = /<build\b[^>]*>([\s\S]*?)<\/build>/.exec(t);
90
91
  if (i)
91
92
  for (const s of i[1].match(/<item\b[^>]*>/g) || []) {
92
93
  const c = p(s, "objectid");
93
- c && r.push({ objectid: c, path: p(s, "p:path") || p(s, "path"), transform: C(p(s, "transform")) });
94
+ c && r.push({ objectid: c, path: p(s, "p:path") || p(s, "path"), transform: B(p(s, "transform")) });
94
95
  }
95
96
  return { objects: n, items: r };
96
97
  }
@@ -98,7 +99,7 @@ function O(t) {
98
99
  const n = String(t).replace(/^\/+/, "");
99
100
  return n.includes("%") ? decodeURIComponent(n) : n;
100
101
  }
101
- function k(t) {
102
+ function L(t) {
102
103
  const n = {};
103
104
  for (const o of t.match(/<metadata\b[^>]*>/g) || []) {
104
105
  const e = p(o, "key");
@@ -106,17 +107,17 @@ function k(t) {
106
107
  }
107
108
  return n;
108
109
  }
109
- function tt(t) {
110
+ function et(t) {
110
111
  const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), e = /<object\b([^>]*)>([\s\S]*?)<\/object>/g;
111
112
  let r;
112
113
  for (; r = e.exec(t); ) {
113
114
  const c = p(r[1], "id");
114
115
  if (c) {
115
116
  const d = r[2];
116
- n.set(c, k(d.replace(/<(?:part|volume)\b[\s\S]*?<\/(?:part|volume)>/g, "")));
117
+ n.set(c, L(d.replace(/<(?:part|volume)\b[\s\S]*?<\/(?:part|volume)>/g, "")));
117
118
  const f = [];
118
119
  for (const u of d.match(/<volume\b[\s\S]*?<\/volume>/g) || []) {
119
- const _ = k(u).volume_type, y = _ === "SupportBlocker" ? "blocker" : _ === "SupportEnforcer" ? "enforcer" : null, j = Number(p(u, "firstid")), S = Number(p(u, "lastid"));
120
+ const _ = L(u).volume_type, y = _ === "SupportBlocker" ? "blocker" : _ === "SupportEnforcer" ? "enforcer" : null, j = Number(p(u, "firstid")), S = Number(p(u, "lastid"));
120
121
  y && Number.isInteger(j) && Number.isInteger(S) && j >= 0 && S >= j && f.push({ firstTriangle: j, lastTriangle: S, kind: y });
121
122
  }
122
123
  f.length && o.set(c, f);
@@ -124,16 +125,16 @@ function tt(t) {
124
125
  }
125
126
  const i = [], s = /<plate\b[^>]*>([\s\S]*?)<\/plate>/g;
126
127
  for (; r = s.exec(t); ) {
127
- const c = r[1], d = k(c.replace(/<model_instance\b[\s\S]*?<\/model_instance>/g, "")), f = [];
128
+ const c = r[1], d = L(c.replace(/<model_instance\b[\s\S]*?<\/model_instance>/g, "")), f = [];
128
129
  for (const u of c.match(/<model_instance\b[\s\S]*?<\/model_instance>/g) || []) {
129
- const _ = k(u).object_id;
130
+ const _ = L(u).object_id;
130
131
  _ && f.push(_);
131
132
  }
132
133
  i.push({ index: Math.max(0, (Number(d.plater_id) || i.length + 1) - 1), objectIds: f });
133
134
  }
134
135
  return { objects: n, plates: i, volumes: o };
135
136
  }
136
- const et = Object.freeze({
137
+ const nt = Object.freeze({
137
138
  manualSupportPoints: "prepared-roundtrip",
138
139
  drainHoles: "preserved-unsupported",
139
140
  modifierVolumes: "prepared-mask-filtering",
@@ -161,11 +162,11 @@ function X(t, n) {
161
162
  const [o, e, r] = n;
162
163
  return [o * t[0] + e * t[3] + r * t[6] + t[9], o * t[1] + e * t[4] + r * t[7] + t[10], o * t[2] + e * t[5] + r * t[8] + t[11]];
163
164
  }
164
- function nt(t, n) {
165
+ function ot(t, n) {
165
166
  const [o, e, r] = n, i = [o * t[0] + e * t[3] + r * t[6], o * t[1] + e * t[4] + r * t[7], o * t[2] + e * t[5] + r * t[8]], s = Math.hypot(...i);
166
167
  return s ? i.map((c) => c / s) : i;
167
168
  }
168
- function ot(t, n) {
169
+ function st(t, n) {
169
170
  const o = (s) => {
170
171
  const c = t.get(s);
171
172
  return c ? n.decode(c) : null;
@@ -179,7 +180,7 @@ function ot(t, n) {
179
180
  hasLayerHeightProfile: !1,
180
181
  hasCustomGcodePerLayer: !1,
181
182
  volumeMeta: /* @__PURE__ */ new Map(),
182
- sla: { capabilities: { ...et }, issues: [], supportPoints: /* @__PURE__ */ new Map(), drainHoles: /* @__PURE__ */ new Map() }
183
+ sla: { capabilities: { ...nt }, issues: [], supportPoints: /* @__PURE__ */ new Map(), drainHoles: /* @__PURE__ */ new Map() }
183
184
  }, r = o("Metadata/project_settings.config");
184
185
  if (r)
185
186
  try {
@@ -189,7 +190,7 @@ function ot(t, n) {
189
190
  }
190
191
  const i = o("Metadata/model_settings.config");
191
192
  if (i) {
192
- const s = tt(i);
193
+ const s = et(i);
193
194
  e.objectMeta = s.objects, e.plates = s.plates, e.volumeMeta = s.volumes;
194
195
  }
195
196
  return e.sla.supportPoints = J(
@@ -199,7 +200,7 @@ function ot(t, n) {
199
200
  e.sla.issues,
200
201
  (s, c) => ({
201
202
  position: s.slice(0, 3),
202
- radius: c === 0 ? 0.4 : s[3],
203
+ radius: c === 0 ? W : s[3],
203
204
  type: c === 0 || s[4] === 2 ? "manual" : s[4] === 1 ? "island" : "slope"
204
205
  })
205
206
  ), e.sla.drainHoles = J(
@@ -213,13 +214,13 @@ function ot(t, n) {
213
214
  }
214
215
  ), e.hasLayerHeightProfile = !!o("Metadata/layer_heights_profile.txt")?.trim(), e.hasCustomGcodePerLayer = !!o("Metadata/custom_gcode_per_layer.xml")?.trim(), e;
215
216
  }
216
- async function rt(t, n = "model") {
217
- const o = ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t), e = await W(o), r = /* @__PURE__ */ new Map();
217
+ async function ct(t, n = "model") {
218
+ const o = ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t), e = await q(o), r = /* @__PURE__ */ new Map();
218
219
  for (const a of Object.keys(e)) r.set(O(a), e[a]);
219
220
  const i = new TextDecoder(), s = /* @__PURE__ */ new Map(), c = (a) => {
220
221
  const w = O(a);
221
222
  if (s.has(w)) return s.get(w);
222
- const l = r.get(w), M = l ? Z(i.decode(l)) : null;
223
+ const l = r.get(w), M = l ? tt(i.decode(l)) : null;
223
224
  return s.set(w, M), M;
224
225
  };
225
226
  let d = "3D/3dmodel.model";
@@ -233,26 +234,26 @@ async function rt(t, n = "model") {
233
234
  }
234
235
  const u = c(d);
235
236
  if (!u) throw new Error(`3MF root model not found: ${d}`);
236
- const _ = [], y = ot(r, i), j = (a, w, l, M, P, N) => {
237
+ const _ = [], y = st(r, i), j = (a, w, l, M, P, N) => {
237
238
  if (N > 16) return;
238
239
  const T = c(w)?.objects.get(a);
239
240
  if (!T) return;
240
241
  if (T.components) {
241
- for (const b of T.components) j(b.objectid, b.path || w, q(b.transform, l), M, P, N + 1);
242
+ for (const b of T.components) j(b.objectid, b.path || w, K(b.transform, l), M, P, N + 1);
242
243
  return;
243
244
  }
244
245
  if (!T.mesh) return;
245
- const { verts: z, tris: I, paint: v } = T.mesh, E = M.length / 9;
246
+ const { verts: z, tris: I, paint: A } = T.mesh, E = M.length / 9;
246
247
  for (let b = 0; b < I.length; b++) {
247
- const m = I[b] * 3, g = z[m], h = z[m + 1], A = z[m + 2];
248
+ const m = I[b] * 3, g = z[m], h = z[m + 1], v = z[m + 2];
248
249
  M.push(
249
- g * l[0] + h * l[3] + A * l[6] + l[9],
250
- g * l[1] + h * l[4] + A * l[7] + l[10],
251
- g * l[2] + h * l[5] + A * l[8] + l[11]
250
+ g * l[0] + h * l[3] + v * l[6] + l[9],
251
+ g * l[1] + h * l[4] + v * l[7] + l[10],
252
+ g * l[2] + h * l[5] + v * l[8] + l[11]
252
253
  );
253
254
  }
254
- if (v) for (const [, b] of $)
255
- for (const [m, g] of v[b]) P[b].set(E + m, g);
255
+ if (A) for (const [, b] of $)
256
+ for (const [m, g] of A[b]) P[b].set(E + m, g);
256
257
  }, S = u.items.length ? u.items : [...u.objects.keys()].filter((a) => u.objects.get(a).mesh).map((a) => ({ objectid: a, path: d, transform: F }));
257
258
  return S.forEach((a, w) => {
258
259
  const l = [], M = G();
@@ -262,10 +263,10 @@ async function rt(t, n = "model") {
262
263
  if (R.length) {
263
264
  const m = /* @__PURE__ */ new Set();
264
265
  for (let g = 0; g < R.length; g++) {
265
- const h = R[g], A = h.firstTriangle * 9, H = Math.min(l.length, (h.lastTriangle + 1) * 9);
266
- if (!(A >= H)) {
267
- for (let L = h.firstTriangle; L <= h.lastTriangle; L++) m.add(L);
268
- N.push({ id: `${a.objectid}:modifier:${g}`, kind: h.kind, tris: new Float32Array(l.slice(A, H)) });
266
+ const h = R[g], v = h.firstTriangle * 9, H = Math.min(l.length, (h.lastTriangle + 1) * 9);
267
+ if (!(v >= H)) {
268
+ for (let k = h.firstTriangle; k <= h.lastTriangle; k++) m.add(k);
269
+ N.push({ id: `${a.objectid}:modifier:${g}`, kind: h.kind, tris: new Float32Array(l.slice(v, H)) });
269
270
  }
270
271
  }
271
272
  if (m.size) {
@@ -277,23 +278,23 @@ async function rt(t, n = "model") {
277
278
  const T = (y.sla.supportPoints.get(w + 1) || []).map((m) => ({ ...m, position: X(a.transform, m.position) })), z = (y.sla.drainHoles.get(w + 1) || []).map((m) => ({
278
279
  ...m,
279
280
  position: X(a.transform, m.position),
280
- normal: nt(a.transform, m.normal)
281
+ normal: ot(a.transform, m.normal)
281
282
  }));
282
- let I = 1 / 0, v = 1 / 0, E = -1 / 0, b = -1 / 0;
283
+ let I = 1 / 0, A = 1 / 0, E = -1 / 0, b = -1 / 0;
283
284
  for (let m = 0; m < P.length; m += 3) {
284
285
  const g = P[m], h = P[m + 1];
285
- g < I && (I = g), g > E && (E = g), h < v && (v = h), h > b && (b = h);
286
+ g < I && (I = g), g > E && (E = g), h < A && (A = h), h > b && (b = h);
286
287
  }
287
288
  _.push({
288
289
  name: S.length > 1 ? `${n}#${w + 1}` : n,
289
290
  tris: P,
290
291
  objectid: a.objectid,
291
- paint: K(M) ? null : M,
292
+ paint: Q(M) ? null : M,
292
293
  sla: { supportPoints: T, drainHoles: z, modifierVolumes: N },
293
- bbox: { minX: I, minY: v, maxX: E, maxY: b }
294
+ bbox: { minX: I, minY: A, maxX: E, maxY: b }
294
295
  });
295
296
  }), { objects: _, project: y };
296
297
  }
297
298
  export {
298
- rt as p
299
+ ct as p
299
300
  };
@@ -1,4 +1,4 @@
1
- import { p as f } from "./parse_3mf-CQ5rAX6P.js";
1
+ import { p as f } from "./parse_3mf-jEUAw8JM.js";
2
2
  self.onmessage = async (a) => {
3
3
  const { id: s, buffer: r, baseName: t } = a.data || {};
4
4
  try {
@@ -0,0 +1,16 @@
1
+ import d, { useRef as l, useState as u, useLayoutEffect as i } from "react";
2
+ import { createPortal as f } from "react-dom";
3
+ function h({ css: s, className: c, children: r }) {
4
+ const a = l(null), [o] = u(() => {
5
+ const t = document.createElement("div");
6
+ return t.style.display = "contents", t;
7
+ });
8
+ return i(() => {
9
+ const t = a.current, n = t.shadowRoot || t.attachShadow({ mode: "open" });
10
+ let e = n.querySelector("style[data-ts-css]");
11
+ e || (e = document.createElement("style"), e.setAttribute("data-ts-css", ""), n.append(e)), e.textContent = s, n.contains(o) || n.append(o);
12
+ }, [s, o]), /* @__PURE__ */ d.createElement("div", { ref: a, className: c }, f(r, o));
13
+ }
14
+ export {
15
+ h as S
16
+ };