babylon.animatable.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var BABYLON = BABYLON || {};
  2. (function () {
  3. BABYLON._Animatable = function (target, from, to, loop, speedRatio) {
  4. this.target = target;
  5. this.fromFrame = from;
  6. this.toFrame = to;
  7. this.loopAnimation = loop;
  8. this.speedRatio = speedRatio ? speedRatio : 1.0;
  9. };
  10. // Members
  11. BABYLON._Animatable.prototype.target = null;
  12. BABYLON._Animatable.prototype.animationStarted = false;
  13. BABYLON._Animatable.prototype.loopAnimation = false;
  14. BABYLON._Animatable.prototype.fromFrame = 0;
  15. BABYLON._Animatable.prototype.toFrame = 100;
  16. BABYLON._Animatable.prototype.speedRatio = 1.0;
  17. // Methods
  18. BABYLON._Animatable.prototype._animate = function (delay) {
  19. if (!this._localDelayOffset) {
  20. this._localDelayOffset = delay;
  21. }
  22. // Animating
  23. var running = false;
  24. var animations = this.target.animations;
  25. for (var index = 0; index < animations.length; index++) {
  26. var isRunning = animations[index].animate(this.target, delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
  27. running = running || isRunning;
  28. }
  29. return running;
  30. };
  31. })();