voxolith

entityFromVox()

Parse a .vox buffer into an entity, cropped to its occupied box. Each distinct palette colour becomes a role (color.0, color.1, ... in first-seen order, colours from the file's palette), so the entity can be restyled like a generated one. Only the first model in the file is read; colours past...

function entityFromVox(buffer: ArrayBuffer, opts?: FromVoxOptions): Entity;

Defined in: engine/src/vox.ts:49

Parse a .vox buffer into an entity, cropped to its occupied box. Each distinct palette colour becomes a role (color.0, color.1, ... in first-seen order, colours from the file's palette), so the entity can be restyled like a generated one. Only the first model in the file is read; colours past 255 roles are dropped.

Parameters

ParameterType
bufferArrayBuffer
opts?FromVoxOptions

Returns

Entity

Example

const res = await fetch(`${import.meta.env.BASE_URL}models/chair.vox`);
const chair = entityFromVox(await res.arrayBuffer(), { id: "chair", kind: "furniture" });
const { base } = palette.allocateFor(chair);

On this page