瀏覽代碼

Fixed Vector2.Transform to also use Translation info of the Matrix

nockawa 9 年之前
父節點
當前提交
051e8f7019
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      src/Math/babylon.math.js
  2. 2 2
      src/Math/babylon.math.ts

+ 2 - 2
src/Math/babylon.math.js

@@ -483,8 +483,8 @@ var BABYLON;
             return new Vector2(x, y);
         };
         Vector2.Transform = function (vector, transformation) {
-            var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]);
-            var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]);
+            var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + transformation.m[12];
+            var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + transformation.m[13];
             return new Vector2(x, y);
         };
         Vector2.Distance = function (value1, value2) {

+ 2 - 2
src/Math/babylon.math.ts

@@ -605,8 +605,8 @@
         }
 
         public static Transform(vector: Vector2, transformation: Matrix): Vector2 {
-            var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]);
-            var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]);
+            var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + transformation.m[12];
+            var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + transformation.m[13];
 
             return new Vector2(x, y);
         }