mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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:
1 parent
b6ac0e9c99
commit
90c8e7763a
19 files changed
+3311
No files matched your search
@@ -0,0 +1,73 @@
|
||||
// Every private Navara member the engine relies on, in one place. Written
|
||||
// against @navaramap/three 0.2.1 (package.json pins it exactly; the test in
|
||||
// internals.test.mjs fails if the two drift apart): re-check each access below
|
||||
// before moving to another Navara version. Each names the parity spike that
|
||||
// found it and the public API that would replace it upstream.
|
||||
|
||||
import { ModelMesh } from '@navaramap/three';
|
||||
|
||||
export const NAVARA_INTERNALS_VERSION = '0.2.1';
|
||||
|
||||
let restoreRelease = null;
|
||||
|
||||
/**
|
||||
* S2: keep 3D-tile positions and indices on the CPU after upload so the
|
||||
* surface ray can hit them. Private: ModelMesh.prototype._releaseGeometryArrays,
|
||||
* which frees every attribute array once the tile is on the GPU. Patched on
|
||||
* the prototype, for all views; idempotent. Upstream ask: an option to retain
|
||||
* tile geometry for ray queries, or a sampleHeight/pickRay over 3D tiles.
|
||||
* Throws when the member is gone (another Navara version).
|
||||
*/
|
||||
export function retainTileGeometry() {
|
||||
if (restoreRelease) return restoreRelease;
|
||||
const proto = ModelMesh.prototype;
|
||||
const release = proto._releaseGeometryArrays;
|
||||
if (typeof release !== 'function')
|
||||
throw new Error('ModelMesh._releaseGeometryArrays not found');
|
||||
proto._releaseGeometryArrays = function releaseAllButPositions(mesh) {
|
||||
const geometry = mesh.geometry;
|
||||
const position = geometry?.attributes?.position;
|
||||
const index = geometry?.index ?? null;
|
||||
if (!position) return release.call(this, mesh);
|
||||
delete geometry.attributes.position;
|
||||
geometry.index = null;
|
||||
try {
|
||||
return release.call(this, mesh);
|
||||
} finally {
|
||||
geometry.attributes.position = position;
|
||||
geometry.index = index;
|
||||
}
|
||||
};
|
||||
restoreRelease = () => {
|
||||
proto._releaseGeometryArrays = release;
|
||||
restoreRelease = null;
|
||||
};
|
||||
return restoreRelease;
|
||||
}
|
||||
|
||||
/**
|
||||
* S2: the loaded 3D-tile roots (ModelMesh objects). Private: view._scenes.mrt,
|
||||
* the scene Navara renders tiles into. Upstream ask: as for
|
||||
* retainTileGeometry.
|
||||
*/
|
||||
export function tileRoots(view) {
|
||||
return (view._scenes?.mrt?.children ?? []).filter(
|
||||
(object) => object instanceof ModelMesh,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* S2/S5: whether Navara has stopped updating (tiles loaded, camera still).
|
||||
* Private: view._isIdle, which the public `idle` event reports only as an
|
||||
* edge. Upstream ask: a public isIdle/tilesLoaded getter.
|
||||
*/
|
||||
export function isIdle(view) {
|
||||
return view._isIdle === true;
|
||||
}
|
||||
|
||||
/** The hooks createNavaraEngine takes. */
|
||||
export const navaraHooks = (view) => ({
|
||||
retainTileGeometry,
|
||||
tileRoots: () => tileRoots(view),
|
||||
isIdle: () => isIdle(view),
|
||||
});
|
||||
Reference in new issue
Block a user