babylon.animatable.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var BABYLON;
  2. (function (BABYLON) {
  3. (function (Internals) {
  4. var Animatable = (function () {
  5. function Animatable(target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
  6. if (typeof fromFrame === "undefined") { fromFrame = 0; }
  7. if (typeof toFrame === "undefined") { toFrame = 100; }
  8. if (typeof loopAnimation === "undefined") { loopAnimation = false; }
  9. if (typeof speedRatio === "undefined") { speedRatio = 1.0; }
  10. this.target = target;
  11. this.fromFrame = fromFrame;
  12. this.toFrame = toFrame;
  13. this.loopAnimation = loopAnimation;
  14. this.speedRatio = speedRatio;
  15. this.onAnimationEnd = onAnimationEnd;
  16. this.animationStarted = false;
  17. this._animations = animations;
  18. }
  19. // Methods
  20. Animatable.prototype._animate = function (delay) {
  21. if (!this._localDelayOffset) {
  22. this._localDelayOffset = delay;
  23. }
  24. // Animating
  25. var running = false;
  26. var animations = this._animations || this.target.animations;
  27. for (var index = 0; index < animations.length; index++) {
  28. var isRunning = animations[index].animate(this.target, delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
  29. running = running || isRunning;
  30. }
  31. if (!running && this.onAnimationEnd) {
  32. this.onAnimationEnd();
  33. }
  34. return running;
  35. };
  36. return Animatable;
  37. })();
  38. Internals.Animatable = Animatable;
  39. })(BABYLON.Internals || (BABYLON.Internals = {}));
  40. var Internals = BABYLON.Internals;
  41. })(BABYLON || (BABYLON = {}));
  42. //# sourceMappingURL=babylon.animatable.js.map