mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(globe): a daylight sky and no daytime stars in the cinematic look
The atmosphere draws physical radiance scaled for an exposure near 10, while the baked Google tiles need exposure 1, so the noon sky came out dark navy with the stars showing through. The cinematic look now scales the atmosphere's radiance-to-luminance factors (sky, aerial perspective, clouds) by 3, leaving the tiles alone, and shows its stars only from space or with the sun below -6 degrees at the camera. Gallery regenerated.
This commit is contained in:
1 parent
bb8c0b83c4
commit
abf16ae8af
7 files changed
+430
-23
No files matched your search
@@ -1,13 +1,16 @@
|
||||
// Builds a Navara look (viewOptions.js navaraScenePlan) on an initialised
|
||||
// view and keeps it current while the view renders: the sun follows the wall
|
||||
// clock as the HUD's SUN elevation does; the cinematic look lights the globe
|
||||
// from the atmosphere when seen from space and shows its clouds only for low
|
||||
// views over low ground. All of it runs only on frames the view draws
|
||||
// from the atmosphere when seen from space, shows its clouds only for low
|
||||
// views over low ground, brightens the atmosphere (atmosphereLuminance.js)
|
||||
// and shows its stars only at night or from space. All of it runs only on frames the view draws
|
||||
// anyway, so an idle view stays idle.
|
||||
|
||||
import { createAtmosphereLuminance } from './atmosphereLuminance.js';
|
||||
import {
|
||||
cloudsVisibleAt,
|
||||
globeLightingAt,
|
||||
starsVisibleAt,
|
||||
sunDateStale,
|
||||
} from './viewOptions.js';
|
||||
|
||||
@@ -15,11 +18,12 @@ import {
|
||||
* @param {object} view an initialised ThreeView with the default plugin
|
||||
* @param {object} plugin its DefaultPlugin
|
||||
* @param {ReturnType<import('./viewOptions.js').navaraScenePlan>} plan
|
||||
* @returns {{ handles: object[], frame: (height: number, moving?: boolean, ground?: number) => boolean }}
|
||||
* @returns {{ handles: object[], frame: (height: number, moving?: boolean, ground?: number, place?: { lat: number, lng: number } | null) => boolean }}
|
||||
* `frame` is called before each frame with the camera height, whether the
|
||||
* camera is moving and the height of the ground in view (metres above the
|
||||
* ellipsoid, NaN when unknown); it returns true when it changed the scene,
|
||||
* so the caller draws one more frame.
|
||||
* camera is moving, the height of the ground in view (metres above the
|
||||
* ellipsoid, NaN when unknown) and the camera's place (degrees, for the
|
||||
* sun's elevation there); it returns true when it changed the scene, so
|
||||
* the caller draws one more frame.
|
||||
*/
|
||||
export function buildNavaraLook(view, plugin, plan, now = () => Date.now()) {
|
||||
const handles = [];
|
||||
@@ -37,13 +41,26 @@ export function buildNavaraLook(view, plugin, plan, now = () => Date.now()) {
|
||||
? null
|
||||
: handles[plan.meshes.length + plan.lights.length + at];
|
||||
};
|
||||
const mesh = (name) => {
|
||||
const at = plan.meshes.findIndex((desc) => Object.hasOwn(desc, name));
|
||||
return at < 0 ? null : handles[at];
|
||||
};
|
||||
const aerial = plan.globeLighting ? effect('aerialPerspective') : null;
|
||||
const clouds = effect('clouds');
|
||||
const stars = plan.daylightHidesStars ? mesh('stars') : null;
|
||||
const atmosphereHandles = {
|
||||
sky: mesh('sky'),
|
||||
aerialPerspective: effect('aerialPerspective'),
|
||||
clouds,
|
||||
};
|
||||
const brighten = createAtmosphereLuminance(plan.atmosphereLuminance ?? 1);
|
||||
let globeLit = false;
|
||||
let cloudsShown = true;
|
||||
let starsShown = true;
|
||||
|
||||
const frame = (height, moving = false, ground = Number.NaN) => {
|
||||
let changed = false;
|
||||
const frame = (height, moving = false, ground = Number.NaN, place = null) => {
|
||||
// Every drawn frame: a material Navara rebuilds comes back unscaled.
|
||||
let changed = brighten(atmosphereHandles);
|
||||
const atmosphere = view.atmosphere;
|
||||
if (atmosphere && sunDateStale(atmosphere.date.getTime(), now())) {
|
||||
atmosphere.date = new Date(now());
|
||||
@@ -75,6 +92,18 @@ export function buildNavaraLook(view, plugin, plan, now = () => Date.now()) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (stars) {
|
||||
const elevation =
|
||||
place && typeof atmosphere?.getSunElevation === 'function'
|
||||
? atmosphere.getSunElevation(place)
|
||||
: Number.NaN;
|
||||
const next = starsVisibleAt(height, elevation, starsShown);
|
||||
if (next !== starsShown) {
|
||||
starsShown = next;
|
||||
stars.update({ visible: next });
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
};
|
||||
return { handles, frame };
|
||||
|
||||
Reference in new issue
Block a user