hex-grid: add all_tris transformer + v2 JSON payload, refactor svg around SerializeGeo - #37
Merged
Merged
Conversation
…ound SerializeGeo Closes #36. - HGridLayout::hex_face_tris() — center-fan flat-top tris (6 per hex) - HGridLayout::all_tris() — unified stream: gap quads split along v0→v2, gap junction tris, hex face tris. Diagonal choice now owned in rust. - New crates/hex-grid/src/serialize.rs with SerializeGeo trait and four implementors: SvgPlain, SvgRich, JsonV1 (gen1: hexes/edges/quads/tris), JsonV2 (gen2: { version, tris }). - Example renamed svg.rs → geo_export.rs, now a thin CLI wrapper around SerializeGeo. --format <svg|svg-rich|json-v1|json-v2>; --rich/--json remain as backward-compat aliases. - Makefile: switch all targets to --example geo_export, add svg-json-v2 target emitting hex-terrain.json, include in svg-preview deps. - web/hex-terrain.html now fetches hex-terrain.json (v2), feeds tris directly to weldedMesh — drops hex-faces / gap-quads / gap-tris toggles since the per-source split is gone client-side. - web/hex-terrain.js: drop unused hexFaceQuads/hexFaceTris helpers. https://claude.ai/code/session_01QQ3Xnp4qT61EV1Kr6b8HtH
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #37 +/- ##
==========================================
- Coverage 76.73% 68.29% -8.45%
==========================================
Files 20 21 +1
Lines 748 839 +91
==========================================
- Hits 574 573 -1
- Misses 174 266 +92 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Closes #36.
Summary
HGridLayout::hex_face_tris()— center-fan flat-top tris (6 per hex, hard-coded fan).HGridLayout::all_tris()— unified triangle stream: gap quads split along the canonical[v0, v2]diagonal, gap junction tris, hex face tris. Diagonal choice now owned in rust, not on the JS client.crates/hex-grid/src/serialize.rs(new) —SerializeGeotrait with four implementors:SvgPlain/SvgRich— existing SVG variantsJsonV1— gen1 payload, byte-compatible with consumers ofhex-grid.json(hexes / edges / quads / tris)JsonV2— gen2 payload{ version: 2, tris: [...] }fromall_tris()svg.rs→geo_export.rs, now a thin CLI wrapper dispatching by--format <svg|svg-rich|json-v1|json-v2>.--richand--jsonkept as backward-compat aliases.--example geo_export; newsvg-json-v2target emitshex-terrain.json; included insvg-previewdeps.web/hex-terrain.html— fetcheshex-terrain.json(v2), feeds the unifiedtrisfield directly toweldedMesh. The per-source toggles (hex faces / gap quads / gap tris) collapse — only filled / wireframe / flat-shading remain, since the per-source split no longer exists client-side.web/hex-terrain.js— drops unusedhexFaceQuads/hexFaceTrishelpers (their work moved to rust).crates/hex-grid/README.md— documents the rename, the--formatflag, and the newJsonV2variant.web/svg-preview.htmlcontinues to consume v1 (hex-grid.json) — gen1 stays byte-identical for backward compat.Decisions (per the issue)
tris(notall_tris) — JSON only has one tri stream so the prefix is redundant.hex_face_tris()triangulation: center-fan, fastest path.SerializeGeolives in the lib (crates/hex-grid/src/serialize.rs), not the example.[v0, v2]to match prior JS behaviour. Documented onall_tris(); revisit after a visual A/B.Test plan
cargo test -p hex-grid— 35 tests pass (4 new:hex_face_tris_count_is_six_per_hex,hex_face_tris_share_height_per_hex,all_tris_count_matches_components, plus fourserialize::testsfor each format)cargo build(full workspace) — cleancargo clippy -p hex-grid --examples --tests— cleangeo_export -- 2 0.6 --format json-v2produces{"version":2,"tris":[...]};--format json-v1produces the gen1 shape;--richstill worksmake svg-previewand loadtarget/svg-preview/hex-terrain.htmlin a browser to confirm the welded mesh renders identically (rust-owned diagonal vs. JS-owned diagonal)https://claude.ai/code/session_01QQ3Xnp4qT61EV1Kr6b8HtH
Generated by Claude Code