Merge branch 'rel-4.2' into dev-4.2-refactor-module
This commit is contained in:
commit
b095d7e949
4 changed files with 43 additions and 22 deletions
45
app.js
45
app.js
|
|
@ -498,6 +498,7 @@ const script = {
|
|||
"&main/kiri",
|
||||
],
|
||||
engine : [
|
||||
"@kiri_work",
|
||||
"&kiri-run/engine",
|
||||
"&main/kiri",
|
||||
],
|
||||
|
|
@ -692,11 +693,12 @@ function generateDevices() {
|
|||
function prepareScripts() {
|
||||
generateDevices();
|
||||
for (let key of Object.keys(script)) {
|
||||
code[key] = concatCode(script[key]);
|
||||
code[key] = concatCode(key);
|
||||
}
|
||||
}
|
||||
|
||||
function concatCode(array) {
|
||||
function concatCode(key) {
|
||||
let array = script[key];
|
||||
let code = [];
|
||||
let direct = array.filter(f => f.charAt(0) !== '@');
|
||||
let inject = array.filter(f => f.charAt(0) === '@').map(f => f.substring(1));
|
||||
|
|
@ -706,11 +708,14 @@ function concatCode(array) {
|
|||
// in debug mode, the script should load dependent
|
||||
// scripts instead of serving a complete bundle
|
||||
if (debug) {
|
||||
const code = [
|
||||
inject.forEach(key => {
|
||||
code.push(synth[key]);
|
||||
});
|
||||
code.push(...[
|
||||
oversion ? `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` : '',
|
||||
'self.debug=true;',
|
||||
'(function() { let load = [ '
|
||||
];
|
||||
]);
|
||||
direct.forEach(file => {
|
||||
const vers = cachever[file] || oversion || dversion || version;
|
||||
code.push(`"/${file.replace(/\\/g,'/')}?${vers}",`);
|
||||
|
|
@ -719,6 +724,7 @@ function concatCode(array) {
|
|||
']; function load_next() {',
|
||||
'let file = load.shift();',
|
||||
'if (!file) return;',
|
||||
// 'console.log("loading", file);',
|
||||
'if (!self.document) { importScripts(file); return load_next() }',
|
||||
'let s = document.createElement("script");',
|
||||
's.type = "text/javascript";',
|
||||
|
|
@ -727,27 +733,24 @@ function concatCode(array) {
|
|||
'document.head.appendChild(s);',
|
||||
'} load_next(); })();'
|
||||
].join('\n'));
|
||||
code = code.join('\n');
|
||||
} else {
|
||||
inject.forEach(key => {
|
||||
code.push(synth[key]);
|
||||
});
|
||||
return code.join('\n');
|
||||
}
|
||||
|
||||
direct.forEach(file => {
|
||||
let cached = getCachedFile(file, path => {
|
||||
return minify(PATH.join(dir,file));
|
||||
direct.forEach(file => {
|
||||
let cached = getCachedFile(file, path => {
|
||||
return minify(PATH.join(dir,file));
|
||||
});
|
||||
if (oversion) {
|
||||
cached = `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` + cached;
|
||||
}
|
||||
code.push(cached);
|
||||
});
|
||||
if (oversion) {
|
||||
cached = `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` + cached;
|
||||
}
|
||||
code.push(cached);
|
||||
});
|
||||
|
||||
inject.forEach(key => {
|
||||
code.push(synth[key]);
|
||||
});
|
||||
|
||||
return code.join('');
|
||||
code = code.join('');
|
||||
synth[key] = `self.${key} = "${Buffer.from(code).toString('base64')}";\n`;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
function getCachedFile(file, fn) {
|
||||
|
|
|
|||
|
|
@ -126,11 +126,15 @@ let Instance;
|
|||
|
||||
ext.manifold.then(mod => {
|
||||
mod.default({
|
||||
locateFile() { return "/wasm/manifold.wasm" }
|
||||
locateFile(a,b,c) {
|
||||
return "/wasm/manifold.wasm";
|
||||
}
|
||||
}).then(inst => {
|
||||
inst.setup();
|
||||
Instance = inst;
|
||||
CSG.Instance = () => { return Instance };
|
||||
}).catch(error => {
|
||||
console.log('manifold load error', error);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -134,6 +134,10 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
|
|||
return error('no processes specified');
|
||||
}
|
||||
|
||||
if (stock.x === 0 || stock.y === 0 || stock.z === 0) {
|
||||
return error("one or more stock dimensions is zero<br>offset stock or set to non zero value");
|
||||
}
|
||||
|
||||
if (stock.x && stock.y && stock.z && !isIndexed) {
|
||||
if (stock.x + 0.00001 < bounds.max.x - bounds.min.x) {
|
||||
return error('stock X too small for part. resize stock or use offset stock');
|
||||
|
|
@ -681,6 +685,12 @@ function contourPolys(widget, polys) {
|
|||
}
|
||||
|
||||
function healPolys(noff) {
|
||||
for (let p of noff) {
|
||||
if (p.appearsClosed()) {
|
||||
p.points.pop();
|
||||
p.setClosed();
|
||||
}
|
||||
}
|
||||
if (noff.length > 1) {
|
||||
let heal = 0;
|
||||
// heal/rejoin open segments that share endpoints
|
||||
|
|
|
|||
|
|
@ -70,6 +70,10 @@ const client = exports({
|
|||
newWorker() {
|
||||
if (self.createWorker) {
|
||||
return self.createWorker();
|
||||
} else if (self.kiri_work) {
|
||||
const work = atob(self.kiri_work);
|
||||
const blob = new Blob([ work ], { type: 'application/javascript' });
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
} else {
|
||||
let _ = debug ? '_' : '';
|
||||
return new Worker(`/code/kiri_work.js?${_}${gapp.version}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue