mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Fly the remaining flights through the camera port, on any viewer
The embed view, the celestial-ring focus, the ground-guard lift, the Bhote Koshi approach and orbit, launch selection and replay flights, and the cockpit's view and takeover now drive the renderer's camera port. The contract gains a sineInOut easing, pinned by a conformance trace. A viewer with no renderer bound, such as one a caller of a public export brings, now gets a camera port too, as it already got an input port: cameraOf builds one over the viewer's own Cesium camera and keeps it for the viewer's life, until a renderer is bound. The Cesium adapter provides the factory as it loads; code that reaches Cesium takes cameraOf from the adapter so the factory comes with it, and findCamera answers null where a missing camera is not an error (HUD, share link, world focus, Recent Imagery's ZOOM IN). A test walks every package export and fails one that can reach the bridge without loading the factory. A destroyed viewer gets no camera and lets go of a built one, and the application renderer stays bound until its viewer is destroyed.
This commit is contained in:
1 parent
c5b716b107
commit
1d4e4ebe90
44 files changed
+1167
-344
No files matched your search
@@ -4,6 +4,7 @@ import {
|
||||
setOverlayEntries,
|
||||
} from '../overlays/worldOverlay.js';
|
||||
import { governorRequestRender } from '../renderGovernor.js';
|
||||
import { cameraOf } from '../render/cesium/camera.js';
|
||||
import {
|
||||
BHOTE_KOSHI_LOCATOR_CREDIT,
|
||||
registerDynamicCredit,
|
||||
@@ -620,6 +621,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
requestRender('bhote-koshi-trigger-record-reveal');
|
||||
const camera = _viewer?.camera;
|
||||
if (!camera?.flyTo) return;
|
||||
const port = cameraOf(_viewer);
|
||||
const generation = _generation;
|
||||
_triggerApproachInFlight = true;
|
||||
const finish = () => {
|
||||
@@ -627,50 +629,54 @@ export function createBhoteKoshiLocatorLayer({
|
||||
attempt.phase = 'finished';
|
||||
_triggerApproachInFlight = false;
|
||||
};
|
||||
camera.flyTo({
|
||||
destination: Cesium.Cartesian3.fromDegrees(
|
||||
TRIGGER_APPROACH_CAMERA.lon,
|
||||
TRIGGER_APPROACH_CAMERA.lat,
|
||||
TRIGGER_APPROACH_CAMERA.alt,
|
||||
),
|
||||
orientation: {
|
||||
heading: Cesium.Math.toRadians(TRIGGER_APPROACH_CAMERA.heading),
|
||||
pitch: Cesium.Math.toRadians(TRIGGER_APPROACH_CAMERA.pitch),
|
||||
roll: Cesium.Math.toRadians(TRIGGER_APPROACH_CAMERA.roll),
|
||||
port.flyTo(
|
||||
{
|
||||
lon: TRIGGER_APPROACH_CAMERA.lon,
|
||||
lat: TRIGGER_APPROACH_CAMERA.lat,
|
||||
height: TRIGGER_APPROACH_CAMERA.alt,
|
||||
},
|
||||
duration: TRIGGER_APPROACH_DURATION_SEC,
|
||||
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
|
||||
complete: () => {
|
||||
if (_triggerApproachAttempt !== attempt || attempt.phase !== 'flying')
|
||||
return;
|
||||
if (
|
||||
!_enabled ||
|
||||
generation !== _generation ||
|
||||
_presentation !== BHOTE_KOSHI_TRIGGER_RECORD_PRESENTATION
|
||||
) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
attempt.phase = 'orbiting';
|
||||
camera.flyTo({
|
||||
destination: Cesium.Cartesian3.fromDegrees(
|
||||
TRIGGER_ORBIT_CAMERA.lon,
|
||||
TRIGGER_ORBIT_CAMERA.lat,
|
||||
TRIGGER_ORBIT_CAMERA.alt,
|
||||
),
|
||||
orientation: {
|
||||
heading: Cesium.Math.toRadians(TRIGGER_ORBIT_CAMERA.heading),
|
||||
pitch: Cesium.Math.toRadians(TRIGGER_ORBIT_CAMERA.pitch),
|
||||
roll: Cesium.Math.toRadians(TRIGGER_ORBIT_CAMERA.roll),
|
||||
},
|
||||
duration: TRIGGER_ORBIT_DURATION_SEC,
|
||||
easingFunction: Cesium.EasingFunction.SINUSOIDAL_IN_OUT,
|
||||
complete: finish,
|
||||
cancel: finish,
|
||||
});
|
||||
{
|
||||
orientation: {
|
||||
heading: Cesium.Math.toRadians(TRIGGER_APPROACH_CAMERA.heading),
|
||||
pitch: Cesium.Math.toRadians(TRIGGER_APPROACH_CAMERA.pitch),
|
||||
roll: Cesium.Math.toRadians(TRIGGER_APPROACH_CAMERA.roll),
|
||||
},
|
||||
durationS: TRIGGER_APPROACH_DURATION_SEC,
|
||||
easing: 'cubicInOut',
|
||||
onComplete: () => {
|
||||
if (_triggerApproachAttempt !== attempt || attempt.phase !== 'flying')
|
||||
return;
|
||||
if (
|
||||
!_enabled ||
|
||||
generation !== _generation ||
|
||||
_presentation !== BHOTE_KOSHI_TRIGGER_RECORD_PRESENTATION
|
||||
) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
attempt.phase = 'orbiting';
|
||||
port.flyTo(
|
||||
{
|
||||
lon: TRIGGER_ORBIT_CAMERA.lon,
|
||||
lat: TRIGGER_ORBIT_CAMERA.lat,
|
||||
height: TRIGGER_ORBIT_CAMERA.alt,
|
||||
},
|
||||
{
|
||||
orientation: {
|
||||
heading: Cesium.Math.toRadians(TRIGGER_ORBIT_CAMERA.heading),
|
||||
pitch: Cesium.Math.toRadians(TRIGGER_ORBIT_CAMERA.pitch),
|
||||
roll: Cesium.Math.toRadians(TRIGGER_ORBIT_CAMERA.roll),
|
||||
},
|
||||
durationS: TRIGGER_ORBIT_DURATION_SEC,
|
||||
easing: 'sineInOut',
|
||||
onComplete: finish,
|
||||
onCancel: finish,
|
||||
},
|
||||
);
|
||||
},
|
||||
onCancel: finish,
|
||||
},
|
||||
cancel: finish,
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
function armTriggerApproach() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
@@ -647,6 +648,7 @@ test('Bhote Koshi trigger-record waits for the scene camera, zooms, then orbits'
|
||||
},
|
||||
cancelFlight() {},
|
||||
};
|
||||
bindFakeCesiumCamera(viewer);
|
||||
const layer = createBhoteKoshiLocatorLayer({
|
||||
boundaryResolver: async () => null,
|
||||
requestRender() {},
|
||||
@@ -703,6 +705,9 @@ for (const phase of ['timer', 'move-end', 'approach', 'orbit']) {
|
||||
},
|
||||
cancelFlight() {},
|
||||
};
|
||||
bindFakeCesiumCamera(viewer);
|
||||
// The renderer's camera port relays these; the layer's own come on top.
|
||||
const portListeners = [moveStart, moveEnd].map((e) => e.numberOfListeners);
|
||||
const layer = createBhoteKoshiLocatorLayer({
|
||||
boundaryResolver: async () => null,
|
||||
overlayHost: overlayHostFixture(),
|
||||
@@ -745,8 +750,10 @@ for (const phase of ['timer', 'move-end', 'approach', 'orbit']) {
|
||||
const oldFlights = [...flights];
|
||||
SceneDirector.prototype.stopScene.call(director);
|
||||
assert.equal(timers.size, 0, 'Stop cancels the actual delayed work');
|
||||
assert.equal(moveStart.numberOfListeners, 0);
|
||||
assert.equal(moveEnd.numberOfListeners, 0);
|
||||
assert.deepEqual(
|
||||
[moveStart, moveEnd].map((e) => e.numberOfListeners),
|
||||
portListeners,
|
||||
);
|
||||
callbacks[0]();
|
||||
moveEnd.raiseEvent();
|
||||
for (const flight of oldFlights) flight.complete();
|
||||
|
||||
Reference in new issue
Block a user