import{L as b}from"./nc-3d-babylon.DXK9i1XM.js";import"./nc-main.DEgIQeOo.js";import"/vue.js";import"./service-worker.DGZzV4eE.js";function O(t){return t.split(" ").filter(s=>s!=="").map(s=>parseFloat(s))}function x(t,s,o){for(;o.length!==s;){const n=O(t.lines[t.index++]);o.push(...n)}}function V(t,s,o){let n=0,e=0,i=0,u=0,f=0,h=0;for(let r=0;r<t.numberOfHorizontalAngles-1;r++)if(o<t.horizontalAngles[r+1]||r===t.numberOfHorizontalAngles-2){e=r,i=t.horizontalAngles[r],u=t.horizontalAngles[r+1];break}for(let r=0;r<t.numberOfVerticalAngles-1;r++)if(s<t.verticalAngles[r+1]||r===t.numberOfVerticalAngles-2){n=r,f=t.verticalAngles[r],h=t.verticalAngles[r+1];break}const c=u-i,m=h-f;if(m===0)return 0;const g=c===0?0:(o-i)/c,A=(s-f)/m,d=c===0?e:e+1,l=b(t.candelaValues[e][n],t.candelaValues[d][n],g),a=b(t.candelaValues[e][n+1],t.candelaValues[d][n+1],g);return b(l,a,A)}function z(t){const n={lines:new TextDecoder("utf-8").decode(t).split(`
`),index:0},e={version:n.lines[0],candelaValues:[],horizontalAngles:[],verticalAngles:[],numberOfHorizontalAngles:0,numberOfVerticalAngles:0};for(n.index=1;n.lines.length>0&&!n.lines[n.index].includes("TILT=");)n.index++;n.lines[n.index].includes("INCLUDE"),n.index++;const i=O(n.lines[n.index++]);e.numberOfLights=i[0],e.lumensPerLamp=i[1],e.candelaMultiplier=i[2],e.numberOfVerticalAngles=i[3],e.numberOfHorizontalAngles=i[4],e.photometricType=i[5],e.unitsType=i[6],e.width=i[7],e.length=i[8],e.height=i[9];const u=O(n.lines[n.index++]);e.ballastFactor=u[0],e.fileGenerationType=u[1],e.inputWatts=u[2];for(let l=0;l<e.numberOfHorizontalAngles;l++)e.candelaValues[l]=[];x(n,e.numberOfVerticalAngles,e.verticalAngles),x(n,e.numberOfHorizontalAngles,e.horizontalAngles);for(let l=0;l<e.numberOfHorizontalAngles;l++)x(n,e.numberOfVerticalAngles,e.candelaValues[l]);let f=-1;for(let l=0;l<e.numberOfHorizontalAngles;l++)for(let a=0;a<e.numberOfVerticalAngles;a++)e.candelaValues[l][a]*=e.candelaValues[l][a]*e.candelaMultiplier*e.ballastFactor*e.fileGenerationType,f=Math.max(f,e.candelaValues[l][a]);if(f>0)for(let l=0;l<e.numberOfHorizontalAngles;l++)for(let a=0;a<e.numberOfVerticalAngles;a++)e.candelaValues[l][a]/=f;const h=180,c=h*2,m=c*h,g=new Float32Array(c*h),A=e.horizontalAngles[0],d=e.horizontalAngles[e.numberOfHorizontalAngles-1];for(let l=0;l<m;l++){let a=l%c;const p=Math.floor(l/c);d-A!==0&&(a<A||a>=d)&&(a%=d*2,a>d&&(a=d*2-a)),g[p+a*h]=V(e,p,a)}return{width:c/2,height:1,data:g}}class H{constructor(){this.supportCascades=!1}loadCubeData(){throw".ies not supported in Cube."}loadData(s,o,n){const e=new Uint8Array(s.buffer,s.byteOffset,s.byteLength),i=z(e);n(i.width,i.height,o.useMipMaps,!1,()=>{const u=o.getEngine();o.type=1,o.format=6,o._gammaSpace=!1,u._uploadDataToTextureDirectly(o,i.data)})}}export{H as _IESTextureLoader};
