babylonjs-editor-tools 5.5.1-alpha.3 → 5.5.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/build/index.node.js +411 -125
  2. package/build/src/decorators/apply.js +5 -5
  3. package/build/src/decorators/apply.js.map +1 -1
  4. package/build/src/loading/script/preload/plugins/gui.js +1 -1
  5. package/build/src/loading/script/preload/plugins/gui.js.map +1 -1
  6. package/build/src/rendering/ssao.js +1 -1
  7. package/build/src/rendering/ssao.js.map +1 -1
  8. package/build/src/rendering/volumetric/pipeline.js +403 -26
  9. package/build/src/rendering/volumetric/pipeline.js.map +1 -1
  10. package/build/src/rendering/volumetric/selector.js +2 -1
  11. package/build/src/rendering/volumetric/selector.js.map +1 -1
  12. package/build/src/rendering/volumetric/shaders-wgsl.js +197 -60
  13. package/build/src/rendering/volumetric/shaders-wgsl.js.map +1 -1
  14. package/build/src/rendering/volumetric/shaders.js +179 -5
  15. package/build/src/rendering/volumetric/shaders.js.map +1 -1
  16. package/build/src/rendering/volumetric/types.js +27 -1
  17. package/build/src/rendering/volumetric/types.js.map +1 -1
  18. package/build/src/rendering/volumetric-lighting.js.map +1 -1
  19. package/build/src/tools/guards.js +8 -0
  20. package/build/src/tools/guards.js.map +1 -1
  21. package/declaration/src/rendering/volumetric/pipeline.d.ts +83 -1
  22. package/declaration/src/rendering/volumetric/selector.d.ts +6 -2
  23. package/declaration/src/rendering/volumetric/shaders-wgsl.d.ts +5 -1
  24. package/declaration/src/rendering/volumetric/shaders.d.ts +16 -2
  25. package/declaration/src/rendering/volumetric/types.d.ts +46 -1
  26. package/declaration/src/rendering/volumetric-lighting.d.ts +1 -1
  27. package/declaration/src/tools/guards.d.ts +7 -0
  28. package/package.json +1 -1
@@ -1,9 +1,12 @@
1
- var je=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Dn=Object.prototype.hasOwnProperty;var a=(t,e)=>je(t,"name",{value:e,configurable:!0});var _n=(t,e)=>{for(var i in e)je(t,i,{get:e[i],enumerable:!0})},Pn=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ln(e))!Dn.call(t,r)&&r!==i&&je(t,r,{get:()=>e[r],enumerable:!(o=Cn(e,r))||o.enumerable});return t};var wn=t=>Pn(je({},"__esModule",{value:!0}),t);var ms={};_n(ms,{AdvancedAssetContainer:()=>ze,AdvancedAssetContainerInstantiatedEntries:()=>Be,Cinematic:()=>We,Database:()=>$e,NodeParticleSystemSet:()=>cn.NodeParticleSystemSet,VolumetricDebugMode:()=>Lo,VolumetricDepthSource:()=>ui,VolumetricDitherMode:()=>ni,VolumetricFogMode:()=>ai,VolumetricLightingRenderingPipeline:()=>Y,VolumetricShadowKind:()=>mi,VolumetricShadowMode:()=>Ao,VolumetricStepDistribution:()=>Co,VolumetricTransmittanceMode:()=>hi,_applyScriptsForObject:()=>G,_getKtx2TextureName:()=>ft,_preloadScriptsAssets:()=>Fi,_registerScriptInstance:()=>zi,_removeRegisteredScriptInstance:()=>mt,addExcludedCompressedTexture:()=>ut,animationFromSprite:()=>ts,animationGroupFromScene:()=>Fa,applyMeshesLODQuality:()=>It,applyRagdollJointLimits:()=>ba,applyRenderingConfigurationForCamera:()=>Pi,applyScriptOnObject:()=>_a,applyShadowsQuality:()=>Rn,applyTexturesQuality:()=>Oa,canUseHdr:()=>ya,componentFromScene:()=>Ra,computeVolumetricBudget:()=>Ie,computeVolumetricShapeKey:()=>qn,configureEngineToUseCompressedTextures:()=>wa,configureMeshDistanceOrScreenCoverage:()=>Tt,configureShadowMapRefreshRate:()=>qe,configureShadowMapRenderListPredicate:()=>Mt,copyAndParseRagdollConfiguration:()=>Ei,createAndOpenDatabase:()=>Qi,createDefaultRenderingPipeline:()=>xo,createMotionBlurPostProcess:()=>go,createSSAO2RenderingPipeline:()=>fo,createSSRRenderingPipeline:()=>co,createTAARenderingPipeline:()=>mo,createVLSPostProcess:()=>so,createVolumetricLightingPrePassConfiguration:()=>gi,createVolumetricLightingRenderingPipeline:()=>jo,defaultPipelineCameraConfigurations:()=>ve,disposeDefaultRenderingPipeline:()=>Qt,disposeMotionBlurPostProcess:()=>jt,disposeSSAO2RenderingPipeline:()=>Wt,disposeSSRRenderingPipeline:()=>Gt,disposeTAARenderingPipeline:()=>Ht,disposeVLSPostProcess:()=>Vt,disposeVolumetricLightingRenderingPipeline:()=>Li,ensureVolumetricLightConfiguration:()=>_o,forceCompileAllSceneMaterials:()=>Ia,generateCinematicAnimationGroup:()=>as,getAllScriptsByClassForObject:()=>_e,getAllVolumetricCandidateLights:()=>To,getAnimationTypeForObject:()=>Ue,getDefaultRenderingPipeline:()=>Te,getDefaultVolumetricLightConfiguration:()=>oi,getDefaultVolumetricLightingConfiguration:()=>Qe,getFromIndexDB:()=>Xe,getHdrTextureType:()=>X,getMotionBlurPostProcess:()=>Kt,getPowerOfTwoUntil:()=>F,getSSAO2RenderingPipeline:()=>zn,getSSRRenderingPipeline:()=>Fn,getScriptByClassForObject:()=>Bi,getTAARenderingPipeline:()=>Gn,getTextureUrl:()=>gt,getVLSPostProcess:()=>Rt,getVolumetricGeometryBufferDepthTexture:()=>Si,getVolumetricGeometryBufferRenderer:()=>Re,getVolumetricLightConfiguration:()=>li,getVolumetricLightRange:()=>tt,getVolumetricLightSteps:()=>si,getVolumetricLightWorldDirection:()=>Me,getVolumetricLightWorldPosition:()=>et,getVolumetricLightingRenderingPipeline:()=>fa,getVolumetricLightingRenderingPipelineConfiguration:()=>Ci,getVolumetricPrePassDepthTexture:()=>vi,getVolumetricPrePassRenderer:()=>ye,guiFromAsset:()=>Ga,isAbstractMesh:()=>oe,isAnyParticleSystem:()=>wt,isArcRotateCamera:()=>Tn,isBone:()=>On,isCamera:()=>Ze,isCascadedShadowGenerator:()=>Dt,isCinematicGroup:()=>rs,isCinematicKey:()=>Yi,isCinematicKeyCut:()=>we,isCinematicKeyEvent:()=>os,isCinematicSound:()=>ns,isClusteredLightContainer:()=>pe,isDecalMesh:()=>to,isDirectionalLight:()=>te,isFreeCamera:()=>An,isGPUParticleSystem:()=>In,isGaussianSplattingMesh:()=>Et,isGroundMesh:()=>En,isHemisphericLight:()=>Ye,isInstancedMesh:()=>Ee,isLight:()=>eo,isMesh:()=>V,isNode:()=>me,isNodeFromStaticGroup:()=>At,isParticleSystem:()=>Pt,isPointLight:()=>Ct,isScene:()=>_t,isShadowGenerator:()=>Lt,isSoundNode:()=>ne,isSpotLight:()=>re,isSprite:()=>Ot,isTexture:()=>Ae,isTransformNode:()=>ee,isUsingKtx2CompressedTextures:()=>ke,isVolumetricLightEnabled:()=>Wn,isVolumetricLightSupported:()=>Qn,isVolumetricLightingSupported:()=>ga,loadMaterialFromFile:()=>Ta,loadScene:()=>Aa,markVolumetricLightsDirty:()=>va,maxVolumetricArrayLights:()=>$,maxVolumetricDirectionalLights:()=>ri,maxVolumetricShadowSlots:()=>E,motionBlurPostProcessCameraConfigurations:()=>ge,nodeFromDescendants:()=>Va,nodeFromScene:()=>Ma,normalizeAtlasJson:()=>ki,normalizeVolumetricLightConfiguration:()=>Do,normalizeVolumetricLightingConfiguration:()=>Se,onKeyboardEvent:()=>Ja,onPointerEvent:()=>Qa,openIndexDB:()=>qi,parseCinematic:()=>is,parseCinematicKeyValue:()=>H,parseDefaultRenderingPipeline:()=>ei,parseKeyFrameAnimations:()=>ji,parseMotionBlurPostProcess:()=>Yt,parseRagdollConfiguration:()=>tr,parseSSAO2RenderingPipeline:()=>$t,parseSSRRenderingPipeline:()=>zt,parseTAARenderingPipeline:()=>Ut,parseVLSPostProcess:()=>Nt,parseVolumetricLightingRenderingPipeline:()=>_i,particleSystemFromScene:()=>za,playSpriteAnimationFromName:()=>Ea,preloadAssetsToDatabase:()=>ps,putInIndexDB:()=>U,registerScriptAssetParser:()=>Da,resolveVolumetricDepthSource:()=>it,resolveVolumetricShadowSlot:()=>Io,saveRenderingConfigurationForCamera:()=>Sa,sceneAsset:()=>Na,scriptAssetsCache:()=>le,scriptAssetsParsers:()=>He,scriptsDictionary:()=>z,selectVolumetricLights:()=>di,serializeDefaultRenderingPipeline:()=>Jt,serializeMotionBlurPostProcess:()=>Zt,serializeSSAO2RenderingPipeline:()=>Xt,serializeSSRRenderingPipeline:()=>Bt,serializeTAARenderingPipeline:()=>kt,serializeVLSPostProcess:()=>Ft,serializeVolumetricLightingRenderingPipeline:()=>Di,setDefaultRenderingPipelineRef:()=>Un,setMotionBlurPostProcessRef:()=>kn,setSSAO2RenderingPipelineRef:()=>Hn,setSSRRenderingPipelineRef:()=>Nn,setStaticDecalsEnabled:()=>Mn,setTAARenderingPipelineRef:()=>Bn,setUseKtx2CompressedTextures:()=>Pa,setVLSPostProcessRef:()=>Vn,setVolumetricLightingRenderingPipelineConfiguration:()=>Ne,setVolumetricLightingRenderingPipelineRef:()=>ua,setupOfflineProvider:()=>ss,soundFromScene:()=>Ba,spriteFromSpriteManager:()=>es,ssaoRenderingPipelineCameraConfigurations:()=>ue,ssrRenderingPipelineCameraConfigurations:()=>de,supportsVolumetricFloatDepthTexture:()=>Ro,taaRenderingPipelineCameraConfigurations:()=>fe,visibleAsAsset:()=>qa,visibleAsBoolean:()=>Ha,visibleAsColor3:()=>$a,visibleAsColor4:()=>Ka,visibleAsEntity:()=>ja,visibleAsKeyMap:()=>Ya,visibleAsNumber:()=>Ua,visibleAsString:()=>ka,visibleAsTexture:()=>Za,visibleAsVector2:()=>Wa,visibleAsVector3:()=>Xa,vlsPostProcessCameraConfigurations:()=>he,volumetricLightMetadataKey:()=>ae,volumetricLightingPrePassConfigurationName:()=>Mo});module.exports=wn(ms);function oe(t){switch(t.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}a(oe,"isAbstractMesh");function V(t){switch(t.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}a(V,"isMesh");function Ee(t){return t.getClassName?.()==="InstancedMesh"}a(Ee,"isInstancedMesh");function On(t){return t.getClassName?.()==="Bone"}a(On,"isBone");function En(t){return t.getClassName?.()==="GroundMesh"}a(En,"isGroundMesh");function ee(t){return t.getClassName?.()==="TransformNode"}a(ee,"isTransformNode");function Ae(t){return t?.getClassName?.()==="Texture"}a(Ae,"isTexture");function Ze(t){switch(t.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}a(Ze,"isCamera");function An(t){switch(t.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}a(An,"isFreeCamera");function Tn(t){return t.getClassName?.()==="ArcRotateCamera"}a(Tn,"isArcRotateCamera");function Ct(t){return t.getClassName?.()==="PointLight"}a(Ct,"isPointLight");function te(t){return t.getClassName?.()==="DirectionalLight"}a(te,"isDirectionalLight");function re(t){return t.getClassName?.()==="SpotLight"}a(re,"isSpotLight");function Ye(t){return t.getClassName?.()==="HemisphericLight"}a(Ye,"isHemisphericLight");function eo(t){switch(t.getClassName?.()){case"Light":case"PointLight":case"SpotLight":case"DirectionalLight":case"HemisphericLight":return!0}return!1}a(eo,"isLight");function Lt(t){return t.getClassName?.()==="ShadowGenerator"}a(Lt,"isShadowGenerator");function Dt(t){return t.getClassName?.()==="CascadedShadowGenerator"}a(Dt,"isCascadedShadowGenerator");function pe(t){return t.getClassName?.()==="ClusteredLightContainer"}a(pe,"isClusteredLightContainer");function me(t){return oe(t)||ee(t)||eo(t)||Ze(t)}a(me,"isNode");function _t(t){return t.getClassName?.()==="Scene"}a(_t,"isScene");function Pt(t){return t.getClassName?.()==="ParticleSystem"}a(Pt,"isParticleSystem");function In(t){return t.getClassName?.()==="GPUParticleSystem"}a(In,"isGPUParticleSystem");function wt(t){switch(t.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}a(wt,"isAnyParticleSystem");function Ot(t){return t.getClassName?.()==="Sprite"}a(Ot,"isSprite");function ne(t){return t.getClassName?.()==="SoundNode"}a(ne,"isSoundNode");function Et(t){return t.getClassName?.()==="GaussianSplattingMesh"}a(Et,"isGaussianSplattingMesh");function At(t){let e=t;for(;e;){if(e.metadata?.isStaticGroup)return!0;e=e.parent}return!1}a(At,"isNodeFromStaticGroup");function Tt(t){t.meshes.forEach(e=>{V(e)&&e.getLODLevels().forEach(i=>{i.mesh&&(i.mesh.originalDistanceOrScreenCoverage=i.distanceOrScreenCoverage)})})}a(Tt,"configureMeshDistanceOrScreenCoverage");function It(t,e){e.meshes.forEach(i=>{V(i)&&i.getLODLevels().forEach(o=>{if(o.mesh?.originalDistanceOrScreenCoverage)switch(t){case"very-low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.125;break;case"low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.25;break;case"medium":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.5;break;case"high":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage;break}})})}a(It,"applyMeshesLODQuality");function to(t){return(t.metadata?.decal??null)!==null}a(to,"isDecalMesh");function Mn(t,e){e.meshes.forEach(i=>{to(i)&&At(i)&&i.setEnabled(t)})}a(Mn,"setStaticDecalsEnabled");function F(t){let e=1;for(;e<=t;)e<<=1;return e>>1}a(F,"getPowerOfTwoUntil");var io=require("babylonjs"),oo=require("babylonjs");function Mt(t){t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.renderListPredicate=o=>Et(o)?!1:io.Vector3.Distance(o.getAbsolutePosition(),e.getAbsolutePosition())<=e.range)})}a(Mt,"configureShadowMapRenderListPredicate");async function qe(t){t.executeWhenReady(()=>{t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.refreshRate=e.metadata?.refreshRate??oo.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}a(qe,"configureShadowMapRefreshRate");function Rn(t,e){e.lights.forEach(i=>{let o=i.getShadowGenerator(),r=o?.getShadowMap();if(o?.originalMapSize){let n=o.originalMapSize;switch(t){case"medium":n=n*.5;break;case"low":n=n*.25;break;case"very-low":n=n*.125;break}n=Math.max(128,F(n)),r?.getSize().width!==n&&r.resize(n)}}),qe(e)}a(Rn,"applyShadowsQuality");var ro=require("babylonjs"),no=require("babylonjs"),ao=require("babylonjs"),w=null,he=new Map;function Rt(){return w}a(Rt,"getVLSPostProcess");function Vn(t){w=t}a(Vn,"setVLSPostProcessRef");function Vt(t){w&&t.activeCamera&&(w.dispose(t.activeCamera),w=null)}a(Vt,"disposeVLSPostProcess");function so(t,e,i){return e??=t.meshes.find(o=>V(o)),w=new ao.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,t.activeCamera,e,100,no.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),w.samples=i?.msaaSamples??1,w}a(so,"createVLSPostProcess");function Ft(){return w?{meshId:w.mesh?.id,exposure:w.exposure,decay:w.decay,weight:w.weight,density:w.density,invert:w.invert,useCustomMeshPosition:w.useCustomMeshPosition,customMeshPosition:w.customMeshPosition.asArray()}:null}a(Ft,"serializeVLSPostProcess");function Nt(t,e,i){let o=null;if(e.meshId){let n=t.getMeshById(e.meshId);n&&V(n)&&(o=n)}let r=w??so(t,o,i);return r.samples=i?.msaaSamples??1,r.exposure=e.exposure,r.decay=e.decay,r.weight=e.weight,r.density=e.density,r.invert=e.invert,r.useCustomMeshPosition=e.useCustomMeshPosition,r.customMeshPosition.copyFrom(ro.Vector3.FromArray(e.customMeshPosition)),r}a(Nt,"parseVLSPostProcess");var lo=require("babylonjs"),D=null,de=new Map;function Fn(){return D}a(Fn,"getSSRRenderingPipeline");function Nn(t){D=t}a(Nn,"setSSRRenderingPipelineRef");function Gt(){D&&(D.dispose(),D=null)}a(Gt,"disposeSSRRenderingPipeline");function co(t,e,i){return D=new lo.SSRRenderingPipeline("SSRRenderingPipeline",t,[e],void 0,X(t.getEngine())),D.samples=i?.msaaSamples??1,D}a(co,"createSSRRenderingPipeline");function Bt(){return D?{samples:D.samples,step:D.step,thickness:D.thickness,strength:D.strength,reflectionSpecularFalloffExponent:D.reflectionSpecularFalloffExponent,maxSteps:D.maxSteps,maxDistance:D.maxDistance,roughnessFactor:D.roughnessFactor,reflectivityThreshold:D.reflectivityThreshold,blurDispersionStrehgth:D.blurDispersionStrength,clipToFrustum:D.clipToFrustum,enableSmoothReflections:D.enableSmoothReflections,enableAutomaticThicknessComputation:D.enableAutomaticThicknessComputation,attenuateFacingCamera:D.attenuateFacingCamera,attenuateScreenBorders:D.attenuateScreenBorders,attenuateIntersectionDistance:D.attenuateIntersectionDistance,attenuateBackfaceReflection:D.attenuateBackfaceReflection,blurDownsample:D.blurDownsample,selfCollisionNumSkip:D.selfCollisionNumSkip,ssrDownsample:D.ssrDownsample,backfaceDepthTextureDownsample:D.backfaceDepthTextureDownsample}:null}a(Bt,"serializeSSRRenderingPipeline");function zt(t,e,i,o){let r=D??co(t,e,o);return r.samples=o?.msaaSamples??1,r.step=i.step,r.thickness=i.thickness,r.strength=i.strength,r.reflectionSpecularFalloffExponent=i.reflectionSpecularFalloffExponent,r.maxSteps=i.maxSteps,r.maxDistance=i.maxDistance,r.roughnessFactor=i.roughnessFactor,r.reflectivityThreshold=i.reflectivityThreshold,r.blurDispersionStrength=i.blurDispersionStrehgth,r.clipToFrustum=i.clipToFrustum,r.enableSmoothReflections=i.enableSmoothReflections,r.enableAutomaticThicknessComputation=i.enableAutomaticThicknessComputation,r.attenuateFacingCamera=i.attenuateFacingCamera,r.attenuateScreenBorders=i.attenuateScreenBorders,r.attenuateIntersectionDistance=i.attenuateIntersectionDistance,r.attenuateBackfaceReflection=i.attenuateBackfaceReflection,r.blurDownsample=i.blurDownsample,r.selfCollisionNumSkip=i.selfCollisionNumSkip,r.ssrDownsample=i.ssrDownsample,r.backfaceDepthTextureDownsample=i.backfaceDepthTextureDownsample,r}a(zt,"parseSSRRenderingPipeline");var po=require("babylonjs"),A=null,fe=new Map;function Gn(){return A}a(Gn,"getTAARenderingPipeline");function Bn(t){A=t}a(Bn,"setTAARenderingPipelineRef");function Ht(){A&&(A.dispose(),A=null)}a(Ht,"disposeTAARenderingPipeline");function mo(t,e,i){return A=new po.TAARenderingPipeline("TAARenderingPipeline",t,[e],X(t.getEngine())),A.msaaSamples=i?.msaaSamples??1,A}a(mo,"createTAARenderingPipeline");function kt(){return A?{factor:A.factor,samples:A.samples,clampHistory:A.clampHistory,reprojectHistory:A.reprojectHistory,disableOnCameraMove:A.disableOnCameraMove}:null}a(kt,"serializeTAARenderingPipeline");function Ut(t,e,i,o){let r=A??mo(t,e,o);return r.msaaSamples=o?.msaaSamples??1,r.factor=i.factor,r.clampHistory=i.clampHistory,r.reprojectHistory=i.reprojectHistory,r.disableOnCameraMove=i.disableOnCameraMove,r}a(Ut,"parseTAARenderingPipeline");var ho=require("babylonjs"),P=null,ue=new Map;function zn(){return P}a(zn,"getSSAO2RenderingPipeline");function Hn(t){P=t}a(Hn,"setSSAO2RenderingPipelineRef");function Wt(){P&&(P.dispose(),P=null)}a(Wt,"disposeSSAO2RenderingPipeline");function fo(t,e,i){return P=new ho.SSAO2RenderingPipeline("SSAO2RenderingPipeline",t,1,[e],void 0,X(t.getEngine())),P.textureSamples=1,P}a(fo,"createSSAO2RenderingPipeline");function Xt(){return P?{radius:P.radius,totalStrength:P.totalStrength,samples:P.samples,maxZ:P.maxZ,minZAspect:P.minZAspect,epsilon:P.epsilon,textureSamples:P.textureSamples,bypassBlur:P.bypassBlur,bilateralSamples:P.bilateralSamples,bilateralSoften:P.bilateralSoften,bilateralTolerance:P.bilateralTolerance,expensiveBlur:P.expensiveBlur}:null}a(Xt,"serializeSSAO2RenderingPipeline");function $t(t,e,i,o){let r=P??fo(t,e,o);return r.textureSamples=1,r.radius=i.radius,r.totalStrength=i.totalStrength,r.samples=i.samples,r.maxZ=i.maxZ,r.minZAspect=i.minZAspect,r.epsilon=i.epsilon,r.bypassBlur=i.bypassBlur,r.bilateralSamples=i.bilateralSamples,r.bilateralSoften=i.bilateralSoften,r.bilateralTolerance=i.bilateralTolerance,r.expensiveBlur=i.expensiveBlur,r}a($t,"parseSSAO2RenderingPipeline");var uo=require("babylonjs"),T=null,ge=new Map;function Kt(){return T}a(Kt,"getMotionBlurPostProcess");function kn(t){T=t}a(kn,"setMotionBlurPostProcessRef");function jt(){T&&(T.dispose(),T=null)}a(jt,"disposeMotionBlurPostProcess");function go(t,e,i){return T=new uo.MotionBlurPostProcess("MotionBlurPostProcess",t,1,e,void 0,void 0,void 0,X(t.getEngine())),T.samples=i?.msaaSamples??1,T.motionStrength=1,T.isObjectBased=!0,T}a(go,"createMotionBlurPostProcess");function Zt(){return T?{isObjectBased:T.isObjectBased,motionStrength:T.motionStrength,motionBlurSamples:T.motionBlurSamples}:null}a(Zt,"serializeMotionBlurPostProcess");function Yt(t,e,i,o){let r=T??go(t,e,o);return r.samples=o?.msaaSamples??1,r.isObjectBased=i.isObjectBased,r.motionStrength=i.motionStrength,r.motionBlurSamples=i.motionBlurSamples,r}a(Yt,"parseMotionBlurPostProcess");var vo=require("babylonjs"),qt=require("babylonjs"),So=require("babylonjs"),yo=require("babylonjs"),bo=require("babylonjs"),g=null,ve=new Map;function Te(){return g}a(Te,"getDefaultRenderingPipeline");function Un(t){g=t}a(Un,"setDefaultRenderingPipelineRef");function Qt(){g&&(g.dispose(),g=null)}a(Qt,"disposeDefaultRenderingPipeline");function xo(t,e,i){return g=new bo.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,t,[e]),g.samples=i?.msaaSamples??1,g.depthOfField.lensSize=512,g.depthOfField.fStop=.25,g.depthOfField.focusDistance=55e3,g}a(xo,"createDefaultRenderingPipeline");function Jt(){return g?{samples:g.samples,fxaaEnabled:g.fxaaEnabled,imageProcessingEnabled:g.imageProcessingEnabled,exposure:g.imageProcessing?.exposure,contrast:g.imageProcessing?.contrast,fromLinearSpace:g.imageProcessing?.fromLinearSpace,toneMappingEnabled:g.imageProcessing?.toneMappingEnabled,toneMappingType:g.imageProcessing?.toneMappingType,ditheringEnabled:g.imageProcessing?.ditheringEnabled,ditheringIntensity:g.imageProcessing?.ditheringIntensity,bloomEnabled:g.bloomEnabled,bloomThreshold:g.bloomThreshold,bloomWeight:g.bloomWeight,bloomScale:g.bloomScale,bloomKernel:g.bloomKernel,sharpenEnabled:g.sharpenEnabled,sharpenEdgeAmount:g.sharpen.edgeAmount,sharpenColorAmount:g.sharpen.colorAmount,grainEnabled:g.grainEnabled,grainIntensity:g.grain.intensity,grainAnimated:g.grain.animated,depthOfFieldEnabled:g.depthOfFieldEnabled,depthOfFieldBlurLevel:g.depthOfFieldBlurLevel,lensSize:g.depthOfField.lensSize,fStop:g.depthOfField.fStop,focusDistance:g.depthOfField.focusDistance,focalLength:g.depthOfField.focalLength,vignetteEnabled:g.imageProcessing?.vignetteEnabled,vignetteColor:g.imageProcessing?.vignetteColor.asArray(),vignetteWeight:g.imageProcessing?.vignetteWeight,chromaticAberrationEnabled:g.chromaticAberrationEnabled,aberrationAmount:g.chromaticAberration.aberrationAmount,radialIntensity:g.chromaticAberration.radialIntensity,direction:g.chromaticAberration.direction.asArray(),centerPosition:g.chromaticAberration.centerPosition.asArray(),glowLayerEnabled:g.glowLayerEnabled,glowLayerIntensity:g.glowLayer?.intensity,glowLayerBlurKernelSize:g.glowLayer?.blurKernelSize,colorGradingEnabled:g.imageProcessing.colorGradingEnabled,colorGradingTexture:g.imageProcessing.colorGradingTexture?.serialize(),colorGradingWithGreenDepth:g.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth,colorCurvesEnabled:g.imageProcessing.colorCurvesEnabled,globalHue:g.imageProcessing.colorCurves?.globalHue,globalDensity:g.imageProcessing.colorCurves?.globalDensity,globalExposure:g.imageProcessing.colorCurves?.globalExposure,globalSaturation:g.imageProcessing.colorCurves?.globalSaturation,highlightsHue:g.imageProcessing.colorCurves?.highlightsHue,highlightsDensity:g.imageProcessing.colorCurves?.highlightsDensity,highlightsExposure:g.imageProcessing.colorCurves?.highlightsExposure,highlightsSaturation:g.imageProcessing.colorCurves?.highlightsSaturation,midtonesHue:g.imageProcessing.colorCurves?.midtonesHue,midtonesDensity:g.imageProcessing.colorCurves?.midtonesDensity,midtonesExposure:g.imageProcessing.colorCurves?.midtonesExposure,midtonesSaturation:g.imageProcessing.colorCurves?.midtonesSaturation,shadowsHue:g.imageProcessing.colorCurves?.shadowsHue,shadowsDensity:g.imageProcessing.colorCurves?.shadowsDensity,shadowsExposure:g.imageProcessing.colorCurves?.shadowsExposure,shadowsSaturation:g.imageProcessing.colorCurves?.shadowsSaturation}:null}a(Jt,"serializeDefaultRenderingPipeline");function ei(t,e,i,o,r){let n=g??xo(t,e,r);if(n.samples=r?.msaaSamples??1,n.fxaaEnabled=i.fxaaEnabled,n.imageProcessingEnabled=i.imageProcessingEnabled,n.imageProcessing){if(n.imageProcessing.exposure=i.exposure,n.imageProcessing.contrast=i.contrast,n.imageProcessing.fromLinearSpace=i.fromLinearSpace,n.imageProcessing.toneMappingEnabled=i.toneMappingEnabled,n.imageProcessing.toneMappingType=i.toneMappingType,n.imageProcessing.ditheringEnabled=i.ditheringEnabled,n.imageProcessing.ditheringIntensity=i.ditheringIntensity,n.imageProcessing.vignetteEnabled=i.vignetteEnabled??!1,n.imageProcessing.vignetteColor=vo.Color4.FromArray(i.vignetteColor??[0,0,0]),n.imageProcessing.vignetteWeight=i.vignetteWeight??.3,n.imageProcessing.colorGradingEnabled=i.colorGradingEnabled??!1,n.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth=i.colorGradingWithGreenDepth??!0,i.colorGradingTexture){let l=null;if(i.colorGradingTexture.customType==="BABYLON.ColorGradingTexture"){let p=o+i.colorGradingTexture.name;l=new yo.ColorGradingTexture(p,t),l.level=i.colorGradingTexture.level}else{let p=So.Texture.Parse(i.colorGradingTexture,t,o);Ae(p)&&(l=p)}n.imageProcessing.colorGradingTexture=l}n.imageProcessing.colorCurvesEnabled=i.colorCurvesEnabled??!1,n.imageProcessing.colorCurves&&(n.imageProcessing.colorCurves.globalHue=i.globalHue??30,n.imageProcessing.colorCurves.globalDensity=i.globalDensity??0,n.imageProcessing.colorCurves.globalExposure=i.globalExposure??0,n.imageProcessing.colorCurves.globalSaturation=i.globalSaturation??0,n.imageProcessing.colorCurves.highlightsHue=i.highlightsHue??30,n.imageProcessing.colorCurves.highlightsDensity=i.highlightsDensity??0,n.imageProcessing.colorCurves.highlightsExposure=i.highlightsExposure??0,n.imageProcessing.colorCurves.highlightsSaturation=i.highlightsSaturation??0,n.imageProcessing.colorCurves.midtonesHue=i.midtonesHue??30,n.imageProcessing.colorCurves.midtonesDensity=i.midtonesDensity??0,n.imageProcessing.colorCurves.midtonesExposure=i.midtonesExposure??0,n.imageProcessing.colorCurves.midtonesSaturation=i.midtonesSaturation??0,n.imageProcessing.colorCurves.shadowsHue=i.shadowsHue??30,n.imageProcessing.colorCurves.shadowsDensity=i.shadowsDensity??0,n.imageProcessing.colorCurves.shadowsExposure=i.shadowsExposure??0,n.imageProcessing.colorCurves.shadowsSaturation=i.shadowsSaturation??0)}return n.bloomEnabled=i.bloomEnabled,n.bloomThreshold=i.bloomThreshold,n.bloomWeight=i.bloomWeight,n.bloomScale=i.bloomScale,n.bloomKernel=i.bloomKernel,n.sharpenEnabled=i.sharpenEnabled,n.sharpen.edgeAmount=i.sharpenEdgeAmount,n.sharpen.colorAmount=i.sharpenColorAmount,n.grainEnabled=i.grainEnabled,n.grain.intensity=i.grainIntensity,n.grain.animated=i.grainAnimated,n.depthOfFieldEnabled=i.depthOfFieldEnabled,n.depthOfFieldBlurLevel=i.depthOfFieldBlurLevel,n.depthOfField.lensSize=i.lensSize,n.depthOfField.fStop=i.fStop,n.depthOfField.focusDistance=i.focusDistance,n.depthOfField.focalLength=i.focalLength,n.chromaticAberrationEnabled=i.chromaticAberrationEnabled??!1,n.chromaticAberration.aberrationAmount=i.aberrationAmount??10,n.chromaticAberration.radialIntensity=i.radialIntensity??1,n.chromaticAberration.direction=qt.Vector2.FromArray(i.direction??[0,0]),n.chromaticAberration.centerPosition=qt.Vector2.FromArray(i.centerPosition??[0,0]),n.glowLayerEnabled=i.glowLayerEnabled??!1,n.glowLayer&&(n.glowLayer.intensity=i.glowLayerIntensity??1,n.glowLayer.blurKernelSize=i.glowLayerBlurKernelSize??32),n}a(ei,"parseDefaultRenderingPipeline");var ae="volumetricLighting",E=8,$=256,ri=4,Co=(i=>(i[i.Linear=0]="Linear",i[i.Exponential=1]="Exponential",i))(Co||{}),ni=(o=>(o[o.None=0]="None",o[o.Bayer=1]="Bayer",o[o.InterleavedGradientNoise=2]="InterleavedGradientNoise",o))(ni||{}),ai=(o=>(o[o.Exponential=0]="Exponential",o[o.ExponentialSquared=1]="ExponentialSquared",o[o.Linear=2]="Linear",o))(ai||{}),Lo=(r=>(r[r.None=0]="None",r[r.Scattering=1]="Scattering",r[r.Transmittance=2]="Transmittance",r[r.LightCount=3]="LightCount",r))(Lo||{});function oi(){return{enabled:!1,volumeIntensity:1,anisotropy:.35,useCustomColor:!1,color:[1,1,1],castVolumetricShadows:!0,shadowDarkness:1,rangeMultiplier:1,priority:0}}a(oi,"getDefaultVolumetricLightConfiguration");function Qe(){return{steps:40,lightSteps:0,resolutionScale:.5,stepDistribution:1,ditherMode:2,ditherStrength:1,temporalJitter:!1,fogMode:0,fogDensity:5e-4,fogStart:0,fogEnd:2e3,fogColor:[1,1,1],albedo:1,maxDistance:1e4,heightFogEnabled:!1,heightFogBaseHeight:0,heightFogFalloff:.01,intensity:1.5,lightExtinctionEnabled:!0,lightExtinctionClamp:1e3,extinctionAmount:0,ambientColor:[1,1,1],ambientIntensity:0,screenSpaceShadows:!0,screenSpaceShadowSteps:6,screenSpaceShadowBias:.02,screenSpaceShadowMaxDistance:2e3,screenSpaceShadowThickness:4,blurPasses:2,blurRadius:3,blurDepthThreshold:.02,upsampleDepthThreshold:.02,maxLights:128,maxShadowedLights:4,pcfTaps:4,selectionRefreshRate:2,debugMode:0}}a(Qe,"getDefaultVolumetricLightingConfiguration");function si(t){return t.lightSteps>0?t.lightSteps:Math.max(4,Math.min(64,Math.round(t.steps*.3)))}a(si,"getVolumetricLightSteps");function b(t,e,i,o){let r=typeof t=="number"&&isFinite(t)?t:e;return Math.min(o,Math.max(i,r))}a(b,"normalizeNumber");function ti(t,e){return!Array.isArray(t)||t.length<3?e.slice():[b(t[0],e[0],0,100),b(t[1],e[1],0,100),b(t[2],e[2],0,100)]}a(ti,"normalizeColor");function Do(t){let e=oi();return!t||typeof t!="object"?e:{enabled:t.enabled??e.enabled,volumeIntensity:b(t.volumeIntensity,e.volumeIntensity,0,1e3),anisotropy:b(t.anisotropy,e.anisotropy,-.95,.95),useCustomColor:t.useCustomColor??e.useCustomColor,color:ti(t.color,e.color),castVolumetricShadows:t.castVolumetricShadows??e.castVolumetricShadows,shadowDarkness:b(t.shadowDarkness,e.shadowDarkness,0,1),rangeMultiplier:b(t.rangeMultiplier,e.rangeMultiplier,0,100),priority:b(t.priority,e.priority,-1e3,1e3)}}a(Do,"normalizeVolumetricLightConfiguration");function Se(t){let e=Qe();return!t||typeof t!="object"?e:{steps:Math.round(b(t.steps,e.steps,4,256)),lightSteps:Math.round(b(t.lightSteps,e.lightSteps,0,128)),resolutionScale:b(t.resolutionScale,e.resolutionScale,.1,1),stepDistribution:Math.round(b(t.stepDistribution,e.stepDistribution,0,1)),ditherMode:Math.round(b(t.ditherMode,e.ditherMode,0,2)),ditherStrength:b(t.ditherStrength,e.ditherStrength,0,1),temporalJitter:t.temporalJitter??e.temporalJitter,fogMode:Math.round(b(t.fogMode,e.fogMode,0,2)),fogDensity:b(t.fogDensity,e.fogDensity,0,100),fogStart:b(t.fogStart,e.fogStart,0,1e6),fogEnd:Math.max(b(t.fogEnd,e.fogEnd,0,1e7),b(t.fogStart,e.fogStart,0,1e6)+.001),fogColor:ti(t.fogColor,e.fogColor),albedo:b(t.albedo,e.albedo,0,1),maxDistance:b(t.maxDistance,e.maxDistance,1,1e6),heightFogEnabled:t.heightFogEnabled??e.heightFogEnabled,heightFogBaseHeight:b(t.heightFogBaseHeight,e.heightFogBaseHeight,-1e6,1e6),heightFogFalloff:b(t.heightFogFalloff,e.heightFogFalloff,0,10),intensity:b(t.intensity,e.intensity,0,100),lightExtinctionEnabled:t.lightExtinctionEnabled??e.lightExtinctionEnabled,lightExtinctionClamp:b(t.lightExtinctionClamp,e.lightExtinctionClamp,0,1e6),extinctionAmount:b(t.extinctionAmount,e.extinctionAmount,0,1),ambientColor:ti(t.ambientColor,e.ambientColor),ambientIntensity:b(t.ambientIntensity,e.ambientIntensity,0,100),screenSpaceShadows:t.screenSpaceShadows??e.screenSpaceShadows,screenSpaceShadowSteps:Math.round(b(t.screenSpaceShadowSteps,e.screenSpaceShadowSteps,1,32)),screenSpaceShadowBias:b(t.screenSpaceShadowBias,e.screenSpaceShadowBias,0,1),screenSpaceShadowMaxDistance:b(t.screenSpaceShadowMaxDistance,e.screenSpaceShadowMaxDistance,1,1e7),screenSpaceShadowThickness:b(t.screenSpaceShadowThickness,e.screenSpaceShadowThickness,.01,1e3),blurPasses:Math.round(b(t.blurPasses,e.blurPasses,0,2)),blurRadius:Math.round(b(t.blurRadius,e.blurRadius,1,6)),blurDepthThreshold:b(t.blurDepthThreshold,e.blurDepthThreshold,1e-4,1),upsampleDepthThreshold:b(t.upsampleDepthThreshold,e.upsampleDepthThreshold,1e-4,1),maxLights:Math.round(b(t.maxLights,e.maxLights,0,$)),maxShadowedLights:Math.round(b(t.maxShadowedLights,e.maxShadowedLights,0,E)),pcfTaps:b(t.pcfTaps,e.pcfTaps,1,4)>=4?4:1,selectionRefreshRate:Math.round(b(t.selectionRefreshRate,e.selectionRefreshRate,1,60)),debugMode:Math.round(b(t.debugMode,e.debugMode,0,3))}}a(Se,"normalizeVolumetricLightingConfiguration");var ii=new WeakSet;function _o(t){t.metadata??={};let e=t.metadata[ae];if(!e||typeof e!="object")return t.metadata[ae]=Do(null),ii.add(t.metadata[ae]),t.metadata[ae];if(ii.has(e))return e;let i=oi();return Object.keys(i).forEach(o=>{e[o]===void 0&&(e[o]=i[o])}),ii.add(e),e}a(_o,"ensureVolumetricLightConfiguration");function li(t){let e=t.metadata?.[ae];return e&&typeof e=="object"?_o(t):null}a(li,"getVolumetricLightConfiguration");function Wn(t){return t.metadata?.[ae]?.enabled===!0}a(Wn,"isVolumetricLightEnabled");var Je=require("babylonjs"),Eo=require("babylonjs"),pi=require("babylonjs"),K=require("babylonjs"),mi=(o=>(o[o.Texture2D=0]="Texture2D",o[o.Sampler2DShadow=1]="Sampler2DShadow",o[o.Cube=2]="Cube",o))(mi||{}),Ao=(o=>(o[o.Standard=0]="Standard",o[o.Esm=1]="Esm",o[o.CloseEsm=2]="CloseEsm",o))(Ao||{}),hi=(o=>(o[o.Analytic=0]="Analytic",o[o.AnalyticHeight=1]="AnalyticHeight",o[o.Numeric=2]="Numeric",o))(hi||{}),Po=10,Xn=4,$n=22,Kn=32,jn=.15;function Ie(t,e){let i=t.getCaps(),o=i.maxFragmentUniformVectors||224,r=t.isWebGPU?Math.floor(o/4):o,n=Math.max(224,r)-Kn,l=Math.max(8,i.maxTexturesImageUnits||16)-1,p=l>=2,s=p?$n:0,c=Math.max(0,Math.min(E,e.maxShadowedLights,l-(p?1:0),Math.floor((n-s)/Po))),m=Math.max(0,Math.min($,e.maxLights,Math.floor((n-s-c*Po)/Xn)));return{maxShadowSlots:c,maxArrayLights:m,maxDirectionalLights:Math.min(ri,m),allowCsm:p}}a(Ie,"computeVolumetricBudget");function To(t){let e=[];return t.lights.forEach(i=>{pe(i)?i.lights.forEach(o=>{e.push({light:o,isClustered:!0})}):e.push({light:i,isClustered:!1})}),e}a(To,"getAllVolumetricCandidateLights");function Io(t,e){let i=t.getShadowGenerator(e.activeCamera)??t.getShadowGenerator();if(!i||!Lt(i))return null;let o=i.getShadowMapForRendering();if(!o?.isReady())return null;let r=i.getShadowMap()?.getSize().width??1024,n=o.textureType===pi.Constants.TEXTURETYPE_UNSIGNED_BYTE,l=!te(t),p=t.needCube?.()===!0;switch(i.filter){case K.ShadowGenerator.FILTER_PCF:case K.ShadowGenerator.FILTER_PCSS:return{generator:i,kind:p?2:1,mode:0,packed:n,mapSize:r,local:l};case K.ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP:case K.ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:1,packed:n,mapSize:r,local:l};case K.ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP:case K.ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:2,packed:n,mapSize:r,local:l};default:return{generator:i,kind:p?2:0,mode:0,packed:n,mapSize:r,local:l}}}a(Io,"resolveVolumetricShadowSlot");function et(t,e){let i=t;return i.computeTransformedInformation?.()&&i.transformedPosition?e.copyFrom(i.transformedPosition):i.position?e.copyFrom(i.position):e.copyFromFloats(0,0,0),e}a(et,"getVolumetricLightWorldPosition");function Me(t,e){let i=t;return i.computeTransformedInformation?.()&&i.transformedDirection?e.copyFrom(i.transformedDirection):i.direction?e.copyFrom(i.direction):e.copyFromFloats(0,0,1),e.normalize()}a(Me,"getVolumetricLightWorldDirection");function tt(t,e,i){let o=t.range>0&&t.range<Number.MAX_VALUE?t.range:i.maxDistance;return Math.max(.001,Math.min(o*e.rangeMultiplier,34e37))}a(tt,"getVolumetricLightRange");var ci=new Je.Vector3,wo=new Je.Vector3;function Zn(t,e,i){if(et(t,i),!re(t))return e;let o=Math.cos(t.angle*.5);if(o<=.5)return e;let r=e/(2*o);return Me(t,wo),i.addInPlace(wo.scaleInPlace(r)),r}a(Zn,"computeVolumetricLightBounds");function Yn(t,e,i){for(let o=0;o<i.length;++o)if(i[o].dotCoordinate(t)<=-e)return!1;return!0}a(Yn,"isSphereInFrustum");function Oo(t){return(t.local?64:0)+t.kind*16+t.mode*4+(t.packed?1:0)}a(Oo,"getShadowSlotSignature");function di(t,e,i,o,r){let n={candidateCount:0,culledCount:0,shadowedCount:0,unshadowedCount:0,droppedCount:0,perLight:new Map},l=Eo.Frustum.GetPlanes(t.getTransformMatrix()),p=e.globalPosition,s=[];To(t).forEach(({light:v,isClustered:C})=>{let R=li(v);if(!R?.enabled)return;if(n.candidateCount++,Ye(v)||!v.isEnabled()||v.intensity<=0||R.volumeIntensity<=0){n.perLight.set(v.uniqueId,{state:"disabled",slot:-1,reason:Ye(v)?"Hemispheric lights have no position nor direction and can't produce light shafts.":"The light is disabled or its intensity is zero."});return}let W=te(v),ce=R.priority*1e3;if(W)ce+=1e6;else{let Ke=Math.min(tt(v,R,i),i.maxDistance),xt=Zn(v,Ke,ci);if(!Yn(ci,xt,l)){n.culledCount++,n.perLight.set(v.uniqueId,{state:"culled",slot:-1,reason:"The light is outside of the frustum of the camera and doesn't reach it."});return}let xn=Math.max(1,Je.Vector3.Distance(ci,p)-xt);ce+=R.volumeIntensity*v.intensity*Math.min(4,xt/xn)}s.push({light:v,config:R,isClustered:C,typeId:v.getTypeID(),score:ce})}),s.sort((v,C)=>C.score-v.score);let c=new Map;r?.shadowed.forEach((v,C)=>{c.set(v.candidate.light.uniqueId,C)});let m=[],h=[],d=new Map,f=null;s.forEach(v=>{let{light:C,config:R}=v;if(!R.castVolumetricShadows){d.set(C.uniqueId,"occlusion is disabled on this light."),h.push(v);return}if(v.isClustered){d.set(C.uniqueId,"clustered lighting doesn't support shadow maps."),h.push(v);return}if(!C.shadowEnabled||!t.shadowsEnabled){d.set(C.uniqueId,"shadows are disabled on this light or on the scene."),h.push(v);return}let W=C.getShadowGenerator(t.activeCamera)??C.getShadowGenerator();if(!W){d.set(C.uniqueId,"the light has no shadow generator."),h.push(v);return}if(Dt(W)&&o.allowCsm){let Ke=W.getShadowMapForRendering();if(!f&&Ke?.isReady()){f={candidate:v,generator:W,cascades:W.numCascades,kind:W.filter===K.ShadowGenerator.FILTER_PCF||W.filter===K.ShadowGenerator.FILTER_PCSS?1:0,packed:Ke.textureType===pi.Constants.TEXTURETYPE_UNSIGNED_BYTE};return}d.set(C.uniqueId,f?"another light already uses the single cascaded shadow map slot.":"its cascaded shadow map is not ready yet."),h.push(v);return}let ce=Io(C,t);if(!ce){d.set(C.uniqueId,"the shadow map of the light is not ready yet."),h.push(v);return}m.push({candidate:v,shadow:ce})});function S(v){let C=v.candidate.score;return c.get(v.candidate.light.uniqueId)===void 0?C:C+Math.abs(C)*jn}a(S,"getHysteresisScore");function u(v){return c.get(v.candidate.light.uniqueId)??Number.MAX_SAFE_INTEGER}a(u,"getPreviousSlot"),m.sort((v,C)=>{let R=S(C)-S(v);return R!==0?R:u(v)-u(C)});let y=m.slice(0,o.maxShadowSlots);y.sort((v,C)=>Oo(v.shadow)-Oo(C.shadow)||u(v)-u(C)),m.slice(o.maxShadowSlots).forEach(v=>{d.set(v.candidate.light.uniqueId,"the shadowed lights budget is full."),h.push(v.candidate)}),h.sort((v,C)=>C.score-v.score);let L=[],_=[],x=[];h.forEach(v=>{te(v.light)?L.length<o.maxDirectionalLights?L.push(v):x.push({candidate:v,reason:`Not rendered: at most ${o.maxDirectionalLights} directional light(s) without a shadow map can take part in the effect.`}):_.push(v)});let M=Math.max(0,o.maxArrayLights-L.length);_.slice(M).forEach(v=>{x.push({candidate:v,reason:'Not rendered: the lights budget is full. Raise "Max Lights" or lower the priority of the other lights.'})});let N=L.concat(_.slice(0,M));if(y.forEach((v,C)=>{n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:C,reason:`Casting volumetric shadows using slot ${C+1} of ${o.maxShadowSlots}.`})}),f){let v=f;n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:-1,reason:`Casting volumetric shadows using its ${v.cascades} shadow cascades.`})}return N.forEach(v=>{n.unshadowedCount++;let C=v.config.castVolumetricShadows?"Occluded using the depth buffer":"Not occluded by the geometry",R=d.get(v.light.uniqueId)??"the light has no shadow map.";n.perLight.set(v.light.uniqueId,{state:"unshadowed",slot:-1,reason:`${C}: ${R}`})}),x.forEach(({candidate:v,reason:C})=>{n.droppedCount++,n.perLight.set(v.light.uniqueId,{state:"dropped",slot:-1,reason:C})}),{shadowed:y,unshadowed:N,directionalCount:L.length,csm:f,stats:n}}a(di,"selectVolumetricLights");function qn(t,e,i){let o=t.shadowed.map(n=>`${n.shadow.kind}.${n.shadow.mode}.${n.shadow.packed?1:0}.${n.shadow.local?1:0}`).join("|"),r=t.csm?`${t.csm.kind}.${t.csm.cascades}.${t.csm.packed?1:0}`:"-";return[e.steps,i.lightSteps,e.stepDistribution,e.ditherMode,e.temporalJitter?1:0,e.heightFogEnabled?1:0,e.lightExtinctionEnabled?1:0,e.pcfTaps,e.blurRadius,e.debugMode,e.screenSpaceShadows?e.screenSpaceShadowSteps:0,i.fogMode,i.transmittance,i.depthMode,i.ldrEncode?1:0,i.reverseDepth?1:0,i.ndcHalfZ?1:0,i.linearDepthPacked?1:0,i.arrayLightCapacity,t.directionalCount,o,r].join(",")}a(qn,"computeVolumetricShapeKey");function Qn(t){return Ct(t)||re(t)||te(t)}a(Qn,"isVolumetricLightSupported");var fi=require("babylonjs"),Jn=0,ui=(o=>(o[o.DepthRenderer=0]="DepthRenderer",o[o.GeometryBuffer=1]="GeometryBuffer",o[o.PrePass=2]="PrePass",o))(ui||{}),Mo="volumetricLighting";function gi(){return{name:Mo,enabled:!1,texturesRequired:[fi.Constants.PREPASS_DEPTH_TEXTURE_TYPE]}}a(gi,"createVolumetricLightingPrePassConfiguration");function ye(t){return t.prePassRenderer??null}a(ye,"getVolumetricPrePassRenderer");function Re(t){return t.geometryBufferRenderer??null}a(Re,"getVolumetricGeometryBufferRenderer");function Ro(t){let e=t.getCaps();return e.textureFloat&&e.textureFloatLinearFiltering||e.textureHalfFloat&&e.textureHalfFloatLinearFiltering}a(Ro,"supportsVolumetricFloatDepthTexture");function it(t){return Ro(t.getEngine())?ye(t)?.isSupported?2:Re(t)?.isSupported?1:0:0}a(it,"resolveVolumetricDepthSource");function vi(t){let e=t.getIndex(fi.Constants.PREPASS_DEPTH_TEXTURE_TYPE);return e===void 0||e<0?null:t.getRenderTarget()?.textures?.[e]??null}a(vi,"getVolumetricPrePassDepthTexture");function Si(t){if(!t.enableDepth)return null;let e=t.getTextureIndex(Jn);return e<0?null:t.getGBuffer()?.textures?.[e]??null}a(Si,"getVolumetricGeometryBufferDepthTexture");var ot=`
1
+ var qe=Object.defineProperty;var Tn=Object.getOwnPropertyDescriptor;var On=Object.getOwnPropertyNames;var En=Object.prototype.hasOwnProperty;var a=(i,e)=>qe(i,"name",{value:e,configurable:!0});var An=(i,e)=>{for(var t in e)qe(i,t,{get:e[t],enumerable:!0})},In=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of On(e))!En.call(i,r)&&r!==t&&qe(i,r,{get:()=>e[r],enumerable:!(o=Tn(e,r))||o.enumerable});return i};var Mn=i=>In(qe({},"__esModule",{value:!0}),i);var Ds={};An(Ds,{AdvancedAssetContainer:()=>Ue,AdvancedAssetContainerInstantiatedEntries:()=>ke,Cinematic:()=>je,Database:()=>Ze,NodeParticleSystemSet:()=>fn.NodeParticleSystemSet,VolumetricDebugMode:()=>mi,VolumetricDepthSource:()=>xi,VolumetricDitherMode:()=>pi,VolumetricFogMode:()=>hi,VolumetricLightingRenderingPipeline:()=>q,VolumetricShadowKind:()=>vi,VolumetricShadowMode:()=>Mo,VolumetricStepDistribution:()=>Lo,VolumetricTransmittanceMode:()=>Si,_applyScriptsForObject:()=>H,_getKtx2TextureName:()=>yt,_preloadScriptsAssets:()=>zi,_registerScriptInstance:()=>Ui,_removeRegisteredScriptInstance:()=>gt,addExcludedCompressedTexture:()=>bt,animationFromSprite:()=>us,animationGroupFromScene:()=>Za,applyMeshesLODQuality:()=>Nt,applyRagdollJointLimits:()=>Ma,applyRenderingConfigurationForCamera:()=>Ei,applyScriptOnObject:()=>Ga,applyShadowsQuality:()=>Hn,applyTexturesQuality:()=>Ha,canUseHdr:()=>Ia,componentFromScene:()=>ja,computeVolumetricBudget:()=>Ve,computeVolumetricShapeKey:()=>ra,configureEngineToUseCompressedTextures:()=>za,configureMeshDistanceOrScreenCoverage:()=>Ft,configureShadowMapRefreshRate:()=>et,configureShadowMapRenderListPredicate:()=>Gt,copyAndParseRagdollConfiguration:()=>Mi,createAndOpenDatabase:()=>to,createDefaultRenderingPipeline:()=>Do,createMotionBlurPostProcess:()=>yo,createSSAO2RenderingPipeline:()=>vo,createSSRRenderingPipeline:()=>mo,createTAARenderingPipeline:()=>fo,createVLSPostProcess:()=>po,createVolumetricLightingPrePassConfiguration:()=>_i,createVolumetricLightingRenderingPipeline:()=>er,defaultPipelineCameraConfigurations:()=>ye,disposeDefaultRenderingPipeline:()=>oi,disposeMotionBlurPostProcess:()=>Jt,disposeSSAO2RenderingPipeline:()=>Zt,disposeSSRRenderingPipeline:()=>Ut,disposeTAARenderingPipeline:()=>$t,disposeVLSPostProcess:()=>zt,disposeVolumetricLightingRenderingPipeline:()=>wi,ensureVolumetricLightConfiguration:()=>To,forceCompileAllSceneMaterials:()=>Xa,generateCinematicAnimationGroup:()=>ys,getAllScriptsByClassForObject:()=>Te,getAllVolumetricCandidateLights:()=>Ro,getAnimationTypeForObject:()=>$e,getDefaultRenderingPipeline:()=>Re,getDefaultVolumetricLightConfiguration:()=>li,getDefaultVolumetricLightingConfiguration:()=>it,getFromIndexDB:()=>Ke,getHdrTextureType:()=>K,getMotionBlurPostProcess:()=>Qt,getPowerOfTwoUntil:()=>N,getSSAO2RenderingPipeline:()=>jn,getSSRRenderingPipeline:()=>Un,getScriptByClassForObject:()=>ki,getTAARenderingPipeline:()=>Xn,getTextureUrl:()=>xt,getVLSPostProcess:()=>Bt,getVolumetricGeometryBufferDepthTexture:()=>Di,getVolumetricGeometryBufferRenderer:()=>Ne,getVolumetricLightConfiguration:()=>ui,getVolumetricLightRange:()=>nt,getVolumetricLightSteps:()=>Po,getVolumetricLightWorldDirection:()=>Fe,getVolumetricLightWorldPosition:()=>rt,getVolumetricLightingRenderingPipeline:()=>wa,getVolumetricLightingRenderingPipelineConfiguration:()=>Pi,getVolumetricPrePassDepthTexture:()=>Ci,getVolumetricPrePassRenderer:()=>xe,getVolumetricSamplingSteps:()=>di,guiFromAsset:()=>qa,isAbstractMesh:()=>ne,isAnyParticleSystem:()=>It,isArcRotateCamera:()=>Nn,isBone:()=>Rn,isCamera:()=>Qe,isCascadedShadowGenerator:()=>Ot,isCinematicGroup:()=>vs,isCinematicKey:()=>Ji,isCinematicKeyCut:()=>Ee,isCinematicKeyEvent:()=>gs,isCinematicSound:()=>Ss,isClusteredLightContainer:()=>me,isDecalMesh:()=>ro,isDirectionalLight:()=>ie,isFreeCamera:()=>Fn,isGPUParticleSystem:()=>Gn,isGaussianSplattingMesh:()=>Rt,isGroundMesh:()=>Vn,isHemisphericLight:()=>Je,isInstancedMesh:()=>Ie,isLight:()=>oo,isMesh:()=>F,isNode:()=>de,isNodeFromStaticGroup:()=>Vt,isParticleSystem:()=>At,isPointLight:()=>wt,isScene:()=>Et,isShadowGenerator:()=>Tt,isSoundNode:()=>se,isSpotLight:()=>ae,isSprite:()=>Mt,isSpriteManagerNode:()=>Bn,isTexture:()=>Me,isTransformNode:()=>te,isUsingKtx2CompressedTextures:()=>Xe,isVolumetricLightEnabled:()=>qn,isVolumetricLightSupported:()=>na,isVolumetricLightingSupported:()=>Oa,loadMaterialFromFile:()=>Wa,loadScene:()=>Ua,markVolumetricLightsDirty:()=>Ea,maxVolumetricArrayLights:()=>Z,maxVolumetricDirectionalLights:()=>ci,maxVolumetricShadowSlots:()=>O,motionBlurPostProcessCameraConfigurations:()=>Se,nodeFromDescendants:()=>Ka,nodeFromScene:()=>$a,normalizeAtlasJson:()=>Xi,normalizeVolumetricLightConfiguration:()=>wo,normalizeVolumetricLightingConfiguration:()=>be,onKeyboardEvent:()=>ms,onPointerEvent:()=>hs,openIndexDB:()=>eo,parseCinematic:()=>fs,parseCinematicKeyValue:()=>W,parseDefaultRenderingPipeline:()=>ni,parseKeyFrameAnimations:()=>qi,parseMotionBlurPostProcess:()=>ti,parseRagdollConfiguration:()=>sr,parseSSAO2RenderingPipeline:()=>qt,parseSSRRenderingPipeline:()=>Xt,parseTAARenderingPipeline:()=>Kt,parseVLSPostProcess:()=>kt,parseVolumetricLightingRenderingPipeline:()=>Oi,particleSystemFromScene:()=>Ja,playSpriteAnimationFromName:()=>ka,preloadAssetsToDatabase:()=>Cs,putInIndexDB:()=>$,registerScriptAssetParser:()=>Na,resolveVolumetricDepthSource:()=>at,resolveVolumetricShadowSlot:()=>Vo,saveRenderingConfigurationForCamera:()=>Aa,sceneAsset:()=>Ya,scriptAssetsCache:()=>pe,scriptAssetsParsers:()=>We,scriptsDictionary:()=>U,selectVolumetricLights:()=>yi,serializeDefaultRenderingPipeline:()=>ri,serializeMotionBlurPostProcess:()=>ei,serializeSSAO2RenderingPipeline:()=>Yt,serializeSSRRenderingPipeline:()=>Wt,serializeTAARenderingPipeline:()=>jt,serializeVLSPostProcess:()=>Ht,serializeVolumetricLightingRenderingPipeline:()=>Ti,setDefaultRenderingPipelineRef:()=>Yn,setMotionBlurPostProcessRef:()=>Zn,setSSAO2RenderingPipelineRef:()=>Kn,setSSRRenderingPipelineRef:()=>Wn,setStaticDecalsEnabled:()=>zn,setTAARenderingPipelineRef:()=>$n,setUseKtx2CompressedTextures:()=>Ba,setVLSPostProcessRef:()=>kn,setVolumetricLightingRenderingPipelineConfiguration:()=>ze,setVolumetricLightingRenderingPipelineRef:()=>Ta,setupOfflineProvider:()=>bs,soundFromScene:()=>Qa,spriteFromSpriteManager:()=>ds,ssaoRenderingPipelineCameraConfigurations:()=>ve,ssrRenderingPipelineCameraConfigurations:()=>fe,supportsVolumetricFloatDepthTexture:()=>No,taaRenderingPipelineCameraConfigurations:()=>ge,visibleAsAsset:()=>ps,visibleAsBoolean:()=>es,visibleAsColor3:()=>ns,visibleAsColor4:()=>as,visibleAsEntity:()=>ss,visibleAsKeyMap:()=>cs,visibleAsNumber:()=>is,visibleAsString:()=>ts,visibleAsTexture:()=>ls,visibleAsVector2:()=>os,visibleAsVector3:()=>rs,vlsPostProcessCameraConfigurations:()=>ue,volumetricLightMetadataKey:()=>le,volumetricLightingPrePassConfigurationName:()=>Fo,volumetricTemporalSamplesDivider:()=>tt});module.exports=Mn(Ds);function ne(i){switch(i.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}a(ne,"isAbstractMesh");function F(i){switch(i.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}a(F,"isMesh");function Ie(i){return i.getClassName?.()==="InstancedMesh"}a(Ie,"isInstancedMesh");function Rn(i){return i.getClassName?.()==="Bone"}a(Rn,"isBone");function Vn(i){return i.getClassName?.()==="GroundMesh"}a(Vn,"isGroundMesh");function te(i){return i.getClassName?.()==="TransformNode"}a(te,"isTransformNode");function Me(i){return i?.getClassName?.()==="Texture"}a(Me,"isTexture");function Qe(i){switch(i.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}a(Qe,"isCamera");function Fn(i){switch(i.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}a(Fn,"isFreeCamera");function Nn(i){return i.getClassName?.()==="ArcRotateCamera"}a(Nn,"isArcRotateCamera");function wt(i){return i.getClassName?.()==="PointLight"}a(wt,"isPointLight");function ie(i){return i.getClassName?.()==="DirectionalLight"}a(ie,"isDirectionalLight");function ae(i){return i.getClassName?.()==="SpotLight"}a(ae,"isSpotLight");function Je(i){return i.getClassName?.()==="HemisphericLight"}a(Je,"isHemisphericLight");function oo(i){switch(i.getClassName?.()){case"Light":case"PointLight":case"SpotLight":case"DirectionalLight":case"HemisphericLight":return!0}return!1}a(oo,"isLight");function Tt(i){return i.getClassName?.()==="ShadowGenerator"}a(Tt,"isShadowGenerator");function Ot(i){return i.getClassName?.()==="CascadedShadowGenerator"}a(Ot,"isCascadedShadowGenerator");function me(i){return i.getClassName?.()==="ClusteredLightContainer"}a(me,"isClusteredLightContainer");function de(i){return ne(i)||te(i)||oo(i)||Qe(i)}a(de,"isNode");function Et(i){return i.getClassName?.()==="Scene"}a(Et,"isScene");function At(i){return i.getClassName?.()==="ParticleSystem"}a(At,"isParticleSystem");function Gn(i){return i.getClassName?.()==="GPUParticleSystem"}a(Gn,"isGPUParticleSystem");function It(i){switch(i.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}a(It,"isAnyParticleSystem");function Bn(i){return i.getClassName?.()==="SpriteManagerNode"}a(Bn,"isSpriteManagerNode");function Mt(i){return i.getClassName?.()==="Sprite"}a(Mt,"isSprite");function se(i){return i.getClassName?.()==="SoundNode"}a(se,"isSoundNode");function Rt(i){return i.getClassName?.()==="GaussianSplattingMesh"}a(Rt,"isGaussianSplattingMesh");function Vt(i){let e=i;for(;e;){if(e.metadata?.isStaticGroup)return!0;e=e.parent}return!1}a(Vt,"isNodeFromStaticGroup");function Ft(i){i.meshes.forEach(e=>{F(e)&&e.getLODLevels().forEach(t=>{t.mesh&&(t.mesh.originalDistanceOrScreenCoverage=t.distanceOrScreenCoverage)})})}a(Ft,"configureMeshDistanceOrScreenCoverage");function Nt(i,e){e.meshes.forEach(t=>{F(t)&&t.getLODLevels().forEach(o=>{if(o.mesh?.originalDistanceOrScreenCoverage)switch(i){case"very-low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.125;break;case"low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.25;break;case"medium":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.5;break;case"high":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage;break}})})}a(Nt,"applyMeshesLODQuality");function ro(i){return(i.metadata?.decal??null)!==null}a(ro,"isDecalMesh");function zn(i,e){e.meshes.forEach(t=>{ro(t)&&Vt(t)&&t.setEnabled(i)})}a(zn,"setStaticDecalsEnabled");function N(i){let e=1;for(;e<=i;)e<<=1;return e>>1}a(N,"getPowerOfTwoUntil");var no=require("babylonjs"),ao=require("babylonjs");function Gt(i){i.lights.forEach(e=>{let t=e.getShadowGenerator()?.getShadowMap();t&&(t.renderListPredicate=o=>Rt(o)?!1:no.Vector3.Distance(o.getAbsolutePosition(),e.getAbsolutePosition())<=e.range)})}a(Gt,"configureShadowMapRenderListPredicate");async function et(i){i.executeWhenReady(()=>{i.lights.forEach(e=>{let t=e.getShadowGenerator()?.getShadowMap();t&&(t.refreshRate=e.metadata?.refreshRate??ao.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}a(et,"configureShadowMapRefreshRate");function Hn(i,e){e.lights.forEach(t=>{let o=t.getShadowGenerator(),r=o?.getShadowMap();if(o?.originalMapSize){let n=o.originalMapSize;switch(i){case"medium":n=n*.5;break;case"low":n=n*.25;break;case"very-low":n=n*.125;break}n=Math.max(128,N(n)),r?.getSize().width!==n&&r.resize(n)}}),et(e)}a(Hn,"applyShadowsQuality");var so=require("babylonjs"),lo=require("babylonjs"),co=require("babylonjs"),w=null,ue=new Map;function Bt(){return w}a(Bt,"getVLSPostProcess");function kn(i){w=i}a(kn,"setVLSPostProcessRef");function zt(i){w&&i.activeCamera&&(w.dispose(i.activeCamera),w=null)}a(zt,"disposeVLSPostProcess");function po(i,e,t){return e??=i.meshes.find(o=>F(o)),w=new co.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,i.activeCamera,e,100,lo.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),w.samples=t?.msaaSamples??1,w}a(po,"createVLSPostProcess");function Ht(){return w?{meshId:w.mesh?.id,exposure:w.exposure,decay:w.decay,weight:w.weight,density:w.density,invert:w.invert,useCustomMeshPosition:w.useCustomMeshPosition,customMeshPosition:w.customMeshPosition.asArray()}:null}a(Ht,"serializeVLSPostProcess");function kt(i,e,t){let o=null;if(e.meshId){let n=i.getMeshById(e.meshId);n&&F(n)&&(o=n)}let r=w??po(i,o,t);return r.samples=t?.msaaSamples??1,r.exposure=e.exposure,r.decay=e.decay,r.weight=e.weight,r.density=e.density,r.invert=e.invert,r.useCustomMeshPosition=e.useCustomMeshPosition,r.customMeshPosition.copyFrom(so.Vector3.FromArray(e.customMeshPosition)),r}a(kt,"parseVLSPostProcess");var ho=require("babylonjs"),D=null,fe=new Map;function Un(){return D}a(Un,"getSSRRenderingPipeline");function Wn(i){D=i}a(Wn,"setSSRRenderingPipelineRef");function Ut(){D&&(D.dispose(),D=null)}a(Ut,"disposeSSRRenderingPipeline");function mo(i,e,t){return D=new ho.SSRRenderingPipeline("SSRRenderingPipeline",i,[e],void 0,K(i.getEngine())),D.samples=t?.msaaSamples??1,D}a(mo,"createSSRRenderingPipeline");function Wt(){return D?{samples:D.samples,step:D.step,thickness:D.thickness,strength:D.strength,reflectionSpecularFalloffExponent:D.reflectionSpecularFalloffExponent,maxSteps:D.maxSteps,maxDistance:D.maxDistance,roughnessFactor:D.roughnessFactor,reflectivityThreshold:D.reflectivityThreshold,blurDispersionStrehgth:D.blurDispersionStrength,clipToFrustum:D.clipToFrustum,enableSmoothReflections:D.enableSmoothReflections,enableAutomaticThicknessComputation:D.enableAutomaticThicknessComputation,attenuateFacingCamera:D.attenuateFacingCamera,attenuateScreenBorders:D.attenuateScreenBorders,attenuateIntersectionDistance:D.attenuateIntersectionDistance,attenuateBackfaceReflection:D.attenuateBackfaceReflection,blurDownsample:D.blurDownsample,selfCollisionNumSkip:D.selfCollisionNumSkip,ssrDownsample:D.ssrDownsample,backfaceDepthTextureDownsample:D.backfaceDepthTextureDownsample}:null}a(Wt,"serializeSSRRenderingPipeline");function Xt(i,e,t,o){let r=D??mo(i,e,o);return r.samples=o?.msaaSamples??1,r.step=t.step,r.thickness=t.thickness,r.strength=t.strength,r.reflectionSpecularFalloffExponent=t.reflectionSpecularFalloffExponent,r.maxSteps=t.maxSteps,r.maxDistance=t.maxDistance,r.roughnessFactor=t.roughnessFactor,r.reflectivityThreshold=t.reflectivityThreshold,r.blurDispersionStrength=t.blurDispersionStrehgth,r.clipToFrustum=t.clipToFrustum,r.enableSmoothReflections=t.enableSmoothReflections,r.enableAutomaticThicknessComputation=t.enableAutomaticThicknessComputation,r.attenuateFacingCamera=t.attenuateFacingCamera,r.attenuateScreenBorders=t.attenuateScreenBorders,r.attenuateIntersectionDistance=t.attenuateIntersectionDistance,r.attenuateBackfaceReflection=t.attenuateBackfaceReflection,r.blurDownsample=t.blurDownsample,r.selfCollisionNumSkip=t.selfCollisionNumSkip,r.ssrDownsample=t.ssrDownsample,r.backfaceDepthTextureDownsample=t.backfaceDepthTextureDownsample,r}a(Xt,"parseSSRRenderingPipeline");var uo=require("babylonjs"),A=null,ge=new Map;function Xn(){return A}a(Xn,"getTAARenderingPipeline");function $n(i){A=i}a($n,"setTAARenderingPipelineRef");function $t(){A&&(A.dispose(),A=null)}a($t,"disposeTAARenderingPipeline");function fo(i,e,t){return A=new uo.TAARenderingPipeline("TAARenderingPipeline",i,[e],K(i.getEngine())),A.msaaSamples=t?.msaaSamples??1,A}a(fo,"createTAARenderingPipeline");function jt(){return A?{factor:A.factor,samples:A.samples,clampHistory:A.clampHistory,reprojectHistory:A.reprojectHistory,disableOnCameraMove:A.disableOnCameraMove}:null}a(jt,"serializeTAARenderingPipeline");function Kt(i,e,t,o){let r=A??fo(i,e,o);return r.msaaSamples=o?.msaaSamples??1,r.factor=t.factor,r.clampHistory=t.clampHistory,r.reprojectHistory=t.reprojectHistory,r.disableOnCameraMove=t.disableOnCameraMove,r}a(Kt,"parseTAARenderingPipeline");var go=require("babylonjs"),P=null,ve=new Map;function jn(){return P}a(jn,"getSSAO2RenderingPipeline");function Kn(i){P=i}a(Kn,"setSSAO2RenderingPipelineRef");function Zt(){P&&(P.dispose(),P=null)}a(Zt,"disposeSSAO2RenderingPipeline");function vo(i,e,t){return P=new go.SSAO2RenderingPipeline("SSAO2RenderingPipeline",i,1,[e],!1,K(i.getEngine())),P.textureSamples=1,P}a(vo,"createSSAO2RenderingPipeline");function Yt(){return P?{radius:P.radius,totalStrength:P.totalStrength,samples:P.samples,maxZ:P.maxZ,minZAspect:P.minZAspect,epsilon:P.epsilon,textureSamples:P.textureSamples,bypassBlur:P.bypassBlur,bilateralSamples:P.bilateralSamples,bilateralSoften:P.bilateralSoften,bilateralTolerance:P.bilateralTolerance,expensiveBlur:P.expensiveBlur}:null}a(Yt,"serializeSSAO2RenderingPipeline");function qt(i,e,t,o){let r=P??vo(i,e,o);return r.textureSamples=1,r.radius=t.radius,r.totalStrength=t.totalStrength,r.samples=t.samples,r.maxZ=t.maxZ,r.minZAspect=t.minZAspect,r.epsilon=t.epsilon,r.bypassBlur=t.bypassBlur,r.bilateralSamples=t.bilateralSamples,r.bilateralSoften=t.bilateralSoften,r.bilateralTolerance=t.bilateralTolerance,r.expensiveBlur=t.expensiveBlur,r}a(qt,"parseSSAO2RenderingPipeline");var So=require("babylonjs"),I=null,Se=new Map;function Qt(){return I}a(Qt,"getMotionBlurPostProcess");function Zn(i){I=i}a(Zn,"setMotionBlurPostProcessRef");function Jt(){I&&(I.dispose(),I=null)}a(Jt,"disposeMotionBlurPostProcess");function yo(i,e,t){return I=new So.MotionBlurPostProcess("MotionBlurPostProcess",i,1,e,void 0,void 0,void 0,K(i.getEngine())),I.samples=t?.msaaSamples??1,I.motionStrength=1,I.isObjectBased=!0,I}a(yo,"createMotionBlurPostProcess");function ei(){return I?{isObjectBased:I.isObjectBased,motionStrength:I.motionStrength,motionBlurSamples:I.motionBlurSamples}:null}a(ei,"serializeMotionBlurPostProcess");function ti(i,e,t,o){let r=I??yo(i,e,o);return r.samples=o?.msaaSamples??1,r.isObjectBased=t.isObjectBased,r.motionStrength=t.motionStrength,r.motionBlurSamples=t.motionBlurSamples,r}a(ti,"parseMotionBlurPostProcess");var bo=require("babylonjs"),ii=require("babylonjs"),xo=require("babylonjs"),_o=require("babylonjs"),Co=require("babylonjs"),f=null,ye=new Map;function Re(){return f}a(Re,"getDefaultRenderingPipeline");function Yn(i){f=i}a(Yn,"setDefaultRenderingPipelineRef");function oi(){f&&(f.dispose(),f=null)}a(oi,"disposeDefaultRenderingPipeline");function Do(i,e,t){return f=new Co.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,i,[e]),f.samples=t?.msaaSamples??1,f.depthOfField.lensSize=512,f.depthOfField.fStop=.25,f.depthOfField.focusDistance=55e3,f}a(Do,"createDefaultRenderingPipeline");function ri(){return f?{samples:f.samples,fxaaEnabled:f.fxaaEnabled,imageProcessingEnabled:f.imageProcessingEnabled,exposure:f.imageProcessing?.exposure,contrast:f.imageProcessing?.contrast,fromLinearSpace:f.imageProcessing?.fromLinearSpace,toneMappingEnabled:f.imageProcessing?.toneMappingEnabled,toneMappingType:f.imageProcessing?.toneMappingType,ditheringEnabled:f.imageProcessing?.ditheringEnabled,ditheringIntensity:f.imageProcessing?.ditheringIntensity,bloomEnabled:f.bloomEnabled,bloomThreshold:f.bloomThreshold,bloomWeight:f.bloomWeight,bloomScale:f.bloomScale,bloomKernel:f.bloomKernel,sharpenEnabled:f.sharpenEnabled,sharpenEdgeAmount:f.sharpen.edgeAmount,sharpenColorAmount:f.sharpen.colorAmount,grainEnabled:f.grainEnabled,grainIntensity:f.grain.intensity,grainAnimated:f.grain.animated,depthOfFieldEnabled:f.depthOfFieldEnabled,depthOfFieldBlurLevel:f.depthOfFieldBlurLevel,lensSize:f.depthOfField.lensSize,fStop:f.depthOfField.fStop,focusDistance:f.depthOfField.focusDistance,focalLength:f.depthOfField.focalLength,vignetteEnabled:f.imageProcessing?.vignetteEnabled,vignetteColor:f.imageProcessing?.vignetteColor.asArray(),vignetteWeight:f.imageProcessing?.vignetteWeight,chromaticAberrationEnabled:f.chromaticAberrationEnabled,aberrationAmount:f.chromaticAberration.aberrationAmount,radialIntensity:f.chromaticAberration.radialIntensity,direction:f.chromaticAberration.direction.asArray(),centerPosition:f.chromaticAberration.centerPosition.asArray(),glowLayerEnabled:f.glowLayerEnabled,glowLayerIntensity:f.glowLayer?.intensity,glowLayerBlurKernelSize:f.glowLayer?.blurKernelSize,colorGradingEnabled:f.imageProcessing.colorGradingEnabled,colorGradingTexture:f.imageProcessing.colorGradingTexture?.serialize(),colorGradingWithGreenDepth:f.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth,colorCurvesEnabled:f.imageProcessing.colorCurvesEnabled,globalHue:f.imageProcessing.colorCurves?.globalHue,globalDensity:f.imageProcessing.colorCurves?.globalDensity,globalExposure:f.imageProcessing.colorCurves?.globalExposure,globalSaturation:f.imageProcessing.colorCurves?.globalSaturation,highlightsHue:f.imageProcessing.colorCurves?.highlightsHue,highlightsDensity:f.imageProcessing.colorCurves?.highlightsDensity,highlightsExposure:f.imageProcessing.colorCurves?.highlightsExposure,highlightsSaturation:f.imageProcessing.colorCurves?.highlightsSaturation,midtonesHue:f.imageProcessing.colorCurves?.midtonesHue,midtonesDensity:f.imageProcessing.colorCurves?.midtonesDensity,midtonesExposure:f.imageProcessing.colorCurves?.midtonesExposure,midtonesSaturation:f.imageProcessing.colorCurves?.midtonesSaturation,shadowsHue:f.imageProcessing.colorCurves?.shadowsHue,shadowsDensity:f.imageProcessing.colorCurves?.shadowsDensity,shadowsExposure:f.imageProcessing.colorCurves?.shadowsExposure,shadowsSaturation:f.imageProcessing.colorCurves?.shadowsSaturation}:null}a(ri,"serializeDefaultRenderingPipeline");function ni(i,e,t,o,r){let n=f??Do(i,e,r);if(n.samples=r?.msaaSamples??1,n.fxaaEnabled=t.fxaaEnabled,n.imageProcessingEnabled=t.imageProcessingEnabled,n.imageProcessing){if(n.imageProcessing.exposure=t.exposure,n.imageProcessing.contrast=t.contrast,n.imageProcessing.fromLinearSpace=t.fromLinearSpace,n.imageProcessing.toneMappingEnabled=t.toneMappingEnabled,n.imageProcessing.toneMappingType=t.toneMappingType,n.imageProcessing.ditheringEnabled=t.ditheringEnabled,n.imageProcessing.ditheringIntensity=t.ditheringIntensity,n.imageProcessing.vignetteEnabled=t.vignetteEnabled??!1,n.imageProcessing.vignetteColor=bo.Color4.FromArray(t.vignetteColor??[0,0,0]),n.imageProcessing.vignetteWeight=t.vignetteWeight??.3,n.imageProcessing.colorGradingEnabled=t.colorGradingEnabled??!1,n.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth=t.colorGradingWithGreenDepth??!0,t.colorGradingTexture){let l=null;if(t.colorGradingTexture.customType==="BABYLON.ColorGradingTexture"){let p=o+t.colorGradingTexture.name;l=new _o.ColorGradingTexture(p,i),l.level=t.colorGradingTexture.level}else{let p=xo.Texture.Parse(t.colorGradingTexture,i,o);Me(p)&&(l=p)}n.imageProcessing.colorGradingTexture=l}n.imageProcessing.colorCurvesEnabled=t.colorCurvesEnabled??!1,n.imageProcessing.colorCurves&&(n.imageProcessing.colorCurves.globalHue=t.globalHue??30,n.imageProcessing.colorCurves.globalDensity=t.globalDensity??0,n.imageProcessing.colorCurves.globalExposure=t.globalExposure??0,n.imageProcessing.colorCurves.globalSaturation=t.globalSaturation??0,n.imageProcessing.colorCurves.highlightsHue=t.highlightsHue??30,n.imageProcessing.colorCurves.highlightsDensity=t.highlightsDensity??0,n.imageProcessing.colorCurves.highlightsExposure=t.highlightsExposure??0,n.imageProcessing.colorCurves.highlightsSaturation=t.highlightsSaturation??0,n.imageProcessing.colorCurves.midtonesHue=t.midtonesHue??30,n.imageProcessing.colorCurves.midtonesDensity=t.midtonesDensity??0,n.imageProcessing.colorCurves.midtonesExposure=t.midtonesExposure??0,n.imageProcessing.colorCurves.midtonesSaturation=t.midtonesSaturation??0,n.imageProcessing.colorCurves.shadowsHue=t.shadowsHue??30,n.imageProcessing.colorCurves.shadowsDensity=t.shadowsDensity??0,n.imageProcessing.colorCurves.shadowsExposure=t.shadowsExposure??0,n.imageProcessing.colorCurves.shadowsSaturation=t.shadowsSaturation??0)}return n.bloomEnabled=t.bloomEnabled,n.bloomThreshold=t.bloomThreshold,n.bloomWeight=t.bloomWeight,n.bloomScale=t.bloomScale,n.bloomKernel=t.bloomKernel,n.sharpenEnabled=t.sharpenEnabled,n.sharpen.edgeAmount=t.sharpenEdgeAmount,n.sharpen.colorAmount=t.sharpenColorAmount,n.grainEnabled=t.grainEnabled,n.grain.intensity=t.grainIntensity,n.grain.animated=t.grainAnimated,n.depthOfFieldEnabled=t.depthOfFieldEnabled,n.depthOfFieldBlurLevel=t.depthOfFieldBlurLevel,n.depthOfField.lensSize=t.lensSize,n.depthOfField.fStop=t.fStop,n.depthOfField.focusDistance=t.focusDistance,n.depthOfField.focalLength=t.focalLength,n.chromaticAberrationEnabled=t.chromaticAberrationEnabled??!1,n.chromaticAberration.aberrationAmount=t.aberrationAmount??10,n.chromaticAberration.radialIntensity=t.radialIntensity??1,n.chromaticAberration.direction=ii.Vector2.FromArray(t.direction??[0,0]),n.chromaticAberration.centerPosition=ii.Vector2.FromArray(t.centerPosition??[0,0]),n.glowLayerEnabled=t.glowLayerEnabled??!1,n.glowLayer&&(n.glowLayer.intensity=t.glowLayerIntensity??1,n.glowLayer.blurKernelSize=t.glowLayerBlurKernelSize??32),n}a(ni,"parseDefaultRenderingPipeline");var le="volumetricLighting",O=8,Z=256,ci=4,tt=3,Lo=(t=>(t[t.Linear=0]="Linear",t[t.Exponential=1]="Exponential",t))(Lo||{}),pi=(o=>(o[o.None=0]="None",o[o.Bayer=1]="Bayer",o[o.InterleavedGradientNoise=2]="InterleavedGradientNoise",o))(pi||{}),hi=(o=>(o[o.Exponential=0]="Exponential",o[o.ExponentialSquared=1]="ExponentialSquared",o[o.Linear=2]="Linear",o))(hi||{}),mi=(r=>(r[r.None=0]="None",r[r.Scattering=1]="Scattering",r[r.Transmittance=2]="Transmittance",r[r.LightCount=3]="LightCount",r))(mi||{});function li(){return{enabled:!1,volumeIntensity:1,anisotropy:.35,useCustomColor:!1,color:[1,1,1],castVolumetricShadows:!1,shadowDarkness:1,rangeMultiplier:1,priority:0}}a(li,"getDefaultVolumetricLightConfiguration");function it(){return{steps:40,lightSteps:0,resolutionScale:.5,stepDistribution:1,ditherMode:2,ditherStrength:1,temporalJitter:!1,temporalAccumulation:!1,temporalAccumulationFactor:.1,fogMode:0,fogDensity:5e-4,fogStart:0,fogEnd:2e3,fogColor:[1,1,1],albedo:1,maxDistance:1e4,heightFogEnabled:!1,heightFogBaseHeight:0,heightFogFalloff:.01,intensity:1.5,lightExtinctionEnabled:!0,lightExtinctionClamp:1e3,extinctionAmount:0,ambientColor:[1,1,1],ambientIntensity:0,screenSpaceShadows:!0,screenSpaceShadowSteps:6,screenSpaceShadowBias:.02,screenSpaceShadowMaxDistance:2e3,screenSpaceShadowThickness:4,blurPasses:2,blurRadius:3,blurDepthThreshold:.02,upsampleDepthThreshold:.02,maxLights:128,maxShadowedLights:4,pcfTaps:4,selectionRefreshRate:2,debugMode:0}}a(it,"getDefaultVolumetricLightingConfiguration");function Po(i){return i.lightSteps>0?i.lightSteps:Math.max(4,Math.min(64,Math.round(i.steps*.3)))}a(Po,"getVolumetricLightSteps");function di(i,e=tt){let t=Po(i);return!i.temporalAccumulation||e<=1?{steps:i.steps,lightSteps:t}:{steps:Math.max(4,Math.ceil(i.steps/e)),lightSteps:Math.max(2,Math.ceil(t/e))}}a(di,"getVolumetricSamplingSteps");function b(i,e,t,o){let r=typeof i=="number"&&isFinite(i)?i:e;return Math.min(o,Math.max(t,r))}a(b,"normalizeNumber");function ai(i,e){return!Array.isArray(i)||i.length<3?e.slice():[b(i[0],e[0],0,100),b(i[1],e[1],0,100),b(i[2],e[2],0,100)]}a(ai,"normalizeColor");function wo(i){let e=li();return!i||typeof i!="object"?e:{enabled:i.enabled??e.enabled,volumeIntensity:b(i.volumeIntensity,e.volumeIntensity,0,1e3),anisotropy:b(i.anisotropy,e.anisotropy,-.95,.95),useCustomColor:i.useCustomColor??e.useCustomColor,color:ai(i.color,e.color),castVolumetricShadows:i.castVolumetricShadows??e.castVolumetricShadows,shadowDarkness:b(i.shadowDarkness,e.shadowDarkness,0,1),rangeMultiplier:b(i.rangeMultiplier,e.rangeMultiplier,0,100),priority:b(i.priority,e.priority,-1e3,1e3)}}a(wo,"normalizeVolumetricLightConfiguration");function be(i){let e=it();return!i||typeof i!="object"?e:{steps:Math.round(b(i.steps,e.steps,4,256)),lightSteps:Math.round(b(i.lightSteps,e.lightSteps,0,128)),resolutionScale:b(i.resolutionScale,e.resolutionScale,.1,1),stepDistribution:Math.round(b(i.stepDistribution,e.stepDistribution,0,1)),ditherMode:Math.round(b(i.ditherMode,e.ditherMode,0,2)),ditherStrength:b(i.ditherStrength,e.ditherStrength,0,1),temporalJitter:i.temporalJitter??e.temporalJitter,temporalAccumulation:i.temporalAccumulation??e.temporalAccumulation,temporalAccumulationFactor:b(i.temporalAccumulationFactor,e.temporalAccumulationFactor,.005,1),fogMode:Math.round(b(i.fogMode,e.fogMode,0,2)),fogDensity:b(i.fogDensity,e.fogDensity,0,100),fogStart:b(i.fogStart,e.fogStart,0,1e6),fogEnd:Math.max(b(i.fogEnd,e.fogEnd,0,1e7),b(i.fogStart,e.fogStart,0,1e6)+.001),fogColor:ai(i.fogColor,e.fogColor),albedo:b(i.albedo,e.albedo,0,1),maxDistance:b(i.maxDistance,e.maxDistance,1,1e6),heightFogEnabled:i.heightFogEnabled??e.heightFogEnabled,heightFogBaseHeight:b(i.heightFogBaseHeight,e.heightFogBaseHeight,-1e6,1e6),heightFogFalloff:b(i.heightFogFalloff,e.heightFogFalloff,0,10),intensity:b(i.intensity,e.intensity,0,100),lightExtinctionEnabled:i.lightExtinctionEnabled??e.lightExtinctionEnabled,lightExtinctionClamp:b(i.lightExtinctionClamp,e.lightExtinctionClamp,0,1e6),extinctionAmount:b(i.extinctionAmount,e.extinctionAmount,0,1),ambientColor:ai(i.ambientColor,e.ambientColor),ambientIntensity:b(i.ambientIntensity,e.ambientIntensity,0,100),screenSpaceShadows:i.screenSpaceShadows??e.screenSpaceShadows,screenSpaceShadowSteps:Math.round(b(i.screenSpaceShadowSteps,e.screenSpaceShadowSteps,1,32)),screenSpaceShadowBias:b(i.screenSpaceShadowBias,e.screenSpaceShadowBias,0,1),screenSpaceShadowMaxDistance:b(i.screenSpaceShadowMaxDistance,e.screenSpaceShadowMaxDistance,1,1e7),screenSpaceShadowThickness:b(i.screenSpaceShadowThickness,e.screenSpaceShadowThickness,.01,1e3),blurPasses:Math.round(b(i.blurPasses,e.blurPasses,0,2)),blurRadius:Math.round(b(i.blurRadius,e.blurRadius,1,6)),blurDepthThreshold:b(i.blurDepthThreshold,e.blurDepthThreshold,1e-4,1),upsampleDepthThreshold:b(i.upsampleDepthThreshold,e.upsampleDepthThreshold,1e-4,1),maxLights:Math.round(b(i.maxLights,e.maxLights,0,Z)),maxShadowedLights:Math.round(b(i.maxShadowedLights,e.maxShadowedLights,0,O)),pcfTaps:b(i.pcfTaps,e.pcfTaps,1,4)>=4?4:1,selectionRefreshRate:Math.round(b(i.selectionRefreshRate,e.selectionRefreshRate,1,60)),debugMode:Math.round(b(i.debugMode,e.debugMode,0,3))}}a(be,"normalizeVolumetricLightingConfiguration");var si=new WeakSet;function To(i){i.metadata??={};let e=i.metadata[le];if(!e||typeof e!="object")return i.metadata[le]=wo(null),si.add(i.metadata[le]),i.metadata[le];if(si.has(e))return e;let t=li();return Object.keys(t).forEach(o=>{e[o]===void 0&&(e[o]=t[o])}),si.add(e),e}a(To,"ensureVolumetricLightConfiguration");function ui(i){let e=i.metadata?.[le];return e&&typeof e=="object"?To(i):null}a(ui,"getVolumetricLightConfiguration");function qn(i){return i.metadata?.[le]?.enabled===!0}a(qn,"isVolumetricLightEnabled");var ot=require("babylonjs"),Io=require("babylonjs"),gi=require("babylonjs"),Y=require("babylonjs"),vi=(o=>(o[o.Texture2D=0]="Texture2D",o[o.Sampler2DShadow=1]="Sampler2DShadow",o[o.Cube=2]="Cube",o))(vi||{}),Mo=(o=>(o[o.Standard=0]="Standard",o[o.Esm=1]="Esm",o[o.CloseEsm=2]="CloseEsm",o))(Mo||{}),Si=(o=>(o[o.Analytic=0]="Analytic",o[o.AnalyticHeight=1]="AnalyticHeight",o[o.Numeric=2]="Numeric",o))(Si||{}),Oo=10,Qn=4,Jn=22,ea=32,ta=.15;function Ve(i,e){let t=i.getCaps(),o=t.maxFragmentUniformVectors||224,r=i.isWebGPU?Math.floor(o/4):o,n=Math.max(224,r)-ea,l=Math.max(8,t.maxTexturesImageUnits||16)-1,p=l>=2,s=p?Jn:0,c=Math.max(0,Math.min(O,e.maxShadowedLights,l-(p?1:0),Math.floor((n-s)/Oo))),h=Math.max(0,Math.min(Z,e.maxLights,Math.floor((n-s-c*Oo)/Qn)));return{maxShadowSlots:c,maxArrayLights:h,maxDirectionalLights:Math.min(ci,h),allowCsm:p}}a(Ve,"computeVolumetricBudget");function Ro(i){let e=[];return i.lights.forEach(t=>{me(t)?t.lights.forEach(o=>{e.push({light:o,isClustered:!0})}):e.push({light:t,isClustered:!1})}),e}a(Ro,"getAllVolumetricCandidateLights");function Vo(i,e){let t=i.getShadowGenerator(e.activeCamera)??i.getShadowGenerator();if(!t||!Tt(t))return null;let o=t.getShadowMapForRendering();if(!o?.isReady())return null;let r=t.getShadowMap()?.getSize().width??1024,n=o.textureType===gi.Constants.TEXTURETYPE_UNSIGNED_BYTE,l=!ie(i),p=i.needCube?.()===!0;switch(t.filter){case Y.ShadowGenerator.FILTER_PCF:case Y.ShadowGenerator.FILTER_PCSS:return{generator:t,kind:p?2:1,mode:0,packed:n,mapSize:r,local:l};case Y.ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP:case Y.ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP:return{generator:t,kind:p?2:0,mode:1,packed:n,mapSize:r,local:l};case Y.ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP:case Y.ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:return{generator:t,kind:p?2:0,mode:2,packed:n,mapSize:r,local:l};default:return{generator:t,kind:p?2:0,mode:0,packed:n,mapSize:r,local:l}}}a(Vo,"resolveVolumetricShadowSlot");function rt(i,e){let t=i;return t.computeTransformedInformation?.()&&t.transformedPosition?e.copyFrom(t.transformedPosition):t.position?e.copyFrom(t.position):e.copyFromFloats(0,0,0),e}a(rt,"getVolumetricLightWorldPosition");function Fe(i,e){let t=i;return t.computeTransformedInformation?.()&&t.transformedDirection?e.copyFrom(t.transformedDirection):t.direction?e.copyFrom(t.direction):e.copyFromFloats(0,0,1),e.normalize()}a(Fe,"getVolumetricLightWorldDirection");function nt(i,e,t){let o=i.range>0&&i.range<Number.MAX_VALUE?i.range:t.maxDistance;return Math.max(.001,Math.min(o*e.rangeMultiplier,34e37))}a(nt,"getVolumetricLightRange");var fi=new ot.Vector3,Eo=new ot.Vector3;function ia(i,e,t){if(rt(i,t),!ae(i))return e;let o=Math.cos(i.angle*.5);if(o<=.5)return e;let r=e/(2*o);return Fe(i,Eo),t.addInPlace(Eo.scaleInPlace(r)),r}a(ia,"computeVolumetricLightBounds");function oa(i,e,t){for(let o=0;o<t.length;++o)if(t[o].dotCoordinate(i)<=-e)return!1;return!0}a(oa,"isSphereInFrustum");function Ao(i){return(i.local?64:0)+i.kind*16+i.mode*4+(i.packed?1:0)}a(Ao,"getShadowSlotSignature");function yi(i,e,t,o,r){let n={candidateCount:0,culledCount:0,shadowedCount:0,unshadowedCount:0,droppedCount:0,perLight:new Map},l=Io.Frustum.GetPlanes(i.getTransformMatrix()),p=e.globalPosition,s=[];Ro(i).forEach(({light:v,isClustered:_})=>{let V=ui(v);if(!V?.enabled)return;if(n.candidateCount++,Je(v)||!v.isEnabled()||v.intensity<=0||V.volumeIntensity<=0){n.perLight.set(v.uniqueId,{state:"disabled",slot:-1,reason:Je(v)?"Hemispheric lights have no position nor direction and can't produce light shafts.":"The light is disabled or its intensity is zero."});return}let j=ie(v),he=V.priority*1e3;if(j)he+=1e6;else{let Ye=Math.min(nt(v,V,t),t.maxDistance),Pt=ia(v,Ye,fi);if(!oa(fi,Pt,l)){n.culledCount++,n.perLight.set(v.uniqueId,{state:"culled",slot:-1,reason:"The light is outside of the frustum of the camera and doesn't reach it."});return}let wn=Math.max(1,ot.Vector3.Distance(fi,p)-Pt);he+=V.volumeIntensity*v.intensity*Math.min(4,Pt/wn)}s.push({light:v,config:V,isClustered:_,typeId:v.getTypeID(),score:he})}),s.sort((v,_)=>_.score-v.score);let c=new Map;r?.shadowed.forEach((v,_)=>{c.set(v.candidate.light.uniqueId,_)});let h=[],m=[],d=new Map,u=null;s.forEach(v=>{let{light:_,config:V}=v;if(!V.castVolumetricShadows){d.set(_.uniqueId,"occlusion is disabled on this light."),m.push(v);return}if(v.isClustered){d.set(_.uniqueId,"clustered lighting doesn't support shadow maps."),m.push(v);return}if(!_.shadowEnabled||!i.shadowsEnabled){d.set(_.uniqueId,"shadows are disabled on this light or on the scene."),m.push(v);return}let j=_.getShadowGenerator(i.activeCamera)??_.getShadowGenerator();if(!j){d.set(_.uniqueId,"the light has no shadow generator."),m.push(v);return}if(Ot(j)&&o.allowCsm){let Ye=j.getShadowMapForRendering();if(!u&&Ye?.isReady()){u={candidate:v,generator:j,cascades:j.numCascades,kind:j.filter===Y.ShadowGenerator.FILTER_PCF||j.filter===Y.ShadowGenerator.FILTER_PCSS?1:0,packed:Ye.textureType===gi.Constants.TEXTURETYPE_UNSIGNED_BYTE};return}d.set(_.uniqueId,u?"another light already uses the single cascaded shadow map slot.":"its cascaded shadow map is not ready yet."),m.push(v);return}let he=Vo(_,i);if(!he){d.set(_.uniqueId,"the shadow map of the light is not ready yet."),m.push(v);return}h.push({candidate:v,shadow:he})});function S(v){let _=v.candidate.score;return c.get(v.candidate.light.uniqueId)===void 0?_:_+Math.abs(_)*ta}a(S,"getHysteresisScore");function g(v){return c.get(v.candidate.light.uniqueId)??Number.MAX_SAFE_INTEGER}a(g,"getPreviousSlot"),h.sort((v,_)=>{let V=S(_)-S(v);return V!==0?V:g(v)-g(_)});let y=h.slice(0,o.maxShadowSlots);y.sort((v,_)=>Ao(v.shadow)-Ao(_.shadow)||g(v)-g(_)),h.slice(o.maxShadowSlots).forEach(v=>{d.set(v.candidate.light.uniqueId,"the shadowed lights budget is full."),m.push(v.candidate)}),m.sort((v,_)=>_.score-v.score);let C=[],L=[],x=[];m.forEach(v=>{ie(v.light)?C.length<o.maxDirectionalLights?C.push(v):x.push({candidate:v,reason:`Not rendered: at most ${o.maxDirectionalLights} directional light(s) without a shadow map can take part in the effect.`}):L.push(v)});let R=Math.max(0,o.maxArrayLights-C.length);L.slice(R).forEach(v=>{x.push({candidate:v,reason:'Not rendered: the lights budget is full. Raise "Max Lights" or lower the priority of the other lights.'})});let B=C.concat(L.slice(0,R));if(y.forEach((v,_)=>{n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:_,reason:`Casting volumetric shadows using slot ${_+1} of ${o.maxShadowSlots}.`})}),u){let v=u;n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:-1,reason:`Casting volumetric shadows using its ${v.cascades} shadow cascades.`})}return B.forEach(v=>{n.unshadowedCount++;let _=v.config.castVolumetricShadows?"Occluded using the depth buffer":"Not occluded by the geometry",V=d.get(v.light.uniqueId)??"the light has no shadow map.";n.perLight.set(v.light.uniqueId,{state:"unshadowed",slot:-1,reason:`${_}: ${V}`})}),x.forEach(({candidate:v,reason:_})=>{n.droppedCount++,n.perLight.set(v.light.uniqueId,{state:"dropped",slot:-1,reason:_})}),{shadowed:y,unshadowed:B,directionalCount:C.length,csm:u,stats:n}}a(yi,"selectVolumetricLights");function ra(i,e,t){let o=i.shadowed.map(n=>`${n.shadow.kind}.${n.shadow.mode}.${n.shadow.packed?1:0}.${n.shadow.local?1:0}`).join("|"),r=i.csm?`${i.csm.kind}.${i.csm.cascades}.${i.csm.packed?1:0}`:"-";return[t.steps,t.lightSteps,e.stepDistribution,e.ditherMode,e.temporalJitter?1:0,e.temporalAccumulation?1:0,e.heightFogEnabled?1:0,e.lightExtinctionEnabled?1:0,e.pcfTaps,e.blurRadius,e.debugMode,e.screenSpaceShadows?e.screenSpaceShadowSteps:0,t.fogMode,t.transmittance,t.depthMode,t.ldrEncode?1:0,t.reverseDepth?1:0,t.ndcHalfZ?1:0,t.linearDepthPacked?1:0,t.arrayLightCapacity,i.directionalCount,o,r].join(",")}a(ra,"computeVolumetricShapeKey");function na(i){return wt(i)||ae(i)||ie(i)}a(na,"isVolumetricLightSupported");var bi=require("babylonjs"),aa=0,xi=(o=>(o[o.DepthRenderer=0]="DepthRenderer",o[o.GeometryBuffer=1]="GeometryBuffer",o[o.PrePass=2]="PrePass",o))(xi||{}),Fo="volumetricLighting";function _i(){return{name:Fo,enabled:!1,texturesRequired:[bi.Constants.PREPASS_DEPTH_TEXTURE_TYPE]}}a(_i,"createVolumetricLightingPrePassConfiguration");function xe(i){return i.prePassRenderer??null}a(xe,"getVolumetricPrePassRenderer");function Ne(i){return i.geometryBufferRenderer??null}a(Ne,"getVolumetricGeometryBufferRenderer");function No(i){let e=i.getCaps();return e.textureFloat&&e.textureFloatLinearFiltering||e.textureHalfFloat&&e.textureHalfFloatLinearFiltering}a(No,"supportsVolumetricFloatDepthTexture");function at(i){return No(i.getEngine())?xe(i)?.isSupported?2:Ne(i)?.isSupported?1:0:0}a(at,"resolveVolumetricDepthSource");function Ci(i){let e=i.getIndex(bi.Constants.PREPASS_DEPTH_TEXTURE_TYPE);return e===void 0||e<0?null:i.getRenderTarget()?.textures?.[e]??null}a(Ci,"getVolumetricPrePassDepthTexture");function Di(i){if(!i.enableDepth)return null;let e=i.getTextureIndex(aa);return e<0?null:i.getGBuffer()?.textures?.[e]??null}a(Di,"getVolumetricGeometryBufferDepthTexture");var Ge=`
2
+ // Stored scaled down by a power of two, which is exact. @see the GLSL version.
3
+ const volLinearDepthScale: f32 = 1.0 / 1024.0;
4
+
2
5
  fn volUnpack(color: vec4f) -> f32 {
3
6
  let bitShift = vec4f(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
4
7
  return dot(color, bitShift);
5
8
  }
6
- `,ea=`
9
+ `,sa=`
7
10
  // Loads the texel under the given coordinates rather than filtering: the 32 bits float textures of the prepass
8
11
  // renderer are not filterable on WebGPU. @see the GLSL version.
9
12
  fn volSampleDepth(uv: vec2f) -> f32 {
@@ -30,13 +33,13 @@ fn volLinearDepth(d: f32) -> f32 {
30
33
  return uniforms.volDepthUnpack.x * d + uniforms.volDepthUnpack.y;
31
34
  #endif
32
35
  }
33
- `;function yi(t){return`
36
+ `;function st(i){return`
34
37
  // Returns the distance along the view axis, in scene units, of the texel at the given coordinates.
35
38
  fn volReadLinearDepth(coordinates: vec2i) -> f32 {
36
39
  #ifdef VOL_LINEAR_DEPTH_PACKED
37
- return volUnpack(textureLoad(${t}, coordinates, 0)) * uniforms.volCameraMinMaxZ.y;
40
+ return volUnpack(textureLoad(${i}, coordinates, 0)) * uniforms.volCameraMinMaxZ.y;
38
41
  #else
39
- return textureLoad(${t}, coordinates, 0).r;
42
+ return textureLoad(${i}, coordinates, 0).r * (1.0 / volLinearDepthScale);
40
43
  #endif
41
44
  }
42
45
 
@@ -45,7 +48,7 @@ fn volReadLinearDepth(coordinates: vec2i) -> f32 {
45
48
  fn volScatterToDepthTexel(scatterTexel: vec2i, depthSize: vec2i) -> vec2i {
46
49
  return min(vec2i((vec2f(scatterTexel) + 0.5) * uniforms.volDepthRatio), depthSize - 1);
47
50
  }
48
- `}a(yi,"buildLinearDepthHelpers");function ta(){return`
51
+ `}a(st,"buildLinearDepthHelpers");function la(){return`
49
52
  varying vUV: vec2f;
50
53
 
51
54
  var textureSamplerSampler: sampler;
@@ -55,8 +58,11 @@ var depthSampler: texture_2d<f32>;
55
58
  uniform volCameraMinMaxZ: vec2f;
56
59
  uniform volDepthUnpack: vec2f;
57
60
 
58
- ${ot}
59
- ${ea}
61
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
62
+ uniform volPassParams: vec4f;
63
+
64
+ ${Ge}
65
+ ${sa}
60
66
 
61
67
  fn volPack(depth: f32) -> vec4f {
62
68
  let bitShift = vec4f(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
@@ -70,15 +76,21 @@ fn volPack(depth: f32) -> vec4f {
70
76
 
71
77
  @fragment
72
78
  fn main(input: FragmentInputs) -> FragmentOutputs {
73
- let viewZ = volLinearDepth(volSampleDepth(input.vUV));
79
+ // Nothing reads the linear depth while the pipeline has nothing to draw.
80
+ if (uniforms.volPassParams.x > 0.5) {
81
+ fragmentOutputs.color = vec4f(0.0);
82
+ } else {
83
+ let viewZ = volLinearDepth(volSampleDepth(input.vUV));
74
84
 
75
- #ifdef VOL_LINEAR_DEPTH_PACKED
76
- fragmentOutputs.color = volPack(clamp(viewZ / uniforms.volCameraMinMaxZ.y, 0.0, 0.9999999));
77
- #else
78
- fragmentOutputs.color = vec4f(viewZ, 0.0, 0.0, 1.0);
79
- #endif
85
+ #ifdef VOL_LINEAR_DEPTH_PACKED
86
+ fragmentOutputs.color = volPack(clamp(viewZ / uniforms.volCameraMinMaxZ.y, 0.0, 0.9999999));
87
+ #else
88
+ // Bounded by the largest 16 bits float.
89
+ fragmentOutputs.color = vec4f(min(viewZ * volLinearDepthScale, 65504.0), 0.0, 0.0, 1.0);
90
+ #endif
91
+ }
80
92
  }
81
- `}a(ta,"buildVolumetricLightingLinearDepthShaderWGSL");function Vo(t,e){return`
93
+ `}a(la,"buildVolumetricLightingLinearDepthShaderWGSL");function Go(i,e){return`
82
94
  let chordLength = t1 - t0;
83
95
 
84
96
  // The point of the view ray closest to the light splits the chord in two halves over which both the
@@ -101,7 +113,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
101
113
 
102
114
  let firstWidth = (closest - t0) / f32(max(firstCount, 1));
103
115
  let secondWidth = (t1 - closest) / f32(max(count - firstCount, 1));
104
- let stratum = volStratumOffset(${t});
116
+ let stratum = volStratumOffset(${i});
105
117
 
106
118
  var result = vec3f(0.0);
107
119
 
@@ -128,7 +140,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
128
140
  }
129
141
 
130
142
  return vec4f(result, 1.0);
131
- `}a(Vo,"buildLocalLightIntegrationWGSL");function ia(t){let e=[],i=[],o=[];for(let r=0;r<t;++r)e.push(`
143
+ `}a(Go,"buildLocalLightIntegrationWGSL");function ca(i){let e=[],t=[],o=[];for(let r=0;r<i;++r)e.push(`
132
144
  #if VOL_SHADOW_SLOT_COUNT > {X}
133
145
  #if VOL_SHADOW_KIND{X} == 2
134
146
  var volShadowSampler{X}Sampler: sampler;
@@ -247,11 +259,11 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
247
259
  // The light clip space position of the points of the view ray is affine in their distance to the camera.
248
260
  let clipOrigin = uniforms.volShadowMatrix[{X}] * vec4f(uniforms.volCameraPosition, 1.0);
249
261
  let clipDirection = uniforms.volShadowMatrix[{X}] * vec4f(volRayDir, 0.0);
250
- ${Vo("f32({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
262
+ ${Go("f32({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
251
263
  }
252
264
  #endif
253
265
  #endif
254
- `.replace(/\{X\}/g,r.toString())),i.push(`
266
+ `.replace(/\{X\}/g,r.toString())),t.push(`
255
267
  #if VOL_SHADOW_SLOT_COUNT > {X}
256
268
  #if VOL_SHADOW_LOCAL{X} == 0
257
269
  {
@@ -285,6 +297,9 @@ uniform volCameraForward: vec3f;
285
297
  uniform volCameraMinMaxZ: vec2f;
286
298
  uniform volFrameIndex: f32;
287
299
 
300
+ // Offset of the current frame along the golden ratio sequence the samples walk with the temporal accumulation.
301
+ uniform volTemporalOffset: f32;
302
+
288
303
  uniform volFogInfos: vec4f;
289
304
  uniform volFogColor: vec3f;
290
305
  uniform volLinearFogEps: f32;
@@ -299,6 +314,9 @@ uniform volAmbient: vec3f;
299
314
  // (maximum distance, dithering strength, light extinction clamp, number of point and spot lights in the arrays)
300
315
  uniform volParams: vec4f;
301
316
 
317
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
318
+ uniform volPassParams: vec4f;
319
+
302
320
  #if VOL_MAX_ARRAY_LIGHTS > 0
303
321
  uniform volLightData: array<vec4f, VOL_MAX_ARRAY_LIGHTS>;
304
322
  uniform volLightDiffuse: array<vec4f, VOL_MAX_ARRAY_LIGHTS>;
@@ -345,8 +363,8 @@ var<private> volJitter: f32;
345
363
  var<private> volClipDirection: vec4f;
346
364
  #endif
347
365
 
348
- ${ot}
349
- ${yi("textureSampler")}
366
+ ${Ge}
367
+ ${st("textureSampler")}
350
368
 
351
369
  fn volMod(x: f32, y: f32) -> f32 {
352
370
  return x - y * floor(x / y);
@@ -813,7 +831,7 @@ ${e.join(`
813
831
  var scattering = vec3f(0.0);
814
832
  var stepLights = 0.0;
815
833
 
816
- ${i.join("")}
834
+ ${t.join("")}
817
835
  #ifdef VOL_CSM
818
836
  {
819
837
  scattering += volEvalDirectionalLight(uniforms.volCsmLightData, uniforms.volCsmLightDiffuse) * mix(1.0, volCsmShadow(t), uniforms.volCsmLightFalloff.w);
@@ -872,7 +890,7 @@ ${i.join("")}
872
890
  let lightDepth = dot(data.xyz, uniforms.volCameraForward);
873
891
  #endif
874
892
 
875
- ${Vo("f32(index)",`#ifdef VOL_SCREEN_SHADOWS
893
+ ${Go("f32(index)",`#ifdef VOL_SCREEN_SHADOWS
876
894
  if (occluded) {
877
895
  contribution *= volScreenShadowToLight(t, lightClip, lightDepth, distanceToLight);
878
896
  }
@@ -899,8 +917,9 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
899
917
  var finalTransmittance = 1.0;
900
918
  var evaluatedLights = 0.0;
901
919
 
902
- // WGSL has no early return from the fragment entry point, the whole integration is guarded instead.
903
- if (tEnd > tStart) {
920
+ // WGSL has no early return from the fragment entry point, the whole integration is guarded instead. Nothing is
921
+ // drawn either while no light reaches the view and the medium neither glows nor attenuates anything.
922
+ if (tEnd > tStart && uniforms.volPassParams.x < 0.5) {
904
923
  // Offsets the samples inside their segments to trade the banding produced by a low sample count for noise.
905
924
  volNoise = 0.0;
906
925
  #if VOL_DITHER == 1
@@ -912,6 +931,11 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
912
931
  #endif
913
932
  volNoise = volInterleavedGradientNoise(ditherPosition);
914
933
  #endif
934
+
935
+ #ifdef VOL_TEMPORAL_ACCUMULATION
936
+ // Each pixel walks the golden ratio sequence from the offset of its dithering pattern. @see the GLSL version.
937
+ volNoise = fract(volNoise + uniforms.volTemporalOffset);
938
+ #endif
915
939
  volJitter = volNoise * uniforms.volParams.y;
916
940
 
917
941
  #ifdef VOL_SCREEN_SHADOWS
@@ -971,58 +995,155 @@ ${o.join("")}
971
995
 
972
996
  fragmentOutputs.color = vec4f(result, finalTransmittance);
973
997
  }
974
- `}a(ia,"buildVolumetricLightingScatteringShaderWGSL");function oa(){return`
998
+ `}a(ca,"buildVolumetricLightingScatteringShaderWGSL");function pa(){return`
975
999
  varying vUV: vec2f;
976
1000
 
977
1001
  var textureSampler: texture_2d<f32>;
1002
+ var volHistorySamplerSampler: sampler;
1003
+ var volHistorySampler: texture_2d<f32>;
978
1004
  var volLinearDepthSampler: texture_2d<f32>;
979
1005
 
980
1006
  uniform volCameraMinMaxZ: vec2f;
981
1007
  uniform volDepthRatio: vec2f;
982
- uniform volBlurDirection: vec2f;
983
- uniform volBlurParams: vec2f;
1008
+ uniform volInverseViewProjection: mat4x4f;
1009
+ uniform volCameraPosition: vec3f;
1010
+ uniform volCameraForward: vec3f;
1011
+ uniform volPreviousViewProjection: mat4x4f;
1012
+
1013
+ // (weight of the current frame, width of the clipping in standard deviations, maximum distance of the march,
1014
+ // 1 when the history holds the previous frame, 2 when the previous frame had nothing to draw)
1015
+ uniform volTemporalParams: vec4f;
1016
+
1017
+ // (distance the camera moved since the previous frame, part of the medium along the view ray whose change the
1018
+ // delay of the history may lag behind)
1019
+ uniform volTemporalMotion: vec2f;
984
1020
 
985
- ${ot}
986
- ${yi("volLinearDepthSampler")}
1021
+ ${Ge}
1022
+ ${st("volLinearDepthSampler")}
987
1023
 
988
1024
  @fragment
989
1025
  fn main(input: FragmentInputs) -> FragmentOutputs {
990
- // Every tap is an exact texel compared using the depth the raymarching used for it. @see the GLSL version.
1026
+ let texel = vec2i(fragmentInputs.position.xy);
991
1027
  let size = vec2i(textureDimensions(textureSampler));
992
- let depthSize = vec2i(textureDimensions(volLinearDepthSampler));
993
- let center = vec2i(fragmentInputs.position.xy);
994
- let direction = vec2i(uniforms.volBlurDirection);
995
1028
 
996
- let centerDepth = volReadLinearDepth(volScatterToDepthTexel(center, depthSize));
997
- let inverseDepthThreshold = 1.0 / max(uniforms.volBlurParams.y * max(centerDepth, uniforms.volCameraMinMaxZ.x), 1e-4);
998
- let sigma = max(uniforms.volBlurParams.x, 1e-4);
999
- let inverseTwoSigma2 = 1.0 / (2.0 * sigma * sigma);
1029
+ // Bounded so a light next to the camera, which a half float can't hold, never turns the history infinite.
1030
+ let current = min(textureLoad(textureSampler, texel, 0), vec4f(65000.0));
1031
+ var result = current;
1000
1032
 
1001
- var result = textureLoad(textureSampler, center, 0);
1002
- var totalWeight = 1.0;
1033
+ // WGSL has no early return from the fragment entry point, the accumulation is guarded instead.
1034
+ if (uniforms.volTemporalParams.w > 0.5) {
1035
+ // The end of the marched part of the view ray is reprojected in the previous frame. @see the GLSL version.
1036
+ let depthSize = vec2i(textureDimensions(volLinearDepthSampler));
1037
+ let viewZ = volReadLinearDepth(volScatterToDepthTexel(texel, depthSize));
1003
1038
 
1004
- for (var i: i32 = 1; i <= VOL_BLUR_RADIUS; i++) {
1005
- let spatialWeight = exp(-f32(i * i) * inverseTwoSigma2);
1039
+ let farPoint = uniforms.volInverseViewProjection * vec4f(input.vUV * 2.0 - 1.0, 1.0, 1.0);
1040
+ let rayDir = normalize(farPoint.xyz / farPoint.w - uniforms.volCameraPosition);
1041
+ let t = min(viewZ / max(dot(rayDir, uniforms.volCameraForward), 1e-4), uniforms.volTemporalParams.z);
1006
1042
 
1007
- let positive = center + direction * i;
1008
- let negative = center - direction * i;
1043
+ let previousClip = uniforms.volPreviousViewProjection * vec4f(rayDir * t, 1.0);
1044
+ let previousUV = (previousClip.xy / previousClip.w) * 0.5 + 0.5;
1009
1045
 
1010
- if (positive.x < size.x && positive.y < size.y) {
1011
- let weight = spatialWeight * exp(-abs(volReadLinearDepth(volScatterToDepthTexel(positive, depthSize)) - centerDepth) * inverseDepthThreshold);
1012
- result += textureLoad(textureSampler, positive, 0) * weight;
1013
- totalWeight += weight;
1014
- }
1046
+ // Clamped so a position reprojected off the screen still reads a valid texel: whether the history is used
1047
+ // at all is decided below. Nothing to draw the previous frame: no light at all, seen through the same medium.
1048
+ let sampled = textureSampleLevel(volHistorySampler, volHistorySamplerSampler, clamp(previousUV, vec2f(0.0), vec2f(1.0)), 0.0);
1049
+ let history = select(sampled, vec4f(0.0, 0.0, 0.0, current.a), uniforms.volTemporalParams.w > 1.5);
1015
1050
 
1016
- if (negative.x >= 0 && negative.y >= 0) {
1017
- let weight = spatialWeight * exp(-abs(volReadLinearDepth(volScatterToDepthTexel(negative, depthSize)) - centerDepth) * inverseDepthThreshold);
1018
- result += textureLoad(textureSampler, negative, 0) * weight;
1019
- totalWeight += weight;
1051
+ let inside = previousClip.w > 0.0 && all(previousUV >= vec2f(0.0)) && all(previousUV <= vec2f(1.0));
1052
+
1053
+ // A history holding an infinity or a NaN would never recover from it.
1054
+ let finite = all(abs(history) < vec4f(1e20));
1055
+
1056
+ if (inside && finite) {
1057
+ // Variance clipping: the history is kept within what the current frame shows around the pixel.
1058
+ var m1 = vec4f(0.0);
1059
+ var m2 = vec4f(0.0);
1060
+
1061
+ for (var y: i32 = -1; y <= 1; y++) {
1062
+ for (var x: i32 = -1; x <= 1; x++) {
1063
+ let c = min(textureLoad(textureSampler, clamp(texel + vec2i(x, y), vec2i(0), size - 1), 0), vec4f(65000.0));
1064
+ m1 += c;
1065
+ m2 += c * c;
1066
+ }
1067
+ }
1068
+
1069
+ let mean = m1 * (1.0 / 9.0);
1070
+ let sigma = sqrt(max(m2 * (1.0 / 9.0) - mean * mean, vec4f(0.0)));
1071
+ let clipped = clamp(history, mean - uniforms.volTemporalParams.y * sigma, mean + uniforms.volTemporalParams.y * sigma);
1072
+
1073
+ // Moving the camera changes the medium along the view ray, the history is trusted less. @see the GLSL version.
1074
+ let motion = uniforms.volTemporalMotion.x / max(t, 1e-3);
1075
+ let factor = max(uniforms.volTemporalParams.x, motion / (motion + uniforms.volTemporalMotion.y));
1076
+
1077
+ // The transmittance only depends on the length of medium in front of the surface. @see the GLSL version.
1078
+ let transmittanceChange = abs(history.a - current.a) / max(max(history.a, current.a), 1e-3);
1079
+ let historyWeight = (1.0 - factor) * (1.0 - smoothstep(0.02, 0.15, transmittanceChange));
1080
+
1081
+ result = mix(current, clipped, historyWeight);
1020
1082
  }
1021
1083
  }
1022
1084
 
1023
- fragmentOutputs.color = result / totalWeight;
1085
+ fragmentOutputs.color = result;
1024
1086
  }
1025
- `}a(oa,"buildVolumetricLightingBlurShaderWGSL");function ra(){return`
1087
+ `}a(pa,"buildVolumetricLightingTemporalShaderWGSL");function ha(){return`
1088
+ varying vUV: vec2f;
1089
+
1090
+ var textureSampler: texture_2d<f32>;
1091
+ var volLinearDepthSampler: texture_2d<f32>;
1092
+
1093
+ uniform volCameraMinMaxZ: vec2f;
1094
+ uniform volDepthRatio: vec2f;
1095
+ uniform volBlurDirection: vec2f;
1096
+ uniform volBlurParams: vec2f;
1097
+
1098
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
1099
+ uniform volPassParams: vec4f;
1100
+
1101
+ ${Ge}
1102
+ ${st("volLinearDepthSampler")}
1103
+
1104
+ @fragment
1105
+ fn main(input: FragmentInputs) -> FragmentOutputs {
1106
+ // Nothing to draw this frame: the composition doesn't read the scattering buffer.
1107
+ if (uniforms.volPassParams.x > 0.5) {
1108
+ fragmentOutputs.color = vec4f(0.0, 0.0, 0.0, 1.0);
1109
+ } else {
1110
+ // Every tap is an exact texel compared using the depth the raymarching used for it. @see the GLSL version.
1111
+ let size = vec2i(textureDimensions(textureSampler));
1112
+ let depthSize = vec2i(textureDimensions(volLinearDepthSampler));
1113
+ let center = vec2i(fragmentInputs.position.xy);
1114
+ let direction = vec2i(uniforms.volBlurDirection);
1115
+
1116
+ let centerDepth = volReadLinearDepth(volScatterToDepthTexel(center, depthSize));
1117
+ let inverseDepthThreshold = 1.0 / max(uniforms.volBlurParams.y * max(centerDepth, uniforms.volCameraMinMaxZ.x), 1e-4);
1118
+ let sigma = max(uniforms.volBlurParams.x, 1e-4);
1119
+ let inverseTwoSigma2 = 1.0 / (2.0 * sigma * sigma);
1120
+
1121
+ var result = textureLoad(textureSampler, center, 0);
1122
+ var totalWeight = 1.0;
1123
+
1124
+ for (var i: i32 = 1; i <= VOL_BLUR_RADIUS; i++) {
1125
+ let spatialWeight = exp(-f32(i * i) * inverseTwoSigma2);
1126
+
1127
+ let positive = center + direction * i;
1128
+ let negative = center - direction * i;
1129
+
1130
+ if (positive.x < size.x && positive.y < size.y) {
1131
+ let weight = spatialWeight * exp(-abs(volReadLinearDepth(volScatterToDepthTexel(positive, depthSize)) - centerDepth) * inverseDepthThreshold);
1132
+ result += textureLoad(textureSampler, positive, 0) * weight;
1133
+ totalWeight += weight;
1134
+ }
1135
+
1136
+ if (negative.x >= 0 && negative.y >= 0) {
1137
+ let weight = spatialWeight * exp(-abs(volReadLinearDepth(volScatterToDepthTexel(negative, depthSize)) - centerDepth) * inverseDepthThreshold);
1138
+ result += textureLoad(textureSampler, negative, 0) * weight;
1139
+ totalWeight += weight;
1140
+ }
1141
+ }
1142
+
1143
+ fragmentOutputs.color = result / totalWeight;
1144
+ }
1145
+ }
1146
+ `}a(ha,"buildVolumetricLightingBlurShaderWGSL");function ma(){return`
1026
1147
  varying vUV: vec2f;
1027
1148
 
1028
1149
  var textureSampler: texture_2d<f32>;
@@ -1034,8 +1155,11 @@ uniform volCameraMinMaxZ: vec2f;
1034
1155
  uniform volDepthRatio: vec2f;
1035
1156
  uniform volComposeParams: vec4f;
1036
1157
 
1037
- ${ot}
1038
- ${yi("volLinearDepthSampler")}
1158
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
1159
+ uniform volPassParams: vec4f;
1160
+
1161
+ ${Ge}
1162
+ ${st("volLinearDepthSampler")}
1039
1163
 
1040
1164
  fn volMod(x: f32, y: f32) -> f32 {
1041
1165
  return x - y * floor(x / y);
@@ -1097,40 +1221,50 @@ fn volUpsample(uv0: vec2f, centerDepth: f32, depthSize: vec2i) -> vec4f {
1097
1221
 
1098
1222
  @fragment
1099
1223
  fn main(input: FragmentInputs) -> FragmentOutputs {
1100
- // The linear depth has the full resolution of the canvas. @see the GLSL version.
1101
- let depthSize = vec2i(textureDimensions(volLinearDepthSampler));
1102
- let centerDepth = volReadLinearDepth(min(vec2i(input.vUV * vec2f(depthSize)), depthSize - 1));
1224
+ // Nothing to draw this frame: the color of the scene passes through. @see the GLSL version.
1225
+ if (uniforms.volPassParams.x > 0.5) {
1226
+ let sceneColor = textureSampleLevel(volSceneSampler, volSceneSamplerSampler, input.vUV, 0.0).rgb;
1227
+ fragmentOutputs.color = vec4f(sceneColor + (volBayer8(fragmentInputs.position.xy) - 0.5) * uniforms.volComposeParams.w, 1.0);
1228
+ } else {
1229
+ // The linear depth has the full resolution of the canvas. @see the GLSL version.
1230
+ let depthSize = vec2i(textureDimensions(volLinearDepthSampler));
1231
+ let centerDepth = volReadLinearDepth(min(vec2i(input.vUV * vec2f(depthSize)), depthSize - 1));
1103
1232
 
1104
- var volumetric = volUpsample(input.vUV, centerDepth, depthSize);
1233
+ var volumetric = volUpsample(input.vUV, centerDepth, depthSize);
1105
1234
 
1106
- #ifdef VOL_LDR_ENCODE
1107
- volumetric = vec4f(volumetric.rgb / max(vec3f(1e-4), 1.0 - volumetric.rgb), volumetric.a);
1108
- #endif
1235
+ #ifdef VOL_LDR_ENCODE
1236
+ volumetric = vec4f(volumetric.rgb / max(vec3f(1e-4), 1.0 - volumetric.rgb), volumetric.a);
1237
+ #endif
1109
1238
 
1110
- // WGSL has no early return from the fragment entry point, so the debug outputs are branches instead.
1111
- #if VOL_DEBUG == 1 || VOL_DEBUG == 3
1112
- fragmentOutputs.color = vec4f(volumetric.rgb * uniforms.volComposeParams.x, 1.0);
1113
- #elif VOL_DEBUG == 2
1114
- fragmentOutputs.color = vec4f(vec3f(volumetric.a), 1.0);
1115
- #else
1116
- var sceneColor = textureSampleLevel(volSceneSampler, volSceneSamplerSampler, input.vUV, 0.0).rgb;
1239
+ // WGSL has no early return from the fragment entry point, so the debug outputs are branches instead.
1240
+ #if VOL_DEBUG == 1 || VOL_DEBUG == 3
1241
+ fragmentOutputs.color = vec4f(volumetric.rgb * uniforms.volComposeParams.x, 1.0);
1242
+ #elif VOL_DEBUG == 2
1243
+ fragmentOutputs.color = vec4f(vec3f(volumetric.a), 1.0);
1244
+ #else
1245
+ var sceneColor = textureSampleLevel(volSceneSampler, volSceneSamplerSampler, input.vUV, 0.0).rgb;
1117
1246
 
1118
- sceneColor *= mix(1.0, volumetric.a, uniforms.volComposeParams.y);
1247
+ sceneColor *= mix(1.0, volumetric.a, uniforms.volComposeParams.y);
1119
1248
 
1120
- var result = sceneColor + volumetric.rgb * uniforms.volComposeParams.x;
1249
+ var result = sceneColor + volumetric.rgb * uniforms.volComposeParams.x;
1121
1250
 
1122
- // Breaks up the banding an 8 bits output would otherwise show on the smooth gradients of the shafts.
1123
- result += (volBayer8(fragmentInputs.position.xy) - 0.5) * uniforms.volComposeParams.w;
1251
+ // Breaks up the banding an 8 bits output would otherwise show on the smooth gradients of the shafts.
1252
+ result += (volBayer8(fragmentInputs.position.xy) - 0.5) * uniforms.volComposeParams.w;
1124
1253
 
1125
- fragmentOutputs.color = vec4f(result, 1.0);
1126
- #endif
1254
+ fragmentOutputs.color = vec4f(result, 1.0);
1255
+ #endif
1256
+ }
1127
1257
  }
1128
- `}a(ra,"buildVolumetricLightingComposeShaderWGSL");function Fo(){return{linearDepth:ta(),scattering:ia(E),blur:oa(),compose:ra()}}a(Fo,"getVolumetricLightingShadersWGSL");var j=require("babylonjs"),Bo=require("babylonjs"),nt="volumetricLightingLinearDepth",at="volumetricLightingScattering",st="volumetricLightingBlur",lt="volumetricLightingCompose",rt=`
1258
+ `}a(ma,"buildVolumetricLightingComposeShaderWGSL");function Bo(){return{linearDepth:la(),scattering:ca(O),temporal:pa(),blur:ha(),compose:ma()}}a(Bo,"getVolumetricLightingShadersWGSL");var z=require("babylonjs"),ko=require("babylonjs"),ct="volumetricLightingLinearDepth",pt="volumetricLightingScattering",ht="volumetricLightingTemporal",mt="volumetricLightingBlur",dt="volumetricLightingCompose",Be=`
1259
+ // Stored scaled down by a power of two, which is exact: a 16 bits float then holds the far plane of the largest
1260
+ // scenes, with a relative precision of 0.05%.
1261
+ const float volLinearDepthScale = 1.0 / 1024.0;
1262
+
1129
1263
  float volUnpack(vec4 color) {
1130
1264
  const vec4 bitShift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
1131
1265
  return dot(color, bitShift);
1132
1266
  }
1133
- `,na=`
1267
+ `,da=`
1134
1268
  // Reads the texel under the given coordinates rather than filtering: the depth of a silhouette must not be
1135
1269
  // averaged with the sky, and the 32 bits float textures of the prepass renderer can't be filtered everywhere.
1136
1270
  float volSampleDepth(vec2 uv) {
@@ -1158,13 +1292,13 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
1158
1292
  return volDepthUnpack.x * d + volDepthUnpack.y;
1159
1293
  #endif
1160
1294
  }
1161
- `,bi=`
1295
+ `,lt=`
1162
1296
  // Returns the distance along the view axis, in scene units, of the texel at the given coordinates.
1163
1297
  float volReadLinearDepth(sampler2D s, ivec2 coordinates) {
1164
1298
  #ifdef VOL_LINEAR_DEPTH_PACKED
1165
1299
  return volUnpack(texelFetch(s, coordinates, 0)) * volCameraMinMaxZ.y;
1166
1300
  #else
1167
- return texelFetch(s, coordinates, 0).r;
1301
+ return texelFetch(s, coordinates, 0).r * (1.0 / volLinearDepthScale);
1168
1302
  #endif
1169
1303
  }
1170
1304
 
@@ -1175,7 +1309,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
1175
1309
  ivec2 volScatterToDepthTexel(ivec2 scatterTexel, ivec2 depthSize) {
1176
1310
  return min(ivec2((vec2(scatterTexel) + 0.5) * volDepthRatio), depthSize - 1);
1177
1311
  }
1178
- `;function aa(){return`precision highp float;
1312
+ `;function ua(){return`precision highp float;
1179
1313
  precision highp int;
1180
1314
 
1181
1315
  varying vec2 vUV;
@@ -1186,8 +1320,11 @@ uniform highp sampler2D depthSampler;
1186
1320
  uniform vec2 volCameraMinMaxZ;
1187
1321
  uniform vec2 volDepthUnpack;
1188
1322
 
1189
- ${rt}
1190
- ${na}
1323
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
1324
+ uniform vec4 volPassParams;
1325
+
1326
+ ${Be}
1327
+ ${da}
1191
1328
 
1192
1329
  vec4 volPack(float depth) {
1193
1330
  const vec4 bitShift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
@@ -1200,15 +1337,22 @@ vec4 volPack(float depth) {
1200
1337
  }
1201
1338
 
1202
1339
  void main(void) {
1340
+ // Nothing reads the linear depth while the pipeline has nothing to draw.
1341
+ if (volPassParams.x > 0.5) {
1342
+ gl_FragColor = vec4(0.0);
1343
+ return;
1344
+ }
1345
+
1203
1346
  float viewZ = volLinearDepth(volSampleDepth(vUV));
1204
1347
 
1205
1348
  #ifdef VOL_LINEAR_DEPTH_PACKED
1206
1349
  gl_FragColor = volPack(clamp(viewZ / volCameraMinMaxZ.y, 0.0, 0.9999999));
1207
1350
  #else
1208
- gl_FragColor = vec4(viewZ, 0.0, 0.0, 1.0);
1351
+ // Bounded by the largest 16 bits float.
1352
+ gl_FragColor = vec4(min(viewZ * volLinearDepthScale, 65504.0), 0.0, 0.0, 1.0);
1209
1353
  #endif
1210
1354
  }
1211
- `}a(aa,"buildVolumetricLightingLinearDepthShader");function No(t,e){return`
1355
+ `}a(ua,"buildVolumetricLightingLinearDepthShader");function zo(i,e){return`
1212
1356
  float chordLength = t1 - t0;
1213
1357
 
1214
1358
  // The point of the view ray closest to the light splits the chord in two halves over which both the
@@ -1225,7 +1369,7 @@ void main(void) {
1225
1369
 
1226
1370
  float firstWidth = (closest - t0) / float(max(firstCount, 1));
1227
1371
  float secondWidth = (t1 - closest) / float(max(count - firstCount, 1));
1228
- float stratum = volStratumOffset(${t});
1372
+ float stratum = volStratumOffset(${i});
1229
1373
 
1230
1374
  vec3 result = vec3(0.0);
1231
1375
 
@@ -1251,7 +1395,7 @@ void main(void) {
1251
1395
  }
1252
1396
 
1253
1397
  return vec4(result, 1.0);
1254
- `}a(No,"buildLocalLightIntegration");function sa(t){let e=[],i=[],o=[];for(let r=0;r<t;++r)e.push(`
1398
+ `}a(zo,"buildLocalLightIntegration");function fa(i){let e=[],t=[],o=[];for(let r=0;r<i;++r)e.push(`
1255
1399
  #if VOL_SHADOW_SLOT_COUNT > {X}
1256
1400
  #if VOL_SHADOW_KIND{X} == 2
1257
1401
  uniform samplerCube volShadowSampler{X};
@@ -1368,11 +1512,11 @@ void main(void) {
1368
1512
  // so each sample only costs a multiply-add instead of a matrix product.
1369
1513
  vec4 clipOrigin = volShadowMatrix[{X}] * vec4(volCameraPosition, 1.0);
1370
1514
  vec4 clipDirection = volShadowMatrix[{X}] * vec4(volRayDir, 0.0);
1371
- ${No("float({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
1515
+ ${zo("float({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
1372
1516
  }
1373
1517
  #endif
1374
1518
  #endif
1375
- `.replace(/\{X\}/g,r.toString())),i.push(`
1519
+ `.replace(/\{X\}/g,r.toString())),t.push(`
1376
1520
  #if VOL_SHADOW_SLOT_COUNT > {X}
1377
1521
  #if VOL_SHADOW_LOCAL{X} == 0
1378
1522
  {
@@ -1409,6 +1553,9 @@ uniform vec3 volCameraForward;
1409
1553
  uniform vec2 volCameraMinMaxZ;
1410
1554
  uniform float volFrameIndex;
1411
1555
 
1556
+ // Offset of the current frame along the golden ratio sequence the samples walk with the temporal accumulation.
1557
+ uniform float volTemporalOffset;
1558
+
1412
1559
  uniform vec4 volFogInfos;
1413
1560
  uniform vec3 volFogColor;
1414
1561
  uniform float volLinearFogEps;
@@ -1423,6 +1570,9 @@ uniform vec3 volAmbient;
1423
1570
  // (maximum distance, dithering strength, light extinction clamp, number of point and spot lights in the arrays)
1424
1571
  uniform vec4 volParams;
1425
1572
 
1573
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
1574
+ uniform vec4 volPassParams;
1575
+
1426
1576
  #if VOL_MAX_ARRAY_LIGHTS > 0
1427
1577
  uniform vec4 volLightData[VOL_MAX_ARRAY_LIGHTS];
1428
1578
  uniform vec4 volLightDiffuse[VOL_MAX_ARRAY_LIGHTS];
@@ -1467,8 +1617,8 @@ float volJitter;
1467
1617
  vec4 volClipDirection;
1468
1618
  #endif
1469
1619
 
1470
- ${rt}
1471
- ${bi}
1620
+ ${Be}
1621
+ ${lt}
1472
1622
 
1473
1623
  float volFallOff(float value, vec2 clipSpaceXY, float frustumEdgeFalloff) {
1474
1624
  float mask = smoothstep(1.0 - frustumEdgeFalloff, 1.00000012, clamp(dot(clipSpaceXY, clipSpaceXY), 0.0, 1.0));
@@ -1986,7 +2136,7 @@ ${e.join(`
1986
2136
  vec3 scattering = vec3(0.0);
1987
2137
  float stepLights = 0.0;
1988
2138
 
1989
- ${i.join("")}
2139
+ ${t.join("")}
1990
2140
  #ifdef VOL_CSM
1991
2141
  {
1992
2142
  scattering += volEvalDirectionalLight(volCsmLightData, volCsmLightDiffuse) * mix(1.0, volCsmShadow(t), volCsmLightFalloff.w);
@@ -2046,7 +2196,7 @@ ${i.join("")}
2046
2196
  float lightDepth = dot(data.xyz, volCameraForward);
2047
2197
  #endif
2048
2198
 
2049
- ${No("float(index)",`#ifdef VOL_SCREEN_SHADOWS
2199
+ ${zo("float(index)",`#ifdef VOL_SCREEN_SHADOWS
2050
2200
  if (occluded) {
2051
2201
  contribution *= volScreenShadowToLight(t, lightClip, lightDepth, distanceToLight);
2052
2202
  }
@@ -2055,6 +2205,12 @@ ${i.join("")}
2055
2205
  #endif
2056
2206
 
2057
2207
  void main(void) {
2208
+ // Nothing to draw this frame: no light reaches the view and the medium neither glows nor attenuates anything.
2209
+ if (volPassParams.x > 0.5) {
2210
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
2211
+ return;
2212
+ }
2213
+
2058
2214
  // Reconstruct the world space direction of the view ray from the UV of the pixel.
2059
2215
  vec4 farPoint = volInverseViewProjection * vec4(vUV * 2.0 - 1.0, 1.0, 1.0);
2060
2216
  volRayDir = normalize(farPoint.xyz / farPoint.w - volCameraPosition);
@@ -2084,6 +2240,14 @@ void main(void) {
2084
2240
  #endif
2085
2241
  volNoise = volInterleavedGradientNoise(ditherPosition);
2086
2242
  #endif
2243
+
2244
+ #ifdef VOL_TEMPORAL_ACCUMULATION
2245
+ // Each pixel walks the golden ratio sequence from the offset of its dithering pattern, one step per frame:
2246
+ // the samples of consecutive frames spread evenly over their segments, and the accumulation averages them.
2247
+ // The pattern of the pixels around stays the same, which is what lets the accumulation tell its noise from
2248
+ // the changes of the scene.
2249
+ volNoise = fract(volNoise + volTemporalOffset);
2250
+ #endif
2087
2251
  volJitter = volNoise * volParams.y;
2088
2252
 
2089
2253
  #ifdef VOL_SCREEN_SHADOWS
@@ -2145,7 +2309,109 @@ ${o.join("")}
2145
2309
 
2146
2310
  gl_FragColor = vec4(result, finalTransmittance);
2147
2311
  }
2148
- `}a(sa,"buildVolumetricLightingScatteringShader");function la(){return`precision highp float;
2312
+ `}a(fa,"buildVolumetricLightingScatteringShader");function ga(){return`precision highp float;
2313
+ precision highp int;
2314
+
2315
+ varying vec2 vUV;
2316
+
2317
+ // Scattering computed this frame, and scattering accumulated over the previous frames, both at the resolution of
2318
+ // the scattering buffer.
2319
+ uniform sampler2D textureSampler;
2320
+ uniform sampler2D volHistorySampler;
2321
+
2322
+ // Full resolution linear depth of the scene, written by the linear depth pass.
2323
+ uniform highp sampler2D volLinearDepthSampler;
2324
+
2325
+ uniform vec2 volCameraMinMaxZ;
2326
+ uniform vec2 volDepthRatio;
2327
+ uniform mat4 volInverseViewProjection;
2328
+ uniform vec3 volCameraPosition;
2329
+ uniform vec3 volCameraForward;
2330
+
2331
+ // View projection matrix of the previous frame, applied to positions relative to the current camera.
2332
+ uniform mat4 volPreviousViewProjection;
2333
+
2334
+ // (weight of the current frame, width of the clipping of the history in standard deviations, maximum distance of
2335
+ // the march, 1 when the history holds the previous frame, 2 when the previous frame had nothing to draw)
2336
+ uniform vec4 volTemporalParams;
2337
+
2338
+ // (distance the camera moved since the previous frame, part of the medium along the view ray whose change the
2339
+ // delay of the history may lag behind)
2340
+ uniform vec2 volTemporalMotion;
2341
+
2342
+ ${Be}
2343
+ ${lt}
2344
+
2345
+ void main(void) {
2346
+ ivec2 texel = ivec2(gl_FragCoord.xy);
2347
+ ivec2 size = textureSize(textureSampler, 0);
2348
+
2349
+ // Bounded so a light next to the camera, which a half float can't hold, never turns the history infinite.
2350
+ vec4 current = min(texelFetch(textureSampler, texel, 0), vec4(65000.0));
2351
+
2352
+ if (volTemporalParams.w < 0.5) {
2353
+ gl_FragColor = current;
2354
+ return;
2355
+ }
2356
+
2357
+ // The end of the marched part of the view ray is reprojected in the previous frame: the medium in front of it
2358
+ // is spread along the ray, but its scattering varies slowly enough for the surface behind it, or the maximum
2359
+ // distance of the march, to be a faithful anchor.
2360
+ ivec2 depthSize = textureSize(volLinearDepthSampler, 0);
2361
+ float viewZ = volReadLinearDepth(volLinearDepthSampler, volScatterToDepthTexel(texel, depthSize));
2362
+
2363
+ vec4 farPoint = volInverseViewProjection * vec4(vUV * 2.0 - 1.0, 1.0, 1.0);
2364
+ vec3 rayDir = normalize(farPoint.xyz / farPoint.w - volCameraPosition);
2365
+ float t = min(viewZ / max(dot(rayDir, volCameraForward), 1e-4), volTemporalParams.z);
2366
+
2367
+ vec4 previousClip = volPreviousViewProjection * vec4(rayDir * t, 1.0);
2368
+ vec2 previousUV = (previousClip.xy / previousClip.w) * 0.5 + 0.5;
2369
+
2370
+ if (previousClip.w <= 0.0 || previousUV.x < 0.0 || previousUV.x > 1.0 || previousUV.y < 0.0 || previousUV.y > 1.0) {
2371
+ gl_FragColor = current;
2372
+ return;
2373
+ }
2374
+
2375
+ // The pipeline had nothing to draw the previous frame: no light at all, seen through the same medium.
2376
+ vec4 history = volTemporalParams.w > 1.5 ? vec4(0.0, 0.0, 0.0, current.a) : texture2D(volHistorySampler, previousUV);
2377
+
2378
+ // A history holding an infinity or a NaN would never recover from it.
2379
+ if (!all(lessThan(abs(history), vec4(1e20)))) {
2380
+ gl_FragColor = current;
2381
+ return;
2382
+ }
2383
+
2384
+ // Variance clipping: the history is kept within what the current frame shows around the pixel.
2385
+ vec4 m1 = vec4(0.0);
2386
+ vec4 m2 = vec4(0.0);
2387
+
2388
+ for (int y = -1; y <= 1; ++y) {
2389
+ for (int x = -1; x <= 1; ++x) {
2390
+ vec4 c = min(texelFetch(textureSampler, clamp(texel + ivec2(x, y), ivec2(0), size - 1), 0), vec4(65000.0));
2391
+ m1 += c;
2392
+ m2 += c * c;
2393
+ }
2394
+ }
2395
+
2396
+ vec4 mean = m1 * (1.0 / 9.0);
2397
+ vec4 sigma = sqrt(max(m2 * (1.0 / 9.0) - mean * mean, vec4(0.0)));
2398
+ vec4 clipped = clamp(history, mean - volTemporalParams.y * sigma, mean + volTemporalParams.y * sigma);
2399
+
2400
+ // The history holds the medium as seen from where the camera was. A rotation of the camera changes nothing to
2401
+ // what a view ray crosses, but moving it changes the medium along the view ray by about the distance it moved
2402
+ // relative to the length of the ray: the weight of the current frame grows with that change, so the delay of
2403
+ // the history never lags behind more than the given part of it.
2404
+ float motion = volTemporalMotion.x / max(t, 1e-3);
2405
+ float factor = max(volTemporalParams.x, motion / (motion + volTemporalMotion.y));
2406
+
2407
+ // The transmittance only depends on the length of medium in front of the surface: when it changed, the history
2408
+ // shows another surface and is dropped. Compared before the clipping, which would hide the change.
2409
+ float transmittanceChange = abs(history.a - current.a) / max(max(history.a, current.a), 1e-3);
2410
+ float historyWeight = (1.0 - factor) * (1.0 - smoothstep(0.02, 0.15, transmittanceChange));
2411
+
2412
+ gl_FragColor = mix(current, clipped, historyWeight);
2413
+ }
2414
+ `}a(ga,"buildVolumetricLightingTemporalShader");function va(){return`precision highp float;
2149
2415
  precision highp int;
2150
2416
 
2151
2417
  varying vec2 vUV;
@@ -2158,10 +2424,19 @@ uniform vec2 volDepthRatio;
2158
2424
  uniform vec2 volBlurDirection;
2159
2425
  uniform vec2 volBlurParams;
2160
2426
 
2161
- ${rt}
2162
- ${bi}
2427
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
2428
+ uniform vec4 volPassParams;
2429
+
2430
+ ${Be}
2431
+ ${lt}
2163
2432
 
2164
2433
  void main(void) {
2434
+ // Nothing to draw this frame: the composition doesn't read the scattering buffer.
2435
+ if (volPassParams.x > 0.5) {
2436
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
2437
+ return;
2438
+ }
2439
+
2165
2440
  // The blur runs at the resolution of the scattering buffer and every tap is an exact texel, compared using
2166
2441
  // the depth the raymarching used for it: no filtering is needed, no depth has to be unpacked nor linearized.
2167
2442
  ivec2 size = textureSize(textureSampler, 0);
@@ -2198,7 +2473,7 @@ void main(void) {
2198
2473
 
2199
2474
  gl_FragColor = result / totalWeight;
2200
2475
  }
2201
- `}a(la,"buildVolumetricLightingBlurShader");function ca(){return`precision highp float;
2476
+ `}a(va,"buildVolumetricLightingBlurShader");function Sa(){return`precision highp float;
2202
2477
  precision highp int;
2203
2478
 
2204
2479
  varying vec2 vUV;
@@ -2211,8 +2486,11 @@ uniform vec2 volCameraMinMaxZ;
2211
2486
  uniform vec2 volDepthRatio;
2212
2487
  uniform vec4 volComposeParams;
2213
2488
 
2214
- ${rt}
2215
- ${bi}
2489
+ // (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
2490
+ uniform vec4 volPassParams;
2491
+
2492
+ ${Be}
2493
+ ${lt}
2216
2494
 
2217
2495
  float volBayer8(vec2 p) {
2218
2496
  vec2 p1 = mod(floor(p), 2.0);
@@ -2270,6 +2548,13 @@ vec4 volUpsample(float centerDepth, ivec2 depthSize) {
2270
2548
  }
2271
2549
 
2272
2550
  void main(void) {
2551
+ // Nothing to draw this frame: the color of the scene passes through, exactly as it would under light shafts of
2552
+ // zero intensity.
2553
+ if (volPassParams.x > 0.5) {
2554
+ gl_FragColor = vec4(texture2D(volSceneSampler, vUV).rgb + (volBayer8(gl_FragCoord.xy) - 0.5) * volComposeParams.w, 1.0);
2555
+ return;
2556
+ }
2557
+
2273
2558
  // The linear depth has the full resolution of the canvas: same texel the depth map would give with a nearest filter.
2274
2559
  ivec2 depthSize = textureSize(volLinearDepthSampler, 0);
2275
2560
  float centerDepth = volReadLinearDepth(volLinearDepthSampler, min(ivec2(vUV * vec2(depthSize)), depthSize - 1));
@@ -2301,42 +2586,43 @@ void main(void) {
2301
2586
 
2302
2587
  gl_FragColor = vec4(result, 1.0);
2303
2588
  }
2304
- `}a(ca,"buildVolumetricLightingComposeShader");var Go={};function zo(t){if(!Go[t]){if(Go[t]=!0,t===Bo.ShaderLanguage.WGSL){let e=Fo();j.ShaderStore.ShadersStoreWGSL[`${nt}PixelShader`]=e.linearDepth,j.ShaderStore.ShadersStoreWGSL[`${at}PixelShader`]=e.scattering,j.ShaderStore.ShadersStoreWGSL[`${st}PixelShader`]=e.blur,j.ShaderStore.ShadersStoreWGSL[`${lt}PixelShader`]=e.compose;return}j.ShaderStore.ShadersStore[`${nt}PixelShader`]=aa(),j.ShaderStore.ShadersStore[`${at}PixelShader`]=sa(E),j.ShaderStore.ShadersStore[`${st}PixelShader`]=la(),j.ShaderStore.ShadersStore[`${lt}PixelShader`]=ca()}}a(zo,"registerVolumetricLightingShaders");var Uo=require("babylonjs"),Wo=require("babylonjs"),Z=require("babylonjs"),be=require("babylonjs"),Ve=require("babylonjs"),Xo=require("babylonjs"),xi=require("babylonjs"),Fe=require("babylonjs"),$o=require("babylonjs"),pa=new be.Vector3(0,0,1),ma=new be.Vector3(0,0,-1),Ho=["resolutionScale","blurPasses"],ha=32,da=["volInverseViewProjection","volViewProjection","volCameraPosition","volCameraForward","volCameraMinMaxZ","volDepthRatio","volFrameIndex","volFogInfos","volFogColor","volLinearFogEps","volMedium","volScreenShadowParams","volAmbient","volParams","volLightData","volLightDiffuse","volLightDirection","volLightFalloff","volShadowLightData","volShadowLightDiffuse","volShadowLightDirection","volShadowLightFalloff","volShadowInfo","volShadowMatrix","volCsmLightData","volCsmLightDiffuse","volCsmLightDirection","volCsmLightFalloff","volCsmInfo","volCsmMatrices"],ko=["volCsmSampler"];for(let t=0;t<E;++t)ko.push(`volShadowSampler${t}`);var Y=class t extends $o.PostProcessRenderPipeline{static{a(this,"VolumetricLightingRenderingPipeline")}static SceneColorEffectName="VolumetricLightingSceneColorEffect";static ScatteringEffectName="VolumetricLightingScatteringEffect";static BlurEffectName="VolumetricLightingBlurEffect";static ComposeEffectName="VolumetricLightingComposeEffect";static GetDefaultFogEnd(e,i){return 1/t.GetDefaultFogDensity(e,i)}static GetDefaultFogDensity(e,i){let o=0;if(e.meshes.length){let r=e.getWorldExtends(),n=r.max.subtract(r.min).length();isFinite(n)&&(o=n)}return o<.001&&(o=Math.max(i.globalPosition.length(),i.maxZ*.001,1)),Math.min(1,Math.max(1e-5,1/Math.max(.001,o)))}static IsSupported(e){return e.isWebGPU?!0:(e.webGLVersion??0)>=2}static GetShaderLanguage(e){return e.isWebGPU?xi.ShaderLanguage.WGSL:xi.ShaderLanguage.GLSL}_scene;_camera;_configuration;_configurationProxy;_textureType;_shaderLanguage;_ldrEncode;_linearDepthPacked;_msaaSamples=1;_msaaSamplesAssigned=!1;_depthSource=0;_depthRenderer=null;_ownsDepthRenderer=!1;_depthMode=0;_prePassConfiguration=gi();_linearDepthPostProcess=null;_scatteringPostProcess=null;_blurPostProcesses=[];_composePostProcess=null;_selection=null;_budget;_linearDepthDefines="";_scatteringDefines="";_blurDefines="";_composeDefines="";_frameCount=0;_lightsDirty=!0;_disposed=!1;_beforeCameraRenderObserver=null;_lightAddedObserver=null;_lightRemovedObserver=null;_inverseViewProjection=be.Matrix.Identity();_temporaryVector=new be.Vector3;_temporaryColor=new Wo.Color3;_lightData=new Float32Array($*4);_lightDiffuse=new Float32Array($*4);_lightDirection=new Float32Array($*4);_lightFalloff=new Float32Array($*4);_shadowLightData=new Float32Array(E*4);_shadowLightDiffuse=new Float32Array(E*4);_shadowLightDirection=new Float32Array(E*4);_shadowLightFalloff=new Float32Array(E*4);_shadowInfo=new Float32Array(E*4);_shadowMatrices=new Float32Array(E*16);_csmLightData=new Float32Array(4);_csmLightDiffuse=new Float32Array(4);_csmLightDirection=new Float32Array(4);_csmLightFalloff=new Float32Array(4);_csmMatrices=new Float32Array(64);constructor(e,i,o,r){super(i.getEngine(),e),this._shaderLanguage=t.GetShaderLanguage(i.getEngine()),zo(this._shaderLanguage),this._scene=i,this._camera=o,this._configuration=Se({...Qe(),fogDensity:r?.fogDensity??t.GetDefaultFogDensity(i,o),fogEnd:r?.fogEnd??t.GetDefaultFogEnd(i,o),screenSpaceShadowMaxDistance:r?.screenSpaceShadowMaxDistance??t.GetDefaultFogEnd(i,o),...r}),this._configurationProxy=new Proxy(this._configuration,{set:a((s,c,m)=>{let h=c;return s[h]===m||(s[h]=m,this._onConfigurationChanged(h)),!0},"set")});let n=i.getEngine(),l=n.getCaps(),p=l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering;this._textureType=p?Z.Constants.TEXTURETYPE_HALF_FLOAT:Z.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._ldrEncode=!p,this._linearDepthPacked=!l.textureFloatRender,this._budget=Ie(n,this._configuration),this._depthSource=it(i),this._setupDepthSource(),this._buildRenderEffects(),i.postProcessRenderPipelineManager.addPipeline(this),i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name,o),this._beforeCameraRenderObserver=i.onBeforeCameraRenderObservable.add(s=>{s===this._camera&&(this._updateDepthSource(),this._updateSelection())}),this._lightAddedObserver=i.onNewLightAddedObservable.add(()=>this.markLightsDirty()),this._lightRemovedObserver=i.onLightRemovedObservable.add(()=>this.markLightsDirty())}get isDisposed(){return this._disposed}get scene(){return this._scene}get camera(){return this._camera}get configuration(){return this._configurationProxy}get depthSource(){return this._depthSource}get msaaSamples(){return this._msaaSamples}set msaaSamples(e){this._msaaSamples=e,this._msaaSamplesAssigned=!0,this._applyMsaaSamples()}getStats(){return this._selection?.stats??null}getBudget(){return this._budget}getClassName(){return"VolumetricLightingRenderingPipeline"}markLightsDirty(){this._lightsDirty=!0}applyConfiguration(e){let i=Se({...this._configuration,...e}),o=Ho.some(r=>i[r]!==this._configuration[r]);Object.assign(this._configuration,i),this._budget=Ie(this._scene.getEngine(),this._configuration),this._lightsDirty=!0,o&&this._rebuildRenderEffects()}serializeConfiguration(){return{...this._configuration,fogColor:this._configuration.fogColor.slice(),ambientColor:this._configuration.ambientColor.slice()}}dispose(){if(this._disposed)return;this._disposed=!0,this._scene.onBeforeCameraRenderObservable.remove(this._beforeCameraRenderObserver),this._scene.onNewLightAddedObservable.remove(this._lightAddedObserver),this._scene.onLightRemovedObservable.remove(this._lightRemovedObserver),this._beforeCameraRenderObserver=null,this._lightAddedObserver=null,this._lightRemovedObserver=null;let e=this._cameras.slice();this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this.name,e),this._disposePostProcesses(e),this._releaseDepthSource(),this._selection=null,this._scene.postProcessRenderPipelineManager.removePipeline(this.name),super.dispose()}_onConfigurationChanged(e){(e==="maxLights"||e==="maxShadowedLights")&&(this._budget=Ie(this._scene.getEngine(),this._configuration)),this._lightsDirty=!0,Ho.includes(e)&&this._rebuildRenderEffects()}_setupDepthSource(){switch(this._depthSource){case 2:this._depthMode=1;break;case 1:this._ensureGeometryBufferDepth(),this._depthMode=1;break;default:this._setupDepthRenderer();break}this._applyPrePassConfiguration(),this._applyMsaaSamples()}_releaseDepthSource(){this._ownsDepthRenderer&&this._scene.disableDepthRenderer(this._camera),this._depthRenderer=null,this._ownsDepthRenderer=!1,this._linearDepthPostProcess&&(this._linearDepthPostProcess._prePassEffectConfiguration=void 0)}_updateDepthSource(){if(this._disposed)return;let e=it(this._scene);if(e===this._depthSource){e===1&&this._ensureGeometryBufferDepth();return}this._releaseDepthSource(),this._depthSource=e,this._setupDepthSource(),ye(this._scene)?.markAsDirty(),this._lightsDirty=!0}_ensureGeometryBufferDepth(){let e=Re(this._scene);e&&!e.enableDepth&&(e.enableDepth=!0)}_applyPrePassConfiguration(){this._linearDepthPostProcess&&this._depthSource===2&&(this._linearDepthPostProcess._prePassEffectConfiguration=this._prePassConfiguration)}_applyMsaaSamples(){if(this._msaaSamplesAssigned){if(this._depthSource===2){let e=ye(this._scene);if(e){e.samples=this._msaaSamples;return}}!this._enableMSAAOnFirstPostProcess(this._msaaSamples)&&this._msaaSamples>1&&console.warn("Volumetric lighting: MSAA is not supported by the engine, the requested samples are ignored.")}}_setupDepthRenderer(){let e=this._scene._depthRenderer?.[this._camera.uniqueId];this._ownsDepthRenderer=!e,this._depthRenderer=e??this._scene.enableDepthRenderer(this._camera,!1,!1,Z.Constants.TEXTURE_NEAREST_SAMPLINGMODE,!1),this._depthRenderer.isPacked?this._depthMode=2:this._depthRenderer.clearColor.r===0?this._depthMode=1:this._depthMode=0}_bindDepthUniforms(e){let i=this._camera,o=this._scene.getEngine();if(e.setFloat2("volCameraMinMaxZ",i.minZ,i.maxZ),this._depthMode===1){e.setFloat2("volDepthUnpack",1,0);return}let r=i.mode===Uo.Camera.ORTHOGRAPHIC_CAMERA,n=r?!o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?i.minZ:o.isNDCHalfZRange?0:i.minZ,l=r?o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:i.maxZ,p=this._scene.getProjectionMatrix().m,s=p[10],c=p[14];if(!s){e.setFloat2("volDepthUnpack",i.maxZ,0);return}let m=o.useReverseDepthBuffer?-1:1;e.setFloat2("volDepthUnpack",m*(n+l)/s,(-m*n-c)/s)}_getEnvironment(){let e=this._configuration,i=0;return e.heightFogEnabled&&(i=e.fogMode===0?1:2),{depthMode:this._depthMode,ldrEncode:this._ldrEncode,reverseDepth:this._scene.getEngine().useReverseDepthBuffer,ndcHalfZ:this._scene.getEngine().isNDCHalfZRange,fogMode:e.fogMode,transmittance:i,linearDepthPacked:this._linearDepthPacked,arrayLightCapacity:this._budget.maxArrayLights,lightSteps:si(e)}}_buildLinearDepthReadDefines(e){return e.linearDepthPacked?`#define VOL_LINEAR_DEPTH_PACKED
2305
- `:""}_buildLinearDepthDefines(e){let i=this._buildLinearDepthReadDefines(e);return e.depthMode===2?i+=`#define VOL_DEPTH_PACKED
2306
- `:e.depthMode===1&&(i+=`#define VOL_DEPTH_VIEWZ
2307
- `),i}_buildScatteringDefines(e,i){let o=this._configuration,r=e?.shadowed??[],n=e?.directionalCount??0,l=e?.csm??null,p=r.filter(c=>!c.shadow.local).length,s=this._buildLinearDepthReadDefines(i);return s+=`#define VOL_STEPS ${o.steps}
2308
- `,s+=`#define VOL_LIGHT_STEPS ${i.lightSteps}
2309
- `,s+=`#define VOL_LOCAL_MAX_STEPS ${Math.max(i.lightSteps,o.steps)}
2589
+ `}a(Sa,"buildVolumetricLightingComposeShader");var Ho={};function Uo(i){if(!Ho[i]){if(Ho[i]=!0,i===ko.ShaderLanguage.WGSL){let e=Bo();z.ShaderStore.ShadersStoreWGSL[`${ct}PixelShader`]=e.linearDepth,z.ShaderStore.ShadersStoreWGSL[`${pt}PixelShader`]=e.scattering,z.ShaderStore.ShadersStoreWGSL[`${ht}PixelShader`]=e.temporal,z.ShaderStore.ShadersStoreWGSL[`${mt}PixelShader`]=e.blur,z.ShaderStore.ShadersStoreWGSL[`${dt}PixelShader`]=e.compose;return}z.ShaderStore.ShadersStore[`${ct}PixelShader`]=ua(),z.ShaderStore.ShadersStore[`${pt}PixelShader`]=fa(O),z.ShaderStore.ShadersStore[`${ht}PixelShader`]=ga(),z.ShaderStore.ShadersStore[`${mt}PixelShader`]=va(),z.ShaderStore.ShadersStore[`${dt}PixelShader`]=Sa()}}a(Uo,"registerVolumetricLightingShaders");var Ko=require("babylonjs"),Zo=require("babylonjs"),E=require("babylonjs"),G=require("babylonjs"),_e=require("babylonjs"),Yo=require("babylonjs"),qo=require("babylonjs"),Li=require("babylonjs"),Ce=require("babylonjs"),Qo=require("babylonjs"),Wo=new G.Vector3(0,0,1),Xo=new G.Vector3(0,0,-1),ya=32,ba="volumetricLighting_",$o=["resolutionScale","blurPasses","temporalAccumulation"],xa=1,_a=.05,Ca=.6180339887498949,Da=32,La=["volInverseViewProjection","volViewProjection","volCameraPosition","volCameraForward","volCameraMinMaxZ","volDepthRatio","volFrameIndex","volTemporalOffset","volFogInfos","volFogColor","volLinearFogEps","volMedium","volScreenShadowParams","volAmbient","volParams","volPassParams","volLightData","volLightDiffuse","volLightDirection","volLightFalloff","volShadowLightData","volShadowLightDiffuse","volShadowLightDirection","volShadowLightFalloff","volShadowInfo","volShadowMatrix","volCsmLightData","volCsmLightDiffuse","volCsmLightDirection","volCsmLightFalloff","volCsmInfo","volCsmMatrices"],jo=["volCsmSampler"];for(let i=0;i<O;++i)jo.push(`volShadowSampler${i}`);var Pa=["volCameraMinMaxZ","volDepthRatio","volInverseViewProjection","volCameraPosition","volCameraForward","volPreviousViewProjection","volTemporalParams","volTemporalMotion"],q=class i extends Qo.PostProcessRenderPipeline{static{a(this,"VolumetricLightingRenderingPipeline")}static SceneColorEffectName="VolumetricLightingSceneColorEffect";static ScatteringEffectName="VolumetricLightingScatteringEffect";static TemporalEffectName="VolumetricLightingTemporalEffect";static BlurEffectName="VolumetricLightingBlurEffect";static ComposeEffectName="VolumetricLightingComposeEffect";static GetDefaultFogEnd(e,t){return 1/i.GetDefaultFogDensity(e,t)}static GetDefaultFogDensity(e,t){let o=0;if(e.meshes.length){let r=e.getWorldExtends(),n=r.max.subtract(r.min).length();isFinite(n)&&(o=n)}return o<.001&&(o=Math.max(t.globalPosition.length(),t.maxZ*.001,1)),Math.min(1,Math.max(1e-5,1/Math.max(.001,o)))}static IsSupported(e){return e.isWebGPU?!0:(e.webGLVersion??0)>=2}static GetShaderLanguage(e){return e.isWebGPU?Li.ShaderLanguage.WGSL:Li.ShaderLanguage.GLSL}_scene;_camera;_configuration;_configurationProxy;_textureType;_shaderLanguage;_ldrEncode;_linearDepthType;_linearDepthPacked;_msaaSamples=1;_msaaSamplesAssigned=!1;_depthSource=0;_depthRenderer=null;_ownsDepthRenderer=!1;_depthMapRenderedWithCamera=!1;_depthMode=0;_prePassConfiguration=_i();_linearDepthPostProcess=null;_scatteringPostProcess=null;_temporalPostProcess=null;_blurPostProcesses=[];_composePostProcess=null;_temporalSamplesDivider=tt;_temporalClippingWidth=xa;_temporalMotionTolerance=_a;_previousCameraPosition=new G.Vector3;_historyTextures=[null,null];_historyFrames=[-1,-1];_historyEmpty=[!1,!1];_historyIndex=0;_temporalFrame=0;_previousViewProjection=G.Matrix.Identity();_previousViewProjectionRelative=G.Matrix.Identity();_cameraTranslation=G.Matrix.Identity();_selection=null;_budget;_linearDepthDefines="";_scatteringDefines="";_temporalDefines="";_blurDefines="";_composeDefines="";_frameCount=0;_lightsDirty=!0;_disposed=!1;_idle=!1;_depthWarmup=new Set;_beforeCameraRenderObserver=null;_afterCameraRenderObserver=null;_lightAddedObserver=null;_lightRemovedObserver=null;_meshAddedObserver=null;_meshRemovedObserver=null;_inverseViewProjection=G.Matrix.Identity();_temporaryVector=new G.Vector3;_temporaryColor=new Zo.Color3;_lightData=new Float32Array(Z*4);_lightDiffuse=new Float32Array(Z*4);_lightDirection=new Float32Array(Z*4);_lightFalloff=new Float32Array(Z*4);_shadowLightData=new Float32Array(O*4);_shadowLightDiffuse=new Float32Array(O*4);_shadowLightDirection=new Float32Array(O*4);_shadowLightFalloff=new Float32Array(O*4);_shadowInfo=new Float32Array(O*4);_shadowMatrices=new Float32Array(O*16);_csmLightData=new Float32Array(4);_csmLightDiffuse=new Float32Array(4);_csmLightDirection=new Float32Array(4);_csmLightFalloff=new Float32Array(4);_csmMatrices=new Float32Array(64);constructor(e,t,o,r){super(t.getEngine(),e),this._shaderLanguage=i.GetShaderLanguage(t.getEngine()),Uo(this._shaderLanguage),this._scene=t,this._camera=o,this._configuration=be({...it(),fogDensity:r?.fogDensity??i.GetDefaultFogDensity(t,o),fogEnd:r?.fogEnd??i.GetDefaultFogEnd(t,o),screenSpaceShadowMaxDistance:r?.screenSpaceShadowMaxDistance??i.GetDefaultFogEnd(t,o),...r}),this._configurationProxy=new Proxy(this._configuration,{set:a((s,c,h)=>{let m=c;return s[m]===h||(s[m]=h,this._onConfigurationChanged(m)),!0},"set")});let n=t.getEngine(),l=n.getCaps(),p=l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering;this._textureType=p?E.Constants.TEXTURETYPE_HALF_FLOAT:E.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._ldrEncode=!p,this._linearDepthType=l.textureHalfFloatRender?E.Constants.TEXTURETYPE_HALF_FLOAT:l.textureFloatRender?E.Constants.TEXTURETYPE_FLOAT:E.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._linearDepthPacked=this._linearDepthType===E.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._budget=Ve(n,this._configuration),this._depthSource=at(t),this._setupDepthSource(),this._buildRenderEffects(),t.postProcessRenderPipelineManager.addPipeline(this),t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name,o),this._beforeCameraRenderObserver=t.onBeforeCameraRenderObservable.add(s=>{s===this._camera&&(this._updateDepthSource(),this._updateSelection(),this._warmUpDepthRenderer())}),this._afterCameraRenderObserver=t.onAfterCameraRenderObservable.add(s=>{s===this._camera&&this._setDepthMapRenderedWithCamera(!1)}),this._lightAddedObserver=t.onNewLightAddedObservable.add(()=>this.markLightsDirty()),this._lightRemovedObserver=t.onLightRemovedObservable.add(()=>this.markLightsDirty()),this._meshAddedObserver=t.onNewMeshAddedObservable.add(s=>{this._ownsDepthRenderer&&this._depthWarmup.add(s)}),this._meshRemovedObserver=t.onMeshRemovedObservable.add(s=>this._depthWarmup.delete(s))}get isDisposed(){return this._disposed}get scene(){return this._scene}get camera(){return this._camera}get configuration(){return this._configurationProxy}get isIdle(){return this._idle}get depthSource(){return this._depthSource}get msaaSamples(){return this._msaaSamples}set msaaSamples(e){this._msaaSamples=e,this._msaaSamplesAssigned=!0,this._applyMsaaSamples()}getStats(){return this._selection?.stats??null}getBudget(){return this._budget}getClassName(){return"VolumetricLightingRenderingPipeline"}markLightsDirty(){this._lightsDirty=!0}applyConfiguration(e){let t=be({...this._configuration,...e}),o=$o.some(r=>t[r]!==this._configuration[r]);Object.assign(this._configuration,t),this._budget=Ve(this._scene.getEngine(),this._configuration),this._lightsDirty=!0,o&&this._rebuildRenderEffects()}serializeConfiguration(){return{...this._configuration,fogColor:this._configuration.fogColor.slice(),ambientColor:this._configuration.ambientColor.slice()}}dispose(){if(this._disposed)return;this._disposed=!0,this._scene.onBeforeCameraRenderObservable.remove(this._beforeCameraRenderObserver),this._scene.onAfterCameraRenderObservable.remove(this._afterCameraRenderObserver),this._scene.onNewLightAddedObservable.remove(this._lightAddedObserver),this._scene.onLightRemovedObservable.remove(this._lightRemovedObserver),this._scene.onNewMeshAddedObservable.remove(this._meshAddedObserver),this._scene.onMeshRemovedObservable.remove(this._meshRemovedObserver),this._beforeCameraRenderObserver=null,this._afterCameraRenderObserver=null,this._lightAddedObserver=null,this._lightRemovedObserver=null,this._meshAddedObserver=null,this._meshRemovedObserver=null;let e=this._cameras.slice();this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this.name,e),this._disposePostProcesses(e),this._releaseDepthSource(),this._selection=null,this._scene.postProcessRenderPipelineManager.removePipeline(this.name),super.dispose()}_onConfigurationChanged(e){(e==="maxLights"||e==="maxShadowedLights")&&(this._budget=Ve(this._scene.getEngine(),this._configuration)),this._lightsDirty=!0,$o.includes(e)&&this._rebuildRenderEffects()}_setupDepthSource(){switch(this._depthSource){case 2:this._depthMode=1;break;case 1:this._ensureGeometryBufferDepth(),this._depthMode=1;break;default:this._setupDepthRenderer();break}this._applyPrePassConfiguration(),this._applyMsaaSamples()}_releaseDepthSource(){this._ownsDepthRenderer&&this._depthRenderer&&(this._setDepthMapRenderedWithCamera(!1),this._depthRenderer.dispose()),this._depthRenderer=null,this._ownsDepthRenderer=!1,this._depthWarmup.clear(),this._linearDepthPostProcess&&(this._linearDepthPostProcess._prePassEffectConfiguration=void 0)}_updateDepthSource(){if(this._disposed)return;let e=at(this._scene);if(e===this._depthSource){e===1&&this._ensureGeometryBufferDepth(),e===0&&this._hasDepthRendererOfCameraChanged()&&(this._releaseDepthSource(),this._setupDepthSource(),this._lightsDirty=!0);return}this._releaseDepthSource(),this._depthSource=e,this._setupDepthSource(),xe(this._scene)?.markAsDirty(),this._lightsDirty=!0}_ensureGeometryBufferDepth(){let e=Ne(this._scene);e&&!e.enableDepth&&(e.enableDepth=!0)}_applyPrePassConfiguration(){this._linearDepthPostProcess&&this._depthSource===2&&(this._linearDepthPostProcess._prePassEffectConfiguration=this._prePassConfiguration)}_applyMsaaSamples(){if(this._msaaSamplesAssigned){if(this._depthSource===2){let e=xe(this._scene);if(e){e.samples=this._msaaSamples;return}}!this._enableMSAAOnFirstPostProcess(this._msaaSamples)&&this._msaaSamples>1&&console.warn("Volumetric lighting: MSAA is not supported by the engine, the requested samples are ignored.")}}_setupDepthRenderer(){let e=this._scene,t=e._depthRenderer?.[this._camera.uniqueId];if(this._ownsDepthRenderer=!t,t)this._depthRenderer=t;else{let o=this._scene.getEngine().getCaps(),r=o.textureHalfFloatRender?E.Constants.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender?E.Constants.TEXTURETYPE_FLOAT:E.Constants.TEXTURETYPE_UNSIGNED_BYTE;this._depthRenderer=new Yo.DepthRenderer(this._scene,r,this._camera,!1,E.Constants.TEXTURE_NEAREST_SAMPLINGMODE,!1,"VolumetricLightingDepth"),this._depthRenderer.enabled=!this._idle,e._depthRenderer??={},e._depthRenderer[`${ba}${this._scene.getUniqueId()}`]=this._depthRenderer,this._scene.meshes.forEach(n=>this._depthWarmup.add(n))}this._depthRenderer.isPacked?this._depthMode=2:this._depthRenderer.clearColor.r===0?this._depthMode=1:this._depthMode=0}_hasDepthRendererOfCameraChanged(){let e=this._scene._depthRenderer?.[this._camera.uniqueId];return this._ownsDepthRenderer?!!e:e!==this._depthRenderer}_setDepthMapRenderedWithCamera(e){if(e===this._depthMapRenderedWithCamera||!this._depthRenderer)return;this._depthMapRenderedWithCamera=e;let t=this._camera.customRenderTargets,o=this._depthRenderer.getDepthMap(),r=t.indexOf(o);e&&r===-1?t.push(o):!e&&r!==-1&&t.splice(r,1)}_bindDepthUniforms(e){let t=this._camera,o=this._scene.getEngine();if(e.setFloat2("volCameraMinMaxZ",t.minZ,t.maxZ),this._depthMode===1){e.setFloat2("volDepthUnpack",1,0);return}let r=t.mode===Ko.Camera.ORTHOGRAPHIC_CAMERA,n=r?!o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?t.minZ:o.isNDCHalfZRange?0:t.minZ,l=r?o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:t.maxZ,p=this._scene.getProjectionMatrix().m,s=p[10],c=p[14];if(!s){e.setFloat2("volDepthUnpack",t.maxZ,0);return}let h=o.useReverseDepthBuffer?-1:1;e.setFloat2("volDepthUnpack",h*(n+l)/s,(-h*n-c)/s)}_getSamplingSteps(){return di(this._configuration,this._temporalSamplesDivider)}_getDitherMode(){let e=this._configuration;return e.temporalAccumulation&&e.ditherMode===0?2:e.ditherMode}_getEnvironment(){let e=this._configuration,t=this._getSamplingSteps(),o=0;return e.heightFogEnabled&&(o=e.fogMode===0?1:2),{depthMode:this._depthMode,ldrEncode:this._ldrEncode,reverseDepth:this._scene.getEngine().useReverseDepthBuffer,ndcHalfZ:this._scene.getEngine().isNDCHalfZRange,fogMode:e.fogMode,transmittance:o,linearDepthPacked:this._linearDepthPacked,arrayLightCapacity:this._budget.maxArrayLights,steps:t.steps,lightSteps:t.lightSteps}}_buildLinearDepthReadDefines(e){return e.linearDepthPacked?`#define VOL_LINEAR_DEPTH_PACKED
2590
+ `:""}_buildLinearDepthDefines(e){let t=this._buildLinearDepthReadDefines(e);return e.depthMode===2?t+=`#define VOL_DEPTH_PACKED
2591
+ `:e.depthMode===1&&(t+=`#define VOL_DEPTH_VIEWZ
2592
+ `),t}_buildScatteringDefines(e,t){let o=this._configuration,r=e?.shadowed??[],n=e?.directionalCount??0,l=e?.csm??null,p=r.filter(c=>!c.shadow.local).length,s=this._buildLinearDepthReadDefines(t);return s+=`#define VOL_STEPS ${t.steps}
2593
+ `,s+=`#define VOL_LIGHT_STEPS ${t.lightSteps}
2594
+ `,s+=`#define VOL_LOCAL_MAX_STEPS ${Math.max(t.lightSteps,t.steps)}
2310
2595
  `,s+=`#define VOL_DISTRIBUTION ${o.stepDistribution}
2311
- `,s+=`#define VOL_DITHER ${o.ditherMode}
2596
+ `,s+=`#define VOL_DITHER ${this._getDitherMode()}
2312
2597
  `,s+=`#define VOL_PCF_TAPS ${o.pcfTaps}
2313
- `,s+=`#define VOL_FOG_MODE ${i.fogMode}
2314
- `,s+=`#define VOL_TRANSMITTANCE ${i.transmittance}
2315
- `,(i.transmittance!==0||i.fogMode!==2)&&(s+=`#define VOL_OPTICAL_DEPTH
2316
- `),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${ha}
2598
+ `,s+=`#define VOL_FOG_MODE ${t.fogMode}
2599
+ `,s+=`#define VOL_TRANSMITTANCE ${t.transmittance}
2600
+ `,(t.transmittance!==0||t.fogMode!==2)&&(s+=`#define VOL_OPTICAL_DEPTH
2601
+ `),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${Da}
2317
2602
  `,s+=`#define VOL_DEBUG ${o.debugMode}
2318
- `,s+=`#define VOL_MAX_ARRAY_LIGHTS ${i.arrayLightCapacity}
2603
+ `,s+=`#define VOL_MAX_ARRAY_LIGHTS ${t.arrayLightCapacity}
2319
2604
  `,s+=`#define VOL_DIRECTIONAL_LIGHT_COUNT ${n}
2320
- `,s+=`#define VOL_LOCAL_ARRAY_LIGHTS ${i.arrayLightCapacity>n?1:0}
2605
+ `,s+=`#define VOL_LOCAL_ARRAY_LIGHTS ${t.arrayLightCapacity>n?1:0}
2321
2606
  `,s+=`#define VOL_SHADOW_SLOT_COUNT ${r.length}
2322
2607
  `,s+=`#define VOL_GLOBAL_LIGHT_COUNT ${n+p+(l?1:0)}
2323
- `,o.ditherMode!==0&&o.temporalJitter&&(s+=`#define VOL_TEMPORAL_JITTER
2608
+ `,o.temporalAccumulation?s+=`#define VOL_TEMPORAL_ACCUMULATION
2609
+ `:o.ditherMode!==0&&o.temporalJitter&&(s+=`#define VOL_TEMPORAL_JITTER
2324
2610
  `),o.heightFogEnabled&&(s+=`#define VOL_HEIGHT_FOG
2325
2611
  `),o.lightExtinctionEnabled&&(s+=`#define VOL_LIGHT_EXTINCTION
2326
2612
  `),o.screenSpaceShadows&&(s+=`#define VOL_SCREEN_SHADOWS
2327
2613
  `,s+=`#define VOL_SCREEN_SHADOW_STEPS ${o.screenSpaceShadowSteps}
2328
- `),i.ldrEncode&&(s+=`#define VOL_LDR_ENCODE
2329
- `),i.reverseDepth&&(s+=`#define VOL_REVERSE_DEPTH
2330
- `),i.ndcHalfZ&&(s+=`#define VOL_NDC_HALF_Z
2331
- `),r.forEach((c,m)=>{s+=`#define VOL_SHADOW_KIND${m} ${c.shadow.kind}
2332
- `,s+=`#define VOL_SHADOW_MODE${m} ${c.shadow.mode}
2333
- `,s+=`#define VOL_SHADOW_LOCAL${m} ${c.shadow.local?1:0}
2334
- `,c.shadow.packed&&(s+=`#define VOL_SHADOW_PACKED${m}
2614
+ `),t.ldrEncode&&(s+=`#define VOL_LDR_ENCODE
2615
+ `),t.reverseDepth&&(s+=`#define VOL_REVERSE_DEPTH
2616
+ `),t.ndcHalfZ&&(s+=`#define VOL_NDC_HALF_Z
2617
+ `),r.forEach((c,h)=>{s+=`#define VOL_SHADOW_KIND${h} ${c.shadow.kind}
2618
+ `,s+=`#define VOL_SHADOW_MODE${h} ${c.shadow.mode}
2619
+ `,s+=`#define VOL_SHADOW_LOCAL${h} ${c.shadow.local?1:0}
2620
+ `,c.shadow.packed&&(s+=`#define VOL_SHADOW_PACKED${h}
2335
2621
  `)}),l&&(s+=`#define VOL_CSM
2336
2622
  `,s+=`#define VOL_CSM_CASCADES ${l.cascades}
2337
2623
  `,s+=`#define VOL_CSM_KIND ${l.kind===1?1:0}
2338
2624
  `,l.packed&&(s+=`#define VOL_CSM_PACKED
2339
- `)),s}_buildBlurDefines(e){return`${this._buildLinearDepthReadDefines(e)}#define VOL_BLUR_RADIUS ${this._configuration.blurRadius}
2340
- `}_buildComposeDefines(e){let i=this._buildLinearDepthReadDefines(e);return i+=`#define VOL_DEBUG ${this._configuration.debugMode}
2341
- `,e.ldrEncode&&(i+=`#define VOL_LDR_ENCODE
2342
- `),i}_createPostProcess(e){let i=new Xo.PostProcess(e.name,e.shaderName,e.uniforms,e.samplers,e.ratio,null,e.samplingMode,this._scene.getEngine(),!1,e.defines,e.textureType,void 0,void 0,!1,e.textureFormat,this._shaderLanguage);return i.autoClear=!1,i.alphaMode=Z.Constants.ALPHA_DISABLE,i}_buildRenderEffects(){let e=this._scene.getEngine(),i=this._configuration,o=this._getEnvironment();this._linearDepthDefines=this._buildLinearDepthDefines(o),this._scatteringDefines=this._buildScatteringDefines(this._selection,o),this._blurDefines=this._buildBlurDefines(o),this._composeDefines=this._buildComposeDefines(o),this._linearDepthPostProcess=this._createPostProcess({name:"VolumetricLightingLinearDepth",shaderName:nt,uniforms:["volCameraMinMaxZ","volDepthUnpack"],samplers:["depthSampler"],ratio:1,samplingMode:Ve.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._linearDepthDefines}),this._linearDepthPostProcess.onApplyObservable.add(r=>this._bindLinearDepth(r)),this._applyPrePassConfiguration(),this._scatteringPostProcess=this._createPostProcess({name:"VolumetricLightingScattering",shaderName:at,uniforms:da,samplers:ko,ratio:1,samplingMode:Ve.Texture.NEAREST_SAMPLINGMODE,textureType:this._linearDepthPacked?Z.Constants.TEXTURETYPE_UNSIGNED_BYTE:Z.Constants.TEXTURETYPE_FLOAT,textureFormat:this._linearDepthPacked?Z.Constants.TEXTUREFORMAT_RGBA:Z.Constants.TEXTUREFORMAT_R,defines:this._scatteringDefines}),this._scatteringPostProcess.onApplyObservable.add(r=>this._bindScattering(r)),this._blurPostProcesses=[];for(let r=0;r<i.blurPasses;++r){let n=this._createPostProcess({name:`VolumetricLightingBlur${r}`,shaderName:st,uniforms:["volCameraMinMaxZ","volDepthRatio","volBlurDirection","volBlurParams"],samplers:["volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Ve.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._blurDefines});n.onApplyObservable.add(l=>this._bindBlur(l,r)),this._blurPostProcesses.push(n)}this._composePostProcess=this._createPostProcess({name:"VolumetricLightingCompose",shaderName:lt,uniforms:["volCameraMinMaxZ","volDepthRatio","volComposeParams"],samplers:["volSceneSampler","volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Ve.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._composeDefines}),this._composePostProcess.onApplyObservable.add(r=>this._bindCompose(r)),this.addEffect(new Fe.PostProcessRenderEffect(e,t.SceneColorEffectName,()=>this._linearDepthPostProcess,!0)),this.addEffect(new Fe.PostProcessRenderEffect(e,t.ScatteringEffectName,()=>this._scatteringPostProcess,!0)),this._blurPostProcesses.length&&this.addEffect(new Fe.PostProcessRenderEffect(e,t.BlurEffectName,()=>this._blurPostProcesses,!0)),this.addEffect(new Fe.PostProcessRenderEffect(e,t.ComposeEffectName,()=>this._composePostProcess,!0)),this._applyMsaaSamples()}_disposePostProcesses(e){[this._linearDepthPostProcess,this._scatteringPostProcess,...this._blurPostProcesses,this._composePostProcess].forEach(o=>{o&&(e.forEach(r=>o.dispose(r)),o.dispose())}),this._linearDepthPostProcess=null,this._scatteringPostProcess=null,this._blurPostProcesses=[],this._composePostProcess=null}_rebuildRenderEffects(){if(this._disposed)return;let e=this._scene.postProcessRenderPipelineManager,i=this._cameras.slice();try{e.detachCamerasFromRenderPipeline(this.name,i),this._disposePostProcesses(i),Object.keys(this._renderEffects).forEach(o=>{delete this._renderEffects[o]}),this._buildRenderEffects()}catch(o){console.error("Failed to rebuild the volumetric lighting rendering pipeline.",o)}finally{try{e.attachCamerasToRenderPipeline(this.name,i)}catch(o){console.error("Failed to re-attach the cameras to the volumetric lighting rendering pipeline.",o)}}this._lightsDirty=!0}_updateSelection(){if(this._disposed||!this._scatteringPostProcess||(++this._frameCount,!(this._lightsDirty||!this._selection||this._frameCount%this._configuration.selectionRefreshRate===0)))return;this._lightsDirty=!1;let i=this._getEnvironment(),o=di(this._scene,this._camera,this._configuration,this._budget,this._selection);this._selection=o;let r=this._buildScatteringDefines(o,i);r!==this._scatteringDefines&&(this._scatteringDefines=r,this._scatteringPostProcess.updateEffect(r));let n=this._buildLinearDepthDefines(i);n!==this._linearDepthDefines&&(this._linearDepthDefines=n,this._linearDepthPostProcess?.updateEffect(n));let l=this._buildBlurDefines(i);l!==this._blurDefines&&(this._blurDefines=l,this._blurPostProcesses.forEach(s=>s.updateEffect(l)));let p=this._buildComposeDefines(i);p!==this._composeDefines&&(this._composeDefines=p,this._composePostProcess?.updateEffect(p))}_writeLight(e,i,o,r,n,l){let{light:p,config:s}=e,c=i*4;te(p)?(Me(p,this._temporaryVector),o[c]=-this._temporaryVector.x,o[c+1]=-this._temporaryVector.y,o[c+2]=-this._temporaryVector.z,o[c+3]=1):(et(p,this._temporaryVector).subtractInPlace(this._camera.globalPosition),o[c]=this._temporaryVector.x,o[c+1]=this._temporaryVector.y,o[c+2]=this._temporaryVector.z,o[c+3]=re(p)?2:0),s.useCustomColor?this._temporaryColor.set(s.color[0],s.color[1],s.color[2]):this._temporaryColor.copyFrom(p.diffuse);let m=p.getScaledIntensity()*s.volumeIntensity*1e-5;r[c]=this._temporaryColor.r*m,r[c+1]=this._temporaryColor.g*m,r[c+2]=this._temporaryColor.b*m,r[c+3]=s.anisotropy,re(p)?(Me(p,this._temporaryVector),n[c]=this._temporaryVector.x,n[c+1]=this._temporaryVector.y,n[c+2]=this._temporaryVector.z,n[c+3]=Math.cos(p.angle*.5),l[c+1]=p.exponent):(n[c]=0,n[c+1]=0,n[c+2]=1,n[c+3]=-1,l[c+1]=1),l[c]=tt(p,s,this._configuration),l[c+2]=s.castVolumetricShadows?1:0,l[c+3]=s.shadowDarkness}_bindLinearDepth(e){let i=null;switch(this._depthSource){case 2:{let o=ye(this._scene);i=o?vi(o):null;break}case 1:{let o=Re(this._scene);i=o?Si(o):null;break}default:i=this._depthRenderer?.getDepthMap()??null;break}i&&(e.setTexture("depthSampler",i),this._bindDepthUniforms(e))}_bindScattering(e){let i=this._scene,o=this._camera,r=this._configuration,n=this._selection;if(!n)return;this._inverseViewProjection.copyFrom(i.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",o.globalPosition),o.getDirectionToRef(i.useRightHandedSystem?ma:pa,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize()),e.setFloat2("volCameraMinMaxZ",o.minZ,o.maxZ),e.setFloat("volFrameIndex",i.getRenderId()%64),this._bindDepthRatio(e),e.setFloat4("volFogInfos",r.fogMode,r.fogStart,r.fogEnd,r.fogDensity),this._temporaryColor.set(r.fogColor[0],r.fogColor[1],r.fogColor[2]),e.setColor3("volFogColor",this._temporaryColor),e.setFloat("volLinearFogEps",Math.max((r.fogEnd-r.fogStart)*.02,1e-4)),e.setFloat4("volMedium",r.albedo,r.heightFogBaseHeight,r.heightFogFalloff,0),r.screenSpaceShadows&&(e.setMatrix("volViewProjection",i.getTransformMatrix()),e.setFloat4("volScreenShadowParams",r.screenSpaceShadowMaxDistance,r.screenSpaceShadowBias,r.screenSpaceShadowThickness,0)),this._temporaryColor.set(r.ambientColor[0],r.ambientColor[1],r.ambientColor[2]).scaleInPlace(r.ambientIntensity),e.setColor3("volAmbient",this._temporaryColor);let l=n.unshadowed.length,p=l-n.directionalCount;e.setFloat4("volParams",r.maxDistance,r.ditherStrength,r.lightExtinctionClamp,p);for(let s=0;s<l;++s)this._writeLight(n.unshadowed[s],s,this._lightData,this._lightDiffuse,this._lightDirection,this._lightFalloff);if(l){let s=l*4;e.setFloatArray4("volLightData",this._lightData.subarray(0,s)),e.setFloatArray4("volLightDiffuse",this._lightDiffuse.subarray(0,s)),e.setFloatArray4("volLightDirection",this._lightDirection.subarray(0,s)),e.setFloatArray4("volLightFalloff",this._lightFalloff.subarray(0,s))}if(n.shadowed.forEach((s,c)=>{this._writeLight(s.candidate,c,this._shadowLightData,this._shadowLightDiffuse,this._shadowLightDirection,this._shadowLightFalloff);let{generator:m,kind:h,mode:d,mapSize:f}=s.shadow,S=s.candidate.light,u=c*4;this._shadowLightFalloff[u+2]=m.frustumEdgeFalloff;let y=S.getDepthMinZ?.(i.activeCamera)??0,L=S.getDepthMaxZ?.(i.activeCamera)??1;this._shadowInfo[u]=m.getDarkness(),this._shadowInfo[u+1]=h===1?1/f:d===0?0:m.depthScale,this._shadowInfo[u+2]=y,this._shadowInfo[u+3]=y+L,m.getTransformMatrix().copyToArray(this._shadowMatrices,c*16);let _=m.getShadowMapForRendering();h===1?e.setDepthStencilTexture(`volShadowSampler${c}`,_):e.setTexture(`volShadowSampler${c}`,_)}),n.shadowed.length){let s=n.shadowed.length*4;e.setFloatArray4("volShadowLightData",this._shadowLightData.subarray(0,s)),e.setFloatArray4("volShadowLightDiffuse",this._shadowLightDiffuse.subarray(0,s)),e.setFloatArray4("volShadowLightDirection",this._shadowLightDirection.subarray(0,s)),e.setFloatArray4("volShadowLightFalloff",this._shadowLightFalloff.subarray(0,s)),e.setFloatArray4("volShadowInfo",this._shadowInfo.subarray(0,s)),e.setMatrices("volShadowMatrix",this._shadowMatrices.subarray(0,n.shadowed.length*16))}if(n.csm){let{candidate:s,generator:c,cascades:m,kind:h}=n.csm,d=s.light;this._writeLight(s,0,this._csmLightData,this._csmLightDiffuse,this._csmLightDirection,this._csmLightFalloff),e.setFloat4("volCsmLightData",this._csmLightData[0],this._csmLightData[1],this._csmLightData[2],this._csmLightData[3]),e.setFloat4("volCsmLightDiffuse",this._csmLightDiffuse[0],this._csmLightDiffuse[1],this._csmLightDiffuse[2],this._csmLightDiffuse[3]),e.setFloat4("volCsmLightDirection",this._csmLightDirection[0],this._csmLightDirection[1],this._csmLightDirection[2],this._csmLightDirection[3]),e.setFloat4("volCsmLightFalloff",this._csmLightFalloff[0],this._csmLightFalloff[1],c.frustumEdgeFalloff,s.config.shadowDarkness);let f=d.getDepthMinZ?.(i.activeCamera)??1,S=d.getDepthMaxZ?.(i.activeCamera)??1,u=c.getShadowMap()?.getSize().width??1024;e.setFloat4("volCsmInfo",c.getDarkness(),1/u,f,f+S);for(let L=0;L<m;++L)c.getCascadeTransformMatrix(L)?.copyToArray(this._csmMatrices,L*16);e.setMatrices("volCsmMatrices",this._csmMatrices.subarray(0,m*16));let y=c.getShadowMapForRendering();h===1?e.setDepthStencilTexture("volCsmSampler",y):e.setTexture("volCsmSampler",y)}}_bindDepthRatio(e){let i=this._scatteringPostProcess,o=this._blurPostProcesses[0]??this._composePostProcess,r=i&&i.width>0?i.width:1,n=i&&i.height>0?i.height:1,l=o&&o.width>0?o.width:r,p=o&&o.height>0?o.height:n;e.setFloat2("volDepthRatio",r/l,n/p)}_bindBlur(e,i){this._scatteringPostProcess&&(e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e),e.setFloat2("volBlurDirection",i%2===0?1:0,i%2===0?0:1),e.setFloat2("volBlurParams",Math.max(this._configuration.blurRadius*.5,.5),this._configuration.blurDepthThreshold))}_bindCompose(e){if(!this._linearDepthPostProcess||!this._scatteringPostProcess)return;let i=this._configuration;e.setTextureFromPostProcess("volSceneSampler",this._linearDepthPostProcess),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e);let o=this._ldrEncode?1/255:0;e.setFloat4("volComposeParams",i.intensity,i.extinctionAmount,i.upsampleDepthThreshold,o)}};var I=null,Ko=null;function Ci(){return Ko}a(Ci,"getVolumetricLightingRenderingPipelineConfiguration");function Ne(t){Ko=t}a(Ne,"setVolumetricLightingRenderingPipelineConfiguration");function fa(){return I?.isDisposed&&(I=null),I}a(fa,"getVolumetricLightingRenderingPipeline");function ua(t){I=t}a(ua,"setVolumetricLightingRenderingPipelineRef");function ga(t){let e=t?.getEngine();return e?Y.IsSupported(e):!1}a(ga,"isVolumetricLightingSupported");function Li(){I&&(I.dispose(),I=null)}a(Li,"disposeVolumetricLightingRenderingPipeline");function jo(t,e,i){return I=new Y("VolumetricLightingRenderingPipeline",t,e),I.msaaSamples=i?.msaaSamples??1,I}a(jo,"createVolumetricLightingRenderingPipeline");function Di(){return I?I.serializeConfiguration():null}a(Di,"serializeVolumetricLightingRenderingPipeline");function _i(t,e,i,o){let r=I??jo(t,e,o);r.msaaSamples=o?.msaaSamples??1;let n={...i};return n.fogDensity===void 0&&(n.fogDensity=Y.GetDefaultFogDensity(r.scene,r.camera)),n.fogEnd===void 0&&(n.fogEnd=Y.GetDefaultFogEnd(r.scene,r.camera)),n.screenSpaceShadowMaxDistance===void 0&&(n.screenSpaceShadowMaxDistance=Y.GetDefaultFogEnd(r.scene,r.camera)),r.applyConfiguration(Se(n)),r}a(_i,"parseVolumetricLightingRenderingPipeline");function va(){I?.markLightsDirty()}a(va,"markVolumetricLightsDirty");var ct=require("babylonjs");function Sa(t){ue.set(t,Xt()),he.set(t,Ft()),de.set(t,Bt()),ge.set(t,Zt()),ve.set(t,Jt()),fe.set(t,kt()),Ne(Di())}a(Sa,"saveRenderingConfigurationForCamera");function Pi(t,e,i){Wt(),Vt(t.getScene()),Gt(),jt(),Li(),Qt(),Ht();let o=ue.get(t);o&&!i?.ssao2Disabled&&$t(t.getScene(),t,o,i);let r=Ci();r&&!i?.volumetricLightingDisabled&&_i(t.getScene(),t,r,i);let n=he.get(t);n&&!i?.vlsDisabled&&Nt(t.getScene(),n,i);let l=de.get(t);l&&!i?.ssrDisabled&&zt(t.getScene(),t,l,i);let p=ge.get(t);p&&!i?.motionBlurDisabled&&Yt(t.getScene(),t,p,i);let s=ve.get(t);s&&!i?.defaultPipelineDisabled&&ei(t.getScene(),t,s,e,i);let c=fe.get(t);c&&!i?.taaDisabled&&Ut(t.getScene(),t,c,i)}a(Pi,"applyRenderingConfigurationForCamera");function ya(t){let e=t.getCaps();return e.textureHalfFloatRender||e.textureFloatRender}a(ya,"canUseHdr");function X(t){let e=t.getCaps();return e.textureHalfFloatRender?ct.Constants.TEXTURETYPE_HALF_FLOAT:e.textureFloatRender?ct.Constants.TEXTURETYPE_FLOAT:ct.Constants.TEXTURETYPE_UNSIGNED_BYTE}a(X,"getHdrTextureType");var Ge=require("babylonjs"),Zo=require("babylonjs");function Yo(t){let e=t.metadata?.physicsAggregate;if(!e)return;let i;V(t)?i=t:Ee(t)&&(i=t.sourceMesh);let o=new Zo.PhysicsAggregate(t,e.shape.type,{mesh:i,mass:e.massProperties.mass});o.body.setMassProperties({mass:e.massProperties.mass,inertia:e.massProperties.inertia?Ge.Vector3.FromArray(e.massProperties.inertia):void 0,centerOfMass:e.massProperties.centerOfMass?Ge.Vector3.FromArray(e.massProperties.centerOfMass):void 0,inertiaOrientation:e.massProperties.inertiaOrientation?Ge.Quaternion.FromArray(e.massProperties.inertiaOrientation):void 0}),o.shape.density=e.shape.density,o.body.setMotionType(e.body.motionType),o.shape.material=e.material,t.physicsAggregate=o,t.metadata.physicsAggregate=void 0}a(Yo,"configurePhysicsAggregate");function qo(t,e){let i=e?.rendering;e.volumetricLightingRenderingPipelineConfiguration&&Ne(e.volumetricLightingRenderingPipelineConfiguration),(Array.isArray(i)?i:[]).forEach(r=>{let n=t.getCameraById(r.cameraId);n&&(r.ssao2RenderingPipeline&&ue.set(n,r.ssao2RenderingPipeline),r.vlsPostProcess&&he.set(n,r.vlsPostProcess),r.ssrRenderingPipeline&&de.set(n,r.ssrRenderingPipeline),r.motionBlurPostProcess&&ge.set(n,r.motionBlurPostProcess),r.defaultRenderingPipeline&&ve.set(n,r.defaultRenderingPipeline),r.taaRenderingPipeline&&fe.set(n,r.taaRenderingPipeline))})}a(qo,"applyRenderingConfigurations");var Qo=require("babylonjs");function xe(t,e,i){return new Promise((o,r)=>{let n=new Qo.WebRequest;n.open("GET",t),n.responseType=e,n.send(),n.addEventListener("progress",l=>{i?.({total:l.total,loaded:l.loaded})}),n.addEventListener("load",()=>{o(e==="text"?n.responseText:n.response)}),n.addEventListener("error",l=>r(l))})}a(xe,"loadFile");async function B(t,e){let i=await xe(t,"text",e);return JSON.parse(i)}a(B,"loadJsonFile");function wi(t,e){let i=e.getNodeByName(t);if(i)return i;let o=e.lights.filter(r=>pe(r));for(let r of o){let n=r.lights.find(l=>l.name===t);if(n)return n}return null}a(wi,"getNodeByName");function Ce(t,e){let i=e.getNodeById(t);if(i)return i;let o=e.lights.filter(r=>pe(r));for(let r of o){let n=r.lights.find(l=>l.id===t);if(n)return n}return null}a(Ce,"getNodeById");var se=require("babylonjs"),Jo=require("babylonjs");function Oi(t){let e=Jo.Vector3.FromArray(t);return e.equals(se.Axis.X)?se.Axis.X:e.equals(se.Axis.Y)?se.Axis.Y:e.equals(se.Axis.Z)?se.Axis.Z:e}a(Oi,"parseAxis");var er=require("babylonjs"),q=require("babylonjs");function tr(t){return t.runtimeConfiguration.forEach(e=>{e.rotationAxis&&(e.rotationAxis=Oi(e.rotationAxis)),e.boneOffsetAxis&&(e.boneOffsetAxis=Oi(e.boneOffsetAxis))}),t}a(tr,"parseRagdollConfiguration");function Ei(t){let e={rootNodeId:t.rootNodeId,skeletonName:t.skeletonName,scalingFactor:t.scalingFactor,runtimeConfiguration:t.runtimeConfiguration.map(i=>({name:i.name,bones:i.bones,width:i.width,depth:i.depth,height:i.height,size:i.size,joint:i.joint,min:i.min,max:i.max,mass:i.mass??1,boxOffset:i.boxOffset,restitution:i.restitution??0,rotationAxis:i.rotationAxis?.slice(),boneOffsetAxis:i.boneOffsetAxis?.slice()}))};return tr(e)}a(Ei,"copyAndParseRagdollConfiguration");function ba(t,e){let i=t.getConstraints(),r=t._skeleton?.getChildren()[0],n=[];if(e.forEach(p=>{(p.bone!==void 0?[p.bone]:p.bones).forEach(c=>{c!==r?.name&&n.push(p)})}),n.length!==i.length)return er.Logger.Warn("Failed to apply the ragdoll joint limits: the constraints of the ragdoll don't match its configuration."),0;let l=0;return i.forEach((p,s)=>{let c=n[s];if((c.joint??q.PhysicsConstraintType.HINGE)!==q.PhysicsConstraintType.HINGE||c.min===void 0||c.max===void 0)return;let h=Math.min(c.min,c.max),d=Math.max(c.min,c.max),f=p._physicsPlugin;f&&(f.setAxisMode(p,q.PhysicsConstraintAxis.ANGULAR_X,q.PhysicsConstraintAxisLimitMode.LIMITED),f.setAxisMinLimit(p,q.PhysicsConstraintAxis.ANGULAR_X,h*Math.PI/180),f.setAxisMaxLimit(p,q.PhysicsConstraintAxis.ANGULAR_X,d*Math.PI/180),++l)}),l}a(ba,"applyRagdollJointLimits");function xa(t){return new Promise(e=>{setTimeout(()=>e(),t)})}a(xa,"waitMs");async function Ai(t){for(;!t();)await xa(150)}a(Ai,"waitUntil");function Ti(t){return t&&JSON.parse(JSON.stringify(t))}a(Ti,"cloneJSObject");var Mi=require("babylonjs"),lr=require("babylonjs"),pt=require("babylonjs"),cr=require("babylonjs"),pr=require("babylonjs"),mr=require("babylonjs"),ie=require("babylonjs"),ir=!1,or=null,Le=[],Ii=new Map;function Ca(t,e){let i=(0,ie._GetAudioEngine)(null);return new mr._WebAudioStaticSound(t,i,e)}a(Ca,"createSoundInstance");function rr(t){if(or?.remove(),!Le.length)return;let e=Mi.Vector3.Zero();or=t.onBeforeRenderObservable.add(()=>{let i=(0,ie._GetAudioEngine)(null).listener.attachedNode;i&&(i.getWorldMatrix().getTranslationToRef(e),Le.forEach(o=>{o.isEnabled(!1)&&o.autoUpdateSpatial&&o.sound?._isSpatial&&o.isPlaying()&&t.activeCamera&&Mi.Vector3.Distance(e,o.getAbsolutePosition())<=o.sound.spatial.maxDistance&&o.sound.spatial.update()}))})}a(rr,"registerUpdateSoundsObserver");function nr(t,e){e.onDisposeObservable.addOnce(()=>{let i=Le.indexOf(t);i!==-1&&Le.splice(i,1)})}a(nr,"registerSoundInstanceCleanup");function ar(t){t.sound&&nr(t,t.sound),t.onDisposeObservable.addOnce(()=>{t.sound?.dispose()})}a(ar,"registerSoundNodeEvents");function La(t,e){return new Promise(async(i,o)=>{if(!t.offlineProvider||!lr.Database.IDBStorageEnabled)return(0,ie.CreateSoundBufferAsync)(e).then(r=>i(r)).catch(r=>o(r));t.offlineProvider.loadFile(e,r=>{(0,ie.CreateSoundBufferAsync)(r).then(n=>i(n)).catch(n=>o(n))},void 0,()=>{o(null)},!0)})}a(La,"loadSoundBuffer");function Ri(t,e){if(!t.soundRelativePath||!t.sound)return;e.onSoundLoadedObservable=new cr.Observable;let i=Ca(t.soundRelativePath,{spatialAutoUpdate:!1});i._initAsync(t.sound.buffer,{spatialAutoUpdate:!0}).then(()=>{i.volume=t.volume,i._isSpatial=t.sound._isSpatial,i._isSpatial&&(i.spatial.attach(e),i.spatial.maxDistance=t.sound.spatial.maxDistance,i.spatial.panningModel=t.sound.spatial.panningModel,i.spatial.distanceModel=t.sound.spatial.distanceModel),e.sound=i,e.soundRelativePath=t.soundRelativePath,e.autoUpdateSpatial=t.autoUpdateSpatial,Le.push(e),nr(e,i),rr(e.getScene()),e.onSoundLoadedObservable.notifyObservers(e)}),ar(e),sr(e,i)}a(Ri,"configureSourceNodeFrom");function sr(t,e){Object.defineProperty(t,"volume",{get:a(()=>e.volume,"get"),set:a(i=>{e.volume=i},"set")}),Object.defineProperty(t,"playbackRate",{get:a(()=>e.playbackRate,"get"),set:a(i=>{e.playbackRate=i},"set")}),t.isPaused=()=>e.state===pt.SoundState.Paused,t.isPlaying=()=>e.state===pt.SoundState.Started,t.isStopped=()=>e.state===pt.SoundState.Stopped,t.pause=()=>e.pause(),t.resume=()=>e.resume(),t.stop=i=>e.stop(i),t.play=i=>e.play(i),t.setVolume=(i,o)=>e.setVolume(i,o),t.getClassName=()=>"SoundNode",t.setSoundSpatial=i=>new Promise(o=>{e._isSpatial=i,setTimeout(()=>{i&&e.spatial.attach(t),o()})}),t.cloneAsync=async(i,o,r)=>new Promise(n=>{let l=t.clone(i,o,r);Ri(t,l),l.onSoundLoadedObservable.addOnce(()=>{setTimeout(()=>n(l))})})}a(sr,"configureSoundNodePrototype");function hr(){ir||(ir=!0,(0,pr.AddParser)("SoundNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSoundNode)return;let n=i.transformNodes?.find(l=>l.id===r.id);if(n&&r.soundRelativePath){let l=`${o}${r.soundRelativePath}`;e.addPendingData(l),Ii.has(l)||Ii.set(l,La(e,l)),Ii.get(l).then(s=>{(0,ie.CreateSoundAsync)(r.soundRelativePath,s,{spatialAutoUpdate:!1}).then(c=>{if(e.removePendingData(l),n.isDisposed())return c.dispose();c.volume=r.volume,c._isSpatial=r.isSpatial,r.isSpatial&&(c.spatial.attach(n),c.spatial.maxDistance=r.maxDistance,c.spatial.panningModel=r.panningModel,c.spatial.distanceModel=r.distanceModel),n.sound=c,n.soundRelativePath=r.soundRelativePath,n.autoUpdateSpatial=r.autoUpdateSpatial,Le.push(n),ar(n),sr(n,c),rr(e)})})}})}))}a(hr,"registerAudioParser");var dr=require("babylonjs");function De(t){let e=new Set;[...t.transformNodes,...t.meshes].forEach(o=>{if(o.metadata?.isStaticGroup){let r=o.getDescendants(!1);r.push(o),r.forEach(n=>{if((oe(n)||ee(n)&&!n.isWorldMatrixFrozen)&&n.billboardMode===dr.AbstractMesh.BILLBOARDMODE_NONE&&n.freezeWorldMatrix(),oe(n)){let l=n.material;l&&!l.isFrozen&&!e.has(l)&&(e.add(l),l.onBindObservable.addOnce(()=>{l.freeze()}))}})}})}a(De,"configureTransformNodes");var Be=class{constructor(e,i){this.entries=e;this.namingId=i}entries;namingId;static{a(this,"AdvancedAssetContainerInstantiatedEntries")}get rootNodes(){return this.entries.rootNodes}get skeletons(){return this.entries.skeletons}get animationGroups(){return this.entries.animationGroups}dispose(){this.entries.dispose()}getRootNodeByName(e){let i=`${e}-${this.namingId}`;return this.entries.rootNodes.find(o=>o.name===i)??null}getNodeByName(e){let i=`${e}-${this.namingId}`;for(let o of this.entries.rootNodes){let r=this._recursivelyGetNodeByName(i,o);if(r)return r}return null}_recursivelyGetNodeByName(e,i){if(i.name===e)return i;for(let o of i.getDescendants(!0)){let r=this._recursivelyGetNodeByName(e,o);if(r)return r}return null}getScriptByClassByObjectName(e,i){let o=this.getNodeByName(e);if(o){let r=_e(o,i);if(r?.length===1)return r[0]}return null}};var Vi=require("babylonjs"),ze=class{static{a(this,"AdvancedAssetContainer")}container;_rootUrl;_scriptsMap;_originalDescendants=[];_nodesMap=new Map;_animationGroupsMap=new Map;constructor(e,i,o){this.container=e,this._rootUrl=i,this._scriptsMap=o,e.populateRootNodes(),e.rootNodes.forEach(r=>{this._originalDescendants.push(r,...r.getDescendants(!1))}),e.animationGroups.forEach(r=>{this._animationGroupsMap.set(r.name,r)}),this._originalDescendants.forEach(r=>{this._nodesMap.set(r,{node:r,metadata:Ti(r.metadata)})})}removeDefault(){this.container.getNodes().forEach(e=>{z.get(e)?.forEach(o=>{mt(e,o)})}),this.container.removeAllFromScene()}getRootNodeByName(e){return this.container.rootNodes.find(i=>i.name===e)??null}getScriptByClassByObjectName(e,i){let o=this.container.getNodes();for(let r of o)if(r.name===e){let n=_e(r,i);if(n?.length===1)return n[0]}return null}instantiate(e){let i=Vi.Tools.RandomId(),o=a(s=>s,"nameFunction"),r=this.container.instantiateModelsToScene(o,!1,{...e,predicate:a(s=>(s.name=`${s.name}@editor-tools@${i}_${s.id}`,e?.predicate?.(s)??!0),"predicate")}),n=new Be(r,i);[...this.container.transformNodes,...this.container.meshes,...this.container.lights,...this.container.cameras,...this.container.animationGroups,...this.container.skeletons].forEach(s=>{let c=s.name.split("@editor-tools@");s.name=c[0]}),r.animationGroups.forEach(s=>{let c=s.name.split("@editor-tools@");s.name=`${c[0]}-${i}`});let p=[];return r.rootNodes.forEach(s=>{p.push(s,...s.getDescendants(!1))}),p.forEach(s=>{let c=s.name.split("@editor-tools@"),m=c[1].split("_").pop();s.name=`${c[0]}-${i}`;let h=this._originalDescendants.find(d=>d.id===m);ne(h)&&ee(s)&&Ri(h,s),s.id=Vi.Tools.RandomId(),s.metadata=Ti(this._nodesMap.get(h).metadata),s.metadata??={},s.metadata.originalId=m,p.forEach(d=>{d.metadata.scripts?.forEach(f=>{Object.keys(f.values||{}).forEach(u=>{let y=f.values[u];if(y.type==="entity"){y.value===m&&(y.value=s.id),y.value===h.name&&(y.value=s.name);let L=this._animationGroupsMap.get(y.value);L&&(y.value=`${L.name}-${i}`)}})})})}),p.forEach(s=>{G(this.container.scene,s,this._scriptsMap,{namingId:i,rootUrl:this._rootUrl})}),De(this.container.scene),n}};var fr=require("babylonjs"),ur=require("babylonjs");async function gr(t,e,i){let o=i.iblIntensity,r=i.environmentIntensity,l=t.split("/").pop().replace(".scene",".babylon"),p=await(0,ur.LoadAssetContainerAsync)(l,i,{rootUrl:e,pluginExtension:".babylon"});return i.onDisposeObservable.addOnce(()=>{p.dispose()}),fr.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(s=>V(s)&&s._checkDelayState()),p.addAllToScene(),i.iblIntensity=o,i.environmentIntensity=r,De(i),p}a(gr,"preloadSceneScriptAsset");async function vr(t,e){return B(`${e}${t}`)}a(vr,"preloadCommonScriptAsset");var le=new Map,He=new Map;function Da(t,e){He.has(t)&&console.warn(`A parser for the extension '${t}' was already registered. It will be overwritten.`),He.set(t,e)}a(Da,"registerScriptAssetParser");async function Fi(t,e,i){let o=[e,...e.transformNodes,...e.meshes,...e.lights,...e.cameras],r=le.get(e);r||(r=new Map,le.set(e,r)),e.onDisposeObservable.addOnce(()=>{le.delete(e)}),o.filter(s=>s.metadata?.scripts?.length).map(s=>s.metadata.scripts).flat().forEach(s=>{if(i[s.key]?.default?._SceneAssets?.forEach(m=>{r.get(m.sceneName)||r.set(m.sceneName,null)}),s.values)for(let m in s.values){if(!s.values.hasOwnProperty(m))continue;let h=s.values[m];h.type==="asset"&&h.value&&!r.get(h.value)&&r.set(h.value,null)}});let l=0;for(let s of r.values())s===null&&++l;if(l===0)return l;let p=[];return r.forEach((s,c)=>{r.get(c)||p.push(new Promise(async m=>{try{let h=c.split(".").pop();switch(h){case"scene":let d=await gr(c,t,e);e.onDisposeObservable.addOnce(()=>{d.dispose(),r.delete(c)}),r.set(c,new ze(d,t,i));break;default:if(He.has(h)){let f=He.get(h);r.set(c,await f({key:c,rootUrl:t,scene:e}));break}else r.set(c,await vr(c,t));break}}catch(h){console.error(h)}m()}))}),await Promise.all(p),l}a(Fi,"_preloadScriptsAssets");var Sr=require("babylonjs"),ht=require("babylonjs"),yr=require("babylonjs"),dt=require("babylonjs"),br=require("babylonjs"),xr=require("babylonjs-gui");function Ni(t,e){return e?`${t}-${e}`:t}a(Ni,"formatNameWithId");function Gi(t,e,i,o,r){let n=o.constructor;if(!n)return;n._NodesFromScene?.forEach(s=>{o[s.propertyKey.toString()]=wi(Ni(s.nodeName,r.namingId),t)}),n._ComponentsFromScene?.length&&t.getEngine().onBeginFrameObservable.addOnce(()=>{n._ComponentsFromScene?.forEach(s=>{let c=[];if([t,...t.transformNodes,...t.meshes,...t.lights,...t.cameras].forEach(h=>{let d=Bi(h,s.componentConstructor);d&&c.push(d)}),c.length>1)throw new Error(`Multiple components of type ${n._ComponentsFromScene[0].componentConstructor.name} found in scene for property "${n._ComponentsFromScene[0].propertyKey.toString()}".`);o[s.propertyKey.toString()]=c[0]??null})}),n._NodesFromDescendants?.forEach(s=>{let c=e.getDescendants?.(s.directDescendantsOnly,m=>m.name===Ni(s.nodeName,r.namingId))[0];o[s.propertyKey.toString()]=c??null}),n._AnimationGroups?.forEach(s=>{o[s.propertyKey.toString()]=t.getAnimationGroupByName(s.animationGroupName)}),n._SoundsFromScene?.forEach(s=>{let c=wi(Ni(s.soundName,r.namingId),t);c&&ne(c)&&(o[s.propertyKey.toString()]=c??null)}),(n._GuiFromAsset??[]).map(async s=>{let c=`${r.rootUrl}assets/${s.pathInAssets}`;try{let m=await B(c),h=xr.AdvancedDynamicTexture.CreateFullscreenUI(m.name,!0,t);h.parseSerializedObject(m.content,!1),o[s.propertyKey.toString()]=h,s.onGuiCreated?.(o,h)}catch(m){throw console.error(`Failed to load GUI from asset: ${c}`),m}}),n._ParticleSystemsFromScene?.forEach(s=>{let c=t.particleSystems?.find(m=>m.name!==s.particleSystemName?!1:s.directDescendantsOnly?m.emitter===e:m);o[s.propertyKey.toString()]=c}),(n._VisibleInInspector??[]).forEach(s=>{let c=s.propertyKey.toString(),m=i.values;if(!m)throw new Error(`No values found for script with key "${i.key}".`);if(m.hasOwnProperty(c)&&m[c].hasOwnProperty("value")){let h=m[c].value;switch(s.configuration.type){case"number":case"boolean":case"keymap":case"string":o[c]=h;break;case"vector2":o[c]=dt.Vector2.FromArray(h);break;case"vector3":o[c]=dt.Vector3.FromArray(h);break;case"color3":o[c]=ht.Color3.FromArray(h);break;case"color4":o[c]=ht.Color4.FromArray(h);break;case"entity":switch(s.configuration.entityType){case"node":case"sound":o[c]=Ce(h,t)??null;break;case"animationGroup":o[c]=t.getAnimationGroupByName(h)??null;break;case"particleSystem":o[c]=t.particleSystems?.find(f=>f.id===h)??null;break}break;case"texture":h&&(o[c]=yr.Texture.Parse(h,t,r.rootUrl));break;case"asset":if(h){let f=s.configuration.assetType,u=le.get(t).get(h);switch(f){case"json":case"gui":case"scene":case"navmesh":case"cinematic":o[c]=u;break;case"ragdoll":o[c]=Ei(u);break;case"nodeParticleSystemSet":let y=br.NodeParticleSystemSet.Parse(u);o[c]=y;break;case"material":o[c]=Sr.Material.Parse(u,t,r.rootUrl);break}}}}});let l=null,p=null;if(n._PointerEvents?.length){if(n._PointerEvents.find(m=>m.options.mode==="attachedMeshOnly")&&!oe(e))throw new Error('@onPointerEvent with mode "attachedMeshOnly" can only be used on scripts attached to meshes (extends AbstractMesh).');if(n._PointerEvents.find(m=>m.options.mode!=="global")&&!me(e))throw new Error('@onPointerEvent with mode different from "global" can be used only on scripts attached to Node: Mesh, Light, Camera, TransformNode.');l=t.onPointerObservable.add(m=>{let h=null;n._PointerEvents.forEach(d=>{if(!d.eventTypes.includes(m.type))return;let f=d.propertyKey.toString();if(d.options.mode==="global")return o[f]?.(m);h=m.pickInfo,h||(h=t.pick(t.pointerX,t.pointerY,u=>u.isVisible&&u.isPickable&&u.isEnabled(!0)&&!u._masterMesh,!1));let S=h.pickedMesh;if(S&&(d.options.mode==="attachedMeshOnly"&&S===e||d.options.mode==="includeDescendants"&&me(e)&&[e,...e.getDescendants(!1)].find(L=>L===S)))return o[f]?.(m)})})}if(n._KeyboardEvents?.length&&(p=t.onKeyboardObservable.add(s=>{n._KeyboardEvents.forEach(c=>{c.eventTypes.includes(s.type)&&o[c.propertyKey.toString()]?.(s)})})),n._SpritesFromSpriteManager?.length){let s=e;if(!ee(s)||!s.isSpriteManager)return console.error("@spriteFromSpriteManager decorator can only be used on SpriteManagerNode.");if(!s.spriteManager)return console.error(`SpriteManagerNode "${s.name}" has no sprite manager assigned.`);n._SpritesFromSpriteManager?.forEach(c=>{let m=s.spriteManager?.sprites.find(h=>h.name===c.spriteName)||null;o[c.propertyKey.toString()]=m})}if(n._AnimationsFromSprite?.length){if(!Ot(e))return console.error("@animationFromSprite decorator can only be used in scripts attached on Sprite.");let s=e.metadata?.spriteAnimations;if(!s?.length)return console.error(`Sprite "${e.name}" has no sprite animations assigned.`);n._AnimationsFromSprite.forEach(c=>{let m=s.find(h=>h.name===c.animationName);m?o[c.propertyKey.toString()]=m??null:console.warn(`Sprite animation named "${c.animationName}" not found on sprite "${e.name}".`)})}return n._SceneAssets?.forEach(s=>{let c=le.get(t);o[s.propertyKey.toString()]=c.get(s.sceneName)}),{observers:{pointerObserver:l,keyboardObserver:p}}}a(Gi,"applyDecorators");function G(t,e,i,o){e.metadata?.scripts&&(e.metadata.scripts?.forEach(r=>{if(!r.enabled)return;let n=i[r.key];if(!n)return;let l=n,p={};if(n.default){l=new n.default(e);let s=Gi(t,e,r,l,o);Object.assign(p,s?.observers??{})}l.onStart&&(p.onStartObserver=t.onBeforeRenderObservable.addOnce(()=>l.onStart(e))),l.onUpdate&&(p.onUpdateObserver=t.onBeforeRenderObservable.add(()=>l.onUpdate(e))),zi(e,l,r.key,p)}),e.metadata.scripts=void 0)}a(G,"_applyScriptsForObject");function _a(t,e,i){if(i??=t.getScene?.(),!i)throw new Error("Cannot apply script on object: no scene available.");let o=new e(t),r={};return Gi(i,t,{values:{}},o,{rootUrl:""}),o.onStart&&(r.onStartObserver=i.onBeforeRenderObservable.addOnce(()=>o.onStart())),o.onUpdate&&i.onBeforeRenderObservable.add(()=>o.onUpdate()),zi(t,o,"runtime",r),o}a(_a,"applyScriptOnObject");var z=new Map;function zi(t,e,i,o){let r={key:i,observers:o,instance:e};z.has(t)?z.get(t).push(r):z.set(t,[r]),(me(t)||wt(t)||_t(t)||ne(t))&&t.onDisposeObservable.addOnce((()=>{z.get(t)?.slice()?.forEach(l=>{mt(t,l)}),z.delete(t)}))}a(zi,"_registerScriptInstance");function mt(t,e){e.observers.onStartObserver?.remove(),e.observers.onUpdateObserver?.remove(),e.observers.pointerObserver?.remove(),e.observers.keyboardObserver?.remove();try{e.instance.onStop?.(t)}catch(r){console.error(`Failed to call onStop for script ${e.key} on object ${t}`,r)}let i=z.get(t),o=i?.indexOf(e)??-1;o!==-1&&i?.splice(o,1)}a(mt,"_removeRegisteredScriptInstance");function _e(t,e){return z.get(t)?.filter(r=>r.instance.constructor===e)?.map(r=>r.instance)??null}a(_e,"getAllScriptsByClassForObject");function Bi(t,e){return _e(t,e)?.[0]??null}a(Bi,"getScriptByClassForObject");var Lr=require("babylonjs"),Cr=!1;function Dr(){Cr||(Cr=!0,(0,Lr.AddParser)("MeshEditorPlugin",(t,e,i,o)=>{t.meshes?.forEach(r=>{r.instances?.forEach(n=>{let l=i.meshes?.find(p=>p.id===n.id);l&&n.billboardMode!==void 0&&(l.billboardMode=n.billboardMode)})})}))}a(Dr,"registerMeshParser");var _r=!1;function Pa(t){_r=t}a(Pa,"setUseKtx2CompressedTextures");function ke(){return _r}a(ke,"isUsingKtx2CompressedTextures");function ft(t){return`${t.substring(0,t.lastIndexOf("."))}.ktx2`}a(ft,"_getKtx2TextureName");function wa(t){t.setCompressedTextureExclusions([".env",".hdr",".dds"]),t.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}a(wa,"configureEngineToUseCompressedTextures");function ut(t,e){t._excludedCompressedTextures&&!t._excludedCompressedTextures?.includes(e)&&t._excludedCompressedTextures?.push(e)}a(ut,"addExcludedCompressedTexture");function Oa(t,e,i){e.loadingTexturesQuality!==t&&(e.loadingTexturesQuality=t,e.textures.forEach(o=>{if(!Ae(o)||!o.url)return;let r=gt(o,e);!r||o.url.includes(r)||o.updateURL(i+r)}))}a(Oa,"applyTexturesQuality");function gt(t,e){if(e.loadingTexturesQuality==="high"||!t.metadata?.baseSize)return t.name;let i=t.metadata.baseSize.width,o=t.metadata.baseSize.height,r=i===F(i)||o===F(o),n="";switch(e.loadingTexturesQuality){case"medium":let d=i*.66>>0,f=o*.66>>0;r&&(d=F(d),f=F(f)),n=`_${d}_${f}`;break;case"low":case"very-low":let S=i*.33>>0,u=o*.33>>0;r&&(S=F(S),u=F(u)),n=`_${S}_${u}`;break}let l=t.name;if(!l||!n)return t.name;let p=l.split("/"),s=p.pop();if(!s)return t.name;let c=s.split(".").pop(),h=`${s.replace(`.${c}`,"")}${n}.${c}`;return p.push(h),p.join("/")}a(gt,"getTextureUrl");var Hi=require("babylonjs"),Pr=!1;function wr(){if(Pr)return;Pr=!0;let t=Hi.SerializationHelper._TextureParser;Hi.SerializationHelper._TextureParser=(e,i,o)=>{ke()&&(e.name&&(e.name=ft(e.name)),e.url&&(e.url=ft(e.url)));let r=gt(e,i);if(!r)return t(e,i,o);let n=e.name;e.name=r;let l=t(e,i,o);return l&&(l.name=n),l}}a(wr,"registerTextureParser");function ki(t){if(!Array.isArray(t.frames)){let e=[];for(let i of Object.keys(t.frames))e.push({filename:i,...t.frames[i]});t.frames=e}}a(ki,"normalizeAtlasJson");function Ea(t,e,i){let r=(t.metadata?.spriteAnimations??[]).find(n=>n.name===e);if(!r)return console.error(`Animation with name "${e}" not found on sprite.`);t.playAnimation(r.from,r.to,r.loop,r.delay,i)}a(Ea,"playSpriteAnimationFromName");var Er=require("babylonjs"),Ar=require("babylonjs"),Tr=require("babylonjs"),Ir=require("babylonjs"),Ui=require("babylonjs"),Pe=require("babylonjs"),Mr=require("babylonjs"),Or=!1;function Rr(){Or||(Or=!0,(0,Mr.AddParser)("SpriteMapNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSpriteMap)return;let n=i.transformNodes?.find(s=>s.id===r.id);if(!n)return;n.isSpriteMap=r.isSpriteMap;let l=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(l);let p=new Tr.WebRequest;p.open("GET",l),p.send(),p.addEventListener("load",()=>{e.removePendingData(l);let s=JSON.parse(p.responseText);ki(s);let c=`${Er.Tools.GetFolderPath(l)}${s.meta.image}`,m=new Ui.Texture(c,e,!1,!1,Ui.Texture.NEAREST_NEAREST,null,null,null,!1,Ar.Engine.TEXTUREFORMAT_RGBA),h=new Ir.SpriteMap(n.name,s,m,{layerCount:r.options.layerCount,stageSize:Pe.Vector2.FromArray(r.options.stageSize??[10,1]),outputSize:Pe.Vector2.FromArray(r.options.outputSize??[100,100]),colorMultiply:Pe.Vector3.FromArray(r.options.colorMultiply??[1,1,1]),flipU:!0},e);r.getClassName=()=>"SpriteMapNode",r.tiles.forEach(f=>{for(let S=0,u=f.repeatCount.x+1;S<u;++S)for(let y=0,L=f.repeatCount.y+1;y<L;++y){let _=S*(f.repeatOffset.x+1),x=y*(f.repeatOffset.y+1);h.changeTiles(f.layer,new Pe.Vector2(f.position.x+_,(h.options.stageSize?.y??0)-1-f.position.y-x),f.tile)}});let d=h._output;d.parent=n,n.spriteMap=h})})}))}a(Rr,"registerSpriteMapParser");var Fr=require("babylonjs"),Nr=require("babylonjs"),vt=require("babylonjs"),Gr=require("babylonjs"),Vr=!1;function Br(){if(Vr)return;Vr=!0,(0,Gr.RegisterShadowGeneratorSceneComponent)(Nr.ShadowGenerator);let t=(0,vt.GetParser)(Fr.SceneComponentConstants.NAME_SHADOWGENERATOR);(0,vt.AddParser)("ShadowGeneratorEditorPlugin",(e,i,o,r)=>{let n=new Map;e.shadowGenerators?.forEach(l=>{if(n.set(l.id,l.mapSize),i.loadingShadowsQuality!=="high"){switch(i.loadingShadowsQuality){case"medium":l.mapSize=l.mapSize*.5;break;case"low":l.mapSize=l.mapSize*.25;break;case"very-low":l.mapSize=l.mapSize*.125;break}l.mapSize=Math.max(128,F(l.mapSize))}}),t?.(e,i,o,r),i.lights.forEach(l=>{let p=l.getShadowGenerator();if(p?.getShadowMap()){let c=p.id,m=n.get(c);m&&(p.originalMapSize=m)}})})}a(Br,"registerShadowGeneratorParser");var kr=require("babylonjs"),Ur=require("babylonjs"),Wr=require("babylonjs"),Wi=require("babylonjs"),Xr=require("babylonjs");function zr(t,e){e?.fogEnabled!==void 0&&(t.fogEnabled=e?.fogEnabled),e?.blendMode!==void 0&&(t.blendMode=e?.blendMode),e?.disableDepthWrite!==void 0&&(t.disableDepthWrite=e?.disableDepthWrite),e?.pixelPerfect!==void 0&&(t.pixelPerfect=e?.pixelPerfect),e?.useLogarithmicDepth!==void 0&&(t.useLogarithmicDepth=e?.useLogarithmicDepth),e?.metadata!==void 0&&(t.metadata=e?.metadata);for(let i of e?.sprites??[]){let o=Ur.Sprite.Parse(i,t);o.uniqueId=i.uniqueId,o.metadata=i.metadata}}a(zr,"parseSerializedSpriteManager");var Hr=!1;function $r(){Hr||(Hr=!0,(0,Xr.AddParser)("SpriteManagerNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSpriteManager)return;let n=i.transformNodes?.find(p=>p.id===r.id);if(!n)return;let l=e.getEngine();if(n.isSpriteManager=r.isSpriteManager,r.atlasJsonRelativePath){let p=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(p);let s=new Wr.WebRequest;s.open("GET",p),s.send(),s.addEventListener("load",()=>{e.removePendingData(p);let c=JSON.parse(s.responseText),m=`${kr.Tools.GetFolderPath(p)}${c.meta.image}`;ut(l,m);let h=new Wi.SpriteManager(n.name,m,1e3,64,e,void 0,void 0,!0,c);n.spriteManager=h,n.getClassName=()=>"SpriteManagerNode",r.spriteManager&&zr(h,r.spriteManager)})}else if(r.spriteManager?.textureUrl){ut(l,r.spriteManager.textureUrl);let p=`${o}${r.spriteManager.textureUrl}`,s=new Wi.SpriteManager(n.name,p,1e3,{width:r.spriteManager.cellWidth,height:r.spriteManager.cellHeight},e,void 0,void 0,!1);n.spriteManager=s,n.getClassName=()=>"SpriteManagerNode",r.spriteManager&&zr(s,r.spriteManager)}})}))}a($r,"registerSpriteManagerParser");var jr=require("babylonjs"),Zr=require("babylonjs"),Kr=!1;function Yr(){Kr||(Kr=!0,(0,Zr.AddParser)("MorphTargetManagerEditorPlugin",(t,e,i,o)=>{t.morphTargetManagers.forEach(r=>{let l=i.meshes.find(c=>c.id===r.meshId)?.morphTargetManager;if(!l||r.targets.find(c=>!c.delayLoadingFile))return;let s=[];r.targets.forEach(c=>{if(!c.delayLoadingFile)return s.push(Promise.resolve(null));let m=`${o}${c.delayLoadingFile}`;e.addPendingData(m);let h=new jr.WebRequest;h.responseType="arraybuffer",h.open("GET",m),h.send(),s.push(new Promise(d=>{h.addEventListener("load",()=>{e.removePendingData(m),d(h.response)})}))}),Promise.all(s).then(c=>{for(let m=0,h=l.numTargets;m<h;++m){let d=l.getTarget(m),f=r.targets[m],S=c[m];if(f.positionsCount){let u=new Float32Array(S,f.positionsOffset,f.positionsCount);d._positions=u,d.setPositions(u)}if(f.normalsCount){let u=new Float32Array(S,f.normalsOffset,f.normalsCount);d._normals=u,d.setNormals(u)}if(f.tangentsCount){let u=new Float32Array(S,f.tangentsOffset,f.tangentsCount);d._tangents=u,d.setTangents(u)}if(f.uvsCount){let u=new Float32Array(S,f.uvsOffset,f.uvsCount);d._uvs=u,d.setUVs(u)}if(f.uv2sCount){let u=new Float32Array(S,f.uv2sOffset,f.uv2sCount);d._uv2s=u,d.setUV2s(u)}}for(let m=0,h=l.numTargets;m<h;++m)l.getTarget(m)._onDataLayoutChanged.notifyObservers()})})}))}a(Yr,"registerMorphTargetManagerParser");var Qr=require("babylonjs"),Jr=require("babylonjs"),qr=!1;function en(){qr||(qr=!0,(0,Qr.AddParser)("NodeParticleSystemSetEditorPlugin",(t,e,i,o)=>{t.meshes?.forEach(r=>{if(!r.isNodeParticleSystemMesh)return;let n=i.meshes?.find(l=>l.id===r.id);n&&(r.nodeParticleSystemSet.blocks?.forEach(l=>{l.url&&(l.url=`${o}${l.url}`)}),n.nodeParticleSystemSet=Jr.NodeParticleSystemSet.Parse(r.nodeParticleSystemSet),n.nodeParticleSystemSet.id=r.nodeParticleSystemSet.id,n.nodeParticleSystemSet.uniqueId=r.uniqueId,e.addPendingData(r.id),n.nodeParticleSystemSet.buildAsync(e,!1).then(l=>{e.removePendingData(r.id),n.particleSystemSet=l,l.systems.forEach(p=>{if(Pt(p)){let s=p._sizeCreation.process;s&&(p._sizeCreation.process=(c,m)=>{s(c,m),c.scale.x*=100,c.scale.y*=100})}}),l.emitterNode=n,l.start()}))})}))}a(en,"registerNodeParticleSystemSetParser");var tn=require("babylonjs");function on(t,e){e??=new tn.ClusteredLightContainer("Clustered Light Container",[],t);let i=t.metadata?.clusteredLight;return i&&(i.lights.length>0&&(e.horizontalTiles=i.horizontalTiles,e.verticalTiles=i.verticalTiles,e.depthSlices=i.depthSlices,e.maxRange=i.maxRange),i.lights.forEach(o=>{let r=t.getLightById(o);r&&e?.addLight(r)})),e}a(on,"configureLights");var nn=require("babylonjs"),$i=require("babylonjs"),an=require("babylonjs"),sn=require("babylonjs"),Xi=new Map;async function rn(t,e){let i=t.getWaitingItemsCount();for(;!t.isDisposed&&(!t.isReady()||t.getWaitingItemsCount()>0);){await new Promise(r=>setTimeout(r,150));let o=i-t.getWaitingItemsCount();o===i&&t.textures.forEach(r=>{r.delayLoadState===$i.Constants.DELAYLOADSTATE_NONE&&(r.delayLoadState=$i.Constants.DELAYLOADSTATE_LOADED)}),e(o/i)}}a(rn,"waitForWaitingItems");async function Aa(t,e,i,o,r){i.loadingQuality=r?.quality??"high",i.loadingTexturesQuality=r?.texturesQuality??i.loadingQuality,i.loadingShadowsQuality=r?.shadowsQuality??i.loadingQuality,i.loadingLodsQuality=r?.lodsQuality??i.loadingQuality,Dr(),hr(),wr(),Br(),Yr(),Rr(),$r(),en();let n=Xi.get(i)??{};if(Xi.set(i,n),i.onDisposeObservable.addOnce(()=>{Xi.delete(i)}),await(0,an.AppendSceneAsync)(`${t}${e}`,i,{pluginExtension:".babylon",onProgress:a(p=>{let s=Math.min(p.loaded/p.total*.5);r?.onProgress?.(s)},"onProgress")}),await rn(i,p=>{r?.onProgress?.(.5+p*.25)}),!r?.skipAssetsPreload){let p=0;do p=await Fi(t,i,o);while(p!==0&&!i.isDisposed)}sn.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(p=>V(p)&&p._checkDelayState());let l=on(i,n.clusteredLightContainer);n.clusteredLightContainer=l,await rn(i,p=>{r?.onProgress?.(.75+p*.25)}),r?.onProgress?.(1),Tt(i),It(i.loadingLodsQuality,i),Mt(i),qe(i),i.metadata?.rendering&&(qo(i,i.metadata),i.activeCamera&&Pi(i.activeCamera,t,r?.postProcessConfiguration)),i.metadata?.physicsGravity&&i.getPhysicsEngine()?.setGravity(nn.Vector3.FromArray(i.metadata?.physicsGravity)),G(i,i,o,t),i.transformNodes.forEach(p=>{G(i,p,o,t)}),i.meshes.forEach(p=>{Yo(p),G(i,p,o,t)}),i.lights.forEach(p=>{G(i,p,o,t)}),l.lights.forEach(p=>{G(i,p,o,t)}),i.cameras.forEach(p=>{G(i,p,o,t)}),i.spriteManagers?.forEach(p=>{p.sprites.forEach(s=>{G(i,s,o,t)})}),De(i)}a(Aa,"loadScene");var ln=require("babylonjs");async function Ta(t,e,i){let o=await B(t+e),n=ln.Tools.Instantiate(o.customType).Parse(o,i,t);return n.id=o.id,n.uniqueId=o.uniqueId,n}a(Ta,"loadMaterialFromFile");function Ia(t){return Promise.all(t.materials.map(async e=>{let i=e.getBindedMeshes();await Promise.all(i.map(async o=>{Ee(o)||await e.forceCompilationAsync(o,{clipPlane:!!t.clipPlane,useInstances:o.hasInstances})}))}))}a(Ia,"forceCompileAllSceneMaterials");var Q=require("babylonjs");function Ue(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Q.Animation.ANIMATIONTYPE_FLOAT;switch(t?.getClassName?.()){case"Vector2":return Q.Animation.ANIMATIONTYPE_VECTOR2;case"Vector3":return Q.Animation.ANIMATIONTYPE_VECTOR3;case"Quaternion":return Q.Animation.ANIMATIONTYPE_QUATERNION;case"Color3":return Q.Animation.ANIMATIONTYPE_COLOR3;case"Color4":return Q.Animation.ANIMATIONTYPE_COLOR4;case"Size":return Q.Animation.ANIMATIONTYPE_SIZE;case"Matrix":return Q.Animation.ANIMATIONTYPE_MATRIX}return null}a(Ue,"getAnimationTypeForObject");var cn=require("babylonjs");function Ma(t){return function(e,i){let o=e.constructor;o._NodesFromScene??=[],o._NodesFromScene.push({propertyKey:i,nodeName:t})}}a(Ma,"nodeFromScene");function Ra(t){return function(e,i){let o=e.constructor;o._ComponentsFromScene??=[],o._ComponentsFromScene.push({propertyKey:i,componentConstructor:t})}}a(Ra,"componentFromScene");function Va(t,e=!1){return function(i,o){let r=i.constructor;r._NodesFromDescendants??=[],r._NodesFromDescendants.push({propertyKey:o,nodeName:t,directDescendantsOnly:e})}}a(Va,"nodeFromDescendants");function Fa(t){return function(e,i){let o=e.constructor;o._AnimationGroups??=[],o._AnimationGroups.push({animationGroupName:t,propertyKey:i})}}a(Fa,"animationGroupFromScene");function Na(t){return function(e,i){let o=e.constructor;o._SceneAssets??=[],o._SceneAssets.push({sceneName:t,propertyKey:i})}}a(Na,"sceneAsset");function Ga(t,e){return function(i,o){let r=i.constructor;r._GuiFromAsset??=[],r._GuiFromAsset.push({propertyKey:o,pathInAssets:t,onGuiCreated:e})}}a(Ga,"guiFromAsset");function Ba(t){return function(e,i){let o=e.constructor;o._SoundsFromScene??=[],o._SoundsFromScene.push({propertyKey:i,soundName:t})}}a(Ba,"soundFromScene");function za(t,e=!1){return function(i,o){let r=i.constructor;r._ParticleSystemsFromScene??=[],r._ParticleSystemsFromScene.push({propertyKey:o,particleSystemName:t,directDescendantsOnly:e})}}a(za,"particleSystemFromScene");function Ha(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"boolean"}})}}a(Ha,"visibleAsBoolean");function ka(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"string"}})}}a(ka,"visibleAsString");function Ua(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"number"}})}}a(Ua,"visibleAsNumber");function Wa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector2"}})}}a(Wa,"visibleAsVector2");function Xa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector3"}})}}a(Xa,"visibleAsVector3");function $a(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color3"}})}}a($a,"visibleAsColor3");function Ka(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color4"}})}}a(Ka,"visibleAsColor4");function ja(t,e,i){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...i,entityType:t,type:"entity"}})}}a(ja,"visibleAsEntity");function Za(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"texture"}})}}a(Za,"visibleAsTexture");function Ya(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"keymap"}})}}a(Ya,"visibleAsKeyMap");function qa(t,e,i){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...i,assetType:t,type:"asset"}})}}a(qa,"visibleAsAsset");function Qa(t,e){return function(i,o){let r=i.constructor;r._PointerEvents??=[],r._PointerEvents.push({propertyKey:o,options:{mode:"global",...e??{}},eventTypes:Array.isArray(t)?t:[t]})}}a(Qa,"onPointerEvent");function Ja(t){return function(e,i){let o=e.constructor;o._KeyboardEvents??=[],o._KeyboardEvents.push({propertyKey:i,eventTypes:Array.isArray(t)?t:[t]})}}a(Ja,"onKeyboardEvent");function es(t){return function(e,i){let o=e.constructor;o._SpritesFromSpriteManager??=[],o._SpritesFromSpriteManager.push({propertyKey:i,spriteName:t})}}a(es,"spriteFromSpriteManager");function ts(t){return function(e,i){let o=e.constructor;o._AnimationsFromSprite??=[],o._AnimationsFromSprite.push({propertyKey:i,animationName:t})}}a(ts,"animationFromSprite");var St=require("babylonjs");function gv(t,e){let i;return t===St.Animation.ANIMATIONTYPE_FLOAT?i=e.value:i=e.value.clone(),{value:i,frame:e.frame,interpolation:e.interpolation,inTangent:t===St.Animation.ANIMATIONTYPE_FLOAT?e.inTangent:e.inTangent?.clone(),outTangent:t===St.Animation.ANIMATIONTYPE_FLOAT?e.outTangent:e.outTangent?.clone()}}a(gv,"cloneKey");function yt(t,e){let i=e.split("."),o=t;for(let r=0;r<i.length;++r)o=o[i[r]];return o}a(yt,"getPropertyValue");function Ki(t,e,i){let o=null;t.onAnimationGroupPlayObservable.add(()=>{o=e.onAfterAnimationsObservable.add(()=>{i()})}),t.onAnimationGroupPauseObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)}),t.onAnimationGroupEndObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)})}a(Ki,"registerAfterAnimationCallback");var J=require("babylonjs"),bt=require("babylonjs"),k=require("babylonjs");function is(t,e){return{name:t.name,framesPerSecond:t.framesPerSecond,outputFramesPerSecond:t.outputFramesPerSecond,tracks:t.tracks.map(i=>{let o=null,r=null;if(i.node?(o=Ce(i.node,e),o||(o=e.particleSystems?.find(l=>l.id===i.node)??null)):i.defaultRenderingPipeline?o=Te():i.volumetricLightScattering&&(o=Rt()),i.propertyPath){let l=yt(o,i.propertyPath);r=Ue(l)}let n=null;return i.sound&&(n=Ce(i.sound,e)),{node:o,sound:n,propertyPath:i.propertyPath,defaultRenderingPipeline:i.defaultRenderingPipeline,volumetricLightScattering:i.volumetricLightScattering,animationGroupWeight:i.animationGroupWeight,animationGroup:i.animationGroup?e.getAnimationGroupByName(i.animationGroup):null,animationGroups:i.animationGroups,sounds:i.sounds,soundVolume:ji(i.soundVolume??[],J.Animation.ANIMATIONTYPE_FLOAT),keyFrameEvents:i.keyFrameEvents?.map(l=>{let p={...l};switch(l.data?.type){case"set-enabled":p.data={type:"set-enabled",value:l.data.value,node:Ce(l.data.node,e)};break;case"apply-impulse":p.data={type:"apply-impulse",radius:l.data.radius,mesh:e.getMeshById(l.data.mesh),force:k.Vector3.FromArray(l.data.force),contactPoint:k.Vector3.FromArray(l.data.contactPoint)};break}return p}),keyFrameAnimations:o&&r!==null&&ji(i.keyFrameAnimations??[],r)}})}}a(is,"parseCinematic");function H(t,e){if(t===null)return null;if(t!==void 0)switch(e){case J.Animation.ANIMATIONTYPE_FLOAT:return t;case J.Animation.ANIMATIONTYPE_VECTOR2:return k.Vector2.FromArray(t);case J.Animation.ANIMATIONTYPE_VECTOR3:return k.Vector3.FromArray(t);case J.Animation.ANIMATIONTYPE_QUATERNION:return k.Quaternion.FromArray(t);case J.Animation.ANIMATIONTYPE_COLOR3:return bt.Color3.FromArray(t);case J.Animation.ANIMATIONTYPE_COLOR4:return bt.Color4.FromArray(t);case J.Animation.ANIMATIONTYPE_MATRIX:return k.Matrix.FromArray(t)}}a(H,"parseCinematicKeyValue");function ji(t,e){return t?.map(i=>{let o=i.type==="key"?i:null;if(o)return{...o,value:H(o.value,e),inTangent:H(o.inTangent,e),outTangent:H(o.outTangent,e)};let r=i.type==="cut"?i:null;if(r)return{...r,key1:{...r.key1,value:H(r.key1.value,e),inTangent:H(r.key1.inTangent,e),outTangent:H(r.key1.outTangent,e)},key2:{...r.key2,value:H(r.key2.value,e),inTangent:H(r.key2.inTangent,e),outTangent:H(r.key2.outTangent,e)}};throw new Error(`Unknown key frame type: ${i.type}`)})}a(ji,"parseKeyFrameAnimations");function pn(t,e){t.onEventObservable.notifyObservers(e.eventName)}a(pn,"handleApplyEvent");function mn(t){t.node?.setEnabled(t.value)}a(mn,"handleSetEnabledEvent");var Zi=require("babylonjs"),hn=Zi.Vector3.Zero();function dn(t,e){let i=e.mesh?[e.mesh]:t.meshes.filter(o=>o.physicsAggregate);e.radius&&(i=i.filter(o=>{let r=o.getBoundingInfo().boundingBox.centerWorld;return Zi.Vector3.Distance(r,e.contactPoint)<=e.radius})),i.forEach(o=>{if(o.physicsAggregate?.body){let r=e.contactPoint.subtract(o.getBoundingInfo().boundingBox.centerWorld);r.multiplyInPlace(e.force),o.physicsAggregate.body.setLinearVelocity(hn),o.physicsAggregate.body.setAngularVelocity(hn),o.physicsAggregate.body.applyImpulse(r.negateInPlace(),e.contactPoint)}})}a(dn,"handleApplyImpulseEvent");var fn=require("babylonjs"),un=require("babylonjs"),We=class extends un.AnimationGroup{static{a(this,"Cinematic")}onEventObservable=new fn.Observable;onEvent(e,i){this.onEventObservable.add(o=>{e===o&&i()})}};function Yi(t){return t.type==="key"}a(Yi,"isCinematicKey");function we(t){return t.type==="cut"}a(we,"isCinematicKeyCut");function os(t){return t.type==="event"}a(os,"isCinematicKeyEvent");function rs(t){return t.type==="group"}a(rs,"isCinematicGroup");function ns(t){return t.type==="sound"}a(ns,"isCinematicSound");var O=require("babylonjs"),Oe=require("babylonjs");function as(t,e,i){let o=new We(t.name,e);return t.tracks.forEach(r=>{let n=r.animationGroup;if(n&&r.animationGroups?.length){let d=n.clone(`${n.name}-cinematic-temp`),f=e.animationGroups.indexOf(d);f!==-1&&e.animationGroups.splice(f,1),o.onAnimationEndObservable.add(()=>{n.stop(),d.stop()});let S=r.animationGroups.reduce((_,x)=>Math.min(_,x.frame),Number.MAX_VALUE)??0,u=r.animationGroups.reduce((_,x)=>Math.max(_,x.frame+x.endFrame),0)??0,y={frame:S},L=new O.Animation(d.name,"frame",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1);if(L.setKeys([{frame:S,value:0},{frame:u,value:u}]),r.animationGroups.forEach(_=>{L.addEvent(new Oe.AnimationEvent(_.frame,()=>{let x=_.repeatCount??0;if(d.to=_.endFrame,d.speedRatio=_.speed,d.stop(),d.play(x>0),d.from!==_.startFrame&&d.goToFrame(_.startFrame),x){let M=0;d.onAnimationGroupLoopObservable.add(()=>{++M,M>x&&d.stop()})}}))}),o.addTargetedAnimation(L,y),(r.animationGroupWeight?.length??0)>=2&&r.animationGroupWeight.find(x=>we(x)?x.key1.value!==1||x.key2.value!==1:x.value!==1)){let x={weight:0},M=new O.Animation(`${d.name}-weights`,"weight",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),N=[];r.animationGroupWeight.forEach(v=>{we(v)?(N.push(v.key1),N.push(v.key2)):N.push(v)}),M.setKeys(N),o.addTargetedAnimation(M,x),Ki(o,e,()=>{d.weight=x.weight})}}let l=r.sound;if(!i?.ignoreSounds&&l&&l.sound?.buffer&&r.sounds?.length){let d={dummy:0,volume:0},f=new O.Animation(l.name,"dummy",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;if(r.sounds?.forEach(u=>{let y=u.endFrame-u.startFrame;S=Math.max(S,u.frame+y),f.addEvent(new Oe.AnimationEvent(u.frame,L=>{let x=(L-u.frame+u.startFrame)/t.framesPerSecond;l.play({startOffset:x})},!1)),f.addEvent(new Oe.AnimationEvent(u.frame+y,()=>{l.stop()}))}),f.setKeys([{frame:0,value:0},{frame:S,value:S}]),o.addTargetedAnimation(f,d),(r.soundVolume?.length??0)>=2){let u=new O.Animation(l.name,"volume",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),y=[];r.soundVolume.forEach(L=>{we(L)?(y.push(L.key1),y.push(L.key2)):y.push(L)}),u.setKeys(y),o.addTargetedAnimation(u,d),Ki(o,e,()=>{l.volume=d.volume})}}if(r.keyFrameEvents){let d={dummy:0},f=new O.Animation("events","dummy",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;r.keyFrameEvents?.forEach(u=>{S=Math.max(S,u.frame),f.addEvent(new Oe.AnimationEvent(u.frame,()=>{switch(u.data?.type){case"event":pn(o,u.data);break;case"set-enabled":mn(u.data);break;case"apply-impulse":dn(e,u.data);break}}))}),f.setKeys([{frame:0,value:0},{frame:S+1,value:S+1}]),o.addTargetedAnimation(f,d)}let p=r.defaultRenderingPipeline?Te():r.node;if(!p||!r.propertyPath||!r.keyFrameAnimations)return;let s=yt(p,r.propertyPath),c=Ue(s);if(c===null)return;let m=new O.Animation(r.propertyPath,r.propertyPath,60,c,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),h=[];r.keyFrameAnimations?.forEach(d=>{if(Yi(d))return h.push(d);we(d)&&(h.push(d.key1),h.push(d.key2),Ze(p)&&r.propertyPath==="position"&&m.addEvent(new Oe.AnimationEvent(d.key1.frame,()=>{let f=Kt();if(!f)return;let S=f.motionStrength;f.motionStrength=0,requestAnimationFrame(()=>{f.motionStrength=S})})))}),m.setKeys(h),o.addTargetedAnimation(m,p)}),o.normalize(),o}a(as,"generateCinematicAnimationGroup");async function qi(t,e){return new Promise((i,o)=>{let r=indexedDB.open(t,1);r.addEventListener("error",()=>o()),r.addEventListener("blocked",()=>o()),r.addEventListener("upgradeneeded",()=>{try{e(r.result)}catch(n){o(n)}}),r.addEventListener("success",()=>{i(r.result)})})}a(qi,"openIndexDB");function Xe(t,e,i){return new Promise(o=>{let n=t.transaction(e).objectStore(e).get(i);n.addEventListener("error",()=>{o(null)}),n.addEventListener("success",()=>{o(n.result??null)})})}a(Xe,"getFromIndexDB");async function U(t,e,i){let r=t.transaction(e,"readwrite").objectStore(e).put(i);await new Promise((n,l)=>{r.addEventListener("error",()=>l()),r.addEventListener("success",()=>n())})}a(U,"putInIndexDB");var gn=require("babylonjs");function ss(t){gn.AbstractEngine.OfflineProviderFactory=(e,i,o=!1)=>new $e(t,e,i,o)}a(ss,"setupOfflineProvider");async function Qi(t,e){let i=await new Promise(o=>{let r=new $e(t,e,n=>o(n?r:null),!1)});return await i?.open(),i}a(Qi,"createAndOpenDatabase");var $e=class{static{a(this,"Database")}enableSceneOffline=!0;enableTexturesOffline=!0;name;_database=null;_manifestVersion=null;_loadFilePromises=new Map;constructor(e,i,o,r){this.name=e,r?o(!1):this._checkManifest(i,o)}async _checkManifest(e,i){try{let o=await B(`${e}.manifest?${Date.now()}`);this._manifestVersion=o.version,i(!0)}catch{this.enableSceneOffline=!1,this.enableTexturesOffline=!1,i(!1)}}async open(e,i){try{this._database=await qi(this.name,o=>{o.createObjectStore("files",{keyPath:"url"}),o.createObjectStore("images",{keyPath:"url"}),o.createObjectStore("versions",{keyPath:"url"})}),e?.()}catch{i?.()}}close(){this._database?.close(),this._database=null,this._loadFilePromises.clear()}async loadImage(e,i){if(!this._database){i.src=e;return}let o=null;await Ai(()=>this._manifestVersion!==null);let r=this._loadFilePromises.get(e);if(r)return r.then(l=>{l!==null?i.src=l:i.src=e});let n=new Promise(async l=>{if(await this._getFileVersionForUrl(e)!==this._manifestVersion?(o=await xe(e,"blob"),await Promise.all([U(this._database,"images",{url:e,data:o}),U(this._database,"versions",{url:e,version:this._manifestVersion})])):o=(await Xe(this._database,"images",e))?.data??null,o!==null){let s=URL.createObjectURL(o);i.src=s}else i.src=e;l(i.src)});this._loadFilePromises.set(e,n)}async saveImage(e){if(!this._database)throw new Error("Database is not available");let i=await xe(e,"blob");await Promise.all([U(this._database,"images",{url:e,data:i}),U(this._database,"versions",{url:e,version:this._manifestVersion})])}async isFileMatchingVersion(e){return await this._getFileVersionForUrl(e)===this._manifestVersion}async loadFile(e,i,o,r,n){if(!this._database)return r?.();let l=null;await Ai(()=>this._manifestVersion!==null);let p=this._loadFilePromises.get(e);if(p)return p.then(c=>{c!==null?i(c):r?.()});let s=new Promise(async c=>{await this._getFileVersionForUrl(e)!==this._manifestVersion?(l=await xe(e,n?"arraybuffer":"text",o),await Promise.all([U(this._database,"files",{url:e,data:l}),U(this._database,"versions",{url:e,version:this._manifestVersion})])):l=(await Xe(this._database,"files",e))?.data??null,l!==null?i(l):r?.(),c(l)});this._loadFilePromises.set(e,s)}async saveFile(e,i,o){if(!this._database)throw new Error("Database is not available");let r=await xe(e,i?"arraybuffer":"text",o);await Promise.all([U(this._database,"files",{url:e,data:r}),U(this._database,"versions",{url:e,version:this._manifestVersion})])}async _getFileVersionForUrl(e){return(await Xe(this._database,"versions",e))?.version??null}};var vn=["mp3","wav"],Sn=["babylonbinarymeshdata"],ls=["ktx","ktx2","jpg","jpeg","png","bmp","webp"],yn=["babylon","json"],Ji=["jpg","jpeg","png","bmp","webp"],bn=["bin","ktx","ktx2",...Sn,...vn],cs=[...yn,...Ji,...bn];async function ps(t,e,i){let o=[],r=await B(`${e}scenes-used-files.json`),n=[];if(i?.scenesFilter){n=i.scenesFilter.map(h=>typeof h=="string"?{sceneName:h,disableSounds:!1,disableTextures:!1,disableGeometries:!1}:h);for(let[h,d]of Object.entries(r))n.find(f=>f.sceneName===h)||delete r[h]}let l=0,p=0,s=i?.engine?.textureFormatInUse?i?.engine?.texturesSupported[0]:null,c=Object.values(r).reduce((h,d)=>h+d.length,0);function m(h){++p,i?.onProgress?.(p/c),h?.()}a(m,"notifyProgress");for(let[h,d]of Object.entries(r)){let f=h.replace(".scene",".babylon"),S=await Qi(t,`${e}${f}`);if(!S)continue;let u=n.find(y=>y.sceneName===h);for(let y=0,L=d.length;y<L;++y){let _=d[y],x=_.split(".").pop()?.toLowerCase();if(!x){m();continue}if(Sn.includes(x)&&u?.disableGeometries){m();continue}if(ls.includes(x)&&u?.disableTextures){m();continue}if(vn.includes(x)&&u?.disableSounds){m();continue}if(Ji.includes(x)&&u?.disableTextures){m();continue}if(x==="ktx")if(s){if(!_.endsWith(s)){m();continue}}else{m();continue}if(x==="ktx2"&&!ke()){m();continue}if(o.length>300){try{await Promise.all(o)}catch{}o.splice(0,o.length)}let M=`${e}${_}`;cs.includes(x)&&o.push(new Promise(async N=>{if(await S.isFileMatchingVersion(M))return m(N);try{Ji.includes(x)?i?.disableImages||(await S.saveImage(M),++l):bn.includes(x)?(await S.saveFile(M,!0),++l):yn.includes(x)&&(await S.saveFile(M,!1),++l)}catch{}m(N)}))}await Promise.all(o),S.close()}return await Promise.all(o),{loadedCount:l,processedFilesCount:p}}a(ps,"preloadAssetsToDatabase");0&&(module.exports={AdvancedAssetContainer,AdvancedAssetContainerInstantiatedEntries,Cinematic,Database,NodeParticleSystemSet,VolumetricDebugMode,VolumetricDepthSource,VolumetricDitherMode,VolumetricFogMode,VolumetricLightingRenderingPipeline,VolumetricShadowKind,VolumetricShadowMode,VolumetricStepDistribution,VolumetricTransmittanceMode,_applyScriptsForObject,_getKtx2TextureName,_preloadScriptsAssets,_registerScriptInstance,_removeRegisteredScriptInstance,addExcludedCompressedTexture,animationFromSprite,animationGroupFromScene,applyMeshesLODQuality,applyRagdollJointLimits,applyRenderingConfigurationForCamera,applyScriptOnObject,applyShadowsQuality,applyTexturesQuality,canUseHdr,componentFromScene,computeVolumetricBudget,computeVolumetricShapeKey,configureEngineToUseCompressedTextures,configureMeshDistanceOrScreenCoverage,configureShadowMapRefreshRate,configureShadowMapRenderListPredicate,copyAndParseRagdollConfiguration,createAndOpenDatabase,createDefaultRenderingPipeline,createMotionBlurPostProcess,createSSAO2RenderingPipeline,createSSRRenderingPipeline,createTAARenderingPipeline,createVLSPostProcess,createVolumetricLightingPrePassConfiguration,createVolumetricLightingRenderingPipeline,defaultPipelineCameraConfigurations,disposeDefaultRenderingPipeline,disposeMotionBlurPostProcess,disposeSSAO2RenderingPipeline,disposeSSRRenderingPipeline,disposeTAARenderingPipeline,disposeVLSPostProcess,disposeVolumetricLightingRenderingPipeline,ensureVolumetricLightConfiguration,forceCompileAllSceneMaterials,generateCinematicAnimationGroup,getAllScriptsByClassForObject,getAllVolumetricCandidateLights,getAnimationTypeForObject,getDefaultRenderingPipeline,getDefaultVolumetricLightConfiguration,getDefaultVolumetricLightingConfiguration,getFromIndexDB,getHdrTextureType,getMotionBlurPostProcess,getPowerOfTwoUntil,getSSAO2RenderingPipeline,getSSRRenderingPipeline,getScriptByClassForObject,getTAARenderingPipeline,getTextureUrl,getVLSPostProcess,getVolumetricGeometryBufferDepthTexture,getVolumetricGeometryBufferRenderer,getVolumetricLightConfiguration,getVolumetricLightRange,getVolumetricLightSteps,getVolumetricLightWorldDirection,getVolumetricLightWorldPosition,getVolumetricLightingRenderingPipeline,getVolumetricLightingRenderingPipelineConfiguration,getVolumetricPrePassDepthTexture,getVolumetricPrePassRenderer,guiFromAsset,isAbstractMesh,isAnyParticleSystem,isArcRotateCamera,isBone,isCamera,isCascadedShadowGenerator,isCinematicGroup,isCinematicKey,isCinematicKeyCut,isCinematicKeyEvent,isCinematicSound,isClusteredLightContainer,isDecalMesh,isDirectionalLight,isFreeCamera,isGPUParticleSystem,isGaussianSplattingMesh,isGroundMesh,isHemisphericLight,isInstancedMesh,isLight,isMesh,isNode,isNodeFromStaticGroup,isParticleSystem,isPointLight,isScene,isShadowGenerator,isSoundNode,isSpotLight,isSprite,isTexture,isTransformNode,isUsingKtx2CompressedTextures,isVolumetricLightEnabled,isVolumetricLightSupported,isVolumetricLightingSupported,loadMaterialFromFile,loadScene,markVolumetricLightsDirty,maxVolumetricArrayLights,maxVolumetricDirectionalLights,maxVolumetricShadowSlots,motionBlurPostProcessCameraConfigurations,nodeFromDescendants,nodeFromScene,normalizeAtlasJson,normalizeVolumetricLightConfiguration,normalizeVolumetricLightingConfiguration,onKeyboardEvent,onPointerEvent,openIndexDB,parseCinematic,parseCinematicKeyValue,parseDefaultRenderingPipeline,parseKeyFrameAnimations,parseMotionBlurPostProcess,parseRagdollConfiguration,parseSSAO2RenderingPipeline,parseSSRRenderingPipeline,parseTAARenderingPipeline,parseVLSPostProcess,parseVolumetricLightingRenderingPipeline,particleSystemFromScene,playSpriteAnimationFromName,preloadAssetsToDatabase,putInIndexDB,registerScriptAssetParser,resolveVolumetricDepthSource,resolveVolumetricShadowSlot,saveRenderingConfigurationForCamera,sceneAsset,scriptAssetsCache,scriptAssetsParsers,scriptsDictionary,selectVolumetricLights,serializeDefaultRenderingPipeline,serializeMotionBlurPostProcess,serializeSSAO2RenderingPipeline,serializeSSRRenderingPipeline,serializeTAARenderingPipeline,serializeVLSPostProcess,serializeVolumetricLightingRenderingPipeline,setDefaultRenderingPipelineRef,setMotionBlurPostProcessRef,setSSAO2RenderingPipelineRef,setSSRRenderingPipelineRef,setStaticDecalsEnabled,setTAARenderingPipelineRef,setUseKtx2CompressedTextures,setVLSPostProcessRef,setVolumetricLightingRenderingPipelineConfiguration,setVolumetricLightingRenderingPipelineRef,setupOfflineProvider,soundFromScene,spriteFromSpriteManager,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,supportsVolumetricFloatDepthTexture,taaRenderingPipelineCameraConfigurations,visibleAsAsset,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsKeyMap,visibleAsNumber,visibleAsString,visibleAsTexture,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations,volumetricLightMetadataKey,volumetricLightingPrePassConfigurationName});
2625
+ `)),s}_buildTemporalDefines(e){return this._buildLinearDepthReadDefines(e)}_buildBlurDefines(e){return`${this._buildLinearDepthReadDefines(e)}#define VOL_BLUR_RADIUS ${this._configuration.blurRadius}
2626
+ `}_buildComposeDefines(e){let t=this._buildLinearDepthReadDefines(e);return t+=`#define VOL_DEBUG ${this._configuration.debugMode}
2627
+ `,e.ldrEncode&&(t+=`#define VOL_LDR_ENCODE
2628
+ `),t}_createPostProcess(e){let t=new qo.PostProcess(e.name,e.shaderName,e.uniforms,e.samplers,e.ratio,null,e.samplingMode,this._scene.getEngine(),!1,e.defines,e.textureType,void 0,void 0,!1,e.textureFormat,this._shaderLanguage);return t.autoClear=e.autoClear??!1,t.alphaMode=E.Constants.ALPHA_DISABLE,t}_buildRenderEffects(){let e=this._scene.getEngine(),t=this._configuration,o=this._getEnvironment();this._linearDepthDefines=this._buildLinearDepthDefines(o),this._scatteringDefines=this._buildScatteringDefines(this._selection,o),this._temporalDefines=this._buildTemporalDefines(o),this._blurDefines=this._buildBlurDefines(o),this._composeDefines=this._buildComposeDefines(o),this._linearDepthPostProcess=this._createPostProcess({name:"VolumetricLightingLinearDepth",shaderName:ct,uniforms:["volCameraMinMaxZ","volDepthUnpack","volPassParams"],samplers:["depthSampler"],ratio:1,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._linearDepthDefines,autoClear:!0}),this._linearDepthPostProcess.onApplyObservable.add(r=>this._bindLinearDepth(r)),this._applyPrePassConfiguration(),this._scatteringPostProcess=this._createPostProcess({name:"VolumetricLightingScattering",shaderName:pt,uniforms:La,samplers:jo,ratio:1,samplingMode:_e.Texture.NEAREST_SAMPLINGMODE,textureType:this._linearDepthType,textureFormat:this._linearDepthPacked?E.Constants.TEXTUREFORMAT_RGBA:E.Constants.TEXTUREFORMAT_R,defines:this._scatteringDefines}),this._scatteringPostProcess.onApplyObservable.add(r=>this._bindScattering(r)),this._temporalPostProcess=null,t.temporalAccumulation&&(this._temporalPostProcess=this._createPostProcess({name:"VolumetricLightingTemporal",shaderName:ht,uniforms:Pa,samplers:["volHistorySampler","volLinearDepthSampler"],ratio:t.resolutionScale,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._temporalDefines}),this._temporalPostProcess.onActivateObservable.add(()=>this._prepareHistory()),this._temporalPostProcess.onApplyObservable.add(r=>this._bindTemporal(r))),this._blurPostProcesses=[];for(let r=0;r<t.blurPasses;++r){let n=this._createPostProcess({name:`VolumetricLightingBlur${r}`,shaderName:mt,uniforms:["volCameraMinMaxZ","volDepthRatio","volBlurDirection","volBlurParams","volPassParams"],samplers:["volLinearDepthSampler"],ratio:t.resolutionScale,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._blurDefines});n.onApplyObservable.add(l=>this._bindBlur(l,r)),this._blurPostProcesses.push(n)}this._composePostProcess=this._createPostProcess({name:"VolumetricLightingCompose",shaderName:dt,uniforms:["volCameraMinMaxZ","volDepthRatio","volComposeParams","volPassParams"],samplers:["volSceneSampler","volLinearDepthSampler"],ratio:t.resolutionScale,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._composeDefines}),this._composePostProcess.onApplyObservable.add(r=>this._bindCompose(r)),this.addEffect(new Ce.PostProcessRenderEffect(e,i.SceneColorEffectName,()=>this._linearDepthPostProcess,!0)),this.addEffect(new Ce.PostProcessRenderEffect(e,i.ScatteringEffectName,()=>this._scatteringPostProcess,!0)),this._temporalPostProcess&&this.addEffect(new Ce.PostProcessRenderEffect(e,i.TemporalEffectName,()=>this._temporalPostProcess,!0)),this._blurPostProcesses.length&&this.addEffect(new Ce.PostProcessRenderEffect(e,i.BlurEffectName,()=>this._blurPostProcesses,!0)),this.addEffect(new Ce.PostProcessRenderEffect(e,i.ComposeEffectName,()=>this._composePostProcess,!0)),this._applyMsaaSamples()}_disposePostProcesses(e){[this._linearDepthPostProcess,this._scatteringPostProcess,this._temporalPostProcess,...this._blurPostProcesses,this._composePostProcess].forEach(o=>{o&&(e.forEach(r=>o.dispose(r)),o.dispose())}),this._linearDepthPostProcess=null,this._scatteringPostProcess=null,this._temporalPostProcess=null,this._blurPostProcesses=[],this._composePostProcess=null,this._disposeHistory()}_disposeHistory(){this._historyTextures.forEach(e=>e?.dispose()),this._historyTextures=[null,null],this._historyFrames=[-1,-1]}_prepareHistory(){let e=this._temporalPostProcess,t=this._blurPostProcesses[0]??this._composePostProcess;if(!e||!t)return;++this._temporalFrame;let o=e.width,r=e.height,n=this._historyTextures[0];if(!n||n.width!==o||n.height!==r){this._disposeHistory();let l=this._scene.getEngine();for(let p=0;p<2;++p)this._historyTextures[p]=l.createRenderTargetTexture({width:o,height:r},{generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,type:this._textureType,format:E.Constants.TEXTUREFORMAT_RGBA,samplingMode:E.Constants.TEXTURE_BILINEAR_SAMPLINGMODE,label:`VolumetricLightingHistory${p}`})}this._historyIndex^=1,t.inputTexture=this._historyTextures[this._historyIndex]}_rebuildRenderEffects(){if(this._disposed)return;let e=this._scene.postProcessRenderPipelineManager,t=this._cameras.slice();try{e.detachCamerasFromRenderPipeline(this.name,t),this._disposePostProcesses(t),Object.keys(this._renderEffects).forEach(o=>{delete this._renderEffects[o]}),this._buildRenderEffects()}catch(o){console.error("Failed to rebuild the volumetric lighting rendering pipeline.",o)}finally{try{e.attachCamerasToRenderPipeline(this.name,t)}catch(o){console.error("Failed to re-attach the cameras to the volumetric lighting rendering pipeline.",o)}}this._lightsDirty=!0}_updateSelection(){if(this._disposed||!this._scatteringPostProcess||(++this._frameCount,!(this._lightsDirty||!this._selection||this._frameCount%this._configuration.selectionRefreshRate===0)))return;this._lightsDirty=!1;let t=this._getEnvironment(),o=yi(this._scene,this._camera,this._configuration,this._budget,this._selection);this._selection=o,this._updateIdleState(o);let r=this._buildScatteringDefines(o,t);r!==this._scatteringDefines&&(this._scatteringDefines=r,this._scatteringPostProcess.updateEffect(r));let n=this._buildTemporalDefines(t);n!==this._temporalDefines&&(this._temporalDefines=n,this._temporalPostProcess?.updateEffect(n));let l=this._buildLinearDepthDefines(t);l!==this._linearDepthDefines&&(this._linearDepthDefines=l,this._linearDepthPostProcess?.updateEffect(l));let p=this._buildBlurDefines(t);p!==this._blurDefines&&(this._blurDefines=p,this._blurPostProcesses.forEach(c=>c.updateEffect(p)));let s=this._buildComposeDefines(t);s!==this._composeDefines&&(this._composeDefines=s,this._composePostProcess?.updateEffect(s))}_updateIdleState(e){let t=this._configuration,o=t.ambientColor,r=e.shadowed.length>0||e.unshadowed.length>0||!!e.csm,n=t.ambientIntensity>0&&(o[0]>0||o[1]>0||o[2]>0),l=!r&&!n&&t.extinctionAmount<=0&&t.debugMode===0;l!==this._idle&&(this._idle=l,this._ownsDepthRenderer&&this._depthRenderer&&(this._depthRenderer.enabled=!l,this._setDepthMapRenderedWithCamera(!l)))}_warmUpDepthRenderer(){let e=this._depthRenderer;if(!this._idle||!this._ownsDepthRenderer||!e||!this._depthWarmup.size)return;let t=this._scene.getEngine().getCaps().instancedArrays,o=[],r=ya;for(let n of this._depthWarmup){if(r--<=0)break;if(this._depthWarmup.delete(n),n.isDisposed()||!n.subMeshes?.length)continue;let l=n.getClassName(),p=n.hasThinInstances||l==="InstancedMesh"||l==="InstancedLinesMesh"||t&&(n.instances?.length??0)>0,s=!0;n.subMeshes.forEach(c=>{let h=c.getMaterial();h&&!h.disableDepthWrite&&c.verticesCount>0&&!e.isReady(c,p)&&(s=!1)}),s||o.push(n)}o.forEach(n=>this._depthWarmup.add(n))}_writeLight(e,t,o,r,n,l){let{light:p,config:s}=e,c=t*4;ie(p)?(Fe(p,this._temporaryVector),o[c]=-this._temporaryVector.x,o[c+1]=-this._temporaryVector.y,o[c+2]=-this._temporaryVector.z,o[c+3]=1):(rt(p,this._temporaryVector).subtractInPlace(this._camera.globalPosition),o[c]=this._temporaryVector.x,o[c+1]=this._temporaryVector.y,o[c+2]=this._temporaryVector.z,o[c+3]=ae(p)?2:0),s.useCustomColor?this._temporaryColor.set(s.color[0],s.color[1],s.color[2]):this._temporaryColor.copyFrom(p.diffuse);let h=p.getScaledIntensity()*s.volumeIntensity*1e-5;r[c]=this._temporaryColor.r*h,r[c+1]=this._temporaryColor.g*h,r[c+2]=this._temporaryColor.b*h,r[c+3]=s.anisotropy,ae(p)?(Fe(p,this._temporaryVector),n[c]=this._temporaryVector.x,n[c+1]=this._temporaryVector.y,n[c+2]=this._temporaryVector.z,n[c+3]=Math.cos(p.angle*.5),l[c+1]=p.exponent):(n[c]=0,n[c+1]=0,n[c+2]=1,n[c+3]=-1,l[c+1]=1),l[c]=nt(p,s,this._configuration),l[c+2]=s.castVolumetricShadows?1:0,l[c+3]=s.shadowDarkness}_bindLinearDepth(e){e.setFloat4("volPassParams",this._idle?1:0,0,0,0);let t=null;switch(this._depthSource){case 2:{let o=xe(this._scene);t=o?Ci(o):null;break}case 1:{let o=Ne(this._scene);t=o?Di(o):null;break}default:t=this._depthRenderer?.getDepthMap()??null;break}t&&(e.setTexture("depthSampler",t),this._bindDepthUniforms(e))}_bindScattering(e){let t=this._scene,o=this._camera,r=this._configuration,n=this._selection;if(!n)return;e.setFloat4("volPassParams",this._idle?1:0,0,0,0),this._inverseViewProjection.copyFrom(t.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",o.globalPosition),o.getDirectionToRef(t.useRightHandedSystem?Xo:Wo,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize()),e.setFloat2("volCameraMinMaxZ",o.minZ,o.maxZ),e.setFloat("volFrameIndex",t.getRenderId()%64),e.setFloat("volTemporalOffset",this._frameCount*Ca%1),this._bindDepthRatio(e),e.setFloat4("volFogInfos",r.fogMode,r.fogStart,r.fogEnd,r.fogDensity),this._temporaryColor.set(r.fogColor[0],r.fogColor[1],r.fogColor[2]),e.setColor3("volFogColor",this._temporaryColor),e.setFloat("volLinearFogEps",Math.max((r.fogEnd-r.fogStart)*.02,1e-4)),e.setFloat4("volMedium",r.albedo,r.heightFogBaseHeight,r.heightFogFalloff,0),r.screenSpaceShadows&&(e.setMatrix("volViewProjection",t.getTransformMatrix()),e.setFloat4("volScreenShadowParams",r.screenSpaceShadowMaxDistance,r.screenSpaceShadowBias,r.screenSpaceShadowThickness,0)),this._temporaryColor.set(r.ambientColor[0],r.ambientColor[1],r.ambientColor[2]).scaleInPlace(r.ambientIntensity),e.setColor3("volAmbient",this._temporaryColor);let l=n.unshadowed.length,p=l-n.directionalCount,s=r.temporalAccumulation?1:r.ditherStrength;e.setFloat4("volParams",r.maxDistance,s,r.lightExtinctionClamp,p);for(let c=0;c<l;++c)this._writeLight(n.unshadowed[c],c,this._lightData,this._lightDiffuse,this._lightDirection,this._lightFalloff);if(l){let c=l*4;e.setFloatArray4("volLightData",this._lightData.subarray(0,c)),e.setFloatArray4("volLightDiffuse",this._lightDiffuse.subarray(0,c)),e.setFloatArray4("volLightDirection",this._lightDirection.subarray(0,c)),e.setFloatArray4("volLightFalloff",this._lightFalloff.subarray(0,c))}if(n.shadowed.forEach((c,h)=>{this._writeLight(c.candidate,h,this._shadowLightData,this._shadowLightDiffuse,this._shadowLightDirection,this._shadowLightFalloff);let{generator:m,kind:d,mode:u,mapSize:S}=c.shadow,g=c.candidate.light,y=h*4;this._shadowLightFalloff[y+2]=m.frustumEdgeFalloff;let C=g.getDepthMinZ?.(t.activeCamera)??0,L=g.getDepthMaxZ?.(t.activeCamera)??1;this._shadowInfo[y]=m.getDarkness(),this._shadowInfo[y+1]=d===1?1/S:u===0?0:m.depthScale,this._shadowInfo[y+2]=C,this._shadowInfo[y+3]=C+L,m.getTransformMatrix().copyToArray(this._shadowMatrices,h*16);let x=m.getShadowMapForRendering();d===1?e.setDepthStencilTexture(`volShadowSampler${h}`,x):e.setTexture(`volShadowSampler${h}`,x)}),n.shadowed.length){let c=n.shadowed.length*4;e.setFloatArray4("volShadowLightData",this._shadowLightData.subarray(0,c)),e.setFloatArray4("volShadowLightDiffuse",this._shadowLightDiffuse.subarray(0,c)),e.setFloatArray4("volShadowLightDirection",this._shadowLightDirection.subarray(0,c)),e.setFloatArray4("volShadowLightFalloff",this._shadowLightFalloff.subarray(0,c)),e.setFloatArray4("volShadowInfo",this._shadowInfo.subarray(0,c)),e.setMatrices("volShadowMatrix",this._shadowMatrices.subarray(0,n.shadowed.length*16))}if(n.csm){let{candidate:c,generator:h,cascades:m,kind:d}=n.csm,u=c.light;this._writeLight(c,0,this._csmLightData,this._csmLightDiffuse,this._csmLightDirection,this._csmLightFalloff),e.setFloat4("volCsmLightData",this._csmLightData[0],this._csmLightData[1],this._csmLightData[2],this._csmLightData[3]),e.setFloat4("volCsmLightDiffuse",this._csmLightDiffuse[0],this._csmLightDiffuse[1],this._csmLightDiffuse[2],this._csmLightDiffuse[3]),e.setFloat4("volCsmLightDirection",this._csmLightDirection[0],this._csmLightDirection[1],this._csmLightDirection[2],this._csmLightDirection[3]),e.setFloat4("volCsmLightFalloff",this._csmLightFalloff[0],this._csmLightFalloff[1],h.frustumEdgeFalloff,c.config.shadowDarkness);let S=u.getDepthMinZ?.(t.activeCamera)??1,g=u.getDepthMaxZ?.(t.activeCamera)??1,y=h.getShadowMap()?.getSize().width??1024;e.setFloat4("volCsmInfo",h.getDarkness(),1/y,S,S+g);for(let L=0;L<m;++L)h.getCascadeTransformMatrix(L)?.copyToArray(this._csmMatrices,L*16);e.setMatrices("volCsmMatrices",this._csmMatrices.subarray(0,m*16));let C=h.getShadowMapForRendering();d===1?e.setDepthStencilTexture("volCsmSampler",C):e.setTexture("volCsmSampler",C)}}_bindDepthRatio(e){let t=this._scatteringPostProcess,o=this._temporalPostProcess??this._blurPostProcesses[0]??this._composePostProcess,r=t&&t.width>0?t.width:1,n=t&&t.height>0?t.height:1,l=o&&o.width>0?o.width:r,p=o&&o.height>0?o.height:n;e.setFloat2("volDepthRatio",r/l,n/p)}_bindTemporal(e){let t=this._scene,o=this._camera,r=this._configuration;if(!this._scatteringPostProcess)return;let n=this._historyIndex^1,l=this._historyTextures[n];e._bindTexture("volHistorySampler",l?.texture??t.getEngine().emptyTexture),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",o.minZ,o.maxZ),this._bindDepthRatio(e),this._inverseViewProjection.copyFrom(t.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",o.globalPosition),o.getDirectionToRef(t.useRightHandedSystem?Xo:Wo,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize());let p=o.globalPosition;G.Matrix.TranslationToRef(p.x,p.y,p.z,this._cameraTranslation),this._cameraTranslation.multiplyToRef(this._previousViewProjection,this._previousViewProjectionRelative),e.setMatrix("volPreviousViewProjection",this._previousViewProjectionRelative);let s=!this._idle&&!!l&&this._historyFrames[n]===this._temporalFrame-1,c=s?this._historyEmpty[n]?2:1:0;e.setFloat4("volTemporalParams",r.temporalAccumulationFactor,this._temporalClippingWidth,r.maxDistance,c);let h=s?G.Vector3.Distance(p,this._previousCameraPosition):0;e.setFloat2("volTemporalMotion",h,this._temporalMotionTolerance),this._historyFrames[this._historyIndex]=this._temporalFrame,this._historyEmpty[this._historyIndex]=this._idle,this._previousViewProjection.copyFrom(t.getTransformMatrix()),this._previousCameraPosition.copyFrom(p)}_bindBlur(e,t){this._scatteringPostProcess&&(e.setFloat4("volPassParams",this._idle?1:0,0,0,0),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e),e.setFloat2("volBlurDirection",t%2===0?1:0,t%2===0?0:1),e.setFloat2("volBlurParams",Math.max(this._configuration.blurRadius*.5,.5),this._configuration.blurDepthThreshold))}_bindCompose(e){if(!this._linearDepthPostProcess||!this._scatteringPostProcess)return;let t=this._configuration;e.setTextureFromPostProcess("volSceneSampler",this._linearDepthPostProcess),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat4("volPassParams",this._idle?1:0,0,0,0),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e);let o=this._ldrEncode?1/255:0;e.setFloat4("volComposeParams",t.intensity,t.extinctionAmount,t.upsampleDepthThreshold,o)}};var M=null,Jo=null;function Pi(){return Jo}a(Pi,"getVolumetricLightingRenderingPipelineConfiguration");function ze(i){Jo=i}a(ze,"setVolumetricLightingRenderingPipelineConfiguration");function wa(){return M?.isDisposed&&(M=null),M}a(wa,"getVolumetricLightingRenderingPipeline");function Ta(i){M=i}a(Ta,"setVolumetricLightingRenderingPipelineRef");function Oa(i){let e=i?.getEngine();return e?q.IsSupported(e):!1}a(Oa,"isVolumetricLightingSupported");function wi(){M&&(M.dispose(),M=null)}a(wi,"disposeVolumetricLightingRenderingPipeline");function er(i,e,t){return M=new q("VolumetricLightingRenderingPipeline",i,e),M.msaaSamples=t?.msaaSamples??1,M}a(er,"createVolumetricLightingRenderingPipeline");function Ti(){return M?M.serializeConfiguration():null}a(Ti,"serializeVolumetricLightingRenderingPipeline");function Oi(i,e,t,o){let r=M??er(i,e,o);r.msaaSamples=o?.msaaSamples??1;let n={...t};return n.fogDensity===void 0&&(n.fogDensity=q.GetDefaultFogDensity(r.scene,r.camera)),n.fogEnd===void 0&&(n.fogEnd=q.GetDefaultFogEnd(r.scene,r.camera)),n.screenSpaceShadowMaxDistance===void 0&&(n.screenSpaceShadowMaxDistance=q.GetDefaultFogEnd(r.scene,r.camera)),r.applyConfiguration(be(n)),r}a(Oi,"parseVolumetricLightingRenderingPipeline");function Ea(){M?.markLightsDirty()}a(Ea,"markVolumetricLightsDirty");var ut=require("babylonjs");function Aa(i){ve.set(i,Yt()),ue.set(i,Ht()),fe.set(i,Wt()),Se.set(i,ei()),ye.set(i,ri()),ge.set(i,jt()),ze(Ti())}a(Aa,"saveRenderingConfigurationForCamera");function Ei(i,e,t){Zt(),zt(i.getScene()),Ut(),Jt(),wi(),oi(),$t();let o=ve.get(i);o&&!t?.ssao2Disabled&&qt(i.getScene(),i,o,t);let r=Pi();r&&!t?.volumetricLightingDisabled&&Oi(i.getScene(),i,r,t);let n=ue.get(i);n&&!t?.vlsDisabled&&kt(i.getScene(),n,t);let l=fe.get(i);l&&!t?.ssrDisabled&&Xt(i.getScene(),i,l,t);let p=Se.get(i);p&&!t?.motionBlurDisabled&&ti(i.getScene(),i,p,t);let s=ye.get(i);s&&!t?.defaultPipelineDisabled&&ni(i.getScene(),i,s,e,t);let c=ge.get(i);c&&!t?.taaDisabled&&Kt(i.getScene(),i,c,t)}a(Ei,"applyRenderingConfigurationForCamera");function Ia(i){let e=i.getCaps();return e.textureHalfFloatRender||e.textureFloatRender}a(Ia,"canUseHdr");function K(i){let e=i.getCaps();return e.textureHalfFloatRender?ut.Constants.TEXTURETYPE_HALF_FLOAT:e.textureFloatRender?ut.Constants.TEXTURETYPE_FLOAT:ut.Constants.TEXTURETYPE_UNSIGNED_BYTE}a(K,"getHdrTextureType");var He=require("babylonjs"),tr=require("babylonjs");function ir(i){let e=i.metadata?.physicsAggregate;if(!e)return;let t;F(i)?t=i:Ie(i)&&(t=i.sourceMesh);let o=new tr.PhysicsAggregate(i,e.shape.type,{mesh:t,mass:e.massProperties.mass});o.body.setMassProperties({mass:e.massProperties.mass,inertia:e.massProperties.inertia?He.Vector3.FromArray(e.massProperties.inertia):void 0,centerOfMass:e.massProperties.centerOfMass?He.Vector3.FromArray(e.massProperties.centerOfMass):void 0,inertiaOrientation:e.massProperties.inertiaOrientation?He.Quaternion.FromArray(e.massProperties.inertiaOrientation):void 0}),o.shape.density=e.shape.density,o.body.setMotionType(e.body.motionType),o.shape.material=e.material,i.physicsAggregate=o,i.metadata.physicsAggregate=void 0}a(ir,"configurePhysicsAggregate");function or(i,e){let t=e?.rendering;e.volumetricLightingRenderingPipelineConfiguration&&ze(e.volumetricLightingRenderingPipelineConfiguration),(Array.isArray(t)?t:[]).forEach(r=>{let n=i.getCameraById(r.cameraId);n&&(r.ssao2RenderingPipeline&&ve.set(n,r.ssao2RenderingPipeline),r.vlsPostProcess&&ue.set(n,r.vlsPostProcess),r.ssrRenderingPipeline&&fe.set(n,r.ssrRenderingPipeline),r.motionBlurPostProcess&&Se.set(n,r.motionBlurPostProcess),r.defaultRenderingPipeline&&ye.set(n,r.defaultRenderingPipeline),r.taaRenderingPipeline&&ge.set(n,r.taaRenderingPipeline))})}a(or,"applyRenderingConfigurations");var rr=require("babylonjs");function De(i,e,t){return new Promise((o,r)=>{let n=new rr.WebRequest;n.open("GET",i),n.responseType=e,n.send(),n.addEventListener("progress",l=>{t?.({total:l.total,loaded:l.loaded})}),n.addEventListener("load",()=>{o(e==="text"?n.responseText:n.response)}),n.addEventListener("error",l=>r(l))})}a(De,"loadFile");async function k(i,e){let t=await De(i,"text",e);return JSON.parse(t)}a(k,"loadJsonFile");function Ai(i,e){let t=e.getNodeByName(i);if(t)return t;let o=e.lights.filter(r=>me(r));for(let r of o){let n=r.lights.find(l=>l.name===i);if(n)return n}return null}a(Ai,"getNodeByName");function Le(i,e){let t=e.getNodeById(i);if(t)return t;let o=e.lights.filter(r=>me(r));for(let r of o){let n=r.lights.find(l=>l.id===i);if(n)return n}return null}a(Le,"getNodeById");var ce=require("babylonjs"),nr=require("babylonjs");function Ii(i){let e=nr.Vector3.FromArray(i);return e.equals(ce.Axis.X)?ce.Axis.X:e.equals(ce.Axis.Y)?ce.Axis.Y:e.equals(ce.Axis.Z)?ce.Axis.Z:e}a(Ii,"parseAxis");var ar=require("babylonjs"),Q=require("babylonjs");function sr(i){return i.runtimeConfiguration.forEach(e=>{e.rotationAxis&&(e.rotationAxis=Ii(e.rotationAxis)),e.boneOffsetAxis&&(e.boneOffsetAxis=Ii(e.boneOffsetAxis))}),i}a(sr,"parseRagdollConfiguration");function Mi(i){let e={rootNodeId:i.rootNodeId,skeletonName:i.skeletonName,scalingFactor:i.scalingFactor,runtimeConfiguration:i.runtimeConfiguration.map(t=>({name:t.name,bones:t.bones,width:t.width,depth:t.depth,height:t.height,size:t.size,joint:t.joint,min:t.min,max:t.max,mass:t.mass??1,boxOffset:t.boxOffset,restitution:t.restitution??0,rotationAxis:t.rotationAxis?.slice(),boneOffsetAxis:t.boneOffsetAxis?.slice()}))};return sr(e)}a(Mi,"copyAndParseRagdollConfiguration");function Ma(i,e){let t=i.getConstraints(),r=i._skeleton?.getChildren()[0],n=[];if(e.forEach(p=>{(p.bone!==void 0?[p.bone]:p.bones).forEach(c=>{c!==r?.name&&n.push(p)})}),n.length!==t.length)return ar.Logger.Warn("Failed to apply the ragdoll joint limits: the constraints of the ragdoll don't match its configuration."),0;let l=0;return t.forEach((p,s)=>{let c=n[s];if((c.joint??Q.PhysicsConstraintType.HINGE)!==Q.PhysicsConstraintType.HINGE||c.min===void 0||c.max===void 0)return;let m=Math.min(c.min,c.max),d=Math.max(c.min,c.max),u=p._physicsPlugin;u&&(u.setAxisMode(p,Q.PhysicsConstraintAxis.ANGULAR_X,Q.PhysicsConstraintAxisLimitMode.LIMITED),u.setAxisMinLimit(p,Q.PhysicsConstraintAxis.ANGULAR_X,m*Math.PI/180),u.setAxisMaxLimit(p,Q.PhysicsConstraintAxis.ANGULAR_X,d*Math.PI/180),++l)}),l}a(Ma,"applyRagdollJointLimits");function Ra(i){return new Promise(e=>{setTimeout(()=>e(),i)})}a(Ra,"waitMs");async function Ri(i){for(;!i();)await Ra(150)}a(Ri,"waitUntil");function Vi(i){return i&&JSON.parse(JSON.stringify(i))}a(Vi,"cloneJSObject");var Ni=require("babylonjs"),ur=require("babylonjs"),ft=require("babylonjs"),fr=require("babylonjs"),gr=require("babylonjs"),vr=require("babylonjs"),oe=require("babylonjs"),lr=!1,cr=null,Pe=[],Fi=new Map;function Va(i,e){let t=(0,oe._GetAudioEngine)(null);return new vr._WebAudioStaticSound(i,t,e)}a(Va,"createSoundInstance");function pr(i){if(cr?.remove(),!Pe.length)return;let e=Ni.Vector3.Zero();cr=i.onBeforeRenderObservable.add(()=>{let t=(0,oe._GetAudioEngine)(null).listener.attachedNode;t&&(t.getWorldMatrix().getTranslationToRef(e),Pe.forEach(o=>{o.isEnabled(!1)&&o.autoUpdateSpatial&&o.sound?._isSpatial&&o.isPlaying()&&i.activeCamera&&Ni.Vector3.Distance(e,o.getAbsolutePosition())<=o.sound.spatial.maxDistance&&o.sound.spatial.update()}))})}a(pr,"registerUpdateSoundsObserver");function hr(i,e){e.onDisposeObservable.addOnce(()=>{let t=Pe.indexOf(i);t!==-1&&Pe.splice(t,1)})}a(hr,"registerSoundInstanceCleanup");function mr(i){i.sound&&hr(i,i.sound),i.onDisposeObservable.addOnce(()=>{i.sound?.dispose()})}a(mr,"registerSoundNodeEvents");function Fa(i,e){return new Promise(async(t,o)=>{if(!i.offlineProvider||!ur.Database.IDBStorageEnabled)return(0,oe.CreateSoundBufferAsync)(e).then(r=>t(r)).catch(r=>o(r));i.offlineProvider.loadFile(e,r=>{(0,oe.CreateSoundBufferAsync)(r).then(n=>t(n)).catch(n=>o(n))},void 0,()=>{o(null)},!0)})}a(Fa,"loadSoundBuffer");function Gi(i,e){if(!i.soundRelativePath||!i.sound)return;e.onSoundLoadedObservable=new fr.Observable;let t=Va(i.soundRelativePath,{spatialAutoUpdate:!1});t._initAsync(i.sound.buffer,{spatialAutoUpdate:!0}).then(()=>{t.volume=i.volume,t._isSpatial=i.sound._isSpatial,t._isSpatial&&(t.spatial.attach(e),t.spatial.maxDistance=i.sound.spatial.maxDistance,t.spatial.panningModel=i.sound.spatial.panningModel,t.spatial.distanceModel=i.sound.spatial.distanceModel),e.sound=t,e.soundRelativePath=i.soundRelativePath,e.autoUpdateSpatial=i.autoUpdateSpatial,Pe.push(e),hr(e,t),pr(e.getScene()),e.onSoundLoadedObservable.notifyObservers(e)}),mr(e),dr(e,t)}a(Gi,"configureSourceNodeFrom");function dr(i,e){Object.defineProperty(i,"volume",{get:a(()=>e.volume,"get"),set:a(t=>{e.volume=t},"set")}),Object.defineProperty(i,"playbackRate",{get:a(()=>e.playbackRate,"get"),set:a(t=>{e.playbackRate=t},"set")}),i.isPaused=()=>e.state===ft.SoundState.Paused,i.isPlaying=()=>e.state===ft.SoundState.Started,i.isStopped=()=>e.state===ft.SoundState.Stopped,i.pause=()=>e.pause(),i.resume=()=>e.resume(),i.stop=t=>e.stop(t),i.play=t=>e.play(t),i.setVolume=(t,o)=>e.setVolume(t,o),i.getClassName=()=>"SoundNode",i.setSoundSpatial=t=>new Promise(o=>{e._isSpatial=t,setTimeout(()=>{t&&e.spatial.attach(i),o()})}),i.cloneAsync=async(t,o,r)=>new Promise(n=>{let l=i.clone(t,o,r);Gi(i,l),l.onSoundLoadedObservable.addOnce(()=>{setTimeout(()=>n(l))})})}a(dr,"configureSoundNodePrototype");function Sr(){lr||(lr=!0,(0,gr.AddParser)("SoundNode",(i,e,t,o)=>{i.transformNodes?.forEach(r=>{if(!r.isSoundNode)return;let n=t.transformNodes?.find(l=>l.id===r.id);if(n&&r.soundRelativePath){let l=`${o}${r.soundRelativePath}`;e.addPendingData(l),Fi.has(l)||Fi.set(l,Fa(e,l)),Fi.get(l).then(s=>{(0,oe.CreateSoundAsync)(r.soundRelativePath,s,{spatialAutoUpdate:!1}).then(c=>{if(e.removePendingData(l),n.isDisposed())return c.dispose();c.volume=r.volume,c._isSpatial=r.isSpatial,r.isSpatial&&(c.spatial.attach(n),c.spatial.maxDistance=r.maxDistance,c.spatial.panningModel=r.panningModel,c.spatial.distanceModel=r.distanceModel),n.sound=c,n.soundRelativePath=r.soundRelativePath,n.autoUpdateSpatial=r.autoUpdateSpatial,Pe.push(n),mr(n),dr(n,c),pr(e)})})}})}))}a(Sr,"registerAudioParser");var yr=require("babylonjs");function we(i){let e=new Set;[...i.transformNodes,...i.meshes].forEach(o=>{if(o.metadata?.isStaticGroup){let r=o.getDescendants(!1);r.push(o),r.forEach(n=>{if((ne(n)||te(n)&&!n.isWorldMatrixFrozen)&&n.billboardMode===yr.AbstractMesh.BILLBOARDMODE_NONE&&n.freezeWorldMatrix(),ne(n)){let l=n.material;l&&!l.isFrozen&&!e.has(l)&&(e.add(l),l.onBindObservable.addOnce(()=>{l.freeze()}))}})}})}a(we,"configureTransformNodes");var ke=class{constructor(e,t){this.entries=e;this.namingId=t}entries;namingId;static{a(this,"AdvancedAssetContainerInstantiatedEntries")}get rootNodes(){return this.entries.rootNodes}get skeletons(){return this.entries.skeletons}get animationGroups(){return this.entries.animationGroups}dispose(){this.entries.dispose()}getRootNodeByName(e){let t=`${e}-${this.namingId}`;return this.entries.rootNodes.find(o=>o.name===t)??null}getNodeByName(e){let t=`${e}-${this.namingId}`;for(let o of this.entries.rootNodes){let r=this._recursivelyGetNodeByName(t,o);if(r)return r}return null}_recursivelyGetNodeByName(e,t){if(t.name===e)return t;for(let o of t.getDescendants(!0)){let r=this._recursivelyGetNodeByName(e,o);if(r)return r}return null}getScriptByClassByObjectName(e,t){let o=this.getNodeByName(e);if(o){let r=Te(o,t);if(r?.length===1)return r[0]}return null}};var Bi=require("babylonjs"),Ue=class{static{a(this,"AdvancedAssetContainer")}container;_rootUrl;_scriptsMap;_originalDescendants=[];_nodesMap=new Map;_animationGroupsMap=new Map;constructor(e,t,o){this.container=e,this._rootUrl=t,this._scriptsMap=o,e.populateRootNodes(),e.rootNodes.forEach(r=>{this._originalDescendants.push(r,...r.getDescendants(!1))}),e.animationGroups.forEach(r=>{this._animationGroupsMap.set(r.name,r)}),this._originalDescendants.forEach(r=>{this._nodesMap.set(r,{node:r,metadata:Vi(r.metadata)})})}removeDefault(){this.container.getNodes().forEach(e=>{U.get(e)?.forEach(o=>{gt(e,o)})}),this.container.removeAllFromScene()}getRootNodeByName(e){return this.container.rootNodes.find(t=>t.name===e)??null}getScriptByClassByObjectName(e,t){let o=this.container.getNodes();for(let r of o)if(r.name===e){let n=Te(r,t);if(n?.length===1)return n[0]}return null}instantiate(e){let t=Bi.Tools.RandomId(),o=a(s=>s,"nameFunction"),r=this.container.instantiateModelsToScene(o,!1,{...e,predicate:a(s=>(s.name=`${s.name}@editor-tools@${t}_${s.id}`,e?.predicate?.(s)??!0),"predicate")}),n=new ke(r,t);[...this.container.transformNodes,...this.container.meshes,...this.container.lights,...this.container.cameras,...this.container.animationGroups,...this.container.skeletons].forEach(s=>{let c=s.name.split("@editor-tools@");s.name=c[0]}),r.animationGroups.forEach(s=>{let c=s.name.split("@editor-tools@");s.name=`${c[0]}-${t}`});let p=[];return r.rootNodes.forEach(s=>{p.push(s,...s.getDescendants(!1))}),p.forEach(s=>{let c=s.name.split("@editor-tools@"),h=c[1].split("_").pop();s.name=`${c[0]}-${t}`;let m=this._originalDescendants.find(d=>d.id===h);se(m)&&te(s)&&Gi(m,s),s.id=Bi.Tools.RandomId(),s.metadata=Vi(this._nodesMap.get(m).metadata),s.metadata??={},s.metadata.originalId=h,p.forEach(d=>{d.metadata.scripts?.forEach(u=>{Object.keys(u.values||{}).forEach(g=>{let y=u.values[g];if(y.type==="entity"){y.value===h&&(y.value=s.id),y.value===m.name&&(y.value=s.name);let C=this._animationGroupsMap.get(y.value);C&&(y.value=`${C.name}-${t}`)}})})})}),p.forEach(s=>{H(this.container.scene,s,this._scriptsMap,{namingId:t,rootUrl:this._rootUrl})}),we(this.container.scene),n}};var br=require("babylonjs"),xr=require("babylonjs");async function _r(i,e,t){let o=t.iblIntensity,r=t.environmentIntensity,l=i.split("/").pop().replace(".scene",".babylon"),p=await(0,xr.LoadAssetContainerAsync)(l,t,{rootUrl:e,pluginExtension:".babylon"});return t.onDisposeObservable.addOnce(()=>{p.dispose()}),br.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&t.meshes.forEach(s=>F(s)&&s._checkDelayState()),p.addAllToScene(),t.iblIntensity=o,t.environmentIntensity=r,we(t),p}a(_r,"preloadSceneScriptAsset");async function Cr(i,e){return k(`${e}${i}`)}a(Cr,"preloadCommonScriptAsset");var pe=new Map,We=new Map;function Na(i,e){We.has(i)&&console.warn(`A parser for the extension '${i}' was already registered. It will be overwritten.`),We.set(i,e)}a(Na,"registerScriptAssetParser");async function zi(i,e,t){let o=[e,...e.transformNodes,...e.meshes,...e.lights,...e.cameras],r=pe.get(e);r||(r=new Map,pe.set(e,r)),e.onDisposeObservable.addOnce(()=>{pe.delete(e)}),o.filter(s=>s.metadata?.scripts?.length).map(s=>s.metadata.scripts).flat().forEach(s=>{if(t[s.key]?.default?._SceneAssets?.forEach(h=>{r.get(h.sceneName)||r.set(h.sceneName,null)}),s.values)for(let h in s.values){if(!s.values.hasOwnProperty(h))continue;let m=s.values[h];m.type==="asset"&&m.value&&!r.get(m.value)&&r.set(m.value,null)}});let l=0;for(let s of r.values())s===null&&++l;if(l===0)return l;let p=[];return r.forEach((s,c)=>{r.get(c)||p.push(new Promise(async h=>{try{let m=c.split(".").pop();switch(m){case"scene":let d=await _r(c,i,e);e.onDisposeObservable.addOnce(()=>{d.dispose(),r.delete(c)}),r.set(c,new Ue(d,i,t));break;default:if(We.has(m)){let u=We.get(m);r.set(c,await u({key:c,rootUrl:i,scene:e}));break}else r.set(c,await Cr(c,i));break}}catch(m){console.error(m)}h()}))}),await Promise.all(p),l}a(zi,"_preloadScriptsAssets");var Dr=require("babylonjs"),vt=require("babylonjs"),Lr=require("babylonjs"),St=require("babylonjs"),Pr=require("babylonjs"),wr=require("babylonjs-gui");function re(i,e){return e?`${i}-${e}`:i}a(re,"formatNameWithId");function Hi(i,e,t,o,r){let n=o.constructor;if(!n)return;n._NodesFromScene?.forEach(s=>{o[s.propertyKey.toString()]=Ai(re(s.nodeName,r.namingId),i)}),n._ComponentsFromScene?.length&&i.getEngine().onBeginFrameObservable.addOnce(()=>{n._ComponentsFromScene?.forEach(s=>{let c=[];if([i,...i.transformNodes,...i.meshes,...i.lights,...i.cameras].forEach(m=>{let d=ki(m,s.componentConstructor);d&&c.push(d)}),c.length>1)throw new Error(`Multiple components of type ${n._ComponentsFromScene[0].componentConstructor.name} found in scene for property "${n._ComponentsFromScene[0].propertyKey.toString()}".`);o[s.propertyKey.toString()]=c[0]??null})}),n._NodesFromDescendants?.forEach(s=>{let c=e.getDescendants?.(s.directDescendantsOnly,h=>h.name===re(s.nodeName,r.namingId))[0];o[s.propertyKey.toString()]=c??null}),n._AnimationGroups?.forEach(s=>{o[s.propertyKey.toString()]=i.getAnimationGroupByName(re(s.animationGroupName,r.namingId))}),n._SoundsFromScene?.forEach(s=>{let c=Ai(re(s.soundName,r.namingId),i);c&&se(c)&&(o[s.propertyKey.toString()]=c??null)}),(n._GuiFromAsset??[]).map(async s=>{let c=`${r.rootUrl}assets/${s.pathInAssets}`;try{let h=await k(c),m=wr.AdvancedDynamicTexture.CreateFullscreenUI(h.name,!0,i);m.parseSerializedObject(h.content,!1),o[s.propertyKey.toString()]=m,s.onGuiCreated?.(o,m)}catch(h){throw console.error(`Failed to load GUI from asset: ${c}`),h}}),n._ParticleSystemsFromScene?.forEach(s=>{let c=i.particleSystems?.find(h=>h.name!==re(s.particleSystemName,r.namingId)?!1:s.directDescendantsOnly?h.emitter===e:h);o[s.propertyKey.toString()]=c}),(n._VisibleInInspector??[]).forEach(s=>{let c=s.propertyKey.toString(),h=t.values;if(!h)throw new Error(`No values found for script with key "${t.key}".`);if(h.hasOwnProperty(c)&&h[c].hasOwnProperty("value")){let m=h[c].value;switch(s.configuration.type){case"number":case"boolean":case"keymap":case"string":o[c]=m;break;case"vector2":o[c]=St.Vector2.FromArray(m);break;case"vector3":o[c]=St.Vector3.FromArray(m);break;case"color3":o[c]=vt.Color3.FromArray(m);break;case"color4":o[c]=vt.Color4.FromArray(m);break;case"entity":switch(s.configuration.entityType){case"node":case"sound":o[c]=Le(m,i)??null;break;case"animationGroup":o[c]=i.getAnimationGroupByName(m)??null;break;case"particleSystem":o[c]=i.particleSystems?.find(u=>u.id===m)??null;break}break;case"texture":m&&(o[c]=Lr.Texture.Parse(m,i,r.rootUrl));break;case"asset":if(m){let u=s.configuration.assetType,g=pe.get(i).get(m);switch(u){case"json":case"gui":case"scene":case"navmesh":case"cinematic":o[c]=g;break;case"ragdoll":o[c]=Mi(g);break;case"nodeParticleSystemSet":let y=Pr.NodeParticleSystemSet.Parse(g);o[c]=y;break;case"material":o[c]=Dr.Material.Parse(g,i,r.rootUrl);break}}}}});let l=null,p=null;if(n._PointerEvents?.length){if(n._PointerEvents.find(h=>h.options.mode==="attachedMeshOnly")&&!ne(e))throw new Error('@onPointerEvent with mode "attachedMeshOnly" can only be used on scripts attached to meshes (extends AbstractMesh).');if(n._PointerEvents.find(h=>h.options.mode!=="global")&&!de(e))throw new Error('@onPointerEvent with mode different from "global" can be used only on scripts attached to Node: Mesh, Light, Camera, TransformNode.');l=i.onPointerObservable.add(h=>{let m=null;n._PointerEvents.forEach(d=>{if(!d.eventTypes.includes(h.type))return;let u=d.propertyKey.toString();if(d.options.mode==="global")return o[u]?.(h);m=h.pickInfo,m||(m=i.pick(i.pointerX,i.pointerY,g=>g.isVisible&&g.isPickable&&g.isEnabled(!0)&&!g._masterMesh,!1));let S=m.pickedMesh;if(S&&(d.options.mode==="attachedMeshOnly"&&S===e||d.options.mode==="includeDescendants"&&de(e)&&[e,...e.getDescendants(!1)].find(C=>C===S)))return o[u]?.(h)})})}if(n._KeyboardEvents?.length&&(p=i.onKeyboardObservable.add(s=>{n._KeyboardEvents.forEach(c=>{c.eventTypes.includes(s.type)&&o[c.propertyKey.toString()]?.(s)})})),n._SpritesFromSpriteManager?.length){let s=e;if(!te(s)||!s.isSpriteManager)return console.error("@spriteFromSpriteManager decorator can only be used on SpriteManagerNode.");if(!s.spriteManager)return console.error(`SpriteManagerNode "${s.name}" has no sprite manager assigned.`);n._SpritesFromSpriteManager?.forEach(c=>{let h=s.spriteManager?.sprites.find(m=>m.name===re(c.spriteName,r.namingId))||null;o[c.propertyKey.toString()]=h})}if(n._AnimationsFromSprite?.length){if(!Mt(e))return console.error("@animationFromSprite decorator can only be used in scripts attached on Sprite.");let s=e.metadata?.spriteAnimations;if(!s?.length)return console.error(`Sprite "${e.name}" has no sprite animations assigned.`);n._AnimationsFromSprite.forEach(c=>{let h=s.find(m=>m.name===re(c.animationName,r.namingId));h?o[c.propertyKey.toString()]=h??null:console.warn(`Sprite animation named "${re(c.animationName,r.namingId)}" not found on sprite "${e.name}".`)})}return n._SceneAssets?.forEach(s=>{let c=pe.get(i);o[s.propertyKey.toString()]=c.get(s.sceneName)}),{observers:{pointerObserver:l,keyboardObserver:p}}}a(Hi,"applyDecorators");function H(i,e,t,o){e.metadata?.scripts&&(e.metadata.scripts?.forEach(r=>{if(!r.enabled)return;let n=t[r.key];if(!n)return;let l=n,p={};if(n.default){l=new n.default(e);let s=Hi(i,e,r,l,o);Object.assign(p,s?.observers??{})}l.onStart&&(p.onStartObserver=i.onBeforeRenderObservable.addOnce(()=>l.onStart(e))),l.onUpdate&&(p.onUpdateObserver=i.onBeforeRenderObservable.add(()=>l.onUpdate(e))),Ui(e,l,r.key,p)}),e.metadata.scripts=void 0)}a(H,"_applyScriptsForObject");function Ga(i,e,t){if(t??=i.getScene?.(),!t)throw new Error("Cannot apply script on object: no scene available.");let o=new e(i),r={};return Hi(t,i,{values:{}},o,{rootUrl:""}),o.onStart&&(r.onStartObserver=t.onBeforeRenderObservable.addOnce(()=>o.onStart())),o.onUpdate&&t.onBeforeRenderObservable.add(()=>o.onUpdate()),Ui(i,o,"runtime",r),o}a(Ga,"applyScriptOnObject");var U=new Map;function Ui(i,e,t,o){let r={key:t,observers:o,instance:e};U.has(i)?U.get(i).push(r):U.set(i,[r]),(de(i)||It(i)||Et(i)||se(i))&&i.onDisposeObservable.addOnce((()=>{U.get(i)?.slice()?.forEach(l=>{gt(i,l)}),U.delete(i)}))}a(Ui,"_registerScriptInstance");function gt(i,e){e.observers.onStartObserver?.remove(),e.observers.onUpdateObserver?.remove(),e.observers.pointerObserver?.remove(),e.observers.keyboardObserver?.remove();try{e.instance.onStop?.(i)}catch(r){console.error(`Failed to call onStop for script ${e.key} on object ${i}`,r)}let t=U.get(i),o=t?.indexOf(e)??-1;o!==-1&&t?.splice(o,1)}a(gt,"_removeRegisteredScriptInstance");function Te(i,e){return U.get(i)?.filter(r=>r.instance.constructor===e)?.map(r=>r.instance)??null}a(Te,"getAllScriptsByClassForObject");function ki(i,e){return Te(i,e)?.[0]??null}a(ki,"getScriptByClassForObject");var Or=require("babylonjs"),Tr=!1;function Er(){Tr||(Tr=!0,(0,Or.AddParser)("MeshEditorPlugin",(i,e,t,o)=>{i.meshes?.forEach(r=>{r.instances?.forEach(n=>{let l=t.meshes?.find(p=>p.id===n.id);l&&n.billboardMode!==void 0&&(l.billboardMode=n.billboardMode)})})}))}a(Er,"registerMeshParser");var Ar=!1;function Ba(i){Ar=i}a(Ba,"setUseKtx2CompressedTextures");function Xe(){return Ar}a(Xe,"isUsingKtx2CompressedTextures");function yt(i){return`${i.substring(0,i.lastIndexOf("."))}.ktx2`}a(yt,"_getKtx2TextureName");function za(i){i.setCompressedTextureExclusions([".env",".hdr",".dds"]),i.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}a(za,"configureEngineToUseCompressedTextures");function bt(i,e){i._excludedCompressedTextures&&!i._excludedCompressedTextures?.includes(e)&&i._excludedCompressedTextures?.push(e)}a(bt,"addExcludedCompressedTexture");function Ha(i,e,t){e.loadingTexturesQuality!==i&&(e.loadingTexturesQuality=i,e.textures.forEach(o=>{if(!Me(o)||!o.url)return;let r=xt(o,e);!r||o.url.includes(r)||o.updateURL(t+r)}))}a(Ha,"applyTexturesQuality");function xt(i,e){if(e.loadingTexturesQuality==="high"||!i.metadata?.baseSize)return i.name;let t=i.metadata.baseSize.width,o=i.metadata.baseSize.height,r=t===N(t)||o===N(o),n="";switch(e.loadingTexturesQuality){case"medium":let d=t*.66>>0,u=o*.66>>0;r&&(d=N(d),u=N(u)),n=`_${d}_${u}`;break;case"low":case"very-low":let S=t*.33>>0,g=o*.33>>0;r&&(S=N(S),g=N(g)),n=`_${S}_${g}`;break}let l=i.name;if(!l||!n)return i.name;let p=l.split("/"),s=p.pop();if(!s)return i.name;let c=s.split(".").pop(),m=`${s.replace(`.${c}`,"")}${n}.${c}`;return p.push(m),p.join("/")}a(xt,"getTextureUrl");var Wi=require("babylonjs"),Ir=!1;function Mr(){if(Ir)return;Ir=!0;let i=Wi.SerializationHelper._TextureParser;Wi.SerializationHelper._TextureParser=(e,t,o)=>{Xe()&&(e.name&&(e.name=yt(e.name)),e.url&&(e.url=yt(e.url)));let r=xt(e,t);if(!r)return i(e,t,o);let n=e.name;e.name=r;let l=i(e,t,o);return l&&(l.name=n),l}}a(Mr,"registerTextureParser");function Xi(i){if(!Array.isArray(i.frames)){let e=[];for(let t of Object.keys(i.frames))e.push({filename:t,...i.frames[t]});i.frames=e}}a(Xi,"normalizeAtlasJson");function ka(i,e,t){let r=(i.metadata?.spriteAnimations??[]).find(n=>n.name===e);if(!r)return console.error(`Animation with name "${e}" not found on sprite.`);i.playAnimation(r.from,r.to,r.loop,r.delay,t)}a(ka,"playSpriteAnimationFromName");var Vr=require("babylonjs"),Fr=require("babylonjs"),Nr=require("babylonjs"),Gr=require("babylonjs"),$i=require("babylonjs"),Oe=require("babylonjs"),Br=require("babylonjs"),Rr=!1;function zr(){Rr||(Rr=!0,(0,Br.AddParser)("SpriteMapNode",(i,e,t,o)=>{i.transformNodes?.forEach(r=>{if(!r.isSpriteMap)return;let n=t.transformNodes?.find(s=>s.id===r.id);if(!n)return;n.isSpriteMap=r.isSpriteMap;let l=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(l);let p=new Nr.WebRequest;p.open("GET",l),p.send(),p.addEventListener("load",()=>{e.removePendingData(l);let s=JSON.parse(p.responseText);Xi(s);let c=`${Vr.Tools.GetFolderPath(l)}${s.meta.image}`,h=new $i.Texture(c,e,!1,!1,$i.Texture.NEAREST_NEAREST,null,null,null,!1,Fr.Engine.TEXTUREFORMAT_RGBA),m=new Gr.SpriteMap(n.name,s,h,{layerCount:r.options.layerCount,stageSize:Oe.Vector2.FromArray(r.options.stageSize??[10,1]),outputSize:Oe.Vector2.FromArray(r.options.outputSize??[100,100]),colorMultiply:Oe.Vector3.FromArray(r.options.colorMultiply??[1,1,1]),flipU:!0},e);r.getClassName=()=>"SpriteMapNode",r.tiles.forEach(u=>{for(let S=0,g=u.repeatCount.x+1;S<g;++S)for(let y=0,C=u.repeatCount.y+1;y<C;++y){let L=S*(u.repeatOffset.x+1),x=y*(u.repeatOffset.y+1);m.changeTiles(u.layer,new Oe.Vector2(u.position.x+L,(m.options.stageSize?.y??0)-1-u.position.y-x),u.tile)}});let d=m._output;d.parent=n,n.spriteMap=m})})}))}a(zr,"registerSpriteMapParser");var kr=require("babylonjs"),Ur=require("babylonjs"),_t=require("babylonjs"),Wr=require("babylonjs"),Hr=!1;function Xr(){if(Hr)return;Hr=!0,(0,Wr.RegisterShadowGeneratorSceneComponent)(Ur.ShadowGenerator);let i=(0,_t.GetParser)(kr.SceneComponentConstants.NAME_SHADOWGENERATOR);(0,_t.AddParser)("ShadowGeneratorEditorPlugin",(e,t,o,r)=>{let n=new Map;e.shadowGenerators?.forEach(l=>{if(n.set(l.id,l.mapSize),t.loadingShadowsQuality!=="high"){switch(t.loadingShadowsQuality){case"medium":l.mapSize=l.mapSize*.5;break;case"low":l.mapSize=l.mapSize*.25;break;case"very-low":l.mapSize=l.mapSize*.125;break}l.mapSize=Math.max(128,N(l.mapSize))}}),i?.(e,t,o,r),t.lights.forEach(l=>{let p=l.getShadowGenerator();if(p?.getShadowMap()){let c=p.id,h=n.get(c);h&&(p.originalMapSize=h)}})})}a(Xr,"registerShadowGeneratorParser");var Kr=require("babylonjs"),Zr=require("babylonjs"),Yr=require("babylonjs"),ji=require("babylonjs"),qr=require("babylonjs");function $r(i,e){e?.fogEnabled!==void 0&&(i.fogEnabled=e?.fogEnabled),e?.blendMode!==void 0&&(i.blendMode=e?.blendMode),e?.disableDepthWrite!==void 0&&(i.disableDepthWrite=e?.disableDepthWrite),e?.pixelPerfect!==void 0&&(i.pixelPerfect=e?.pixelPerfect),e?.useLogarithmicDepth!==void 0&&(i.useLogarithmicDepth=e?.useLogarithmicDepth),e?.metadata!==void 0&&(i.metadata=e?.metadata);for(let t of e?.sprites??[]){let o=Zr.Sprite.Parse(t,i);o.uniqueId=t.uniqueId,o.metadata=t.metadata}}a($r,"parseSerializedSpriteManager");var jr=!1;function Qr(){jr||(jr=!0,(0,qr.AddParser)("SpriteManagerNode",(i,e,t,o)=>{i.transformNodes?.forEach(r=>{if(!r.isSpriteManager)return;let n=t.transformNodes?.find(p=>p.id===r.id);if(!n)return;let l=e.getEngine();if(n.isSpriteManager=r.isSpriteManager,r.atlasJsonRelativePath){let p=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(p);let s=new Yr.WebRequest;s.open("GET",p),s.send(),s.addEventListener("load",()=>{e.removePendingData(p);let c=JSON.parse(s.responseText),h=`${Kr.Tools.GetFolderPath(p)}${c.meta.image}`;bt(l,h);let m=new ji.SpriteManager(n.name,h,1e3,64,e,void 0,void 0,!0,c);n.spriteManager=m,n.getClassName=()=>"SpriteManagerNode",r.spriteManager&&$r(m,r.spriteManager)})}else if(r.spriteManager?.textureUrl){bt(l,r.spriteManager.textureUrl);let p=`${o}${r.spriteManager.textureUrl}`,s=new ji.SpriteManager(n.name,p,1e3,{width:r.spriteManager.cellWidth,height:r.spriteManager.cellHeight},e,void 0,void 0,!1);n.spriteManager=s,n.getClassName=()=>"SpriteManagerNode",r.spriteManager&&$r(s,r.spriteManager)}})}))}a(Qr,"registerSpriteManagerParser");var en=require("babylonjs"),tn=require("babylonjs"),Jr=!1;function on(){Jr||(Jr=!0,(0,tn.AddParser)("MorphTargetManagerEditorPlugin",(i,e,t,o)=>{i.morphTargetManagers.forEach(r=>{let l=t.meshes.find(c=>c.id===r.meshId)?.morphTargetManager;if(!l||r.targets.find(c=>!c.delayLoadingFile))return;let s=[];r.targets.forEach(c=>{if(!c.delayLoadingFile)return s.push(Promise.resolve(null));let h=`${o}${c.delayLoadingFile}`;e.addPendingData(h);let m=new en.WebRequest;m.responseType="arraybuffer",m.open("GET",h),m.send(),s.push(new Promise(d=>{m.addEventListener("load",()=>{e.removePendingData(h),d(m.response)})}))}),Promise.all(s).then(c=>{for(let h=0,m=l.numTargets;h<m;++h){let d=l.getTarget(h),u=r.targets[h],S=c[h];if(u.positionsCount){let g=new Float32Array(S,u.positionsOffset,u.positionsCount);d._positions=g,d.setPositions(g)}if(u.normalsCount){let g=new Float32Array(S,u.normalsOffset,u.normalsCount);d._normals=g,d.setNormals(g)}if(u.tangentsCount){let g=new Float32Array(S,u.tangentsOffset,u.tangentsCount);d._tangents=g,d.setTangents(g)}if(u.uvsCount){let g=new Float32Array(S,u.uvsOffset,u.uvsCount);d._uvs=g,d.setUVs(g)}if(u.uv2sCount){let g=new Float32Array(S,u.uv2sOffset,u.uv2sCount);d._uv2s=g,d.setUV2s(g)}}for(let h=0,m=l.numTargets;h<m;++h)l.getTarget(h)._onDataLayoutChanged.notifyObservers()})})}))}a(on,"registerMorphTargetManagerParser");var nn=require("babylonjs"),an=require("babylonjs"),rn=!1;function sn(){rn||(rn=!0,(0,nn.AddParser)("NodeParticleSystemSetEditorPlugin",(i,e,t,o)=>{i.meshes?.forEach(r=>{if(!r.isNodeParticleSystemMesh)return;let n=t.meshes?.find(l=>l.id===r.id);n&&(r.nodeParticleSystemSet.blocks?.forEach(l=>{l.url&&(l.url=`${o}${l.url}`)}),n.nodeParticleSystemSet=an.NodeParticleSystemSet.Parse(r.nodeParticleSystemSet),n.nodeParticleSystemSet.id=r.nodeParticleSystemSet.id,n.nodeParticleSystemSet.uniqueId=r.uniqueId,e.addPendingData(r.id),n.nodeParticleSystemSet.buildAsync(e,!1).then(l=>{e.removePendingData(r.id),n.particleSystemSet=l,l.systems.forEach(p=>{if(At(p)){let s=p._sizeCreation.process;s&&(p._sizeCreation.process=(c,h)=>{s(c,h),c.scale.x*=100,c.scale.y*=100})}}),l.emitterNode=n,l.start()}))})}))}a(sn,"registerNodeParticleSystemSetParser");var ln=require("babylonjs");function cn(i,e){e??=new ln.ClusteredLightContainer("Clustered Light Container",[],i);let t=i.metadata?.clusteredLight;return t&&(t.lights.length>0&&(e.horizontalTiles=t.horizontalTiles,e.verticalTiles=t.verticalTiles,e.depthSlices=t.depthSlices,e.maxRange=t.maxRange),t.lights.forEach(o=>{let r=i.getLightById(o);r&&e?.addLight(r)})),e}a(cn,"configureLights");var hn=require("babylonjs"),Zi=require("babylonjs"),mn=require("babylonjs"),dn=require("babylonjs"),Ki=new Map;async function pn(i,e){let t=i.getWaitingItemsCount();for(;!i.isDisposed&&(!i.isReady()||i.getWaitingItemsCount()>0);){await new Promise(r=>setTimeout(r,150));let o=t-i.getWaitingItemsCount();o===t&&i.textures.forEach(r=>{r.delayLoadState===Zi.Constants.DELAYLOADSTATE_NONE&&(r.delayLoadState=Zi.Constants.DELAYLOADSTATE_LOADED)}),e(o/t)}}a(pn,"waitForWaitingItems");async function Ua(i,e,t,o,r){t.loadingQuality=r?.quality??"high",t.loadingTexturesQuality=r?.texturesQuality??t.loadingQuality,t.loadingShadowsQuality=r?.shadowsQuality??t.loadingQuality,t.loadingLodsQuality=r?.lodsQuality??t.loadingQuality,Er(),Sr(),Mr(),Xr(),on(),zr(),Qr(),sn();let n=Ki.get(t)??{};if(Ki.set(t,n),t.onDisposeObservable.addOnce(()=>{Ki.delete(t)}),await(0,mn.AppendSceneAsync)(`${i}${e}`,t,{pluginExtension:".babylon",onProgress:a(p=>{let s=Math.min(p.loaded/p.total*.5);r?.onProgress?.(s)},"onProgress")}),await pn(t,p=>{r?.onProgress?.(.5+p*.25)}),!r?.skipAssetsPreload){let p=0;do p=await zi(i,t,o);while(p!==0&&!t.isDisposed)}dn.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&t.meshes.forEach(p=>F(p)&&p._checkDelayState());let l=cn(t,n.clusteredLightContainer);n.clusteredLightContainer=l,await pn(t,p=>{r?.onProgress?.(.75+p*.25)}),r?.onProgress?.(1),Ft(t),Nt(t.loadingLodsQuality,t),Gt(t),et(t),t.metadata?.rendering&&(or(t,t.metadata),t.activeCamera&&Ei(t.activeCamera,i,r?.postProcessConfiguration)),t.metadata?.physicsGravity&&t.getPhysicsEngine()?.setGravity(hn.Vector3.FromArray(t.metadata?.physicsGravity)),H(t,t,o,i),t.transformNodes.forEach(p=>{H(t,p,o,i)}),t.meshes.forEach(p=>{ir(p),H(t,p,o,i)}),t.lights.forEach(p=>{H(t,p,o,i)}),l.lights.forEach(p=>{H(t,p,o,i)}),t.cameras.forEach(p=>{H(t,p,o,i)}),t.spriteManagers?.forEach(p=>{p.sprites.forEach(s=>{H(t,s,o,i)})}),we(t)}a(Ua,"loadScene");var un=require("babylonjs");async function Wa(i,e,t){let o=await k(i+e),n=un.Tools.Instantiate(o.customType).Parse(o,t,i);return n.id=o.id,n.uniqueId=o.uniqueId,n}a(Wa,"loadMaterialFromFile");function Xa(i){return Promise.all(i.materials.map(async e=>{let t=e.getBindedMeshes();await Promise.all(t.map(async o=>{Ie(o)||await e.forceCompilationAsync(o,{clipPlane:!!i.clipPlane,useInstances:o.hasInstances})}))}))}a(Xa,"forceCompileAllSceneMaterials");var J=require("babylonjs");function $e(i){if(!isNaN(parseFloat(i))&&isFinite(i))return J.Animation.ANIMATIONTYPE_FLOAT;switch(i?.getClassName?.()){case"Vector2":return J.Animation.ANIMATIONTYPE_VECTOR2;case"Vector3":return J.Animation.ANIMATIONTYPE_VECTOR3;case"Quaternion":return J.Animation.ANIMATIONTYPE_QUATERNION;case"Color3":return J.Animation.ANIMATIONTYPE_COLOR3;case"Color4":return J.Animation.ANIMATIONTYPE_COLOR4;case"Size":return J.Animation.ANIMATIONTYPE_SIZE;case"Matrix":return J.Animation.ANIMATIONTYPE_MATRIX}return null}a($e,"getAnimationTypeForObject");var fn=require("babylonjs");function $a(i){return function(e,t){let o=e.constructor;o._NodesFromScene??=[],o._NodesFromScene.push({propertyKey:t,nodeName:i})}}a($a,"nodeFromScene");function ja(i){return function(e,t){let o=e.constructor;o._ComponentsFromScene??=[],o._ComponentsFromScene.push({propertyKey:t,componentConstructor:i})}}a(ja,"componentFromScene");function Ka(i,e=!1){return function(t,o){let r=t.constructor;r._NodesFromDescendants??=[],r._NodesFromDescendants.push({propertyKey:o,nodeName:i,directDescendantsOnly:e})}}a(Ka,"nodeFromDescendants");function Za(i){return function(e,t){let o=e.constructor;o._AnimationGroups??=[],o._AnimationGroups.push({animationGroupName:i,propertyKey:t})}}a(Za,"animationGroupFromScene");function Ya(i){return function(e,t){let o=e.constructor;o._SceneAssets??=[],o._SceneAssets.push({sceneName:i,propertyKey:t})}}a(Ya,"sceneAsset");function qa(i,e){return function(t,o){let r=t.constructor;r._GuiFromAsset??=[],r._GuiFromAsset.push({propertyKey:o,pathInAssets:i,onGuiCreated:e})}}a(qa,"guiFromAsset");function Qa(i){return function(e,t){let o=e.constructor;o._SoundsFromScene??=[],o._SoundsFromScene.push({propertyKey:t,soundName:i})}}a(Qa,"soundFromScene");function Ja(i,e=!1){return function(t,o){let r=t.constructor;r._ParticleSystemsFromScene??=[],r._ParticleSystemsFromScene.push({propertyKey:o,particleSystemName:i,directDescendantsOnly:e})}}a(Ja,"particleSystemFromScene");function es(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"boolean"}})}}a(es,"visibleAsBoolean");function ts(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"string"}})}}a(ts,"visibleAsString");function is(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"number"}})}}a(is,"visibleAsNumber");function os(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"vector2"}})}}a(os,"visibleAsVector2");function rs(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"vector3"}})}}a(rs,"visibleAsVector3");function ns(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"color3"}})}}a(ns,"visibleAsColor3");function as(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"color4"}})}}a(as,"visibleAsColor4");function ss(i,e,t){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...t,entityType:i,type:"entity"}})}}a(ss,"visibleAsEntity");function ls(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"texture"}})}}a(ls,"visibleAsTexture");function cs(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"keymap"}})}}a(cs,"visibleAsKeyMap");function ps(i,e,t){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...t,assetType:i,type:"asset"}})}}a(ps,"visibleAsAsset");function hs(i,e){return function(t,o){let r=t.constructor;r._PointerEvents??=[],r._PointerEvents.push({propertyKey:o,options:{mode:"global",...e??{}},eventTypes:Array.isArray(i)?i:[i]})}}a(hs,"onPointerEvent");function ms(i){return function(e,t){let o=e.constructor;o._KeyboardEvents??=[],o._KeyboardEvents.push({propertyKey:t,eventTypes:Array.isArray(i)?i:[i]})}}a(ms,"onKeyboardEvent");function ds(i){return function(e,t){let o=e.constructor;o._SpritesFromSpriteManager??=[],o._SpritesFromSpriteManager.push({propertyKey:t,spriteName:i})}}a(ds,"spriteFromSpriteManager");function us(i){return function(e,t){let o=e.constructor;o._AnimationsFromSprite??=[],o._AnimationsFromSprite.push({propertyKey:t,animationName:i})}}a(us,"animationFromSprite");var Ct=require("babylonjs");function Iv(i,e){let t;return i===Ct.Animation.ANIMATIONTYPE_FLOAT?t=e.value:t=e.value.clone(),{value:t,frame:e.frame,interpolation:e.interpolation,inTangent:i===Ct.Animation.ANIMATIONTYPE_FLOAT?e.inTangent:e.inTangent?.clone(),outTangent:i===Ct.Animation.ANIMATIONTYPE_FLOAT?e.outTangent:e.outTangent?.clone()}}a(Iv,"cloneKey");function Dt(i,e){let t=e.split("."),o=i;for(let r=0;r<t.length;++r)o=o[t[r]];return o}a(Dt,"getPropertyValue");function Yi(i,e,t){let o=null;i.onAnimationGroupPlayObservable.add(()=>{o=e.onAfterAnimationsObservable.add(()=>{t()})}),i.onAnimationGroupPauseObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)}),i.onAnimationGroupEndObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)})}a(Yi,"registerAfterAnimationCallback");var ee=require("babylonjs"),Lt=require("babylonjs"),X=require("babylonjs");function fs(i,e){return{name:i.name,framesPerSecond:i.framesPerSecond,outputFramesPerSecond:i.outputFramesPerSecond,tracks:i.tracks.map(t=>{let o=null,r=null;if(t.node?(o=Le(t.node,e),o||(o=e.particleSystems?.find(l=>l.id===t.node)??null)):t.defaultRenderingPipeline?o=Re():t.volumetricLightScattering&&(o=Bt()),t.propertyPath){let l=Dt(o,t.propertyPath);r=$e(l)}let n=null;return t.sound&&(n=Le(t.sound,e)),{node:o,sound:n,propertyPath:t.propertyPath,defaultRenderingPipeline:t.defaultRenderingPipeline,volumetricLightScattering:t.volumetricLightScattering,animationGroupWeight:t.animationGroupWeight,animationGroup:t.animationGroup?e.getAnimationGroupByName(t.animationGroup):null,animationGroups:t.animationGroups,sounds:t.sounds,soundVolume:qi(t.soundVolume??[],ee.Animation.ANIMATIONTYPE_FLOAT),keyFrameEvents:t.keyFrameEvents?.map(l=>{let p={...l};switch(l.data?.type){case"set-enabled":p.data={type:"set-enabled",value:l.data.value,node:Le(l.data.node,e)};break;case"apply-impulse":p.data={type:"apply-impulse",radius:l.data.radius,mesh:e.getMeshById(l.data.mesh),force:X.Vector3.FromArray(l.data.force),contactPoint:X.Vector3.FromArray(l.data.contactPoint)};break}return p}),keyFrameAnimations:o&&r!==null&&qi(t.keyFrameAnimations??[],r)}})}}a(fs,"parseCinematic");function W(i,e){if(i===null)return null;if(i!==void 0)switch(e){case ee.Animation.ANIMATIONTYPE_FLOAT:return i;case ee.Animation.ANIMATIONTYPE_VECTOR2:return X.Vector2.FromArray(i);case ee.Animation.ANIMATIONTYPE_VECTOR3:return X.Vector3.FromArray(i);case ee.Animation.ANIMATIONTYPE_QUATERNION:return X.Quaternion.FromArray(i);case ee.Animation.ANIMATIONTYPE_COLOR3:return Lt.Color3.FromArray(i);case ee.Animation.ANIMATIONTYPE_COLOR4:return Lt.Color4.FromArray(i);case ee.Animation.ANIMATIONTYPE_MATRIX:return X.Matrix.FromArray(i)}}a(W,"parseCinematicKeyValue");function qi(i,e){return i?.map(t=>{let o=t.type==="key"?t:null;if(o)return{...o,value:W(o.value,e),inTangent:W(o.inTangent,e),outTangent:W(o.outTangent,e)};let r=t.type==="cut"?t:null;if(r)return{...r,key1:{...r.key1,value:W(r.key1.value,e),inTangent:W(r.key1.inTangent,e),outTangent:W(r.key1.outTangent,e)},key2:{...r.key2,value:W(r.key2.value,e),inTangent:W(r.key2.inTangent,e),outTangent:W(r.key2.outTangent,e)}};throw new Error(`Unknown key frame type: ${t.type}`)})}a(qi,"parseKeyFrameAnimations");function gn(i,e){i.onEventObservable.notifyObservers(e.eventName)}a(gn,"handleApplyEvent");function vn(i){i.node?.setEnabled(i.value)}a(vn,"handleSetEnabledEvent");var Qi=require("babylonjs"),Sn=Qi.Vector3.Zero();function yn(i,e){let t=e.mesh?[e.mesh]:i.meshes.filter(o=>o.physicsAggregate);e.radius&&(t=t.filter(o=>{let r=o.getBoundingInfo().boundingBox.centerWorld;return Qi.Vector3.Distance(r,e.contactPoint)<=e.radius})),t.forEach(o=>{if(o.physicsAggregate?.body){let r=e.contactPoint.subtract(o.getBoundingInfo().boundingBox.centerWorld);r.multiplyInPlace(e.force),o.physicsAggregate.body.setLinearVelocity(Sn),o.physicsAggregate.body.setAngularVelocity(Sn),o.physicsAggregate.body.applyImpulse(r.negateInPlace(),e.contactPoint)}})}a(yn,"handleApplyImpulseEvent");var bn=require("babylonjs"),xn=require("babylonjs"),je=class extends xn.AnimationGroup{static{a(this,"Cinematic")}onEventObservable=new bn.Observable;onEvent(e,t){this.onEventObservable.add(o=>{e===o&&t()})}};function Ji(i){return i.type==="key"}a(Ji,"isCinematicKey");function Ee(i){return i.type==="cut"}a(Ee,"isCinematicKeyCut");function gs(i){return i.type==="event"}a(gs,"isCinematicKeyEvent");function vs(i){return i.type==="group"}a(vs,"isCinematicGroup");function Ss(i){return i.type==="sound"}a(Ss,"isCinematicSound");var T=require("babylonjs"),Ae=require("babylonjs");function ys(i,e,t){let o=new je(i.name,e);return i.tracks.forEach(r=>{let n=r.animationGroup;if(n&&r.animationGroups?.length){let d=n.clone(`${n.name}-cinematic-temp`),u=e.animationGroups.indexOf(d);u!==-1&&e.animationGroups.splice(u,1),o.onAnimationEndObservable.add(()=>{n.stop(),d.stop()});let S=r.animationGroups.reduce((L,x)=>Math.min(L,x.frame),Number.MAX_VALUE)??0,g=r.animationGroups.reduce((L,x)=>Math.max(L,x.frame+x.endFrame),0)??0,y={frame:S},C=new T.Animation(d.name,"frame",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1);if(C.setKeys([{frame:S,value:0},{frame:g,value:g}]),r.animationGroups.forEach(L=>{C.addEvent(new Ae.AnimationEvent(L.frame,()=>{let x=L.repeatCount??0;if(d.to=L.endFrame,d.speedRatio=L.speed,d.stop(),d.play(x>0),d.from!==L.startFrame&&d.goToFrame(L.startFrame),x){let R=0;d.onAnimationGroupLoopObservable.add(()=>{++R,R>x&&d.stop()})}}))}),o.addTargetedAnimation(C,y),(r.animationGroupWeight?.length??0)>=2&&r.animationGroupWeight.find(x=>Ee(x)?x.key1.value!==1||x.key2.value!==1:x.value!==1)){let x={weight:0},R=new T.Animation(`${d.name}-weights`,"weight",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),B=[];r.animationGroupWeight.forEach(v=>{Ee(v)?(B.push(v.key1),B.push(v.key2)):B.push(v)}),R.setKeys(B),o.addTargetedAnimation(R,x),Yi(o,e,()=>{d.weight=x.weight})}}let l=r.sound;if(!t?.ignoreSounds&&l&&l.sound?.buffer&&r.sounds?.length){let d={dummy:0,volume:0},u=new T.Animation(l.name,"dummy",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;if(r.sounds?.forEach(g=>{let y=g.endFrame-g.startFrame;S=Math.max(S,g.frame+y),u.addEvent(new Ae.AnimationEvent(g.frame,C=>{let x=(C-g.frame+g.startFrame)/i.framesPerSecond;l.play({startOffset:x})},!1)),u.addEvent(new Ae.AnimationEvent(g.frame+y,()=>{l.stop()}))}),u.setKeys([{frame:0,value:0},{frame:S,value:S}]),o.addTargetedAnimation(u,d),(r.soundVolume?.length??0)>=2){let g=new T.Animation(l.name,"volume",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),y=[];r.soundVolume.forEach(C=>{Ee(C)?(y.push(C.key1),y.push(C.key2)):y.push(C)}),g.setKeys(y),o.addTargetedAnimation(g,d),Yi(o,e,()=>{l.volume=d.volume})}}if(r.keyFrameEvents){let d={dummy:0},u=new T.Animation("events","dummy",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;r.keyFrameEvents?.forEach(g=>{S=Math.max(S,g.frame),u.addEvent(new Ae.AnimationEvent(g.frame,()=>{switch(g.data?.type){case"event":gn(o,g.data);break;case"set-enabled":vn(g.data);break;case"apply-impulse":yn(e,g.data);break}}))}),u.setKeys([{frame:0,value:0},{frame:S+1,value:S+1}]),o.addTargetedAnimation(u,d)}let p=r.defaultRenderingPipeline?Re():r.node;if(!p||!r.propertyPath||!r.keyFrameAnimations)return;let s=Dt(p,r.propertyPath),c=$e(s);if(c===null)return;let h=new T.Animation(r.propertyPath,r.propertyPath,60,c,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),m=[];r.keyFrameAnimations?.forEach(d=>{if(Ji(d))return m.push(d);Ee(d)&&(m.push(d.key1),m.push(d.key2),Qe(p)&&r.propertyPath==="position"&&h.addEvent(new Ae.AnimationEvent(d.key1.frame,()=>{let u=Qt();if(!u)return;let S=u.motionStrength;u.motionStrength=0,requestAnimationFrame(()=>{u.motionStrength=S})})))}),h.setKeys(m),o.addTargetedAnimation(h,p)}),o.normalize(),o}a(ys,"generateCinematicAnimationGroup");async function eo(i,e){return new Promise((t,o)=>{let r=indexedDB.open(i,1);r.addEventListener("error",()=>o()),r.addEventListener("blocked",()=>o()),r.addEventListener("upgradeneeded",()=>{try{e(r.result)}catch(n){o(n)}}),r.addEventListener("success",()=>{t(r.result)})})}a(eo,"openIndexDB");function Ke(i,e,t){return new Promise(o=>{let n=i.transaction(e).objectStore(e).get(t);n.addEventListener("error",()=>{o(null)}),n.addEventListener("success",()=>{o(n.result??null)})})}a(Ke,"getFromIndexDB");async function $(i,e,t){let r=i.transaction(e,"readwrite").objectStore(e).put(t);await new Promise((n,l)=>{r.addEventListener("error",()=>l()),r.addEventListener("success",()=>n())})}a($,"putInIndexDB");var _n=require("babylonjs");function bs(i){_n.AbstractEngine.OfflineProviderFactory=(e,t,o=!1)=>new Ze(i,e,t,o)}a(bs,"setupOfflineProvider");async function to(i,e){let t=await new Promise(o=>{let r=new Ze(i,e,n=>o(n?r:null),!1)});return await t?.open(),t}a(to,"createAndOpenDatabase");var Ze=class{static{a(this,"Database")}enableSceneOffline=!0;enableTexturesOffline=!0;name;_database=null;_manifestVersion=null;_loadFilePromises=new Map;constructor(e,t,o,r){this.name=e,r?o(!1):this._checkManifest(t,o)}async _checkManifest(e,t){try{let o=await k(`${e}.manifest?${Date.now()}`);this._manifestVersion=o.version,t(!0)}catch{this.enableSceneOffline=!1,this.enableTexturesOffline=!1,t(!1)}}async open(e,t){try{this._database=await eo(this.name,o=>{o.createObjectStore("files",{keyPath:"url"}),o.createObjectStore("images",{keyPath:"url"}),o.createObjectStore("versions",{keyPath:"url"})}),e?.()}catch{t?.()}}close(){this._database?.close(),this._database=null,this._loadFilePromises.clear()}async loadImage(e,t){if(!this._database){t.src=e;return}let o=null;await Ri(()=>this._manifestVersion!==null);let r=this._loadFilePromises.get(e);if(r)return r.then(l=>{l!==null?t.src=l:t.src=e});let n=new Promise(async l=>{if(await this._getFileVersionForUrl(e)!==this._manifestVersion?(o=await De(e,"blob"),await Promise.all([$(this._database,"images",{url:e,data:o}),$(this._database,"versions",{url:e,version:this._manifestVersion})])):o=(await Ke(this._database,"images",e))?.data??null,o!==null){let s=URL.createObjectURL(o);t.src=s}else t.src=e;l(t.src)});this._loadFilePromises.set(e,n)}async saveImage(e){if(!this._database)throw new Error("Database is not available");let t=await De(e,"blob");await Promise.all([$(this._database,"images",{url:e,data:t}),$(this._database,"versions",{url:e,version:this._manifestVersion})])}async isFileMatchingVersion(e){return await this._getFileVersionForUrl(e)===this._manifestVersion}async loadFile(e,t,o,r,n){if(!this._database)return r?.();let l=null;await Ri(()=>this._manifestVersion!==null);let p=this._loadFilePromises.get(e);if(p)return p.then(c=>{c!==null?t(c):r?.()});let s=new Promise(async c=>{await this._getFileVersionForUrl(e)!==this._manifestVersion?(l=await De(e,n?"arraybuffer":"text",o),await Promise.all([$(this._database,"files",{url:e,data:l}),$(this._database,"versions",{url:e,version:this._manifestVersion})])):l=(await Ke(this._database,"files",e))?.data??null,l!==null?t(l):r?.(),c(l)});this._loadFilePromises.set(e,s)}async saveFile(e,t,o){if(!this._database)throw new Error("Database is not available");let r=await De(e,t?"arraybuffer":"text",o);await Promise.all([$(this._database,"files",{url:e,data:r}),$(this._database,"versions",{url:e,version:this._manifestVersion})])}async _getFileVersionForUrl(e){return(await Ke(this._database,"versions",e))?.version??null}};var Cn=["mp3","wav"],Dn=["babylonbinarymeshdata"],xs=["ktx","ktx2","jpg","jpeg","png","bmp","webp"],Ln=["babylon","json"],io=["jpg","jpeg","png","bmp","webp"],Pn=["bin","ktx","ktx2",...Dn,...Cn],_s=[...Ln,...io,...Pn];async function Cs(i,e,t){let o=[],r=await k(`${e}scenes-used-files.json`),n=[];if(t?.scenesFilter){n=t.scenesFilter.map(m=>typeof m=="string"?{sceneName:m,disableSounds:!1,disableTextures:!1,disableGeometries:!1}:m);for(let[m,d]of Object.entries(r))n.find(u=>u.sceneName===m)||delete r[m]}let l=0,p=0,s=t?.engine?.textureFormatInUse?t?.engine?.texturesSupported[0]:null,c=Object.values(r).reduce((m,d)=>m+d.length,0);function h(m){++p,t?.onProgress?.(p/c),m?.()}a(h,"notifyProgress");for(let[m,d]of Object.entries(r)){let u=m.replace(".scene",".babylon"),S=await to(i,`${e}${u}`);if(!S)continue;let g=n.find(y=>y.sceneName===m);for(let y=0,C=d.length;y<C;++y){let L=d[y],x=L.split(".").pop()?.toLowerCase();if(!x){h();continue}if(Dn.includes(x)&&g?.disableGeometries){h();continue}if(xs.includes(x)&&g?.disableTextures){h();continue}if(Cn.includes(x)&&g?.disableSounds){h();continue}if(io.includes(x)&&g?.disableTextures){h();continue}if(x==="ktx")if(s){if(!L.endsWith(s)){h();continue}}else{h();continue}if(x==="ktx2"&&!Xe()){h();continue}if(o.length>300){try{await Promise.all(o)}catch{}o.splice(0,o.length)}let R=`${e}${L}`;_s.includes(x)&&o.push(new Promise(async B=>{if(await S.isFileMatchingVersion(R))return h(B);try{io.includes(x)?t?.disableImages||(await S.saveImage(R),++l):Pn.includes(x)?(await S.saveFile(R,!0),++l):Ln.includes(x)&&(await S.saveFile(R,!1),++l)}catch{}h(B)}))}await Promise.all(o),S.close()}return await Promise.all(o),{loadedCount:l,processedFilesCount:p}}a(Cs,"preloadAssetsToDatabase");0&&(module.exports={AdvancedAssetContainer,AdvancedAssetContainerInstantiatedEntries,Cinematic,Database,NodeParticleSystemSet,VolumetricDebugMode,VolumetricDepthSource,VolumetricDitherMode,VolumetricFogMode,VolumetricLightingRenderingPipeline,VolumetricShadowKind,VolumetricShadowMode,VolumetricStepDistribution,VolumetricTransmittanceMode,_applyScriptsForObject,_getKtx2TextureName,_preloadScriptsAssets,_registerScriptInstance,_removeRegisteredScriptInstance,addExcludedCompressedTexture,animationFromSprite,animationGroupFromScene,applyMeshesLODQuality,applyRagdollJointLimits,applyRenderingConfigurationForCamera,applyScriptOnObject,applyShadowsQuality,applyTexturesQuality,canUseHdr,componentFromScene,computeVolumetricBudget,computeVolumetricShapeKey,configureEngineToUseCompressedTextures,configureMeshDistanceOrScreenCoverage,configureShadowMapRefreshRate,configureShadowMapRenderListPredicate,copyAndParseRagdollConfiguration,createAndOpenDatabase,createDefaultRenderingPipeline,createMotionBlurPostProcess,createSSAO2RenderingPipeline,createSSRRenderingPipeline,createTAARenderingPipeline,createVLSPostProcess,createVolumetricLightingPrePassConfiguration,createVolumetricLightingRenderingPipeline,defaultPipelineCameraConfigurations,disposeDefaultRenderingPipeline,disposeMotionBlurPostProcess,disposeSSAO2RenderingPipeline,disposeSSRRenderingPipeline,disposeTAARenderingPipeline,disposeVLSPostProcess,disposeVolumetricLightingRenderingPipeline,ensureVolumetricLightConfiguration,forceCompileAllSceneMaterials,generateCinematicAnimationGroup,getAllScriptsByClassForObject,getAllVolumetricCandidateLights,getAnimationTypeForObject,getDefaultRenderingPipeline,getDefaultVolumetricLightConfiguration,getDefaultVolumetricLightingConfiguration,getFromIndexDB,getHdrTextureType,getMotionBlurPostProcess,getPowerOfTwoUntil,getSSAO2RenderingPipeline,getSSRRenderingPipeline,getScriptByClassForObject,getTAARenderingPipeline,getTextureUrl,getVLSPostProcess,getVolumetricGeometryBufferDepthTexture,getVolumetricGeometryBufferRenderer,getVolumetricLightConfiguration,getVolumetricLightRange,getVolumetricLightSteps,getVolumetricLightWorldDirection,getVolumetricLightWorldPosition,getVolumetricLightingRenderingPipeline,getVolumetricLightingRenderingPipelineConfiguration,getVolumetricPrePassDepthTexture,getVolumetricPrePassRenderer,getVolumetricSamplingSteps,guiFromAsset,isAbstractMesh,isAnyParticleSystem,isArcRotateCamera,isBone,isCamera,isCascadedShadowGenerator,isCinematicGroup,isCinematicKey,isCinematicKeyCut,isCinematicKeyEvent,isCinematicSound,isClusteredLightContainer,isDecalMesh,isDirectionalLight,isFreeCamera,isGPUParticleSystem,isGaussianSplattingMesh,isGroundMesh,isHemisphericLight,isInstancedMesh,isLight,isMesh,isNode,isNodeFromStaticGroup,isParticleSystem,isPointLight,isScene,isShadowGenerator,isSoundNode,isSpotLight,isSprite,isSpriteManagerNode,isTexture,isTransformNode,isUsingKtx2CompressedTextures,isVolumetricLightEnabled,isVolumetricLightSupported,isVolumetricLightingSupported,loadMaterialFromFile,loadScene,markVolumetricLightsDirty,maxVolumetricArrayLights,maxVolumetricDirectionalLights,maxVolumetricShadowSlots,motionBlurPostProcessCameraConfigurations,nodeFromDescendants,nodeFromScene,normalizeAtlasJson,normalizeVolumetricLightConfiguration,normalizeVolumetricLightingConfiguration,onKeyboardEvent,onPointerEvent,openIndexDB,parseCinematic,parseCinematicKeyValue,parseDefaultRenderingPipeline,parseKeyFrameAnimations,parseMotionBlurPostProcess,parseRagdollConfiguration,parseSSAO2RenderingPipeline,parseSSRRenderingPipeline,parseTAARenderingPipeline,parseVLSPostProcess,parseVolumetricLightingRenderingPipeline,particleSystemFromScene,playSpriteAnimationFromName,preloadAssetsToDatabase,putInIndexDB,registerScriptAssetParser,resolveVolumetricDepthSource,resolveVolumetricShadowSlot,saveRenderingConfigurationForCamera,sceneAsset,scriptAssetsCache,scriptAssetsParsers,scriptsDictionary,selectVolumetricLights,serializeDefaultRenderingPipeline,serializeMotionBlurPostProcess,serializeSSAO2RenderingPipeline,serializeSSRRenderingPipeline,serializeTAARenderingPipeline,serializeVLSPostProcess,serializeVolumetricLightingRenderingPipeline,setDefaultRenderingPipelineRef,setMotionBlurPostProcessRef,setSSAO2RenderingPipelineRef,setSSRRenderingPipelineRef,setStaticDecalsEnabled,setTAARenderingPipelineRef,setUseKtx2CompressedTextures,setVLSPostProcessRef,setVolumetricLightingRenderingPipelineConfiguration,setVolumetricLightingRenderingPipelineRef,setupOfflineProvider,soundFromScene,spriteFromSpriteManager,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,supportsVolumetricFloatDepthTexture,taaRenderingPipelineCameraConfigurations,visibleAsAsset,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsKeyMap,visibleAsNumber,visibleAsString,visibleAsTexture,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations,volumetricLightMetadataKey,volumetricLightingPrePassConfigurationName,volumetricTemporalSamplesDivider});