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

+2 -1
View File
@@ -5,6 +5,7 @@ import { createVoiceCommands } from './commands.js';
import { cameraPoseKey, createPointerTracker } from './pointerContext.js';
import { createPointerPicker } from './pointerPick.js';
import { createReferentRegistry } from './referents.js';
import { canvasOf } from '../render/rendererOf.js';
export * from './realtimeController.js';
const ACTION_NAMES = new Set(GEV_ACTION_SCHEMAS.map((schema) => schema.name));
@@ -32,7 +33,7 @@ export function withToolCatalog(runner, loadCatalog) {
/** Compose the standalone action runner with the voice controls. */
export function initGevVoiceCommands(options) {
const canvas = options.viewer?.scene?.canvas || null;
const canvas = canvasOf(options.viewer);
const cameraKey = () => cameraPoseKey(options.viewer);
// Point-and-ask: the tracker and referents are shared by the runner (which
// resolves 'pointer' and referent:n) and the controls (which snapshot the
+3 -4
View File
@@ -1,5 +1,5 @@
import { pickAt as defaultPickAt } from '../input/dispatcher.js';
import { findCamera } from '../render/rendererOf.js';
import { canvasOf, findCamera } from '../render/rendererOf.js';
import { resolvePickedContext } from '../data/pickedContext.js';
import { cameraPoseKey } from './pointerContext.js';
import * as defaultAnnotationResolver from '../annotations/annotationResolver.js';
@@ -37,9 +37,8 @@ export function createPointerPicker({
pickAt = defaultPickAt,
}) {
return function pickPointer(x, y) {
const scene = viewer?.scene;
const canvas = scene?.canvas;
if (!scene || !canvas) return null;
const canvas = canvasOf(viewer);
if (!canvas) return null;
const width = canvas.clientWidth || canvas.width || 0;
const height = canvas.clientHeight || canvas.height || 0;
if (!width || !height) return null;
+3 -2
View File
@@ -3,6 +3,7 @@ import {
hasStructuredViewIdentity,
} from './realtimeProtocol.js';
import { cameraPoseKey } from './pointerContext.js';
import { canvasOf } from '../render/rendererOf.js';
/** The live viewer's camera pose identity (Cesium-free read). */
function readViewerCameraKey() {
@@ -20,7 +21,7 @@ const VIEWPORT_MAX_ENCODED_BYTES = 200 * 1024;
export async function captureViewportImage() {
const viewer = window.__godsEyeView?.viewer;
const source =
viewer?.scene?.canvas ||
canvasOf(viewer) ||
document.querySelector('#cesiumContainer .cesium-widget canvas');
if (!source || !source.width || !source.height) return null;
// No fresh frame (hidden, or the bounded render wait timed out) → no
@@ -130,7 +131,7 @@ export function pointerCropRect({
*/
async function capturePointerCrop(screenPx) {
const viewer = window.__godsEyeView?.viewer;
const source = viewer?.scene?.canvas;
const source = canvasOf(viewer);
if (!source?.width || !source?.height || !screenPx) return null;
const fresh = await renderFreshPointerFrame(viewer);
if (!fresh) return null;