raycastAny.lua 2.7 KB

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