feat: layer the nightdrive sky and atmosphere

This commit is contained in:
2026-09-02 14:52:03 +03:00
parent 3c932cb840
commit 5c52de9134
15 changed files with 801 additions and 168 deletions

View File

@@ -2,7 +2,7 @@ import * as THREE from 'three';
import type { EnvironmentChapter } from '@/journey/types';
import type { RenderQualitySettings } from '@/scene/render-quality';
import type { SceneResourceBag } from '@/scene/resources';
import { CHAPTER_PALETTES } from '@/scene/world/palette';
import { CHAPTER_PALETTES, type MutableChapterPalette } from '@/scene/world/palette';
export interface TerrainWorld {
group: WorldGroup;
@@ -11,6 +11,7 @@ export interface TerrainWorld {
speed: number,
chapter: EnvironmentChapter,
routeProgress: number,
palette?: Readonly<MutableChapterPalette>,
): void;
}
@@ -131,14 +132,19 @@ export function createTerrain(
return {
group,
update(distance, speed, chapter, routeProgress) {
const palette = CHAPTER_PALETTES[chapter];
update(distance, speed, chapter, routeProgress, palette) {
const chapterPalette = CHAPTER_PALETTES[chapter];
uniforms.uDistance.value = finiteOrZero(distance);
uniforms.uSpeed.value = clamp01(speed);
uniforms.uRouteProgress.value = clamp01(routeProgress);
uniforms.uTerrainEnergy.value = palette.terrainEnergy;
lowColor.setHex(palette.terrainLow);
highColor.setHex(palette.terrainHigh);
uniforms.uTerrainEnergy.value = palette?.terrainEnergy ?? chapterPalette.terrainEnergy;
if (palette) {
lowColor.copy(palette.terrainLow);
highColor.copy(palette.terrainHigh);
} else {
lowColor.setHex(chapterPalette.terrainLow);
highColor.setHex(chapterPalette.terrainHigh);
}
},
};
}