mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Add layer and map credits through the renderer's credits port
The street-level provider credits, the map source credit, the shared inline OpenStreetMap and OpenMapTiles credits and the ALPR provider credit go through the renderer's credits port instead of Cesium's credit display. Their markup has one link each and is read as the port's plain data; the ALPR credit is built as plain data, which the port escapes. src/maps/credits.js and src/layers/streetLevel/credits.js no longer reach Cesium and leave the allow-list. findCredits finds the port as findCamera finds the camera: a Cesium viewer of a caller's own, with no renderer bound, gets a credits port over its own credit display, so the public entries keep their attribution. A port built that way is released, not disposed, when a renderer binds later, and a credit let go after its viewer is destroyed leaves the display alone. The per-layer data credits and the transit and event credits stay on Cesium's display: their markup carries several links each, which the contract's credit cannot hold.
This commit is contained in:
1 parent
979e2213b9
commit
765a0db094
26 files changed
+418
-142
No files matched your search
@@ -4,7 +4,9 @@ import {
|
||||
bindRenderer,
|
||||
cameraOf,
|
||||
findCamera,
|
||||
findCredits,
|
||||
provideUnboundCamera,
|
||||
provideUnboundCredits,
|
||||
rendererOf,
|
||||
} from './rendererOf.js';
|
||||
|
||||
@@ -87,3 +89,44 @@ test('a destroyed scene gets no built camera, and lets go of the one it had', (t
|
||||
assert.throws(() => cameraOf(viewer), /destroyed/);
|
||||
assert.equal(disposed, 1, 'once');
|
||||
});
|
||||
|
||||
test('with no renderer bound, findCredits builds one port per scene and keeps it working once one is', (t) => {
|
||||
t.after(() => provideUnboundCredits(null));
|
||||
const built = [];
|
||||
provideUnboundCredits((host) => {
|
||||
if (!host.creditDisplay) return null;
|
||||
const entry = { port: { id: built.length }, disposed: 0, released: 0 };
|
||||
entry.dispose = () => (entry.disposed += 1);
|
||||
entry.release = () => (entry.released += 1);
|
||||
built.push(entry);
|
||||
return entry;
|
||||
});
|
||||
const viewer = { creditDisplay: {} };
|
||||
assert.equal(findCredits(viewer), built[0].port);
|
||||
assert.equal(findCredits(viewer), built[0].port, 'kept, not rebuilt');
|
||||
assert.equal(findCredits({}), null, 'nothing to build over');
|
||||
assert.equal(findCredits(null), null);
|
||||
|
||||
const credits = { list: () => [] };
|
||||
const unbind = bindRenderer(viewer, { credits });
|
||||
assert.equal(findCredits(viewer), credits);
|
||||
assert.equal(
|
||||
built[0].disposed,
|
||||
0,
|
||||
'the credits added through the built port stay until their Off',
|
||||
);
|
||||
assert.equal(built[0].released, 1, 'but it stops following the frames');
|
||||
unbind();
|
||||
assert.equal(
|
||||
findCredits(viewer),
|
||||
built[1].port,
|
||||
'unbound again: a fresh one',
|
||||
);
|
||||
|
||||
let destroyed = false;
|
||||
const gone = { creditDisplay: {}, isDestroyed: () => destroyed };
|
||||
const port = findCredits(gone);
|
||||
destroyed = true;
|
||||
assert.equal(findCredits(gone), null);
|
||||
assert.equal(built.find((entry) => entry.port === port).disposed, 1);
|
||||
});
|
||||
Reference in new issue
Block a user