Ray.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. 射线由一个原点向一个确定的方向发射。它被[page:Raycaster](光线投射)所使用,
  14. 以用于辅助[link:https://en.wikipedia.org/wiki/Ray_casting raycasting]。
  15. 光线投射用于在各个物体之间进行拾取(当鼠标经过三维空间中的物体/对象时进行拾取)。
  16. </p>
  17. <h2>构造函数</h2>
  18. <h3>[name]( [param:Vector3 origin], [param:Vector3 direction] )</h3>
  19. <p>
  20. [page:Vector3 origin] - (可选)[page:Ray](射线)的原点,默认值是一个位于(0, 0, 0)的[page:Vector3]。<br />
  21. [page:Vector3 direction] - [page:Vector3] [page:Ray](射线)的方向。该向量必须被标准化(使用[page:Vector3.normalize]函数),这样才能使方法正常运行。
  22. 默认值是一个位于(0, 0, 0)的[page:Vector3]。<br /><br />
  23. 创建一个新的[name]。
  24. </p>
  25. <h2>属性</h2>
  26. <h3>[property:Vector3 origin]</h3>
  27. <p>[page:Ray](射线)的原点,默认值是一个位于(0, 0, 0)的[page:Vector3]。</p>
  28. <h3>[property:Vector3 direction]</h3>
  29. <p>
  30. [page:Ray](射线)的方向。该向量必须被标准化(使用[page:Vector3.normalize]函数),这样才能使方法正常运行。
  31. 默认值是一个位于(0, 0, 0)的[page:Vector3]。
  32. </p>
  33. <h2>方法</h2>
  34. <h3>[method:Ray applyMatrix4]( [param:Matrix4 matrix4] )</h3>
  35. <p>
  36. [page:Matrix4 matrix4] - 将被用于这个[page:Ray]的[page:Matrix4]。<br /><br />
  37. 使用传入的[page:Matrix4]来变换这个[page:Ray]。
  38. </p>
  39. <h3>[method:Vector3 at]( [param:Float t], [param:Vector3 target] ) </h3>
  40. <p>
  41. [page:Float t] - 使用这一传入的距离,在[page:Ray]上确定一个位置。<br />
  42. [page:Vector3 target] — 结果将复制到这一Vector3中。<br /><br />
  43. 获得这一[page:Ray]上给定距离处的[page:Vector3]。
  44. </p>
  45. <h3>[method:Ray clone]()</h3>
  46. <p>
  47. 创建一个新的和这个Ray具有相同[page:.origin origin]和[page:.direction direction]的Ray。
  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. 沿着[page:Ray],获得与所传入[page:Vector3]最接近的点。
  54. </p>
  55. <h3>[method:Ray copy]( [param:Ray ray] )</h3>
  56. <p>
  57. 复制所传入Ray的[page:.origin origin]和[page:.direction direction]属性到这个Ray上。
  58. </p>
  59. <h3>[method:Float distanceSqToPoint]( [param:Vector3 point] )</h3>
  60. <p>
  61. [page:Vector3 point] - the [page:Vector3] to compute a distance to.<br /><br />
  62. 获得[page:Ray]与传入的[page:Vector3]之间最近的平方距离。
  63. </p>
  64. <h3>[method:Float distanceSqToSegment]( [param:Vector3 v0], [param:Vector3 v1], [param:Vector3 optionalPointOnRay], [param:Vector3 optionalPointOnSegment] )</h3>
  65. <p>
  66. [page:Vector3 v0] - the start of the line segment.<br />
  67. [page:Vector3 v1] - the end of the line segment.<br />
  68. optionalPointOnRay - (optional) if this is provided, it receives the point on this
  69. [page:Ray] that is closest to the segment.<br />
  70. optionalPointOnSegment - (optional) if this is provided, it receives the point
  71. on the line segment that is closest to this [page:Ray].<br /><br />
  72. Get the squared distance between this [page:Ray] and a line segment.
  73. </p>
  74. <h3>[method:Float distanceToPlane]( [param:Plane plane] )</h3>
  75. <p>
  76. [page:Plane plane] - the [page:Plane] to get the distance to.<br /><br />
  77. Get the distance from [page:.origin origin] to the [page:Plane], or *null* if the [page:Ray] doesn't intersect the [page:Plane].
  78. </p>
  79. <h3>[method:Float distanceToPoint]( [param:Vector3 point] )</h3>
  80. <p>
  81. [page:Vector3 point] - [page:Vector3] The [page:Vector3] to compute a distance to.<br /><br />
  82. Get the distance of the closest approach between the [page:Ray] and the [page:Vector3 point].
  83. </p>
  84. <h3>[method:Boolean equals]( [param:Ray ray] )</h3>
  85. <p>
  86. [page:Ray ray] - 用于比较的[page:Ray]。<br /><br />
  87. 如果所传入的[page:Ray ray]具有和当前Ray相同的[page:.offset offset]和[page:.direction direction]则返回true。
  88. </p>
  89. <h3>[method:Vector3 intersectBox]( [param:Box3 box], [param:Vector3 target] )</h3>
  90. <p>
  91. [page:Box3 box] - the [page:Box3] to intersect with.<br />
  92. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  93. 相交
  94. Intersect this [page:Ray] with a [page:Box3], returning the intersection point or
  95. *null* if there is no intersection.
  96. </p>
  97. <h3>[method:Vector3 intersectPlane]( [param:Plane plane], [param:Vector3 target] )</h3>
  98. <p>
  99. [page:Plane plane] - the [page:Plane] to intersect with.<br />
  100. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  101. Intersect this [page:Ray] with a [page:Plane], returning the intersection point or
  102. *null* if there is no intersection.
  103. </p>
  104. <h3>[method:Vector3 intersectSphere]( [param:Sphere sphere], [param:Vector3 target] )</h3>
  105. <p>
  106. [page:Sphere sphere] - the [page:Sphere] to intersect with.<br />
  107. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  108. Intersect this [page:Ray] with a [page:Sphere], returning the intersection point or
  109. *null* if there is no intersection.
  110. </p>
  111. <h3>[method:Vector3 intersectTriangle]( [param:Vector3 a], [param:Vector3 b], [param:Vector3 c], [param:Boolean backfaceCulling], [param:Vector3 target] )</h3>
  112. <p>
  113. [page:Vector3 a], [page:Vector3 b], [page:Vector3 c] - The [page:Vector3] points making up the triangle.<br />
  114. [page:Boolean backfaceCulling] - whether to use backface culling.<br />
  115. [page:Vector3 target] — the result will be copied into this Vector3.<br /><br />
  116. Intersect this [page:Ray] with a triangle, returning the intersection point or *null*
  117. if there is no intersection.
  118. </p>
  119. <h3>[method:Boolean intersectsBox]( [param:Box3 box] )</h3>
  120. <p>
  121. [page:Box3 box] - the [page:Box3] to intersect with.<br /><br />
  122. Return true if this [page:Ray] intersects with the [page:Box3].
  123. </p>
  124. <h3>[method:Boolean intersectsPlane]( [param:Plane plane] )</h3>
  125. <p>
  126. [page:Plane plane] - the [page:Plane] to intersect with.<br /><br />
  127. Return true if this [page:Ray] intersects with the [page:Plane].
  128. </p>
  129. <h3>[method:Boolean intersectsSphere]( [param:Sphere sphere] )</h3>
  130. <p>
  131. [page:Sphere sphere] - the [page:Sphere] to intersect with.<br /><br />
  132. Return true if this [page:Ray] intersects with the [page:Sphere].
  133. </p>
  134. <h3>[method:Ray lookAt]( [param:Vector3 v] )</h3>
  135. <p>
  136. [page:Vector3 v] - 将要“直视”的[page:Vector3]<br /><br />
  137. 调整光线的方向到世界坐标中该向量所指代的点。
  138. </p>
  139. <h3>[method:Ray recast]( [param:Float t] )</h3>
  140. <p>
  141. [page:Float t] - The distance along the [page:Ray] to interpolate.<br /><br />
  142. Shift the origin of this [page:Ray] along its direction by the distance given.
  143. </p>
  144. <h3>[method:Ray set]( [param:Vector3 origin], [param:Vector3 direction] )</h3>
  145. <p>
  146. [page:Vector3 origin] - the [page:.origin origin] of the [page:Ray].<br />
  147. [page:Vector3 origin] - the [page:.direction direction] of the [page:Ray].
  148. This must be normalized (with [page:Vector3.normalize]) for the methods to operate
  149. properly.<br /><br />
  150. Copy the parameters to the [page:.origin origin] and [page:.direction direction] properties
  151. of this ray.
  152. </p>
  153. <h2>源代码</h2>
  154. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  155. </body>
  156. </html>