mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Brings in main up to f24abfc88: cockpit subject providers, the render
failure notice, aircraft drawn in their own mesh colours, airport ground
vehicles, and an aircraft with no ground track facing its true heading.
Under the seam:
- The render failure notice lives in the Cesium adapter
(src/render/cesium/renderFailure.js) and is the application hook
renderFailureNotice({allowReload, store}); its private Cesium fields
(Event's raise queue, the widget's render loop flag) are read through
internals.js. The inline panel's timer waits while the frame port reports
the loop stopped, and goes on after a Retry.
- Ordinary aircraft models draw white with the 'highlight' colour blend
through the draw port; tracked and emergency colours tint the mesh.
- Held trains and transit vehicles hide their route set and markers through
the draw port; the fleet model test fakes answer loads through the fake
draw port instead of Cesium's glTF loader.
- The Cockpit's subject view follows and places the camera through the
camera port.
54 lines
2.4 KiB
JavaScript
54 lines
2.4 KiB
JavaScript
/**
|
|
* @module render/applicationHooks
|
|
* @description What a renderer's plugin may hand the application beside the
|
|
* contract: behaviour the application uses where a renderer has it, and does
|
|
* without where it has none. Nothing here is part of the renderer contract,
|
|
* and the application never asks which renderer it runs on: it reads the
|
|
* hooks of the renderer it was given, each of them optional.
|
|
*
|
|
* - `mapEngine`: the renderer's own map engine (`src/maps/engine.js`), which
|
|
* the map stacks switch through in place of the globe port
|
|
* (`src/maps/globeEngine.js`).
|
|
* - `trimStaleCommands()`: drops the draw commands a renderer keeps for a
|
|
* while after it stops drawing them; run after a layer turns off.
|
|
* - `viewerDrawsEntity(entity)`: whether an entity is one the renderer draws
|
|
* itself (Cockpit asks whether the aircraft it flies still draws).
|
|
* - `qaHandles`: values QA scripts read from `window.__godsEyeView`.
|
|
* - `ownCreditDisplay`: true when the renderer shows its credits in a
|
|
* display of its own; otherwise the application shows what its credits
|
|
* port lists (`src/ui/creditsView.js`).
|
|
* - `renderFailureNotice({allowReload, store})`: a recoverable notice,
|
|
* published to `store`, when the renderer stops drawing
|
|
* (`src/render/cesium/renderFailure.js`); returns its removal.
|
|
*
|
|
* A plugin hands them as its `applicationHooks(renderer)`
|
|
* (`ApplicationHooks`, `contract/renderer.d.ts`); the application scene
|
|
* records them here as it creates the renderer. What the renderer should
|
|
* do is in the contract instead: keeping the Earth framed on zooming out is
|
|
* `camera.controls.keepEarthFramed`, the detection overlay's depth test is
|
|
* `query.occlusionTest`, and an inline panel keeps drawing through the frame
|
|
* port (`src/app/panelRendering.js`).
|
|
*/
|
|
|
|
const hooks = new WeakMap();
|
|
const NONE = Object.freeze({});
|
|
|
|
/**
|
|
* Hand the application `value`'s hooks for `renderer`. A renderer's plugin
|
|
* calls it as it creates the renderer; a later call replaces them.
|
|
* @param {object} renderer
|
|
* @param {object} value
|
|
*/
|
|
export function provideApplicationHooks(renderer, value) {
|
|
hooks.set(renderer, Object.freeze({ ...value }));
|
|
}
|
|
|
|
/**
|
|
* The hooks `renderer`'s plugin provided; an empty object when it provided
|
|
* none, or `renderer` is not an object.
|
|
* @param {object|null|undefined} renderer
|
|
* @returns {Readonly<object>}
|
|
*/
|
|
export const applicationHooksOf = (renderer) =>
|
|
(renderer && hooks.get(renderer)) || NONE;
|