mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42: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
@@ -202,8 +202,37 @@ test('renderNow throws the error Cesium raises on renderError', () => {
|
||||
if (fail) for (const cb of listeners) cb(scene, failure);
|
||||
},
|
||||
};
|
||||
renderNow(scene);
|
||||
const owner = { scene, clock: { currentTime: 'now' } };
|
||||
renderNow(owner);
|
||||
fail = true;
|
||||
assert.throws(() => renderNow(scene), failure);
|
||||
assert.throws(() => renderNow(owner), failure);
|
||||
assert.equal(listeners.size, 0, 'it stops listening either way');
|
||||
});
|
||||
|
||||
test('renderNow ifDue runs a frame of the widget’s own loop, as its render() does', () => {
|
||||
const listeners = new Set();
|
||||
const failure = new Error('worker failed');
|
||||
const calls = [];
|
||||
let fail = false;
|
||||
const scene = {
|
||||
renderError: {
|
||||
addEventListener: (cb) => (listeners.add(cb), () => listeners.delete(cb)),
|
||||
},
|
||||
forceRender: () => calls.push('forceRender'),
|
||||
};
|
||||
// The widget's render(): the camera's flight and input, the clock's
|
||||
// tick, then a draw if one is due.
|
||||
const owner = {
|
||||
scene,
|
||||
clock: { currentTime: 'now' },
|
||||
render() {
|
||||
calls.push('render');
|
||||
if (fail) for (const cb of listeners) cb(scene, failure);
|
||||
},
|
||||
};
|
||||
renderNow(owner, { ifDue: true });
|
||||
assert.deepEqual(calls, ['render']);
|
||||
fail = true;
|
||||
assert.throws(() => renderNow(owner, { ifDue: true }), failure);
|
||||
assert.equal(listeners.size, 0);
|
||||
});
|
||||
Reference in new issue
Block a user