feat: shadows, baked vertex AO, post-processing + central config.js

Visuals:
- PCFSoftShadowMap (2048²), directional light follows player with a tight
  shadow frustum (SHADOW_AREA) for high texel density; opak blocks cast+receive,
  water receives.
- Baked vertex ambient occlusion ("smooth lighting"): per-vertex solid-neighbor
  lookup (0fps algorithm) written into a color attribute, with flip-triangulation
  to avoid brightness seams across quad diagonals.
- EffectComposer: RenderPass -> UnrealBloomPass (subtle) -> OutputPass with
  ACES filmic tone-mapping + sRGB. HalfFloat render target (anti-banding) + MSAA.

Controls:
- Sprint moved from Ctrl to Shift (Ctrl is problematic in browsers). Shift in
  fly mode still means "descend" (no conflict, sprint only applies when walking).

config.js:
- New central js/config.js for all tweakable values (world, performance,
  renderer/tone-mapping, sky & fog, camera, lighting, shadows, bloom, AO,
  player physics, mouse sensitivity, reach) with SHADOWS_ENABLED / BLOOM_ENABLED
  feature toggles. Structural engine constants stay in constants.js.
- SEA_LEVEL / WORLD_SEED moved constants.js -> config.js (consumers rewired).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
minecraft-cloneandClaude committed 2026-06-21 00:46:03 +02:00
1 parent 1049253d54
commit f009789c42
9 files changed
+282 -59

No files matched your search

+9 -11
View File
@@ -1,16 +1,10 @@
// First-Person-Spieler: Bewegung, Gravitation, AABB-Kollision, Springen,
// Flug-Modus, Schwimmen. yaw/pitch steuern die Kamera (extern gesetzt).
import { isSolid, BLOCK } from './constants.js';
import { PLAYER, MOUSE_SENSITIVITY } from './config.js';
const HALF = 0.3; // halbe Spielerbreite (X/Z)
const HEIGHT = 1.8; // Spielerhoehe
const EYE = 1.62; // Augenposition ueber den Fuessen
const GRAVITY = 26;
const JUMP_VEL = 8.6;
const WALK = 4.7;
const SPRINT = 7.2;
const FLY_SPEED = 9.5;
const MAX_FALL = 50;
// Werte aus config.js (PLAYER). Lokal gebunden, damit die Verwendungen kurz bleiben.
const { HALF, HEIGHT, EYE, GRAVITY, JUMP_VEL, WALK, SPRINT, FLY_SPEED, MAX_FALL } = PLAYER;
export class Player {
constructor(world) {
@@ -43,7 +37,7 @@ export class Player {
update(input, dt) {
// --- Maus-Look ---
const sens = 0.0022;
const sens = MOUSE_SENSITIVITY;
this.yaw -= input.mouseDX * sens;
this.pitch -= input.mouseDY * sens;
const lim = Math.PI / 2 - 0.001;
@@ -71,7 +65,11 @@ export class Player {
const len = Math.hypot(mx, mz);
if (len > 0) { mx /= len; mz /= len; }
const speed = this.flying ? FLY_SPEED : (input.down('ControlLeft') ? SPRINT : WALK);
// Sprint: Shift (Ctrl ist im Browser unbequem – Browser-Shortcuts).
// ShiftLeft/Right dient im Fly-Modus gleichzeitig als "Runter" – kein
// Konflikt, da Sprint nur beim Gehen greift (Fly nutzt konstante FLY_SPEED).
const sprint = input.down('ShiftLeft') || input.down('ShiftRight');
const speed = this.flying ? FLY_SPEED : (sprint ? SPRINT : WALK);
if (this.flying) {
this.vel[0] = mx * speed;