-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
OrthographicCamera.ts
52 lines (47 loc) · 949 Bytes
/
OrthographicCamera.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Mat4 from "../math/Mat4";
import Camera from "./Camera";
export default class OrthographicCamera extends Camera {
public left: number;
public right: number;
public bottom: number;
public top: number;
public near: number;
public far: number;
public constructor(
{
left = -1,
right = 1,
bottom = -1,
top = 1,
near = 0.1,
far = 1000
}: {
left: number;
right: number;
bottom: number;
top: number;
near: number;
far: number;
}
) {
super();
this.left = left;
this.right = right;
this.bottom = bottom;
this.top = top;
this.near = near;
this.far = far;
this.updateProjectionMatrix();
}
public updateProjectionMatrix(): void {
this.projectionMatrix = Mat4.orthographic(
this.left / this.zoomFactor,
this.right / this.zoomFactor,
this.bottom / this.zoomFactor,
this.top / this.zoomFactor,
this.near,
this.far
);
this.updateProjectionMatrixInverse();
}
}