This is PERFECT thanks a lot!!
For future reference, here’s a working example:
function clickedBlenderObject(event) { // returns the clicked object if any, null otherwise
let mouse = new v3d.Vector2();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
let raycaster = new v3d.Raycaster()
raycaster.setFromCamera(mouse, app.camera);
let intersected = raycaster.intersectObjects(app.scene.children)
return intersected.length?intersected[0].object:null
}
function myFunction(event) {
let clicked_object = clickedBlenderObject(event)
if (clicked_object) {
//do whatever you want with your clicked_object and the event
}
}
window.addEventListener('click', myFunction);
Of course, much more can be done since the raycasting encapsulates much more infos.
Once more, thank you GlifTek :)