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)
Warning: sysroot "/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" not found (ignoring for now).
Vapor 3.9.3
Python 3.9.19 (/opt/anaconda3/envs/vapor)
OpenGL 4.1 Metal - 83.1
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/0ce7424ff8db25a6bd43e87e11a25eaa8d067e5c6aca3cb481d37e821cabfc69.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/5da85c1cb932bb8e8293c67f73f3389cb93919822375e84de3ed2a042d87f667.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/210f07dacd2685f013b6455d9e734095fbc40d406044349699c83a17bce106fa.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/57c4bc2054142dda0fdb91d9f11ff4ff14e8f0abdccbdd8c39a40b799796b715.png