mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Fly scenes through the renderer bridge and take the scene director off the Cesium list
The director converts degrees itself, finds its camera through the renderer bridge rather than the Cesium adapter, and reads the canvas from its bound renderer. A caller handing it a viewer of its own with no renderer bound loads the package's ./render/cesium/unbound export first, as other Cesium-free entries ask.
This commit is contained in:
1 parent
1cfa62c7ba
commit
dbf1647572
3 files changed
+25
-19
No files matched your search
@@ -81,7 +81,6 @@
|
|||||||
"src/sceneCommandRelease.js",
|
"src/sceneCommandRelease.js",
|
||||||
"src/scenes/dataPacks/geometry.js",
|
"src/scenes/dataPacks/geometry.js",
|
||||||
"src/scenes/dataPacks/presentation.js",
|
"src/scenes/dataPacks/presentation.js",
|
||||||
"src/scenes/director.js",
|
|
||||||
"src/services/groundSnap.js",
|
"src/services/groundSnap.js",
|
||||||
"src/services/meshFloorSampler.js",
|
"src/services/meshFloorSampler.js",
|
||||||
"src/sky/starrySky.js",
|
"src/sky/starrySky.js",
|
||||||
|
|||||||
@@ -96,6 +96,10 @@ const DRAW_FROM_CALLER = new Set([
|
|||||||
* `./render/cesium/unbound`.
|
* `./render/cesium/unbound`.
|
||||||
*/
|
*/
|
||||||
const CAMERA_FROM_CALLER = new Set([
|
const CAMERA_FROM_CALLER = new Set([
|
||||||
|
// Not Cesium-free yet: its data packs still draw through Cesium in their
|
||||||
|
// own listed modules. Its flights ask `cameraOf`, which throws until the
|
||||||
|
// caller has loaded the export.
|
||||||
|
'./scenes',
|
||||||
'./ui/navigation',
|
'./ui/navigation',
|
||||||
'./voice/commands',
|
'./voice/commands',
|
||||||
'./voice/controller',
|
'./voice/controller',
|
||||||
|
|||||||
+21
-18
@@ -21,9 +21,8 @@ import { SceneControls } from '../ui/scenes.js';
|
|||||||
import { createToast } from '../ui/toast.js';
|
import { createToast } from '../ui/toast.js';
|
||||||
import { buildPlaybackQueue, playSceneQueue } from '../director/playback.js';
|
import { buildPlaybackQueue, playSceneQueue } from '../director/playback.js';
|
||||||
import { createScenePlaybackAdapter } from './playbackAdapter.js';
|
import { createScenePlaybackAdapter } from './playbackAdapter.js';
|
||||||
import * as Cesium from 'cesium';
|
import { toRadians } from '../geo/vector.js';
|
||||||
import { cameraOf } from '../render/cesium/camera.js';
|
import { cameraOf, findCamera, rendererOf } from '../render/rendererOf.js';
|
||||||
import { findCamera } from '../render/rendererOf.js';
|
|
||||||
import {
|
import {
|
||||||
SCENE_APPEND_RECIPES,
|
SCENE_APPEND_RECIPES,
|
||||||
SCENE_RECIPES,
|
SCENE_RECIPES,
|
||||||
@@ -76,13 +75,16 @@ const STORAGE_CHECKPOINT_KEY = 'godsEyeView.sceneProject.checkpoint.v1';
|
|||||||
* Orchestrates deterministic cinematic scene playback.
|
* Orchestrates deterministic cinematic scene playback.
|
||||||
*
|
*
|
||||||
* The director owns a mutable project (persisted in localStorage) containing
|
* The director owns a mutable project (persisted in localStorage) containing
|
||||||
* scenes and shots. It drives camera flights via Cesium, applies visual/style
|
* scenes and shots. It drives camera flights via the renderer, applies
|
||||||
* state through the styleManager, toggles data layers via the dataManager, and
|
* visual/style state through the styleManager, toggles data layers via the
|
||||||
* records timestamped telemetry events during each run for later export.
|
* dataManager, and records timestamped telemetry events during each run for
|
||||||
|
* later export.
|
||||||
*/
|
*/
|
||||||
export class SceneDirector {
|
export class SceneDirector {
|
||||||
/**
|
/**
|
||||||
* @param {Cesium.Viewer} viewer - The Cesium viewer instance
|
* @param {object} viewer - The scene's viewer (its renderer's host). Given
|
||||||
|
* a viewer with no renderer bound, the caller loads
|
||||||
|
* the package's `./render/cesium/unbound` export first.
|
||||||
* @param {Object} styleManager - Controls visual state (bloom, sharpen, HUD, detection, style presets)
|
* @param {Object} styleManager - Controls visual state (bloom, sharpen, HUD, detection, style presets)
|
||||||
* @param {Object} dataManager - Manages data layer enable/disable and per-layer params
|
* @param {Object} dataManager - Manages data layer enable/disable and per-layer params
|
||||||
*/
|
*/
|
||||||
@@ -134,7 +136,8 @@ export class SceneDirector {
|
|||||||
};
|
};
|
||||||
this._cameraHandoffUnsubscribe =
|
this._cameraHandoffUnsubscribe =
|
||||||
styleManager.subscribeCameraHandoff?.(yieldCamera);
|
styleManager.subscribeCameraHandoff?.(yieldCamera);
|
||||||
const canvas = viewer.scene?.canvas;
|
// A viewer of the caller's own, with no renderer bound, has its canvas.
|
||||||
|
const canvas = rendererOf(viewer)?.canvas ?? viewer.scene?.canvas;
|
||||||
for (const event of ['pointerdown', 'wheel'])
|
for (const event of ['pointerdown', 'wheel'])
|
||||||
canvas?.addEventListener(event, yieldCamera, { passive: true });
|
canvas?.addEventListener(event, yieldCamera, { passive: true });
|
||||||
this._removeCameraInput = () => {
|
this._removeCameraInput = () => {
|
||||||
@@ -1365,7 +1368,7 @@ export class SceneDirector {
|
|||||||
return travel;
|
return travel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Publish a travel phase only after Cesium has accepted the camera flight. */
|
/** Publish a travel phase only after the renderer has accepted the camera flight. */
|
||||||
_publishShotTravel(scene, shot, cameraTravel) {
|
_publishShotTravel(scene, shot, cameraTravel) {
|
||||||
const states = this._layerStatesForShot(scene, shot, { cameraTravel });
|
const states = this._layerStatesForShot(scene, shot, { cameraTravel });
|
||||||
for (const [layerId, state] of Object.entries(states)) {
|
for (const [layerId, state] of Object.entries(states)) {
|
||||||
@@ -1761,9 +1764,9 @@ export class SceneDirector {
|
|||||||
height: cameraState.alt,
|
height: cameraState.alt,
|
||||||
},
|
},
|
||||||
orientation: {
|
orientation: {
|
||||||
heading: Cesium.Math.toRadians(cameraState.heading || 0),
|
heading: toRadians(cameraState.heading || 0),
|
||||||
pitch: Cesium.Math.toRadians(cameraState.pitch ?? -35),
|
pitch: toRadians(cameraState.pitch ?? -35),
|
||||||
roll: Cesium.Math.toRadians(cameraState.roll || 0),
|
roll: toRadians(cameraState.roll || 0),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@@ -2003,7 +2006,7 @@ export class SceneDirector {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the active scene run. Sets the cancellation token, aborts the
|
* Cancel the active scene run. Sets the cancellation token, aborts the
|
||||||
* run's in-flight layer transitions and Cesium camera flight, and logs a
|
* run's in-flight layer transitions and camera flight, and logs a
|
||||||
* stop event.
|
* stop event.
|
||||||
*
|
*
|
||||||
* The abort is the part that stops work already under way: a layer
|
* The abort is the part that stops work already under way: a layer
|
||||||
@@ -2450,7 +2453,7 @@ export class SceneDirector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fly the Cesium camera to the given position over the specified duration
|
* Fly the camera to the given position over the specified duration
|
||||||
* using cubic ease-in-out. Resolves when the flight completes, is cancelled,
|
* using cubic ease-in-out. Resolves when the flight completes, is cancelled,
|
||||||
* or a safety timeout fires (duration + 0.6s).
|
* or a safety timeout fires (duration + 0.6s).
|
||||||
* @param {Object} cameraState - Target { lat, lon, alt, heading, pitch, roll }
|
* @param {Object} cameraState - Target { lat, lon, alt, heading, pitch, roll }
|
||||||
@@ -2488,9 +2491,9 @@ export class SceneDirector {
|
|||||||
|
|
||||||
cameraOf(this.viewer).flyTo(destination, {
|
cameraOf(this.viewer).flyTo(destination, {
|
||||||
orientation: {
|
orientation: {
|
||||||
heading: Cesium.Math.toRadians(cameraState.heading || 0),
|
heading: toRadians(cameraState.heading || 0),
|
||||||
pitch: Cesium.Math.toRadians(cameraState.pitch ?? -35),
|
pitch: toRadians(cameraState.pitch ?? -35),
|
||||||
roll: Cesium.Math.toRadians(cameraState.roll || 0),
|
roll: toRadians(cameraState.roll || 0),
|
||||||
},
|
},
|
||||||
durationS: duration,
|
durationS: duration,
|
||||||
easing: 'cubicInOut',
|
easing: 'cubicInOut',
|
||||||
@@ -2498,7 +2501,7 @@ export class SceneDirector {
|
|||||||
onCancel: finish,
|
onCancel: finish,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Safety timeout in case Cesium callbacks fail to fire
|
// Safety timeout in case the flight's callbacks fail to fire
|
||||||
if (!done) timer = setTimeout(finish, (duration + 0.6) * 1000);
|
if (!done) timer = setTimeout(finish, (duration + 0.6) * 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user