1
0

AnimationAction.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">
  12. AnimationActions schedule the performance of the animations which are
  13. stored in [page:AnimationClip AnimationClips].<br /><br />
  14. Note: Most of AnimationAction's methods can be chained.<br /><br />
  15. For an overview of the different elements of the three.js animation system
  16. see the "Animation System" article in the "Next Steps" section of the
  17. manual.
  18. </p>
  19. <h2>Constructor</h2>
  20. <h3>
  21. [name]( [param:AnimationMixer mixer], [param:AnimationClip clip],
  22. [param:Object3D localRoot] )
  23. </h3>
  24. <p>
  25. [page:AnimationMixer mixer] - the `AnimationMixer` that is controlled by
  26. this action.<br />
  27. [page:AnimationClip clip] - the `AnimationClip` that holds the animation
  28. data for this action.<br />
  29. [page:Object3D localRoot] - the root object on which this action is
  30. performed.<br />
  31. [page:Number blendMode] - defines how the animation is blended/combined
  32. when two or more animations are simultaneously played.<br /><br />
  33. Note: Instead of calling this constructor directly you should instantiate
  34. an AnimationAction with [page:AnimationMixer.clipAction] since this method
  35. provides caching for better performance.
  36. </p>
  37. <h2>Properties</h2>
  38. <h3>[property:Number blendMode]</h3>
  39. <p>
  40. Defines how the animation is blended/combined when two or more animations
  41. are simultaneously played. Valid values are *NormalAnimationBlendMode*
  42. (default) and *AdditiveAnimationBlendMode*.
  43. </p>
  44. <h3>[property:Boolean clampWhenFinished]</h3>
  45. <p>
  46. If `clampWhenFinished` is set to true the animation will automatically be
  47. [page:.paused paused] on its last frame.<br /><br />
  48. If `clampWhenFinished` is set to false, [page:.enabled enabled] will
  49. automatically be switched to false when the last loop of the action has
  50. finished, so that this action has no further impact.<br /><br />
  51. Default is `false`.<br /><br />
  52. Note: `clampWhenFinished` has no impact if the action is interrupted (it
  53. has only an effect if its last loop has really finished).
  54. </p>
  55. <h3>[property:Boolean enabled]</h3>
  56. <p>
  57. Setting `enabled` to `false` disables this action, so that it has no
  58. impact. Default is `true`.<br /><br />
  59. When the action is re-enabled, the animation continues from its current
  60. [page:.time time] (setting `enabled` to `false` doesn't reset the
  61. action).<br /><br />
  62. Note: Setting `enabled` to `true` doesn’t automatically restart the
  63. animation. Setting `enabled` to `true` will only restart the animation
  64. immediately if the following condition is fulfilled: [page:.paused paused]
  65. is `false`, this action has not been deactivated in the meantime (by
  66. executing a [page:.stop stop] or [page:.reset reset] command), and neither
  67. [page:.weight weight] nor [page:.timeScale timeScale] is `0`.
  68. </p>
  69. <h3>[property:Number loop]</h3>
  70. <p>
  71. The looping mode (can be changed with [page:.setLoop setLoop]). Default is
  72. [page:Animation THREE.LoopRepeat] (with an infinite number of
  73. [page:.repetitions repetitions])<br /><br />
  74. Must be one of these constants:<br /><br />
  75. [page:Animation THREE.LoopOnce] - playing the clip once,<br />
  76. [page:Animation THREE.LoopRepeat] - playing the clip with the chosen
  77. number of `repetitions`, each time jumping from the end of the clip
  78. directly to its beginning,<br />
  79. [page:Animation THREE.LoopPingPong] - playing the clip with the chosen
  80. number of `repetitions`, alternately playing forward and backward.
  81. </p>
  82. <h3>[property:Boolean paused]</h3>
  83. <p>
  84. Setting `paused` to `true` pauses the execution of the action by setting
  85. the effective time scale to `0`. Default is `false`.<br /><br />
  86. </p>
  87. <h3>[property:Number repetitions]</h3>
  88. <p>
  89. The number of repetitions of the performed [page:AnimationClip] over the
  90. course of this action. Can be set via [page:.setLoop setLoop]. Default is
  91. `Infinity`.<br /><br />
  92. Setting this number has no effect, if the [page:.loop loop mode] is set to
  93. [page:Animation THREE.LoopOnce].
  94. </p>
  95. <h3>[property:Number time]</h3>
  96. <p>
  97. The local time of this action (in seconds, starting with `0`).<br /><br />
  98. The value gets clamped or wrapped to `0...clip.duration` (according to the
  99. loop state). It can be scaled relatively to the global mixer time by
  100. changing [page:.timeScale timeScale] (using [page:.setEffectiveTimeScale setEffectiveTimeScale] or [page:.setDuration setDuration]).<br />
  101. </p>
  102. <h3>[property:Number timeScale]</h3>
  103. <p>
  104. Scaling factor for the [page:.time time]. A value of `0` causes the
  105. animation to pause. Negative values cause the animation to play backwards.
  106. Default is `1`.<br /><br />
  107. Properties/methods concerning `timeScale` (respectively `time`) are:
  108. [page:.getEffectiveTimeScale getEffectiveTimeScale],
  109. [page:.halt halt],
  110. [page:.paused paused],
  111. [page:.setDuration setDuration],
  112. [page:.setEffectiveTimeScale setEffectiveTimeScale],
  113. [page:.stopWarping stopWarping],
  114. [page:.syncWith syncWith],
  115. [page:.warp warp].
  116. </p>
  117. <h3>[property:Number weight]</h3>
  118. <p>
  119. The degree of influence of this action (in the interval `[0, 1]`). Values
  120. between `0` (no impact) and `1` (full impact) can be used to blend between
  121. several actions. Default is `1`. <br /><br />
  122. Properties/methods concerning `weight` are:
  123. [page:.crossFadeFrom crossFadeFrom],
  124. [page:.crossFadeTo crossFadeTo],
  125. [page:.enabled enabled],
  126. [page:.fadeIn fadeIn],
  127. [page:.fadeOut fadeOut],
  128. [page:.getEffectiveWeight getEffectiveWeight],
  129. [page:.setEffectiveWeight setEffectiveWeight],
  130. [page:.stopFading stopFading].
  131. </p>
  132. <h3>[property:Boolean zeroSlopeAtEnd]</h3>
  133. <p>
  134. Enables smooth interpolation without separate clips for start, loop and
  135. end. Default is `true`.
  136. </p>
  137. <h3>[property:Boolean zeroSlopeAtStart]</h3>
  138. <p>
  139. Enables smooth interpolation without separate clips for start, loop and
  140. end. Default is `true`.
  141. </p>
  142. <h2>Methods</h2>
  143. <h3>
  144. [method:this crossFadeFrom]( [param:AnimationAction fadeOutAction], [param:Number durationInSeconds], [param:Boolean warpBoolean] )
  145. </h3>
  146. <p>
  147. Causes this action to [page:.fadeIn fade in], fading out another action
  148. simultaneously, within the passed time interval. This method can be
  149. chained.<br /><br />
  150. If warpBoolean is true, additional [page:.warp warping] (gradually changes
  151. of the time scales) will be applied.<br /><br />
  152. Note: Like with `fadeIn`/`fadeOut`, the fading starts/ends with a weight
  153. of `1`.
  154. </p>
  155. <h3>
  156. [method:this crossFadeTo]( [param:AnimationAction fadeInAction], [param:Number durationInSeconds], [param:Boolean warpBoolean] )
  157. </h3>
  158. <p>
  159. Causes this action to [page:.fadeOut fade out], fading in another action
  160. simultaneously, within the passed time interval. This method can be
  161. chained.<br /><br />
  162. If warpBoolean is true, additional [page:.warp warping] (gradually changes
  163. of the time scales) will be applied.<br /><br />
  164. Note: Like with `fadeIn`/`fadeOut`, the fading starts/ends with a weight
  165. of `1`.
  166. </p>
  167. <h3>[method:this fadeIn]( [param:Number durationInSeconds] )</h3>
  168. <p>
  169. Increases the [page:.weight weight] of this action gradually from `0` to
  170. `1`, within the passed time interval. This method can be chained.
  171. </p>
  172. <h3>[method:this fadeOut]( [param:Number durationInSeconds] )</h3>
  173. <p>
  174. Decreases the [page:.weight weight] of this action gradually from `1` to
  175. `0`, within the passed time interval. This method can be chained.
  176. </p>
  177. <h3>[method:Number getEffectiveTimeScale]()</h3>
  178. <p>
  179. Returns the effective time scale (considering the current states of
  180. warping and [page:.paused paused]).
  181. </p>
  182. <h3>[method:Number getEffectiveWeight]()</h3>
  183. <p>
  184. Returns the effective weight (considering the current states of fading and
  185. [page:.enabled enabled]).
  186. </p>
  187. <h3>[method:AnimationClip getClip]()</h3>
  188. <p>Returns the clip which holds the animation data for this action.</p>
  189. <h3>[method:AnimationMixer getMixer]()</h3>
  190. <p>Returns the mixer which is responsible for playing this action.</p>
  191. <h3>[method:Object3D getRoot]()</h3>
  192. <p>Returns the root object on which this action is performed.</p>
  193. <h3>[method:this halt]( [param:Number durationInSeconds] )</h3>
  194. <p>
  195. Decelerates this animation's speed to `0` by decreasing [page:.timeScale timeScale] gradually (starting from its current value), within the passed
  196. time interval. This method can be chained.
  197. </p>
  198. <h3>[method:Boolean isRunning]()</h3>
  199. <p>
  200. Returns true if the action’s [page:.time time] is currently running.<br /><br />
  201. In addition to being activated in the mixer (see [page:.isScheduled isScheduled]) the following conditions must be fulfilled: [page:.paused paused] is equal to false, [page:.enabled enabled] is equal to true,
  202. [page:.timeScale timeScale] is different from `0`, and there is no
  203. scheduling for a delayed start ([page:.startAt startAt]).<br /><br />
  204. Note: `isRunning` being true doesn’t necessarily mean that the animation
  205. can actually be seen. This is only the case, if [page:.weight weight] is
  206. additionally set to a non-zero value.
  207. </p>
  208. <h3>[method:Boolean isScheduled]()</h3>
  209. <p>
  210. Returns true, if this action is activated in the mixer.<br /><br />
  211. Note: This doesn’t necessarily mean that the animation is actually running
  212. (compare the additional conditions for [page:.isRunning isRunning]).
  213. </p>
  214. <h3>[method:this play]()</h3>
  215. <p>
  216. Tells the mixer to activate the action. This method can be chained.<br /><br />
  217. Note: Activating this action doesn’t necessarily mean that the animation
  218. starts immediately: If the action had already finished before (by reaching
  219. the end of its last loop), or if a time for a delayed start has been set
  220. (via [page:.startAt startAt]), a [page:.reset reset] must be executed
  221. first. Some other settings ([page:.paused paused]=true, [page:.enabled enabled]=false, [page:.weight weight]=0, [page:.timeScale timeScale]=0)
  222. can prevent the animation from playing, too.
  223. </p>
  224. <h3>[method:this reset]()</h3>
  225. <p>
  226. Resets the action. This method can be chained.<br /><br />
  227. This method sets [page:.paused paused] to false, [page:.enabled enabled]
  228. to true, [page:.time time] to `0`, interrupts any scheduled fading and
  229. warping, and removes the internal loop count and scheduling for delayed
  230. starting.<br /><br />
  231. Note: .`reset` is always called by [page:.stop stop], but .`reset` doesn’t
  232. call .`stop` itself. This means: If you want both, resetting and stopping,
  233. don’t call .`reset`; call .`stop` instead.
  234. </p>
  235. <h3>[method:this setDuration]( [param:Number durationInSeconds] )</h3>
  236. <p>
  237. Sets the duration for a single loop of this action (by adjusting
  238. [page:.timeScale timeScale] and stopping any scheduled warping). This
  239. method can be chained.
  240. </p>
  241. <h3>[method:this setEffectiveTimeScale]( [param:Number timeScale] )</h3>
  242. <p>
  243. Sets the [page:.timeScale timeScale] and stops any scheduled warping. This
  244. method can be chained.<br /><br />
  245. If [page:.paused paused] is false, the effective time scale (an internal
  246. property) will also be set to this value; otherwise the effective time
  247. scale (directly affecting the animation at this moment) will be set to
  248. `0`.<br /><br />
  249. Note: .`paused` will not be switched to `true` automatically, if
  250. .`timeScale` is set to `0` by this method.
  251. </p>
  252. <h3>[method:this setEffectiveWeight]( [param:Number weight] )</h3>
  253. <p>
  254. Sets the [page:.weight weight] and stops any scheduled fading. This method
  255. can be chained.<br /><br />
  256. If [page:.enabled enabled] is true, the effective weight (an internal
  257. property) will also be set to this value; otherwise the effective weight
  258. (directly affecting the animation at this moment) will be set to `0`.<br /><br />
  259. Note: .`enabled` will not be switched to `false` automatically, if
  260. .`weight` is set to `0` by this method.
  261. </p>
  262. <h3>
  263. [method:this setLoop]( [param:Number loopMode], [param:Number repetitions])
  264. </h3>
  265. <p>
  266. Sets the [page:.loop loop mode] and the number of [page:.repetitions repetitions]. This method can be chained.
  267. </p>
  268. <h3>[method:this startAt]( [param:Number startTimeInSeconds] )</h3>
  269. <p>
  270. Defines the time for a delayed start (usually passed as
  271. [page:AnimationMixer.time] + deltaTimeInSeconds). This method can be
  272. chained.<br /><br />
  273. Note: The animation will only start at the given time, if .`startAt` is
  274. chained with [page:.play play], or if the action has already been
  275. activated in the mixer (by a previous call of .`play`, without stopping or
  276. resetting it in the meantime).
  277. </p>
  278. <h3>[method:this stop]()</h3>
  279. <p>
  280. Tells the mixer to deactivate this action. This method can be chained.<br /><br />
  281. The action will be immediately stopped and completely [page:.reset reset].<br /><br />
  282. Note: You can stop all active actions on the same mixer in one go via
  283. [page:AnimationMixer.stopAllAction mixer.stopAllAction].
  284. </p>
  285. <h3>[method:this stopFading]()</h3>
  286. <p>
  287. Stops any scheduled [page:.fadeIn fading] which is applied to this action.
  288. This method can be chained.
  289. </p>
  290. <h3>[method:this stopWarping]()</h3>
  291. <p>
  292. Stops any scheduled [page:.warp warping] which is applied to this action.
  293. This method can be chained.
  294. </p>
  295. <h3>[method:this syncWith]( [param:AnimationAction otherAction] )</h3>
  296. <p>
  297. Synchronizes this action with the passed other action. This method can be
  298. chained.<br /><br />
  299. Synchronizing is done by setting this action’s [page:.time time] and
  300. [page:.timeScale timeScale] values to the corresponding values of the
  301. other action (stopping any scheduled warping).<br /><br />
  302. Note: Future changes of the other action's `time` and `timeScale` will not
  303. be detected.
  304. </p>
  305. <h3>
  306. [method:this warp]( [param:Number startTimeScale], [param:Number endTimeScale], [param:Number durationInSeconds] )
  307. </h3>
  308. <p>
  309. Changes the playback speed, within the passed time interval, by modifying
  310. [page:.timeScale timeScale] gradually from `startTimeScale` to
  311. `endTimeScale`. This method can be chained.
  312. </p>
  313. <h2>Events</h2>
  314. <p class="desc">
  315. There are two events indicating when a single loop of the action
  316. respectively the entire action has finished. You can react to them with:
  317. </p>
  318. <code>
  319. mixer.addEventListener( 'loop', function( e ) { …} ); // properties of e: type, action and loopDelta
  320. mixer.addEventListener( 'finished', function( e ) { …} ); // properties of e: type, action and direction
  321. </code>
  322. <h2>Source</h2>
  323. <p>
  324. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  325. </p>
  326. </body>
  327. </html>