mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Merge main through #1532 into the renderer seam
Brings in voice camera tilt (#1520) and free look with globe-in-view recovery (#1532). The tilt and look maths in cameraVerbs.js and globeInView.js run on camera poses and the geo helpers instead of Cesium. The free-look height limit lives in the Cesium adapter (render/cesium/freeLookLimit.js), installed through the application viewer hooks; the globe-in-view recovery that main added to app/viewer.js runs on the camera port in app/globeInViewRecovery.js. The scene-mode checks are gone with the 2D and Columbus modes the seam does not draw.
This commit is contained in:
commit
96764f85ca
28 files changed
+4764
-145
No files matched your search
@@ -5,7 +5,8 @@
|
||||
* 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 scene imports this module and no other
|
||||
* 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`).
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
@@ -14,6 +15,7 @@ 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 };
|
||||
|
||||
@@ -59,5 +61,9 @@ export function applicationViewerHooks(viewer) {
|
||||
// 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),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @module render/cesium/freeLookLimit
|
||||
* @description Keeps the Cesium camera controller's free look to low
|
||||
* heights. It writes that controller's own settings, so it lives in the
|
||||
* adapter; the application installs it through the scene's viewer hooks
|
||||
* (`application.js`).
|
||||
*/
|
||||
/**
|
||||
* Allow Cesium's free look only below `maxHeight` and return its disposer.
|
||||
* Orbit, tilt and zoom stay available at every height. A value other code
|
||||
* sets later is kept as the one to allow below that height, and restored on
|
||||
* dispose; a `false` written while the camera is above `maxHeight` cannot be
|
||||
* told apart from this limit's own write, so dispose restores the earlier
|
||||
* value then. `enableLook` gates the Shift+drag binding only: below its trackball
|
||||
* height Cesium also turns the camera in place for a drag that starts on the
|
||||
* stars. That height is lowered to `maxHeight` too, so above it such a drag
|
||||
* orbits the globe, as it does above Cesium's own 7,500 km.
|
||||
*/
|
||||
export function installFreeLookHeightLimit(viewer, maxHeight) {
|
||||
const scene = viewer?.scene;
|
||||
const controller = scene?.screenSpaceCameraController;
|
||||
const camera = viewer?.camera;
|
||||
if (!controller || !camera || !scene?.preUpdate)
|
||||
throw new TypeError('A complete Cesium viewer is required');
|
||||
|
||||
const originalTrackBallHeight = controller.minimumTrackBallHeight;
|
||||
const trackBallHeight = Math.min(originalTrackBallHeight, maxHeight);
|
||||
controller.minimumTrackBallHeight = trackBallHeight;
|
||||
let wanted = controller.enableLook;
|
||||
let written;
|
||||
const sync = () => {
|
||||
if (written !== undefined && controller.enableLook !== written)
|
||||
wanted = controller.enableLook;
|
||||
const height = camera.positionCartographic?.height;
|
||||
written = wanted && !(Number.isFinite(height) && height > maxHeight);
|
||||
controller.enableLook = written;
|
||||
};
|
||||
sync();
|
||||
const removeListener = scene.preUpdate.addEventListener(sync);
|
||||
|
||||
let active = true;
|
||||
return () => {
|
||||
if (!active) return;
|
||||
active = false;
|
||||
removeListener();
|
||||
if (controller.enableLook === written) controller.enableLook = wanted;
|
||||
if (controller.minimumTrackBallHeight === trackBallHeight)
|
||||
controller.minimumTrackBallHeight = originalTrackBallHeight;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user