From 655b92e2a0ac4e9acc2cb96f063b03f06056f7f2 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 1 Sep 2021 13:50:28 -0400 Subject: [PATCH] fix displayed animation coordinates to line up with exported gcode --- app.js | 2 +- src/mode/cam/animate.js | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index 647485f6..6e4a8850 100644 --- a/app.js +++ b/app.js @@ -72,7 +72,6 @@ function init(mod) { ])); mod.add(fixedmap("/api/", api)); if (debug) { - mod.static("/src/", "src"); mod.static("/mod/", "mod"); mod.sync("/reload", () => { mod.reload(); @@ -80,6 +79,7 @@ function init(mod) { }); } mod.add(rewriteHtmlVersion); + mod.static("/src/", "src"); mod.static("/obj/", "web/obj"); mod.static("/moto/", "web/moto"); mod.static("/meta/", "web/meta"); diff --git a/src/mode/cam/animate.js b/src/mode/cam/animate.js index 80b629c7..3d68e0b3 100644 --- a/src/mode/cam/animate.js +++ b/src/mode/cam/animate.js @@ -17,7 +17,8 @@ self.kiri.loader.push(function() { speedLabel, speed, pauseButton, - playButton; + playButton, + posOffset = { x:0, y:0, z:0 }; // ---( CLIENT FUNCTIONS )--- @@ -92,8 +93,11 @@ self.kiri.loader.push(function() { return; } if (data.mesh_add) { - const { id, ind, pos } = data.mesh_add; + const { id, ind, pos, offset } = data.mesh_add; meshAdd(id, ind, pos); + if (offset) { + posOffset = offset; + } } if (data.mesh_del) { deleteMesh(data.mesh_del); @@ -107,9 +111,9 @@ self.kiri.loader.push(function() { mesh.position.z = pos.z; SPACE.update(); if (id !== 0) { - toolPosX.value = (pos.x * unitScale).toFixed(2); - toolPosY.value = (pos.y * unitScale).toFixed(2); - toolPosZ.value = (pos.z * unitScale).toFixed(2); + toolPosX.value = ((pos.x + posOffset.x) * unitScale).toFixed(2); + toolPosY.value = ((pos.y + posOffset.y) * unitScale).toFixed(2); + toolPosZ.value = ((pos.z + posOffset.z) * unitScale).toFixed(2); } } } @@ -221,6 +225,7 @@ self.kiri.loader.push(function() { if (KIRI.worker) KIRI.worker.animate_setup = function(data, send) { const { settings } = data; + const { process } = settings; const print = current.print; const density = parseInt(settings.controller.animesh) * 1000; @@ -235,6 +240,11 @@ self.kiri.loader.push(function() { const stepsX = Math.floor(stock.x / step); const stepsY = Math.floor(stock.y / step); const { pos, ind } = createGrid(stepsX, stepsY, stock, step); + const offset = { + x: process.outputOriginCenter ? 0 : stock.x / 2, + y: process.outputOriginCenter ? 0 : stock.y / 2, + z: process.camOriginTop ? -stock.z : 0 + } grid = pos; gridX = stepsX; @@ -248,7 +258,7 @@ self.kiri.loader.push(function() { center = Object.assign({}, stock.center); center.z -= stock.z / 2; - send.data({ mesh_add: { id: 0, pos, ind } }); + send.data({ mesh_add: { id: 0, pos, ind, offset } }); send.data({ mesh_move: { id: 0, pos: center } }); send.done(); };