I've a GLTF model, I want to update its map texture but as soon as I do it, the new texture is displaying but the UV mapping of my model is not set anymore.
Is there a way to preserve the UV mapping when I load a new texture ? Here's the code I used to call a new map texture at some point in my website :
model.traverse(child => {
if (
child instanceof THREE.Mesh
) {
child.material.map = newTexture;
}
})
When replacing color textures of a glTF asset, you need these two lines.
newTexture.encoding = THREE.sRGBEncoding; // color textures must be marked as sRGB
newTexture.flipY = false; // honor glTF's uv convention
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With