Jupyter notebooks¤
A draw-once pythreejs widget for Jupyter notebooks and Colab, built on compas_notebook.
Note
This viewer needs optional dependencies included in the viz
extra. Without them, the viewer degrades to a null object that warns on use.
Notebook Viewer¤
NotebookViewer
¤
NotebookViewer(width: int | None = None, height: int | None = None, show_grid: bool | None = None, viewport: Literal['top', 'perspective'] | None = None, camera_position: list[float] | None = None, camera_target: list[float] | None = None, config: Config | None = None, **kwargs: Any)
A thin wrapper on compas_notebook.viewer.Viewer.
It subclasses the COMPAS notebook viewer so that the scene, the toolbar and
show all work natively. The force density datastructures render through
their registered scene objects, so add only provides a couple of kwarg
conveniences.
For convenience it also accepts the width, height, show_grid,
viewport, camera_position and camera_target keyword arguments
directly and folds them into a compas_notebook.config.Config, so
the common setup does not require building a config by hand.
add
¤
add(data: Geometry | Datastructure, **kwargs: Any) -> SceneObject
Add a data object to the viewer.
This is a convenience shortcut for viewer.scene.add. The force
density datastructures dispatch through the scene registry to their
scene objects (ThreeFDNetworkObject, ThreeFDMeshObject).
Dispatch is purely by type. To draw a force density datastructure as plain
geometry instead, convert it to its COMPAS base first and add that, e.g.
viewer.add(mesh.copy(cls=Mesh)) or
viewer.add(network.copy(cls=Network)).
Parameters:
-
data(Geometry | Datastructure) –The geometry or datastructure to visualize.
-
kwargs(Any, default:{}) –Additional visualization options passed to the scene object.
Returns:
-
scene_object(SceneObject) –The created scene object.