diff --git a/js/kiri-driver-sla.js b/js/kiri-driver-sla.js index fceeb5aa..fc96126a 100644 --- a/js/kiri-driver-sla.js +++ b/js/kiri-driver-sla.js @@ -528,21 +528,32 @@ let gs_kiri_sla = exports; * @param {Function} update incremental callback */ function printSetup(print, update) { + update(1); + }; + + /** + * DRIVER PRINT CONTRACT - runs in worker + * @param {Object} print state object + * @param {Function} online streaming reply + * @param {Function} ondone last reply + */ + function printExport(print, online, ondone) { let widgets = print.widgets, settings = print.settings, device = settings.device, process = settings.process, - output = print.images = [], + output = print.output, + images = [], layermax = 0, width = 2560, height = 1440, width2 = width/2, height2 = height/2, scaleX = width / device.bedWidth, - scaleY = height / device.bedDepth; - - let mark = Date.now(); + scaleY = height / device.bedDepth, + mark = Date.now(); + // find max layer count widgets.forEach(widget => { layermax = Math.max(widget.slices.length); }); @@ -558,6 +569,7 @@ let gs_kiri_sla = exports; ctx.closePath(); } + // generate layer 8-bit bitaps using canvas for (let index=0; index < layermax; index++) { let layer = new OffscreenCanvas(height,width); let ctx = layer.getContext('2d'); @@ -588,42 +600,21 @@ let gs_kiri_sla = exports; } }); let data = ctx.getImageData(0,0,height,width).data; + // reduce RGBA to R let red = new Uint8ClampedArray(data.length / 4); for (let i=0; i { - online({ - progress: (index / print.images.length) * 0.25, - message: "image_xfer", - data: image - }); - }); - let exp_func; switch (device.deviceName) { @@ -636,9 +627,9 @@ let gs_kiri_sla = exports; } let file = exp_func(print, { - width: 2560, - height: 1440, - lines: print.images, + width: width, + height: height, + lines: images, small: previewSmall.data, large: previewLarge.data }, (progress, message) => { @@ -646,13 +637,11 @@ let gs_kiri_sla = exports; }); ondone({ - width: 2560, - height: 1440, + width: width, + height: height, file: file },[file]); - // release memory - print.images = null; console.log('print.export', Date.now() - mark); }; @@ -729,7 +718,7 @@ let gs_kiri_sla = exports; if (count === 0) { // TODO fix with contract for exposing layer count // hack uses expected gcode output array in print object - print.output = print.printView; + // print.output = print.printView; return; } diff --git a/js/kiri-export.js b/js/kiri-export.js index 9c7f7ed2..387b2706 100644 --- a/js/kiri-export.js +++ b/js/kiri-export.js @@ -32,19 +32,16 @@ let gs_kiri_export = exports; case 'SLA': return exportPrintSLA(currentPrint); } } else { - switch (API.mode.get()) { - case 'SLA': - API.function.slice(exportPrint); - break; - default: - API.function.print(exportPrint); - break; - } + API.function.print(exportPrint); } } function exportPrintSLA(currentPrint) { if (currentPrint) { + if (currentPrint.exported) { + KIRI.driver.SLA.printDownload(currentPrint); + return; + } let lines = []; let times = {}; let mark = Date.now(); @@ -62,6 +59,7 @@ let gs_kiri_export = exports; if (line.progress) API.show.progress(line.progress, "exporting"); if (line.data) lines.push(line.data); }, function(done) { + currentPrint.exported = true; times[`${seq++}_${segment}`] = Date.now() - mark; console.log(times); API.show.progress(0); diff --git a/js/kiri-init.js b/js/kiri-init.js index 0f92afe8..42ebac48 100644 --- a/js/kiri-init.js +++ b/js/kiri-init.js @@ -314,9 +314,7 @@ var gs_kiri_init = exports; API.function.slice(); break; case cca('p'): // prepare print - if (!API.conf.isSliceSkipped()) { - API.function.print(); - } + API.function.print(); break; case cca('P'): // position widget positionSelection(); @@ -1278,7 +1276,7 @@ var gs_kiri_init = exports; expert: UC.newBoolean(LANG.op_xprt_s, booleanSave, {title:LANG.op_xprt_l}), compact: UC.newBoolean(LANG.op_comp_s, booleanSave, {title:LANG.op_comp_l}), dark: UC.newBoolean(LANG.op_dark_s, booleanSave, {title:LANG.op_dark_l}), - showOrigin: UC.newBoolean(LANG.op_show_s, booleanSave, {title:LANG.op_show_l}), + showOrigin: UC.newBoolean(LANG.op_show_s, booleanSave, {title:LANG.op_show_l, modes:GCODE}), alignTop: UC.newBoolean(LANG.op_alig_s, booleanSave, {title:LANG.op_alig_l, modes:CAM}), autoLayout: UC.newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}), freeLayout: UC.newBoolean(LANG.op_free_s, booleanSave, {title:LANG.op_free_l, modes:ALL, expert:true}), diff --git a/js/kiri.js b/js/kiri.js index d8e19852..68a64880 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -60,8 +60,7 @@ self.kiri.copyright = exports.COPYRIGHT; topZ = 0, showFavorites = SDB.getItem('dev-favorites') === 'true', alerts = [], - grouping = false, - skipSliceView = false; + grouping = false; if (SETUP.rm) renderMode = parseInt(SETUP.rm[0]); DBUG.enable(); @@ -165,8 +164,7 @@ self.kiri.copyright = exports.COPYRIGHT; update: updateSettings, restore: restoreSettings, export: settingsExport, - import: settingsImport, - isSliceSkipped: () => { return skipSliceView } + import: settingsImport }, color, const: { @@ -648,8 +646,7 @@ self.kiri.copyright = exports.COPYRIGHT; } function preparePrint(callback) { - let tpFactor = skipSliceView ? 0.5 : 1, - tpBase = skipSliceView ? 0.5 : 0; + if (viewMode === VIEWS.PREVIEW) return; // kick off slicing it hasn't been done already for (let i=0; i < WIDGETS.length; i++) { @@ -674,23 +671,20 @@ self.kiri.copyright = exports.COPYRIGHT; forAllWidgets(function(widget) { widget.setColor(color.cam_preview); }); - } else if (!skipSliceView) { + } else { setOpacity(color.preview_opacity); } currentPrint = kiri.newPrint(settings, WIDGETS); currentPrint.setup(true, function(update, status) { - setProgress(tpBase + update * tpFactor, status); + setProgress(update, status); }, function() { if (!currentPrint) { return setViewMode(VIEWS.ARRANGE); } setProgress(0); - - if (skipSliceView) { - setOpacity(0); - } + setOpacity(0); currentPrint.render(); @@ -749,7 +743,6 @@ self.kiri.copyright = exports.COPYRIGHT; countdown = WIDGETS.length, preserveMax = API.var.layer_max, preserveLayer = API.var.layer_at, - tpFactor = skipSliceView ? 0.5 : 1, totalProgress, track = {}; @@ -770,14 +763,12 @@ self.kiri.copyright = exports.COPYRIGHT; widget.setColor(color.slicing); widget.slice(settings, function(sliced, error) { let mark = UTIL.time(); - if (!skipSliceView) { - // on done - widget.render(renderMode, MODE === MODES.CAM); - // clear wireframe - widget.setWireframe(false, color.wireframe, color.wireframe_opacity); - widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity); - widget.setColor(color.deselected); - } + // on done + widget.render(renderMode, MODE === MODES.CAM); + // clear wireframe + widget.setWireframe(false, color.wireframe, color.wireframe_opacity); + widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity); + widget.setColor(color.deselected); // update UI info if (sliced) { // update segment time @@ -792,19 +783,11 @@ self.kiri.copyright = exports.COPYRIGHT; } // on the last exit, update ui and call the callback if (--countdown === 0 || error || errored) { - if (skipSliceView) { - if (!(error || errored)) { - preparePrint(callback); - } else { - setProgress(0); - } - } else { - setProgress(0); - showSlices(preserveLayer); - setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity); - if (callback && typeof callback === 'function') { - callback(); - } + setProgress(0); + showSlices(preserveLayer); + setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity); + if (callback && typeof callback === 'function') { + callback(); } } // update slider window @@ -831,7 +814,7 @@ self.kiri.copyright = exports.COPYRIGHT; forAllWidgets(function(w) { totalProgress += (track[w.id] || 0); }); - setProgress((totalProgress / WIDGETS.length) * tpFactor, msg); + setProgress((totalProgress / WIDGETS.length), msg); }, true); }); } @@ -942,7 +925,7 @@ self.kiri.copyright = exports.COPYRIGHT; y = -camStock.position.y; } settings.origin = {x, y, z}; - if (settings.controller.showOrigin) { + if (settings.controller.showOrigin && MODE !== MODES.SLA) { SPACE.platform.setOrigin(x,y,z); } else { SPACE.platform.setOrigin(); @@ -970,7 +953,6 @@ self.kiri.copyright = exports.COPYRIGHT; height = parseFloat(dev.bedHeight) ); SPACE.platform.setGZOff(height/2 - 0.1); - // SPACE.platform.setHidden(width > 500 || depth > 500); platform.update_origin(); SPACE.scene.freeze(frozen); } @@ -1845,10 +1827,8 @@ self.kiri.copyright = exports.COPYRIGHT; showModeActive(UI.modeSlice); break; case VIEWS.PREVIEW: - // if (MODE !== MODES.SLA) { - showLayerView(true); - showModeActive(UI.modePreview); - // } + showLayerView(true); + showModeActive(UI.modePreview); break; default: DBUG.log("invalid view mode: "+mode); @@ -1873,7 +1853,6 @@ self.kiri.copyright = exports.COPYRIGHT; function setExpert(bool) { UC.setExpert(UI.expert.checked = control.expert = bool); - updateSkipSliceView(); } function getMode() { @@ -1908,6 +1887,7 @@ self.kiri.copyright = exports.COPYRIGHT; } MODE = MODES[mode]; // updates right-hand menu by enabling/disabling fields + setViewMode(VIEWS.ARRANGE); UC.setMode(MODE); API.conf.load(); API.conf.save(); @@ -1919,6 +1899,7 @@ self.kiri.copyright = exports.COPYRIGHT; UI.modeLASER.setAttribute('class', MODE === MODES.LASER ? 'buton' : ''); UI.mode.style.display = lock ? 'none' : ''; UI.modeTable.style.display = lock ? 'none' : ''; + UI.modelOpacity.style.display = MODE === MODES.SLA ? 'none' : ''; if (camStock) { camStock.material.visible = settings.mode === 'CAM'; } @@ -1927,19 +1908,12 @@ self.kiri.copyright = exports.COPYRIGHT; triggerSettingsEvent(); platformUpdateSelected(); updateFields(); - updateSkipSliceView(); if (settings.device.new) { API.show.devices(); } API.event.emit("mode.set", mode); } - function updateSkipSliceView() { - skipSliceView = MODE === MODES.SLA && - (!LOCAL || settings.controller.expert !== LOCAL); - UI.modePreview.style.display = skipSliceView ? 'none' : ''; - } - function currentDeviceName() { return settings.filter[getMode()]; } diff --git a/js/license.js b/js/license.js index 118b8566..448275f9 100644 --- a/js/license.js +++ b/js/license.js @@ -1,7 +1,7 @@ var exports = { COPYRIGHT:"Copyright (C) Stewart Allen - All Rights Reserved", LICENSE:"See the license.md file included with the source distribution", - VERSION:"1.9.4" + VERSION:"1.9.5" }; if (!module) var module = {}; module.exports = exports; diff --git a/js/moto-space.js b/js/moto-space.js index 76ca2171..66e2a1e8 100644 --- a/js/moto-space.js +++ b/js/moto-space.js @@ -633,7 +633,8 @@ var MOTO = window.moto = window.moto || {}; SCENE.remove(current); SCENE.add(platform); - } + }, + world: WORLD }, view: {