瀏覽代碼

Fixed bug with texture coordinates matrices

David Catuhe 10 年之前
父節點
當前提交
6303307ce7

文件差異過大導致無法顯示
+ 1012 - 1012
dist/preview release/babylon.d.ts


文件差異過大導致無法顯示
+ 8 - 9
dist/preview release/babylon.js


文件差異過大導致無法顯示
+ 8 - 7
dist/preview release/babylon.max.js


文件差異過大導致無法顯示
+ 12 - 13
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -4,5 +4,6 @@
   - **Updates**
     - New `Material.sideOrientation` property to define clockwise or counter-clockwise faces selection. [Demo here](http://www.babylonjs-playground.com/#1TZJQY) ([deltakosh](https://github.com/deltakosh))
   - **Bug fixes**
+    - Fixed bug with texture coordinates matrices ([deltakosh](https://github.com/deltakosh))
   - **Breaking changes**
 

+ 6 - 6
src/Materials/Textures/babylon.texture.js

@@ -71,14 +71,14 @@ var BABYLON;
             this.getScene().getEngine().updateTextureSamplingMode(samplingMode, this._texture);
         };
         Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
-            x -= this.uOffset + 0.5;
-            y -= this.vOffset + 0.5;
+            x *= this.uScale;
+            y *= this.vScale;
+            x -= 0.5 * this.uScale;
+            y -= 0.5 * this.vScale;
             z -= 0.5;
             BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
-            t.x *= this.uScale;
-            t.y *= this.vScale;
-            t.x += 0.5;
-            t.y += 0.5;
+            t.x += 0.5 * this.uScale + this.uOffset;
+            t.y += 0.5 * this.vScale + this.vOffset;
             t.z += 0.5;
         };
         Texture.prototype.getTextureMatrix = function () {

+ 7 - 7
src/Materials/Textures/babylon.texture.ts

@@ -107,17 +107,17 @@
         }
 
         private _prepareRowForTextureGeneration(x: number, y: number, z: number, t: Vector3): void {
-            x -= this.uOffset + 0.5;
-            y -= this.vOffset + 0.5;
+            x *= this.uScale;
+            y *= this.vScale;
+
+            x -= 0.5 * this.uScale;
+            y -= 0.5 * this.vScale;
             z -= 0.5;
 
             Vector3.TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
 
-            t.x *= this.uScale;
-            t.y *= this.vScale;
-
-            t.x += 0.5;
-            t.y += 0.5;
+            t.x += 0.5 * this.uScale + this.uOffset;
+            t.y += 0.5 * this.vScale + this.vOffset;
             t.z += 0.5;
         }
 

+ 1 - 0
src/Math/babylon.math.js

@@ -1399,6 +1399,7 @@ var BABYLON;
         Quaternion.RotationAxis = function (axis, angle) {
             var result = new Quaternion();
             var sin = Math.sin(angle / 2);
+            axis.normalize();
             result.w = Math.cos(angle / 2);
             result.x = axis.x * sin;
             result.y = axis.y * sin;

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

@@ -1719,10 +1719,11 @@
         }
 
         public static RotationAxis(axis: Vector3, angle: number): Quaternion {
-            axis.normalize();
             var result = new Quaternion();
             var sin = Math.sin(angle / 2);
 
+            axis.normalize(); 
+
             result.w = Math.cos(angle / 2);
             result.x = axis.x * sin;
             result.y = axis.y * sin;