Browse Source

Merge pull request #1043 from dad72/patch-16

Update babylon.skeleton.ts : Add getIndexOnSkeletonByName(string)
David Catuhe 9 years ago
parent
commit
0008a97b44
1 changed files with 14 additions and 0 deletions
  1. 14 0
      src/Bones/babylon.skeleton.ts

+ 14 - 0
src/Bones/babylon.skeleton.ts

@@ -96,6 +96,20 @@
             }
             return animationRanges;
         }
+        
+        /**
+        * get a index on skeleton by name
+        * @param {string} the bone's name
+        * @return {number} the indice of bone on
+        */
+        public getIndexOnSkeletonByName(name: string): number {
+                for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
+                    if (this.bones[boneIndex].name === name) {
+                        return boneIndex;
+                    }
+                }
+                return null;
+        }
 
         /** 
          *  note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences