Add player-following light and darken dungeon surroundings
This commit is contained in:
+15
-2
@@ -39,6 +39,7 @@ export class Game {
|
|||||||
camera: THREE.PerspectiveCamera;
|
camera: THREE.PerspectiveCamera;
|
||||||
renderer: THREE.WebGLRenderer;
|
renderer: THREE.WebGLRenderer;
|
||||||
clock: THREE.Clock;
|
clock: THREE.Clock;
|
||||||
|
private playerLight!: THREE.PointLight;
|
||||||
|
|
||||||
player!: Player;
|
player!: Player;
|
||||||
enemies: Enemy[] = [];
|
enemies: Enemy[] = [];
|
||||||
@@ -359,10 +360,10 @@ export class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setupLighting() {
|
private setupLighting() {
|
||||||
const ambient = new THREE.AmbientLight(0x556688, 0.35);
|
const ambient = new THREE.AmbientLight(0x556688, 0.08);
|
||||||
this.scene.add(ambient);
|
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.position.set(30, 40, 20);
|
||||||
dirLight.castShadow = true;
|
dirLight.castShadow = true;
|
||||||
dirLight.shadow.mapSize.width = 1024;
|
dirLight.shadow.mapSize.width = 1024;
|
||||||
@@ -374,6 +375,11 @@ export class Game {
|
|||||||
dirLight.shadow.camera.top = 60;
|
dirLight.shadow.camera.top = 60;
|
||||||
dirLight.shadow.camera.bottom = -60;
|
dirLight.shadow.camera.bottom = -60;
|
||||||
this.scene.add(dirLight);
|
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() {
|
private setupArena() {
|
||||||
@@ -1256,6 +1262,13 @@ export class Game {
|
|||||||
this.player.body.position.z
|
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
|
// Clean dead enemies
|
||||||
for (let i = this.enemies.length - 1; i >= 0; i--) {
|
for (let i = this.enemies.length - 1; i >= 0; i--) {
|
||||||
const enemy = this.enemies[i];
|
const enemy = this.enemies[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user