Is there a way to trigger a PDF download when clicking on a 3D object in a Three.js scene?
Below is an example of how I have set up the Raycaster:
var raycaster;
var mouse = { x: 0, y: 0 };
init();
function init() {
raycaster = new THREE.Raycaster();
renderer.domElement.addEventListener( 'click', raycast, false );
}
function raycast( event ) {
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 firstIntersectedObject = intersects[ 0 ];
}
}