three-slicer 0.1.1 → 0.1.2
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/dist/SettingsPanel.js +112 -112
- package/components/styles.css +9 -9
- package/data/invalidation-map.json +1 -1
- package/engine/examples/headless.mjs +2 -2
- package/engine/index.js +2 -2
- package/engine/src/data.js +7 -7
- package/engine/src/settings.js +34 -34
- package/engine/src/slicer.worker.js +23 -21
- package/engine/src/toggle_eval.js +11 -11
- package/package.json +1 -1
- package/types/components.d.ts +5 -5
- package/types/data/config-schema.json.d.ts +6 -6
- package/types/data/invalidation-map.json.d.ts +5 -5
- package/types/data/toggle-rules.json.d.ts +5 -5
- package/types/data/ui-tree.json.d.ts +3 -3
- package/types/data.d.ts +6 -6
- package/types/gen_settings_types.mjs +10 -10
- package/types/settings-keys.d.ts +4 -4
- package/types/settings.d.ts +6 -6
- package/types/toggle.d.ts +6 -6
- package/types/viewer-loaders.d.ts +8 -8
- package/types/viewer-toolpath.d.ts +17 -17
- package/types/viewer.d.ts +3 -3
- package/types/wasm.d.ts +3 -3
- package/types/worker.d.ts +2 -2
- package/viewer/dist/Viewport.js +1760 -966
- package/viewer/dist/make_worker.js +6 -6
- package/viewer/dist/model_loaders.js +35 -35
- package/viewer/dist/toolpath_gpu.js +146 -147
- package/viewer/styles.css +25 -25
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
// three-slicer/viewer/loaders —
|
|
1
|
+
// three-slicer/viewer/loaders — pure loaders, independent of the kernel.
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** The 5 built-ins plus any extension registered via `registerLoader()`, which pushes onto this array. */
|
|
4
4
|
export const SUPPORTED_EXT: string[]
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/** Lowercased extension. Empty string when there is no dot. */
|
|
7
7
|
export function fileExt(name: string): string
|
|
8
8
|
|
|
9
9
|
export interface LoadedObject {
|
|
10
10
|
name: string
|
|
11
|
-
/**
|
|
11
|
+
/** Triangle vertex coordinates (N*9, model z-up) */
|
|
12
12
|
modelPos: Float32Array
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/** A single file may contain several objects (3mf/amf/step) -> always an array. */
|
|
16
16
|
export function loadModel(name: string, buffer: ArrayBuffer): Promise<LoadedObject[]>
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Registers an extra format. Formats needing heavy dependencies (STEP=OCCT WASM, etc.) are not bundled here,
|
|
20
|
+
* so the app wires them up itself. The `<Viewport/>` file dialog and drag-and-drop filters pick them up automatically.
|
|
21
21
|
*
|
|
22
22
|
* ```js
|
|
23
23
|
* import { registerLoader } from 'three-slicer/viewer/loaders'
|
|
@@ -29,5 +29,5 @@ export function registerLoader(
|
|
|
29
29
|
fn: (buffer: ArrayBuffer, name: string) => LoadedObject[] | Promise<LoadedObject[]>,
|
|
30
30
|
): void
|
|
31
31
|
|
|
32
|
-
/**
|
|
32
|
+
/** Connected-component split. Returns `null` when there is only one component (cannot split) — not an empty array. */
|
|
33
33
|
export function splitConnectedComponents(localPos: Float32Array): Float32Array[] | null
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
// three-slicer/viewer/toolpath —
|
|
2
|
-
//
|
|
1
|
+
// three-slicer/viewer/toolpath — kernel layers -> GPU-instanced toolpath.
|
|
2
|
+
// Does not import three: makeToolpath takes the THREE namespace as an argument (guaranteeing a single instance).
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/** The 24 triangle indices of the 8-vertex diamond cross-section (from SegmentTemplate.cpp:18) */
|
|
5
5
|
export const VERTEX_DATA: number[]
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/** Toolpath type -> color. 0=travel, 1=wall … 11=prime */
|
|
8
8
|
export const TYPE_COLOR: Record<number, number[]>
|
|
9
9
|
export const TYPE_LABEL: Record<number, string>
|
|
10
10
|
|
|
11
|
-
/**
|
|
11
|
+
/** Blue-to-red 11-color heatmap (libvgcode ColorRange.hpp:14) */
|
|
12
12
|
export const DEFAULT_RANGES_COLORS: number[][]
|
|
13
13
|
|
|
14
14
|
export interface ViewTypeDef {
|
|
15
15
|
key: 'feature' | 'speed' | 'height' | 'width' | 'fan' | 'temp'
|
|
16
16
|
label: string
|
|
17
|
-
/**
|
|
17
|
+
/** Whether values are continuous (heatmap). False means a fixed color. */
|
|
18
18
|
cont: boolean
|
|
19
19
|
unit: string
|
|
20
20
|
}
|
|
21
21
|
export const VIEW_TYPES: ViewTypeDef[]
|
|
22
22
|
|
|
23
|
-
/**
|
|
23
|
+
/** Per-vertex extra data */
|
|
24
24
|
export interface SegmentMeta {
|
|
25
25
|
vType: Uint8Array
|
|
26
26
|
vWidth: Float32Array
|
|
@@ -42,16 +42,16 @@ export interface SegmentData {
|
|
|
42
42
|
maxAbs: number
|
|
43
43
|
hasNaN: boolean
|
|
44
44
|
meta: SegmentMeta
|
|
45
|
-
/**
|
|
45
|
+
/** Total extruded length per type (index = toolpath type, length 16) */
|
|
46
46
|
typeLengths: Float64Array
|
|
47
|
-
/**
|
|
47
|
+
/** Null when there is not a single vertex */
|
|
48
48
|
bbox: { min: [number, number, number]; max: [number, number, number] } | null
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
51
|
+
/** Kernel layers[{z, paths(stride8), widths[]}] -> GPU stream. */
|
|
52
52
|
export function buildSegmentData(layers: unknown[], defaultLineWidth: number): SegmentData
|
|
53
53
|
|
|
54
|
-
/**
|
|
54
|
+
/** Length share per type (%), descending by pct. The kernel does not expose time per role, so length is used as an approximation. */
|
|
55
55
|
export function roleRatios(typeLengths: Float64Array | number[]): Array<{
|
|
56
56
|
type: number
|
|
57
57
|
label: string
|
|
@@ -60,7 +60,7 @@ export function roleRatios(typeLengths: Float64Array | number[]): Array<{
|
|
|
60
60
|
}>
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* speed/fan/temp
|
|
63
|
+
* speed/fan/temp are absent from the kernel toolpath and derived from settings — these are the values used for that.
|
|
64
64
|
*/
|
|
65
65
|
export interface ColorContext {
|
|
66
66
|
speedByType?: Record<number, number>
|
|
@@ -73,26 +73,26 @@ export interface ColorContext {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export interface ColorResult {
|
|
76
|
-
/**
|
|
76
|
+
/** Per-vertex RGBA (nV*4). The color is packed into `.r`. */
|
|
77
77
|
color: Float32Array
|
|
78
78
|
min: number
|
|
79
79
|
max: number
|
|
80
80
|
viewType: ViewTypeDef['key']
|
|
81
81
|
label: string
|
|
82
82
|
unit: string
|
|
83
|
-
/**
|
|
83
|
+
/** False means fixed colors — min/max are 0 and no legend should be drawn. */
|
|
84
84
|
cont: boolean
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export function computeColors(data: SegmentData, viewType: ViewTypeDef['key'], ctx: ColorContext): ColorResult
|
|
88
88
|
|
|
89
89
|
export interface ToolpathHandle {
|
|
90
|
-
/** THREE.Mesh —
|
|
90
|
+
/** THREE.Mesh — typed by the THREE namespace passed in */
|
|
91
91
|
mesh: any
|
|
92
92
|
/** THREE.LineSegments (travel) */
|
|
93
93
|
travLines: any
|
|
94
94
|
setLayerRange(lo: number, hi: number): void
|
|
95
|
-
/**
|
|
95
|
+
/** Backwards compatible — same as setLayerRange(0, n-1). */
|
|
96
96
|
setVisibleLayers(n: number): void
|
|
97
97
|
setTravelVisible(visible: boolean): void
|
|
98
98
|
setColors(color: Float32Array): void
|
|
@@ -101,5 +101,5 @@ export interface ToolpathHandle {
|
|
|
101
101
|
layerCount: number
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
/** @param THREE - `import * as THREE from 'three'`
|
|
104
|
+
/** @param THREE - the `import * as THREE from 'three'` namespace. The consumer's instance is used as-is. */
|
|
105
105
|
export function makeToolpath(THREE: any, data: SegmentData): ToolpathHandle
|
package/types/viewer.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import type * as React from 'react'
|
|
|
3
3
|
import type { SlicerSettings } from './settings-keys.d.ts'
|
|
4
4
|
|
|
5
5
|
export interface ViewportProps {
|
|
6
|
-
/**
|
|
6
|
+
/** Sparse settings map. Defaults to `{}`. */
|
|
7
7
|
settings?: SlicerSettings
|
|
8
|
-
/** React setState
|
|
8
|
+
/** React setState shape. Defaults to a no-op. */
|
|
9
9
|
setSettings?: React.Dispatch<React.SetStateAction<SlicerSettings>>
|
|
10
|
-
/**
|
|
10
|
+
/** Left process-panel slot — usually `<SettingsPanel embedded/>`. Defaults to null. */
|
|
11
11
|
processPanel?: React.ReactNode
|
|
12
12
|
}
|
|
13
13
|
|
package/types/wasm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// three-slicer/wasm, three-slicer/wasm-mt — emscripten
|
|
2
|
-
// ponytail:
|
|
3
|
-
// three-slicer
|
|
1
|
+
// three-slicer/wasm, three-slicer/wasm-mt — emscripten glue (generated, 3.5MB+).
|
|
2
|
+
// ponytail: no precise types here. The glue changes on every rebuild, and the public API is
|
|
3
|
+
// createSlicer() from three-slicer. Anyone using this directly already knows the kernel internals.
|
|
4
4
|
declare const factory: (opts?: Record<string, unknown>) => Promise<any>
|
|
5
5
|
export default factory
|
package/types/worker.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
// three-slicer/worker —
|
|
2
|
-
// `new Worker(new URL('three-slicer/worker', import.meta.url), { type: 'module' })
|
|
1
|
+
// three-slicer/worker — the slice worker script. Not a module you import, but the target of
|
|
2
|
+
// `new Worker(new URL('three-slicer/worker', import.meta.url), { type: 'module' })`.
|
|
3
3
|
export {}
|