Skip to content

Welded hex-terrain demo + weldedMesh rename - #35

Merged
dynnamitt merged 5 commits into
mainfrom
claude/mesh-subdivision-terminology-90uWj
Apr 27, 2026
Merged

Welded hex-terrain demo + weldedMesh rename#35
dynnamitt merged 5 commits into
mainfrom
claude/mesh-subdivision-terminology-90uWj

Conversation

@dynnamitt

Copy link
Copy Markdown
Owner

Summary

  • Adds web/hex-terrain.html — a three.js demo that takes the rust crate's quad/tri vec3s straight from hex-grid.json and welds them into a single indexed BufferGeometry (no JS-side tessellation choices, just exact-xyz vertex dedup).
  • Rust side: HGridLayout::gap_quads() and gap_tris() emit gap geometry; crates/hex-grid/examples/svg.rs JSON output gains "quads" and "tris" fields.
  • JS side: weldedMesh(quads, tris) (renamed from weldedMeshFromQuads) with JSDoc covering welding semantics, the CCW-fan triangulation rule, and the exact-match (no-epsilon) caveat.
  • Pipeline: make hex-terrain target wired into the svg-preview aggregate; workflow trigger paths cover the new files.

Test plan

  • make svg-preview builds without errors and emits hex-terrain.html + hex-terrain.js into the deploy dir
  • Open hex-terrain.html from the deployed preview — mesh renders, the six toggle buttons (filled / wireframe / flat shading / hex faces / gap quads / gap tris) all work
  • Toggling gap tris off shows triangular holes at every 3-hex junction (confirms tris are needed)
  • Stats line shows welded vertex count is lower than quads × 4 + tris × 3 (welding actually deduped)

🤖 Generated with Claude Code

claude and others added 3 commits April 26, 2026 20:17
Adds web/hex-terrain.html, a new three.js demo that takes the hex
grid's quad and tri vec3 data straight from hex-grid.json and welds
overlapping vertices into a single indexed BufferGeometry. The
subdivision is therefore preset by the rust crate -- no JS-side
tessellation choices, just exact-xyz vertex dedup.

Rust side
- HGridLayout::gap_quads() emits each gap quad as [Vec3; 4] in CCW
  order ready for triangulation.
- HGridLayout::gap_tris() emits each 3-hex-junction tri as [Vec3; 3]
  using the canonical-ownership rule from h_terrain/gaps.rs.
- crates/hex-grid/examples/svg.rs JSON output gains "quads" and "tris"
  fields next to the existing "hexes" and "edges".

JS side
- web/hex-terrain.js exports weldedMeshFromQuads(quads, tris) which
  hashes each [x, y, z] verbatim and reuses indices for matches. Hex
  faces are fan-tris from each hex's center (their corner vec3s line
  up exactly with the quad/tri corners that share them).
- web/hex-terrain.html wires six toggle buttons above the canvas
  (filled, wireframe, flat shading, hex faces, gap quads, gap tris)
  plus a live vertex/triangle counter.

Pipeline
- Makefile gets a hex-terrain target wired into the svg-preview
  aggregate.
- svg-preview.yml trigger paths cover the two new files.
- Cross-links updated on svg-preview.html and hex-tessellate.html.
The name implied quads-only input, but the function also accepts tris
(needed to fill 3-hex junction gaps). The new name reflects what it
actually builds; JSDoc spells out the triangulation rule and the
exact-match welding (no epsilon merge).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Makes the welded mesh structure visible at first glance — wireframe
toggle starts active and the line color shifts from a muted blue to
a warm yellow that contrasts the dark teal fill.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Apr 26, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.73%. Comparing base (bb48d7b) to head (1b46ea5).

Files with missing lines Patch % Lines
crates/hex-grid/src/layout.rs 0.00% 28 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
- Coverage   80.70%   76.73%   -3.97%     
==========================================
  Files          20       20              
  Lines         710      748      +38     
==========================================
+ Hits          573      574       +1     
- Misses        137      174      +37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

claude added 2 commits April 26, 2026 23:19
…t a perf optim

At ~300 tris the welded indexed mesh saves microseconds at best. The
real wins are watertight topology at hex-face-to-gap-quad seams (driven
by HGridLayout::vertex returning identical Vec3 for shared corners) and
free averaged normals across faces. Captures when indexed welded meshes
do start to pay off (100k+ tris with non-trivial vertex shaders) so
future readers don't mistake the technique for a hot-path optimization.
@dynnamitt
dynnamitt merged commit d920619 into main Apr 27, 2026
2 checks passed
@dynnamitt
dynnamitt deleted the claude/mesh-subdivision-terminology-90uWj branch April 27, 2026 08:09
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.

3 participants