Skip to content

feat: add wireframe density controls for flat and curved surfaces - #98

Merged
devaraj3 merged 1 commit into
mainfrom
fix/wireframe-density-rendering
Aug 7, 2026
Merged

devaraj3 merged 1 commit into
mainfrom
fix/wireframe-density-rendering

Conversation

@devaraj3

@devaraj3 devaraj3 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

What changed

Wireframe mode has been fundamentally reworked. Previously, toggling Wireframe rendered every triangle edge from the mesh tessellation (THREE.WireframeGeometry) as opaque black lines on an opaque solid — an unreadable dense tangle, unrelated to the model's actual geometric edges.

Final architecture:

  • Wireframe ON now makes the solid body semi-transparent, with softened (reduced opacity, dark grey rather than pure black) line overlays visible through it
  • Edges are classified as flat (near-0° between adjacent triangles — tessellation artifacts with no real shape information) or curved (genuine angle between adjacent triangles — holes, fillets, cylindrical surfaces)
  • Flat edges: thinned via spatial/voxel-grid deduplication (one segment kept per 3D grid cell) — produces clean, evenly-distributed crisscross texture without the maze/parallel-only artifacts of earlier attempts
  • Curved edges: connected chains are traced first (following shared vertices around a hole rim, fillet, etc.), then thinned along the chain's path order — this keeps loops looking like loops (webs/polygons) instead of fragmenting into disconnected dashes
  • Both densities were tunable via sliders during development; final values are now locked in as defaults (Flat Surface Density: 25%, Curved Surface Detail: 65%) and the sliders are hidden from the UI (gated behind SHOW_WIREFRAME_DENSITY_CONTROLS = false, not deleted — a one-line flip re-exposes them later if needed)
  • The always-on "feature edge" system (clean part-boundary lines visible regardless of the Wireframe toggle) is completely untouched and independent throughout — this was mistakenly conflated with Wireframe mode in one intermediate attempt, which was identified and reverted

Why

This went through many iterations before landing here, worth summarizing for future reference:

  • Root cause of the original density bug: a skip-condition meant to avoid double-rendering checked a flag that was never actually set on the object being checked, so the dense fallback ran unconditionally on every mesh
  • Early fixes attempted depthTest/polygonOffset changes to solve back-face bleed-through — these caused GPU-specific regressions (worked in headless testing, failed on real hardware) and were reverted
  • Pure angle-threshold filtering (EdgesGeometry alone) was tried at multiple thresholds — always failed one of two ways: too high a threshold destroyed genuine curve detail on small features (holes rendering as bare rings), too low a threshold removed 100% of flat-face diagonals by mathematical necessity, leaving only parallel/circumferential lines
  • Pure spatial thinning (no connectivity awareness) handled flat faces well but fragmented curved loops into disconnected dashes
  • SimplifyModifier (mesh simplification) produced good curved-surface results but was too slow for live interaction and gave uncoordinated results on flat areas
  • The working solution required treating flat and curved geometry as genuinely different problems, each solved with the technique that worked for that specific case, rather than one universal method

Validation

  • Flat faces show genuine crisscross/zigzag texture — confirmed visually across multiple rounds, not parallel-lines-only, not a dense tangle
  • Counterbore, countersink, and hole boundaries show connected web/polygon structure — confirmed visually, not dashed/fragmented
  • Both density values locked to their approved defaults (25% / 65%), sliders hidden, sidebar layout confirmed clean with no gaps
  • Always-on feature edges confirmed unaffected and independent of the Wireframe toggle
  • Wireframe toggle on/off repeatedly — confirmed stable
  • npm run build
  • npm run lint
  • npm run typecheck
  • Full regression matrix (STEP single/multi-part, IGES, STL, OBJ, assembly flat/parts mode) — re-confirm once more on this exact final state before merging, since it was last verified a few iterations ago

Notes

  • The two density values are stored as real, working sliders internally — just hidden. If a future need arises (e.g. per-file-type tuning, or exposing to advanced users), re-enabling is a one-line change, not a rebuild
  • No changes to picking/raycasting, measurement, or any other viewer feature — this was scoped entirely to wireframe rendering

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cad-viewer Ready Ready Preview Aug 7, 2026 4:40am

@devaraj3
devaraj3 merged commit 3730de5 into main Aug 7, 2026
6 checks passed
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.

1 participant