Euler.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Euler - 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">Euler</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A class representing Euler angles.</p>
  16. <p>Euler angles describe a rotational transformation by rotating an object on
  17. its various axes in specified amounts per axis, and a specified axis
  18. order.</p>
  19. <p>Iterating through an instance will yield its components (x, y, z,
  20. order) in the corresponding order.</p></div>
  21. <h2>Code Example</h2>
  22. <div translate="no"><pre><code class="language-js">const a = new THREE.Euler( 0, 1, 1.57, 'XYZ' );
  23. const b = new THREE.Vector3( 1, 0, 1 );
  24. b.applyEuler(a);
  25. </code></pre></div>
  26. </header>
  27. <article>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="Euler" translate="no">new <a href="#Euler">Euler</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>, order : <span class="param-type">string</span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new euler instance.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name">
  39. <strong>x</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The angle of the x axis in radians.</p>
  43. <p>Default is <code>0</code>.</p>
  44. </td>
  45. </tr>
  46. <tr>
  47. <td class="name">
  48. <strong>y</strong>
  49. </td>
  50. <td class="description last">
  51. <p>The angle of the y axis in radians.</p>
  52. <p>Default is <code>0</code>.</p>
  53. </td>
  54. </tr>
  55. <tr>
  56. <td class="name">
  57. <strong>z</strong>
  58. </td>
  59. <td class="description last">
  60. <p>The angle of the z axis in radians.</p>
  61. <p>Default is <code>0</code>.</p>
  62. </td>
  63. </tr>
  64. <tr>
  65. <td class="name">
  66. <strong>order</strong>
  67. </td>
  68. <td class="description last">
  69. <p>A string representing the order that the rotations are applied.</p>
  70. <p>Default is <code>Euler.DEFAULT_ORDER</code>.</p>
  71. </td>
  72. </tr>
  73. </tbody>
  74. </table>
  75. </div>
  76. </div>
  77. <h2 class="subsection-title">Properties</h2>
  78. <div class="member">
  79. <h3 class="name" id="isEuler" translate="no">.<a href="#isEuler">isEuler</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  80. <div class="description">
  81. <p>This flag can be used for type testing.</p>
  82. <p>Default is <code>true</code>.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="order" translate="no">.<a href="#order">order</a><span class="type-signature"> : string</span> </h3>
  87. <div class="description">
  88. <p>A string representing the order that the rotations are applied.</p>
  89. <p>Default is <code>'XYZ'</code>.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="x" translate="no">.<a href="#x">x</a><span class="type-signature"> : number</span> </h3>
  94. <div class="description">
  95. <p>The angle of the x axis in radians.</p>
  96. <p>Default is <code>0</code>.</p>
  97. </div>
  98. </div>
  99. <div class="member">
  100. <h3 class="name" id="y" translate="no">.<a href="#y">y</a><span class="type-signature"> : number</span> </h3>
  101. <div class="description">
  102. <p>The angle of the y axis in radians.</p>
  103. <p>Default is <code>0</code>.</p>
  104. </div>
  105. </div>
  106. <div class="member">
  107. <h3 class="name" id="z" translate="no">.<a href="#z">z</a><span class="type-signature"> : number</span> </h3>
  108. <div class="description">
  109. <p>The angle of the z axis in radians.</p>
  110. <p>Default is <code>0</code>.</p>
  111. </div>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id=".DEFAULT_ORDER" translate="no">.<a href="#.DEFAULT_ORDER">DEFAULT_ORDER</a><span class="type-signature"> : string</span> </h3>
  115. <div class="description">
  116. <p>The default Euler angle order.</p>
  117. <p>Default is <code>'XYZ'</code>.</p>
  118. </div>
  119. </div>
  120. <h2 class="subsection-title">Methods</h2>
  121. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  122. <div class="method">
  123. <div class="description">
  124. <p>Returns a new Euler instance with copied values from this instance.</p>
  125. </div>
  126. <dl class="details">
  127. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  128. </dl>
  129. </div>
  130. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( euler : <span class="param-type"><a href="Euler.html">Euler</a></span> )</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  131. <div class="method">
  132. <div class="description">
  133. <p>Copies the values of the given Euler instance to this instance.</p>
  134. </div>
  135. <table class="params">
  136. <tbody>
  137. <tr>
  138. <td class="name">
  139. <strong>euler</strong>
  140. </td>
  141. <td class="description last">
  142. <p>The Euler instance to copy.</p>
  143. </td>
  144. </tr>
  145. </tbody>
  146. </table>
  147. <dl class="details">
  148. <dt class="tag-returns"><strong>Returns:</strong> A reference to this Euler instance.</dt>
  149. </dl>
  150. </div>
  151. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( euler : <span class="param-type"><a href="Euler.html">Euler</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  152. <div class="method">
  153. <div class="description">
  154. <p>Returns <code>true</code> if this Euler instance is equal with the given one.</p>
  155. </div>
  156. <table class="params">
  157. <tbody>
  158. <tr>
  159. <td class="name">
  160. <strong>euler</strong>
  161. </td>
  162. <td class="description last">
  163. <p>The Euler instance to test for equality.</p>
  164. </td>
  165. </tr>
  166. </tbody>
  167. </table>
  168. <dl class="details">
  169. <dt class="tag-returns"><strong>Returns:</strong> Whether this Euler instance is equal with the given one.</dt>
  170. </dl>
  171. </div>
  172. <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, number, number, ?string></span> )</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  173. <div class="method">
  174. <div class="description">
  175. <p>Sets this Euler instance's components to values from the given array. The first three
  176. entries of the array are assign to the x,y and z components. An optional fourth entry
  177. defines the Euler order.</p>
  178. </div>
  179. <table class="params">
  180. <tbody>
  181. <tr>
  182. <td class="name">
  183. <strong>array</strong>
  184. </td>
  185. <td class="description last">
  186. <p>An array holding the Euler component values.</p>
  187. </td>
  188. </tr>
  189. </tbody>
  190. </table>
  191. <dl class="details">
  192. <dt class="tag-returns"><strong>Returns:</strong> A reference to this Euler instance.</dt>
  193. </dl>
  194. </div>
  195. <h3 class="name name-method" id="reorder" translate="no">.<a href="#reorder">reorder</a><span class="signature">( newOrder : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  196. <div class="method">
  197. <div class="description">
  198. <p>Resets the euler angle with a new order by creating a quaternion from this
  199. euler angle and then setting this euler angle with the quaternion and the
  200. new order.</p>
  201. <p>Warning: This discards revolution information.</p>
  202. </div>
  203. <table class="params">
  204. <tbody>
  205. <tr>
  206. <td class="name">
  207. <strong>newOrder</strong>
  208. </td>
  209. <td class="description last">
  210. <p>A string representing the new order that the rotations are applied.</p>
  211. </td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. <dl class="details">
  216. <dt class="tag-returns"><strong>Returns:</strong> A reference to this Euler instance.</dt>
  217. </dl>
  218. </div>
  219. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</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>, order : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  220. <div class="method">
  221. <div class="description">
  222. <p>Sets the Euler components.</p>
  223. </div>
  224. <table class="params">
  225. <tbody>
  226. <tr>
  227. <td class="name">
  228. <strong>x</strong>
  229. </td>
  230. <td class="description last">
  231. <p>The angle of the x axis in radians.</p>
  232. </td>
  233. </tr>
  234. <tr>
  235. <td class="name">
  236. <strong>y</strong>
  237. </td>
  238. <td class="description last">
  239. <p>The angle of the y axis in radians.</p>
  240. </td>
  241. </tr>
  242. <tr>
  243. <td class="name">
  244. <strong>z</strong>
  245. </td>
  246. <td class="description last">
  247. <p>The angle of the z axis in radians.</p>
  248. </td>
  249. </tr>
  250. <tr>
  251. <td class="name">
  252. <strong>order</strong>
  253. </td>
  254. <td class="description last">
  255. <p>A string representing the order that the rotations are applied.</p>
  256. </td>
  257. </tr>
  258. </tbody>
  259. </table>
  260. <dl class="details">
  261. <dt class="tag-returns"><strong>Returns:</strong> A reference to this Euler instance.</dt>
  262. </dl>
  263. </div>
  264. <h3 class="name name-method" id="setFromQuaternion" translate="no">.<a href="#setFromQuaternion">setFromQuaternion</a><span class="signature">( q : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span>, order : <span class="param-type">string</span>, update : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  265. <div class="method">
  266. <div class="description">
  267. <p>Sets the angles of this Euler instance from a normalized quaternion.</p>
  268. </div>
  269. <table class="params">
  270. <tbody>
  271. <tr>
  272. <td class="name">
  273. <strong>q</strong>
  274. </td>
  275. <td class="description last">
  276. <p>A normalized Quaternion.</p>
  277. </td>
  278. </tr>
  279. <tr>
  280. <td class="name">
  281. <strong>order</strong>
  282. </td>
  283. <td class="description last">
  284. <p>A string representing the order that the rotations are applied.</p>
  285. </td>
  286. </tr>
  287. <tr>
  288. <td class="name">
  289. <strong>update</strong>
  290. </td>
  291. <td class="description last">
  292. <p>Whether the internal <code>onChange</code> callback should be executed or not.</p>
  293. <p>Default is <code>true</code>.</p>
  294. </td>
  295. </tr>
  296. </tbody>
  297. </table>
  298. <dl class="details">
  299. <dt class="tag-returns"><strong>Returns:</strong> A reference to this Euler instance.</dt>
  300. </dl>
  301. </div>
  302. <h3 class="name name-method" id="setFromRotationMatrix" translate="no">.<a href="#setFromRotationMatrix">setFromRotationMatrix</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span>, order : <span class="param-type">string</span>, update : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  303. <div class="method">
  304. <div class="description">
  305. <p>Sets the angles of this Euler instance from a pure rotation matrix.</p>
  306. </div>
  307. <table class="params">
  308. <tbody>
  309. <tr>
  310. <td class="name">
  311. <strong>m</strong>
  312. </td>
  313. <td class="description last">
  314. <p>A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).</p>
  315. </td>
  316. </tr>
  317. <tr>
  318. <td class="name">
  319. <strong>order</strong>
  320. </td>
  321. <td class="description last">
  322. <p>A string representing the order that the rotations are applied.</p>
  323. </td>
  324. </tr>
  325. <tr>
  326. <td class="name">
  327. <strong>update</strong>
  328. </td>
  329. <td class="description last">
  330. <p>Whether the internal <code>onChange</code> callback should be executed or not.</p>
  331. <p>Default is <code>true</code>.</p>
  332. </td>
  333. </tr>
  334. </tbody>
  335. </table>
  336. <dl class="details">
  337. <dt class="tag-returns"><strong>Returns:</strong> A reference to this Euler instance.</dt>
  338. </dl>
  339. </div>
  340. <h3 class="name name-method" id="setFromVector3" translate="no">.<a href="#setFromVector3">setFromVector3</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, order : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Euler.html">Euler</a></span> </h3>
  341. <div class="method">
  342. <div class="description">
  343. <p>Sets the angles of this Euler instance from the given vector.</p>
  344. </div>
  345. <table class="params">
  346. <tbody>
  347. <tr>
  348. <td class="name">
  349. <strong>v</strong>
  350. </td>
  351. <td class="description last">
  352. <p>The vector.</p>
  353. </td>
  354. </tr>
  355. <tr>
  356. <td class="name">
  357. <strong>order</strong>
  358. </td>
  359. <td class="description last">
  360. <p>A string representing the order that the rotations are applied.</p>
  361. </td>
  362. </tr>
  363. </tbody>
  364. </table>
  365. <dl class="details">
  366. <dt class="tag-returns"><strong>Returns:</strong> A reference to this Euler instance.</dt>
  367. </dl>
  368. </div>
  369. <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, number, number, string></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.&lt;number, number, number, string></span> </h3>
  370. <div class="method">
  371. <div class="description">
  372. <p>Writes the components of this Euler instance to the given array. If no array is provided,
  373. the method returns a new instance.</p>
  374. </div>
  375. <table class="params">
  376. <tbody>
  377. <tr>
  378. <td class="name">
  379. <strong>array</strong>
  380. </td>
  381. <td class="description last">
  382. <p>The target array holding the Euler components.</p>
  383. <p>Default is <code>[]</code>.</p>
  384. </td>
  385. </tr>
  386. <tr>
  387. <td class="name">
  388. <strong>offset</strong>
  389. </td>
  390. <td class="description last">
  391. <p>Index of the first element in the array.</p>
  392. <p>Default is <code>0</code>.</p>
  393. </td>
  394. </tr>
  395. </tbody>
  396. </table>
  397. <dl class="details">
  398. <dt class="tag-returns"><strong>Returns:</strong> The Euler components.</dt>
  399. </dl>
  400. </div>
  401. <h2 class="subsection-title">Source</h2>
  402. <p>
  403. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Euler.js" translate="no" target="_blank" rel="noopener">src/math/Euler.js</a>
  404. </p>
  405. </article>
  406. </section>
  407. <script src="../scripts/linenumber.js"></script>
  408. <script src="../scripts/page.js"></script>
  409. </body>
  410. </html>
粤ICP备19079148号