Browse Source

We do the line-picking in local space.

stephomi 12 years ago
parent
commit
78b653e557
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/core/Raycaster.js

+ 6 - 6
src/core/Raycaster.js

@@ -353,20 +353,20 @@
 
 
 			for ( var i = 0; i < nbVertices - 1; i = i + step ) {
 			for ( var i = 0; i < nbVertices - 1; i = i + step ) {
 
 
-				localRay.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
-				interSegment.applyMatrix4( object.matrixWorld );
-				interRay.applyMatrix4( object.matrixWorld );
+				var distSq = localRay.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
 
 
-				if ( interRay.distanceToSquared( interSegment ) <= precisionSq ) {
+				if ( distSq <= precisionSq ) {
 
 
-					var distance = raycaster.ray.origin.distanceTo( interRay );
+					var distance = localRay.origin.distanceTo( interRay );
 
 
 					if ( raycaster.near <= distance && distance <= raycaster.far ) {
 					if ( raycaster.near <= distance && distance <= raycaster.far ) {
 
 
 						intersects.push( {
 						intersects.push( {
 
 
 							distance: distance,
 							distance: distance,
-							point: interSegment.clone(),
+							// 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,
 							face: null,
 							faceIndex: null,
 							faceIndex: null,
 							object: object
 							object: object