diff --git a/src/kiri/export.js b/src/kiri/export.js index 03b67adf..0585a199 100644 --- a/src/kiri/export.js +++ b/src/kiri/export.js @@ -19,24 +19,14 @@ let printSeq = parseInt(SDB['kiri-print-seq'] || SDB['print-seq'] || "0") + 1; - function isPrepared() { - return API.view.get() === API.const.VIEWS.PREVIEW; - } - function exportFile(options) { - if (isPrepared()) { - const mode = API.mode.get(); - API.event.emit('export', mode); - switch (mode) { - case 'LASER': return callExportLaser(options); - case 'FDM': return callExport(options, mode); - case 'CAM': return callExport(options, mode); - case 'SLA': return callExportSLA(options); - } - } else { - API.function.prepare(function() { - exportFile(options) - }); + const mode = API.mode.get(); + API.event.emit('export', mode); + switch (mode) { + case 'LASER': return callExportLaser(options); + case 'FDM': return callExport(options, mode); + case 'CAM': return callExport(options, mode); + case 'SLA': return callExportSLA(options); } } diff --git a/src/kiri/init.js b/src/kiri/init.js index 833c79ef..db29e41b 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -154,7 +154,10 @@ UI.fps.style.display = on ? 'block' : ''; if (on) { setInterval(() => { - UI.fps.innerText = SPACE.view.getFPS().toFixed(2); + const nv = SPACE.view.getFPS().toFixed(2); + if (nv !== UI.fps.innerText) { + UI.fps.innerText = nv; + } }, 100); } } diff --git a/src/kiri/main.js b/src/kiri/main.js index 9d02379b..d3904983 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -42,6 +42,7 @@ MODE = MODES.FDM, STACKS = KIRI.stacks, DRIVER = undefined, + complete = {}, onEvent = {}, selectedMeshes = [], localFilterKey ='kiri-gcode-filters', @@ -239,7 +240,7 @@ slice: prepareSlices, print: preparePreview, prepare: preparePreview, - export: function() { KIRI.export(...arguments) }, + export: prepareExport, cancel: cancelWorker, clear: KIRI.client.clear }, @@ -696,6 +697,9 @@ callback = preparePreview; } + // clear completion marks + complete = {}; + hideSlider(true); platform.deselect(); setViewMode(VIEWS.SLICE); @@ -752,6 +756,8 @@ API.event.emit('slice.end', getMode()); // print stats DBUG.log(segtimes); + // mark slicing complete for prep/preview + complete.slice = true; if (callback && typeof callback === 'function') { callback(); } @@ -783,11 +789,14 @@ } function preparePreview(callback) { - if (viewMode === VIEWS.PREVIEW) return; - if (viewMode === VIEWS.ARRANGE) { + if (complete.preview) { + return; + } + if (!complete.slice) { prepareSlices(() => { preparePreview(callback); }); + return; } hideSlider(true); @@ -834,12 +843,27 @@ updateSpeeds(maxSpeed); } + // mark preview complete for export + complete.preview = true; + if (typeof(callback) === 'function') { callback(); } }); } + function prepareExport() { + const argsave = arguments; + if (!complete.preview) { + preparePreview(() => { + prepareExport(...argsave); + }); + return; + } + complete.export = true; + KIRI.export(...argsave); + } + function loadCode(code, type) { setViewMode(VIEWS.PREVIEW); setOpacity(0); diff --git a/src/mode/cam/topo.js b/src/mode/cam/topo.js index de4b7ee6..9b848568 100644 --- a/src/mode/cam/topo.js +++ b/src/mode/cam/topo.js @@ -133,6 +133,7 @@ function push_point(x,y,z) { const newP = newPoint(x,y,z); + // todo: merge co-linear, not just co-planar if (lastP && lastP.z === z) { if (curvesOnly) { end_poly(); @@ -189,7 +190,6 @@ // eliminate if points "under" other lines for (let j=0; j= i-1 && j <= i+1) continue; let l2 = lines[j], p3 = l2.p1, p4 = l2.p2; // sort p3,p4 by y for comparison @@ -211,7 +211,7 @@ .addPolys(slice.topPolys()); }); - // for each Y slice, find z grid value (x/z swapped) + // raster grid: for each Y slice, find z grid value (x/z swapped) for (j=0, jl=slices.length; j