I want to get the name of the group with raycaster but insted to take the name i take the name empty the code i have is this
what i nead to do is,, when the mouse is over the group mesh, i nead to alert me the name of the goup or somethithing that i know that i hit the specific mesh
` // +++++++++++++++++++++ RAY CASTER +++++++++++++++++++++
// creating group and add all the pieses
group = new THREE.Object3D(); //create an empty container
group.add(obj_body); //add a mesh with geometry to it
group.name = 'myGroupName';
scene.add(group);
ray_objects.push(group);
var raycaster = new THREE.Raycaster();
var mouse = new THREE.Vector2();
window.addEventListener( 'mousemove', onMouseMove, false );
window.addEventListener( 'onDocumentMouseDown', onMouseMove, false );
function onMouseMove( event ) {
// calculate mouse position in normalized device coordinates
// (-1 to +1) for both components
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
// console.log(mouse.x);
$("#x_pos").html(mouse.x);
$("#y_pos").html(mouse.y);
// update the picking ray with the camera and mouse position
raycaster.setFromCamera( mouse, camera );
// calculate objects intersecting the picking ray
var intersects = raycaster.intersectObjects( ray_objects, true );
for ( var i = 0; i < intersects.length; i++ ) {
if (intersects.length > 0) {
var firstIntersectedObject = intersects[0];
// alert(firstIntersectedObject);
console.log(firstIntersectedObject);
intersects[ 0 ].object.material.color.set( 0x00ff00 );
// this will give you the first intersected Object if there aremultiple.
renderer.render( selected_scene, camera );
}
// alert(intersects);
}}`