mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
The arrival ground guard replaced camera.flyTo, flyToBoundingSphere,
setView, lookAt and cancelFlight with wrappers so a direct caller would stop
it. It now remembers the pose it started on and, before each retry, yields
if a flight is under way or the camera has moved across the ground, down or
around. A straight rise is not a move: Cesium's terrain collision lifts a
buried eye that way as tiles load, which is the case the guard exists for.
This also catches owners the wrappers missed (a pose written directly,
lookAtTransform), and no camera method is replaced.
Recent imagery and weather overwrote provider.requestImage (weather also
provider.credit) to ration tiles. They now state that policy as a hook with
withTileRequestHook(provider, { requestImage, credit }) from
src/render/cesium/tileRequests.js, which hands Cesium a provider delegating
to the original and leaves the original untouched.
Every private Cesium field the app reaches goes through a named helper in
src/render/cesium/internals.js: the main and offscreen pick views and their
command extents, a billboard's collection, a cluster's point collection,
the widget's render-loop latch, the WebGL context and the current camera
flight. internals.test.mjs fails when the installed Cesium stops declaring
one of them, and a source scan fails on private access anywhere else. The
cyber sonar's primitives.update wrap stays until the effects work.
Live (Austin, keyless globe): a buried eye is lifted to 253 m over a 133 m
surface; a setView or flyTo by another caller makes the guard yield; radar
loads its tiles through the hook. Documented in docs/APPLICATION.md and
docs/CURRENT-STATE.md.
51 lines
2.0 KiB
JavaScript
51 lines
2.0 KiB
JavaScript
/**
|
|
* @module render/cesium/tileRequests
|
|
* @description Admission hooks for an imagery provider's tile requests.
|
|
*
|
|
* A layer that rations its tiles (a request budget, readiness accounting,
|
|
* dropping a frame that is no longer shown) states that policy as a hook
|
|
* instead of replacing the provider's `requestImage`. The provider itself is
|
|
* left untouched: the returned provider delegates everything to it through
|
|
* its prototype and routes only tile requests, and optionally the credit,
|
|
* through the hook.
|
|
*
|
|
* Fields Cesium writes onto a provider land on the returned one, so a
|
|
* provider that reads such a field itself (a time-dynamic WMTS provider's
|
|
* `_reload`) is not suited; the URL-template and raster providers that use
|
|
* hooks today read none.
|
|
*/
|
|
|
|
/**
|
|
* @typedef {object} TileRequest
|
|
* @property {number} x
|
|
* @property {number} y
|
|
* @property {number} level
|
|
* @property {object} [request] Cesium `Request`, when Cesium passed one.
|
|
*/
|
|
|
|
/**
|
|
* @param {object} provider A Cesium imagery provider (or one built by the app).
|
|
* @param {object} hooks
|
|
* @param {(tile: TileRequest, issue: () => Promise<any>|undefined) => Promise<any>|undefined} [hooks.requestImage]
|
|
* Decides each request. `issue()` asks the provider; returning `undefined`
|
|
* defers the tile, and Cesium asks again on a later frame.
|
|
* @param {() => object} [hooks.credit] The credit Cesium shows for the layer,
|
|
* read every frame, so it can change without restaging the imagery.
|
|
* @returns {object} A provider to hand to `ImageryLayer`.
|
|
*/
|
|
export function withTileRequestHook(provider, { requestImage, credit } = {}) {
|
|
const hooked = Object.create(provider);
|
|
if (requestImage)
|
|
hooked.requestImage = (x, y, level, request) =>
|
|
requestImage({ x, y, level, request }, () =>
|
|
provider.requestImage(x, y, level, request),
|
|
);
|
|
if (credit)
|
|
Object.defineProperty(hooked, 'credit', {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get: credit,
|
|
});
|
|
return hooked;
|
|
}
|