From 4268dfbbf8680cc6f7f37b524c519f5dc7305650 Mon Sep 17 00:00:00 2001 From: Steve Jackson Date: Mon, 15 Apr 2019 14:35:31 -0700 Subject: [PATCH] More adaptive 3D camera This lets us load models with larger geometric sizes --- src/athena/viewer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/athena/viewer.py b/src/athena/viewer.py index 20b7b92..0077ec6 100644 --- a/src/athena/viewer.py +++ b/src/athena/viewer.py @@ -93,10 +93,14 @@ def __init__(self, window, camera, geometry): def reset(self): ratio = self._windowAspectRatio() - self.camera.lens().setPerspectiveProjection(45, ratio, .01, 1000) aabb_size = self.aabb.max - self.aabb.min + cam_distance = 2 * max(aabb_size.x(), aabb_size.y(), aabb_size.z()) + frustum_max = cam_distance * 2 + frustum_min = frustum_max / 1e5 + + self.camera.lens().setPerspectiveProjection(45, ratio, frustum_min, frustum_max) cam_loc = self.aabb.center + vec3d( cam_distance, 0, 0 ) self.camera.setPosition( cam_loc ) self.camera.setViewCenter( self.aabb.center )