Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

block-models

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

block-models

custom non-cube block models for voxel.js

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

block-models

Generate custom (non-cube) block models

screenshot

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:

screenshot

Usage

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.

License

MIT

Keywords

FAQs

Package last updated on 30 Dec 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc