KeyframeTrack.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>KeyframeTrack - 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">KeyframeTrack</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Represents s a timed sequence of keyframes, which are composed of lists of
  16. times and related values, and which are used to animate a specific property
  17. of an object.</p></div>
  18. </header>
  19. <article>
  20. <div class="container-overview">
  21. <h2>Constructor</h2>
  22. <h3 class="name name-method" id="KeyframeTrack" translate="no">new <a href="#KeyframeTrack">KeyframeTrack</a><span class="signature">( name : <span class="param-type">string</span>, times : <span class="param-type">Array.&lt;number></span>, values : <span class="param-type">Array.&lt;(number|string|boolean)></span>, interpolation : <span class="param-type"><a href="global.html#InterpolateLinear">InterpolateLinear</a> | <a href="global.html#InterpolateDiscrete">InterpolateDiscrete</a> | <a href="global.html#InterpolateSmooth">InterpolateSmooth</a></span> )</span> </h3>
  23. <div class="method">
  24. <div class="description">
  25. <p>Constructs a new keyframe track.</p>
  26. </div>
  27. <table class="params">
  28. <tbody>
  29. <tr>
  30. <td class="name">
  31. <strong>name</strong>
  32. </td>
  33. <td class="description last">
  34. <p>The keyframe track's name.</p>
  35. </td>
  36. </tr>
  37. <tr>
  38. <td class="name">
  39. <strong>times</strong>
  40. </td>
  41. <td class="description last">
  42. <p>A list of keyframe times.</p>
  43. </td>
  44. </tr>
  45. <tr>
  46. <td class="name">
  47. <strong>values</strong>
  48. </td>
  49. <td class="description last">
  50. <p>A list of keyframe values.</p>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td class="name">
  55. <strong>interpolation</strong>
  56. </td>
  57. <td class="description last">
  58. <p>The interpolation type.</p>
  59. </td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. </div>
  64. </div>
  65. <h2 class="subsection-title">Properties</h2>
  66. <div class="member">
  67. <h3 class="name" id="DefaultInterpolation" translate="no">.<a href="#DefaultInterpolation">DefaultInterpolation</a><span class="type-signature"> : <a href="global.html#InterpolateLinear">InterpolateLinear</a> | <a href="global.html#InterpolateDiscrete">InterpolateDiscrete</a> | <a href="global.html#InterpolateSmooth">InterpolateSmooth</a></span> </h3>
  68. <div class="description">
  69. <p>The default interpolation type of this keyframe track.</p>
  70. <p>Default is <code>InterpolateLinear</code>.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="TimeBufferType" translate="no">.<a href="#TimeBufferType">TimeBufferType</a><span class="type-signature"> : TypedArray | Array</span> </h3>
  75. <div class="description">
  76. <p>The time buffer type of this keyframe track.</p>
  77. <p>Default is <code>Float32Array.constructor</code>.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="ValueBufferType" translate="no">.<a href="#ValueBufferType">ValueBufferType</a><span class="type-signature"> : TypedArray | Array</span> </h3>
  82. <div class="description">
  83. <p>The value buffer type of this keyframe track.</p>
  84. <p>Default is <code>Float32Array.constructor</code>.</p>
  85. </div>
  86. </div>
  87. <div class="member">
  88. <h3 class="name" id="ValueTypeName" translate="no">.<a href="#ValueTypeName">ValueTypeName</a><span class="type-signature"> : String</span> </h3>
  89. <div class="description">
  90. <p>The value type name.</p>
  91. <p>Default is <code>''</code>.</p>
  92. </div>
  93. </div>
  94. <div class="member">
  95. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  96. <div class="description">
  97. <p>The track's name can refer to morph targets or bones or
  98. possibly other values within an animated object. See PropertyBinding#parseTrackName
  99. for the forms of strings that can be parsed for property binding.</p>
  100. </div>
  101. </div>
  102. <div class="member">
  103. <h3 class="name" id="times" translate="no">.<a href="#times">times</a><span class="type-signature"> : Float32Array</span> </h3>
  104. <div class="description">
  105. <p>The keyframe times.</p>
  106. </div>
  107. </div>
  108. <div class="member">
  109. <h3 class="name" id="values" translate="no">.<a href="#values">values</a><span class="type-signature"> : Float32Array</span> </h3>
  110. <div class="description">
  111. <p>The keyframe values.</p>
  112. </div>
  113. </div>
  114. <h2 class="subsection-title">Methods</h2>
  115. <h3 class="name name-method" id="InterpolantFactoryMethodDiscrete" translate="no">.<a href="#InterpolantFactoryMethodDiscrete">InterpolantFactoryMethodDiscrete</a><span class="signature">( result : <span class="param-type">TypedArray</span> )</span><span class="type-signature"> : <a href="DiscreteInterpolant.html">DiscreteInterpolant</a></span> </h3>
  116. <div class="method">
  117. <div class="description">
  118. <p>Factory method for creating a new discrete interpolant.</p>
  119. </div>
  120. <table class="params">
  121. <tbody>
  122. <tr>
  123. <td class="name">
  124. <strong>result</strong>
  125. </td>
  126. <td class="description last">
  127. <p>The result buffer.</p>
  128. </td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. <dl class="details">
  133. <dt class="tag-returns"><strong>Returns:</strong> The new interpolant.</dt>
  134. </dl>
  135. </div>
  136. <h3 class="name name-method" id="InterpolantFactoryMethodLinear" translate="no">.<a href="#InterpolantFactoryMethodLinear">InterpolantFactoryMethodLinear</a><span class="signature">( result : <span class="param-type">TypedArray</span> )</span><span class="type-signature"> : <a href="LinearInterpolant.html">LinearInterpolant</a></span> </h3>
  137. <div class="method">
  138. <div class="description">
  139. <p>Factory method for creating a new linear interpolant.</p>
  140. </div>
  141. <table class="params">
  142. <tbody>
  143. <tr>
  144. <td class="name">
  145. <strong>result</strong>
  146. </td>
  147. <td class="description last">
  148. <p>The result buffer.</p>
  149. </td>
  150. </tr>
  151. </tbody>
  152. </table>
  153. <dl class="details">
  154. <dt class="tag-returns"><strong>Returns:</strong> The new interpolant.</dt>
  155. </dl>
  156. </div>
  157. <h3 class="name name-method" id="InterpolantFactoryMethodSmooth" translate="no">.<a href="#InterpolantFactoryMethodSmooth">InterpolantFactoryMethodSmooth</a><span class="signature">( result : <span class="param-type">TypedArray</span> )</span><span class="type-signature"> : <a href="CubicInterpolant.html">CubicInterpolant</a></span> </h3>
  158. <div class="method">
  159. <div class="description">
  160. <p>Factory method for creating a new smooth interpolant.</p>
  161. </div>
  162. <table class="params">
  163. <tbody>
  164. <tr>
  165. <td class="name">
  166. <strong>result</strong>
  167. </td>
  168. <td class="description last">
  169. <p>The result buffer.</p>
  170. </td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. <dl class="details">
  175. <dt class="tag-returns"><strong>Returns:</strong> The new interpolant.</dt>
  176. </dl>
  177. </div>
  178. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="KeyframeTrack.html">KeyframeTrack</a></span> </h3>
  179. <div class="method">
  180. <div class="description">
  181. <p>Returns a new keyframe track with copied values from this instance.</p>
  182. </div>
  183. <dl class="details">
  184. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  185. </dl>
  186. </div>
  187. <h3 class="name name-method" id="getInterpolation" translate="no">.<a href="#getInterpolation">getInterpolation</a><span class="signature">()</span><span class="type-signature"> : <a href="global.html#InterpolateLinear">InterpolateLinear</a> | <a href="global.html#InterpolateDiscrete">InterpolateDiscrete</a> | <a href="global.html#InterpolateSmooth">InterpolateSmooth</a></span> </h3>
  188. <div class="method">
  189. <div class="description">
  190. <p>Returns the current interpolation type.</p>
  191. </div>
  192. <dl class="details">
  193. <dt class="tag-returns"><strong>Returns:</strong> The interpolation type.</dt>
  194. </dl>
  195. </div>
  196. <h3 class="name name-method" id="getValueSize" translate="no">.<a href="#getValueSize">getValueSize</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  197. <div class="method">
  198. <div class="description">
  199. <p>Returns the value size.</p>
  200. </div>
  201. <dl class="details">
  202. <dt class="tag-returns"><strong>Returns:</strong> The value size.</dt>
  203. </dl>
  204. </div>
  205. <h3 class="name name-method" id="optimize" translate="no">.<a href="#optimize">optimize</a><span class="signature">()</span><span class="type-signature"> : <a href="AnimationClip.html">AnimationClip</a></span> </h3>
  206. <div class="method">
  207. <div class="description">
  208. <p>Optimizes this keyframe track by removing equivalent sequential keys (which are
  209. common in morph target sequences).</p>
  210. </div>
  211. <dl class="details">
  212. <dt class="tag-returns"><strong>Returns:</strong> A reference to this animation clip.</dt>
  213. </dl>
  214. </div>
  215. <h3 class="name name-method" id="scale" translate="no">.<a href="#scale">scale</a><span class="signature">( timeScale : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="KeyframeTrack.html">KeyframeTrack</a></span> </h3>
  216. <div class="method">
  217. <div class="description">
  218. <p>Scale all keyframe times by a factor (useful for frame - seconds conversions).</p>
  219. </div>
  220. <table class="params">
  221. <tbody>
  222. <tr>
  223. <td class="name">
  224. <strong>timeScale</strong>
  225. </td>
  226. <td class="description last">
  227. <p>The time scale.</p>
  228. </td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. <dl class="details">
  233. <dt class="tag-returns"><strong>Returns:</strong> A reference to this keyframe track.</dt>
  234. </dl>
  235. </div>
  236. <h3 class="name name-method" id="setInterpolation" translate="no">.<a href="#setInterpolation">setInterpolation</a><span class="signature">( interpolation : <span class="param-type"><a href="global.html#InterpolateLinear">InterpolateLinear</a> | <a href="global.html#InterpolateDiscrete">InterpolateDiscrete</a> | <a href="global.html#InterpolateSmooth">InterpolateSmooth</a></span> )</span><span class="type-signature"> : <a href="KeyframeTrack.html">KeyframeTrack</a></span> </h3>
  237. <div class="method">
  238. <div class="description">
  239. <p>Defines the interpolation factor method for this keyframe track.</p>
  240. </div>
  241. <table class="params">
  242. <tbody>
  243. <tr>
  244. <td class="name">
  245. <strong>interpolation</strong>
  246. </td>
  247. <td class="description last">
  248. <p>The interpolation type.</p>
  249. </td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <dl class="details">
  254. <dt class="tag-returns"><strong>Returns:</strong> A reference to this keyframe track.</dt>
  255. </dl>
  256. </div>
  257. <h3 class="name name-method" id="shift" translate="no">.<a href="#shift">shift</a><span class="signature">( timeOffset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="KeyframeTrack.html">KeyframeTrack</a></span> </h3>
  258. <div class="method">
  259. <div class="description">
  260. <p>Moves all keyframes either forward or backward in time.</p>
  261. </div>
  262. <table class="params">
  263. <tbody>
  264. <tr>
  265. <td class="name">
  266. <strong>timeOffset</strong>
  267. </td>
  268. <td class="description last">
  269. <p>The offset to move the time values.</p>
  270. </td>
  271. </tr>
  272. </tbody>
  273. </table>
  274. <dl class="details">
  275. <dt class="tag-returns"><strong>Returns:</strong> A reference to this keyframe track.</dt>
  276. </dl>
  277. </div>
  278. <h3 class="name name-method" id="trim" translate="no">.<a href="#trim">trim</a><span class="signature">( startTime : <span class="param-type">number</span>, endTime : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="KeyframeTrack.html">KeyframeTrack</a></span> </h3>
  279. <div class="method">
  280. <div class="description">
  281. <p>Removes keyframes before and after animation without changing any values within the defined time range.</p>
  282. <p>Note: The method does not shift around keys to the start of the track time, because for interpolated
  283. keys this will change their values</p>
  284. </div>
  285. <table class="params">
  286. <tbody>
  287. <tr>
  288. <td class="name">
  289. <strong>startTime</strong>
  290. </td>
  291. <td class="description last">
  292. <p>The start time.</p>
  293. </td>
  294. </tr>
  295. <tr>
  296. <td class="name">
  297. <strong>endTime</strong>
  298. </td>
  299. <td class="description last">
  300. <p>The end time.</p>
  301. </td>
  302. </tr>
  303. </tbody>
  304. </table>
  305. <dl class="details">
  306. <dt class="tag-returns"><strong>Returns:</strong> A reference to this keyframe track.</dt>
  307. </dl>
  308. </div>
  309. <h3 class="name name-method" id="validate" translate="no">.<a href="#validate">validate</a><span class="signature">()</span><span class="type-signature"> : boolean</span> </h3>
  310. <div class="method">
  311. <div class="description">
  312. <p>Performs minimal validation on the keyframe track. Returns <code>true</code> if the values
  313. are valid.</p>
  314. </div>
  315. <dl class="details">
  316. <dt class="tag-returns"><strong>Returns:</strong> Whether the keyframes are valid or not.</dt>
  317. </dl>
  318. </div>
  319. <h2 class="subsection-title">Static Methods</h2>
  320. <h3 class="name name-method" id=".toJSON" translate="no">.<a href="#.toJSON">toJSON</a><span class="signature">( track : <span class="param-type"><a href="KeyframeTrack.html">KeyframeTrack</a></span> )</span><span class="type-signature"> : Object</span> </h3>
  321. <div class="method">
  322. <div class="description">
  323. <p>Converts the keyframe track to JSON.</p>
  324. </div>
  325. <table class="params">
  326. <tbody>
  327. <tr>
  328. <td class="name">
  329. <strong>track</strong>
  330. </td>
  331. <td class="description last">
  332. <p>The keyframe track to serialize.</p>
  333. </td>
  334. </tr>
  335. </tbody>
  336. </table>
  337. <dl class="details">
  338. <dt class="tag-returns"><strong>Returns:</strong> The serialized keyframe track as JSON.</dt>
  339. </dl>
  340. </div>
  341. <h2 class="subsection-title">Source</h2>
  342. <p>
  343. <a href="https://github.com/mrdoob/three.js/blob/master/src/animation/KeyframeTrack.js" translate="no" target="_blank" rel="noopener">src/animation/KeyframeTrack.js</a>
  344. </p>
  345. </article>
  346. </section>
  347. <script src="../scripts/linenumber.js"></script>
  348. <script src="../scripts/page.js"></script>
  349. </body>
  350. </html>
粤ICP备19079148号