ShapeJS Developer Tutorials

Overview

ShapeJS provides a powerful system for generating 3D printable objects via a simple Javascript program. ShapeJS works on a voxel representation. A voxel is similar to a 2D pixel but it represents a volume element in 3 dimensional space. A script provides mechanisms to easily set the desired voxels using a series of data sources and transformations.

The voxel based representation gives ShapeJS greater flexibility in shape generation over traditional representation via triangle meshes. It is similar to advantages 2D raster graphics has over 2D vector graphics. Vector graphics is great for drawing diagrams, while raster graphics is the tool of choice for anything else.

The way to fill the voxel grid is to create an object with DataSource interface, which can calculate signed distance function for each point in space. This object is fed to an instance of GridMaker which controls the calculations. The distance function calculations may be very complex task for complex object. But this calculation can be simplified by composing complex object from many simpler one using several simple operations.

There are several predefined simple object like Sphere, Box, Cylinder, and Cone. More complex methods include functionality to convert 2D image to a 3D embossed object.

The real power of ShapeJS is in the flexibility of combining and transforming objects represented as distance function. There are usual boolean operations on objects which include Union, Intersection, and Subtraction.

There is a flexible set of transformations which can be applied to any DataSource object. Transformations include standard 3D linear transformations like Rotation, Translation, and Scale. The flexibility of ShapeJS allows usage of arbitrary non linear transformation, including RingWrap and PeriodicWrap. Several simple transformations can be composed into more complex transformation using CompositeTransform. A transformation can be applied to any DataSource object.