* generate a perspective projection matrix, with the result replacing the current matrix * @param fov - vertical field of view in radians * @param aspect - aspect ratio (width / height) * @param near - distance to the near clipping plane along the -Z axis * @param far - distance to the far c
(fov: number, aspect: number, near: number, far: number)
| 586 | * @returns Reference to this object for method chaining |
| 587 | */ |
| 588 | perspective(fov: number, aspect: number, near: number, far: number) { |
| 589 | const a = this.val; |
| 590 | const f = 1.0 / Math.tan(fov / 2.0); |
| 591 | const nf = 1.0 / (near - far); |
| 592 | |
| 593 | a[0] = f / aspect; |
| 594 | a[1] = 0.0; |
| 595 | a[2] = 0.0; |
| 596 | a[3] = 0.0; |
| 597 | a[4] = 0.0; |
| 598 | a[5] = f; |
| 599 | a[6] = 0.0; |
| 600 | a[7] = 0.0; |
| 601 | a[8] = 0.0; |
| 602 | a[9] = 0.0; |
| 603 | a[10] = (far + near) * nf; |
| 604 | a[11] = -1.0; |
| 605 | a[12] = 0.0; |
| 606 | a[13] = 0.0; |
| 607 | a[14] = 2.0 * far * near * nf; |
| 608 | a[15] = 0.0; |
| 609 | |
| 610 | return this; |
| 611 | } |
| 612 | |
| 613 | /** |
| 614 | * scale the matrix |
no outgoing calls
no test coverage detected