My code is configured to change the colors of certain objects based on different conditions. Currently, it utilizes loops like
for (j = 0; j < objects[i].children.length; j++) {
objects[i].children[j].material.color.setHex(0x1A75FF);
}
to update the color when necessary from the render() function.
The issue arises when dealing with MeshLambertMaterial and MeshFaceMaterial objects. The provided code works flawlessly for MeshLambertMaterial, but throws an error
Cannot read property 'setHex' of undefined
when trying to execute it on a MeshFaceMaterial object.
I have been unable to find a solution to this problem so far. If there is a fix that involves converting all scene objects to MeshFaceMaterial allowing the color setting process to be unified in one function, I am willing to make that adjustment.
(What I absolutely do not want is to handle separate sets of code within the loop based on whether the object has LambertMaterial or FaceMaterial!)