Pārlūkot izejas kodu

animations can now be played backwards by making the start frame larger than the end frame

Adam Bowman 8 gadi atpakaļ
vecāks
revīzija
d71488e0e8
2 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  1. 1 1
      src/Animations/babylon.animation.ts
  2. 4 0
      src/babylon.scene.ts

+ 1 - 1
src/Animations/babylon.animation.ts

@@ -571,7 +571,7 @@
             var ratio = delay * (this.framePerSecond * speedRatio) / 1000.0;
             var highLimitValue = 0;
 
-            if (ratio > range && !loop) { // If we are out of range and not looping get back to caller
+            if (((to > from && ratio > range) || (from > to && ratio < range)) && !loop) { // If we are out of range and not looping get back to caller
                 returnValue = false;
                 highLimitValue = this._getKeyValue(this._keys[this._keys.length - 1].value);
             } else {

+ 4 - 0
src/babylon.scene.ts

@@ -1642,6 +1642,10 @@
          */
         public beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio: number = 1.0, onAnimationEnd?: () => void, animatable?: Animatable): Animatable {
 
+            if(from > to && speedRatio > 0){
+                speedRatio *= -1;
+            }
+
             this.stopAnimation(target);
 
             if (!animatable) {