Ray.html 7.7 KB

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