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",
|
"&main/kiri",
|
||||||
],
|
],
|
||||||
engine : [
|
engine : [
|
||||||
|
"@kiri_work",
|
||||||
"&kiri-run/engine",
|
"&kiri-run/engine",
|
||||||
"&main/kiri",
|
"&main/kiri",
|
||||||
],
|
],
|
||||||
|
|
@ -692,11 +693,12 @@ function generateDevices() {
|
||||||
function prepareScripts() {
|
function prepareScripts() {
|
||||||
generateDevices();
|
generateDevices();
|
||||||
for (let key of Object.keys(script)) {
|
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 code = [];
|
||||||
let direct = array.filter(f => f.charAt(0) !== '@');
|
let direct = array.filter(f => f.charAt(0) !== '@');
|
||||||
let inject = array.filter(f => f.charAt(0) === '@').map(f => f.substring(1));
|
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
|
// in debug mode, the script should load dependent
|
||||||
// scripts instead of serving a complete bundle
|
// scripts instead of serving a complete bundle
|
||||||
if (debug) {
|
if (debug) {
|
||||||
const code = [
|
inject.forEach(key => {
|
||||||
|
code.push(synth[key]);
|
||||||
|
});
|
||||||
|
code.push(...[
|
||||||
oversion ? `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` : '',
|
oversion ? `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` : '',
|
||||||
'self.debug=true;',
|
'self.debug=true;',
|
||||||
'(function() { let load = [ '
|
'(function() { let load = [ '
|
||||||
];
|
]);
|
||||||
direct.forEach(file => {
|
direct.forEach(file => {
|
||||||
const vers = cachever[file] || oversion || dversion || version;
|
const vers = cachever[file] || oversion || dversion || version;
|
||||||
code.push(`"/${file.replace(/\\/g,'/')}?${vers}",`);
|
code.push(`"/${file.replace(/\\/g,'/')}?${vers}",`);
|
||||||
|
|
@ -719,6 +724,7 @@ function concatCode(array) {
|
||||||
']; function load_next() {',
|
']; function load_next() {',
|
||||||
'let file = load.shift();',
|
'let file = load.shift();',
|
||||||
'if (!file) return;',
|
'if (!file) return;',
|
||||||
|
// 'console.log("loading", file);',
|
||||||
'if (!self.document) { importScripts(file); return load_next() }',
|
'if (!self.document) { importScripts(file); return load_next() }',
|
||||||
'let s = document.createElement("script");',
|
'let s = document.createElement("script");',
|
||||||
's.type = "text/javascript";',
|
's.type = "text/javascript";',
|
||||||
|
|
@ -727,27 +733,24 @@ function concatCode(array) {
|
||||||
'document.head.appendChild(s);',
|
'document.head.appendChild(s);',
|
||||||
'} load_next(); })();'
|
'} load_next(); })();'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
|
code = code.join('\n');
|
||||||
|
} else {
|
||||||
inject.forEach(key => {
|
inject.forEach(key => {
|
||||||
code.push(synth[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 => {
|
if (oversion) {
|
||||||
return minify(PATH.join(dir,file));
|
cached = `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` + cached;
|
||||||
|
}
|
||||||
|
code.push(cached);
|
||||||
});
|
});
|
||||||
if (oversion) {
|
code = code.join('');
|
||||||
cached = `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` + cached;
|
synth[key] = `self.${key} = "${Buffer.from(code).toString('base64')}";\n`;
|
||||||
}
|
}
|
||||||
code.push(cached);
|
return code;
|
||||||
});
|
|
||||||
|
|
||||||
inject.forEach(key => {
|
|
||||||
code.push(synth[key]);
|
|
||||||
});
|
|
||||||
|
|
||||||
return code.join('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCachedFile(file, fn) {
|
function getCachedFile(file, fn) {
|
||||||
|
|
|
||||||
|
|
@ -126,11 +126,15 @@ let Instance;
|
||||||
|
|
||||||
ext.manifold.then(mod => {
|
ext.manifold.then(mod => {
|
||||||
mod.default({
|
mod.default({
|
||||||
locateFile() { return "/wasm/manifold.wasm" }
|
locateFile(a,b,c) {
|
||||||
|
return "/wasm/manifold.wasm";
|
||||||
|
}
|
||||||
}).then(inst => {
|
}).then(inst => {
|
||||||
inst.setup();
|
inst.setup();
|
||||||
Instance = inst;
|
Instance = inst;
|
||||||
CSG.Instance = () => { return Instance };
|
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');
|
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 && stock.y && stock.z && !isIndexed) {
|
||||||
if (stock.x + 0.00001 < bounds.max.x - bounds.min.x) {
|
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');
|
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) {
|
function healPolys(noff) {
|
||||||
|
for (let p of noff) {
|
||||||
|
if (p.appearsClosed()) {
|
||||||
|
p.points.pop();
|
||||||
|
p.setClosed();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (noff.length > 1) {
|
if (noff.length > 1) {
|
||||||
let heal = 0;
|
let heal = 0;
|
||||||
// heal/rejoin open segments that share endpoints
|
// heal/rejoin open segments that share endpoints
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,10 @@ const client = exports({
|
||||||
newWorker() {
|
newWorker() {
|
||||||
if (self.createWorker) {
|
if (self.createWorker) {
|
||||||
return 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 {
|
} else {
|
||||||
let _ = debug ? '_' : '';
|
let _ = debug ? '_' : '';
|
||||||
return new Worker(`/code/kiri_work.js?${_}${gapp.version}`);
|
return new Worker(`/code/kiri_work.js?${_}${gapp.version}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue