Let the shell's share link, HUD, orbit and navigation follow another globe engine

The shell reads its viewer, engine and map stack from the attached scene. ShareLinkManager, IntelHUD and OrbitController gain attachEngine, NavigationController setScene and LocationNavigation attachScene/detachScene, so a switch can keep them and move only their camera listeners; between engines they write and read nothing. The voice runner and session voice modules are owned by their packages, which check:boundaries needs since the voice commit.
This commit is contained in:
German Khokhlov committed 2026-11-03 17:48:08 +04:00
1 parent 741b6f67eb
commit d1fdb9eb45
9 files changed
+243 -17

No files matched your search

+32 -9
View File
@@ -168,9 +168,9 @@ export class StyleManager extends ShellFacade {
this._feedback = new ShellFeedback({
readLayers: () => this._dataManager?.getAll?.() || [],
});
this.viewer = viewer;
this.engine = engine;
this.mapStackController = mapStackController;
// The attached globe: its viewer (null on Navara), engine and map
// stack. An engine switch replaces it (attachScene/detachScene).
this._scene = { viewer, engine, mapStackController };
this.placeSearch = placeSearch;
this._navigation = new NavigationController({
@@ -458,7 +458,7 @@ export class StyleManager extends ShellFacade {
},
isNavigationCurrent: (generation) =>
generation === this._navigationGeneration,
cancelOwnedNavigation: () => this.engine.camera.cancelFlight(),
cancelOwnedNavigation: () => this.engine?.camera.cancelFlight(),
// A host may open a share code without a `/share/<code>` address.
initialShareCode,
});
@@ -625,7 +625,10 @@ export class StyleManager extends ShellFacade {
this._publishActiveStyle();
this._updateLocationMiniStatus();
this._shareRestoration.start({ engineSwitch, retainScene: Boolean(this._layerSession?.handoffLayers) });
this._shareRestoration.start({
engineSwitch,
retainScene: Boolean(this._layerSession?.handoffLayers),
});
// Keep the parameter panel from overlapping toggle controls.
this._layoutRightPanels();
@@ -644,6 +647,21 @@ export class StyleManager extends ShellFacade {
this._layerBindings.observeCamera();
}
/** The attached globe's Cesium viewer; null on Navara or between engines. */
get viewer() {
return this._scene?.viewer ?? null;
}
/** The attached globe engine; null between engines. */
get engine() {
return this._scene?.engine ?? null;
}
/** The attached globe's map stack; null between engines. */
get mapStackController() {
return this._scene?.mapStackController ?? null;
}
// Compatibility reads for existing controls, scene snapshots and Cockpit.
/** Advance camera authority and settle any older search UI immediately. */
@@ -1475,7 +1493,7 @@ export class StyleManager extends ShellFacade {
* @returns {void}
*/
applyCameraState(cameraState, duration = 2.8) {
if (!cameraState) return;
if (!cameraState || !this.engine) return;
this.engine.camera.flyTo({
destination: geo.cartesian3.fromDegrees(
cameraState.lon,
@@ -1856,12 +1874,17 @@ export class StyleManager extends ShellFacade {
// re-enable a mode's entry layer and republish `_contextMode` while the
// rest of teardown is tearing those very layers down.
this._contextControls.stop();
this._navigation.destroy({ retainScene: Boolean(this._layerSession?.handoffLayers) });
this._navigation.destroy({
retainScene: Boolean(this._layerSession?.handoffLayers),
});
// Close camera-entry seams synchronously. Context restoration may await
// layer work, so leaving these listeners attached until afterward lets a
// focus event release tracking or start a flight during teardown.
if (this._layerSession && !this._layerSession.lifetime.signal.aborted &&
this._contextControls.canRetainScene()) {
if (
this._layerSession &&
!this._layerSession.lifetime.signal.aborted &&
this._contextControls.canRetainScene()
) {
this._layerSession.contextScene = this._contextControls.captureScene();
} else {
if (this._layerSession) this._layerSession.contextScene = null;
+24
View File
@@ -443,6 +443,30 @@ export class LocationNavigation {
}
/** Revoke callbacks and settle owned camera work before the viewer is released. */
/**
* Leave the globe (an engine switch): its reset flight, world-jump
* transition and orbit end; the search, its text and the readout stay.
*/
detachScene() {
this._cancelGlobeReset?.();
this._cancelGlobeReset = null;
if (this._worldJumpActive) this._endWorldJumpTransition();
clearTimeout(this._trafficTransitionTimer);
this._trafficTransitionTimer = null;
this._stopOrbit();
this.orbitController?.attachEngine(null);
this.viewer = null;
this.engine = null;
}
/** Navigate on another globe (an engine switch). */
attachScene({ viewer = null, engine = engineFromViewer(viewer) } = {}) {
if (this._disposed) return;
this.viewer = viewer;
this.engine = engine;
this.orbitController?.attachEngine(engine);
}
destroy() {
if (this._disposed) return;
this._disposed = true;
+23 -2
View File
@@ -254,7 +254,10 @@ export class NavigationController {
});
}
_reassertNavigationHandoff(generation, { trackingOrigin = 'tool', keepTracking = false } = {}) {
_reassertNavigationHandoff(
generation,
{ trackingOrigin = 'tool', keepTracking = false } = {},
) {
return reassertNavigationHandoff({
generation,
currentGeneration: this._navigationGeneration,
@@ -270,6 +273,24 @@ export class NavigationController {
},
});
}
/**
* The globe the camera authority applies to (an engine switch), or none.
* Leaving a globe retires every deferred navigation started on it: its
* flight cannot land on the next one. `retainScene` keeps the selection a
* handoff carries across.
*/
setScene({ viewer = null, engine = null } = {}, { retainScene = true } = {}) {
if (this._disposed) return;
if (this.engine && engine !== this.engine) {
cancelCameraArrival(this.engine);
this._stampNavigation({
cancelPendingSelection: !retainScene,
clearSearchedLocation: false,
});
}
this.viewer = viewer;
this.engine = engine ?? engineFromViewer(viewer);
}
/** Subscribe to ownership changes without claiming the camera or exposing mutable state. */
subscribeCameraHandoff(listener) {
return this._cameraHandoffs.subscribe(listener, { emitCurrent: false });
@@ -282,6 +303,6 @@ export class NavigationController {
}
destroy({ retainScene = false } = {}) {
this.stop();
this._stampNavigation({cancelPendingSelection: !retainScene});
this._stampNavigation({ cancelPendingSelection: !retainScene });
}
}