File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ class Line3 {
142142 _startEnd . subVectors ( this . end , this . start ) ;
143143
144144 const startEnd2 = _startEnd . dot ( _startEnd ) ;
145+
146+ if ( startEnd2 === 0 ) return 0 ;
147+
145148 const startEnd_startP = _startEnd . dot ( _startP ) ;
146149
147150 let t = startEnd_startP / startEnd2 ;
Original file line number Diff line number Diff line change @@ -161,6 +161,12 @@ export default QUnit.module( 'Maths', () => {
161161 a . closestPointToPoint ( one3 . clone ( ) , true , point ) ;
162162 assert . ok ( point . distanceTo ( one3 . clone ( ) ) < 0.0001 , 'Passed!' ) ;
163163
164+ // degenerate line (zero-length)
165+ const b = new Line3 ( one3 . clone ( ) , one3 . clone ( ) ) ;
166+ assert . ok ( b . closestPointToPointParameter ( zero3 . clone ( ) , true ) == 0 , 'Passed!' ) ;
167+ b . closestPointToPoint ( zero3 . clone ( ) , true , point ) ;
168+ assert . ok ( point . distanceTo ( one3 . clone ( ) ) < 0.0001 , 'Passed!' ) ;
169+
164170 } ) ;
165171
166172 QUnit . test ( 'applyMatrix4' , ( assert ) => {
You can’t perform that action at this time.
0 commit comments