mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
refactor(overlays): hand the shell's overlay host the engine, not the viewer
The controls pass the scene engine to the shell, which initializes the world overlay on it; initWorldOverlay takes only a globe engine (a viewer or null is refused), so the shell no longer needs a viewer for its overlay. engineFromViewer only returns the engine registered for a viewer (the scene engine until teardown) and never builds one, so no engine can outlive its viewer without a destroy path. Overlay and detection tests and the allocation worker build a Cesium engine on their mock viewers and destroy it with them; frame allocation is unchanged.
This commit is contained in:
1 parent
3e3aa0bd9f
commit
12c9651a67
10 files changed
+145
-105
No files matched your search
@@ -3,6 +3,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import * as Cesium from 'cesium';
|
||||
import { createCesiumEngine } from '../globe/cesium/createCesiumEngine.js';
|
||||
import {
|
||||
countFadingRenderEntries,
|
||||
destroyDetection,
|
||||
@@ -247,8 +248,11 @@ function installEnvironment({ width = 800, height = 600, dpr = 2, search = '' }
|
||||
scene: { postRender, requestRender() {} },
|
||||
};
|
||||
|
||||
// Shell modules take the globe engine; the Cesium engine runs on the mock.
|
||||
const engine = createCesiumEngine(viewer);
|
||||
return {
|
||||
viewer,
|
||||
engine,
|
||||
postRender,
|
||||
document,
|
||||
ctx,
|
||||
@@ -259,6 +263,7 @@ function installEnvironment({ width = 800, height = 600, dpr = 2, search = '' }
|
||||
cleanup() {
|
||||
destroyDetection();
|
||||
destroyWorldOverlay();
|
||||
engine.destroy();
|
||||
Date.now = originalDateNow;
|
||||
if (originalPath2D === undefined) delete globalThis.Path2D;
|
||||
else globalThis.Path2D = originalPath2D;
|
||||
@@ -353,7 +358,7 @@ test('detection lifecycle re-hosts unchanged painters behind the sole host liste
|
||||
const env = installEnvironment({ search: '?detectDebug=1' });
|
||||
const modes = [];
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [detectableLayer()], (mode) => modes.push(mode));
|
||||
assert.equal(env.postRender.listeners.size, 1);
|
||||
assert.equal(env.document.getElementById('detection-overlay'), null);
|
||||
@@ -507,7 +512,7 @@ test('callouts stop painting the moment the last detectable object goes away', (
|
||||
type: 'AIR',
|
||||
}];
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [{ id: 'flights', getDetectableObjects: () => objects }], () => {});
|
||||
setMode('DENSE');
|
||||
env.advance(250);
|
||||
@@ -543,7 +548,7 @@ test('every style paints its OWN plate token through the production callout path
|
||||
// path once per style and reads the fill style the shared canvas received.
|
||||
const env = installEnvironment();
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [mixedTierLayer()], () => {});
|
||||
setMode('DENSE');
|
||||
settleFrame(env);
|
||||
@@ -581,7 +586,7 @@ test('space-tier callouts take the heavier plate while air contacts keep the lig
|
||||
// tiers at once can show it.
|
||||
const env = installEnvironment();
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [mixedTierLayer()], () => {});
|
||||
setDetectionStyle('surveillance');
|
||||
setMode('DENSE');
|
||||
@@ -609,7 +614,7 @@ test('space-tier callouts take the heavier plate while air contacts keep the lig
|
||||
test('surveillance military tier reaches the dedicated render target as shipped red', () => {
|
||||
const env = installEnvironment();
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [militaryLayer()], () => {});
|
||||
setDetectionStyle('surveillance');
|
||||
setMode('DENSE');
|
||||
@@ -631,7 +636,7 @@ test('pathological detection paint holds alternate frames without freezing share
|
||||
// Opts into the telemetry banner: the held-frame assertions count banner paints.
|
||||
const env = installEnvironment({ search: '?detectDebug=1' });
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [detectableLayer()], () => {});
|
||||
setOverlayEntries('valve-card', [{
|
||||
id: 'ambient-card',
|
||||
@@ -738,7 +743,7 @@ test('the mode banner is absent by default and present behind the flag', () => {
|
||||
const painted = (search) => {
|
||||
const env = installEnvironment({ search });
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [detectableLayer()], () => {});
|
||||
setMode('DENSE');
|
||||
env.advance(250);
|
||||
@@ -765,7 +770,7 @@ test('detection telemetry stays reachable programmatically with the banner hidde
|
||||
// is the supported way to read them, and is what the QA harnesses use.
|
||||
const env = installEnvironment();
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [detectableLayer()], () => {});
|
||||
setMode('DENSE');
|
||||
env.advance(250);
|
||||
@@ -793,7 +798,7 @@ test('civilian and military AIR brackets cover front, left, and right at Sparse
|
||||
metric: 'FL120',
|
||||
type: 'AIR',
|
||||
}));
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [{ id: layerId, getDetectableObjects: () => objects }], () => {});
|
||||
setDetectionTuning({ densityPct: 25 });
|
||||
setMode('SPARSE');
|
||||
@@ -851,7 +856,7 @@ test('the backdrop feather reaches the canvas as a lighter plate against sky', (
|
||||
// the shared canvas actually received for each plate.
|
||||
const env = installEnvironment();
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(env.viewer, [backdropLayer()], () => {});
|
||||
setDetectionStyle('normal');
|
||||
setMode('DENSE');
|
||||
@@ -909,7 +914,7 @@ test('a transit vehicle is a contact: box, route, mode and operator on the share
|
||||
},
|
||||
];
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
initWorldOverlay(env.engine);
|
||||
initDetection(
|
||||
env.viewer,
|
||||
[{ id: 'transit', getDetectableObjects: () => objects }],
|
||||
|
||||
Reference in new issue
Block a user