From a31af266cf1417c580624c0524cd5525b68caeb0 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 25 Nov 2020 13:09:01 -0500 Subject: [PATCH] fix animation for offset parts --- src/mode/cam/animate.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mode/cam/animate.js b/src/mode/cam/animate.js index b9f0ac84..f74bb57f 100644 --- a/src/mode/cam/animate.js +++ b/src/mode/cam/animate.js @@ -159,7 +159,8 @@ self.kiri.loader.push(function() { // ---( WORKER FUNCTIONS )--- - let path, pathIndex, stock, grid, gridX, gridY, tool, tools, rez, last, toolID = 1; + let stock, center, grid, gridX, gridY, rez; + let path, pathIndex, tool, tools, last, toolID = 1; if (KIRI.worker) KIRI.worker.animate_setup = function(data, send) { @@ -188,7 +189,7 @@ self.kiri.loader.push(function() { animating = false; animateClear = false; - const center = Object.assign({}, stock.center); + center = Object.assign({}, stock.center); center.z -= stock.z / 2; send.data({ mesh_add: { id: 0, pos, ind } }); @@ -336,8 +337,8 @@ self.kiri.loader.push(function() { const { size, pix } = tool.profileDim; const mid = Math.floor(pix/2); const update = new Float32Array(Math.round(prof.length * 0.8)); - const rx = Math.floor((pos.x + stock.x / 2 - size / 2) / rez); - const ry = Math.floor((pos.y + stock.y / 2 - size / 2) / rez); + const rx = Math.floor((pos.x + stock.x / 2 - size / 2 - center.x) / rez); + const ry = Math.floor((pos.y + stock.y / 2 - size / 2 - center.y) / rez); let upos = 0; // deform mesh to lowest point on tool profile for (let i=0, il=prof.length; i < il; ) {