export const TILE_PX = 256; export const WORLD_HALF = 16384; // gtadb-Weltgrenze in Metern export const CHUNK_SIZE = 250; export const SLICE = { x0: -1000, x1: 2000, y0: -500, y1: 2500 }; export const CHUNKS_PER_SIDE = (SLICE.x1 - SLICE.x0) / CHUNK_SIZE; // 12 export const worldToThree = (X, Y) => ({ x: X, z: -Y }); export const threeToWorld = (x, z) => ({ X: x, Y: -z }); export function tileForWorld(X, Y) { return { row: Math.floor((WORLD_HALF - Y) / TILE_PX), col: Math.floor((X + WORLD_HALF) / TILE_PX), }; } export function chunkForWorld(X, Y) { return { i: Math.floor((X - SLICE.x0) / CHUNK_SIZE), j: Math.floor((SLICE.y1 - Y) / CHUNK_SIZE), }; } /** Nordwest-Ecke eines Chunks in Weltkoordinaten. */ export function chunkOrigin(i, j) { return { X: SLICE.x0 + i * CHUNK_SIZE, Y: SLICE.y1 - j * CHUNK_SIZE }; }