Skip to content

Fix 2D view and change it to a top down view - #38

Merged
RalfLeonFasler merged 2 commits into
Lethonium:mainfrom
Meteord:feat/top-down-2d
Nov 11, 2026
Merged

RalfLeonFasler merged 2 commits into
Lethonium:mainfrom
Meteord:feat/top-down-2d

Conversation

@Meteord

@Meteord Meteord commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Why

The 2D view was still the old lane strip: it stretched across the window, showed almost nothing on a solo ride, and ignored the selected season and time of day. It is also the fallback for devices without WebGL 2, so those riders never saw the world's theming.
grafik

This replaces the lane strip with a top-down map built from data the client already has, and gives that map the same biome and lighting inputs as the 3D world.
grafik

What changed

  • Replaced view/pelotonView.js with view/rideMapView.js: a heading-up top-down map with the coast and island hillshade, context roads, the ridden road with edge lines and lane dividers, and rider/vehicle markers. The Training layout clips it above the workout band like the 3D view.
  • Added view/rideMapDecor.js: deterministic tree dots near forests and thin outline houses in villages and at cafés, generated from the route's scenery zones and the map's cafés, then culled to the view.
  • Added view/rideMapTheme.js: maps the selected biome's 2D palette and the time-of-day preset onto the map's ground, water, road, markings, trees and buildings. Winter paints snow, ice, pine dots and ploughed roads; golden hour and dusk tint the map; auto follows the local clock.
  • Added the 2D palette data to the temperate and winter biomes, and reused the same theme in the start menu's map preview.
  • Updated main.js so app.timeMode is stored even without a 3D view, and so biome/time changes reach 2D-only and no-WebGL sessions.
  • Kept rider, vehicle and HUD colors unchanged. No server or protocol changes.
  • Updated the canvas IDs/styles/i18n strings, README/package description, architecture docs, ADR 0020 and CHANGELOG.md.
  • Added tests for the map theme, biome map palettes, 2D rendering and themed decorations; existing map/decor tests were updated for the new tree shading model.

Checklist

  • New behaviour started with a failing test
  • make check passes — 992 client tests and all Rust tests; lint clean
  • Docs updated (ADR 0020, docs/architecture.md, README; no protocol change)
  • CHANGELOG.md entry

@RalfLeonFasler RalfLeonFasler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, the top-down map is a clear step up from the lane strip. I ran it locally: ESLint is clean and all 992 client tests pass. I also checked it in the browser for temperate day, winter dusk and the Training layout, and the layout, biome and time-of-day handling all work.

Some changes before merging:

  1. Winter contrast. The ridden road (map.road ≈ light grey) on SNOW is hard to tell apart from the ground, and at dusk the edge lines nearly disappear. The road you're on should stay the most readable thing on the map. A darker road or a darker edge/outline in winter would do it.
  2. The drafting indicator is gone. The old view drew the draft gap (draft was passed to drawPeloton); drawRideMap drops it. The HUD still shows "drafting x %" as text, so this may be fine, but please make it a deliberate choice: either show the draft on the map (e.g. a short band from me to the rider ahead) or mention the removal in the CHANGELOG.
  3. The same colours are defined three times. The temperate building and tree colours live in temperate.js (map, flora.mapColors), again in rideMapTheme.js (DEFAULT_BUILDINGS, TEMPERATE_TREES) and again in rideMapDecor.js (HOUSE_FILL etc., TREE_COLORS). Please keep them in the biome only and have the theme always pass them in. Also, temperate uses CSS strings and winter uses 0–1 arrays plus *Alpha; one format for both would remove most of the colorCss/parseColor handling. theme.landRgb is only used by its own test.
  4. Tree size is in pixels, buildings are in metres. drawDecorations draws tree.r as a pixel radius while buildings scale with camera.scale, so trees stay 3 px dots at any zoom or resolution. Probably tree.r * camera.scale (with a minimum size)?
  5. Per-frame work. Every frame recomputes offsetNodes for the whole route (edges plus each lane divider) and strokes every road of the network in full. roadDecorations is already cached per map; the offset lines could be cached per route the same way. Since this view is the fallback for devices without WebGL 2, it's worth keeping it light.

Smaller things:

  • The CHANGELOG adds a second ### Changed heading under [Unreleased]; please put the entries under the existing one.
  • In the cockpit layout, my arrow (riderY: 0.62) sits right under the "Tap left, then right" hint card.
  • Commits: please squash into imperative messages (CONTRIBUTING) and rebase instead of merging main in.

@RalfLeonFasler RalfLeonFasler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for the points in my review comment above.

@Meteord

Meteord commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I changed the following:

  • Winter contrast — darker road + lifted context roads, edge lines readable (day/dusk)
  • Draft indicator — soft band me → leader, passed from main.js; noted in CHANGELOG/ADR
  • Colours once — biome-only source, 0–1 arrays; dupes + landRgb removed; biome test pins it
  • Trees in metres — tree.r * camera.scale, 1.5 px min, cull margin follows radius
  • Per-frame work — offset lines cached per route, off-view context roads skipped
  • CHANGELOG — one Added/Changed/Fixed under [Unreleased] (72 entries kept)
  • Cockpit arrow — riderY: 0.5, clears the paddle meter
  • Commits — one squashed conventional commit rebased on upstream main (793f4db), pushed

@RalfLeonFasler

Copy link
Copy Markdown
Contributor

Thanks, this addresses everything from the review. To get it merged today, we pushed one small commit on top (6da1634):

  1. ADR renumbered to 0024. 0020 is already taken on main by 0020-sharing-riders-with-openbikenet.md, and 0021–0023 are used too, so the 2D map ADR is now docs/adr/0024-2d-map-view.md.
  2. CHANGELOG limited to your three 2D map entries. The last push also reformatted the whole file (a blank line between every entry, merged ### Fixed sections, released entries moved back under [Unreleased]). That's outside this PR and overlaps with docs: Let Release Please write the changelog #82, which is folding the 0.1.0 notes into their release section. So the file is back to main's version, with your three entries under [Unreleased] → ### Changed. If you think the CHANGELOG layout should change, a separate PR for that is welcome.

Meteord and others added 2 commits November 11, 2026 23:25
Replace the lane strip with a heading-up top-down map (ADR 0020): the island's
coast and hillshade, every road as a thin context line, the ridden road with
its edge lines and lane markings, the golden lemons still on the road, the
draft gap ahead of me when drafting, and one mark per rider or vehicle,
including my best lap's ghost. The map follows the selected season and time of
day like the 3D world; the biome is the single source of its 2D colours, in
0-1 RGB arrays like every other biome colour. Decorations are generated once
per map, lane offset lines are cached per route, and context roads outside the
view are skipped whole, so the WebGL 2 fallback stays light. Trees and
buildings are placed in metres and scale with the map's zoom.
ADR 0020 is taken by the OpenBikeNet ADR on main; the 2D map view is
0024. The CHANGELOG goes back to main's layout with the three 2D map
entries under [Unreleased] → Changed; reshaping the whole file is
left to the release notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RalfLeonFasler
RalfLeonFasler enabled auto-merge (squash) November 11, 2026 22:26
@RalfLeonFasler
RalfLeonFasler merged commit 3893e4a into Lethonium:main Nov 11, 2026
4 checks passed
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