Line3.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Line3 - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">Line3</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>An analytical line segment in 3D space represented by a start and end point.</p></div>
  16. </header>
  17. <article>
  18. <div class="container-overview">
  19. <h2>Constructor</h2>
  20. <h3 class="name name-method" id="Line3" translate="no">new <a href="#Line3">Line3</a><span class="signature">( start : <span class="param-type">Vector3</span>, end : <span class="param-type">Vector3</span> )</span> </h3>
  21. <div class="method">
  22. <div class="description">
  23. <p>Constructs a new line segment.</p>
  24. </div>
  25. <table class="params">
  26. <tbody>
  27. <tr>
  28. <td class="name"><code>start</code></td>
  29. <td class="description last"><p>Start of the line segment.<br/>Default is <code>(0,0,0)</code>.</p></td>
  30. </tr>
  31. <tr>
  32. <td class="name"><code>end</code></td>
  33. <td class="description last"><p>End of the line segment.<br/>Default is <code>(0,0,0)</code>.</p></td>
  34. </tr>
  35. </tbody>
  36. </table>
  37. </div>
  38. </div>
  39. <h2 class="subsection-title">Properties</h2>
  40. <div class="member">
  41. <h3 class="name" id="end" translate="no">.<a href="#end">end</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  42. <div class="description">
  43. <p>End of the line segment.</p>
  44. </div>
  45. </div>
  46. <div class="member">
  47. <h3 class="name" id="start" translate="no">.<a href="#start">start</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  48. <div class="description">
  49. <p>Start of the line segment.</p>
  50. </div>
  51. </div>
  52. <h2 class="subsection-title">Methods</h2>
  53. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( matrix : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  54. <div class="method">
  55. <div class="description">
  56. <p>Applies a 4x4 transformation matrix to this line segment.</p>
  57. </div>
  58. <table class="params">
  59. <tbody>
  60. <tr>
  61. <td class="name"><code>matrix</code></td>
  62. <td class="description last"><p>The transformation matrix.</p></td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. <dl class="details">
  67. <dt class="tag-returns"><strong>Returns:</strong> A reference to this line segment.</dt>
  68. </dl>
  69. </div>
  70. <h3 class="name name-method" id="at" translate="no">.<a href="#at">at</a><span class="signature">( t : <span class="param-type">number</span>, target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  71. <div class="method">
  72. <div class="description">
  73. <p>Returns a vector at a certain position along the line segment.</p>
  74. </div>
  75. <table class="params">
  76. <tbody>
  77. <tr>
  78. <td class="name"><code>t</code></td>
  79. <td class="description last"><p>A value between <code>[0,1]</code> to represent a position along the line segment.</p></td>
  80. </tr>
  81. <tr>
  82. <td class="name"><code>target</code></td>
  83. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. <dl class="details">
  88. <dt class="tag-returns"><strong>Returns:</strong> The delta vector.</dt>
  89. </dl>
  90. </div>
  91. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  92. <div class="method">
  93. <div class="description">
  94. <p>Returns a new line segment with copied values from this instance.</p>
  95. </div>
  96. <dl class="details">
  97. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  98. </dl>
  99. </div>
  100. <h3 class="name name-method" id="closestPointToPoint" translate="no">.<a href="#closestPointToPoint">closestPointToPoint</a><span class="signature">( point : <span class="param-type">Vector3</span>, clampToLine : <span class="param-type">boolean</span>, target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  101. <div class="method">
  102. <div class="description">
  103. <p>Returns the closest point on the line for a given point.</p>
  104. </div>
  105. <table class="params">
  106. <tbody>
  107. <tr>
  108. <td class="name"><code>point</code></td>
  109. <td class="description last"><p>The point to compute the closest point on the line for.</p></td>
  110. </tr>
  111. <tr>
  112. <td class="name"><code>clampToLine</code></td>
  113. <td class="description last"><p>Whether to clamp the result to the range <code>[0,1]</code> or not.</p></td>
  114. </tr>
  115. <tr>
  116. <td class="name"><code>target</code></td>
  117. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. <dl class="details">
  122. <dt class="tag-returns"><strong>Returns:</strong> The closest point on the line.</dt>
  123. </dl>
  124. </div>
  125. <h3 class="name name-method" id="closestPointToPointParameter" translate="no">.<a href="#closestPointToPointParameter">closestPointToPointParameter</a><span class="signature">( point : <span class="param-type">Vector3</span>, clampToLine : <span class="param-type">boolean</span> )</span><span class="type-signature"> : number</span> </h3>
  126. <div class="method">
  127. <div class="description">
  128. <p>Returns a point parameter based on the closest point as projected on the line segment.</p>
  129. </div>
  130. <table class="params">
  131. <tbody>
  132. <tr>
  133. <td class="name"><code>point</code></td>
  134. <td class="description last"><p>The point for which to return a point parameter.</p></td>
  135. </tr>
  136. <tr>
  137. <td class="name"><code>clampToLine</code></td>
  138. <td class="description last"><p>Whether to clamp the result to the range <code>[0,1]</code> or not.</p></td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. <dl class="details">
  143. <dt class="tag-returns"><strong>Returns:</strong> The point parameter.</dt>
  144. </dl>
  145. </div>
  146. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( line : <span class="param-type">Line3</span> )</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  147. <div class="method">
  148. <div class="description">
  149. <p>Copies the values of the given line segment to this instance.</p>
  150. </div>
  151. <table class="params">
  152. <tbody>
  153. <tr>
  154. <td class="name"><code>line</code></td>
  155. <td class="description last"><p>The line segment to copy.</p></td>
  156. </tr>
  157. </tbody>
  158. </table>
  159. <dl class="details">
  160. <dt class="tag-returns"><strong>Returns:</strong> A reference to this line segment.</dt>
  161. </dl>
  162. </div>
  163. <h3 class="name name-method" id="delta" translate="no">.<a href="#delta">delta</a><span class="signature">( target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  164. <div class="method">
  165. <div class="description">
  166. <p>Returns the delta vector of the line segment's start and end point.</p>
  167. </div>
  168. <table class="params">
  169. <tbody>
  170. <tr>
  171. <td class="name"><code>target</code></td>
  172. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <dl class="details">
  177. <dt class="tag-returns"><strong>Returns:</strong> The delta vector.</dt>
  178. </dl>
  179. </div>
  180. <h3 class="name name-method" id="distance" translate="no">.<a href="#distance">distance</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  181. <div class="method">
  182. <div class="description">
  183. <p>Returns the Euclidean distance between the line' start and end point.</p>
  184. </div>
  185. <dl class="details">
  186. <dt class="tag-returns"><strong>Returns:</strong> The Euclidean distance.</dt>
  187. </dl>
  188. </div>
  189. <h3 class="name name-method" id="distanceSq" translate="no">.<a href="#distanceSq">distanceSq</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  190. <div class="method">
  191. <div class="description">
  192. <p>Returns the squared Euclidean distance between the line' start and end point.</p>
  193. </div>
  194. <dl class="details">
  195. <dt class="tag-returns"><strong>Returns:</strong> The squared Euclidean distance.</dt>
  196. </dl>
  197. </div>
  198. <h3 class="name name-method" id="distanceSqToLine3" translate="no">.<a href="#distanceSqToLine3">distanceSqToLine3</a><span class="signature">( line : <span class="param-type">Line3</span>, c1 : <span class="param-type">Vector3</span>, c2 : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : number</span> </h3>
  199. <div class="method">
  200. <div class="description">
  201. <p>Returns the closest squared distance between this line segment and the given one.</p>
  202. </div>
  203. <table class="params">
  204. <tbody>
  205. <tr>
  206. <td class="name"><code>line</code></td>
  207. <td class="description last"><p>The line segment to compute the closest squared distance to.</p></td>
  208. </tr>
  209. <tr>
  210. <td class="name"><code>c1</code></td>
  211. <td class="description last"><p>The closest point on this line segment.</p></td>
  212. </tr>
  213. <tr>
  214. <td class="name"><code>c2</code></td>
  215. <td class="description last"><p>The closest point on the given line segment.</p></td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. <dl class="details">
  220. <dt class="tag-returns"><strong>Returns:</strong> The squared distance between this line segment and the given one.</dt>
  221. </dl>
  222. </div>
  223. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( line : <span class="param-type">Line3</span> )</span><span class="type-signature"> : boolean</span> </h3>
  224. <div class="method">
  225. <div class="description">
  226. <p>Returns <code>true</code> if this line segment is equal with the given one.</p>
  227. </div>
  228. <table class="params">
  229. <tbody>
  230. <tr>
  231. <td class="name"><code>line</code></td>
  232. <td class="description last"><p>The line segment to test for equality.</p></td>
  233. </tr>
  234. </tbody>
  235. </table>
  236. <dl class="details">
  237. <dt class="tag-returns"><strong>Returns:</strong> Whether this line segment is equal with the given one.</dt>
  238. </dl>
  239. </div>
  240. <h3 class="name name-method" id="getCenter" translate="no">.<a href="#getCenter">getCenter</a><span class="signature">( target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  241. <div class="method">
  242. <div class="description">
  243. <p>Returns the center of the line segment.</p>
  244. </div>
  245. <table class="params">
  246. <tbody>
  247. <tr>
  248. <td class="name"><code>target</code></td>
  249. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <dl class="details">
  254. <dt class="tag-returns"><strong>Returns:</strong> The center point.</dt>
  255. </dl>
  256. </div>
  257. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( start : <span class="param-type">Vector3</span>, end : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  258. <div class="method">
  259. <div class="description">
  260. <p>Sets the start and end values by copying the given vectors.</p>
  261. </div>
  262. <table class="params">
  263. <tbody>
  264. <tr>
  265. <td class="name"><code>start</code></td>
  266. <td class="description last"><p>The start point.</p></td>
  267. </tr>
  268. <tr>
  269. <td class="name"><code>end</code></td>
  270. <td class="description last"><p>The end point.</p></td>
  271. </tr>
  272. </tbody>
  273. </table>
  274. <dl class="details">
  275. <dt class="tag-returns"><strong>Returns:</strong> A reference to this line segment.</dt>
  276. </dl>
  277. </div>
  278. <h2 class="subsection-title">Source</h2>
  279. <p>
  280. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Line3.js" target="_blank" rel="noopener" translate="no">src/math/Line3.js</a>
  281. </p>
  282. </article>
  283. </section>
  284. <script src="../scripts/linenumber.js"></script>
  285. <script src="../scripts/page.js"></script>
  286. </body>
  287. </html>
粤ICP备19079148号