Add player-following light and darken dungeon surroundings

This commit is contained in:
2026-08-19 09:52:51 +02:00
parent 110a8596a5
commit 18d8654d9d
+15 -2
View File
@@ -39,6 +39,7 @@ export class Game {
camera: THREE.PerspectiveCamera;
renderer: THREE.WebGLRenderer;
clock: THREE.Clock;
private playerLight!: THREE.PointLight;
player!: Player;
enemies: Enemy[] = [];
@@ -359,10 +360,10 @@ export class Game {
}
private setupLighting() {
const ambient = new THREE.AmbientLight(0x556688, 0.35);
const ambient = new THREE.AmbientLight(0x556688, 0.08);
this.scene.add(ambient);
const dirLight = new THREE.DirectionalLight(0xccddff, 0.55);
const dirLight = new THREE.DirectionalLight(0xccddff, 0.15);
dirLight.position.set(30, 40, 20);
dirLight.castShadow = true;
dirLight.shadow.mapSize.width = 1024;
@@ -374,6 +375,11 @@ export class Game {
dirLight.shadow.camera.top = 60;
dirLight.shadow.camera.bottom = -60;
this.scene.add(dirLight);
// Lichtschein um den Spieler: Radius erhellt Umgebung, außerhalb wird es dunkler
this.playerLight = new THREE.PointLight(0xffeebb, 90, 20, 2);
this.playerLight.position.set(0, 6, 0);
this.scene.add(this.playerLight);
}
private setupArena() {
@@ -1256,6 +1262,13 @@ export class Game {
this.player.body.position.z
);
// Lichtschein folgt dem Spieler
this.playerLight.position.set(
this.player.body.position.x,
6,
this.player.body.position.z
);
// Clean dead enemies
for (let i = this.enemies.length - 1; i >= 0; i--) {
const enemy = this.enemies[i];