Follow, drape and read the camera through the ports, not the viewer

- What the camera follows is the camera port's target only: no layer
  tracks an entity of its own any more, so followed.js stops reading and
  writing viewer.trackedEntity and the viewer's clock.
- Draped imagery's host is the globe port's imagery while the globe is
  shown (isGlobeVisible, or no shown base tileset where a renderer cannot
  say), else the shown base tileset; weather uses the same resolver.
- The World Packet reads the eye from the camera port's pose, and vessels
  ask again for the view on the camera port's moveEnd.
- The stub's canvas takes event listeners, and in a page is a real canvas
  filling the container it is given; createStubRendererPlugin makes it a
  renderer plugin.

The viewer access record is now empty.
This commit is contained in:
Sameh Khamis committed 2026-11-10 17:18:10 -08:00
1 parent ebbe006924
commit a72d4c3b1f
11 files changed
+230 -213

No files matched your search

+19 -11
View File
@@ -1,28 +1,36 @@
/**
* Where draped imagery can go on the current map stack. A globe stack drapes
* on `viewer.imageryLayers`; a 3D-tiles stack hides the globe, and Cesium
* 1.138 drapes imagery onto the tileset's own `imageryLayers` instead. When
* neither exists there is nowhere to drape and the caller says so.
* on the globe port's imagery; a 3D-tiles stack hides the globe, and the
* renderer drapes that imagery onto the shown base tileset instead. When
* neither is drawn there is nowhere to drape and the caller says so.
*/
import { msg } from '../i18n/marker.js';
import { findGlobe } from '../render/rendererOf.js';
/** Guidance shown when the active map stack cannot host draped imagery. */
export const NO_IMAGERY_HOST = msg(
'Hidden by this map source · choose a globe map',
);
const NONE = Object.freeze({ collection: null, kind: 'none' });
/**
* Resolve the imagery layer collection for the active map stack.
* Resolve the imagery host for the active map stack: the globe port's
* imagery while the globe is shown, else the shown base tileset (the map
* stack's `getImageryHostTileset()`), else none. `collection` names the host
* (one value per host, so a change of host is a change of it). A renderer
* that does not say whether its globe is shown (no `globeVisibility`) has it
* shown whenever no base tileset is.
* @param {{ viewer?: object, tileset?: object }} scene
* @returns {{ collection: object | null, kind: 'globe' | 'tileset' | 'none' }}
*/
export function resolveImageryHost({ viewer, tileset } = {}) {
if (viewer?.scene?.globe?.show === true && viewer.imageryLayers) {
return { collection: viewer.imageryLayers, kind: 'globe' };
}
if (tileset?.imageryLayers && !tileset.isDestroyed?.()) {
return { collection: tileset.imageryLayers, kind: 'tileset' };
}
return { collection: null, kind: 'none' };
const globe = findGlobe(viewer);
const shownTileset =
tileset && tileset.isDestroyed?.() !== true ? tileset : null;
const globeShown = globe?.isGlobeVisible?.() ?? (globe && !shownTileset);
if (globe && globeShown) return { collection: globe.imagery, kind: 'globe' };
if (shownTileset) return { collection: shownTileset, kind: 'tileset' };
return NONE;
}