MagicaVoxel model data parser and mesh builder.
<script src="vox.js"></script>
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.
<script src="three.js"></script>
<script src="vox.js"></script>
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.
<script src="vox.js"></script>
<img id="img">
var textureFactory = new vox.TextureFactory();
var canvas = textureFactory.createCanvas(voxelData);
document.getElementById("img").src = canvas.toDataURL();
.createCanvas(voxelData)
method returns HTMLCanvasElement.
http://daishihmr.github.io/vox.js/docs/
- saving function