Skip to content

andstor/three-voxel-loader

Repository files navigation

three-voxel-loader

three.js plugin for loading voxel data

npm version Build Coverage Status Language grade: JavaScript

This is a plugin for three.js. It provides support for loading voxel data and turning it into a three.js Mesh.

Examples - Documentation - Wiki

Table of Contents

🖼 Preview

Preview

Installation

This library requires the peer dependency three.js.

$ npm install --save three
$ npm install --save three-voxel-loader

Usage

Syntax

new VoxelLoader()

Example

const VoxelLoader = require('three-voxel-loader');

// Instantiate the loader
let loader = new VoxelLoader();

// Load a resource from provided URL.
loader.load(
  // Resource URL.
  'models/chicken.vox',

  // Called when resource is loaded.
  function ( voxels ) {
    scene.add( voxels );
  },

  // Called when loading is in progresses.
  function ( xhr ) {
    console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  },

  // Called when loading has errors.
  function ( error ) {
    console.log( 'An error happened' );
  }
);

Import support

Importing of several file types and data structures with voxel data are supported.

File formats

Data structures

License

Copyright © 2020 André Storhaug

three-voxel-loader is licensed under the MIT License.