Define the renderer contract, with a stub renderer and a conformance suite

The renderer contract is what the application asks of a 3D renderer, so a
renderer other than Cesium can draw the same application. 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
any 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:
Sameh Khamis committed 2026-11-04 14:21:48 -08:00
1 parent fb30287898
commit 2fc99e7c19
65 files changed
+12761 -9

No files matched your search

+22
View File
@@ -5126,5 +5126,27 @@
"exports": ["./queries/heights"],
"modules": ["src/queries/heights.js"],
"external": ["cesium"]
},
"render": {
"exports": ["./render/contract", "./render/stub", "./render/conformance"],
"modules": [
"src/render/contract/index.js",
"src/render/stub/index.js",
"src/render/conformance/index.js",
"src/render/conformance/scenes.js",
"src/render/conformance/cameraScripts.js",
"src/render/conformance/visual.js",
"src/render/conformance/cameraRunner.js",
"src/render/conformance/expect.js",
"src/render/conformance/checks/ports.js",
"src/render/stub/math.js",
"src/render/stub/motion.js",
"src/render/stub/camera.js",
"src/render/stub/geodesic.js",
"src/render/stub/viewRectangle.js",
"src/render/conformance/goldens/camera.json",
"src/render/conformance/checks/camera.js"
],
"external": []
}
}