mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
The startup fly-in, orbit, world-target focus, the arrival ground guard, arrival ownership, camera sensitivity claims, landmark/viewport/globe flights and place search (with its view bias and near-view recovery) take the globe engine. Callers that still hold a viewer (voice, layers until phase 1c) reach the same engine through engineFromViewer, and arrival ownership is keyed by the engine whichever one a caller names. The ground guard yields on camera.commanded instead of patching the viewer camera itself; on Cesium that event hooks the same command methods and tracking changes, so direct Cesium callers still end it. Landmark framing reads the frustum fov from the pose's fovy and aspectRatio. Tests that built viewer doubles now run on the fake engine (or on the Cesium engine over the same double), with the same expectations.
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { flyToAustin } from '../camera.js';
|
|
import { createFakeEngine } from '../globe/testing/fakeEngine.js';
|
|
|
|
test('teardown before the initial camera delay prevents a late flight', (t) => {
|
|
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
const engine = createFakeEngine();
|
|
const stop = flyToAustin(engine);
|
|
stop();
|
|
t.mock.timers.tick(1000);
|
|
assert.equal(engine.fake.callsOf('camera.flyTo').length, 0);
|
|
assert.equal(engine.fake.callsOf('camera.cancelFlight').length, 1);
|
|
});
|
|
|
|
test('the startup fly-in starts high over Austin, then flies in on the engine', (t) => {
|
|
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
const engine = createFakeEngine();
|
|
flyToAustin(engine);
|
|
const [view] = engine.fake.callsOf('camera.setView')[0].args;
|
|
assert.deepEqual(view.orientation, {
|
|
heading: 0,
|
|
pitch: -Math.PI / 2,
|
|
roll: 0,
|
|
});
|
|
t.mock.timers.tick(500);
|
|
const [flight] = engine.fake.callsOf('camera.flyTo')[0].args;
|
|
assert.equal(flight.duration, 4);
|
|
assert.equal(flight.easing, 'cubicInOut');
|
|
});
|
|
|
|
test('a destroyed engine gets no late flight', (t) => {
|
|
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
const engine = createFakeEngine();
|
|
const stop = flyToAustin(engine);
|
|
engine.destroy();
|
|
t.mock.timers.tick(1000);
|
|
stop();
|
|
assert.equal(engine.fake.callsOf('camera.flyTo').length, 0);
|
|
assert.equal(engine.fake.callsOf('camera.cancelFlight').length, 0);
|
|
});
|