Drive the camera orbit and the FPS readout through the frame port

The orbit controller and the frame-rate monitor had left the Cesium
allow-list but still hooked the scene's preRender and postRender events.
They now listen through the frame port; the monitor looks the port up
each time it is shown, so a renderer bound after it was created is the
one it counts.
This commit is contained in:
Sameh Khamis committed 2026-11-07 01:04:47 -08:00
1 parent d0aa8d8f7d
commit 30b6be1da0
4 files changed
+20 -7

No files matched your search

+6 -3
View File
@@ -1,5 +1,6 @@
import { useStatusStore } from './stores/status.js';
import { applicationPinia } from './vueRuntime.js';
import { findFrame } from '../render/rendererOf.js';
/**
* Count rendered globe frames while the optional readout is visible. The
@@ -10,9 +11,9 @@ export function createFrameRateMonitor({
documentRef = document,
store = useStatusStore(applicationPinia()),
}) {
const frameEvent = viewer?.scene?.postRender;
const frameOfViewer = () => findFrame(viewer);
// A page without the scene chrome has no title bar to show it in.
if (!documentRef.getElementById('title-bar') || !frameEvent)
if (!documentRef.getElementById('title-bar') || !frameOfViewer())
return { destroy() {} };
// i18n-ignore: FPS is a unit code, the same in every language
@@ -43,7 +44,9 @@ export function createFrameRateMonitor({
startedAt = performance.now();
// i18n-ignore: FPS is a unit code, the same in every language
present({ visible: true, text: 'FPS —' });
removeFrameListener = frameEvent.addEventListener(() => {
// Looked up when shown, so a renderer bound since creation is the one
// counted.
removeFrameListener = frameOfViewer()?.on('postRender', () => {
frames++;
});
timer = setInterval(() => {