Parcourir la source

Fix index on intersection. (#30424)

Jonathan Zopes il y a 1 an
Parent
commit
df853401ac
1 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 6 6
      src/objects/Line.js

+ 6 - 6
src/objects/Line.js

@@ -119,7 +119,7 @@ class Line extends Object3D {
 				const a = index.getX( i );
 				const b = index.getX( i + 1 );
 
-				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
+				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b, i );
 
 				if ( intersect ) {
 
@@ -134,7 +134,7 @@ class Line extends Object3D {
 				const a = index.getX( end - 1 );
 				const b = index.getX( start );
 
-				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
+				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b, end - 1 );
 
 				if ( intersect ) {
 
@@ -151,7 +151,7 @@ class Line extends Object3D {
 
 			for ( let i = start, l = end - 1; i < l; i += step ) {
 
-				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, i, i + 1 );
+				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, i, i + 1, i );
 
 				if ( intersect ) {
 
@@ -163,7 +163,7 @@ class Line extends Object3D {
 
 			if ( this.isLineLoop ) {
 
-				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, end - 1, start );
+				const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, end - 1, start, end - 1 );
 
 				if ( intersect ) {
 
@@ -210,7 +210,7 @@ class Line extends Object3D {
 
 }
 
-function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
+function checkIntersection( object, raycaster, ray, thresholdSq, a, b, i ) {
 
 	const positionAttribute = object.geometry.attributes.position;
 
@@ -233,7 +233,7 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
 		// What do we want? intersection point on the ray or on the segment??
 		// point: raycaster.ray.at( distance ),
 		point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
-		index: a,
+		index: i,
 		face: null,
 		faceIndex: null,
 		barycoord: null,

粤ICP备19079148号