hiccup-sdf-to-obj
v0.0.9hiccup-sdf-to-obj
Tools for exporting hiccup-sdf
models to OBJs. Supports single CPU, threaded CPU and GPU mashing. Designed for offline export in node.js.
Installation
npm install hiccup-sdf-to-obj --save
Usage
CPU meshing
const fs = require("fs")
const sdfToObj = require("hiccup-sdf-to-obj")
const tree = ["sphere"];
sdfToObj(tree, obj => {
fs.writeFileSync(path.join(__dirname, "sphere.obj"), obj);
});
$ node export-obj.js
Threaded CPU meshing
Uses worker threads:
const fs = require("fs")
const sdfToObj = require("hiccup-sdf-to-obj/threaded")
const tree = ["sphere"];
sdfToObj(tree, obj => {
fs.writeFileSync(path.join(__dirname, "sphere.obj"), obj);
});
$ node --experimental-worker export-obj.js
Warning: currently map
from hiccup-sdf
is not supported in threaded export!
GPU meshing
Uses offscreen Electron to render on GPU and mesh to OBJ.
const fs = require("fs")
const sdfToObj = require("hiccup-sdf-to-obj/gpu")
const tree = ["sphere"];
sdfToObj(tree, obj => {
fs.writeFileSync(path.join(__dirname, "sphere.obj"), obj);
});
$ node export-obj.js
API
All options are optional.
sdfToObj(tree, [options], callback)
tree
-hiccup-sdf
model treeoptions.size
- resolution for meshing,128
is the default, for GPU meshing256
usually gives nicer results, for single CPU64
is recommended for speed (but ugly exports)options.threads
- number of threads to spawn, works only withthreaded
exports, defaults to4
callback(obj)
- callback called with obj string if succeeded, otherwisenull
Acknowledgements
This project was developed in part at Laboratory, an artist residency for interactive arts: https://laboratoryspokane.com.
npm i [email protected]
Metadata
- MIT
- Whatever
- Szymon Kaliski
- released 6/4/2019