glTF exporter: Fix exporting `aspectRatio` for Perspective Cameras

Thanks pop!
This commit is contained in:
Julien Duroure 2020-07-21 20:16:08 +02:00
parent 63dd8498ac
commit 2b4bf943d0
2 changed files with 4 additions and 4 deletions

View File

@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (1, 3, 32),
"version": (1, 3, 33),
'blender': (2, 90, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -92,18 +92,18 @@ def __gather_perspective(blender_camera, export_settings):
width = bpy.context.scene.render.pixel_aspect_x * bpy.context.scene.render.resolution_x
height = bpy.context.scene.render.pixel_aspect_y * bpy.context.scene.render.resolution_y
perspective.aspectRatio = width / height
perspective.aspect_ratio = width / height
if width >= height:
if blender_camera.sensor_fit != 'VERTICAL':
perspective.yfov = 2.0 * math.atan(math.tan(blender_camera.angle * 0.5) / perspective.aspectRatio)
perspective.yfov = 2.0 * math.atan(math.tan(blender_camera.angle * 0.5) / perspective.aspect_ratio)
else:
perspective.yfov = blender_camera.angle
else:
if blender_camera.sensor_fit != 'HORIZONTAL':
perspective.yfov = blender_camera.angle
else:
perspective.yfov = 2.0 * math.atan(math.tan(blender_camera.angle * 0.5) / perspective.aspectRatio)
perspective.yfov = 2.0 * math.atan(math.tan(blender_camera.angle * 0.5) / perspective.aspect_ratio)
perspective.znear = blender_camera.clip_start
perspective.zfar = blender_camera.clip_end