瀏覽代碼

added Bone.getAbsolutePositionFromLocal

Adam Bowman 8 年之前
父節點
當前提交
366600e55d
共有 1 個文件被更改,包括 27 次插入0 次删除
  1. 27 0
      src/Bones/babylon.bone.ts

+ 27 - 0
src/Bones/babylon.bone.ts

@@ -689,5 +689,32 @@
             }
         }
 
+        public getAbsolutePositionFromLocal(position:Vector3, mesh?:AbstractMesh): Vector3{
+
+            var result = Vector3.Zero();
+
+            this.getAbsolutePositionFromLocalToRef(position, mesh, result);
+
+            return result;
+
+        }
+
+        public getAbsolutePositionFromLocalToRef(position:Vector3, mesh:AbstractMesh, result:Vector3): void{
+
+            this._skeleton.computeAbsoluteTransforms();
+
+            var tmat = Tmp.Matrix[0];
+            
+            if (mesh) {
+                tmat.copyFrom(this.getAbsoluteTransform());
+                tmat.multiplyToRef(mesh.getWorldMatrix(), tmat);
+            }else{
+                tmat = this.getAbsoluteTransform();
+            }
+
+            Vector3.TransformCoordinatesToRef(position, tmat, result);
+
+        }
+
     }
 }