So I have a scene with planets everytime I click on a different planet it is returning the same uuid and name “VenusLow_venus_0” and “53FFC54B-FF01-4BF7-A741-BE2F9A9B6315”
so If I click the Sun for example or Jupiter it is returning the VenusLow name and the 53FF uuid it is the same if I click the black space where there is no object…
I an curious to what I am doing wrong?
Snippet:
var raycaster, mouse;
init();
function init() {
raycaster = new THREE.Raycaster();
mouse = new THREE.Vector2();
renderergl.domElement.addEventListener( 'click', onClick, false );
}
function onClick() {
event.preventDefault();
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
var intersects = raycaster.intersectObjects( scene.children, true );
if (intersects.length > 0){
var clickedID = intersects[0].object.uuid;
var clickedName = intersects[0].object.name;
console.log('You clicked: ' + clickedName);
console.log('UUID: ' + clickedID);
}
}