Skip to content

Commit

Permalink
Merge pull request #166 from chrishavlin/add_set_position_camera_func
Browse files Browse the repository at this point in the history
add camera.set_position to TrackballCamera
  • Loading branch information
chrishavlin authored Dec 13, 2024
2 parents e093d4e + 7371831 commit 709b216
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ ENV/
.vscode/
.idea/

# Screenshots
# Screenshots and examples
snap_*.png
examples/*.png

# pytest outputs
report.html
4 changes: 4 additions & 0 deletions examples/amr_osmesa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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._update_matrices()
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 709b216

Please sign in to comment.