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