Skip to main content

Crate voxsmith

Crate voxsmith 

Source
Expand description

Utilities for working with voxels.

voxcore’s VoxState is the in-memory representation of a voxj document. This crate converts between the two, both at the value level (vox_state_from_voxj_codec_main / voxj_codec_main_from_vox_state) and straight to and from .voxj / .voxjz bytes (vox_state_from_voxj_bytes, vox_state_to_voxj_bytes, vox_state_to_voxjz_bytes).

Functions§

vox_state_from_voxj_bytes
Loads a .voxj or .voxjz document into a VoxState. The container form is detected from the leading bytes, the encoded geometry is decoded, and the result is loaded into voxcore’s in-memory form.
vox_state_from_voxj_codec_main
Loads a VoxjCodecMain into a VoxState. Entities take ids in listing order, so each id equals its voxj array index and cross-references carry over.
vox_state_to_voxj_bytes
Writes a VoxState to compact .voxj JSON bytes, choosing the smallest block encodings per object. The document is stamped with the current voxj format version.
vox_state_to_voxjz_bytes
Writes a VoxState to a .voxjz zip archive holding one compact .voxj member, choosing the smallest block encodings per object. The document is stamped with the current voxj format version.
voxj_codec_main_from_vox_state
Writes a VoxState back into a VoxjCodecMain (decoded voxj geometry). Objects, palettes, and hierarchy nodes are emitted in id order, so each lands at its original array index and the cross references carry over unchanged. Each object emits one voxel per live cell, in ascending raster order.