feat: build procedural lifecycle-safe drive scene
This commit is contained in:
33
src/scene/world/sun.ts
Normal file
33
src/scene/world/sun.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as THREE from 'three';
|
||||
import type { EnvironmentChapter } from '@/journey/types';
|
||||
import type { SceneResourceBag } from '@/scene/resources';
|
||||
|
||||
const chapterWarmth: Readonly<Record<EnvironmentChapter, number>> = {
|
||||
'deep-night': 0,
|
||||
systems: 0.12,
|
||||
infrastructure: 0.24,
|
||||
builds: 0.42,
|
||||
'pre-dawn': 0.68,
|
||||
destination: 1,
|
||||
};
|
||||
|
||||
export function createSun(resources: SceneResourceBag) {
|
||||
const geometry = resources.own('geometry', new THREE.CircleGeometry(18, 64));
|
||||
const material = resources.own('material', new THREE.MeshBasicMaterial({
|
||||
color: 0xff6f83,
|
||||
transparent: true,
|
||||
opacity: 0.82,
|
||||
fog: false,
|
||||
}));
|
||||
const mesh = new THREE.Mesh(geometry, material);
|
||||
mesh.position.set(0, 12, -128);
|
||||
|
||||
return {
|
||||
mesh,
|
||||
update(chapter: EnvironmentChapter, routeProgress: number) {
|
||||
const warmth = Math.max(chapterWarmth[chapter], routeProgress);
|
||||
material.color.setRGB(1, 0.34 + warmth * 0.24, 0.42 + warmth * 0.22);
|
||||
mesh.position.y = 12 + warmth * 5;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user