add optional slice ordering via selection
This commit is contained in:
parent
caa986e9a2
commit
de41b25fba
2 changed files with 12 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ import { exportFile } from './export.js';
|
|||
* Properties: slice, preview, export
|
||||
*/
|
||||
let complete = {};
|
||||
let order;
|
||||
|
||||
/**
|
||||
* Prepare and execute slicing for all widgets on the platform.
|
||||
|
|
@ -46,6 +47,10 @@ function prepareSlices(callback, scale = 1, offset = 0) {
|
|||
callback = preparePreview;
|
||||
}
|
||||
|
||||
order = api.selection.count() ?
|
||||
Object.assign({}, ...api.selection.widgets().map((w,i) => ({[w.id]:i}))) :
|
||||
undefined;
|
||||
|
||||
const widgets = api.widgets.all();
|
||||
const settings = conf.get();
|
||||
const { device, process, controller } = settings;
|
||||
|
|
@ -371,6 +376,7 @@ function preparePreview(callback, scale = 1, offset = 0) {
|
|||
// pass preview mode to worker
|
||||
settings.pmode = feature.pmode;
|
||||
settings.render = true;
|
||||
settings.order = order;
|
||||
|
||||
client.prepare(settings, (progress, message, layer) => {
|
||||
if (layer) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export async function cam_prepare(widgets, settings, update) {
|
|||
const count = active.length;
|
||||
const weight = 1 / count;
|
||||
const print = self.kiri_worker.current.print = newPrint(settings, active);
|
||||
const { origin } = settings;
|
||||
const { order, origin } = settings;
|
||||
|
||||
// wait for safe eval setup
|
||||
await print.ready();
|
||||
|
|
@ -37,7 +37,11 @@ export async function cam_prepare(widgets, settings, update) {
|
|||
print.output = [];
|
||||
|
||||
// sort output by distance to origin
|
||||
if (origin) {
|
||||
if (order) {
|
||||
active.sort((a,b) => {
|
||||
return (order[a.id] ?? Infinity) - (order[b.id] ?? Infinity);
|
||||
});
|
||||
} else if (origin) {
|
||||
let point = newPoint().move(origin);
|
||||
active.sort((w0,w1) =>
|
||||
newPoint().move(w0.track.pos).distTo2D(point) -
|
||||
|
|
|
|||
Loading…
Reference in a new issue