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.

1 lines 103 kB
import{h as e,C as t,T as s,P as i,O as r,M as n,i as a,L as o,a as l,E as h,j as d,k as u,V as _,S as c,l as g,m as f,n as p,o as m,p as T,q as x,r as E,s as b,t as P,A as R,_ as v,b as S,u as y,v as M,w as D,x as I,y as w,z as O,D as A,R as C,F as B,G as N,H as V,Q as L}from"./index-Bw2N6w1y.esm.min.js";import{ShaderMaterial as U}from"./shaderMaterial-KwJfUZhd.esm.min.js";import"./engine.multiRender-gRI12SyD.esm.min.js";import{P as G,I as F}from"./iblCdfGenerator-D9XroGsE.esm.min.js";import"./clipPlaneFragment-DTAX_VuH.esm.min.js";import"./bumpFragment-D3p_HOgc.esm.min.js";import"./helperFunctions-VdqKNhfd.esm.min.js";import"./bakedVertexAnimation-Dbk5wTYa.esm.min.js";import"./morphTargetsVertex-BHQJhrZk.esm.min.js";import"./instancesDeclaration-DZjj-68d.esm.min.js";import"./sceneUboDeclaration-NN0CuugE.esm.min.js";import"./clipPlaneVertex-Bnps_8-3.esm.min.js";import"./bumpVertex-BtZN56Oq.esm.min.js";import{R as W}from"./rawTexture-CPAqHIA7.esm.min.js";import{S as X}from"./standardMaterial-D6B7cUry.esm.min.js";class z extends e{get isSupported(){return this._engine?.getCaps().drawBuffersExtension??!1}get textures(){return this._textures}get count(){return this._count}get depthTexture(){return this._textures[this._textures.length-1]}set wrapU(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapU=e}set wrapV(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapV=e}constructor(e,s,i,r,n,a){const o=!(!n||!n.generateMipMaps)&&n.generateMipMaps,l=!(!n||!n.generateDepthTexture)&&n.generateDepthTexture,h=n&&n.depthTextureFormat?n.depthTextureFormat:t.TEXTUREFORMAT_DEPTH16,d=!n||void 0===n.doNotChangeAspectRatio||n.doNotChangeAspectRatio,u=!(!n||!n.drawOnlyOnFirstAttachmentByDefault)&&n.drawOnlyOnFirstAttachmentByDefault;if(super(e,s,r,o,d,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0),!this.isSupported)return void this.dispose();this._textureNames=a;const _=[],c=[],g=[],f=[],p=[],m=[],T=[],x=[];this._initTypes(i,_,c,g,f,p,m,T,x,n);const E=!n||void 0===n.generateDepthBuffer||n.generateDepthBuffer,b=!(!n||void 0===n.generateStencilBuffer)&&n.generateStencilBuffer,P=n&&n.samples?n.samples:1;this._multiRenderTargetOptions={samplingModes:c,generateMipMaps:o,generateDepthBuffer:E,generateStencilBuffer:b,generateDepthTexture:l,depthTextureFormat:h,types:_,textureCount:i,useSRGBBuffers:g,samples:P,formats:f,targetTypes:p,faceIndex:m,layerIndex:T,layerCounts:x,labels:a,label:e},this._count=i,this._drawOnlyOnFirstAttachmentByDefault=u,i>0&&(this._createInternalTextures(),this._createTextures(a))}_initTypes(e,i,r,n,a,o,l,h,d,u){for(let _=0;_<e;_++)u&&u.types&&void 0!==u.types[_]?i.push(u.types[_]):i.push(u&&u.defaultType?u.defaultType:t.TEXTURETYPE_UNSIGNED_BYTE),u&&u.samplingModes&&void 0!==u.samplingModes[_]?r.push(u.samplingModes[_]):r.push(s.BILINEAR_SAMPLINGMODE),u&&u.useSRGBBuffers&&void 0!==u.useSRGBBuffers[_]?n.push(u.useSRGBBuffers[_]):n.push(!1),u&&u.formats&&void 0!==u.formats[_]?a.push(u.formats[_]):a.push(t.TEXTUREFORMAT_RGBA),u&&u.targetTypes&&void 0!==u.targetTypes[_]?o.push(u.targetTypes[_]):o.push(t.TEXTURE_2D),u&&u.faceIndex&&void 0!==u.faceIndex[_]?l.push(u.faceIndex[_]):l.push(0),u&&u.layerIndex&&void 0!==u.layerIndex[_]?h.push(u.layerIndex[_]):h.push(0),u&&u.layerCounts&&void 0!==u.layerCounts[_]?d.push(u.layerCounts[_]):d.push(1)}_createInternaTextureIndexMapping(){const e={},t=[];if(!this._renderTarget)return t;const s=this._renderTarget.textures;for(let i=0;i<s.length;i++){const r=s[i];if(!r)continue;const n=e[r.uniqueId];void 0!==n?t[i]=n:e[r.uniqueId]=i}return t}_rebuild(e=!1,t=!1,s){if(this._count<1||e)return;const i=this._createInternaTextureIndexMapping();this.releaseInternalTextures(),this._createInternalTextures(),t&&(this._releaseTextures(),this._createTextures(s));const r=this._renderTarget.textures;for(let e=0;e<r.length;e++){const t=this._textures[e];void 0!==i[e]&&this._renderTarget.setTexture(r[i[e]],e),t._texture=r[e],t._texture&&(t._noMipmap=!t._texture.useMipMaps,t._useSRGBBuffer=t._texture._useSRGBBuffer)}1!==this.samples&&this._renderTarget.setSamples(this.samples,!this._drawOnlyOnFirstAttachmentByDefault,!0)}_createInternalTextures(){this._renderTarget=this._getEngine().createMultipleRenderTarget(this._size,this._multiRenderTargetOptions,!this._drawOnlyOnFirstAttachmentByDefault),this._texture=this._renderTarget.texture}_releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;e++)this._textures[e]._texture=null,this._textures[e].dispose()}_createTextures(e){const t=this._renderTarget.textures;this._textures=[];for(let i=0;i<t.length;i++){const r=new s(null,this.getScene());e?.[i]&&(r.name=e[i]),r._texture=t[i],r._texture&&(r._noMipmap=!r._texture.useMipMaps,r._useSRGBBuffer=r._texture._useSRGBBuffer),this._textures.push(r)}}setInternalTexture(e,i,r=!0){if(this.renderTarget&&(0===i&&(this._texture=e),this.renderTarget.setTexture(e,i,r),this.textures[i]||(this.textures[i]=new s(null,this.getScene()),this.textures[i].name=this._textureNames?.[i]??this.textures[i].name),this.textures[i]._texture=e,this.textures[i]._noMipmap=!e.useMipMaps,this.textures[i]._useSRGBBuffer=e._useSRGBBuffer,this._count=this.renderTarget.textures?this.renderTarget.textures.length:0,this._multiRenderTargetOptions.types&&(this._multiRenderTargetOptions.types[i]=e.type),this._multiRenderTargetOptions.samplingModes&&(this._multiRenderTargetOptions.samplingModes[i]=e.samplingMode),this._multiRenderTargetOptions.useSRGBBuffers&&(this._multiRenderTargetOptions.useSRGBBuffers[i]=e._useSRGBBuffer),this._multiRenderTargetOptions.targetTypes&&-1!==this._multiRenderTargetOptions.targetTypes[i])){let s=0;s=e.is2DArray?t.TEXTURE_2D_ARRAY:e.isCube?t.TEXTURE_CUBE_MAP:e.is3D?t.TEXTURE_3D:t.TEXTURE_2D,this._multiRenderTargetOptions.targetTypes[i]=s}}setLayerAndFaceIndex(e,t=-1,s=-1){this.textures[e]&&this.renderTarget&&(this._multiRenderTargetOptions.layerIndex&&(this._multiRenderTargetOptions.layerIndex[e]=t),this._multiRenderTargetOptions.faceIndex&&(this._multiRenderTargetOptions.faceIndex[e]=s),this.renderTarget.setLayerAndFaceIndex(e,t,s))}setLayerAndFaceIndices(e,t){this.renderTarget&&(this._multiRenderTargetOptions.layerIndex=e,this._multiRenderTargetOptions.faceIndex=t,this.renderTarget.setLayerAndFaceIndices(e,t))}get samples(){return this._samples}set samples(e){this._renderTarget?this._samples=this._renderTarget.setSamples(e):this._samples=e}resize(e){this._processSizeParameter(e),this._rebuild(!1,void 0,this._textureNames)}updateCount(e,t,s){this._multiRenderTargetOptions.textureCount=e,this._count=e;const i=[],r=[],n=[],a=[],o=[],l=[],h=[],d=[];this._textureNames=s,this._initTypes(e,i,r,n,a,o,l,h,d,t),this._multiRenderTargetOptions.types=i,this._multiRenderTargetOptions.samplingModes=r,this._multiRenderTargetOptions.useSRGBBuffers=n,this._multiRenderTargetOptions.formats=a,this._multiRenderTargetOptions.targetTypes=o,this._multiRenderTargetOptions.faceIndex=l,this._multiRenderTargetOptions.layerIndex=h,this._multiRenderTargetOptions.layerCounts=d,this._multiRenderTargetOptions.labels=s,this._rebuild(!1,!0,s)}_unbindFrameBuffer(e,t){this._renderTarget&&e.unBindMultiColorAttachmentFramebuffer(this._renderTarget,this.isCube,(()=>{this.onAfterRenderObservable.notifyObservers(t)}))}dispose(e=!1){this._releaseTextures(),e?this._texture=null:this.releaseInternalTextures(),super.dispose()}releaseInternalTextures(){const e=this._renderTarget?.textures;if(e){for(let t=e.length-1;t>=0;t--)this._textures[t]._texture=null;this._renderTarget?.dispose(),this._renderTarget=null}}}class Y{getVoxelGrid(){return this._triPlanarVoxelization?this._voxelGridRT:this._voxelGridZaxis}getDebugPassPP(){return this._voxelDebugPass||this._createDebugPass(),this._voxelDebugPass}get triPlanarVoxelization(){return this._triPlanarVoxelization}set triPlanarVoxelization(e){this._triPlanarVoxelization!==e&&(this._triPlanarVoxelization=e,this._disposeVoxelTextures(),this._createTextures())}setWorldScaleMatrix(e){this._invWorldScaleMatrix=e}isVoxelizationInProgress(){return this._voxelizationInProgress}get voxelResolutionExp(){return this._voxelResolutionExp}set voxelResolutionExp(e){this._voxelResolutionExp===e&&this._voxelGridZaxis||(this._voxelResolutionExp=Math.round(Math.min(Math.max(e,3),9)),this._voxelResolution=Math.pow(2,this._voxelResolutionExp),this._disposeVoxelTextures(),this._createTextures())}set voxelDebugAxis(e){this._voxelDebugAxis=e}get voxelDebugAxis(){return this._voxelDebugAxis}setDebugDisplayParams(e,t,s,i){this._debugSizeParams.set(e,t,s,i)}setDebugMipNumber(e){this._debugMipNumber=e}get debugPassName(){return this._debugPassName}get voxelDebugEnabled(){return this._voxelDebugEnabled}set voxelDebugEnabled(s){this._voxelDebugEnabled!==s&&(this._voxelDebugEnabled=s,s&&(this._voxelSlabDebugRT=new e("voxelSlabDebug",{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},this._scene,{generateDepthBuffer:!0,generateMipMaps:!1,type:t.TEXTURETYPE_UNSIGNED_BYTE,format:t.TEXTUREFORMAT_RGBA,samplingMode:t.TEXTURE_NEAREST_SAMPLINGMODE}),this._voxelSlabDebugRT.noPrePassRenderer=!0),this._voxelSlabDebugRT&&this._removeVoxelRTs([this._voxelSlabDebugRT]),this._voxelDebugEnabled?(this._addRTsForRender([this._voxelSlabDebugRT],this._includedMeshes,this._voxelDebugAxis,1,!0),this._setDebugBindingsBound=this._setDebugBindings.bind(this),this._scene.onBeforeRenderObservable.add(this._setDebugBindingsBound)):this._scene.onBeforeRenderObservable.removeCallback(this._setDebugBindingsBound))}_createDebugPass(){const e=this._engine.isWebGPU;if(!this._voxelDebugPass){const s={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:t.TEXTUREFORMAT_RGBA,textureType:t.TEXTURETYPE_UNSIGNED_BYTE,samplingMode:t.TEXTURE_NEAREST_SAMPLINGMODE,uniforms:["sizeParams","mipNumber"],samplers:["voxelTexture","voxelSlabTexture"],engine:this._engine,reusable:!1,shaderLanguage:e?1:0,extraInitializations:(e,t)=>{this._isVoxelGrid3D?e?t.push(import("./iblVoxelGrid3dDebug.fragment-Dxb1FvVs.esm.min.js")):t.push(import("./iblVoxelGrid3dDebug.fragment-B_oD-4g7.esm.min.js")):e?t.push(import("./iblVoxelGrid2dArrayDebug.fragment-DpTnZr6m.esm.min.js")):t.push(import("./iblVoxelGrid2dArrayDebug.fragment-DrZ22IIh.esm.min.js"))}};this._voxelDebugPass=new i(this.debugPassName,this._isVoxelGrid3D?"iblVoxelGrid3dDebug":"iblVoxelGrid2dArrayDebug",s),this._voxelDebugPass.onApplyObservable.add((e=>{0===this._voxelDebugAxis?e.setTexture("voxelTexture",this._voxelGridXaxis):1===this._voxelDebugAxis?e.setTexture("voxelTexture",this._voxelGridYaxis):2===this._voxelDebugAxis?e.setTexture("voxelTexture",this._voxelGridZaxis):e.setTexture("voxelTexture",this.getVoxelGrid()),e.setTexture("voxelSlabTexture",this._voxelSlabDebugRT),e.setVector4("sizeParams",this._debugSizeParams),e.setFloat("mipNumber",this._debugMipNumber)}))}}constructor(e,t,s=6,i=!0){this._voxelMrtsXaxis=[],this._voxelMrtsYaxis=[],this._voxelMrtsZaxis=[],this._isVoxelGrid3D=!0,this.onVoxelizationCompleteObservable=new r,this._renderTargets=[],this._triPlanarVoxelization=!0,this._voxelizationInProgress=!1,this._invWorldScaleMatrix=n.Identity(),this._voxelResolution=64,this._voxelResolutionExp=6,this._mipArray=[],this._voxelDebugEnabled=!1,this._voxelDebugAxis=-1,this._debugSizeParams=new a(0,0,0,0),this._includedMeshes=[],this._debugMipNumber=0,this._debugPassName="Voxelization Debug Pass",this._scene=e,this._engine=e.getEngine(),this._triPlanarVoxelization=i,this._engine.getCaps().drawBuffersExtension||o.Error("Can't do voxel rendering without the draw buffers extension.");const d=this._engine.isWebGPU;this._maxDrawBuffers=this._engine.getCaps().maxDrawBuffers||0,this._copyMipEffectRenderer=new l(this._engine),this._copyMipEffectWrapper=new h({engine:this._engine,fragmentShader:"copyTexture3DLayerToTexture",useShaderStore:!0,uniformNames:["layerNum"],samplerNames:["textureSampler"],shaderLanguage:d?1:0,extraInitializationsAsync:async()=>{d?await import("./copyTexture3DLayerToTexture.fragment-T3KpCYdV.esm.min.js"):await import("./copyTexture3DLayerToTexture.fragment-BxSMTO2-.esm.min.js")}}),this.voxelResolutionExp=s}_generateMipMaps(){const e=Math.ceil(Math.log2(this._voxelResolution));for(let t=1;t<e+1;t++)this._generateMipMap(t)}_generateMipMap(e){const t=this._mipArray[e-1];t&&(t.setTexture("srcMip",1===e?this.getVoxelGrid():this._mipArray[e-2]),t.render())}_copyMipMaps(){const e=Math.ceil(Math.log2(this._voxelResolution));for(let t=1;t<e+1;t++)this._copyMipMap(t)}_copyMipMap(t){const s=this._mipArray[t-1];if(!s)return;const i=this.getVoxelGrid();let r;if(r=i instanceof e&&i.renderTarget?i.renderTarget:i._rtWrapper,r){this._copyMipEffectRenderer.saveStates();const e=s.getSize().width;for(let i=0;i<e;i++)this._engine.bindFramebuffer(r,0,e,e,!0,t,i),this._copyMipEffectRenderer.applyEffectWrapper(this._copyMipEffectWrapper),this._copyMipEffectWrapper.effect.setTexture("textureSampler",s),this._copyMipEffectWrapper.effect.setInt("layerNum",i),this._copyMipEffectRenderer.draw(),this._engine.unBindFramebuffer(r,!0);this._copyMipEffectRenderer.restoreStates()}}_computeNumberOfSlabs(){return Math.ceil(this._voxelResolution/this._maxDrawBuffers)}_createTextures(){const i=this._engine.isWebGPU,r={width:this._voxelResolution,height:this._voxelResolution,layers:this._isVoxelGrid3D?void 0:this._voxelResolution,depth:this._isVoxelGrid3D?this._voxelResolution:void 0},n={generateDepthBuffer:!1,generateMipMaps:!1,type:t.TEXTURETYPE_UNSIGNED_BYTE,format:t.TEXTUREFORMAT_R,samplingMode:t.TEXTURE_NEAREST_SAMPLINGMODE},a=this._computeNumberOfSlabs(),o={generateDepthBuffer:!1,generateMipMaps:!0,type:t.TEXTURETYPE_UNSIGNED_BYTE,format:t.TEXTUREFORMAT_R,samplingMode:t.TEXTURE_NEAREST_NEAREST_MIPNEAREST,shaderLanguage:i?1:0,extraInitializationsAsync:async()=>{i?await import("./iblCombineVoxelGrids.fragment-KPMEgy5u.esm.min.js"):await import("./iblCombineVoxelGrids.fragment-COkaUjAf.esm.min.js")}};this._triPlanarVoxelization?(this._voxelGridXaxis=new e("voxelGridXaxis",r,this._scene,n),this._voxelGridYaxis=new e("voxelGridYaxis",r,this._scene,n),this._voxelGridZaxis=new e("voxelGridZaxis",r,this._scene,n),this._voxelMrtsXaxis=this._createVoxelMRTs("x_axis_",this._voxelGridXaxis,a),this._voxelMrtsYaxis=this._createVoxelMRTs("y_axis_",this._voxelGridYaxis,a),this._voxelMrtsZaxis=this._createVoxelMRTs("z_axis_",this._voxelGridZaxis,a),this._voxelGridRT=new G("combinedVoxelGrid",r,"iblCombineVoxelGrids",this._scene,o,!1),this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._voxelGridRT),1),this._voxelGridRT.setFloat("layer",0),this._voxelGridRT.setTexture("voxelXaxisSampler",this._voxelGridXaxis),this._voxelGridRT.setTexture("voxelYaxisSampler",this._voxelGridYaxis),this._voxelGridRT.setTexture("voxelZaxisSampler",this._voxelGridZaxis),this._voxelGridRT.autoClear=!1,this._voxelGridRT.wrapU=s.CLAMP_ADDRESSMODE,this._voxelGridRT.wrapV=s.CLAMP_ADDRESSMODE):(this._voxelGridZaxis=new e("voxelGridZaxis",r,this._scene,o),this._voxelMrtsZaxis=this._createVoxelMRTs("z_axis_",this._voxelGridZaxis,a));const l={generateDepthBuffer:!1,generateMipMaps:!1,type:t.TEXTURETYPE_UNSIGNED_BYTE,format:t.TEXTUREFORMAT_R,samplingMode:t.TEXTURE_NEAREST_SAMPLINGMODE,shaderLanguage:i?1:0,extraInitializationsAsync:async()=>{i?await import("./iblGenerateVoxelMip.fragment-BKcPTdNP.esm.min.js"):await import("./iblGenerateVoxelMip.fragment-BwVcr7bb.esm.min.js")}};this._mipArray=new Array(Math.ceil(Math.log2(this._voxelResolution)));for(let e=1;e<=this._mipArray.length;e++){const t=this._voxelResolution>>e,i={width:t,height:t,depth:t};this._mipArray[e-1]=new G("voxelMip"+e,i,"iblGenerateVoxelMip",this._scene,l,!1),this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._mipArray[e-1]),1);const r=this._mipArray[e-1];r.autoClear=!1,r.wrapU=s.CLAMP_ADDRESSMODE,r.wrapV=s.CLAMP_ADDRESSMODE,r.setTexture("srcMip",e>1?this._mipArray[e-2]:this.getVoxelGrid()),r.setInt("layerNum",0)}this._createVoxelMaterials()}_createVoxelMRTs(e,i,r){i.wrapU=s.CLAMP_ADDRESSMODE,i.wrapV=s.CLAMP_ADDRESSMODE,i.noPrePassRenderer=!0;const n=[],a=new Array(this._maxDrawBuffers).fill(this._isVoxelGrid3D?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY);for(let s=0;s<r;s++){let r=new Array(this._maxDrawBuffers).fill(0);r=r.map(((e,t)=>s*this._maxDrawBuffers+t));let o=new Array(this._maxDrawBuffers).fill("");o=o.map(((t,i)=>"voxel_grid_"+e+(s*this._maxDrawBuffers+i)));const l=new z("mrt_"+e+s,{width:this._voxelResolution,height:this._voxelResolution,depth:this._isVoxelGrid3D?this._voxelResolution:void 0},this._maxDrawBuffers,this._scene,{types:new Array(this._maxDrawBuffers).fill(t.TEXTURETYPE_UNSIGNED_BYTE),samplingModes:new Array(this._maxDrawBuffers).fill(t.TEXTURE_TRILINEAR_SAMPLINGMODE),generateMipMaps:!1,targetTypes:a,formats:new Array(this._maxDrawBuffers).fill(t.TEXTUREFORMAT_R),faceIndex:new Array(this._maxDrawBuffers).fill(0),layerIndex:r,layerCounts:new Array(this._maxDrawBuffers).fill(this._voxelResolution),generateDepthBuffer:!1,generateStencilBuffer:!1},o);l.clearColor=new d(0,0,0,1),l.noPrePassRenderer=!0;for(let e=0;e<this._maxDrawBuffers;e++)l.setInternalTexture(i.getInternalTexture(),e);n.push(l)}return n}_disposeVoxelTextures(){this._stopVoxelization();for(let e=0;e<this._voxelMrtsZaxis.length;e++)this._triPlanarVoxelization&&(this._voxelMrtsXaxis[e].dispose(!0),this._voxelMrtsYaxis[e].dispose(!0)),this._voxelMrtsZaxis[e].dispose(!0);this._triPlanarVoxelization&&(this._voxelGridXaxis?.dispose(),this._voxelGridYaxis?.dispose(),this._voxelGridRT?.dispose()),this._voxelGridZaxis?.dispose();for(const e of this._mipArray)e.dispose();this._voxelMaterial?.dispose(),this._voxelSlabDebugMaterial?.dispose(),this._mipArray=[],this._voxelMrtsXaxis=[],this._voxelMrtsYaxis=[],this._voxelMrtsZaxis=[]}_createVoxelMaterials(){const e=this._engine.isWebGPU;this._voxelMaterial=new U("voxelization",this._scene,"iblVoxelGrid",{uniforms:["world","viewMatrix","invWorldScale","nearPlane","farPlane","stepSize"],defines:["MAX_DRAW_BUFFERS "+this._maxDrawBuffers],shaderLanguage:e?1:0,extraInitializationsAsync:async()=>{e?await Promise.all([import("./iblVoxelGrid.fragment-D_fFJWVZ.esm.min.js"),import("./iblVoxelGrid.vertex-B1A6V3tq.esm.min.js")]):await Promise.all([import("./iblVoxelGrid.fragment-CXX-njJX.esm.min.js"),import("./iblVoxelGrid.vertex-BvMZZKY7.esm.min.js")])}}),this._voxelMaterial.cullBackFaces=!1,this._voxelMaterial.backFaceCulling=!1,this._voxelMaterial.depthFunction=u.ALWAYS,this._voxelSlabDebugMaterial=new U("voxelSlabDebug",this._scene,"iblVoxelSlabDebug",{uniforms:["world","viewMatrix","cameraViewMatrix","projection","invWorldScale","nearPlane","farPlane","stepSize"],defines:["MAX_DRAW_BUFFERS "+this._maxDrawBuffers],shaderLanguage:e?1:0,extraInitializationsAsync:async()=>{e?await Promise.all([import("./iblVoxelSlabDebug.fragment-BB5Mkt_Q.esm.min.js"),import("./iblVoxelSlabDebug.vertex-S6zml7h4.esm.min.js")]):await Promise.all([import("./iblVoxelSlabDebug.fragment-DxiKrd2e.esm.min.js"),import("./iblVoxelSlabDebug.vertex-B32fqfk-.esm.min.js")])}})}_setDebugBindings(){this._voxelSlabDebugMaterial.setMatrix("projection",this._scene.activeCamera.getProjectionMatrix()),this._voxelSlabDebugMaterial.setMatrix("cameraViewMatrix",this._scene.activeCamera.getViewMatrix())}isReady(){let e=this.getVoxelGrid().isReady();for(let t=0;t<this._mipArray.length;t++){const s=this._mipArray[t].isReady();e&&=s}return!(!e||this._voxelizationInProgress)}_stopVoxelization(){this._removeVoxelRTs(this._voxelMrtsXaxis),this._removeVoxelRTs(this._voxelMrtsYaxis),this._removeVoxelRTs(this._voxelMrtsZaxis)}_removeVoxelRTs(e){const t=this._renderTargets.findIndex((t=>t===e[0]));if(t>=0)this._renderTargets.splice(t,e.length);else{const t=this._scene.customRenderTargets.findIndex((t=>t===e[0]));t>=0&&this._scene.customRenderTargets.splice(t,e.length)}}updateVoxelGrid(e){this._stopVoxelization(),this._includedMeshes=e,this._voxelizationInProgress=!0,this._triPlanarVoxelization?(this._addRTsForRender(this._voxelMrtsXaxis,e,0),this._addRTsForRender(this._voxelMrtsYaxis,e,1),this._addRTsForRender(this._voxelMrtsZaxis,e,2)):this._addRTsForRender(this._voxelMrtsZaxis,e,2),this._voxelDebugEnabled&&this._addRTsForRender([this._voxelSlabDebugRT],e,this._voxelDebugAxis,1,!0),this._renderVoxelGridBound=this._renderVoxelGrid.bind(this),this._scene.onAfterRenderObservable.add(this._renderVoxelGridBound)}_renderVoxelGrid(){if(this._voxelizationInProgress){let e=this.getVoxelGrid().isReady();for(let t=0;t<this._mipArray.length;t++){const s=this._mipArray[t].isReady();e&&=s}for(let t=0;t<this._renderTargets.length;t++){const s=this._renderTargets[t].isReadyForRendering();e&&=s}if(e){for(const e of this._renderTargets)e.render();this._stopVoxelization(),this._triPlanarVoxelization&&this._voxelGridRT.render(),this._generateMipMaps(),this._copyMipEffectWrapper.effect.whenCompiledAsync().then((()=>{this._copyMipMaps(),this._scene.onAfterRenderObservable.removeCallback(this._renderVoxelGridBound),this._voxelizationInProgress=!1,this.onVoxelizationCompleteObservable.notifyObservers()}))}}}_addRTsForRender(e,t,s,i=0,r=!1){const a=1/this._computeNumberOfSlabs();let o;o=0===i?this._voxelMaterial:this._voxelSlabDebugMaterial;for(let i=0;i<e.length;i++){const r=e[i];r.renderList=[];const l=i*a,h=(i+1)*a,d=a/this._maxDrawBuffers,u=new _(0,0,0);let c=new _(0,0,1);0===s?c=new _(1,0,0):1===s&&(c=new _(0,1,0));let g=new _(0,1,0);if(1===s&&(g=new _(1,0,0)),r.onBeforeRenderObservable.add((()=>{o.setMatrix("viewMatrix",n.LookAtLH(u,c,g)),o.setMatrix("invWorldScale",this._invWorldScaleMatrix),o.setFloat("nearPlane",l),o.setFloat("farPlane",h),o.setFloat("stepSize",d)})),0===t.length)return;for(const e of t)if(e){e.subMeshes&&e.subMeshes.length>0&&(r.renderList?.push(e),r.setMaterialForRendering(e,o));const t=e.getChildMeshes();for(const e of t)e.subMeshes&&e.subMeshes.length>0&&(r.renderList?.push(e),r.setMaterialForRendering(e,o))}}if(r)for(const t of e)-1===this._scene.customRenderTargets.indexOf(t)&&this._scene.customRenderTargets.push(t);else this._renderTargets=this._renderTargets.concat(e)}resize(){this._voxelSlabDebugRT?.resize({width:this._scene.getEngine().getRenderWidth(),height:this._scene.getEngine().getRenderHeight()})}dispose(){this._disposeVoxelTextures(),this._voxelSlabDebugRT&&(this._removeVoxelRTs([this._voxelSlabDebugRT]),this._voxelSlabDebugRT.dispose()),this._voxelDebugPass&&this._voxelDebugPass.dispose()}}const H="mrtFragmentDeclaration";c.IncludesShadersStore[H]||(c.IncludesShadersStore[H]="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n");const j="geometryPixelShader",k="#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#ifdef BUMP\nvarying mat4 vWorldView;varying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#if defined(VELOCITY) || defined(VELOCITY_LINEAR)\nvarying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIVITY)\n#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nuniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;\n#endif\n#ifdef ALBEDOTEXTURE\nvarying vec2 vAlbedoUV;uniform sampler2D albedoSampler;\n#endif\n#ifdef REFLECTIVITYCOLOR\nuniform vec3 reflectivityColor;\n#endif\n#ifdef ALBEDOCOLOR\nuniform vec3 albedoColor;\n#endif\n#ifdef METALLIC\nuniform float metallic;\n#endif\n#if defined(ROUGHNESS) || defined(GLOSSINESS)\nuniform float glossiness;\n#endif\n#endif\n#if defined(ALPHATEST) && defined(NEED_UV)\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<mrtFragmentDeclaration>[SCENE_MRT_COUNT]\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<helperFunctions>\nvoid main() {\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include<bumpFragment>\n#ifdef NORMAL_WORLDSPACE\nnormalOutput=normalW;\n#else\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#endif\n#else\nnormalOutput=normalize(vNormalV);\n#endif\n#ifdef ENCODE_NORMAL\nnormalOutput=normalOutput*0.5+0.5;\n#endif\n#ifdef DEPTH\ngl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n#endif\n#ifdef NORMAL\ngl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);\n#endif\n#ifdef SCREENSPACE_DEPTH\ngl_FragData[SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef VELOCITY_LINEAR\nvec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) -\n(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#ifdef METALLICWORKFLOW\nfloat metal=1.0;float roughness=1.0;\n#ifdef ORMTEXTURE\nmetal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;\n#endif\n#ifdef METALLIC\nmetal*=metallic;\n#endif\n#ifdef ROUGHNESS\nroughness*=(1.0-glossiness); \n#endif\nreflectivity.a-=roughness;vec3 color=vec3(1.0);\n#ifdef ALBEDOTEXTURE\ncolor=texture2D(albedoSampler,vAlbedoUV).rgb;\n#ifdef GAMMAALBEDO\ncolor=toLinearSpace(color);\n#endif\n#endif\n#ifdef ALBEDOCOLOR\ncolor*=albedoColor.xyz;\n#endif\nreflectivity.rgb=mix(vec3(0.04),color,metal);\n#else\n#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nreflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#ifdef GAMMAREFLECTIVITYTEXTURE\nreflectivity.rgb=toLinearSpace(reflectivity.rgb);\n#endif\n#else \n#ifdef REFLECTIVITYCOLOR\nreflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;\n#endif\n#endif\n#ifdef GLOSSINESSS\nreflectivity.a*=glossiness; \n#endif\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}\n";c.ShadersStore[j]||(c.ShadersStore[j]=k);const Z={name:j,shader:k};var K=Object.freeze({__proto__:null,geometryPixelShader:Z});const q="geometryVertexDeclaration";c.IncludesShadersStore[q]||(c.IncludesShadersStore[q]="uniform mat4 viewProjection;uniform mat4 view;");const $="geometryUboDeclaration";c.IncludesShadersStore[$]||(c.IncludesShadersStore[$]="#include<sceneUboDeclaration>\n");const Q="geometryVertexShader",J="precision highp float;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\n#include<__decl__geometryVertex>\n#include<clipPlaneVertexDeclaration>\nattribute vec3 position;attribute vec3 normal;\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;varying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;uniform mat4 albedoMatrix;varying vec2 vReflectivityUV;varying vec2 vAlbedoUV;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#if defined(VELOCITY) || defined(VELOCITY_LINEAR)\nuniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;vec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef UV2\nvec2 uv2Updated=uv2;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;mat3 normalWorld=mat3(finalWorld);vNormalW=normalize(normalWorld*normalUpdated);\n#else\n#ifdef NORMAL_WORLDSPACE\nvNormalV=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\n#endif\nvViewPos=view*worldPos;\n#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP)\nvPositionW=worldPos.xyz/worldPos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#include<clipPlaneVertex>\n#ifdef NEED_UV\n#ifdef UV1\n#if defined(ALPHATEST) && defined(ALPHATEST_UV1)\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uvUpdated;\n#endif\n#ifdef BUMP_UV1\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV1\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef ALBEDO_UV1\nvAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#if defined(ALPHATEST) && defined(ALPHATEST_UV2)\nvUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0));\n#else\nvUV=uv2Updated;\n#endif\n#ifdef BUMP_UV2\nvBumpUV=vec2(bumpMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV2\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#ifdef ALBEDO_UV2\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#endif\n#endif\n#include<bumpVertex>\n}\n";c.ShadersStore[Q]||(c.ShadersStore[Q]=J);const ee={name:Q,shader:J};var te=Object.freeze({__proto__:null,geometryVertexShader:ee});const se=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","boneTextureWidth"];R(se);class ie{get normalsAreUnsigned(){return this._normalsAreUnsigned}_linkPrePassRenderer(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add((()=>{})))}_unlinkPrePassRenderer(){this._linkedWithPrePass=!1,this._createRenderTargets()}_resetLayout(){this._enableDepth=!0,this._enableNormal=!0,this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._enableVelocityLinear=!1,this._enableScreenspaceDepth=!1,this._attachmentsFromPrePass=[]}_forceTextureType(e,t){e===ie.POSITION_TEXTURE_TYPE?(this._positionIndex=t,this._enablePosition=!0):e===ie.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=t,this._enableVelocity=!0):e===ie.VELOCITY_LINEAR_TEXTURE_TYPE?(this._velocityLinearIndex=t,this._enableVelocityLinear=!0):e===ie.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=t,this._enableReflectivity=!0):e===ie.DEPTH_TEXTURE_TYPE?(this._depthIndex=t,this._enableDepth=!0):e===ie.NORMAL_TEXTURE_TYPE?(this._normalIndex=t,this._enableNormal=!0):e===ie.SCREENSPACE_DEPTH_TEXTURE_TYPE&&(this._screenspaceDepthIndex=t,this._enableScreenspaceDepth=!0)}_setAttachments(e){this._attachmentsFromPrePass=e}_linkInternalTexture(e){this._multiRenderTarget.setInternalTexture(e,0,!1)}get renderList(){return this._multiRenderTarget.renderList}set renderList(e){this._multiRenderTarget.renderList=e}get isSupported(){return this._multiRenderTarget.isSupported}getTextureIndex(e){switch(e){case ie.POSITION_TEXTURE_TYPE:return this._positionIndex;case ie.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case ie.VELOCITY_LINEAR_TEXTURE_TYPE:return this._velocityLinearIndex;case ie.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;case ie.DEPTH_TEXTURE_TYPE:return this._depthIndex;case ie.NORMAL_TEXTURE_TYPE:return this._normalIndex;case ie.SCREENSPACE_DEPTH_TEXTURE_TYPE:return this._screenspaceDepthIndex;default:return-1}}get enableDepth(){return this._enableDepth}set enableDepth(e){this._enableDepth=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableNormal(){return this._enableNormal}set enableNormal(e){this._enableNormal=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enablePosition(){return this._enablePosition}set enablePosition(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableVelocity(){return this._enableVelocity}set enableVelocity(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets()),this._scene.needsPreviousWorldMatrices=e}get enableVelocityLinear(){return this._enableVelocityLinear}set enableVelocityLinear(e){this._enableVelocityLinear=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableReflectivity(){return this._enableReflectivity}set enableReflectivity(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableScreenspaceDepth(){return this._enableScreenspaceDepth}set enableScreenspaceDepth(e){this._enableScreenspaceDepth=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get scene(){return this._scene}get ratio(){return"object"==typeof this._ratioOrDimensions?1:this._ratioOrDimensions}get shaderLanguage(){return this._shaderLanguage}constructor(e,s=1,i=t.TEXTUREFORMAT_DEPTH16,r){this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this.generateNormalsInWorldSpace=!1,this._normalsAreUnsigned=!1,this._resizeObserver=null,this._enableDepth=!0,this._enableNormal=!0,this._enablePosition=!1,this._enableVelocity=!1,this._enableVelocityLinear=!1,this._enableReflectivity=!1,this._enableScreenspaceDepth=!1,this._clearColor=new d(0,0,0,0),this._clearDepthColor=new d(0,0,0,1),this._positionIndex=-1,this._velocityIndex=-1,this._velocityLinearIndex=-1,this._reflectivityIndex=-1,this._depthIndex=-1,this._normalIndex=-1,this._screenspaceDepthIndex=-1,this._linkedWithPrePass=!1,this.useSpecificClearForDepthTexture=!1,this._shaderLanguage=0,this._shadersLoaded=!1,this._scene=e,this._ratioOrDimensions=s,this._useUbo=e.getEngine().supportsUniformBuffers,this._depthFormat=i,this._textureTypesAndFormats=r||{},this._initShaderSourceAsync(),ie._SceneComponentInitialization(this._scene),this._createRenderTargets()}async _initShaderSourceAsync(){this._scene.getEngine().isWebGPU&&!ie.ForceGLSL?(this._shaderLanguage=1,await Promise.all([import("./geometry.vertex-CChqimxP.esm.min.js"),import("./geometry.fragment-DQ2RDWU7.esm.min.js")])):await Promise.all([Promise.resolve().then((function(){return te})),Promise.resolve().then((function(){return K}))]),this._shadersLoaded=!0}isReady(e,t){if(!this._shadersLoaded)return!1;const s=e.getMaterial();if(s&&s.disableDepthWrite)return!1;const i=[],r=[f.PositionKind,f.NormalKind],n=e.getMesh();let a=!1,o=!1;if(s){let e=!1;if(s.needAlphaTestingForMesh(n)&&s.getAlphaTestTexture()&&(i.push("#define ALPHATEST"),i.push(`#define ALPHATEST_UV${s.getAlphaTestTexture().coordinatesIndex+1}`),e=!0),(s.bumpTexture||s.normalTexture)&&g.BumpTextureEnabled){const t=s.bumpTexture||s.normalTexture;i.push("#define BUMP"),i.push(`#define BUMP_UV${t.coordinatesIndex+1}`),e=!0}if(this._enableReflectivity){let t=!1;"PBRMetallicRoughnessMaterial"===s.getClassName()?(s.metallicRoughnessTexture&&(i.push("#define ORMTEXTURE"),i.push(`#define REFLECTIVITY_UV${s.metallicRoughnessTexture.coordinatesIndex+1}`),i.push("#define METALLICWORKFLOW"),e=!0,t=!0),null!=s.metallic&&(i.push("#define METALLIC"),i.push("#define METALLICWORKFLOW"),t=!0),null!=s.roughness&&(i.push("#define ROUGHNESS"),i.push("#define METALLICWORKFLOW"),t=!0),t&&(s.baseTexture&&(i.push("#define ALBEDOTEXTURE"),i.push(`#define ALBEDO_UV${s.baseTexture.coordinatesIndex+1}`),s.baseTexture.gammaSpace&&i.push("#define GAMMAALBEDO"),e=!0),s.baseColor&&i.push("#define ALBEDOCOLOR"))):"PBRSpecularGlossinessMaterial"===s.getClassName()?(s.specularGlossinessTexture?(i.push("#define SPECULARGLOSSINESSTEXTURE"),i.push(`#define REFLECTIVITY_UV${s.specularGlossinessTexture.coordinatesIndex+1}`),e=!0,s.specularGlossinessTexture.gammaSpace&&i.push("#define GAMMAREFLECTIVITYTEXTURE")):s.specularColor&&i.push("#define REFLECTIVITYCOLOR"),null!=s.glossiness&&i.push("#define GLOSSINESS")):"PBRMaterial"===s.getClassName()?(s.metallicTexture&&(i.push("#define ORMTEXTURE"),i.push(`#define REFLECTIVITY_UV${s.metallicTexture.coordinatesIndex+1}`),i.push("#define METALLICWORKFLOW"),e=!0,t=!0),null!=s.metallic&&(i.push("#define METALLIC"),i.push("#define METALLICWORKFLOW"),t=!0),null!=s.roughness&&(i.push("#define ROUGHNESS"),i.push("#define METALLICWORKFLOW"),t=!0),t?(s.albedoTexture&&(i.push("#define ALBEDOTEXTURE"),i.push(`#define ALBEDO_UV${s.albedoTexture.coordinatesIndex+1}`),s.albedoTexture.gammaSpace&&i.push("#define GAMMAALBEDO"),e=!0),s.albedoColor&&i.push("#define ALBEDOCOLOR")):(s.reflectivityTexture?(i.push("#define SPECULARGLOSSINESSTEXTURE"),i.push(`#define REFLECTIVITY_UV${s.reflectivityTexture.coordinatesIndex+1}`),s.reflectivityTexture.gammaSpace&&i.push("#define GAMMAREFLECTIVITYTEXTURE"),e=!0):s.reflectivityColor&&i.push("#define REFLECTIVITYCOLOR"),null!=s.microSurface&&i.push("#define GLOSSINESS"))):"StandardMaterial"===s.getClassName()&&(s.specularTexture&&(i.push("#define REFLECTIVITYTEXTURE"),i.push(`#define REFLECTIVITY_UV${s.specularTexture.coordinatesIndex+1}`),s.specularTexture.gammaSpace&&i.push("#define GAMMAREFLECTIVITYTEXTURE"),e=!0),s.specularColor&&i.push("#define REFLECTIVITYCOLOR"))}e&&(i.push("#define NEED_UV"),n.isVerticesDataPresent(f.UVKind)&&(r.push(f.UVKind),i.push("#define UV1"),a=!0),n.isVerticesDataPresent(f.UV2Kind)&&(r.push(f.UV2Kind),i.push("#define UV2"),o=!0))}this._enableDepth&&(i.push("#define DEPTH"),i.push("#define DEPTH_INDEX "+this._depthIndex)),this._enableNormal&&(i.push("#define NORMAL"),i.push("#define NORMAL_INDEX "+this._normalIndex)),this._enablePosition&&(i.push("#define POSITION"),i.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(i.push("#define VELOCITY"),i.push("#define VELOCITY_INDEX "+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(n)&&i.push("#define BONES_VELOCITY_ENABLED")),this._enableVelocityLinear&&(i.push("#define VELOCITY_LINEAR"),i.push("#define VELOCITY_LINEAR_INDEX "+this._velocityLinearIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(n)&&i.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(i.push("#define REFLECTIVITY"),i.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),this._enableScreenspaceDepth&&-1!==this._screenspaceDepthIndex&&(i.push("#define SCREENSPACE_DEPTH_INDEX "+this._screenspaceDepthIndex),i.push("#define SCREENSPACE_DEPTH")),this.generateNormalsInWorldSpace&&i.push("#define NORMAL_WORLDSPACE"),this._normalsAreUnsigned&&i.push("#define ENCODE_NORMAL"),n.useBones&&n.computeBonesUsingShaders&&n.skeleton?(r.push(f.MatricesIndicesKind),r.push(f.MatricesWeightsKind),n.numBoneInfluencers>4&&(r.push(f.MatricesIndicesExtraKind),r.push(f.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),i.push("#define BONETEXTURE "+n.skeleton.isUsingTextureForMatrices),i.push("#define BonesPerMesh "+(n.skeleton.bones.length+1))):(i.push("#define NUM_BONE_INFLUENCERS 0"),i.push("#define BONETEXTURE false"),i.push("#define BonesPerMesh 0"));const l=n.morphTargetManager?p(n.morphTargetManager,i,r,n,!0,!0,!1,a,o,!1):0;t&&(i.push("#define INSTANCES"),m(r,this._enableVelocity||this._enableVelocityLinear),e.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES")),this._linkedWithPrePass?i.push("#define SCENE_MRT_COUNT "+this._attachmentsFromPrePass.length):i.push("#define SCENE_MRT_COUNT "+this._multiRenderTarget.textures.length),T(s,this._scene,i);const h=this._scene.getEngine(),d=e._getDrawWrapper(void 0,!0),u=d.defines,_=i.join("\n");return u!==_&&d.setEffect(h.createEffect("geometry",{attributes:r,uniformsNames:se,samplers:["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets","boneSampler"],defines:_,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:l},shaderLanguage:this.shaderLanguage},h),_),d.effect.isReady()}getGBuffer(){return this._multiRenderTarget}get samples(){return this._multiRenderTarget.samples}set samples(e){this._multiRenderTarget.samples=e}dispose(){if(this._resizeObserver){this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null}this.getGBuffer().dispose()}_assignRenderTargetIndices(){const e=[],t=[];let s=0;return this._enableDepth&&(this._depthIndex=s,s++,e.push("gBuffer_Depth"),t.push(this._textureTypesAndFormats[ie.DEPTH_TEXTURE_TYPE])),this._enableNormal&&(this._normalIndex=s,s++,e.push("gBuffer_Normal"),t.push(this._textureTypesAndFormats[ie.NORMAL_TEXTURE_TYPE])),this._enablePosition&&(this._positionIndex=s,s++,e.push("gBuffer_Position"),t.push(this._textureTypesAndFormats[ie.POSITION_TEXTURE_TYPE])),this._enableVelocity&&(this._velocityIndex=s,s++,e.push("gBuffer_Velocity"),t.push(this._textureTypesAndFormats[ie.VELOCITY_TEXTURE_TYPE])),this._enableVelocityLinear&&(this._velocityLinearIndex=s,s++,e.push("gBuffer_VelocityLinear"),t.push(this._textureTypesAndFormats[ie.VELOCITY_LINEAR_TEXTURE_TYPE])),this._enableReflectivity&&(this._reflectivityIndex=s,s++,e.push("gBuffer_Reflectivity"),t.push(this._textureTypesAndFormats[ie.REFLECTIVITY_TEXTURE_TYPE])),this._enableScreenspaceDepth&&(this._screenspaceDepthIndex=s,s++,e.push("gBuffer_ScreenspaceDepth"),t.push(this._textureTypesAndFormats[ie.SCREENSPACE_DEPTH_TEXTURE_TYPE])),[s,e,t]}_createRenderTargets(){const e=this._scene.getEngine(),[i,r,a]=this._assignRenderTargetIndices();let o=t.TEXTURETYPE_UNSIGNED_BYTE;e._caps.textureFloat&&e._caps.textureFloatLinearFiltering?o=t.TEXTURETYPE_FLOAT:e._caps.textureHalfFloat&&e._caps.textureHalfFloatLinearFiltering&&(o=t.TEXTURETYPE_HALF_FLOAT);const l=void 0!==this._ratioOrDimensions.width?this._ratioOrDimensions:{width:e.getRenderWidth()*this._ratioOrDimensions,height:e.getRenderHeight()*this._ratioOrDimensions},h=[],d=[];for(const e of a)e?(h.push(e.textureType),d.push(e.textureFormat)):(h.push(o),d.push(t.TEXTUREFORMAT_RGBA));if(this._normalsAreUnsigned=h[ie.NORMAL_TEXTURE_TYPE]===t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV||h[ie.NORMAL_TEXTURE_TYPE]===t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,this._multiRenderTarget=new z("gBuffer",l,i,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,types:h,formats:d,depthTextureFormat:this._depthFormat},r.concat("gBuffer_DepthBuffer")),!this.isSupported)return;this._multiRenderTarget.wrapU=s.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=s.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null;const u=[!0],_=[!1],c=[!0];for(let e=1;e<i;++e)u.push(!0),c.push(!1),_.push(!0);const f=e.buildTextureLayout(u),p=e.buildTextureLayout(_),m=e.buildTextureLayout(c);this._multiRenderTarget.onClearObservable.add((e=>{e.bindAttachments(this.useSpecificClearForDepthTexture?p:f),e.clear(this._clearColor,!0,!0,!0),this.useSpecificClearForDepthTexture&&(e.bindAttachments(m),e.clear(this._clearDepthColor,!0,!0,!0)),e.bindAttachments(f)})),this._resizeObserver=e.onResizeObservable.add((()=>{if(this._multiRenderTarget){const t=void 0!==this._ratioOrDimensions.width?this._ratioOrDimensions:{width:e.getRenderWidth()*this._ratioOrDimensions,height:e.getRenderHeight()*this._ratioOrDimensions};this._multiRenderTarget.resize(t)}}));const T=e=>{const t=e.getRenderingMesh(),s=e.getEffectiveMesh(),i=this._scene,r=i.getEngine(),a=e.getMaterial();if(!a)return;if(s._internalAbstractMeshDataInfo._isActiveIntermediate=!1,(this._enableVelocity||this._enableVelocityLinear)&&!this._previousTransformationMatrices[s.uniqueId]&&(this._previousTransformationMatrices[s.uniqueId]={world:n.Identity(),viewProjection:i.getTransformMatrix()},t.skeleton)){const e=t.skeleton.getTransformMatrices(t);this._previousBonesTransformationMatrices[t.uniqueId]=this._copyBonesTransformationMatrices(e,new Float32Array(e.length))}const o=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(o.mustReturn)return;const l=r.getCaps().instancedArrays&&(null!==o.visibleInstances[e._id]||t.hasThinInstances),h=s.getWorldMatrix();if(this.isReady(e,l)){const n=e._getDrawWrapper();if(!n)return;const d=n.effect;let u;r.enableEffect(n),l||t._bind(e,d,a.fillMode),this._useUbo?(x(d,this._scene.getSceneUniformBuffer()),this._scene.finalizeSceneUbo()):(d.setMatrix("viewProjection",i.getTransformMatrix()),d.setMatrix("view",i.getViewMatrix()));const _=t._instanceDataStorage;if(_.isFrozen||!a.backFaceCulling&&null===a.sideOrientation)u=_.sideOrientation;else{const e=s._getWorldMatrixDeterminant();u=a._getEffectiveOrientation(t),e<0&&(u=u===P.ClockWiseSideOrientation?P.CounterClockWiseSideOrientation:P.ClockWiseSideOrientation)}if(a._preBind(n,u),a.needAlphaTestingForMesh(s)){const e=a.getAlphaTestTexture();e&&(d.setTexture("diffuseSampler",e),d.setMatrix("diffuseMatrix",e.getTextureMatrix()))}if((a.bumpTexture||a.normalTexture)&&i.getEngine().getCaps().standardDerivatives&&g.BumpTextureEnabled){const e=a.bumpTexture||a.normalTexture;d.setFloat3("vBumpInfos",e.coordinatesIndex,1/e.level,a.parallaxScaleBias),d.setMatrix("bumpMatrix",e.getTextureMatrix()),d.setTexture("bumpSampler",e),d.setFloat2("vTangentSpaceParams",a.invertNormalMapX?-1:1,a.invertNormalMapY?-1:1)}if(this._enableReflectivity&&("PBRMetallicRoughnessMaterial"===a.getClassName()?(null!==a.metallicRoughnessTexture&&(d.setTexture("reflectivitySampler",a.metallicRoughnessTexture),d.setMatrix("reflectivityMatrix",a.metallicRoughnessTexture.getTextureMatrix())),null!==a.metallic&&d.setFloat("metallic",a.metallic),null!==a.roughness&&d.setFloat("glossiness",1-a.roughness),null!==a.baseTexture&&(d.setTexture("albedoSampler",a.baseTexture),d.setMatrix("albedoMatrix",a.baseTexture.getTextureMatrix())),null!==a.baseColor&&d.setColor3("albedoColor",a.baseColor)):"PBRSpecularGlossinessMaterial"===a.getClassName()?(null!==a.specularGlossinessTexture?(d.setTexture("reflectivitySampler",a.specularGlossinessTexture),d.setMatrix("reflectivityMatrix",a.specularGlossinessTexture.getTextureMatrix())):null!==a.specularColor&&d.setColor3("reflectivityColor",a.specularColor),null!==a.glossiness&&d.setFloat("glossiness",a.glossiness)):"PBRMaterial"===a.getClassName()?(null!==a.metallicTexture&&(d.setTexture("reflectivitySampler",a.metallicTexture),d.setMatrix("reflectivityMatrix",a.metallicTexture.getTextureMatrix())),null!==a.metallic&&d.setFloat("metallic",a.metallic),null!==a.roughness&&d.setFloat("glossiness",1-a.roughness),null!==a.roughness||null!==a.metallic||null!==a.metallicTexture?(null!==a.albedoTexture&&(d.setTexture("albedoSampler",a.albedoTexture),d.setMatrix("albedoMatrix",a.albedoTexture.getTextureMatrix())),null!==a.albedoColor&&d.setColor3("albedoColor",a.albedoColor)):(null!==a.reflectivityTexture?(d.setTexture("reflectivitySampler",a.reflectivityTexture),d.setMatrix("reflectivityMatrix",a.reflectivityTexture.getTextureMatrix())):null!==a.reflectivityColor&&d.setColor3("reflectivityColor",a.reflectivityColor),null!==a.microSurface&&d.setFloat("glossiness",a.microSurface))):"StandardMaterial"===a.getClassName()&&(null!==a.specularTexture&&(d.setTexture("reflectivitySampler",a.specularTexture),d.setMatrix("reflectivityMatrix",a.specularTexture.getTextureMatrix())),null!==a.specularColor&&d.setColor3("reflectivityColor",a.specularColor))),E(d,a,this._scene),t.useBones&&t.computeBonesUsingShaders&&t.skeleton){const e=t.sk