mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Give a viewer with no renderer an effects port, as cameras get
The renderer bridge builds and keeps an effects port over a viewer no renderer is bound to, with a factory the Cesium effects module provides, so visual settings on a caller's own viewer draw their styles, bloom and sharpen as before and give the scene's bloom back when destroyed. The application shell loads the factory; a test checks every export that reaches the effects lookup loads it.
This commit is contained in:
1 parent
6a7905fc49
commit
94b8b0bd30
8 files changed
+333
-64
No files matched your search
@@ -5,8 +5,10 @@ import {
|
||||
cameraOf,
|
||||
findCamera,
|
||||
findCredits,
|
||||
findEffects,
|
||||
provideUnboundCamera,
|
||||
provideUnboundCredits,
|
||||
provideUnboundEffects,
|
||||
rendererOf,
|
||||
} from './rendererOf.js';
|
||||
|
||||
@@ -130,3 +132,36 @@ test('with no renderer bound, findCredits builds one port per scene and keeps it
|
||||
assert.equal(findCredits(gone), null);
|
||||
assert.equal(built.find((entry) => entry.port === port).disposed, 1);
|
||||
});
|
||||
|
||||
test('with no renderer bound, findEffects builds one effects port per scene until a renderer is bound', (t) => {
|
||||
t.after(() => provideUnboundEffects(null));
|
||||
const built = [];
|
||||
provideUnboundEffects((host) => {
|
||||
if (!host.scene) return null;
|
||||
const entry = { port: { id: built.length }, disposed: 0 };
|
||||
entry.dispose = () => (entry.disposed += 1);
|
||||
built.push(entry);
|
||||
return entry;
|
||||
});
|
||||
const viewer = { scene: {} };
|
||||
assert.equal(findEffects(viewer), built[0].port);
|
||||
assert.equal(findEffects(viewer), built[0].port, 'kept, not rebuilt');
|
||||
assert.equal(findEffects({}), null, 'nothing to build over');
|
||||
assert.equal(findEffects(null), null);
|
||||
const effects = { styles() {} };
|
||||
const unbind = bindRenderer(viewer, { effects });
|
||||
assert.equal(built[0].disposed, 1, 'the renderer supersedes the built port');
|
||||
assert.equal(findEffects(viewer), effects);
|
||||
unbind();
|
||||
assert.equal(
|
||||
findEffects(viewer),
|
||||
built[1].port,
|
||||
'unbound again: a fresh one',
|
||||
);
|
||||
let destroyed = false;
|
||||
const gone = { scene: {}, isDestroyed: () => destroyed };
|
||||
findEffects(gone);
|
||||
destroyed = true;
|
||||
assert.equal(findEffects(gone), null);
|
||||
assert.equal(built[2].disposed, 1, 'let go with its scene');
|
||||
});
|
||||
Reference in new issue
Block a user