Files
gods-eye-view/src/ui/frameRateView.test.mjs
T
German Khokhlov 18f69c2699 Follow, credits, embed views and FPS through the engine on Navara
Five places still read the Cesium viewer and so did nothing, or the wrong
thing, on Navara. Each now goes through the globe contract, and Cesium
behaves as before.

- The Navara ground floor stands aside while the camera inputs are
  suspended, not only while they are switched off. The cockpit suspends
  them, so its eye 12 m up no longer jumps to the floor's 30 m between
  updates. A follow's own suspension keeps the floor on, as before.
- Follow state comes from engine.camera.following() and followChanged
  instead of viewer.trackedEntity. Enabling CCTV during a follow no longer
  flies away and ends it, a new follow stamps navigation, Director cards
  wait while a subject is followed, and an explicit navigation stops the
  follow on both engines.
- Navara registers every data credit, as Cesium does. The allowlist left
  out the layers that moved to Navara later (CCTV agencies, street-level
  imagery, GIBS, routing, bike feeds and others).
- Annotation links and embed mode attach on every engine; their camera
  flights use engine.camera.flyTo. Only Cesium adds the timer that keeps
  an inline panel drawing.
- The FPS readout counts engine.frames.postRender, so it shows on Navara.

Each fix has a test that fails without it.
2026-11-08 17:05:27 +04:00

45 lines
1.8 KiB
JavaScript

// src/ui/frameRateView.test.mjs — the title bar's FPS readout renders what
// createFrameRateMonitor() publishes and toggles with the backquote key.
import '../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { createApp, nextTick } from 'vue';
import { createPinia } from 'pinia';
import { useStatusStore } from './stores/status.js';
import { createFrameRateMonitor } from './frameRateMonitor.js';
import SceneChromeView from './views/SceneChromeView.vue';
test('the FPS readout sits in the title bar, hidden until the backquote key', async (t) => {
document.body.replaceChildren();
const pinia = createPinia();
const app = createApp(SceneChromeView).use(pinia);
app.mount(document.body.appendChild(document.createElement('div')));
t.after(() => app.unmount());
const readout = () =>
document.querySelector('#title-bar .frame-rate-readout');
assert.equal(readout(), null, 'no readout without a monitor');
const monitor = createFrameRateMonitor({
engine: { frames: { postRender: { addEventListener: () => () => {} } } },
store: useStatusStore(pinia),
});
t.after(() => monitor.destroy());
await nextTick();
const element = readout();
assert.ok(element.previousElementSibling.classList.contains('subtitle'));
assert.ok(element.classList.contains('scene-text-holdout'));
assert.equal(element.hidden, true);
assert.equal(element.textContent, 'FPS —');
assert.equal(
element.title,
'Rendered globe frames per second · toggle with `',
);
document.dispatchEvent(
new KeyboardEvent('keydown', { key: '`', bubbles: true, cancelable: true }),
);
await nextTick();
assert.equal(readout().hidden, false);
monitor.destroy();
await nextTick();
assert.equal(readout(), null);
});