Skip to content

feat: infinite terrain streaming with 3-chunk radius#13

Merged
maxfelker merged 2 commits into
mainfrom
feat/infinite-terrain
Mar 1, 2026
Merged

feat: infinite terrain streaming with 3-chunk radius#13
maxfelker merged 2 commits into
mainfrom
feat/infinite-terrain

Conversation

@maxfelker

Copy link
Copy Markdown
Owner

Summary

Implements true infinite terrain — as the player walks, the world generates ahead of them with no visible edge.

Changes

Go / WASM

  • RenderRadius: 512 → 1536 (3-chunk radius, ~28 chunks visible at once)
  • DistanceThreshold: 1100 → 2560 (5-chunk eviction with hysteresis to prevent thrash)
  • MaxConcurrentChunks: 3 → 64 (removes the throttle that limited initial load to 3 chunks)
  • World.Update(): Stripped redundant heightmap/normals generation — goGenerateChunk owns that. Update is now pure coordinate math, returning sorted nearest-first chunk list
  • Center-based distance: Uses chunk center (cx+0.5)*size instead of corner for more accurate circular loading
  • goWorldUpdate: Only evicts heightmaps on chunk removal (generation side was already handled by goGenerateChunk)

TypeScript

  • Parallel generation: streamUpdate now uses Promise.all — all new chunks in a batch are queued to the WASM worker concurrently (GPU upload happens progressively as each completes)
  • Stream trigger: 256 → 128 units — fires every quarter-chunk of movement for more responsive horizon loading
  • Immediate first stream: lastStreamX/Z initialized to -99999 so the render loop triggers a full streaming pass on the very first frame

Testing

  • All Go tests pass
  • All 56 TypeScript tests pass
  • Docker production build passes (67MB image)

Reviewable commits

  1. e4acee5 — Go world streaming: 3-chunk radius, no throttle, no redundant generation
  2. 7d1ef58 — TypeScript: parallel chunk gen, faster stream trigger, immediate first stream

maxfelker and others added 2 commits March 1, 2026 12:06
- streamUpdate: generates all new chunks concurrently via Promise.all
  instead of sequential await — GPU upload happens progressively
- Stream trigger: 256 → 128 units (quarter-chunk for responsiveness)
- lastStreamX/Z: initialized to -99999 to force immediate first stream

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- RenderRadius: 512 → 1536 (3-chunk radius, ~28 chunks visible)
- DistanceThreshold: 1100 → 2560 (5-chunk eviction hysteresis)
- MaxConcurrentChunks: 3 → 64 (no effective throttle)
- World.Update(): strip redundant heightmap generation (goGenerateChunk handles it)
- Use chunk-center distance for circular frustum (more accurate than corner)
- Sort chunksToAdd nearest-first for better load UX
- goWorldUpdate: only clean up evicted heightmaps, not populate

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maxfelker maxfelker force-pushed the feat/infinite-terrain branch from e4acee5 to 1bfd23c Compare March 1, 2026 20:06
@maxfelker maxfelker merged commit c7f6bc0 into main Mar 1, 2026
1 check passed
@maxfelker maxfelker deleted the feat/infinite-terrain branch March 1, 2026 20:06
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