Template:Jscad: Difference between revisions

From BITPlan Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 88: Line 88:
   function updateSolid()
   function updateSolid()
   {
   {
     gProcessor.setJsCad(document.getElementById('code').value);
     gProcessor.setJsCad(document.getElementById('jscadcode').value);
   }
   }
</script>
</script>
Line 95: Line 95:
<h2>Source code</h2>
<h2>Source code</h2>
Below is the OpenJsCad script.
Below is the OpenJsCad script.
<textarea id='code' style="height: 500px">{{{code|}}}</textarea>
<textarea id='jscadcode' style="height: 500px">{{{code|}}}</textarea>
<input type="submit" value="Update" onclick="updateSolid(); return false;">
<input type="submit" value="Update" onclick="updateSolid(); return false;">
<script>
<script>

Revision as of 08:49, 10 June 2019

Usage

Put your JSCAD code inside a source tag and add a call of this template

{{jscad|title=OpenJSCAD.org Logo|code=// title      : OpenJSCAD.org Logo
// author     : Rene K. Mueller
// license    : MIT License
// revision   : 0.003
// tags       : Logo,Intersection,Sphere,Cube
// file       : logo.jscad

function main () {
  return union(
    difference(
      cube({size: 3, center: true}),
      sphere({r: 2, center: true})
    ),
    intersection(
      sphere({r: 1.3, center: true}),
      cube({size: 2.1, center: true})
    )
  ).translate([0, 0, 1.5]).scale(10);
}
}}

Example

Source code

Below is the OpenJsCad script.