Hi everyone.I just a newbie and researching about threejs. I create a roof by ExtrudeGeometry and apply texture on it,
Problem : texture was stretching in Chrome and still fine in FF
I was use method mapping uv, I just find it on internet
var geometry = extrudedRoofGeometry;
geometry.uvsNeedUpdate = true;
geometry.faceVertexUvs[0] = [];
geometry.faces.forEach(function (face) {
var components = ['x', 'y', 'z'].sort(function (a, b) {
return Math.abs(face.normal[a]) > Math.abs(face.normal[b]);
});
var v1 = geometry.vertices[face.a];
var v2 = geometry.vertices[face.b];
var v3 = geometry.vertices[face.c];
geometry.faceVertexUvs[0].push([
new THREE.Vector2(v1[components[0]], v1[components[1]]),
new THREE.Vector2(v2[components[0]], v2[components[1]]),
new THREE.Vector2(v3[components[0]], v3[components[1]])
]);
})
In Firefox
In Chorme
Please, give me some advice. Thanks,