Faking an orthographic camera with a default perspective one? (FOV or focal length)

Hello! Is there any way to use a normal perspective camera (such as ArcRotateCamera) like an orthographic camera? By that, I mean raising a value to increase the focal length, or lowering/shrinking its field of view (FOV.)


The best example I can describe is viewing a camera inside of Blender and raising the Focal Length value until the FOV is so small or narrow that it’s essentially orthographic. I tried looking for such a feature in the API, but it only seems to be part of a depth of field effect.

Thanks!

You can set the mode to orthographic with:

camera.mode = ArcRotateCamera.ORTHOGRAPHIC_CAMERA

And restore with:

camera.mode = ArcRotateCamera.PERSPECTIVE_CAMERA

In orthographic mode you’ll need to reset alpha and beta depending on what orthographic view you want i.e. left, front, top etc.

You’ll also need to set orthoTop, orthoBottom, orthoLeft and orthoRight for “zoom” level, factoring in the current aspect ratio.

1 Like

Yes that’s how to use a standalone orthographic camera, but I want to adjust the focal length on a standard perspective camera.

Now that I think about it though, I could’ve worded my question better: how do I make a normal camera zoom in without moving its location towards the subject?

You should be able to directly update fov TargetCamera | Babylon.js Documentation (babylonjs.com) :slight_smile:

1 Like

Thank you! Decreasing that fov value to less than 0.1 (and then moving the camera backwards) was what I was trying to do.

Apparently there’s a Wikipedia article for the effect I had in mind: it’s called the Dolly zoom or the Hitchcock effect.

image

3 Likes

That’s cool to know! :open_mouth: