Bläddra i källkod

move morph target animation serialization outside getNodeByID

Kacey Coley 6 år sedan
förälder
incheckning
4246f39d42
2 ändrade filer med 12 tillägg och 9 borttagningar
  1. 11 3
      src/Animations/babylon.animationGroup.ts
  2. 1 6
      src/babylon.scene.ts

+ 11 - 3
src/Animations/babylon.animationGroup.ts

@@ -405,10 +405,18 @@ module BABYLON {
                 var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
                 var animation = Animation.Parse(targetedAnimation.animation);
                 var id = targetedAnimation.targetId;
-                var targetNode = scene.getNodeByID(id);
+                if (targetedAnimation.animation.property === "influence") { // morph target animation
+                    let morphTarget = scene.getMorphTargetByID(id);
+                    if (morphTarget) {
+                        animationGroup.addTargetedAnimation(animation, morphTarget);
+                    }
+                }
+                else {
+                    var targetNode = scene.getNodeByID(id);
 
-                if (targetNode != null) {
-                    animationGroup.addTargetedAnimation(animation, targetNode);
+                    if (targetNode != null) {
+                        animationGroup.addTargetedAnimation(animation, targetNode);
+                    }
                 }
             }
 

+ 1 - 6
src/babylon.scene.ts

@@ -3803,7 +3803,7 @@ module BABYLON {
          * @param id defines the id to search for
          * @return the found node or null if not found at all
          */
-        public getNodeByID(id: string): Nullable<Node | MorphTarget> {
+        public getNodeByID(id: string): Nullable<Node> {
             const mesh = this.getMeshByID(id);
             if (mesh) {
                 return mesh;
@@ -3829,11 +3829,6 @@ module BABYLON {
                 return bone;
             }
 
-            const morphTarget = this.getMorphTargetByID(id);
-            if (morphTarget) {
-                return morphTarget;
-            }
-
             return null;
         }