Files
planet/docs/technical/en/earth-render-layer-order.md
T
rayd1o 5bfc790dec
ci / backend (push) Has been cancelled
ci / frontend (push) Has been cancelled
release / images (push) Has been cancelled
ci / delivery (push) Has been cancelled
release: bump version to 0.75.0
2026-09-23 21:20:12 +08:00

14 KiB
Raw Blame History

Earth Render Layer Order

The compute topic reuses the compute-center Interactable icons, depth behavior, and layer order. Country/year changes replace that layer's data and clear prior selection. Its HUD is screen UI excluded from Earth picking in main.js. Regional cards are tethered in screen space; rear anchors do not draw connectors through the globe. Facility details reuse the existing card and mobile details drawer. The existing outer atmosphere shell remains, while the starfield is restored to commit 83a10a6c (brightStarOpacity:0.88; no tint/brightness calibration). The HD overlay is a white MeshBasicMaterial with opacity 1 and toneMapped:false; texture-colors.js selects the r128 encoding/LinearTosRGB path or r160 colorSpace/colorspace fragment. No Phong white light, colored twilight, blue night tint, camera boost, or shoulder curve is added. No new post-processing, GPU draw pass, or high-resolution texture was added; the compute topic adds 45 local SVG flag assets.

This document records the current Earth renderer's layer order and the intent of each layer. When adjusting renderOrder, radius offsets, depth strategy, or pointer interaction, update this document accordingly.

Note: the layer control panel order and the registration / startup load order are two separate semantics.

Order type Current sequence Notes
Control panel order Cables → Satellites → Compute Centers → Vessels → BGP → Terrain → HD Texture → Cloud Layer → Border Lines → Grid Controlled by displayOrder, sorted by operational relevance; satellite trails moved to Settings and are no longer a layer-list item.
Registration / startup load order Grid → Border Lines / Land-Ocean Base → HD Texture → Cloud Layer → Cables → Compute Centers → Vessels → BGP → Satellites Controlled by registration order and startupPriority, sorted surface-to-sky; the startup queue reads persisted layer visibility first, skips normal layers explicitly saved as hidden, and HD Texture does not download the texture when disabled; Border Lines are the exception: the land-ocean base always preloads, while the persisted state only controls interactive border lines and hover; Trails and Terrain are dependency/optional display layers and do not participate in normal startup data loading.

Surface Layer Stack

Order Layer Source Render / Radius Strategy Depth / Interaction Strategy Notes
-1000 Celestial background mesh celestial.js Background sphere Not part of surface picking Behind all Earth content.
-1 Earth occluder sphere earth.js Invisible inner sphere Writes depth buffer Occludes objects behind the Earth.
0 Earth base sphere earth.js CONFIG.earthRadius Surface picking fallback target Dark base; still visible when all optional map layers are off.
0.2 Country dark tint country-boundaries.js tintAltitudeOffset Raycast disabled Used when HD texture is off.
0.86 Land/ocean base fill country-boundaries.js landAltitudeOffset = 0.32; ocean #010609, land #080f1b Raycast disabled Base map remains usable even when country borders are off; radius is separated from the base sphere to avoid far-zoom z-fighting.
0.96 HD Earth texture earth.js textureOverlayAltitudeOffset = EARTH_SURFACE_TEXTURE_ALTITUDE_OFFSET = 0.48 Surface picking target when visible HD texture always overlays the land/ocean base fill; radius must stay above the land/ocean base and far enough from the base sphere.
1 Atmospheric glow and clouds earth.js Atmosphere / cloud spheres Not in normal object selection path Cloud layer controlled by the "Cloud Layer" toggle.
1 Submarine cables / landing points cables.js, cable-batches.js All cable segments share one LineSegments; all landing points use instanced billboards; render order remains 1; cable altitude offset stays 0.2, while landing-point anchors use the HD surface offset 0.48 Original Line / Sprite objects retain per-item picking and selection state but no longer draw individually; landing-point sphere occlusion remains, with depthTest: false on the batch Style textures and instance attributes preserve color, pulse, size, visibility, and click behavior.
1.2 Real terrain earth.js, terrain.js TERRAIN_CONFIG.baseRadiusOffset plus terrain displacement Raycast disabled Terrain overlays HD texture; temporarily hidden when HD texture is off, restores to prior state when re-enabled.
2.05 Grid lines earth.js CONFIG.earthRadius + 0.14 Raycast disabled Low-opacity lines over HD texture.
0.97–0.99 Country borders country-boundaries.js lineAltitudeOffset = EARTH_SURFACE_TEXTURE_ALTITUDE_OFFSET = 0.48; claim lines have no extra lift Raycast disabled Line geometry still has its own renderOrder, but it shares the exact same radius as the HD texture shell to avoid parallax while the globe rotates.
0.98 Country border hover glow country-boundaries.js Same surface mapping, no extra lift depthTest: true, transparent render queue, raycast disabled Additive glow to reinforce border edge and terrain hover visibility.
0.99 Country border hover line country-boundaries.js hoverAltitudeOffset = EARTH_SURFACE_TEXTURE_ALTITUDE_OFFSET = 0.48 depthTest: true, transparent render queue, raycast disabled Neon red-orange hover line; aligned with the normal borders and HD texture shell to avoid ghosting or floating; China and Taiwan share the same highlight group.
3 Satellite footprint fill / Iridium coverage ring satellites.js, iridium-footprint-adapter.js GROUND_FOOTPRINT_RENDER_ORDER depth-tested; Iridium adapter fill / ring use the same renderOrder Footprint above land / texture / terrain and country borders, below compute centers and satellites.
3-4.5 BGP collectors, event rings, and event markers bgp.js, interactable.js Collector markers use BGP_COLLECTOR_RENDER_ORDER = 4.4; event markers use BGP_EVENT_RENDER_ORDER = 4.5; overlays remain in BGP-owned groups Screen-space Interactable picking; BGP collectors/events may use collision avoidance where appropriate BGP collectors share the surface-facility band with vessels; BGP events share the compute-center band.
4.3 AIS vessel track lines vessels.js VESSEL_RENDER_ORDER - 0.1; CONFIG.earthRadius + VESSEL_CONFIG.track.altitudeOffset Follows vessel selection, not independently picked Recent track for the selected vessel, below vessel markers.
4.4 AIS vessel markers vessels.js, interactable.js VESSEL_RENDER_ORDER; business radius CONFIG.earthRadius + VESSEL_CONFIG.altitudeOffset; normal markers are bucketed THREE.Points, hover / locked states are single-point overlays depthTest: true; main.js uses screen-space picking for front-facing markers; cluster: false and avoidance: false Moving vessels use triangular point textures, anchored / slow vessels use dots. Dense waterways may overlap and do not participate in dynamic screen clustering, avoiding Points rebuilds during rotation.
4.5 Compute centers compute-centers.js, interactable.js COMPUTE_CENTER_RENDER_ORDER Screen-space Interactable picking, with surface-icon collision handling Surface facilities, below satellites.
5 Satellite background dot satellites.js Fixed renderOrder; by default TLE/SGP4 altitude is compressed to CONFIG.earthRadius + 4..25; with real altitude disabled or propagation failed, uses fallbackAltitudeOffset = 8 Screen-space satellite picking Below satellite dots.
6 Satellite dots satellites.js Same compressed / fallback height as satellite backdrop dots Screen-space satellite picking Satellite dots above footprints and compute centers.
12+ Satellite locked ring, halo, predicted orbit satellites.js SATELLITE_CONFIG.overlayRenderOrder and offsets; predicted orbit follows the same real-altitude toggle and fixes the lock-time globe pose to draw a closed inertial orbit; returns to same-sphere mode when real altitude is disabled Satellite overlay path Used for selected/locked satellite emphasis.
98-100 Sun / moon halo and sprite celestial.js Fixed renderOrder Celestial picking disabled Foreground celestial sprites.

Full-set rendering and updates

  • Batching changes GPU submission, not the number of satellites, cable segments, or landing points. It does not filter data by the visible hemisphere. Every adjacent cable vertex pair remains present, and picking still returns the original business object.
  • Satellite foreground and backdrop remain two Points draws. Vertex shaders compute breathing from static per-point parameters and a shared frame-time uniform; existing hover/locked state still controls point masking.
  • satellite-position-worker.js uses the same Three.js / SGP4 versions as the main thread. satellite-propagation.js owns shared orbit, display-altitude, and fallback calculations. Full positions and initial trail samples use transferable arrays; only one calculation is in flight. Reload, clear, and altitude-mode changes terminate the previous Worker.
  • Worker startup failure or SATELLITE_CONFIG.workerStartupTimeoutMs expiry falls back to the shared synchronous calculation. Counts, APIs, the existing update interval, and trail length are unchanged.
  • Verify full draw ranges, per-item picking, locked overlays, trails, rear-side occlusion, visibility toggles, and resource release after clearing. Frame-time comparisons require identical data, view, and resolution.

Toggle Behavior

Toggle Behavior
HD texture off Hides HD texture, enables country tint / base surface, disables terrain and day/night toggle interaction, and remembers terrain and day/night previous states.
HD texture on Restores HD texture and the remembered terrain / day/night states.
Terrain on Displayed above HD texture, but below country border hover, footprints, satellites, and other emphasis layers.
Cloud layer Only controls cloud mesh visibility.
Border Lines off Hides only interactive border lines and hover, clearing hover state; the land/ocean base fill remains as the Earth base map.
Real Satellite Altitude off Satellite dots, trails, and predicted orbits use the legacy same-sphere height; satellites with missing TLE data or failed propagation also use this fallback height.

Depth Spacing Rules

The Earth surface is not a single mesh. It is a stack of near-concentric shells: base sphere, land/ocean base, HD texture, terrain, clouds, atmosphere, and the occluder. Radius offsets that look harmless at close zoom can collapse into the same depth-buffer pixels at zoomed-out views such as 50%, causing z-fighting that appears as black blocks, snow, or flicker.

Maintenance rules:

  • Do not reach first for hiding layers at far zoom. Check neighboring shell altitudeOffset, renderOrder, depthTest, and depthWrite first.
  • Whole-globe overlays such as the land/ocean base and HD texture must keep explicit separation from CONFIG.earthRadius; the current stable values are landAltitudeOffset = 0.32 and textureOverlayAltitudeOffset = EARTH_SURFACE_TEXTURE_ALTITUDE_OFFSET = 0.48.
  • Country borders, coastlines, claim lines, and country hover lines must use EARTH_SURFACE_TEXTURE_ALTITUDE_OFFSET, exactly matching the HD texture shell. Do not give border lines an independent lower or higher offset, because globe rotation will make the lines appear to drift relative to the surface texture.
  • Any new whole-globe or near-whole-globe surface overlay must be screenshot-verified at 50% zoom and at common close zooms, with no black blocks, snow, flicker, or obvious floating.
  • If these radii change, update this document and the intent around the constants in frontend/public/earth/js/constants.js.

Interaction Rules

Interaction Current Rule
Earth coordinate hover When HD texture is visible, uses the HD texture overlay as the surface picking target; otherwise uses the Earth base sphere.
Country border hover Converts surface pick coordinates to lat/lon, then uses GeoJSON point-in-polygon; the border hover line itself does not receive raycasts.
Country border hover visual On hover, dims normal border lines and draws depth-tested glow and solid lines below landing points.
China / Taiwan hover CHN and TWN are grouped in the same hover highlight group; the tooltip still shows the actually-hit feature.
Terrain Acts as a visual layer only; terrain.raycast is disabled.
Satellites Uses screen-space satellite picking to prevent footprints or surface layers from blocking satellite clicks.

Surface attachment and landing point order

earth-surface.js projects geographic vertices onto the high-resolution SphereGeometry UV triangles at geometry construction time. Boundaries, coastlines, claim lines, hover outlines and landing points share this surface mapping. Long edges are subdivided using the surface grid spacing. Landing-point anchors now use the texture shell offset of 0.48; cable line offsets remain 0.2. The draw order is texture 0.96, boundaries/highlights 0.97–0.99, then landing points 1. Hover outlines always use the transparent queue with depth testing, so they do not draw through the globe or over landing markers. Geography is unchanged, and cached geometry is not rebuilt during rotation.

Startup loading versus drawing order

The selected full-resolution surface loads before independent data requests; boundary construction no longer blocks its first frame. This does not change renderOrder, depth behavior, geometry precision or image resolution. Data refresh retains the surface, with texture disposal limited to successful replacement or scene teardown.