I want to resize the uv map for my wardrobe configurator Realtime. I don’t want repeating the texture because it is getting memory larger and less performance for cloning textures. I want to use one texture on multiple objects. Here is my code. I did references from some uv updating code. Please help me I am getting sick of it for 20 hours
function scaleUV(obj, x, y) {
try {
if (obj.hasOwnProperty("geometry")) {
var uvAttribute = obj.geometry.getAttribute("uv");
uvAttribute.setUsage( THREE.DynamicDrawUsage );
var factor = (wWidth / 2.5) * 0.25;
for (var i = 0; i < uvAttribute.count; i++) {
var u = uvAttribute.getX(i);
var v = uvAttribute.getY(i);
if (u != 0) {
u =factor;
u = u.toFixed(2);
}
uvAttribute.setXY(i, u, v);
}
console.log(uvAttribute)
uvAttribute.needsUpdate= true;
}
} catch (err) {}
}
if (e.name.includes("texture")) {
if (e instanceof THREE.MeshStandardMaterial) {
e.color.set("#dedede");
e.map = uvmapchecker;
updateTexture(e.map, 1, 1, rotation);
scaleUV(wBack);
}
}