mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Complete the Cesium frame port
The frame port now does everything the contract asks of it on Cesium: preUpdate says whether the tick draws (Cesium's own render test, read live until the tick is over), holds are counted per reason, and suspend, target fps, renderNow and diagnostics are real. Releasing the last hold asks for one more frame. whenSettled also waits until Cesium stops redrawing on its own. Each request or worker task Cesium completes queues a redraw (a terrain picker build after the camera moved, say), which no loading flag shows, so it now waits for quiet frames and then a short stretch in which the loop draws nothing by itself. It is bounded by its timeout, names a stopped loop, and ends on destroy. The app renderer still leaves out the members that steer the loop: the render governor and the page's visibility handling own those settings until they move onto the port. The new frame.prediction check compares the preUpdate answer with what each tick drew.
This commit is contained in:
1 parent
1a9bdd9b63
commit
e6d22e55d7
11 files changed
+842
-55
No files matched your search
@@ -19,8 +19,11 @@ export const CESIUM_CHECKS = new Set([
|
||||
'draw.models',
|
||||
'draw.pick',
|
||||
'draw.sets',
|
||||
'frame.demand',
|
||||
'frame.order',
|
||||
'frame.prediction',
|
||||
'frame.renderOnce',
|
||||
'frame.suspend',
|
||||
'frame.time',
|
||||
'globe.sky',
|
||||
'query.heights',
|
||||
@@ -31,25 +34,24 @@ export const CESIUM_CHECKS = new Set([
|
||||
'renderer.whenSettled',
|
||||
]);
|
||||
|
||||
/** A tick fails the check rather than hang it when the loop has stopped. */
|
||||
const TICK_TIMEOUT_MS = 5000;
|
||||
/** A frame fails the check rather than hang it when frames stop. */
|
||||
const FRAME_TIMEOUT_MS = 5000;
|
||||
|
||||
/**
|
||||
* One tick of the render loop, through the contract: it resolves once the
|
||||
* next tick (drawn or not) has run, so loads and timers progress between
|
||||
* ticks. It asks for no frame itself, so a check's own `requestRender` is
|
||||
* what makes a tick draw.
|
||||
* One frame of the page: it resolves once the render loop's tick for the
|
||||
* next animation frame (drawn or not, or none while suspended) has run, so
|
||||
* loads and timers progress between frames. Cesium's loop asks for its
|
||||
* animation frame before this does, so its tick runs first. It asks for no
|
||||
* render itself: a check's own `requestRender` is what makes a tick draw.
|
||||
*/
|
||||
function nextTick(r) {
|
||||
function nextFrame() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
off();
|
||||
reject(new Error('the render loop did not tick'));
|
||||
}, TICK_TIMEOUT_MS);
|
||||
const off = r.frame.on('preUpdate', () => {
|
||||
off();
|
||||
const timer = setTimeout(
|
||||
() => reject(new Error('no animation frame came')),
|
||||
FRAME_TIMEOUT_MS,
|
||||
);
|
||||
requestAnimationFrame(() => {
|
||||
clearTimeout(timer);
|
||||
// The rest of the tick (render, postRender) runs in the same task.
|
||||
setTimeout(resolve, 0);
|
||||
});
|
||||
});
|
||||
@@ -90,7 +92,7 @@ export function createCesiumHarness({ name = 'cesium', model } = {}) {
|
||||
};
|
||||
return renderer;
|
||||
},
|
||||
frame: nextTick,
|
||||
frame: nextFrame,
|
||||
now: () => performance.now(),
|
||||
toEcef,
|
||||
tolerance: DEFAULT_TOLERANCE,
|
||||
|
||||
Reference in new issue
Block a user