From c8cbf3a088f847e238dfbdde58fc17b24f2e85e7 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 9 Oct 2022 14:37:45 -0400 Subject: [PATCH] change cnc animation speed from timeout steps to step resolution bringing faster animation at a cost of precision at higher speeds --- src/kiri-mode/cam/animate.js | 13 ++++++------- src/kiri/ui.js | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/kiri-mode/cam/animate.js b/src/kiri-mode/cam/animate.js index db1b82d3..6ff71225 100644 --- a/src/kiri-mode/cam/animate.js +++ b/src/kiri-mode/cam/animate.js @@ -12,7 +12,7 @@ const { CAM } = driver; let meshes = {}, unitScale = 1, progress, - speedValues = [ 25, 12, 6, 3 ], + speedValues = [ 1, 2, 3, 4 ], speedNames = [ "1x", "2x", "4x", "8x" ], speedMax = speedValues.length - 1, speedIndex = 0, @@ -57,7 +57,6 @@ kiri.load(() => { pauseButton = UC.newButton(null,pause,{icon:'',title:"pause"}), UC.newButton(null,step,{icon:'',title:"single step"}), UC.newButton(null,fast,{icon:'',title:"toggle speed"}), - UC.newButton(null,skip,{icon:'',title:"skip forward without animation"}), speedLabel = UC.newLabel("speed", {class:"speed"}), progress = UC.newLabel('0%', {class:"progress"}) ]); @@ -387,6 +386,7 @@ kiri.load(() => { updateTool(next.tool, send); } const id = toolID; + const rezstep = rez * renderSpeed; if (last) { const lp = last.point, np = next.point; // dwell ops have no point @@ -396,13 +396,13 @@ kiri.load(() => { } const dx = np.x - lp.x, dy = np.y - lp.y, dz = np.z - lp.z; // skip moves that are closer than resolution - if (Math.sqrt(dx*dx +dy*dy + dz*dz) < rez) { + if (Math.sqrt(dx*dx + dy*dy + dz*dz) < rezstep) { setTimeout(() => { renderPath(send) }, 0); return; } const md = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz)); - const st = Math.ceil(md / rez); + const st = Math.ceil(md / rezstep); const mx = dx / st, my = dy / st, mz = dz / st; const moves = []; for (let i=0, x=lp.x, y=lp.y, z=lp.z; i { send.data({ mesh_move: { id, pos } }); } } - let pauseTime = skipMode ? 0 : renderSpeed; if (index < moves.length) { - setTimeout(update, pauseTime); + setTimeout(update, 0); } else { - setTimeout(() => { renderPath(send) }, pauseTime); + setTimeout(() => { renderPath(send) }, 0); } } update(0); diff --git a/src/kiri/ui.js b/src/kiri/ui.js index 9066cdd0..c65343c0 100644 --- a/src/kiri/ui.js +++ b/src/kiri/ui.js @@ -901,7 +901,6 @@ gapp.register("kiri.ui", [], (root, exports) => { row.classList.add(ce); }); } - row.isBlank = true; return row; }