developer friendly syntax for getParameterDefinitions proposal and interactive demo

  • This is a cross post from
    this demo also aims to be a template for future jscad tutorials

    Here is a presentation of a proposal for a new jscad feature:

    It is an additional syntax that can be used instead getParameterDefinitions to simplify writing scripts that use parameters.

    The intention is to keep getParameterDefinitions and have also this alternative way of defining parameters

    the 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 getParameterDefinitions

    The parser would internally generate this definition based on the source above

    function getParameterDefinitions(){
      return [
        {"name":"_group_2","type":"group","caption":"location (initially closed)","initial":"closed"},

    and the form would be something like this:

    also, this demo uses a new worker implementation (with regl-renderer) that renders to offscreen canvas transferControlToOffscreen so both renderer and script execution are in the worker.

Log in to reply