1
0

Ray.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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], [param:Vector3 target] )
  60. </h3>
  61. <p>
  62. [page:Vector3 point] - the point to get the closest approach to. <br />
  63. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  64. Get the point along this [page:Ray] that is closest to the [page:Vector3]
  65. provided.
  66. </p>
  67. <h3>[method:this copy]( [param:Ray ray] )</h3>
  68. <p>
  69. Copies the [page:.origin origin] and [page:.direction direction]
  70. properties of [page:Ray ray] into this ray.
  71. </p>
  72. <h3>[method:Float distanceSqToPoint]( [param:Vector3 point] )</h3>
  73. <p>
  74. [page:Vector3 point] - the [page:Vector3] to compute a distance to.<br /><br />
  75. Get the squared distance of the closest approach between the [page:Ray]
  76. and the [page:Vector3].
  77. </p>
  78. <h3>
  79. [method:Float distanceSqToSegment]( [param:Vector3 v0], [param:Vector3 v1],
  80. [param:Vector3 optionalPointOnRay], [param:Vector3 optionalPointOnSegment] )
  81. </h3>
  82. <p>
  83. [page:Vector3 v0] - the start of the line segment.<br />
  84. [page:Vector3 v1] - the end of the line segment.<br />
  85. optionalPointOnRay - (optional) if this is provided, it receives the point
  86. on this [page:Ray] that is closest to the segment.<br />
  87. optionalPointOnSegment - (optional) if this is provided, it receives the
  88. point on the line segment that is closest to this [page:Ray].<br /><br />
  89. Get the squared distance between this [page:Ray] and a line segment.
  90. </p>
  91. <h3>[method:Float distanceToPlane]( [param:Plane plane] )</h3>
  92. <p>
  93. [page:Plane plane] - the [page:Plane] to get the distance to.<br /><br />
  94. Get the distance from [page:.origin origin] to the [page:Plane], or `null`
  95. if the [page:Ray] doesn't intersect the [page:Plane].
  96. </p>
  97. <h3>[method:Float distanceToPoint]( [param:Vector3 point] )</h3>
  98. <p>
  99. [page:Vector3 point] - [page:Vector3] The [page:Vector3] to compute a
  100. distance to.<br /><br />
  101. Get the distance of the closest approach between the [page:Ray] and the
  102. [page:Vector3 point].
  103. </p>
  104. <h3>[method:Boolean equals]( [param:Ray ray] )</h3>
  105. <p>
  106. [page:Ray ray] - the [page:Ray] to compare to.<br /><br />
  107. Returns true if this and the other [page:Ray ray] have equal [page:.origin origin]
  108. and [page:.direction direction].
  109. </p>
  110. <h3>
  111. [method:Vector3 intersectBox]( [param:Box3 box], [param:Vector3 target] )
  112. </h3>
  113. <p>
  114. [page:Box3 box] - the [page:Box3] to intersect with.<br />
  115. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  116. Intersect this [page:Ray] with a [page:Box3], returning the intersection
  117. point or `null` if there is no intersection.
  118. </p>
  119. <h3>
  120. [method:Vector3 intersectPlane]( [param:Plane plane], [param:Vector3 target] )
  121. </h3>
  122. <p>
  123. [page:Plane plane] - the [page:Plane] to intersect with.<br />
  124. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  125. Intersect this [page:Ray] with a [page:Plane], returning the intersection
  126. point or `null` if there is no intersection.
  127. </p>
  128. <h3>
  129. [method:Vector3 intersectSphere]( [param:Sphere sphere], [param:Vector3 target] )
  130. </h3>
  131. <p>
  132. [page:Sphere sphere] - the [page:Sphere] to intersect with.<br />
  133. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  134. Intersect this [page:Ray] with a [page:Sphere], returning the intersection
  135. point or `null` if there is no intersection.
  136. </p>
  137. <h3>
  138. [method:Vector3 intersectTriangle]( [param:Vector3 a], [param:Vector3 b], [param:Vector3 c], [param:Boolean backfaceCulling], [param:Vector3 target] )
  139. </h3>
  140. <p>
  141. [page:Vector3 a], [page:Vector3 b], [page:Vector3 c] - The [page:Vector3]
  142. points making up the triangle.<br />
  143. [page:Boolean backfaceCulling] - whether to use backface culling.<br />
  144. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  145. Intersect this [page:Ray] with a triangle, returning the intersection
  146. point or `null` if there is no intersection.
  147. </p>
  148. <h3>[method:Boolean intersectsBox]( [param:Box3 box] )</h3>
  149. <p>
  150. [page:Box3 box] - the [page:Box3] to intersect with.<br /><br />
  151. Return true if this [page:Ray] intersects with the [page:Box3].
  152. </p>
  153. <h3>[method:Boolean intersectsPlane]( [param:Plane plane] )</h3>
  154. <p>
  155. [page:Plane plane] - the [page:Plane] to intersect with.<br /><br />
  156. Return true if this [page:Ray] intersects with the [page:Plane].
  157. </p>
  158. <h3>[method:Boolean intersectsSphere]( [param:Sphere sphere] )</h3>
  159. <p>
  160. [page:Sphere sphere] - the [page:Sphere] to intersect with.<br /><br />
  161. Return true if this [page:Ray] intersects with the [page:Sphere].
  162. </p>
  163. <h3>[method:this lookAt]( [param:Vector3 v] )</h3>
  164. <p>
  165. [page:Vector3 v] - The [page:Vector3] to look at.<br /><br />
  166. Adjusts the direction of the ray to point at the vector in world
  167. coordinates.
  168. </p>
  169. <h3>[method:this recast]( [param:Float t] )</h3>
  170. <p>
  171. [page:Float t] - The distance along the [page:Ray] to interpolate.<br /><br />
  172. Shift the origin of this [page:Ray] along its direction by the distance
  173. given.
  174. </p>
  175. <h3>
  176. [method:this set]( [param:Vector3 origin], [param:Vector3 direction] )
  177. </h3>
  178. <p>
  179. [page:Vector3 origin] - the [page:.origin origin] of the [page:Ray].<br />
  180. [page:Vector3 direction] - the [page:.direction direction] of the
  181. [page:Ray]. This must be normalized (with [page:Vector3.normalize]) for
  182. the methods to operate properly.<br /><br />
  183. Sets this ray's [page:.origin origin] and [page:.direction direction]
  184. properties by copying the values from the given objects.
  185. </p>
  186. <h2>Source</h2>
  187. <p>
  188. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  189. </p>
  190. </body>
  191. </html>