Welded hex-terrain demo + weldedMesh rename - #35
Merged
Conversation
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
web/hex-terrain.html— a three.js demo that takes the rust crate's quad/tri vec3s straight fromhex-grid.jsonand welds them into a single indexedBufferGeometry(no JS-side tessellation choices, just exact-xyz vertex dedup).HGridLayout::gap_quads()andgap_tris()emit gap geometry;crates/hex-grid/examples/svg.rsJSON output gains"quads"and"tris"fields.weldedMesh(quads, tris)(renamed fromweldedMeshFromQuads) with JSDoc covering welding semantics, the CCW-fan triangulation rule, and the exact-match (no-epsilon) caveat.make hex-terraintarget wired into thesvg-previewaggregate; workflow trigger paths cover the new files.Test plan
make svg-previewbuilds without errors and emitshex-terrain.html+hex-terrain.jsinto the deploy dirhex-terrain.htmlfrom the deployed preview — mesh renders, the six toggle buttons (filled / wireframe / flat shading / hex faces / gap quads / gap tris) all workquads × 4 + tris × 3(welding actually deduped)🤖 Generated with Claude Code