import anywidget
from traitlets import Any
from pathlib import Path
import numpy as np
size = 17
def f(i,j,k):
return (1+np.cos(i*j*0.1))*0.5
voxelarray = np.fromfunction(f, (size, size, size))
# voxelarray = np.random.rand(size, size, size)
voxelarray_int = np.uint8(voxelarray * 255)
class HelloWidget(anywidget.AnyWidget):
_esm = Path("widget.js")
voxel_data = Any().tag(sync=True)
voxel_data_list = voxelarray_int.tolist()
three_viewer = HelloWidget()
three_viewer.voxel_data = voxel_data_list
page = three_viewer