Skip to content
/ vox.js Public
forked from minimo/vox.js

MagicaVoxel *.vox file parser and Three.js mesh builder.

License

Notifications You must be signed in to change notification settings

henteko/vox.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MagicaVoxel model data parser and mesh builder.

Join the chat at https://gitter.im/daishihmr/vox.js

Example

show mesh

update texture

with Physijs

with cannon.js

Usage

parse .vox file

html

<script src="vox.js"></script>

javascript

var parser = new vox.Parser();
parser.parse("./p10.vox").then(function(voxelData) {
    
    voxelData.voxels; // voxel position and color data
    voxelData.size; // model size
    voxelData.palette; // palette data

});

.parse(url) method returns Promise object.

build THREE.Mesh object

html

<script src="three.js"></script>
<script src="vox.js"></script>

javascript

var scene = new THREE.Scene();

var param = { voxelSize: 5 };
var builder = new vox.MeshBuilder(voxelData, param);
var mesh = builder.createMesh();
scene.add(mesh);

.createMesh(voxelData, param) method returns THREE.Mesh object.

create Image from palette

html

<script src="vox.js"></script>
<img id="img">

javascript

var textureFactory = new vox.TextureFactory();
var canvas = textureFactory.createCanvas(voxelData);
document.getElementById("img").src = canvas.toDataURL();

.createCanvas(voxelData) method returns HTMLCanvasElement.

API Reference

http://daishihmr.github.io/vox.js/docs/

TODO

  • saving function

About

MagicaVoxel *.vox file parser and Three.js mesh builder.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 95.2%
  • HTML 4.8%