I currently have a city based on the example of Mr Doob's tutorial: "How to do a procedural city in 100 lines". In the tutorial you can see the that he creates 100 building meshes which then get merged into 1 city mesh for performance reasons. Then one material gets made that is applied to the city mesh, giving every building a texture.
What I want to stop is the clamping and stretching of the building texture. In order to create a more realistic "the windows are the same height on different buildings" look.
What I think would be the solution is to manipulate the face vertex UV's with the scaling values of the geometry.
With the following code I can scale the texture 2x.
let faceVertexUvs = buildingMesh.geometry.faceVertexUvs[0];
for (let k = 0; k < faceVertexUvs.length; k++) {
const uvs = faceVertexUvs[k];
if ( k == 4 || k == 5){
// Make the roof blank
uvs[0].set(0, 0);
uvs[1].set(0, 0);
uvs[2].set(0, 0);
}
else if( k % 2 == 0) {
uvs[0].set(0, 0.5);
uvs[1].set(0, 0);
uvs[2].set(0.5, 0.5);
}
else {
uvs[0].set(0, 0);
uvs[1].set(0.5, 0);
uvs[2].set(0.5, 0.5);
}
}
However I would like to only scale vertically and leave the horizontal scaling alone. But I don't completely understand the relation between the 2 triangles.