// Lädt die benötigten Poly-Haven-Texturen in 1k nach public/textures/. Vorhandene Dateien bleiben // unangetastet, damit ein neuer Eintrag die übrigen Texturen nicht still ändert. import { existsSync } from "node:fs"; import { mkdir, writeFile } from "node:fs/promises"; const UA = { "User-Agent": "leonida-assets/0.1 (local hobby project)" }; const SLUGS = ["asphalt_02", "concrete_pavement_03", "white_stucco", "sand_01", "leafy_grass", "grass_path_2", "palm_bark", "concrete_pavement", "brushed_concrete_04"]; const MAPS = ["Diffuse", "nor_gl", "arm"]; await mkdir("public/textures", { recursive: true }); for (const slug of SLUGS) { if (MAPS.every((map) => existsSync(`public/textures/${slug}_${map}.jpg`))) continue; const files = await (await fetch(`https://api.polyhaven.com/files/${slug}`, { headers: UA })).json(); for (const map of MAPS) { const target = `public/textures/${slug}_${map}.jpg`; if (existsSync(target)) continue; const entry = files[map]?.["1k"]?.jpg; if (!entry) { console.warn(`${slug}: ${map} fehlt`); continue; } const buf = Buffer.from(await (await fetch(entry.url, { headers: UA })).arrayBuffer()); await writeFile(target, buf); console.log(`${slug}_${map}.jpg ${(buf.length / 1e6).toFixed(1)} MB`); } } // modular_sidewalk_curb_kit (Just8, CC BY 4.0) wird nicht mehr gebraucht. Der Gehweg nimmt seit der // Gehwegtextur-Korrektur concrete_pavement, der Bordstein seit dem Bordstein-Befund // brushed_concrete_04 - beide von Poly Haven (CC0) und beide oben in SLUGS. Die Geometrie des // Bordsteins war ohnehin selbst gebaut (s. src/world/geometry.js, kerbGeometry).