t2-mapper/docs/assets/loaders-5n1D4iOD.js
2026-04-08 23:48:42 -07:00

1 line
No EOL
2.4 KiB
JavaScript
Raw Permalink Blame History

import{t as e}from"./logger-B058WGzf.js";import{c as t,n,s as r,t as i}from"./manifest-BIDT_vSa.js";import{a}from"./stringUtils-1MyeFdQ_.js";import{a as o}from"./mission-yeigCtfF.js";function s(e){return e.split(/(?:\r\n|\r|\n)/g).map(e=>e.trim()).filter(Boolean).filter(e=>!e.startsWith(`;`)).map(e=>{let t=e.match(/^(.+)\s(\d+)$/);if(t){let e=parseInt(t[2],10);return{name:t[1],frameCount:e}}else return{name:e,frameCount:1}})}var c=256;function l(e){let t=new DataView(e),n=0,r=t.getUint8(n++),i=new Uint16Array(c*c),a=[],o=e=>{let r=``;for(let i=0;i<e;i++){let e=t.getUint8(n+i);if(e===0)break;r+=String.fromCharCode(e)}return n+=e,r};for(let e=0;e<c*c;e++){let r=t.getUint16(n,!0);n+=2,i[e]=r}n+=256*256;let s=i;for(let e=0;e<8;e++){let r=t.getUint8(n++),i=o(r);e<6&&r>0&&a.push(i)}let l=[];for(let e of a){let e=new Uint8Array(c*c);for(let r=0;r<c*c;r++)e[r]=t.getUint8(n++);l.push(e)}return{version:r,textureNames:a,heightMap:s,alphaMaps:l}}var u=e(`loaders`),d=`/t2-mapper/base/`,f=`/t2-mapper/white.png`;function p(e,t){let n;try{n=i(e)}catch(n){if(t)return u.warn(`Resource "%s" not found — rendering fallback`,e),t;throw n}let[a,o]=r(n);return a?`${d}@vl2/${a}/${o}`:`${d}${o}`}function m(e){return p(`interiors/${e}`).replace(/\.dif$/i,`.glb`)}function h(e){return p(`shapes/${e}`).replace(/\.dts$/i,`.glb`)}function g(e){return e=e.replace(/^terrain\./,``),p(t(`textures/terrain/${e}`),f)}function _(e,n){let r=a(n).split(`/`);return p(t(`${r.length>1?r.slice(0,-1).join(`/`)+`/`:``}${e}`),f)}function v(e,n=f){return p(t(`textures/${e}`),n??void 0)}function y(e){return p(`audio/${/\.\w+$/.test(e)?e:`${e}.wav`}`).replace(/\.wav$/i,`.m4a`)}async function b(e){let t=p(`textures/${e}`);return(await(await fetch(t)).text()).split(/(?:\r\n|\r|\n)/).map(e=>{if(e=e.trim(),!e.startsWith(`;`))return e}).filter(Boolean)}async function x(e){let t=n(e),r=await(await fetch(p(t.resourcePath))).arrayBuffer(),i;try{i=new TextDecoder(`utf-8`,{fatal:!0}).decode(r)}catch{i=new TextDecoder(`windows-1252`).decode(r)}return i=i.replaceAll(`<EFBFBD>`,`'`),o(i)}async function S(e){let t=p(`terrains/${e}`);u.debug(`Fetching terrain: %s`,t);let n=await fetch(t);if(!n.ok)throw Error(`[loadTerrain] Failed to fetch ${t}: ${n.status} ${n.statusText}`);let r=await n.arrayBuffer();return u.debug(`Loaded terrain %s: %d bytes`,e,r.byteLength),l(r)}async function C(e){let t=p(e);return s(await(await fetch(t)).text())}export{_ as a,C as c,h as d,g as f,p as i,x as l,d as n,m as o,v as p,y as r,b as s,f as t,S as u};