mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
fix(embed): an inline panel's timer frames move the camera, take input and run the clock again
When a host stops animation frames, the panel drew from a timer with the
viewer's render(): the camera's flight and input, the clock's tick, then a
draw if due. Through the frame port it called renderNow(), which on Cesium
only forced a draw, so flights stood still, drags and zooms did nothing
and the clock stopped. renderNow takes {ifDue: true}: one tick of the
loop as its own would run it, drawing only a frame that is due (the
widget's render() on Cesium; the stub's tick without a forced request).
This commit is contained in:
1 parent
f4beb676ae
commit
03a7d8827a
9 files changed
+86
-22
No files matched your search
@@ -103,19 +103,23 @@ export function willDraw(scene, time) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The contract's `renderNow` on `scene`: draw a frame at `time` even when
|
||||
* nothing asked for one, and throw the error Cesium caught and raised on
|
||||
* `renderError` when the frame failed.
|
||||
* @param {object} scene
|
||||
* @param {object} [time] A Cesium JulianDate.
|
||||
* The contract's `renderNow` on `owner`'s scene: draw a frame at the
|
||||
* clock's time even when nothing asked for one, or with `ifDue` run one
|
||||
* frame of the widget's own loop (`render()`: the camera's flight and
|
||||
* input, the clock's tick, then a draw if one is due); throw the error
|
||||
* Cesium caught and raised on `renderError` when the frame failed.
|
||||
* @param {object} owner A Cesium `Viewer` or `CesiumWidget`.
|
||||
* @param {{ifDue?: boolean}} [options]
|
||||
*/
|
||||
export function renderNow(scene, time) {
|
||||
export function renderNow(owner, { ifDue = false } = {}) {
|
||||
const scene = owner.scene;
|
||||
let failure = null;
|
||||
const off = scene.renderError?.addEventListener((_scene, error) => {
|
||||
failure ??= { error };
|
||||
});
|
||||
try {
|
||||
scene.forceRender(time);
|
||||
if (ifDue) owner.render();
|
||||
else scene.forceRender(owner.clock?.currentTime);
|
||||
} finally {
|
||||
off?.();
|
||||
}
|
||||
@@ -259,7 +263,7 @@ export function createSceneFrame(viewer) {
|
||||
viewer.useDefaultRenderLoop = suspended ? false : ownLoop;
|
||||
if (!suspended && !gone()) scene.requestRender();
|
||||
},
|
||||
renderNow: () => renderNow(scene, viewer.clock?.currentTime),
|
||||
renderNow: (options) => renderNow(viewer, options),
|
||||
renderOnce({ timeoutMs } = {}) {
|
||||
if (gone()) return Promise.resolve();
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
Reference in new issue
Block a user