Plane.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Plane - 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">Plane</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A two dimensional surface that extends infinitely in 3D space, represented
  16. in <a href="http://mathworld.wolfram.com/HessianNormalForm.html" target="_blank" rel="noopener">Hessian normal form</a>
  17. by a unit length normal vector and a constant.</p></div>
  18. </header>
  19. <article>
  20. <div class="container-overview">
  21. <h2>Constructor</h2>
  22. <h3 class="name name-method" id="Plane" translate="no">new <a href="#Plane">Plane</a><span class="signature">( normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, constant : <span class="param-type">number</span> )</span> </h3>
  23. <div class="method">
  24. <div class="description">
  25. <p>Constructs a new plane.</p>
  26. </div>
  27. <table class="params">
  28. <tbody>
  29. <tr>
  30. <td class="name">
  31. <strong translate="no">normal</strong>
  32. </td>
  33. <td class="description last">
  34. <p>A unit length vector defining the normal of the plane.</p>
  35. <p>Default is <code>(1,0,0)</code>.</p>
  36. </td>
  37. </tr>
  38. <tr>
  39. <td class="name">
  40. <strong translate="no">constant</strong>
  41. </td>
  42. <td class="description last">
  43. <p>The signed distance from the origin to the plane.</p>
  44. <p>Default is <code>0</code>.</p>
  45. </td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. <h2 class="subsection-title">Properties</h2>
  52. <div class="member">
  53. <h3 class="name" id="constant" translate="no">.<a href="#constant">constant</a><span class="type-signature"> : number</span> </h3>
  54. <div class="description">
  55. <p>The signed distance from the origin to the plane.</p>
  56. <p>Default is <code>0</code>.</p>
  57. </div>
  58. </div>
  59. <div class="member">
  60. <h3 class="name" id="isPlane" translate="no">.<a href="#isPlane">isPlane</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  61. <div class="description">
  62. <p>This flag can be used for type testing.</p>
  63. <p>Default is <code>true</code>.</p>
  64. </div>
  65. </div>
  66. <div class="member">
  67. <h3 class="name" id="normal" translate="no">.<a href="#normal">normal</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  68. <div class="description">
  69. <p>A unit length vector defining the normal of the plane.</p>
  70. </div>
  71. </div>
  72. <h2 class="subsection-title">Methods</h2>
  73. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( matrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span>, optionalNormalMatrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  74. <div class="method">
  75. <div class="description">
  76. <p>Apply a 4x4 matrix to the plane. The matrix must be an affine, homogeneous transform.</p>
  77. <p>The optional normal matrix can be pre-computed like so:</p>
  78. <pre><code class="language-js">const optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
  79. </code></pre>
  80. </div>
  81. <table class="params">
  82. <tbody>
  83. <tr>
  84. <td class="name">
  85. <strong translate="no">matrix</strong>
  86. </td>
  87. <td class="description last">
  88. <p>The transformation matrix.</p>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td class="name">
  93. <strong translate="no">optionalNormalMatrix</strong>
  94. </td>
  95. <td class="description last">
  96. <p>A pre-computed normal matrix.</p>
  97. </td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. <dl class="details">
  102. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  103. </dl>
  104. </div>
  105. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  106. <div class="method">
  107. <div class="description">
  108. <p>Returns a new plane with copied values from this instance.</p>
  109. </div>
  110. <dl class="details">
  111. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  112. </dl>
  113. </div>
  114. <h3 class="name name-method" id="coplanarPoint" translate="no">.<a href="#coplanarPoint">coplanarPoint</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>
  115. <div class="method">
  116. <div class="description">
  117. <p>Returns a coplanar vector to the plane, by calculating the
  118. projection of the normal at the origin onto the plane.</p>
  119. </div>
  120. <table class="params">
  121. <tbody>
  122. <tr>
  123. <td class="name">
  124. <strong translate="no">target</strong>
  125. </td>
  126. <td class="description last">
  127. <p>The target vector that is used to store the method's result.</p>
  128. </td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. <dl class="details">
  133. <dt class="tag-returns"><strong>Returns:</strong> The coplanar point.</dt>
  134. </dl>
  135. </div>
  136. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( plane : <span class="param-type"><a href="Plane.html">Plane</a></span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  137. <div class="method">
  138. <div class="description">
  139. <p>Copies the values of the given plane to this instance.</p>
  140. </div>
  141. <table class="params">
  142. <tbody>
  143. <tr>
  144. <td class="name">
  145. <strong translate="no">plane</strong>
  146. </td>
  147. <td class="description last">
  148. <p>The plane to copy.</p>
  149. </td>
  150. </tr>
  151. </tbody>
  152. </table>
  153. <dl class="details">
  154. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  155. </dl>
  156. </div>
  157. <h3 class="name name-method" id="distanceToPoint" translate="no">.<a href="#distanceToPoint">distanceToPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  158. <div class="method">
  159. <div class="description">
  160. <p>Returns the signed distance from the given point to this plane.</p>
  161. </div>
  162. <table class="params">
  163. <tbody>
  164. <tr>
  165. <td class="name">
  166. <strong translate="no">point</strong>
  167. </td>
  168. <td class="description last">
  169. <p>The point to compute the distance for.</p>
  170. </td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. <dl class="details">
  175. <dt class="tag-returns"><strong>Returns:</strong> The signed distance.</dt>
  176. </dl>
  177. </div>
  178. <h3 class="name name-method" id="distanceToSphere" translate="no">.<a href="#distanceToSphere">distanceToSphere</a><span class="signature">( sphere : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : number</span> </h3>
  179. <div class="method">
  180. <div class="description">
  181. <p>Returns the signed distance from the given sphere to this plane.</p>
  182. </div>
  183. <table class="params">
  184. <tbody>
  185. <tr>
  186. <td class="name">
  187. <strong translate="no">sphere</strong>
  188. </td>
  189. <td class="description last">
  190. <p>The sphere to compute the distance for.</p>
  191. </td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. <dl class="details">
  196. <dt class="tag-returns"><strong>Returns:</strong> The signed distance.</dt>
  197. </dl>
  198. </div>
  199. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( plane : <span class="param-type"><a href="Plane.html">Plane</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  200. <div class="method">
  201. <div class="description">
  202. <p>Returns <code>true</code> if this plane is equal with the given one.</p>
  203. </div>
  204. <table class="params">
  205. <tbody>
  206. <tr>
  207. <td class="name">
  208. <strong translate="no">plane</strong>
  209. </td>
  210. <td class="description last">
  211. <p>The plane to test for equality.</p>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <dl class="details">
  217. <dt class="tag-returns"><strong>Returns:</strong> Whether this plane is equal with the given one.</dt>
  218. </dl>
  219. </div>
  220. <h3 class="name name-method" id="intersectLine" translate="no">.<a href="#intersectLine">intersectLine</a><span class="signature">( line : <span class="param-type"><a href="Line3.html">Line3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, clampToLine : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  221. <div class="method">
  222. <div class="description">
  223. <p>Returns the intersection point of the passed line and the plane. Returns
  224. <code>null</code> if the line does not intersect. Returns the line's starting point if
  225. the line is coplanar with the plane.</p>
  226. </div>
  227. <table class="params">
  228. <tbody>
  229. <tr>
  230. <td class="name">
  231. <strong translate="no">line</strong>
  232. </td>
  233. <td class="description last">
  234. <p>The line to compute the intersection for.</p>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td class="name">
  239. <strong translate="no">target</strong>
  240. </td>
  241. <td class="description last">
  242. <p>The target vector that is used to store the method's result.</p>
  243. </td>
  244. </tr>
  245. <tr>
  246. <td class="name">
  247. <strong translate="no">clampToLine</strong>
  248. </td>
  249. <td class="description last">
  250. <p>Whether to clamp the intersection to the line segment.</p>
  251. <p>Default is <code>true</code>.</p>
  252. </td>
  253. </tr>
  254. </tbody>
  255. </table>
  256. <dl class="details">
  257. <dt class="tag-returns"><strong>Returns:</strong> The intersection point. Returns <code>null</code> if no intersection is detected.</dt>
  258. </dl>
  259. </div>
  260. <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>
  261. <div class="method">
  262. <div class="description">
  263. <p>Returns <code>true</code> if the given bounding box intersects with the plane.</p>
  264. </div>
  265. <table class="params">
  266. <tbody>
  267. <tr>
  268. <td class="name">
  269. <strong translate="no">box</strong>
  270. </td>
  271. <td class="description last">
  272. <p>The bounding box to test.</p>
  273. </td>
  274. </tr>
  275. </tbody>
  276. </table>
  277. <dl class="details">
  278. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding box intersects with the plane or not.</dt>
  279. </dl>
  280. </div>
  281. <h3 class="name name-method" id="intersectsLine" translate="no">.<a href="#intersectsLine">intersectsLine</a><span class="signature">( line : <span class="param-type"><a href="Line3.html">Line3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  282. <div class="method">
  283. <div class="description">
  284. <p>Returns <code>true</code> if the given line segment intersects with (passes through) the plane.</p>
  285. </div>
  286. <table class="params">
  287. <tbody>
  288. <tr>
  289. <td class="name">
  290. <strong translate="no">line</strong>
  291. </td>
  292. <td class="description last">
  293. <p>The line to test.</p>
  294. </td>
  295. </tr>
  296. </tbody>
  297. </table>
  298. <dl class="details">
  299. <dt class="tag-returns"><strong>Returns:</strong> Whether the given line segment intersects with the plane or not.</dt>
  300. </dl>
  301. </div>
  302. <h3 class="name name-method" id="intersectsSphere" translate="no">.<a href="#intersectsSphere">intersectsSphere</a><span class="signature">( sphere : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  303. <div class="method">
  304. <div class="description">
  305. <p>Returns <code>true</code> if the given bounding sphere intersects with the plane.</p>
  306. </div>
  307. <table class="params">
  308. <tbody>
  309. <tr>
  310. <td class="name">
  311. <strong translate="no">sphere</strong>
  312. </td>
  313. <td class="description last">
  314. <p>The bounding sphere to test.</p>
  315. </td>
  316. </tr>
  317. </tbody>
  318. </table>
  319. <dl class="details">
  320. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding sphere intersects with the plane or not.</dt>
  321. </dl>
  322. </div>
  323. <h3 class="name name-method" id="negate" translate="no">.<a href="#negate">negate</a><span class="signature">()</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  324. <div class="method">
  325. <div class="description">
  326. <p>Negates both the plane normal and the constant.</p>
  327. </div>
  328. <dl class="details">
  329. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  330. </dl>
  331. </div>
  332. <h3 class="name name-method" id="normalize" translate="no">.<a href="#normalize">normalize</a><span class="signature">()</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  333. <div class="method">
  334. <div class="description">
  335. <p>Normalizes the plane normal and adjusts the constant accordingly.</p>
  336. </div>
  337. <dl class="details">
  338. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  339. </dl>
  340. </div>
  341. <h3 class="name name-method" id="projectPoint" translate="no">.<a href="#projectPoint">projectPoint</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>
  342. <div class="method">
  343. <div class="description">
  344. <p>Projects a the given point onto the plane.</p>
  345. </div>
  346. <table class="params">
  347. <tbody>
  348. <tr>
  349. <td class="name">
  350. <strong translate="no">point</strong>
  351. </td>
  352. <td class="description last">
  353. <p>The point to project.</p>
  354. </td>
  355. </tr>
  356. <tr>
  357. <td class="name">
  358. <strong translate="no">target</strong>
  359. </td>
  360. <td class="description last">
  361. <p>The target vector that is used to store the method's result.</p>
  362. </td>
  363. </tr>
  364. </tbody>
  365. </table>
  366. <dl class="details">
  367. <dt class="tag-returns"><strong>Returns:</strong> The projected point on the plane.</dt>
  368. </dl>
  369. </div>
  370. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, constant : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  371. <div class="method">
  372. <div class="description">
  373. <p>Sets the plane components by copying the given values.</p>
  374. </div>
  375. <table class="params">
  376. <tbody>
  377. <tr>
  378. <td class="name">
  379. <strong translate="no">normal</strong>
  380. </td>
  381. <td class="description last">
  382. <p>The normal.</p>
  383. </td>
  384. </tr>
  385. <tr>
  386. <td class="name">
  387. <strong translate="no">constant</strong>
  388. </td>
  389. <td class="description last">
  390. <p>The constant.</p>
  391. </td>
  392. </tr>
  393. </tbody>
  394. </table>
  395. <dl class="details">
  396. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  397. </dl>
  398. </div>
  399. <h3 class="name name-method" id="setComponents" translate="no">.<a href="#setComponents">setComponents</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span>, w : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  400. <div class="method">
  401. <div class="description">
  402. <p>Sets the plane components by defining <code>x</code>, <code>y</code>, <code>z</code> as the
  403. plane normal and <code>w</code> as the constant.</p>
  404. </div>
  405. <table class="params">
  406. <tbody>
  407. <tr>
  408. <td class="name">
  409. <strong translate="no">x</strong>
  410. </td>
  411. <td class="description last">
  412. <p>The value for the normal's x component.</p>
  413. </td>
  414. </tr>
  415. <tr>
  416. <td class="name">
  417. <strong translate="no">y</strong>
  418. </td>
  419. <td class="description last">
  420. <p>The value for the normal's y component.</p>
  421. </td>
  422. </tr>
  423. <tr>
  424. <td class="name">
  425. <strong translate="no">z</strong>
  426. </td>
  427. <td class="description last">
  428. <p>The value for the normal's z component.</p>
  429. </td>
  430. </tr>
  431. <tr>
  432. <td class="name">
  433. <strong translate="no">w</strong>
  434. </td>
  435. <td class="description last">
  436. <p>The constant value.</p>
  437. </td>
  438. </tr>
  439. </tbody>
  440. </table>
  441. <dl class="details">
  442. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  443. </dl>
  444. </div>
  445. <h3 class="name name-method" id="setFromCoplanarPoints" translate="no">.<a href="#setFromCoplanarPoints">setFromCoplanarPoints</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="Plane.html">Plane</a></span> </h3>
  446. <div class="method">
  447. <div class="description">
  448. <p>Sets the plane from three coplanar points. The winding order is
  449. assumed to be counter-clockwise, and determines the direction of
  450. the plane normal.</p>
  451. </div>
  452. <table class="params">
  453. <tbody>
  454. <tr>
  455. <td class="name">
  456. <strong translate="no">a</strong>
  457. </td>
  458. <td class="description last">
  459. <p>The first coplanar point.</p>
  460. </td>
  461. </tr>
  462. <tr>
  463. <td class="name">
  464. <strong translate="no">b</strong>
  465. </td>
  466. <td class="description last">
  467. <p>The second coplanar point.</p>
  468. </td>
  469. </tr>
  470. <tr>
  471. <td class="name">
  472. <strong translate="no">c</strong>
  473. </td>
  474. <td class="description last">
  475. <p>The third coplanar point.</p>
  476. </td>
  477. </tr>
  478. </tbody>
  479. </table>
  480. <dl class="details">
  481. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  482. </dl>
  483. </div>
  484. <h3 class="name name-method" id="setFromNormalAndCoplanarPoint" translate="no">.<a href="#setFromNormalAndCoplanarPoint">setFromNormalAndCoplanarPoint</a><span class="signature">( normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  485. <div class="method">
  486. <div class="description">
  487. <p>Sets the plane from the given normal and coplanar point (that is a point
  488. that lies onto the plane).</p>
  489. </div>
  490. <table class="params">
  491. <tbody>
  492. <tr>
  493. <td class="name">
  494. <strong translate="no">normal</strong>
  495. </td>
  496. <td class="description last">
  497. <p>The normal.</p>
  498. </td>
  499. </tr>
  500. <tr>
  501. <td class="name">
  502. <strong translate="no">point</strong>
  503. </td>
  504. <td class="description last">
  505. <p>A coplanar point.</p>
  506. </td>
  507. </tr>
  508. </tbody>
  509. </table>
  510. <dl class="details">
  511. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  512. </dl>
  513. </div>
  514. <h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</a><span class="signature">( offset : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  515. <div class="method">
  516. <div class="description">
  517. <p>Translates the plane by the distance defined by the given offset vector.
  518. Note that this only affects the plane constant and will not affect the normal vector.</p>
  519. </div>
  520. <table class="params">
  521. <tbody>
  522. <tr>
  523. <td class="name">
  524. <strong translate="no">offset</strong>
  525. </td>
  526. <td class="description last">
  527. <p>The offset vector.</p>
  528. </td>
  529. </tr>
  530. </tbody>
  531. </table>
  532. <dl class="details">
  533. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  534. </dl>
  535. </div>
  536. <h2 class="subsection-title">Source</h2>
  537. <p>
  538. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Plane.js" translate="no" target="_blank" rel="noopener">src/math/Plane.js</a>
  539. </p>
  540. </article>
  541. </section>
  542. <script src="../scripts/linenumber.js"></script>
  543. <script src="../scripts/page.js"></script>
  544. </body>
  545. </html>
粤ICP备19079148号