Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTFLoader: camera xfov calculation is wrong #13642

Closed
4 tasks done
pjoe opened this issue Mar 20, 2018 · 4 comments
Closed
4 tasks done

GLTFLoader: camera xfov calculation is wrong #13642

pjoe opened this issue Mar 20, 2018 · 4 comments

Comments

@pjoe
Copy link

pjoe commented Mar 20, 2018

Description of the problem

xfov is not calculated correctly. As fov is an angle you can not just multiply aspect ratio, but should do something like xfov = atan(tan(yfov) / aspectratio) (see https://www.gamedev.net/forums/topic/203238-perspective---x---fov/?tab=comments#comment-2294951)

This conversion is done here: https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/GLTFLoader.js#L2356

Three.js version
  • Dev
  • r91
Browser
  • All of them
OS
  • All of them
@pjoe
Copy link
Author

pjoe commented Mar 20, 2018

After more testing the right formula is:

xfov=2*Math.atan(Math.tan(yfov/2) * aspect)

@donmccurdy
Copy link
Collaborator

Thanks for the report! Looking at this now, I'm not sure why we convert to xfov at all... glTF provides yfov, or "The floating-point vertical field of view in radians", and the THREE.PerspectiveCamera constructor expects "Camera frustum vertical field of view" in degrees. So we should just convert directly from radians to degrees.

@pjoe
Copy link
Author

pjoe commented Mar 20, 2018

Hah, that explains what I'm seeing ... double (or triple) checked that the xfov got calculated correctly, but scene still didn't look quite right :)

Should be very easy fix then.

@donmccurdy
Copy link
Collaborator

Opened #13646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants