johnwebbcole / jscad-utils

A collection of utilities for use in jscad
https://gitlab.com/johnwebbcole/jscad-utils
ISC License
30 stars 3 forks source link

v2 example #7

Open iammikecohen opened 3 years ago

iammikecohen commented 3 years ago

I've started working with JSCAD v2 and not too far into setting up a some modules I really need .snap Do you have a snippet showing how to setup the new @jwc/jscad-utils?

I naively tried to instantiate in the old way and get an error:

const { cube } = require('@jscad/csg/api').primitives3d
const CSG = require('@jscad/csg/api').csg
const { init } = require('@jwc/jscad-utils');

const main = params => {
    init(CSG)
    return cube();
}

module.exports = { main };

"SyntaxError: Unexpected token *"

johnwebbcole commented 3 years ago

The unit tests work against the @jscad/csg objects, however, I don't have things working when running inside the jscad.xyz site. Sounds like a fun project for this weekend.

In the meantime, you might look at copying the snap and calcSnap functions and applying them in your project.