openscad-js
OpenSCAD, but in a real language :)
Usage
const { compile, modules: m } = require('@smrq/openscad-js');
const model = m.translate([10, 20, 30])(
m.cube([1, 2, 3], { center: true })
);
console.log(compile(model));
What features in OpenSCAD does this support?
Literally anything that follows the OpenSCAD module syntax. Nothing is built into this library, it just rewrites things into the OpenSCAD syntax.
m.foo(1, 2, { bar: 3, baz: 4 })(
m.quux([5, 6, 7])
)
=>
foo(1, 2, bar=3, baz=4) {
quux([5, 6, 7]);
}
m.
I don't want to prefix everything with That's too bad for you.
Isn't there another way?
Okay, but don't say I didn't warn you.
const { compile, globals } = require('@smrq/openscad');
with (globals(x => eval(x))) {
const model = translate([10, 20, 30])(
cube([1, 2, 3], { center: true })
);
console.log(compile(model));
}