Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to preserve UV mapping when uptdating map texture

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;
    }
})
like image 732
Michaël Avatar asked Jan 22 '26 03:01

Michaël


1 Answers

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
like image 92
Mugen87 Avatar answered Jan 24 '26 19:01

Mugen87



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!