voxels_group#
- k3d.factory.voxels_group(space_size, voxels_group=[], chunks_ids=[], color_map=None, wireframe=False, outlines=True, outlines_color=0, opacity=1.0, name=None, group=None, custom_data=None, compression_level=0, **kwargs)[source]#
Create a VoxelsGroup drawable for 3D volumetric data.
By default, the voxels are a grid inscribed in the -0.5 < x, y, z < 0.5 cube regardless of the passed voxel array shape, like aspect ratio.
Different grid size, shape and rotation can be obtained using kwargs
voxels_group(..., bounds=[0, 300, 0, 400, 0, 500])
voxels_group(..., scaling=[scale_x, scale_y, scale_z])
- Parameters
space_size (array_like) – Width, Height, Length of space. Must be non-negative.
voxels_group (list, optional) – List of voxel_chunk in format {voxels: np.array, coord: [x,y,z], multiple: number}, by default [].
chunks_ids (list, optional) – List of voxels_chunk id, by default [].
color_map (int, optional) – List of Hex color, by default None. The color defined at index i is for voxel value (i+1).
wireframe (bool, optional) – Display voxels as wireframe, by default False.
outlines (bool, optional) – Display voxels outlines, by default True.
outlines_color (int, optional) – Hex color of voxels outlines, by default 0.
opacity (float, optional) – Opacity of voxels, by default 1.0.
name (str, optional) – Object name, by default None.
group (str, optional) – Name of a group, by default None.
custom_data (dict) – A object with custom data attached to object.
compression_level (int, optional) – Level of data compression [-1, 9], by default 0.
**kwargs – For other keyword-only arguments, see process_transform_arguments.
- Returns
VoxelsGroup Drawable.
- Return type
VoxelsGroup
See also
Examples#
import k3d
import numpy as np
voxels = np.array([[[0, 1],
[1, 2]],
[[2, 2],
[1, 1]]])
chunk1 = k3d.voxel_chunk(voxels, [0, 0, 0])
chunk2 = k3d.voxel_chunk(voxels, [3, 3, 3])
group = [{'voxels': chunk1['voxels'],
'coord': chunk1['coord'],
'multiple': chunk1['multiple']},
{'voxels': chunk2['voxels'],
'coord': chunk2['coord'],
'multiple': chunk2['multiple']}]
ids = [chunk1['id'], chunk2['id']]
plt_voxels_group = k3d.voxels_group(space_size=[10, 10, 10],
voxels_group=group,
chunks_ids=ids)
plot = k3d.plot()
plot += plt_voxels_group
plot.display()