import{L as V,I as X}from"./index-T8LZyOXI.js";import{WebGPUEngine as f}from"./webgpuEngine-DGfphiII.js";import"./index-BkylzejB.js";import"./instancesVertex-whkiHs58.js";import"./bakedVertexAnimation-pP_Q27Xv.js";import"./instancesDeclaration-DC1IjOTo.js";import"./helperFunctions-DWhiOIpN.js";import"./fresnelFunction-D7WrCcC3.js";import"./meshUboDeclaration-BwWX2F0q.js";import"./sceneUboDeclaration-BjEQq3vx.js";import"./decalFragment-IIyqJ_Ex.js";import"./audioEngine-DWueLylS.js";f.prototype.unBindMultiColorAttachmentFramebuffer=function(t,e=!1,n){n&&n(),this._endCurrentRenderPass(),t.disableAutomaticMSAAResolve||this.resolveMultiFramebuffer(t,!1),e||this.generateMipMapsMultiFramebuffer(t),this._currentRenderTarget=null,this._mrtAttachments=[],this._cacheRenderPipeline.setMRT([]),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)};f.prototype.createMultipleRenderTarget=function(t,e,n){let a=!1,l=!0,i=!1,m=!1,c=15,g=1,o=1;const U=0,v=3,H=!1,k=5,N=3553;let x=[],T=[],M=[],_=[],y=[],R=[],b=[],S=[],F=[],A=[],d=!1;const u=this._createHardwareRenderTargetWrapper(!0,!1,t);e!==void 0&&(a=e.generateMipMaps??!1,l=e.generateDepthBuffer??!0,i=e.generateStencilBuffer??!1,m=e.generateDepthTexture??!1,g=e.textureCount??1,c=e.depthTextureFormat??15,x=e.types||x,T=e.samplingModes||T,M=e.useSRGBBuffers||M,_=e.formats||_,y=e.targetTypes||y,R=e.faceIndex||R,b=e.layerIndex||b,S=e.layerCounts||S,F=e.labels||F,A=e.creationFlags||A,o=e.samples??o,d=e.dontCreateTextures??!1);const D=t.width??t,G=t.height??t,B=[],I=[],P=[];u.label=e?.label??"MultiRenderTargetWrapper",u._generateDepthBuffer=l,u._generateStencilBuffer=i,u._attachments=I,u._defaultAttachments=P;let h=null;(l||i||m)&&!d&&(m||(l&&i?c=13:l?c=14:c=19),h=u.createDepthStencilTexture(0,!1,i,1,c,u.label+"-DepthStencil"));const w=e!==void 0&&typeof e=="object"&&e.createMipMaps&&!a;for(let s=0;s<g;s++){let C=T[s]||v,p=x[s]||U;const Y=_[s]||k,j=(M[s]||H)&&this._caps.supportSRGBBuffers,E=y[s]||N,L=S[s]??1,O=A[s];if((p===1&&!this._caps.textureFloatLinearFiltering||p===2&&!this._caps.textureHalfFloatLinearFiltering)&&(C=1),p===1&&!this._caps.textureFloat&&(p=0,V.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),I.push(s+1),P.push(n?s+1:s===0?1:0),E===-1||d)continue;const r=new X(this,6);switch(B[s]=r,E){case 34067:r.isCube=!0;break;case 32879:r.is3D=!0,r.baseDepth=r.depth=L;break;case 35866:r.is2DArray=!0,r.baseDepth=r.depth=L;break}r.baseWidth=D,r.baseHeight=G,r.width=D,r.height=G,r.isReady=!0,r.samples=1,r.generateMipMaps=a,r.samplingMode=C,r.type=p,r._cachedWrapU=0,r._cachedWrapV=0,r._useSRGBBuffer=j,r.format=Y,r.label=F[s]??u.label+"-Texture"+s,this._internalTexturesCache.push(r),w&&(r.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(r,void 0,void 0,void 0,O),w&&(r.generateMipMaps=!1)}return h&&(h.incrementReferences(),B[g]=h,this._internalTexturesCache.push(h)),u.setTextures(B),u.setLayerAndFaceIndices(b,R),d?u._samples=o:this.updateMultipleRenderTargetTextureSampleCount(u,o),u};f.prototype.updateMultipleRenderTargetTextureSampleCount=function(t,e){if(!t||!t.textures||t.textures.length===0||t.textures[0].samples===e)return e;const n=t.textures.length;if(n===0)return 1;e=Math.min(e,this.getCaps().maxMSAASamples);for(let a=0;a<n;++a)t.textures[a]._hardwareTexture?.releaseMSAATextures();for(let a=0;a<n;++a){const l=t.textures[a];l.samples=e}return t._depthStencilTexture&&(t._depthStencilTexture.samples=e),t._samples=e,e};f.prototype.generateMipMapsMultiFramebuffer=function(t){const e=t;if(!e.isMulti)return;const a=e._attachments.length;for(let l=0;l<a;l++){const i=e.textures[l];i.generateMipMaps&&!i.isCube&&!i.is3D&&this._generateMipmaps(i)}};f.prototype.resolveMultiFramebuffer=function(t,e=!0){this.resolveFramebuffer(t,e)};f.prototype.bindAttachments=function(t){t.length===0||!this._currentRenderTarget||(this._mrtAttachments=t,this._currentRenderPass&&this._cacheRenderPipeline.setMRTAttachments(t))};f.prototype.buildTextureLayout=function(t,e=!1){const n=[];if(e)n.push(1);else for(let a=0;a<t.length;a++)t[a]?n.push(a+1):n.push(0);return n};f.prototype.restoreSingleAttachment=function(){};f.prototype.restoreSingleAttachmentForRenderTarget=function(){};
