add standalone slicing engine / api

This commit is contained in:
Stewart Allen 2020-12-31 23:22:39 -05:00
commit f8c8f73349
5 changed files with 54 additions and 8 deletions

27
app.js
View file

@ -341,6 +341,32 @@ const script = {
"kiri/codec",
"kiri/worker"
].map(p => `src/${p}.js`),
engine : [
"kiri",
"license",
"ext/three",
"add/array",
"add/three",
"geo/base",
"geo/debug",
"geo/render",
"geo/point",
"geo/points",
"geo/slope",
"geo/line",
"geo/bounds",
"geo/polygon",
"geo/polygons",
"moto/kv",
// "moto/ajax",
"moto/load-stl",
"kiri/conf",
"kiri/client",
"kiri/slice",
"kiri/layers",
"kiri/widget",
"kiri/codec",
].map(p => `src/${p}.js`),
meta : [
"ext/three",
"license",
@ -681,6 +707,7 @@ function prepareScripts() {
code.meta = concatCode(script.meta);
code.kiri = concatCode(script.kiri);
code.worker = concatCode(script.worker);
code.engine = concatCode(script.engine);
}
function concatCode(array) {

View file

@ -3,6 +3,7 @@
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
* `B` normals possibly inverted on faces in 2D to 3D conversion
* `B` normalize left, bottom, right pop menu time/click and value persistence
* `P` duplicate objects should share same slice data unless rotated or scaled
* `P` allow selection to me decimated on demand (context menu?)
@ -97,3 +98,9 @@
# More CNC
* https://www.researchgate.net/publication/250328721_Toolpath_Optimization_on_Automatic_Removal_Uncut_and_Application
# Zip output
* https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html
* https://en.wikipedia.org/wiki/ZIP_(file_format)
* https://stuk.github.io/jszip/

View file

@ -3,15 +3,12 @@
"use strict";
// this code runs in kiri's main loop
if (!self.kiri) self.kiri = {};
let loc = self.location,
let KIRI = self.kiri = self.kiri || {},
loc = self.location,
host = loc.hostname,
port = loc.port,
proto = loc.protocol,
time = function() { return new Date().getTime() },
KIRI = self.kiri,
BASE = self.base,
seqid = 1,
syncd = {},
running = {},

View file

@ -60,9 +60,6 @@
DBUG.enable();
// remove version, preserve other settings
WIN.history.replaceState({},'','/kiri/' + encodeOpt(SETUP) + LOC.hash);
// add show() to catalog for API
CATALOG.show = showCatalog;
@ -446,6 +443,9 @@
STATS.set('init', inits);
STATS.set('kiri', kiri.version);
// remove version from url, preserve other settings
WIN.history.replaceState({},'','/kiri/' + encodeOpt(SETUP) + LOC.hash);
/** ******************************************************************
* Utility Functions
******************************************************************* */

View file

@ -45,6 +45,21 @@
isThin = settings.controller.lineType === "line",
isFlat = settings.controller.lineType === "flat";
// compute bounds if missing
if (!bounds) {
bounds = new THREE.Box3();
for (let widget of widgets) {
let wp = widget.track.pos;
let wb = widget.bounds.clone();
wb.min.x += wp.x;
wb.max.x += wp.x;
wb.min.y += wp.y;
wb.max.y += wp.y;
bounds.union(wb);
}
settings.bounds = bounds;
}
// TODO pick a widget with a slice on the first layer and use that nozzle
// create brim, skirt, raft if specificed in FDM mode (code shared by laser)
if (process.outputBrimCount || process.outputRaft) {