mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Read the camera verbs' and voice actions' canvas from the renderer
The camera verbs size their keyhole fit by the renderer's canvas and listen on it for the user's input, and the voice actions size their view samples by it, rather than reaching through `viewer.scene`; a viewer with no renderer bound answers with its own canvas, the same element. The test fakes give their viewers a canvas, and a fake camera binding's renderer reports the fake viewer's.
This commit is contained in:
1 parent
20fdfd492e
commit
b47aa5f3de
14 files changed
+46
-9
No files matched your search
+12
-5
@@ -21,7 +21,12 @@ import {
|
||||
toRadians,
|
||||
} from '../geo/index.js';
|
||||
import { sphereFromPoints } from '../geo/sphere.js';
|
||||
import { cameraOf, findCamera, findQuery } from '../render/rendererOf.js';
|
||||
import {
|
||||
cameraOf,
|
||||
findCamera,
|
||||
findQuery,
|
||||
rendererOf,
|
||||
} from '../render/rendererOf.js';
|
||||
import { CITY_POIS } from '../cityPois.js';
|
||||
import { greatCircleKm } from '../geoDistance.js';
|
||||
import {
|
||||
@@ -3965,13 +3970,16 @@ function selectedEntityContext(dataManager) {
|
||||
return summarizeContextRecord(record, { includeProperties: true });
|
||||
}
|
||||
|
||||
/** The canvas the renderer draws in (the viewer's own when none is bound). */
|
||||
const canvasOf = (viewer) => rendererOf(viewer)?.canvas ?? viewer.canvas;
|
||||
|
||||
function visibleEntityContexts(
|
||||
viewer,
|
||||
dataManager,
|
||||
{ layerId = null, limit = 5, target = null } = {},
|
||||
) {
|
||||
const nearbyRecords = [];
|
||||
const canvas = viewer.scene.canvas;
|
||||
const canvas = canvasOf(viewer);
|
||||
const width = canvas.clientWidth || canvas.width || 0;
|
||||
const height = canvas.clientHeight || canvas.height || 0;
|
||||
const centerX = width / 2;
|
||||
@@ -4322,7 +4330,7 @@ function cameraViewSignature(camera) {
|
||||
function getViewTargetCartesian(viewer) {
|
||||
const query = findQuery(viewer);
|
||||
if (!query) return null;
|
||||
const canvas = viewer.scene.canvas;
|
||||
const canvas = canvasOf(viewer);
|
||||
const width = canvas.clientWidth || canvas.width || 0;
|
||||
const height = canvas.clientHeight || canvas.height || 0;
|
||||
const x = width / 2;
|
||||
@@ -4356,8 +4364,7 @@ function getViewTargetCartesian(viewer) {
|
||||
}
|
||||
|
||||
function sampleViewportCartographics(viewer) {
|
||||
const scene = viewer.scene;
|
||||
const canvas = scene.canvas;
|
||||
const canvas = canvasOf(viewer);
|
||||
const width = canvas.clientWidth || canvas.width || 0;
|
||||
const height = canvas.clientHeight || canvas.height || 0;
|
||||
if (!width || !height) return [];
|
||||
|
||||
Reference in new issue
Block a user