MD2CharacterComplex.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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">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.<br/>Default is <code>2.5</code>.</p>
  36. </div>
  37. </div>
  38. <div class="member">
  39. <h3 class="name" id="animationFPS" translate="no">.<a href="#animationFPS">animationFPS</a><span class="type-signature"> : number</span> </h3>
  40. <div class="description">
  41. <p>The FPS<br/>Default is <code>6</code>.</p>
  42. </div>
  43. </div>
  44. <div class="member">
  45. <h3 class="name" id="backAcceleration" translate="no">.<a href="#backAcceleration">backAcceleration</a><span class="type-signature"> : number</span> </h3>
  46. <div class="description">
  47. <p>The character's back acceleration.<br/>Default is <code>600</code>.</p>
  48. </div>
  49. </div>
  50. <div class="member">
  51. <h3 class="name" id="controls" translate="no">.<a href="#controls">controls</a><span class="type-signature"> : Object</span> </h3>
  52. <div class="description">
  53. <p>The movement controls.<br/>Default is <code>null</code>.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="currentSkin" translate="no">.<a href="#currentSkin">currentSkin</a><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  58. <div class="description">
  59. <p>The current skin.<br/>Default is <code>undefined</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="frontAcceleration" translate="no">.<a href="#frontAcceleration">frontAcceleration</a><span class="type-signature"> : number</span> </h3>
  64. <div class="description">
  65. <p>The character's front acceleration.<br/>Default is <code>600</code>.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="frontDeceleration" translate="no">.<a href="#frontDeceleration">frontDeceleration</a><span class="type-signature"> : number</span> </h3>
  70. <div class="description">
  71. <p>The character's front deceleration.<br/>Default is <code>600</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="maxReverseSpeed" translate="no">.<a href="#maxReverseSpeed">maxReverseSpeed</a><span class="type-signature"> : number</span> </h3>
  76. <div class="description">
  77. <p>The character's maximum reverse speed.<br/>Default is <code>- 275</code>.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="maxSpeed" translate="no">.<a href="#maxSpeed">maxSpeed</a><span class="type-signature"> : number</span> </h3>
  82. <div class="description">
  83. <p>The character's maximum speed.<br/>Default is <code>275</code>.</p>
  84. </div>
  85. </div>
  86. <div class="member">
  87. <h3 class="name" id="meshBody" translate="no">.<a href="#meshBody">meshBody</a><span class="type-signature"> : <a href="Mesh.html">Mesh</a></span> </h3>
  88. <div class="description">
  89. <p>The body mesh.<br/>Default is <code>null</code>.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="meshWeapon" translate="no">.<a href="#meshWeapon">meshWeapon</a><span class="type-signature"> : <a href="Mesh.html">Mesh</a></span> </h3>
  94. <div class="description">
  95. <p>The weapon mesh.<br/>Default is <code>null</code>.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <h3 class="name" id="root" translate="no">.<a href="#root">root</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  100. <div class="description">
  101. <p>The root 3D object</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="scale" translate="no">.<a href="#scale">scale</a><span class="type-signature"> : number</span> </h3>
  106. <div class="description">
  107. <p>The mesh scale.<br/>Default is <code>1</code>.</p>
  108. </div>
  109. </div>
  110. <div class="member">
  111. <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>
  112. <div class="description">
  113. <p>The body skins.</p>
  114. </div>
  115. </div>
  116. <div class="member">
  117. <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>
  118. <div class="description">
  119. <p>The weapon skins.</p>
  120. </div>
  121. </div>
  122. <div class="member">
  123. <h3 class="name" id="transitionFrames" translate="no">.<a href="#transitionFrames">transitionFrames</a><span class="type-signature"> : number</span> </h3>
  124. <div class="description">
  125. <p>The transition frames.<br/>Default is <code>15</code>.</p>
  126. </div>
  127. </div>
  128. <div class="member">
  129. <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>
  130. <div class="description">
  131. <p>The weapon meshes.</p>
  132. </div>
  133. </div>
  134. <h2 class="subsection-title">Methods</h2>
  135. <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>
  136. <div class="method">
  137. <div class="description">
  138. <p>Toggles shadow casting and receiving on the character's meshes.</p>
  139. </div>
  140. <table class="params">
  141. <tbody>
  142. <tr>
  143. <td class="name"><code>enable</code></td>
  144. <td class="description last"><p>Whether to enable shadows or not.</p></td>
  145. </tr>
  146. </tbody>
  147. </table>
  148. </div>
  149. <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>
  150. <div class="method">
  151. <div class="description">
  152. <p>Loads the character model for the given config.</p>
  153. </div>
  154. <table class="params">
  155. <tbody>
  156. <tr>
  157. <td class="name"><code>config</code></td>
  158. <td class="description last"><p>The config which defines the model and textures paths.</p></td>
  159. </tr>
  160. </tbody>
  161. </table>
  162. </div>
  163. <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>
  164. <div class="method">
  165. <div class="description">
  166. <p>Sets the defined animation clip as the active animation.</p>
  167. </div>
  168. <table class="params">
  169. <tbody>
  170. <tr>
  171. <td class="name"><code>animationName</code></td>
  172. <td class="description last"><p>The name of the animation clip.</p></td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. </div>
  177. <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>
  178. <div class="method">
  179. <div class="description">
  180. <p>Sets the animation playback rate.</p>
  181. </div>
  182. <table class="params">
  183. <tbody>
  184. <tr>
  185. <td class="name"><code>rate</code></td>
  186. <td class="description last"><p>The playback rate to set.</p></td>
  187. </tr>
  188. </tbody>
  189. </table>
  190. </div>
  191. <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>
  192. <div class="method">
  193. <div class="description">
  194. <p>Sets the skin defined by the given skin index. This will result in a different texture
  195. for the body mesh.</p>
  196. </div>
  197. <table class="params">
  198. <tbody>
  199. <tr>
  200. <td class="name"><code>index</code></td>
  201. <td class="description last"><p>The skin index.</p></td>
  202. </tr>
  203. </tbody>
  204. </table>
  205. </div>
  206. <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>
  207. <div class="method">
  208. <div class="description">
  209. <p>Toggles visibility on the character's meshes.</p>
  210. </div>
  211. <table class="params">
  212. <tbody>
  213. <tr>
  214. <td class="name"><code>enable</code></td>
  215. <td class="description last"><p>Whether the character is visible or not.</p></td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. </div>
  220. <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>
  221. <div class="method">
  222. <div class="description">
  223. <p>Sets the weapon defined by the given weapon index. This will result in a different weapon
  224. hold by the character.</p>
  225. </div>
  226. <table class="params">
  227. <tbody>
  228. <tr>
  229. <td class="name"><code>index</code></td>
  230. <td class="description last"><p>The weapon index.</p></td>
  231. </tr>
  232. </tbody>
  233. </table>
  234. </div>
  235. <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>
  236. <div class="method">
  237. <div class="description">
  238. <p>Sets the wireframe material flag.</p>
  239. </div>
  240. <table class="params">
  241. <tbody>
  242. <tr>
  243. <td class="name"><code>wireframeEnabled</code></td>
  244. <td class="description last"><p>Whether to enable wireframe rendering or not.</p></td>
  245. </tr>
  246. </tbody>
  247. </table>
  248. </div>
  249. <h3 class="name name-method" id="shareParts" translate="no">.<a href="#shareParts">shareParts</a><span class="signature">( original : <span class="param-type">MD2CharacterComplex</span> )</span> </h3>
  250. <div class="method">
  251. <div class="description">
  252. <p>Shares certain resources from a different character model.</p>
  253. </div>
  254. <table class="params">
  255. <tbody>
  256. <tr>
  257. <td class="name"><code>original</code></td>
  258. <td class="description last"><p>The original MD2 character.</p></td>
  259. </tr>
  260. </tbody>
  261. </table>
  262. </div>
  263. <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>
  264. <div class="method">
  265. <div class="description">
  266. <p>Updates the animations of the mesh. Must be called inside the animation loop.</p>
  267. </div>
  268. <table class="params">
  269. <tbody>
  270. <tr>
  271. <td class="name"><code>delta</code></td>
  272. <td class="description last"><p>The delta time in seconds.</p></td>
  273. </tr>
  274. </tbody>
  275. </table>
  276. </div>
  277. <h3 class="name name-method" id="updateBehaviors" translate="no">.<a href="#updateBehaviors">updateBehaviors</a><span class="signature">()</span> </h3>
  278. <div class="method">
  279. <div class="description">
  280. <p>Updates the animation state based on the control inputs.</p>
  281. </div>
  282. </div>
  283. <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>
  284. <div class="method">
  285. <div class="description">
  286. <p>Transforms the character model based on the control input.</p>
  287. </div>
  288. <table class="params">
  289. <tbody>
  290. <tr>
  291. <td class="name"><code>delta</code></td>
  292. <td class="description last"><p>The delta time in seconds.</p></td>
  293. </tr>
  294. </tbody>
  295. </table>
  296. </div>
  297. <h2 class="subsection-title">Source</h2>
  298. <p>
  299. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/misc/MD2CharacterComplex.js" target="_blank" rel="noopener" translate="no">examples/jsm/misc/MD2CharacterComplex.js</a>
  300. </p>
  301. </article>
  302. </section>
  303. <script src="../scripts/linenumber.js"></script>
  304. <script src="../scripts/page.js"></script>
  305. </body>
  306. </html>
粤ICP备19079148号