Read the canvas from the renderer in the layers, voice and tools

Files off the Cesium list sized themselves by, listened on and set the
cursor of `viewer.scene.canvas`. They now read `canvasOf(viewer)` from
src/render/rendererOf.js: the bound renderer's canvas, else the viewer's
own, the same element. Recent Imagery's divider moves the split through the
globe port (`globeSplitTarget`, moved from the flood event into
src/ui/imagerySplit.js), and traffic flow passes the viewer to the listed
surface module (`viewerRoadSurface`) instead of reaching for its scene.

The test fakes give their viewers a canvas, and the fake renderers report
it, as the Cesium renderer reports the viewer's.
This commit is contained in:
Sameh Khamis committed 2026-11-07 18:10:39 -08:00
1 parent abe9f97768
commit b19fa56565
49 files changed
+269 -119

No files matched your search

+10
View File
@@ -186,6 +186,16 @@ export function bindRenderer(host, renderer) {
*/
export const rendererOf = (host) => (host && renderers.get(host)) || null;
/**
* The canvas the renderer bound to `host` draws in; with none bound, the
* scene object's own `canvas` (a viewer's), the same element the default
* renderer reports. For sizing by it and listening on it as DOM.
* @param {object|null|undefined} host
* @returns {HTMLCanvasElement|null}
*/
export const canvasOf = (host) =>
rendererOf(host)?.canvas ?? host?.canvas ?? null;
/**
* The camera port of the renderer bound to `host`; with no renderer bound,
* one built over `host` by the provided factory and kept with it while
+14
View File
@@ -3,6 +3,7 @@ import test from 'node:test';
import {
bindRenderer,
cameraOf,
canvasOf,
drawOf,
findCamera,
findCredits,
@@ -27,6 +28,19 @@ test('a scene finds its renderer until it is unbound', () => {
assert.equal(rendererOf(scene), null);
});
test("canvasOf answers with the renderer's canvas, else the host's own", () => {
const own = { id: 'own' };
const drawn = { id: 'drawn' };
const scene = { canvas: own };
assert.equal(canvasOf(scene), own);
assert.equal(canvasOf({}), null);
assert.equal(canvasOf(null), null);
const unbind = bindRenderer(scene, { canvas: drawn });
assert.equal(canvasOf(scene), drawn);
unbind();
assert.equal(canvasOf(scene), own);
});
test('a stale unbind leaves a later binding alone', () => {
const scene = {};
const unbindFirst = bindRenderer(scene, { id: 'first' });