babylon.animatable.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. module BABYLON.Internals {
  2. export class Animatable {
  3. private _localDelayOffset: number;
  4. private _animations: any;
  5. public animationStarted = false;
  6. constructor(public target, public fromFrame: number = 0, public toFrame: number = 100, public loopAnimation: boolean = false, public speedRatio: number = 1.0, public onAnimationEnd?, animations?: any) {
  7. this._animations = animations;
  8. }
  9. // Methods
  10. public _animate(delay: number): boolean {
  11. if (!this._localDelayOffset) {
  12. this._localDelayOffset = delay;
  13. }
  14. // Animating
  15. var running = false;
  16. var animations = this._animations || this.target.animations;
  17. for (var index = 0; index < animations.length; index++) {
  18. var isRunning = animations[index].animate(this.target, delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
  19. running = running || isRunning;
  20. }
  21. if (!running && this.onAnimationEnd) {
  22. this.onAnimationEnd();
  23. }
  24. return running;
  25. }
  26. }
  27. }