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