Skip to content

Add geometry open-boundary diagnostics#252

Closed
Bennett-hash wants to merge 2 commits into
gkjohnson:mainfrom
Bennett-hash:add-solid-diagnostics-debug-helpers
Closed

Add geometry open-boundary diagnostics#252
Bennett-hash wants to merge 2 commits into
gkjohnson:mainfrom
Bennett-hash:add-solid-diagnostics-debug-helpers

Conversation

@Bennett-hash
Copy link
Copy Markdown

Summary

  • add geometry diagnostics for identifying open boundary edges and connected open-boundary regions
  • expose the helpers from the package entry point and TypeScript declarations
  • add debug-page controls for inspecting diagnostic regions

Fixes #68

Verification

  • npm ci
  • targeted geometry diagnostics tests
  • full test suite
  • lint (existing warnings only)
  • examples build
  • git diff --check

Copilot AI review requested due to automatic review settings May 21, 2026 10:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces geometry diagnostics utilities to help identify open boundary edges and connected open-boundary regions (useful for debugging “missing faces” / non-watertight CSG results), exposes them through the package entry points (JS + TS), and adds debug-page controls to visualize and log the diagnostic regions.

Changes:

  • Added getGeometryDiagnostic, getOpenBoundaryEdges, getOpenTriangleSets, and getTriangle utilities for open-boundary analysis.
  • Exported the new helpers via src/index.js and added TypeScript declarations.
  • Enhanced examples/debug.js to display open edges / triangle sets and to log triangle definitions for problematic regions.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Utils.geometryDiagnostics.test.js Adds targeted tests covering solid vs open geometries and disjoint-edge fragment handling.
src/utils/geometryDiagnostics.js Implements open-boundary edge detection, grouping into connected open-triangle sets, and a diagnostic summary object.
src/index.js Exposes the new diagnostics and isWaterTight from the package entry point.
src/index.d.ts Adds TS types and function declarations for the new diagnostics APIs.
examples/debug.js Adds GUI toggles and rendering/logging for diagnostic open edges and open triangle sets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/geometryDiagnostics.js Outdated
Comment on lines +106 to +114
const parent = this.parents.get( value );
if ( parent === value ) {

return value;

}

const root = this.find( parent );
this.parents.set( value, root );
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in bb22602: DisjointSet.find now validates that values have been added before lookup, uses iterative root discovery/path compression, and throws a clear error if an unexpected parent is missing. This avoids recursive stack growth on large meshes and fails explicitly for invalid input.

Verification:

  • npm test -- Utils.geometryDiagnostics.test.js
  • npm test
  • npm run lint (existing warnings only)
  • npm run build-examples
  • git diff --check

Comment on lines +219 to +223
const {
matchDisjointEdges = true,
useAllAttributes = false,
} = options;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in bb22602: when useAllAttributes is true, disjoint-edge matching is disabled via effectiveMatchDisjointEdges so edges intentionally separated by attribute differences are not reconnected by the position-only fallback.

Verification:

  • npm test -- Utils.geometryDiagnostics.test.js
  • npm test
  • npm run lint (existing warnings only)
  • npm run build-examples
  • git diff --check

Comment on lines +45 to +54
const vertexA = line ? line.start.clone() : getTriangleVertex( geometry, triangleIndex, edgeIndex, new Vector3() );
const vertexB = line ? line.end.clone() : getTriangleVertex( geometry, triangleIndex, nextEdgeIndex, new Vector3() );

return {
triangleIndex,
edgeIndex,
vertexIndices: [ vertexIndexA, vertexIndexB ],
vertexHashes: [ hashVertex3( vertexA ), hashVertex3( vertexB ) ],
vertices: [ vertexA, vertexB ],
line: line ? line.clone() : new Line3( vertexA.clone(), vertexB.clone() ),
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in bb22602: fragment/disjoint boundary edges now set vertexIndices to null and expose originalVertexIndices separately. The TypeScript declaration reflects this shape, and the regression test covers the fragment case.

Verification:

  • npm test -- Utils.geometryDiagnostics.test.js
  • npm test
  • npm run lint (existing warnings only)
  • npm run build-examples
  • git diff --check

@Bennett-hash Bennett-hash closed this by deleting the head repository May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Produce debug page, utilities for finding and understanding incorrectly clipped triangles

2 participants