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

Import camera fov #1001

Closed
pixue opened this issue Mar 27, 2020 · 5 comments
Closed

Import camera fov #1001

pixue opened this issue Mar 27, 2020 · 5 comments

Comments

@pixue
Copy link

pixue commented Mar 27, 2020

All fov of cameras imported from gltf/glb files are lost.

To Reproduce
Steps to reproduce the behavior:

  1. Import a gltf or glb with cameras defined.
  2. All camera fov-s are lost
    Blender282a

Expected behavior
Camera fov defined (or its equivalent in mm), not default focal length of 50mm.

Test files gltf&glb
Test.zip

Version

  • OS: Windows 10
  • Blender Version 2.82a

Additional context
Test files are created using ThreeJS editor, adding some cameras and customizing their fov. Then I export to gltf and glb.
Captura
I see that the fov is stored in the definition of each camera inside the cameras array of gltf file.

@VForsmann
Copy link

VForsmann commented Apr 20, 2020

I have the same problem. The camera in the gltf has a yFOV value, which is calculated down to the default FocalLength of 50mm after importing the gltf.

Blender: blender2.83a
System: Linux Mint 19.3 Cinnamon (4.4.8)

I am also using a GLTF-File exported from three.js using the GLTFExporter.

The result as part of a JSON looks like this:
image

In Blender I can find the camera, but not with yFOV but with a default FocalLength of 50mm (~ 40 degrees fov):
image
image

--> 1.668 * (180/Math.PI) returns something near 95 degrees I guess. That should be the right FOV-value.

@SakuPartamies
Copy link

SakuPartamies commented Apr 22, 2020

I can confirm the issue as well. The camera is imported as default 50mm, which is not correct. I have made a three.js WebGL scene and exported it as glTF. In Blender camera FOV is not imported.

Below is an image to present the issue. I can manually change the camera lens to Focal Length and convert the FOV value in glTF file to degrees to type in Blender. That will correct the problem, but this should be automatically done by the importer.

Software:
Windows 10: 10.0.18363
Chrome: 80.0.3987.163 (64bit)
Blender: 2.81
Import-Export: glTF 2.0 (v. 1.0.5)

gltf_blender_camera-FOV_problem

@VForsmann
Copy link

Hey,

I could find out, that they already fixed it, but its not released in the newest Blender I guess.

So to workaround this clone this git repo, and copy the glTF-Blender-IO/addons/io_scene_gltf2 folder to replace your local blender/x.xx/scripts/addons/io_scene_gltf2 folder.

For me this worked, you can find the camera fix in io_scene_gltf2/blender/imp/gltf2_blender_camera.py where you can find the added:

cam.angle_y = pycamera.perspective.yfov
cam.lens_unit = "FOV"
cam.sensor_fit = "VERTICAL"

Hope I could help out :)

@SakuPartamies
Copy link

Yes, you are right. It is in 2.83 branch like you mentioned and at least import was working correct in my Blender 2.81. Other branches didn't have that change as I checked.

Thanks.

@pixue pixue closed this as completed Apr 22, 2020
@pixue
Copy link
Author

pixue commented Apr 22, 2020

Hello,
I just tried it and it seems to have the expected behavior.
Thank you!

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

3 participants