mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Read what the camera follows through one module
src/data/followed.js answers what the camera follows: the camera port's target, or the entity a layer still tracks itself, seen through the same fields. Ownership checks, render holds, guards, voice actions, the CCTV pacing and the navigation release paths read it instead of Cesium's trackedEntity, so they keep working when layers follow through the port. The release paths stop following, cancel the flight and release the camera through the port. The rotate refusal names the followed target by its name or label title.
This commit is contained in:
1 parent
6c215f93a9
commit
7eec2f828c
29 files changed
+404
-97
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { isFollowing } from '../../data/followed.js';
|
||||
import { isUnavailableCapability } from '../../sources/capability.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
@@ -369,13 +370,12 @@ export function createAlprCamerasLayer({ source, services } = {}) {
|
||||
{
|
||||
id: 'find-camera',
|
||||
label: t('SHOW NEAREST'),
|
||||
title: state.viewer?.trackedEntity
|
||||
title: isFollowing(state.viewer)
|
||||
? t(
|
||||
'Stop following the current object before navigating to a camera',
|
||||
)
|
||||
: t('Move to the nearest loaded camera and show its details'),
|
||||
disabled:
|
||||
!state.enabled || !count || Boolean(state.viewer?.trackedEntity),
|
||||
disabled: !state.enabled || !count || isFollowing(state.viewer),
|
||||
onClick: focusNearest,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isFollowing } from '../../data/followed.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import {
|
||||
@@ -499,7 +500,7 @@ export function createAlprPresentation({ state, services, source }) {
|
||||
|
||||
function focusNearest() {
|
||||
const camera = state.viewer?.camera;
|
||||
if (!state.enabled || !camera?.positionWC || state.viewer.trackedEntity)
|
||||
if (!state.enabled || !camera?.positionWC || isFollowing(state.viewer))
|
||||
return false;
|
||||
let nearest = null,
|
||||
distance = Infinity;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { followedOf } from '../../data/followed.js';
|
||||
import {
|
||||
AWARENESS_RADIUS_M,
|
||||
AWARENESS_RELATIONSHIP,
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
SUBJECT_PRESENCE,
|
||||
AWARENESS_PAGE_SIZE,
|
||||
} from './policy.js';
|
||||
import { readEntityRecord } from '../../data/entityRecords.js';
|
||||
|
||||
// coverageLabel is machine-composed English from installations/controls.js
|
||||
// (pinned by src/data/militaryInstallations.test.mjs); translate the known
|
||||
@@ -192,9 +192,7 @@ export function createSubject({ state: layerState, services, parts, source }) {
|
||||
*/
|
||||
|
||||
function currentTrackedFlightSubject() {
|
||||
const trackedKey = normalizeContextId(
|
||||
readEntityRecord(layerState.viewer?.trackedEntity)?.trackedId,
|
||||
);
|
||||
const trackedKey = normalizeContextId(followedOf(layerState.viewer)?.key);
|
||||
if (!trackedKey) return null;
|
||||
const subjects = [
|
||||
flightsLayer.getTrackedSubject?.(),
|
||||
@@ -261,19 +259,15 @@ export function createSubject({ state: layerState, services, parts, source }) {
|
||||
) {
|
||||
if (!subject?.position) return null;
|
||||
if (subject.layerId === 'flights' || subject.layerId === 'military') {
|
||||
const trackedPosition = readEntityRecord(
|
||||
layerState.viewer?.trackedEntity,
|
||||
)?.displayPosition?.();
|
||||
const followed = followedOf(layerState.viewer);
|
||||
const trackedPosition = followed?.displayPosition?.();
|
||||
if (trackedPosition) {
|
||||
return {
|
||||
position: Cesium.Cartesian3.clone(trackedPosition),
|
||||
// Only the follow camera's own contact proves presence this way; a
|
||||
// different tracked entity says nothing about this subject.
|
||||
presence:
|
||||
String(
|
||||
readEntityRecord(layerState.viewer?.trackedEntity)?.trackedId ||
|
||||
'',
|
||||
) === subjectKey(subject)
|
||||
String(followed?.key || '') === subjectKey(subject)
|
||||
? SUBJECT_PRESENCE.LIVE
|
||||
: SUBJECT_PRESENCE.UNCHECKED,
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { followedOf } from '../../data/followed.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
GEO_PROGRESS_NOTIFY_INTERVAL_MS,
|
||||
@@ -125,16 +126,16 @@ export function createGeometryQueue({
|
||||
* throughput without restarting the queue.
|
||||
*
|
||||
* @param {Object} [ownership={}] Current camera-ownership state.
|
||||
* @param {*} [ownership.trackedEntity] Cesium tracked entity, if any.
|
||||
* @param {*} [ownership.followed] What the camera follows, if anything.
|
||||
* @param {boolean} [ownership.cockpitActive] Whether cockpit owns the camera.
|
||||
* @returns {{ batchSize: number, delayMs: number }} Drain pacing.
|
||||
*/
|
||||
|
||||
function cctvGeometryDrainPacing({
|
||||
trackedEntity = null,
|
||||
followed = null,
|
||||
cockpitActive = false,
|
||||
} = {}) {
|
||||
if (trackedEntity || cockpitActive) {
|
||||
if (followed || cockpitActive) {
|
||||
return {
|
||||
batchSize: GEO_TRACKING_BATCH_SIZE,
|
||||
delayMs: GEO_TRACKING_BATCH_DELAY_MS,
|
||||
@@ -213,7 +214,7 @@ export function createGeometryQueue({
|
||||
const batchResult = processCctvGeometryDrainBatch({
|
||||
queue: layerState._geoQueue,
|
||||
readOwnership: () => ({
|
||||
trackedEntity: layerState._viewer.trackedEntity,
|
||||
followed: followedOf(layerState._viewer),
|
||||
cockpitActive:
|
||||
typeof document !== 'undefined' &&
|
||||
document.body?.classList.contains('cockpit-mode'),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isFollowing } from '../../data/followed.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { CCTV_FOCUS_RESULT } from './policy.js';
|
||||
import { cameraOf } from '../../render/cesium/camera.js';
|
||||
@@ -52,7 +53,7 @@ export function createNavigation({
|
||||
console.debug('[Data:CCTV] focus ignored while cockpit owns the camera');
|
||||
return CCTV_FOCUS_RESULT.COCKPIT_ACTIVE;
|
||||
}
|
||||
if (viewer.trackedEntity) {
|
||||
if (isFollowing(viewer)) {
|
||||
console.debug(
|
||||
'[Data:CCTV] focus ignored while a tracked entity owns the camera',
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { stopFollowing } from '../../data/followed.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { cameraOf } from '../../render/cesium/camera.js';
|
||||
@@ -354,7 +355,7 @@ export function createReplay({ state: layerState, services, parts, source }) {
|
||||
syncReplayButton();
|
||||
parts.overlays.syncMissionOverlayEntries();
|
||||
parts.policyHelpers.releaseAircraftTracking(layerState._dataManager);
|
||||
layerState._viewer.trackedEntity = undefined;
|
||||
stopFollowing(layerState._viewer);
|
||||
const camera = cameraOf(layerState._viewer);
|
||||
camera.cancelFlight();
|
||||
layerState._animationStarts.set(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isFollowing } from '../../data/followed.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
HORIZON_CAMERA_MOVE_EPSILON_M,
|
||||
@@ -149,7 +150,7 @@ export function createNavigation({
|
||||
/** Radio may move the globe only while no tracked entity owns the follow camera. */
|
||||
|
||||
function radioCameraNavigationAllowed(viewer = layerState._viewer) {
|
||||
return Boolean(viewer?.camera) && !viewer.trackedEntity;
|
||||
return Boolean(viewer?.camera) && !isFollowing(viewer);
|
||||
}
|
||||
|
||||
function radioGlobeRecenterPlan(viewer = layerState._viewer) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { onFollowChanged } from '../../data/followed.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { VESSEL_OVERLAY_SOURCE_ID } from '../../data/vesselLabels.js';
|
||||
|
||||
@@ -97,14 +98,11 @@ export function createSelection({
|
||||
state.keyTarget = keyTarget;
|
||||
state.keydownHandler = onVesselKeyDown;
|
||||
keyTarget.addEventListener('keydown', state.keydownHandler);
|
||||
// Vessels never set viewer.trackedEntity, so any new tracked entity belongs
|
||||
// to another layer and takes interaction ownership of the scene.
|
||||
state.trackedEntityRemover = viewer.trackedEntityChanged.addEventListener(
|
||||
() => {
|
||||
if (viewer.trackedEntity && state.selectedRecord)
|
||||
clearVesselInspection();
|
||||
},
|
||||
);
|
||||
// Vessels never follow, so anything newly followed belongs to another
|
||||
// layer and takes interaction ownership of the scene.
|
||||
state.trackedEntityRemover = onFollowChanged(viewer, (followed) => {
|
||||
if (followed && state.selectedRecord) clearVesselInspection();
|
||||
});
|
||||
}
|
||||
|
||||
/** Select one live vessel and request one UI-owned camera transfer. */
|
||||
|
||||
Reference in new issue
Block a user