How do I calculate near/far for OrthographicFrustum?

How do I calculate the near and far values when switching from PerspectiveFrustum to OrthographicFrustum?
The example in the API, which uses the maximumRadius, leads to a false dispaly where the lower part of the globe is hidden when zooming into a location.

Hi @mholthausen, currently, in the Camera class, there is a function switchToOrthographicFrustum() which will switch from perspective to orthographic projection. At the first glance, it seems like they only adjust the width of the frustum while near and far plane are constant. Hopefully, that helps.

1 Like

For calculating the width of the frustum, it is in the private function calculateOrthographicFrustumWidth() in the Camera.js. I think the algorithm tries to shoot a ray out to the scene or globe and find the distance between the intersection point and the camera. That distance will be assigned to the width of the frustum. I think it is just an approximation to make sure the width of the frustum is proportional with the distance between the camera and the globe. Please let me know if that helps

Usually no need to alter near/far planes going to orthographic I would think. Zooming in orthographic would be adjusting the width of the rectangular frustum (then setting frustum height according to aspect ratio and width.) Unless you’re doing OrthographicFrustum in one of the 3D modes?

1 Like