mirror of
git://soft.sys114.com/mainsail
synced 2026-02-04 13:10:36 +09:00
2 lines
2.5 KiB
JavaScript
2 lines
2.5 KiB
JavaScript
import"./Viewer-DVCEMRp5.js";import"./vuetify-Ce4WN_Dg.js";import"./overlayscrollbars-CiKU261J.js";import"./index-Bku7SJna.js";import"./echarts-DzoUeqWp.js";import"./codemirror-ZSHHXwGs.js";function A(t,e){return e>1023?t*Math.pow(2,1023)*Math.pow(2,e-1023):e<-1074?t*Math.pow(2,-1074)*Math.pow(2,e+1074):t*Math.pow(2,e)}function R(t,e,a,i,r,l){r>0?(r=A(1,r-136),t[l+0]=e*r,t[l+1]=a*r,t[l+2]=i*r):(t[l+0]=0,t[l+1]=0,t[l+2]=0)}function g(t,e){let a="",i="";for(let r=e;r<t.length-e&&(i=String.fromCharCode(t[r]),i!="\n");r++)a+=i;return a}function D(t){let e=0,a=0,i=g(t,0);if(i[0]!="#"||i[1]!="?")throw"Bad HDR Format.";let r=!1,l=!1,s=0;do s+=i.length+1,i=g(t,s),i=="FORMAT=32-bit_rle_rgbe"?l=!0:i.length==0&&(r=!0);while(!r);if(!l)throw"HDR Bad header format, unsupported FORMAT";s+=i.length+1,i=g(t,s);const n=/^-Y (.*) \+X (.*)$/g.exec(i);if(!n||n.length<3)throw"HDR Bad header format, no size";if(a=parseInt(n[2]),e=parseInt(n[1]),a<8||a>32767)throw"HDR Bad header format, unsupported size";return s+=i.length+1,{height:e,width:a,dataPosition:s}}function b(t,e){return _(t,e)}function _(t,e){let a=e.height;const i=e.width;let r,l,s,c,n,o=e.dataPosition,f=0,d=0,h=0;const m=new ArrayBuffer(i*4),w=new Uint8Array(m),B=new ArrayBuffer(e.width*e.height*4*3),u=new Float32Array(B);for(;a>0;){if(r=t[o++],l=t[o++],s=t[o++],c=t[o++],r!=2||l!=2||s&128||e.width<8||e.width>32767)return H(t,e);if((s<<8|c)!=i)throw"HDR Bad header format, wrong scan line width";for(f=0,h=0;h<4;h++)for(d=(h+1)*i;f<d;)if(r=t[o++],l=t[o++],r>128){if(n=r-128,n==0||n>d-f)throw"HDR Bad Format, bad scanline data (run)";for(;n-- >0;)w[f++]=l}else{if(n=r,n==0||n>d-f)throw"HDR Bad Format, bad scanline data (non-run)";if(w[f++]=l,--n>0)for(let p=0;p<n;p++)w[f++]=t[o++]}for(h=0;h<i;h++)r=w[h],l=w[h+i],s=w[h+2*i],c=w[h+3*i],R(u,r,l,s,c,(e.height-a)*i*3+h*3);a--}return u}function H(t,e){let a=e.height;const i=e.width;let r,l,s,c,n,o=e.dataPosition;const f=new ArrayBuffer(e.width*e.height*4*3),d=new Float32Array(f);for(;a>0;){for(n=0;n<e.width;n++)r=t[o++],l=t[o++],s=t[o++],c=t[o++],R(d,r,l,s,c,(e.height-a)*i*3+n*3);a--}return d}class C{constructor(){this.supportCascades=!1}loadCubeData(){throw".env not supported in Cube."}loadData(e,a,i){const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),l=D(r),s=b(r,l),c=l.width*l.height,n=new Float32Array(c*4);for(let o=0;o<c;o+=1)n[o*4]=s[o*3],n[o*4+1]=s[o*3+1],n[o*4+2]=s[o*3+2],n[o*4+3]=1;i(l.width,l.height,a.generateMipMaps,!1,()=>{const o=a.getEngine();a.type=1,a.format=5,a._gammaSpace=!1,o._uploadDataToTextureDirectly(a,n)})}}export{C as _HDRTextureLoader};
|