mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Give each scene its own render governor, owner holds and recent idle requests. Make the Cesium render backend own its request mode directly, so the governor drives engine.render on both engines without a dependency back from Cesium. Route layer requests through their attached engine and capture the attachment's governor for camera motions, orbit, annotations and shell controls. Release retained-layer holds before clearing the outgoing engine, and destroy the governor after scene consumers have detached. Preserve Cesium's owner-keyed holds, pre-install buffering, last-release settling frame and one-shot requests during continuous rendering. Navara keeps the same render policy. There is no intended visible change on either engine. Simultaneous scenes no longer share holds, and an old captured service cannot release a replacement attachment's hold. Cover both rules on fake and headless Cesium engines, including an old orbit ending after reattachment. Viewer-reference lines fall from 910 to 891, Navara-kind checks from 2 to 1, and engine-name lines from 33 to 32. All other coupling counts stay unchanged. Checked in the browser, keyless: qa-perf passes on both engines with the same idle, active and release counts as before (24 checks on Cesium, 22 on Navara).
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import * as geo from './geo/index.js';
|
|
import { createFakeEngine } from './globe/testing/fakeEngine.js';
|
|
import { OrbitController } from './orbit.js';
|
|
import { getRenderGovernorDiagnostics } from './renderGovernor.js';
|
|
|
|
test('orbit locks onto the target every frame from the current heading, and stop releases it', (t) => {
|
|
t.mock.timers.enable({ apis: ['Date'], now: 1000 });
|
|
const engine = createFakeEngine();
|
|
engine.fake.setPose({
|
|
position: geo.cartesian3.fromDegrees(-97.74, 30.26, 2000),
|
|
heading: 0.4,
|
|
pitch: -0.5,
|
|
roll: 0,
|
|
});
|
|
const target = geo.cartesian3.fromDegrees(-97.74, 30.27, 30);
|
|
const orbit = new OrbitController(engine);
|
|
assert.equal(
|
|
orbit.toggle(target, { radius: 800, pitch: -20, speed: 10 }),
|
|
true,
|
|
);
|
|
assert.ok(
|
|
getRenderGovernorDiagnostics(engine).holds.includes('camera-orbit'),
|
|
);
|
|
t.mock.timers.tick(500);
|
|
engine.fake.frame();
|
|
const [first] = engine.fake.callsOf('camera.lookAt');
|
|
assert.deepEqual(first.args[0], target);
|
|
assert.ok(
|
|
Math.abs(first.args[1].heading - (0.4 + geo.math.toRadians(5))) < 1e-9,
|
|
);
|
|
assert.equal(first.args[1].pitch, geo.math.toRadians(-20));
|
|
assert.equal(first.args[1].range, 800);
|
|
assert.equal(orbit.toggle(), false);
|
|
assert.equal(engine.fake.callsOf('camera.release').length, 1);
|
|
assert.ok(
|
|
!getRenderGovernorDiagnostics(engine).holds.includes('camera-orbit'),
|
|
);
|
|
engine.fake.frame();
|
|
assert.equal(
|
|
engine.fake.callsOf('camera.lookAt').length,
|
|
1,
|
|
'no frames after stop',
|
|
);
|
|
});
|
|
|
|
test('orbit needs a target', () => {
|
|
const engine = createFakeEngine();
|
|
const orbit = new OrbitController(engine);
|
|
assert.equal(orbit.toggle(null), false);
|
|
assert.equal(engine.frames.preRender.numberOfListeners, 0);
|
|
});
|