Skip to content

Commit

Permalink
add camera.set_position
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishavlin committed Dec 11, 2024
1 parent e093d4e commit 93473ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions yt_idv/cameras/trackball_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ def offset_position(self, dpos=None):

def _compute_matrices(self):
pass

def set_position(self, pos):
self.position = pos
self.view_matrix = get_lookat_matrix(self.position, self.focus, self.up)
9 changes: 9 additions & 0 deletions yt_idv/tests/test_yt_idv.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def test_snapshots(osmesa_fake_amr, image_store):
image_store(osmesa_fake_amr)


def test_camera_position(osmesa_fake_amr, image_store):
"""Check that we can update the camera position"""
vm = osmesa_fake_amr.scene.camera.view_matrix
osmesa_fake_amr.scene.camera.set_position([0.5, 2.0, 3.0])
# check that the view matrix has changed
assert np.sum(np.abs(vm - osmesa_fake_amr.scene.camera.view_matrix)) > 0.0
image_store(osmesa_fake_amr)


def test_depth_buffer_toggle(osmesa_fake_amr, image_store):
osmesa_fake_amr.scene.components[0].use_db = True
image_store(osmesa_fake_amr)
Expand Down

0 comments on commit 93473ef

Please sign in to comment.