bjorn 3 ngày trước cách đây
mục cha
commit
e093d39e9d
43 tập tin đã thay đổi với 299 bổ sung1012 xóa
  1. 89 562
      api/init.lua
  2. 4 4
      api/lovr/audio/getDevice.lua
  3. 3 7
      api/lovr/audio/newSource.lua
  4. 2 1
      api/lovr/data/Blob/getName.lua
  5. 3 1
      api/lovr/data/Image/encode.lua
  6. 5 13
      api/lovr/data/ModelData/getAnimationChannelCount.lua
  7. 4 12
      api/lovr/data/ModelData/getAnimationDuration.lua
  8. 13 12
      api/lovr/data/ModelData/getAnimationKeyframe.lua
  9. 4 12
      api/lovr/data/ModelData/getAnimationKeyframeCount.lua
  10. 3 4
      api/lovr/data/ModelData/getAnimationName.lua
  11. 4 12
      api/lovr/data/ModelData/getAnimationNode.lua
  12. 5 13
      api/lovr/data/ModelData/getAnimationProperty.lua
  13. 3 11
      api/lovr/data/ModelData/getAnimationSmoothMode.lua
  14. 14 23
      api/lovr/data/ModelData/getMaterial.lua
  15. 6 15
      api/lovr/data/ModelData/getNodeChildren.lua
  16. 4 12
      api/lovr/data/ModelData/getNodeMeshes.lua
  17. 4 12
      api/lovr/data/ModelData/getNodeOrientation.lua
  18. 5 13
      api/lovr/data/ModelData/getNodeParent.lua
  19. 4 12
      api/lovr/data/ModelData/getNodePose.lua
  20. 4 12
      api/lovr/data/ModelData/getNodePosition.lua
  21. 4 12
      api/lovr/data/ModelData/getNodeScale.lua
  22. 4 12
      api/lovr/data/ModelData/getNodeSkin.lua
  23. 4 12
      api/lovr/data/ModelData/getNodeTransform.lua
  24. 0 1
      api/lovr/data/ModelData/getSkinCount.lua
  25. 1 0
      api/lovr/data/ModelData/getSkinJoints.lua
  26. 11 13
      api/lovr/data/Rasterizer/getAdvance.lua
  27. 11 13
      api/lovr/data/Rasterizer/getBearing.lua
  28. 6 12
      api/lovr/data/Rasterizer/getBoundingBox.lua
  29. 4 12
      api/lovr/data/Rasterizer/getCurves.lua
  30. 6 12
      api/lovr/data/Rasterizer/getDimensions.lua
  31. 1 1
      api/lovr/data/Rasterizer/getFontSize.lua
  32. 5 13
      api/lovr/data/Rasterizer/getHeight.lua
  33. 4 25
      api/lovr/data/Rasterizer/getKerning.lua
  34. 5 13
      api/lovr/data/Rasterizer/getWidth.lua
  35. 13 2
      api/lovr/data/Rasterizer/hasGlyphs.lua
  36. 4 12
      api/lovr/data/Rasterizer/newImage.lua
  37. 1 1
      api/lovr/data/Sound/getFrames.lua
  38. 4 20
      api/lovr/data/Sound/setFrames.lua
  39. 6 15
      api/lovr/data/newImage.lua
  40. 4 12
      api/lovr/data/newModelData.lua
  41. 6 14
      api/lovr/data/newRasterizer.lua
  42. 10 20
      api/lovr/data/newSound.lua
  43. 2 2
      api/lovr/graphics/Model/getAnimationName.lua

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 89 - 562
api/init.lua


+ 4 - 4
api/lovr/audio/getDevice.lua

@@ -11,12 +11,12 @@ return {
   },
   returns = {
     name = {
-      type = 'string',
-      description = 'The name of the device.'
+      type = 'string | nil',
+      description = 'The name of the device, or `nil` if no device is set.'
     },
     id = {
-      type = 'userdata',
-      description = 'The opaque id of the device.'
+      type = 'userdata | nil',
+      description = 'The opaque id of the device, or `nil` if no device is set.'
     }
   },
   variants = {

+ 3 - 7
api/lovr/audio/newSource.lua

@@ -3,13 +3,9 @@ return {
   summary = 'Create a new Source.',
   description = 'Creates a new Source from an ogg, wav, or mp3 file.',
   arguments = {
-    filename = {
-      type = 'string',
-      description = 'The filename of the sound to load.'
-    },
-    blob = {
-      type = 'Blob',
-      description = 'The Blob containing the Source data.'
+    file = {
+      type = 'string | Blob',
+      description = 'A filename or Blob containing audio data to load.'
     },
     sound = {
       type = 'Sound',

+ 2 - 1
api/lovr/data/Blob/getName.lua

@@ -16,5 +16,6 @@ return {
       arguments = {},
       returns = { 'name' }
     }
-  }
+  },
+  notes = 'If a Blob was created without a name, its name will default to the empty string.'
 }

+ 3 - 1
api/lovr/data/Image/encode.lua

@@ -1,6 +1,8 @@
 return {
   summary = 'Encode the Image as png.',
-  description = 'Encodes the Image to an uncompressed png.  This intended mainly for debugging.',
+  description = [[
+    Encodes the Image to an **uncompressed** png.  This intended mainly for debugging.
+  ]],
   arguments = {},
   returns = {
     blob = {

+ 5 - 13
api/lovr/data/ModelData/getAnimationChannelCount.lua

@@ -3,16 +3,12 @@ return {
   description = [[
     Returns the number of channels in an animation.
 
-    A channel is a set of keyframes for a single property of a node.
+    A channel is a set of keyframes targeting a single property of a node.
   ]],
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of an animation.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of an animation.'
+    animation = {
+      type = 'number | string',
+      description = 'The name or index of an animation.'
     }
   },
   returns = {
@@ -23,11 +19,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'count' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'animation' },
       returns = { 'count' }
     }
   },

+ 4 - 12
api/lovr/data/ModelData/getAnimationDuration.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the duration of an animation.',
   description = 'Returns the duration of an animation.',
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the animation.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the animation.'
+    animation = {
+      type = 'string | number',
+      description = 'The name or index of an animation.'
     }
   },
   returns = {
@@ -19,11 +15,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'duration' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'animation' },
       returns = { 'duration' }
     }
   },

+ 13 - 12
api/lovr/data/ModelData/getAnimationKeyframe.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get a keyframe in a channel of an animation.',
   description = 'Returns a single keyframe in a channel of an animation.',
   arguments = {
-    index = {
+    animation = {
       type = 'number',
-      description = 'The index of an animation.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of an animation.'
+      description = 'The name or index of an animation.'
     },
     channel = {
       type = 'number',
@@ -26,19 +22,24 @@ return {
     },
     ['...'] = {
       type = 'number',
-      description = 'The data for the keyframe (either 3 or 4 numbers depending on the property).'
+      description = 'The data for the keyframe (3 or more numbers, depending on the property).'
     }
   },
   variants = {
     {
-      arguments = { 'index', 'channel', 'keyframe' },
-      returns = { 'time', '...' }
-    },
-    {
-      arguments = { 'name', 'channel', 'keyframe' },
+      arguments = { 'animation', 'channel', 'keyframe' },
       returns = { 'time', '...' }
     }
   },
+  notes = [[
+    The number of values returned after `time` depends on the `AnimationProperty` targeted by the
+    channel:
+
+    - `translation`: 3 numbers
+    - `rotation`: 4 numbers (returned as raw quaternion components)
+    - `scale`: 3 numbers
+    - `weights`: variable, contains 1 number for each blend shape in the node
+  ]],
   related = {
     'ModelData:getAnimationSmoothMode',
     'ModelData:getAnimationKeyframeCount'

+ 4 - 12
api/lovr/data/ModelData/getAnimationKeyframeCount.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the number of keyframes in a channel of an animation.',
   description = 'Returns the number of keyframes in a channel of an animation.',
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of an animation.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of an animation.'
+    animation = {
+      type = 'string | number',
+      description = 'The name or index of an animation.'
     },
     channel = {
       type = 'number',
@@ -23,11 +19,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index', 'channel' },
-      returns = { 'count' }
-    },
-    {
-      arguments = { 'name', 'channel' },
+      arguments = { 'animation', 'channel' },
       returns = { 'count' }
     }
   },

+ 3 - 4
api/lovr/data/ModelData/getAnimationName.lua

@@ -4,13 +4,13 @@ return {
   arguments = {
     index = {
       type = 'number',
-      description = 'The index of the animation.'
+      description = 'The index of an animation.'
     }
   },
   returns = {
     name = {
-      type = 'string',
-      description = 'The name of the animation.'
+      type = 'string | nil',
+      description = 'The name of the animation, or `nil` if the animation doesn\'t have a name.'
     }
   },
   variants = {
@@ -19,7 +19,6 @@ return {
       returns = { 'name' }
     }
   },
-  notes = 'If the animation does not have a name, this function returns `nil`.',
   related = {
     'Model:getAnimationName'
   }

+ 4 - 12
api/lovr/data/ModelData/getAnimationNode.lua

@@ -1,14 +1,10 @@
 return {
   summary = 'Get the node targeted by the channel of an animation.',
-  description = 'Returns the index of a node targeted by an animation\'s channel.',
+  description = 'Returns the index of the node targeted by an animation\'s channel.',
   arguments = {
-    index = {
+    animation = {
       type = 'number',
-      description = 'The index of an animation.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of an animation.'
+      description = 'The index or name of an animation.'
     },
     channel = {
       type = 'number',
@@ -23,11 +19,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index', 'channel' },
-      returns = { 'node' }
-    },
-    {
-      arguments = { 'name', 'channel' },
+      arguments = { 'animation', 'channel' },
       returns = { 'node' }
     }
   },

+ 5 - 13
api/lovr/data/ModelData/getAnimationProperty.lua

@@ -1,14 +1,10 @@
 return {
-  summary = 'Get the property targeted by the channel of an animation.',
+  summary = 'Get the property targeted by a channel of an animation.',
   description = 'Returns the property targeted by an animation\'s channel.',
   arguments = {
     index = {
-      type = 'number',
-      description = 'The index of an animation.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of an animation.'
+      type = 'string | number',
+      description = 'The name or index of an animation.'
     },
     channel = {
       type = 'number',
@@ -19,17 +15,13 @@ return {
     property = {
       type = 'AnimationProperty',
       description = [[
-        The property (translation, rotation, scale, weights) affected by the keyframes.
+        The property (translation, rotation, scale, or weights) affected by the keyframes.
       ]]
     }
   },
   variants = {
     {
-      arguments = { 'index', 'channel' },
-      returns = { 'property' }
-    },
-    {
-      arguments = { 'name', 'channel' },
+      arguments = { 'animation', 'channel' },
       returns = { 'property' }
     }
   },

+ 3 - 11
api/lovr/data/ModelData/getAnimationSmoothMode.lua

@@ -3,12 +3,8 @@ return {
   description = 'Returns the smooth mode of a channel in an animation.',
   arguments = {
     index = {
-      type = 'number',
-      description = 'The index of an animation.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of an animation.'
+      type = 'string | number',
+      description = 'The name or index of an animation.'
     },
     channel = {
       type = 'number',
@@ -23,11 +19,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index', 'channel' },
-      returns = { 'smooth' }
-    },
-    {
-      arguments = { 'name', 'channel' },
+      arguments = { 'animation', 'channel' },
       returns = { 'smooth' }
     }
   },

+ 14 - 23
api/lovr/data/ModelData/getMaterial.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the material properties for a material in the model.',
   description = 'Returns a table with all of the properties of a material.',
   arguments = {
-    index = {
+    material = {
       type = 'number',
-      description = 'The index of a material.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of a material.'
+      description = 'The name or index of a material.'
     }
   },
   returns = {
@@ -18,7 +14,7 @@ return {
       table = {
         {
           name = 'color',
-          type = 'table',
+          type = '{number}',
           description = [[
             The color of the material.  The table contains the `r`, `g`, `b`, and `a` components of the color,
             from 0 to 1.
@@ -26,7 +22,7 @@ return {
         },
         {
           name = 'glow',
-          type = 'table',
+          type = '{number}',
           description = [[
             The glow color of the material (sometimes called emissive).  The table contains the `r`,
             `g`, and `b` components of the color from 0 to 1, and a fourth number indicating the
@@ -35,12 +31,12 @@ return {
         },
         {
           name = 'uvShift',
-          type = 'table',
+          type = '{number}',
           description = 'A table with 2 numbers indicating an offset to apply to UVs.'
         },
         {
           name = 'uvScale',
-          type = 'table',
+          type = '{number}',
           description = [[
             A table with 2 numbers indicating a scale to apply to UVs.  By default, shaders apply
             the UV scale before the UV offset.
@@ -101,17 +97,17 @@ return {
         },
         {
           name = 'texture',
-          type = 'number',
+          type = 'number | nil',
           description = 'The index of the Image used for the color texture.',
         },
         {
           name = 'glowTexture',
-          type = 'number',
+          type = 'number | nil',
           description = 'The index of the Image used for the glow texture.',
         },
         {
           name = 'occlusionTexture',
-          type = 'number',
+          type = 'number | nil',
           description = [[
             The index of the Image used for the ambient occlusion texture.  The red channel of the
             texture is used for ambient occlusion, allowing multiple parameters to use the same
@@ -120,7 +116,7 @@ return {
         },
         {
           name = 'metalnessTexture',
-          type = 'number',
+          type = 'number | nil',
           description = [[
             The index of the Image used for the metalness texture.  The blue channel of the texture
             is used for metalness, allowing multiple parameters to use the same texture.
@@ -128,7 +124,7 @@ return {
         },
         {
           name = 'roughnessTexture',
-          type = 'number',
+          type = 'number | nil',
           description = [[
             The index of the Image to use for the roughness texture.  The green channel of the
             texture is used for roughness, allowing multiple parameters to use the same texture.
@@ -136,7 +132,7 @@ return {
         },
         {
           name = 'clearcoatTexture',
-          type = 'number',
+          type = 'number | nil',
           description = [[
             The index of the Image to use for the clearcoat texture.  The red channel of the texture
             is used for the clearcoat parameter, allowing multiple parameters to use the same
@@ -145,7 +141,7 @@ return {
         },
         {
           name = 'normalTexture',
-          type = 'number',
+          type = 'number | nil',
           description = 'The index of the Image to use for the normal map.'
         }
       }
@@ -153,15 +149,10 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'properties' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'material' },
       returns = { 'properties' }
     }
   },
-  notes = 'All images are optional and may be `nil`.',
   related = {
     'ModelData:getMaterialCount',
     'ModelData:getMeshMaterial',

+ 6 - 15
api/lovr/data/ModelData/getNodeChildren.lua

@@ -4,32 +4,23 @@ return {
     Given a parent node, this function returns a table with the indices of its children.
   ]],
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the parent node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the parent node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of the parent node.'
     }
   },
   returns = {
     children = {
-      type = 'table',
-      description = 'A table containing a node index for each child of the node.'
+      type = '{number}',
+      description = 'A table containing the node index of each child of the parent node.'
     }
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'children' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'children' }
     }
   },
-  notes = 'If the node does not have any children, this function returns an empty table.',
   related = {
     'ModelData:getNodeParent',
     'ModelData:getRootNode',

+ 4 - 12
api/lovr/data/ModelData/getNodeMeshes.lua

@@ -6,13 +6,9 @@ return {
     multiple meshes, and meshes can be reused in multiple nodes.
   ]],
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of a node.'
     }
   },
   returns = {
@@ -23,11 +19,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'meshes' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'meshes' }
     }
   },

+ 4 - 12
api/lovr/data/ModelData/getNodeOrientation.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the local orientation of a node.',
   description = 'Returns local orientation of a node, relative to its parent.',
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of a node.'
     }
   },
   returns = {
@@ -31,11 +27,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'angle', 'ax', 'ay', 'az' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'angle', 'ax', 'ay', 'az' }
     }
   },

+ 5 - 13
api/lovr/data/ModelData/getNodeParent.lua

@@ -2,28 +2,20 @@ return {
   summary = 'Get the parent of a node.',
   description = 'Given a child node, this function returns the index of its parent.',
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the child node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the child node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of the child node.'
     }
   },
   returns = {
     parent = {
       type = 'number',
-      description = 'The index of the parent.'
+      description = 'The index of the parent node.'
     }
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'parent' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'parent' }
     }
   },

+ 4 - 12
api/lovr/data/ModelData/getNodePose.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the local pose of a node.',
   description = 'Returns local pose (position and orientation) of a node, relative to its parent.',
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of a node.'
     }
   },
   returns = {
@@ -43,11 +39,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'x', 'y', 'z', 'angle', 'ax', 'ay', 'az' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'x', 'y', 'z', 'angle', 'ax', 'ay', 'az' }
     }
   },

+ 4 - 12
api/lovr/data/ModelData/getNodePosition.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the local position of a node.',
   description = 'Returns local position of a node, relative to its parent.',
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of a node.'
     }
   },
   returns = {
@@ -27,11 +23,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'x', 'y', 'z' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'x', 'y', 'z' }
     }
   },

+ 4 - 12
api/lovr/data/ModelData/getNodeScale.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the local scale of a node.',
   description = 'Returns local scale of a node, relative to its parent.',
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of a node.'
     }
   },
   returns = {
@@ -27,11 +23,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'sx', 'sy', 'sz' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'sx', 'sy', 'sz' }
     }
   },

+ 4 - 12
api/lovr/data/ModelData/getNodeSkin.lua

@@ -6,13 +6,9 @@ return {
     animation of its meshes.
   ]],
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of a node.'
     }
   },
   returns = {
@@ -23,11 +19,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'skin' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'skin' }
     }
   },

+ 4 - 12
api/lovr/data/ModelData/getNodeTransform.lua

@@ -4,13 +4,9 @@ return {
     Returns local transform (position, orientation, and scale) of a node, relative to its parent.
   ]],
   arguments = {
-    index = {
-      type = 'number',
-      description = 'The index of the node.'
-    },
-    name = {
-      type = 'string',
-      description = 'The name of the node.'
+    node = {
+      type = 'string | number',
+      description = 'The name or index of a node.'
     }
   },
   returns = {
@@ -57,11 +53,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'index' },
-      returns = { 'x', 'y', 'z', 'sx', 'sy', 'sz', 'angle', 'ax', 'ay', 'az' }
-    },
-    {
-      arguments = { 'name' },
+      arguments = { 'node' },
       returns = { 'x', 'y', 'z', 'sx', 'sy', 'sz', 'angle', 'ax', 'ay', 'az' }
     }
   },

+ 0 - 1
api/lovr/data/ModelData/getSkinCount.lua

@@ -17,7 +17,6 @@ return {
       returns = { 'count' }
     }
   },
-  notes = 'There is currently a maximum of 256 skins.',
   related = {
     'Model:hasJoints'
   }

+ 1 - 0
api/lovr/data/ModelData/getSkinJoints.lua

@@ -13,6 +13,7 @@ return {
       description = 'The joints in the skin.'
     }
   },
+  notes = 'There is currently a maximum of 256 joints per skin.',
   variants = {
     {
       arguments = { 'skin' },

+ 11 - 13
api/lovr/data/Rasterizer/getAdvance.lua

@@ -5,13 +5,9 @@ return {
     advance the cursor after rendering the glyph.
   ]],
   arguments = {
-    character = {
-      type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+    glyph = {
+      type = 'string | number',
+      description = 'A character or codepoint.'
     }
   },
   returns = {
@@ -22,12 +18,14 @@ return {
   },
   variants = {
     {
-      arguments = { 'character' },
-      returns = { 'advance' }
-    },
-    {
-      arguments = { 'codepoint' },
+      arguments = { 'glyph' },
       returns = { 'advance' }
     }
-  }
+  },
+  example = [[
+    local rasterizer = lovr.data.newRasterizer()
+    local advance1 = rasterizer:getAdvance('H') + rasterizer:getAdvance('i')
+    local advance2 = rasterizer:getAdvance(72) + rasterizer:getAdvance(105)
+    assert(advance1 == advance2)
+  ]]
 }

+ 11 - 13
api/lovr/data/Rasterizer/getBearing.lua

@@ -5,13 +5,9 @@ return {
     the cursor to the edge of the glyph.
   ]],
   arguments = {
-    character = {
-      type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+    glyph = {
+      type = 'string | number',
+      description = 'A character or codepoint.'
     }
   },
   returns = {
@@ -22,12 +18,14 @@ return {
   },
   variants = {
     {
-      arguments = { 'character' },
-      returns = { 'bearing' }
-    },
-    {
-      arguments = { 'codepoint' },
+      arguments = { 'glyph' },
       returns = { 'bearing' }
     }
-  }
+  },
+  example = [[
+    local rasterizer = lovr.data.newRasterizer()
+
+    -- In the default font, H is wider than i
+    assert(rasterizer:getBearing('H') > rasterizer:getBearing('i'))
+  ]]
 }

+ 6 - 12
api/lovr/data/Rasterizer/getBoundingBox.lua

@@ -5,13 +5,9 @@ return {
     coordinates use a cartesian "y up" coordinate system.
   ]],
   arguments = {
-    character = {
-      type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+    glyph = {
+      type = 'string | number',
+      description = 'A character or codepoint.'
     }
   },
   returns = {
@@ -34,14 +30,12 @@ return {
   },
   variants = {
     {
-      arguments = { 'character' },
-      returns = { 'x1', 'y1', 'x2', 'y2' }
-    },
-    {
-      arguments = { 'codepoint' },
+      description = 'Get the bounding box of a single glyph.',
+      arguments = { 'glyph' },
       returns = { 'x1', 'y1', 'x2', 'y2' }
     },
     {
+      description = 'Get the bounding box around all glyphs in the font.',
       arguments = {},
       returns = { 'x1', 'y1', 'x2', 'y2' }
     }

+ 4 - 12
api/lovr/data/Rasterizer/getCurves.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get the bezier curves defining a glyph.',
   description = 'Returns the bezier curve control points defining the shape of a glyph.',
   arguments = {
-    character = {
-      type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+    glyph = {
+      type = 'string | number',
+      description = 'A character or codepoint.'
     },
     three = {
       type = 'boolean',
@@ -26,11 +22,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'character', 'three' },
-      returns = { 'curves' }
-    },
-    {
-      arguments = { 'codepoint', 'three' },
+      arguments = { 'glyph', 'three' },
       returns = { 'curves' }
     }
   },

+ 6 - 12
api/lovr/data/Rasterizer/getDimensions.lua

@@ -1,14 +1,12 @@
 return {
   summary = 'Get the dimensions of a glyph, or the font.',
-  description = 'Returns the dimensions of a glyph, or the dimensions of any glyph.',
+  description = [[
+    Returns the dimensions of a glyph, or the largest dimensions of any glyph in the font.
+  ]],
   arguments = {
-    character = {
+    glyph = {
       type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+      description = 'A character or codepoint.'
     }
   },
   returns = {
@@ -23,11 +21,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'character' },
-      returns = { 'width', 'height' }
-    },
-    {
-      arguments = { 'codepoint' },
+      arguments = { 'glyph' },
       returns = { 'width', 'height' }
     },
     {

+ 1 - 1
api/lovr/data/Rasterizer/getFontSize.lua

@@ -2,7 +2,7 @@ return {
   summary = 'Get the size of the font.',
   description = [[
     Returns the size of the font, in pixels.  This is the size the rasterizer was created with, and
-    defines the size of images it rasterizes.
+    determines the size of images it rasterizes.
   ]],
   arguments = {},
   returns = {

+ 5 - 13
api/lovr/data/Rasterizer/getHeight.lua

@@ -1,14 +1,10 @@
 return {
   summary = 'Get the height of a glyph, or the font.',
-  description = 'Returns the height of a glyph, or the maximum height of any glyph.',
+  description = 'Returns the height of a glyph, or the maximum height of any glyph in the font.',
   arguments = {
-    character = {
-      type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+    glyph = {
+      type = 'string | number',
+      description = 'A character or codepoint.'
     }
   },
   returns = {
@@ -19,11 +15,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'character' },
-      returns = { 'height' }
-    },
-    {
-      arguments = { 'codepoint' },
+      arguments = { 'glyph' },
       returns = { 'height' }
     },
     {

+ 4 - 25
api/lovr/data/Rasterizer/getKerning.lua

@@ -6,21 +6,12 @@ return {
   ]],
   arguments = {
     first = {
-      type = 'string',
-      description = 'The first character.'
-    },
-    firstCodepoint = {
-      type = 'number',
-      description = 'The first codepoint.'
+      type = 'string | number',
+      description = 'The character or codepoint representing the first glyph.'
     },
     second = {
-      type = 'string',
-      description = 'The second character.'
-    },
-    secondCodepoint = {
-      name = 'secondCodepoint',
-      type = 'number',
-      description = 'The second codepoint.'
+      type = 'string | number',
+      description = 'The character or codepoint representing the second glyph.'
     }
   },
   returns = {
@@ -33,18 +24,6 @@ return {
     {
       arguments = { 'first', 'second' },
       returns = { 'keming' }
-    },
-    {
-      arguments = { 'firstCodepoint', 'second' },
-      returns = { 'keming' }
-    },
-    {
-      arguments = { 'first', 'secondCodepoint' },
-      returns = { 'keming' }
-    },
-    {
-      arguments = { 'firstCodepoint', 'secondCodepoint' },
-      returns = { 'keming' }
     }
   },
   related = {

+ 5 - 13
api/lovr/data/Rasterizer/getWidth.lua

@@ -1,14 +1,10 @@
 return {
   summary = 'Get the width of a glyph, or the font.',
-  description = 'Returns the width of a glyph, or the maximum width of any glyph.',
+  description = 'Returns the width of a glyph, or the maximum width of any glyph in the font.',
   arguments = {
-    character = {
-      type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+    glyph = {
+      type = 'string | number',
+      description = 'A character or codepoint.'
     }
   },
   returns = {
@@ -19,11 +15,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'character' },
-      returns = { 'width' }
-    },
-    {
-      arguments = { 'codepoint' },
+      arguments = { 'glyph' },
       returns = { 'width' }
     },
     {

+ 13 - 2
api/lovr/data/Rasterizer/hasGlyphs.lua

@@ -3,8 +3,8 @@ return {
   description = 'Returns whether the Rasterizer can rasterize a set of glyphs.',
   arguments = {
     ['...'] = {
-      type = '*',
-      description = 'Strings (sets of characters) or numbers (character codes) to check for.'
+      type = 'string | number',
+      description = 'Strings (characters) or numbers (codepoints) to check for.'
     }
   },
   returns = {
@@ -21,6 +21,17 @@ return {
       returns = { 'hasGlyphs' }
     }
   },
+  example = [[
+    rasterizer = lovr.data.newRasterizer()
+
+    function lovr.draw(pass)
+      if rasterizer:hasGlyphs('Ö') then
+        pass:text('LÖVR!!!', 0, 2, -3)
+      else
+        pass:text('>:(', 0, 2, -3)
+      end
+    end
+  ]],
   related = {
     'Rasterizer:getGlyphCount'
   }

+ 4 - 12
api/lovr/data/Rasterizer/newImage.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Get an Image of a rasterized glyph.',
   description = 'Returns an `Image` containing a rasterized glyph.',
   arguments = {
-    character = {
-      type = 'string',
-      description = 'A character.'
-    },
-    codepoint = {
-      type = 'number',
-      description = 'A codepoint.'
+    glyph = {
+      type = 'string | number',
+      description = 'A character or codepoint to rasterize.'
     },
     spread = {
       type = 'number',
@@ -29,11 +25,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'character', 'spread', 'padding' },
-      returns = { 'image' }
-    },
-    {
-      arguments = { 'codepoint', 'spread', 'padding' },
+      arguments = { 'glyph', 'spread', 'padding' },
       returns = { 'image' }
     }
   },

+ 1 - 1
api/lovr/data/Sound/getFrames.lua

@@ -41,7 +41,7 @@ return {
   },
   returns = {
     t = {
-      type = 'table',
+      type = '{number}',
       description = 'A table containing audio frames.'
     },
     count = {

+ 4 - 20
api/lovr/data/Sound/setFrames.lua

@@ -2,17 +2,9 @@ return {
   summary = 'Write frames to the Sound.',
   description = 'Writes frames to the Sound.',
   arguments = {
-    t = {
-      type = 'table',
-      description = 'A table containing frames to write.'
-    },
-    blob = {
-      type = 'Blob',
-      description = 'A Blob containing frames to write.'
-    },
-    sound = {
-      type = 'Sound',
-      description = 'Another Sound to copy frames from.'
+    source = {
+      type = 'table | Blob | Sound',
+      description = 'A table, Blob, or Sound containing audio frames to write.'
     },
     count = {
       type = 'number',
@@ -38,15 +30,7 @@ return {
   },
   variants = {
     {
-      arguments = { 't', 'count', 'dstOffset', 'srcOffset' },
-      returns = { 'count' }
-    },
-    {
-      arguments = { 'blob', 'count', 'dstOffset', 'srcOffset' },
-      returns = { 'count' }
-    },
-    {
-      arguments = { 'sound', 'count', 'dstOffset', 'srcOffset' },
+      arguments = { 'source', 'count', 'dstOffset', 'srcOffset' },
       returns = { 'count' }
     }
   },

+ 6 - 15
api/lovr/data/newImage.lua

@@ -1,8 +1,8 @@
 return {
   summary = 'Create a new Image.',
   description = [[
-    Creates a new Image.  Image data can be loaded and decoded from an image file, or a raw block of
-    pixels with a specified width, height, and format can be created.
+    Creates a new Image.  Image data can be loaded and decoded from an image file.  Alternatively, a
+    blank image can be created with a given width, height, and format.
   ]],
   arguments = {
     width = {
@@ -18,13 +18,9 @@ return {
       default = 'rgba8',
       description = 'The format of the texture\'s pixels.'
     },
-    filename = {
-      type = 'string',
-      description = 'The filename of the image to load.'
-    },
-    blob = {
-      type = 'Blob',
-      description = 'The Blob containing image data to decode.'
+    file = {
+      type = 'string | Blob',
+      description = 'A filename or Blob containing an image file to load.'
     },
     data = {
       type = 'Blob',
@@ -45,7 +41,7 @@ return {
   variants = {
     {
       description = 'Load image data from a file.',
-      arguments = { 'filename' },
+      arguments = { 'file' },
       returns = { 'image' }
     },
     {
@@ -57,11 +53,6 @@ return {
       description = 'Clone an existing Image.',
       arguments = { 'source' },
       returns = { 'image' }
-    },
-    {
-      description = 'Decode image data from a Blob.',
-      arguments = { 'blob' },
-      returns = { 'image' }
     }
   },
   notes = [[

+ 4 - 12
api/lovr/data/newModelData.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Create a new ModelData.',
   description = 'Loads a 3D model from a file.  The supported 3D file formats are OBJ and glTF.',
   arguments = {
-    filename = {
-      type = 'string',
-      description = 'The filename of the model to load.'
-    },
-    blob = {
-      type = 'Blob',
-      description = 'The Blob containing data for a model to decode.'
+    file = {
+      type = 'string | Blob',
+      description = 'A filename or Blob containing the model data to import.'
     }
   },
   returns = {
@@ -19,11 +15,7 @@ return {
   },
   variants = {
     {
-      arguments = { 'filename' },
-      returns = { 'modelData' }
-    },
-    {
-      arguments = { 'blob' },
+      arguments = { 'file' },
       returns = { 'modelData' }
     }
   }

+ 6 - 14
api/lovr/data/newRasterizer.lua

@@ -2,13 +2,9 @@ return {
   summary = 'Create a new Rasterizer.',
   description = 'Creates a new Rasterizer from a TTF or BMFont file.',
   arguments = {
-    filename = {
-      type = 'string',
-      description = 'The filename of the font file to load.'
-    },
-    blob = {
-      type = 'Blob',
-      description = 'The Blob containing font data.'
+    file = {
+      type = 'string | Blob',
+      description = 'A filename or Blob containing the font file to load.'
     },
     size = {
       type = 'number',
@@ -28,16 +24,12 @@ return {
   },
   variants = {
     {
-      description = 'Create a Rasterizer for the default font included with LÖVR (Varela Round).',
-      arguments = { 'size' },
-      returns = { 'rasterizer' }
-    },
-    {
-      arguments = { 'filename', 'size' },
+      arguments = { 'file', 'size' },
       returns = { 'rasterizer' }
     },
     {
-      arguments = { 'blob', 'size' },
+      description = 'Create a Rasterizer for the default font included with LÖVR (Varela Round).',
+      arguments = { 'size' },
       returns = { 'rasterizer' }
     }
   }

+ 10 - 20
api/lovr/data/newSound.lua

@@ -33,23 +33,20 @@ return {
       description = 'The sample rate, in Hz.'
     },
     contents = {
-      type = '*',
+      type = [[Blob | 'stream' | nil]],
       default = 'nil',
       description = [[
         A Blob containing raw audio samples to use as the initial contents, 'stream' to create an
         audio stream, or `nil` to leave the data initialized to zero.
       ]]
     },
-    filename = {
-      type = 'string',
-      description = 'The filename of a sound to load.'
-    },
-    blob = {
-      type = 'Blob',
-      description = 'The Blob containing audio file data to load.'
+    file = {
+      type = 'string | Blob',
+      description = 'A filename or Blob containing a sound file to load.'
     },
     decode = {
       type = 'boolean',
+      default = 'false',
       description = 'Whether compressed audio files should be immediately decoded.'
     }
   },
@@ -67,20 +64,13 @@ return {
     },
     {
       description = [[
-        Load a sound from a file.  Compressed audio formats (OGG, MP3) can optionally be decoded
-        into raw sounds.
-      ]],
-      arguments = { 'filename', 'decode' },
-      returns = { 'sound' }
-    },
-    {
-      description = [[
-        Load a sound from a Blob containing the data of an audio file.  Compressed audio formats
-        (OGG, MP3) can optionally be decoded into raw sounds.
+        Load a sound from a filename or Blob containing the data of an audio file.  Compressed audio
+        formats (OGG, MP3) can optionally be decoded into raw sounds.
 
-        If the Blob contains raw audio samples, use the first variant instead of this one.
+        If you want to load a Blob containing raw audio samples, use the first variant of this
+        function and pass the Blob as the `contents`.
       ]],
-      arguments = { 'blob', 'decode' },
+      arguments = { 'file', 'decode' },
       returns = { 'sound' }
     }
   },

+ 2 - 2
api/lovr/graphics/Model/getAnimationName.lua

@@ -9,8 +9,8 @@ return {
   },
   returns = {
     name = {
-      type = 'string',
-      description = 'The name of the animation.'
+      type = 'string | nil',
+      description = 'The name of the animation, or `nil` if the animation doesn\'t have a name.'
     }
   },
   variants = {

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác