Reference navigation
On this page
CLASS · v0.9.1
Camera
A perspective camera with orbit, zoom, framing, depth cueing, and EEVEE lens focus.
from proteinmotion.camera import CameraConstructor
Camera()Notes
Each scene creates its own camera at scene.camera. Use frame() for initial setup and Focus or scene.focus() for animated camera movement.
Attributes
| Name | Description |
|---|---|
target | Look-at point in world coordinates. |
distance | Distance from the camera to its target, initially 70 Å. |
theta, phi | Horizontal and vertical angles in radians. |
fov | Vertical field of view in radians; initially 38 degrees. |
depth_cue | Distance fog strength; 0 disables it. |
radius | Framing radius used to choose clipping planes. |
dof | Whether EEVEE depth of field is enabled; initially False. |
fstop | Lens f-number, initially 5.6. Lower values produce more blur. |
Example and output
This excerpt runs inside a scene’s construct() method. The full example file includes imports, structure loading, and camera setup. Run it from a repository checkout.
p = ubiquitin()
frame(self, p)
helix = p.select(chain="A", residues=(23, 34))
marker = helix.highlight(
style="box",
color="#f2ba67",
padding=1.5,
)
self.play(FadeIn(marker), run_time=0.6)
self.focus(helix, margin=1.6, run_time=1.5)
self.play(self.camera.animate.orbit(0.4), run_time=2)
self.play(FadeOut(marker), run_time=0.6)
self.focus(p, run_time=1.5)Ubiquitin residues 23–34.
Methods and properties
| Name | Description |
|---|---|
| set_focus()method | Set lens focus without moving or zooming the camera. |
| focus_pointproperty | Current lens target in world ångströms, following the selected atoms. |
| frame()method | Frame the supplied proteins or regions immediately and stop previous tracking. |
| focus()method | Frame a protein or region immediately and optionally track its center. |
| update_tracking()method | Update the camera target from the tracked region while keeping zoom fixed. |
| orbit()method | Change horizontal and vertical camera angles. |
| zoom()method | Divide camera distance by factor. Values greater than 1 zoom in. |
| eyeproperty | Current camera position in world coordinates. |
| matrix()method | Compute the view-projection matrix for the given image aspect ratio. |
| animateproperty | Create a builder for orbit, zoom, and focus animations. |
| snapshot()method | Capture the current state for deterministic timeline evaluation. |
| restore()method | Restore a state produced by snapshot(). |
Camera.set_focus(
target,
*,
chain=None,
residues=None,
atoms=None,
fstop=5.6,
follow=True,
)Set lens focus without moving or zooming the camera.
| Parameter | Default | Description |
|---|---|---|
target | Required | Protein, Region, world point, or None to disable DOF. |
chainkeyword only | None | Author chain ID or a collection of IDs; None selects all chains. |
residueskeyword only | None | Author residue number, inclusive (first, last) tuple, or list of individual numbers. |
atomskeyword only | None | Atom name or list of names, such as "CA"; None selects all atom names. |
fstopkeyword only | 5.6 | Lens f-number. Lower values produce a shallower depth of field. Must be positive. |
followkeyword only | True | Track the mean selected position through motion; False fixes the initial world point. |
Returns: The camera.
Selectors apply to a Protein target. Ranges use inclusive PDB author numbers. atoms="CA" focuses on the Cα centroid. A region defines one focus plane, rather than making all selected atoms equally sharp.
Camera.focus_pointCurrent lens target in world ångströms, following the selected atoms.
Camera.frame(*proteins, margin=1.25, aspect=16 / 9)Frame the supplied proteins or regions immediately and stop previous tracking.
| Parameter | Default | Description |
|---|---|---|
*proteins | — | Protein or annotation objects to add or render. |
marginkeyword only | 1.25 | Positive framing margin; larger values leave more space around the target. |
aspectkeyword only | 16 / 9 | Image width divided by height. |
Returns: The camera.
Camera.focus(target, *, margin=1.25, aspect=16 / 9, follow=True)Frame a protein or region immediately and optionally track its center.
| Parameter | Default | Description |
|---|---|---|
target | Required | Object to animate or use as a destination. The supported object type depends on the operation. |
marginkeyword only | 1.25 | Positive framing margin; larger values leave more space around the target. |
aspectkeyword only | 16 / 9 | Image width divided by height. |
followkeyword only | True | Track the selection’s center after the focus completes. |
Returns: The camera.
Camera.update_tracking()Update the camera target from the tracked region while keeping zoom fixed.
Returns: None
Camera.orbit(theta=0.0, phi=0.0)Change horizontal and vertical camera angles.
| Parameter | Default | Description |
|---|---|---|
theta | 0.0 | Change in horizontal camera angle, in radians. |
phi | 0.0 | Change in vertical camera angle, in radians. |
Returns: The camera or animation builder.
Camera.zoom(factor)Divide camera distance by factor. Values greater than 1 zoom in.
| Parameter | Default | Description |
|---|---|---|
factor | Required | Positive scale or zoom factor. |
Returns: The camera or animation builder.
Camera.eyeCurrent camera position in world coordinates.
Camera.matrix(aspect)Compute the view-projection matrix for the given image aspect ratio.
| Parameter | Default | Description |
|---|---|---|
aspect | Required | Image width divided by height. |
Returns: 4 × 4 array.
Camera.animateCreate a builder for orbit, zoom, and focus animations.
Returns: Animate
Camera.snapshot()Capture the current state for deterministic timeline evaluation.
Returns: State dictionary.
Camera.restore(state)Restore a state produced by snapshot().
| Parameter | Default | Description |
|---|---|---|
state | Required | State returned by snapshot(). |
Returns: None