modelAnimation.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import { AnimationGroup, Vector3 } from "babylonjs";
  2. /**
  3. * Animation play mode enum - is the animation looping or playing once
  4. */
  5. export declare const enum AnimationPlayMode {
  6. ONCE = 0,
  7. LOOP = 1,
  8. }
  9. /**
  10. * An enum representing the current state of an animation object
  11. */
  12. export declare const enum AnimationState {
  13. INIT = 0,
  14. PLAYING = 1,
  15. PAUSED = 2,
  16. STOPPED = 3,
  17. ENDED = 4,
  18. }
  19. /**
  20. * The different type of easing functions available
  21. */
  22. export declare const enum EasingFunction {
  23. Linear = 0,
  24. CircleEase = 1,
  25. BackEase = 2,
  26. BounceEase = 3,
  27. CubicEase = 4,
  28. ElasticEase = 5,
  29. ExponentialEase = 6,
  30. PowerEase = 7,
  31. QuadraticEase = 8,
  32. QuarticEase = 9,
  33. QuinticEase = 10,
  34. SineEase = 11,
  35. }
  36. /**
  37. * Defines a simple animation to be applied to a model (scale).
  38. */
  39. export interface ModelAnimationConfiguration {
  40. /**
  41. * Time of animation, in seconds
  42. */
  43. time: number;
  44. /**
  45. * Scale to apply
  46. */
  47. scaling?: Vector3;
  48. /**
  49. * Easing function to apply
  50. * See SPECTRE.EasingFunction
  51. */
  52. easingFunction?: number;
  53. /**
  54. * An Easing mode to apply to the easing function
  55. * See BABYLON.EasingFunction
  56. */
  57. easingMode?: number;
  58. }
  59. /**
  60. * This interface can be implemented to define new types of ModelAnimation objects.
  61. */
  62. export interface IModelAnimation {
  63. /**
  64. * Current animation state (playing, stopped etc')
  65. */
  66. readonly state: AnimationState;
  67. /**
  68. * the name of the animation
  69. */
  70. readonly name: string;
  71. /**
  72. * Get the max numbers of frame available in the animation group
  73. *
  74. * In correlation to an arry, this would be ".length"
  75. */
  76. readonly frames: number;
  77. /**
  78. * Get the current frame playing right now.
  79. * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
  80. *
  81. * In correlation to an array, this would be the current index
  82. */
  83. readonly currentFrame: number;
  84. /**
  85. * Animation's FPS value
  86. */
  87. readonly fps: number;
  88. /**
  89. * Get or set the animation's speed ration (Frame-to-fps)
  90. */
  91. speedRatio: number;
  92. /**
  93. * Gets or sets the aimation's play mode.
  94. */
  95. playMode: AnimationPlayMode;
  96. /**
  97. * Start the animation
  98. */
  99. start(): any;
  100. /**
  101. * Stop the animation.
  102. * This will fail silently if the animation group is already stopped.
  103. */
  104. stop(): any;
  105. /**
  106. * Pause the animation
  107. * This will fail silently if the animation is not currently playing
  108. */
  109. pause(): any;
  110. /**
  111. * Reset this animation
  112. */
  113. reset(): any;
  114. /**
  115. * Restart the animation
  116. */
  117. restart(): any;
  118. /**
  119. * Go to a specific
  120. * @param frameNumber the frame number to go to
  121. */
  122. goToFrame(frameNumber: number): any;
  123. /**
  124. * Dispose this animation
  125. */
  126. dispose(): any;
  127. }
  128. /**
  129. * The GroupModelAnimation is an implementation of the IModelAnimation interface using BABYLON's
  130. * native GroupAnimation class.
  131. */
  132. export declare class GroupModelAnimation implements IModelAnimation {
  133. private _animationGroup;
  134. private _playMode;
  135. private _state;
  136. /**
  137. * Create a new GroupModelAnimation object using an AnimationGroup object
  138. * @param _animationGroup The aniamtion group to base the class on
  139. */
  140. constructor(_animationGroup: AnimationGroup);
  141. /**
  142. * Get the animation's name
  143. */
  144. readonly name: string;
  145. /**
  146. * Get the current animation's state
  147. */
  148. readonly state: AnimationState;
  149. /**
  150. * Gets the speed ratio to use for all animations
  151. */
  152. /**
  153. * Sets the speed ratio to use for all animations
  154. */
  155. speedRatio: number;
  156. /**
  157. * Get the max numbers of frame available in the animation group
  158. *
  159. * In correlation to an arry, this would be ".length"
  160. */
  161. readonly frames: number;
  162. /**
  163. * Get the current frame playing right now.
  164. * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
  165. *
  166. * In correlation to an array, this would be the current index
  167. */
  168. readonly currentFrame: number;
  169. /**
  170. * Get the FPS value of this animation
  171. */
  172. readonly fps: number;
  173. /**
  174. * What is the animation'S play mode (looping or played once)
  175. */
  176. /**
  177. * Set the play mode.
  178. * If the animation is played, it will continue playing at least once more, depending on the new play mode set.
  179. * If the animation is not set, the will be initialized and will wait for the user to start playing it.
  180. */
  181. playMode: AnimationPlayMode;
  182. /**
  183. * Reset the animation group
  184. */
  185. reset(): void;
  186. /**
  187. * Restart the animation group
  188. */
  189. restart(): void;
  190. /**
  191. *
  192. * @param frameNumber Go to a specific frame in the animation
  193. */
  194. goToFrame(frameNumber: number): void;
  195. /**
  196. * Start playing the animation.
  197. */
  198. start(): void;
  199. /**
  200. * Pause the animation
  201. */
  202. pause(): void;
  203. /**
  204. * Stop the animation.
  205. * This will fail silently if the animation group is already stopped.
  206. */
  207. stop(): void;
  208. /**
  209. * Dispose this animation object.
  210. */
  211. dispose(): void;
  212. }