Last active
January 7, 2017 00:18
-
-
Save kaosat-dev/2040b655bbf50ccf3842f4e7adccab94 to your computer and use it in GitHub Desktop.
jscad-node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var jscad = require('openjscad') | |
| var path = require('path') | |
| var fs = require('fs') | |
| const {generateOutput} = jscad | |
| const inputPath = path.resolve(__dirname, './logo.jscad') | |
| const script = fs.readFileSync(inputPath, 'UTF8') | |
| jscad.compile(script, {}) | |
| .then(function (input) { | |
| const output = generateOutput('stl', input) | |
| const {type, encoding, size} = output | |
| fs.writeFileSync('foo.stl',output.asBuffer()) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function main() { | |
| return union( | |
| difference( | |
| cube({size: 5, center: true}), | |
| sphere({r:4, center: true}) | |
| ), | |
| intersection( | |
| sphere({r: 2.3, center: true}), | |
| cube({size: 3.1, center: true}) | |
| ) | |
| ).translate([0,0,1.5]).scale(5); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment