mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(app): the globe opens at planet level
The camera starts with the whole Earth in view, looking straight down, instead of flying in to Austin. A shared link flies on from there. A different start, a city for instance, is set with the startView option of createApplicationControls. The Cesium renderer and the test stub now start from the same pose, so state that carries over from the first frames (screen clusters, marker selection, label placement) no longer depends on which of them drew it.
This commit is contained in:
1 parent
e9085e8df3
commit
639e92b4f7
20 files changed
+72
-116
No files matched your search
Vendored
+10
-9
@@ -1,6 +1,6 @@
|
||||
import { catalogControlServices } from './catalog.js';
|
||||
import { StyleManager } from '../ui/composition.js';
|
||||
import { flyToAustin } from '../camera.js';
|
||||
import { applyStartView, START_VIEW } from '../camera.js';
|
||||
import { initCockpitCloudEffects } from '../cockpitCloudEffects.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
|
||||
@@ -8,7 +8,9 @@ import { t } from '../i18n/index.js';
|
||||
* Construct the existing controls and camera presentation. `initialShareCode`
|
||||
* opens a share code (the `<code>` of `/share/<code>`) at start-up, for a host
|
||||
* whose address does not carry one. `localePicker: false` removes the language
|
||||
* picker, for a page that does not initialize the app's locale.
|
||||
* picker, for a page that does not initialize the app's locale. `startView` is
|
||||
* where the camera starts (the whole planet by default; a host may pass a
|
||||
* city); a shared view flies from there.
|
||||
*/
|
||||
export function createApplicationControls({
|
||||
scene: { viewer, mapStackController, operations, viewerDrawsEntity },
|
||||
@@ -20,7 +22,10 @@ export function createApplicationControls({
|
||||
defer,
|
||||
initialShareCode = null,
|
||||
localePicker = true,
|
||||
startView = START_VIEW,
|
||||
}) {
|
||||
// Every boot starts from the same view, before share restoration flies on.
|
||||
applyStartView(viewer, startView);
|
||||
// Initialize the style manager (post-processing, HUD, locations, share links)
|
||||
const styleManager = new Controls(viewer, {
|
||||
services: {
|
||||
@@ -52,13 +57,9 @@ export function createApplicationControls({
|
||||
});
|
||||
defer(() => cockpitCloudEffects?.destroy());
|
||||
|
||||
// If no share link state, do default fly-to Austin
|
||||
if (!styleManager.hasShareState) {
|
||||
loaderStatus.textContent = t('Flying to Austin, TX...');
|
||||
defer(flyToAustin(viewer));
|
||||
} else {
|
||||
loaderStatus.textContent = t('Restoring shared view...');
|
||||
}
|
||||
loaderStatus.textContent = styleManager.hasShareState
|
||||
? t('Restoring shared view...')
|
||||
: t('Loading');
|
||||
|
||||
return { styleManager, weatherEffects, cockpitCloudEffects };
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import test, { after, before } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import '../testSupport/stubMgrs.mjs';
|
||||
import { installVueDom } from '../testSupport/vueDom.mjs';
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
const { createApplicationControls } = await import('./controls.js');
|
||||
|
||||
@@ -21,7 +22,10 @@ test('the application controls start and stop', () => {
|
||||
const cleanups = [];
|
||||
createApplicationControls({
|
||||
scene: {
|
||||
viewer: {},
|
||||
viewer: bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: { setView() {} },
|
||||
}),
|
||||
mapStackController: {},
|
||||
operations: {
|
||||
surface: { controlServices: {} },
|
||||
|
||||
@@ -1,68 +1,41 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { flyToAustin } from '../camera.js';
|
||||
import { applyStartView, START_VIEW } from '../camera.js';
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
test('teardown before the initial camera delay prevents a late flight', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
let flights = 0;
|
||||
let cancelled = 0;
|
||||
const stop = flyToAustin(
|
||||
bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: {
|
||||
setView() {},
|
||||
flyTo() {
|
||||
flights++;
|
||||
},
|
||||
cancelFlight() {
|
||||
cancelled++;
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
stop();
|
||||
t.mock.timers.tick(1000);
|
||||
assert.equal(flights, 0);
|
||||
assert.equal(cancelled, 0, 'no fly-in started, so none to cancel');
|
||||
});
|
||||
|
||||
test('teardown cancels the fly-in, not a flight the user started since', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const cancelled = [];
|
||||
let current = null;
|
||||
const viewer = bindFakeCesiumCamera({
|
||||
function viewerRecording(views) {
|
||||
return bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: {
|
||||
get _currentFlight() {
|
||||
return current;
|
||||
setView(view) {
|
||||
views.push(view);
|
||||
},
|
||||
setView() {},
|
||||
flyTo(options) {
|
||||
current?.cancel();
|
||||
current = {
|
||||
name: options.duration === 4 ? 'fly-in' : 'user',
|
||||
...options,
|
||||
};
|
||||
},
|
||||
cancelFlight() {
|
||||
cancelled.push(current?.name);
|
||||
const flight = current;
|
||||
current = null;
|
||||
flight?.cancel();
|
||||
flyTo() {
|
||||
assert.fail('a start view is set, not flown to');
|
||||
},
|
||||
},
|
||||
});
|
||||
const stop = flyToAustin(viewer);
|
||||
t.mock.timers.tick(500);
|
||||
stop();
|
||||
assert.deepEqual(cancelled, ['fly-in']);
|
||||
}
|
||||
|
||||
// A user flight replaces the fly-in; teardown leaves it alone.
|
||||
const second = flyToAustin(viewer);
|
||||
t.mock.timers.tick(500);
|
||||
viewer.camera.flyTo({ duration: 2 });
|
||||
second();
|
||||
assert.deepEqual(cancelled, ['fly-in']);
|
||||
assert.equal(current.name, 'user');
|
||||
test('the camera starts over the whole planet, looking straight down', () => {
|
||||
const views = [];
|
||||
applyStartView(viewerRecording(views));
|
||||
assert.equal(views.length, 1);
|
||||
assert.ok(START_VIEW.height >= 20000000, 'the whole planet is in view');
|
||||
assert.ok(Math.abs(views[0].orientation.pitch + Math.PI / 2) < 1e-9);
|
||||
assert.equal(views[0].orientation.heading, 0);
|
||||
});
|
||||
|
||||
test('a host can start the camera at a city instead', () => {
|
||||
const views = [];
|
||||
applyStartView(viewerRecording(views), {
|
||||
lon: 2.35,
|
||||
lat: 48.86,
|
||||
height: 5000,
|
||||
heading: 90,
|
||||
pitch: -30,
|
||||
});
|
||||
assert.equal(views.length, 1);
|
||||
assert.ok(Math.abs(views[0].orientation.heading - Math.PI / 2) < 1e-9);
|
||||
assert.ok(Math.abs(views[0].orientation.pitch + Math.PI / 6) < 1e-9);
|
||||
});
|
||||
Reference in new issue
Block a user