Преглед изворни кода

fixed issue with mesh not staying attached to bone when animation changes

Adam Bowman пре 8 година
родитељ
комит
b0f4183fe0
1 измењених фајлова са 29 додато и 11 уклоњено
  1. 29 11
      src/Animations/babylon.animatable.ts

+ 29 - 11
src/Animations/babylon.animatable.ts

@@ -102,23 +102,41 @@
             var idx = this._scene._activeAnimatables.indexOf(this);
 
             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;
+
+                if(animationName){
+
+                    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 ++;
+                    }
+
+                    if (animations.length == numberOfAnimationsStopped) {
+                        this._scene._activeAnimatables.splice(idx, 1);
+
+                        if (this.onAnimationEnd) {
+                            this.onAnimationEnd();
+                        }
                     }
-                    animations[index].reset();
-                    animations.splice(index, 1);
-                    numberOfAnimationsStopped ++;
-                }
 
-                if (animations.length == numberOfAnimationsStopped) {
-                    this._scene._activeAnimatables.splice(idx, 1);
+                } else {
+
+                    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();
                     }
+
                 }
             }
         }