Skip to content

Commit

Permalink
Fix index on intersection. (#30424)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanzopes authored Jan 30, 2025
1 parent 558b7c7 commit df85340
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/objects/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

Expand All @@ -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 ) {

Expand All @@ -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 ) {

Expand All @@ -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 ) {

Expand Down Expand Up @@ -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;

Expand All @@ -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,
Expand Down

0 comments on commit df85340

Please sign in to comment.