diff --git a/.gitignore b/.gitignore index 19283ec..5532662 100644 --- a/.gitignore +++ b/.gitignore @@ -111,8 +111,9 @@ ENV/ .vscode/ .idea/ -# Screenshots +# Screenshots and examples snap_*.png +examples/*.png # pytest outputs report.html diff --git a/examples/amr_osmesa.py b/examples/amr_osmesa.py index 3be5a77..c01a44a 100644 --- a/examples/amr_osmesa.py +++ b/examples/amr_osmesa.py @@ -15,3 +15,7 @@ image = rc.run() yt.write_bitmap(image, "step2.png") + +rc.scene.camera.set_position([1.0, 1.5, 3.0]) +image = rc.run() +yt.write_bitmap(image, "step3_set_position.png") diff --git a/yt_idv/cameras/trackball_camera.py b/yt_idv/cameras/trackball_camera.py index aae1d1f..f4fd10a 100644 --- a/yt_idv/cameras/trackball_camera.py +++ b/yt_idv/cameras/trackball_camera.py @@ -86,3 +86,7 @@ def offset_position(self, dpos=None): def _compute_matrices(self): pass + + def set_position(self, pos): + self.position = pos + self._update_matrices() diff --git a/yt_idv/tests/test_yt_idv.py b/yt_idv/tests/test_yt_idv.py index 144cd3e..07f68e5 100644 --- a/yt_idv/tests/test_yt_idv.py +++ b/yt_idv/tests/test_yt_idv.py @@ -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)