three-slicer-viewer 0.3.2 → 0.3.3

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.
@@ -1,34 +1,34 @@
1
- import * as P from "three";
2
- import { OBJLoader as k } from "three/examples/jsm/loaders/OBJLoader.js";
1
+ import * as k from "three";
2
+ import { OBJLoader as P } from "three/examples/jsm/loaders/OBJLoader.js";
3
3
  import { PLYLoader as x } from "three/examples/jsm/loaders/PLYLoader.js";
4
4
  import { AMFLoader as S } from "three/examples/jsm/loaders/AMFLoader.js";
5
- import { p as M } from "./parse_3mf-BZISF3eW.js";
5
+ import { p as M } from "./parse_3mf-CpbA-6Iq.js";
6
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;
7
+ const b = 80, y = 84, _ = 50, B = (t) => y + t * _;
8
+ let p = null, h = !1, D = 0;
9
9
  const w = /* @__PURE__ */ new Map();
10
- function $() {
10
+ function W() {
11
11
  if (h || typeof Worker > "u") return null;
12
- if (d) return d;
12
+ if (p) return p;
13
13
  try {
14
- d = v(), d.onmessage = (t) => {
14
+ p = v(), p.onmessage = (t) => {
15
15
  const { id: e, objects: s, project: r, error: n } = t.data || {}, c = w.get(e);
16
16
  c && (w.delete(e), n ? c.reject(new Error(n)) : c.resolve({ objects: s, project: r }));
17
- }, d.onerror = () => {
17
+ }, p.onerror = () => {
18
18
  h = !0;
19
19
  for (const [, t] of w) t.reject(new Error("3MF parse worker failed"));
20
- w.clear(), d = null;
20
+ w.clear(), p = null;
21
21
  };
22
22
  } catch {
23
- h = !0, d = null;
23
+ h = !0, p = null;
24
24
  }
25
- return d;
25
+ return p;
26
26
  }
27
- async function b(t, e) {
28
- const s = $();
27
+ async function $(t, e) {
28
+ const s = W();
29
29
  if (!s) return M(t, e);
30
30
  try {
31
- const r = ++W, n = new Promise((c, i) => w.set(r, { resolve: c, reject: i }));
31
+ const r = ++D, n = new Promise((c, i) => w.set(r, { resolve: c, reject: i }));
32
32
  return s.postMessage({ id: r, buffer: t, baseName: e }), await n;
33
33
  } catch {
34
34
  return M(t, e);
@@ -46,8 +46,8 @@ function C(t) {
46
46
  function O(t) {
47
47
  const e = new DataView(t);
48
48
  if (t.byteLength >= y) {
49
- const i = e.getUint32(_, !0);
50
- if (t.byteLength === D(i)) {
49
+ const i = e.getUint32(b, !0);
50
+ if (t.byteLength === B(i)) {
51
51
  const l = new Float32Array(i * 9);
52
52
  let f = y, u = 0;
53
53
  for (let o = 0; o < i; o++) {
@@ -67,7 +67,7 @@ function O(t) {
67
67
  function j(t, e) {
68
68
  const s = t?.attributes?.position;
69
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);
70
+ const r = t.index, n = new k.Vector3(), c = Math.floor((r ? r.count : s.count) / 3), i = new Float32Array(c * 9);
71
71
  let l = 0;
72
72
  const f = (u) => {
73
73
  n.fromBufferAttribute(s, u), e && n.applyMatrix4(e), i[l++] = n.x, i[l++] = n.y, i[l++] = n.z;
@@ -108,7 +108,7 @@ async function V(t, e) {
108
108
  return [{ name: t, modelPos: r }];
109
109
  }
110
110
  case "obj": {
111
- const r = new k().parse(new TextDecoder().decode(e));
111
+ const r = new P().parse(new TextDecoder().decode(e));
112
112
  return L(t, F(r), !1);
113
113
  }
114
114
  case "ply": {
@@ -117,7 +117,7 @@ async function V(t, e) {
117
117
  return [{ name: t, modelPos: n }];
118
118
  }
119
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 }));
120
+ const { objects: r, project: n } = await $(e, t), c = r.map((i) => ({ name: i.name, modelPos: i.tris, baked: i.baked, objectid: i.objectid, paint: i.paint, bbox: i.bbox, project: n }));
121
121
  if (!c.length && n.gcodePlates) return [{ name: t, gcodePlates: n.gcodePlates, project: n }];
122
122
  if (!c.length) throw new Error("No mesh in 3MF");
123
123
  return c;
@@ -154,7 +154,7 @@ function R(t) {
154
154
  const s = 1e4, r = /* @__PURE__ */ new Map(), n = new Int32Array(e * 3);
155
155
  for (let o = 0; o < e; o++)
156
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)}`;
157
+ const d = o * 9 + a * 3, m = `${Math.round(t[d] * s)},${Math.round(t[d + 1] * s)},${Math.round(t[d + 2] * s)}`;
158
158
  let g = r.get(m);
159
159
  g === void 0 && (g = r.size, r.set(m, g)), n[o * 3 + a] = g;
160
160
  }
@@ -169,22 +169,22 @@ function R(t) {
169
169
  }, f = /* @__PURE__ */ new Map();
170
170
  for (let o = 0; o < e; o++)
171
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);
172
+ const d = n[o * 3 + a], m = n[o * 3 + (a + 1) % 3], g = d < m ? d * 4294967296 + m : m * 4294967296 + d, E = f.get(g);
173
173
  E === void 0 ? f.set(g, o) : l(o, E);
174
174
  }
175
175
  const u = /* @__PURE__ */ new Map();
176
176
  for (let o = 0; o < e; o++) {
177
177
  const a = i(o);
178
- let p = u.get(a);
179
- p || (p = [], u.set(a, p)), p.push(o);
178
+ let d = u.get(a);
179
+ d || (d = [], u.set(a, d)), d.push(o);
180
180
  }
181
181
  return u.size < 2 ? null : [...u.values()].sort((o, a) => a.length - o.length);
182
182
  }
183
183
  export {
184
184
  X as G,
185
- _ as S,
185
+ b as S,
186
186
  y as a,
187
- B as b,
187
+ _ as b,
188
188
  T as c,
189
189
  R as d,
190
190
  I as e,
@@ -192,5 +192,5 @@ export {
192
192
  q as g,
193
193
  V as l,
194
194
  H as r,
195
- D as s
195
+ B as s
196
196
  };
@@ -2,9 +2,9 @@ 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-BZISF3eW.js";
5
+ import "./parse_3mf-CpbA-6Iq.js";
6
6
  import "./make_worker.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";
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-Dk9rqXFb.js";
8
8
  export {
9
9
  m as GCODE_EXTS,
10
10
  n as SUPPORTED_EXT,