comments and tweaks on belt slicing
This commit is contained in:
parent
eb534a17ff
commit
9aae90880c
6 changed files with 53 additions and 52 deletions
|
|
@ -137,15 +137,6 @@ const client = exports({
|
|||
restarting = false;
|
||||
},
|
||||
|
||||
decimate(vertices, options, callback) {
|
||||
let alert = kiri.api.show.alert('processing model', 1000);
|
||||
vertices = vertices.buffer.slice(0);
|
||||
send("decimate", {vertices, options}, (output) => {
|
||||
kiri.api.hide.alert(alert);
|
||||
callback(output);
|
||||
});
|
||||
},
|
||||
|
||||
config(obj) {
|
||||
send("config", obj, noop);
|
||||
},
|
||||
|
|
@ -171,27 +162,27 @@ const client = exports({
|
|||
// send list of currently valid widgets
|
||||
send("sync", { valid: widgets.map(w => w.id) }, () => {});
|
||||
// sync any widget that has changed
|
||||
widgets.forEach(widget => {
|
||||
if (widget.modified || !syncd[widget.id]) {
|
||||
syncd[widget.id] = true;
|
||||
let vertices = widget.getGeoVertices();
|
||||
send("sync", {
|
||||
id: widget.id,
|
||||
meta: widget.meta,
|
||||
group: widget.group.id,
|
||||
track: widget.track,
|
||||
vertices: copy ? vertices.slice() : vertices,
|
||||
position: widget.mesh.position,
|
||||
}, done => {
|
||||
widget.modified = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
for (let widget of widgets.filter(w => w.modified || !syncd[w.id])) {
|
||||
syncd[widget.id] = true;
|
||||
let vertices = widget.getGeoVertices();
|
||||
send("sync", {
|
||||
id: widget.id,
|
||||
meta: widget.meta,
|
||||
group: widget.group.id,
|
||||
track: widget.track,
|
||||
vertices: copy ? vertices.slice() : vertices,
|
||||
position: widget.mesh.position,
|
||||
}, done => {
|
||||
widget.modified = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// for belt / angled printing
|
||||
rotate(settings, callback) {
|
||||
send("rotate", { settings }, reply => {
|
||||
if (reply.group) {
|
||||
// collect post-rotation data for slice/preview renders
|
||||
for (let widget of kiri.Widget.Groups.forid(reply.group)) {
|
||||
widget.belt = reply.belt;
|
||||
}
|
||||
|
|
@ -201,6 +192,7 @@ const client = exports({
|
|||
});
|
||||
},
|
||||
|
||||
// called once for each widget
|
||||
slice(settings, widget, callback) {
|
||||
send("slice", {
|
||||
id: widget.id,
|
||||
|
|
@ -217,10 +209,13 @@ const client = exports({
|
|||
});
|
||||
},
|
||||
|
||||
// called once after each widget is sliced
|
||||
// performs merged actions that consider all widget slice data
|
||||
sliceAll(settings, callback) {
|
||||
send("sliceAll", { settings }, callback);
|
||||
},
|
||||
|
||||
// turn widget slices into unified path output
|
||||
prepare(settings, update, done) {
|
||||
send("prepare", { settings }, reply => {
|
||||
if (reply.progress) {
|
||||
|
|
@ -235,6 +230,7 @@ const client = exports({
|
|||
});
|
||||
},
|
||||
|
||||
// convert path output to gcode or other target file output
|
||||
export(settings, online, ondone) {
|
||||
send("export", { settings }, reply => {
|
||||
if (reply.line) {
|
||||
|
|
|
|||
|
|
@ -27,12 +27,15 @@ function prepareSlices(callback, scale = 1, offset = 0) {
|
|||
const { stacks } = kiri;
|
||||
|
||||
if (view.is_arrange()) {
|
||||
// in arrange mode, create a screenshot at the start slicing
|
||||
// this can be used later by exports and rendered on some devices
|
||||
let snap = space.screenshot();
|
||||
view.snapshot = snap.substring(snap.indexOf(",") + 1);
|
||||
client.snap(space.screenshot2({width: 640}));
|
||||
}
|
||||
|
||||
if (mode.is_sla() && !callback) {
|
||||
// in SLA mode, slice and preview are the same thing
|
||||
callback = preparePreview;
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +46,7 @@ function prepareSlices(callback, scale = 1, offset = 0) {
|
|||
const mark = Date.now();
|
||||
|
||||
// force layout in belt mode when widget exceeds bed length
|
||||
// which has the side-effect (intended) of increasing the bed size
|
||||
if (widgets.length && isBelt) {
|
||||
let doLayout = false;
|
||||
for (let w of widgets) {
|
||||
|
|
@ -115,18 +119,23 @@ function prepareSlices(callback, scale = 1, offset = 0) {
|
|||
|
||||
stacks.clear();
|
||||
if (isBelt) {
|
||||
// force re-sync in belt mode
|
||||
// clearing cache causes data to be re-sent to worker
|
||||
client.clear();
|
||||
// we send copies of vertices in belt mode only (possibly obsolete?)
|
||||
client.sync(undefined, true);
|
||||
// belt op required to rotate meshes for slicing
|
||||
client.rotate(settings);
|
||||
} else {
|
||||
// send updated vertices if widget has been rotated/scaled
|
||||
client.sync();
|
||||
}
|
||||
client.sync(undefined, isBelt);
|
||||
client.rotate(settings);
|
||||
|
||||
function sliceNext() {
|
||||
if (toSlice.length) {
|
||||
// while more widgets to slice
|
||||
sliceWidget(toSlice.shift())
|
||||
} else {
|
||||
// once all slicing done, run sliceAll() once
|
||||
// once all slicing done, run sliceAll() once for all widgets
|
||||
client.sliceAll(settings, sliceDone);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue