Ray.html 7.6 KB

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