three-slicer 0.1.1 → 0.1.3
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/config-schema.json +999 -900
- package/data/invalidation-map.json +6 -5
- package/data/printers.json +1 -0
- package/data/processes.js +2 -0
- package/data/toggle-rules.json +44 -44
- package/data/ui-tree.json +170 -494
- package/engine/examples/headless.mjs +2 -2
- package/engine/index.js +2 -2
- package/engine/src/data.js +13 -7
- package/engine/src/settings.js +120 -35
- package/engine/src/slicer.worker.js +23 -21
- package/engine/src/slicer_core.js +0 -0
- package/engine/src/slicer_core.mt.js +0 -0
- package/engine/src/toggle_eval.js +11 -11
- package/package.json +4 -2
- 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/printers.json.d.ts +23 -0
- package/types/data/processes.js.d.ts +21 -0
- 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 +10 -7
- package/types/gen_settings_types.mjs +10 -10
- package/types/settings-keys.d.ts +18 -7
- 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 +46 -25
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// processes.js — print (process) presets extracted from OrcaSlicer's resources/profiles/<Vendor>/process/.
|
|
2
|
+
// Emitted as a JS module rather than JSON because it is loaded dynamically: see engine/src/data.js for why.
|
|
3
|
+
// Column layout, same as printers.json — `keys` names the columns once and each row in `sets` is positional.
|
|
4
|
+
// Prefer `processPresets()` from three-slicer/settings over decoding this by hand.
|
|
5
|
+
|
|
6
|
+
/** A positional row aligned to `keys`; `null` where the profile chain never set that option. */
|
|
7
|
+
export type ProcessRow = (unknown | null)[]
|
|
8
|
+
|
|
9
|
+
export interface ProcessData {
|
|
10
|
+
/** Option keys, in column order — the keys the kernel consumes, read out of engine/src/settings.js */
|
|
11
|
+
keys: string[]
|
|
12
|
+
/** Deduplicated value rows */
|
|
13
|
+
sets: ProcessRow[]
|
|
14
|
+
/** `[preset name, index into sets]`, indexed by the numbers in `byPrinter` */
|
|
15
|
+
presets: [string, number][]
|
|
16
|
+
/** Printer profile name -> indices into `presets` */
|
|
17
|
+
byPrinter: Record<string, number[]>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare const processes: ProcessData
|
|
21
|
+
export default processes
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// three-slicer/data/toggle-rules.json —
|
|
2
|
-
//
|
|
1
|
+
// three-slicer/data/toggle-rules.json — enable_if expressions extracted from upstream toggle_options().
|
|
2
|
+
// Top-level key = group name (e.g. 'toggle_print_fff_options', 'TabPrinter::toggle_options').
|
|
3
3
|
|
|
4
4
|
export interface ToggleRule {
|
|
5
|
-
/**
|
|
5
|
+
/** The raw C++ expression string. Evaluated by evalEnableIf in three-slicer/toggle. */
|
|
6
6
|
enable_if?: string
|
|
7
|
-
/**
|
|
7
|
+
/** The config-schema keys governed by this condition */
|
|
8
8
|
fields?: string[]
|
|
9
9
|
line?: number
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface ToggleGroup {
|
|
13
|
-
/**
|
|
13
|
+
/** Local variable name -> the upstream C++ expression (string). Translation is hardcoded in toggle_eval.js. */
|
|
14
14
|
locals: Record<string, string>
|
|
15
15
|
rules: ToggleRule[]
|
|
16
16
|
stats?: { toggle_calls_in_source: number; rules_extracted: number }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// three-slicer/data/ui-tree.json —
|
|
2
|
-
//
|
|
1
|
+
// three-slicer/data/ui-tree.json — the page/group tree from upstream Tab.cpp.
|
|
2
|
+
// Top-level key = builder name (e.g. 'TabPrint::build'), value = the pages that builder creates.
|
|
3
3
|
|
|
4
4
|
export interface UIGroup {
|
|
5
5
|
group: string
|
|
6
6
|
line?: number
|
|
7
|
-
/** config-schema
|
|
7
|
+
/** The config-schema option keys */
|
|
8
8
|
options: string[]
|
|
9
9
|
}
|
|
10
10
|
|
package/types/data.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
// three-slicer/data —
|
|
2
|
-
// import attribute(`with { type: 'json' }`)
|
|
1
|
+
// three-slicer/data — the extracted JSON files. Prefer this over importing the raw JSON:
|
|
2
|
+
// the import attribute (`with { type: 'json' }`) is already applied, so it works in Node and bundlers alike.
|
|
3
3
|
import type { ConfigOption } from './data/config-schema.json.d.ts'
|
|
4
4
|
import type { UIPage } from './data/ui-tree.json.d.ts'
|
|
5
5
|
import type { ToggleGroup } from './data/toggle-rules.json.d.ts'
|
|
6
6
|
import type { InvalidationRule } from './data/invalidation-map.json.d.ts'
|
|
7
|
+
import type { PrinterData, PrinterRow, PrinterEntry } from './data/printers.json.d.ts'
|
|
7
8
|
|
|
8
|
-
export type { ConfigOption, UIPage, ToggleGroup, InvalidationRule }
|
|
9
|
+
export type { ConfigOption, UIPage, ToggleGroup, InvalidationRule, PrinterData, PrinterRow, PrinterEntry }
|
|
9
10
|
|
|
10
|
-
/** 907
|
|
11
|
+
/** The 907 option definitions */
|
|
11
12
|
export const schema: Record<string, ConfigOption>
|
|
12
|
-
/**
|
|
13
|
+
/** Builder name -> page tree */
|
|
13
14
|
export const uiTree: Record<string, UIPage[]>
|
|
14
|
-
/**
|
|
15
|
+
/** Group name -> enable_if rules */
|
|
15
16
|
export const toggleRules: Record<string, ToggleGroup>
|
|
16
|
-
/**
|
|
17
|
+
/** Setting key change -> invalidated steps */
|
|
17
18
|
export const invalidationMap: Record<string, InvalidationRule[]>
|
|
19
|
+
/** Machine limits per printer, from the upstream vendor profiles */
|
|
20
|
+
export const printers: PrinterData
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// config-schema.json
|
|
2
|
-
//
|
|
1
|
+
// config-schema.json -> types/settings-keys.d.ts (the SlicerSettings interface, 907 keys).
|
|
2
|
+
// Regenerate: node types/gen_settings_types.mjs (do not hand-edit — fix this script instead)
|
|
3
3
|
//
|
|
4
|
-
// ponytail:
|
|
5
|
-
// (
|
|
4
|
+
// ponytail: mapping is driven purely by the schema's coXxx type. min/max and nullable are not reflected in types
|
|
5
|
+
// (they are runtime validation, not type validation, and 907 keys x branded number slows tsc down).
|
|
6
6
|
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
7
7
|
import { dirname, resolve } from 'node:path'
|
|
8
8
|
import { fileURLToPath } from 'node:url'
|
|
@@ -11,12 +11,12 @@ const here = dirname(fileURLToPath(import.meta.url))
|
|
|
11
11
|
const schema = JSON.parse(readFileSync(resolve(here, '../data/config-schema.json'), 'utf8'))
|
|
12
12
|
|
|
13
13
|
const lit = (v) => "'" + String(v).replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'"
|
|
14
|
-
//
|
|
14
|
+
// Some coEnum entries have no enum_values (70/64 mismatch) -> fail open to string.
|
|
15
15
|
const enumOf = (o) => (Array.isArray(o.enum_values) && o.enum_values.length)
|
|
16
16
|
? o.enum_values.map(lit).join(' | ')
|
|
17
17
|
: 'string'
|
|
18
18
|
|
|
19
|
-
//
|
|
19
|
+
// Vector types are `T[] | T` — settingScalar() accepts both, and the UI edits only the first element (settings.js:9).
|
|
20
20
|
const vec = (t) => `${/\|/.test(t) ? `(${t})` : t}[] | ${/\|/.test(t) ? `(${t})` : t}`
|
|
21
21
|
|
|
22
22
|
function tsType(o) {
|
|
@@ -53,18 +53,18 @@ for (const key of Object.keys(schema).sort()) {
|
|
|
53
53
|
writeFileSync(resolve(here, 'settings-keys.d.ts'), `// AUTO-GENERATED by types/gen_settings_types.mjs — DO NOT EDIT.
|
|
54
54
|
// Source: data/config-schema.json (${Object.keys(schema).length} keys)
|
|
55
55
|
|
|
56
|
-
/** [x, y] — coPoint
|
|
56
|
+
/** [x, y] — coPoint family */
|
|
57
57
|
export type Point = [number, number]
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
* Slicer settings map. Sparse — it holds only edited keys; missing keys use the config-schema default.
|
|
61
|
+
* If you need arbitrary key extension, widen it with \`SlicerSettings & Record<string, unknown>\`.
|
|
62
62
|
*/
|
|
63
63
|
export interface SlicerSettings {
|
|
64
64
|
${lines.join('\n')}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
/**
|
|
67
|
+
/** Setting keys that exist in config-schema */
|
|
68
68
|
export type SettingKey = keyof SlicerSettings & string
|
|
69
69
|
`)
|
|
70
70
|
console.log(`settings-keys.d.ts written — ${Object.keys(schema).length} keys`)
|
package/types/settings-keys.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// AUTO-GENERATED by types/gen_settings_types.mjs — DO NOT EDIT.
|
|
2
|
-
// Source: data/config-schema.json (
|
|
2
|
+
// Source: data/config-schema.json (906 keys)
|
|
3
3
|
|
|
4
|
-
/** [x, y] — coPoint
|
|
4
|
+
/** [x, y] — coPoint family */
|
|
5
5
|
export type Point = [number, number]
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* Slicer settings map. Sparse — it holds only edited keys; missing keys use the config-schema default.
|
|
9
|
+
* If you need arbitrary key extension, widen it with `SlicerSettings & Record<string, unknown>`.
|
|
10
10
|
*/
|
|
11
11
|
export interface SlicerSettings {
|
|
12
12
|
absolute_correction?: number
|
|
@@ -831,6 +831,7 @@ export interface SlicerSettings {
|
|
|
831
831
|
machine_hotend_change_time?: number
|
|
832
832
|
/** Filament load time — (s) — Time to load new filament when switch filament. It's usually applicable for single-extruder multi-material machines. For tool changers or multi-tool machines, it's typically 0. For statistics only. */
|
|
833
833
|
machine_load_filament_time?: number
|
|
834
|
+
/** (mm/s²) — Maximum acceleration of the E axis */
|
|
834
835
|
machine_max_acceleration_e?: number[] | number
|
|
835
836
|
/** (mm/s²) — Maximum acceleration for extruding (M204 P) */
|
|
836
837
|
machine_max_acceleration_extruding?: number[] | number
|
|
@@ -838,22 +839,33 @@ export interface SlicerSettings {
|
|
|
838
839
|
machine_max_acceleration_retracting?: number[] | number
|
|
839
840
|
/** (mm/s²) — Maximum acceleration for travel (M204 T), it only applies to Marlin 2. */
|
|
840
841
|
machine_max_acceleration_travel?: number[] | number
|
|
842
|
+
/** (mm/s²) — Maximum acceleration of the X axis */
|
|
841
843
|
machine_max_acceleration_x?: number[] | number
|
|
844
|
+
/** (mm/s²) — Maximum acceleration of the Y axis */
|
|
842
845
|
machine_max_acceleration_y?: number[] | number
|
|
846
|
+
/** (mm/s²) — Maximum acceleration of the Z axis */
|
|
843
847
|
machine_max_acceleration_z?: number[] | number
|
|
844
848
|
/** (N) — The allowed maximum output force of Y axis */
|
|
845
849
|
machine_max_force_Y?: number
|
|
850
|
+
/** (mm/s) — Maximum jerk of the E axis */
|
|
846
851
|
machine_max_jerk_e?: number[] | number
|
|
852
|
+
/** (mm/s) — Maximum jerk of the X axis */
|
|
847
853
|
machine_max_jerk_x?: number[] | number
|
|
854
|
+
/** (mm/s) — Maximum jerk of the Y axis */
|
|
848
855
|
machine_max_jerk_y?: number[] | number
|
|
856
|
+
/** (mm/s) — Maximum jerk of the Z axis */
|
|
849
857
|
machine_max_jerk_z?: number[] | number
|
|
850
858
|
/** (mm) — Maximum junction deviation (M205 J, only apply if JD > 0 for Marlin Firmware If your Marlin 2 printer uses Classic Jerk set this value to 0.) */
|
|
851
859
|
machine_max_junction_deviation?: number[] | number
|
|
852
860
|
/** (g) — The allowed max printed mass on a plate */
|
|
853
861
|
machine_max_printed_mass?: number
|
|
862
|
+
/** (mm/s) — Maximum speed of E axis */
|
|
854
863
|
machine_max_speed_e?: number[] | number
|
|
864
|
+
/** (mm/s) — Maximum speed of X axis */
|
|
855
865
|
machine_max_speed_x?: number[] | number
|
|
866
|
+
/** (mm/s) — Maximum speed of Y axis */
|
|
856
867
|
machine_max_speed_y?: number[] | number
|
|
868
|
+
/** (mm/s) — Maximum speed of Z axis */
|
|
857
869
|
machine_max_speed_z?: number[] | number
|
|
858
870
|
/** (mm/s) — Minimum speed for extruding (M205 S) */
|
|
859
871
|
machine_min_extruding_rate?: number[] | number
|
|
@@ -1056,8 +1068,6 @@ export interface SlicerSettings {
|
|
|
1056
1068
|
physical_printer_preset?: string
|
|
1057
1069
|
/** Send progress to pipe — Send progress to pipe. */
|
|
1058
1070
|
pipe?: string
|
|
1059
|
-
/** Capabilities — Configuration for the plugin capabilities this preset uses, overriding the global Capabilities configuration. Stored as a raw JSON array and edited through the dialog behind the button, never typed in directly. */
|
|
1060
|
-
plugin_config_overrides?: string
|
|
1061
1071
|
/** Plugins Used — Plugin capabilities referenced by this preset, stored as name;uuid;capability. */
|
|
1062
1072
|
plugins?: string[] | string
|
|
1063
1073
|
/** Position — Position of the extruder at the beginning of the custom G-code block. If the custom G-code travels somewhere else, it should write to this variable so OrcaSlicer knows where it travels from when it gets control back. */
|
|
@@ -1074,6 +1084,7 @@ export interface SlicerSettings {
|
|
|
1074
1084
|
preheat_steps?: number
|
|
1075
1085
|
/** Preheat time — (s) — To reduce the waiting time after tool change, Orca can preheat the next tool while the current tool is still in use. This setting specifies the time in seconds to preheat the next tool. Orca will insert a M104 command to preheat the tool in advance. */
|
|
1076
1086
|
preheat_time?: number
|
|
1087
|
+
/** Capabilities — Configuration for the plugin capabilities this preset uses, overriding the global Capabilities configuration. Stored as a raw JSON array and edited through the dialog behind the button, never typed in directly. */
|
|
1077
1088
|
preset_name?: string
|
|
1078
1089
|
/** Printer preset names — Names of presets related to the physical printer. */
|
|
1079
1090
|
preset_names?: string[] | string
|
|
@@ -1700,5 +1711,5 @@ export interface SlicerSettings {
|
|
|
1700
1711
|
zhop?: number
|
|
1701
1712
|
}
|
|
1702
1713
|
|
|
1703
|
-
/**
|
|
1714
|
+
/** Setting keys that exist in config-schema */
|
|
1704
1715
|
export type SettingKey = keyof SlicerSettings & string
|
package/types/settings.d.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import type { SlicerSettings, SettingKey, Point } from './settings-keys.d.ts'
|
|
3
3
|
export type { SlicerSettings, SettingKey, Point }
|
|
4
4
|
|
|
5
|
-
/** config-schema
|
|
5
|
+
/** The config-schema default value (undefined for unknown keys) */
|
|
6
6
|
export function schemaDefault(key: string): unknown
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/** Settings map first, schema default otherwise. Vector types are returned as-is. */
|
|
9
9
|
export function settingRaw(settings: SlicerSettings | null | undefined, key: string): unknown
|
|
10
10
|
|
|
11
|
-
/** settingRaw
|
|
11
|
+
/** Normalizes settingRaw to a scalar — [0] for vectors. */
|
|
12
12
|
export function settingScalar(settings: SlicerSettings | null | undefined, key: string): unknown
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* ponytail:
|
|
17
|
-
*
|
|
15
|
+
* Settings map -> kernel slice params. Derived from schema keys; missing keys are filled with internal defaults.
|
|
16
|
+
* ponytail: 53 returned keys, so Record instead of listing each — kernel params are passed straight to slice(),
|
|
17
|
+
* not an API consumers read field by field. Expand it when field access is actually needed.
|
|
18
18
|
*/
|
|
19
19
|
export function deriveKernelParams(settings: SlicerSettings | null | undefined): Record<string, unknown>
|
package/types/toggle.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// three-slicer/toggle —
|
|
1
|
+
// three-slicer/toggle — partial evaluation of the enable_if expressions in toggle-rules.json.
|
|
2
2
|
import type { SlicerSettings } from './settings-keys.d.ts'
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/** Settings accessor — schema default when a value is missing, [0] for vector types. */
|
|
5
5
|
export interface ToggleCfg {
|
|
6
6
|
bool(key: string): boolean
|
|
7
7
|
int(key: string): number
|
|
8
8
|
float(key: string): number
|
|
9
|
-
/**
|
|
9
|
+
/** Whether the key exists in config-schema */
|
|
10
10
|
has(key: string): boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function makeCfg(settings: SlicerSettings | null | undefined): ToggleCfg
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Evaluates a single enable_if expression. Untranslatable expressions return `null` (= fail-open, stays enabled) —
|
|
17
|
+
* make sure to treat that as distinct from `false`.
|
|
18
18
|
*/
|
|
19
19
|
export function evalEnableIf(expr: string, locals: Record<string, unknown>, cfg: ToggleCfg): boolean | null
|
|
20
20
|
|
|
21
|
-
/**
|
|
21
|
+
/** Keys that must be disabled under the current settings -> the enable_if expression that disabled them. Only rules that are unambiguously false. */
|
|
22
22
|
export function disabledKeys(cfg: ToggleCfg): Record<string, string>
|
|
@@ -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 {}
|