Socket
Book a DemoInstallSign in
Socket

hiccup-sdf-to-obj

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hiccup-sdf-to-obj

export hiccup-sdf models to OBJ

latest
npmnpm
Version
0.0.10
Version published
Weekly downloads
5
150%
Maintainers
1
Weekly downloads
 
Created
Source

hiccup-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 tree
  • options.size - resolution for meshing, 128 is the default, for GPU meshing 256 usually gives nicer results, for single CPU 64 is recommended for speed (but ugly exports)
  • options.threads - number of threads to spawn, works only with threaded exports, defaults to 4
  • callback(obj) - callback called with obj string if succeeded, otherwise null

Acknowledgements

This project was developed in part at Laboratory, an artist residency for interactive arts: https://laboratoryspokane.com.

FAQs

Package last updated on 04 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts