three-slicer-viewer 0.3.5 → 0.4.0

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 CHANGED
@@ -1,7 +1,8 @@
1
1
  # three-slicer-viewer/components — the settings form
2
2
 
3
- (Published as `three-slicer-viewer/components`, MIT. `three-slicer/components` is the same component with upstream's
4
- schema, tab tree and toggle rules plugged in; everything below applies to both.)
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 # react is an OPTIONAL peer — npm does not install it for you
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 the `<Viewport/>` in `three-slicer/viewer` — one state connects all three.
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 lives in its own package: `three-slicer/viewer`.
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/viewer` supplies. Install `three-slicer` for that, and note that
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/components does that with OrcaSlicer's data; a host may pass its own.
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
 
package/VIEWER.md CHANGED
@@ -1,26 +1,30 @@
1
1
  # three-slicer-viewer — the viewer
2
2
 
3
- (Published as `three-slicer-viewer`, MIT. `three-slicer/viewer` is the same component with the WASM kernel and the
4
- vendor catalog plugged in; everything below applies to both.)
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
  ![The Prepare tab — drag-and-drop viewport with the printer, filament and process cards in the right sidebar](../../slice-sidebar.png)
9
9
 
10
10
  ```bash
11
- npm i three-slicer react react-dom three # the three are optional peers; the viewer needs all of them
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/viewer'
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/viewer/toolpath` — GPU toolpath renderer (`buildSegmentData`, `makeToolpath`, view-type colorers)
51
- - `three-slicer/viewer/loaders` — model loaders returning unified triangle soup
52
- - `three-slicer/viewer/gcode` — `parseGcode(text)`, G-code back into the layer stream the renderer consumes
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/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.
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/viewer/toolpath`,
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)
package/dist/index.js CHANGED
@@ -4864,7 +4864,7 @@ function Dp({ error: e }) {
4864
4864
  return /* @__PURE__ */ i.createElement("div", { className: "slice-err side-warn", "data-testid": "slice-err" }, t, r && /* @__PURE__ */ i.createElement("pre", { className: "slice-err-detail" }, r));
4865
4865
  }
4866
4866
  function Gp() {
4867
- return "0.3.5";
4867
+ return "0.4.0";
4868
4868
  }
4869
4869
  const Br = Gp();
4870
4870
  function Up({ on: e = !0 }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-slicer-viewer",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
4
4
  "description": "The three-slicer viewer without the slicer — model loading, G-code parsing, GPU toolpath rendering and the settings transforms, under MIT. Plug a slicer in through the `slicer` prop.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,12 +1,12 @@
1
- // three-slicer/components
1
+ // three-slicer-viewer/components
2
2
  import type * as React from 'react'
3
3
  import type { SlicerSettings } from './settings-keys.d.ts'
4
4
 
5
5
  export interface SettingsPanelProps {
6
6
  /**
7
7
  * The config schema to render from. Defaults to this package's reduced schema — types, defaults, enum values,
8
- * layout flags and units, but no label or tooltip, so a field is labelled by its key. `three-slicer/components`
9
- * passes the full schema; a host may pass its own (a translation, its own vocabulary).
8
+ * layout flags and units, but no label or tooltip, so a field is labelled by its key. Pass
9
+ * three-slicer/data's full schema for upstream's labels; a host may pass its own (a translation, its own vocabulary).
10
10
  */
11
11
  schema?: Record<string, Record<string, unknown>>
12
12
  /** The tab/page/group tree. Defaults to one flat page per builder over this package's ui-tree keys. */
package/types/gcode.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- // three-slicer/viewer/gcode — G-code text -> kernel-shaped layer stream (renderable without slicing).
2
- // Feed the returned layers straight into buildSegmentData (three-slicer/viewer/toolpath).
1
+ // three-slicer-viewer/gcode — G-code text -> kernel-shaped layer stream (renderable without slicing).
2
+ // Feed the returned layers straight into buildSegmentData (three-slicer-viewer/toolpath).
3
3
 
4
4
  export interface GcodeLayer {
5
5
  z: number
@@ -1,5 +1,4 @@
1
1
  // three-slicer-viewer — kernel layers -> GPU-instanced toolpath.
2
- // Also published as three-slicer/viewer/toolpath, which re-exports this package.
3
2
  // Does not import three: makeToolpath takes the THREE namespace as an argument (guaranteeing a single instance).
4
3
 
5
4
  /** The 24 triangle indices of the 8-vertex diamond cross-section (from SegmentTemplate.cpp:18) */
package/types/viewer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // three-slicer/viewer
1
+ // three-slicer-viewer
2
2
  import type * as React from 'react'
3
3
  import type { SlicerSettings } from './settings-keys.d.ts'
4
4
  import type { ProcessPresetsApi, FilamentPresetsApi } from './settings.d.ts'
@@ -114,8 +114,8 @@ export interface ViewportProps {
114
114
  */
115
115
  slicer?: (deps: Record<string, unknown>) => SlicerHandle
116
116
  /**
117
- * The vendor preset catalog. This package ships none — nothing passed means empty pickers. `three-slicer/viewer`
118
- * passes its bundled OrcaSlicer extraction; a host with its own fleet passes its own (a partial object is
117
+ * The vendor preset catalog. This package ships none — nothing passed means empty pickers. `three-slicer/settings`'
118
+ * `bundledCatalog` is the OrcaSlicer extraction; a host with its own fleet passes its own (a partial object is
119
119
  * merged over the empty catalog).
120
120
  */
121
121
  catalog?: Catalog | null
@@ -254,5 +254,5 @@ export function resolveCatalog(catalog?: Partial<Catalog> | null): Catalog
254
254
  export function useNoopSlicer(): SlicerHandle
255
255
 
256
256
  /** The slicing hook, unbound. `deps.makeWorker` must return a Worker speaking this package's slice protocol —
257
- * three-slicer/viewer supplies its WASM kernel worker and re-exports the bound hook. */
257
+ * three-slicer/client's makeSlicerWorker is the WASM kernel's. */
258
258
  export function useSlicer(deps: Record<string, unknown> & { makeWorker: () => Worker }): SlicerHandle