@sienci/gviewer 0.1.7 → 0.1.8

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/dist/gviewer.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const U = /([A-Za-z])\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+))/g;
2
2
  class R {
3
- parseLine(e) {
4
- const n = [], t = this.stripComments(e, n), s = this.parseWords(t), r = s.filter((a) => {
3
+ parseLine(t) {
4
+ const n = [], e = this.stripComments(t, n), s = this.parseWords(e), r = s.filter((a) => {
5
5
  const c = a.letter.toUpperCase();
6
6
  return c === "G" || c === "M";
7
7
  }), i = s.filter((a) => {
@@ -9,20 +9,20 @@ class R {
9
9
  return c !== "G" && c !== "M";
10
10
  });
11
11
  return {
12
- raw: e,
12
+ raw: t,
13
13
  words: s,
14
14
  gcodes: r,
15
15
  params: i,
16
16
  comments: n
17
17
  };
18
18
  }
19
- stripComments(e, n) {
20
- let t = "", s = !1, r = -1, i = "";
21
- for (let a = 0; a < e.length; a += 1) {
22
- const c = e[a];
19
+ stripComments(t, n) {
20
+ let e = "", s = !1, r = -1, i = "";
21
+ for (let a = 0; a < t.length; a += 1) {
22
+ const c = t[a];
23
23
  if (!s && c === ";") {
24
- const u = e.slice(a + 1);
25
- n.push({ type: "semicolon", text: u, start: a, end: e.length });
24
+ const u = t.slice(a + 1);
25
+ n.push({ type: "semicolon", text: u, start: a, end: t.length });
26
26
  break;
27
27
  }
28
28
  if (c === "(") {
@@ -42,25 +42,25 @@ class R {
42
42
  i += c;
43
43
  continue;
44
44
  }
45
- t += c;
45
+ e += c;
46
46
  }
47
47
  return s && n.push({
48
48
  type: "paren",
49
49
  text: i,
50
50
  start: r,
51
- end: e.length
52
- }), t;
51
+ end: t.length
52
+ }), e;
53
53
  }
54
- parseWords(e) {
54
+ parseWords(t) {
55
55
  const n = [];
56
- for (const t of e.matchAll(U)) {
57
- const s = t[0], r = t[1].toUpperCase(), i = Number(t[2]), a = t.index ?? 0, c = a + s.length;
56
+ for (const e of t.matchAll(U)) {
57
+ const s = e[0], r = e[1].toUpperCase(), i = Number(e[2]), a = e.index ?? 0, c = a + s.length;
58
58
  n.push({ letter: r, value: i, raw: s, start: a, end: c });
59
59
  }
60
60
  return n;
61
61
  }
62
62
  }
63
- const X = ["X", "Y", "Z", "A", "B", "C"], C = {
63
+ const Z = ["X", "Y", "Z", "A", "B", "C"], X = {
64
64
  motion: "G0",
65
65
  distance: "G90",
66
66
  plane: "G17",
@@ -74,11 +74,11 @@ const X = ["X", "Y", "Z", "A", "B", "C"], C = {
74
74
  coordinateSystem: "G54"
75
75
  };
76
76
  class L {
77
- constructor(e = {}) {
78
- this.parser = new R(), this.modals = { ...C }, this.position = { X: 0, Y: 0, Z: 0, A: 0, B: 0, C: 0 }, this.callbacks = e, this.feedRates = /* @__PURE__ */ new Set(), this.spindleSpeeds = /* @__PURE__ */ new Set(), this.tools = /* @__PURE__ */ new Set();
77
+ constructor(t = {}) {
78
+ this.parser = new R(), this.modals = { ...X }, this.position = { X: 0, Y: 0, Z: 0, A: 0, B: 0, C: 0 }, this.callbacks = t, this.feedRates = /* @__PURE__ */ new Set(), this.spindleSpeeds = /* @__PURE__ */ new Set(), this.tools = /* @__PURE__ */ new Set();
79
79
  }
80
- setCallbacks(e) {
81
- this.callbacks = e;
80
+ setCallbacks(t) {
81
+ this.callbacks = t;
82
82
  }
83
83
  getModals() {
84
84
  return { ...this.modals };
@@ -96,17 +96,17 @@ class L {
96
96
  return Array.from(this.tools);
97
97
  }
98
98
  reset() {
99
- this.modals = { ...C }, this.position = { X: 0, Y: 0, Z: 0, A: 0, B: 0, C: 0 }, this.feedRates.clear(), this.spindleSpeeds.clear(), this.tools.clear();
99
+ this.modals = { ...X }, this.position = { X: 0, Y: 0, Z: 0, A: 0, B: 0, C: 0 }, this.feedRates.clear(), this.spindleSpeeds.clear(), this.tools.clear();
100
100
  }
101
- processLine(e) {
102
- const n = this.parser.parseLine(e), t = { ...this.position };
101
+ processLine(t) {
102
+ const n = this.parser.parseLine(t), e = { ...this.position };
103
103
  this.updateModals(n);
104
104
  const s = this.modals.motion, r = this.modals.plane;
105
- let i = this.applyAxes(n, t), a, c, u = "none";
106
- return s === "G0" || s === "G1" ? N(t, i) || (u = "linear", this.position = { ...i }, this.emitLinear({ start: t, end: i })) : (s === "G2" || s === "G3") && (N(t, i) || (u = "arc", c = this.arcCenter(n, t, i, r), a = this.computeArcMax(t, i, s, r, c), this.position = { ...i }, this.emitArc({ start: t, end: i, max: a, center: c, plane: r, motion: s }))), {
105
+ let i = this.applyAxes(n, e), a, c, u = "none";
106
+ return s === "G0" || s === "G1" ? N(e, i) || (u = "linear", this.position = { ...i }, this.emitLinear({ start: e, end: i })) : (s === "G2" || s === "G3") && (N(e, i) || (u = "arc", c = this.arcCenter(n, e, i, r), a = this.computeArcMax(e, i, s, r, c), this.position = { ...i }, this.emitArc({ start: e, end: i, max: a, center: c, plane: r, motion: s }))), {
107
107
  parsed: n,
108
108
  modals: { ...this.modals },
109
- start: t,
109
+ start: e,
110
110
  end: i,
111
111
  movement: u,
112
112
  arcMax: a
@@ -115,77 +115,77 @@ class L {
115
115
  unitsScale() {
116
116
  return this.modals.units === "G20" ? 25.4 : 1;
117
117
  }
118
- updateModals(e) {
119
- for (const n of e.gcodes) {
118
+ updateModals(t) {
119
+ for (const n of t.gcodes) {
120
120
  if (n.letter.toUpperCase() === "G") {
121
- const t = `G${Math.trunc(n.value)}`;
122
- (t === "G0" || t === "G1" || t === "G2" || t === "G3") && (this.modals.motion = t), (t === "G90" || t === "G91") && (this.modals.distance = t), (t === "G17" || t === "G18" || t === "G19") && (this.modals.plane = t), (t === "G20" || t === "G21") && (this.modals.units = t), (t === "G93" || t === "G94") && (this.modals.feedMode = t), (t === "G54" || t === "G55" || t === "G56" || t === "G57" || t === "G58" || t === "G59") && (this.modals.coordinateSystem = t);
121
+ const e = `G${Math.trunc(n.value)}`;
122
+ (e === "G0" || e === "G1" || e === "G2" || e === "G3") && (this.modals.motion = e), (e === "G90" || e === "G91") && (this.modals.distance = e), (e === "G17" || e === "G18" || e === "G19") && (this.modals.plane = e), (e === "G20" || e === "G21") && (this.modals.units = e), (e === "G93" || e === "G94") && (this.modals.feedMode = e), (e === "G54" || e === "G55" || e === "G56" || e === "G57" || e === "G58" || e === "G59") && (this.modals.coordinateSystem = e);
123
123
  }
124
124
  if (n.letter.toUpperCase() === "M") {
125
- const t = `M${Math.trunc(n.value)}`;
126
- (t === "M7" || t === "M8" || t === "M9") && (this.modals.coolant = t), (t === "M3" || t === "M4" || t === "M5") && (this.modals.spindle = t);
125
+ const e = `M${Math.trunc(n.value)}`;
126
+ (e === "M7" || e === "M8" || e === "M9") && (this.modals.coolant = e), (e === "M3" || e === "M4" || e === "M5") && (this.modals.spindle = e);
127
127
  }
128
128
  }
129
- for (const n of e.params) {
130
- const t = n.letter.toUpperCase();
131
- t === "F" && (this.modals.feedRate = n.value, this.feedRates.add(n.value)), t === "S" && (this.modals.spindleSpeed = n.value, this.spindleSpeeds.add(n.value)), t === "T" && (this.modals.tool = n.value, this.tools.add(n.value));
129
+ for (const n of t.params) {
130
+ const e = n.letter.toUpperCase();
131
+ e === "F" && (this.modals.feedRate = n.value, this.feedRates.add(n.value)), e === "S" && (this.modals.spindleSpeed = n.value, this.spindleSpeeds.add(n.value)), e === "T" && (this.modals.tool = n.value, this.tools.add(n.value));
132
132
  }
133
133
  }
134
- applyAxes(e, n) {
135
- const t = { ...n }, s = this.unitsScale();
136
- for (const r of X) {
137
- const i = e.params.find((c) => c.letter.toUpperCase() === r);
134
+ applyAxes(t, n) {
135
+ const e = { ...n }, s = this.unitsScale();
136
+ for (const r of Z) {
137
+ const i = t.params.find((c) => c.letter.toUpperCase() === r);
138
138
  if (!i)
139
139
  continue;
140
140
  const a = r === "X" || r === "Y" || r === "Z" ? i.value * s : i.value;
141
- this.modals.distance === "G90" ? t[r] = a : t[r] = t[r] + a;
141
+ this.modals.distance === "G90" ? e[r] = a : e[r] = e[r] + a;
142
142
  }
143
- return t;
143
+ return e;
144
144
  }
145
- computeArcMax(e, n, t, s, r) {
146
- const { primary: i, secondary: a, tertiary: c } = F(s), u = q(
147
- e[i],
148
- e[a],
145
+ computeArcMax(t, n, e, s, r) {
146
+ const { primary: i, secondary: a, tertiary: c } = C(s), u = j(
147
+ t[i],
148
+ t[a],
149
149
  r[i],
150
150
  r[a]
151
151
  ), f = Math.atan2(
152
- e[a] - r[a],
153
- e[i] - r[i]
152
+ t[a] - r[a],
153
+ t[i] - r[i]
154
154
  ), d = Math.atan2(
155
155
  n[a] - r[a],
156
156
  n[i] - r[i]
157
- ), y = $(f, d, t);
158
- let l = Number.NEGATIVE_INFINITY, p = Number.NEGATIVE_INFINITY;
157
+ ), y = $(f, d, e);
158
+ let l = Number.NEGATIVE_INFINITY, h = Number.NEGATIVE_INFINITY;
159
159
  for (const A of y) {
160
- const w = r[i] + u * Math.cos(A), h = r[a] + u * Math.sin(A);
161
- w > l && (l = w), h > p && (p = h);
160
+ const G = r[i] + u * Math.cos(A), p = r[a] + u * Math.sin(A);
161
+ G > l && (l = G), p > h && (h = p);
162
162
  }
163
- const x = { ...e };
164
- x[i] = l, x[a] = p, x[c] = Math.max(e[c], n[c]);
165
- for (const A of X)
166
- A !== i && A !== a && A !== c && (x[A] = Math.max(e[A], n[A]));
167
- return x;
163
+ const M = { ...t };
164
+ M[i] = l, M[a] = h, M[c] = Math.max(t[c], n[c]);
165
+ for (const A of Z)
166
+ A !== i && A !== a && A !== c && (M[A] = Math.max(t[A], n[A]));
167
+ return M;
168
168
  }
169
- arcCenter(e, n, t, s) {
170
- const { primary: r, secondary: i } = F(s), a = { ...n }, c = this.unitsScale(), u = V(e, "R"), f = _(e, s), d = f.primary === null ? null : f.primary * c, y = f.secondary === null ? null : f.secondary * c;
169
+ arcCenter(t, n, e, s) {
170
+ const { primary: r, secondary: i } = C(s), a = { ...n }, c = this.unitsScale(), u = F(t, "R"), f = _(t, s), d = f.primary === null ? null : f.primary * c, y = f.secondary === null ? null : f.secondary * c;
171
171
  if (d !== null || y !== null)
172
172
  return a[r] = n[r] + (d ?? 0), a[i] = n[i] + (y ?? 0), a;
173
173
  if (u === null)
174
174
  return a;
175
- const l = u * c, p = n[r], x = n[i], A = t[r], w = t[i], h = A - p, G = w - x, P = Math.hypot(h, G);
176
- if (P === 0)
175
+ const l = u * c, h = n[r], M = n[i], A = e[r], G = e[i], p = A - h, w = G - M, S = Math.hypot(p, w);
176
+ if (S === 0)
177
177
  return a;
178
- const I = Math.abs(l), m = Math.sqrt(Math.max(0, I * I - P / 2 * (P / 2))), M = (p + A) / 2, v = (x + w) / 2, S = -G / P, Y = h / P, E = l >= 0 ? 1 : -1;
179
- return a[r] = M + E * S * m, a[i] = v + E * Y * m, a;
178
+ const I = Math.abs(l), m = Math.sqrt(Math.max(0, I * I - S / 2 * (S / 2))), x = (h + A) / 2, v = (M + G) / 2, P = -w / S, E = p / S, Y = l >= 0 ? 1 : -1;
179
+ return a[r] = x + Y * P * m, a[i] = v + Y * E * m, a;
180
180
  }
181
- emitLinear(e) {
181
+ emitLinear(t) {
182
182
  const n = this.callbacks.onLinearMove;
183
183
  if (!n)
184
184
  return;
185
- const t = e.end.A - e.start.A, s = Math.max(1, Math.ceil(Math.abs(t) / D));
186
- let r = { ...e.start };
185
+ const e = t.end.A - t.start.A, s = Math.max(1, Math.ceil(Math.abs(e) / W));
186
+ let r = { ...t.start };
187
187
  for (let i = 1; i <= s; i += 1) {
188
- const a = i / s, c = W(e.start, e.end, a), u = Z(r), f = Z(c);
188
+ const a = i / s, c = q(t.start, t.end, a), u = V(r), f = V(c);
189
189
  n({
190
190
  modals: { ...this.modals },
191
191
  start: { ...r },
@@ -195,92 +195,92 @@ class L {
195
195
  }), r = c;
196
196
  }
197
197
  }
198
- emitArc(e) {
198
+ emitArc(t) {
199
199
  const n = this.callbacks.onArcMove;
200
200
  if (!n)
201
201
  return;
202
- const t = Z(e.start), s = Z(e.end), r = Z(e.max), i = Z(e.center);
202
+ const e = V(t.start), s = V(t.end), r = V(t.max), i = V(t.center);
203
203
  n({
204
204
  modals: { ...this.modals },
205
- start: { ...e.start },
206
- end: { ...e.end },
207
- max: { ...e.max },
208
- center: { ...e.center },
209
- plane: e.plane,
210
- motion: e.motion,
211
- transformedStart: t,
205
+ start: { ...t.start },
206
+ end: { ...t.end },
207
+ max: { ...t.max },
208
+ center: { ...t.center },
209
+ plane: t.plane,
210
+ motion: t.motion,
211
+ transformedStart: e,
212
212
  transformedEnd: s,
213
213
  transformedMax: r,
214
214
  transformedCenter: i
215
215
  });
216
216
  }
217
217
  }
218
- function V(o, e) {
219
- const n = o.params.find((t) => t.letter.toUpperCase() === e);
218
+ function F(o, t) {
219
+ const n = o.params.find((e) => e.letter.toUpperCase() === t);
220
220
  return n ? n.value : null;
221
221
  }
222
- function F(o) {
222
+ function C(o) {
223
223
  return o === "G18" ? { primary: "Z", secondary: "X", tertiary: "Y" } : o === "G19" ? { primary: "Y", secondary: "Z", tertiary: "X" } : { primary: "X", secondary: "Y", tertiary: "Z" };
224
224
  }
225
- function _(o, e) {
226
- const n = V(o, "I"), t = V(o, "J"), s = V(o, "K");
227
- return e === "G18" ? { primary: s, secondary: n } : e === "G19" ? { primary: t, secondary: s } : { primary: n, secondary: t };
225
+ function _(o, t) {
226
+ const n = F(o, "I"), e = F(o, "J"), s = F(o, "K");
227
+ return t === "G18" ? { primary: s, secondary: n } : t === "G19" ? { primary: e, secondary: s } : { primary: n, secondary: e };
228
228
  }
229
- function $(o, e, n) {
230
- const t = Math.PI * 2;
231
- let s = b(o), r = b(e);
232
- const i = [0, Math.PI / 2, Math.PI, 3 * Math.PI / 2, t];
229
+ function $(o, t, n) {
230
+ const e = Math.PI * 2;
231
+ let s = b(o), r = b(t);
232
+ const i = [0, Math.PI / 2, Math.PI, 3 * Math.PI / 2, e];
233
233
  if (n === "G2") {
234
- s < r && (s += t);
234
+ s < r && (s += e);
235
235
  const c = [s, r];
236
236
  for (const u of i) {
237
237
  let f = u;
238
- f < r && (f += t), f <= s && f >= r && c.push(f);
238
+ f < r && (f += e), f <= s && f >= r && c.push(f);
239
239
  }
240
240
  return c;
241
241
  }
242
- r < s && (r += t);
242
+ r < s && (r += e);
243
243
  const a = [s, r];
244
244
  for (const c of i) {
245
245
  let u = c;
246
- u < s && (u += t), u >= s && u <= r && a.push(u);
246
+ u < s && (u += e), u >= s && u <= r && a.push(u);
247
247
  }
248
248
  return a;
249
249
  }
250
250
  function b(o) {
251
- const e = Math.PI * 2;
252
- let n = o % e;
253
- return n < 0 && (n += e), n;
251
+ const t = Math.PI * 2;
252
+ let n = o % t;
253
+ return n < 0 && (n += t), n;
254
254
  }
255
- function q(o, e, n, t) {
256
- return Math.hypot(o - n, e - t);
255
+ function j(o, t, n, e) {
256
+ return Math.hypot(o - n, t - e);
257
257
  }
258
- function N(o, e) {
259
- return X.every((n) => o[n] === e[n]);
258
+ function N(o, t) {
259
+ return Z.every((n) => o[n] === t[n]);
260
260
  }
261
- const D = 5;
262
- function W(o, e, n) {
261
+ const W = 5;
262
+ function q(o, t, n) {
263
263
  return {
264
- X: o.X + (e.X - o.X) * n,
265
- Y: o.Y + (e.Y - o.Y) * n,
266
- Z: o.Z + (e.Z - o.Z) * n,
267
- A: o.A + (e.A - o.A) * n,
268
- B: o.B + (e.B - o.B) * n,
269
- C: o.C + (e.C - o.C) * n
264
+ X: o.X + (t.X - o.X) * n,
265
+ Y: o.Y + (t.Y - o.Y) * n,
266
+ Z: o.Z + (t.Z - o.Z) * n,
267
+ A: o.A + (t.A - o.A) * n,
268
+ B: o.B + (t.B - o.B) * n,
269
+ C: o.C + (t.C - o.C) * n
270
270
  };
271
271
  }
272
- function Z(o) {
273
- const e = o.A * Math.PI / 180, n = Math.cos(e), t = Math.sin(e), s = o.Y * n - o.Z * t, r = o.Y * t + o.Z * n;
272
+ function V(o) {
273
+ const t = o.A * Math.PI / 180, n = Math.cos(t), e = Math.sin(t), s = o.Y * n - o.Z * e, r = o.Y * e + o.Z * n;
274
274
  return { ...o, Y: s, Z: r };
275
275
  }
276
- function ne(o, e = {}) {
277
- const n = [], t = e.arcSegments ?? 30, s = e.collector ?? {}, r = new L({
276
+ function ne(o, t = {}) {
277
+ const n = [], e = t.arcSegments ?? 30, s = t.collector ?? {}, r = new L({
278
278
  onLinearMove: (i) => {
279
279
  (s.onLinearMove ?? z)(i, n);
280
280
  },
281
281
  onArcMove: (i) => {
282
282
  (s.onArcMove ?? ((c, u) => {
283
- g(c, u, t);
283
+ g(c, u, e);
284
284
  }))(i, n);
285
285
  }
286
286
  });
@@ -288,14 +288,14 @@ function ne(o, e = {}) {
288
288
  i && r.processLine(i);
289
289
  return Float32Array.from(n);
290
290
  }
291
- function oe(o, e = {}) {
292
- const n = [], t = [], s = e.arcSegments ?? 30, r = new L({
291
+ function oe(o, t = {}) {
292
+ const n = [], e = [], s = t.arcSegments ?? 30, r = new L({
293
293
  onLinearMove: (i) => {
294
294
  const a = i.transformedStart ?? i.start, c = i.transformedEnd ?? i.end;
295
- (i.modals.motion === "G0" ? n : t).push(a.X, a.Y, a.Z, c.X, c.Y, c.Z);
295
+ (i.modals.motion === "G0" ? n : e).push(a.X, a.Y, a.Z, c.X, c.Y, c.Z);
296
296
  },
297
297
  onArcMove: (i) => {
298
- const a = i.modals.motion === "G0" ? n : t;
298
+ const a = i.modals.motion === "G0" ? n : e;
299
299
  g(i, a, s);
300
300
  }
301
301
  });
@@ -303,71 +303,71 @@ function oe(o, e = {}) {
303
303
  i && r.processLine(i);
304
304
  return {
305
305
  rapid: Float32Array.from(n),
306
- cutting: Float32Array.from(t)
306
+ cutting: Float32Array.from(e)
307
307
  };
308
308
  }
309
- async function re(o, e = {}) {
309
+ async function re(o, t = {}) {
310
310
  var y;
311
- const n = [], t = [], s = e.arcSegments ?? 30, r = e.batch, i = Math.max(1, Math.floor((r == null ? void 0 : r.everyLines) ?? 5e3)), a = Math.max(0, Math.floor((r == null ? void 0 : r.yieldEveryLines) ?? 5e4));
311
+ const n = [], e = [], s = t.arcSegments ?? 30, r = t.batch, i = Math.max(1, Math.floor((r == null ? void 0 : r.everyLines) ?? 5e3)), a = Math.max(0, Math.floor((r == null ? void 0 : r.yieldEveryLines) ?? 5e4));
312
312
  let c = i, u = a > 0 ? a : Number.POSITIVE_INFINITY;
313
313
  const f = new L({
314
314
  onLinearMove: (l) => {
315
- const p = l.transformedStart ?? l.start, x = l.transformedEnd ?? l.end;
316
- (l.modals.motion === "G0" ? n : t).push(p.X, p.Y, p.Z, x.X, x.Y, x.Z);
315
+ const h = l.transformedStart ?? l.start, M = l.transformedEnd ?? l.end;
316
+ (l.modals.motion === "G0" ? n : e).push(h.X, h.Y, h.Z, M.X, M.Y, M.Z);
317
317
  },
318
318
  onArcMove: (l) => {
319
- const p = l.modals.motion === "G0" ? n : t;
320
- g(l, p, s);
319
+ const h = l.modals.motion === "G0" ? n : e;
320
+ g(l, h, s);
321
321
  }
322
322
  }), d = o.length;
323
323
  for (let l = 0; l < d; l += 1) {
324
324
  if ((y = r == null ? void 0 : r.shouldAbort) != null && y.call(r))
325
325
  throw new Error("Aborted.");
326
- const p = o[l];
327
- if (!p) {
328
- r != null && r.onProgress && (l + 1 === d || l + 1 === c) && (r.onProgress(l + 1, d), c += i), a > 0 && (l + 1 === d || l + 1 === u) && (await new Promise((x) => {
329
- setTimeout(x, 0);
326
+ const h = o[l];
327
+ if (!h) {
328
+ r != null && r.onProgress && (l + 1 === d || l + 1 === c) && (r.onProgress(l + 1, d), c += i), a > 0 && (l + 1 === d || l + 1 === u) && (await new Promise((M) => {
329
+ setTimeout(M, 0);
330
330
  }), u += a);
331
331
  continue;
332
332
  }
333
- f.processLine(p), r != null && r.onProgress && (l + 1 === d || l + 1 === c) && (r.onProgress(l + 1, d), c += i), a > 0 && (l + 1 === d || l + 1 === u) && (await new Promise((x) => {
334
- setTimeout(x, 0);
333
+ f.processLine(h), r != null && r.onProgress && (l + 1 === d || l + 1 === c) && (r.onProgress(l + 1, d), c += i), a > 0 && (l + 1 === d || l + 1 === u) && (await new Promise((M) => {
334
+ setTimeout(M, 0);
335
335
  }), u += a);
336
336
  }
337
337
  return {
338
338
  rapid: Float32Array.from(n),
339
- cutting: Float32Array.from(t)
339
+ cutting: Float32Array.from(e)
340
340
  };
341
341
  }
342
- async function se(o, e = {}) {
343
- var w;
344
- const n = [], t = e.arcSegments ?? 30, s = e.batch, r = Math.max(1, Math.floor((s == null ? void 0 : s.everyLines) ?? 5e3)), i = Math.max(0, Math.floor((s == null ? void 0 : s.yieldEveryLines) ?? 5e4));
342
+ async function se(o, t = {}) {
343
+ var G;
344
+ const n = [], e = t.arcSegments ?? 30, s = t.batch, r = Math.max(1, Math.floor((s == null ? void 0 : s.everyLines) ?? 5e3)), i = Math.max(0, Math.floor((s == null ? void 0 : s.yieldEveryLines) ?? 5e4));
345
345
  let a = r, c = i > 0 ? i : Number.POSITIVE_INFINITY;
346
346
  const u = new Int32Array(o.length);
347
347
  u.fill(-1);
348
348
  const f = new Int32Array(o.length);
349
349
  f.fill(-1);
350
350
  const d = new Uint8Array(o.length), y = new Int32Array(o.length);
351
- let l = -1, p = 0;
352
- const x = new L({
353
- onLinearMove: (h) => {
354
- const G = h.modals.motion === "G0" ? 1 : 2;
355
- l >= 0 && (p === 0 ? p = G : p !== G && (p = 3)), z(h, n);
351
+ let l = -1, h = 0;
352
+ const M = new L({
353
+ onLinearMove: (p) => {
354
+ const w = p.modals.motion === "G0" ? 1 : 2;
355
+ l >= 0 && (h === 0 ? h = w : h !== w && (h = 3)), z(p, n);
356
356
  },
357
- onArcMove: (h) => {
358
- const G = h.modals.motion === "G0" ? 1 : 2;
359
- l >= 0 && (p === 0 ? p = G : p !== G && (p = 3)), g(h, n, t);
357
+ onArcMove: (p) => {
358
+ const w = p.modals.motion === "G0" ? 1 : 2;
359
+ l >= 0 && (h === 0 ? h = w : h !== w && (h = 3)), g(p, n, e);
360
360
  }
361
361
  }), A = o.length;
362
- for (let h = 0; h < A; h += 1) {
363
- if ((w = s == null ? void 0 : s.shouldAbort) != null && w.call(s))
362
+ for (let p = 0; p < A; p += 1) {
363
+ if ((G = s == null ? void 0 : s.shouldAbort) != null && G.call(s))
364
364
  throw new Error("Aborted.");
365
- const G = n.length / 3;
366
- l = h, p = 0;
367
- const P = o[h];
368
- P && x.processLine(P), l = -1;
365
+ const w = n.length / 3;
366
+ l = p, h = 0;
367
+ const S = o[p];
368
+ S && M.processLine(S), l = -1;
369
369
  const I = n.length / 3;
370
- I > G && (u[h] = G, f[h] = I, d[h] = p), y[h] = I, s != null && s.onProgress && (h + 1 === A || h + 1 === a) && (s.onProgress(h + 1, A), a += r), i > 0 && (h + 1 === A || h + 1 === c) && (await new Promise((m) => {
370
+ I > w && (u[p] = w, f[p] = I, d[p] = h), y[p] = I, s != null && s.onProgress && (p + 1 === A || p + 1 === a) && (s.onProgress(p + 1, A), a += r), i > 0 && (p + 1 === A || p + 1 === c) && (await new Promise((m) => {
371
371
  setTimeout(m, 0);
372
372
  }), c += i);
373
373
  }
@@ -379,28 +379,28 @@ async function se(o, e = {}) {
379
379
  prefixEndVertex: y
380
380
  };
381
381
  }
382
- function ie(o, e = {}) {
383
- const n = e.arcSegments ?? 30, t = Math.max(1, Math.floor(e.bucketCount ?? 16)), s = e.baseOpacity ?? 0.9, { minPower: r, maxPower: i } = ee(o), a = [], c = Array.from({ length: t }, () => []), u = new L({
382
+ function ie(o, t = {}) {
383
+ const n = t.arcSegments ?? 30, e = Math.max(1, Math.floor(t.bucketCount ?? 16)), s = t.baseOpacity ?? 0.9, { minPower: r, maxPower: i } = ee(o), a = [], c = Array.from({ length: e }, () => []), u = new L({
384
384
  onLinearMove: (d) => {
385
385
  const y = d.transformedStart ?? d.start, l = d.transformedEnd ?? d.end;
386
386
  if (d.modals.motion === "G0") {
387
387
  a.push(y.X, y.Y, y.Z, l.X, l.Y, l.Z);
388
388
  return;
389
389
  }
390
- const p = B(d.modals.spindleSpeed, r, i, t);
391
- c[p].push(y.X, y.Y, y.Z, l.X, l.Y, l.Z);
390
+ const h = B(d.modals.spindleSpeed, r, i, e);
391
+ c[h].push(y.X, y.Y, y.Z, l.X, l.Y, l.Z);
392
392
  },
393
393
  onArcMove: (d) => {
394
394
  if (d.modals.motion === "G0")
395
395
  return;
396
- const y = B(d.modals.spindleSpeed, r, i, t), l = c[y];
396
+ const y = B(d.modals.spindleSpeed, r, i, e), l = c[y];
397
397
  g(d, l, n);
398
398
  }
399
399
  });
400
400
  for (const d of o)
401
401
  d && u.processLine(d);
402
402
  const f = c.map((d, y) => ({
403
- opacity: O(y, t, s),
403
+ opacity: O(y, e, s),
404
404
  vertices: Float32Array.from(d)
405
405
  }));
406
406
  return {
@@ -410,29 +410,29 @@ function ie(o, e = {}) {
410
410
  maxPower: i
411
411
  };
412
412
  }
413
- async function ae(o, e = {}) {
414
- const n = await K(o, e);
413
+ async function ae(o, t = {}) {
414
+ const n = await K(o, t);
415
415
  return {
416
416
  rapid: n.rapidPositions,
417
- buckets: n.buckets.map((t) => ({ opacity: t.opacity, vertices: t.positions })),
417
+ buckets: n.buckets.map((e) => ({ opacity: e.opacity, vertices: e.positions })),
418
418
  minPower: n.minPower,
419
419
  maxPower: n.maxPower
420
420
  };
421
421
  }
422
- async function j(o, e = {}) {
423
- var P, I;
424
- const n = e.arcSegments ?? 30, t = Math.max(1, Math.floor(e.bucketCount ?? 16)), s = !!e.laserMode, r = e.batch, i = o.length * (s ? 2 : 1), a = Math.max(1, Math.floor((r == null ? void 0 : r.everyLines) ?? 5e3)), c = Math.max(0, Math.floor((r == null ? void 0 : r.yieldEveryLines) ?? 5e4));
422
+ async function D(o, t = {}) {
423
+ var S, I;
424
+ const n = t.arcSegments ?? 30, e = Math.max(1, Math.floor(t.bucketCount ?? 16)), s = !!t.laserMode, r = t.batch, i = o.length * (s ? 2 : 1), a = Math.max(1, Math.floor((r == null ? void 0 : r.everyLines) ?? 5e3)), c = Math.max(0, Math.floor((r == null ? void 0 : r.yieldEveryLines) ?? 5e4));
425
425
  let u = a, f = c > 0 ? c : Number.POSITIVE_INFINITY, d = Number.NEGATIVE_INFINITY, y = !1;
426
426
  if (s) {
427
427
  const m = new R();
428
- for (const M of o) {
429
- if (!M)
428
+ for (const x of o) {
429
+ if (!x)
430
430
  continue;
431
- if (m.parseLine(M).gcodes.some((Y) => {
432
- if (Y.letter !== "M")
431
+ if (m.parseLine(x).gcodes.some((E) => {
432
+ if (E.letter !== "M")
433
433
  return !1;
434
- const E = Math.trunc(Y.value);
435
- return E === 3 || E === 4 || E === 5;
434
+ const Y = Math.trunc(E.value);
435
+ return Y === 3 || Y === 4 || Y === 5;
436
436
  })) {
437
437
  y = !1;
438
438
  break;
@@ -443,97 +443,97 @@ async function j(o, e = {}) {
443
443
  const l = (m) => m.spindle === "M5" || !(m.spindle === "M3" || m.spindle === "M4" || y && m.spindle === null) ? !1 : m.spindleSpeed === null ? !0 : m.spindleSpeed > 0;
444
444
  if (s) {
445
445
  const m = new L({
446
- onLinearMove: (M) => {
447
- if (!l(M.modals))
446
+ onLinearMove: (x) => {
447
+ if (!l(x.modals))
448
448
  return;
449
- const v = M.modals.spindleSpeed;
449
+ const v = x.modals.spindleSpeed;
450
450
  v === null || v <= 0 || (d = Math.max(d, v));
451
451
  },
452
- onArcMove: (M) => {
453
- if (!l(M.modals))
452
+ onArcMove: (x) => {
453
+ if (!l(x.modals))
454
454
  return;
455
- const v = M.modals.spindleSpeed;
455
+ const v = x.modals.spindleSpeed;
456
456
  v === null || v <= 0 || (d = Math.max(d, v));
457
457
  }
458
458
  });
459
- for (let M = 0; M < o.length; M += 1) {
460
- if ((P = r == null ? void 0 : r.shouldAbort) != null && P.call(r))
459
+ for (let x = 0; x < o.length; x += 1) {
460
+ if ((S = r == null ? void 0 : r.shouldAbort) != null && S.call(r))
461
461
  throw new Error("Aborted.");
462
- const v = o[M];
462
+ const v = o[x];
463
463
  v && m.processLine(v);
464
- const S = M + 1;
465
- r != null && r.onProgress && (S === i || S === u) && (r.onProgress(S, i), u += a), c > 0 && (S === i || S === f) && (await new Promise((Y) => {
466
- setTimeout(Y, 0);
464
+ const P = x + 1;
465
+ r != null && r.onProgress && (P === i || P === u) && (r.onProgress(P, i), u += a), c > 0 && (P === i || P === f) && (await new Promise((E) => {
466
+ setTimeout(E, 0);
467
467
  }), f += c);
468
468
  }
469
469
  Number.isFinite(d) || (d = 0);
470
470
  } else
471
471
  d = 0;
472
- const p = (m) => {
473
- if (t <= 1)
472
+ const h = (m) => {
473
+ if (e <= 1)
474
474
  return 0;
475
475
  if (m === null)
476
- return t - 1;
477
- const M = m;
478
- if (M <= 0)
476
+ return e - 1;
477
+ const x = m;
478
+ if (x <= 0)
479
479
  return 0;
480
480
  if (d <= 0)
481
- return t - 1;
482
- const v = Math.min(1, Math.max(0, M / d)), S = 1 + Math.floor(v * (t - 2));
483
- return Math.min(t - 1, Math.max(1, S));
484
- }, x = [], A = s ? Array.from({ length: t }, () => []) : [new Array()], w = new Int32Array(o.length), h = Array.from(
485
- { length: s ? t : 1 },
481
+ return e - 1;
482
+ const v = Math.min(1, Math.max(0, x / d)), P = 1 + Math.floor(v * (e - 2));
483
+ return Math.min(e - 1, Math.max(1, P));
484
+ }, M = [], A = s ? Array.from({ length: e }, () => []) : [new Array()], G = new Int32Array(o.length), p = Array.from(
485
+ { length: s ? e : 1 },
486
486
  () => new Int32Array(o.length)
487
- ), G = new L({
487
+ ), w = new L({
488
488
  onLinearMove: (m) => {
489
- const M = m.transformedStart ?? m.start, v = m.transformedEnd ?? m.end;
489
+ const x = m.transformedStart ?? m.start, v = m.transformedEnd ?? m.end;
490
490
  if (m.modals.motion === "G0") {
491
- x.push(M.X, M.Y, M.Z, v.X, v.Y, v.Z);
491
+ M.push(x.X, x.Y, x.Z, v.X, v.Y, v.Z);
492
492
  return;
493
493
  }
494
494
  if (s && !l(m.modals))
495
495
  return;
496
- const S = s ? p(m.modals.spindleSpeed) : 0;
497
- A[S].push(M.X, M.Y, M.Z, v.X, v.Y, v.Z);
496
+ const P = s ? h(m.modals.spindleSpeed) : 0;
497
+ A[P].push(x.X, x.Y, x.Z, v.X, v.Y, v.Z);
498
498
  },
499
499
  onArcMove: (m) => {
500
500
  if (m.modals.motion === "G0" || s && !l(m.modals))
501
501
  return;
502
- const M = s ? p(m.modals.spindleSpeed) : 0, v = A[M];
502
+ const x = s ? h(m.modals.spindleSpeed) : 0, v = A[x];
503
503
  g(m, v, n);
504
504
  }
505
505
  });
506
506
  for (let m = 0; m < o.length; m += 1) {
507
507
  if ((I = r == null ? void 0 : r.shouldAbort) != null && I.call(r))
508
508
  throw new Error("Aborted.");
509
- const M = o[m];
510
- M && G.processLine(M), w[m] = x.length / 3;
511
- for (let S = 0; S < A.length; S += 1)
512
- h[S][m] = A[S].length / 3;
509
+ const x = o[m];
510
+ x && w.processLine(x), G[m] = M.length / 3;
511
+ for (let P = 0; P < A.length; P += 1)
512
+ p[P][m] = A[P].length / 3;
513
513
  const v = s ? o.length + m + 1 : m + 1;
514
- r != null && r.onProgress && (v === i || v === u) && (r.onProgress(v, i), u += a), c > 0 && (v === i || v === f) && (await new Promise((S) => {
515
- setTimeout(S, 0);
514
+ r != null && r.onProgress && (v === i || v === u) && (r.onProgress(v, i), u += a), c > 0 && (v === i || v === f) && (await new Promise((P) => {
515
+ setTimeout(P, 0);
516
516
  }), f += c);
517
517
  }
518
518
  return {
519
- rapid: { positions: Float32Array.from(x), prefixEndVertex: w },
520
- cuts: A.map((m, M) => ({
519
+ rapid: { positions: Float32Array.from(M), prefixEndVertex: G },
520
+ cuts: A.map((m, x) => ({
521
521
  positions: Float32Array.from(m),
522
- prefixEndVertex: h[M]
522
+ prefixEndVertex: p[x]
523
523
  })),
524
524
  cutBucketCount: A.length,
525
525
  minPower: 0,
526
526
  maxPower: d
527
527
  };
528
528
  }
529
- async function K(o, e = {}) {
530
- const n = Math.max(1, Math.floor(e.bucketCount ?? 16)), t = e.baseOpacity ?? 0.9, s = await j(o, {
531
- arcSegments: e.arcSegments,
529
+ async function K(o, t = {}) {
530
+ const n = Math.max(1, Math.floor(t.bucketCount ?? 16)), e = t.baseOpacity ?? 0.9, s = await D(o, {
531
+ arcSegments: t.arcSegments,
532
532
  bucketCount: n,
533
533
  laserMode: !0,
534
- batch: e.batch
534
+ batch: t.batch
535
535
  }), r = s.cuts.map((i, a) => ({
536
- opacity: O(a, n, t),
536
+ opacity: O(a, n, e),
537
537
  positions: i.positions,
538
538
  prefixEndVertex: i.prefixEndVertex
539
539
  }));
@@ -545,15 +545,15 @@ async function K(o, e = {}) {
545
545
  maxPower: s.maxPower
546
546
  };
547
547
  }
548
- function ce(o, e) {
549
- o.push(e.X, e.Y, e.Z);
548
+ function ce(o, t) {
549
+ o.push(t.X, t.Y, t.Z);
550
550
  }
551
- function z(o, e) {
552
- const n = o.transformedStart ?? o.start, t = o.transformedEnd ?? o.end;
553
- e.push(n.X, n.Y, n.Z, t.X, t.Y, t.Z);
551
+ function z(o, t) {
552
+ const n = o.transformedStart ?? o.start, e = o.transformedEnd ?? o.end;
553
+ t.push(n.X, n.Y, n.Z, e.X, e.Y, e.Z);
554
554
  }
555
- function g(o, e, n) {
556
- const t = Math.max(1, Math.floor(n)), { primary: s, secondary: r } = H(o.plane), i = J(
555
+ function g(o, t, n) {
556
+ const e = Math.max(1, Math.floor(n)), { primary: s, secondary: r } = H(o.plane), i = J(
557
557
  o.start[s],
558
558
  o.start[r],
559
559
  o.center[s],
@@ -569,87 +569,87 @@ function g(o, e, n) {
569
569
  o.motion === "G2" ? f <= d && (f += u) : d <= f && (d += u);
570
570
  const y = o.motion === "G2" ? f - d : d - f;
571
571
  let l = { ...o.start };
572
- for (let p = 1; p <= t; p += 1) {
573
- const x = p / t, A = o.motion === "G2" ? f - y * x : f + y * x, w = Q(o.start, o.end, x);
574
- w[s] = o.center[s] + i * Math.cos(A), w[r] = o.center[r] + i * Math.sin(A);
575
- const h = T(l), G = T(w);
576
- e.push(
577
- h.X,
578
- h.Y,
579
- h.Z,
580
- G.X,
581
- G.Y,
582
- G.Z
583
- ), l = w;
572
+ for (let h = 1; h <= e; h += 1) {
573
+ const M = h / e, A = o.motion === "G2" ? f - y * M : f + y * M, G = Q(o.start, o.end, M);
574
+ G[s] = o.center[s] + i * Math.cos(A), G[r] = o.center[r] + i * Math.sin(A);
575
+ const p = T(l), w = T(G);
576
+ t.push(
577
+ p.X,
578
+ p.Y,
579
+ p.Z,
580
+ w.X,
581
+ w.Y,
582
+ w.Z
583
+ ), l = G;
584
584
  }
585
585
  }
586
586
  function T(o) {
587
- const e = o.A * Math.PI / 180, n = Math.cos(e), t = Math.sin(e), s = o.Y * n - o.Z * t, r = o.Y * t + o.Z * n;
587
+ const t = o.A * Math.PI / 180, n = Math.cos(t), e = Math.sin(t), s = o.Y * n - o.Z * e, r = o.Y * e + o.Z * n;
588
588
  return { ...o, Y: s, Z: r };
589
589
  }
590
590
  function H(o) {
591
591
  return o === "G18" ? { primary: "Z", secondary: "X" } : o === "G19" ? { primary: "Y", secondary: "Z" } : { primary: "X", secondary: "Y" };
592
592
  }
593
593
  function k(o) {
594
- const e = Math.PI * 2;
595
- let n = o % e;
596
- return n < 0 && (n += e), n;
594
+ const t = Math.PI * 2;
595
+ let n = o % t;
596
+ return n < 0 && (n += t), n;
597
597
  }
598
- function J(o, e, n, t) {
599
- return Math.hypot(o - n, e - t);
598
+ function J(o, t, n, e) {
599
+ return Math.hypot(o - n, t - e);
600
600
  }
601
- function Q(o, e, n) {
601
+ function Q(o, t, n) {
602
602
  return {
603
- X: o.X + (e.X - o.X) * n,
604
- Y: o.Y + (e.Y - o.Y) * n,
605
- Z: o.Z + (e.Z - o.Z) * n,
606
- A: o.A + (e.A - o.A) * n,
607
- B: o.B + (e.B - o.B) * n,
608
- C: o.C + (e.C - o.C) * n
603
+ X: o.X + (t.X - o.X) * n,
604
+ Y: o.Y + (t.Y - o.Y) * n,
605
+ Z: o.Z + (t.Z - o.Z) * n,
606
+ A: o.A + (t.A - o.A) * n,
607
+ B: o.B + (t.B - o.B) * n,
608
+ C: o.C + (t.C - o.C) * n
609
609
  };
610
610
  }
611
611
  function ee(o) {
612
- let e = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
613
- const t = new L({
612
+ let t = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
613
+ const e = new L({
614
614
  onLinearMove: (s) => {
615
615
  const r = s.modals.spindleSpeed;
616
- r !== null && (e = Math.min(e, r), n = Math.max(n, r));
616
+ r !== null && (t = Math.min(t, r), n = Math.max(n, r));
617
617
  },
618
618
  onArcMove: (s) => {
619
619
  const r = s.modals.spindleSpeed;
620
- r !== null && (e = Math.min(e, r), n = Math.max(n, r));
620
+ r !== null && (t = Math.min(t, r), n = Math.max(n, r));
621
621
  }
622
622
  });
623
623
  for (const s of o)
624
- s && t.processLine(s);
625
- return !Number.isFinite(e) || !Number.isFinite(n) ? { minPower: 0, maxPower: 0 } : { minPower: e, maxPower: n };
624
+ s && e.processLine(s);
625
+ return !Number.isFinite(t) || !Number.isFinite(n) ? { minPower: 0, maxPower: 0 } : { minPower: t, maxPower: n };
626
626
  }
627
- function B(o, e, n, t) {
628
- if (t <= 1)
627
+ function B(o, t, n, e) {
628
+ if (e <= 1)
629
629
  return 0;
630
- const s = o ?? e;
631
- if (n <= e)
632
- return t - 1;
633
- const r = (s - e) / (n - e), i = Math.floor(r * (t - 1));
634
- return Math.min(t - 1, Math.max(0, i));
630
+ const s = o ?? t;
631
+ if (n <= t)
632
+ return e - 1;
633
+ const r = (s - t) / (n - t), i = Math.floor(r * (e - 1));
634
+ return Math.min(e - 1, Math.max(0, i));
635
635
  }
636
- function O(o, e, n) {
637
- if (e <= 1)
636
+ function O(o, t, n) {
637
+ if (t <= 1)
638
638
  return n;
639
- const t = o / (e - 1);
640
- return n * t;
639
+ const e = o / (t - 1);
640
+ return n * e;
641
641
  }
642
642
  function le(o) {
643
- const e = new Float32Array(o.vertices), n = new Uint32Array(o.frames), t = new Float32Array(o.colorArrayBuffer), { verticesLen: s, framesLen: r } = o, i = /* @__PURE__ */ new Map();
643
+ const t = new Float32Array(o.vertices), n = new Uint32Array(o.frames), e = new Float32Array(o.colorArrayBuffer), { verticesLen: s, framesLen: r } = o, i = /* @__PURE__ */ new Map();
644
644
  for (let a = 0; a < r; a++) {
645
645
  const c = n[a], u = a < r - 1 ? n[a + 1] : s / 3;
646
646
  if (u <= c + 1) continue;
647
- const f = c * 4, d = t[f], y = t[f + 1], l = t[f + 2], p = t[f + 3], x = te(d, y, l), A = `${x}|${Math.round(p * 100)}`;
648
- let w = i.get(A);
649
- w || (w = { hexColor: x, opacity: p, pos: [], rgb: [] }, i.set(A, w));
650
- for (let h = c; h < u - 1; h++) {
651
- const G = h * 3, P = (h + 1) * 3;
652
- w.pos.push(e[G], e[G + 1], e[G + 2], e[P], e[P + 1], e[P + 2]), w.rgb.push(d, y, l, d, y, l);
647
+ const f = c * 4, d = e[f], y = e[f + 1], l = e[f + 2], h = e[f + 3], M = te(d, y, l), A = `${M}|${Math.round(h * 100)}`;
648
+ let G = i.get(A);
649
+ G || (G = { hexColor: M, opacity: h, pos: [], rgb: [] }, i.set(A, G));
650
+ for (let p = c; p < u - 1; p++) {
651
+ const w = p * 3, S = (p + 1) * 3;
652
+ G.pos.push(t[w], t[w + 1], t[w + 2], t[S], t[S + 1], t[S + 2]), G.rgb.push(d, y, l, d, y, l);
653
653
  }
654
654
  }
655
655
  return Array.from(i.values()).map(({ hexColor: a, opacity: c, pos: u, rgb: f }) => ({
@@ -659,9 +659,37 @@ function le(o) {
659
659
  rgbColors: new Float32Array(f)
660
660
  }));
661
661
  }
662
- function te(o, e, n) {
663
- const t = (s) => Math.round(Math.min(1, Math.max(0, s)) * 255).toString(16).padStart(2, "0");
664
- return `#${t(o)}${t(e)}${t(n)}`;
662
+ function te(o, t, n) {
663
+ const e = (s) => Math.round(Math.min(1, Math.max(0, s)) * 255).toString(16).padStart(2, "0");
664
+ return `#${e(o)}${e(t)}${e(n)}`;
665
+ }
666
+ function de(o) {
667
+ const t = new Float32Array(o.vertices), n = new Uint32Array(o.frames), e = new Float32Array(o.colorArrayBuffer), { verticesLen: s, framesLen: r } = o, i = [], a = [], c = [], u = [], f = new Int32Array(r), d = new Int32Array(r);
668
+ for (let y = 0; y < r; y++) {
669
+ const l = n[y], h = y < r - 1 ? n[y + 1] : s / 3;
670
+ if (h > l + 1) {
671
+ const M = e[l * 4 + 3] < 0.75, A = M ? i : c, G = M ? a : u;
672
+ for (let p = l; p < h - 1; p++) {
673
+ const w = p * 3, S = (p + 1) * 3;
674
+ A.push(t[w], t[w + 1], t[w + 2], t[S], t[S + 1], t[S + 2]);
675
+ const I = p * 4, m = (p + 1) * 4;
676
+ G.push(e[I], e[I + 1], e[I + 2], e[m], e[m + 1], e[m + 2]);
677
+ }
678
+ }
679
+ f[y] = i.length / 3, d[y] = c.length / 3;
680
+ }
681
+ return {
682
+ rapid: {
683
+ positions: Float32Array.from(i),
684
+ colors: Float32Array.from(a),
685
+ prefixEndVertex: f
686
+ },
687
+ cut: {
688
+ positions: Float32Array.from(c),
689
+ colors: Float32Array.from(u),
690
+ prefixEndVertex: d
691
+ }
692
+ };
665
693
  }
666
694
  export {
667
695
  R as GCodeParser,
@@ -672,8 +700,9 @@ export {
672
700
  se as buildMovementGeometryFromLinesBatched,
673
701
  oe as buildMovementVerticesFromLines,
674
702
  re as buildMovementVerticesFromLinesBatched,
675
- j as buildToolpathGeometryFromLinesBatched,
703
+ D as buildToolpathGeometryFromLinesBatched,
676
704
  ne as buildVerticesFromLines,
677
705
  le as buildWorkerSegmentGroups,
706
+ de as buildWorkerToolpathStreams,
678
707
  ce as pushXYZ
679
708
  };