Skip to content

Commit

Permalink
Fix the orientation of the forward vector in lookAt()
Browse files Browse the repository at this point in the history
  • Loading branch information
romainguy committed Mar 1, 2022
1 parent fa553fa commit 54d6e97
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/dev/romainguy/kotlin/math/Matrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ fun lookTowards(eye: Float3, forward: Float3, up: Float3 = Float3(z = 1.0f)): Ma
val f = normalize(forward)
val r = normalize(f x up)
val u = normalize(r x f)
return Mat4(Float4(r), Float4(u), Float4(f), Float4(eye, 1.0f))
return Mat4(Float4(r), Float4(u), Float4(-f), Float4(eye, 1.0f))
}

fun perspective(fov: Float, ratio: Float, near: Float, far: Float): Mat4 {
Expand Down

0 comments on commit 54d6e97

Please sign in to comment.