Fix the perspective projection

Reviewed By: kukulski

Differential Revision: D2907261

fb-gh-sync-id: 3954b015ece9c4339a674c4fcc2c2c7187b6da41
shipit-source-id: 3954b015ece9c4339a674c4fcc2c2c7187b6da41
This commit is contained in:
Renyu Liu 2016-02-08 15:05:41 -08:00 committed by facebook-github-bot-4
parent 194092e729
commit 843b556769
1 changed files with 7 additions and 1 deletions

View File

@ -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) { 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 r_depth = 1 / (near - far);
var C = (far + near) * r_depth; var C = (far + near) * r_depth;
var D = 2 * (far * near * r_depth); var D = 2 * (far * near * r_depth);