Browse Source

Write lots of docs;

bjorn 2 years ago
parent
commit
7551de91ed

File diff suppressed because it is too large
+ 267 - 1
api/init.lua


+ 16 - 2
api/lovr/data/Blob/getString.lua

@@ -1,7 +1,21 @@
 return {
   summary = 'Get the Blob\'s contents as a string.',
   description = 'Returns a binary string containing the Blob\'s data.',
-  arguments = {},
+  arguments = {
+    offset = {
+      type = 'number',
+      default = '0',
+      description = 'A byte offset into the Blob where the string will start.'
+    },
+    size = {
+      type = 'number',
+      default = 'nil',
+      description = [[
+        The number of bytes the string will contain.  If nil, the rest of the data in the Blob will
+        be used, based on the `offset` parameter.
+      ]]
+    }
+  },
   returns = {
     data = {
       type = 'string',
@@ -10,7 +24,7 @@ return {
   },
   variants = {
     {
-      arguments = {},
+      arguments = { 'offset', 'size' },
       returns = { 'data' }
     }
   },

+ 12 - 0
api/lovr/graphics/Pass/cone.lua

@@ -64,6 +64,14 @@ return {
       type = 'Mat4',
       description = 'The transform of the cone.'
     },
+    p1 = {
+      type = 'Vec3',
+      description = 'The position of the base of the cone.'
+    },
+    p2 = {
+      type = 'Vec3',
+      description = 'The position of the tip of the cone.'
+    },
     segments = {
       type = 'number',
       default = '64',
@@ -83,6 +91,10 @@ return {
     {
       arguments = { 'transform', 'segments' },
       returns = {}
+    },
+    {
+      arguments = { 'p1', 'p2', 'radius', 'segments' },
+      returns = {}
     }
   },
   notes = [[

+ 104 - 0
api/lovr/graphics/Pass/roundrect.lua

@@ -0,0 +1,104 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a rounded rectangle.',
+  description = 'Draws a rounded rectangle.',
+  arguments = {
+    x = {
+      type = 'number',
+      default = '0',
+      description = 'The x coordinate of the center of the rectangle.'
+    },
+    y = {
+      type = 'number',
+      default = '0',
+      description = 'The y coordinate of the center of the rectangle.'
+    },
+    z = {
+      type = 'number',
+      default = '0',
+      description = 'The z coordinate of the center of the rectangle.'
+    },
+    width = {
+      type = 'number',
+      default = '1',
+      description = 'The width of the rectangle.'
+    },
+    height = {
+      type = 'number',
+      default = '1',
+      description = 'The height of the rectangle.'
+    },
+    thickness = {
+      type = 'number',
+      default = '1',
+      description = 'The thickness of the rectangle.'
+    },
+    angle = {
+      type = 'number',
+      default = '0',
+      description = 'The rotation of the rectangle around its rotation axis, in radians.'
+    },
+    ax = {
+      type = 'number',
+      default = '0',
+      description = 'The x component of the axis of rotation.'
+    },
+    ay = {
+      type = 'number',
+      default = '1',
+      description = 'The y component of the axis of rotation.'
+    },
+    az = {
+      type = 'number',
+      default = '0',
+      description = 'The z component of the axis of rotation.'
+    },
+    position = {
+      type = 'Vec3',
+      description = 'The position of the rectangle.'
+    },
+    size = {
+      type = 'Vec3',
+      description = 'The size of the rectangle (width, height, thickness).'
+    },
+    orientation = {
+      type = 'Quat',
+      description = 'The orientation of the rectangle.'
+    },
+    transform = {
+      type = 'Mat4',
+      description = 'The transform of the rectangle.'
+    },
+    radius = {
+      type = 'number',
+      default = '0',
+      description = [[
+        The radius of the rectangle corners.  If the radius is zero or negative, the rectangle will
+        have sharp corners.
+      ]]
+    },
+    segments = {
+      type = 'number',
+      default = '8',
+      description = [[
+        The number of circular segments to use for each corner.  This increases the smoothness, but
+        increases the number of vertices in the mesh.
+      ]]
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'z', 'width', 'height', 'thickness', 'angle', 'ax', 'ay', 'az', 'radius', 'segments' },
+      returns = {}
+    },
+    {
+      arguments = { 'position', 'size', 'orientation', 'radius', 'segments' },
+      returns = {}
+    },
+    {
+      arguments = { 'transform', 'radius', 'segments' },
+      returns = {}
+    }
+  }
+}

+ 1 - 0
api/lovr/headset/isFocused.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'headset',
   summary = 'Check if LÖVR has VR input focus.',
   description = [[
     Returns whether LÖVR has VR input focus.  Focus is lost when the VR system menu is shown.  The

+ 27 - 0
api/lovr/headset/isPassthroughEnabled.lua

@@ -0,0 +1,27 @@
+return {
+  tag = 'headset',
+  summary = 'Check if passthrough is active.',
+  description = [[
+    Returns whether passthrough is active.  When passthrough is active, the real world will be
+    rendered behind any content rendered by LÖVR, using the alpha channel to blend between the two.
+  ]],
+  arguments = {},
+  returns = {
+    active = {
+      type = 'boolean',
+      description = 'Whether passthrough is active.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'active' }
+    }
+  },
+  notes = [[
+    This feature is currently only supported on Oculus Quest devices.
+  ]],
+  related = {
+    'lovr.headset.setPassthroughEnabled'
+  }
+}

+ 32 - 0
api/lovr/headset/setPassthroughEnabled.lua

@@ -0,0 +1,32 @@
+return {
+  tag = 'headset',
+  summary = 'Enable or disable passthrough.',
+  description = [[
+    Sets whether passthrough is active.  When passthrough is active, the real world will be rendered
+    behind any content rendered by LÖVR, using the alpha channel to blend between the two.
+  ]],
+  arguments = {
+    enable = {
+      type = 'boolean',
+      description = 'Whether passthrough should be enabled.'
+    }
+  },
+  returns = {
+    success = {
+      type = 'boolean',
+      description = 'Whether the passthrough state was set successfully.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'enable' },
+      returns = { 'success' }
+    }
+  },
+  notes = [[
+    This feature is currently only supported on Oculus Quest devices.
+  ]],
+  related = {
+    'lovr.headset.isPassthroughEnabled'
+  }
+}

+ 29 - 0
api/lovr/math/Mat4/reflect.lua

@@ -0,0 +1,29 @@
+return {
+  summary = 'Create a matrix that reflects across a plane.',
+  description = [[
+    Turns the matrix into a reflection matrix that transforms values as though they were reflected
+    across a plane.
+  ]],
+  arguments = {
+    position = {
+      type = 'Vec3',
+      description = 'The position of the plane.'
+    },
+    normal = {
+      type = 'Vec3',
+      description = 'The normal vector of the plane.'
+    }
+  },
+  returns = {
+    m = {
+      type = 'Mat4',
+      description = 'The original matrix, with modified values.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'position', 'normal' },
+      returns = { 'm' }
+    }
+  }
+}

+ 31 - 10
api/lovr/math/Vectors/init.lua

@@ -42,29 +42,31 @@ return {
 
         local position = lovr.math.vec3(x, y, z)
 
-    As a further shorthand, these vector constructors are placed on the global scope.  If you prefer to
-    keep the global scope clean, this can be configured using the `t.math.globals` flag in `lovr.conf`.
+    As a shortcut, vector constructors are placed on the global scope.  The uppercase name of the
+    vector is a function that will create a permanent vector, and the lowercase name will create a
+    temporary vector.  This can be disabled using the `t.math.globals` option in `lovr.conf`.
 
         local position = vec3(x1, y1, z1) + vec3(x2, y2, z2)
+        local transform = Mat4()
 
-    Temporary vectors, with all their speed, come with an important restriction: they can only be used
-    during the frame in which they were created.  Saving them into variables and using them later on
-    will throw an error:
+    Temporary vectors, with all their speed, come with an important restriction: they can only be
+    used during the frame in which they were created.  Saving them into variables and using them
+    later on will throw an error:
 
         local position = vec3(1, 2, 3)
 
         function lovr.update(dt)
-          -- Reusing a temporary vector across frames will error:
+          -- Reusing the temporary 'position' vector across frames will error:
           position:add(vec3(dt))
         end
 
-    It's possible to overflow the temporary vector pool.  If that happens, `lovr.math.drain` can be used
-    to periodically drain the pool, invalidating any existing temporary vectors.
+    It's possible to overflow the temporary vector pool.  If that happens, `lovr.math.drain` can be
+    used to periodically drain the pool, invalidating any existing temporary vectors.
 
     ### Metamethods
 
-    Vectors have metamethods, allowing them to be used using the normal math operators like `+`, `-`,
-    `*`, `/`, etc.
+    Vectors have metamethods, allowing them to be used using the normal math operators like `+`,
+    `-`, `*`, `/`, etc.
 
         print(vec3(2, 4, 6) * .5 + vec3(10, 20, 30))
 
@@ -103,5 +105,24 @@ return {
     a vector object.  For quaternions you can choose whether you want to unpack the angle/axis
     representation or the raw quaternion components.  Similarly, matrices support raw unpacking as well
     as decomposition into translation/scale/rotation values.
+
+    ### Vector Constants
+
+    The following vector constants are available.  They return new temporary vectors each time they
+    are used:
+
+    - `vec2.zero` (0, 0)
+    - `vec2.one` (1, 1)
+    - `vec3.zero` (0, 0, 0)
+    - `vec3.one` (1, 1, 1)
+    - `vec3.left` (-1, 0, 0)
+    - `vec3.right` (1, 0, 0)
+    - `vec3.up` (0, 1, 0)
+    - `vec3.down` (0, -1, 0)
+    - `vec3.back` (0, 0, 1)
+    - `vec3.forward` (0, 0, -1)
+    - `vec4.zero` (0, 0, 0, 0)
+    - `vec4.one` (1, 1, 1, 1)
+    - `quat.identity` (0, 0, 0, 1)
   ]]
 }

+ 24 - 0
api/lovr/physics/World/getTags.lua

@@ -0,0 +1,24 @@
+return {
+  tag = 'worldCollision',
+  summary = 'Get the list of tags the World was created with.',
+  description = 'Returns the list of collision tags used when creating the World.',
+  arguments = {},
+  returns = {
+    tags = {
+      type = 'table',
+      description = 'A table of collision tags (strings).'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'tags' }
+    }
+  },
+  related = {
+    'lovr.physics.newWorld',
+    'World:enableCollisionBetween',
+    'World:disableCollisionBetween',
+    'World:isCollisionEnabledBetween'
+  }
+}

+ 2 - 1
api/lovr/thread/Channel/push.lua

@@ -2,7 +2,8 @@ return {
   summary = 'Push a message onto the Channel.',
   description = [[
     Pushes a message onto the Channel.  The following types of data can be pushed: nil, boolean,
-    number, string, and userdata.  Tables should be serialized to strings.
+    number, string, lightuserdata, vectors, and userdata (LÖVR objects).  Notably, tables are not
+    currently supported and should be serialized to strings.
   ]],
   arguments = {
     message = {

Some files were not shown because too many files changed in this diff