Template:Jscad: Difference between revisions

From BITPlan Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
Put your JSCAD code inside a source tag and add a call of this template
Put your JSCAD code inside a source tag and add a call of this template
<pre>
<pre>
{{jscad|title=OpenJSCAD.org Logo|code=// title      : OpenJSCAD.org Logo
{{jscad|title=OpenJSCAD example|code=function main()
// author    : Rene K. Mueller
{
// license    : MIT License
  var resolution = 24; // increase to get smoother corners (will get slow!)
// revision   : 0.003
 
// tags      : Logo,Intersection,Sphere,Cube
   var cube1 = CSG.roundedCube({center: [0,0,0], radius: [10,10,10], roundradius: 2, resolution: resolution});
// file      : logo.jscad
   var sphere1 = CSG.sphere({center: [5, 5, 5], radius: 10, resolution: resolution });
 
  var sphere2 = sphere1.translate([12, 5, 0]);
function main () {
  var sphere3 = CSG.sphere({center: [20, 0, 0], radius: 30, resolution: resolution });
   return union(
 
    difference(
  var result = cube1;
      cube({size: 3, center: true}),
  result = result.union(sphere1);
      sphere({r: 2, center: true})
   result = result.subtract(sphere2);
    ),
  result = result.intersect(sphere3);
    intersection(
  return result;
      sphere({r: 1.3, center: true}),
      cube({size: 2.1, center: true})
    )
   ).translate([0, 0, 1.5]).scale(10);
}
}
}}
</pre>
== Example ==
{{jscad|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);
}
}}
}}



Revision as of 13:24, 10 June 2019

Usage

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



  
  
  
  


OpenJSCAD example

Source code

Below is the OpenJsCad script.