Skip to content

Commit

Permalink
fix rebuild with lat params used for smooth switch
Browse files Browse the repository at this point in the history
  • Loading branch information
hrgdavor committed Jan 29, 2024
1 parent 02f8612 commit bb0f436
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion apps/jscad-web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -206,6 +206,7 @@ sendCmdAndSpin('init', {

let working
let lastParams
let lastRunParams
const paramChangeCallback = async params => {
if (!working) {
lastParams = null
Expand All @@ -217,6 +218,7 @@ const paramChangeCallback = async params => {
let result
try{
result = await sendCmdAndSpin('runMain', { params, smooth: viewState.smoothRender })
lastRunParams = params
} finally{
working = false
}
Expand All @@ -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)
}

Expand Down
1 change: 0 additions & 1 deletion packages/render-threejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export function RenderThreejs({
}

function setScene(scene,{smooth}={}) {
console.warn('options', {smooth})
groups.forEach(group => {
_scene.remove(group)
})
Expand Down
4 changes: 3 additions & 1 deletion packages/worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit bb0f436

Please sign in to comment.