Matrix3.html 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Matrix3 - 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">Matrix3</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Represents a 3x3 matrix.</p>
  16. <p>A Note on Row-Major and Column-Major Ordering:</p>
  17. <p>The constructor and <a href="Matrix3.html#set">Matrix3#set</a> method take arguments in
  18. <a href="https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order" target="_blank" rel="noopener">row-major</a>
  19. order, while internally they are stored in the <a href="Matrix3.html#elements">Matrix3#elements</a> array in column-major order.
  20. This means that calling:</p>
  21. <p>will result in the elements array containing:</p>
  22. <pre><code class="language-js">m.elements = [ 11, 21, 31,
  23. 12, 22, 32,
  24. 13, 23, 33 ];
  25. </code></pre>
  26. <p>and internally all calculations are performed using column-major ordering.
  27. However, as the actual ordering makes no difference mathematically and
  28. most people are used to thinking about matrices in row-major order, the
  29. three.js documentation shows matrices in row-major order. Just bear in
  30. mind that if you are reading the source code, you'll have to take the
  31. transpose of any matrices outlined here to make sense of the calculations.</p></div>
  32. <h2>Code Example</h2>
  33. <div translate="no"><pre><code class="language-js">const m = new THREE.Matrix();
  34. m.set( 11, 12, 13,
  35. 21, 22, 23,
  36. 31, 32, 33 );
  37. </code></pre></div>
  38. </header>
  39. <article>
  40. <div class="container-overview">
  41. <h2>Constructor</h2>
  42. <h3 class="name name-method" id="Matrix3" translate="no">new <a href="#Matrix3">Matrix3</a><span class="signature">( n11 : <span class="param-type">number</span>, n12 : <span class="param-type">number</span>, n13 : <span class="param-type">number</span>, n21 : <span class="param-type">number</span>, n22 : <span class="param-type">number</span>, n23 : <span class="param-type">number</span>, n31 : <span class="param-type">number</span>, n32 : <span class="param-type">number</span>, n33 : <span class="param-type">number</span> )</span> </h3>
  43. <div class="method">
  44. <div class="description">
  45. <p>Constructs a new 3x3 matrix. The arguments are supposed to be
  46. in row-major order. If no arguments are provided, the constructor
  47. initializes the matrix as an identity matrix.</p>
  48. </div>
  49. <table class="params">
  50. <tbody>
  51. <tr>
  52. <td class="name">
  53. <strong>n11</strong>
  54. </td>
  55. <td class="description last">
  56. <p>1-1 matrix element.</p>
  57. </td>
  58. </tr>
  59. <tr>
  60. <td class="name">
  61. <strong>n12</strong>
  62. </td>
  63. <td class="description last">
  64. <p>1-2 matrix element.</p>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td class="name">
  69. <strong>n13</strong>
  70. </td>
  71. <td class="description last">
  72. <p>1-3 matrix element.</p>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td class="name">
  77. <strong>n21</strong>
  78. </td>
  79. <td class="description last">
  80. <p>2-1 matrix element.</p>
  81. </td>
  82. </tr>
  83. <tr>
  84. <td class="name">
  85. <strong>n22</strong>
  86. </td>
  87. <td class="description last">
  88. <p>2-2 matrix element.</p>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td class="name">
  93. <strong>n23</strong>
  94. </td>
  95. <td class="description last">
  96. <p>2-3 matrix element.</p>
  97. </td>
  98. </tr>
  99. <tr>
  100. <td class="name">
  101. <strong>n31</strong>
  102. </td>
  103. <td class="description last">
  104. <p>3-1 matrix element.</p>
  105. </td>
  106. </tr>
  107. <tr>
  108. <td class="name">
  109. <strong>n32</strong>
  110. </td>
  111. <td class="description last">
  112. <p>3-2 matrix element.</p>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td class="name">
  117. <strong>n33</strong>
  118. </td>
  119. <td class="description last">
  120. <p>3-3 matrix element.</p>
  121. </td>
  122. </tr>
  123. </tbody>
  124. </table>
  125. </div>
  126. </div>
  127. <h2 class="subsection-title">Properties</h2>
  128. <div class="member">
  129. <h3 class="name" id="elements" translate="no">.<a href="#elements">elements</a><span class="type-signature"> : Array.&lt;number></span> </h3>
  130. <div class="description">
  131. <p>A column-major list of matrix values.</p>
  132. </div>
  133. </div>
  134. <div class="member">
  135. <h3 class="name" id="isMatrix3" translate="no">.<a href="#isMatrix3">isMatrix3</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  136. <div class="description">
  137. <p>This flag can be used for type testing.</p>
  138. <p>Default is <code>true</code>.</p>
  139. </div>
  140. </div>
  141. <h2 class="subsection-title">Methods</h2>
  142. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  143. <div class="method">
  144. <div class="description">
  145. <p>Returns a matrix with copied values from this instance.</p>
  146. </div>
  147. <dl class="details">
  148. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  149. </dl>
  150. </div>
  151. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  152. <div class="method">
  153. <div class="description">
  154. <p>Copies the values of the given matrix to this instance.</p>
  155. </div>
  156. <table class="params">
  157. <tbody>
  158. <tr>
  159. <td class="name">
  160. <strong>m</strong>
  161. </td>
  162. <td class="description last">
  163. <p>The matrix to copy.</p>
  164. </td>
  165. </tr>
  166. </tbody>
  167. </table>
  168. <dl class="details">
  169. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  170. </dl>
  171. </div>
  172. <h3 class="name name-method" id="determinant" translate="no">.<a href="#determinant">determinant</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  173. <div class="method">
  174. <div class="description">
  175. <p>Computes and returns the determinant of this matrix.</p>
  176. </div>
  177. <dl class="details">
  178. <dt class="tag-returns"><strong>Returns:</strong> The determinant.</dt>
  179. </dl>
  180. </div>
  181. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( matrix : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  182. <div class="method">
  183. <div class="description">
  184. <p>Returns <code>true</code> if this matrix is equal with the given one.</p>
  185. </div>
  186. <table class="params">
  187. <tbody>
  188. <tr>
  189. <td class="name">
  190. <strong>matrix</strong>
  191. </td>
  192. <td class="description last">
  193. <p>The matrix to test for equality.</p>
  194. </td>
  195. </tr>
  196. </tbody>
  197. </table>
  198. <dl class="details">
  199. <dt class="tag-returns"><strong>Returns:</strong> Whether this matrix is equal with the given one.</dt>
  200. </dl>
  201. </div>
  202. <h3 class="name name-method" id="extractBasis" translate="no">.<a href="#extractBasis">extractBasis</a><span class="signature">( xAxis : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, yAxis : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, zAxis : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  203. <div class="method">
  204. <div class="description">
  205. <p>Extracts the basis of this matrix into the three axis vectors provided.</p>
  206. </div>
  207. <table class="params">
  208. <tbody>
  209. <tr>
  210. <td class="name">
  211. <strong>xAxis</strong>
  212. </td>
  213. <td class="description last">
  214. <p>The basis's x axis.</p>
  215. </td>
  216. </tr>
  217. <tr>
  218. <td class="name">
  219. <strong>yAxis</strong>
  220. </td>
  221. <td class="description last">
  222. <p>The basis's y axis.</p>
  223. </td>
  224. </tr>
  225. <tr>
  226. <td class="name">
  227. <strong>zAxis</strong>
  228. </td>
  229. <td class="description last">
  230. <p>The basis's z axis.</p>
  231. </td>
  232. </tr>
  233. </tbody>
  234. </table>
  235. <dl class="details">
  236. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  237. </dl>
  238. </div>
  239. <h3 class="name name-method" id="fromArray" translate="no">.<a href="#fromArray">fromArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  240. <div class="method">
  241. <div class="description">
  242. <p>Sets the elements of the matrix from the given array.</p>
  243. </div>
  244. <table class="params">
  245. <tbody>
  246. <tr>
  247. <td class="name">
  248. <strong>array</strong>
  249. </td>
  250. <td class="description last">
  251. <p>The matrix elements in column-major order.</p>
  252. </td>
  253. </tr>
  254. <tr>
  255. <td class="name">
  256. <strong>offset</strong>
  257. </td>
  258. <td class="description last">
  259. <p>Index of the first element in the array.</p>
  260. <p>Default is <code>0</code>.</p>
  261. </td>
  262. </tr>
  263. </tbody>
  264. </table>
  265. <dl class="details">
  266. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  267. </dl>
  268. </div>
  269. <h3 class="name name-method" id="getNormalMatrix" translate="no">.<a href="#getNormalMatrix">getNormalMatrix</a><span class="signature">( matrix4 : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  270. <div class="method">
  271. <div class="description">
  272. <p>Computes the normal matrix which is the inverse transpose of the upper
  273. left 3x3 portion of the given 4x4 matrix.</p>
  274. </div>
  275. <table class="params">
  276. <tbody>
  277. <tr>
  278. <td class="name">
  279. <strong>matrix4</strong>
  280. </td>
  281. <td class="description last">
  282. <p>The 4x4 matrix.</p>
  283. </td>
  284. </tr>
  285. </tbody>
  286. </table>
  287. <dl class="details">
  288. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  289. </dl>
  290. </div>
  291. <h3 class="name name-method" id="identity" translate="no">.<a href="#identity">identity</a><span class="signature">()</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  292. <div class="method">
  293. <div class="description">
  294. <p>Sets this matrix to the 3x3 identity matrix.</p>
  295. </div>
  296. <dl class="details">
  297. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  298. </dl>
  299. </div>
  300. <h3 class="name name-method" id="invert" translate="no">.<a href="#invert">invert</a><span class="signature">()</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  301. <div class="method">
  302. <div class="description">
  303. <p>Inverts this matrix, using the <a href="https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution" target="_blank" rel="noopener">analytic method</a>.
  304. You can not invert with a determinant of zero. If you attempt this, the method produces
  305. a zero matrix instead.</p>
  306. </div>
  307. <dl class="details">
  308. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  309. </dl>
  310. </div>
  311. <h3 class="name name-method" id="makeRotation" translate="no">.<a href="#makeRotation">makeRotation</a><span class="signature">( theta : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  312. <div class="method">
  313. <div class="description">
  314. <p>Sets this matrix as a 2D rotational transformation.</p>
  315. </div>
  316. <table class="params">
  317. <tbody>
  318. <tr>
  319. <td class="name">
  320. <strong>theta</strong>
  321. </td>
  322. <td class="description last">
  323. <p>The rotation in radians.</p>
  324. </td>
  325. </tr>
  326. </tbody>
  327. </table>
  328. <dl class="details">
  329. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  330. </dl>
  331. </div>
  332. <h3 class="name name-method" id="makeScale" translate="no">.<a href="#makeScale">makeScale</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  333. <div class="method">
  334. <div class="description">
  335. <p>Sets this matrix as a 2D scale transform.</p>
  336. </div>
  337. <table class="params">
  338. <tbody>
  339. <tr>
  340. <td class="name">
  341. <strong>x</strong>
  342. </td>
  343. <td class="description last">
  344. <p>The amount to scale in the X axis.</p>
  345. </td>
  346. </tr>
  347. <tr>
  348. <td class="name">
  349. <strong>y</strong>
  350. </td>
  351. <td class="description last">
  352. <p>The amount to scale in the Y axis.</p>
  353. </td>
  354. </tr>
  355. </tbody>
  356. </table>
  357. <dl class="details">
  358. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  359. </dl>
  360. </div>
  361. <h3 class="name name-method" id="makeTranslation" translate="no">.<a href="#makeTranslation">makeTranslation</a><span class="signature">( x : <span class="param-type">number | <a href="Vector2.html">Vector2</a></span>, y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  362. <div class="method">
  363. <div class="description">
  364. <p>Sets this matrix as a 2D translation transform.</p>
  365. </div>
  366. <table class="params">
  367. <tbody>
  368. <tr>
  369. <td class="name">
  370. <strong>x</strong>
  371. </td>
  372. <td class="description last">
  373. <p>The amount to translate in the X axis or alternatively a translation vector.</p>
  374. </td>
  375. </tr>
  376. <tr>
  377. <td class="name">
  378. <strong>y</strong>
  379. </td>
  380. <td class="description last">
  381. <p>The amount to translate in the Y axis.</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 matrix.</dt>
  388. </dl>
  389. </div>
  390. <h3 class="name name-method" id="multiply" translate="no">.<a href="#multiply">multiply</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  391. <div class="method">
  392. <div class="description">
  393. <p>Post-multiplies this matrix by the given 3x3 matrix.</p>
  394. </div>
  395. <table class="params">
  396. <tbody>
  397. <tr>
  398. <td class="name">
  399. <strong>m</strong>
  400. </td>
  401. <td class="description last">
  402. <p>The matrix to multiply with.</p>
  403. </td>
  404. </tr>
  405. </tbody>
  406. </table>
  407. <dl class="details">
  408. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  409. </dl>
  410. </div>
  411. <h3 class="name name-method" id="multiplyMatrices" translate="no">.<a href="#multiplyMatrices">multiplyMatrices</a><span class="signature">( a : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span>, b : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  412. <div class="method">
  413. <div class="description">
  414. <p>Multiples the given 3x3 matrices and stores the result
  415. in this matrix.</p>
  416. </div>
  417. <table class="params">
  418. <tbody>
  419. <tr>
  420. <td class="name">
  421. <strong>a</strong>
  422. </td>
  423. <td class="description last">
  424. <p>The first matrix.</p>
  425. </td>
  426. </tr>
  427. <tr>
  428. <td class="name">
  429. <strong>b</strong>
  430. </td>
  431. <td class="description last">
  432. <p>The second matrix.</p>
  433. </td>
  434. </tr>
  435. </tbody>
  436. </table>
  437. <dl class="details">
  438. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  439. </dl>
  440. </div>
  441. <h3 class="name name-method" id="multiplyScalar" translate="no">.<a href="#multiplyScalar">multiplyScalar</a><span class="signature">( s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  442. <div class="method">
  443. <div class="description">
  444. <p>Multiplies every component of the matrix by the given scalar.</p>
  445. </div>
  446. <table class="params">
  447. <tbody>
  448. <tr>
  449. <td class="name">
  450. <strong>s</strong>
  451. </td>
  452. <td class="description last">
  453. <p>The scalar.</p>
  454. </td>
  455. </tr>
  456. </tbody>
  457. </table>
  458. <dl class="details">
  459. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  460. </dl>
  461. </div>
  462. <h3 class="name name-method" id="premultiply" translate="no">.<a href="#premultiply">premultiply</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  463. <div class="method">
  464. <div class="description">
  465. <p>Pre-multiplies this matrix by the given 3x3 matrix.</p>
  466. </div>
  467. <table class="params">
  468. <tbody>
  469. <tr>
  470. <td class="name">
  471. <strong>m</strong>
  472. </td>
  473. <td class="description last">
  474. <p>The matrix to multiply with.</p>
  475. </td>
  476. </tr>
  477. </tbody>
  478. </table>
  479. <dl class="details">
  480. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  481. </dl>
  482. </div>
  483. <h3 class="name name-method" id="rotate" translate="no">.<a href="#rotate">rotate</a><span class="signature">( theta : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  484. <div class="method">
  485. <div class="description">
  486. <p>Rotates this matrix by the given angle.</p>
  487. </div>
  488. <table class="params">
  489. <tbody>
  490. <tr>
  491. <td class="name">
  492. <strong>theta</strong>
  493. </td>
  494. <td class="description last">
  495. <p>The rotation in radians.</p>
  496. </td>
  497. </tr>
  498. </tbody>
  499. </table>
  500. <dl class="details">
  501. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  502. </dl>
  503. </div>
  504. <h3 class="name name-method" id="scale" translate="no">.<a href="#scale">scale</a><span class="signature">( sx : <span class="param-type">number</span>, sy : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  505. <div class="method">
  506. <div class="description">
  507. <p>Scales this matrix with the given scalar values.</p>
  508. </div>
  509. <table class="params">
  510. <tbody>
  511. <tr>
  512. <td class="name">
  513. <strong>sx</strong>
  514. </td>
  515. <td class="description last">
  516. <p>The amount to scale in the X axis.</p>
  517. </td>
  518. </tr>
  519. <tr>
  520. <td class="name">
  521. <strong>sy</strong>
  522. </td>
  523. <td class="description last">
  524. <p>The amount to scale in the Y axis.</p>
  525. </td>
  526. </tr>
  527. </tbody>
  528. </table>
  529. <dl class="details">
  530. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  531. </dl>
  532. </div>
  533. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( n11 : <span class="param-type">number</span>, n12 : <span class="param-type">number</span>, n13 : <span class="param-type">number</span>, n21 : <span class="param-type">number</span>, n22 : <span class="param-type">number</span>, n23 : <span class="param-type">number</span>, n31 : <span class="param-type">number</span>, n32 : <span class="param-type">number</span>, n33 : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  534. <div class="method">
  535. <div class="description">
  536. <p>Sets the elements of the matrix.The arguments are supposed to be
  537. in row-major order.</p>
  538. </div>
  539. <table class="params">
  540. <tbody>
  541. <tr>
  542. <td class="name">
  543. <strong>n11</strong>
  544. </td>
  545. <td class="description last">
  546. <p>1-1 matrix element.</p>
  547. </td>
  548. </tr>
  549. <tr>
  550. <td class="name">
  551. <strong>n12</strong>
  552. </td>
  553. <td class="description last">
  554. <p>1-2 matrix element.</p>
  555. </td>
  556. </tr>
  557. <tr>
  558. <td class="name">
  559. <strong>n13</strong>
  560. </td>
  561. <td class="description last">
  562. <p>1-3 matrix element.</p>
  563. </td>
  564. </tr>
  565. <tr>
  566. <td class="name">
  567. <strong>n21</strong>
  568. </td>
  569. <td class="description last">
  570. <p>2-1 matrix element.</p>
  571. </td>
  572. </tr>
  573. <tr>
  574. <td class="name">
  575. <strong>n22</strong>
  576. </td>
  577. <td class="description last">
  578. <p>2-2 matrix element.</p>
  579. </td>
  580. </tr>
  581. <tr>
  582. <td class="name">
  583. <strong>n23</strong>
  584. </td>
  585. <td class="description last">
  586. <p>2-3 matrix element.</p>
  587. </td>
  588. </tr>
  589. <tr>
  590. <td class="name">
  591. <strong>n31</strong>
  592. </td>
  593. <td class="description last">
  594. <p>3-1 matrix element.</p>
  595. </td>
  596. </tr>
  597. <tr>
  598. <td class="name">
  599. <strong>n32</strong>
  600. </td>
  601. <td class="description last">
  602. <p>3-2 matrix element.</p>
  603. </td>
  604. </tr>
  605. <tr>
  606. <td class="name">
  607. <strong>n33</strong>
  608. </td>
  609. <td class="description last">
  610. <p>3-3 matrix element.</p>
  611. </td>
  612. </tr>
  613. </tbody>
  614. </table>
  615. <dl class="details">
  616. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  617. </dl>
  618. </div>
  619. <h3 class="name name-method" id="setFromMatrix4" translate="no">.<a href="#setFromMatrix4">setFromMatrix4</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  620. <div class="method">
  621. <div class="description">
  622. <p>Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.</p>
  623. </div>
  624. <table class="params">
  625. <tbody>
  626. <tr>
  627. <td class="name">
  628. <strong>m</strong>
  629. </td>
  630. <td class="description last">
  631. <p>The 4x4 matrix.</p>
  632. </td>
  633. </tr>
  634. </tbody>
  635. </table>
  636. <dl class="details">
  637. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  638. </dl>
  639. </div>
  640. <h3 class="name name-method" id="setUvTransform" translate="no">.<a href="#setUvTransform">setUvTransform</a><span class="signature">( tx : <span class="param-type">number</span>, ty : <span class="param-type">number</span>, sx : <span class="param-type">number</span>, sy : <span class="param-type">number</span>, rotation : <span class="param-type">number</span>, cx : <span class="param-type">number</span>, cy : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  641. <div class="method">
  642. <div class="description">
  643. <p>Sets the UV transform matrix from offset, repeat, rotation, and center.</p>
  644. </div>
  645. <table class="params">
  646. <tbody>
  647. <tr>
  648. <td class="name">
  649. <strong>tx</strong>
  650. </td>
  651. <td class="description last">
  652. <p>Offset x.</p>
  653. </td>
  654. </tr>
  655. <tr>
  656. <td class="name">
  657. <strong>ty</strong>
  658. </td>
  659. <td class="description last">
  660. <p>Offset y.</p>
  661. </td>
  662. </tr>
  663. <tr>
  664. <td class="name">
  665. <strong>sx</strong>
  666. </td>
  667. <td class="description last">
  668. <p>Repeat x.</p>
  669. </td>
  670. </tr>
  671. <tr>
  672. <td class="name">
  673. <strong>sy</strong>
  674. </td>
  675. <td class="description last">
  676. <p>Repeat y.</p>
  677. </td>
  678. </tr>
  679. <tr>
  680. <td class="name">
  681. <strong>rotation</strong>
  682. </td>
  683. <td class="description last">
  684. <p>Rotation, in radians. Positive values rotate counterclockwise.</p>
  685. </td>
  686. </tr>
  687. <tr>
  688. <td class="name">
  689. <strong>cx</strong>
  690. </td>
  691. <td class="description last">
  692. <p>Center x of rotation.</p>
  693. </td>
  694. </tr>
  695. <tr>
  696. <td class="name">
  697. <strong>cy</strong>
  698. </td>
  699. <td class="description last">
  700. <p>Center y of rotation</p>
  701. </td>
  702. </tr>
  703. </tbody>
  704. </table>
  705. <dl class="details">
  706. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  707. </dl>
  708. </div>
  709. <h3 class="name name-method" id="toArray" translate="no">.<a href="#toArray">toArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.&lt;number></span> </h3>
  710. <div class="method">
  711. <div class="description">
  712. <p>Writes the elements of this matrix to the given array. If no array is provided,
  713. the method returns a new instance.</p>
  714. </div>
  715. <table class="params">
  716. <tbody>
  717. <tr>
  718. <td class="name">
  719. <strong>array</strong>
  720. </td>
  721. <td class="description last">
  722. <p>The target array holding the matrix elements in column-major order.</p>
  723. <p>Default is <code>[]</code>.</p>
  724. </td>
  725. </tr>
  726. <tr>
  727. <td class="name">
  728. <strong>offset</strong>
  729. </td>
  730. <td class="description last">
  731. <p>Index of the first element in the array.</p>
  732. <p>Default is <code>0</code>.</p>
  733. </td>
  734. </tr>
  735. </tbody>
  736. </table>
  737. <dl class="details">
  738. <dt class="tag-returns"><strong>Returns:</strong> The matrix elements in column-major order.</dt>
  739. </dl>
  740. </div>
  741. <h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</a><span class="signature">( tx : <span class="param-type">number</span>, ty : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  742. <div class="method">
  743. <div class="description">
  744. <p>Translates this matrix by the given scalar values.</p>
  745. </div>
  746. <table class="params">
  747. <tbody>
  748. <tr>
  749. <td class="name">
  750. <strong>tx</strong>
  751. </td>
  752. <td class="description last">
  753. <p>The amount to translate in the X axis.</p>
  754. </td>
  755. </tr>
  756. <tr>
  757. <td class="name">
  758. <strong>ty</strong>
  759. </td>
  760. <td class="description last">
  761. <p>The amount to translate in the Y axis.</p>
  762. </td>
  763. </tr>
  764. </tbody>
  765. </table>
  766. <dl class="details">
  767. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  768. </dl>
  769. </div>
  770. <h3 class="name name-method" id="transpose" translate="no">.<a href="#transpose">transpose</a><span class="signature">()</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  771. <div class="method">
  772. <div class="description">
  773. <p>Transposes this matrix in place.</p>
  774. </div>
  775. <dl class="details">
  776. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  777. </dl>
  778. </div>
  779. <h3 class="name name-method" id="transposeIntoArray" translate="no">.<a href="#transposeIntoArray">transposeIntoArray</a><span class="signature">( r : <span class="param-type">Array.&lt;number></span> )</span><span class="type-signature"> : <a href="Matrix3.html">Matrix3</a></span> </h3>
  780. <div class="method">
  781. <div class="description">
  782. <p>Transposes this matrix into the supplied array, and returns itself unchanged.</p>
  783. </div>
  784. <table class="params">
  785. <tbody>
  786. <tr>
  787. <td class="name">
  788. <strong>r</strong>
  789. </td>
  790. <td class="description last">
  791. <p>An array to store the transposed matrix elements.</p>
  792. </td>
  793. </tr>
  794. </tbody>
  795. </table>
  796. <dl class="details">
  797. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  798. </dl>
  799. </div>
  800. <h2 class="subsection-title">Source</h2>
  801. <p>
  802. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Matrix3.js" translate="no" target="_blank" rel="noopener">src/math/Matrix3.js</a>
  803. </p>
  804. </article>
  805. </section>
  806. <script src="../scripts/linenumber.js"></script>
  807. <script src="../scripts/page.js"></script>
  808. </body>
  809. </html>
粤ICP备19079148号