Browse Source

Improve lookAt docs;

bjorn 1 year ago
parent
commit
272cec2eb8
2 changed files with 14 additions and 3 deletions
  1. 6 1
      api/init.lua
  2. 8 2
      api/lovr/math/Mat4/lookAt.lua

+ 6 - 1
api/init.lua

@@ -28707,9 +28707,14 @@ return {
             {
               name = "lookAt",
               summary = "Create a view transform that looks from a position to target position.",
-              description = "Sets a view transform matrix that moves and orients camera to look at a target point.\n\nThis is useful for changing camera position and orientation. The resulting Mat4 matrix can be passed to `lovr.graphics.transform()` directly (without inverting) before rendering the scene.\n\nThe lookAt() function produces same result as target() after matrix inversion.",
+              description = "Sets a view transform matrix that moves and orients camera to look at a target point.\n\nThis is useful for changing camera position and orientation.\n\nThe lookAt() function produces same result as target() after matrix inversion.",
               key = "Mat4:lookAt",
               module = "lovr.math",
+              examples = {
+                {
+                  code = "function lovr.draw(pass)\n  pass:setViewPose(1, mat4():lookAt(cameraPos, playerPos), true)\n\n  -- draw scene\nend"
+                }
+              },
               related = {
                 "Mat4:target",
                 "Quat:direction"

+ 8 - 2
api/lovr/math/Mat4/lookAt.lua

@@ -3,8 +3,7 @@ return {
   description = [[
     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 resulting Mat4 matrix can be
-    passed to `lovr.graphics.transform()` directly (without inverting) before rendering the scene.
+    This is useful for changing camera position and orientation.
 
     The lookAt() function produces same result as target() after matrix inversion.
   ]],
@@ -35,6 +34,13 @@ return {
       returns = { 'self' }
     }
   },
+  example = [[
+    function lovr.draw(pass)
+      pass:setViewPose(1, mat4():lookAt(cameraPos, playerPos), true)
+
+      -- draw scene
+    end
+  ]],
   related = {
     'Mat4:target',
     'Quat:direction'