mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
feat(render): a renderer can draw weather: the weather capability adds globe.weather (clouds, fog, haze, rain and snow, 0 to 1, and the wind they drift on); the view shows the conditions observed under the camera, and the Display panel's Weather group sets them by hand
This commit is contained in:
1 parent
639e92b4f7
commit
0b1dc325bc
29 files changed
+869
-27
No files matched your search
Vendored
+2
@@ -152,6 +152,8 @@ export type Capability =
|
||||
| 'terrain'
|
||||
/** Atmosphere scattering applied to drawn models. */
|
||||
| 'modelAtmosphere'
|
||||
/** Clouds, fog, haze, rain and snow around the view (`globe.weather`). */
|
||||
| 'weather'
|
||||
/** Imagery draped onto 3D tiles as well as the globe. */
|
||||
| 'imageryOnTiles'
|
||||
/** A screen-split comparison between imagery layers. */
|
||||
|
||||
@@ -76,20 +76,26 @@ function nestedShape(type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** `[member, optional]` for every member, nested shapes dotted. */
|
||||
function members(type, prefix = '') {
|
||||
/**
|
||||
* `[member, optional]` for every member, nested shapes dotted; a member of
|
||||
* an optional shape is as optional as the shape.
|
||||
*/
|
||||
function members(type, prefix = '', inOptional = false) {
|
||||
const out = [];
|
||||
for (const property of checker.getPropertiesOfType(type)) {
|
||||
const name = `${prefix}${property.name}`;
|
||||
const optional = Boolean(property.flags & ts.SymbolFlags.Optional);
|
||||
const optional =
|
||||
inOptional || Boolean(property.flags & ts.SymbolFlags.Optional);
|
||||
out.push([name, optional]);
|
||||
const declaration = property.valueDeclaration ?? property.declarations?.[0];
|
||||
const propertyType = checker.getTypeOfSymbolAtLocation(
|
||||
property,
|
||||
declaration,
|
||||
);
|
||||
const declared = checker.getTypeOfSymbolAtLocation(property, declaration);
|
||||
// An optional member's shape, without the `undefined` its `?` adds.
|
||||
const propertyType =
|
||||
property.flags & ts.SymbolFlags.Optional
|
||||
? checker.getNonNullableType(declared)
|
||||
: declared;
|
||||
const nested = nestedShape(propertyType);
|
||||
if (nested) out.push(...members(nested, `${name}.`));
|
||||
if (nested) out.push(...members(nested, `${name}.`, optional));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Vendored
+42
@@ -215,6 +215,36 @@ export interface SkySettings {
|
||||
lighting: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* `weather`: the conditions drawn around the view. Each strength is 0..1,
|
||||
* 0 drawing none of it; all are 0 at first. Clouds are a layer above the
|
||||
* ground that the camera can fly into and above; fog and haze thin what is
|
||||
* seen with distance, fog close in, haze far off; rain and snow fall around
|
||||
* the eye below the clouds and are not drawn from above them. A renderer
|
||||
* fades what makes no sense at the camera's height (rain from orbit) by
|
||||
* itself. None of it is picked or answers height queries. The application sets the
|
||||
* conditions observed at the view, which the user can override.
|
||||
*/
|
||||
export interface WeatherSettings {
|
||||
/** Cloud cover. */
|
||||
clouds: number;
|
||||
/** Fog: 1 is about 500 m visibility or less. */
|
||||
fog: number;
|
||||
/** Haze. */
|
||||
haze: number;
|
||||
/** Rain. */
|
||||
rain: number;
|
||||
/** Snow. */
|
||||
snow: number;
|
||||
/** What the clouds and precipitation drift with. */
|
||||
wind: {
|
||||
/** Metres per second. */
|
||||
speedMps: number;
|
||||
/** Where the wind blows from, degrees clockwise from north. */
|
||||
fromDeg: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* View-lit shading of the drawn terrain's own relief (the ellipsoid's
|
||||
* curvature where terrain has no normals); darkens only, at most
|
||||
@@ -295,6 +325,18 @@ export interface GlobePort {
|
||||
get(): SkySettings;
|
||||
set(settings: Partial<SkySettings>): void;
|
||||
};
|
||||
/**
|
||||
* `weather`. `set` keeps each strength it is not given or given as no
|
||||
* number, clamps the others to 0..1, and asks for a frame. `wind` is taken
|
||||
* whole: a speed below 0 or missing is 0, the direction is wrapped into
|
||||
* [0, 360) and a missing one is 0. `get` answers a copy of what was set;
|
||||
* at first every strength and the wind speed are 0 (`CLEAR_WEATHER` in
|
||||
* `src/render/weather.js`, whose `mergeWeather` is these rules).
|
||||
*/
|
||||
readonly weather?: {
|
||||
get(): WeatherSettings;
|
||||
set(settings: Partial<WeatherSettings>): void;
|
||||
};
|
||||
/** Whether that part of the base has finished loading what is in view. */
|
||||
isSettled(kind: SettleKind): boolean;
|
||||
on(event: 'progress', cb: (progress: LoadProgress) => void): Off;
|
||||
|
||||
@@ -19,6 +19,7 @@ export const CAPABILITIES = Object.freeze([
|
||||
'finestHeights',
|
||||
'terrain',
|
||||
'modelAtmosphere',
|
||||
'weather',
|
||||
'imageryOnTiles',
|
||||
'splitSwipe',
|
||||
'imageryFrames',
|
||||
@@ -147,6 +148,9 @@ export const PORTS = deepFreeze({
|
||||
['setSurfaceShading', 'surfaceShading'],
|
||||
['imagery.getSplit', 'splitSwipe'],
|
||||
['imagery.setSplit', 'splitSwipe'],
|
||||
['weather', 'weather'],
|
||||
['weather.get', 'weather'],
|
||||
['weather.set', 'weather'],
|
||||
]),
|
||||
draw: Object.fromEntries([
|
||||
...required(
|
||||
@@ -353,6 +357,7 @@ export const ROLES = deepFreeze([
|
||||
members: [
|
||||
'effects',
|
||||
'globe.sky',
|
||||
'globe.weather',
|
||||
'globe.setSurfaceShading',
|
||||
'imageryLayer.lit',
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user