I'm trying to apply MeshStandardMaterial to a mesh of a GLTF imported model. The GLTF model for testing is a simple cube exported from Blender.
After succesfully load the GLTF model I did:
this.material = new THREE.MeshStandardMaterial({
map: this.texture,
})
this.cubePost2Model = this.resources.items.cubePost2.scene
this.cubePost2Model.traverse((child) =>
{
if(child instanceof THREE.Mesh)
{
child.castShadow = true
child.material = this.material // This line throw the error
console.log(child) // Returns succesfully one mesh
}
})
this.scene.add(this.cubePost2Model)
In the previous code, this line: child.material = this.material throw an error in the console:
Uncaught TypeError: Cannot read properties of undefined (reading 'visible')
