binvox

1.1.0 • Public • Published

BINVOX

Parser and builder for BINVOX voxel file format.

npm version Build Coverage Status Language grade: JavaScript

Specification of vox file format can be found here.

Documentation - Wiki

Table of Contents

Install

$ npm install --save binvox

Usage

Syntax

// Import via ES6 modules
import {Builder, Parser} from 'binvox';
// or UMD
const BINVOX = require('binvox');

Example

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".

API

BINVOX.Parser

BINVOX.Builder

License

Copyright © 2020 André Storhaug

BINVOX is licensed under the MIT License.

Package Sidebar

Install

npm i binvox

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

48.3 kB

Total Files

10

Last publish

Collaborators

  • andstor