When I try to traverse a Group, item types are Object3D<Event>. So I can’t use child in the code below and face an error (clones’s type is Group):
clones.traverse((child) => {
if (child.isMesh) {
child.material.envMapIntensity = 4;
}
});
I tried to use (child as Mesh) like this:
clones.traverse((child) => {
if ((child as Mesh).isMesh) {
(child as Mesh).material.envMapIntensity = 4;
}
});
Now I get an error for envMapIntensity telling me that
Property 'envMapIntensity' does not exist on type 'Material | Material[]'. Property 'envMapIntensity' does not exist on type 'Material'.ts(2339)