| 3 | |
| 4 | /* A camera looking down -z with y up, as the scene sets it; projection by hand. */ |
| 5 | function project(point: { x: number; y: number; z: number }, frame: ReturnType<typeof pathFrame>, viewport: { width: number; height: number }, fov: number) { |
| 6 | const depth = frame.position.z - point.z; |
| 7 | const half = Math.tan((fov * Math.PI) / 360) * depth; |
| 8 | const aspect = viewport.width / viewport.height; |
| 9 | return { x: ((point.x - frame.position.x) / (half * aspect) + 1) / 2 * viewport.width, y: (1 - (point.y - frame.position.y) / half) / 2 * viewport.height }; |
| 10 | } |
| 11 | |
| 12 | describe('hand test K6: the camera frames a shown path', () => { |
| 13 | const view = { direction: { x: 0, y: 0, z: -1 }, up: { x: 0, y: 1, z: 0 } }; |