diff --git a/src/app/lib/GCodeVirtualizer.js b/src/app/lib/GCodeVirtualizer.js index e4e87978d..01ee71d4d 100644 --- a/src/app/lib/GCodeVirtualizer.js +++ b/src/app/lib/GCodeVirtualizer.js @@ -205,8 +205,6 @@ class GCodeVirtualizer extends EventEmitter { ]; feedrateCounter = 0; - hasSetV1 = false; - handlers = { // G0: Rapid Linear Move 'G0': (params) => { @@ -244,19 +242,11 @@ class GCodeVirtualizer extends EventEmitter { this.updateBounds(targetPosition); this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z, targetPosition.a); - if (!this.hasSetV1) { - this.data[this.totalLines].lineData = { - v1: this.offsetG92(v1), - v2: this.offsetG92(v2), - shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD, - }; - this.hasSetV1 = true; - } else { - this.data[this.totalLines].lineData = { - v2: this.offsetG92(v2), - shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD, - }; - } + this.data[this.totalLines].lineData = { + v1: this.offsetG92(v1), + v2: this.offsetG92(v2), + shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD, + }; }, // G1: Linear Move // Usage @@ -307,19 +297,11 @@ class GCodeVirtualizer extends EventEmitter { this.updateBounds(targetPosition); this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z, targetPosition.a); - if (!this.hasSetV1) { - this.data[this.totalLines].lineData = { - v1: this.offsetG92(v1), - v2: this.offsetG92(v2), - shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD, - }; - this.hasSetV1 = true; - } else { - this.data[this.totalLines].lineData = { - v2: this.offsetG92(v2), - shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD, - }; - } + this.data[this.totalLines].lineData = { + v1: this.offsetG92(v1), + v2: this.offsetG92(v2), + shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD, + }; }, // G2 & G3: Controlled Arc Move // Usage @@ -410,19 +392,11 @@ class GCodeVirtualizer extends EventEmitter { this.updateBounds(targetPosition); this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z); - if (!this.hasSetV1) { - this.data[this.totalLines].lineData = { - v1: this.offsetG92(v1), - v2: this.offsetG92(v2), - v0: this.offsetG92(v0) - }; - this.hasSetV1 = true; - } else { - this.data[this.totalLines].lineData = { - v2: this.offsetG92(v2), - v0: this.offsetG92(v0) - }; - } + this.data[this.totalLines].lineData = { + v1: this.offsetG92(v1), + v2: this.offsetG92(v2), + v0: this.offsetG92(v0) + }; }, 'G3': (params) => { if (this.modal.motion !== 'G3') { @@ -494,19 +468,11 @@ class GCodeVirtualizer extends EventEmitter { this.updateBounds(targetPosition); this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z); - if (!this.hasSetV1) { - this.data[this.totalLines].lineData = { - v1: this.offsetG92(v1), - v2: this.offsetG92(v2), - v0: this.offsetG92(v0) - }; - this.hasSetV1 = true; - } else { - this.data[this.totalLines].lineData = { - v2: this.offsetG92(v2), - v0: this.offsetG92(v0) - }; - } + this.data[this.totalLines].lineData = { + v1: this.offsetG92(v1), + v2: this.offsetG92(v2), + v0: this.offsetG92(v0) + }; }, // G4: Dwell // Parameters diff --git a/src/app/workers/Visualize.worker.js b/src/app/workers/Visualize.worker.js index 3d943f55b..76e3e497e 100644 --- a/src/app/workers/Visualize.worker.js +++ b/src/app/workers/Visualize.worker.js @@ -406,21 +406,10 @@ onmessage = function({ data }) { const entry = data[i]; if (entry.lineData) { - const { v2, v0, shouldUseAddCurve } = entry.lineData; - // use previous v2 as v1 unless there is no previous entry - let v1 = entry.lineData.v1; - if (!v1) { - // sometimes the last line doesn't have movements, so we must search for the last line with a movement - for (let x = i - 1; x >= 0; x--) { - if (data[x].lineData && data[x].lineData.v2) { - v1 = data[x].lineData.v2; - break; - } - } - } + const { v1, v2, v0, shouldUseAddCurve, dwellTime } = entry.lineData; if (modal.motion === 'G4') { - vm.addToTotalTime(entry.lineData.dwellTime); + vm.addToTotalTime(dwellTime); } else { const targetPosition = { x: v2.x, y: v2.y, z: v2.z }; if (modal.motion === 'G1' || modal.motion === 'G0') {