docs: function runJscadWorker(e) {
    var r = {cmd: "error", txt: "try again"};
    if (e.data instanceof Object) {
      var data = e.data;
      if(data.cmd == 'render') {
      // verify the command contents
        if(!data.parameters) { throw new Error("JSCAD Processor: missing 'parameters'"); }
      // setup the environment
        if(data.libraries && data.libraries.length) {
          data.libraries.map( function(l) { importScripts(l); } );
        }
      // setup the script
        if (typeof(main) == 'function') {
          var results = main( data.parameters );
          if (!results.length) { results = [results]; }
        // convert the results to a compact format for transfer back
          var objects = [];
          for(var i=0; i<results.length; i++) {
            var o = results[i];
            if (o instanceof CAG || o instanceof CSG) {
              objects.push(o.toCompactBinary());
            }
          }
        // return the results
          if (objects.length > 0) {
            r.cmd = "rendered";
            r.objects = objects;
          } else {
            r.err = 'The JSCAD script must return one or more CSG or CAG solids.';
          }
        } else {
          r.err = 'The JSCAD script must contain a function main() which returns one or more CSG or CAG solids.';
        }
      } else {
        throw new Error('JSCAD Processor: invalid worker command: '+data.cmd);
      }
    }
    postMessage(r);
  }