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
@@ -75,7 +75,8 @@ const ONE_DEGREE = Math.PI / 180;
|
||||
* @param {(reason: string) => void} options.requestRender
|
||||
* @param {(error: Error) => void} options.report
|
||||
* @param {boolean} [options.thresholds] `cameraChangeThreshold`: each
|
||||
* `changed` listener's own threshold (default true).
|
||||
* `changed` listener's own threshold (default true). `framing`: whether
|
||||
* the controls have `keepEarthFramed` (default false).
|
||||
*/
|
||||
export function createStubCamera({
|
||||
viewport,
|
||||
@@ -85,6 +86,7 @@ export function createStubCamera({
|
||||
report,
|
||||
drawnPosition = () => null,
|
||||
thresholds = true,
|
||||
framing = false,
|
||||
}) {
|
||||
// Local frame values; world values are `frame` applied to them.
|
||||
let frame = IDENTITY;
|
||||
@@ -147,6 +149,9 @@ export function createStubCamera({
|
||||
pitchRange: [-Math.PI / 2, 0],
|
||||
zoomInputs: ['wheel', 'pinch', 'rightDrag'],
|
||||
};
|
||||
// The stub takes no user input: there is nothing to keep framed, and the
|
||||
// setting only reads back.
|
||||
if (framing) controls.keepEarthFramed = false;
|
||||
|
||||
function aspectRatio() {
|
||||
const { width, height } = viewport();
|
||||
|
||||
@@ -234,6 +234,7 @@ export function createStubRenderer(options = {}) {
|
||||
report,
|
||||
drawnPosition: (ref, aheadMs) => drawnPosition(ref, aheadMs),
|
||||
thresholds: capabilities.has('cameraChangeThreshold'),
|
||||
framing: capabilities.has('keepEarthFramed'),
|
||||
});
|
||||
camera.setViewRectangle(viewRectangle);
|
||||
if (capabilities.has('followFrame'))
|
||||
@@ -1064,6 +1065,28 @@ export function createStubRenderer(options = {}) {
|
||||
return rayEllipsoid(ray);
|
||||
},
|
||||
};
|
||||
// The stub's only surface is the ellipsoid: a point is hidden behind its
|
||||
// horizon, answered at once.
|
||||
if (capabilities.has('occlusionTest'))
|
||||
query.occlusionTest = () => {
|
||||
let now = 0;
|
||||
return {
|
||||
mode: 'sync',
|
||||
maxPerFrame: Number.POSITIVE_INFINITY,
|
||||
beginFrame(t) {
|
||||
now = t;
|
||||
},
|
||||
add(point, position) {
|
||||
point.pending = false;
|
||||
point.answered = true;
|
||||
if (isOccluded(position)) point.lastHiddenAt = now;
|
||||
return true;
|
||||
},
|
||||
endFrame() {},
|
||||
reset() {},
|
||||
destroy() {},
|
||||
};
|
||||
};
|
||||
|
||||
// --- Input -----------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in new issue
Block a user