voxel_chunk#

k3d.factory.voxel_chunk(voxels, coord, multiple=1, compression_level=0)[source]#

Create a VoxelChunk that can be used for voxels_group.

Parameters
  • voxels (array_like) – 3D array of int from 0 to 255. 0 means empty voxel; 1 and above refer to value of a colormap.

  • coord (array_like) – Coordinates of the chunk.

  • multiple (int, optional) – For future usage, by default 1.

  • compression_level (int, optional) – Level of data compression [-1, 9], by default 0.

Returns

Voxel chunk.

Return type

VoxelChunk

See also

Examples#

import k3d
import numpy as np

voxels = np.array([[[0, 1],
                    [1, 2]],
                   [[2, 2],
                    [1, 1]]])

chunk = k3d.voxel_chunk(voxels, [0, 0, 0])

"""
VoxelChunk(coord=array([0, 0, 0], dtype=uint32),
           id=139644634801104,
           multiple=1,
           voxels=array([[[0, 1],
                          [1, 2]],
                         [[2, 2],
                          [1, 1]]], dtype=uint8))
"""