mrdoob/three.js — Issue #718: help with intersection test
Author: dwegner79
Created: 2011-11-02 21:01:15+00:00
State: open

I had an intersection that was working fine when my canvas was taking up the whole window in my browser however ever since I have added other elements to the document the intersection is no longer correct, I realize that I might need to use other sizes then the window.innerHeight and width but nothing that I tried really worked.

this is my intersection code:

function findIntersections(event) {
var mouseX = event.clientX / renderer.domElement.width;
var mouseY = event.clientY / renderer.domElement.height;

var vector = new THREE.Vector3(mouseX * 2 - 1, - mouseY * 2 + 1, 0.5 );

projector.unprojectVector( vector, camera );

var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );

intersects = ray.intersectScene( scene );
}