Timed imagery reads the drawn globe tiles through internals.js

The tiles the globe last drew are a private Cesium field: read through
globeTilesDrawn, whose field the internals test checks the installed
Cesium still declares.
This commit is contained in:
Sameh Khamis committed 2026-11-11 17:20:58 -08:00
1 parent ee9de4edda
commit a043854f27
3 files changed
+21 -1

No files matched your search

+2 -1
View File
@@ -13,6 +13,7 @@
* segment end is the nearest frame. * segment end is the nearest frame.
*/ */
import * as Cesium from 'cesium'; import * as Cesium from 'cesium';
import { globeTilesDrawn } from './internals.js';
/** How far apart the times a video segment is seen at are, ms. */ /** How far apart the times a video segment is seen at are, ms. */
export const VIDEO_STEP_MS = 250; export const VIDEO_STEP_MS = 250;
@@ -294,7 +295,7 @@ const SETTLED = new Set([
*/ */
export function layerDrawn(scene, layer) { export function layerDrawn(scene, layer) {
if (!layer || layer.isDestroyed?.() || !layer.ready) return false; if (!layer || layer.isDestroyed?.() || !layer.ready) return false;
const tiles = scene.globe?._surface?._tilesToRender; const tiles = globeTilesDrawn(scene.globe);
if (!tiles?.length) return false; if (!tiles?.length) return false;
const bounds = layer.imageryProvider?.rectangle ?? layer.rectangle; const bounds = layer.imageryProvider?.rectangle ?? layer.rectangle;
for (const tile of tiles) { for (const tile of tiles) {
+11
View File
@@ -211,6 +211,17 @@ export function trimGlobeTiles(globe) {
globe?._surface?._tileReplacementQueue?.trimTiles(0); globe?._surface?._tileReplacementQueue?.trimTiles(0);
} }
/**
* The globe tiles the last frame drew, for timed imagery to tell when a
* frame's own imagery is what they draw (`imageryFrames.js`); Cesium says
* only whether every tile has loaded, prefetched layers included.
* @param {object} globe Cesium Globe.
* @returns {object[]} Cesium QuadtreeTiles.
*/
export function globeTilesDrawn(globe) {
return globe?._surface?._tilesToRender ?? [];
}
const NO_CREDITS = Object.freeze([]); const NO_CREDITS = Object.freeze([]);
/** /**
+8
View File
@@ -13,6 +13,7 @@ import {
commandExtents, commandExtents,
creditDisplayContents, creditDisplayContents,
defaultView, defaultView,
globeTilesDrawn,
lastRenderTime, lastRenderTime,
lastSeenCamera, lastSeenCamera,
materialTexture, materialTexture,
@@ -59,6 +60,7 @@ test('every private field the app reaches is still declared by the installed Ces
[ENGINE, 'Scene/View.js', '_cameraClone'], [ENGINE, 'Scene/View.js', '_cameraClone'],
[ENGINE, 'Scene/Scene.js', '_frameState'], [ENGINE, 'Scene/Scene.js', '_frameState'],
[ENGINE, 'Scene/Globe.js', '_surface'], [ENGINE, 'Scene/Globe.js', '_surface'],
[ENGINE, 'Scene/QuadtreePrimitive.js', '_tilesToRender'],
[ENGINE, 'Scene/QuadtreePrimitive.js', '_tileReplacementQueue'], [ENGINE, 'Scene/QuadtreePrimitive.js', '_tileReplacementQueue'],
[ENGINE, 'Scene/CreditDisplay.js', '_staticCredits'], [ENGINE, 'Scene/CreditDisplay.js', '_staticCredits'],
[ENGINE, 'Scene/CreditDisplay.js', '_currentFrameCredits'], [ENGINE, 'Scene/CreditDisplay.js', '_currentFrameCredits'],
@@ -283,3 +285,9 @@ test('trimGlobeTiles empties the globe cache of what the frame did not draw', ()
trimGlobeTiles(undefined); trimGlobeTiles(undefined);
assert.deepEqual(trims, [0]); assert.deepEqual(trims, [0]);
}); });
test('globeTilesDrawn reads the tiles the globe last drew', () => {
const tiles = [{}];
assert.equal(globeTilesDrawn({ _surface: { _tilesToRender: tiles } }), tiles);
assert.deepEqual(globeTilesDrawn(undefined), []);
});