Skip to content

Commit e2a9737

Browse files
committed
Revert some changes
1 parent b7dcebc commit e2a9737

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

src/utils/trimToBeneathTriPlane.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Plane, Vector3, MathUtils, PlaneHelper } from 'three';
1+
import { Plane, Vector3 } from 'three';
22
import { isYProjectedTriangleDegenerate } from './triangleLineUtils.js';
33

44
const EPSILON = 1e-16;
@@ -35,8 +35,7 @@ export function trimToBeneathTriPlane( tri, line, lineTarget ) {
3535
line.delta( _lineDirection ).normalize();
3636
if ( Math.abs( _plane.normal.dot( _lineDirection ) ) < EPSILON ) {
3737

38-
// if the line is definitely above or on the plane then skip it
39-
if ( ( isStartOnPlane || ! isStartBelow ) && ( isEndOnPlane || ! isEndBelow ) ) {
38+
if ( isStartOnPlane || ! isStartBelow ) {
4039

4140
return false;
4241

@@ -64,20 +63,40 @@ export function trimToBeneathTriPlane( tri, line, lineTarget ) {
6463

6564
} else {
6665

67-
const t = MathUtils.mapLinear( 0, startDist, endDist, 0, 1 );
68-
line.at( t, _planeHit );
66+
let didHit = _plane.intersectLine( line, _planeHit );
67+
if ( ! didHit ) {
6968

70-
if ( isStartBelow ) {
69+
if ( isStartOnPlane ) {
7170

72-
lineTarget.start.copy( line.start );
73-
lineTarget.end.copy( _planeHit );
74-
return true;
71+
_planeHit.copy( line.start );
72+
didHit = true;
7573

76-
} else if ( isEndBelow ) {
74+
}
7775

78-
lineTarget.end.copy( line.end );
79-
lineTarget.start.copy( _planeHit );
80-
return true;
76+
if ( isEndOnPlane ) {
77+
78+
_planeHit.copy( line.end );
79+
didHit = true;
80+
81+
}
82+
83+
}
84+
85+
if ( didHit ) {
86+
87+
if ( isStartBelow ) {
88+
89+
lineTarget.start.copy( line.start );
90+
lineTarget.end.copy( _planeHit );
91+
return true;
92+
93+
} else if ( isEndBelow ) {
94+
95+
lineTarget.end.copy( line.end );
96+
lineTarget.start.copy( _planeHit );
97+
return true;
98+
99+
}
81100

82101
}
83102

0 commit comments

Comments
 (0)