Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase epsilon constant #734

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/math/ExtendedTriangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Triangle, Vector3, Line3, Sphere, Plane } from 'three';
import { SeparatingAxisBounds } from './SeparatingAxisBounds.js';
import { closestPointsSegmentToSegment, sphereIntersectTriangle } from './MathUtilities.js';

const ZERO_EPSILON = 1e-15;
const ZERO_EPSILON = 1e-14;
function isNearZero( value ) {

return Math.abs( value ) < ZERO_EPSILON;
Expand Down Expand Up @@ -192,6 +192,13 @@ ExtendedTriangle.prototype.intersectsTriangle = ( function () {

}

count ++;
if ( count === 2 && startPointIntersection === - 1 ) {

break;

}

} else if ( count >= 2 ) {

// if we're here that means that there must have been one point that had
Expand All @@ -203,13 +210,6 @@ ExtendedTriangle.prototype.intersectsTriangle = ( function () {

}

count ++;
if ( count === 2 && startPointIntersection === - 1 ) {

break;

}

}

}
Expand Down
28 changes: 28 additions & 0 deletions test/Math.TriangleIntersections.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,34 @@

} );

it( 'triangles should return a correct intersection (issue #655)', () => {

t1.a.set( 32.22699737548828, 1.2630000114440918, - 11.8149995803833 );
t1.b.set( 31.316997528076172, 1.2630000114440918, - 11.739999771118164 );
t1.c.set( 32.22699737548828, 1.2630000114440918, - 11.739999771118164 );
t1.needsUpdate = true;

t2.a.set( 31.316997528076172, 1.933000087738037, - 7.585000038146973 );
t2.b.set( 31.316997528076172, - 0.8669999837875366, - 7.295000076293945 );
t2.c.set( 31.316997528076172, - 0.8669999837875366, - 7.585000038146973 );
t2.needsUpdate = true;

expect( t1.intersectsTriangle( t2 ) ).toBe( false );

t2.a.set( 32.22699737548828, 1.2630000114440918, - 11.8149995803833 );
t2.b.set( 31.316997528076172, 1.2630000114440918, - 11.739999771118164 );
t2.c.set( 32.22699737548828, 1.2630000114440918, - 11.739999771118164 );
t2.needsUpdate = true;

t1.a.set( 31.316997528076172, 1.933000087738037, - 7.585000038146973 );
t1.b.set( 31.316997528076172, - 0.8669999837875366, - 7.295000076293945 );
t1.c.set( 31.316997528076172, - 0.8669999837875366, - 7.585000038146973 );
t1.needsUpdate = true;

expect( t1.intersectsTriangle( t2 ) ).toBe( false );

} );

} );

describe( 'Triangle Intersection line', () => {
Expand Down Expand Up @@ -296,7 +324,7 @@

// this test fails due to floating point precision issues. If the triangles are scaled up
// it reports an intersection as expected.
it.skip( 'triangles almost coplanar should intersect on point', () => {

Check warning on line 327 in test/Math.TriangleIntersections.test.js

View workflow job for this annotation

GitHub Actions / build (20.x, 0.159.0)

Disabled test

Check warning on line 327 in test/Math.TriangleIntersections.test.js

View workflow job for this annotation

GitHub Actions / build (20.x, 0.168.0)

Disabled test

Check warning on line 327 in test/Math.TriangleIntersections.test.js

View workflow job for this annotation

GitHub Actions / build (20.x, latest)

Disabled test

t1.a.set( 0.0720, 0.2096, 0.3220 );
t1.b.set( 0.0751, 0.2148, 0.3234 );
Expand Down
Loading