https://i.sstatic.net/Ooh8W.png
Objective:
I am aiming to identify the closest vertex to the clicked point.
Components Needed:
- Perspective camera
- Icosahedron geometry (applied basicmeshmaterial with wireframe)
- Rotating geometry
- Raycaster
Current Click Handler Code:
mouse = new THREE.Vector2();
mouse.x = (event.clientX / renderer.domElement.clientWidth) * 2 - 1;
mouse.y = - (event.clientY / renderer.domElement.clientHeight) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObject(icosahedron);
// Closest 3D point: intersects[0].point
// Corresponding object face: intersects[0].face
Appreciate your help!