mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Load the default renderer as the page starts, and follow through the camera port in tests
- The standalone page starts loading the default renderer as it starts (loadDefaultRenderer), so Cesium arrives beside the page's own setup, not after it; the scene takes a plugin or a promise of one. - Where a follow target's layer has no display position yet, the followed position is the target's own position at the frame port's scene time. - The globe engine's photoreal base that fails to come back is off again and the globe shown; a later switch tries again. The draped-imagery host asks the map engine whether the globe is shown where the renderer cannot say. The scene resizes the renderer with its container. - Cockpit and voice tests follow through the camera port (followEntity), not by setting the viewer's tracked entity; the fake frame port has a scene time.
This commit is contained in:
1 parent
6daf63d90c
commit
ae4fbb5053
21 files changed
+328
-87
No files matched your search
@@ -12,7 +12,7 @@
|
||||
* north-up) read the target's `displayPosition`: a port target without one
|
||||
* is followed by the camera but not shown by them.
|
||||
*/
|
||||
import { findCamera } from '../render/rendererOf.js';
|
||||
import { findCamera, findFrame } from '../render/rendererOf.js';
|
||||
import { readEntityRecord } from './entityRecords.js';
|
||||
|
||||
/**
|
||||
@@ -156,12 +156,17 @@ export function resumeFollowing(viewer, followed) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Where `followed` is shown this frame: the layer's display cache; null
|
||||
* when it has none, or it answers nothing.
|
||||
* Where `followed` is shown this frame: the layer's display cache, else the
|
||||
* target's own position at the frame port's scene time; null when neither
|
||||
* answers.
|
||||
* @param {object} viewer
|
||||
* @param {Followed|null} followed
|
||||
*/
|
||||
export function followedPosition(viewer, followed) {
|
||||
const display = followed?.displayPosition;
|
||||
return (typeof display === 'function' ? display() : null) || null;
|
||||
const shown = typeof display === 'function' ? display() : null;
|
||||
if (shown) return shown;
|
||||
if (typeof followed?.position !== 'function') return null;
|
||||
const time = findFrame(viewer)?.time?.();
|
||||
return followed.position(Number.isFinite(time) ? time : Date.now()) || null;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
} from './followed.js';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { createCameraEvents } from '../render/camera/events.js';
|
||||
import { createStubRenderer } from '../render/stub/index.js';
|
||||
|
||||
/** A camera port that follows, for a viewer bound to a renderer. */
|
||||
function followingPort() {
|
||||
@@ -108,3 +109,21 @@ test('followedPosition reads the display cache', () => {
|
||||
assert.deepEqual(followedPosition({}, view), { x: 7, y: 8, z: 9 });
|
||||
assert.equal(followedPosition({}, null), null);
|
||||
});
|
||||
|
||||
test('followedPosition falls back to the target position at scene time', () => {
|
||||
const renderer = createStubRenderer();
|
||||
const viewer = {};
|
||||
bindRenderer(viewer, renderer);
|
||||
renderer.frame.setTime(1234);
|
||||
const seen = [];
|
||||
const target = {
|
||||
key: 't',
|
||||
frame: 'enu',
|
||||
viewFrom: { x: 0, y: 0, z: 1 },
|
||||
position: (time) => (seen.push(time), { x: 1, y: 2, z: 3 }),
|
||||
};
|
||||
assert.deepEqual(followedPosition(viewer, target), { x: 1, y: 2, z: 3 });
|
||||
assert.deepEqual(seen, [1234]);
|
||||
target.displayPosition = () => ({ x: 4, y: 5, z: 6 });
|
||||
assert.deepEqual(followedPosition(viewer, target), { x: 4, y: 5, z: 6 });
|
||||
});
|
||||
Reference in new issue
Block a user