mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Define the renderer contract, with a stub renderer and a conformance suite
The renderer contract is what the application asks of a 3D renderer. It is nine ports (frame, globe, draw, camera, query, input, effects, credits, quality) plus the renderer itself, one strict .d.ts per port in src/render/contract/. PORTS lists every member at run time, and a TypeScript-compiler test fails when the list and the types disagree on one member. An optional member exists only with its capability; a required one answers null or empty without it. Nothing in the application uses the contract yet. The stub renderer (src/render/stub/) implements every port in memory and draws nothing. Its camera is a port of the default camera's maths: views, lookAt, flights with their height arc and easing, rectangle framing on the geodesic midpoint, the view rectangle with its horizon and pole cases, changed thresholds, follows, and flights that finish inside the call. The conformance suite (src/render/conformance/) runs 59 checks against a renderer through the contract alone, in Node or in a browser page. The camera checks compare traces recorded from Cesium's own Camera, headless on a virtual clock (scripts/record-camera-goldens.mjs), to 1 mm, 1e-9 and 1e-3 px. The other checks cover listener rules on every subscription, the frame loop, draw sets, picks, motion clocks, heights, leases, imagery, styles, credits and quality knobs. The stub passes all of them but the model check, which needs a glTF asset. Reference scenes draw one scene per primitive family, a city and a calibration path from orbit to the street, from contract calls only and with no network. /dev/conformance/ draws them on the Cesium scene renderer (src/render/cesium/sceneRenderer.js), records references through a dev-server-only, loopback-only endpoint, and compares captures with pixelmatch's antialias detection plus a solid-pixel count. Measured on Cesium: every MSAA setting passes, and a dropped 4 px point, a dropped 2 px line and a 1 px shift of the view fail. visual.js states the limits. The package exports ./render/contract, ./render/stub and ./render/conformance. Documented in docs/RENDERER-CONTRACT.md, docs/CODE-BOUNDARIES.md and docs/CURRENT-STATE.md.
This commit is contained in:
1 parent
464c29a9ed
commit
8db995acfc
65 files changed
+12759
-9
No files matched your search
Vendored
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* Questions about what is on screen.
|
||||
*
|
||||
* Picks, projection and rays are synchronous and answer against the last
|
||||
* presented frame. Heights have a synchronous cache-only form that may
|
||||
* return null, and asynchronous forms that load what they need.
|
||||
*/
|
||||
import type { Ecef, LonLat, Meta, Ray, ScreenXY } from './common';
|
||||
|
||||
/** One thing under the pointer. */
|
||||
export interface Hit {
|
||||
/** The draw set's id. */
|
||||
set: string;
|
||||
/** The item's id. */
|
||||
id: string;
|
||||
/** The item's `meta`, as it was given; absent when the item had none. */
|
||||
meta?: Meta;
|
||||
/** The map itself (tiles or globe), rather than a drawn item. */
|
||||
surface: boolean;
|
||||
/** Where the hit is, when the renderer knows it. */
|
||||
position?: Ecef;
|
||||
}
|
||||
|
||||
export interface PickWindow {
|
||||
/** Pick window, CSS pixels; default 3 × 3. */
|
||||
width?: number;
|
||||
height?: number;
|
||||
/**
|
||||
* What the pick is for. A hover pick may skip costly exact tests (a
|
||||
* point-in-polygon on a large fill) that a select pick must make.
|
||||
*/
|
||||
purpose?: 'hover' | 'select';
|
||||
}
|
||||
|
||||
export interface HeightOptions {
|
||||
/** `surface`: tiles where they are drawn, otherwise terrain. */
|
||||
against?: 'surface' | 'terrain' | 'tiles';
|
||||
/** Set ids to see through. */
|
||||
exclude?: string[];
|
||||
}
|
||||
|
||||
export interface HeightSample {
|
||||
/** Metres above the ellipsoid. */
|
||||
height: number;
|
||||
/** 1 for the most detailed data, lower for a coarser level. */
|
||||
confidence: number;
|
||||
source: 'tiles' | 'terrain' | 'ellipsoid';
|
||||
/** The detail answered from: what is drawn now, or (`finestHeights`) the finest available. */
|
||||
lod: 'visible' | 'finest';
|
||||
/** Edge length of the tile answered from, metres, when known. */
|
||||
tileSizeM?: number;
|
||||
}
|
||||
|
||||
export interface QueryPort {
|
||||
pick(x: number, y: number, window?: PickWindow): Hit | null;
|
||||
drillPick(
|
||||
x: number,
|
||||
y: number,
|
||||
options?: PickWindow & { limit?: number },
|
||||
): Hit[];
|
||||
/** `pickPosition`: depth under the pointer, against tiles and terrain. */
|
||||
pickPosition(x: number, y: number): Ecef | null;
|
||||
pickEllipsoid(x: number, y: number): Ecef | null;
|
||||
/** Where a ray meets the globe surface (not tiles). */
|
||||
pickGlobe(ray: Ray): Ecef | null;
|
||||
pickRay(x: number, y: number): Ray;
|
||||
/** Screen position, or null behind the eye (off-screen points still answer). */
|
||||
project(position: Ecef): ScreenXY | null;
|
||||
/**
|
||||
* Packed `x, y, z` in → packed `x, y` out, CSS pixels; NaN for points
|
||||
* behind the eye. For the label overlay's per-frame pass.
|
||||
*/
|
||||
projectMany(source: Float64Array, out: Float32Array): void;
|
||||
/** Hidden by the ellipsoid's horizon from the current eye. */
|
||||
isOccluded(position: Ecef): boolean;
|
||||
/** `sampleHeight`: cached height now, or null when not loaded. */
|
||||
sampleHeightNow(point: LonLat, options?: HeightOptions): number | null;
|
||||
/**
|
||||
* `sampleHeight`: cached heights for many points at once: packed `lon, lat`
|
||||
* degrees in, one height per point out (NaN when not loaded). The app makes
|
||||
* its per-frame height reads through this, once a frame.
|
||||
*/
|
||||
sampleHeightNowMany(
|
||||
points: Float64Array,
|
||||
out: Float64Array,
|
||||
options?: HeightOptions,
|
||||
): void;
|
||||
/**
|
||||
* `sampleHeight`: heights, loading as needed; null per miss.
|
||||
* `mostDetailed` (`finestHeights`) waits for the finest data.
|
||||
*/
|
||||
sampleHeight(
|
||||
points: LonLat[],
|
||||
options?: HeightOptions & { mostDetailed?: boolean },
|
||||
): Promise<Array<HeightSample | null>>;
|
||||
/** `sampleHeight`: positions moved onto the surface; null per miss. */
|
||||
clampToSurface(
|
||||
positions: Ecef[],
|
||||
options?: HeightOptions,
|
||||
): Promise<Array<Ecef | null>>;
|
||||
/** `rayCast`: first surface hit along a ray. */
|
||||
rayCast(
|
||||
ray: Ray,
|
||||
options?: HeightOptions & { maxDistance?: number },
|
||||
): Promise<Ecef | null>;
|
||||
}
|
||||
Reference in new issue
Block a user