Packages/FoldKit/Tests/FoldingTests/CameraTests.swift

00ea029d0652da12d0f4237769e7020b72cfa7f3
fold/Packages/FoldKit/Tests/FoldingTests/CameraTests.swift history · blame · raw

10 lines · 379 bytes

1 symbol in this file
 1import Testing
 2import simd
 3import Folding
 4
 5@Test func viewProjectionMapsTheTargetToTheCentreOfClipSpace() {
 6    let c = Camera(eye: SIMD3(0, 0, 5), target: .zero, up: SIMD3(0, 1, 0), fieldOfView: .pi / 4)
 7    let p = c.viewProjection(aspect: 1.5) * SIMD4(0, 0, 0, 1)
 8    #expect(abs(p.x / p.w) < 1e-12 && abs(p.y / p.w) < 1e-12)
 9    #expect(c.viewDirection == SIMD3(0, 0, -1))
10}