| 70 | } |
| 71 | |
| 72 | export class Camera { |
| 73 | eye = new Vector3(0, 1, 2); |
| 74 | target = new Vector3(0, 0, 0); |
| 75 | up = Vector3.up(); |
| 76 | aspect = 0; |
| 77 | fovy = 45.0; |
| 78 | znear = 0.1; |
| 79 | zfar = 100.0; |
| 80 | |
| 81 | constructor(width, height) { |
| 82 | this.aspect = width / height; |
| 83 | } |
| 84 | |
| 85 | buildViewProjMatrix() { |
| 86 | const view = Matrix4.lookAtRh(this.eye, this.target, this.up); |
| 87 | const proj = new PerspectiveFov(new Deg(this.fovy), this.aspect, this.znear, this.zfar) |
| 88 | .toPerspective() |
| 89 | .toMatrix4(); |
| 90 | return OPENGL_TO_WGPU_MATRIX.mul(proj.mul(view)).toFloat32Array(); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | export class HelloCameraApp extends App { |
| 95 | constructor() { |