From c13e2f71e9d393f3cdf58a26aeb0314122d0d16c Mon Sep 17 00:00:00 2001 From: Marco Musy Date: Mon, 25 Mar 2024 23:03:26 +0100 Subject: [PATCH] reset_camera as per #1079 --- docs/changes.md | 1 + vedo/plotter.py | 8 ++++---- vedo/version.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index 4182d138..54060209 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -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 diff --git a/vedo/plotter.py b/vedo/plotter.py index 369407ee..174e55c0 100644 --- a/vedo/plotter.py +++ b/vedo/plotter.py @@ -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)) diff --git a/vedo/version.py b/vedo/version.py index 15274d75..422ae3d8 100644 --- a/vedo/version.py +++ b/vedo/version.py @@ -1 +1 @@ -_version = '2024.5.1+dev08' +_version = '2024.5.1+dev09'