diff --git a/src/main.js b/src/main.js index c21e8d6..bdb0c78 100644 --- a/src/main.js +++ b/src/main.js @@ -790,13 +790,21 @@ async function renderRoom(room) { entities: [] }; + // Renderizar tile // Renderizar tile const tileDef = ASSETS.tiles[room.tile.type]; - const tileTex = await loadTexture(tileDef.src); + const baseTex = await loadTexture(tileDef.src); + const tileTex = baseTex.clone(); // CLONAR para no afectar a otras salas + tileTex.needsUpdate = true; // Asegurar que Three.js sepa que es nueva + tileTex.wrapS = THREE.RepeatWrapping; tileTex.wrapT = THREE.RepeatWrapping; - // Ajustar repetición según tamaño real de la sala para evitar estiramiento - tileTex.repeat.set(tileDef.width / 4, tileDef.height / 4); + + // Lógica de repetición: La textura base es de 4x4 celdas. + // Si la sala es 8x4, repetimos 2 en X, 1 en Y. + const repeatX = tileDef.width / 4; + const repeatY = tileDef.height / 4; + tileTex.repeat.set(repeatX, repeatY); const worldWidth = tileDef.width * CONFIG.CELL_SIZE; const worldHeight = tileDef.height * CONFIG.CELL_SIZE;