Pārlūkot izejas kodu

mandatory commit

jbousquie 10 gadi atpakaļ
vecāks
revīzija
6b18719213
1 mainītis faili ar 10 papildinājumiem un 4 dzēšanām
  1. 10 4
      src/Mesh/babylon.mesh.vertexData.js

+ 10 - 4
src/Mesh/babylon.mesh.vertexData.js

@@ -487,6 +487,7 @@ var BABYLON;
             var width = 1;
             var height = 1;
             var depth = 1;
+            var faceUV = options.faceUV || new Array(6);
             if (options.width !== undefined) {
                 width = options.width || 1;
                 height = options.height || 1;
@@ -497,6 +498,11 @@ var BABYLON;
                 height = options || 1;
                 depth = options || 1;
             }
+            for (var f = 0; f < 6; f++) {
+                if (faceUV[f] === undefined) {
+                    faceUV[f] = new BABYLON.Vector4(0, 0, 1, 1);
+                }
+            }
             sideOrientation = sideOrientation || options.sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
             var scaleVector = new BABYLON.Vector3(width / 2, height / 2, depth / 2);
             // Create each face in turn.
@@ -517,19 +523,19 @@ var BABYLON;
                 var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
                 positions.push(vertex.x, vertex.y, vertex.z);
                 normals.push(normal.x, normal.y, normal.z);
-                uvs.push(1.0, 1.0);
+                uvs.push(faceUV[index].z, faceUV[index].w);
                 vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
                 positions.push(vertex.x, vertex.y, vertex.z);
                 normals.push(normal.x, normal.y, normal.z);
-                uvs.push(0.0, 1.0);
+                uvs.push(faceUV[index].x, faceUV[index].w);
                 vertex = normal.add(side1).add(side2).multiply(scaleVector);
                 positions.push(vertex.x, vertex.y, vertex.z);
                 normals.push(normal.x, normal.y, normal.z);
-                uvs.push(0.0, 0.0);
+                uvs.push(faceUV[index].x, faceUV[index].y);
                 vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
                 positions.push(vertex.x, vertex.y, vertex.z);
                 normals.push(normal.x, normal.y, normal.z);
-                uvs.push(1.0, 0.0);
+                uvs.push(faceUV[index].z, faceUV[index].y);
             }
             // sides
             VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);