three-slicer 0.3.0 → 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/engine/src/sla_core.js
CHANGED
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
// Determinism: iteration order is the STL's own triangle order, stitching maps insert in encounter order, and
|
|
11
11
|
// vertices on a slicing plane are pushed up by a fixed epsilon — same input bytes, same output bytes.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// The toolpath stream and binary STL layouts. This worker is standalone (no imports), so it keeps its own copy of
|
|
14
|
+
// numbers the viewer holds in core/toolpath_encoding.js and core/stl_format.js; TOOLPATH_SPEC.md is the contract.
|
|
15
|
+
const STRIDE = 8 // floats per segment: [x0,y0,z0,enc, x1,y1,z1,enc]
|
|
16
|
+
const ROLE_CONTOUR = 1 // ROLE.WALL — rendered as 'wall' by the preview's feature colouring
|
|
17
|
+
const STL_HEADER_BYTES = 80
|
|
18
|
+
const STL_DATA_OFFSET = 84 // header + the uint32 triangle count
|
|
19
|
+
const STL_TRIANGLE_BYTES = 50
|
|
14
20
|
const CONTOUR_WIDTH = 0.2 // display width of a contour segment (SLA has no bead width)
|
|
15
21
|
const PLANE_EPS = 1e-9 // a vertex exactly on a plane counts as above it — deterministic tie-break
|
|
16
22
|
const KEY_SCALE = 1e4 // endpoint welding: 0.1 micrometre grid
|
|
@@ -18,13 +24,13 @@ const KEY_SCALE = 1e4 // endpoint welding: 0.1 micrometre grid
|
|
|
18
24
|
/** Binary STL -> Float32Array of 9 floats per triangle (vertices only; normals are recomputed). */
|
|
19
25
|
export function parseBinarySTL(bytes) {
|
|
20
26
|
if (!(bytes instanceof Uint8Array)) bytes = new Uint8Array(bytes)
|
|
21
|
-
if (bytes.byteLength <
|
|
27
|
+
if (bytes.byteLength < STL_DATA_OFFSET) return { error: 'not a binary STL (shorter than its own header)' }
|
|
22
28
|
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
23
|
-
const count = dv.getUint32(
|
|
24
|
-
if (
|
|
29
|
+
const count = dv.getUint32(STL_HEADER_BYTES, true)
|
|
30
|
+
if (STL_DATA_OFFSET + STL_TRIANGLE_BYTES * count !== bytes.byteLength) return { error: 'not a binary STL (triangle count does not match the byte length)' }
|
|
25
31
|
const tris = new Float32Array(count * 9)
|
|
26
32
|
for (let i = 0; i < count; i++) {
|
|
27
|
-
const base =
|
|
33
|
+
const base = STL_DATA_OFFSET + STL_TRIANGLE_BYTES * i + 12 // skip the stored normal — recomputed from the winding below
|
|
28
34
|
for (let f = 0; f < 9; f++) tris[i * 9 + f] = dv.getFloat32(base + 4 * f, true)
|
|
29
35
|
}
|
|
30
36
|
return { tris, count }
|
|
@@ -149,15 +155,15 @@ export function sliceSla(stlBytes, params = {}, hooks = {}) {
|
|
|
149
155
|
for (const pts of loops) { area += loopArea(pts); segCount += pts.length / 2 }
|
|
150
156
|
area = Math.max(0, area)
|
|
151
157
|
volume += area * thickness
|
|
152
|
-
const paths = new Float32Array(segCount *
|
|
158
|
+
const paths = new Float32Array(segCount * STRIDE)
|
|
153
159
|
const widths = new Float32Array(segCount)
|
|
154
160
|
let w = 0
|
|
155
161
|
for (const pts of loops) {
|
|
156
162
|
const n = pts.length / 2
|
|
157
163
|
for (let p = 0; p < n; p++) {
|
|
158
164
|
const q = (p + 1) % n
|
|
159
|
-
paths[w *
|
|
160
|
-
paths[w *
|
|
165
|
+
paths[w * STRIDE] = pts[p * 2]; paths[w * STRIDE + 1] = pts[p * 2 + 1]; paths[w * STRIDE + 2] = top; paths[w * STRIDE + 3] = ROLE_CONTOUR
|
|
166
|
+
paths[w * STRIDE + 4] = pts[q * 2]; paths[w * STRIDE + 5] = pts[q * 2 + 1]; paths[w * STRIDE + 6] = top; paths[w * STRIDE + 7] = ROLE_CONTOUR
|
|
161
167
|
widths[w] = CONTOUR_WIDTH
|
|
162
168
|
w++
|
|
163
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-slicer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Browser/WASM 3D-printing slicer reverse-engineered from OrcaSlicer: slicing engine (Arachne walls, tree/grid supports, multi-material), SLA resin slicing with PrusaSlicer's ported support/pad chain and .sl1 export, React viewer with GPU toolpath preview, and schema-driven settings UI.",
|
|
5
5
|
"license": "AGPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -90,27 +90,24 @@
|
|
|
90
90
|
},
|
|
91
91
|
"files": [
|
|
92
92
|
"engine",
|
|
93
|
-
"!engine/**/.omc",
|
|
94
93
|
"types",
|
|
95
|
-
"!**/
|
|
94
|
+
"!**/tests/**",
|
|
96
95
|
"!types/gen_*.mjs",
|
|
97
96
|
"components/dist",
|
|
98
97
|
"viewer/dist",
|
|
99
|
-
"viewer/styles.css",
|
|
100
|
-
"components/styles.css",
|
|
101
98
|
"data",
|
|
102
99
|
"data/ui-tree-keys.json",
|
|
103
100
|
"data/config-schema-lean.json",
|
|
104
101
|
"!data/config-schema-builddump.json",
|
|
105
|
-
"!data/**/.omc",
|
|
106
102
|
"README.md",
|
|
107
103
|
"CHANGELOG.md",
|
|
108
104
|
"THIRD-PARTY-NOTICES.md",
|
|
109
|
-
"LICENSE.txt"
|
|
105
|
+
"LICENSE.txt",
|
|
106
|
+
"!**/.omc"
|
|
110
107
|
],
|
|
111
108
|
"repository": {
|
|
112
109
|
"type": "git",
|
|
113
|
-
"url": "git+https://github.com/kimgh06/
|
|
110
|
+
"url": "git+https://github.com/kimgh06/Three_Slicer.git",
|
|
114
111
|
"directory": "packages"
|
|
115
112
|
},
|
|
116
113
|
"homepage": "https://slicer.kimgh06.com",
|
|
@@ -137,6 +134,6 @@
|
|
|
137
134
|
"clipping"
|
|
138
135
|
],
|
|
139
136
|
"dependencies": {
|
|
140
|
-
"three-slicer-viewer": "0.3.
|
|
137
|
+
"three-slicer-viewer": "0.3.1"
|
|
141
138
|
}
|
|
142
139
|
}
|
package/types/settings.d.ts
CHANGED
|
@@ -172,6 +172,18 @@ export function printerDefaultPreset(profileName: string): string
|
|
|
172
172
|
/** The schema keys the kernel's machine limits are read from — for UI that shows which ones are in play. */
|
|
173
173
|
export const machineLimitKeys: string[]
|
|
174
174
|
|
|
175
|
+
/** deriveKernelParams' fallbacks when neither the settings map nor the schema gives a usable value, keyed by schema
|
|
176
|
+
* key. NOT the schema defaults — several differ on purpose. Frozen. */
|
|
177
|
+
export const FFF_FALLBACKS: Readonly<Record<string, number | boolean | string>>
|
|
178
|
+
/** deriveSlaParams' fallbacks (its reader treats non-positive values as absent). Frozen. */
|
|
179
|
+
export const SLA_FALLBACKS: Readonly<Record<string, number>>
|
|
180
|
+
/** What `line_width` 0 ("auto") resolves to. */
|
|
181
|
+
export const AUTO_LINE_WIDTH: number
|
|
182
|
+
/** The bed when `printable_area` is empty or malformed — the bbox of the schema's own default. */
|
|
183
|
+
export const BED_FALLBACK: Readonly<{ width: number; depth: number }>
|
|
184
|
+
/** Kernel machine-limit parameter -> [schema key, fallback]. Frozen. */
|
|
185
|
+
export const MACHINE_LIMITS: Readonly<Record<string, readonly [string, number]>>
|
|
186
|
+
|
|
175
187
|
// ---- Lazily loaded presets --------------------------------------------------
|
|
176
188
|
// Both facades hide the column layout of the artifact they wrap; the promise is created once and reused.
|
|
177
189
|
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 1,
|
|
3
|
-
"entries": {
|
|
4
|
-
"79a93d4a2f8f50b95f852280616242fee1855dc99a3c75211917f55e72e95fae": {
|
|
5
|
-
"last_emitted_at_ms": 1788437194779,
|
|
6
|
-
"message": "Use parallel execution for independent tasks. Use run_in_background for long operations (npm install, builds, tests)."
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
"updated_at": "2026-09-03T12:06:34.779Z"
|
|
10
|
-
}
|