From b3cbd701a9df066e5518163e31e7d845f92174d8 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 30 Nov 2020 11:30:02 -0500 Subject: [PATCH] adjust tool pos to units. fix slicer bucketing --- notes.md | 1 - src/kiri/slicer2.js | 2 +- src/mode/cam/animate.js | 8 +++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/notes.md b/notes.md index 138b3d1f..817de5de 100644 --- a/notes.md +++ b/notes.md @@ -4,7 +4,6 @@ * `cnc` * - tracing (chamfer, engrave) * - auto feature detection (slicing) -* - show tool x,y,z during animation * `laser` * - drag knife support * `all` diff --git a/src/kiri/slicer2.js b/src/kiri/slicer2.js index 58407425..3b68fbe9 100644 --- a/src/kiri/slicer2.js +++ b/src/kiri/slicer2.js @@ -162,7 +162,7 @@ if (bucketCount > 1) { // create empty buckets - for (let i = 0; i < bucketCount + 1; i++) { + for (let i = 0; i <= bucketCount + 1; i++) { buckets.push([]); } diff --git a/src/mode/cam/animate.js b/src/mode/cam/animate.js index bb737f82..f7a4a000 100644 --- a/src/mode/cam/animate.js +++ b/src/mode/cam/animate.js @@ -8,6 +8,7 @@ self.kiri.loader.push(function() { CAM = KIRI.driver.CAM, API, WORLD, SPACE, meshes = {}, + unitScale = 1, toolPosX, toolPosY, toolPosZ, speedValues = [ 25, 12, 6, 3 ], speedNames = [ "1x", "2x", "4x", "8x" ], @@ -96,9 +97,9 @@ self.kiri.loader.push(function() { mesh.position.z = pos.z; SPACE.update(); if (id !== 0) { - toolPosX.value = pos.x.toFixed(2); - toolPosY.value = pos.y.toFixed(2); - toolPosZ.value = pos.z.toFixed(2); + toolPosX.value = (pos.x * unitScale).toFixed(2); + toolPosY.value = (pos.y * unitScale).toFixed(2); + toolPosZ.value = (pos.z * unitScale).toFixed(2); } } } @@ -169,6 +170,7 @@ self.kiri.loader.push(function() { if (KIRI.client) KIRI.client.animate_setup = function(settings, ondone) { + unitScale = settings.controller.units === 'in' ? 1/25.4 : 1; send("animate_setup", {settings}, ondone); };