Triangle.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Triangle - 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">Triangle</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A geometric triangle as defined by three vectors representing its three corners.</p></div>
  16. </header>
  17. <article>
  18. <div class="container-overview">
  19. <h2>Constructor</h2>
  20. <h3 class="name name-method" id="Triangle" translate="no">new <a href="#Triangle">Triangle</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, c : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span> </h3>
  21. <div class="method">
  22. <div class="description">
  23. <p>Constructs a new triangle.</p>
  24. </div>
  25. <table class="params">
  26. <tbody>
  27. <tr>
  28. <td class="name">
  29. <strong>a</strong>
  30. </td>
  31. <td class="description last">
  32. <p>The first corner of the triangle.</p>
  33. <p>Default is <code>(0,0,0)</code>.</p>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td class="name">
  38. <strong>b</strong>
  39. </td>
  40. <td class="description last">
  41. <p>The second corner of the triangle.</p>
  42. <p>Default is <code>(0,0,0)</code>.</p>
  43. </td>
  44. </tr>
  45. <tr>
  46. <td class="name">
  47. <strong>c</strong>
  48. </td>
  49. <td class="description last">
  50. <p>The third corner of the triangle.</p>
  51. <p>Default is <code>(0,0,0)</code>.</p>
  52. </td>
  53. </tr>
  54. </tbody>
  55. </table>
  56. </div>
  57. </div>
  58. <h2 class="subsection-title">Properties</h2>
  59. <div class="member">
  60. <h3 class="name" id="a" translate="no">.<a href="#a">a</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  61. <div class="description">
  62. <p>The first corner of the triangle.</p>
  63. </div>
  64. </div>
  65. <div class="member">
  66. <h3 class="name" id="b" translate="no">.<a href="#b">b</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  67. <div class="description">
  68. <p>The second corner of the triangle.</p>
  69. </div>
  70. </div>
  71. <div class="member">
  72. <h3 class="name" id="c" translate="no">.<a href="#c">c</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  73. <div class="description">
  74. <p>The third corner of the triangle.</p>
  75. </div>
  76. </div>
  77. <h2 class="subsection-title">Methods</h2>
  78. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Triangle.html">Triangle</a></span> </h3>
  79. <div class="method">
  80. <div class="description">
  81. <p>Returns a new triangle with copied values from this instance.</p>
  82. </div>
  83. <dl class="details">
  84. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  85. </dl>
  86. </div>
  87. <h3 class="name name-method" id="closestPointToPoint" translate="no">.<a href="#closestPointToPoint">closestPointToPoint</a><span class="signature">( p : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  88. <div class="method">
  89. <div class="description">
  90. <p>Returns the closest point on the triangle to the given point.</p>
  91. </div>
  92. <table class="params">
  93. <tbody>
  94. <tr>
  95. <td class="name">
  96. <strong>p</strong>
  97. </td>
  98. <td class="description last">
  99. <p>The point to compute the closest point for.</p>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td class="name">
  104. <strong>target</strong>
  105. </td>
  106. <td class="description last">
  107. <p>The target vector that is used to store the method's result.</p>
  108. </td>
  109. </tr>
  110. </tbody>
  111. </table>
  112. <dl class="details">
  113. <dt class="tag-returns"><strong>Returns:</strong> The closest point on the triangle.</dt>
  114. </dl>
  115. </div>
  116. <h3 class="name name-method" id="containsPoint" translate="no">.<a href="#containsPoint">containsPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  117. <div class="method">
  118. <div class="description">
  119. <p>Returns <code>true</code> if the given point, when projected onto the plane of the
  120. triangle, lies within the triangle.</p>
  121. </div>
  122. <table class="params">
  123. <tbody>
  124. <tr>
  125. <td class="name">
  126. <strong>point</strong>
  127. </td>
  128. <td class="description last">
  129. <p>The point in 3D space to test.</p>
  130. </td>
  131. </tr>
  132. </tbody>
  133. </table>
  134. <dl class="details">
  135. <dt class="tag-returns"><strong>Returns:</strong> Whether the given point, when projected onto the plane of the
  136. triangle, lies within the triangle or not.</dt>
  137. </dl>
  138. </div>
  139. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( triangle : <span class="param-type"><a href="Triangle.html">Triangle</a></span> )</span><span class="type-signature"> : <a href="Triangle.html">Triangle</a></span> </h3>
  140. <div class="method">
  141. <div class="description">
  142. <p>Copies the values of the given triangle to this instance.</p>
  143. </div>
  144. <table class="params">
  145. <tbody>
  146. <tr>
  147. <td class="name">
  148. <strong>triangle</strong>
  149. </td>
  150. <td class="description last">
  151. <p>The triangle to copy.</p>
  152. </td>
  153. </tr>
  154. </tbody>
  155. </table>
  156. <dl class="details">
  157. <dt class="tag-returns"><strong>Returns:</strong> A reference to this triangle.</dt>
  158. </dl>
  159. </div>
  160. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( triangle : <span class="param-type"><a href="Triangle.html">Triangle</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  161. <div class="method">
  162. <div class="description">
  163. <p>Returns <code>true</code> if this triangle is equal with the given one.</p>
  164. </div>
  165. <table class="params">
  166. <tbody>
  167. <tr>
  168. <td class="name">
  169. <strong>triangle</strong>
  170. </td>
  171. <td class="description last">
  172. <p>The triangle to test for equality.</p>
  173. </td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. <dl class="details">
  178. <dt class="tag-returns"><strong>Returns:</strong> Whether this triangle is equal with the given one.</dt>
  179. </dl>
  180. </div>
  181. <h3 class="name name-method" id="getArea" translate="no">.<a href="#getArea">getArea</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  182. <div class="method">
  183. <div class="description">
  184. <p>Computes the area of the triangle.</p>
  185. </div>
  186. <dl class="details">
  187. <dt class="tag-returns"><strong>Returns:</strong> The triangle's area.</dt>
  188. </dl>
  189. </div>
  190. <h3 class="name name-method" id="getBarycoord" translate="no">.<a href="#getBarycoord">getBarycoord</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  191. <div class="method">
  192. <div class="description">
  193. <p>Computes a barycentric coordinates from the given vector.
  194. Returns <code>null</code> if the triangle is degenerate.</p>
  195. </div>
  196. <table class="params">
  197. <tbody>
  198. <tr>
  199. <td class="name">
  200. <strong>point</strong>
  201. </td>
  202. <td class="description last">
  203. <p>A point in 3D space.</p>
  204. </td>
  205. </tr>
  206. <tr>
  207. <td class="name">
  208. <strong>target</strong>
  209. </td>
  210. <td class="description last">
  211. <p>The target vector that is used to store the method's result.</p>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <dl class="details">
  217. <dt class="tag-returns"><strong>Returns:</strong> The barycentric coordinates for the given point</dt>
  218. </dl>
  219. </div>
  220. <h3 class="name name-method" id="getInterpolation" translate="no">.<a href="#getInterpolation">getInterpolation</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, v1 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, v2 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, v3 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  221. <div class="method">
  222. <div class="description">
  223. <p>Computes the value barycentrically interpolated for the given point on the
  224. triangle. Returns <code>null</code> if the triangle is degenerate.</p>
  225. </div>
  226. <table class="params">
  227. <tbody>
  228. <tr>
  229. <td class="name">
  230. <strong>point</strong>
  231. </td>
  232. <td class="description last">
  233. <p>Position of interpolated point.</p>
  234. </td>
  235. </tr>
  236. <tr>
  237. <td class="name">
  238. <strong>v1</strong>
  239. </td>
  240. <td class="description last">
  241. <p>Value to interpolate of first vertex.</p>
  242. </td>
  243. </tr>
  244. <tr>
  245. <td class="name">
  246. <strong>v2</strong>
  247. </td>
  248. <td class="description last">
  249. <p>Value to interpolate of second vertex.</p>
  250. </td>
  251. </tr>
  252. <tr>
  253. <td class="name">
  254. <strong>v3</strong>
  255. </td>
  256. <td class="description last">
  257. <p>Value to interpolate of third vertex.</p>
  258. </td>
  259. </tr>
  260. <tr>
  261. <td class="name">
  262. <strong>target</strong>
  263. </td>
  264. <td class="description last">
  265. <p>The target vector that is used to store the method's result.</p>
  266. </td>
  267. </tr>
  268. </tbody>
  269. </table>
  270. <dl class="details">
  271. <dt class="tag-returns"><strong>Returns:</strong> The interpolated value.</dt>
  272. </dl>
  273. </div>
  274. <h3 class="name name-method" id="getMidpoint" translate="no">.<a href="#getMidpoint">getMidpoint</a><span class="signature">( target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  275. <div class="method">
  276. <div class="description">
  277. <p>Computes the midpoint of the triangle.</p>
  278. </div>
  279. <table class="params">
  280. <tbody>
  281. <tr>
  282. <td class="name">
  283. <strong>target</strong>
  284. </td>
  285. <td class="description last">
  286. <p>The target vector that is used to store the method's result.</p>
  287. </td>
  288. </tr>
  289. </tbody>
  290. </table>
  291. <dl class="details">
  292. <dt class="tag-returns"><strong>Returns:</strong> The triangle's midpoint.</dt>
  293. </dl>
  294. </div>
  295. <h3 class="name name-method" id="getNormal" translate="no">.<a href="#getNormal">getNormal</a><span class="signature">( target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  296. <div class="method">
  297. <div class="description">
  298. <p>Computes the normal of the triangle.</p>
  299. </div>
  300. <table class="params">
  301. <tbody>
  302. <tr>
  303. <td class="name">
  304. <strong>target</strong>
  305. </td>
  306. <td class="description last">
  307. <p>The target vector that is used to store the method's result.</p>
  308. </td>
  309. </tr>
  310. </tbody>
  311. </table>
  312. <dl class="details">
  313. <dt class="tag-returns"><strong>Returns:</strong> The triangle's normal.</dt>
  314. </dl>
  315. </div>
  316. <h3 class="name name-method" id="getPlane" translate="no">.<a href="#getPlane">getPlane</a><span class="signature">( target : <span class="param-type"><a href="Plane.html">Plane</a></span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  317. <div class="method">
  318. <div class="description">
  319. <p>Computes a plane the triangle lies within.</p>
  320. </div>
  321. <table class="params">
  322. <tbody>
  323. <tr>
  324. <td class="name">
  325. <strong>target</strong>
  326. </td>
  327. <td class="description last">
  328. <p>The target vector that is used to store the method's result.</p>
  329. </td>
  330. </tr>
  331. </tbody>
  332. </table>
  333. <dl class="details">
  334. <dt class="tag-returns"><strong>Returns:</strong> The plane the triangle lies within.</dt>
  335. </dl>
  336. </div>
  337. <h3 class="name name-method" id="intersectsBox" translate="no">.<a href="#intersectsBox">intersectsBox</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  338. <div class="method">
  339. <div class="description">
  340. <p>Returns <code>true</code> if this triangle intersects with the given box.</p>
  341. </div>
  342. <table class="params">
  343. <tbody>
  344. <tr>
  345. <td class="name">
  346. <strong>box</strong>
  347. </td>
  348. <td class="description last">
  349. <p>The box to intersect.</p>
  350. </td>
  351. </tr>
  352. </tbody>
  353. </table>
  354. <dl class="details">
  355. <dt class="tag-returns"><strong>Returns:</strong> Whether this triangle intersects with the given box or not.</dt>
  356. </dl>
  357. </div>
  358. <h3 class="name name-method" id="isFrontFacing" translate="no">.<a href="#isFrontFacing">isFrontFacing</a><span class="signature">( direction : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  359. <div class="method">
  360. <div class="description">
  361. <p>Returns <code>true</code> if the triangle is oriented towards the given direction.</p>
  362. </div>
  363. <table class="params">
  364. <tbody>
  365. <tr>
  366. <td class="name">
  367. <strong>direction</strong>
  368. </td>
  369. <td class="description last">
  370. <p>The (normalized) direction vector.</p>
  371. </td>
  372. </tr>
  373. </tbody>
  374. </table>
  375. <dl class="details">
  376. <dt class="tag-returns"><strong>Returns:</strong> Whether the triangle is oriented towards the given direction or not.</dt>
  377. </dl>
  378. </div>
  379. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, c : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Triangle.html">Triangle</a></span> </h3>
  380. <div class="method">
  381. <div class="description">
  382. <p>Sets the triangle's vertices by copying the given values.</p>
  383. </div>
  384. <table class="params">
  385. <tbody>
  386. <tr>
  387. <td class="name">
  388. <strong>a</strong>
  389. </td>
  390. <td class="description last">
  391. <p>The first corner of the triangle.</p>
  392. </td>
  393. </tr>
  394. <tr>
  395. <td class="name">
  396. <strong>b</strong>
  397. </td>
  398. <td class="description last">
  399. <p>The second corner of the triangle.</p>
  400. </td>
  401. </tr>
  402. <tr>
  403. <td class="name">
  404. <strong>c</strong>
  405. </td>
  406. <td class="description last">
  407. <p>The third corner of the triangle.</p>
  408. </td>
  409. </tr>
  410. </tbody>
  411. </table>
  412. <dl class="details">
  413. <dt class="tag-returns"><strong>Returns:</strong> A reference to this triangle.</dt>
  414. </dl>
  415. </div>
  416. <h3 class="name name-method" id="setFromAttributeAndIndices" translate="no">.<a href="#setFromAttributeAndIndices">setFromAttributeAndIndices</a><span class="signature">( attribute : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a></span>, i0 : <span class="param-type">number</span>, i1 : <span class="param-type">number</span>, i2 : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Triangle.html">Triangle</a></span> </h3>
  417. <div class="method">
  418. <div class="description">
  419. <p>Sets the triangle's vertices by copying the given attribute values.</p>
  420. </div>
  421. <table class="params">
  422. <tbody>
  423. <tr>
  424. <td class="name">
  425. <strong>attribute</strong>
  426. </td>
  427. <td class="description last">
  428. <p>A buffer attribute with 3D points data.</p>
  429. </td>
  430. </tr>
  431. <tr>
  432. <td class="name">
  433. <strong>i0</strong>
  434. </td>
  435. <td class="description last">
  436. <p>The attribute index representing the first corner of the triangle.</p>
  437. </td>
  438. </tr>
  439. <tr>
  440. <td class="name">
  441. <strong>i1</strong>
  442. </td>
  443. <td class="description last">
  444. <p>The attribute index representing the second corner of the triangle.</p>
  445. </td>
  446. </tr>
  447. <tr>
  448. <td class="name">
  449. <strong>i2</strong>
  450. </td>
  451. <td class="description last">
  452. <p>The attribute index representing the third corner of the triangle.</p>
  453. </td>
  454. </tr>
  455. </tbody>
  456. </table>
  457. <dl class="details">
  458. <dt class="tag-returns"><strong>Returns:</strong> A reference to this triangle.</dt>
  459. </dl>
  460. </div>
  461. <h3 class="name name-method" id="setFromPointsAndIndices" translate="no">.<a href="#setFromPointsAndIndices">setFromPointsAndIndices</a><span class="signature">( points : <span class="param-type">Array.&lt;<a href="Vector3.html">Vector3</a>></span>, i0 : <span class="param-type">number</span>, i1 : <span class="param-type">number</span>, i2 : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Triangle.html">Triangle</a></span> </h3>
  462. <div class="method">
  463. <div class="description">
  464. <p>Sets the triangle's vertices by copying the given array values.</p>
  465. </div>
  466. <table class="params">
  467. <tbody>
  468. <tr>
  469. <td class="name">
  470. <strong>points</strong>
  471. </td>
  472. <td class="description last">
  473. <p>An array with 3D points.</p>
  474. </td>
  475. </tr>
  476. <tr>
  477. <td class="name">
  478. <strong>i0</strong>
  479. </td>
  480. <td class="description last">
  481. <p>The array index representing the first corner of the triangle.</p>
  482. </td>
  483. </tr>
  484. <tr>
  485. <td class="name">
  486. <strong>i1</strong>
  487. </td>
  488. <td class="description last">
  489. <p>The array index representing the second corner of the triangle.</p>
  490. </td>
  491. </tr>
  492. <tr>
  493. <td class="name">
  494. <strong>i2</strong>
  495. </td>
  496. <td class="description last">
  497. <p>The array index representing the third corner of the triangle.</p>
  498. </td>
  499. </tr>
  500. </tbody>
  501. </table>
  502. <dl class="details">
  503. <dt class="tag-returns"><strong>Returns:</strong> A reference to this triangle.</dt>
  504. </dl>
  505. </div>
  506. <h2 class="subsection-title">Static Methods</h2>
  507. <h3 class="name name-method" id=".containsPoint" translate="no">.<a href="#.containsPoint">containsPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, c : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  508. <div class="method">
  509. <div class="description">
  510. <p>Returns <code>true</code> if the given point, when projected onto the plane of the
  511. triangle, lies within the triangle.</p>
  512. </div>
  513. <table class="params">
  514. <tbody>
  515. <tr>
  516. <td class="name">
  517. <strong>point</strong>
  518. </td>
  519. <td class="description last">
  520. <p>The point in 3D space to test.</p>
  521. </td>
  522. </tr>
  523. <tr>
  524. <td class="name">
  525. <strong>a</strong>
  526. </td>
  527. <td class="description last">
  528. <p>The first corner of the triangle.</p>
  529. </td>
  530. </tr>
  531. <tr>
  532. <td class="name">
  533. <strong>b</strong>
  534. </td>
  535. <td class="description last">
  536. <p>The second corner of the triangle.</p>
  537. </td>
  538. </tr>
  539. <tr>
  540. <td class="name">
  541. <strong>c</strong>
  542. </td>
  543. <td class="description last">
  544. <p>The third corner of the triangle.</p>
  545. </td>
  546. </tr>
  547. </tbody>
  548. </table>
  549. <dl class="details">
  550. <dt class="tag-returns"><strong>Returns:</strong> Whether the given point, when projected onto the plane of the
  551. triangle, lies within the triangle or not.</dt>
  552. </dl>
  553. </div>
  554. <h3 class="name name-method" id=".getBarycoord" translate="no">.<a href="#.getBarycoord">getBarycoord</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, c : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  555. <div class="method">
  556. <div class="description">
  557. <p>Computes a barycentric coordinates from the given vector.
  558. Returns <code>null</code> if the triangle is degenerate.</p>
  559. </div>
  560. <table class="params">
  561. <tbody>
  562. <tr>
  563. <td class="name">
  564. <strong>point</strong>
  565. </td>
  566. <td class="description last">
  567. <p>A point in 3D space.</p>
  568. </td>
  569. </tr>
  570. <tr>
  571. <td class="name">
  572. <strong>a</strong>
  573. </td>
  574. <td class="description last">
  575. <p>The first corner of the triangle.</p>
  576. </td>
  577. </tr>
  578. <tr>
  579. <td class="name">
  580. <strong>b</strong>
  581. </td>
  582. <td class="description last">
  583. <p>The second corner of the triangle.</p>
  584. </td>
  585. </tr>
  586. <tr>
  587. <td class="name">
  588. <strong>c</strong>
  589. </td>
  590. <td class="description last">
  591. <p>The third corner of the triangle.</p>
  592. </td>
  593. </tr>
  594. <tr>
  595. <td class="name">
  596. <strong>target</strong>
  597. </td>
  598. <td class="description last">
  599. <p>The target vector that is used to store the method's result.</p>
  600. </td>
  601. </tr>
  602. </tbody>
  603. </table>
  604. <dl class="details">
  605. <dt class="tag-returns"><strong>Returns:</strong> The barycentric coordinates for the given point</dt>
  606. </dl>
  607. </div>
  608. <h3 class="name name-method" id=".getInterpolatedAttribute" translate="no">.<a href="#.getInterpolatedAttribute">getInterpolatedAttribute</a><span class="signature">( attr : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a></span>, i1 : <span class="param-type">number</span>, i2 : <span class="param-type">number</span>, i3 : <span class="param-type">number</span>, barycoord : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  609. <div class="method">
  610. <div class="description">
  611. <p>Computes the value barycentrically interpolated for the given attribute and indices.</p>
  612. </div>
  613. <table class="params">
  614. <tbody>
  615. <tr>
  616. <td class="name">
  617. <strong>attr</strong>
  618. </td>
  619. <td class="description last">
  620. <p>The attribute to interpolate.</p>
  621. </td>
  622. </tr>
  623. <tr>
  624. <td class="name">
  625. <strong>i1</strong>
  626. </td>
  627. <td class="description last">
  628. <p>Index of first vertex.</p>
  629. </td>
  630. </tr>
  631. <tr>
  632. <td class="name">
  633. <strong>i2</strong>
  634. </td>
  635. <td class="description last">
  636. <p>Index of second vertex.</p>
  637. </td>
  638. </tr>
  639. <tr>
  640. <td class="name">
  641. <strong>i3</strong>
  642. </td>
  643. <td class="description last">
  644. <p>Index of third vertex.</p>
  645. </td>
  646. </tr>
  647. <tr>
  648. <td class="name">
  649. <strong>barycoord</strong>
  650. </td>
  651. <td class="description last">
  652. <p>The barycoordinate value to use to interpolate.</p>
  653. </td>
  654. </tr>
  655. <tr>
  656. <td class="name">
  657. <strong>target</strong>
  658. </td>
  659. <td class="description last">
  660. <p>The target vector that is used to store the method's result.</p>
  661. </td>
  662. </tr>
  663. </tbody>
  664. </table>
  665. <dl class="details">
  666. <dt class="tag-returns"><strong>Returns:</strong> The interpolated attribute value.</dt>
  667. </dl>
  668. </div>
  669. <h3 class="name name-method" id=".getInterpolation" translate="no">.<a href="#.getInterpolation">getInterpolation</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, p1 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, p2 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, p3 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, v1 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, v2 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, v3 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  670. <div class="method">
  671. <div class="description">
  672. <p>Computes the value barycentrically interpolated for the given point on the
  673. triangle. Returns <code>null</code> if the triangle is degenerate.</p>
  674. </div>
  675. <table class="params">
  676. <tbody>
  677. <tr>
  678. <td class="name">
  679. <strong>point</strong>
  680. </td>
  681. <td class="description last">
  682. <p>Position of interpolated point.</p>
  683. </td>
  684. </tr>
  685. <tr>
  686. <td class="name">
  687. <strong>p1</strong>
  688. </td>
  689. <td class="description last">
  690. <p>The first corner of the triangle.</p>
  691. </td>
  692. </tr>
  693. <tr>
  694. <td class="name">
  695. <strong>p2</strong>
  696. </td>
  697. <td class="description last">
  698. <p>The second corner of the triangle.</p>
  699. </td>
  700. </tr>
  701. <tr>
  702. <td class="name">
  703. <strong>p3</strong>
  704. </td>
  705. <td class="description last">
  706. <p>The third corner of the triangle.</p>
  707. </td>
  708. </tr>
  709. <tr>
  710. <td class="name">
  711. <strong>v1</strong>
  712. </td>
  713. <td class="description last">
  714. <p>Value to interpolate of first vertex.</p>
  715. </td>
  716. </tr>
  717. <tr>
  718. <td class="name">
  719. <strong>v2</strong>
  720. </td>
  721. <td class="description last">
  722. <p>Value to interpolate of second vertex.</p>
  723. </td>
  724. </tr>
  725. <tr>
  726. <td class="name">
  727. <strong>v3</strong>
  728. </td>
  729. <td class="description last">
  730. <p>Value to interpolate of third vertex.</p>
  731. </td>
  732. </tr>
  733. <tr>
  734. <td class="name">
  735. <strong>target</strong>
  736. </td>
  737. <td class="description last">
  738. <p>The target vector that is used to store the method's result.</p>
  739. </td>
  740. </tr>
  741. </tbody>
  742. </table>
  743. <dl class="details">
  744. <dt class="tag-returns"><strong>Returns:</strong> The interpolated value.</dt>
  745. </dl>
  746. </div>
  747. <h3 class="name name-method" id=".getNormal" translate="no">.<a href="#.getNormal">getNormal</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, c : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  748. <div class="method">
  749. <div class="description">
  750. <p>Computes the normal vector of a triangle.</p>
  751. </div>
  752. <table class="params">
  753. <tbody>
  754. <tr>
  755. <td class="name">
  756. <strong>a</strong>
  757. </td>
  758. <td class="description last">
  759. <p>The first corner of the triangle.</p>
  760. </td>
  761. </tr>
  762. <tr>
  763. <td class="name">
  764. <strong>b</strong>
  765. </td>
  766. <td class="description last">
  767. <p>The second corner of the triangle.</p>
  768. </td>
  769. </tr>
  770. <tr>
  771. <td class="name">
  772. <strong>c</strong>
  773. </td>
  774. <td class="description last">
  775. <p>The third corner of the triangle.</p>
  776. </td>
  777. </tr>
  778. <tr>
  779. <td class="name">
  780. <strong>target</strong>
  781. </td>
  782. <td class="description last">
  783. <p>The target vector that is used to store the method's result.</p>
  784. </td>
  785. </tr>
  786. </tbody>
  787. </table>
  788. <dl class="details">
  789. <dt class="tag-returns"><strong>Returns:</strong> The triangle's normal.</dt>
  790. </dl>
  791. </div>
  792. <h3 class="name name-method" id=".isFrontFacing" translate="no">.<a href="#.isFrontFacing">isFrontFacing</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, c : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, direction : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  793. <div class="method">
  794. <div class="description">
  795. <p>Returns <code>true</code> if the triangle is oriented towards the given direction.</p>
  796. </div>
  797. <table class="params">
  798. <tbody>
  799. <tr>
  800. <td class="name">
  801. <strong>a</strong>
  802. </td>
  803. <td class="description last">
  804. <p>The first corner of the triangle.</p>
  805. </td>
  806. </tr>
  807. <tr>
  808. <td class="name">
  809. <strong>b</strong>
  810. </td>
  811. <td class="description last">
  812. <p>The second corner of the triangle.</p>
  813. </td>
  814. </tr>
  815. <tr>
  816. <td class="name">
  817. <strong>c</strong>
  818. </td>
  819. <td class="description last">
  820. <p>The third corner of the triangle.</p>
  821. </td>
  822. </tr>
  823. <tr>
  824. <td class="name">
  825. <strong>direction</strong>
  826. </td>
  827. <td class="description last">
  828. <p>The (normalized) direction vector.</p>
  829. </td>
  830. </tr>
  831. </tbody>
  832. </table>
  833. <dl class="details">
  834. <dt class="tag-returns"><strong>Returns:</strong> Whether the triangle is oriented towards the given direction or not.</dt>
  835. </dl>
  836. </div>
  837. <h2 class="subsection-title">Source</h2>
  838. <p>
  839. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Triangle.js" translate="no" target="_blank" rel="noopener">src/math/Triangle.js</a>
  840. </p>
  841. </article>
  842. </section>
  843. <script src="../scripts/linenumber.js"></script>
  844. <script src="../scripts/page.js"></script>
  845. </body>
  846. </html>
粤ICP备19079148号