diff --git a/src/core/TriangleSplitter.js b/src/core/TriangleSplitter.js index 123cf9e0..d4f15fd8 100644 --- a/src/core/TriangleSplitter.js +++ b/src/core/TriangleSplitter.js @@ -112,11 +112,7 @@ export class TriangleSplitter { if ( Math.abs( 1.0 - Math.abs( _triangleNormal.dot( normal ) ) ) < PARALLEL_EPSILON ) { - if ( this.coplanarTriangleUsed === false ) { - - this.coplanarTriangleUsed = true; - - } + this.coplanarTriangleUsed = true; for ( let i = 0, l = triangles.length; i < l; i ++ ) { diff --git a/src/core/operations/operations.js b/src/core/operations/operations.js index e97d5fb7..bbf801c2 100644 --- a/src/core/operations/operations.js +++ b/src/core/operations/operations.js @@ -10,6 +10,7 @@ import { } from './operationsUtils.js'; import { getTriCount } from '../utils/geometryUtils.js'; import { HOLLOW_INTERSECTION, HOLLOW_SUBTRACTION } from '../constants.js'; +import { isTriDegenerate } from '../utils/triangleUtils.js'; const _matrix = new Matrix4(); const _normalMatrix = new Matrix3(); @@ -296,12 +297,19 @@ function performWholeTriangleOperations( const i2 = aIndex.getX( i3 + 2 ); const groupIndex = groupOffset === - 1 ? 0 : groupIndices[ currId ] + groupOffset; - for ( let k = 0, lk = _attr.length; k < lk; k ++ ) { + _tri.a.fromBufferAttribute( aPosition, i0 ); + _tri.b.fromBufferAttribute( aPosition, i1 ); + _tri.c.fromBufferAttribute( aPosition, i2 ); + if ( ! isTriDegenerate( _tri ) ) { - const action = _actions[ k ]; - const attrSet = _attr[ k ].getGroupAttrSet( groupIndex ); - const invertTri = action === INVERT_TRI; - appendAttributesFromIndices( i0, i1, i2, aAttributes, a.matrixWorld, _normalMatrix, attrSet, invertTri !== invertedGeometry ); + for ( let k = 0, lk = _attr.length; k < lk; k ++ ) { + + const action = _actions[ k ]; + const attrSet = _attr[ k ].getGroupAttrSet( groupIndex ); + const invertTri = action === INVERT_TRI; + appendAttributesFromIndices( i0, i1, i2, aAttributes, a.matrixWorld, _normalMatrix, attrSet, invertTri !== invertedGeometry ); + + } } diff --git a/src/core/utils/triangleUtils.js b/src/core/utils/triangleUtils.js index 76e1c464..62671acd 100644 --- a/src/core/utils/triangleUtils.js +++ b/src/core/utils/triangleUtils.js @@ -10,10 +10,10 @@ export function isTriDegenerate( tri, eps = EPSILON ) { // compute angles to determine whether they're degenerate _AB.subVectors( tri.b, tri.a ); _AC.subVectors( tri.c, tri.a ); - _CB.subVectors( tri.c, tri.b ); + _CB.subVectors( tri.b, tri.c ); const angle1 = _AB.angleTo( _AC ); // AB v AC - const angle2 = _AB.angleTo( _CB ) - Math.PI; // AB v BC - 180deg + const angle2 = _AB.angleTo( _CB ); // AB v BC const angle3 = Math.PI - angle1 - angle2; // 180deg - angle1 - angle2 return Math.abs( angle1 ) < eps ||