mrdoob/three.js — pull request #3641 by stephomi (2013-07-15 13:57:40+00:00)
Title: Line-picking

Follows https://github.com/mrdoob/three.js/pull/3635:

0. Renamed ``distanceToSegment`` to ``distanceSqToSegment``

1. Indeed this is stupid... Here's what I can do
```javascript
for ( var i = 0; i < nbVertices - 1; i = i + step ) {

var dist = localRay.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );

if ( dist <= precisionSq ) {

var distance = localRay.origin.distanceTo( interRay );

if ( raycaster.near <= distance && distance <= raycaster.far ) {

intersects.push( {

distance: distance,
// What do we want? intersection point on the ray or on the segment??
//point: raycaster.ray.at( distance ),
point: interSegment.clone().applyMatrix4( object.matrixWorld ),
face: null,
faceIndex: null,
object: object

} );
```
But in that case I think the scale matrix got an impact on 'dist'. The demo still works fine, though.
And btw what do we expect the raycaster to return as an intersection point? The point on the ray or on the line object (currently it's on the line)?

2. For the line intersection, I got some problems when dealing with scale matrix because the localRay wasn't normalized... that's why I normalized it. I think I kind of sux with scale matrix :(

3. If i'm not mistaken there're no signed distance in ``Ray`` anymore

4. Hmm currently it returns the ray's origin (btw in that case I forgot to put the value in the optional target arf). I don't think it's wrong saying that the closest point of a point behind the ray is the ray's origin...

5. I think only the scale matrix plays a role between local/world space when using ``Raycaster.linePrecision``