feat(globe): implement the engine on Navara

src/globe/navara builds the GlobeEngine on a Navara 0.2.1 ThreeView. The
engine keeps the camera pose in src/geo values and pushes it to Navara's
setCamera in degrees (Cesium's heading/pitch/roll convention, S4);
whatever Navara moves itself (user input, its flyTo arc) is read back
from the drawn camera each frame. Projection, picks against the
ellipsoid and the view rectangle are geo math on that pose, with
Navara's fov kept on Cesium's 60° across the wider side.

- flights: Navara flyTo in ms with mapped easings, cancelFlight via an
  empty setCamera, user input cancels a flight as in Cesium
- events: moveStart/moveEnd (500 ms still)/changed from the pose
- render: forceUpdate and animation (render on demand, S5)
- surface: S2 CPU ray over 3D-tile meshes, Navara terrain fallback
- maps: OSM/Esri raster, Re:Earth or ion quantized-mesh terrain,
  Google 3D tiles with a browser key and Google's logo
- input: DOM pointer events with ScreenSpaceEventHandler semantics
- the three private Navara members used live in internals.js, pinned
  to 0.2.1 by a test

index.js builds the product view (MSAA 4, native pixel ratio, preserved
drawing buffer, effects=minimal) for a dynamic import. The contract
QA script gains --engine=navara on a dev-only harness page: 46/46
contract and 4/4 Navara checks; Cesium stays 53/53.
This commit is contained in:
German Khokhlov committed 2026-10-15 19:03:58 +04:00
1 parent b6ac0e9c99
commit 90c8e7763a
19 files changed
+3311

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
// How the product builds its Navara view (S4, S5): render on demand (the
// engine's render.setContinuous turns animation on), MSAA 4 as Cesium's
// msaaSamples, the device pixel ratio unless a measurement pins one, a canvas
// whose WebGL2 context keeps its drawing buffer (Cesium's
// contextOptions.webgl.preserveDrawingBuffer, for captures), and the
// `minimal` look: sky, stars, sky light and sun without post effects —
// Navara's photoreal chain costs about 5 ms a frame and greys the Google
// tiles with tone mapping.
/** WebGL2 attributes Navara 0.2.1 asks for, plus preserveDrawingBuffer. */
export const NAVARA_CONTEXT_ATTRIBUTES = Object.freeze({
alpha: true,
antialias: true,
depth: true,
stencil: true,
premultipliedAlpha: true,
preserveDrawingBuffer: true,
powerPreference: 'default',
});
const MSAA_SAMPLES = 4;
/** ThreeView options; `pixelRatio` only when a measurement pins it. */
export function navaraViewOptions({ container, canvas, pixelRatio } = {}) {
return {
container,
...(canvas ? { canvas } : {}),
animation: false,
multisampling: MSAA_SAMPLES,
...(pixelRatio !== undefined ? { pixelRatio } : {}),
};
}
const PLANS = {
minimal: { pluginDefault: false, effects: [] },
photoreal: { pluginDefault: true, effects: [] },
};
/**
* What the view adds for a look: descriptor names, or the default plugin's
* own addDefaultPhotorealScene (sky, sun, aerial perspective, lens flare,
* tone mapping, SMAA).
*/
export function navaraScenePlan(effects = 'minimal') {
if (!Object.hasOwn(PLANS, effects))
throw new RangeError(`Unknown Navara effects: ${effects}`);
return {
pluginDefault: PLANS[effects].pluginDefault,
meshes: ['sky', 'stars'],
lights: ['skyLightProbe', 'sun'],
effects: [...PLANS[effects].effects],
};
}