3DBAG buildings as an optional checkbox (on by default) #12

Open
opened 2026-07-30 13:37:48 +00:00 by jeroen · 0 comments
Owner

Problem

3DBAG can only be disabled at the environment level (VIBE_3DBAG_URL="",
crates/viberfox/src/systems/osm_buildings.rs:64). In the Layers panel it is
just a static caption under the Buildings checkbox
(crates/viberfox/src/systems/data_layers.rs:1187-1195); the one
buildings_enabled flag governs OSM meshes, window glow and the 3DBAG LoD2.2
meshes together (data_layers.rs:1008-1017). There is no way to run pure-OSM
buildings at runtime.

Approach

Add tdbag_enabled: bool (default true) to DataLayers
(data_layers.rs:300), rendered as an indented checkbox "3DBAG (NL)" under
Buildings — shown only when tdbag_attribution() reports coverage, replacing
the static caption (an "OSM 3D buildings" label remains).

Route the flag through the existing coverage predicates rather than adding new
branches: mirror it into an AtomicBool in osm_buildings and make
tdbag_covers() (osm_buildings.rs:161) and lod22_covers()
(osm_buildings.rs:170) return false while disabled. Toggling off then
behaves exactly like the already-handled "host unreachable" case
(osm_buildings.rs:104), and every fallback comes for free:

  • update_lod22 stops queueing covered cells (lod22.rs:194)
  • the OSM detail patch resumes over formerly covered cells (osm_buildings.rs:510-520)
  • far extrusions fill the LoD2.2 near radius (osm_buildings.rs:610-615)
  • LoD1.2 cell fetches fall back to Overpass (osm_buildings.rs:1721)

Two pieces of explicit cleanup on the off-edge, mirroring the re-anchor
teardown (lod22.rs:136-148): despawn the spawned Lod22Mesh cells, call
colliders.clear_lod22(), and clear lod.requested so re-enabling re-queues
them. Track the previous toggle state in Lod22Buildings (or a Local) to
run this once per edge. Re-enabling needs no extra work: lod22 cells re-queue,
and the existing over_lod22 path despawns the OSM detail patch
(osm_buildings.rs:514-517).

Acceptance criteria

  • Indented "3DBAG (NL)" checkbox under Buildings, visible only when 3DBAG coverage is loaded; on by default.
  • Unchecking it over Groningen despawns the LoD2.2 meshes, clears their colliders, and OSM extrusions (detail patch + far cells) stream in as replacements.
  • While off, new building-cell fetches go to Overpass, never to the 3DBAG host.
  • Re-checking restores LoD2.2 meshes and removes the OSM detail patch over covered cells.
  • The Buildings master checkbox still hides/shows all building meshes regardless of the 3DBAG flag; the two flags are independent.
  • Avatar collision keeps working in both states (footprints from whichever streamer owns the cell).

Verification

  • cargo check -p viberfox
  • cargo test -p viberfox --bin viberfox
  • In-app: fly over Groningen, toggle 3DBAG off/on in the Layers panel; verify the mesh swap and that collisions still block walking into a building. As a headless proxy for the off-state, VIBE_3DBAG_URL="" cargo shots --only <groningen preset> should look identical to the toggled-off panel state.

Out of scope

  • Persisting the toggle across restarts (none of the sibling layer toggles persist).
  • Purging already-fetched LoD1.2/3DBAG-derived far extrusions or their disk cache when toggling off — they match the OSM look (osm_buildings.rs:190) and wash out on the next re-anchor. The attribution footer therefore also stays gated on coverage presence, not on the toggle.
  • A CLI/shot-manifest flag for the toggle.

Branch: feat/12-3dbag-toggle

## Problem 3DBAG can only be disabled at the environment level (`VIBE_3DBAG_URL=""`, `crates/viberfox/src/systems/osm_buildings.rs:64`). In the Layers panel it is just a static caption under the Buildings checkbox (`crates/viberfox/src/systems/data_layers.rs:1187-1195`); the one `buildings_enabled` flag governs OSM meshes, window glow and the 3DBAG LoD2.2 meshes together (`data_layers.rs:1008-1017`). There is no way to run pure-OSM buildings at runtime. ## Approach Add `tdbag_enabled: bool` (default `true`) to `DataLayers` (`data_layers.rs:300`), rendered as an indented checkbox **"3DBAG (NL)"** under Buildings — shown only when `tdbag_attribution()` reports coverage, replacing the static caption (an "OSM 3D buildings" label remains). Route the flag through the existing coverage predicates rather than adding new branches: mirror it into an `AtomicBool` in `osm_buildings` and make `tdbag_covers()` (`osm_buildings.rs:161`) and `lod22_covers()` (`osm_buildings.rs:170`) return `false` while disabled. Toggling off then behaves exactly like the already-handled "host unreachable" case (`osm_buildings.rs:104`), and every fallback comes for free: - `update_lod22` stops queueing covered cells (`lod22.rs:194`) - the OSM detail patch resumes over formerly covered cells (`osm_buildings.rs:510-520`) - far extrusions fill the LoD2.2 near radius (`osm_buildings.rs:610-615`) - LoD1.2 cell fetches fall back to Overpass (`osm_buildings.rs:1721`) Two pieces of explicit cleanup on the off-edge, mirroring the re-anchor teardown (`lod22.rs:136-148`): despawn the spawned `Lod22Mesh` cells, call `colliders.clear_lod22()`, and clear `lod.requested` so re-enabling re-queues them. Track the previous toggle state in `Lod22Buildings` (or a `Local`) to run this once per edge. Re-enabling needs no extra work: lod22 cells re-queue, and the existing `over_lod22` path despawns the OSM detail patch (`osm_buildings.rs:514-517`). ## Acceptance criteria - [ ] Indented "3DBAG (NL)" checkbox under Buildings, visible only when 3DBAG coverage is loaded; on by default. - [ ] Unchecking it over Groningen despawns the LoD2.2 meshes, clears their colliders, and OSM extrusions (detail patch + far cells) stream in as replacements. - [ ] While off, new building-cell fetches go to Overpass, never to the 3DBAG host. - [ ] Re-checking restores LoD2.2 meshes and removes the OSM detail patch over covered cells. - [ ] The Buildings master checkbox still hides/shows all building meshes regardless of the 3DBAG flag; the two flags are independent. - [ ] Avatar collision keeps working in both states (footprints from whichever streamer owns the cell). ## Verification - `cargo check -p viberfox` - `cargo test -p viberfox --bin viberfox` - In-app: fly over Groningen, toggle 3DBAG off/on in the Layers panel; verify the mesh swap and that collisions still block walking into a building. As a headless proxy for the off-state, `VIBE_3DBAG_URL="" cargo shots --only <groningen preset>` should look identical to the toggled-off panel state. ## Out of scope - Persisting the toggle across restarts (none of the sibling layer toggles persist). - Purging already-fetched LoD1.2/3DBAG-derived far extrusions or their disk cache when toggling off — they match the OSM look (`osm_buildings.rs:190`) and wash out on the next re-anchor. The attribution footer therefore also stays gated on coverage presence, not on the toggle. - A CLI/shot-manifest flag for the toggle. --- Branch: `feat/12-3dbag-toggle`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jeroen/cartopolis#12
No description provided.