Skip to content

Advanced snippet editor

Davor Hrg edited this page Jun 4, 2021 · 2 revisions

Analysing the whole script would be cumbersome, but a dynamic editor for a part of a script(small snippet) could be useful.

Also main model could be calculated and rendered, and if snippet changes it is ok only to recalculate it, and main model can be left as-is.

sample script

function main({//jscadparams
  height=10,
}){
let radius = 10

//jscaddebug:1
let cylinder1 = cylinder({height, radius})

return [
   cuboid(size:[10,10,10]),
   cylinder1,
]
}

script would be changed to emit variable values during execution by analyzing the code that needs to be debugged, and discovering variables. I could also work if the snippet is inside a loop, as jscadEmmit would be called multiple times.

function main({//jscadparams
  height=10,
}){
let radius = 10

jscadEmmit({height, radius})//jscaddebug:1
let cylinder1 = cylinder({height, radius})

return [
   cuboid(size:[10,10,10]),
   cylinder1,
]
}

the relevant code would be:

cylinder({height, radius})

the scene would then optionally be rendered semi transparent and opaque geometry that is in the snippet would be added extra. This would also allow to have an advanced helper utility for editing such snippet.

Clone this wiki locally