// Lädt das HDRI "Nowhere Road" (Poly Haven, CC0) in 4k als Radiance-.hdr nach public/textures/. // Dasselbe Bild wie das 84-MB-EXR von Poly Haven, als RGBE aber nur ein Drittel so groß und ohne // eigenen Encoder — src/world/sky.js macht daraus Himmel, Umgebungslicht und Sonne. import { createHash } from "node:crypto"; import { mkdir, writeFile } from "node:fs/promises"; const UA = { "User-Agent": "leonida-assets/0.1 (local hobby project)" }; const SLUG = "nowhere_road"; const RESOLUTION = "4k"; const files = await (await fetch(`https://api.polyhaven.com/files/${SLUG}`, { headers: UA })).json(); const entry = files.hdri?.[RESOLUTION]?.hdr; if (!entry) throw new Error(`${SLUG}: kein ${RESOLUTION}-HDR bei Poly Haven`); const buf = Buffer.from(await (await fetch(entry.url, { headers: UA })).arrayBuffer()); // Ein abgebrochener Download ergäbe ein halbes Panorama, das HDRLoader trotzdem still lädt. const md5 = createHash("md5").update(buf).digest("hex"); if (md5 !== entry.md5) throw new Error(`${SLUG}: MD5 ${md5} statt ${entry.md5}`); await mkdir("public/textures", { recursive: true }); await writeFile(`public/textures/${SLUG}_${RESOLUTION}.hdr`, buf); console.log(`${SLUG}_${RESOLUTION}.hdr ${(buf.length / 1e6).toFixed(1)} MB`);