I am currently working on implementing a system for selecting objects in the scene by hovering or clicking on them. Within the scene, there are object groups that were created in the following way (please note that I am still learning three.js and this code may not be the most efficient):
var obj = new THREE.Object3D();
// Grouping all segments of the model into a single object
for (c = 0; c < seg.length; c++) {
obj.add(seg[c]);
}
// Adding the object to the array and updating the screen
objects[objects.length] = obj;
scene.add(objects[objects.length-1]);
The issue arises when attempting to change the color of the meshes within the object groups once they are already in the scene. An error occurs stating that `color.setHex` is undefined. The part of the code used to set the color appears as follows:
for (j = 0; j < intersects[0].object.children.length; j++) {
intersects[0].object.children[j].color.setHex(0x1A75FF);
}