mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Start the application through the contract, not on the Cesium viewer
The application scene takes a renderer plugin and no longer refuses one without a Cesium viewer. It loads the default (Cesium) plugin only when it is given none, so a page on the stub never loads Cesium. - Every layer and tool is handed the application's own scene object (createSceneHost): the container and isDestroyed(), bound to the renderer, the same on Cesium and the stub. - What only Cesium needs at startup is done in its plugin's create: the free-look height limit, and keyboard access to its credits' expand link (creditKeyboard.js moves into the adapter). - What a plugin may hand the application beside the contract goes through provideApplicationHooks, each hook optional: Cesium's map engine, stale command trimming, inline panel rendering, viewerDrawsEntity, the zoom-out guard, and the viewer QA scripts read from window.__godsEyeView. - The map stacks, and the photoreal base the scene loads, switch through the renderer's own map engine (mapEngineFor), else its globe port (globeEngine.js). The Cesium engine takes the scene object and changes the viewer behind it.
This commit is contained in:
1 parent
a72d4c3b1f
commit
6daf63d90c
24 files changed
+825
-241
No files matched your search
@@ -1,69 +1,10 @@
|
||||
/**
|
||||
* @module render/cesium/application
|
||||
* @description The Cesium adapter's side of the application scene
|
||||
* (`src/app/scene.js`), its composition root: the default renderer plugin,
|
||||
* the viewer behind a renderer it made, the photoreal base tileset the scene
|
||||
* loads into that viewer, and the viewer hooks the scene hands the
|
||||
* application (stale command trimming, inline panel rendering, whether an
|
||||
* entity is the viewer's own, the zoom-out guard, the free-look height
|
||||
* limit). The scene imports this module and no other
|
||||
* part of the adapter (`src/render/noCesiumOutsideRender.test.mjs`).
|
||||
* (`src/app/scene.js`), its composition root: the default renderer plugin.
|
||||
* Everything else the application needs of this renderer comes with each
|
||||
* renderer the plugin makes (`appRenderer.js`). The scene imports this
|
||||
* module, when it is given no renderer of its own, and no other part of the
|
||||
* adapter (`src/render/noCesiumOutsideRender.test.mjs`).
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import { cesiumRenderer, cesiumViewerOf } from './appRenderer.js';
|
||||
import { loadPhotorealisticTileset } from './google3d.js';
|
||||
import { keepPanelRendering } from './panelRendering.js';
|
||||
import { trimStaleSceneCommands } from './sceneCommandRelease.js';
|
||||
import { installZoomOutGuard } from './zoomOutGuard.js';
|
||||
import { installFreeLookHeightLimit } from './freeLookLimit.js';
|
||||
|
||||
export { cesiumRenderer, cesiumViewerOf };
|
||||
|
||||
/**
|
||||
* Load Google Photorealistic 3D Tiles for the application, by the best route
|
||||
* the credentials allow (`google3d.js`).
|
||||
* @param {{googleApiKey?: string, googleTokens?: object|null, cesiumToken?: string}} credentials
|
||||
* @returns {Promise<{tileset: object|null, route: string, errors: Error[]}>}
|
||||
*/
|
||||
export const loadApplicationPhotoreal = (credentials) =>
|
||||
loadPhotorealisticTileset(Cesium, credentials);
|
||||
|
||||
/** Draw the loaded photoreal tileset in `viewer`. */
|
||||
export function showApplicationPhotoreal(viewer, tileset) {
|
||||
viewer.scene.primitives.add(tileset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the photoreal tileset: out of `viewer`, which destroys it, or
|
||||
* destroyed by itself when the viewer never held it.
|
||||
*/
|
||||
export function releaseApplicationPhotoreal(viewer, tileset) {
|
||||
if (tileset && !tileset.isDestroyed()) {
|
||||
if (!viewer.scene.primitives.remove(tileset)) tileset.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What the application scene hands the application about its viewer.
|
||||
* @param {object} viewer
|
||||
*/
|
||||
export function applicationViewerHooks(viewer) {
|
||||
return {
|
||||
// Drops the draw commands the scene keeps after it stops drawing them;
|
||||
// run after a drawn frame (see sceneCommandRelease.js).
|
||||
trimStaleCommands: () => trimStaleSceneCommands(viewer.scene),
|
||||
// Keeps the globe drawing in an inline panel whose host stops animation
|
||||
// frames (embed mode, src/app/embed.js).
|
||||
keepPanelRendering: (options) => keepPanelRendering(viewer, options),
|
||||
// Whether an entity is one of the viewer's own (Cockpit asks whether
|
||||
// the aircraft it flies still draws).
|
||||
viewerDrawsEntity: (entity) => viewer.entities.contains(entity),
|
||||
// Keeps outward user zooms bounded and the Earth framed; returns its
|
||||
// disposer (see zoomOutGuard.js).
|
||||
installZoomOutGuard: (options) => installZoomOutGuard(viewer, options),
|
||||
// Allows the camera controller's free look only near the ground; returns
|
||||
// its disposer (see freeLookLimit.js).
|
||||
installFreeLookHeightLimit: (maxHeight) =>
|
||||
installFreeLookHeightLimit(viewer, maxHeight),
|
||||
};
|
||||
}
|
||||
export { cesiumRenderer } from './appRenderer.js';
|
||||
Reference in new issue
Block a user