mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Application scene and conformance page leave the Cesium allow-list
The application scene is the composition root: it now takes everything it needs from one adapter module (src/render/cesium/application.js), which loads, shows and releases the photoreal tileset and hands out the viewer hooks. The conformance page keeps importing the adapter's harness and scene renderer, since running the suite on Cesium is its purpose. Both are named in the ratchet as the only files outside the adapter that may import it, each limited to those modules, by name only, and the modules may not hand out the Cesium namespace. Only geoImportPins stays on the allow-list.
This commit is contained in:
1 parent
26665e8390
commit
4c587a6d0f
7 files changed
+222
-33
No files matched your search
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @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 scene imports this module 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';
|
||||
|
||||
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),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user