bjorn 1 年之前
父节点
当前提交
8182dd555a
共有 40 个文件被更改,包括 777 次插入378 次删除
  1. 490 259
      api/init.lua
  2. 7 2
      api/lovr/callbacks/conf.lua
  3. 8 4
      api/lovr/callbacks/draw.lua
  4. 8 4
      api/lovr/callbacks/errhand.lua
  5. 7 2
      api/lovr/callbacks/focus.lua
  6. 9 6
      api/lovr/callbacks/keypressed.lua
  7. 8 4
      api/lovr/callbacks/keyreleased.lua
  8. 7 2
      api/lovr/callbacks/load.lua
  9. 9 6
      api/lovr/callbacks/log.lua
  10. 8 4
      api/lovr/callbacks/mirror.lua
  11. 10 8
      api/lovr/callbacks/mousemoved.lua
  12. 9 6
      api/lovr/callbacks/mousepressed.lua
  13. 9 6
      api/lovr/callbacks/mousereleased.lua
  14. 8 4
      api/lovr/callbacks/permission.lua
  15. 7 2
      api/lovr/callbacks/quit.lua
  16. 6 0
      api/lovr/callbacks/recenter.lua
  17. 8 4
      api/lovr/callbacks/resize.lua
  18. 7 2
      api/lovr/callbacks/restart.lua
  19. 7 2
      api/lovr/callbacks/run.lua
  20. 9 5
      api/lovr/callbacks/textinput.lua
  21. 8 4
      api/lovr/callbacks/threaderror.lua
  22. 7 2
      api/lovr/callbacks/update.lua
  23. 7 2
      api/lovr/callbacks/visible.lua
  24. 8 4
      api/lovr/callbacks/wheelmoved.lua
  25. 10 11
      api/lovr/physics/Collider/getInertia.lua
  26. 2 2
      api/lovr/physics/Collider/getTag.lua
  27. 1 0
      api/lovr/physics/Collider/setInertia.lua
  28. 4 0
      api/lovr/physics/ConeJoint/init.lua
  29. 1 1
      api/lovr/physics/ConvexShape/getPointCount.lua
  30. 4 0
      api/lovr/physics/ConvexShape/init.lua
  31. 1 1
      api/lovr/physics/HingeJoint/setLimits.lua
  32. 60 1
      api/lovr/physics/Shape/getInertia.lua
  33. 6 0
      api/lovr/physics/Shape/isDestroyed.lua
  34. 4 0
      api/lovr/physics/WeldJoint/init.lua
  35. 0 3
      api/lovr/physics/World/overlapShape.lua
  36. 2 2
      api/lovr/physics/World/raycast.lua
  37. 2 2
      api/lovr/physics/World/setCallbacks.lua
  38. 1 1
      api/lovr/physics/World/shapecast.lua
  39. 0 4
      api/lovr/physics/newWorld.lua
  40. 8 6
      api/main.lua

文件差异内容过多而无法显示
+ 490 - 259
api/init.lua


+ 7 - 2
api/lovr/callbacks/conf.lua

@@ -7,8 +7,7 @@ return {
     file that's loaded before the rest of the framework initializes.
     file that's loaded before the rest of the framework initializes.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 't',
+    t = {
       type = 'table',
       type = 'table',
       description = 'The table to edit the configuration settings on.',
       description = 'The table to edit the configuration settings on.',
       table = {
       table = {
@@ -252,6 +251,12 @@ return {
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 't' },
+      returns = {}
+    }
+  },
   notes = [[
   notes = [[
     Disabling unused modules can improve startup time.
     Disabling unused modules can improve startup time.
 
 

+ 8 - 4
api/lovr/callbacks/draw.lua

@@ -7,19 +7,23 @@ return {
     the headset display, otherwise it will render to the desktop window.
     the headset display, otherwise it will render to the desktop window.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'pass',
+    pass = {
       type = 'Pass',
       type = 'Pass',
       description = 'A render pass targeting the main display (headset or window).'
       description = 'A render pass targeting the main display (headset or window).'
     }
     }
   },
   },
   returns = {
   returns = {
-    {
-      name = 'skip',
+    skip = {
       type = 'boolean',
       type = 'boolean',
       description = 'If truthy, the input Pass will not be submitted to the GPU.'
       description = 'If truthy, the input Pass will not be submitted to the GPU.'
     }
     }
   },
   },
+  variants = {
+    {
+      arguments = { 'pass' },
+      returns = { 'skip' }
+    }
+  },
   notes = [[
   notes = [[
     To render to the desktop window when a VR headset is connected, use the `lovr.mirror` callback.
     To render to the desktop window when a VR headset is connected, use the `lovr.mirror` callback.
 
 

+ 8 - 4
api/lovr/callbacks/errhand.lua

@@ -16,15 +16,13 @@ return {
     to the window.
     to the window.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'message',
+    message = {
       type = 'string',
       type = 'string',
       description = 'The error message.'
       description = 'The error message.'
     }
     }
   },
   },
   returns = {
   returns = {
-    {
-      name = 'handler',
+    handler = {
       type = 'function',
       type = 'function',
       arguments = {},
       arguments = {},
       returns = {
       returns = {
@@ -39,6 +37,12 @@ return {
       ]]
       ]]
     }
     }
   },
   },
+  variants = {
+    {
+      arguments = { 'message' },
+      returns = { 'handler' }
+    }
+  },
   example = {
   example = {
     description = 'The default error handler.',
     description = 'The default error handler.',
     code = [[
     code = [[

+ 7 - 2
api/lovr/callbacks/focus.lua

@@ -8,13 +8,18 @@ return {
     make sense to pause the game or reduce visual fidelity when the application loses focus.
     make sense to pause the game or reduce visual fidelity when the application loses focus.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'focused',
+    focused = {
       type = 'boolean',
       type = 'boolean',
       description = 'Whether the program is now focused.'
       description = 'Whether the program is now focused.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'focused' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.headset.isFocused',
     'lovr.headset.isFocused',
     'lovr.visible'
     'lovr.visible'

+ 9 - 6
api/lovr/callbacks/keypressed.lua

@@ -3,23 +3,26 @@ return {
   summary = 'Called when a key is pressed.',
   summary = 'Called when a key is pressed.',
   description = 'This callback is called when a key is pressed.',
   description = 'This callback is called when a key is pressed.',
   arguments = {
   arguments = {
-    {
-      name = 'key',
+    key = {
       type = 'KeyCode',
       type = 'KeyCode',
       description = 'The key that was pressed.'
       description = 'The key that was pressed.'
     },
     },
-    {
-      name = 'scancode',
+    scancode = {
       type = 'number',
       type = 'number',
       description = 'The id of the key (ignores keyboard layout, may vary between keyboards).'
       description = 'The id of the key (ignores keyboard layout, may vary between keyboards).'
     },
     },
-    {
-      name = 'repeating',
+    ['repeat'] = {
       type = 'boolean',
       type = 'boolean',
       description = 'Whether the event is the result of a key repeat instead of an actual press.'
       description = 'Whether the event is the result of a key repeat instead of an actual press.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'key', 'scancode', 'repeat' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.system.wasKeyPressed',
     'lovr.system.wasKeyPressed',
     'lovr.keyreleased',
     'lovr.keyreleased',

+ 8 - 4
api/lovr/callbacks/keyreleased.lua

@@ -3,18 +3,22 @@ return {
   summary = 'Called when a key is released.',
   summary = 'Called when a key is released.',
   description = 'This callback is called when a key is released.',
   description = 'This callback is called when a key is released.',
   arguments = {
   arguments = {
-    {
-      name = 'key',
+    key = {
       type = 'KeyCode',
       type = 'KeyCode',
       description = 'The key that was released.'
       description = 'The key that was released.'
     },
     },
-    {
-      name = 'scancode',
+    scancode = {
       type = 'number',
       type = 'number',
       description = 'The id of the key (ignores keyboard layout, may vary between keyboards).'
       description = 'The id of the key (ignores keyboard layout, may vary between keyboards).'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'key', 'scancode' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.system.wasKeyReleased',
     'lovr.system.wasKeyReleased',
     'lovr.keypressed',
     'lovr.keypressed',

+ 7 - 2
api/lovr/callbacks/load.lua

@@ -6,13 +6,18 @@ return {
     work, like loading resources and initializing classes and variables.
     work, like loading resources and initializing classes and variables.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'arg',
+    arg = {
       type = 'table',
       type = 'table',
       description = 'The command line arguments provided to the program.'
       description = 'The command line arguments provided to the program.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'arg' },
+      returns = {}
+    }
+  },
   example = [[
   example = [[
     function lovr.load(arg)
     function lovr.load(arg)
       model = lovr.graphics.newModel('sponza.gltf')
       model = lovr.graphics.newModel('sponza.gltf')

+ 9 - 6
api/lovr/callbacks/log.lua

@@ -14,23 +14,26 @@ return {
     by calling the callback.
     by calling the callback.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'message',
+    message = {
       type = 'string',
       type = 'string',
       description = 'The log message.  It may end in a newline.'
       description = 'The log message.  It may end in a newline.'
     },
     },
-    {
-      name = 'level',
+    level = {
       type = 'string',
       type = 'string',
       description = 'The log level (`debug`, `info`, `warn`, or `error`).'
       description = 'The log level (`debug`, `info`, `warn`, or `error`).'
     },
     },
-    {
-      name = 'tag',
+    tag = {
       type = 'string',
       type = 'string',
       description = 'The log tag.'
       description = 'The log tag.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'message', 'level', 'tag' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'Pass:text'
     'Pass:text'
   }
   }

+ 8 - 4
api/lovr/callbacks/mirror.lua

@@ -8,19 +8,23 @@ return {
     HUD could be rendered.
     HUD could be rendered.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'pass',
+    pass = {
       type = 'Pass',
       type = 'Pass',
       description = 'A render pass targeting the window.'
       description = 'A render pass targeting the window.'
     }
     }
   },
   },
   returns = {
   returns = {
-    {
-      name = 'skip',
+    skip = {
       type = 'boolean',
       type = 'boolean',
       description = 'If truthy, the input Pass will not be submitted to the GPU.'
       description = 'If truthy, the input Pass will not be submitted to the GPU.'
     }
     }
   },
   },
+  variants = {
+    {
+      arguments = { 'pass' },
+      returns = { 'skip' }
+    }
+  },
   example = {
   example = {
     description = [[
     description = [[
       The default `lovr.mirror` implementation draws the headset mirror texture to the window if
       The default `lovr.mirror` implementation draws the headset mirror texture to the window if

+ 10 - 8
api/lovr/callbacks/mousemoved.lua

@@ -3,28 +3,30 @@ return {
   summary = 'Called when the mouse is moved.',
   summary = 'Called when the mouse is moved.',
   description = 'This callback is called when the mouse is moved.',
   description = 'This callback is called when the mouse is moved.',
   arguments = {
   arguments = {
-    {
-      name = 'x',
+    x = {
       type = 'number',
       type = 'number',
       description = 'The new x position of the mouse.'
       description = 'The new x position of the mouse.'
     },
     },
-    {
-      name = 'y',
+    y = {
       type = 'number',
       type = 'number',
       description = 'The new y position of the mouse.'
       description = 'The new y position of the mouse.'
     },
     },
-    {
-      name = 'dx',
+    dx = {
       type = 'number',
       type = 'number',
       description = 'The movement on the x axis since the last mousemove event.'
       description = 'The movement on the x axis since the last mousemove event.'
     },
     },
-    {
-      name = 'dy',
+    dy = {
       type = 'number',
       type = 'number',
       description = 'The movement on the y axis since the last mousemove event.'
       description = 'The movement on the y axis since the last mousemove event.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'dx', 'dy' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.mousepressed',
     'lovr.mousepressed',
     'lovr.mousereleased',
     'lovr.mousereleased',

+ 9 - 6
api/lovr/callbacks/mousepressed.lua

@@ -3,18 +3,15 @@ return {
   summary = 'Called when a mouse button is pressed.',
   summary = 'Called when a mouse button is pressed.',
   description = 'This callback is called when a mouse button is pressed.',
   description = 'This callback is called when a mouse button is pressed.',
   arguments = {
   arguments = {
-    {
-      name = 'x',
+    x = {
       type = 'number',
       type = 'number',
       description = 'The x position of the mouse when the button was pressed.'
       description = 'The x position of the mouse when the button was pressed.'
     },
     },
-    {
-      name = 'y',
+    y = {
       type = 'number',
       type = 'number',
       description = 'The y position of the mouse when the button was pressed.'
       description = 'The y position of the mouse when the button was pressed.'
     },
     },
-    {
-      name = 'button',
+    button = {
       type = 'number',
       type = 'number',
       description = [[
       description = [[
         The button that was pressed.  Will be 1 for the primary button, 2 for the secondary button,
         The button that was pressed.  Will be 1 for the primary button, 2 for the secondary button,
@@ -23,6 +20,12 @@ return {
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'button' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.mousereleased',
     'lovr.mousereleased',
     'lovr.mousemoved',
     'lovr.mousemoved',

+ 9 - 6
api/lovr/callbacks/mousereleased.lua

@@ -3,18 +3,15 @@ return {
   summary = 'Called when a mouse button is released.',
   summary = 'Called when a mouse button is released.',
   description = 'This callback is called when a mouse button is released.',
   description = 'This callback is called when a mouse button is released.',
   arguments = {
   arguments = {
-    {
-      name = 'x',
+    x = {
       type = 'number',
       type = 'number',
       description = 'The x position of the mouse when the button was released.'
       description = 'The x position of the mouse when the button was released.'
     },
     },
-    {
-      name = 'y',
+    y = {
       type = 'number',
       type = 'number',
       description = 'The y position of the mouse when the button was released.'
       description = 'The y position of the mouse when the button was released.'
     },
     },
-    {
-      name = 'button',
+    button = {
       type = 'number',
       type = 'number',
       description = [[
       description = [[
         The button that was released.  Will be 1 for the primary button, 2 for the secondary button,
         The button that was released.  Will be 1 for the primary button, 2 for the secondary button,
@@ -23,6 +20,12 @@ return {
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'button' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.mousepressed',
     'lovr.mousepressed',
     'lovr.mousemoved',
     'lovr.mousemoved',

+ 8 - 4
api/lovr/callbacks/permission.lua

@@ -7,18 +7,22 @@ return {
     granted or denied.
     granted or denied.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'permission',
+    permission = {
       type = 'Permission',
       type = 'Permission',
       description = 'The type of permission.'
       description = 'The type of permission.'
     },
     },
-    {
-      name = 'granted',
+    granted = {
       type = 'boolean',
       type = 'boolean',
       description = 'Whether permission was granted or denied.'
       description = 'Whether permission was granted or denied.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'permission', 'granted' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.system.requestPermission'
     'lovr.system.requestPermission'
   }
   }

+ 7 - 2
api/lovr/callbacks/quit.lua

@@ -7,12 +7,17 @@ return {
   ]],
   ]],
   arguments = {},
   arguments = {},
   returns = {
   returns = {
-    {
+    abort = {
       type = 'boolean',
       type = 'boolean',
-      name = 'abort',
       description = 'Whether quitting should be aborted.'
       description = 'Whether quitting should be aborted.'
     }
     }
   },
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'abort' }
+    }
+  },
   example = [[
   example = [[
     function lovr.quit()
     function lovr.quit()
       if shouldQuit() then
       if shouldQuit() then

+ 6 - 0
api/lovr/callbacks/recenter.lua

@@ -10,6 +10,12 @@ return {
   ]],
   ]],
   arguments = {},
   arguments = {},
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = {},
+      returns = {}
+    }
+  },
   notes = [[
   notes = [[
     Note that the pose of the `floor` device will not always be at the origin of the coordinate
     Note that the pose of the `floor` device will not always be at the origin of the coordinate
     space.  It uses a fixed position on the floor in the real world, usually the center of the
     space.  It uses a fixed position on the floor in the real world, usually the center of the

+ 8 - 4
api/lovr/callbacks/resize.lua

@@ -3,18 +3,22 @@ return {
   summary = 'Called when the window is resized.',
   summary = 'Called when the window is resized.',
   description = 'This callback is called when the desktop window is resized.',
   description = 'This callback is called when the desktop window is resized.',
   arguments = {
   arguments = {
-    {
-      name = 'width',
+    width = {
       type = 'number',
       type = 'number',
       description = 'The new width of the window.'
       description = 'The new width of the window.'
     },
     },
-    {
-      name = 'height',
+    height = {
       type = 'number',
       type = 'number',
       description = 'The new height of the window.'
       description = 'The new height of the window.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'width', 'height' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'Pass:getDimensions',
     'Pass:getDimensions',
     'Pass:getWidth',
     'Pass:getWidth',

+ 7 - 2
api/lovr/callbacks/restart.lua

@@ -9,12 +9,17 @@ return {
   ]],
   ]],
   arguments = {},
   arguments = {},
   returns = {
   returns = {
-    {
+    cookie = {
       type = '*',
       type = '*',
-      name = 'cookie',
       description = 'The value to send to the next `lovr.load`.'
       description = 'The value to send to the next `lovr.load`.'
     }
     }
   },
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'cookie' }
+    }
+  },
   notes = [[
   notes = [[
     Only nil, booleans, numbers, and strings are supported types for the return value.
     Only nil, booleans, numbers, and strings are supported types for the return value.
   ]],
   ]],

+ 7 - 2
api/lovr/callbacks/run.lua

@@ -7,8 +7,7 @@ return {
   ]],
   ]],
   arguments = {},
   arguments = {},
   returns = {
   returns = {
-    {
-      name = 'loop',
+    loop = {
       type = 'function',
       type = 'function',
       arguments = {},
       arguments = {},
       returns = {
       returns = {
@@ -20,6 +19,12 @@ return {
       description = 'The main loop function.'
       description = 'The main loop function.'
     }
     }
   },
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'loop' }
+    }
+  },
   notes = [[
   notes = [[
     The main loop function can return one of the following values:
     The main loop function can return one of the following values:
 
 

+ 9 - 5
api/lovr/callbacks/textinput.lua

@@ -8,24 +8,28 @@ return {
     called with `!`.
     called with `!`.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'text',
+    text = {
       type = 'string',
       type = 'string',
       description = 'The UTF-8 encoded character.'
       description = 'The UTF-8 encoded character.'
     },
     },
-    {
-      name = 'code',
+    code = {
       type = 'number',
       type = 'number',
       description = 'The integer codepoint of the character.'
       description = 'The integer codepoint of the character.'
     }
     }
   },
   },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'text', 'code' },
+      returns = {}
+    }
+  },
   notes = [[
   notes = [[
     Some characters in UTF-8 unicode take multiple bytes to encode.  Due to the way Lua works, the
     Some characters in UTF-8 unicode take multiple bytes to encode.  Due to the way Lua works, the
     length of these strings will be bigger than 1 even though they are just a single character.  The
     length of these strings will be bigger than 1 even though they are just a single character.  The
     `utf8` library included with LÖVR can be used to manipulate UTF-8 strings.  `Pass:text` will
     `utf8` library included with LÖVR can be used to manipulate UTF-8 strings.  `Pass:text` will
     also correctly handle UTF-8.
     also correctly handle UTF-8.
   ]],
   ]],
-  returns = {},
   related = {
   related = {
     'lovr.keypressed',
     'lovr.keypressed',
     'lovr.keyreleased'
     'lovr.keyreleased'

+ 8 - 4
api/lovr/callbacks/threaderror.lua

@@ -8,18 +8,22 @@ return {
     The default implementation of this callback will call `lovr.errhand` with the error.
     The default implementation of this callback will call `lovr.errhand` with the error.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'thread',
+    thread = {
       type = 'Thread',
       type = 'Thread',
       description = 'The Thread that errored.'
       description = 'The Thread that errored.'
     },
     },
-    {
-      name = 'message',
+    message = {
       type = 'string',
       type = 'string',
       description = 'The error message.'
       description = 'The error message.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'thread', 'message' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'Thread',
     'Thread',
     'Thread:getError',
     'Thread:getError',

+ 7 - 2
api/lovr/callbacks/update.lua

@@ -8,13 +8,18 @@ return {
     speed.
     speed.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'dt',
+    dt = {
       type = 'number',
       type = 'number',
       description = 'The number of seconds elapsed since the last update.'
       description = 'The number of seconds elapsed since the last update.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'dt' },
+      returns = {}
+    }
+  },
   example = [[
   example = [[
     function lovr.update(dt)
     function lovr.update(dt)
       ball.vy = ball.vy + ball.gravity * dt
       ball.vy = ball.vy + ball.gravity * dt

+ 7 - 2
api/lovr/callbacks/visible.lua

@@ -8,13 +8,18 @@ return {
     stop calling `lovr.draw`.
     stop calling `lovr.draw`.
   ]],
   ]],
   arguments = {
   arguments = {
-    {
-      name = 'visible',
+    visible = {
       type = 'boolean',
       type = 'boolean',
       description = 'Whether the application is visible in the headset display.'
       description = 'Whether the application is visible in the headset display.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'visible' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.headset.isVisible',
     'lovr.headset.isVisible',
     'lovr.focus'
     'lovr.focus'

+ 8 - 4
api/lovr/callbacks/wheelmoved.lua

@@ -3,18 +3,22 @@ return {
   summary = 'Called when a mouse wheel is moved.',
   summary = 'Called when a mouse wheel is moved.',
   description = 'This callback is called on scroll action, from a mouse wheel or a touchpad',
   description = 'This callback is called on scroll action, from a mouse wheel or a touchpad',
   arguments = {
   arguments = {
-    {
-      name = 'deltaX',
+    dx = {
       type = 'number',
       type = 'number',
       description = 'The relative horizontal motion; rightward movement resuts in positive values.'
       description = 'The relative horizontal motion; rightward movement resuts in positive values.'
     },
     },
-    {
-      name = 'deltaY',
+    dy = {
       type = 'number',
       type = 'number',
       description = 'The relative vertical motion; upward movement results in positive values.'
       description = 'The relative vertical motion; upward movement results in positive values.'
     }
     }
   },
   },
   returns = {},
   returns = {},
+  variants = {
+    {
+      arguments = { 'dx', 'dy' },
+      returns = {}
+    }
+  },
   related = {
   related = {
     'lovr.mousepressed',
     'lovr.mousepressed',
     'lovr.mousereleased',
     'lovr.mousereleased',

+ 10 - 11
api/lovr/physics/Collider/getInertia.lua

@@ -28,27 +28,27 @@ return {
       type = 'number',
       type = 'number',
       description = 'The z component of the diagonal matrix.'
       description = 'The z component of the diagonal matrix.'
     },
     },
-    qx = {
+    angle = {
       type = 'number',
       type = 'number',
-      description = 'The x component of the inertia rotation quaternion.'
+      description = 'The angle of the inertia rotation.'
     },
     },
-    qy = {
+    ax = {
       type = 'number',
       type = 'number',
-      description = 'The y component of the inertia rotation quaternion.'
+      description = 'The x component of the inertia rotation axis.'
     },
     },
-    qz = {
+    ay = {
       type = 'number',
       type = 'number',
-      description = 'The z component of the inertia rotation quaternion.'
+      description = 'The y component of the inertia rotation axis.'
     },
     },
-    qw = {
+    az = {
       type = 'number',
       type = 'number',
-      description = 'The w component of the inertia rotation quaternion.'
+      description = 'The z component of the inertia rotation axis.'
     }
     }
   },
   },
   variants = {
   variants = {
     {
     {
       arguments = {},
       arguments = {},
-      returns = { 'dx', 'dy', 'dz', 'qx', 'qy', 'qz', 'qw' }
+      returns = { 'dx', 'dy', 'dz', 'angle', 'ax', 'ay', 'az' }
     }
     }
   },
   },
   notes = [[
   notes = [[
@@ -58,8 +58,7 @@ return {
     Use `Collider:resetMassData` to reset the inertia and other mass properties based on the
     Use `Collider:resetMassData` to reset the inertia and other mass properties based on the
     Collider's shapes.
     Collider's shapes.
 
 
-    If the Collider is kinematic or all rotation axes are disabled, this returns 0 for the diagonal
-    and an identity quaternion for the rotation.
+    If the Collider is kinematic or all rotation axes are disabled, this returns zeroes.
   ]],
   ]],
   related = {
   related = {
     'Collider:getMass',
     'Collider:getMass',

+ 2 - 2
api/lovr/physics/Collider/getTag.lua

@@ -18,8 +18,8 @@ return {
   },
   },
   variants = {
   variants = {
     {
     {
-      arguments = {}
-      returns = { 'tag' },
+      arguments = {},
+      returns = { 'tag' }
     }
     }
   },
   },
   related = {
   related = {

+ 1 - 0
api/lovr/physics/Collider/setInertia.lua

@@ -52,6 +52,7 @@ return {
       description = 'The inertia rotation.'
       description = 'The inertia rotation.'
     }
     }
   },
   },
+  returns = {},
   variants = {
   variants = {
     {
     {
       arguments = { 'dx', 'dy', 'dz', 'angle', 'ax', 'ay', 'az' },
       arguments = { 'dx', 'dy', 'dz', 'angle', 'ax', 'ay', 'az' },

+ 4 - 0
api/lovr/physics/ConeJoint/init.lua

@@ -0,0 +1,4 @@
+return {
+  summary = 'TODO',
+  description = 'TODO'
+}

+ 1 - 1
api/lovr/physics/ConvexShape/getPointCount.lua

@@ -17,7 +17,7 @@ return {
   notes = [[
   notes = [[
     This isn't necessarily the same as the number of points or vertices that were used to create the
     This isn't necessarily the same as the number of points or vertices that were used to create the
     shape, since points inside the hull will be discarded.
     shape, since points inside the hull will be discarded.
-  ]]
+  ]],
   related = {
   related = {
     'ConvexShape:getPoint'
     'ConvexShape:getPoint'
   }
   }

+ 4 - 0
api/lovr/physics/ConvexShape/init.lua

@@ -0,0 +1,4 @@
+return {
+  summary = 'TODO',
+  description = 'TODO'
+}

+ 1 - 1
api/lovr/physics/HingeJoint/setLimits.lua

@@ -17,7 +17,7 @@ return {
   returns = {},
   returns = {},
   variants = {
   variants = {
     {
     {
-      arguments = { 'lower', 'upper' },
+      arguments = { 'min', 'max' },
       returns = {}
       returns = {}
     },
     },
     {
     {

+ 60 - 1
api/lovr/physics/Shape/getInertia.lua

@@ -1,4 +1,63 @@
 return {
 return {
   summary = 'Get the inertia of the Shape.',
   summary = 'Get the inertia of the Shape.',
-  description = 'Returns the inertia of the Shape.'
+  description = [[
+    Returns the inertia of the Shape.
+
+    Inertia is kind of like "angular mass".  Regular mass determines how resistant a Collider is to
+    linear forces (movement), whereas inertia determines how resistant the Collider is to torque
+    (rotation).  Colliders with less inertia are more spinny.
+
+    In 3D, inertia is represented by a 3x3 matrix, called a tensor.  To make calculations easier,
+    the physics engine stores the inertia using eigenvalue decomposition, splitting the matrix into
+    a diagonal matrix and a rotation.  It's complicated!
+
+    In a realistic simulation, mass and inertia follow a linear relationship.  If the mass of an
+    object increases, the diagonal part of its inertia should increase proportionally.
+  ]],
+  arguments = {},
+  returns = {
+    dx = {
+      type = 'number',
+      description = 'The x component of the diagonal matrix.'
+    },
+    dy = {
+      type = 'number',
+      description = 'The y component of the diagonal matrix.'
+    },
+    dz = {
+      type = 'number',
+      description = 'The z component of the diagonal matrix.'
+    },
+    angle = {
+      type = 'number',
+      description = 'The angle of the inertia rotation.'
+    },
+    ax = {
+      type = 'number',
+      description = 'The x component of the inertia rotation axis.'
+    },
+    ay = {
+      type = 'number',
+      description = 'The y component of the inertia rotation axis.'
+    },
+    az = {
+      type = 'number',
+      description = 'The z component of the inertia rotation axis.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'dx', 'dy', 'dz', 'angle', 'ax', 'ay', 'az' }
+    }
+  },
+  notes = [[
+    `MeshShape` and `TerrainShape` do not have mass or volue, and for those shapes this function
+    returns zeroes.
+  ]],
+  related = {
+    'Shape:getMass',
+    'Shape:getCenterOfMass',
+    'Collider:getInertia'
+  }
 }
 }

+ 6 - 0
api/lovr/physics/Shape/isDestroyed.lua

@@ -10,6 +10,12 @@ return {
       description = 'Whether the Shape has been destroyed.'
       description = 'Whether the Shape has been destroyed.'
     }
     }
   },
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'destroyed' }
+    }
+  },
   related = {
   related = {
     'Shape:destroy',
     'Shape:destroy',
     'Collider:isDestroyed',
     'Collider:isDestroyed',

+ 4 - 0
api/lovr/physics/WeldJoint/init.lua

@@ -0,0 +1,4 @@
+return {
+  summary = 'TODO',
+  description = 'TODO'
+}

+ 0 - 3
api/lovr/physics/World/overlapShape.lua

@@ -128,9 +128,6 @@ return {
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
     }
     }
   },
   },
-  example = {
-    -- Show an example of colliding a sphere and getting all the stuff it touches
-  },
   related = {
   related = {
     'World:shapecast',
     'World:shapecast',
     'World:raycast',
     'World:raycast',

+ 2 - 2
api/lovr/physics/World/raycast.lua

@@ -137,7 +137,7 @@ return {
       returns = {}
       returns = {}
     },
     },
     {
     {
-      arguments = { 'start', 'end', 'filter', 'callback' },
+      arguments = { 'origin', 'endpoint', 'filter', 'callback' },
       returns = {}
       returns = {}
     },
     },
     {
     {
@@ -145,7 +145,7 @@ return {
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
     },
     },
     {
     {
-      arguments = { 'start', 'end', 'filter' },
+      arguments = { 'origin', 'endpoint', 'filter' },
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
     }
     }
   },
   },

+ 2 - 2
api/lovr/physics/World/setCallbacks.lua

@@ -41,8 +41,8 @@ return {
   returns = {},
   returns = {},
   variants = {
   variants = {
     {
     {
-      arguments = { 'callbacks' }
-      returns = {},
+      arguments = { 'callbacks' },
+      returns = {}
     }
     }
   }
   }
 }
 }

+ 1 - 1
api/lovr/physics/World/shapecast.lua

@@ -56,7 +56,7 @@ return {
       type = 'Vec3',
       type = 'Vec3',
       description = 'The position to start at.'
       description = 'The position to start at.'
     },
     },
-    endpoint = {
+    destination = {
       type = 'Vec3',
       type = 'Vec3',
       description = 'The position to move the shape to.'
       description = 'The position to move the shape to.'
     },
     },

+ 0 - 4
api/lovr/physics/newWorld.lua

@@ -157,9 +157,5 @@ return {
       arguments = { 'settings' },
       arguments = { 'settings' },
       returns = { 'world' }
       returns = { 'world' }
     }
     }
-  },
-  example = {
-    -- show creating the world with default settings, so you can copy-paste
-    -- maybe another one with a bouncing sphere
   }
   }
 }
 }

+ 8 - 6
api/main.lua

@@ -58,12 +58,13 @@ local function warnIf(cond, ...)
 end
 end
 
 
 -- Processors
 -- Processors
-local function processExample(example)
+local function processExample(example, key)
   if type(example) == 'string' then
   if type(example) == 'string' then
     return {
     return {
       code = unindent(example)
       code = unindent(example)
     }
     }
   else
   else
+    assert(example.code, string.format('%s example is missing code', key))
     example.description = unwrap(example.description)
     example.description = unwrap(example.description)
     example.code = unindent(example.code)
     example.code = unindent(example.code)
   end
   end
@@ -99,7 +100,7 @@ local function processFunction(path, parent)
   fn.examples = pluralify(fn, 'example')
   fn.examples = pluralify(fn, 'example')
 
 
   for k, example in ipairs(fn.examples or {}) do
   for k, example in ipairs(fn.examples or {}) do
-    fn.examples[k] = processExample(example)
+    fn.examples[k] = processExample(example, fn.key)
   end
   end
 
 
   assert(fn.variants, string.format('Function %q is missing variants', fn.key))
   assert(fn.variants, string.format('Function %q is missing variants', fn.key))
@@ -163,6 +164,7 @@ end
 
 
 local function processObject(path, parent)
 local function processObject(path, parent)
   local object = require(path .. '.init')
   local object = require(path .. '.init')
+  assert(type(object) == 'table', string.format('%s/init.lua did not return a table', path))
 
 
   object.key = path:match('[^/]+$')
   object.key = path:match('[^/]+$')
   object.name = object.key
   object.name = object.key
@@ -210,7 +212,7 @@ local function processObject(path, parent)
   end
   end
 
 
   for k, example in ipairs(object.examples or {}) do
   for k, example in ipairs(object.examples or {}) do
-    object.examples[k] = processExample(example)
+    object.examples[k] = processExample(example, object.key)
   end
   end
 
 
   track(object)
   track(object)
@@ -236,7 +238,7 @@ local function processModule(path)
 
 
   module.examples = pluralify(module, 'example')
   module.examples = pluralify(module, 'example')
   for k, example in ipairs(module.examples or {}) do
   for k, example in ipairs(module.examples or {}) do
-    module.examples[k] = processExample(example)
+    module.examples[k] = processExample(example, module.key)
   end
   end
 
 
   for _, file in ipairs(lovr.filesystem.getDirectoryItems(path)) do
   for _, file in ipairs(lovr.filesystem.getDirectoryItems(path)) do
@@ -296,12 +298,12 @@ local function validateFunction(fn)
   for _, variant in ipairs(fn.variants) do
   for _, variant in ipairs(fn.variants) do
     for _, arg in ipairs(variant.arguments) do
     for _, arg in ipairs(variant.arguments) do
       warnIf(not arg or not arg.name, 'Invalid argument for variant of %s', fn.key)
       warnIf(not arg or not arg.name, 'Invalid argument for variant of %s', fn.key)
-      warnIf(not arg.type or (arg.type:match('^[A-Z]') and not lookup[arg.type]), 'Invalid or missing argument type %s in %s', arg.type, fn.key)
+      warnIf(not arg.type or (arg.type:match('^[A-Z]') and not lookup[arg.type]), 'Invalid or missing argument type in %s', fn.key)
     end
     end
 
 
     for _, ret in ipairs(variant.returns) do
     for _, ret in ipairs(variant.returns) do
       warnIf(not ret or not ret.name, 'Invalid return for variant of %s', fn.key)
       warnIf(not ret or not ret.name, 'Invalid return for variant of %s', fn.key)
-      warnIf(not ret.type or (ret.type:match('^[A-Z]') and not lookup[ret.type]), 'Invalid or missing return type %s for %s variant', ret.type, fn.key)
+      warnIf(not ret.type or (ret.type:match('^[A-Z]') and not lookup[ret.type]), 'Invalid or missing return type in %s', fn.key)
     end
     end
   end
   end
 
 

部分文件因为文件数量过多而无法显示