Skip to content

Commit df85340

Browse files
Fix index on intersection. (#30424)
1 parent 558b7c7 commit df85340

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/objects/Line.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Line extends Object3D {
119119
const a = index.getX( i );
120120
const b = index.getX( i + 1 );
121121

122-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
122+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b, i );
123123

124124
if ( intersect ) {
125125

@@ -134,7 +134,7 @@ class Line extends Object3D {
134134
const a = index.getX( end - 1 );
135135
const b = index.getX( start );
136136

137-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
137+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b, end - 1 );
138138

139139
if ( intersect ) {
140140

@@ -151,7 +151,7 @@ class Line extends Object3D {
151151

152152
for ( let i = start, l = end - 1; i < l; i += step ) {
153153

154-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, i, i + 1 );
154+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, i, i + 1, i );
155155

156156
if ( intersect ) {
157157

@@ -163,7 +163,7 @@ class Line extends Object3D {
163163

164164
if ( this.isLineLoop ) {
165165

166-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, end - 1, start );
166+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, end - 1, start, end - 1 );
167167

168168
if ( intersect ) {
169169

@@ -210,7 +210,7 @@ class Line extends Object3D {
210210

211211
}
212212

213-
function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
213+
function checkIntersection( object, raycaster, ray, thresholdSq, a, b, i ) {
214214

215215
const positionAttribute = object.geometry.attributes.position;
216216

@@ -233,7 +233,7 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
233233
// What do we want? intersection point on the ray or on the segment??
234234
// point: raycaster.ray.at( distance ),
235235
point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
236-
index: a,
236+
index: i,
237237
face: null,
238238
faceIndex: null,
239239
barycoord: null,

0 commit comments

Comments
 (0)