In [ ]:
import yt
import numpy as np
from yt.testing import fake_vr_orientation_test_ds

ds = fake_vr_orientation_test_ds()

# now we do volume rendering
sc = yt.create_scene(ds, field='density')
# Change transfer function
tf = yt.ColorTransferFunction((np.log10(0.1), np.log10(1.)))
tf.sample_colormap(np.log10(0.9), 0.01, colormap="spectral")
tf.sample_colormap(np.log10(0.8), 0.01, colormap="spectral")
tf.sample_colormap(np.log10(0.6), 0.01, colormap="spectral")
tf.sample_colormap(np.log10(0.2), 0.01, colormap="spectral")
render_source = sc.get_source(0)
render_source.transfer_function = tf

In [ ]:
# perspective camera
cam = sc.add_camera(ds, lens_type='perspective')
cam.resolution = (500, 500)
cam.width = ds.arr([2, 2, 1], 'code_length')
cam.position = ds.arr([2.5, 0, 0], 'code_length')
cam.switch_orientation(normal_vector=[-1, 0, 0],
                       north_vector=[0, 0, 1])
sc.render()
sc.show(sigma_clip=6.0)

In [ ]:
# move cam by one step
cam.position = ds.arr([4, 0, 0], 'code_length')
sc.render()
sc.show(sigma_clip=6.0)

In [ ]:
# move cam by several steps
final_position = ds.arr([2.5, 0, 0], 'code_length')
for i in cam.iter_move(final_position, 5):
    sc.save('move_%04d' % i, sigma_clip=6.0)

In [ ]:
# rotate cam by one step
rot_center = ds.arr([0, 0, 0], 'code_length')
angle = np.pi / 4.
cam.rotate(angle, rot_vector=[0, 0, 1], rot_center=rot_center)
sc.render()
sc.show(sigma_clip=6.0)

In [ ]:
# rotate cam by several steps
final_angle = -np.pi / 2.
for i in cam.iter_rotate(final_angle, 5, rot_vector=[-1, 1, 0], rot_center=rot_center):
    sc.save('rotation_%04d' % i, sigma_clip=6.0)