Bläddra i källkod

Merge pull request #1692 from abow/AnimatableStopFix

fixed all animations in scene stopping as a result of last fix
David Catuhe 8 år sedan
förälder
incheckning
73340bdaee
1 ändrade filer med 15 tillägg och 8 borttagningar
  1. 15 8
      src/Animations/babylon.animatable.ts

+ 15 - 8
src/Animations/babylon.animatable.ts

@@ -99,21 +99,24 @@
         }
 
         public stop(animationName?: string): void {
-            var idx = this._scene._activeAnimatables.indexOf(this);
+            
+            if (animationName) {
 
-            if (idx > -1) {
+                var idx = this._scene._activeAnimatables.indexOf(this);
 
-                if(animationName){
+                if (idx > -1) {
 
                     var animations = this._animations;
                     var numberOfAnimationsStopped = 0;
+                    
                     for (var index = animations.length - 1; index >= 0; index--) {
                         if (typeof animationName === "string" && animations[index].name != animationName) {
                             continue;
                         }
+
                         animations[index].reset();
                         animations.splice(index, 1);
-                        numberOfAnimationsStopped ++;
+                        numberOfAnimationsStopped++;
                     }
 
                     if (animations.length == numberOfAnimationsStopped) {
@@ -123,21 +126,25 @@
                             this.onAnimationEnd();
                         }
                     }
+                }
 
-                } else {
+            } else {
 
+                var index = this._scene._activeAnimatables.indexOf(this);
+
+                if (index > -1) {
                     this._scene._activeAnimatables.splice(index, 1);
                     var animations = this._animations;
-
+                    
                     for (var index = 0; index < animations.length; index++) {
                         animations[index].reset();
                     }
-
+                    
                     if (this.onAnimationEnd) {
                         this.onAnimationEnd();
                     }
-
                 }
+
             }
         }