From 9526b1d86a6b4f34ac690b46b1abd7e64ac7f25f Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 5 Dec 2020 16:00:54 -0500 Subject: [PATCH] add progress to animation. toggle play/pause button show/hide --- notes.md | 2 +- src/mode/cam/animate.js | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/notes.md b/notes.md index ae24833c..c96b65d5 100644 --- a/notes.md +++ b/notes.md @@ -83,7 +83,7 @@ * `F` add support for tapered ball mills * `F` warn when part > stock or cuts go outside bed * `F` animation should clear the mesh in areas where the cuts go through the stock? -* `P` crossing open space check point is outside camshell before returning max z +* `F` show render progress bar or % * `P` detect render message backlog and pause or warn * `P` redo all path route / planning in prepare to account for terrain before camOut * `P` fast forward animation with "chunking" or "skip animation" diff --git a/src/mode/cam/animate.js b/src/mode/cam/animate.js index f692a5dd..c4a5d826 100644 --- a/src/mode/cam/animate.js +++ b/src/mode/cam/animate.js @@ -9,12 +9,14 @@ self.kiri.loader.push(function() { API, WORLD, SPACE, meshes = {}, unitScale = 1, - toolPosX, toolPosY, toolPosZ, + progress, toolPosX, toolPosY, toolPosZ, speedValues = [ 25, 12, 6, 3 ], speedNames = [ "1x", "2x", "4x", "8x" ], speedIndex = 0, speedLabel, - speed; + speed, + pauseButton, + playButton; // ---( CLIENT FUNCTIONS )--- @@ -43,10 +45,10 @@ self.kiri.loader.push(function() { UC.setGroup(layer); UC.newRow([ UC.newButton(null,replay,{icon:'',title:"restart"}), - UC.newButton(null,play,{icon:'',title:"play"}), + playButton = UC.newButton(null,play,{icon:'',title:"play"}), + pauseButton = UC.newButton(null,pause,{icon:'',title:"pause"}), UC.newButton(null,step,{icon:'',title:"step"}), - UC.newButton(null,fast,{icon:'',title:"faster"}), - UC.newButton(null,pause,{icon:'',title:"pause"}), + UC.newButton(null,fast,{icon:'',title:"speed"}), speedLabel = UC.newLabel("speed") ]); updateSpeed(); @@ -56,9 +58,12 @@ self.kiri.loader.push(function() { const toolpos = $('layer-toolpos'); toolpos.innerHTML = ''; UC.setGroup(toolpos); + progress = UC.newInput('%', {disabled: true, size: 5}); toolPosX = UC.newInput('x', {disabled: true, size: 7}); toolPosY = UC.newInput('y', {disabled: true, size: 7}); toolPosZ = UC.newInput('z', {disabled: true, size: 7}); + playButton.style.display = ''; + pauseButton.style.display = 'none'; }); }; @@ -151,21 +156,32 @@ self.kiri.loader.push(function() { function play(opts) { const { steps } = opts; updateSpeed(); + if (steps !== 1) { + playButton.style.display = 'none'; + pauseButton.style.display = ''; + } KIRI.client.animate({speed, steps: steps || Infinity}, handleGridUpdate); } function fast(opts) { const { steps } = opts; updateSpeed(1); + playButton.style.display = 'none'; + pauseButton.style.display = ''; KIRI.client.animate({speed, steps: steps || Infinity}, handleGridUpdate); } function pause() { + playButton.style.display = ''; + pauseButton.style.display = 'none'; KIRI.client.animate({speed: 0}, handleGridUpdate); } function handleGridUpdate(data) { checkMeshCommands(data); + if (data && data.progress) { + progress.value = (data.progress * 100).toFixed(1) + } } if (KIRI.client) @@ -338,6 +354,7 @@ self.kiri.loader.push(function() { } moves.push(next.point); renderMoves(id, moves, send); + send.data({ progress: pathIndex / path.length }); } else { tool.pos = next.point; send.data({ mesh_move: { id, pos: next.point }});