mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Test layers on one engine and share selection and shader helpers
Layer display tests no longer re-check Cesium primitives in every layer: they run on the fake engine, and one Cesium translation check per ground kind lives in the Cesium engine's ground tests. Their harnesses are shared, and the fake-engine, Cesium-engine and flights tests that repeated the contract suite are gone, 340 tests in all. The press-travel measurement is shared by the selection dispatcher and CCTV, which loses its ScreenSpaceEventHandler shim and world-click module. ALPR, installations and bikeshare share one selection keeper and selected marker write. Layers with their own click rules keep their handlers. Navara's pulse is a class like the ground pass, the ground and imagery passes share the surface uniforms, and the colour, log-depth and occlusion GLSL lives in one chunk module, each caller keeping its depth bias. The ground suite runs inside the contract suite (--only=ground:), and fixture and script names say what they test. Behaviour is unchanged on both engines.
This commit is contained in:
1 parent
7f478e3815
commit
b4556f9763
101 files changed
+1095
-4071
No files matched your search
@@ -1,14 +1,11 @@
|
||||
// The FIRMS display on the fake engine and on the Cesium engine over a stub
|
||||
// scene: the same calls, the same drawing, read back from each engine's own
|
||||
// store (the fake's mover and ground sets, Cesium's billboards and ground
|
||||
// primitives).
|
||||
// Layer display behavior on the fake engine.
|
||||
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import * as geo from '../../../geo/index.js';
|
||||
import { createFakeEngine } from '../../../globe/testing/fakeEngine.js';
|
||||
import { createFakeEventHandlers } from '../../../globe/cesium/testing/fakeViewer.mjs';
|
||||
import { createCesiumMoversEngine } from '../../../testSupport/cesiumMoversEngine.mjs';
|
||||
|
||||
import { SPRITE_LAYER_ORDER } from '../../../data/spriteOrder.js';
|
||||
import { constantRgba } from '../../shared/color.js';
|
||||
import { createFirmsDisplay } from './display.js';
|
||||
@@ -94,76 +91,7 @@ function fakeHarness() {
|
||||
};
|
||||
}
|
||||
|
||||
function cesiumHarness() {
|
||||
const handlers = createFakeEventHandlers();
|
||||
const { engine, viewer, primitive } = createCesiumMoversEngine({
|
||||
engineOptions: {
|
||||
createEventHandler: handlers.create,
|
||||
scheduleFrame: (run) => run(),
|
||||
},
|
||||
});
|
||||
viewer.scene.groundPrimitives = new Cesium.PrimitiveCollection();
|
||||
engine.camera.setView({ destination: at(FIRE.lon, FIRE.lat, 2_000_000) });
|
||||
let native;
|
||||
viewer.scene.pick = () => native;
|
||||
viewer.scene.drillPick = () => (native ? [native] : []);
|
||||
const ground = watchGround(engine);
|
||||
return {
|
||||
name: 'the Cesium engine',
|
||||
engine,
|
||||
viewer,
|
||||
ground,
|
||||
sprites(id) {
|
||||
const collection = primitive(id);
|
||||
if (!collection) return null;
|
||||
const listed = engine.movers.list().find((entry) => entry.id === id);
|
||||
const count = listed?.count ?? 0;
|
||||
return {
|
||||
collection,
|
||||
count,
|
||||
instances: Array.from({ length: count }, (_, i) => {
|
||||
const billboard = collection.get(i);
|
||||
return {
|
||||
show: billboard.show,
|
||||
scale: billboard.scale,
|
||||
alpha: billboard.color.alpha,
|
||||
pickId: billboard.id,
|
||||
billboard,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
/** The Cesium ground primitives of a set. */
|
||||
groundPrimitives(id) {
|
||||
const root = viewer.scene.groundPrimitives.get(0);
|
||||
for (let i = 0; i < (root?.length ?? 0); i++) {
|
||||
const slot = root.get(i);
|
||||
const values = Array.from({ length: slot.length }, (_, j) =>
|
||||
slot.get(j),
|
||||
);
|
||||
if (values.some((value) => value.gevGroundSet === id))
|
||||
return { slot, values };
|
||||
}
|
||||
return null;
|
||||
},
|
||||
click(picked) {
|
||||
native = picked;
|
||||
for (const handler of handlers.handlers)
|
||||
handler.fire(Cesium.ScreenSpaceEventType.LEFT_CLICK, {
|
||||
position: new Cesium.Cartesian2(10, 20),
|
||||
});
|
||||
native = undefined;
|
||||
},
|
||||
// A Cesium pick of the instance's billboard.
|
||||
pickOf(setId, instance) {
|
||||
const billboard = primitive(setId).get(instance);
|
||||
return { primitive: billboard, id: billboard.id };
|
||||
},
|
||||
destroy: () => engine.destroy(),
|
||||
};
|
||||
}
|
||||
|
||||
const HARNESSES = [fakeHarness, cesiumHarness];
|
||||
const HARNESSES = [fakeHarness];
|
||||
const display = (h, options = {}) =>
|
||||
createFirmsDisplay(h.engine, {
|
||||
id: 'firms-fixture',
|
||||
@@ -535,8 +463,6 @@ for (const make of HARNESSES) {
|
||||
test(`${name}: the heatmap is one imagery layer over the globe, faded by its alpha`, () => {
|
||||
const restore = stubDocument();
|
||||
const h = make();
|
||||
// Cesium drapes it on the globe's own imagery stack.
|
||||
const stack = new Cesium.ImageryLayerCollection();
|
||||
if (h.viewer) {
|
||||
h.viewer.imageryLayers = stack;
|
||||
h.viewer.scene.globe.show = true;
|
||||
|
||||
Reference in new issue
Block a user