Need help in group collision detection

Is this the essence of the question?

Joining and modifying arbitrary geometries is non-trivial. I would check out how to rebuild the geometry using CSG methods, as discussed here and in other threads.

That code will be hopelessly inefficient, even if you get it to work. You are iterating over vertices of one geometry, and then casting rays into others. The built-in raycast of three.js iterates over all faces of the geometry, and does not “remember” anything from previous raycasts. So all faces are iterated for every source vertex, that is V*F, where V is the number of source vertices and F is the number of target faces. If all the geometries are really simple it will work, but as soon as you add any complexity to both the ray source and the ray “recipients”, it will hang for ages. Actually, and I consider this a weakness of three.js, even if you only add substantial complexity to the target meshes you will have lag.

That is right. Groups collect other objects, some of which may have geometries. If you really want to iterate over all vertices in a group, you must keep track of the combined transforms during traversal.

BufferGeometry is the recommended type of geometry nowadays. Geometry is “dying”.