Skip to content

Commit

Permalink
reset_camera as per #1079
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Mar 25, 2024
1 parent cfeadc0 commit c13e2f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- add `FlyOverSurface` class and `examples/basic/interaction_modes3.py`
- address #1072 for pyinstaller
- add `mesh.extrude_and_trim_with()` method out of #1077
- fix `reset_camera()` by @sergei9838 and Eric


## Soft-breaking Changes
Expand Down
8 changes: 4 additions & 4 deletions vedo/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,14 +1344,14 @@ def reset_camera(self, tight=None) -> "Plotter":
self.renderer.ResetCamera()
else:
x0, x1, y0, y1, z0, z1 = self.renderer.ComputeVisiblePropBounds()

cam = self.renderer.GetActiveCamera()
cam = self.camera

self.renderer.ComputeAspect()
aspect = self.renderer.GetAspect()
angle = np.pi * cam.GetViewAngle() / 180.0
dx, dy = (x1 - x0) * 0.999, (y1 - y0) * 0.999
dist = max(dx / aspect[0], dy) / np.sin(angle / 2) / 2
dx = x1 - x0
dy = y1 - y0
dist = max(dx / aspect[0], dy) / np.tan(angle / 2) / 2

cam.SetViewUp(0, 1, 0)
cam.SetPosition(x0 + dx / 2, y0 + dy / 2, dist * (1 + tight))
Expand Down
2 changes: 1 addition & 1 deletion vedo/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_version = '2024.5.1+dev08'
_version = '2024.5.1+dev09'

0 comments on commit c13e2f7

Please sign in to comment.