From bb0f436df7d8df033aff9a254ddf809128fe37d9 Mon Sep 17 00:00:00 2001 From: Davor Hrg Date: Mon, 29 Jan 2024 22:39:32 +0100 Subject: [PATCH] fix rebuild with lat params used for smooth switch --- apps/jscad-web/main.js | 5 ++++- packages/render-threejs/index.js | 1 - packages/worker/worker.js | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/jscad-web/main.js b/apps/jscad-web/main.js index a09b06c..944565a 100644 --- a/apps/jscad-web/main.js +++ b/apps/jscad-web/main.js @@ -29,7 +29,7 @@ let currentBase = appBase const toUrl = path => new URL(path, appBase).toString() const viewState = new ViewState() -viewState.onRequireReRender = ()=>paramChangeCallback(lastParams) +viewState.onRequireReRender = ()=>paramChangeCallback(lastRunParams) const gizmo = (window.gizmo = new Gizmo()) byId('overlay').parentNode.appendChild(gizmo) @@ -206,6 +206,7 @@ sendCmdAndSpin('init', { let working let lastParams +let lastRunParams const paramChangeCallback = async params => { if (!working) { lastParams = null @@ -217,6 +218,7 @@ const paramChangeCallback = async params => { let result try{ result = await sendCmdAndSpin('runMain', { params, smooth: viewState.smoothRender }) + lastRunParams = params } finally{ working = false } @@ -229,6 +231,7 @@ const runScript = async ({ script, url = './jscad.model.js', base = currentBase, loadDefault = false // don't load default model if something else was loaded const result = await sendCmdAndSpin('runScript', { script, url, base, root, smooth: viewState.smoothRender }) genParams({ target: byId('paramsDiv'), params: result.def || {}, callback: paramChangeCallback }) + lastRunParams = result.params handlers.entities(result) } diff --git a/packages/render-threejs/index.js b/packages/render-threejs/index.js index d66513e..add012e 100644 --- a/packages/render-threejs/index.js +++ b/packages/render-threejs/index.js @@ -199,7 +199,6 @@ export function RenderThreejs({ } function setScene(scene,{smooth}={}) { - console.warn('options', {smooth}) groups.forEach(group => { _scene.remove(group) }) diff --git a/packages/worker/worker.js b/packages/worker/worker.js index f8ebc9e..3ae0319 100644 --- a/packages/worker/worker.js +++ b/packages/worker/worker.js @@ -91,8 +91,10 @@ const runScript = async ({ script, url, base=globalBase, root=base }) => { main = scriptModule.main // if the main function is the default export if(!main && typeof scriptModule == 'function') main = scriptModule - let out = await runMain({ params: extractDefaults(def) }) + let params = extractDefaults(def) + let out = await runMain({ params }) out.def = def + out.params = params return out }