Skip to content

Draw a flat surface for the terrain viewer - #95

Open
mouftz wants to merge 4 commits into
mainfrom
terrain-viewer-surface
Open

mouftz wants to merge 4 commits into
mainfrom
terrain-viewer-surface

Conversation

@mouftz

@mouftz mouftz commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Milestone #78 of the terrain viewer epic (#77): terrain is now drawn in the browser.
Closes #82, #83, #84 and #85.

  • Draw a flat surface on the page #82 Flat surface. Adds three.js and replaces the starter page with a full-window view:
    a square plane under a camera looking straight down. camera.ts fits the plane to the
    window without stretching it, at any window shape. The same plane gets raised into 3D
    later, so none of this setup is redone.
  • Turn a height grid into coloured cells #83 Heights to colours. colours.ts maps each height to a colour along a ramp of
    water, sand, grass, rock and snow. Heights outside 0–255 are pulled to the ends. The
    colour stops are one short list, so the Elevation Encoding ticket can retune them in one
    place.
  • Show the coloured cells on the surface #84 Cells on the surface. terrain.ts turns a grid into a texture on the plane, with
    nearest-neighbour filtering so each cell stays a sharp square instead of blurring into
    its neighbours.
  • Produce a height grid without a backend #85 Stand-in for the backend. terrainSource.ts answers a request of seed, corner
    and size (in cells) with a height grid. It is async and takes one request object, so
    the HTTP service from Ask for terrain over HTTP #75 can replace it without the rest of the viewer changing. Each
    height comes only from the cell's world position, so two regions that meet along an
    edge agree about the terrain there.

Validation

  • scripts/quality-check.sh passes locally
  • Appropriate /test commands were run and are passing (e.g. /test gpu)
  • Unit tests were added / e2e tests were added where applicable
  • Manual testing, if applicable (describe further):

Ran the dev server and checked each step in a browser. The plane stays square and centred
in wide and tall windows. Cells draw with hard edges, and the stand-in produces a coastline
rather than noise. No scrollbars, and the console is clean.

19 unit tests cover: the canvas following the window size and cleaning up when removed,
the camera framing, colours staying in range and clamping, one opaque pixel per cell in
order, sharp-edged filtering, and the stand-in's grid size, range, seeds, negative corners,
and two overlapping regions returning identical heights for the cells they share.

Checklist

  • The change is focused and easy to review.
  • Tests were added or updated for behaviour changes.
  • No secrets, generated files, or files that only make sense on my machine are included.
  • Relevant documentation is updated.

@mouftz
mouftz marked this pull request as draft September 24, 2026 18:16
@coveralls

coveralls commented Sep 24, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 36890505088

Coverage remained the same at 98.593%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 782
Covered Lines: 771
Line Coverage: 98.59%
Coverage Strength: 0.99 hits per line

💛 - Coveralls

@mouftz
mouftz force-pushed the terrain-viewer-surface branch from afd6095 to 584cf7a Compare September 26, 2026 17:45
@mouftz
mouftz marked this pull request as ready for review October 1, 2026 16:15
@mouftz mouftz changed the title WIP: Draw a flat surface for the terrain viewer Draw a flat surface for the terrain viewer Oct 1, 2026
@mouftz mouftz self-assigned this Oct 1, 2026
@mouftz
mouftz requested a review from KurbyDoo October 1, 2026 16:17
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.

Draw a flat surface on the page

2 participants