from k3d import K3D
from ipywidgets import interact, IntSlider
width = height = length = 3
color_map = (0xFF0000, 0x00FF00)
voxels = (1,) * width * height * length
obj = K3D.voxels(voxels, color_map, width=width, height=height, length=length)
plot = K3D(voxel_paint_color=2)
plot += obj
@interact(color=IntSlider(value=plot.voxel_paint_color, min=0, max=len(color_map)))
def color(color):
plot.voxel_paint_color = color
plot.display()
obj.voxels.flatten() # initial data
Edit object (add/remove some voxels)
obj.fetch_data() # this is an async operation
obj.voxels.flatten() # updated data