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