Skip to content

@divnotes/dn-voxel-loader - v0.1.10 / dn-voxel-loader

Module: dn-voxel-loader

Fileoverview

Main entry point for DN Voxel Loader.

Author

DivNotes

Table of contents

Interfaces

Functions

Functions

load

load(source): Promise<VoxelData>

Loads and parses a .vox file from a URL or ArrayBuffer.

Parameters

NameTypeDescription
sourcestring | ArrayBuffer | BufferThe URL of the .vox file or an ArrayBuffer/Buffer containing the file data.

Returns

Promise<VoxelData>

A promise that resolves with the parsed voxel data.

Throws

If the source is invalid, fetch fails, or parsing fails.

Example

ts
// Load from URL
try {
  const voxelData = await load('path/to/your/model.vox');
  console.log('Voxels loaded:', voxelData);
  // Use voxelData (e.g., render it)
} catch (error) {
  console.error('Loading failed:', error);
}

Example

ts
// Load from ArrayBuffer (e.g., from a file input)
async function handleFile(file) {
  const arrayBuffer = await file.arrayBuffer();
  try {
    const voxelData = await load(arrayBuffer);
    console.log('Voxels loaded:', voxelData);
  } catch (error) {
    console.error('Loading failed:', error);
  }
}

Defined in

index.js:47

Released under the MPL-2.0 License.