babylon.animatable.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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.animationStartDate = new Date();
  9. this.speedRatio = speedRatio ? speedRatio : 1.0;
  10. };
  11. // Members
  12. BABYLON._Animatable.prototype.target = null;
  13. BABYLON._Animatable.prototype.animationStarted = false;
  14. BABYLON._Animatable.prototype.loopAnimation = false;
  15. BABYLON._Animatable.prototype.fromFrame = false;
  16. BABYLON._Animatable.prototype.toFrame = false;
  17. BABYLON._Animatable.prototype.speedRatio = 1.0;
  18. // Methods
  19. BABYLON._Animatable.prototype._animate = function () {
  20. // Getting time
  21. var now = new Date();
  22. var delay = now - this.animationStartDate;
  23. // Animating
  24. var running = false;
  25. var animations = this.target.animations;
  26. for (var index = 0; index < animations.length; index++) {
  27. var isRunning = animations[index].animate(this.target, delay, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
  28. running = running || isRunning;
  29. }
  30. return running;
  31. };
  32. })();