3D scenes
Place 3D objects inside a Scene3D to give them a shared camera and depth buffer. Position the resulting layer in the canvas with the same layout and animation controls as a Box.
Transform3D applies uniform scale, x/y/z rotation, then translation. Use a signal for any transform input. The camera accepts azimuth, elevation, roll, target, zoom, and focal_distance. Enable perspective for perspective projection.
Geometry
| Use | To build |
|---|---|
Cube(size), Prism([width, length, height]) | Box-shaped solids. |
Sphere, Torus, Cylinder, Cone | Round solids with a configurable radius and sampling resolution. |
Line3D(start, end), Dot3D(point) | A cylindrical segment or a spherical marker at a world point. |
Arrow3D(start, end) | A depth-tested arrow with a screen-facing head. |
Mesh3D(points, triangles) | A mesh with zero-based triangle indices. Each point is [x, y, z] in lengths. |
SurfaceGrid(points, columns) | A surface from rows of points, with a fixed number of columns. |
Path3D, Scatter3D, Wireframe | Screen-width paths, markers, and mesh edges. |
Solids and indexed meshes are shaded by default. Use smooth=true on Sphere, Torus, or Dot3D to interpolate lighting across the surface. A Mesh3D can supply one direction in normals for each vertex. The demo centers a smooth-shaded ball in the opening of a flat-shaded torus. The cube is also flat-shaded. Pass lit=false to keep the specified fill color. Use a color with alpha for translucency. WebGPU resolves opaque visibility per sample and composites translucent geometry using weighted blending.
Place plots and annotations in a scene
ThreeDAxes.frame(), ax.plot_surface(f), and ax.plot_parametric_curve(f) produce objects for the same Scene3D. Use ax.c2p([x, y, z]) to place solids at data coordinates. Plot shows a face-on view that tilts and gains depth. Flow fields shows the Lorenz attractor.
To make an upright label follow a point in the scene, use project3d(point, camera, depth=depth) for its 2D position. Place a label directly in the canvas to keep its position independent of the camera.