GithubHelp home page GithubHelp logo

imclab / ndarray-stl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from max-mapper/ndarray-stl

0.0 2.0 0.0 2.18 MB

convert voxels into 3D printable .stl files

Home Page: http://maxogden.github.io/ndarray-stl/?png=http://i.imgur.com/ccBkMVY.png

ndarray-stl's Introduction

ndarray-stl

Converts an ndarray of voxels into an ascii STL file suitable for 3D printing or other 3D applications.

You can also smooth the voxel volumes using various isosurface smoothing algorithms such as marching cubes or surface nets.

STL files don't support color data, sorry.

NPM

npm install ndarray-stl

How it works

This will work with any voxel data, but I built it to work with another app I made called Voxel Builder. One of the users of DIY.org named burgzt took a 3D Mario designed by Mikola Lysenko and made a copy in the builder app:

mario

When you export your creation from Voxel Builder you get a PNG file with the voxel data magically encoded inside. That means you can upload the PNG photo of your creation into any app that knows how to extract it (such as the WebGl powered voxel-critter) and you can then fully view edit your 3D in that app.

For example, this image has encoded voxel data hidden inside:

mario-encoded

In the ndarray-stl demo I load the mario image (or any PNG url, you can specify one in the address bar), read the voxel data from the PNG and then generate an STL file from the voxels using ndarray-stl. You can also generate a smoothed voxel model. STL files can then be loaded into programs like MakerWare and 3D printed!

mario-makerware

The above shows three STL files loaded into MakerWare: unsmoothed, smoothed with surface nets and smoothed with marching cubes.

marios

Here are the 3 variations of Mario printed out by @vladikoff at the Mozilla San Francisco office. You can view more photos from his print here. Thanks, Vlad!

Mikola Lysenko, the original designer of the 3D mario, has a Shapeways store where you can order a full color mario printed in sandstone and have it shipped to you.

process

Mikola also wrote a post about the process of creating the 3D mario based on 2D sprites.

At this point in time there are over 400 creations that have been made with Voxel Builder. Any of them can be loaded into the ndarray-stl demo. Here are some good ones:

api

see demo.js for example usage

var stl = require('ndarray-stl')

require the module

stl(voxels, options)

voxels has to be a 3d ndarray. returns an ascii stl string.

options an object with these defaults:

{
  "smooth": false,
  "method": "surfaceNets",
  "faceFormat": false
}

You can set smooth to true and pick a smoothing method, available methods are surfaceNets, marchingCubes or marchingTetrahedra.

To change the face format that gets serialized into the STL you can specify a faceFormat, e.g.:

function (f) {
  var backwardsWindedFaceVertices = [f[2], f[1], f[0]]
  return backwardsWindedFaceVertices.map(function rotateVertices(v) {
    return [v[0], -v[2], v[1]]
  })
}

license

BSD

ndarray-stl's People

Contributors

max-mapper avatar vladikoff avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.