rename sliceAll to slicePost for driver contract

This commit is contained in:
Stewart Allen 2026-01-05 11:21:21 -05:00
commit 5ef26bef03
7 changed files with 32 additions and 18 deletions

View file

@ -146,8 +146,8 @@ function prepareSlices(callback, scale = 1, offset = 0) {
// while more widgets to slice // while more widgets to slice
sliceWidget(toSlice.shift()) sliceWidget(toSlice.shift())
} else { } else {
// once all slicing done, run sliceAll() once for all widgets // once all slicing done, run slicePost() once for all widgets
client.sliceAll(settings, sliceDone); client.slicePost(settings, sliceDone);
} }
} }

View file

@ -237,8 +237,8 @@ export const client = {
// called once after each widget is sliced // called once after each widget is sliced
// performs merged actions that consider all widget slice data // performs merged actions that consider all widget slice data
sliceAll(settings, callback) { slicePost(settings, callback) {
send("sliceAll", { settings }, callback); send("slicePost", { settings }, callback);
}, },
// turn widget slices into unified path output // turn widget slices into unified path output

View file

@ -116,6 +116,7 @@ export const CAM = {
surface_find, surface_find,
slicePre: cam_slice_pre, slicePre: cam_slice_pre,
slice: cam_slice, slice: cam_slice,
slicePost: undefined,
prepare: cam_prepare, prepare: cam_prepare,
export: cam_export export: cam_export
}; };

View file

@ -14,6 +14,11 @@ import { util } from '../../../geo/base.js';
// state shared across all widget slicing // state shared across all widget slicing
let shared; let shared;
/**
* DRIVER SLICE CONTRACT
*
* global slice operation run before individual widget slice() operations
*/
export function cam_slice_pre(settings) { export function cam_slice_pre(settings) {
shared = { ops: { } }; shared = { ops: { } };
} }
@ -21,6 +26,8 @@ export function cam_slice_pre(settings) {
/** /**
* DRIVER SLICE CONTRACT * DRIVER SLICE CONTRACT
* *
* slice operations run per-widget between slicePre and sliceAll
*
* @param {Object} settings * @param {Object} settings
* @param {Widget} widget * @param {Widget} widget
* @param {Function} output * @param {Function} output

View file

@ -1,7 +1,7 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { util } from '../../../geo/base.js'; import { util } from '../../../geo/base.js';
import { fdm_slice, sliceAll, supports } from './slice.js'; import { fdm_slice, slicePost, supports } from './slice.js';
import { fdm_prepare } from './prepare.js'; import { fdm_prepare } from './prepare.js';
import { fdm_export } from './export.js'; import { fdm_export } from './export.js';
import { codec } from '../../core/codec.js'; import { codec } from '../../core/codec.js';
@ -40,8 +40,9 @@ export const FDM = {
init, init,
extrudePerMM, extrudePerMM,
extrudeMM, extrudeMM,
slicePre: undefined,
slice: fdm_slice, slice: fdm_slice,
sliceAll: sliceAll, slicePost: slicePost,
prepare: fdm_prepare, prepare: fdm_prepare,
export: fdm_export export: fdm_export
}; };

View file

@ -19,7 +19,7 @@ let tracker = util.pwait,
fat = 1.5, fat = 1.5,
COLOR = { COLOR = {
anchor: { check: 0x999933, face: 0x999933, line: 0x999933, opacity, lopacity, fat }, anchor: { check: 0x999933, face: 0x999933, line: 0x999933, opacity, lopacity, fat },
fill: { check: 0x00bb77, face: 0x00bb77, line: 0x00bb77, opacity, lopacity, fat }, fill: { check: 0x005588, face: 0x005588, line: 0x005588, opacity, lopacity, fat },
gaps: { check: 0xaa3366, face: 0xaa3366, line: 0xaa3366, opacity, lopacity, fat }, gaps: { check: 0xaa3366, face: 0xaa3366, line: 0xaa3366, opacity, lopacity, fat },
infill: { check: 0x3322bb, face: 0x3322bb, line: 0x3322bb, opacity, lopacity, fat }, infill: { check: 0x3322bb, face: 0x3322bb, line: 0x3322bb, opacity, lopacity, fat },
inset: { line: 0xaaaaaa, check: 0xaaaaaa, face: 0 }, inset: { line: 0xaaaaaa, check: 0xaaaaaa, face: 0 },
@ -29,7 +29,7 @@ let tracker = util.pwait,
thin: { check: 0xbb8800, face: 0xbb8800, line: 0xbb8800, opacity, lopacity, fat }, thin: { check: 0xbb8800, face: 0xbb8800, line: 0xbb8800, opacity, lopacity, fat },
}, },
COLOR_DARK = Object.assign({}, COLOR, { COLOR_DARK = Object.assign({}, COLOR, {
fill: { check: 0x008855, face: 0x008855, line: 0x008855, opacity, lopacity, fat }, fill: { check: 0x005588, face: 0x005588, line: 0x005588, opacity, lopacity, fat },
infill: { check: 0x3322bb, face: 0x3322bb, line: 0x3322bb, opacity, lopacity, fat }, infill: { check: 0x3322bb, face: 0x3322bb, line: 0x3322bb, opacity, lopacity, fat },
inset: { line: 0x555555, check: 0x555555 }, inset: { line: 0x555555, check: 0x555555 },
part: { line: 0x777777, check: 0x777777, face: 0 }, part: { line: 0x777777, check: 0x777777, face: 0 },
@ -58,7 +58,12 @@ function vopt(opt) {
return opt; return opt;
} }
export function sliceAll(settings, onupdate) { /**
* DRIVER SLICE CONTRACT
*
* global slice operation run after all individual widget slice() complete
*/
export function slicePost(settings, onupdate) {
// future home of brim and anchor generation // future home of brim and anchor generation
let widgets = Object.values(self.kiri_worker.cache) let widgets = Object.values(self.kiri_worker.cache)
.filter(w => !w.meta.disabled) .filter(w => !w.meta.disabled)

View file

@ -7,17 +7,17 @@ import '../../add/three.js';
import { base } from '../../geo/base.js'; import { base } from '../../geo/base.js';
import { codec } from '../core/codec.js'; import { codec } from '../core/codec.js';
import { consts } from '../core/consts.js'; import { consts } from '../core/consts.js';
import { util } from '../../geo/base.js';
import { newPoint } from '../../geo/point.js';
import { polygons as POLY } from '../../geo/polygons.js';
import { newPrint } from '../core/print.js';
import { render } from '../core/render.js';
import { wasm_ctrl } from '../../geo/wasm.js';
import { version } from '../../moto/license.js';
import { Widget, newWidget } from '../core/widget.js';
import { load } from "../../load/png.js";
import { JSZip } from '../../ext/jszip-esm.js'; import { JSZip } from '../../ext/jszip-esm.js';
import { load } from "../../load/png.js";
import { newPoint } from '../../geo/point.js';
import { newPrint } from '../core/print.js';
import { polygons as POLY } from '../../geo/polygons.js';
import { RasterPath } from '../../gpu/raster.js'; import { RasterPath } from '../../gpu/raster.js';
import { render } from '../core/render.js';
import { util } from '../../geo/base.js';
import { version } from '../../moto/license.js';
import { wasm_ctrl } from '../../geo/wasm.js';
import { Widget, newWidget } from '../core/widget.js';
import { CAM } from '../mode/cam/driver-be.js'; import { CAM } from '../mode/cam/driver-be.js';
import { DRAG } from '../mode/drag/driver.js'; import { DRAG } from '../mode/drag/driver.js';
@ -482,13 +482,13 @@ const dispatch = {
}); });
}, },
sliceAll(data, send) { slicePost(data, send) {
const { settings } = data; const { settings } = data;
const { mode } = settings; const { mode } = settings;
const driver = drivers[mode]; const driver = drivers[mode];
if (driver.sliceAll) { if (driver.slicePost) {
driver.sliceAll(settings, send.data); driver.slicePost(settings, send.data);
} }
send.done({done: true}); send.done({done: true});