Plane.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  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>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>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>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>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>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>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>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>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>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> )</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>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>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. </tbody>
  246. </table>
  247. <dl class="details">
  248. <dt class="tag-returns"><strong>Returns:</strong> The intersection point.</dt>
  249. </dl>
  250. </div>
  251. <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>
  252. <div class="method">
  253. <div class="description">
  254. <p>Returns <code>true</code> if the given bounding box intersects with the plane.</p>
  255. </div>
  256. <table class="params">
  257. <tbody>
  258. <tr>
  259. <td class="name">
  260. <strong>box</strong>
  261. </td>
  262. <td class="description last">
  263. <p>The bounding box to test.</p>
  264. </td>
  265. </tr>
  266. </tbody>
  267. </table>
  268. <dl class="details">
  269. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding box intersects with the plane or not.</dt>
  270. </dl>
  271. </div>
  272. <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>
  273. <div class="method">
  274. <div class="description">
  275. <p>Returns <code>true</code> if the given line segment intersects with (passes through) the plane.</p>
  276. </div>
  277. <table class="params">
  278. <tbody>
  279. <tr>
  280. <td class="name">
  281. <strong>line</strong>
  282. </td>
  283. <td class="description last">
  284. <p>The line to test.</p>
  285. </td>
  286. </tr>
  287. </tbody>
  288. </table>
  289. <dl class="details">
  290. <dt class="tag-returns"><strong>Returns:</strong> Whether the given line segment intersects with the plane or not.</dt>
  291. </dl>
  292. </div>
  293. <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>
  294. <div class="method">
  295. <div class="description">
  296. <p>Returns <code>true</code> if the given bounding sphere intersects with the plane.</p>
  297. </div>
  298. <table class="params">
  299. <tbody>
  300. <tr>
  301. <td class="name">
  302. <strong>sphere</strong>
  303. </td>
  304. <td class="description last">
  305. <p>The bounding sphere to test.</p>
  306. </td>
  307. </tr>
  308. </tbody>
  309. </table>
  310. <dl class="details">
  311. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding sphere intersects with the plane or not.</dt>
  312. </dl>
  313. </div>
  314. <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>
  315. <div class="method">
  316. <div class="description">
  317. <p>Negates both the plane normal and the constant.</p>
  318. </div>
  319. <dl class="details">
  320. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  321. </dl>
  322. </div>
  323. <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>
  324. <div class="method">
  325. <div class="description">
  326. <p>Normalizes the plane normal and adjusts the constant accordingly.</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="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>
  333. <div class="method">
  334. <div class="description">
  335. <p>Projects a the given point onto the plane.</p>
  336. </div>
  337. <table class="params">
  338. <tbody>
  339. <tr>
  340. <td class="name">
  341. <strong>point</strong>
  342. </td>
  343. <td class="description last">
  344. <p>The point to project.</p>
  345. </td>
  346. </tr>
  347. <tr>
  348. <td class="name">
  349. <strong>target</strong>
  350. </td>
  351. <td class="description last">
  352. <p>The target vector that is used to store the method's result.</p>
  353. </td>
  354. </tr>
  355. </tbody>
  356. </table>
  357. <dl class="details">
  358. <dt class="tag-returns"><strong>Returns:</strong> The projected point on the plane.</dt>
  359. </dl>
  360. </div>
  361. <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>
  362. <div class="method">
  363. <div class="description">
  364. <p>Sets the plane components by copying the given values.</p>
  365. </div>
  366. <table class="params">
  367. <tbody>
  368. <tr>
  369. <td class="name">
  370. <strong>normal</strong>
  371. </td>
  372. <td class="description last">
  373. <p>The normal.</p>
  374. </td>
  375. </tr>
  376. <tr>
  377. <td class="name">
  378. <strong>constant</strong>
  379. </td>
  380. <td class="description last">
  381. <p>The constant.</p>
  382. </td>
  383. </tr>
  384. </tbody>
  385. </table>
  386. <dl class="details">
  387. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  388. </dl>
  389. </div>
  390. <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>
  391. <div class="method">
  392. <div class="description">
  393. <p>Sets the plane components by defining <code>x</code>, <code>y</code>, <code>z</code> as the
  394. plane normal and <code>w</code> as the constant.</p>
  395. </div>
  396. <table class="params">
  397. <tbody>
  398. <tr>
  399. <td class="name">
  400. <strong>x</strong>
  401. </td>
  402. <td class="description last">
  403. <p>The value for the normal's x component.</p>
  404. </td>
  405. </tr>
  406. <tr>
  407. <td class="name">
  408. <strong>y</strong>
  409. </td>
  410. <td class="description last">
  411. <p>The value for the normal's y component.</p>
  412. </td>
  413. </tr>
  414. <tr>
  415. <td class="name">
  416. <strong>z</strong>
  417. </td>
  418. <td class="description last">
  419. <p>The value for the normal's z component.</p>
  420. </td>
  421. </tr>
  422. <tr>
  423. <td class="name">
  424. <strong>w</strong>
  425. </td>
  426. <td class="description last">
  427. <p>The constant value.</p>
  428. </td>
  429. </tr>
  430. </tbody>
  431. </table>
  432. <dl class="details">
  433. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  434. </dl>
  435. </div>
  436. <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>
  437. <div class="method">
  438. <div class="description">
  439. <p>Sets the plane from three coplanar points. The winding order is
  440. assumed to be counter-clockwise, and determines the direction of
  441. the plane normal.</p>
  442. </div>
  443. <table class="params">
  444. <tbody>
  445. <tr>
  446. <td class="name">
  447. <strong>a</strong>
  448. </td>
  449. <td class="description last">
  450. <p>The first coplanar point.</p>
  451. </td>
  452. </tr>
  453. <tr>
  454. <td class="name">
  455. <strong>b</strong>
  456. </td>
  457. <td class="description last">
  458. <p>The second coplanar point.</p>
  459. </td>
  460. </tr>
  461. <tr>
  462. <td class="name">
  463. <strong>c</strong>
  464. </td>
  465. <td class="description last">
  466. <p>The third coplanar point.</p>
  467. </td>
  468. </tr>
  469. </tbody>
  470. </table>
  471. <dl class="details">
  472. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  473. </dl>
  474. </div>
  475. <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>
  476. <div class="method">
  477. <div class="description">
  478. <p>Sets the plane from the given normal and coplanar point (that is a point
  479. that lies onto the plane).</p>
  480. </div>
  481. <table class="params">
  482. <tbody>
  483. <tr>
  484. <td class="name">
  485. <strong>normal</strong>
  486. </td>
  487. <td class="description last">
  488. <p>The normal.</p>
  489. </td>
  490. </tr>
  491. <tr>
  492. <td class="name">
  493. <strong>point</strong>
  494. </td>
  495. <td class="description last">
  496. <p>A coplanar point.</p>
  497. </td>
  498. </tr>
  499. </tbody>
  500. </table>
  501. <dl class="details">
  502. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  503. </dl>
  504. </div>
  505. <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>
  506. <div class="method">
  507. <div class="description">
  508. <p>Translates the plane by the distance defined by the given offset vector.
  509. Note that this only affects the plane constant and will not affect the normal vector.</p>
  510. </div>
  511. <table class="params">
  512. <tbody>
  513. <tr>
  514. <td class="name">
  515. <strong>offset</strong>
  516. </td>
  517. <td class="description last">
  518. <p>The offset vector.</p>
  519. </td>
  520. </tr>
  521. </tbody>
  522. </table>
  523. <dl class="details">
  524. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  525. </dl>
  526. </div>
  527. <h2 class="subsection-title">Source</h2>
  528. <p>
  529. <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>
  530. </p>
  531. </article>
  532. </section>
  533. <script src="../scripts/linenumber.js"></script>
  534. <script src="../scripts/page.js"></script>
  535. </body>
  536. </html>
粤ICP备19079148号