voxels_group#
- k3d.factory.voxels_group(space_size: List | ndarray | Tuple, voxels_group: List[Dict[str, Any]] = None, chunks_ids: List[int] = None, color_map: List[List[float]] | Dict[str, Any] | ndarray | None = None, wireframe: bool = False, outlines: bool = True, outlines_color: int = 0, opacity: float = 1.0, roughness: float = 0.4, metalness: float = 0.0, name: str | None = None, group: str | None = None, custom_data: Dict[str, Any] | None = None, compression_level: int = 0, visible: bool = True, **kwargs: Any) VoxelsGroup[source]#
Create a VoxelsGroup drawable, a voxel space assembled from chunks.
- Parameters:
space_size (array_like) – Width, height and length of the voxel space, in voxels.
voxels_group (array_like, optional) – List of chunks in format {voxels ‘np.array, coord’ [x,y,z], multiple: number}. Default is None.
chunks_ids (list, optional) – Ids of the VoxelChunk objects the group is assembled from. Default is None.
color_map (list, optional) – A list of float quadruplets (attribute value, R, G, B), sorted by attribute value. The first quadruplet should have value 0.0, the last 1.0; R, G, B are RGB color components in the range 0.0 to 1.0. Default is None.
wireframe (bool, optional) – Whether mesh should display as wireframe. Default is False.
outlines (bool, optional) – Whether mesh should display with outlines. Default is True.
outlines_color (int, optional) – Packed RGB color of the resulting outlines (0xff0000 is red, 0xff is blue) Default is 0.
opacity (float, optional) – Opacity of voxels. Default is 1.0.
roughness (float, optional) – Roughness of the material. Default is 0.4.
metalness (float, optional) – Metalness of the material. Default is 0.0.
name (str, optional) – A name of the object. Default is None.
group (str, optional) – A name of a group. Default is None.
custom_data (dict, optional) – An object with custom data attached to object. Default is None.
compression_level (int, optional) – Level of compression [-1, 9]. Default is 0.
visible (bool, optional) – Whether the object is drawn. Default is True.
**kwargs – Additional keyword arguments passed to process_transform_arguments.
- Returns:
The created VoxelsGroup object.
- 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()