mrdoob/three.js — Issue #693: Ray intersect possible with a div?
Author: lburge
Created: 2011-10-28 12:18:28+00:00
State: open

Hi,
Just wondering if there is a way to do this? I'm trying to make a somewhat GUI element with an onMouseDown funct. My code so far is below, it does work as Ive used the same with a cube. I have a div with id in the body too :)

function onDocumentMouseDown( event ) {
event.preventDefault();
var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
projector.unprojectVector( vector, camera );

var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
var $leftBtn2 = $('#leftBtn2');
var leftBtnIntersects = ray.intersectObject( $leftBtn2 );

if ( leftBtnIntersects.length > 0 && spinning == false) {
animate();

}

}