Skip to content

Commit

Permalink
Fix perspective camera FOV export. (mrdoob#9482)
Browse files Browse the repository at this point in the history
From blender, `camera.angle` returns the fov according to longest rendering dimension in radians. This patch returns a value three.js expects: an horizontal fov in degrees.
  • Loading branch information
charlesfleche authored and mrdoob committed Aug 15, 2016
1 parent 51e25a8 commit 3423b6d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
from bpy import data, types, context
from .. import logger

Expand Down Expand Up @@ -74,7 +75,11 @@ def fov(camera):
"""
logger.debug("camera.fov(%s)", camera)
return camera.angle
fov_in_radians = camera.angle
aspect_ratio = aspect(camera)
if aspect_ratio > 1:
fov_in_radians = 2 * math.atan(math.tan(fov_in_radians / 2) / aspect_ratio)
return math.degrees(fov_in_radians)


@_camera
Expand Down

0 comments on commit 3423b6d

Please sign in to comment.