@smrq/openscad-js

1.0.5 • Public • Published

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]);
}

I don't want to prefix everything with m.

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));

}

Readme

Keywords

none

Package Sidebar

Install

npm i @smrq/openscad-js

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

3.98 kB

Total Files

3

Last publish

Collaborators

  • smrq