Problems With Changing Color Of Gltf Object
With this answer as a reference, I have succeeded in changing the color of the gltf model. (Change the color of an object (.dae or gltf) in 'AR.JS') However, the model texture
Solution 1:
There is no texture, because once the model is loaded, you go through the nodes and remove it:
node.material.map = null; // removes the texture
Furthermore - the car seems black even with the color changed. The "metal" parts are rough and not metallic (roughness: 0.5, metalness: 0). If you change that, the car will change its color (visually speaking):
el.addEventListener('changecolor', e =>{
// set the new color
let colorp = e.detail.color;
let colorHex = Number(colorp.replace('#', '0x'));
let color3D = new THREE.Color(colorHex);
// apply for the "metal" materials for (var i = 0; i < self.cars.length; i++) {
if (!self.cars[i].material) returnif (self.cars[i].name.includes("meta")) {
self.cars[i].material.metalness = 0.7self.cars[i].material.roughness = 0.2self.cars[i].material.color = color3D;
}
}
});
Check it out in this glitch.
Post a Comment for "Problems With Changing Color Of Gltf Object"