three-slicer-viewer 0.2.5 → 0.3.1
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/COMPONENTS.md +4 -1
- package/README.md +7 -3
- package/TOOLPATH_SPEC.md +2 -2
- package/VIEWER.md +68 -1
- package/dist/components.js +102 -111
- package/dist/gcode_parse.js +148 -146
- package/dist/index.js +3615 -3619
- package/dist/model_loaders-aHV5ix50.js +188 -0
- package/dist/model_loaders.js +12 -181
- package/dist/{parse_3mf-CQ5rAX6P.js → parse_3mf-jEUAw8JM.js} +49 -48
- package/dist/parse_3mf.worker.js +1 -1
- package/dist/shadow_host-CQ3LirzD.js +16 -0
- package/dist/sl1_encode.worker.js +1 -1
- package/dist/{sl1_write-CvrNejbW.js → sl1_write-BovHbg3k.js} +66 -65
- package/dist/sla_reconstruct-CRZ3TrI1.js +178 -0
- package/dist/sla_reconstruct.worker.js +1 -1
- package/dist/sla_slice.worker.js +22 -21
- package/dist/theme-2oyfMuvf.js +97 -0
- package/dist/toolpath.js +132 -129
- package/dist/toolpath_encoding-BuYs95qZ.js +23 -0
- package/dist/viewer_defaults-B7UUZ582.js +28 -0
- package/package.json +37 -5
- package/src/settings/index.js +2 -0
- package/src/settings/kernel_defaults.js +144 -0
- package/src/settings/settings_core.js +114 -131
- package/types/loaders.d.ts +2 -2
- package/types/settings.d.ts +12 -0
- package/dist/sla_reconstruct-CXkYhux2.js +0 -176
package/dist/gcode_parse.js
CHANGED
|
@@ -1,190 +1,192 @@
|
|
|
1
|
-
|
|
1
|
+
import { D as at, a as rt } from "./viewer_defaults-B7UUZ582.js";
|
|
2
|
+
import { R as t, e as B } from "./toolpath_encoding-BuYs95qZ.js";
|
|
3
|
+
const F = 1e-6, lt = {
|
|
2
4
|
// OrcaSlicer / PrusaSlicer ;TYPE: names
|
|
3
|
-
"outer wall":
|
|
4
|
-
"external perimeter":
|
|
5
|
-
"inner wall":
|
|
6
|
-
perimeter:
|
|
7
|
-
"internal perimeter":
|
|
8
|
-
"overhang wall":
|
|
9
|
-
"overhang perimeter":
|
|
10
|
-
"sparse infill":
|
|
11
|
-
"internal infill":
|
|
12
|
-
"solid infill":
|
|
13
|
-
"internal solid infill":
|
|
14
|
-
"top solid infill":
|
|
15
|
-
"top surface":
|
|
16
|
-
"bottom surface":
|
|
17
|
-
skirt:
|
|
18
|
-
brim:
|
|
19
|
-
"skirt/brim":
|
|
20
|
-
support:
|
|
21
|
-
"support material":
|
|
22
|
-
"support material interface":
|
|
23
|
-
"support interface":
|
|
24
|
-
"support transition":
|
|
25
|
-
raft:
|
|
26
|
-
"gap fill":
|
|
27
|
-
"gap infill":
|
|
28
|
-
"thin wall":
|
|
29
|
-
bridge:
|
|
30
|
-
"bridge infill":
|
|
31
|
-
"internal bridge":
|
|
32
|
-
"internal bridge infill":
|
|
33
|
-
ironing:
|
|
34
|
-
"prime tower":
|
|
35
|
-
"wipe tower":
|
|
36
|
-
custom:
|
|
5
|
+
"outer wall": t.WALL,
|
|
6
|
+
"external perimeter": t.WALL,
|
|
7
|
+
"inner wall": t.WALL,
|
|
8
|
+
perimeter: t.WALL,
|
|
9
|
+
"internal perimeter": t.WALL,
|
|
10
|
+
"overhang wall": t.WALL,
|
|
11
|
+
"overhang perimeter": t.WALL,
|
|
12
|
+
"sparse infill": t.SPARSE,
|
|
13
|
+
"internal infill": t.SPARSE,
|
|
14
|
+
"solid infill": t.SOLID,
|
|
15
|
+
"internal solid infill": t.SOLID,
|
|
16
|
+
"top solid infill": t.SOLID,
|
|
17
|
+
"top surface": t.SOLID,
|
|
18
|
+
"bottom surface": t.SOLID,
|
|
19
|
+
skirt: t.SKIRT,
|
|
20
|
+
brim: t.SKIRT,
|
|
21
|
+
"skirt/brim": t.SKIRT,
|
|
22
|
+
support: t.SUPPORT,
|
|
23
|
+
"support material": t.SUPPORT,
|
|
24
|
+
"support material interface": t.SUPPORT,
|
|
25
|
+
"support interface": t.SUPPORT,
|
|
26
|
+
"support transition": t.SUPPORT,
|
|
27
|
+
raft: t.RAFT,
|
|
28
|
+
"gap fill": t.GAP,
|
|
29
|
+
"gap infill": t.GAP,
|
|
30
|
+
"thin wall": t.THIN,
|
|
31
|
+
bridge: t.BRIDGE,
|
|
32
|
+
"bridge infill": t.BRIDGE,
|
|
33
|
+
"internal bridge": t.BRIDGE,
|
|
34
|
+
"internal bridge infill": t.BRIDGE,
|
|
35
|
+
ironing: t.IRONING,
|
|
36
|
+
"prime tower": t.PRIME,
|
|
37
|
+
"wipe tower": t.PRIME,
|
|
38
|
+
custom: t.WALL,
|
|
37
39
|
// Cura ;TYPE: names
|
|
38
|
-
"wall-outer":
|
|
39
|
-
"wall-inner":
|
|
40
|
-
fill:
|
|
41
|
-
skin:
|
|
42
|
-
"support-interface":
|
|
43
|
-
"prime-tower":
|
|
44
|
-
},
|
|
45
|
-
["skirt/brim",
|
|
46
|
-
["skirt",
|
|
47
|
-
["walls",
|
|
48
|
-
["thin-wall",
|
|
49
|
-
["gap-fill",
|
|
50
|
-
["bridge",
|
|
51
|
-
["ironing",
|
|
52
|
-
["support",
|
|
53
|
-
["prime tower",
|
|
54
|
-
["wipe_tower_real",
|
|
55
|
-
],
|
|
56
|
-
1:
|
|
57
|
-
2:
|
|
58
|
-
3:
|
|
59
|
-
4:
|
|
60
|
-
5:
|
|
61
|
-
6:
|
|
62
|
-
7:
|
|
63
|
-
8:
|
|
64
|
-
9:
|
|
65
|
-
10:
|
|
66
|
-
11:
|
|
67
|
-
12:
|
|
68
|
-
13:
|
|
69
|
-
14:
|
|
70
|
-
15:
|
|
71
|
-
16:
|
|
72
|
-
17:
|
|
40
|
+
"wall-outer": t.WALL,
|
|
41
|
+
"wall-inner": t.WALL,
|
|
42
|
+
fill: t.SPARSE,
|
|
43
|
+
skin: t.SOLID,
|
|
44
|
+
"support-interface": t.SUPPORT,
|
|
45
|
+
"prime-tower": t.PRIME
|
|
46
|
+
}, ot = [
|
|
47
|
+
["skirt/brim", t.SKIRT],
|
|
48
|
+
["skirt", t.SKIRT],
|
|
49
|
+
["walls", t.WALL],
|
|
50
|
+
["thin-wall", t.THIN],
|
|
51
|
+
["gap-fill", t.GAP],
|
|
52
|
+
["bridge", t.BRIDGE],
|
|
53
|
+
["ironing", t.IRONING],
|
|
54
|
+
["support", t.SUPPORT],
|
|
55
|
+
["prime tower", t.PRIME],
|
|
56
|
+
["wipe_tower_real", t.PRIME]
|
|
57
|
+
], ct = (I, f) => I === f || f.length < I.length && " (:/".includes(I[f.length]) && I.startsWith(f), ft = {
|
|
58
|
+
1: t.WALL,
|
|
59
|
+
2: t.WALL,
|
|
60
|
+
3: t.WALL,
|
|
61
|
+
4: t.SPARSE,
|
|
62
|
+
5: t.SOLID,
|
|
63
|
+
6: t.SOLID,
|
|
64
|
+
7: t.SOLID,
|
|
65
|
+
8: t.IRONING,
|
|
66
|
+
9: t.BRIDGE,
|
|
67
|
+
10: t.BRIDGE,
|
|
68
|
+
11: t.GAP,
|
|
69
|
+
12: t.SKIRT,
|
|
70
|
+
13: t.SKIRT,
|
|
71
|
+
14: t.SUPPORT,
|
|
72
|
+
15: t.SUPPORT,
|
|
73
|
+
16: t.SUPPORT,
|
|
74
|
+
17: t.PRIME
|
|
73
75
|
};
|
|
74
|
-
function
|
|
75
|
-
const
|
|
76
|
-
let
|
|
77
|
-
const
|
|
78
|
-
let
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
const
|
|
83
|
-
if (!(
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
} else
|
|
76
|
+
function Lt(I, f = {}) {
|
|
77
|
+
const it = Math.PI / 4 * (f.filamentDiameter > 0 ? f.filamentDiameter : at) ** 2, nt = f.defaultLayerHeight > 0 ? f.defaultLayerHeight : rt;
|
|
78
|
+
let p = 0, u = 0, h = 0, G = 0, d = !0, O = !0, w = 0, T = t.WALL, W = 0, L = null;
|
|
79
|
+
const P = [];
|
|
80
|
+
let b = !1, D = !0, K = NaN, z = 0, H = 0, k = 0;
|
|
81
|
+
const Y = /* @__PURE__ */ new Set([0]), y = (a) => {
|
|
82
|
+
L = { z: a, p: [], w: [] }, P.push(L), D = !1, K = NaN, T = t.WALL, W = 0;
|
|
83
|
+
}, st = () => P.length > 1 ? P[P.length - 2].z : 0, Z = (a, c, R, A, m, i, e) => {
|
|
84
|
+
const r = Math.hypot(A - a, m - c, i - R);
|
|
85
|
+
if (!(r < F))
|
|
86
|
+
if (e > F) {
|
|
87
|
+
k += e, D ? y(Number.isNaN(K) ? i : K) : !b && i > L.z + 1e-3 && y(i);
|
|
88
|
+
const l = B(T, w);
|
|
89
|
+
L.p.push(a, c, R, l, A, m, i, l);
|
|
90
|
+
const n = Math.max(0.02, L.z - st() || nt), _ = W > 0 ? W : e * it / (r * n) + n * (1 - Math.PI / 4);
|
|
91
|
+
L.w.push(Math.min(3, Math.max(0.05, _))), z++;
|
|
92
|
+
} else L && (L.p.push(a, c, R, B(t.TRAVEL, w), A, m, i, B(t.TRAVEL, w)), L.w.push(0), H++);
|
|
91
93
|
};
|
|
92
|
-
for (const
|
|
94
|
+
for (const a of I.split(`
|
|
93
95
|
`)) {
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
|
|
96
|
+
const c = a.indexOf(";"), R = (c < 0 ? a : a.slice(0, c)).trim(), A = c < 0 ? "" : a.slice(c + 1).trim();
|
|
97
|
+
if (A && !R) {
|
|
98
|
+
const e = A.toLowerCase();
|
|
99
|
+
if (e.startsWith("type:")) {
|
|
100
|
+
T = lt[e.slice(5).trim()] ?? t.WALL;
|
|
99
101
|
continue;
|
|
100
102
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
+
if (e.startsWith("_extrusion_role:")) {
|
|
104
|
+
T = ft[parseInt(e.slice(16), 10)] ?? t.WALL;
|
|
103
105
|
continue;
|
|
104
106
|
}
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
107
|
+
if (e.startsWith("width:")) {
|
|
108
|
+
const n = parseFloat(e.slice(6));
|
|
109
|
+
W = n > 0 ? n : 0;
|
|
108
110
|
continue;
|
|
109
111
|
}
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
+
if (e.startsWith("layer_change") || e.startsWith("layer:")) {
|
|
113
|
+
b = !0, D = !0;
|
|
112
114
|
continue;
|
|
113
115
|
}
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
116
|
+
if (e.startsWith("z:")) {
|
|
117
|
+
const n = parseFloat(e.slice(2));
|
|
118
|
+
D && n > 0 && (b = !0, y(n));
|
|
117
119
|
continue;
|
|
118
120
|
}
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
121
|
+
const r = /^layer \d+ z([-\d.]+)/.exec(e);
|
|
122
|
+
if (r) {
|
|
123
|
+
b = !0, y(parseFloat(r[1]));
|
|
122
124
|
continue;
|
|
123
125
|
}
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
+
const l = ot.find(([n]) => ct(e, n));
|
|
127
|
+
l && (T = l[1]);
|
|
126
128
|
continue;
|
|
127
129
|
}
|
|
128
|
-
if (!
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
|
|
130
|
+
if (!R) continue;
|
|
131
|
+
const m = R.split(/\s+/), i = m[0].toUpperCase();
|
|
132
|
+
if (i === "G90") {
|
|
133
|
+
d = !0;
|
|
132
134
|
continue;
|
|
133
135
|
}
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
+
if (i === "G91") {
|
|
137
|
+
d = !1;
|
|
136
138
|
continue;
|
|
137
139
|
}
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
+
if (i === "M82") {
|
|
141
|
+
O = !0;
|
|
140
142
|
continue;
|
|
141
143
|
}
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
+
if (i === "M83") {
|
|
145
|
+
O = !1;
|
|
144
146
|
continue;
|
|
145
147
|
}
|
|
146
|
-
if (/^T\d+$/.test(
|
|
147
|
-
|
|
148
|
+
if (/^T\d+$/.test(i)) {
|
|
149
|
+
w = parseInt(i.slice(1), 10), Y.add(w);
|
|
148
150
|
continue;
|
|
149
151
|
}
|
|
150
|
-
if (
|
|
151
|
-
let
|
|
152
|
-
for (let
|
|
153
|
-
const
|
|
154
|
-
Number.isNaN(
|
|
152
|
+
if (i === "G92" || i === "G0" || i === "G1" || i === "G2" || i === "G3") {
|
|
153
|
+
let e = NaN, r = NaN, l = NaN, n = NaN, _ = 0, q = 0;
|
|
154
|
+
for (let N = 1; N < m.length; N++) {
|
|
155
|
+
const s = m[N][0], o = parseFloat(m[N].slice(1));
|
|
156
|
+
Number.isNaN(o) || (s === "X" || s === "x" ? e = o : s === "Y" || s === "y" ? r = o : s === "Z" || s === "z" ? l = o : s === "E" || s === "e" ? n = o : s === "I" || s === "i" ? _ = o : (s === "J" || s === "j") && (q = o));
|
|
155
157
|
}
|
|
156
|
-
if (
|
|
157
|
-
Number.isNaN(
|
|
158
|
+
if (i === "G92") {
|
|
159
|
+
Number.isNaN(e) || (p = e), Number.isNaN(r) || (u = r), Number.isNaN(l) || (h = l), Number.isNaN(n) || (G = n);
|
|
158
160
|
continue;
|
|
159
161
|
}
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
let
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
let
|
|
168
|
-
for (let
|
|
169
|
-
const
|
|
170
|
-
|
|
162
|
+
const U = Number.isNaN(e) ? p : d ? e : p + e, x = Number.isNaN(r) ? u : d ? r : u + r, v = Number.isNaN(l) ? h : d ? l : h + l, j = Number.isNaN(n) ? 0 : O ? n - G : n;
|
|
163
|
+
if (i === "G2" || i === "G3") {
|
|
164
|
+
const N = p + _, s = u + q, o = Math.hypot(p - N, u - s), g = Math.atan2(u - s, p - N);
|
|
165
|
+
let S = Math.atan2(x - s, U - N);
|
|
166
|
+
const C = i === "G3";
|
|
167
|
+
C && S <= g + F && (S += 2 * Math.PI), !C && S >= g - F && (S -= 2 * Math.PI);
|
|
168
|
+
const E = Math.max(1, Math.min(360, Math.ceil(Math.abs(S - g) * o / 0.3)));
|
|
169
|
+
let V = p, X = u, J = h;
|
|
170
|
+
for (let M = 1; M <= E; M++) {
|
|
171
|
+
const $ = g + (S - g) * M / E, Q = M === E ? U : N + o * Math.cos($), tt = M === E ? x : s + o * Math.sin($), et = h + (v - h) * M / E;
|
|
172
|
+
Z(V, X, J, Q, tt, et, j / E), V = Q, X = tt, J = et;
|
|
171
173
|
}
|
|
172
174
|
} else
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
Z(p, u, h, U, x, v, j);
|
|
176
|
+
p = U, u = x, h = v, Number.isNaN(n) || (G = O ? n : G + n);
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
return {
|
|
178
|
-
layers:
|
|
180
|
+
layers: P.map((a) => ({ z: a.z, paths: Float32Array.from(a.p), widths: Float32Array.from(a.w) })),
|
|
179
181
|
stats: {
|
|
180
|
-
layers:
|
|
181
|
-
path_segments:
|
|
182
|
+
layers: P.length,
|
|
183
|
+
path_segments: z,
|
|
182
184
|
travel_segments: H,
|
|
183
|
-
filament_mm:
|
|
184
|
-
tools: [...
|
|
185
|
+
filament_mm: k,
|
|
186
|
+
tools: [...Y].sort((a, c) => a - c)
|
|
185
187
|
}
|
|
186
188
|
};
|
|
187
189
|
}
|
|
188
190
|
export {
|
|
189
|
-
|
|
191
|
+
Lt as parseGcode
|
|
190
192
|
};
|