go-viee-fetch-Demo/public/static/lib/plugin/ht-textureLoader.js

1 line
252 KiB
JavaScript
Raw Normal View History

2025-08-25 20:25:55 +08:00
!function(r){"use strict";function R(R,z){function O(R,z){switch(R){case W:console.error("Parse RGBE failed, read Error: "+(z||""));break;case y:console.error("Parse RGBE failed, write Error: "+(z||""));break;case x:console.error("Parse RGBE failed, bad File Format: "+(z||""));break;default:console.error("Parse RGBE failed, error: "+(z||""))}return I}function p(R,z,d){z=z||1024;for(var r=R.pos,G=-1,C=0,T="",X=String.fromCharCode.apply(null,new Uint16Array(R.subarray(r,r+128)));(G=X.indexOf($))<0&&C<z&&r<R.byteLength;)T+=X,C+=X.length,r+=128,X+=String.fromCharCode.apply(null,new Uint16Array(R.subarray(r,r+128)));return-1<G&&(!1!==d&&(R.pos+=C+G+1),T+X.slice(0,G))}var d,r,G,C,T,X,E,s,o,n,I=-1,W=1,y=2,x=3,B=4,$="\n",i=((R=new Uint8Array(R)).pos=0,function(R){var z,d,r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,G=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,C=/^\s*FORMAT=(\S+)\s*$/,T=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,X={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(R.pos>=R.byteLength||!(z=p(R)))return O(W,"no header found");if(!(d=z.match(/^#\?(\S+)/)))return O(x,"bad initial token");for(X.valid|=1,X.programtype=d[1],X.string+=z+"\n";;){if(!1===(z=p(R)))break;if(X.string+=z+"\n","#"===z.charAt(0))X.comments+=z+"\n";else if((d=z.match(r))&&(X.gamma=parseFloat(d[1])),(d=z.match(G))&&(X.exposure=parseFloat(d[1])),(d=z.match(C))&&(X.valid|=2,X.format=d[1]),(d=z.match(T))&&(X.valid|=4,X.height=parseInt(d[1],10),X.width=parseInt(d[2],10)),2&X.valid&&4&X.valid)break}return 2&X.valid?4&X.valid?X:O(x,"missing image size specifier"):O(x,"missing format specifier")}(R));if(I!==i){var U,j=i.width,V=i.height,e=function(R,z,d){var r=z;if(r<8||32767<r||2!==R[0]||2!==R[1]||128&R[2])return new Uint8Array(R);if(r!==(R[2]<<8|R[3]))return O(x,"wrong scanline width");var G=new Uint8Array(4*z*d);if(!G.length)return O(B,"unable to allocate buffer space");for(var C=0,T=0,X=4*r,p=new Uint8Array(4),E=new Uint8Array(X),s=d;0<s&&T<R.byteLength;){if(T+4>R.byteLength)return O(W);if(p[0]=R[T++],p[1]=R[T++],p[2]=R[T++],p[3]=R[T++],2!=p[0]||2!=p[1]||(p[2]<<8|p[3])!=r)return O(x,"bad rgbe scanline format");for(var o=0;o<X&&T<R.byteLength;){var n,I=128<(n=R[T++]);if(I&&(n-=128),0===n||X<o+n)return O(x,"bad scanline data");if(I)for(var y=R[T++],$=0;$<n;$++)E[o++]=y;else E.set(R.subarray(T,T+n),o),o+=n,T+=n}for(var i=r,$=0;$<i;$++){var U=0;G[C]=E[$+0],U+=r,G[C+1]=E[$+U],U+=r,G[C+2]=E[$+U],U+=r,G[C+3]=E[$+U],C+=4}s--}return G}(R.subarray(R.pos),j,V);if(I!==e){if(5126===z){for(var Z=e.length/4,h=new Float32Array(4*Z),K=0;K<Z;K++)s=h,o=E=4*K,n=void 0,n=(X=e)[E+3],n=Math.pow(2,n-128)/255,s[o+0]=X[E+0]*n,s[o+1]=X[E+1]*n,s[o+2]=X[E+2]*n,s[o+3]=1;U=h}else{Z=e.length/4;for(var m=new Uint16Array(4*Z),K=0;K<Z;K++)G=m,C=r=4*K,T=void 0,T=(d=e)[r+3],T=Math.pow(2,T-128)/255,G[C+0]=b(Math.min(d[r+0]*T,65504)),G[C+1]=b(Math.min(d[r+1]*T,65504)),G[C+2]=b(Math.min(d[r+2]*T,65504)),G[C+3]=b(1);U=m,z=5131}return{width:j,height:V,data:U,header:i.string,gamma:i.gamma,exposure:i.exposure,format:void 0,type:z}}}return null}var z,d,G,C,y,$,T,X=ht.Default,b=(ht.graph3d.WebGLConstants,function(){for(var R=new ArrayBuffer(4),d=new Float32Array(R),R=(new Uint32Array(R),new ArrayBuffer(4)),d=new Float32Array(R),r=new Uint32Array(R),G=new Uint32Array(512),C=new Uint32Array(512),z=0;z<256;++z)(s=z-127)<-27?(G[z]=0,G[256|z]=32768,C[z]=24,C[256|z]=24):s<-14?(G[z]=1024>>-s-14,G[256|z]=1024>>-s-14|32768,C[z]=-s-1,C[256|z]=-s-1):s<=15?(G[z]=s+15<<10,G[256|z]=s+15<<10|32768,C[z]=13,C[256|z]=13):s<128?(G[z]=31744,G[256|z]=64512,C[z]=24,C[256|z]=24):(G[z]=31744,G[256|z]=64512,C[z]=13,C[256|z]=13);for(var T=new Uint32Array(2048),X=new Uint32Array(64),p=new Uint32Array(64),z=1;z<1024;++z){for(var E=z<<13,s=0;0==(8388608&E);)E<<=1,s-=8388608;E&=-8388609,s+=947912704,T[z]=E|s}for(z=1024;z<2048;++z)T[z]=939524096+(z-1024<<13);for(z=1;z<31;++z)X[z]=z<<23;X[31]=1199570944,X[32]=2147483648;for(z=33;z<63;++z)X[z]=2147483648+(z-32<<23);X[63]=3347054592;for(z=1;z<64;++z)32!==z&&(p[z]=1024);return function(R){65504<Math.abs(R)&&console.warn("Value out of range."),R=Mat