developer friendly syntax for getParameterDefinitions proposal and interactive demo
-
This is a cross post from https://github.com/jscad/OpenJSCAD.org/discussions/875
this demo also aims to be a template for future jscad tutorials
Here is a presentation of a proposal for a new jscad feature: http://3d.hrg.hr/jscad/three/new_params_proposal/parameters.html#0
It is an additional syntax that can be used instead
getParameterDefinitionsto simplify writing scripts that use parameters.The intention is to keep
getParameterDefinitionsand have also this alternative way of defining parametersthe idea is allow developer to write the source source file like this:
function main({//jscadparams // size radius = 22,// Radius {type:'slider', live:1} // location (initially closed) {initial: 'closed'} x=0, // {type:'slider', live:1} y=0, // {type:'slider', live:1} z=0, // {type:'slider', live:1} }){ return translate([x,y,z],sphere({radius, height:x})) }and the script does not have to provide
getParameterDefinitionsThe parser would internally generate this definition based on the source above
function getParameterDefinitions(){ return [ {"name":"_group_1","type":"group","caption":"size"}, {"caption":"Radius","type":"slider","name":"radius","initial":22,"live":1,"min":0,"max":44}, {"name":"_group_2","type":"group","caption":"location (initially closed)","initial":"closed"}, {"caption":"x","type":"slider","name":"x","initial":0,"live":1,"min":0,"max":100}, {"caption":"y","type":"slider","name":"y","initial":0,"live":1,"min":0,"max":100}, {"caption":"z","type":"slider","name":"z","initial":0,"live":1,"min":0,"max":100}, ] }and the form would be something like this:

also, this demo uses a new worker implementation (with regl-renderer) that renders to offscreen canvas
transferControlToOffscreenso both renderer and script execution are in the worker.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login