mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Application extras come from the renderer plugin; framing, occlusion and panel drawing are contract ports
A renderer plugin may supply applicationHooks(renderer) for what only its renderer has (map engine, own credits, stale commands, QA handles). What every renderer should do moves onto the contract: controls.keepEarthFramed (behind the keepEarthFramed capability), query.occlusionTest (behind occlusionTest), and panel drawing, which keepPanelRendering now does through resize and frame.renderNow through the contract. renderNow throws when the frame fails to draw. The Cesium port installs its zoom-out guard through keepEarthFramed (a setView no longer cancels its turn) and answers occlusionTest with the scene's probe; the stub answers it with a horizon test.
This commit is contained in:
1 parent
a755f63638
commit
619c19ea67
40 files changed
+737
-323
No files matched your search
Vendored
+10
@@ -201,6 +201,16 @@ export interface CameraControls {
|
||||
* the page.
|
||||
*/
|
||||
zoomInputs: Array<'wheel' | 'pinch' | 'rightDrag' | 'ctrlWheel'>;
|
||||
/**
|
||||
* `keepEarthFramed`: keep the whole Earth in reach and in frame as the
|
||||
* user zooms out. An outward user zoom goes no farther than about
|
||||
* 40,000 km, or than the height a camera command left the eye at when
|
||||
* that is higher (the user then zooms in from there), and from high up
|
||||
* it turns the view down toward the globe so the whole Earth stays in
|
||||
* frame. A camera command, a follow and a flight are not held to it, and
|
||||
* a camera command ends any turn under way. Off by default.
|
||||
*/
|
||||
keepEarthFramed?: boolean;
|
||||
}
|
||||
|
||||
export type CameraEvent =
|
||||
|
||||
Vendored
+4
@@ -170,6 +170,10 @@ export type Capability =
|
||||
| 'gpuTiming'
|
||||
/** Depth picks against tiles and terrain. */
|
||||
| 'pickPosition'
|
||||
/** Points tested against the frame's depth (`query.occlusionTest`). */
|
||||
| 'occlusionTest'
|
||||
/** Outward user zooms that keep the Earth framed (`controls.keepEarthFramed`). */
|
||||
| 'keepEarthFramed'
|
||||
/** Height sampling against tiles and terrain. */
|
||||
| 'sampleHeight'
|
||||
/** Ray casts against tiles and terrain. */
|
||||
|
||||
Vendored
+1
-1
@@ -72,7 +72,7 @@ export interface FramePort {
|
||||
diagnostics(): FrameDiagnostics;
|
||||
/** Stop ticking while the page is hidden; resume on `false`. */
|
||||
suspend(hidden: boolean): void;
|
||||
/** Draw a frame now, synchronously. */
|
||||
/** Draw a frame now, synchronously; throws when the frame fails to draw. */
|
||||
renderNow(): void;
|
||||
/** Resolves after the next frame has been drawn and presented. */
|
||||
renderOnce(options?: { timeoutMs?: number }): Promise<void>;
|
||||
|
||||
@@ -45,6 +45,8 @@ export const CAPABILITIES = Object.freeze([
|
||||
'globeVisibility',
|
||||
'followFrame',
|
||||
'cameraChangeThreshold',
|
||||
'occlusionTest',
|
||||
'keepEarthFramed',
|
||||
]);
|
||||
|
||||
/** @type {readonly import('./frame').FrameStep[]} */
|
||||
@@ -199,9 +201,10 @@ export const PORTS = deepFreeze({
|
||||
'matrices',
|
||||
),
|
||||
['followFrame', 'followFrame'],
|
||||
['controls.keepEarthFramed', 'keepEarthFramed'],
|
||||
]),
|
||||
query: Object.fromEntries(
|
||||
required(
|
||||
query: Object.fromEntries([
|
||||
...required(
|
||||
'pick',
|
||||
'drillPick',
|
||||
'pickPosition',
|
||||
@@ -216,7 +219,8 @@ export const PORTS = deepFreeze({
|
||||
'clampToSurface',
|
||||
'rayCast',
|
||||
),
|
||||
),
|
||||
['occlusionTest', 'occlusionTest'],
|
||||
]),
|
||||
input: Object.fromEntries(
|
||||
required(
|
||||
'on',
|
||||
|
||||
Vendored
+50
@@ -92,6 +92,12 @@ export interface QueryPort {
|
||||
projectMany(source: Float64Array, out: Float32Array): void;
|
||||
/** Hidden by the ellipsoid's horizon from the current eye. */
|
||||
isOccluded(position: Ecef): boolean;
|
||||
/**
|
||||
* `occlusionTest`: a test of many points against the depth of the frames
|
||||
* drawn, for overlays that leave out what something stands in front of.
|
||||
* Each call makes a new one; its owner destroys it.
|
||||
*/
|
||||
occlusionTest?(): OcclusionTest;
|
||||
/** `sampleHeight`: cached height now, or null when not loaded. */
|
||||
sampleHeightNow(point: LonLat, options?: HeightOptions): number | null;
|
||||
/**
|
||||
@@ -113,3 +119,47 @@ export interface QueryPort {
|
||||
options?: HeightOptions & { maxDistance?: number },
|
||||
): Promise<Ecef | null>;
|
||||
}
|
||||
|
||||
/**
|
||||
* One point under test (`OcclusionTest.add`): the test's owner keeps it and
|
||||
* reads the answer from it. The test sets `pending` when it takes the point,
|
||||
* and when the answer comes clears `pending`, sets `answered` and, when
|
||||
* something drawn stood in front of the point, sets `lastHiddenAt` to
|
||||
* `OcclusionTest`'s clock as of the frame it was tested against.
|
||||
*/
|
||||
export interface OcclusionPoint {
|
||||
pending: boolean;
|
||||
answered: boolean;
|
||||
lastHiddenAt: number;
|
||||
/** When the owner queued it, on the same clock. */
|
||||
queuedAt: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests points against the depth of the frames as drawn, without waiting
|
||||
* for the GPU: an answer may come a frame or two after its test.
|
||||
*/
|
||||
export interface OcclusionTest {
|
||||
/**
|
||||
* `'async'` while answers come a frame or two after their test, `'sync'`
|
||||
* while they come at once, `'off'` while nothing can be tested (no depth
|
||||
* to test against): every point is then to be taken as seen.
|
||||
*/
|
||||
readonly mode: 'async' | 'sync' | 'off';
|
||||
/** How many points it takes in one frame; Infinity when unbounded. */
|
||||
readonly maxPerFrame: number;
|
||||
/** Open a frame, collecting the answers that have come; `now` dates them. */
|
||||
beginFrame(now: number): void;
|
||||
/**
|
||||
* Test `point`, at `position`, against this frame: hidden when a surface
|
||||
* drawn stands in front of it by more than a small margin, which grows as
|
||||
* the view looks along the ground rather than down on it. False when it
|
||||
* cannot take one more this frame.
|
||||
*/
|
||||
add(point: OcclusionPoint, position: Ecef): boolean;
|
||||
/** Close the frame: start the tests taken. */
|
||||
endFrame(): void;
|
||||
/** Drop every test under way. */
|
||||
reset(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
Vendored
+33
@@ -25,6 +25,39 @@ export interface RendererPlugin {
|
||||
/** Stable id, recorded with each session (`'cesium'`, ...). */
|
||||
id: string;
|
||||
create(options: CreateOptions): Promise<Renderer>;
|
||||
/**
|
||||
* What the plugin hands the application beside the contract for a
|
||||
* renderer it made, asked once, right after `create` resolves. Omitted:
|
||||
* none.
|
||||
*/
|
||||
applicationHooks?(renderer: Renderer): ApplicationHooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* What only some renderers have and the application uses where given, does
|
||||
* application uses each where given and does without where not. None is a
|
||||
* do is in the ports.
|
||||
*/
|
||||
export interface ApplicationHooks {
|
||||
/**
|
||||
* The renderer's own map engine, which the map stacks switch through in
|
||||
* place of the globe port (`src/maps/engine.js`).
|
||||
*/
|
||||
mapEngine?: unknown;
|
||||
/**
|
||||
* True when the renderer shows its credits in a display of its own;
|
||||
* otherwise the application shows what the credits port lists.
|
||||
*/
|
||||
ownCreditDisplay?: boolean;
|
||||
/**
|
||||
* Drop the draw commands the renderer keeps for a while after it stops
|
||||
* drawing them; run after a layer turns off.
|
||||
*/
|
||||
trimStaleCommands?(): void;
|
||||
/** Whether an entity is one the renderer draws itself. */
|
||||
viewerDrawsEntity?(entity: unknown): boolean;
|
||||
/** Values QA scripts read from the page's debug handle. */
|
||||
qaHandles?: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export interface CreateOptions {
|
||||
|
||||
Reference in new issue
Block a user