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