Hi, I was trying to add shadows, and when I tried the following solution some of the meshes in the model changed to black color. I didn’t understand what’s wrong.
My code:
let loader = new THREE.GLTFLoader();
loader.parse(text, undefined,
function (gltf) {
model = gltf.scene;
model.scale.set(1, 1, 1);
scene.add(model);
model.traverse((mesh) => {
if (!mesh.isMesh) return;
mesh.material.roughness = 0;
mesh.material.metalness = .5;
mesh.castShadow = true
mesh.recieveShadow = true
mesh.geometry.computeVertexNormals()
});
},
undefined,
function (error) {
buttonBussy(false);
console.error(error);
}
);
Thanks,
Binoy