From f30865c60a5f36c82ef27e4df8157f1b3ce9a967 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 4 Mar 2021 15:17:09 -0500 Subject: [PATCH] stub in placeholder for fdm animation --- src/kiri/main.js | 6 +++++- src/kiri/stack.js | 1 + src/mode/cam/client.js | 4 ++-- src/mode/fdm/client.js | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/kiri/main.js b/src/kiri/main.js index 07e9f9e6..3fa57428 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -287,7 +287,7 @@ slice: prepareSlices, print: preparePreview, prepare: preparePreview, - animate: noop, + animate: prepareAnimation, export: prepareExport, cancel: cancelWorker, clear: KIRI.client.clear, @@ -1221,6 +1221,10 @@ }); } + function prepareAnimation() { + API.event.emit("function.animate", {mode: settings.mode}); + } + function prepareExport() { const argsave = arguments; if (!complete.preview) { diff --git a/src/kiri/stack.js b/src/kiri/stack.js index a510b60c..48d6f268 100644 --- a/src/kiri/stack.js +++ b/src/kiri/stack.js @@ -49,6 +49,7 @@ } setLastFraction(frac = 1) { + if (this.lastVis) for (let mesh of this.lastVis.children) { let geo = mesh.geometry; let pos = geo.attributes.position; diff --git a/src/mode/cam/client.js b/src/mode/cam/client.js index b58aed86..2bf4f16d 100644 --- a/src/mode/cam/client.js +++ b/src/mode/cam/client.js @@ -41,7 +41,7 @@ API = api; // wire up animate button in ui - api.function.animate = () => { + api.event.on("function.animate", (mode) => { if (isCamMode && !camStock) { return api.show.alert("animation requires stock to be enabled"); } @@ -50,7 +50,7 @@ animate(); } }); - }; + }); api.event.on("mode.set", (mode) => { isCamMode = mode === 'CAM'; diff --git a/src/mode/fdm/client.js b/src/mode/fdm/client.js index 8e6296f7..7f56f8a2 100644 --- a/src/mode/fdm/client.js +++ b/src/mode/fdm/client.js @@ -102,6 +102,24 @@ } } + api.event.on("function.animate", (mode) => { + if (!isFdmMode) { + return; + } + if (!API.conf.get().controller.danger) { + return; + } + let pct = 0; + let int = setInterval(function() { + if (pct <= 1) { + api.const.STACKS.setFraction(pct); + pct += 0.05; + } else { + api.const.STACKS.setFraction(1); + clearTimeout(int); + } + }, 50); + }); api.event.on("mode.set", mode => { isFdmMode = mode === 'FDM'; lastMode = mode;