Ray.html 8.2 KB

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