For example, check out this JSFiddle link.
The interesting part occurs during the mousedown
event:
var hits = raycaster.intersectObjects( [object1, object2, object3] );
if ( hits.length > 0 ) {
console.log(hits[ 0 ].object)
hits[ 0 ].object.material.color.setHex( Math.random() * 0xffffff );
}
The concept behind this code is that when the user clicks, a Ray is emitted from that point to detect any intersections. Subsequently, the color of the intersected object is changed to a random new color. However, what's peculiar is that even objects not included in the hits
array have their colors altered (you'll observe this in the console where the clicked object gets displayed).
Why is this happening?