mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Fly layer focus flights through the camera port
flyToBounds takes an easing, as flyTo does: in the contract, the Cesium port and the reference recorder, pinned by a new conformance trace. The flights of radio, awareness, CCTV, submarine cables, cyclones, the launch preview, installations, ALPR, street-level framing, recent imagery, weather and world focus now go through the renderer's camera port. Street-level framing cancels its own flight handle rather than whatever flight is current. worldFocus.js no longer reaches Cesium and leaves the allow-list. Layer pose reads stay for each layer's own slice. The local GeoJSON flight stays on Cesium: gods-eye-view/infrastructure is used with plain Cesium viewers that have no renderer bound.
This commit is contained in:
1 parent
46a53bb49c
commit
c5b716b107
31 files changed
+2349
-871
No files matched your search
@@ -26,6 +26,7 @@ import {
|
||||
import { entityRecord, readEntityRecord } from '../../data/entityRecords.js';
|
||||
import { alprMarkers } from './markerState.js';
|
||||
import { heightsFor } from '../../queries/heights.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
export function createAlprPresentation({ state, services, source }) {
|
||||
const { governorRequestRender } = services.render;
|
||||
@@ -534,14 +535,18 @@ export function createAlprPresentation({ state, services, source }) {
|
||||
validAlprGroundHeight(height) ? height : 0,
|
||||
);
|
||||
if (!selectRecord(nearest.id)) return false;
|
||||
camera.flyToBoundingSphere(new Cesium.BoundingSphere(center, 30), {
|
||||
duration: 1.2,
|
||||
offset: new Cesium.HeadingPitchRange(
|
||||
camera.heading || 0,
|
||||
-Math.PI / 4,
|
||||
800,
|
||||
),
|
||||
});
|
||||
const port = cameraOf(state.viewer);
|
||||
port.flyToBounds(
|
||||
{ center, radius: 30 },
|
||||
{
|
||||
durationS: 1.2,
|
||||
offset: {
|
||||
heading: port.pose().heading || 0,
|
||||
pitch: -Math.PI / 4,
|
||||
range: 800,
|
||||
},
|
||||
},
|
||||
);
|
||||
governorRequestRender('alpr-focus');
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { VESSEL_FOCUS_RADIUS_M } from './policy.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
export function createFocus({ state: layerState, services, parts, source }) {
|
||||
const flightsLayer = services.flights;
|
||||
@@ -45,9 +46,9 @@ export function createFocus({ state: layerState, services, parts, source }) {
|
||||
)
|
||||
return true;
|
||||
announceNavigationAuthority('context-vessel-focus');
|
||||
layerState.viewer.camera.flyToBoundingSphere(
|
||||
new Cesium.BoundingSphere(vessel.position, VESSEL_FOCUS_RADIUS_M),
|
||||
{ duration: 1.4 },
|
||||
cameraOf(layerState.viewer).flyToBounds(
|
||||
{ center: vessel.position, radius: VESSEL_FOCUS_RADIUS_M },
|
||||
{ durationS: 1.4 },
|
||||
);
|
||||
return true;
|
||||
}
|
||||
@@ -180,9 +181,9 @@ export function createFocus({ state: layerState, services, parts, source }) {
|
||||
announceNavigationAuthority('context-vessel-autofocus', {
|
||||
cancelPendingSelection: false,
|
||||
});
|
||||
layerState.viewer.camera.flyToBoundingSphere(
|
||||
new Cesium.BoundingSphere(vessel.position, VESSEL_FOCUS_RADIUS_M),
|
||||
{ duration: 1.6 },
|
||||
cameraOf(layerState.viewer).flyToBounds(
|
||||
{ center: vessel.position, radius: VESSEL_FOCUS_RADIUS_M },
|
||||
{ durationS: 1.6 },
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { CCTV_FOCUS_RESULT } from './policy.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
export function createNavigation({
|
||||
state: layerState,
|
||||
@@ -59,19 +60,16 @@ export function createNavigation({
|
||||
}
|
||||
const { camera } = record;
|
||||
const range = Math.max(280, camera.rangeM * 1.18);
|
||||
viewer.camera.flyToBoundingSphere(
|
||||
new Cesium.BoundingSphere(
|
||||
record.position,
|
||||
Math.max(40, camera.rangeM * 0.36),
|
||||
),
|
||||
cameraOf(viewer).flyToBounds(
|
||||
{ center: record.position, radius: Math.max(40, camera.rangeM * 0.36) },
|
||||
{
|
||||
offset: new Cesium.HeadingPitchRange(
|
||||
parts.model.toRad(camera.headingDeg),
|
||||
parts.model.toRad(-22),
|
||||
offset: {
|
||||
heading: parts.model.toRad(camera.headingDeg),
|
||||
pitch: parts.model.toRad(-22),
|
||||
range,
|
||||
),
|
||||
duration: Math.max(0.2, duration || 0),
|
||||
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
|
||||
},
|
||||
durationS: Math.max(0.2, duration || 0),
|
||||
easing: 'cubicInOut',
|
||||
},
|
||||
);
|
||||
return CCTV_FOCUS_RESULT.FOCUSED;
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
translateKnown,
|
||||
} from '../../i18n/index.js';
|
||||
import { formatQuantity } from '../../ui/unitLabels.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
// "10-12 15:00 UTC" never breaks across lines: no-break spaces, and a word
|
||||
// joiner after the hyphen (JetBrains Mono has no U+2011 non-breaking hyphen).
|
||||
@@ -319,12 +320,15 @@ export function createCyclonesLayer({
|
||||
selectedId !== storm.id
|
||||
)
|
||||
return;
|
||||
return viewer.camera.flyToBoundingSphere(sphere, {
|
||||
duration: matchMedia?.('(prefers-reduced-motion: reduce)')
|
||||
?.matches
|
||||
? 0
|
||||
: 1.4,
|
||||
});
|
||||
cameraOf(viewer).flyToBounds(
|
||||
{ center: sphere.center, radius: sphere.radius },
|
||||
{
|
||||
durationS: matchMedia?.('(prefers-reduced-motion: reduce)')
|
||||
?.matches
|
||||
? 0
|
||||
: 1.4,
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from '../../data/inputOwnership.js';
|
||||
import { isOwnedByOtherLayer } from '../../data/pickRegistry.js';
|
||||
import { fakeInput } from '../../input/testDoubles.mjs';
|
||||
import { bindFakeCesiumCamera } from '../../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
/** Record each click subscription the layer makes, as the old handler fakes did. */
|
||||
function recordHandlers(viewer, handlers) {
|
||||
@@ -120,6 +121,7 @@ test('map selection yields to pointer owners and owns only its enabled handler',
|
||||
},
|
||||
},
|
||||
};
|
||||
bindFakeCesiumCamera(viewer);
|
||||
recordHandlers(viewer, handlers);
|
||||
layer.init(viewer);
|
||||
layer.setRowControlsListener(() => notices++);
|
||||
@@ -360,7 +362,10 @@ function harness(
|
||||
setSelection(id) {
|
||||
selection = id;
|
||||
},
|
||||
getFocusSphere: () => ({ radius: 500000 }),
|
||||
getFocusSphere: () => ({
|
||||
center: { x: 6378137, y: 0, z: 0 },
|
||||
radius: 500000,
|
||||
}),
|
||||
clear() {
|
||||
cleared++;
|
||||
},
|
||||
@@ -384,6 +389,7 @@ function harness(
|
||||
navigation.push({ sphere, options }),
|
||||
},
|
||||
};
|
||||
bindFakeCesiumCamera(viewer);
|
||||
layer.init(viewer);
|
||||
layer.attachShellServices({
|
||||
runNavigation: (fn) => {
|
||||
|
||||
Vendored
+11
-10
@@ -6,6 +6,7 @@ import {
|
||||
ANCHOR_REFRESH_M,
|
||||
} from './policy.js';
|
||||
import { formatNumber, t, tn } from '../../i18n/index.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
// installationFeedback.js is shared with the HUD (src/loadingFeedback.js) and
|
||||
// hands back msg()-marked English plus values; getStats translates them here.
|
||||
@@ -175,16 +176,16 @@ export function createControls({ state: layerState, services, parts, source }) {
|
||||
// No camera flight without a real selection: a flight plus a stale subject
|
||||
// reads as success to Context navigation and strands NEXT on this item.
|
||||
if (!parts.selection.selectRecord(record.id)) return false;
|
||||
layerState.viewer.camera.flyToBoundingSphere(
|
||||
new Cesium.BoundingSphere(
|
||||
Cesium.Cartesian3.fromDegrees(
|
||||
record.longitude,
|
||||
record.latitude,
|
||||
parts.rendering.installationSurfaceHeightM(record),
|
||||
),
|
||||
18000,
|
||||
),
|
||||
{ duration: 1.4 },
|
||||
cameraOf(layerState.viewer).flyToBounds(
|
||||
{
|
||||
center: {
|
||||
lon: record.longitude,
|
||||
lat: record.latitude,
|
||||
height: parts.rendering.installationSurfaceHeightM(record),
|
||||
},
|
||||
radius: 18000,
|
||||
},
|
||||
{ durationS: 1.4 },
|
||||
);
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
import {
|
||||
SATELLITE_STANDALONE_DEFAULTS,
|
||||
LAUNCH_PAD_ZONE_MAX_CAMERA_HEIGHT_M,
|
||||
@@ -228,17 +229,12 @@ export function createPolicyHelpers({
|
||||
const range = parts.panel.missionHoverPreviewRange(
|
||||
layerState._viewer.camera.positionCartographic?.height,
|
||||
);
|
||||
const position = Cesium.Cartesian3.fromDegrees(launch.lon, launch.lat);
|
||||
layerState._viewer.camera.flyToBoundingSphere(
|
||||
new Cesium.BoundingSphere(position, 0),
|
||||
cameraOf(layerState._viewer).flyToBounds(
|
||||
{ center: { lon: launch.lon, lat: launch.lat }, radius: 0 },
|
||||
{
|
||||
offset: new Cesium.HeadingPitchRange(
|
||||
0,
|
||||
-Cesium.Math.PI_OVER_TWO,
|
||||
range,
|
||||
),
|
||||
duration: 0.8,
|
||||
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
|
||||
offset: { heading: 0, pitch: -Cesium.Math.PI_OVER_TWO, range },
|
||||
durationS: 0.8,
|
||||
easing: 'cubicInOut',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
GLOBAL_RADIO_ALTITUDE_M,
|
||||
RADIO_GLOBE_RECENTER_MAX_HEIGHT_M,
|
||||
} from './policy.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
export function createNavigation({
|
||||
state: layerState,
|
||||
@@ -229,7 +230,7 @@ export function createNavigation({
|
||||
)
|
||||
return;
|
||||
layerState._activeRadioCameraFlight = null;
|
||||
layerState._viewer.camera.cancelFlight();
|
||||
cameraOf(layerState._viewer).cancelFlight();
|
||||
}
|
||||
|
||||
function invalidateRadioCameraNavigation() {
|
||||
@@ -247,7 +248,7 @@ export function createNavigation({
|
||||
);
|
||||
}
|
||||
|
||||
function startRadioCameraFlight(navigation, options, onComplete) {
|
||||
function startRadioCameraFlight(navigation, flight, onComplete) {
|
||||
if (!radioCameraNavigationIsCurrent(navigation)) return false;
|
||||
const token = ++layerState._radioCameraFlightSequence;
|
||||
layerState._activeRadioCameraFlight = {
|
||||
@@ -260,10 +261,10 @@ export function createNavigation({
|
||||
if (completed && radioCameraNavigationIsCurrent(navigation))
|
||||
onComplete?.();
|
||||
};
|
||||
layerState._viewer.camera.flyTo({
|
||||
...options,
|
||||
complete: () => finish(true),
|
||||
cancel: () => finish(false),
|
||||
cameraOf(layerState._viewer).flyTo(flight.destination, {
|
||||
...flight.options,
|
||||
onComplete: () => finish(true),
|
||||
onCancel: () => finish(false),
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@@ -280,17 +281,15 @@ export function createNavigation({
|
||||
return startRadioCameraFlight(
|
||||
navigation,
|
||||
{
|
||||
destination: Cesium.Cartesian3.fromDegrees(
|
||||
plan.lon,
|
||||
plan.lat,
|
||||
plan.height,
|
||||
),
|
||||
orientation: {
|
||||
heading: plan.heading,
|
||||
pitch: plan.pitch,
|
||||
roll: plan.roll,
|
||||
destination: { lon: plan.lon, lat: plan.lat, height: plan.height },
|
||||
options: {
|
||||
orientation: {
|
||||
heading: plan.heading,
|
||||
pitch: plan.pitch,
|
||||
roll: plan.roll,
|
||||
},
|
||||
durationS: navigation.duration,
|
||||
},
|
||||
duration: navigation.duration,
|
||||
},
|
||||
() => {
|
||||
navigation.phase = 'settled';
|
||||
@@ -340,13 +339,15 @@ export function createNavigation({
|
||||
activeNavigation,
|
||||
{
|
||||
destination: activeNavigation.recenterPlan.destination,
|
||||
orientation: {
|
||||
heading: activeNavigation.cameraState.heading,
|
||||
pitch: activeNavigation.cameraState.pitch,
|
||||
roll: activeNavigation.cameraState.roll,
|
||||
options: {
|
||||
orientation: {
|
||||
heading: activeNavigation.cameraState.heading,
|
||||
pitch: activeNavigation.cameraState.pitch,
|
||||
roll: activeNavigation.cameraState.roll,
|
||||
},
|
||||
durationS: recenterDuration,
|
||||
easing: 'cubicInOut',
|
||||
},
|
||||
duration: recenterDuration,
|
||||
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
|
||||
},
|
||||
() => {
|
||||
activeNavigation.recentered = true;
|
||||
@@ -363,14 +364,10 @@ export function createNavigation({
|
||||
if (!station || !radioCameraNavigationAllowed(layerState._viewer))
|
||||
return false;
|
||||
cancelActiveRadioCameraFlight();
|
||||
layerState._viewer.camera.flyTo({
|
||||
destination: Cesium.Cartesian3.fromDegrees(
|
||||
station.lon,
|
||||
station.lat,
|
||||
85_000,
|
||||
),
|
||||
duration: 1.1,
|
||||
});
|
||||
cameraOf(layerState._viewer).flyTo(
|
||||
{ lon: station.lon, lat: station.lat, height: 85_000 },
|
||||
{ durationS: 1.1 },
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -34,6 +34,7 @@ import {
|
||||
} from './model.js';
|
||||
import { msg, t } from '../../i18n/index.js';
|
||||
import { READOUT_WORDS, displayDay, displayMetres } from './display.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
/**
|
||||
* Quiet time after the last arrow key before the focused day previews, so a
|
||||
@@ -987,15 +988,17 @@ export function createRecentImageryLayer({
|
||||
height: canvas?.clientHeight,
|
||||
fovy: camera.frustum?.fovy,
|
||||
});
|
||||
camera.flyTo({
|
||||
destination: ellipsoid.cartographicToCartesian({
|
||||
cameraOf(_viewer).flyTo(
|
||||
ellipsoid.cartographicToCartesian({
|
||||
longitude: toRadians(target.lon),
|
||||
latitude: toRadians(target.lat),
|
||||
height,
|
||||
}),
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
duration: ZOOM_FIT_SECONDS,
|
||||
});
|
||||
{
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
durationS: ZOOM_FIT_SECONDS,
|
||||
},
|
||||
);
|
||||
return height;
|
||||
},
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import test from 'node:test';
|
||||
import * as Cesium from 'cesium';
|
||||
import assert from 'node:assert/strict';
|
||||
import { NO_IMAGERY_HOST } from '../../maps/imageryHost.js';
|
||||
import { acquireImageryComparison } from '../../maps/imageryComparison.js';
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
manualTimers,
|
||||
settle,
|
||||
} from './testDoubles.mjs';
|
||||
import { bindFakeCesiumCamera } from '../../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
const NOW = new Date('2026-09-21T15:00:00Z');
|
||||
const LINK_BOX = {
|
||||
@@ -133,6 +135,7 @@ function fixture({
|
||||
});
|
||||
if (viirs) layer.setSources({ viirs: true });
|
||||
const viewer = { camera: {} };
|
||||
bindFakeCesiumCamera(viewer);
|
||||
const reasons = [];
|
||||
layer.subscribe((snapshot, reason) => reasons.push(reason));
|
||||
layer.init(viewer);
|
||||
@@ -966,6 +969,8 @@ test('USE VIEW takes the camera rectangle and refuses a view over the cap instea
|
||||
test('ZOOM IN: an oversized box or view flies top-down to its centre at the height whose view is 400 km wide', () => {
|
||||
const f = fixture();
|
||||
const flights = [];
|
||||
const landing = (i) =>
|
||||
Cesium.Ellipsoid.WGS84.cartesianToCartographic(flights[i].destination);
|
||||
const deg = (rad) => (rad * 180) / Math.PI;
|
||||
const rad = (value) => (value * Math.PI) / 180;
|
||||
// A 1000 × 500 canvas with a 60° horizontal FOV.
|
||||
@@ -976,7 +981,8 @@ test('ZOOM IN: an oversized box or view flies top-down to its centre at the heig
|
||||
scene: {
|
||||
canvas: { clientWidth: 1000, clientHeight: 500 },
|
||||
ellipsoid: {
|
||||
cartographicToCartesian: (c) => ({ ...c, cartesian: true }),
|
||||
cartographicToCartesian: (c) =>
|
||||
Cesium.Ellipsoid.WGS84.cartographicToCartesian(c),
|
||||
cartesianToCartographic: (c) => c && { ...c },
|
||||
},
|
||||
},
|
||||
@@ -999,9 +1005,9 @@ test('ZOOM IN: an oversized box or view flies top-down to its centre at the heig
|
||||
assert.ok(Math.abs(height - expected) < 1e-6, String(height));
|
||||
assert.equal(flights.length, 1);
|
||||
const [flight] = flights;
|
||||
assert.ok(Math.abs(deg(flight.destination.longitude) - 10) < 1e-9);
|
||||
assert.ok(Math.abs(deg(flight.destination.latitude) - 10) < 1e-9);
|
||||
assert.equal(flight.destination.height, height);
|
||||
assert.ok(Math.abs(deg(landing(0).longitude) - 10) < 1e-9);
|
||||
assert.ok(Math.abs(deg(landing(0).latitude) - 10) < 1e-9);
|
||||
assert.ok(Math.abs(landing(0).height - height) < 1e-6);
|
||||
assert.deepEqual(flight.orientation, {
|
||||
heading: 0,
|
||||
pitch: -Math.PI / 2,
|
||||
@@ -1019,14 +1025,14 @@ test('ZOOM IN: an oversized box or view flies top-down to its centre at the heig
|
||||
assert.equal(f.layer.useCurrentView(), false);
|
||||
assert.equal(f.snap().zoomToFit, true);
|
||||
f.layer.zoomToFit();
|
||||
assert.ok(Math.abs(deg(flights[1].destination.longitude) + 97) < 1e-9);
|
||||
assert.ok(Math.abs(deg(flights[1].destination.latitude) - 31) < 1e-9);
|
||||
assert.ok(Math.abs(deg(landing(1).longitude) + 97) < 1e-9);
|
||||
assert.ok(Math.abs(deg(landing(1).latitude) - 31) < 1e-9);
|
||||
// Sky at the centre: the view rectangle's centre instead.
|
||||
centreHit = null;
|
||||
f.layer.useCurrentView();
|
||||
f.layer.zoomToFit();
|
||||
assert.ok(Math.abs(deg(flights[2].destination.longitude) + 98) < 1e-9);
|
||||
assert.ok(Math.abs(deg(flights[2].destination.latitude) - 30) < 1e-9);
|
||||
assert.ok(Math.abs(deg(landing(2).longitude) + 98) < 1e-9);
|
||||
assert.ok(Math.abs(deg(landing(2).latitude) - 30) < 1e-9);
|
||||
// The box tool's own oversized drag carries its box.
|
||||
f.layer.reportBoxRefusal('Box is 2,226 km wide · limit 1,000 km', {
|
||||
west: 0,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { plausibleSurfaceHeight, sampledSurfaceHeight } from './view.js';
|
||||
import { heightsFor } from '../../queries/heights.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
/** Fly the globe camera once to frame a photo after it opens. */
|
||||
export function createCameraFraming({ state }) {
|
||||
@@ -49,36 +50,37 @@ export function createCameraFraming({ state }) {
|
||||
return;
|
||||
const ground = groundHeightAt(position.lon, position.lat, altitude);
|
||||
// Owned before the call: starting it cancels the previous flight (ours
|
||||
// included) synchronously, and a zero-length one completes at once.
|
||||
// included), and a zero-length one completes inside the call.
|
||||
const current = {};
|
||||
flight = current;
|
||||
const release = () => {
|
||||
if (flight === current) flight = null;
|
||||
};
|
||||
state.viewer.camera.flyToBoundingSphere(
|
||||
new Cesium.BoundingSphere(
|
||||
Cesium.Cartesian3.fromDegrees(position.lon, position.lat, ground + 2),
|
||||
4,
|
||||
),
|
||||
const started = cameraOf(state.viewer).flyToBounds(
|
||||
{
|
||||
offset: new Cesium.HeadingPitchRange(
|
||||
Cesium.Math.toRadians(bearing || 0),
|
||||
Cesium.Math.toRadians(-32),
|
||||
140,
|
||||
),
|
||||
duration: 1.6,
|
||||
complete: release,
|
||||
cancel: release,
|
||||
center: { lon: position.lon, lat: position.lat, height: ground + 2 },
|
||||
radius: 4,
|
||||
},
|
||||
{
|
||||
offset: {
|
||||
heading: Cesium.Math.toRadians(bearing || 0),
|
||||
pitch: Cesium.Math.toRadians(-32),
|
||||
range: 140,
|
||||
},
|
||||
durationS: 1.6,
|
||||
onComplete: release,
|
||||
onCancel: release,
|
||||
},
|
||||
);
|
||||
if (flight === current) current.handle = started;
|
||||
}
|
||||
|
||||
/** Stop our framing flight if it is still in the air; another feature's flight is left alone. */
|
||||
function cancel() {
|
||||
if (!flight) return;
|
||||
// Give up ownership first: cancelFlight delivers `cancel` synchronously.
|
||||
const { handle } = flight;
|
||||
flight = null;
|
||||
state.viewer?.camera?.cancelFlight?.();
|
||||
handle?.cancel();
|
||||
}
|
||||
|
||||
return { attachNavigation, begin, frame, cancel };
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import * as Cesium from 'cesium';
|
||||
import { bindFakeCesiumCamera } from '../../testSupport/fakeCameraPort.mjs';
|
||||
import { createStreetLevelLayer } from './index.js';
|
||||
import { MAPILLARY_CREDIT_HTML } from './providers/mapillary/policy.js';
|
||||
import { createMapillaryProvider } from './providers/mapillary/index.js';
|
||||
@@ -326,7 +327,7 @@ function fakeViewer() {
|
||||
disableRootEvents: true,
|
||||
onwheel: null,
|
||||
});
|
||||
return {
|
||||
return bindFakeCesiumCamera({
|
||||
credits,
|
||||
flights,
|
||||
scene: {
|
||||
@@ -358,7 +359,7 @@ function fakeViewer() {
|
||||
if (at !== -1) credits.splice(at, 1);
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** A layer over `providers`, initialised and enabled on a stand-in viewer. */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { cablePicks } from './pickState.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
export function createInteraction({ state, inputFor }) {
|
||||
function registerPickEntity(entity, info) {
|
||||
@@ -45,22 +46,20 @@ export function createInteraction({ state, inputFor }) {
|
||||
|
||||
function flyToReference(viewer, reference) {
|
||||
if (!viewer || !reference) return;
|
||||
const destination = Cesium.Cartesian3.fromDegrees(
|
||||
reference.lon,
|
||||
reference.lat,
|
||||
6500,
|
||||
);
|
||||
viewer.camera.cancelFlight();
|
||||
viewer.camera.flyTo({
|
||||
destination,
|
||||
orientation: {
|
||||
heading: viewer.camera.heading || 0,
|
||||
pitch: Cesium.Math.toRadians(-52),
|
||||
roll: 0,
|
||||
const camera = cameraOf(viewer);
|
||||
camera.cancelFlight();
|
||||
camera.flyTo(
|
||||
{ lon: reference.lon, lat: reference.lat, height: 6500 },
|
||||
{
|
||||
orientation: {
|
||||
heading: camera.pose().heading || 0,
|
||||
pitch: Cesium.Math.toRadians(-52),
|
||||
roll: 0,
|
||||
},
|
||||
durationS: 1.35,
|
||||
easing: 'cubicInOut',
|
||||
},
|
||||
duration: 1.35,
|
||||
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
|
||||
});
|
||||
);
|
||||
}
|
||||
return {
|
||||
registerPickEntity,
|
||||
|
||||
@@ -7,6 +7,7 @@ import { createWeatherRendering } from './rendering.js';
|
||||
import { weatherDisplay, insideExtent, escapeCreditText } from './display.js';
|
||||
import { createShellCesium, createShellScene } from './shellFixture.mjs';
|
||||
import { formatScaleLabel } from '../../ui/unitLabels.js';
|
||||
import { bindFakeCesiumCamera } from '../../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
const times = ['2026-09-15T20:00:00.000Z', '2026-09-15T20:05:00.000Z'];
|
||||
const base = {
|
||||
@@ -58,18 +59,22 @@ async function shownLayer(id, manifest, params, view = {}) {
|
||||
getDiagnostics: () => ({ time, loading: false, error: null }),
|
||||
}),
|
||||
});
|
||||
layer.init({
|
||||
camera: {
|
||||
moveEnd: { addEventListener: () => () => {} },
|
||||
flyTo: ({ destination }) => flights.push(destination),
|
||||
pickEllipsoid: () =>
|
||||
view.center ? Cesium.Cartesian3.fromDegrees(...view.center) : undefined,
|
||||
},
|
||||
scene: {
|
||||
canvas: { clientWidth: 800, clientHeight: 600 },
|
||||
globe: { ellipsoid: Cesium.Ellipsoid.WGS84 },
|
||||
},
|
||||
});
|
||||
layer.init(
|
||||
bindFakeCesiumCamera({
|
||||
camera: {
|
||||
moveEnd: { addEventListener: () => () => {} },
|
||||
flyTo: ({ destination }) => flights.push(destination),
|
||||
pickEllipsoid: () =>
|
||||
view.center
|
||||
? Cesium.Cartesian3.fromDegrees(...view.center)
|
||||
: undefined,
|
||||
},
|
||||
scene: {
|
||||
canvas: { clientWidth: 800, clientHeight: 600 },
|
||||
globe: { ellipsoid: Cesium.Ellipsoid.WGS84 },
|
||||
},
|
||||
}),
|
||||
);
|
||||
if (params) layer.setParams(params);
|
||||
layer.enable();
|
||||
await layer.update();
|
||||
@@ -638,6 +643,7 @@ function globeViewer() {
|
||||
requestRender() {},
|
||||
},
|
||||
};
|
||||
bindFakeCesiumCamera(viewer);
|
||||
class Provider {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
|
||||
+14
-11
@@ -10,6 +10,7 @@ import {
|
||||
} from './clock.js';
|
||||
import { formatUtcDayMonth, t, msg } from '../../i18n/index.js';
|
||||
import { formatScaleLabel } from '../../ui/unitLabels.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
|
||||
/**
|
||||
* A stored (English) failure in the language. HTTP failures from source.js
|
||||
@@ -475,17 +476,19 @@ export function createWeatherLayer({
|
||||
(lightning
|
||||
? { west: 110, south: -25, east: 0, north: 80 }
|
||||
: manifest.bounds);
|
||||
runNavigation(() =>
|
||||
viewer.camera.flyTo({
|
||||
destination: cesium.Rectangle.fromDegrees(
|
||||
b.west,
|
||||
b.south,
|
||||
b.east,
|
||||
b.north,
|
||||
),
|
||||
duration: motion?.matches ? 0 : 1.4,
|
||||
}),
|
||||
);
|
||||
runNavigation(() => {
|
||||
cameraOf(viewer).flyTo(
|
||||
{
|
||||
rect: {
|
||||
west: b.west,
|
||||
south: b.south,
|
||||
east: b.east,
|
||||
north: b.north,
|
||||
},
|
||||
},
|
||||
{ durationS: motion?.matches ? 0 : 1.4 },
|
||||
);
|
||||
});
|
||||
}
|
||||
if (clock && enabled) {
|
||||
if (params.play === true) void clock.togglePlay();
|
||||
|
||||
Reference in new issue
Block a user