feat: Minecraft Clone MVP – prozedurale Welt, Blöcke, Abbauen/Setzen

- Weltgenerierung: FBM-Terrain, 3 Biome (Plains/Wald/Wüste), Höhlen, Wasser, Bäume
- Blöcke: Grass, Dirt, Stein, Sand, Holz, Blätter, Wasser (+Bedrock)
- Interaktion: DDA-Voxel-Raycast, Abbauen (LMB) & Setzen (RMB), Hotbar 1-6
- Spieler: First-Person, Gravitation, AABB-Kollision, Springen, Fly-Mode (F)
- Engine: Chunk-Streaming (16x16x64), Face-Culling, opaker+transparenter Pass
- Stack: Three.js + simplex-noise via CDN, prozedurale Texturen, kein Build-Step

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
minecraft-cloneandClaude committed 2026-06-20 23:55:12 +02:00
commit 1049253d54
15 files changed
+1436

No files matched your search

+93
View File
@@ -0,0 +1,93 @@
// Globale Konstanten und Block-/Biome-Definitionen
// --- Welt-Dimensionen ---
export const CHUNK_SIZE = 16; // X und Z Ausdehnung eines Chunks
export const CHUNK_HEIGHT = 64; // Y Ausdehnung eines Chunks
export const SEA_LEVEL = 26;
export const WORLD_SEED = 1337;
// --- Block-Typen ---
export const BLOCK = {
AIR: 0,
GRASS: 1,
DIRT: 2,
STONE: 3,
SAND: 4,
WOOD: 5,
LEAVES: 6,
WATER: 7,
BEDROCK: 8,
};
// Welche Bloecke fuer den Spieler nicht solide sind (keine Kollision, durchschaubar)
export function isTransparent(id) {
return id === BLOCK.AIR || id === BLOCK.WATER;
}
export function isSolid(id) {
return id !== BLOCK.AIR && id !== BLOCK.WATER;
}
// Wasser als einziger (halb-)transparenter Renderblock
export function isRenderTransparent(id) {
return id === BLOCK.WATER;
}
// --- Biome ---
export const BIOME = { PLAINS: 0, FOREST: 1, DESERT: 2 };
// --- Texturatlas ---
export const ATLAS_COLS = 16; // Tiles pro Reihe
export const TILE_PX = 16; // Pixel pro Tile
export const ATLAS_PX = ATLAS_COLS * TILE_PX; // 256
// Tile-Indizes im Atlas (Reihe 0)
export const TILE = {
GRASS_TOP: 0,
GRASS_SIDE: 1,
DIRT: 2,
STONE: 3,
SAND: 4,
WOOD_TOP: 5,
WOOD_SIDE: 6,
LEAVES: 7,
WATER: 8,
};
// Liefert (col,row) im Atlas fuer einen Block + Seite ('top'|'bottom'|'side')
export function tileFor(block, side) {
let idx;
switch (block) {
case BLOCK.GRASS:
idx = side === 'top' ? TILE.GRASS_TOP : side === 'bottom' ? TILE.DIRT : TILE.GRASS_SIDE;
break;
case BLOCK.DIRT: idx = TILE.DIRT; break;
case BLOCK.STONE: idx = TILE.STONE; break;
case BLOCK.SAND: idx = TILE.SAND; break;
case BLOCK.WOOD:
idx = (side === 'top' || side === 'bottom') ? TILE.WOOD_TOP : TILE.WOOD_SIDE;
break;
case BLOCK.LEAVES: idx = TILE.LEAVES; break;
case BLOCK.WATER: idx = TILE.WATER; break;
default: idx = TILE.STONE;
}
return { col: idx % ATLAS_COLS, row: Math.floor(idx / ATLAS_COLS) };
}
// Bloecke, die per Hotbar gesetzt werden koennen
export const HOTBAR = [
BLOCK.GRASS,
BLOCK.DIRT,
BLOCK.STONE,
BLOCK.SAND,
BLOCK.WOOD,
BLOCK.LEAVES,
];
// Anzeige-Farben pro Block fuer die Hotbar-Symbole
export const BLOCK_COLOR = {
[BLOCK.GRASS]: '#6ab04c',
[BLOCK.DIRT]: '#8b5a2b',
[BLOCK.STONE]: '#8a8a8a',
[BLOCK.SAND]: '#e6d8a8',
[BLOCK.WOOD]: '#6e4f2a',
[BLOCK.LEAVES]:'#3f8a2f',
};