three.js plugin for loading voxel data
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
This library requires the peer dependency three.js.
$ npm install --save three
$ npm install --save three-voxel-loader
new VoxelLoader()
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' );
}
);
Importing of several file types and data structures with voxel data are supported.
- 3D array
- Sparse octree
Copyright © 2020 André Storhaug
three-voxel-loader is licensed under the MIT License.