mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
fix(cctv): keep the Context camera card's still and tidy the visibility port
The still preview gate looked only at the CCTV panel, so the Context camera card, which reads the same frame, stopped updating while the panel was collapsed or another phone sheet was open. A mounted card now counts itself in the CCTV store, and the still is requested while the panel or a card is shown; live video still follows the panel only. Review follow-ups in the same area: - visiblePoints is registered once, in createCesiumPorts, and drops checks for input that cannot happen; the contract documents horizonMarginM and when it answers false or null. - The layer passes the mount and the four corners once each and asks findCamera for the port. - Phone sheet names come from a shared module instead of literals. - Layer tests cover the fetch gate; the geometry cases moved to the camera port tests. Comments and CURRENT-STATE match the code.
This commit is contained in:
1 parent
b020a1cd91
commit
99a70a0e0c
18 files changed
+545
-430
No files matched your search
+24
-13
@@ -4,6 +4,15 @@ import { cctvSourceLabelText, cctvSourceMessageText } from './cctvFrames.js';
|
||||
import { createCctvVideoSurface } from './cctvVideo.js';
|
||||
import { presentCctvCalibration } from './cctvCalibration.js';
|
||||
import { roundHeadingDegrees } from '../data/headingDegrees.js';
|
||||
import {
|
||||
MOBILE_SHELL_CLASS,
|
||||
MOBILE_SHEET_ATTR,
|
||||
sheetForPanelId,
|
||||
} from './mobileSheets.js';
|
||||
|
||||
const CAMERAS_SHEET = sheetForPanelId('cctv-panel');
|
||||
const CONTEXT_SHEET = sheetForPanelId('global-context-panel');
|
||||
|
||||
export function _calBadgeLabel(badge) {
|
||||
switch (badge) {
|
||||
case 'calibrated':
|
||||
@@ -274,19 +283,21 @@ export function _renderCctvState(state) {
|
||||
const liveIntent =
|
||||
enabled && !!activeCamera?.isVideo && !activeCamera?.browserMediaUrl;
|
||||
this.store.setLive(liveIntent);
|
||||
// A background tab or a collapsed panel shows nothing, so neither plays the
|
||||
// video nor fetches the still; the observer and the visibilitychange listener
|
||||
// render again when the panel is shown.
|
||||
// On phones the panel also belongs to one sheet: the shell hides it unless
|
||||
// data-mobile-sheet is 'cameras'.
|
||||
const body = typeof document !== 'undefined' ? document.body : null;
|
||||
const sheetClosed =
|
||||
!!body?.classList?.contains('mobile-shell') &&
|
||||
body.getAttribute('data-mobile-sheet') !== 'cameras';
|
||||
// A background tab, a collapsed panel or a closed phone sheet shows no
|
||||
// picture; the observers and visibilitychange render again on showing.
|
||||
const body = globalThis.document?.body;
|
||||
const phone = body?.classList.contains(MOBILE_SHELL_CLASS);
|
||||
const sheet = body?.getAttribute(MOBILE_SHEET_ATTR);
|
||||
const tabShown = !!body && !document.hidden;
|
||||
const panelShown =
|
||||
!(typeof document !== 'undefined' && document.hidden) &&
|
||||
!this._cctvPanel?.classList?.contains('collapsed') &&
|
||||
!sheetClosed;
|
||||
tabShown &&
|
||||
!this._cctvPanel?.classList.contains('collapsed') &&
|
||||
(!phone || sheet === CAMERAS_SHEET);
|
||||
// Context's camera card shows the same still.
|
||||
const cardShown =
|
||||
tabShown &&
|
||||
this.store.previewCards > 0 &&
|
||||
(!phone || sheet === CONTEXT_SHEET);
|
||||
if (this._cctvVideo) {
|
||||
const visible = liveIntent && panelShown;
|
||||
if (!visible || this._cctvVideoCameraId !== activeId) {
|
||||
@@ -313,7 +324,7 @@ export function _renderCctvState(state) {
|
||||
// immediate so navigation never waits on the prior camera's request.
|
||||
if (
|
||||
nextSrc &&
|
||||
panelShown &&
|
||||
(panelShown || cardShown) &&
|
||||
(cameraChanged || (!frameLoading && this._frame.currentSrc !== nextSrc))
|
||||
) {
|
||||
this._queueCctvFrame(nextSrc, nextCameraId, cameraChanged);
|
||||
|
||||
Reference in new issue
Block a user