UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

3 lines (2 loc) 4.89 kB
import{C as e,L as t,a1 as r}from"./index-Bw2N6w1y.esm.min.js";import{WebGPUEngine as s}from"./webgpuEngine-BbHr3Bhe.esm.min.js";import"./bakedVertexAnimation-C76-HDZc.esm.min.js";import"./instancesDeclaration-DrjSuS-6.esm.min.js";import"./helperFunctions-BD2JDv1s.esm.min.js";import"./fresnelFunction-UiVWse9C.esm.min.js";import"./meshUboDeclaration-B530jCEj.esm.min.js";import"./sceneUboDeclaration-Bfi1TSBE.esm.min.js";import"./decalFragment-BoIWDCTJ.esm.min.js";import"./audioEngine-BZ_elF0R.esm.min.js";s.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t=!1,r){r&&r(),this._endCurrentRenderPass(),t||this.generateMipMapsMultiFramebuffer(e),this._currentRenderTarget=null,this._mrtAttachments=[],this._cacheRenderPipeline.setMRT([]),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)},s.prototype.createMultipleRenderTarget=function(s,n,a){let i=!1,p=!0,u=!1,o=!1,T=e.TEXTUREFORMAT_DEPTH16,l=1,c=1;const h=e.TEXTURETYPE_UNSIGNED_BYTE,m=e.TEXTURE_TRILINEAR_SAMPLINGMODE,E=e.TEXTUREFORMAT_RGBA,_=e.TEXTURE_2D;let R=[],d=[],f=[],M=[],A=[],g=[],x=[],S=[],D=[],F=[],U=!1;const b=this._createHardwareRenderTargetWrapper(!0,!1,s);void 0!==n&&(i=n.generateMipMaps??!1,p=n.generateDepthBuffer??!0,u=n.generateStencilBuffer??!1,o=n.generateDepthTexture??!1,l=n.textureCount??1,T=n.depthTextureFormat??e.TEXTUREFORMAT_DEPTH16,R=n.types||R,d=n.samplingModes||d,f=n.useSRGBBuffers||f,M=n.formats||M,A=n.targetTypes||A,g=n.faceIndex||g,x=n.layerIndex||x,S=n.layerCounts||S,D=n.labels||D,F=n.creationFlags||F,c=n.samples??c,U=n.dontCreateTextures??!1);const y=s.width??s,P=s.height??s,X=[],L=[],B=[];b.label=n?.label??"MultiRenderTargetWrapper",b._generateDepthBuffer=p,b._generateStencilBuffer=u,b._attachments=L,b._defaultAttachments=B;let C=null;(p||u||o)&&!U&&(o||(T=p&&u?e.TEXTUREFORMAT_DEPTH24_STENCIL8:p?e.TEXTUREFORMAT_DEPTH32_FLOAT:e.TEXTUREFORMAT_STENCIL8),C=b.createDepthStencilTexture(0,!1,u,1,T,b.label+"-DepthStencil"));const O=void 0!==n&&"object"==typeof n&&n.createMipMaps&&!i;for(let s=0;s<l;s++){let n=d[s]||m,p=R[s]||h;const u=M[s]||E,o=!!f[s]&&this._caps.supportSRGBBuffers,T=A[s]||_,l=S[s]??1,c=F[s];if((p!==e.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(p!==e.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(n=e.TEXTURE_NEAREST_SAMPLINGMODE),p!==e.TEXTURETYPE_FLOAT||this._caps.textureFloat||(p=e.TEXTURETYPE_UNSIGNED_BYTE,t.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),L.push(s+1),B.push(a?s+1:0===s?1:0),-1===T||U)continue;const g=new r(this,6);switch(X[s]=g,T){case e.TEXTURE_CUBE_MAP:g.isCube=!0;break;case e.TEXTURE_3D:g.is3D=!0,g.baseDepth=g.depth=l;break;case e.TEXTURE_2D_ARRAY:g.is2DArray=!0,g.baseDepth=g.depth=l}g.baseWidth=y,g.baseHeight=P,g.width=y,g.height=P,g.isReady=!0,g.samples=1,g.generateMipMaps=i,g.samplingMode=n,g.type=p,g._cachedWrapU=e.TEXTURE_CLAMP_ADDRESSMODE,g._cachedWrapV=e.TEXTURE_CLAMP_ADDRESSMODE,g._useSRGBBuffer=o,g.format=u,g.label=D[s]??b.label+"-Texture"+s,this._internalTexturesCache.push(g),O&&(g.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(g,void 0,void 0,void 0,c,!0),O&&(g.generateMipMaps=!1)}return C&&(C.incrementReferences(),X[l]=C,this._internalTexturesCache.push(C)),b.setTextures(X),b.setLayerAndFaceIndices(x,g),U?b._samples=c:this.updateMultipleRenderTargetTextureSampleCount(b,c),b},s.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(!e||!e.textures||0===e.textures.length||e.textures[0].samples===t)return t;const r=e.textures.length;if(0===r)return 1;t=Math.min(t,this.getCaps().maxMSAASamples);for(let t=0;t<r;++t){const r=e.textures[t]._hardwareTexture;r?.releaseMSAATexture(e.getBaseArrayLayer(t))}const s=e._depthStencilTexture===e.textures[r-1];for(let s=0;s<r;++s){const r=e.textures[s];this._textureHelper.createMSAATexture(r,t,!1,e.getBaseArrayLayer(s)),r.samples=t}return e._depthStencilTexture&&!s&&(this._textureHelper.createMSAATexture(e._depthStencilTexture,t),e._depthStencilTexture.samples=t),e._samples=t,t},s.prototype.generateMipMapsMultiFramebuffer=function(e){const t=e;if(!t.isMulti)return;const r=t._attachments.length;for(let e=0;e<r;e++){const r=t.textures[e];!r.generateMipMaps||r.isCube||r.is3D||this._generateMipmaps(r)}},s.prototype.resolveMultiFramebuffer=function(e){throw new Error("resolveMultiFramebuffer is not yet implemented in WebGPU!")},s.prototype.bindAttachments=function(e){0!==e.length&&this._currentRenderTarget&&(this._mrtAttachments=e,this._currentRenderPass&&this._cacheRenderPipeline.setMRTAttachments(e))},s.prototype.buildTextureLayout=function(e){const t=[];for(let r=0;r<e.length;r++)e[r]?t.push(r+1):t.push(0);return t},s.prototype.restoreSingleAttachment=function(){},s.prototype.restoreSingleAttachmentForRenderTarget=function(){}; //# sourceMappingURL=engine.multiRender-CKoRA8mz.esm.min.js.map