mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
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:
1 parent
abe9f97768
commit
b19fa56565
49 files changed
+269
-119
No files matched your search
@@ -156,7 +156,12 @@ test('mission hover throttles, clears on motion/hidden, and releases listeners',
|
||||
removeEventListener: (_n, fn) => listeners.delete(fn),
|
||||
};
|
||||
const camera = fakeCameraPort();
|
||||
const viewer = { scene: { canvas: { style: {} } } };
|
||||
const viewer = {
|
||||
get canvas() {
|
||||
return this.scene?.canvas;
|
||||
},
|
||||
scene: { canvas: { style: {} } },
|
||||
};
|
||||
bindRenderer(viewer, { camera: camera.port });
|
||||
const hover = createLaunchHover({
|
||||
viewer,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { isPointerFree } from '../../data/inputOwnership.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { findCamera, findFrame } from '../../render/rendererOf.js';
|
||||
import { canvasOf, findCamera, findFrame } from '../../render/rendererOf.js';
|
||||
|
||||
const HOVER_PICK_INTERVAL_MS = 120;
|
||||
|
||||
@@ -25,8 +25,9 @@ export function createLaunchHover({
|
||||
let pendingPosition = null;
|
||||
let trailingTimer = null;
|
||||
const clearCursor = () => {
|
||||
if (ownsCursor && viewer.scene.canvas.style.cursor === 'pointer')
|
||||
viewer.scene.canvas.style.cursor = '';
|
||||
const canvas = canvasOf(viewer);
|
||||
if (ownsCursor && canvas.style.cursor === 'pointer')
|
||||
canvas.style.cursor = '';
|
||||
ownsCursor = false;
|
||||
};
|
||||
const cancelTrailing = () => {
|
||||
@@ -60,7 +61,7 @@ export function createLaunchHover({
|
||||
const pick = (position, at) => {
|
||||
lastPick = at;
|
||||
if (launchAt(position)) {
|
||||
viewer.scene.canvas.style.cursor = 'pointer';
|
||||
canvasOf(viewer).style.cursor = 'pointer';
|
||||
ownsCursor = true;
|
||||
} else clearCursor();
|
||||
};
|
||||
@@ -215,8 +216,8 @@ export function createLifecycle({
|
||||
parts.selection.stopMissionZoomAnchor();
|
||||
parts.rendering.showMissions(false);
|
||||
parts.orbitRendering.syncMissionOrbitPrimitiveVisibility();
|
||||
if (layerState._viewer?.scene?.canvas)
|
||||
layerState._viewer.scene.canvas.style.cursor = '';
|
||||
const canvas = canvasOf(layerState._viewer);
|
||||
if (canvas) canvas.style.cursor = '';
|
||||
parts.launchPad.hideLaunchPadZone();
|
||||
parts.overlays.hideReplayVehicleOverlay();
|
||||
layerState._selectedLaunchId = null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { WGS84 } from '../../geo/ellipsoid.js';
|
||||
import { dot, magnitude, normalize, toDegrees } from '../../geo/vector.js';
|
||||
import { findQuery } from '../../render/rendererOf.js';
|
||||
import { canvasOf, findQuery } from '../../render/rendererOf.js';
|
||||
import { t, msg } from '../../i18n/index.js';
|
||||
import {
|
||||
createCyberSonarSampler,
|
||||
@@ -489,7 +489,7 @@ export function createOverlays({ state: layerState, services, parts, source }) {
|
||||
hideReplayVehicleOverlay();
|
||||
return null;
|
||||
}
|
||||
const canvas = layerState._viewer.scene.canvas;
|
||||
const canvas = canvasOf(layerState._viewer);
|
||||
if (
|
||||
windowPosition.x < -80 ||
|
||||
windowPosition.y < -100 ||
|
||||
|
||||
@@ -122,7 +122,12 @@ test('the scene chrome renders the overlay in the globe container', async (t) =>
|
||||
|
||||
test('the replay overlay sits where the query port projects the vehicle, facing along its path', async () => {
|
||||
const { bindRenderer } = await import('../../render/rendererOf.js');
|
||||
const viewer = { scene: { canvas: { clientWidth: 800, clientHeight: 600 } } };
|
||||
const viewer = {
|
||||
get canvas() {
|
||||
return this.scene?.canvas;
|
||||
},
|
||||
scene: { canvas: { clientWidth: 800, clientHeight: 600 } },
|
||||
};
|
||||
const projected = [];
|
||||
let behindEye = false;
|
||||
// The path runs along x; the port puts x metres at x pixels, y = 300.
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
vec,
|
||||
} from '../../geo/vector.js';
|
||||
import { MISSION_GLOBE_VIEW_RANGE_M, MISSION_FOCUS_RANGE_M } from './policy.js';
|
||||
import { cameraOf, findCamera } from '../../render/rendererOf.js';
|
||||
import { cameraOf, canvasOf, findCamera } from '../../render/rendererOf.js';
|
||||
|
||||
export function createSelection({
|
||||
state: layerState,
|
||||
@@ -23,7 +23,7 @@ export function createSelection({
|
||||
const { getKeyholeGeometry } = services.geometry;
|
||||
|
||||
function focusFullGlobe(viewer, duration = 2.4) {
|
||||
const canvas = viewer?.scene?.canvas;
|
||||
const canvas = canvasOf(viewer);
|
||||
const height = canvas?.clientHeight || canvas?.height;
|
||||
const width = canvas?.clientWidth || canvas?.width;
|
||||
if (!(width > 0) || !(height > 0)) return;
|
||||
@@ -121,7 +121,7 @@ export function createSelection({
|
||||
const launchPosition = fromDegrees(launch.lon, launch.lat);
|
||||
let range = 18000000;
|
||||
if (orbitPositions?.length > 1) {
|
||||
const canvas = layerState._viewer.scene.canvas;
|
||||
const canvas = canvasOf(layerState._viewer);
|
||||
const fovy = camera.pose().fovy || toRadians(60);
|
||||
const aspect = Math.max(
|
||||
0.1,
|
||||
|
||||
Reference in new issue
Block a user