From 843b5567698327525015326e87bcaaa5cfbe807f Mon Sep 17 00:00:00 2001 From: Renyu Liu Date: Mon, 8 Feb 2016 15:05:41 -0800 Subject: [PATCH] Fix the perspective projection Reviewed By: kukulski Differential Revision: D2907261 fb-gh-sync-id: 3954b015ece9c4339a674c4fcc2c2c7187b6da41 shipit-source-id: 3954b015ece9c4339a674c4fcc2c2c7187b6da41 --- Libraries/Utilities/MatrixMath.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/Utilities/MatrixMath.js b/Libraries/Utilities/MatrixMath.js index addc8660e..32f3cd32f 100755 --- a/Libraries/Utilities/MatrixMath.js +++ b/Libraries/Utilities/MatrixMath.js @@ -67,8 +67,14 @@ var MatrixMath = { ]; }, + /** + * This create a perspective projection towards negative z + * Clipping the z range of [-near, -far] + * + * @param fovInRadians - field of view in randians + */ createPerspective: function(fovInRadians, aspect, near, far) { - var h = 1 / Math.tan(fovInRadians); + var h = 1 / Math.tan(fovInRadians / 2); var r_depth = 1 / (near - far); var C = (far + near) * r_depth; var D = 2 * (far * near * r_depth);