1.0.5 • Published 3 years ago

@smrq/openscad-js v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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

}
1.0.5

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago