|
@@ -53,6 +53,9 @@ export class PerspectiveView implements View
|
53
|
53
|
/** A 4x4 matrix that projects the viewer space into the clip space, i.e., [-1,1]^3 */
|
54
|
54
|
private readonly _projectionMatrix: SpeedyMatrix;
|
55
|
55
|
|
|
56
|
+ /** Tangent of the half of the horizontal field-of-view */
|
|
57
|
+ private readonly _tanOfHalfFovx: number;
|
|
58
|
+
|
56
|
59
|
/** Tangent of the half of the vertical field-of-view */
|
57
|
60
|
private readonly _tanOfHalfFovy: number;
|
58
|
61
|
|
|
@@ -86,6 +89,7 @@ export class PerspectiveView implements View
|
86
|
89
|
throw new IllegalArgumentError(`View expects near < far (found near = ${this._near} and far = ${this._far})`);
|
87
|
90
|
|
88
|
91
|
this._aspect = screenSize.width / screenSize.height;
|
|
92
|
+ this._tanOfHalfFovx = intrinsics[U0] / intrinsics[FX];
|
89
|
93
|
this._tanOfHalfFovy = intrinsics[V0] / intrinsics[FY];
|
90
|
94
|
this._projectionMatrix = PerspectiveView._computeProjectionMatrix(intrinsics, this._near, this._far);
|
91
|
95
|
}
|
|
@@ -107,6 +111,14 @@ export class PerspectiveView implements View
|
107
|
111
|
}
|
108
|
112
|
|
109
|
113
|
/**
|
|
114
|
+ * Horizontal field-of-view of the frustum, measured in radians
|
|
115
|
+ */
|
|
116
|
+ get fovx(): number
|
|
117
|
+ {
|
|
118
|
+ return 2 * Math.atan(this._tanOfHalfFovx);
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ /**
|
110
|
122
|
* Vertical field-of-view of the frustum, measured in radians
|
111
|
123
|
*/
|
112
|
124
|
get fovy(): number
|