node package manager


custom non-cube block models for voxel.js


Generate custom (non-cube) block models


For an example, run npm start or try the live demo.

Usable with voxel-mesher and voxel-shader to show the custom model in a voxel.js world:



var parseBlockModel = require('block-models');

var model = parseBlockModel(modelDefn[, getTextureUV[, x, y, z]])

Returns an object with vertices and uv properties set to arrays suitable for passing to WebGL. Parameters:

  • modelDefn: model definition (see format below)

  • getTextureUV: optional callback to lookup UV coordinates for textures in an atlas (defaults to 0.0-1.0)

  • x, y, z: optional vertex offset

Model definition

Blocks are composed of textured planes, faces from an array of one or more cubes. Slab example:

    {from: [0,0,0],
    to: [16,8,16],
    faceData: {
        down: {},
        up: {},
        north: {},
        south: {},
        west: {},
        east: {}},
  • from, to: coordinates defining the cube
  • faceData: object with properties for each face to show (down, up, north, south, west, east)
  • face names can be omitted to not display the corresponding plane
  • texture: texture name for getTextureUV UV coordinate mapping

Note: this format is similar to Minecraft 1.8's block model system, but not completely compatible or as powerful.

You can experiment changing the model definition and viewing the results in realtime using the demo.