progressive transfer of prepare data. zerocodec helps in this scenario
This commit is contained in:
parent
4da43685f4
commit
45b8ac8c2d
7 changed files with 33 additions and 22 deletions
|
|
@ -163,7 +163,7 @@ KIRI.work = {
|
||||||
prepare : function(settings, update, done) {
|
prepare : function(settings, update, done) {
|
||||||
send("prepare", { settings }, function(reply) {
|
send("prepare", { settings }, function(reply) {
|
||||||
if (reply.progress) {
|
if (reply.progress) {
|
||||||
update(reply.progress, reply.message);
|
update(reply.progress, reply.message, reply.layer);
|
||||||
}
|
}
|
||||||
if (reply.done) {
|
if (reply.done) {
|
||||||
done(reply.output, reply.maxSpeed);
|
done(reply.output, reply.maxSpeed);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
const BASE = self.base, KIRI = self.kiri, handlers = {};
|
const BASE = self.base, KIRI = self.kiri, handlers = {};
|
||||||
const freeMem = true;
|
const freeMem = true;
|
||||||
const zeroOut = false;
|
const zeroOut = true;
|
||||||
|
|
||||||
const codec = KIRI.codec = {
|
const codec = KIRI.codec = {
|
||||||
encode: encode,
|
encode: encode,
|
||||||
|
|
|
||||||
|
|
@ -855,9 +855,13 @@
|
||||||
segNumber = 0,
|
segNumber = 0,
|
||||||
startTime,
|
startTime,
|
||||||
lastMsg,
|
lastMsg,
|
||||||
now = Date.now();
|
now = Date.now(),
|
||||||
|
output = [];
|
||||||
|
|
||||||
KIRI.client.prepare(settings, function(progress, message) {
|
KIRI.client.prepare(settings, function(progress, message, layer) {
|
||||||
|
if (layer) {
|
||||||
|
output.push(KIRI.codec.decode(layer));
|
||||||
|
}
|
||||||
if (message !== lastMsg) {
|
if (message !== lastMsg) {
|
||||||
let mark = Date.now();
|
let mark = Date.now();
|
||||||
if (lastMsg) {
|
if (lastMsg) {
|
||||||
|
|
@ -867,7 +871,7 @@
|
||||||
startTime = mark;
|
startTime = mark;
|
||||||
}
|
}
|
||||||
API.show.progress(progress, message);
|
API.show.progress(progress, message);
|
||||||
}, function (output, maxSpeed) {
|
}, function (oldout, maxSpeed) {
|
||||||
if (lastMsg) {
|
if (lastMsg) {
|
||||||
segtimes[`${segNumber++}_${lastMsg}`] = Date.now() - startTime;
|
segtimes[`${segNumber++}_${lastMsg}`] = Date.now() - startTime;
|
||||||
}
|
}
|
||||||
|
|
@ -875,8 +879,8 @@
|
||||||
API.show.progress(0);
|
API.show.progress(0);
|
||||||
if (!isCam) setOpacity(0);
|
if (!isCam) setOpacity(0);
|
||||||
|
|
||||||
output = KIRI.codec.decode(output);
|
// output = KIRI.codec.decode(output);
|
||||||
if (feature.preview && output) {
|
if (feature.preview && output.length) {
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
STACKS.clear();
|
STACKS.clear();
|
||||||
const stack = STACKS.create('print', SPACE.platform.world)
|
const stack = STACKS.create('print', SPACE.platform.world)
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,13 @@ KIRI.worker = {
|
||||||
return console.log({invalid_print_driver: mode, driver});
|
return console.log({invalid_print_driver: mode, driver});
|
||||||
}
|
}
|
||||||
|
|
||||||
const layers = driver.prepare(widgets, settings, (progress, message) => {
|
const layers = driver.prepare(widgets, settings, (progress, message, layer) => {
|
||||||
send.data({ progress, message });
|
const state = { zeros: [] };
|
||||||
|
const emit = { progress, message };
|
||||||
|
if (layer) {
|
||||||
|
emit.layer = KIRI.codec.encode(layer, state)
|
||||||
|
}
|
||||||
|
send.data(emit);
|
||||||
});
|
});
|
||||||
|
|
||||||
const print = current.print || {};
|
const print = current.print || {};
|
||||||
|
|
@ -132,7 +137,7 @@ KIRI.worker = {
|
||||||
|
|
||||||
send.done({
|
send.done({
|
||||||
done: true,
|
done: true,
|
||||||
output: KIRI.codec.encode(layers, state),
|
// output: KIRI.codec.encode(layers, state),
|
||||||
maxSpeed
|
maxSpeed
|
||||||
}, state.zeros);
|
}, state.zeros);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
print.render = KIRI.driver.FDM.prepareRender(print.output, progress => {
|
print.render = KIRI.driver.FDM.prepareRender(print.output, (progress, layer) => {
|
||||||
update(0.5 + progress * 0.5, "render");
|
update(0.5 + progress * 0.5, "render", layer);
|
||||||
}, {
|
}, {
|
||||||
thin: true,
|
thin: true,
|
||||||
print: 0,
|
print: 0,
|
||||||
|
|
|
||||||
|
|
@ -365,23 +365,23 @@
|
||||||
// if layer produced output, append to output array
|
// if layer produced output, append to output array
|
||||||
if (layerout.length) output.append(layerout);
|
if (layerout.length) output.append(layerout);
|
||||||
|
|
||||||
// notify progress
|
|
||||||
layerout.layer = layer++;
|
|
||||||
update((layer / maxLayers) * 0.5, "prepare");
|
|
||||||
|
|
||||||
// retract after last layer
|
// retract after last layer
|
||||||
if (layer === maxLayers && layerout.length) {
|
if (layer === maxLayers && layerout.length) {
|
||||||
layerout.last().retract = true;
|
layerout.last().retract = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// notify progress
|
||||||
|
layerout.layer = layer++;
|
||||||
|
update((layer / maxLayers) * 0.5, "prepare");
|
||||||
|
|
||||||
slices = [];
|
slices = [];
|
||||||
layerout = [];
|
layerout = [];
|
||||||
lastOut = undefined;
|
lastOut = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
print.output = output;
|
print.output = output;
|
||||||
print.render = FDM.prepareRender(output, progress => {
|
print.render = FDM.prepareRender(output, (progress, layer) => {
|
||||||
update(0.5 + progress * 0.5, "render");
|
update(0.5 + progress * 0.5, "render", layer);
|
||||||
}, { tools: device.extruders, thin: isThin, flat: isFlat, fdm: true });
|
}, { tools: device.extruders, thin: isThin, flat: isFlat, fdm: true });
|
||||||
return print.render;
|
return print.render;
|
||||||
};
|
};
|
||||||
|
|
@ -578,7 +578,7 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
update(index / levels.length);
|
update(index / levels.length, output);
|
||||||
});
|
});
|
||||||
|
|
||||||
return layers;
|
return layers;
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@
|
||||||
merged.push(p);
|
merged.push(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
update(slices++ / totalSlices);
|
update((slices++ / totalSlices) * 0.5, "prepare");
|
||||||
});
|
});
|
||||||
let start = newPoint(0,0,0);
|
let start = newPoint(0,0,0);
|
||||||
let gather = [];
|
let gather = [];
|
||||||
|
|
@ -149,7 +149,7 @@
|
||||||
} else {
|
} else {
|
||||||
widget.slices.forEach(function(slice) {
|
widget.slices.forEach(function(slice) {
|
||||||
sliceEmitObjects(print, slice, output);
|
sliceEmitObjects(print, slice, output);
|
||||||
update(slices++ / totalSlices);
|
update((slices++ / totalSlices) * 0.5, "prepare");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -209,7 +209,9 @@
|
||||||
// console.log({laser_it: output});
|
// console.log({laser_it: output});
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return print.render = FDM.prepareRender(output, update, { thin: true, z: 0, action: "cut" });
|
return print.render = FDM.prepareRender(output, (progress, layer) => {
|
||||||
|
update(0.5 + progress * 0.5, "render", layer);
|
||||||
|
}, { thin: true, z: 0, action: "cut" });
|
||||||
};
|
};
|
||||||
|
|
||||||
function exportLaser(print, online, ondone) {
|
function exportLaser(print, online, ondone) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue