stub in zip library

This commit is contained in:
Stewart Allen 2021-02-01 16:39:22 -05:00
commit bab0a13a14
6 changed files with 31 additions and 2 deletions

1
app.js
View file

@ -299,6 +299,7 @@ const script = {
"kiri", "kiri",
"ext/three", "ext/three",
"ext/pngjs", "ext/pngjs",
"ext/jszip",
"license", "license",
"ext/clip2", "ext/clip2",
"ext/earcut", "ext/earcut",

View file

@ -26,6 +26,7 @@
"connect": "^3.7.0", "connect": "^3.7.0",
"earcut": "^2.2.2", "earcut": "^2.2.2",
"express-useragent": "^1.0.13", "express-useragent": "^1.0.13",
"jszip": "^3.5.0",
"level": "^6.0.1", "level": "^6.0.1",
"leveldown": "^5.6.0", "leveldown": "^5.6.0",
"levelup": "^4.4.0", "levelup": "^4.4.0",

1
src/ext/jszip.js Symbolic link
View file

@ -0,0 +1 @@
../../node_modules/jszip/dist/jszip.js

View file

@ -15,7 +15,9 @@ let KIRI = self.kiri = self.kiri || {},
syncd = {}, syncd = {},
running = {}, running = {},
slicing = {}, slicing = {},
worker = null; worker = null
// occ = new Worker("/kiri/ext/occ-worker.js", {type:"module"}),
;
/** /**
* @param {Function} fn name of function in KIRI.worker * @param {Function} fn name of function in KIRI.worker
@ -243,6 +245,12 @@ KIRI.work = {
output(reply.done); output(reply.done);
} }
}, [ data.png ]); }, [ data.png ]);
},
zip: function(files) {
send("zip", {files}, reply => {
console.log({zip_said: reply});
});
} }
}; };

View file

@ -536,6 +536,24 @@ KIRI.worker = {
// send.done({done: {verts, faces, bigv, vi, ii}}, [ bigv.buffer ]); // send.done({done: {verts, faces, bigv, vi, ii}}, [ bigv.buffer ]);
send.done({done: {bigv}}, [ bigv.buffer ]); send.done({done: {bigv}}, [ bigv.buffer ]);
}); });
},
zip: function(data, send) {
let { files } = data;
let zip = new JSZip();
for (let file of files) {
zip.file(file.name, file.data);
}
zip.generateAsync({
type: "uint8array",
compression: "DEFLATE",
compressionOptions: { level: 3 },
streamFiles: true
}, progress => {
send.data(progress);
}).then(output => {
send.done(output);
});
} }
}; };

View file

@ -405,7 +405,7 @@
indices = indices.appendAll(flats).sort((a,b) => b-a); indices = indices.appendAll(flats).sort((a,b) => b-a);
// console.log('indices', ...indices, {zBottom, slicer}); // console.log('indices', ...indices, {zBottom, slicer});
if (op.outside && !op.inside) { if (op.outside && !op.inside) {
console.log({outline_bypass: indices, down: op.down}); // console.log({outline_bypass: indices, down: op.down});
indices.forEach((ind,i) => { indices.forEach((ind,i) => {
if (flats.indexOf(ind) >= 0) { if (flats.indexOf(ind) >= 0) {
// exclude flats // exclude flats