mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
The flights and military layers now reach the renderer only through its ports: motion, queries, state, tracking, enrichment, evidence and policy read the camera pose, project through the query port, request and suspend frames through the frame port, and key per-frame caches on the frames drawn rather than the scene's frame number. Policy is plain data, the enrichment view test is pose-based, and the tracked aircraft is an icon in a draw-port set with a plain holder standing in for the entity that Cockpit, the tracked card and share links read. The mesh floor sampler can sample through the query port, excluding named draw sets, and both layers use it that way. A pick of another layer's tracked icon is never taken for one of a layer's own contacts. Twelve layer files leave the Cesium allow-list.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
/**
|
|
* @module data/renderedFrames
|
|
* @description How many frames a viewer's renderer has drawn: a key that
|
|
* changes once per drawn frame, after it is drawn, for per-frame caches.
|
|
* Everything that reads a cache keyed by it in one tick (the follow camera,
|
|
* the frame's `preUpdate` and `preRender` work, the readouts in its
|
|
* `postRender`) sees one value; a tick that draws nothing keeps the key, as
|
|
* the default renderer's own frame number does.
|
|
*/
|
|
import { findFrame } from '../render/rendererOf.js';
|
|
|
|
/** Per frame port: `{count}`, counted on its `postRender`. */
|
|
const counters = new WeakMap();
|
|
|
|
/**
|
|
* The number of frames drawn so far on `viewer`'s frame port, or -1 when it
|
|
* has none. Counting starts on the first call.
|
|
* @param {object|null|undefined} viewer
|
|
* @returns {number}
|
|
*/
|
|
export function renderedFrames(viewer) {
|
|
const frame = viewer ? findFrame(viewer) : null;
|
|
if (!frame) return -1;
|
|
let counter = counters.get(frame);
|
|
if (!counter) {
|
|
counter = { count: 0 };
|
|
counters.set(frame, counter);
|
|
frame.on('postRender', () => {
|
|
counter.count += 1;
|
|
});
|
|
}
|
|
return counter.count;
|
|
}
|