mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
The contract gains render.setSharpen({ enabled, amount }) and
render.sharpen(). Navara draws it as a custom EffectDesc: Cesium's unsharp
mask (3x3 box blur, gamma 2.2 round trip so one amount matches Cesium)
right after tone mapping and before SMAA/FXAA, skipping sky and cloud
pixels by scene depth. The Cesium engine keeps the state only; Cesium mode
still sharpens with its own post stage, unchanged. The fake engine records
it and the contract suite checks it.
Without a viewer the Sharpen slider and toggle drive the engine with the
same slider-to-amount mapping. On Navara the defaults, presets and share
links read Cesium's 49 % as 80 %.
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
// GlobeRender on the app's render governor, which owns Cesium's
|
|
// requestRenderMode and maximumRenderTimeChange; the engine only takes a
|
|
// hold under its own owner id.
|
|
|
|
import {
|
|
governorRequestRender,
|
|
holdContinuousRender,
|
|
isRenderGovernorInstalled,
|
|
releaseContinuousRender,
|
|
} from '../../renderGovernor.js';
|
|
import { SHARPEN_INITIAL, mergeSharpen } from '../contract.js';
|
|
|
|
export const RENDER_OWNER = 'globe-engine';
|
|
|
|
/**
|
|
* @param {Cesium.Viewer} viewer
|
|
* @param {{ requestRender?: (reason: string) => void }} [options] Defaults to
|
|
* the render governor when it governs this viewer, else the scene itself
|
|
* (before the governor is installed, or on another viewer).
|
|
* @returns {{ render: import('../contract.js').GlobeRender, destroy: () => void }}
|
|
*/
|
|
export function createCesiumRender(
|
|
viewer,
|
|
{
|
|
requestRender = (reason) => {
|
|
if (isRenderGovernorInstalled(viewer)) governorRequestRender(reason);
|
|
else viewer.scene.requestRender?.();
|
|
},
|
|
} = {},
|
|
) {
|
|
let held = false;
|
|
let sharpen = { ...SHARPEN_INITIAL };
|
|
const render = {
|
|
request(reason = RENDER_OWNER) {
|
|
requestRender(reason);
|
|
},
|
|
setContinuous(enabled) {
|
|
held = Boolean(enabled);
|
|
if (held) holdContinuousRender(RENDER_OWNER);
|
|
else releaseContinuousRender(RENDER_OWNER);
|
|
},
|
|
// The scene's real mode: another owner's hold keeps it continuous.
|
|
isContinuous: () => viewer.scene.requestRenderMode === false,
|
|
// State only: in Cesium mode the app's own post stage sharpens
|
|
// (src/ui/visualEffects.js), and the scene stays as it was.
|
|
setSharpen(options) {
|
|
sharpen = mergeSharpen(sharpen, options);
|
|
},
|
|
sharpen: () => ({ ...sharpen }),
|
|
};
|
|
return {
|
|
render,
|
|
destroy() {
|
|
if (held) render.setContinuous(false);
|
|
},
|
|
};
|
|
}
|