浏览代码

added bone.getLocalPositionFromAbsolute

Adam Bowman 8 年之前
父节点
当前提交
5af7a14944
共有 1 个文件被更改,包括 28 次插入0 次删除
  1. 28 0
      src/Bones/babylon.bone.ts

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

@@ -753,5 +753,33 @@
 
         }
 
+        public getLocalPositionFromAbsolute(position:Vector3, mesh?:AbstractMesh): Vector3{
+
+            var result = Vector3.Zero();
+
+            this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
+
+            return result;
+
+        }
+
+        public getLocalPositionFromAbsoluteToRef(position:Vector3, mesh:AbstractMesh, result:Vector3): void{
+
+            this._skeleton.computeAbsoluteTransforms();
+
+            var tmat = Tmp.Matrix[0];
+
+            tmat.copyFrom(this.getAbsoluteTransform());
+            
+            if (mesh) {
+                tmat.multiplyToRef(mesh.getWorldMatrix(), tmat);
+            }
+
+            tmat.invert();
+
+            Vector3.TransformCoordinatesToRef(position, tmat, result);
+
+        }
+
     }
 }