Template:Jscad: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
<noinclude> | <noinclude> | ||
= Usage = | = Usage = | ||
<pre> | <pre> | ||
{{jscad|title=OpenJSCAD example|code=function main() | |||
{ | |||
var resolution = 24; // increase to get smoother corners (will get slow!) | |||
var cube1 = CSG.roundedCube({center: [0,0,0], radius: [10,10,10], roundradius: 2, resolution: resolution}); | |||
var sphere1 = CSG.sphere({center: [5, 5, 5], radius: 10, resolution: resolution }); | |||
var sphere2 = sphere1.translate([12, 5, 0]); | |||
var sphere3 = CSG.sphere({center: [20, 0, 0], radius: 30, resolution: resolution }); | |||
var result = cube1; | |||
result = result.union(sphere1); | |||
result = result.subtract(sphere2); | |||
result = result.intersect(sphere3); | |||
return result; | |||
} | |||
}} | |||
</pre> | |||
= Example = | |||
{{jscad|title=OpenJSCAD example|code=function main() | {{jscad|title=OpenJSCAD example|code=function main() | ||
{ | { | ||
Revision as of 13:43, 10 June 2019
Usage
{{jscad|title=OpenJSCAD example|code=function main()
{
var resolution = 24; // increase to get smoother corners (will get slow!)
var cube1 = CSG.roundedCube({center: [0,0,0], radius: [10,10,10], roundradius: 2, resolution: resolution});
var sphere1 = CSG.sphere({center: [5, 5, 5], radius: 10, resolution: resolution });
var sphere2 = sphere1.translate([12, 5, 0]);
var sphere3 = CSG.sphere({center: [20, 0, 0], radius: 30, resolution: resolution });
var result = cube1;
result = result.union(sphere1);
result = result.subtract(sphere2);
result = result.intersect(sphere3);
return result;
}
}}
Example
OpenJSCAD example
Playground
You can try out modifications of the source code right here.
Source code
function main()
{
var resolution = 24; // increase to get smoother corners (will get slow!)
var cube1 = CSG.roundedCube({center: [0,0,0], radius: [10,10,10], roundradius: 2, resolution: resolution});
var sphere1 = CSG.sphere({center: [5, 5, 5], radius: 10, resolution: resolution });
var sphere2 = sphere1.translate([12, 5, 0]);
var sphere3 = CSG.sphere({center: [20, 0, 0], radius: 30, resolution: resolution });
var result = cube1;
result = result.union(sphere1);
result = result.subtract(sphere2);
result = result.intersect(sphere3);
return result;
}