1import{n as e}from"./rolldown-runtime-CNC7AqOf.js";import{D as t,E as n,a as r,s as i}from"./math.vector-ClNoYZga.js";import{T as a,t as o}from"./math.scalar.functions-B6BS_UAb.js";import{i as s,t as c}from"./math.color-BnnXpOzI.js";import{J as l,Y as u,q as d}from"./textureTools-BoGgdlYo.js";var f,p,m=e((()=>{i(),a(),u(),t(),s(),f=class{constructor(e,t,n,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=n,this.worldAxisForFileY=r}},p=class{static ConvertCubeMapTextureToSphericalPolynomial(e){if(!e.isCube)return null;e.getScene()?.getEngine().flushFramebuffer();let t=e.getSize().width,n=e.readPixels(0,void 0,void 0,!1),r=e.readPixels(1,void 0,void 0,!1),i,a;e.isRenderTarget?(i=e.readPixels(3,void 0,void 0,!1),a=e.readPixels(2,void 0,void 0,!1)):(i=e.readPixels(2,void 0,void 0,!1),a=e.readPixels(3,void 0,void 0,!1));let o=e.readPixels(4,void 0,void 0,!1),s=e.readPixels(5,void 0,void 0,!1),c=e.gammaSpace;return new Promise(e=>{Promise.all([r,n,i,a,o,s]).then(([n,r,i,a,o,s])=>{let l={size:t,right:r,left:n,up:i,down:a,front:o,back:s,format:5,type:+(n instanceof Float32Array),gammaSpace:c};e(this.ConvertCubeMapToSphericalPolynomial(l))})})}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static ConvertCubeMapToSphericalPolynomial(e){let t=new d,r=0,i=2/e.size,a=i,s=.5*i,u=s-1;for(let l=0;l<6;l++){let d=this._FileFaces[l],f=e[d.name],p=u,m=e.format===5?4:3;for(let l=0;l<e.size;l++){let h=u;for(let a=0;a<e.size;a++){let u=d.worldAxisForFileX.scale(h).add(d.worldAxisForFileY.scale(p)).add(d.worldAxisForNormal);u.normalize();let g=this._AreaElement(h-s,p-s)-this._AreaElement(h-s,p+s)-this._AreaElement(h+s,p-s)+this._AreaElement(h+s,p+s),_=f[l*e.size*m+a*m+0],v=f[l*e.size*m+a*m+1],y=f[l*e.size*m+a*m+2];isNaN(_)&&(_=0),isNaN(v)&&(v=0),isNaN(y)&&(y=0),e.type===0&&(_/=255,v/=255,y/=255),e.gammaSpace&&(_=o(_)**+n,v=o(v)**+n,y=o(y)**+n);let b=this.MAX_HDRI_VALUE;if(this.PRESERVE_CLAMPED_COLORS){let e=Math.max(_,v,y);if(e>b){let t=b/e;_*=t,v*=t,y*=t}}else _=o(_,0,b),v=o(v,0,b),y=o(y,0,b);let x=new c(_,v,y);t.addLight(u,x,g),r+=g,h+=i}p+=a}}let f=4*Math.PI*6/6/r;return t.scaleInPlace(f),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),l.FromHarmonics(t)}},p._FileFaces=[new f(`right`,new r(1,0,0),new r(0,0,-1),new r(0,-1,0)),new f(`left`,new r(-1,0,0),new r(0,0,1),new r(0,-1,0)),new f(`up`,new r(0,1,0),new r(1,0,0),new r(0,0,1)),new f(`down`,new r(0,-1,0),new r(1,0,0),new r(0,0,-1)),new f(`front`,new r(0,0,1),new r(1,0,0),new r(0,-1,0)),new f(`back`,new r(0,0,-1),new r(-1,0,0),new r(0,-1,0))],p.MAX_HDRI_VALUE=4096,p.PRESERVE_CLAMPED_COLORS=!1}));export{m as n,p as t}; 2//# sourceMappingURL=cubemapToSphericalPolynomial-Ejn3woeK.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.