raycastClosest.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. return {
  2. tag = 'worldBasics',
  3. summary = 'Cast a ray through the World, returning the closest hit.',
  4. description = 'Casts a ray through the World, returning the closest Shape that was hit.',
  5. arguments = {
  6. x1 = {
  7. type = 'number',
  8. description = 'The x coordinate of the starting position of the ray.',
  9. },
  10. y1 = {
  11. type = 'number',
  12. description = 'The y coordinate of the starting position of the ray.',
  13. },
  14. z1 = {
  15. type = 'number',
  16. description = 'The z coordinate of the starting position of the ray.',
  17. },
  18. x2 = {
  19. type = 'number',
  20. description = 'The x coordinate of the ending position of the ray.',
  21. },
  22. y2 = {
  23. type = 'number',
  24. description = 'The y coordinate of the ending position of the ray.',
  25. },
  26. z2 = {
  27. type = 'number',
  28. description = 'The z coordinate of the ending position of the ray.',
  29. },
  30. start = {
  31. type = 'Vec3',
  32. description = 'The starting position of the ray.'
  33. },
  34. ['end'] = {
  35. type = 'Vec3',
  36. description = 'The end position of the ray.'
  37. },
  38. tag = {
  39. type = 'string',
  40. default = 'nil',
  41. description = 'A tag filter. Shapes will only be returned if their Collider has this tag.'
  42. }
  43. },
  44. returns = {
  45. shape = {
  46. type = 'Shape',
  47. description = 'The Shape that was hit, or nil if there wasn\'t a hit.'
  48. },
  49. x = {
  50. type = 'number',
  51. description = 'The x position of the intersection point.'
  52. },
  53. y = {
  54. type = 'number',
  55. description = 'The y position of the intersection point.'
  56. },
  57. z = {
  58. type = 'number',
  59. description = 'The z position of the intersection point.'
  60. },
  61. nx = {
  62. type = 'number',
  63. description = 'The x component of the normal vector at the intersection point.'
  64. },
  65. ny = {
  66. type = 'number',
  67. description = 'The y component of the normal vector at the intersection point.'
  68. },
  69. nz = {
  70. type = 'number',
  71. description = 'The z component of the normal vector at the intersection point.'
  72. }
  73. },
  74. variants = {
  75. {
  76. arguments = { 'x1', 'y1', 'z1', 'x2', 'y2', 'z2', 'tag' },
  77. returns = { 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
  78. },
  79. {
  80. arguments = { 'start', 'end', 'tag' },
  81. returns = { 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
  82. }
  83. },
  84. notes = [[
  85. Compared to `World:raycast`, this avoids creating a closure and might be more convenient. It
  86. might be slightly slower than `World:raycastAny` though.
  87. ]],
  88. related = {
  89. 'World:raycast',
  90. 'World:raycastAny',
  91. 'World:queryBox',
  92. 'World:querySphere'
  93. }
  94. }