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