npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@voxel-tool/exporter

v0.4.2

Published

Voxel model exporter — convert .vox / voxel data to GLTF, GLB, OBJ, STL, PLY, USDZ and FBX (built on Three.js exporters)

Readme

@voxel-tool/exporter

Standalone voxel-model exporter for Node and the browser. Convert MagicaVoxel .vox (or raw voxel data + palette) into general-purpose 3D formats, built on the official Three.js exporters.

This package is part of the voxel-tool monorepo and is published alongside @voxel-tool/core, @voxel-tool/viewer, and the framework bindings.

Supported formats

| Format | Extension | Color / material fidelity | |---|---|---| | GLB | .glb | Vertex colors + PBR (best fidelity) | | glTF | .gltf | Vertex colors + PBR (JSON) | | OBJ | .obj | Geometry only — Three's OBJExporter does not emit vertex colors for meshes (only for Points), so OBJ carries no color | | STL | .stl | No color (ideal for 3D printing); ascii or binary | | PLY | .ply | Vertex colors; ascii or binary | | USDZ | .usdz | Vertex colors + PBR (single-sided materials) | | FBX | .fbx | Vertex colors via @comfyorg/fbx-exporter-three; PBR is approximated (Lambert/Phong) |

GLTF/GLB/OBJ/STL/PLY/USDZ are produced by Three.js built-in exporters; only FBX requires the third-party library (bundled as a dependency, not optional).

Why a standalone package?

Voxel geometry is built with face-culling (only air-exposed faces) and merged into a single buffer with vertex colors corrected from sRGB to linear (so exports match what you see on screen). The export object is a y-up THREE.Group (the voxel-local z-up space is flipped to match Blender/Unity).

Install

npm install @voxel-tool/exporter three

three is a peer/regular dependency and must be installed by the consumer (the package externalizes it so it is not duplicated).

Usage

From a parsed .vox (Node)

import { readFileSync, writeFileSync } from 'node:fs';
import { parseVox } from '@voxel-tool/core';
import { VoxelExporter } from '@voxel-tool/exporter';

const vox = parseVox(readFileSync('model.vox'));
const exporter = new VoxelExporter(vox);

writeFileSync('model.glb', Buffer.from(await exporter.export('glb'))); // ArrayBuffer
writeFileSync('model.fbx', await exporter.export('fbx'));              // Uint8Array

Pure data (no @voxel-tool/core needed)

import { VoxelExporter, buildExportObject, exportModel } from '@voxel-tool/exporter';

const input = {
  instances: [
    { voxels: [{ x: 0, y: 0, z: 0, i: 1 }, { x: 1, y: 0, z: 0, i: 2 }] },
  ],
  palette,   // 256 × [r,g,b,a], or omit to use the default palette
  materials, // optional: { 1: { metalness: 0.8, roughness: 0.2 }, ... }
};

const exporter = new VoxelExporter(input);
const objText = await exporter.export('obj');     // string
const stl = await exporter.export('stl');         // DataView (binary)
const ply = await exporter.export('ply', { binary: false }); // string (ascii)

In the browser (download)

const exporter = new VoxelExporter(vox);
await exporter.download('glb'); // saves model.glb
await exporter.download('obj', { filename: 'my-model.obj' });

API

  • class VoxelExporter(input) — build(), export(format, options?), toBlob(format, options?), download(format, options?)
  • buildExportObject(input) → THREE.Group (the y-up export object; reuse it for your own rendering too)
  • exportModel(object3d, format, options?) → Promise<string | ArrayBuffer | Uint8Array | DataView>
  • toBlob(data, mime?), toUint8Array(data), downloadModel(data, filename, mime?)
  • Constants: FORMATS, DEFAULT_FILENAMES, MIME_TYPES

input accepts three shapes: a parseVox result ({ models, scene, palette?, materials? }), a single model ({ model, palette?, materials? }), or explicit instances ({ instances, palette?, materials? }).

Notes / limitations

  • OBJ has no vertex colors (Three's mesh path omits them) — use GLB/PLY/USDZ/FBX when color matters.
  • STL has no color by design (for printing).
  • FBX is a third-party binary format; PBR materials are approximated. Prefer GLB for maximum fidelity.
  • Color is exported in linear space and converted to sRGB by the target importer; the source palette is treated as sRGB.

License

MIT