Plane.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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">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">Vector3</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"><code>normal</code></td>
  31. <td class="description last"><p>A unit length vector defining the normal of the plane.<br/>Default is <code>(1,0,0)</code>.</p></td>
  32. </tr>
  33. <tr>
  34. <td class="name"><code>constant</code></td>
  35. <td class="description last"><p>The signed distance from the origin to the plane.<br/>Default is <code>0</code>.</p></td>
  36. </tr>
  37. </tbody>
  38. </table>
  39. </div>
  40. </div>
  41. <h2 class="subsection-title">Properties</h2>
  42. <div class="member">
  43. <h3 class="name" id="constant" translate="no">.<a href="#constant">constant</a><span class="type-signature"> : number</span> </h3>
  44. <div class="description">
  45. <p>The signed distance from the origin to the plane.<br/>Default is <code>0</code>.</p>
  46. </div>
  47. </div>
  48. <div class="member">
  49. <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>
  50. <div class="description">
  51. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  52. </div>
  53. </div>
  54. <div class="member">
  55. <h3 class="name" id="normal" translate="no">.<a href="#normal">normal</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  56. <div class="description">
  57. <p>A unit length vector defining the normal of the plane.</p>
  58. </div>
  59. </div>
  60. <h2 class="subsection-title">Methods</h2>
  61. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( matrix : <span class="param-type">Matrix4</span>, optionalNormalMatrix : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  62. <div class="method">
  63. <div class="description">
  64. <p>Apply a 4x4 matrix to the plane. The matrix must be an affine, homogeneous transform.</p>
  65. <p>The optional normal matrix can be pre-computed like so:</p>
  66. <pre><code class="language-js">const optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
  67. </code></pre>
  68. </div>
  69. <table class="params">
  70. <tbody>
  71. <tr>
  72. <td class="name"><code>matrix</code></td>
  73. <td class="description last"><p>The transformation matrix.</p></td>
  74. </tr>
  75. <tr>
  76. <td class="name"><code>optionalNormalMatrix</code></td>
  77. <td class="description last"><p>A pre-computed normal matrix.</p></td>
  78. </tr>
  79. </tbody>
  80. </table>
  81. <dl class="details">
  82. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  83. </dl>
  84. </div>
  85. <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>
  86. <div class="method">
  87. <div class="description">
  88. <p>Returns a new plane with copied values from this instance.</p>
  89. </div>
  90. <dl class="details">
  91. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  92. </dl>
  93. </div>
  94. <h3 class="name name-method" id="coplanarPoint" translate="no">.<a href="#coplanarPoint">coplanarPoint</a><span class="signature">( target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  95. <div class="method">
  96. <div class="description">
  97. <p>Returns a coplanar vector to the plane, by calculating the
  98. projection of the normal at the origin onto the plane.</p>
  99. </div>
  100. <table class="params">
  101. <tbody>
  102. <tr>
  103. <td class="name"><code>target</code></td>
  104. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. <dl class="details">
  109. <dt class="tag-returns"><strong>Returns:</strong> The coplanar point.</dt>
  110. </dl>
  111. </div>
  112. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( plane : <span class="param-type">Plane</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  113. <div class="method">
  114. <div class="description">
  115. <p>Copies the values of the given plane to this instance.</p>
  116. </div>
  117. <table class="params">
  118. <tbody>
  119. <tr>
  120. <td class="name"><code>plane</code></td>
  121. <td class="description last"><p>The plane to copy.</p></td>
  122. </tr>
  123. </tbody>
  124. </table>
  125. <dl class="details">
  126. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  127. </dl>
  128. </div>
  129. <h3 class="name name-method" id="distanceToPoint" translate="no">.<a href="#distanceToPoint">distanceToPoint</a><span class="signature">( point : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : number</span> </h3>
  130. <div class="method">
  131. <div class="description">
  132. <p>Returns the signed distance from the given point to this plane.</p>
  133. </div>
  134. <table class="params">
  135. <tbody>
  136. <tr>
  137. <td class="name"><code>point</code></td>
  138. <td class="description last"><p>The point to compute the distance for.</p></td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. <dl class="details">
  143. <dt class="tag-returns"><strong>Returns:</strong> The signed distance.</dt>
  144. </dl>
  145. </div>
  146. <h3 class="name name-method" id="distanceToSphere" translate="no">.<a href="#distanceToSphere">distanceToSphere</a><span class="signature">( sphere : <span class="param-type">Sphere</span> )</span><span class="type-signature"> : number</span> </h3>
  147. <div class="method">
  148. <div class="description">
  149. <p>Returns the signed distance from the given sphere to this plane.</p>
  150. </div>
  151. <table class="params">
  152. <tbody>
  153. <tr>
  154. <td class="name"><code>sphere</code></td>
  155. <td class="description last"><p>The sphere to compute the distance for.</p></td>
  156. </tr>
  157. </tbody>
  158. </table>
  159. <dl class="details">
  160. <dt class="tag-returns"><strong>Returns:</strong> The signed distance.</dt>
  161. </dl>
  162. </div>
  163. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( plane : <span class="param-type">Plane</span> )</span><span class="type-signature"> : boolean</span> </h3>
  164. <div class="method">
  165. <div class="description">
  166. <p>Returns <code>true</code> if this plane is equal with the given one.</p>
  167. </div>
  168. <table class="params">
  169. <tbody>
  170. <tr>
  171. <td class="name"><code>plane</code></td>
  172. <td class="description last"><p>The plane to test for equality.</p></td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <dl class="details">
  177. <dt class="tag-returns"><strong>Returns:</strong> Whether this plane is equal with the given one.</dt>
  178. </dl>
  179. </div>
  180. <h3 class="name name-method" id="intersectLine" translate="no">.<a href="#intersectLine">intersectLine</a><span class="signature">( line : <span class="param-type">Line3</span>, target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  181. <div class="method">
  182. <div class="description">
  183. <p>Returns the intersection point of the passed line and the plane. Returns
  184. <code>null</code> if the line does not intersect. Returns the line's starting point if
  185. the line is coplanar with the plane.</p>
  186. </div>
  187. <table class="params">
  188. <tbody>
  189. <tr>
  190. <td class="name"><code>line</code></td>
  191. <td class="description last"><p>The line to compute the intersection for.</p></td>
  192. </tr>
  193. <tr>
  194. <td class="name"><code>target</code></td>
  195. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  196. </tr>
  197. </tbody>
  198. </table>
  199. <dl class="details">
  200. <dt class="tag-returns"><strong>Returns:</strong> The intersection point.</dt>
  201. </dl>
  202. </div>
  203. <h3 class="name name-method" id="intersectsBox" translate="no">.<a href="#intersectsBox">intersectsBox</a><span class="signature">( box : <span class="param-type">Box3</span> )</span><span class="type-signature"> : boolean</span> </h3>
  204. <div class="method">
  205. <div class="description">
  206. <p>Returns <code>true</code> if the given bounding box intersects with the plane.</p>
  207. </div>
  208. <table class="params">
  209. <tbody>
  210. <tr>
  211. <td class="name"><code>box</code></td>
  212. <td class="description last"><p>The bounding box to test.</p></td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <dl class="details">
  217. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding box intersects with the plane or not.</dt>
  218. </dl>
  219. </div>
  220. <h3 class="name name-method" id="intersectsLine" translate="no">.<a href="#intersectsLine">intersectsLine</a><span class="signature">( line : <span class="param-type">Line3</span> )</span><span class="type-signature"> : boolean</span> </h3>
  221. <div class="method">
  222. <div class="description">
  223. <p>Returns <code>true</code> if the given line segment intersects with (passes through) the plane.</p>
  224. </div>
  225. <table class="params">
  226. <tbody>
  227. <tr>
  228. <td class="name"><code>line</code></td>
  229. <td class="description last"><p>The line to test.</p></td>
  230. </tr>
  231. </tbody>
  232. </table>
  233. <dl class="details">
  234. <dt class="tag-returns"><strong>Returns:</strong> Whether the given line segment intersects with the plane or not.</dt>
  235. </dl>
  236. </div>
  237. <h3 class="name name-method" id="intersectsSphere" translate="no">.<a href="#intersectsSphere">intersectsSphere</a><span class="signature">( sphere : <span class="param-type">Sphere</span> )</span><span class="type-signature"> : boolean</span> </h3>
  238. <div class="method">
  239. <div class="description">
  240. <p>Returns <code>true</code> if the given bounding sphere intersects with the plane.</p>
  241. </div>
  242. <table class="params">
  243. <tbody>
  244. <tr>
  245. <td class="name"><code>sphere</code></td>
  246. <td class="description last"><p>The bounding sphere to test.</p></td>
  247. </tr>
  248. </tbody>
  249. </table>
  250. <dl class="details">
  251. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding sphere intersects with the plane or not.</dt>
  252. </dl>
  253. </div>
  254. <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>
  255. <div class="method">
  256. <div class="description">
  257. <p>Negates both the plane normal and the constant.</p>
  258. </div>
  259. <dl class="details">
  260. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  261. </dl>
  262. </div>
  263. <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>
  264. <div class="method">
  265. <div class="description">
  266. <p>Normalizes the plane normal and adjusts the constant accordingly.</p>
  267. </div>
  268. <dl class="details">
  269. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  270. </dl>
  271. </div>
  272. <h3 class="name name-method" id="projectPoint" translate="no">.<a href="#projectPoint">projectPoint</a><span class="signature">( point : <span class="param-type">Vector3</span>, target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  273. <div class="method">
  274. <div class="description">
  275. <p>Projects a the given point onto the plane.</p>
  276. </div>
  277. <table class="params">
  278. <tbody>
  279. <tr>
  280. <td class="name"><code>point</code></td>
  281. <td class="description last"><p>The point to project.</p></td>
  282. </tr>
  283. <tr>
  284. <td class="name"><code>target</code></td>
  285. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  286. </tr>
  287. </tbody>
  288. </table>
  289. <dl class="details">
  290. <dt class="tag-returns"><strong>Returns:</strong> The projected point on the plane.</dt>
  291. </dl>
  292. </div>
  293. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( normal : <span class="param-type">Vector3</span>, constant : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  294. <div class="method">
  295. <div class="description">
  296. <p>Sets the plane components by copying the given values.</p>
  297. </div>
  298. <table class="params">
  299. <tbody>
  300. <tr>
  301. <td class="name"><code>normal</code></td>
  302. <td class="description last"><p>The normal.</p></td>
  303. </tr>
  304. <tr>
  305. <td class="name"><code>constant</code></td>
  306. <td class="description last"><p>The constant.</p></td>
  307. </tr>
  308. </tbody>
  309. </table>
  310. <dl class="details">
  311. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  312. </dl>
  313. </div>
  314. <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>
  315. <div class="method">
  316. <div class="description">
  317. <p>Sets the plane components by defining <code>x</code>, <code>y</code>, <code>z</code> as the
  318. plane normal and <code>w</code> as the constant.</p>
  319. </div>
  320. <table class="params">
  321. <tbody>
  322. <tr>
  323. <td class="name"><code>x</code></td>
  324. <td class="description last"><p>The value for the normal's x component.</p></td>
  325. </tr>
  326. <tr>
  327. <td class="name"><code>y</code></td>
  328. <td class="description last"><p>The value for the normal's y component.</p></td>
  329. </tr>
  330. <tr>
  331. <td class="name"><code>z</code></td>
  332. <td class="description last"><p>The value for the normal's z component.</p></td>
  333. </tr>
  334. <tr>
  335. <td class="name"><code>w</code></td>
  336. <td class="description last"><p>The constant value.</p></td>
  337. </tr>
  338. </tbody>
  339. </table>
  340. <dl class="details">
  341. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  342. </dl>
  343. </div>
  344. <h3 class="name name-method" id="setFromCoplanarPoints" translate="no">.<a href="#setFromCoplanarPoints">setFromCoplanarPoints</a><span class="signature">( a : <span class="param-type">Vector3</span>, b : <span class="param-type">Vector3</span>, c : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  345. <div class="method">
  346. <div class="description">
  347. <p>Sets the plane from three coplanar points. The winding order is
  348. assumed to be counter-clockwise, and determines the direction of
  349. the plane normal.</p>
  350. </div>
  351. <table class="params">
  352. <tbody>
  353. <tr>
  354. <td class="name"><code>a</code></td>
  355. <td class="description last"><p>The first coplanar point.</p></td>
  356. </tr>
  357. <tr>
  358. <td class="name"><code>b</code></td>
  359. <td class="description last"><p>The second coplanar point.</p></td>
  360. </tr>
  361. <tr>
  362. <td class="name"><code>c</code></td>
  363. <td class="description last"><p>The third coplanar point.</p></td>
  364. </tr>
  365. </tbody>
  366. </table>
  367. <dl class="details">
  368. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  369. </dl>
  370. </div>
  371. <h3 class="name name-method" id="setFromNormalAndCoplanarPoint" translate="no">.<a href="#setFromNormalAndCoplanarPoint">setFromNormalAndCoplanarPoint</a><span class="signature">( normal : <span class="param-type">Vector3</span>, point : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  372. <div class="method">
  373. <div class="description">
  374. <p>Sets the plane from the given normal and coplanar point (that is a point
  375. that lies onto the plane).</p>
  376. </div>
  377. <table class="params">
  378. <tbody>
  379. <tr>
  380. <td class="name"><code>normal</code></td>
  381. <td class="description last"><p>The normal.</p></td>
  382. </tr>
  383. <tr>
  384. <td class="name"><code>point</code></td>
  385. <td class="description last"><p>A coplanar point.</p></td>
  386. </tr>
  387. </tbody>
  388. </table>
  389. <dl class="details">
  390. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  391. </dl>
  392. </div>
  393. <h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</a><span class="signature">( offset : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Plane.html">Plane</a></span> </h3>
  394. <div class="method">
  395. <div class="description">
  396. <p>Translates the plane by the distance defined by the given offset vector.
  397. Note that this only affects the plane constant and will not affect the normal vector.</p>
  398. </div>
  399. <table class="params">
  400. <tbody>
  401. <tr>
  402. <td class="name"><code>offset</code></td>
  403. <td class="description last"><p>The offset vector.</p></td>
  404. </tr>
  405. </tbody>
  406. </table>
  407. <dl class="details">
  408. <dt class="tag-returns"><strong>Returns:</strong> A reference to this plane.</dt>
  409. </dl>
  410. </div>
  411. <h2 class="subsection-title">Source</h2>
  412. <p>
  413. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Plane.js" target="_blank" rel="noopener" translate="no">src/math/Plane.js</a>
  414. </p>
  415. </article>
  416. </section>
  417. <script src="../scripts/linenumber.js"></script>
  418. <script src="../scripts/page.js"></script>
  419. </body>
  420. </html>
粤ICP备19079148号