I’m working on customizing a 3D model of jeans, and with the addition of the flipX function it doesn’t work correctly. It’s built on basis of Examples/decals
Here I’m modifying texture, and applying it to material
// texture is an image, loaded by TextureLoader
texture.wrapS = THREE.RepeatWrapping;
texture.repeat.x = flipX; // -1 or 1
decalMaterial.map = texture;
This code is in the function that is responsible for adding decal on click
let material = decalMaterial.clone();
let decal = new THREE.Mesh(new DecalGeometry(basicModel, position, orientation, size), material);
It works perfectly fine, until I’m switching flipX
Because all decals use the same texture, if I change it, it changes even on existing decals
Then I tried to use the copy of texture on each decal
let t = new THREE.Texture();
t = texture.clone(); // or t.copy(texture);
t.wrapS = THREE.RepeatWrapping;
t.repeat.x = flipX; // -1 or 1
decalMaterial.map = t;
I don’t know why, but it adds new mesh to the scene, but it’s not appearing on the canvas.
The only solution I see, is to create duplicate set of textures, and apply it if FlipX is on, but it will use additional traffic and memory, so it’s bad solution.
Does anyone have an idea how to solve this?