Ray.html 8.4 KB

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