Ray.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">
  12. A ray that emits from an origin in a certain direction. This is used by
  13. the [page:Raycaster] to assist with
  14. [link:https://en.wikipedia.org/wiki/Ray_casting raycasting]. Raycasting is
  15. used for mouse picking (working out what objects in the 3D space the mouse
  16. is over) amongst other things.
  17. </p>
  18. <h2>Constructor</h2>
  19. <h3>[name]( [param:Vector3 origin], [param:Vector3 direction] )</h3>
  20. <p>
  21. [page:Vector3 origin] - (optional) the origin of the [page:Ray]. Default
  22. is a [page:Vector3] at (0, 0, 0).<br />
  23. [page:Vector3 direction] - [page:Vector3] The direction of the [page:Ray].
  24. This must be normalized (with [page:Vector3.normalize]) for the methods to
  25. operate properly. Default is a [page:Vector3] at (0, 0, -1).<br /><br />
  26. Creates a new [name].
  27. </p>
  28. <h2>Properties</h2>
  29. <h3>[property:Vector3 origin]</h3>
  30. <p>
  31. The origin of the [page:Ray]. Default is a [page:Vector3] at `(0, 0, 0)`.
  32. </p>
  33. <h3>[property:Vector3 direction]</h3>
  34. <p>
  35. The direction of the [page:Ray]. This must be normalized (with
  36. [page:Vector3.normalize]) for the methods to operate properly. Default is
  37. a [page:Vector3] at (0, 0, -1).
  38. </p>
  39. <h2>Methods</h2>
  40. <h3>[method:this applyMatrix4]( [param:Matrix4 matrix4] )</h3>
  41. <p>
  42. [page:Matrix4 matrix4] - the [page:Matrix4] to apply to this
  43. [page:Ray].<br /><br />
  44. Transform this [page:Ray] by the [page:Matrix4].
  45. </p>
  46. <h3>[method:Vector3 at]( [param:Float t], [param:Vector3 target] )</h3>
  47. <p>
  48. [page:Float t] - the distance along the [page:Ray] to retrieve a position
  49. for.<br />
  50. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  51. Get a [page:Vector3] that is a given distance along this [page:Ray].
  52. </p>
  53. <h3>[method:Ray clone]()</h3>
  54. <p>
  55. Creates a new Ray with identical [page:.origin origin] and
  56. [page:.direction direction] to this one.
  57. </p>
  58. <h3>
  59. [method:Vector3 closestPointToPoint]( [param:Vector3 point],
  60. [param:Vector3 target] )
  61. </h3>
  62. <p>
  63. [page:Vector3 point] - the point to get the closest approach to. <br />
  64. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  65. Get the point along this [page:Ray] that is closest to the [page:Vector3]
  66. provided.
  67. </p>
  68. <h3>[method:this copy]( [param:Ray ray] )</h3>
  69. <p>
  70. Copies the [page:.origin origin] and [page:.direction direction]
  71. properties of [page:Ray ray] into this ray.
  72. </p>
  73. <h3>[method:Float distanceSqToPoint]( [param:Vector3 point] )</h3>
  74. <p>
  75. [page:Vector3 point] - the [page:Vector3] to compute a distance to.<br /><br />
  76. Get the squared distance of the closest approach between the [page:Ray]
  77. and the [page:Vector3].
  78. </p>
  79. <h3>
  80. [method:Float distanceSqToSegment]( [param:Vector3 v0], [param:Vector3 v1],
  81. [param:Vector3 optionalPointOnRay], [param:Vector3 optionalPointOnSegment] )
  82. </h3>
  83. <p>
  84. [page:Vector3 v0] - the start of the line segment.<br />
  85. [page:Vector3 v1] - the end of the line segment.<br />
  86. optionalPointOnRay - (optional) if this is provided, it receives the point
  87. on this [page:Ray] that is closest to the segment.<br />
  88. optionalPointOnSegment - (optional) if this is provided, it receives the
  89. point on the line segment that is closest to this [page:Ray].<br /><br />
  90. Get the squared distance between this [page:Ray] and a line segment.
  91. </p>
  92. <h3>[method:Float distanceToPlane]( [param:Plane plane] )</h3>
  93. <p>
  94. [page:Plane plane] - the [page:Plane] to get the distance to.<br /><br />
  95. Get the distance from [page:.origin origin] to the [page:Plane], or `null`
  96. if the [page:Ray] doesn't intersect the [page:Plane].
  97. </p>
  98. <h3>[method:Float distanceToPoint]( [param:Vector3 point] )</h3>
  99. <p>
  100. [page:Vector3 point] - [page:Vector3] The [page:Vector3] to compute a
  101. distance to.<br /><br />
  102. Get the distance of the closest approach between the [page:Ray] and the
  103. [page:Vector3 point].
  104. </p>
  105. <h3>[method:Boolean equals]( [param:Ray ray] )</h3>
  106. <p>
  107. [page:Ray ray] - the [page:Ray] to compare to.<br /><br />
  108. Returns true if this and the other [page:Ray ray] have equal [page:.origin origin]
  109. and [page:.direction direction].
  110. </p>
  111. <h3>
  112. [method:Vector3 intersectBox]( [param:Box3 box], [param:Vector3 target] )
  113. </h3>
  114. <p>
  115. [page:Box3 box] - the [page:Box3] to intersect with.<br />
  116. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  117. Intersect this [page:Ray] with a [page:Box3], returning the intersection
  118. point or `null` if there is no intersection.
  119. </p>
  120. <h3>
  121. [method:Vector3 intersectPlane]( [param:Plane plane], [param:Vector3 target] )
  122. </h3>
  123. <p>
  124. [page:Plane plane] - the [page:Plane] to intersect with.<br />
  125. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  126. Intersect this [page:Ray] with a [page:Plane], returning the intersection
  127. point or `null` if there is no intersection.
  128. </p>
  129. <h3>
  130. [method:Vector3 intersectSphere]( [param:Sphere sphere], [param:Vector3 target] )
  131. </h3>
  132. <p>
  133. [page:Sphere sphere] - the [page:Sphere] to intersect with.<br />
  134. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  135. Intersect this [page:Ray] with a [page:Sphere], returning the intersection
  136. point or `null` if there is no intersection.
  137. </p>
  138. <h3>
  139. [method:Vector3 intersectTriangle]( [param:Vector3 a], [param:Vector3 b],
  140. [param:Vector3 c], [param:Boolean backfaceCulling], [param:Vector3 target] )
  141. </h3>
  142. <p>
  143. [page:Vector3 a], [page:Vector3 b], [page:Vector3 c] - The [page:Vector3]
  144. points making up the triangle.<br />
  145. [page:Boolean backfaceCulling] - whether to use backface culling.<br />
  146. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  147. Intersect this [page:Ray] with a triangle, returning the intersection
  148. point or `null` if there is no intersection.
  149. </p>
  150. <h3>[method:Boolean intersectsBox]( [param:Box3 box] )</h3>
  151. <p>
  152. [page:Box3 box] - the [page:Box3] to intersect with.<br /><br />
  153. Return true if this [page:Ray] intersects with the [page:Box3].
  154. </p>
  155. <h3>[method:Boolean intersectsPlane]( [param:Plane plane] )</h3>
  156. <p>
  157. [page:Plane plane] - the [page:Plane] to intersect with.<br /><br />
  158. Return true if this [page:Ray] intersects with the [page:Plane].
  159. </p>
  160. <h3>[method:Boolean intersectsSphere]( [param:Sphere sphere] )</h3>
  161. <p>
  162. [page:Sphere sphere] - the [page:Sphere] to intersect with.<br /><br />
  163. Return true if this [page:Ray] intersects with the [page:Sphere].
  164. </p>
  165. <h3>[method:this lookAt]( [param:Vector3 v] )</h3>
  166. <p>
  167. [page:Vector3 v] - The [page:Vector3] to look at.<br /><br />
  168. Adjusts the direction of the ray to point at the vector in world
  169. coordinates.
  170. </p>
  171. <h3>[method:this recast]( [param:Float t] )</h3>
  172. <p>
  173. [page:Float t] - The distance along the [page:Ray] to interpolate.<br /><br />
  174. Shift the origin of this [page:Ray] along its direction by the distance
  175. given.
  176. </p>
  177. <h3>
  178. [method:this set]( [param:Vector3 origin], [param:Vector3 direction] )
  179. </h3>
  180. <p>
  181. [page:Vector3 origin] - the [page:.origin origin] of the [page:Ray].<br />
  182. [page:Vector3 direction] - the [page:.direction direction] of the
  183. [page:Ray]. This must be normalized (with [page:Vector3.normalize]) for
  184. the methods to operate properly.<br /><br />
  185. Sets this ray's [page:.origin origin] and [page:.direction direction]
  186. properties by copying the values from the given objects.
  187. </p>
  188. <h2>Source</h2>
  189. <p>
  190. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  191. </p>
  192. </body>
  193. </html>