Skip to content

Instantly share code, notes, and snippets.

@kaosat-dev
Last active January 7, 2017 00:18
Show Gist options
  • Save kaosat-dev/2040b655bbf50ccf3842f4e7adccab94 to your computer and use it in GitHub Desktop.
Save kaosat-dev/2040b655bbf50ccf3842f4e7adccab94 to your computer and use it in GitHub Desktop.
jscad-node.js
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())
})
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