manifold-to-step
v0.0.4
Published
Convert [manifold-3d](https://github.com/elalish/manifold) objects to STEP files.
Readme
manifold-to-step
Convert manifold-3d objects to STEP files.
Installation
npm install manifold-to-step manifold-3dUsage
import Module from "manifold-3d"
import { manifoldToStep } from "manifold-to-step"
import fs from "fs"
const wasm = await Module()
wasm.setup()
const { Manifold } = wasm
// Primitives
const cube = Manifold.cube([10, 10, 10], true)
fs.writeFileSync("cube.step", manifoldToStep(cube))
const sphere = Manifold.sphere(5, 16)
fs.writeFileSync("sphere.step", manifoldToStep(sphere))
const cylinder = Manifold.cylinder(10, 5)
fs.writeFileSync("cylinder.step", manifoldToStep(cylinder))
const cuboid = Manifold.cube([10, 5, 3], true)
fs.writeFileSync("cuboid.step", manifoldToStep(cuboid))
// Transforms
const translated = cube.translate([5, 5, 5])
fs.writeFileSync("translated.step", manifoldToStep(translated))
// Colors
fs.writeFileSync("red-cube.step", manifoldToStep({ manifold: cube, color: [1, 0, 0] }))
// Boolean operations
const union = cube.add(sphere)
fs.writeFileSync("union.step", manifoldToStep(union))
const subtracted = cube.subtract(sphere)
fs.writeFileSync("subtract.step", manifoldToStep(subtracted))
const intersected = cube.intersect(sphere)
fs.writeFileSync("intersect.step", manifoldToStep(intersected))
// Multiple colored parts
fs.writeFileSync("multi.step", manifoldToStep([
{ manifold: cube, color: [1, 0, 0] },
{ manifold: sphere.translate([15, 0, 0]), color: [0, 0, 1] },
]))
// Clean up WASM objects
cube.delete()
sphere.delete()