i have locally prepared a screen with tshirt gltf modal. clicking upon html button i replace modal material color, i laso place a cartoon image over the chest of object through textureloader and mapping on child.
there is a problem when i click upon button and change color of sobject, it some how affects the cartoon image color tones. following are the images of different colors placement on gltf.
following is the code which i use to load gltf and click on button to replace its color.
const texture = new THREE.TextureLoader().load( './t-shirt.002.png', function(value){
value.flipY = false;
value.encoding = THREE.sRGBEncoding;
});
console.log(texture);
new GLTFLoader().load('./tshirt1.gltf', function(gltf){
gltf.scene.traverse(function (child) {
if (child.isMesh) {
//child.material.color.set(0xffffff);
child.material.map = texture;
child.material.map.needsUpdate = false;
}
});
obj = gltf.scene.children[0];;
gltf.scene.position.set(0,0,0);
scene.add(gltf.scene);
render();
});
and
$('.color li button').on('click', function(){
const color = $(this).data('background');
obj.traverse(function (node) {
if (node.isMesh) {
node.material.color.set(parseInt('0x'+color));
}
});
obj.updateMatrix();
});
kindly advice how can I fix this issue? my requirement is replacing color of gltf it does not affect on chest sticker.
Thanks