MD2CharacterComplex.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>MD2CharacterComplex - 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">MD2CharacterComplex</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>This class represents a management component for animated MD2
  16. character assets. It provides a larger API compared to <a href="MD2Character.html">MD2Character</a>.</p></div>
  17. </header>
  18. <article>
  19. <h2 class="subsection-title">Import</h2>
  20. <p><span translate="no">MD2CharacterComplex</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  21. <pre><code class="language-js">import { MD2CharacterComplex } from 'three/addons/misc/MD2CharacterComplex.js';</code></pre>
  22. <div class="container-overview">
  23. <h2>Constructor</h2>
  24. <h3 class="name name-method" id="MD2CharacterComplex" translate="no">new <a href="#MD2CharacterComplex">MD2CharacterComplex</a><span class="signature">()</span> </h3>
  25. <div class="method">
  26. <div class="description">
  27. <p>Constructs a new MD2 character.</p>
  28. </div>
  29. </div>
  30. </div>
  31. <h2 class="subsection-title">Properties</h2>
  32. <div class="member">
  33. <h3 class="name" id="angularSpeed" translate="no">.<a href="#angularSpeed">angularSpeed</a><span class="type-signature"> : number</span> </h3>
  34. <div class="description">
  35. <p>The character's angular speed.</p>
  36. <p>Default is <code>2.5</code>.</p>
  37. </div>
  38. </div>
  39. <div class="member">
  40. <h3 class="name" id="animationFPS" translate="no">.<a href="#animationFPS">animationFPS</a><span class="type-signature"> : number</span> </h3>
  41. <div class="description">
  42. <p>The FPS</p>
  43. <p>Default is <code>6</code>.</p>
  44. </div>
  45. </div>
  46. <div class="member">
  47. <h3 class="name" id="backAcceleration" translate="no">.<a href="#backAcceleration">backAcceleration</a><span class="type-signature"> : number</span> </h3>
  48. <div class="description">
  49. <p>The character's back acceleration.</p>
  50. <p>Default is <code>600</code>.</p>
  51. </div>
  52. </div>
  53. <div class="member">
  54. <h3 class="name" id="controls" translate="no">.<a href="#controls">controls</a><span class="type-signature"> : Object</span> </h3>
  55. <div class="description">
  56. <p>The movement controls.</p>
  57. <p>Default is <code>null</code>.</p>
  58. </div>
  59. </div>
  60. <div class="member">
  61. <h3 class="name" id="currentSkin" translate="no">.<a href="#currentSkin">currentSkin</a><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  62. <div class="description">
  63. <p>The current skin.</p>
  64. <p>Default is <code>undefined</code>.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="frontAcceleration" translate="no">.<a href="#frontAcceleration">frontAcceleration</a><span class="type-signature"> : number</span> </h3>
  69. <div class="description">
  70. <p>The character's front acceleration.</p>
  71. <p>Default is <code>600</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="frontDeceleration" translate="no">.<a href="#frontDeceleration">frontDeceleration</a><span class="type-signature"> : number</span> </h3>
  76. <div class="description">
  77. <p>The character's front deceleration.</p>
  78. <p>Default is <code>600</code>.</p>
  79. </div>
  80. </div>
  81. <div class="member">
  82. <h3 class="name" id="maxReverseSpeed" translate="no">.<a href="#maxReverseSpeed">maxReverseSpeed</a><span class="type-signature"> : number</span> </h3>
  83. <div class="description">
  84. <p>The character's maximum reverse speed.</p>
  85. <p>Default is <code>- 275</code>.</p>
  86. </div>
  87. </div>
  88. <div class="member">
  89. <h3 class="name" id="maxSpeed" translate="no">.<a href="#maxSpeed">maxSpeed</a><span class="type-signature"> : number</span> </h3>
  90. <div class="description">
  91. <p>The character's maximum speed.</p>
  92. <p>Default is <code>275</code>.</p>
  93. </div>
  94. </div>
  95. <div class="member">
  96. <h3 class="name" id="meshBody" translate="no">.<a href="#meshBody">meshBody</a><span class="type-signature"> : <a href="Mesh.html">Mesh</a></span> </h3>
  97. <div class="description">
  98. <p>The body mesh.</p>
  99. <p>Default is <code>null</code>.</p>
  100. </div>
  101. </div>
  102. <div class="member">
  103. <h3 class="name" id="meshWeapon" translate="no">.<a href="#meshWeapon">meshWeapon</a><span class="type-signature"> : <a href="Mesh.html">Mesh</a></span> </h3>
  104. <div class="description">
  105. <p>The weapon mesh.</p>
  106. <p>Default is <code>null</code>.</p>
  107. </div>
  108. </div>
  109. <div class="member">
  110. <h3 class="name" id="root" translate="no">.<a href="#root">root</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  111. <div class="description">
  112. <p>The root 3D object</p>
  113. </div>
  114. </div>
  115. <div class="member">
  116. <h3 class="name" id="scale" translate="no">.<a href="#scale">scale</a><span class="type-signature"> : number</span> </h3>
  117. <div class="description">
  118. <p>The mesh scale.</p>
  119. <p>Default is <code>1</code>.</p>
  120. </div>
  121. </div>
  122. <div class="member">
  123. <h3 class="name" id="skinsBody" translate="no">.<a href="#skinsBody">skinsBody</a><span class="type-signature"> : Array.&lt;<a href="Texture.html">Texture</a>></span> </h3>
  124. <div class="description">
  125. <p>The body skins.</p>
  126. </div>
  127. </div>
  128. <div class="member">
  129. <h3 class="name" id="skinsWeapon" translate="no">.<a href="#skinsWeapon">skinsWeapon</a><span class="type-signature"> : Array.&lt;<a href="Texture.html">Texture</a>></span> </h3>
  130. <div class="description">
  131. <p>The weapon skins.</p>
  132. </div>
  133. </div>
  134. <div class="member">
  135. <h3 class="name" id="transitionFrames" translate="no">.<a href="#transitionFrames">transitionFrames</a><span class="type-signature"> : number</span> </h3>
  136. <div class="description">
  137. <p>The transition frames.</p>
  138. <p>Default is <code>15</code>.</p>
  139. </div>
  140. </div>
  141. <div class="member">
  142. <h3 class="name" id="weapons" translate="no">.<a href="#weapons">weapons</a><span class="type-signature"> : Array.&lt;<a href="Mesh.html">Mesh</a>></span> </h3>
  143. <div class="description">
  144. <p>The weapon meshes.</p>
  145. </div>
  146. </div>
  147. <h2 class="subsection-title">Methods</h2>
  148. <h3 class="name name-method" id="enableShadows" translate="no">.<a href="#enableShadows">enableShadows</a><span class="signature">( enable : <span class="param-type">boolean</span> )</span> </h3>
  149. <div class="method">
  150. <div class="description">
  151. <p>Toggles shadow casting and receiving on the character's meshes.</p>
  152. </div>
  153. <table class="params">
  154. <tbody>
  155. <tr>
  156. <td class="name">
  157. <strong>enable</strong>
  158. </td>
  159. <td class="description last">
  160. <p>Whether to enable shadows or not.</p>
  161. </td>
  162. </tr>
  163. </tbody>
  164. </table>
  165. </div>
  166. <h3 class="name name-method" id="loadParts" translate="no">.<a href="#loadParts">loadParts</a><span class="signature">( config : <span class="param-type">Object</span> )</span> </h3>
  167. <div class="method">
  168. <div class="description">
  169. <p>Loads the character model for the given config.</p>
  170. </div>
  171. <table class="params">
  172. <tbody>
  173. <tr>
  174. <td class="name">
  175. <strong>config</strong>
  176. </td>
  177. <td class="description last">
  178. <p>The config which defines the model and textures paths.</p>
  179. </td>
  180. </tr>
  181. </tbody>
  182. </table>
  183. </div>
  184. <h3 class="name name-method" id="setAnimation" translate="no">.<a href="#setAnimation">setAnimation</a><span class="signature">( animationName : <span class="param-type">string</span> )</span> </h3>
  185. <div class="method">
  186. <div class="description">
  187. <p>Sets the defined animation clip as the active animation.</p>
  188. </div>
  189. <table class="params">
  190. <tbody>
  191. <tr>
  192. <td class="name">
  193. <strong>animationName</strong>
  194. </td>
  195. <td class="description last">
  196. <p>The name of the animation clip.</p>
  197. </td>
  198. </tr>
  199. </tbody>
  200. </table>
  201. </div>
  202. <h3 class="name name-method" id="setPlaybackRate" translate="no">.<a href="#setPlaybackRate">setPlaybackRate</a><span class="signature">( rate : <span class="param-type">number</span> )</span> </h3>
  203. <div class="method">
  204. <div class="description">
  205. <p>Sets the animation playback rate.</p>
  206. </div>
  207. <table class="params">
  208. <tbody>
  209. <tr>
  210. <td class="name">
  211. <strong>rate</strong>
  212. </td>
  213. <td class="description last">
  214. <p>The playback rate to set.</p>
  215. </td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. </div>
  220. <h3 class="name name-method" id="setSkin" translate="no">.<a href="#setSkin">setSkin</a><span class="signature">( index : <span class="param-type">number</span> )</span> </h3>
  221. <div class="method">
  222. <div class="description">
  223. <p>Sets the skin defined by the given skin index. This will result in a different texture
  224. for the body mesh.</p>
  225. </div>
  226. <table class="params">
  227. <tbody>
  228. <tr>
  229. <td class="name">
  230. <strong>index</strong>
  231. </td>
  232. <td class="description last">
  233. <p>The skin index.</p>
  234. </td>
  235. </tr>
  236. </tbody>
  237. </table>
  238. </div>
  239. <h3 class="name name-method" id="setVisible" translate="no">.<a href="#setVisible">setVisible</a><span class="signature">( enable : <span class="param-type">boolean</span> )</span> </h3>
  240. <div class="method">
  241. <div class="description">
  242. <p>Toggles visibility on the character's meshes.</p>
  243. </div>
  244. <table class="params">
  245. <tbody>
  246. <tr>
  247. <td class="name">
  248. <strong>enable</strong>
  249. </td>
  250. <td class="description last">
  251. <p>Whether the character is visible or not.</p>
  252. </td>
  253. </tr>
  254. </tbody>
  255. </table>
  256. </div>
  257. <h3 class="name name-method" id="setWeapon" translate="no">.<a href="#setWeapon">setWeapon</a><span class="signature">( index : <span class="param-type">number</span> )</span> </h3>
  258. <div class="method">
  259. <div class="description">
  260. <p>Sets the weapon defined by the given weapon index. This will result in a different weapon
  261. hold by the character.</p>
  262. </div>
  263. <table class="params">
  264. <tbody>
  265. <tr>
  266. <td class="name">
  267. <strong>index</strong>
  268. </td>
  269. <td class="description last">
  270. <p>The weapon index.</p>
  271. </td>
  272. </tr>
  273. </tbody>
  274. </table>
  275. </div>
  276. <h3 class="name name-method" id="setWireframe" translate="no">.<a href="#setWireframe">setWireframe</a><span class="signature">( wireframeEnabled : <span class="param-type">boolean</span> )</span> </h3>
  277. <div class="method">
  278. <div class="description">
  279. <p>Sets the wireframe material flag.</p>
  280. </div>
  281. <table class="params">
  282. <tbody>
  283. <tr>
  284. <td class="name">
  285. <strong>wireframeEnabled</strong>
  286. </td>
  287. <td class="description last">
  288. <p>Whether to enable wireframe rendering or not.</p>
  289. </td>
  290. </tr>
  291. </tbody>
  292. </table>
  293. </div>
  294. <h3 class="name name-method" id="shareParts" translate="no">.<a href="#shareParts">shareParts</a><span class="signature">( original : <span class="param-type"><a href="MD2CharacterComplex.html">MD2CharacterComplex</a></span> )</span> </h3>
  295. <div class="method">
  296. <div class="description">
  297. <p>Shares certain resources from a different character model.</p>
  298. </div>
  299. <table class="params">
  300. <tbody>
  301. <tr>
  302. <td class="name">
  303. <strong>original</strong>
  304. </td>
  305. <td class="description last">
  306. <p>The original MD2 character.</p>
  307. </td>
  308. </tr>
  309. </tbody>
  310. </table>
  311. </div>
  312. <h3 class="name name-method" id="updateAnimations" translate="no">.<a href="#updateAnimations">updateAnimations</a><span class="signature">( delta : <span class="param-type">number</span> )</span> </h3>
  313. <div class="method">
  314. <div class="description">
  315. <p>Updates the animations of the mesh. Must be called inside the animation loop.</p>
  316. </div>
  317. <table class="params">
  318. <tbody>
  319. <tr>
  320. <td class="name">
  321. <strong>delta</strong>
  322. </td>
  323. <td class="description last">
  324. <p>The delta time in seconds.</p>
  325. </td>
  326. </tr>
  327. </tbody>
  328. </table>
  329. </div>
  330. <h3 class="name name-method" id="updateBehaviors" translate="no">.<a href="#updateBehaviors">updateBehaviors</a><span class="signature">()</span> </h3>
  331. <div class="method">
  332. <div class="description">
  333. <p>Updates the animation state based on the control inputs.</p>
  334. </div>
  335. </div>
  336. <h3 class="name name-method" id="updateMovementModel" translate="no">.<a href="#updateMovementModel">updateMovementModel</a><span class="signature">( delta : <span class="param-type">number</span> )</span> </h3>
  337. <div class="method">
  338. <div class="description">
  339. <p>Transforms the character model based on the control input.</p>
  340. </div>
  341. <table class="params">
  342. <tbody>
  343. <tr>
  344. <td class="name">
  345. <strong>delta</strong>
  346. </td>
  347. <td class="description last">
  348. <p>The delta time in seconds.</p>
  349. </td>
  350. </tr>
  351. </tbody>
  352. </table>
  353. </div>
  354. <h2 class="subsection-title">Source</h2>
  355. <p>
  356. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/misc/MD2CharacterComplex.js" translate="no" target="_blank" rel="noopener">examples/jsm/misc/MD2CharacterComplex.js</a>
  357. </p>
  358. </article>
  359. </section>
  360. <script src="../scripts/linenumber.js"></script>
  361. <script src="../scripts/page.js"></script>
  362. </body>
  363. </html>
粤ICP备19079148号