update sla driver code format
This commit is contained in:
parent
e22fe7d483
commit
ce031cdd84
7 changed files with 1843 additions and 1820 deletions
2
app.js
2
app.js
|
|
@ -432,6 +432,7 @@ const script = {
|
||||||
"kiri/pack",
|
"kiri/pack",
|
||||||
"kiri/utils",
|
"kiri/utils",
|
||||||
"kiri/slice",
|
"kiri/slice",
|
||||||
|
"kiri/print",
|
||||||
"kiri/layers",
|
"kiri/layers",
|
||||||
"kiri-mode/fdm/fill",
|
"kiri-mode/fdm/fill",
|
||||||
"kiri-mode/fdm/driver",
|
"kiri-mode/fdm/driver",
|
||||||
|
|
@ -454,7 +455,6 @@ const script = {
|
||||||
"kiri-mode/cam/animate",
|
"kiri-mode/cam/animate",
|
||||||
"kiri-mode/laser/driver",
|
"kiri-mode/laser/driver",
|
||||||
"kiri/widget",
|
"kiri/widget",
|
||||||
"kiri/print",
|
|
||||||
"kiri/codec",
|
"kiri/codec",
|
||||||
"kiri/worker"
|
"kiri/worker"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,21 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
// dep: geo.base
|
||||||
|
// dep: kiri-mode.sla.driver
|
||||||
|
gapp.register("kiri-mode.sla.client", [], (root, exports) => {
|
||||||
|
|
||||||
let KIRI = self.kiri,
|
const { base, kiri } = root;
|
||||||
BASE = self.base,
|
const { driver } = kiri;
|
||||||
UTIL = BASE.util,
|
const { util } = base;
|
||||||
SLA = KIRI.driver.SLA;
|
const { SLA } = driver;
|
||||||
|
|
||||||
SLA.init = function(kiri, api) {
|
gapp.overlay(SLA, {
|
||||||
|
init,
|
||||||
|
printDownload
|
||||||
|
});
|
||||||
|
|
||||||
|
function init(kiri, api) {
|
||||||
api.event.on("mode.set", (mode) => {
|
api.event.on("mode.set", (mode) => {
|
||||||
if (mode === 'SLA') {
|
if (mode === 'SLA') {
|
||||||
api.ui.func.preview.classList.add('hide');
|
api.ui.func.preview.classList.add('hide');
|
||||||
|
|
@ -17,17 +24,17 @@
|
||||||
api.ui.func.preview.classList.remove('hide');
|
api.ui.func.preview.classList.remove('hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SLA.printDownload = function(output, API, names) {
|
function printDownload(output, api, names) {
|
||||||
const { file, width, height, layers, volume } = output;
|
const { file, width, height, layers, volume } = output;
|
||||||
const fileroot = names[0] || "print";
|
const fileroot = names[0] || "print";
|
||||||
const filename = `${fileroot}-${new Date().getTime().toString(36)}`;
|
const filename = `${fileroot}-${new Date().getTime().toString(36)}`;
|
||||||
|
|
||||||
API.ajax("/kiri/output-sla.html", html => {
|
api.ajax("/kiri/output-sla.html", html => {
|
||||||
API.ui.print.innerHTML = html;
|
api.ui.print.innerHTML = html;
|
||||||
|
|
||||||
let settings = API.conf.get(),
|
let settings = api.conf.get(),
|
||||||
process = settings.process,
|
process = settings.process,
|
||||||
device = settings.device,
|
device = settings.device,
|
||||||
print_sec = (process.slaBaseLayers * process.slaBaseOn) +
|
print_sec = (process.slaBaseLayers * process.slaBaseOn) +
|
||||||
|
|
@ -68,28 +75,28 @@
|
||||||
switch (device.deviceName) {
|
switch (device.deviceName) {
|
||||||
case 'Anycubic.Photon':
|
case 'Anycubic.Photon':
|
||||||
download.innerText += " .photon";
|
download.innerText += " .photon";
|
||||||
download.onclick = () => { saveFile(API, file, ".photon") };
|
download.onclick = () => { saveFile(api, file, ".photon") };
|
||||||
break;
|
break;
|
||||||
case 'Anycubic.Photon.S':
|
case 'Anycubic.Photon.S':
|
||||||
download.innerText += " .photons";
|
download.innerText += " .photons";
|
||||||
download.onclick = () => { saveFile(API, file, ".photons") };
|
download.onclick = () => { saveFile(api, file, ".photons") };
|
||||||
break;
|
break;
|
||||||
case 'Creality.Halot.Sky':
|
case 'Creality.Halot.Sky':
|
||||||
default:
|
default:
|
||||||
download.innerText += " .cxdlp";
|
download.innerText += " .cxdlp";
|
||||||
download.onclick = () => { saveFile(API, file, ".cxdlp") };
|
download.onclick = () => { saveFile(api, file, ".cxdlp") };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
API.modal.show('print');
|
api.modal.show('print');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveFile(API, file, ext) {
|
function saveFile(api, file, ext) {
|
||||||
saveAs(
|
saveAs(
|
||||||
new Blob([file], { type: "application/octet-stream" }),
|
new Blob([file], { type: "application/octet-stream" }),
|
||||||
$('print-filename').value + ext);
|
$('print-filename').value + ext);
|
||||||
API.modal.hide();
|
api.modal.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,26 +2,26 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
// use: kiri.print
|
||||||
|
// use: kiri.worker
|
||||||
|
gapp.register("kiri-mode.sla.driver", [], (root, exports) => {
|
||||||
|
|
||||||
if (!self.kiri.driver) self.kiri.driver = { };
|
const { kiri } = root
|
||||||
if (self.kiri.driver.SLA) return;
|
const { driver } = kiri;
|
||||||
|
|
||||||
const KIRI = self.kiri,
|
const SLA = driver.SLA = {
|
||||||
SLA = KIRI.driver.SLA = {
|
|
||||||
// init, // src/mode/sla/client.js
|
|
||||||
// slice, // src/mode/sla/slice.js
|
|
||||||
prepare,
|
prepare,
|
||||||
// export, // src/mode/sla/export.js
|
|
||||||
// printDownload, // src/mode/sla/client.js
|
|
||||||
legacy: false
|
legacy: false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (SLA.legacy) console.log("SLA Driver in Legacy Mode");
|
if (SLA.legacy) {
|
||||||
|
console.log("SLA Driver in Legacy Mode");
|
||||||
|
}
|
||||||
|
|
||||||
// runs in worker. would usually be in src/mode/sla/prepare.js
|
// runs in worker. would usually be in src/mode/sla/prepare.js
|
||||||
|
// but the SLA driver skips the prepare step because there is no path routing
|
||||||
function prepare(widgets, settings, update) {
|
function prepare(widgets, settings, update) {
|
||||||
self.worker.print = KIRI.newPrint(settings, widgets);
|
root.worker.print = kiri.newPrint(settings, widgets);
|
||||||
if (!SLA.wasm) {
|
if (!SLA.wasm) {
|
||||||
fetch('/wasm/kiri-sla.wasm')
|
fetch('/wasm/kiri-sla.wasm')
|
||||||
.then(response => response.arrayBuffer())
|
.then(response => response.arrayBuffer())
|
||||||
|
|
@ -46,4 +46,4 @@
|
||||||
update(1);
|
update(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,19 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
// dep: geo.base
|
||||||
|
// dep: kiri-mode.sla.driver
|
||||||
|
// dep: kiri-mode.sla.x_cxdlp
|
||||||
|
// dep: kiri-mode.sla.x_photons
|
||||||
|
gapp.register("kiri-mode.sla.export", [], (root, exports) => {
|
||||||
|
|
||||||
let KIRI = self.kiri,
|
const { base, kiri } = root
|
||||||
BASE = self.base,
|
const { driver } = kiri;
|
||||||
UTIL = BASE.util,
|
const { util } = base;
|
||||||
SLA = KIRI.driver.SLA;
|
const { SLA } = driver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DRIVER PRINT CONTRACT - runs in worker
|
* DRIVER CONTRACT - runs in worker
|
||||||
* @param {Object} print state object
|
* @param {Object} print state object
|
||||||
* @param {Function} online streaming reply
|
* @param {Function} online streaming reply
|
||||||
* @param {Function} ondone last reply
|
* @param {Function} ondone last reply
|
||||||
|
|
@ -167,4 +171,4 @@
|
||||||
console.log({generateCXDLP: print, conf, progress});
|
console.log({generateCXDLP: print, conf, progress});
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,27 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
// dep: geo.base
|
||||||
|
// dep: geo.point
|
||||||
|
// dep: geo.polygon
|
||||||
|
// dep: geo.polygons
|
||||||
|
// dep: kiri.slice
|
||||||
|
// dep: kiri-mode.sla.driver
|
||||||
|
gapp.register("kiri-mode.sla.slice", [], (root, exports) => {
|
||||||
|
|
||||||
let KIRI = self.kiri,
|
const { base, kiri } = root;
|
||||||
BASE = self.base,
|
const { driver, newSlice, newTop } = kiri;
|
||||||
POLY = BASE.polygons,
|
const { util, newPoint, newPolygon, polygons } = base;
|
||||||
UTIL = BASE.util,
|
const { SLA } = driver;
|
||||||
SLA = KIRI.driver.SLA,
|
|
||||||
FDM = KIRI.driver.FDM.share,
|
const POLY = polygons;
|
||||||
tracker = UTIL.pwait,
|
const FDM = driver.FDM.share;
|
||||||
newTop = KIRI.newTop,
|
const tracker = util.pwait;
|
||||||
newSlice = KIRI.newSlice,
|
|
||||||
newPoint = BASE.newPoint,
|
let fill_cache;
|
||||||
newPolygon = BASE.newPolygon,
|
|
||||||
fill_cache;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DRIVER SLICE CONTRACT - runs in worker
|
* DRIVER CONTRACT - runs in worker
|
||||||
*
|
|
||||||
* @param {Object} settings
|
* @param {Object} settings
|
||||||
* @param {Widget} Widget
|
* @param {Widget} Widget
|
||||||
* @param {Function} onupdate (called with % complete and optional message)
|
* @param {Function} onupdate (called with % complete and optional message)
|
||||||
|
|
@ -27,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
SLA.slice = function(settings, widget, onupdate, ondone) {
|
SLA.slice = function(settings, widget, onupdate, ondone) {
|
||||||
let { process, device, controller } = settings,
|
let { process, device, controller } = settings,
|
||||||
isConcurrent = controller.threaded && KIRI.minions.concurrent,
|
isConcurrent = controller.threaded && kiri.minions.concurrent,
|
||||||
work_total,
|
work_total,
|
||||||
work_remain;
|
work_remain;
|
||||||
|
|
||||||
|
|
@ -178,7 +181,7 @@
|
||||||
let trims = slice.solids || [];
|
let trims = slice.solids || [];
|
||||||
traces.appendAll(trims);
|
traces.appendAll(trims);
|
||||||
// slice.unioned = POLY.setZ(POLY.union(traces, undefined, true), slice.z);
|
// slice.unioned = POLY.setZ(POLY.union(traces, undefined, true), slice.z);
|
||||||
slice.unioned = POLY.setZ(await KIRI.minions.union(traces), slice.z);
|
slice.unioned = POLY.setZ(await kiri.minions.union(traces), slice.z);
|
||||||
} else {
|
} else {
|
||||||
slice.unioned = traces;
|
slice.unioned = traces;
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +214,7 @@
|
||||||
let bounds = widget.getBoundingBox();
|
let bounds = widget.getBoundingBox();
|
||||||
let points = widget.getPoints();
|
let points = widget.getPoints();
|
||||||
|
|
||||||
BASE.slice(points, {
|
base.slice(points, {
|
||||||
indices: process.indices || process.xray,
|
indices: process.indices || process.xray,
|
||||||
union: controller.healMesh,
|
union: controller.healMesh,
|
||||||
debug: process.xray,
|
debug: process.xray,
|
||||||
|
|
@ -221,7 +224,7 @@
|
||||||
zInc: height,
|
zInc: height,
|
||||||
// slicer function (worker local or minion distributed)
|
// slicer function (worker local or minion distributed)
|
||||||
slicer(z, points, opts) {
|
slicer(z, points, opts) {
|
||||||
return (isConcurrent ? KIRI.minions.sliceZ : BASE.sliceZ)(z, points, opts);
|
return (isConcurrent ? kiri.minions.sliceZ : base.sliceZ)(z, points, opts);
|
||||||
},
|
},
|
||||||
onupdate(v) {
|
onupdate(v) {
|
||||||
return onupdate(0.0 + v * 0.25);
|
return onupdate(0.0 + v * 0.25);
|
||||||
|
|
@ -602,7 +605,7 @@
|
||||||
if (!cached && seq_c !== 1)
|
if (!cached && seq_c !== 1)
|
||||||
for (let x=start_x; x<end_x; x += step_x) {
|
for (let x=start_x; x<end_x; x += step_x) {
|
||||||
fill.push(
|
fill.push(
|
||||||
BASE.newPolygon().centerRectangle({
|
base.newPolygon().centerRectangle({
|
||||||
x: x + step_x/2,
|
x: x + step_x/2,
|
||||||
y: 0,
|
y: 0,
|
||||||
z: slice.z
|
z: slice.z
|
||||||
|
|
@ -613,7 +616,7 @@
|
||||||
if (!cached && seq_c !== 3)
|
if (!cached && seq_c !== 3)
|
||||||
for (let y=start_y; y<end_y; y += step_y) {
|
for (let y=start_y; y<end_y; y += step_y) {
|
||||||
fill.push(
|
fill.push(
|
||||||
BASE.newPolygon().centerRectangle({
|
base.newPolygon().centerRectangle({
|
||||||
x: 0,
|
x: 0,
|
||||||
y: y + step_y/2,
|
y: y + step_y/2,
|
||||||
z: slice.z
|
z: slice.z
|
||||||
|
|
@ -699,4 +702,4 @@
|
||||||
return {width, height, data:buf, png};
|
return {width, height, data:buf, png};
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
(function() {
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
gapp.register("kiri-mode.sla.x_cxdlp", [], (root, exports) => {
|
||||||
|
|
||||||
const default_values = {
|
const default_values = {
|
||||||
magic1: 'CXSW3DV2',
|
magic1: 'CXSW3DV2',
|
||||||
|
|
@ -447,4 +451,5 @@
|
||||||
} else if (self.navigator) {
|
} else if (self.navigator) {
|
||||||
self.CXDLP = CXDLP;
|
self.CXDLP = CXDLP;
|
||||||
}
|
}
|
||||||
}());
|
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
(function() {
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
let KIRI = self.kiri,
|
"use strict";
|
||||||
BASE = self.base,
|
|
||||||
UTIL = BASE.util,
|
gapp.register("kiri-mode.sla.x_photons", [], (root, exports) => {
|
||||||
SLA = KIRI.driver.SLA;
|
|
||||||
|
const { base, kiri } = root;
|
||||||
|
const { driver } = kiri;
|
||||||
|
const { util } = base;
|
||||||
|
const { SLA } = driver;
|
||||||
|
|
||||||
function generatePhoton(print, conf, progress) {
|
function generatePhoton(print, conf, progress) {
|
||||||
let printset = print.settings,
|
let printset = print.settings,
|
||||||
|
|
@ -536,4 +540,4 @@
|
||||||
renderLayerWasm
|
renderLayerWasm
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue