Change texture gltf onclick

Can a button be made to change the texture gltf using three.js or javascript?

examles

webgl_loader_gltf_variants

It’s possible.
You can log the object and identify the meshes you want to modify material of, then change the value of material maps.

Thank you so much
I do not understand
Example here
what should I do

Please answer me

It should be something like this. You load the texture via the Texture Loader and apply it to a child mesh.

An example code:

wardrobeLoader2 = new THREE.TextureLoader().load('./textures/table42/textures/wardrobeorig.png');
			gltfLoader.load('./textures/table42/scene.gltf', (gltf) => {
                wardrobe = gltf.scene;
             
                wardrobe.traverse(function(node) {

                    if (node instanceof THREE.Mesh) {
						
						node.material.map = wardrobeLoader2;
                    }
                
                });
                scene.add(wardrobe);
            });
1 Like

Thank you so much

Do You have documentation?

I tried to use the code above by Irakli_Kandelaki for my .png texture for a gltf model. However, when the model loads it appears dark, if not completely black. I tried searching for a solution but haven’t found one. Any help would be appreciated!

Hello, This is no problem.
In example https://webxr-sneakers.lusion.co/

Thank you.