Controlling the Camera

Vapor provides several functions to control the camera position and direction. Here are a few examples.

import example_utils
from vapor import session, renderer, dataset, camera

ses = session.Session()
data = example_utils.OpenExampleDataset(ses)

ren = data.NewRenderer(renderer.VolumeIsoRenderer)
ren.SetIsoValues([-0.10, 0.2])

# Show 3D orientation arrows.
ses.GetSceneAnnotations().SetAxisArrowEnabled(True)
Vapor 3.10.0
Python 3.9.19 (/opt/anaconda3/envs/vapor)
OpenGL 4.1 Metal - 89.3
cam = ses.GetCamera()

View All

help(cam.ViewAll)
cam.ViewAll()
ses.Show()
Help on method ViewAll in module vapor.camera:

ViewAll() method of vapor.camera.Camera instance
    Places the camera above the dataset looking down so that it is visible in its entirety.
    This is the default view when opening a new dataset.
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 2 GLD_TEXTURE_INDEX_3D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
../_images/4fcbaa4949b162fb29b067d88e013b5da77480a480eb68dcd3d07bfcbbfedcce.png

Align View

help(cam.AlignView)
cam.AlignView("-X")
ses.Show()
Help on method AlignView in module vapor.camera:

AlignView(axis: str) method of vapor.camera.Camera instance
    Align camera looking down an axis
    Axis format: [+-][XYZ]
../_images/8d0b231c7042b590dc2d21dfb0d34c49fb45a774a212dedf6a3620a6edf3c7fb.png

Zoom

help(cam.Zoom)
cam.Zoom(-0.4)
ses.Show()
Help on method Zoom in module vapor.camera:

Zoom(fractionOfDistanceToTarget: float) method of vapor.camera.Camera instance
    Moves the camera a fractionOfDistanceToTarget with positive zooming in and negative zooming out.
../_images/8e41032b9a309fd63ff079f8c5b1c3bdbd27a53638b6ebad99f96ee867ddc434.png

Look At

help(cam.LookAt)
cam.LookAt((32, -100, 100), ren.GetTransform().GetOrigin())
ses.Show()
Help on method LookAt in module vapor.camera:

LookAt(camera_position: tuple[float, float, float], target: tuple[float, float, float], up: tuple[float, float, float] = (0, 0, 1)) method of vapor.camera.Camera instance
    Moves the camera to camera_position facing target. up can be used to adjust the camera roll.
../_images/839592179d0ac5af3fa58a8a8a25191956db1c50902fa722a31eee34d92329e4.png