three-slicer-viewer 0.3.5 → 0.4.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 +12 -7
- package/README.md +9 -2
- package/VIEWER.md +15 -11
- package/dist/index.js +2886 -2861
- package/dist/model_loaders-kvOxEvFT.js +230 -0
- package/dist/model_loaders.js +14 -9
- package/dist/parse_3mf-6PLUgcZp.js +951 -0
- package/dist/parse_3mf.worker.js +101 -39
- package/package.json +5 -1
- package/src/settings/toggle_eval.js +112 -6
- package/types/components.d.ts +3 -3
- package/types/gcode.d.ts +2 -2
- package/types/loaders.d.ts +23 -1
- package/types/toggle.d.ts +6 -0
- package/types/toolpath.d.ts +0 -1
- package/types/viewer.d.ts +4 -4
- package/types/workers.d.ts +10 -0
- package/dist/model_loaders-Dk9rqXFb.js +0 -196
- package/dist/parse_3mf-CpbA-6Iq.js +0 -666
package/COMPONENTS.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# three-slicer-viewer/components — the settings form
|
|
2
2
|
|
|
3
|
-
(Published as `three-slicer-viewer/components`, MIT.
|
|
4
|
-
schema
|
|
3
|
+
(Published as `three-slicer-viewer/components`, MIT. Upstream's labels, tab tree and toggle rules come from
|
|
4
|
+
`three-slicer` through the `schema`, `uiTree` and `toggle` props, as below; without them every field is labelled by
|
|
5
|
+
its key and nothing is disabled.)
|
|
5
6
|
|
|
6
7
|
Reusable React components for the browser slicer. Props-driven — no global state, no React context, no router coupling (proven standalone by the tarball consumer gate `packages/pack_check.sh`).
|
|
7
8
|
|
|
@@ -12,16 +13,20 @@ An OrcaSlicer-style settings form generated from `three-slicer/data` (schema + U
|
|
|
12
13
|
The tab set follows the printer profile's technology: a settings map whose `printer_technology` says SLA swaps the FFF tabs for the SLA ones (print/material/printer builders carry the technology in their upstream builder name, which is what the filter reads). No prop needed — change the profile in the shared settings map and the panel follows.
|
|
13
14
|
|
|
14
15
|
```bash
|
|
15
|
-
npm i three-slicer react react-dom
|
|
16
|
+
npm i three-slicer three-slicer-viewer react react-dom # same version for the two; react is an OPTIONAL peer — npm does not install it for you
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
```jsx
|
|
19
20
|
import { useState } from 'react'
|
|
20
|
-
import SettingsPanel from 'three-slicer/components'
|
|
21
|
+
import SettingsPanel from 'three-slicer-viewer/components'
|
|
22
|
+
import { schema, uiTree } from 'three-slicer/data' // upstream's labels, tooltips and tab tree (AGPL)
|
|
23
|
+
import { makeCfg, disabledKeys } from 'three-slicer/toggle' // the evaluator bound to upstream's rules (AGPL)
|
|
24
|
+
|
|
25
|
+
const toggle = { makeCfg, disabledKeys }
|
|
21
26
|
|
|
22
27
|
function App() {
|
|
23
28
|
const [settings, setSettings] = useState({}) // sparse map: edited keys only; missing = schema default
|
|
24
|
-
return <SettingsPanel settings={settings} setSettings={setSettings} />
|
|
29
|
+
return <SettingsPanel schema={schema} uiTree={uiTree} toggle={toggle} settings={settings} setSettings={setSettings} />
|
|
25
30
|
}
|
|
26
31
|
```
|
|
27
32
|
|
|
@@ -36,11 +41,11 @@ Props:
|
|
|
36
41
|
| `customWidgets` | `{ [schemaKey]: Component }` (optional) | Replace schema-driven widgets per key (e.g. `{ printable_area: MyBedEditor }`) |
|
|
37
42
|
| `only` | `{ builder, page? }` (optional) | Pins the panel to one builder/page and drops the search/page/mode chrome — how `<Viewport/>`'s `motionPanel` slot is meant to be filled |
|
|
38
43
|
|
|
39
|
-
The same `settings` object feeds `deriveKernelParams()` in `three-slicer` and
|
|
44
|
+
The same `settings` object feeds `deriveKernelParams()` in `three-slicer` and `three-slicer-viewer`'s `<Viewport/>` — one state connects all three.
|
|
40
45
|
|
|
41
46
|
Ships transpiled ESM (`dist/`); react is an optional peer dependency. The panel arrives fully styled: its stylesheet is inlined into the bundle and injected into a Shadow DOM root, so host CSS neither styles it nor collides with it.
|
|
42
47
|
|
|
43
|
-
The 3D viewport
|
|
48
|
+
The 3D viewport is the package's main entry, `three-slicer-viewer` ([VIEWER.md](VIEWER.md)).
|
|
44
49
|
|
|
45
50
|
## License
|
|
46
51
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ commercial products.
|
|
|
6
6
|
|
|
7
7
|
This is [`three-slicer`](https://www.npmjs.com/package/three-slicer) with the kernel taken out. It displays and
|
|
8
8
|
exports; it does not slice. Slicing is plugged in through two props — `slicer` (a hook driving a kernel) and
|
|
9
|
-
`catalog` (vendor presets) — which `three-slicer
|
|
9
|
+
`catalog` (vendor presets) — which `three-slicer` supplies (below). Install `three-slicer` for that, and note that
|
|
10
10
|
doing so puts your application under AGPL.
|
|
11
11
|
|
|
12
12
|
Developed in the [`Three_Slicer`](https://github.com/kimgh06/Three_Slicer) monorepo (`viewer-package/`), where it
|
|
@@ -41,7 +41,7 @@ const slicer = (deps) => useSlicer({ ...deps, makeWorker: makeSlicerWorker })
|
|
|
41
41
|
import SettingsPanel from 'three-slicer-viewer/components'
|
|
42
42
|
|
|
43
43
|
// Bare: fields labelled by key, nothing disabled. Pass `schema`, `uiTree` and `toggle` for labels, tabs and
|
|
44
|
-
// enable/disable rules — three-slicer/
|
|
44
|
+
// enable/disable rules — three-slicer/data and /toggle carry OrcaSlicer's; a host may pass its own.
|
|
45
45
|
<SettingsPanel settings={settings} setSettings={setSettings} />
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -67,6 +67,13 @@ handle.setColors(computeColors(data, 'speed', ctx).color) // recolour without a
|
|
|
67
67
|
`/gcode` import neither React nor three (`makeToolpath` takes the THREE namespace as an argument), so a
|
|
68
68
|
headless consumer pulls in no renderer at all.
|
|
69
69
|
|
|
70
|
+
## Starting the 3mf parse worker early
|
|
71
|
+
|
|
72
|
+
`three-slicer-viewer/workers` exports the factories of this package's workers. A host that can run a script before
|
|
73
|
+
its bundle (the browser extension in the monorepo does) starts `makeParse3mfWorker()` there and hands it to
|
|
74
|
+
`adoptParseWorker` from `three-slicer-viewer/loaders`; `preloadModel(name, file)` then starts a parse before the
|
|
75
|
+
viewport mounts, and `<Viewport files>` takes its result.
|
|
76
|
+
|
|
70
77
|
## Licensing
|
|
71
78
|
|
|
72
79
|
MIT. It depends on nothing AGPL, which a check in this repository enforces rather than documents
|
package/VIEWER.md
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
# three-slicer-viewer — the viewer
|
|
2
2
|
|
|
3
|
-
(Published as `three-slicer-viewer`, MIT.
|
|
4
|
-
|
|
3
|
+
(Published as `three-slicer-viewer`, MIT. Slicing and the vendor presets come from `three-slicer` through the
|
|
4
|
+
`slicer` and `catalog` props, as below; without them the viewer loads, displays and exports, but never slices.)
|
|
5
5
|
|
|
6
6
|
3D slicer viewer as a React component: three.js viewport (orbit/transform gizmos), model import (STL/OBJ/3MF/AMF/PLY + pluggable formats such as STEP, multi-object, drag & drop), Web Worker slicing via `three-slicer`, support and material painting, per-extruder filament presets, multi-plate, and a GPU-instanced volumetric toolpath preview ported from OrcaSlicer's libvgcode (millions of segments in a single draw path, per-feature colors, layer range slider, G-code export).
|
|
7
7
|
|
|
8
8
|

|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npm i three-slicer react react-dom three
|
|
11
|
+
npm i three-slicer three-slicer-viewer react react-dom three # same version for the two; the last three are optional peers the viewer needs
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
```jsx
|
|
15
15
|
import { useState } from 'react'
|
|
16
|
-
import Viewport from 'three-slicer
|
|
16
|
+
import Viewport, { useSlicer } from 'three-slicer-viewer'
|
|
17
|
+
import { makeSlicerWorker } from 'three-slicer/client' // the WASM kernel's worker (AGPL)
|
|
18
|
+
import { bundledCatalog } from 'three-slicer/settings' // OrcaSlicer's vendor presets (AGPL)
|
|
19
|
+
|
|
20
|
+
const slicer = (deps) => useSlicer({ ...deps, makeWorker: makeSlicerWorker }) // module-level: it is a hook
|
|
17
21
|
|
|
18
22
|
function App() {
|
|
19
23
|
const [settings, setSettings] = useState({}) // OrcaSlicer schema keys; sparse — defaults fill the rest
|
|
20
24
|
// The container matters — see Layout below.
|
|
21
25
|
return (
|
|
22
26
|
<div style={{ position: 'relative', width: '100%', height: '100vh' }}>
|
|
23
|
-
<Viewport settings={settings} setSettings={setSettings} />
|
|
27
|
+
<Viewport slicer={slicer} catalog={bundledCatalog} settings={settings} setSettings={setSettings} />
|
|
24
28
|
</div>
|
|
25
29
|
)
|
|
26
30
|
}
|
|
@@ -37,7 +41,7 @@ the initial containing block instead, which usually looks like the viewer coveri
|
|
|
37
41
|
|
|
38
42
|
There is no width or height prop: the component always fills that container, and resizes with it.
|
|
39
43
|
|
|
40
|
-
Slice parameters are derived from `settings` via `three-slicer`'s schema mapping — pair it with `three-slicer/components`' `<SettingsPanel/>` sharing the same state for a full slicer UI.
|
|
44
|
+
Slice parameters are derived from `settings` via `three-slicer`'s schema mapping — pair it with `three-slicer-viewer/components`' `<SettingsPanel/>` ([COMPONENTS.md](COMPONENTS.md)) sharing the same state for a full slicer UI.
|
|
41
45
|
|
|
42
46
|
A `.3mf` written by a slicer (OrcaSlicer/BambuStudio save, MakerWorld download) imports as a **project**: plate layout, project settings, and support/material painting are restored, not just the meshes. Where a facet carries both paint kinds, material paint wins and the dropped support paint is reported.
|
|
43
47
|
|
|
@@ -47,9 +51,9 @@ next to the material picker) takes a **function** `(settings, setSettings) => Re
|
|
|
47
51
|
card binds each extruder's per-extruder values.
|
|
48
52
|
|
|
49
53
|
Subpath exports for custom UIs (framework-free, no React):
|
|
50
|
-
- `three-slicer
|
|
51
|
-
- `three-slicer
|
|
52
|
-
- `three-slicer
|
|
54
|
+
- `three-slicer-viewer/toolpath` — GPU toolpath renderer (`buildSegmentData`, `makeToolpath`, view-type colorers)
|
|
55
|
+
- `three-slicer-viewer/loaders` — model loaders returning unified triangle soup
|
|
56
|
+
- `three-slicer-viewer/gcode` — `parseGcode(text)`, G-code back into the layer stream the renderer consumes
|
|
53
57
|
|
|
54
58
|
## Embedding it without the panels
|
|
55
59
|
|
|
@@ -233,7 +237,7 @@ Two limits to expect while using it:
|
|
|
233
237
|
- Painting a region onto a second extruder only takes effect with **support turned off**. The painted multi-material path emits no support, so a support-enabled slice deliberately stays on the single-material path (where painted support keeps working as before).
|
|
234
238
|
- On a machine with two or more extruders, a support *blocker* paint and an *Extruder 2* paint are the same mark and cannot be told apart.
|
|
235
239
|
|
|
236
|
-
If you consume `three-slicer
|
|
240
|
+
If you consume `three-slicer-viewer/toolpath` directly, note that the stride-8 role field `paths[k+3]` now carries the printing extruder alongside the role as `role + tool * 16`. Mask it — `& 15` for the role, `>>> 4` for the tool. Streams produced before this encoding are entirely below 16 and decode to their own role with tool 0, so older data still reads correctly.
|
|
237
241
|
|
|
238
242
|
## Turning behaviour off
|
|
239
243
|
|
|
@@ -336,7 +340,7 @@ The component owns its scene, and the props are the whole interface — there is
|
|
|
336
340
|
- Everything else the component owns — camera, selection, plate count, paint state — is reported through `onEvent`
|
|
337
341
|
and settable only by the user.
|
|
338
342
|
|
|
339
|
-
If you need programmatic control over the scene, build on the subpath exports (`three-slicer
|
|
343
|
+
If you need programmatic control over the scene, build on the subpath exports (`three-slicer-viewer/toolpath`,
|
|
340
344
|
`/loaders`, `/gcode`) and `three-slicer/client` rather than on `<Viewport/>`.
|
|
341
345
|
|
|
342
346
|
## Multithreaded slicing (automatic)
|