diff --git a/src/sliceActions/helpers/GCode.js b/src/sliceActions/helpers/GCode.js index f41e3b5..aa7a04f 100644 --- a/src/sliceActions/helpers/GCode.js +++ b/src/sliceActions/helpers/GCode.js @@ -38,7 +38,7 @@ export default class GCode { turnFanOn(fanSpeed) { this._isFanOn = true; - const gcode = { [M_COMMAND]: 106 } + const gcode = { [M_COMMAND]: 106 }; if (typeof fanSpeed !== 'undefined') gcode[FAN_SPEED] = fanSpeed; this._addGCode(gcode); diff --git a/src/sliceActions/slice.js b/src/sliceActions/slice.js index c51582f..e56b678 100644 --- a/src/sliceActions/slice.js +++ b/src/sliceActions/slice.js @@ -14,19 +14,11 @@ import { hslToRgb } from './helpers/color.js'; // // import removePrecision from './removePrecision.js'; export default function(settings, geometry, openObjectIndexes, constructLinePreview, onProgress) { - const totalStages = 11; - let current = -1; - const updateProgress = (action) => { - current ++; - if (typeof onProgress !== 'undefined') { - onProgress({ - progress: { - done: current, - total: totalStages, - action - } - }); - } + const total = 11; + let done = -1; + const updateProgress = action => { + done ++; + if (onProgress) onProgress({ progress: { done, total, action } }); }; updateProgress('Constructing unique lines from geometry'); @@ -70,9 +62,9 @@ export default function(settings, geometry, openObjectIndexes, constructLinePrev return gcode; } -const PRECISION_INVERSE = 1000; +const PRECISION = 1000; function toFixedTrimmed(value) { - return (Math.round(value * PRECISION_INVERSE) / PRECISION_INVERSE).toString(); + return (Math.round(value * PRECISION) / PRECISION).toString(); } function gcodeToString(gcode) { diff --git a/src/slicer.js b/src/slicer.js index b651aec..0f77d18 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -96,9 +96,7 @@ function sliceAsync(settings, geometry, openObjectIndexes, constructLinePreview, break; } case 'PROGRESS': { - if (typeof onProgress !== 'undefined') { - onProgress(data); - } + if (typeof onProgress !== 'undefined') onProgress(data); break; } }