mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Navara's own flight clock loses time on slow frames (a one-second flight took 1.55 s at 50 ms frames and 3.1 s at 100 ms), so stories waited for the director's timeout. The adapter now owns the flight deadline and lands the camera on time. On Cesium a flight still counted as active inside its complete callback, because Cesium removes its tween only afterwards. The contract suite checks completion time and state for every easing.
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { createFakeEngine } from '../fakeEngine.js';
|
|
import { createContractSuite } from './index.mjs';
|
|
|
|
for (const timing of ['on time', 'late', 'missing']) {
|
|
test(`flight duration check: ${timing} completion`, async (context) => {
|
|
let now = 0;
|
|
context.mock.method(performance, 'now', () => now);
|
|
const engine = createFakeEngine();
|
|
const flyTo = engine.camera.flyTo;
|
|
engine.camera.flyTo = (options) =>
|
|
flyTo({
|
|
...options,
|
|
complete: () => {
|
|
if (timing === 'missing') return;
|
|
if (timing === 'late') now += 200;
|
|
options.complete?.();
|
|
},
|
|
});
|
|
const check = createContractSuite(engine, {
|
|
waitFrames: async (count) => {
|
|
for (let frame = 0; frame < count; frame++) {
|
|
now += 50;
|
|
engine.fake.frame(50);
|
|
}
|
|
},
|
|
}).find(({ name }) => name.startsWith('camera.flyTo: completes within'));
|
|
try {
|
|
if (timing === 'on time') await check.run();
|
|
else
|
|
await assert.rejects(
|
|
check.run(),
|
|
timing === 'late'
|
|
? /flight completed after 600 ms/
|
|
: /flight missed its duration/,
|
|
);
|
|
assert.equal(engine.camera.flightActive(), false);
|
|
} finally {
|
|
engine.destroy();
|
|
}
|
|
});
|
|
}
|