Mat4:lookAt

Edit

Sets a view transform matrix that moves and orients camera to look at a target point.

This is useful for changing camera position and orientation.

The lookAt() function produces same result as target() after matrix inversion.

self = Mat4:lookAt(from, to, up)

Arguments

NameTypeDefaultDescription
fromVec3 The position of the viewer.
toVec3 The position of the target.
upVec3Vec3(0, 1, 0) The up vector of the viewer.

Returns

NameTypeDescription
selfMat4 The modified matrix.

Example

function lovr.draw(pass)
  pass:setViewPose(1, mat4():lookAt(cameraPos, playerPos), true)

  -- draw scene
end

See also