KeyframeTrack.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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">InterpolateLinear | InterpolateDiscrete | InterpolateSmooth</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"><code>name</code></td>
  31. <td class="description last"><p>The keyframe track's name.</p></td>
  32. </tr>
  33. <tr>
  34. <td class="name"><code>times</code></td>
  35. <td class="description last"><p>A list of keyframe times.</p></td>
  36. </tr>
  37. <tr>
  38. <td class="name"><code>values</code></td>
  39. <td class="description last"><p>A list of keyframe values.</p></td>
  40. </tr>
  41. <tr>
  42. <td class="name"><code>interpolation</code></td>
  43. <td class="description last"><p>The interpolation type.</p></td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <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>
  52. <div class="description">
  53. <p>The default interpolation type of this keyframe track.<br/>Default is <code>InterpolateLinear</code>.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="TimeBufferType" translate="no">.<a href="#TimeBufferType">TimeBufferType</a><span class="type-signature"> : TypedArray | Array</span> </h3>
  58. <div class="description">
  59. <p>The time buffer type of this keyframe track.<br/>Default is <code>Float32Array.constructor</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="ValueBufferType" translate="no">.<a href="#ValueBufferType">ValueBufferType</a><span class="type-signature"> : TypedArray | Array</span> </h3>
  64. <div class="description">
  65. <p>The value buffer type of this keyframe track.<br/>Default is <code>Float32Array.constructor</code>.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="ValueTypeName" translate="no">.<a href="#ValueTypeName">ValueTypeName</a><span class="type-signature"> : String</span> </h3>
  70. <div class="description">
  71. <p>The value type name.<br/>Default is <code>''</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  76. <div class="description">
  77. <p>The track's name can refer to morph targets or bones or
  78. possibly other values within an animated object. See PropertyBinding#parseTrackName
  79. for the forms of strings that can be parsed for property binding.</p>
  80. </div>
  81. </div>
  82. <div class="member">
  83. <h3 class="name" id="times" translate="no">.<a href="#times">times</a><span class="type-signature"> : Float32Array</span> </h3>
  84. <div class="description">
  85. <p>The keyframe times.</p>
  86. </div>
  87. </div>
  88. <div class="member">
  89. <h3 class="name" id="values" translate="no">.<a href="#values">values</a><span class="type-signature"> : Float32Array</span> </h3>
  90. <div class="description">
  91. <p>The keyframe values.</p>
  92. </div>
  93. </div>
  94. <h2 class="subsection-title">Methods</h2>
  95. <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>
  96. <div class="method">
  97. <div class="description">
  98. <p>Factory method for creating a new discrete interpolant.</p>
  99. </div>
  100. <table class="params">
  101. <tbody>
  102. <tr>
  103. <td class="name"><code>result</code></td>
  104. <td class="description last"><p>The result buffer.</p></td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. <dl class="details">
  109. <dt class="tag-returns"><strong>Returns:</strong> The new interpolant.</dt>
  110. </dl>
  111. </div>
  112. <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>
  113. <div class="method">
  114. <div class="description">
  115. <p>Factory method for creating a new linear interpolant.</p>
  116. </div>
  117. <table class="params">
  118. <tbody>
  119. <tr>
  120. <td class="name"><code>result</code></td>
  121. <td class="description last"><p>The result buffer.</p></td>
  122. </tr>
  123. </tbody>
  124. </table>
  125. <dl class="details">
  126. <dt class="tag-returns"><strong>Returns:</strong> The new interpolant.</dt>
  127. </dl>
  128. </div>
  129. <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>
  130. <div class="method">
  131. <div class="description">
  132. <p>Factory method for creating a new smooth interpolant.</p>
  133. </div>
  134. <table class="params">
  135. <tbody>
  136. <tr>
  137. <td class="name"><code>result</code></td>
  138. <td class="description last"><p>The result buffer.</p></td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. <dl class="details">
  143. <dt class="tag-returns"><strong>Returns:</strong> The new interpolant.</dt>
  144. </dl>
  145. </div>
  146. <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>
  147. <div class="method">
  148. <div class="description">
  149. <p>Returns a new keyframe track with copied values from this instance.</p>
  150. </div>
  151. <dl class="details">
  152. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  153. </dl>
  154. </div>
  155. <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>
  156. <div class="method">
  157. <div class="description">
  158. <p>Returns the current interpolation type.</p>
  159. </div>
  160. <dl class="details">
  161. <dt class="tag-returns"><strong>Returns:</strong> The interpolation type.</dt>
  162. </dl>
  163. </div>
  164. <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>
  165. <div class="method">
  166. <div class="description">
  167. <p>Returns the value size.</p>
  168. </div>
  169. <dl class="details">
  170. <dt class="tag-returns"><strong>Returns:</strong> The value size.</dt>
  171. </dl>
  172. </div>
  173. <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>
  174. <div class="method">
  175. <div class="description">
  176. <p>Optimizes this keyframe track by removing equivalent sequential keys (which are
  177. common in morph target sequences).</p>
  178. </div>
  179. <dl class="details">
  180. <dt class="tag-returns"><strong>Returns:</strong> A reference to this animation clip.</dt>
  181. </dl>
  182. </div>
  183. <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>
  184. <div class="method">
  185. <div class="description">
  186. <p>Scale all keyframe times by a factor (useful for frame - seconds conversions).</p>
  187. </div>
  188. <table class="params">
  189. <tbody>
  190. <tr>
  191. <td class="name"><code>timeScale</code></td>
  192. <td class="description last"><p>The time scale.</p></td>
  193. </tr>
  194. </tbody>
  195. </table>
  196. <dl class="details">
  197. <dt class="tag-returns"><strong>Returns:</strong> A reference to this keyframe track.</dt>
  198. </dl>
  199. </div>
  200. <h3 class="name name-method" id="setInterpolation" translate="no">.<a href="#setInterpolation">setInterpolation</a><span class="signature">( interpolation : <span class="param-type">InterpolateLinear | InterpolateDiscrete | InterpolateSmooth</span> )</span><span class="type-signature"> : <a href="KeyframeTrack.html">KeyframeTrack</a></span> </h3>
  201. <div class="method">
  202. <div class="description">
  203. <p>Defines the interpolation factor method for this keyframe track.</p>
  204. </div>
  205. <table class="params">
  206. <tbody>
  207. <tr>
  208. <td class="name"><code>interpolation</code></td>
  209. <td class="description last"><p>The interpolation type.</p></td>
  210. </tr>
  211. </tbody>
  212. </table>
  213. <dl class="details">
  214. <dt class="tag-returns"><strong>Returns:</strong> A reference to this keyframe track.</dt>
  215. </dl>
  216. </div>
  217. <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>
  218. <div class="method">
  219. <div class="description">
  220. <p>Moves all keyframes either forward or backward in time.</p>
  221. </div>
  222. <table class="params">
  223. <tbody>
  224. <tr>
  225. <td class="name"><code>timeOffset</code></td>
  226. <td class="description last"><p>The offset to move the time values.</p></td>
  227. </tr>
  228. </tbody>
  229. </table>
  230. <dl class="details">
  231. <dt class="tag-returns"><strong>Returns:</strong> A reference to this keyframe track.</dt>
  232. </dl>
  233. </div>
  234. <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>
  235. <div class="method">
  236. <div class="description">
  237. <p>Removes keyframes before and after animation without changing any values within the defined time range.</p>
  238. <p>Note: The method does not shift around keys to the start of the track time, because for interpolated
  239. keys this will change their values</p>
  240. </div>
  241. <table class="params">
  242. <tbody>
  243. <tr>
  244. <td class="name"><code>startTime</code></td>
  245. <td class="description last"><p>The start time.</p></td>
  246. </tr>
  247. <tr>
  248. <td class="name"><code>endTime</code></td>
  249. <td class="description last"><p>The end time.</p></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="validate" translate="no">.<a href="#validate">validate</a><span class="signature">()</span><span class="type-signature"> : boolean</span> </h3>
  258. <div class="method">
  259. <div class="description">
  260. <p>Performs minimal validation on the keyframe track. Returns <code>true</code> if the values
  261. are valid.</p>
  262. </div>
  263. <dl class="details">
  264. <dt class="tag-returns"><strong>Returns:</strong> Whether the keyframes are valid or not.</dt>
  265. </dl>
  266. </div>
  267. <h2 class="subsection-title">Static Methods</h2>
  268. <h3 class="name name-method" id=".toJSON" translate="no">.<a href="#.toJSON">toJSON</a><span class="signature">( track : <span class="param-type">KeyframeTrack</span> )</span><span class="type-signature"> : Object</span> </h3>
  269. <div class="method">
  270. <div class="description">
  271. <p>Converts the keyframe track to JSON.</p>
  272. </div>
  273. <table class="params">
  274. <tbody>
  275. <tr>
  276. <td class="name"><code>track</code></td>
  277. <td class="description last"><p>The keyframe track to serialize.</p></td>
  278. </tr>
  279. </tbody>
  280. </table>
  281. <dl class="details">
  282. <dt class="tag-returns"><strong>Returns:</strong> The serialized keyframe track as JSON.</dt>
  283. </dl>
  284. </div>
  285. <h2 class="subsection-title">Source</h2>
  286. <p>
  287. <a href="https://github.com/mrdoob/three.js/blob/master/src/animation/KeyframeTrack.js" target="_blank" rel="noopener" translate="no">src/animation/KeyframeTrack.js</a>
  288. </p>
  289. </article>
  290. </section>
  291. <script src="../scripts/linenumber.js"></script>
  292. <script src="../scripts/page.js"></script>
  293. </body>
  294. </html>
粤ICP备19079148号