mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
The wind relief now asks the globe port for hillshade surface shading at 0.28 instead of building a globe material itself; the Cesium globe port draws the same view-directed shading, over terrain normals or the globe's curvature, and the unbound provider now lists surfaceShading. The wind layer's canvas flow, bounds, imagery fade and render requests go through the camera, frame and query ports, so src/layers/wind/rendering.js and relief.js leave the Cesium allow list. A refused shading request is taken back so it never shows after Wind is off, and a camera height that is not a number falls back as before. The application layers and standalone catalog entries no longer load the unbound factories themselves: a viewer with no renderer bound needs render/cesium/unbound loaded first. The contract and current-state docs say what the Cesium adapter's fields and surface shading do now.
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
import { findGlobe } from '../../render/rendererOf.js';
|
|
|
|
/** The darkest the relief shading gets, as an opacity. */
|
|
export const WIND_RELIEF_STRENGTH = 0.28;
|
|
|
|
/**
|
|
* View-directed display shading of the globe's relief while the wind layer
|
|
* shows: the globe port's `hillshade` surface shading (capability
|
|
* `surfaceShading`), over the terrain's own normals or, without them, the
|
|
* ellipsoid's curvature. It stands for no sun, changes no geometry and asks
|
|
* for no data. The renderer owns the material: it never takes one someone
|
|
* else holds, and gives it back when cleared. No animation or source
|
|
* acquisition.
|
|
*/
|
|
export function createWindRelief({ getViewer, globeOf = findGlobe } = {}) {
|
|
// The globe port shading for this layer, and the viewer it belongs to.
|
|
let globe = null;
|
|
let viewer = null;
|
|
let destroyed = false;
|
|
let reason = 'Not attached';
|
|
const alive = (value) => value && !value.isDestroyed?.();
|
|
|
|
function clear() {
|
|
if (globe && alive(viewer)) globe.setSurfaceShading(null);
|
|
globe = null;
|
|
viewer = null;
|
|
reason = destroyed ? 'Destroyed' : 'Not attached';
|
|
}
|
|
|
|
return {
|
|
attach() {
|
|
if (destroyed) return false;
|
|
const next = getViewer?.();
|
|
const port = alive(next) ? globeOf(next) : null;
|
|
if (globe && globe === port) return true;
|
|
clear();
|
|
if (typeof port?.setSurfaceShading !== 'function') {
|
|
reason = 'Globe material unavailable';
|
|
return false;
|
|
}
|
|
try {
|
|
port.setSurfaceShading({
|
|
kind: 'hillshade',
|
|
strength: WIND_RELIEF_STRENGTH,
|
|
});
|
|
} catch {
|
|
// The port may hold the request even though it could not draw it;
|
|
// take it back so it never shows up later, after Wind is off.
|
|
try {
|
|
port.setSurfaceShading(null);
|
|
} catch {
|
|
// Nothing was kept.
|
|
}
|
|
reason = 'Relief material unavailable';
|
|
return false;
|
|
}
|
|
globe = port;
|
|
viewer = next;
|
|
reason = null;
|
|
return true;
|
|
},
|
|
clear,
|
|
destroy() {
|
|
if (destroyed) return;
|
|
destroyed = true;
|
|
clear();
|
|
},
|
|
getDiagnostics() {
|
|
return {
|
|
active: globe !== null,
|
|
reason,
|
|
lighting: 'View-directed display shading',
|
|
mode: globe ? 'hillshade' : null,
|
|
maxOpacity: WIND_RELIEF_STRENGTH,
|
|
};
|
|
},
|
|
};
|
|
}
|