فهرست منبع

Update babylon.skeleton.ts

I handed over the functions as before and have added another that better suits what I wanted to do.
This allows you to:
```
var hant_left = skeleton.searchIndexOnSkeletonByName("hant_left");
sword.attachToBone(skeleton.bones[hant_left], character);
```
It is easier to give a bone name as an index for attachToBone
David 9 سال پیش
والد
کامیت
2b0e2425e7
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      src/Bones/babylon.skeleton.ts

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

@@ -96,6 +96,21 @@
             }
             return animationRanges;
         }
+        
+        /**
+        * get a bone using its id
+        * @param {string} the bone's name
+        * @param {Skeleton} the skeleton 
+        * @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