فهرست منبع

fixed scaling bug when rotating bone in world space and mesh is scaled

Adam Bowman 8 سال پیش
والد
کامیت
a107cd72a7
1فایلهای تغییر یافته به همراه9 افزوده شده و 7 حذف شده
  1. 9 7
      src/Bones/babylon.bone.ts

+ 9 - 7
src/Bones/babylon.bone.ts

@@ -393,17 +393,19 @@
         private _getNegativeRotationToRef(rotMatInv: Matrix, space = Space.LOCAL, mesh: AbstractMesh = null): void {
 
             if (space == Space.WORLD) {
-                rotMatInv.copyFrom(this.getAbsoluteTransform());
-                if (mesh) {
+                var scaleMatrix = BABYLON.Tmp.Matrix[2];
+				scaleMatrix.copyFrom(this._scaleMatrix);
+				rotMatInv.copyFrom(this.getAbsoluteTransform());
+				if (mesh) {
                     rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
+					var meshScale = BABYLON.Tmp.Matrix[3];
+					BABYLON.Matrix.ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, meshScale);
+					scaleMatrix.multiplyToRef(meshScale, scaleMatrix);
                 }
-                rotMatInv.invert();
-                var scaleMatrix = Tmp.Matrix[2];
-                scaleMatrix.copyFrom(this._scaleMatrix);
+				rotMatInv.invert();
                 scaleMatrix.m[0] *= -1;
                 rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
-            }
-            else {
+            } else {
                 rotMatInv.copyFrom(this.getLocalMatrix());
                 rotMatInv.invert();
                 var scaleMatrix = Tmp.Matrix[2];