Parser and builder for BINVOX voxel file format.
Specification of vox file format can be found here.
$ npm install --save binvox
// Import via ES6 modules
import {Builder, Parser} from 'binvox';
// or UMD
const BINVOX = require('binvox');
This Node.js example reads a BONVOX file and parses it:
const fs = require('fs');
const BINVOX = require('binvox');
fs.readFile('path/to/file.binvox', (err, data) => {
if (err) throw new Error(err);
const parser = new BINVOX.Parser();
const result = parser.parse(data.buffer);
console.log(result);
})
where data.buffer
is an instance of ArrayBuffer.
It is recommended to read the official BINVOX specification, in order to understand the structure of the data.
The output consists of various file information, in addition to the actual voxel data:
{
dimension: { depth: 32, width: 32, height: 32 },
translate: { depth: 11.81, width: 21.39, height: -1.69 },
scale: 30.206,
voxels: [...]
}
voxels
contain the actual voxel data (points), and looks like this:
[
{ x: 0, y: 2, z: 3 },
{ x: 0, y: 3, z: 3 },
{ x: 0, y: 4, z: 3 },
...,
]
where the index of each voxel is ordered by the voxel's "location in space".
Copyright © 2023 James Edwards
BINVOX is licensed under the MIT License.