When I cast a ray with origin point inside the face of a Mesh, it won't detect a collision. Quick example (a modified version of examples/canvas_interactive_cubes.html from r45): https://gist.github.com/1366114
var V = THREE.Vector3;
changing the line 159 of the gist, from
var origin = new V(20, 20, 20);
var origin = new V(19.5, 19.5, 19.5);
shows that the collision will work fine.
Your code didn't seem to work with r46.
However, using this code I can indeed reproduce the issue:
var origin = new THREE.Vector3(0, 0, 10);
var direction = new THREE.Vector3( 0, 0, -1);
var ray = new THREE.Ray( origin, direction );
Ah, that's good. Sorry I forgot to mention, but the bug did happened on r46 and dev branch, and it was coded for dev branch using the Ray.js from the dev branch (the Three.js build doesn't seem to use the latest Ray.js, this is why I included under the name newray.js).
But I'm glad you managed to reproduce it.
Is this still happening?
I'll try to repro it.
I think this still happens. The culprit is a few lines in Raycaster that look like this
if ( distance < precision || distance < raycaster.near || distance > raycaster.far ) continue;
So, apparently, if the origin is too close to a plane (distance is zero), it will abort the intersection test. I'm not sure what was the original intended behavior here.
@mrdoob Yes, it still happens. jsFiddle showing it:
The original webgl_interactive_cubes (for comparison's sake) is http://jsfiddle.net/9CczQ/1
@mrdoob do you think this might be resolved now? I created a simple test and it seems to be working correctly, but not sure if I understood the original problem properly.
@kevanstannard Seems to be. Thanks!