babylonjs-editor-tools 5.5.1 → 5.5.2
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.
- package/build/index.node.js +407 -121
- package/build/src/decorators/apply.js +2 -2
- package/build/src/decorators/apply.js.map +1 -1
- package/build/src/decorators/scene.js +16 -16
- package/build/src/decorators/scene.js.map +1 -1
- package/build/src/decorators/sound.js +2 -2
- package/build/src/decorators/sound.js.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/loading/loader.js +21 -7
- package/build/src/loading/loader.js.map +1 -1
- package/build/src/rendering/order.js +110 -0
- package/build/src/rendering/order.js.map +1 -0
- package/build/src/rendering/ssao.js +1 -1
- package/build/src/rendering/ssao.js.map +1 -1
- package/build/src/rendering/tools.js +3 -0
- package/build/src/rendering/tools.js.map +1 -1
- package/build/src/rendering/volumetric/pipeline.js +403 -26
- package/build/src/rendering/volumetric/pipeline.js.map +1 -1
- package/build/src/rendering/volumetric/selector.js +2 -1
- package/build/src/rendering/volumetric/selector.js.map +1 -1
- package/build/src/rendering/volumetric/shaders-wgsl.js +197 -60
- package/build/src/rendering/volumetric/shaders-wgsl.js.map +1 -1
- package/build/src/rendering/volumetric/shaders.js +179 -5
- package/build/src/rendering/volumetric/shaders.js.map +1 -1
- package/build/src/rendering/volumetric/types.js +27 -1
- package/build/src/rendering/volumetric/types.js.map +1 -1
- package/build/src/rendering/volumetric-lighting.js.map +1 -1
- package/build/src/tools/scene.js +18 -5
- package/build/src/tools/scene.js.map +1 -1
- package/declaration/src/decorators/apply.d.ts +8 -4
- package/declaration/src/decorators/scene.d.ts +18 -9
- package/declaration/src/decorators/sound.d.ts +10 -1
- package/declaration/src/index.d.ts +1 -0
- package/declaration/src/loading/loader.d.ts +1 -1
- package/declaration/src/rendering/order.d.ts +31 -0
- package/declaration/src/rendering/volumetric/pipeline.d.ts +83 -1
- package/declaration/src/rendering/volumetric/selector.d.ts +6 -2
- package/declaration/src/rendering/volumetric/shaders-wgsl.d.ts +5 -1
- package/declaration/src/rendering/volumetric/shaders.d.ts +16 -2
- package/declaration/src/rendering/volumetric/types.d.ts +46 -1
- package/declaration/src/rendering/volumetric-lighting.d.ts +1 -1
- package/declaration/src/tools/scene.d.ts +2 -1
- package/package.json +1 -1
package/build/index.node.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
var Ze=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Dn=Object.prototype.hasOwnProperty;var a=(t,e)=>Ze(t,"name",{value:e,configurable:!0});var _n=(t,e)=>{for(var i in e)Ze(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&&Ze(t,r,{get:()=>e[r],enumerable:!(o=Cn(e,r))||o.enumerable});return t};var wn=t=>Pn(Ze({},"__esModule",{value:!0}),t);var hs={};_n(hs,{AdvancedAssetContainer:()=>He,AdvancedAssetContainerInstantiatedEntries:()=>ze,Cinematic:()=>Xe,Database:()=>Ke,NodeParticleSystemSet:()=>cn.NodeParticleSystemSet,VolumetricDebugMode:()=>Lo,VolumetricDepthSource:()=>gi,VolumetricDitherMode:()=>ai,VolumetricFogMode:()=>si,VolumetricLightingRenderingPipeline:()=>Y,VolumetricShadowKind:()=>hi,VolumetricShadowMode:()=>Ao,VolumetricStepDistribution:()=>Co,VolumetricTransmittanceMode:()=>di,_applyScriptsForObject:()=>G,_getKtx2TextureName:()=>ut,_preloadScriptsAssets:()=>Ni,_registerScriptInstance:()=>zi,_removeRegisteredScriptInstance:()=>ht,addExcludedCompressedTexture:()=>gt,animationFromSprite:()=>is,animationGroupFromScene:()=>Na,applyMeshesLODQuality:()=>Mt,applyRagdollJointLimits:()=>xa,applyRenderingConfigurationForCamera:()=>wi,applyScriptOnObject:()=>Pa,applyShadowsQuality:()=>Vn,applyTexturesQuality:()=>Ea,canUseHdr:()=>ba,componentFromScene:()=>Va,computeVolumetricBudget:()=>Me,computeVolumetricShapeKey:()=>Qn,configureEngineToUseCompressedTextures:()=>Oa,configureMeshDistanceOrScreenCoverage:()=>It,configureShadowMapRefreshRate:()=>Qe,configureShadowMapRenderListPredicate:()=>Rt,copyAndParseRagdollConfiguration:()=>Ai,createAndOpenDatabase:()=>Qi,createDefaultRenderingPipeline:()=>xo,createMotionBlurPostProcess:()=>go,createSSAO2RenderingPipeline:()=>fo,createSSRRenderingPipeline:()=>co,createTAARenderingPipeline:()=>mo,createVLSPostProcess:()=>so,createVolumetricLightingPrePassConfiguration:()=>vi,createVolumetricLightingRenderingPipeline:()=>jo,defaultPipelineCameraConfigurations:()=>Se,disposeDefaultRenderingPipeline:()=>Jt,disposeMotionBlurPostProcess:()=>Zt,disposeSSAO2RenderingPipeline:()=>Xt,disposeSSRRenderingPipeline:()=>Bt,disposeTAARenderingPipeline:()=>kt,disposeVLSPostProcess:()=>Ft,disposeVolumetricLightingRenderingPipeline:()=>Di,ensureVolumetricLightConfiguration:()=>_o,forceCompileAllSceneMaterials:()=>Ma,generateCinematicAnimationGroup:()=>ss,getAllScriptsByClassForObject:()=>Pe,getAllVolumetricCandidateLights:()=>To,getAnimationTypeForObject:()=>We,getDefaultRenderingPipeline:()=>Ie,getDefaultVolumetricLightConfiguration:()=>ri,getDefaultVolumetricLightingConfiguration:()=>Je,getFromIndexDB:()=>$e,getHdrTextureType:()=>X,getMotionBlurPostProcess:()=>jt,getPowerOfTwoUntil:()=>F,getSSAO2RenderingPipeline:()=>Hn,getSSRRenderingPipeline:()=>Nn,getScriptByClassForObject:()=>Bi,getTAARenderingPipeline:()=>Bn,getTextureUrl:()=>vt,getVLSPostProcess:()=>Vt,getVolumetricGeometryBufferDepthTexture:()=>yi,getVolumetricGeometryBufferRenderer:()=>Ve,getVolumetricLightConfiguration:()=>ci,getVolumetricLightRange:()=>it,getVolumetricLightSteps:()=>li,getVolumetricLightWorldDirection:()=>Re,getVolumetricLightWorldPosition:()=>tt,getVolumetricLightingRenderingPipeline:()=>ua,getVolumetricLightingRenderingPipelineConfiguration:()=>Li,getVolumetricPrePassDepthTexture:()=>Si,getVolumetricPrePassRenderer:()=>be,guiFromAsset:()=>Ba,isAbstractMesh:()=>re,isAnyParticleSystem:()=>Ot,isArcRotateCamera:()=>Tn,isBone:()=>On,isCamera:()=>Ye,isCascadedShadowGenerator:()=>_t,isCinematicGroup:()=>ns,isCinematicKey:()=>Yi,isCinematicKeyCut:()=>Oe,isCinematicKeyEvent:()=>rs,isCinematicSound:()=>as,isClusteredLightContainer:()=>me,isDecalMesh:()=>to,isDirectionalLight:()=>te,isFreeCamera:()=>An,isGPUParticleSystem:()=>In,isGaussianSplattingMesh:()=>At,isGroundMesh:()=>En,isHemisphericLight:()=>qe,isInstancedMesh:()=>Ae,isLight:()=>eo,isMesh:()=>V,isNode:()=>he,isNodeFromStaticGroup:()=>Tt,isParticleSystem:()=>wt,isPointLight:()=>Lt,isScene:()=>Pt,isShadowGenerator:()=>Dt,isSoundNode:()=>ae,isSpotLight:()=>ne,isSprite:()=>Et,isSpriteManagerNode:()=>Mn,isTexture:()=>Te,isTransformNode:()=>ee,isUsingKtx2CompressedTextures:()=>Ue,isVolumetricLightEnabled:()=>Xn,isVolumetricLightSupported:()=>Jn,isVolumetricLightingSupported:()=>va,loadMaterialFromFile:()=>Ia,loadScene:()=>Ta,markVolumetricLightsDirty:()=>Sa,maxVolumetricArrayLights:()=>$,maxVolumetricDirectionalLights:()=>ni,maxVolumetricShadowSlots:()=>E,motionBlurPostProcessCameraConfigurations:()=>ve,nodeFromDescendants:()=>Fa,nodeFromScene:()=>Ra,normalizeAtlasJson:()=>ki,normalizeVolumetricLightConfiguration:()=>Do,normalizeVolumetricLightingConfiguration:()=>ye,onKeyboardEvent:()=>es,onPointerEvent:()=>Ja,openIndexDB:()=>qi,parseCinematic:()=>os,parseCinematicKeyValue:()=>H,parseDefaultRenderingPipeline:()=>ti,parseKeyFrameAnimations:()=>ji,parseMotionBlurPostProcess:()=>qt,parseRagdollConfiguration:()=>tr,parseSSAO2RenderingPipeline:()=>Kt,parseSSRRenderingPipeline:()=>Ht,parseTAARenderingPipeline:()=>Wt,parseVLSPostProcess:()=>Gt,parseVolumetricLightingRenderingPipeline:()=>Pi,particleSystemFromScene:()=>Ha,playSpriteAnimationFromName:()=>Aa,preloadAssetsToDatabase:()=>ms,putInIndexDB:()=>U,registerScriptAssetParser:()=>_a,resolveVolumetricDepthSource:()=>ot,resolveVolumetricShadowSlot:()=>Io,saveRenderingConfigurationForCamera:()=>ya,sceneAsset:()=>Ga,scriptAssetsCache:()=>ce,scriptAssetsParsers:()=>ke,scriptsDictionary:()=>z,selectVolumetricLights:()=>fi,serializeDefaultRenderingPipeline:()=>ei,serializeMotionBlurPostProcess:()=>Yt,serializeSSAO2RenderingPipeline:()=>$t,serializeSSRRenderingPipeline:()=>zt,serializeTAARenderingPipeline:()=>Ut,serializeVLSPostProcess:()=>Nt,serializeVolumetricLightingRenderingPipeline:()=>_i,setDefaultRenderingPipelineRef:()=>Wn,setMotionBlurPostProcessRef:()=>Un,setSSAO2RenderingPipelineRef:()=>kn,setSSRRenderingPipelineRef:()=>Gn,setStaticDecalsEnabled:()=>Rn,setTAARenderingPipelineRef:()=>zn,setUseKtx2CompressedTextures:()=>wa,setVLSPostProcessRef:()=>Fn,setVolumetricLightingRenderingPipelineConfiguration:()=>Ge,setVolumetricLightingRenderingPipelineRef:()=>ga,setupOfflineProvider:()=>ls,soundFromScene:()=>za,spriteFromSpriteManager:()=>ts,ssaoRenderingPipelineCameraConfigurations:()=>ge,ssrRenderingPipelineCameraConfigurations:()=>fe,supportsVolumetricFloatDepthTexture:()=>Ro,taaRenderingPipelineCameraConfigurations:()=>ue,visibleAsAsset:()=>Qa,visibleAsBoolean:()=>ka,visibleAsColor3:()=>Ka,visibleAsColor4:()=>ja,visibleAsEntity:()=>Za,visibleAsKeyMap:()=>qa,visibleAsNumber:()=>Wa,visibleAsString:()=>Ua,visibleAsTexture:()=>Ya,visibleAsVector2:()=>Xa,visibleAsVector3:()=>$a,vlsPostProcessCameraConfigurations:()=>de,volumetricLightMetadataKey:()=>se,volumetricLightingPrePassConfigurationName:()=>Mo});module.exports=wn(hs);function re(t){switch(t.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}a(re,"isAbstractMesh");function V(t){switch(t.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}a(V,"isMesh");function Ae(t){return t.getClassName?.()==="InstancedMesh"}a(Ae,"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 Te(t){return t?.getClassName?.()==="Texture"}a(Te,"isTexture");function Ye(t){switch(t.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}a(Ye,"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 Lt(t){return t.getClassName?.()==="PointLight"}a(Lt,"isPointLight");function te(t){return t.getClassName?.()==="DirectionalLight"}a(te,"isDirectionalLight");function ne(t){return t.getClassName?.()==="SpotLight"}a(ne,"isSpotLight");function qe(t){return t.getClassName?.()==="HemisphericLight"}a(qe,"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 Dt(t){return t.getClassName?.()==="ShadowGenerator"}a(Dt,"isShadowGenerator");function _t(t){return t.getClassName?.()==="CascadedShadowGenerator"}a(_t,"isCascadedShadowGenerator");function me(t){return t.getClassName?.()==="ClusteredLightContainer"}a(me,"isClusteredLightContainer");function he(t){return re(t)||ee(t)||eo(t)||Ye(t)}a(he,"isNode");function Pt(t){return t.getClassName?.()==="Scene"}a(Pt,"isScene");function wt(t){return t.getClassName?.()==="ParticleSystem"}a(wt,"isParticleSystem");function In(t){return t.getClassName?.()==="GPUParticleSystem"}a(In,"isGPUParticleSystem");function Ot(t){switch(t.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}a(Ot,"isAnyParticleSystem");function Mn(t){return t.getClassName?.()==="SpriteManagerNode"}a(Mn,"isSpriteManagerNode");function Et(t){return t.getClassName?.()==="Sprite"}a(Et,"isSprite");function ae(t){return t.getClassName?.()==="SoundNode"}a(ae,"isSoundNode");function At(t){return t.getClassName?.()==="GaussianSplattingMesh"}a(At,"isGaussianSplattingMesh");function Tt(t){let e=t;for(;e;){if(e.metadata?.isStaticGroup)return!0;e=e.parent}return!1}a(Tt,"isNodeFromStaticGroup");function It(t){t.meshes.forEach(e=>{V(e)&&e.getLODLevels().forEach(i=>{i.mesh&&(i.mesh.originalDistanceOrScreenCoverage=i.distanceOrScreenCoverage)})})}a(It,"configureMeshDistanceOrScreenCoverage");function Mt(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(Mt,"applyMeshesLODQuality");function to(t){return(t.metadata?.decal??null)!==null}a(to,"isDecalMesh");function Rn(t,e){e.meshes.forEach(i=>{to(i)&&Tt(i)&&i.setEnabled(t)})}a(Rn,"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 Rt(t){t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.renderListPredicate=o=>At(o)?!1:io.Vector3.Distance(o.getAbsolutePosition(),e.getAbsolutePosition())<=e.range)})}a(Rt,"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 Vn(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(Vn,"applyShadowsQuality");var ro=require("babylonjs"),no=require("babylonjs"),ao=require("babylonjs"),w=null,de=new Map;function Vt(){return w}a(Vt,"getVLSPostProcess");function Fn(t){w=t}a(Fn,"setVLSPostProcessRef");function Ft(t){w&&t.activeCamera&&(w.dispose(t.activeCamera),w=null)}a(Ft,"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 Nt(){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(Nt,"serializeVLSPostProcess");function Gt(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(Gt,"parseVLSPostProcess");var lo=require("babylonjs"),D=null,fe=new Map;function Nn(){return D}a(Nn,"getSSRRenderingPipeline");function Gn(t){D=t}a(Gn,"setSSRRenderingPipelineRef");function Bt(){D&&(D.dispose(),D=null)}a(Bt,"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 zt(){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(zt,"serializeSSRRenderingPipeline");function Ht(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(Ht,"parseSSRRenderingPipeline");var po=require("babylonjs"),A=null,ue=new Map;function Bn(){return A}a(Bn,"getTAARenderingPipeline");function zn(t){A=t}a(zn,"setTAARenderingPipelineRef");function kt(){A&&(A.dispose(),A=null)}a(kt,"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 Ut(){return A?{factor:A.factor,samples:A.samples,clampHistory:A.clampHistory,reprojectHistory:A.reprojectHistory,disableOnCameraMove:A.disableOnCameraMove}:null}a(Ut,"serializeTAARenderingPipeline");function Wt(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(Wt,"parseTAARenderingPipeline");var ho=require("babylonjs"),P=null,ge=new Map;function Hn(){return P}a(Hn,"getSSAO2RenderingPipeline");function kn(t){P=t}a(kn,"setSSAO2RenderingPipelineRef");function Xt(){P&&(P.dispose(),P=null)}a(Xt,"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 $t(){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($t,"serializeSSAO2RenderingPipeline");function Kt(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(Kt,"parseSSAO2RenderingPipeline");var uo=require("babylonjs"),T=null,ve=new Map;function jt(){return T}a(jt,"getMotionBlurPostProcess");function Un(t){T=t}a(Un,"setMotionBlurPostProcessRef");function Zt(){T&&(T.dispose(),T=null)}a(Zt,"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 Yt(){return T?{isObjectBased:T.isObjectBased,motionStrength:T.motionStrength,motionBlurSamples:T.motionBlurSamples}:null}a(Yt,"serializeMotionBlurPostProcess");function qt(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(qt,"parseMotionBlurPostProcess");var vo=require("babylonjs"),Qt=require("babylonjs"),So=require("babylonjs"),yo=require("babylonjs"),bo=require("babylonjs"),g=null,Se=new Map;function Ie(){return g}a(Ie,"getDefaultRenderingPipeline");function Wn(t){g=t}a(Wn,"setDefaultRenderingPipelineRef");function Jt(){g&&(g.dispose(),g=null)}a(Jt,"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 ei(){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(ei,"serializeDefaultRenderingPipeline");function ti(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);Te(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(ti,"parseDefaultRenderingPipeline");var se="volumetricLighting",E=8,$=256,ni=4,Co=(i=>(i[i.Linear=0]="Linear",i[i.Exponential=1]="Exponential",i))(Co||{}),ai=(o=>(o[o.None=0]="None",o[o.Bayer=1]="Bayer",o[o.InterleavedGradientNoise=2]="InterleavedGradientNoise",o))(ai||{}),si=(o=>(o[o.Exponential=0]="Exponential",o[o.ExponentialSquared=1]="ExponentialSquared",o[o.Linear=2]="Linear",o))(si||{}),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 ri(){return{enabled:!1,volumeIntensity:1,anisotropy:.35,useCustomColor:!1,color:[1,1,1],castVolumetricShadows:!0,shadowDarkness:1,rangeMultiplier:1,priority:0}}a(ri,"getDefaultVolumetricLightConfiguration");function Je(){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(Je,"getDefaultVolumetricLightingConfiguration");function li(t){return t.lightSteps>0?t.lightSteps:Math.max(4,Math.min(64,Math.round(t.steps*.3)))}a(li,"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 ii(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(ii,"normalizeColor");function Do(t){let e=ri();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:ii(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 ye(t){let e=Je();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:ii(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:ii(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(ye,"normalizeVolumetricLightingConfiguration");var oi=new WeakSet;function _o(t){t.metadata??={};let e=t.metadata[se];if(!e||typeof e!="object")return t.metadata[se]=Do(null),oi.add(t.metadata[se]),t.metadata[se];if(oi.has(e))return e;let i=ri();return Object.keys(i).forEach(o=>{e[o]===void 0&&(e[o]=i[o])}),oi.add(e),e}a(_o,"ensureVolumetricLightConfiguration");function ci(t){let e=t.metadata?.[se];return e&&typeof e=="object"?_o(t):null}a(ci,"getVolumetricLightConfiguration");function Xn(t){return t.metadata?.[se]?.enabled===!0}a(Xn,"isVolumetricLightEnabled");var et=require("babylonjs"),Eo=require("babylonjs"),mi=require("babylonjs"),K=require("babylonjs"),hi=(o=>(o[o.Texture2D=0]="Texture2D",o[o.Sampler2DShadow=1]="Sampler2DShadow",o[o.Cube=2]="Cube",o))(hi||{}),Ao=(o=>(o[o.Standard=0]="Standard",o[o.Esm=1]="Esm",o[o.CloseEsm=2]="CloseEsm",o))(Ao||{}),di=(o=>(o[o.Analytic=0]="Analytic",o[o.AnalyticHeight=1]="AnalyticHeight",o[o.Numeric=2]="Numeric",o))(di||{}),Po=10,$n=4,Kn=22,jn=32,Zn=.15;function Me(t,e){let i=t.getCaps(),o=i.maxFragmentUniformVectors||224,r=t.isWebGPU?Math.floor(o/4):o,n=Math.max(224,r)-jn,l=Math.max(8,i.maxTexturesImageUnits||16)-1,p=l>=2,s=p?Kn: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)/$n)));return{maxShadowSlots:c,maxArrayLights:m,maxDirectionalLights:Math.min(ni,m),allowCsm:p}}a(Me,"computeVolumetricBudget");function To(t){let e=[];return t.lights.forEach(i=>{me(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||!Dt(i))return null;let o=i.getShadowMapForRendering();if(!o?.isReady())return null;let r=i.getShadowMap()?.getSize().width??1024,n=o.textureType===mi.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 tt(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(tt,"getVolumetricLightWorldPosition");function Re(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(Re,"getVolumetricLightWorldDirection");function it(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(it,"getVolumetricLightRange");var pi=new et.Vector3,wo=new et.Vector3;function Yn(t,e,i){if(tt(t,i),!ne(t))return e;let o=Math.cos(t.angle*.5);if(o<=.5)return e;let r=e/(2*o);return Re(t,wo),i.addInPlace(wo.scaleInPlace(r)),r}a(Yn,"computeVolumetricLightBounds");function qn(t,e,i){for(let o=0;o<i.length;++o)if(i[o].dotCoordinate(t)<=-e)return!1;return!0}a(qn,"isSphereInFrustum");function Oo(t){return(t.local?64:0)+t.kind*16+t.mode*4+(t.packed?1:0)}a(Oo,"getShadowSlotSignature");function fi(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=ci(v);if(!R?.enabled)return;if(n.candidateCount++,qe(v)||!v.isEnabled()||v.intensity<=0||R.volumeIntensity<=0){n.perLight.set(v.uniqueId,{state:"disabled",slot:-1,reason:qe(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),pe=R.priority*1e3;if(W)pe+=1e6;else{let je=Math.min(it(v,R,i),i.maxDistance),Ct=Yn(v,je,pi);if(!qn(pi,Ct,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,et.Vector3.Distance(pi,p)-Ct);pe+=R.volumeIntensity*v.intensity*Math.min(4,Ct/xn)}s.push({light:v,config:R,isClustered:C,typeId:v.getTypeID(),score:pe})}),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(_t(W)&&o.allowCsm){let je=W.getShadowMapForRendering();if(!f&&je?.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:je.textureType===mi.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 pe=Io(C,t);if(!pe){d.set(C.uniqueId,"the shadow map of the light is not ready yet."),h.push(v);return}m.push({candidate:v,shadow:pe})});function S(v){let C=v.candidate.score;return c.get(v.candidate.light.uniqueId)===void 0?C:C+Math.abs(C)*Zn}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(fi,"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 Jn(t){return Lt(t)||ne(t)||te(t)}a(Jn,"isVolumetricLightSupported");var ui=require("babylonjs"),ea=0,gi=(o=>(o[o.DepthRenderer=0]="DepthRenderer",o[o.GeometryBuffer=1]="GeometryBuffer",o[o.PrePass=2]="PrePass",o))(gi||{}),Mo="volumetricLighting";function vi(){return{name:Mo,enabled:!1,texturesRequired:[ui.Constants.PREPASS_DEPTH_TEXTURE_TYPE]}}a(vi,"createVolumetricLightingPrePassConfiguration");function be(t){return t.prePassRenderer??null}a(be,"getVolumetricPrePassRenderer");function Ve(t){return t.geometryBufferRenderer??null}a(Ve,"getVolumetricGeometryBufferRenderer");function Ro(t){let e=t.getCaps();return e.textureFloat&&e.textureFloatLinearFiltering||e.textureHalfFloat&&e.textureHalfFloatLinearFiltering}a(Ro,"supportsVolumetricFloatDepthTexture");function ot(t){return Ro(t.getEngine())?be(t)?.isSupported?2:Ve(t)?.isSupported?1:0:0}a(ot,"resolveVolumetricDepthSource");function Si(t){let e=t.getIndex(ui.Constants.PREPASS_DEPTH_TEXTURE_TYPE);return e===void 0||e<0?null:t.getRenderTarget()?.textures?.[e]??null}a(Si,"getVolumetricPrePassDepthTexture");function yi(t){if(!t.enableDepth)return null;let e=t.getTextureIndex(ea);return e<0?null:t.getGBuffer()?.textures?.[e]??null}a(yi,"getVolumetricGeometryBufferDepthTexture");var rt=`
|
|
1
|
+
var Qe=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var Vn=Object.getOwnPropertyNames;var Fn=Object.prototype.hasOwnProperty;var a=(t,e)=>Qe(t,"name",{value:e,configurable:!0});var Nn=(t,e)=>{for(var i in e)Qe(t,i,{get:e[i],enumerable:!0})},Gn=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vn(e))!Fn.call(t,o)&&o!==i&&Qe(t,o,{get:()=>e[o],enumerable:!(r=Rn(e,o))||r.enumerable});return t};var Bn=t=>Gn(Qe({},"__esModule",{value:!0}),t);var Es={};Nn(Es,{AdvancedAssetContainer:()=>We,AdvancedAssetContainerInstantiatedEntries:()=>Ue,Cinematic:()=>Ke,Database:()=>Ye,NodeParticleSystemSet:()=>xn.NodeParticleSystemSet,VolumetricDebugMode:()=>gi,VolumetricDepthSource:()=>Li,VolumetricDitherMode:()=>ui,VolumetricFogMode:()=>fi,VolumetricLightingRenderingPipeline:()=>q,VolumetricShadowKind:()=>xi,VolumetricShadowMode:()=>Bo,VolumetricStepDistribution:()=>Ao,VolumetricTransmittanceMode:()=>_i,_applyScriptsForObject:()=>H,_getKtx2TextureName:()=>xt,_preloadScriptsAssets:()=>Wi,_registerScriptInstance:()=>ji,_removeRegisteredScriptInstance:()=>St,addExcludedCompressedTexture:()=>_t,animationFromSprite:()=>bs,animationGroupFromScene:()=>es,applyMeshesLODQuality:()=>Bt,applyRagdollJointLimits:()=>Ba,applyRenderingConfigurationForCamera:()=>Ri,applyScriptOnObject:()=>Wa,applyShadowsQuality:()=>jn,applyTexturesQuality:()=>ja,canUseHdr:()=>Ga,componentFromScene:()=>is,computeVolumetricBudget:()=>Fe,computeVolumetricShapeKey:()=>pa,configureEngineToUseCompressedTextures:()=>$a,configureMeshDistanceOrScreenCoverage:()=>Gt,configureShadowMapRefreshRate:()=>tt,configureShadowMapRenderListPredicate:()=>zt,copyAndParseRagdollConfiguration:()=>Ni,createAndOpenDatabase:()=>no,createDefaultRenderingPipeline:()=>Eo,createMotionBlurPostProcess:()=>Lo,createSSAO2RenderingPipeline:()=>Co,createSSRRenderingPipeline:()=>yo,createTAARenderingPipeline:()=>xo,createVLSPostProcess:()=>vo,createVolumetricLightingPrePassConfiguration:()=>Pi,createVolumetricLightingRenderingPipeline:()=>ar,defaultPipelineCameraConfigurations:()=>be,disposeDefaultRenderingPipeline:()=>si,disposeMotionBlurPostProcess:()=>oi,disposeSSAO2RenderingPipeline:()=>Jt,disposeSSRRenderingPipeline:()=>jt,disposeTAARenderingPipeline:()=>Yt,disposeVLSPostProcess:()=>Wt,disposeVolumetricLightingRenderingPipeline:()=>Ai,ensureVolumetricLightConfiguration:()=>Ro,forceCompileAllSceneMaterials:()=>qa,generateCinematicAnimationGroup:()=>Ls,getAllScriptsByClassForObject:()=>Te,getAllVolumetricCandidateLights:()=>zo,getAnimationTypeForObject:()=>je,getDefaultRenderingPipeline:()=>Ve,getDefaultVolumetricLightConfiguration:()=>mi,getDefaultVolumetricLightingConfiguration:()=>rt,getFromIndexDB:()=>Ze,getHdrTextureType:()=>K,getMotionBlurPostProcess:()=>ii,getPowerOfTwoUntil:()=>N,getSSAO2RenderingPipeline:()=>Jn,getSSRRenderingPipeline:()=>Zn,getScriptByClassForObject:()=>$i,getTAARenderingPipeline:()=>qn,getTextureUrl:()=>Ct,getVLSPostProcess:()=>Ut,getVolumetricGeometryBufferDepthTexture:()=>Oi,getVolumetricGeometryBufferRenderer:()=>Ge,getVolumetricLightConfiguration:()=>Si,getVolumetricLightRange:()=>st,getVolumetricLightSteps:()=>Io,getVolumetricLightWorldDirection:()=>Ne,getVolumetricLightWorldPosition:()=>at,getVolumetricLightingRenderingPipeline:()=>Ma,getVolumetricLightingRenderingPipelineConfiguration:()=>Ei,getVolumetricPrePassDepthTexture:()=>wi,getVolumetricPrePassRenderer:()=>_e,getVolumetricSamplingSteps:()=>vi,guiFromAsset:()=>os,isAbstractMesh:()=>ne,isAnyParticleSystem:()=>Rt,isArcRotateCamera:()=>Un,isBone:()=>zn,isCamera:()=>Je,isCascadedShadowGenerator:()=>At,isCinematicGroup:()=>Cs,isCinematicKey:()=>oo,isCinematicKeyCut:()=>Ae,isCinematicKeyEvent:()=>_s,isCinematicSound:()=>Ds,isClusteredLightContainer:()=>me,isDecalMesh:()=>lo,isDirectionalLight:()=>ie,isFreeCamera:()=>kn,isGPUParticleSystem:()=>Wn,isGaussianSplattingMesh:()=>Ft,isGroundMesh:()=>Hn,isHemisphericLight:()=>et,isInstancedMesh:()=>Me,isLight:()=>so,isMesh:()=>F,isNode:()=>de,isNodeFromStaticGroup:()=>Nt,isParticleSystem:()=>Mt,isPointLight:()=>Tt,isScene:()=>It,isShadowGenerator:()=>Et,isSoundNode:()=>se,isSpotLight:()=>ae,isSprite:()=>Vt,isSpriteManagerNode:()=>Xn,isTexture:()=>Re,isTransformNode:()=>te,isUsingKtx2CompressedTextures:()=>$e,isVolumetricLightEnabled:()=>oa,isVolumetricLightSupported:()=>ha,isVolumetricLightingSupported:()=>Va,keepRenderingPipelinesOrdered:()=>kt,loadMaterialFromFile:()=>Ya,loadScene:()=>Za,markVolumetricLightsDirty:()=>Fa,maxVolumetricArrayLights:()=>Z,maxVolumetricDirectionalLights:()=>di,maxVolumetricShadowSlots:()=>T,motionBlurPostProcessCameraConfigurations:()=>ye,nodeFromDescendants:()=>Ja,nodeFromScene:()=>Qa,normalizeAtlasJson:()=>Zi,normalizeVolumetricLightConfiguration:()=>Mo,normalizeVolumetricLightingConfiguration:()=>xe,onKeyboardEvent:()=>Ss,onPointerEvent:()=>vs,openIndexDB:()=>ro,parseCinematic:()=>xs,parseCinematicKeyValue:()=>W,parseDefaultRenderingPipeline:()=>ci,parseKeyFrameAnimations:()=>to,parseMotionBlurPostProcess:()=>ni,parseRagdollConfiguration:()=>dr,parseSSAO2RenderingPipeline:()=>ti,parseSSRRenderingPipeline:()=>Zt,parseTAARenderingPipeline:()=>Qt,parseVLSPostProcess:()=>$t,parseVolumetricLightingRenderingPipeline:()=>Mi,particleSystemFromScene:()=>ns,playSpriteAnimationFromName:()=>Ka,preloadAssetsToDatabase:()=>Ts,putInIndexDB:()=>$,registerScriptAssetParser:()=>Ua,renderingPipelinesOrder:()=>it,resolveVolumetricDepthSource:()=>lt,resolveVolumetricShadowSlot:()=>Ho,saveRenderingConfigurationForCamera:()=>Na,sceneAsset:()=>ts,scriptAssetsCache:()=>pe,scriptAssetsParsers:()=>Xe,scriptsDictionary:()=>U,selectVolumetricLights:()=>Ci,serializeDefaultRenderingPipeline:()=>li,serializeMotionBlurPostProcess:()=>ri,serializeSSAO2RenderingPipeline:()=>ei,serializeSSRRenderingPipeline:()=>Kt,serializeTAARenderingPipeline:()=>qt,serializeVLSPostProcess:()=>Xt,serializeVolumetricLightingRenderingPipeline:()=>Ii,setDefaultRenderingPipelineRef:()=>ia,setMotionBlurPostProcessRef:()=>ta,setSSAO2RenderingPipelineRef:()=>ea,setSSRRenderingPipelineRef:()=>Yn,setStaticDecalsEnabled:()=>$n,setTAARenderingPipelineRef:()=>Qn,setUseKtx2CompressedTextures:()=>Xa,setVLSPostProcessRef:()=>Kn,setVolumetricLightingRenderingPipelineConfiguration:()=>He,setVolumetricLightingRenderingPipelineRef:()=>Ra,setupOfflineProvider:()=>Ps,sortCameraPostProcesses:()=>mo,soundFromScene:()=>rs,spriteFromSpriteManager:()=>ys,ssaoRenderingPipelineCameraConfigurations:()=>Se,ssrRenderingPipelineCameraConfigurations:()=>ge,supportsVolumetricFloatDepthTexture:()=>Uo,taaRenderingPipelineCameraConfigurations:()=>ve,visibleAsAsset:()=>gs,visibleAsBoolean:()=>as,visibleAsColor3:()=>hs,visibleAsColor4:()=>ms,visibleAsEntity:()=>ds,visibleAsKeyMap:()=>fs,visibleAsNumber:()=>ls,visibleAsString:()=>ss,visibleAsTexture:()=>us,visibleAsVector2:()=>cs,visibleAsVector3:()=>ps,vlsPostProcessCameraConfigurations:()=>fe,volumetricLightMetadataKey:()=>le,volumetricLightingPrePassConfigurationName:()=>ko,volumetricTemporalSamplesDivider:()=>ot});module.exports=Bn(Es);function ne(t){switch(t.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}a(ne,"isAbstractMesh");function F(t){switch(t.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}a(F,"isMesh");function Me(t){return t.getClassName?.()==="InstancedMesh"}a(Me,"isInstancedMesh");function zn(t){return t.getClassName?.()==="Bone"}a(zn,"isBone");function Hn(t){return t.getClassName?.()==="GroundMesh"}a(Hn,"isGroundMesh");function te(t){return t.getClassName?.()==="TransformNode"}a(te,"isTransformNode");function Re(t){return t?.getClassName?.()==="Texture"}a(Re,"isTexture");function Je(t){switch(t.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}a(Je,"isCamera");function kn(t){switch(t.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}a(kn,"isFreeCamera");function Un(t){return t.getClassName?.()==="ArcRotateCamera"}a(Un,"isArcRotateCamera");function Tt(t){return t.getClassName?.()==="PointLight"}a(Tt,"isPointLight");function ie(t){return t.getClassName?.()==="DirectionalLight"}a(ie,"isDirectionalLight");function ae(t){return t.getClassName?.()==="SpotLight"}a(ae,"isSpotLight");function et(t){return t.getClassName?.()==="HemisphericLight"}a(et,"isHemisphericLight");function so(t){switch(t.getClassName?.()){case"Light":case"PointLight":case"SpotLight":case"DirectionalLight":case"HemisphericLight":return!0}return!1}a(so,"isLight");function Et(t){return t.getClassName?.()==="ShadowGenerator"}a(Et,"isShadowGenerator");function At(t){return t.getClassName?.()==="CascadedShadowGenerator"}a(At,"isCascadedShadowGenerator");function me(t){return t.getClassName?.()==="ClusteredLightContainer"}a(me,"isClusteredLightContainer");function de(t){return ne(t)||te(t)||so(t)||Je(t)}a(de,"isNode");function It(t){return t.getClassName?.()==="Scene"}a(It,"isScene");function Mt(t){return t.getClassName?.()==="ParticleSystem"}a(Mt,"isParticleSystem");function Wn(t){return t.getClassName?.()==="GPUParticleSystem"}a(Wn,"isGPUParticleSystem");function Rt(t){switch(t.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}a(Rt,"isAnyParticleSystem");function Xn(t){return t.getClassName?.()==="SpriteManagerNode"}a(Xn,"isSpriteManagerNode");function Vt(t){return t.getClassName?.()==="Sprite"}a(Vt,"isSprite");function se(t){return t.getClassName?.()==="SoundNode"}a(se,"isSoundNode");function Ft(t){return t.getClassName?.()==="GaussianSplattingMesh"}a(Ft,"isGaussianSplattingMesh");function Nt(t){let e=t;for(;e;){if(e.metadata?.isStaticGroup)return!0;e=e.parent}return!1}a(Nt,"isNodeFromStaticGroup");function Gt(t){t.meshes.forEach(e=>{F(e)&&e.getLODLevels().forEach(i=>{i.mesh&&(i.mesh.originalDistanceOrScreenCoverage=i.distanceOrScreenCoverage)})})}a(Gt,"configureMeshDistanceOrScreenCoverage");function Bt(t,e){e.meshes.forEach(i=>{F(i)&&i.getLODLevels().forEach(r=>{if(r.mesh?.originalDistanceOrScreenCoverage)switch(t){case"very-low":r.distanceOrScreenCoverage=r.mesh.originalDistanceOrScreenCoverage*.125;break;case"low":r.distanceOrScreenCoverage=r.mesh.originalDistanceOrScreenCoverage*.25;break;case"medium":r.distanceOrScreenCoverage=r.mesh.originalDistanceOrScreenCoverage*.5;break;case"high":r.distanceOrScreenCoverage=r.mesh.originalDistanceOrScreenCoverage;break}})})}a(Bt,"applyMeshesLODQuality");function lo(t){return(t.metadata?.decal??null)!==null}a(lo,"isDecalMesh");function $n(t,e){e.meshes.forEach(i=>{lo(i)&&Nt(i)&&i.setEnabled(t)})}a($n,"setStaticDecalsEnabled");function N(t){let e=1;for(;e<=t;)e<<=1;return e>>1}a(N,"getPowerOfTwoUntil");var co=require("babylonjs"),po=require("babylonjs");function zt(t){t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.renderListPredicate=r=>Ft(r)?!1:co.Vector3.Distance(r.getAbsolutePosition(),e.getAbsolutePosition())<=e.range)})}a(zt,"configureShadowMapRenderListPredicate");async function tt(t){t.executeWhenReady(()=>{t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.refreshRate=e.metadata?.refreshRate??po.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}a(tt,"configureShadowMapRefreshRate");function jn(t,e){e.lights.forEach(i=>{let r=i.getShadowGenerator(),o=r?.getShadowMap();if(r?.originalMapSize){let n=r.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,N(n)),o?.getSize().width!==n&&o.resize(n)}}),tt(e)}a(jn,"applyShadowsQuality");var it=["SSAO2RenderingPipeline","VolumetricLightingRenderingPipeline","VolumetricLightScatteringPostProcess","SSRRenderingPipeline","MotionBlurPostProcess","DefaultRenderingPipeline","TAARenderingPipeline"],ue=new Map,Ht=new WeakMap;function ho(t){return Object.values(t._renderEffects??{})}a(ho,"getRenderEffects");function mo(t){let e=t.getScene(),i=t._postProcesses;if(!i?.length)return!1;ue.clear();let r=e.postProcessRenderPipelineManager?.supportedPipelines??[];r.forEach(s=>{let c=it.indexOf(s.getClassName());c!==-1&&ho(s).forEach(h=>{h.getPostProcesses(t)?.forEach(m=>ue.set(m,c))})});let o=[],n=-1,l=!0;if(i.forEach((s,c)=>{if(!s)return;let h=ue.get(s);if(h===void 0){if(h=it.indexOf(s.getClassName()),h===-1)return;ue.set(s,h)}o.push(c),h<n&&(l=!1),n=Math.max(n,h)}),l)return!1;let p=o.map(s=>i[s]).sort((s,c)=>ue.get(s)-ue.get(c));return o.forEach((s,c)=>i[s]=p[c]),r.forEach(s=>{it.indexOf(s.getClassName())!==-1&&ho(s).forEach(c=>{let h=c._indicesForCamera,m=c.getPostProcesses(t);h?.[t.name]&&m&&(h[t.name]=m.map(d=>i.indexOf(d)))})}),t._cascadePostProcessesToRigCams?.(),e.prePassRenderer?.markAsDirty(),!0}a(mo,"sortCameraPostProcesses");function kt(t){if(Ht.has(t))return;let e=t.onBeforeCameraRenderObservable.add(i=>mo(i));Ht.set(t,e),t.onDisposeObservable.addOnce(()=>Ht.delete(t))}a(kt,"keepRenderingPipelinesOrdered");var uo=require("babylonjs"),fo=require("babylonjs"),go=require("babylonjs"),w=null,fe=new Map;function Ut(){return w}a(Ut,"getVLSPostProcess");function Kn(t){w=t}a(Kn,"setVLSPostProcessRef");function Wt(t){w&&t.activeCamera&&(w.dispose(t.activeCamera),w=null)}a(Wt,"disposeVLSPostProcess");function vo(t,e,i){return e??=t.meshes.find(r=>F(r)),w=new go.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,t.activeCamera,e,100,fo.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),w.samples=i?.msaaSamples??1,w}a(vo,"createVLSPostProcess");function Xt(){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(Xt,"serializeVLSPostProcess");function $t(t,e,i){let r=null;if(e.meshId){let n=t.getMeshById(e.meshId);n&&F(n)&&(r=n)}let o=w??vo(t,r,i);return o.samples=i?.msaaSamples??1,o.exposure=e.exposure,o.decay=e.decay,o.weight=e.weight,o.density=e.density,o.invert=e.invert,o.useCustomMeshPosition=e.useCustomMeshPosition,o.customMeshPosition.copyFrom(uo.Vector3.FromArray(e.customMeshPosition)),o}a($t,"parseVLSPostProcess");var So=require("babylonjs"),D=null,ge=new Map;function Zn(){return D}a(Zn,"getSSRRenderingPipeline");function Yn(t){D=t}a(Yn,"setSSRRenderingPipelineRef");function jt(){D&&(D.dispose(),D=null)}a(jt,"disposeSSRRenderingPipeline");function yo(t,e,i){return D=new So.SSRRenderingPipeline("SSRRenderingPipeline",t,[e],void 0,K(t.getEngine())),D.samples=i?.msaaSamples??1,D}a(yo,"createSSRRenderingPipeline");function Kt(){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(Kt,"serializeSSRRenderingPipeline");function Zt(t,e,i,r){let o=D??yo(t,e,r);return o.samples=r?.msaaSamples??1,o.step=i.step,o.thickness=i.thickness,o.strength=i.strength,o.reflectionSpecularFalloffExponent=i.reflectionSpecularFalloffExponent,o.maxSteps=i.maxSteps,o.maxDistance=i.maxDistance,o.roughnessFactor=i.roughnessFactor,o.reflectivityThreshold=i.reflectivityThreshold,o.blurDispersionStrength=i.blurDispersionStrehgth,o.clipToFrustum=i.clipToFrustum,o.enableSmoothReflections=i.enableSmoothReflections,o.enableAutomaticThicknessComputation=i.enableAutomaticThicknessComputation,o.attenuateFacingCamera=i.attenuateFacingCamera,o.attenuateScreenBorders=i.attenuateScreenBorders,o.attenuateIntersectionDistance=i.attenuateIntersectionDistance,o.attenuateBackfaceReflection=i.attenuateBackfaceReflection,o.blurDownsample=i.blurDownsample,o.selfCollisionNumSkip=i.selfCollisionNumSkip,o.ssrDownsample=i.ssrDownsample,o.backfaceDepthTextureDownsample=i.backfaceDepthTextureDownsample,o}a(Zt,"parseSSRRenderingPipeline");var bo=require("babylonjs"),A=null,ve=new Map;function qn(){return A}a(qn,"getTAARenderingPipeline");function Qn(t){A=t}a(Qn,"setTAARenderingPipelineRef");function Yt(){A&&(A.dispose(),A=null)}a(Yt,"disposeTAARenderingPipeline");function xo(t,e,i){return A=new bo.TAARenderingPipeline("TAARenderingPipeline",t,[e],K(t.getEngine())),A.msaaSamples=i?.msaaSamples??1,A}a(xo,"createTAARenderingPipeline");function qt(){return A?{factor:A.factor,samples:A.samples,clampHistory:A.clampHistory,reprojectHistory:A.reprojectHistory,disableOnCameraMove:A.disableOnCameraMove}:null}a(qt,"serializeTAARenderingPipeline");function Qt(t,e,i,r){let o=A??xo(t,e,r);return o.msaaSamples=r?.msaaSamples??1,o.factor=i.factor,o.clampHistory=i.clampHistory,o.reprojectHistory=i.reprojectHistory,o.disableOnCameraMove=i.disableOnCameraMove,o}a(Qt,"parseTAARenderingPipeline");var _o=require("babylonjs"),P=null,Se=new Map;function Jn(){return P}a(Jn,"getSSAO2RenderingPipeline");function ea(t){P=t}a(ea,"setSSAO2RenderingPipelineRef");function Jt(){P&&(P.dispose(),P=null)}a(Jt,"disposeSSAO2RenderingPipeline");function Co(t,e,i){return P=new _o.SSAO2RenderingPipeline("SSAO2RenderingPipeline",t,1,[e],!1,K(t.getEngine())),P.textureSamples=1,P}a(Co,"createSSAO2RenderingPipeline");function ei(){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(ei,"serializeSSAO2RenderingPipeline");function ti(t,e,i,r){let o=P??Co(t,e,r);return o.textureSamples=1,o.radius=i.radius,o.totalStrength=i.totalStrength,o.samples=i.samples,o.maxZ=i.maxZ,o.minZAspect=i.minZAspect,o.epsilon=i.epsilon,o.bypassBlur=i.bypassBlur,o.bilateralSamples=i.bilateralSamples,o.bilateralSoften=i.bilateralSoften,o.bilateralTolerance=i.bilateralTolerance,o.expensiveBlur=i.expensiveBlur,o}a(ti,"parseSSAO2RenderingPipeline");var Do=require("babylonjs"),I=null,ye=new Map;function ii(){return I}a(ii,"getMotionBlurPostProcess");function ta(t){I=t}a(ta,"setMotionBlurPostProcessRef");function oi(){I&&(I.dispose(),I=null)}a(oi,"disposeMotionBlurPostProcess");function Lo(t,e,i){return I=new Do.MotionBlurPostProcess("MotionBlurPostProcess",t,1,e,void 0,void 0,void 0,K(t.getEngine())),I.samples=i?.msaaSamples??1,I.motionStrength=1,I.isObjectBased=!0,I}a(Lo,"createMotionBlurPostProcess");function ri(){return I?{isObjectBased:I.isObjectBased,motionStrength:I.motionStrength,motionBlurSamples:I.motionBlurSamples}:null}a(ri,"serializeMotionBlurPostProcess");function ni(t,e,i,r){let o=I??Lo(t,e,r);return o.samples=r?.msaaSamples??1,o.isObjectBased=i.isObjectBased,o.motionStrength=i.motionStrength,o.motionBlurSamples=i.motionBlurSamples,o}a(ni,"parseMotionBlurPostProcess");var Po=require("babylonjs"),ai=require("babylonjs"),wo=require("babylonjs"),Oo=require("babylonjs"),To=require("babylonjs"),f=null,be=new Map;function Ve(){return f}a(Ve,"getDefaultRenderingPipeline");function ia(t){f=t}a(ia,"setDefaultRenderingPipelineRef");function si(){f&&(f.dispose(),f=null)}a(si,"disposeDefaultRenderingPipeline");function Eo(t,e,i){return f=new To.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,t,[e]),f.samples=i?.msaaSamples??1,f.depthOfField.lensSize=512,f.depthOfField.fStop=.25,f.depthOfField.focusDistance=55e3,f}a(Eo,"createDefaultRenderingPipeline");function li(){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(li,"serializeDefaultRenderingPipeline");function ci(t,e,i,r,o){let n=f??Eo(t,e,o);if(n.samples=o?.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=Po.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=r+i.colorGradingTexture.name;l=new Oo.ColorGradingTexture(p,t),l.level=i.colorGradingTexture.level}else{let p=wo.Texture.Parse(i.colorGradingTexture,t,r);Re(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=ai.Vector2.FromArray(i.direction??[0,0]),n.chromaticAberration.centerPosition=ai.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(ci,"parseDefaultRenderingPipeline");var le="volumetricLighting",T=8,Z=256,di=4,ot=3,Ao=(i=>(i[i.Linear=0]="Linear",i[i.Exponential=1]="Exponential",i))(Ao||{}),ui=(r=>(r[r.None=0]="None",r[r.Bayer=1]="Bayer",r[r.InterleavedGradientNoise=2]="InterleavedGradientNoise",r))(ui||{}),fi=(r=>(r[r.Exponential=0]="Exponential",r[r.ExponentialSquared=1]="ExponentialSquared",r[r.Linear=2]="Linear",r))(fi||{}),gi=(o=>(o[o.None=0]="None",o[o.Scattering=1]="Scattering",o[o.Transmittance=2]="Transmittance",o[o.LightCount=3]="LightCount",o))(gi||{});function mi(){return{enabled:!1,volumeIntensity:1,anisotropy:.35,useCustomColor:!1,color:[1,1,1],castVolumetricShadows:!1,shadowDarkness:1,rangeMultiplier:1,priority:0}}a(mi,"getDefaultVolumetricLightConfiguration");function rt(){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(rt,"getDefaultVolumetricLightingConfiguration");function Io(t){return t.lightSteps>0?t.lightSteps:Math.max(4,Math.min(64,Math.round(t.steps*.3)))}a(Io,"getVolumetricLightSteps");function vi(t,e=ot){let i=Io(t);return!t.temporalAccumulation||e<=1?{steps:t.steps,lightSteps:i}:{steps:Math.max(4,Math.ceil(t.steps/e)),lightSteps:Math.max(2,Math.ceil(i/e))}}a(vi,"getVolumetricSamplingSteps");function b(t,e,i,r){let o=typeof t=="number"&&isFinite(t)?t:e;return Math.min(r,Math.max(i,o))}a(b,"normalizeNumber");function pi(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(pi,"normalizeColor");function Mo(t){let e=mi();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:pi(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(Mo,"normalizeVolumetricLightConfiguration");function xe(t){let e=rt();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,temporalAccumulation:t.temporalAccumulation??e.temporalAccumulation,temporalAccumulationFactor:b(t.temporalAccumulationFactor,e.temporalAccumulationFactor,.005,1),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:pi(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:pi(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,Z)),maxShadowedLights:Math.round(b(t.maxShadowedLights,e.maxShadowedLights,0,T)),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(xe,"normalizeVolumetricLightingConfiguration");var hi=new WeakSet;function Ro(t){t.metadata??={};let e=t.metadata[le];if(!e||typeof e!="object")return t.metadata[le]=Mo(null),hi.add(t.metadata[le]),t.metadata[le];if(hi.has(e))return e;let i=mi();return Object.keys(i).forEach(r=>{e[r]===void 0&&(e[r]=i[r])}),hi.add(e),e}a(Ro,"ensureVolumetricLightConfiguration");function Si(t){let e=t.metadata?.[le];return e&&typeof e=="object"?Ro(t):null}a(Si,"getVolumetricLightConfiguration");function oa(t){return t.metadata?.[le]?.enabled===!0}a(oa,"isVolumetricLightEnabled");var nt=require("babylonjs"),Go=require("babylonjs"),bi=require("babylonjs"),Y=require("babylonjs"),xi=(r=>(r[r.Texture2D=0]="Texture2D",r[r.Sampler2DShadow=1]="Sampler2DShadow",r[r.Cube=2]="Cube",r))(xi||{}),Bo=(r=>(r[r.Standard=0]="Standard",r[r.Esm=1]="Esm",r[r.CloseEsm=2]="CloseEsm",r))(Bo||{}),_i=(r=>(r[r.Analytic=0]="Analytic",r[r.AnalyticHeight=1]="AnalyticHeight",r[r.Numeric=2]="Numeric",r))(_i||{}),Vo=10,ra=4,na=22,aa=32,sa=.15;function Fe(t,e){let i=t.getCaps(),r=i.maxFragmentUniformVectors||224,o=t.isWebGPU?Math.floor(r/4):r,n=Math.max(224,o)-aa,l=Math.max(8,i.maxTexturesImageUnits||16)-1,p=l>=2,s=p?na:0,c=Math.max(0,Math.min(T,e.maxShadowedLights,l-(p?1:0),Math.floor((n-s)/Vo))),h=Math.max(0,Math.min(Z,e.maxLights,Math.floor((n-s-c*Vo)/ra)));return{maxShadowSlots:c,maxArrayLights:h,maxDirectionalLights:Math.min(di,h),allowCsm:p}}a(Fe,"computeVolumetricBudget");function zo(t){let e=[];return t.lights.forEach(i=>{me(i)?i.lights.forEach(r=>{e.push({light:r,isClustered:!0})}):e.push({light:i,isClustered:!1})}),e}a(zo,"getAllVolumetricCandidateLights");function Ho(t,e){let i=t.getShadowGenerator(e.activeCamera)??t.getShadowGenerator();if(!i||!Et(i))return null;let r=i.getShadowMapForRendering();if(!r?.isReady())return null;let o=i.getShadowMap()?.getSize().width??1024,n=r.textureType===bi.Constants.TEXTURETYPE_UNSIGNED_BYTE,l=!ie(t),p=t.needCube?.()===!0;switch(i.filter){case Y.ShadowGenerator.FILTER_PCF:case Y.ShadowGenerator.FILTER_PCSS:return{generator:i,kind:p?2:1,mode:0,packed:n,mapSize:o,local:l};case Y.ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP:case Y.ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:1,packed:n,mapSize:o,local:l};case Y.ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP:case Y.ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:2,packed:n,mapSize:o,local:l};default:return{generator:i,kind:p?2:0,mode:0,packed:n,mapSize:o,local:l}}}a(Ho,"resolveVolumetricShadowSlot");function at(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(at,"getVolumetricLightWorldPosition");function Ne(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(Ne,"getVolumetricLightWorldDirection");function st(t,e,i){let r=t.range>0&&t.range<Number.MAX_VALUE?t.range:i.maxDistance;return Math.max(.001,Math.min(r*e.rangeMultiplier,34e37))}a(st,"getVolumetricLightRange");var yi=new nt.Vector3,Fo=new nt.Vector3;function la(t,e,i){if(at(t,i),!ae(t))return e;let r=Math.cos(t.angle*.5);if(r<=.5)return e;let o=e/(2*r);return Ne(t,Fo),i.addInPlace(Fo.scaleInPlace(o)),o}a(la,"computeVolumetricLightBounds");function ca(t,e,i){for(let r=0;r<i.length;++r)if(i[r].dotCoordinate(t)<=-e)return!1;return!0}a(ca,"isSphereInFrustum");function No(t){return(t.local?64:0)+t.kind*16+t.mode*4+(t.packed?1:0)}a(No,"getShadowSlotSignature");function Ci(t,e,i,r,o){let n={candidateCount:0,culledCount:0,shadowedCount:0,unshadowedCount:0,droppedCount:0,perLight:new Map},l=Go.Frustum.GetPlanes(t.getTransformMatrix()),p=e.globalPosition,s=[];zo(t).forEach(({light:v,isClustered:_})=>{let V=Si(v);if(!V?.enabled)return;if(n.candidateCount++,et(v)||!v.isEnabled()||v.intensity<=0||V.volumeIntensity<=0){n.perLight.set(v.uniqueId,{state:"disabled",slot:-1,reason:et(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 qe=Math.min(st(v,V,i),i.maxDistance),Ot=la(v,qe,yi);if(!ca(yi,Ot,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 Mn=Math.max(1,nt.Vector3.Distance(yi,p)-Ot);he+=V.volumeIntensity*v.intensity*Math.min(4,Ot/Mn)}s.push({light:v,config:V,isClustered:_,typeId:v.getTypeID(),score:he})}),s.sort((v,_)=>_.score-v.score);let c=new Map;o?.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||!t.shadowsEnabled){d.set(_.uniqueId,"shadows are disabled on this light or on the scene."),m.push(v);return}let j=_.getShadowGenerator(t.activeCamera)??_.getShadowGenerator();if(!j){d.set(_.uniqueId,"the light has no shadow generator."),m.push(v);return}if(At(j)&&r.allowCsm){let qe=j.getShadowMapForRendering();if(!u&&qe?.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:qe.textureType===bi.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=Ho(_,t);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(_)*sa}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,r.maxShadowSlots);y.sort((v,_)=>No(v.shadow)-No(_.shadow)||g(v)-g(_)),h.slice(r.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<r.maxDirectionalLights?C.push(v):x.push({candidate:v,reason:`Not rendered: at most ${r.maxDirectionalLights} directional light(s) without a shadow map can take part in the effect.`}):L.push(v)});let R=Math.max(0,r.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 ${r.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(Ci,"selectVolumetricLights");function pa(t,e,i){let r=t.shadowed.map(n=>`${n.shadow.kind}.${n.shadow.mode}.${n.shadow.packed?1:0}.${n.shadow.local?1:0}`).join("|"),o=t.csm?`${t.csm.kind}.${t.csm.cascades}.${t.csm.packed?1:0}`:"-";return[i.steps,i.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,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,r,o].join(",")}a(pa,"computeVolumetricShapeKey");function ha(t){return Tt(t)||ae(t)||ie(t)}a(ha,"isVolumetricLightSupported");var Di=require("babylonjs"),ma=0,Li=(r=>(r[r.DepthRenderer=0]="DepthRenderer",r[r.GeometryBuffer=1]="GeometryBuffer",r[r.PrePass=2]="PrePass",r))(Li||{}),ko="volumetricLighting";function Pi(){return{name:ko,enabled:!1,texturesRequired:[Di.Constants.PREPASS_DEPTH_TEXTURE_TYPE]}}a(Pi,"createVolumetricLightingPrePassConfiguration");function _e(t){return t.prePassRenderer??null}a(_e,"getVolumetricPrePassRenderer");function Ge(t){return t.geometryBufferRenderer??null}a(Ge,"getVolumetricGeometryBufferRenderer");function Uo(t){let e=t.getCaps();return e.textureFloat&&e.textureFloatLinearFiltering||e.textureHalfFloat&&e.textureHalfFloatLinearFiltering}a(Uo,"supportsVolumetricFloatDepthTexture");function lt(t){return Uo(t.getEngine())?_e(t)?.isSupported?2:Ge(t)?.isSupported?1:0:0}a(lt,"resolveVolumetricDepthSource");function wi(t){let e=t.getIndex(Di.Constants.PREPASS_DEPTH_TEXTURE_TYPE);return e===void 0||e<0?null:t.getRenderTarget()?.textures?.[e]??null}a(wi,"getVolumetricPrePassDepthTexture");function Oi(t){if(!t.enableDepth)return null;let e=t.getTextureIndex(ma);return e<0?null:t.getGBuffer()?.textures?.[e]??null}a(Oi,"getVolumetricGeometryBufferDepthTexture");var Be=`
|
|
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
|
-
`,
|
|
9
|
+
`,da=`
|
|
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
|
|
36
|
+
`;function ct(t){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
40
|
return volUnpack(textureLoad(${t}, coordinates, 0)) * uniforms.volCameraMinMaxZ.y;
|
|
38
41
|
#else
|
|
39
|
-
return textureLoad(${t}, coordinates, 0).r;
|
|
42
|
+
return textureLoad(${t}, 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(
|
|
51
|
+
`}a(ct,"buildLinearDepthHelpers");function ua(){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
|
-
|
|
59
|
-
|
|
61
|
+
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
62
|
+
uniform volPassParams: vec4f;
|
|
63
|
+
|
|
64
|
+
${Be}
|
|
65
|
+
${da}
|
|
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
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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(
|
|
93
|
+
`}a(ua,"buildVolumetricLightingLinearDepthShaderWGSL");function Wo(t,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
|
|
@@ -128,7 +140,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
return vec4f(result, 1.0);
|
|
131
|
-
`}a(
|
|
143
|
+
`}a(Wo,"buildLocalLightIntegrationWGSL");function fa(t){let e=[],i=[],r=[];for(let o=0;o<t;++o)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
|
-
${
|
|
262
|
+
${Wo("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,
|
|
266
|
+
`.replace(/\{X\}/g,o.toString())),i.push(`
|
|
255
267
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
256
268
|
#if VOL_SHADOW_LOCAL{X} == 0
|
|
257
269
|
{
|
|
@@ -262,7 +274,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
262
274
|
}
|
|
263
275
|
#endif
|
|
264
276
|
#endif
|
|
265
|
-
`.replace(/\{X\}/g,
|
|
277
|
+
`.replace(/\{X\}/g,o.toString())),r.push(`
|
|
266
278
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
267
279
|
#if VOL_SHADOW_LOCAL{X} == 1
|
|
268
280
|
lightResult = volIntegrateShadowSlot{X}(tStart, tEnd);
|
|
@@ -270,7 +282,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
270
282
|
evaluatedLights += lightResult.w;
|
|
271
283
|
#endif
|
|
272
284
|
#endif
|
|
273
|
-
`.replace(/\{X\}/g,
|
|
285
|
+
`.replace(/\{X\}/g,o.toString()));return`
|
|
274
286
|
varying vUV: vec2f;
|
|
275
287
|
|
|
276
288
|
// Full resolution linear depth of the scene, written by the linear depth pass.
|
|
@@ -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
|
-
${
|
|
349
|
-
${
|
|
366
|
+
${Be}
|
|
367
|
+
${ct("textureSampler")}
|
|
350
368
|
|
|
351
369
|
fn volMod(x: f32, y: f32) -> f32 {
|
|
352
370
|
return x - y * floor(x / y);
|
|
@@ -872,7 +890,7 @@ ${i.join("")}
|
|
|
872
890
|
let lightDepth = dot(data.xyz, uniforms.volCameraForward);
|
|
873
891
|
#endif
|
|
874
892
|
|
|
875
|
-
${
|
|
893
|
+
${Wo("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
|
-
|
|
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
|
|
@@ -938,7 +962,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
938
962
|
evaluatedLights += lightResult.w;
|
|
939
963
|
#endif
|
|
940
964
|
|
|
941
|
-
${
|
|
965
|
+
${r.join("")}
|
|
942
966
|
|
|
943
967
|
#if VOL_LOCAL_ARRAY_LIGHTS == 1
|
|
944
968
|
let localEnd = VOL_DIRECTIONAL_LIGHT_COUNT + i32(uniforms.volParams.w + 0.5);
|
|
@@ -971,58 +995,155 @@ ${o.join("")}
|
|
|
971
995
|
|
|
972
996
|
fragmentOutputs.color = vec4f(result, finalTransmittance);
|
|
973
997
|
}
|
|
974
|
-
`}a(
|
|
998
|
+
`}a(fa,"buildVolumetricLightingScatteringShaderWGSL");function ga(){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
|
|
983
|
-
uniform
|
|
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
|
-
${
|
|
986
|
-
${
|
|
1021
|
+
${Be}
|
|
1022
|
+
${ct("volLinearDepthSampler")}
|
|
987
1023
|
|
|
988
1024
|
@fragment
|
|
989
1025
|
fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
990
|
-
|
|
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
|
-
|
|
997
|
-
let
|
|
998
|
-
|
|
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
|
-
|
|
1002
|
-
|
|
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
|
-
|
|
1005
|
-
let
|
|
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
|
|
1008
|
-
let
|
|
1043
|
+
let previousClip = uniforms.volPreviousViewProjection * vec4f(rayDir * t, 1.0);
|
|
1044
|
+
let previousUV = (previousClip.xy / previousClip.w) * 0.5 + 0.5;
|
|
1009
1045
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
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
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
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
|
|
1085
|
+
fragmentOutputs.color = result;
|
|
1024
1086
|
}
|
|
1025
|
-
`}a(
|
|
1087
|
+
`}a(ga,"buildVolumetricLightingTemporalShaderWGSL");function va(){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
|
+
${Be}
|
|
1102
|
+
${ct("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(va,"buildVolumetricLightingBlurShaderWGSL");function Sa(){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
|
-
|
|
1038
|
-
|
|
1158
|
+
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
1159
|
+
uniform volPassParams: vec4f;
|
|
1160
|
+
|
|
1161
|
+
${Be}
|
|
1162
|
+
${ct("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
|
-
//
|
|
1101
|
-
|
|
1102
|
-
|
|
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
|
-
|
|
1233
|
+
var volumetric = volUpsample(input.vUV, centerDepth, depthSize);
|
|
1105
1234
|
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
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
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
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
|
-
|
|
1247
|
+
sceneColor *= mix(1.0, volumetric.a, uniforms.volComposeParams.y);
|
|
1119
1248
|
|
|
1120
|
-
|
|
1249
|
+
var result = sceneColor + volumetric.rgb * uniforms.volComposeParams.x;
|
|
1121
1250
|
|
|
1122
|
-
|
|
1123
|
-
|
|
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
|
-
|
|
1126
|
-
|
|
1254
|
+
fragmentOutputs.color = vec4f(result, 1.0);
|
|
1255
|
+
#endif
|
|
1256
|
+
}
|
|
1127
1257
|
}
|
|
1128
|
-
`}a(
|
|
1258
|
+
`}a(Sa,"buildVolumetricLightingComposeShaderWGSL");function Xo(){return{linearDepth:ua(),scattering:fa(T),temporal:ga(),blur:va(),compose:Sa()}}a(Xo,"getVolumetricLightingShadersWGSL");var z=require("babylonjs"),Ko=require("babylonjs"),ht="volumetricLightingLinearDepth",mt="volumetricLightingScattering",dt="volumetricLightingTemporal",ut="volumetricLightingBlur",ft="volumetricLightingCompose",ze=`
|
|
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
|
-
`,
|
|
1267
|
+
`,ya=`
|
|
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
|
-
`,
|
|
1295
|
+
`,pt=`
|
|
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
|
|
1312
|
+
`;function ba(){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
|
-
|
|
1190
|
-
|
|
1323
|
+
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
1324
|
+
uniform vec4 volPassParams;
|
|
1325
|
+
|
|
1326
|
+
${ze}
|
|
1327
|
+
${ya}
|
|
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
|
-
|
|
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(
|
|
1355
|
+
`}a(ba,"buildVolumetricLightingLinearDepthShader");function $o(t,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
|
|
@@ -1251,7 +1395,7 @@ void main(void) {
|
|
|
1251
1395
|
}
|
|
1252
1396
|
|
|
1253
1397
|
return vec4(result, 1.0);
|
|
1254
|
-
`}a(
|
|
1398
|
+
`}a($o,"buildLocalLightIntegration");function xa(t){let e=[],i=[],r=[];for(let o=0;o<t;++o)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
|
-
${
|
|
1515
|
+
${$o("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,
|
|
1519
|
+
`.replace(/\{X\}/g,o.toString())),i.push(`
|
|
1376
1520
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
1377
1521
|
#if VOL_SHADOW_LOCAL{X} == 0
|
|
1378
1522
|
{
|
|
@@ -1384,7 +1528,7 @@ void main(void) {
|
|
|
1384
1528
|
}
|
|
1385
1529
|
#endif
|
|
1386
1530
|
#endif
|
|
1387
|
-
`.replace(/\{X\}/g,
|
|
1531
|
+
`.replace(/\{X\}/g,o.toString())),r.push(`
|
|
1388
1532
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
1389
1533
|
#if VOL_SHADOW_LOCAL{X} == 1
|
|
1390
1534
|
lightResult = volIntegrateShadowSlot{X}(tStart, tEnd);
|
|
@@ -1392,7 +1536,7 @@ void main(void) {
|
|
|
1392
1536
|
evaluatedLights += lightResult.a;
|
|
1393
1537
|
#endif
|
|
1394
1538
|
#endif
|
|
1395
|
-
`.replace(/\{X\}/g,
|
|
1539
|
+
`.replace(/\{X\}/g,o.toString()));return`precision highp float;
|
|
1396
1540
|
precision highp int;
|
|
1397
1541
|
|
|
1398
1542
|
varying vec2 vUV;
|
|
@@ -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
|
-
${
|
|
1471
|
-
${
|
|
1620
|
+
${ze}
|
|
1621
|
+
${pt}
|
|
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));
|
|
@@ -2046,7 +2196,7 @@ ${i.join("")}
|
|
|
2046
2196
|
float lightDepth = dot(data.xyz, volCameraForward);
|
|
2047
2197
|
#endif
|
|
2048
2198
|
|
|
2049
|
-
${
|
|
2199
|
+
${$o("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
|
|
@@ -2113,7 +2277,7 @@ void main(void) {
|
|
|
2113
2277
|
evaluatedLights += lightResult.a;
|
|
2114
2278
|
#endif
|
|
2115
2279
|
|
|
2116
|
-
${
|
|
2280
|
+
${r.join("")}
|
|
2117
2281
|
|
|
2118
2282
|
#if VOL_LOCAL_ARRAY_LIGHTS == 1
|
|
2119
2283
|
int localEnd = VOL_DIRECTIONAL_LIGHT_COUNT + int(volParams.w + 0.5);
|
|
@@ -2145,7 +2309,109 @@ ${o.join("")}
|
|
|
2145
2309
|
|
|
2146
2310
|
gl_FragColor = vec4(result, finalTransmittance);
|
|
2147
2311
|
}
|
|
2148
|
-
`}a(
|
|
2312
|
+
`}a(xa,"buildVolumetricLightingScatteringShader");function _a(){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
|
+
${ze}
|
|
2343
|
+
${pt}
|
|
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(_a,"buildVolumetricLightingTemporalShader");function Ca(){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
|
-
|
|
2162
|
-
|
|
2427
|
+
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
2428
|
+
uniform vec4 volPassParams;
|
|
2429
|
+
|
|
2430
|
+
${ze}
|
|
2431
|
+
${pt}
|
|
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(
|
|
2476
|
+
`}a(Ca,"buildVolumetricLightingBlurShader");function Da(){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
|
-
|
|
2215
|
-
|
|
2489
|
+
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
2490
|
+
uniform vec4 volPassParams;
|
|
2491
|
+
|
|
2492
|
+
${ze}
|
|
2493
|
+
${pt}
|
|
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(pa,"buildVolumetricLightingComposeShader");var Go={};function zo(t){if(!Go[t]){if(Go[t]=!0,t===Bo.ShaderLanguage.WGSL){let e=Fo();j.ShaderStore.ShadersStoreWGSL[`${at}PixelShader`]=e.linearDepth,j.ShaderStore.ShadersStoreWGSL[`${st}PixelShader`]=e.scattering,j.ShaderStore.ShadersStoreWGSL[`${lt}PixelShader`]=e.blur,j.ShaderStore.ShadersStoreWGSL[`${ct}PixelShader`]=e.compose;return}j.ShaderStore.ShadersStore[`${at}PixelShader`]=sa(),j.ShaderStore.ShadersStore[`${st}PixelShader`]=la(E),j.ShaderStore.ShadersStore[`${lt}PixelShader`]=ca(),j.ShaderStore.ShadersStore[`${ct}PixelShader`]=pa()}}a(zo,"registerVolumetricLightingShaders");var Uo=require("babylonjs"),Wo=require("babylonjs"),Z=require("babylonjs"),xe=require("babylonjs"),Fe=require("babylonjs"),Xo=require("babylonjs"),Ci=require("babylonjs"),Ne=require("babylonjs"),$o=require("babylonjs"),ma=new xe.Vector3(0,0,1),ha=new xe.Vector3(0,0,-1),Ho=["resolutionScale","blurPasses"],da=32,fa=["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?Ci.ShaderLanguage.WGSL:Ci.ShaderLanguage.GLSL}_scene;_camera;_configuration;_configurationProxy;_textureType;_shaderLanguage;_ldrEncode;_linearDepthPacked;_msaaSamples=1;_msaaSamplesAssigned=!1;_depthSource=0;_depthRenderer=null;_ownsDepthRenderer=!1;_depthMode=0;_prePassConfiguration=vi();_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=xe.Matrix.Identity();_temporaryVector=new xe.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=ye({...Je(),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=Me(n,this._configuration),this._depthSource=ot(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=ye({...this._configuration,...e}),o=Ho.some(r=>i[r]!==this._configuration[r]);Object.assign(this._configuration,i),this._budget=Me(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=Me(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=ot(this._scene);if(e===this._depthSource){e===1&&this._ensureGeometryBufferDepth();return}this._releaseDepthSource(),this._depthSource=e,this._setupDepthSource(),be(this._scene)?.markAsDirty(),this._lightsDirty=!0}_ensureGeometryBufferDepth(){let e=Ve(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=be(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:li(e)}}_buildLinearDepthReadDefines(e){return e.linearDepthPacked?`#define VOL_LINEAR_DEPTH_PACKED
|
|
2589
|
+
`}a(Da,"buildVolumetricLightingComposeShader");var jo={};function Zo(t){if(!jo[t]){if(jo[t]=!0,t===Ko.ShaderLanguage.WGSL){let e=Xo();z.ShaderStore.ShadersStoreWGSL[`${ht}PixelShader`]=e.linearDepth,z.ShaderStore.ShadersStoreWGSL[`${mt}PixelShader`]=e.scattering,z.ShaderStore.ShadersStoreWGSL[`${dt}PixelShader`]=e.temporal,z.ShaderStore.ShadersStoreWGSL[`${ut}PixelShader`]=e.blur,z.ShaderStore.ShadersStoreWGSL[`${ft}PixelShader`]=e.compose;return}z.ShaderStore.ShadersStore[`${ht}PixelShader`]=ba(),z.ShaderStore.ShadersStore[`${mt}PixelShader`]=xa(T),z.ShaderStore.ShadersStore[`${dt}PixelShader`]=_a(),z.ShaderStore.ShadersStore[`${ut}PixelShader`]=Ca(),z.ShaderStore.ShadersStore[`${ft}PixelShader`]=Da()}}a(Zo,"registerVolumetricLightingShaders");var er=require("babylonjs"),tr=require("babylonjs"),E=require("babylonjs"),G=require("babylonjs"),Ce=require("babylonjs"),ir=require("babylonjs"),or=require("babylonjs"),Ti=require("babylonjs"),De=require("babylonjs"),rr=require("babylonjs"),Yo=new G.Vector3(0,0,1),qo=new G.Vector3(0,0,-1),La=32,Pa="volumetricLighting_",Qo=["resolutionScale","blurPasses","temporalAccumulation"],wa=1,Oa=.05,Ta=.6180339887498949,Ea=32,Aa=["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 t=0;t<T;++t)Jo.push(`volShadowSampler${t}`);var Ia=["volCameraMinMaxZ","volDepthRatio","volInverseViewProjection","volCameraPosition","volCameraForward","volPreviousViewProjection","volTemporalParams","volTemporalMotion"],q=class t extends rr.PostProcessRenderPipeline{static{a(this,"VolumetricLightingRenderingPipeline")}static SceneColorEffectName="VolumetricLightingSceneColorEffect";static ScatteringEffectName="VolumetricLightingScatteringEffect";static TemporalEffectName="VolumetricLightingTemporalEffect";static BlurEffectName="VolumetricLightingBlurEffect";static ComposeEffectName="VolumetricLightingComposeEffect";static GetDefaultFogEnd(e,i){return 1/t.GetDefaultFogDensity(e,i)}static GetDefaultFogDensity(e,i){let r=0;if(e.meshes.length){let o=e.getWorldExtends(),n=o.max.subtract(o.min).length();isFinite(n)&&(r=n)}return r<.001&&(r=Math.max(i.globalPosition.length(),i.maxZ*.001,1)),Math.min(1,Math.max(1e-5,1/Math.max(.001,r)))}static IsSupported(e){return e.isWebGPU?!0:(e.webGLVersion??0)>=2}static GetShaderLanguage(e){return e.isWebGPU?Ti.ShaderLanguage.WGSL:Ti.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=Pi();_linearDepthPostProcess=null;_scatteringPostProcess=null;_temporalPostProcess=null;_blurPostProcesses=[];_composePostProcess=null;_temporalSamplesDivider=ot;_temporalClippingWidth=wa;_temporalMotionTolerance=Oa;_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 tr.Color3;_lightData=new Float32Array(Z*4);_lightDiffuse=new Float32Array(Z*4);_lightDirection=new Float32Array(Z*4);_lightFalloff=new Float32Array(Z*4);_shadowLightData=new Float32Array(T*4);_shadowLightDiffuse=new Float32Array(T*4);_shadowLightDirection=new Float32Array(T*4);_shadowLightFalloff=new Float32Array(T*4);_shadowInfo=new Float32Array(T*4);_shadowMatrices=new Float32Array(T*16);_csmLightData=new Float32Array(4);_csmLightDiffuse=new Float32Array(4);_csmLightDirection=new Float32Array(4);_csmLightFalloff=new Float32Array(4);_csmMatrices=new Float32Array(64);constructor(e,i,r,o){super(i.getEngine(),e),this._shaderLanguage=t.GetShaderLanguage(i.getEngine()),Zo(this._shaderLanguage),this._scene=i,this._camera=r,this._configuration=xe({...rt(),fogDensity:o?.fogDensity??t.GetDefaultFogDensity(i,r),fogEnd:o?.fogEnd??t.GetDefaultFogEnd(i,r),screenSpaceShadowMaxDistance:o?.screenSpaceShadowMaxDistance??t.GetDefaultFogEnd(i,r),...o}),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=i.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=Fe(n,this._configuration),this._depthSource=lt(i),this._setupDepthSource(),this._buildRenderEffects(),i.postProcessRenderPipelineManager.addPipeline(this),i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name,r),this._beforeCameraRenderObserver=i.onBeforeCameraRenderObservable.add(s=>{s===this._camera&&(this._updateDepthSource(),this._updateSelection(),this._warmUpDepthRenderer())}),this._afterCameraRenderObserver=i.onAfterCameraRenderObservable.add(s=>{s===this._camera&&this._setDepthMapRenderedWithCamera(!1)}),this._lightAddedObserver=i.onNewLightAddedObservable.add(()=>this.markLightsDirty()),this._lightRemovedObserver=i.onLightRemovedObservable.add(()=>this.markLightsDirty()),this._meshAddedObserver=i.onNewMeshAddedObservable.add(s=>{this._ownsDepthRenderer&&this._depthWarmup.add(s)}),this._meshRemovedObserver=i.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 i=xe({...this._configuration,...e}),r=Qo.some(o=>i[o]!==this._configuration[o]);Object.assign(this._configuration,i),this._budget=Fe(this._scene.getEngine(),this._configuration),this._lightsDirty=!0,r&&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=Fe(this._scene.getEngine(),this._configuration)),this._lightsDirty=!0,Qo.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=lt(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(),_e(this._scene)?.markAsDirty(),this._lightsDirty=!0}_ensureGeometryBufferDepth(){let e=Ge(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=_e(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,i=e._depthRenderer?.[this._camera.uniqueId];if(this._ownsDepthRenderer=!i,i)this._depthRenderer=i;else{let r=this._scene.getEngine().getCaps(),o=r.textureHalfFloatRender?E.Constants.TEXTURETYPE_HALF_FLOAT:r.textureFloatRender?E.Constants.TEXTURETYPE_FLOAT:E.Constants.TEXTURETYPE_UNSIGNED_BYTE;this._depthRenderer=new ir.DepthRenderer(this._scene,o,this._camera,!1,E.Constants.TEXTURE_NEAREST_SAMPLINGMODE,!1,"VolumetricLightingDepth"),this._depthRenderer.enabled=!this._idle,e._depthRenderer??={},e._depthRenderer[`${Pa}${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 i=this._camera.customRenderTargets,r=this._depthRenderer.getDepthMap(),o=i.indexOf(r);e&&o===-1?i.push(r):!e&&o!==-1&&i.splice(o,1)}_bindDepthUniforms(e){let i=this._camera,r=this._scene.getEngine();if(e.setFloat2("volCameraMinMaxZ",i.minZ,i.maxZ),this._depthMode===1){e.setFloat2("volDepthUnpack",1,0);return}let o=i.mode===er.Camera.ORTHOGRAPHIC_CAMERA,n=o?!r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:1:r.useReverseDepthBuffer&&r.isNDCHalfZRange?i.minZ:r.isNDCHalfZRange?0:i.minZ,l=o?r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:1:r.useReverseDepthBuffer&&r.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 h=r.useReverseDepthBuffer?-1:1;e.setFloat2("volDepthUnpack",h*(n+l)/s,(-h*n-c)/s)}_getSamplingSteps(){return vi(this._configuration,this._temporalSamplesDivider)}_getDitherMode(){let e=this._configuration;return e.temporalAccumulation&&e.ditherMode===0?2:e.ditherMode}_getEnvironment(){let e=this._configuration,i=this._getSamplingSteps(),r=0;return e.heightFogEnabled&&(r=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:r,linearDepthPacked:this._linearDepthPacked,arrayLightCapacity:this._budget.maxArrayLights,steps:i.steps,lightSteps:i.lightSteps}}_buildLinearDepthReadDefines(e){return e.linearDepthPacked?`#define VOL_LINEAR_DEPTH_PACKED
|
|
2305
2590
|
`:""}_buildLinearDepthDefines(e){let i=this._buildLinearDepthReadDefines(e);return e.depthMode===2?i+=`#define VOL_DEPTH_PACKED
|
|
2306
2591
|
`:e.depthMode===1&&(i+=`#define VOL_DEPTH_VIEWZ
|
|
2307
|
-
`),i}_buildScatteringDefines(e,i){let
|
|
2592
|
+
`),i}_buildScatteringDefines(e,i){let r=this._configuration,o=e?.shadowed??[],n=e?.directionalCount??0,l=e?.csm??null,p=o.filter(c=>!c.shadow.local).length,s=this._buildLinearDepthReadDefines(i);return s+=`#define VOL_STEPS ${i.steps}
|
|
2308
2593
|
`,s+=`#define VOL_LIGHT_STEPS ${i.lightSteps}
|
|
2309
|
-
`,s+=`#define VOL_LOCAL_MAX_STEPS ${Math.max(i.lightSteps,
|
|
2310
|
-
`,s+=`#define VOL_DISTRIBUTION ${
|
|
2311
|
-
`,s+=`#define VOL_DITHER ${
|
|
2312
|
-
`,s+=`#define VOL_PCF_TAPS ${
|
|
2594
|
+
`,s+=`#define VOL_LOCAL_MAX_STEPS ${Math.max(i.lightSteps,i.steps)}
|
|
2595
|
+
`,s+=`#define VOL_DISTRIBUTION ${r.stepDistribution}
|
|
2596
|
+
`,s+=`#define VOL_DITHER ${this._getDitherMode()}
|
|
2597
|
+
`,s+=`#define VOL_PCF_TAPS ${r.pcfTaps}
|
|
2313
2598
|
`,s+=`#define VOL_FOG_MODE ${i.fogMode}
|
|
2314
2599
|
`,s+=`#define VOL_TRANSMITTANCE ${i.transmittance}
|
|
2315
2600
|
`,(i.transmittance!==0||i.fogMode!==2)&&(s+=`#define VOL_OPTICAL_DEPTH
|
|
2316
|
-
`),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${
|
|
2317
|
-
`,s+=`#define VOL_DEBUG ${
|
|
2601
|
+
`),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${Ea}
|
|
2602
|
+
`,s+=`#define VOL_DEBUG ${r.debugMode}
|
|
2318
2603
|
`,s+=`#define VOL_MAX_ARRAY_LIGHTS ${i.arrayLightCapacity}
|
|
2319
2604
|
`,s+=`#define VOL_DIRECTIONAL_LIGHT_COUNT ${n}
|
|
2320
2605
|
`,s+=`#define VOL_LOCAL_ARRAY_LIGHTS ${i.arrayLightCapacity>n?1:0}
|
|
2321
|
-
`,s+=`#define VOL_SHADOW_SLOT_COUNT ${
|
|
2606
|
+
`,s+=`#define VOL_SHADOW_SLOT_COUNT ${o.length}
|
|
2322
2607
|
`,s+=`#define VOL_GLOBAL_LIGHT_COUNT ${n+p+(l?1:0)}
|
|
2323
|
-
`,
|
|
2324
|
-
|
|
2325
|
-
`),
|
|
2326
|
-
`),
|
|
2327
|
-
|
|
2608
|
+
`,r.temporalAccumulation?s+=`#define VOL_TEMPORAL_ACCUMULATION
|
|
2609
|
+
`:r.ditherMode!==0&&r.temporalJitter&&(s+=`#define VOL_TEMPORAL_JITTER
|
|
2610
|
+
`),r.heightFogEnabled&&(s+=`#define VOL_HEIGHT_FOG
|
|
2611
|
+
`),r.lightExtinctionEnabled&&(s+=`#define VOL_LIGHT_EXTINCTION
|
|
2612
|
+
`),r.screenSpaceShadows&&(s+=`#define VOL_SCREEN_SHADOWS
|
|
2613
|
+
`,s+=`#define VOL_SCREEN_SHADOW_STEPS ${r.screenSpaceShadowSteps}
|
|
2328
2614
|
`),i.ldrEncode&&(s+=`#define VOL_LDR_ENCODE
|
|
2329
2615
|
`),i.reverseDepth&&(s+=`#define VOL_REVERSE_DEPTH
|
|
2330
2616
|
`),i.ndcHalfZ&&(s+=`#define VOL_NDC_HALF_Z
|
|
2331
|
-
`),
|
|
2332
|
-
`,s+=`#define VOL_SHADOW_MODE${
|
|
2333
|
-
`,s+=`#define VOL_SHADOW_LOCAL${
|
|
2334
|
-
`,c.shadow.packed&&(s+=`#define VOL_SHADOW_PACKED${
|
|
2617
|
+
`),o.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}
|
|
2625
|
+
`)),s}_buildTemporalDefines(e){return this._buildLinearDepthReadDefines(e)}_buildBlurDefines(e){return`${this._buildLinearDepthReadDefines(e)}#define VOL_BLUR_RADIUS ${this._configuration.blurRadius}
|
|
2340
2626
|
`}_buildComposeDefines(e){let i=this._buildLinearDepthReadDefines(e);return i+=`#define VOL_DEBUG ${this._configuration.debugMode}
|
|
2341
2627
|
`,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:at,uniforms:["volCameraMinMaxZ","volDepthUnpack"],samplers:["depthSampler"],ratio:1,samplingMode:Fe.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:st,uniforms:fa,samplers:ko,ratio:1,samplingMode:Fe.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:lt,uniforms:["volCameraMinMaxZ","volDepthRatio","volBlurDirection","volBlurParams"],samplers:["volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Fe.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:ct,uniforms:["volCameraMinMaxZ","volDepthRatio","volComposeParams"],samplers:["volSceneSampler","volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Fe.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._composeDefines}),this._composePostProcess.onApplyObservable.add(r=>this._bindCompose(r)),this.addEffect(new Ne.PostProcessRenderEffect(e,t.SceneColorEffectName,()=>this._linearDepthPostProcess,!0)),this.addEffect(new Ne.PostProcessRenderEffect(e,t.ScatteringEffectName,()=>this._scatteringPostProcess,!0)),this._blurPostProcesses.length&&this.addEffect(new Ne.PostProcessRenderEffect(e,t.BlurEffectName,()=>this._blurPostProcesses,!0)),this.addEffect(new Ne.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=fi(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)?(Re(p,this._temporaryVector),o[c]=-this._temporaryVector.x,o[c+1]=-this._temporaryVector.y,o[c+2]=-this._temporaryVector.z,o[c+3]=1):(tt(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]=ne(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,ne(p)?(Re(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]=it(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=be(this._scene);i=o?Si(o):null;break}case 1:{let o=Ve(this._scene);i=o?yi(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?ha:ma,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 Li(){return Ko}a(Li,"getVolumetricLightingRenderingPipelineConfiguration");function Ge(t){Ko=t}a(Ge,"setVolumetricLightingRenderingPipelineConfiguration");function ua(){return I?.isDisposed&&(I=null),I}a(ua,"getVolumetricLightingRenderingPipeline");function ga(t){I=t}a(ga,"setVolumetricLightingRenderingPipelineRef");function va(t){let e=t?.getEngine();return e?Y.IsSupported(e):!1}a(va,"isVolumetricLightingSupported");function Di(){I&&(I.dispose(),I=null)}a(Di,"disposeVolumetricLightingRenderingPipeline");function jo(t,e,i){return I=new Y("VolumetricLightingRenderingPipeline",t,e),I.msaaSamples=i?.msaaSamples??1,I}a(jo,"createVolumetricLightingRenderingPipeline");function _i(){return I?I.serializeConfiguration():null}a(_i,"serializeVolumetricLightingRenderingPipeline");function Pi(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(ye(n)),r}a(Pi,"parseVolumetricLightingRenderingPipeline");function Sa(){I?.markLightsDirty()}a(Sa,"markVolumetricLightsDirty");var pt=require("babylonjs");function ya(t){ge.set(t,$t()),de.set(t,Nt()),fe.set(t,zt()),ve.set(t,Yt()),Se.set(t,ei()),ue.set(t,Ut()),Ge(_i())}a(ya,"saveRenderingConfigurationForCamera");function wi(t,e,i){Xt(),Ft(t.getScene()),Bt(),Zt(),Di(),Jt(),kt();let o=ge.get(t);o&&!i?.ssao2Disabled&&Kt(t.getScene(),t,o,i);let r=Li();r&&!i?.volumetricLightingDisabled&&Pi(t.getScene(),t,r,i);let n=de.get(t);n&&!i?.vlsDisabled&&Gt(t.getScene(),n,i);let l=fe.get(t);l&&!i?.ssrDisabled&&Ht(t.getScene(),t,l,i);let p=ve.get(t);p&&!i?.motionBlurDisabled&&qt(t.getScene(),t,p,i);let s=Se.get(t);s&&!i?.defaultPipelineDisabled&&ti(t.getScene(),t,s,e,i);let c=ue.get(t);c&&!i?.taaDisabled&&Wt(t.getScene(),t,c,i)}a(wi,"applyRenderingConfigurationForCamera");function ba(t){let e=t.getCaps();return e.textureHalfFloatRender||e.textureFloatRender}a(ba,"canUseHdr");function X(t){let e=t.getCaps();return e.textureHalfFloatRender?pt.Constants.TEXTURETYPE_HALF_FLOAT:e.textureFloatRender?pt.Constants.TEXTURETYPE_FLOAT:pt.Constants.TEXTURETYPE_UNSIGNED_BYTE}a(X,"getHdrTextureType");var Be=require("babylonjs"),Zo=require("babylonjs");function Yo(t){let e=t.metadata?.physicsAggregate;if(!e)return;let i;V(t)?i=t:Ae(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?Be.Vector3.FromArray(e.massProperties.inertia):void 0,centerOfMass:e.massProperties.centerOfMass?Be.Vector3.FromArray(e.massProperties.centerOfMass):void 0,inertiaOrientation:e.massProperties.inertiaOrientation?Be.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&&Ge(e.volumetricLightingRenderingPipelineConfiguration),(Array.isArray(i)?i:[]).forEach(r=>{let n=t.getCameraById(r.cameraId);n&&(r.ssao2RenderingPipeline&&ge.set(n,r.ssao2RenderingPipeline),r.vlsPostProcess&&de.set(n,r.vlsPostProcess),r.ssrRenderingPipeline&&fe.set(n,r.ssrRenderingPipeline),r.motionBlurPostProcess&&ve.set(n,r.motionBlurPostProcess),r.defaultRenderingPipeline&&Se.set(n,r.defaultRenderingPipeline),r.taaRenderingPipeline&&ue.set(n,r.taaRenderingPipeline))})}a(qo,"applyRenderingConfigurations");var Qo=require("babylonjs");function Ce(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(Ce,"loadFile");async function B(t,e){let i=await Ce(t,"text",e);return JSON.parse(i)}a(B,"loadJsonFile");function Oi(t,e){let i=e.getNodeByName(t);if(i)return i;let o=e.lights.filter(r=>me(r));for(let r of o){let n=r.lights.find(l=>l.name===t);if(n)return n}return null}a(Oi,"getNodeByName");function Le(t,e){let i=e.getNodeById(t);if(i)return i;let o=e.lights.filter(r=>me(r));for(let r of o){let n=r.lights.find(l=>l.id===t);if(n)return n}return null}a(Le,"getNodeById");var le=require("babylonjs"),Jo=require("babylonjs");function Ei(t){let e=Jo.Vector3.FromArray(t);return e.equals(le.Axis.X)?le.Axis.X:e.equals(le.Axis.Y)?le.Axis.Y:e.equals(le.Axis.Z)?le.Axis.Z:e}a(Ei,"parseAxis");var er=require("babylonjs"),q=require("babylonjs");function tr(t){return t.runtimeConfiguration.forEach(e=>{e.rotationAxis&&(e.rotationAxis=Ei(e.rotationAxis)),e.boneOffsetAxis&&(e.boneOffsetAxis=Ei(e.boneOffsetAxis))}),t}a(tr,"parseRagdollConfiguration");function Ai(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(Ai,"copyAndParseRagdollConfiguration");function xa(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(xa,"applyRagdollJointLimits");function Ca(t){return new Promise(e=>{setTimeout(()=>e(),t)})}a(Ca,"waitMs");async function Ti(t){for(;!t();)await Ca(150)}a(Ti,"waitUntil");function Ii(t){return t&&JSON.parse(JSON.stringify(t))}a(Ii,"cloneJSObject");var Ri=require("babylonjs"),lr=require("babylonjs"),mt=require("babylonjs"),cr=require("babylonjs"),pr=require("babylonjs"),mr=require("babylonjs"),ie=require("babylonjs"),ir=!1,or=null,De=[],Mi=new Map;function La(t,e){let i=(0,ie._GetAudioEngine)(null);return new mr._WebAudioStaticSound(t,i,e)}a(La,"createSoundInstance");function rr(t){if(or?.remove(),!De.length)return;let e=Ri.Vector3.Zero();or=t.onBeforeRenderObservable.add(()=>{let i=(0,ie._GetAudioEngine)(null).listener.attachedNode;i&&(i.getWorldMatrix().getTranslationToRef(e),De.forEach(o=>{o.isEnabled(!1)&&o.autoUpdateSpatial&&o.sound?._isSpatial&&o.isPlaying()&&t.activeCamera&&Ri.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=De.indexOf(t);i!==-1&&De.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 Da(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(Da,"loadSoundBuffer");function Vi(t,e){if(!t.soundRelativePath||!t.sound)return;e.onSoundLoadedObservable=new cr.Observable;let i=La(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,De.push(e),nr(e,i),rr(e.getScene()),e.onSoundLoadedObservable.notifyObservers(e)}),ar(e),sr(e,i)}a(Vi,"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===mt.SoundState.Paused,t.isPlaying=()=>e.state===mt.SoundState.Started,t.isStopped=()=>e.state===mt.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);Vi(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),Mi.has(l)||Mi.set(l,Da(e,l)),Mi.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,De.push(n),ar(n),sr(n,c),rr(e)})})}})}))}a(hr,"registerAudioParser");var dr=require("babylonjs");function _e(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((re(n)||ee(n)&&!n.isWorldMatrixFrozen)&&n.billboardMode===dr.AbstractMesh.BILLBOARDMODE_NONE&&n.freezeWorldMatrix(),re(n)){let l=n.material;l&&!l.isFrozen&&!e.has(l)&&(e.add(l),l.onBindObservable.addOnce(()=>{l.freeze()}))}})}})}a(_e,"configureTransformNodes");var ze=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=Pe(o,i);if(r?.length===1)return r[0]}return null}};var Fi=require("babylonjs"),He=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:Ii(r.metadata)})})}removeDefault(){this.container.getNodes().forEach(e=>{z.get(e)?.forEach(o=>{ht(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=Pe(r,i);if(n?.length===1)return n[0]}return null}instantiate(e){let i=Fi.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 ze(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);ae(h)&&ee(s)&&Vi(h,s),s.id=Fi.Tools.RandomId(),s.metadata=Ii(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})}),_e(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,_e(i),p}a(gr,"preloadSceneScriptAsset");async function vr(t,e){return B(`${e}${t}`)}a(vr,"preloadCommonScriptAsset");var ce=new Map,ke=new Map;function _a(t,e){ke.has(t)&&console.warn(`A parser for the extension '${t}' was already registered. It will be overwritten.`),ke.set(t,e)}a(_a,"registerScriptAssetParser");async function Ni(t,e,i){let o=[e,...e.transformNodes,...e.meshes,...e.lights,...e.cameras],r=ce.get(e);r||(r=new Map,ce.set(e,r)),e.onDisposeObservable.addOnce(()=>{ce.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 He(d,t,i));break;default:if(ke.has(h)){let f=ke.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(Ni,"_preloadScriptsAssets");var Sr=require("babylonjs"),dt=require("babylonjs"),yr=require("babylonjs"),ft=require("babylonjs"),br=require("babylonjs"),xr=require("babylonjs-gui");function oe(t,e){return e?`${t}-${e}`:t}a(oe,"formatNameWithId");function Gi(t,e,i,o,r){let n=o.constructor;if(!n)return;n._NodesFromScene?.forEach(s=>{o[s.propertyKey.toString()]=Oi(oe(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===oe(s.nodeName,r.namingId))[0];o[s.propertyKey.toString()]=c??null}),n._AnimationGroups?.forEach(s=>{o[s.propertyKey.toString()]=t.getAnimationGroupByName(oe(s.animationGroupName,r.namingId))}),n._SoundsFromScene?.forEach(s=>{let c=Oi(oe(s.soundName,r.namingId),t);c&&ae(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!==oe(s.particleSystemName,r.namingId)?!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]=ft.Vector2.FromArray(h);break;case"vector3":o[c]=ft.Vector3.FromArray(h);break;case"color3":o[c]=dt.Color3.FromArray(h);break;case"color4":o[c]=dt.Color4.FromArray(h);break;case"entity":switch(s.configuration.entityType){case"node":case"sound":o[c]=Le(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=ce.get(t).get(h);switch(f){case"json":case"gui":case"scene":case"navmesh":case"cinematic":o[c]=u;break;case"ragdoll":o[c]=Ai(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")&&!re(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")&&!he(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"&&he(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===oe(c.spriteName,r.namingId))||null;o[c.propertyKey.toString()]=m})}if(n._AnimationsFromSprite?.length){if(!Et(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===oe(c.animationName,r.namingId));m?o[c.propertyKey.toString()]=m??null:console.warn(`Sprite animation named "${oe(c.animationName,r.namingId)}" not found on sprite "${e.name}".`)})}return n._SceneAssets?.forEach(s=>{let c=ce.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 Pa(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(Pa,"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]),(he(t)||Ot(t)||Pt(t)||ae(t))&&t.onDisposeObservable.addOnce((()=>{z.get(t)?.slice()?.forEach(l=>{ht(t,l)}),z.delete(t)}))}a(zi,"_registerScriptInstance");function ht(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(ht,"_removeRegisteredScriptInstance");function Pe(t,e){return z.get(t)?.filter(r=>r.instance.constructor===e)?.map(r=>r.instance)??null}a(Pe,"getAllScriptsByClassForObject");function Bi(t,e){return Pe(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 wa(t){_r=t}a(wa,"setUseKtx2CompressedTextures");function Ue(){return _r}a(Ue,"isUsingKtx2CompressedTextures");function ut(t){return`${t.substring(0,t.lastIndexOf("."))}.ktx2`}a(ut,"_getKtx2TextureName");function Oa(t){t.setCompressedTextureExclusions([".env",".hdr",".dds"]),t.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}a(Oa,"configureEngineToUseCompressedTextures");function gt(t,e){t._excludedCompressedTextures&&!t._excludedCompressedTextures?.includes(e)&&t._excludedCompressedTextures?.push(e)}a(gt,"addExcludedCompressedTexture");function Ea(t,e,i){e.loadingTexturesQuality!==t&&(e.loadingTexturesQuality=t,e.textures.forEach(o=>{if(!Te(o)||!o.url)return;let r=vt(o,e);!r||o.url.includes(r)||o.updateURL(i+r)}))}a(Ea,"applyTexturesQuality");function vt(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(vt,"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)=>{Ue()&&(e.name&&(e.name=ut(e.name)),e.url&&(e.url=ut(e.url)));let r=vt(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 Aa(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(Aa,"playSpriteAnimationFromName");var Er=require("babylonjs"),Ar=require("babylonjs"),Tr=require("babylonjs"),Ir=require("babylonjs"),Ui=require("babylonjs"),we=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:we.Vector2.FromArray(r.options.stageSize??[10,1]),outputSize:we.Vector2.FromArray(r.options.outputSize??[100,100]),colorMultiply:we.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 we.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"),St=require("babylonjs"),Gr=require("babylonjs"),Vr=!1;function Br(){if(Vr)return;Vr=!0,(0,Gr.RegisterShadowGeneratorSceneComponent)(Nr.ShadowGenerator);let t=(0,St.GetParser)(Fr.SceneComponentConstants.NAME_SHADOWGENERATOR);(0,St.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}`;gt(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){gt(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(wt(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 Ta(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 Ni(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),It(i),Mt(i.loadingLodsQuality,i),Rt(i),Qe(i),i.metadata?.rendering&&(qo(i,i.metadata),i.activeCamera&&wi(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)})}),_e(i)}a(Ta,"loadScene");var ln=require("babylonjs");async function Ia(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(Ia,"loadMaterialFromFile");function Ma(t){return Promise.all(t.materials.map(async e=>{let i=e.getBindedMeshes();await Promise.all(i.map(async o=>{Ae(o)||await e.forceCompilationAsync(o,{clipPlane:!!t.clipPlane,useInstances:o.hasInstances})}))}))}a(Ma,"forceCompileAllSceneMaterials");var Q=require("babylonjs");function We(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(We,"getAnimationTypeForObject");var cn=require("babylonjs");function Ra(t){return function(e,i){let o=e.constructor;o._NodesFromScene??=[],o._NodesFromScene.push({propertyKey:i,nodeName:t})}}a(Ra,"nodeFromScene");function Va(t){return function(e,i){let o=e.constructor;o._ComponentsFromScene??=[],o._ComponentsFromScene.push({propertyKey:i,componentConstructor:t})}}a(Va,"componentFromScene");function Fa(t,e=!1){return function(i,o){let r=i.constructor;r._NodesFromDescendants??=[],r._NodesFromDescendants.push({propertyKey:o,nodeName:t,directDescendantsOnly:e})}}a(Fa,"nodeFromDescendants");function Na(t){return function(e,i){let o=e.constructor;o._AnimationGroups??=[],o._AnimationGroups.push({animationGroupName:t,propertyKey:i})}}a(Na,"animationGroupFromScene");function Ga(t){return function(e,i){let o=e.constructor;o._SceneAssets??=[],o._SceneAssets.push({sceneName:t,propertyKey:i})}}a(Ga,"sceneAsset");function Ba(t,e){return function(i,o){let r=i.constructor;r._GuiFromAsset??=[],r._GuiFromAsset.push({propertyKey:o,pathInAssets:t,onGuiCreated:e})}}a(Ba,"guiFromAsset");function za(t){return function(e,i){let o=e.constructor;o._SoundsFromScene??=[],o._SoundsFromScene.push({propertyKey:i,soundName:t})}}a(za,"soundFromScene");function Ha(t,e=!1){return function(i,o){let r=i.constructor;r._ParticleSystemsFromScene??=[],r._ParticleSystemsFromScene.push({propertyKey:o,particleSystemName:t,directDescendantsOnly:e})}}a(Ha,"particleSystemFromScene");function ka(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"boolean"}})}}a(ka,"visibleAsBoolean");function Ua(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"string"}})}}a(Ua,"visibleAsString");function Wa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"number"}})}}a(Wa,"visibleAsNumber");function Xa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector2"}})}}a(Xa,"visibleAsVector2");function $a(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector3"}})}}a($a,"visibleAsVector3");function Ka(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color3"}})}}a(Ka,"visibleAsColor3");function ja(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color4"}})}}a(ja,"visibleAsColor4");function Za(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(Za,"visibleAsEntity");function Ya(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"texture"}})}}a(Ya,"visibleAsTexture");function qa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"keymap"}})}}a(qa,"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 Ja(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(Ja,"onPointerEvent");function es(t){return function(e,i){let o=e.constructor;o._KeyboardEvents??=[],o._KeyboardEvents.push({propertyKey:i,eventTypes:Array.isArray(t)?t:[t]})}}a(es,"onKeyboardEvent");function ts(t){return function(e,i){let o=e.constructor;o._SpritesFromSpriteManager??=[],o._SpritesFromSpriteManager.push({propertyKey:i,spriteName:t})}}a(ts,"spriteFromSpriteManager");function is(t){return function(e,i){let o=e.constructor;o._AnimationsFromSprite??=[],o._AnimationsFromSprite.push({propertyKey:i,animationName:t})}}a(is,"animationFromSprite");var yt=require("babylonjs");function yv(t,e){let i;return t===yt.Animation.ANIMATIONTYPE_FLOAT?i=e.value:i=e.value.clone(),{value:i,frame:e.frame,interpolation:e.interpolation,inTangent:t===yt.Animation.ANIMATIONTYPE_FLOAT?e.inTangent:e.inTangent?.clone(),outTangent:t===yt.Animation.ANIMATIONTYPE_FLOAT?e.outTangent:e.outTangent?.clone()}}a(yv,"cloneKey");function bt(t,e){let i=e.split("."),o=t;for(let r=0;r<i.length;++r)o=o[i[r]];return o}a(bt,"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"),xt=require("babylonjs"),k=require("babylonjs");function os(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=Le(i.node,e),o||(o=e.particleSystems?.find(l=>l.id===i.node)??null)):i.defaultRenderingPipeline?o=Ie():i.volumetricLightScattering&&(o=Vt()),i.propertyPath){let l=bt(o,i.propertyPath);r=We(l)}let n=null;return i.sound&&(n=Le(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: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: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(os,"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 xt.Color3.FromArray(t);case J.Animation.ANIMATIONTYPE_COLOR4:return xt.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"),Xe=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 Oe(t){return t.type==="cut"}a(Oe,"isCinematicKeyCut");function rs(t){return t.type==="event"}a(rs,"isCinematicKeyEvent");function ns(t){return t.type==="group"}a(ns,"isCinematicGroup");function as(t){return t.type==="sound"}a(as,"isCinematicSound");var O=require("babylonjs"),Ee=require("babylonjs");function ss(t,e,i){let o=new Xe(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 Ee.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=>Oe(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=>{Oe(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 Ee.AnimationEvent(u.frame,L=>{let x=(L-u.frame+u.startFrame)/t.framesPerSecond;l.play({startOffset:x})},!1)),f.addEvent(new Ee.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=>{Oe(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 Ee.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?Ie():r.node;if(!p||!r.propertyPath||!r.keyFrameAnimations)return;let s=bt(p,r.propertyPath),c=We(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);Oe(d)&&(h.push(d.key1),h.push(d.key2),Ye(p)&&r.propertyPath==="position"&&m.addEvent(new Ee.AnimationEvent(d.key1.frame,()=>{let f=jt();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(ss,"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 $e(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($e,"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 ls(t){gn.AbstractEngine.OfflineProviderFactory=(e,i,o=!1)=>new Ke(t,e,i,o)}a(ls,"setupOfflineProvider");async function Qi(t,e){let i=await new Promise(o=>{let r=new Ke(t,e,n=>o(n?r:null),!1)});return await i?.open(),i}a(Qi,"createAndOpenDatabase");var Ke=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 Ti(()=>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 Ce(e,"blob"),await Promise.all([U(this._database,"images",{url:e,data:o}),U(this._database,"versions",{url:e,version:this._manifestVersion})])):o=(await $e(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 Ce(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 Ti(()=>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 Ce(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 $e(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 Ce(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 $e(this._database,"versions",e))?.version??null}};var vn=["mp3","wav"],Sn=["babylonbinarymeshdata"],cs=["ktx","ktx2","jpg","jpeg","png","bmp","webp"],yn=["babylon","json"],Ji=["jpg","jpeg","png","bmp","webp"],bn=["bin","ktx","ktx2",...Sn,...vn],ps=[...yn,...Ji,...bn];async function ms(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(cs.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"&&!Ue()){m();continue}if(o.length>300){try{await Promise.all(o)}catch{}o.splice(0,o.length)}let M=`${e}${_}`;ps.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(ms,"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,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});
|
|
2628
|
+
`),i}_createPostProcess(e){let i=new or.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=e.autoClear??!1,i.alphaMode=E.Constants.ALPHA_DISABLE,i}_buildRenderEffects(){let e=this._scene.getEngine(),i=this._configuration,r=this._getEnvironment();this._linearDepthDefines=this._buildLinearDepthDefines(r),this._scatteringDefines=this._buildScatteringDefines(this._selection,r),this._temporalDefines=this._buildTemporalDefines(r),this._blurDefines=this._buildBlurDefines(r),this._composeDefines=this._buildComposeDefines(r),this._linearDepthPostProcess=this._createPostProcess({name:"VolumetricLightingLinearDepth",shaderName:ht,uniforms:["volCameraMinMaxZ","volDepthUnpack","volPassParams"],samplers:["depthSampler"],ratio:1,samplingMode:Ce.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._linearDepthDefines,autoClear:!0}),this._linearDepthPostProcess.onApplyObservable.add(o=>this._bindLinearDepth(o)),this._applyPrePassConfiguration(),this._scatteringPostProcess=this._createPostProcess({name:"VolumetricLightingScattering",shaderName:mt,uniforms:Aa,samplers:Jo,ratio:1,samplingMode:Ce.Texture.NEAREST_SAMPLINGMODE,textureType:this._linearDepthType,textureFormat:this._linearDepthPacked?E.Constants.TEXTUREFORMAT_RGBA:E.Constants.TEXTUREFORMAT_R,defines:this._scatteringDefines}),this._scatteringPostProcess.onApplyObservable.add(o=>this._bindScattering(o)),this._temporalPostProcess=null,i.temporalAccumulation&&(this._temporalPostProcess=this._createPostProcess({name:"VolumetricLightingTemporal",shaderName:dt,uniforms:Ia,samplers:["volHistorySampler","volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Ce.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._temporalDefines}),this._temporalPostProcess.onActivateObservable.add(()=>this._prepareHistory()),this._temporalPostProcess.onApplyObservable.add(o=>this._bindTemporal(o))),this._blurPostProcesses=[];for(let o=0;o<i.blurPasses;++o){let n=this._createPostProcess({name:`VolumetricLightingBlur${o}`,shaderName:ut,uniforms:["volCameraMinMaxZ","volDepthRatio","volBlurDirection","volBlurParams","volPassParams"],samplers:["volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Ce.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._blurDefines});n.onApplyObservable.add(l=>this._bindBlur(l,o)),this._blurPostProcesses.push(n)}this._composePostProcess=this._createPostProcess({name:"VolumetricLightingCompose",shaderName:ft,uniforms:["volCameraMinMaxZ","volDepthRatio","volComposeParams","volPassParams"],samplers:["volSceneSampler","volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Ce.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._composeDefines}),this._composePostProcess.onApplyObservable.add(o=>this._bindCompose(o)),this.addEffect(new De.PostProcessRenderEffect(e,t.SceneColorEffectName,()=>this._linearDepthPostProcess,!0)),this.addEffect(new De.PostProcessRenderEffect(e,t.ScatteringEffectName,()=>this._scatteringPostProcess,!0)),this._temporalPostProcess&&this.addEffect(new De.PostProcessRenderEffect(e,t.TemporalEffectName,()=>this._temporalPostProcess,!0)),this._blurPostProcesses.length&&this.addEffect(new De.PostProcessRenderEffect(e,t.BlurEffectName,()=>this._blurPostProcesses,!0)),this.addEffect(new De.PostProcessRenderEffect(e,t.ComposeEffectName,()=>this._composePostProcess,!0)),this._applyMsaaSamples()}_disposePostProcesses(e){[this._linearDepthPostProcess,this._scatteringPostProcess,this._temporalPostProcess,...this._blurPostProcesses,this._composePostProcess].forEach(r=>{r&&(e.forEach(o=>r.dispose(o)),r.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,i=this._blurPostProcesses[0]??this._composePostProcess;if(!e||!i)return;++this._temporalFrame;let r=e.width,o=e.height,n=this._historyTextures[0];if(!n||n.width!==r||n.height!==o){this._disposeHistory();let l=this._scene.getEngine();for(let p=0;p<2;++p)this._historyTextures[p]=l.createRenderTargetTexture({width:r,height:o},{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,i.inputTexture=this._historyTextures[this._historyIndex]}_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(r=>{delete this._renderEffects[r]}),this._buildRenderEffects()}catch(r){console.error("Failed to rebuild the volumetric lighting rendering pipeline.",r)}finally{try{e.attachCamerasToRenderPipeline(this.name,i)}catch(r){console.error("Failed to re-attach the cameras to the volumetric lighting rendering pipeline.",r)}}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(),r=Ci(this._scene,this._camera,this._configuration,this._budget,this._selection);this._selection=r,this._updateIdleState(r);let o=this._buildScatteringDefines(r,i);o!==this._scatteringDefines&&(this._scatteringDefines=o,this._scatteringPostProcess.updateEffect(o));let n=this._buildTemporalDefines(i);n!==this._temporalDefines&&(this._temporalDefines=n,this._temporalPostProcess?.updateEffect(n));let l=this._buildLinearDepthDefines(i);l!==this._linearDepthDefines&&(this._linearDepthDefines=l,this._linearDepthPostProcess?.updateEffect(l));let p=this._buildBlurDefines(i);p!==this._blurDefines&&(this._blurDefines=p,this._blurPostProcesses.forEach(c=>c.updateEffect(p)));let s=this._buildComposeDefines(i);s!==this._composeDefines&&(this._composeDefines=s,this._composePostProcess?.updateEffect(s))}_updateIdleState(e){let i=this._configuration,r=i.ambientColor,o=e.shadowed.length>0||e.unshadowed.length>0||!!e.csm,n=i.ambientIntensity>0&&(r[0]>0||r[1]>0||r[2]>0),l=!o&&!n&&i.extinctionAmount<=0&&i.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 i=this._scene.getEngine().getCaps().instancedArrays,r=[],o=La;for(let n of this._depthWarmup){if(o--<=0)break;if(this._depthWarmup.delete(n),n.isDisposed()||!n.subMeshes?.length)continue;let l=n.getClassName(),p=n.hasThinInstances||l==="InstancedMesh"||l==="InstancedLinesMesh"||i&&(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||r.push(n)}r.forEach(n=>this._depthWarmup.add(n))}_writeLight(e,i,r,o,n,l){let{light:p,config:s}=e,c=i*4;ie(p)?(Ne(p,this._temporaryVector),r[c]=-this._temporaryVector.x,r[c+1]=-this._temporaryVector.y,r[c+2]=-this._temporaryVector.z,r[c+3]=1):(at(p,this._temporaryVector).subtractInPlace(this._camera.globalPosition),r[c]=this._temporaryVector.x,r[c+1]=this._temporaryVector.y,r[c+2]=this._temporaryVector.z,r[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;o[c]=this._temporaryColor.r*h,o[c+1]=this._temporaryColor.g*h,o[c+2]=this._temporaryColor.b*h,o[c+3]=s.anisotropy,ae(p)?(Ne(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]=st(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 i=null;switch(this._depthSource){case 2:{let r=_e(this._scene);i=r?wi(r):null;break}case 1:{let r=Ge(this._scene);i=r?Oi(r):null;break}default:i=this._depthRenderer?.getDepthMap()??null;break}i&&(e.setTexture("depthSampler",i),this._bindDepthUniforms(e))}_bindScattering(e){let i=this._scene,r=this._camera,o=this._configuration,n=this._selection;if(!n)return;e.setFloat4("volPassParams",this._idle?1:0,0,0,0),this._inverseViewProjection.copyFrom(i.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",r.globalPosition),r.getDirectionToRef(i.useRightHandedSystem?qo:Yo,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize()),e.setFloat2("volCameraMinMaxZ",r.minZ,r.maxZ),e.setFloat("volFrameIndex",i.getRenderId()%64),e.setFloat("volTemporalOffset",this._frameCount*Ta%1),this._bindDepthRatio(e),e.setFloat4("volFogInfos",o.fogMode,o.fogStart,o.fogEnd,o.fogDensity),this._temporaryColor.set(o.fogColor[0],o.fogColor[1],o.fogColor[2]),e.setColor3("volFogColor",this._temporaryColor),e.setFloat("volLinearFogEps",Math.max((o.fogEnd-o.fogStart)*.02,1e-4)),e.setFloat4("volMedium",o.albedo,o.heightFogBaseHeight,o.heightFogFalloff,0),o.screenSpaceShadows&&(e.setMatrix("volViewProjection",i.getTransformMatrix()),e.setFloat4("volScreenShadowParams",o.screenSpaceShadowMaxDistance,o.screenSpaceShadowBias,o.screenSpaceShadowThickness,0)),this._temporaryColor.set(o.ambientColor[0],o.ambientColor[1],o.ambientColor[2]).scaleInPlace(o.ambientIntensity),e.setColor3("volAmbient",this._temporaryColor);let l=n.unshadowed.length,p=l-n.directionalCount,s=o.temporalAccumulation?1:o.ditherStrength;e.setFloat4("volParams",o.maxDistance,s,o.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?.(i.activeCamera)??0,L=g.getDepthMaxZ?.(i.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?.(i.activeCamera)??1,g=u.getDepthMaxZ?.(i.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 i=this._scatteringPostProcess,r=this._temporalPostProcess??this._blurPostProcesses[0]??this._composePostProcess,o=i&&i.width>0?i.width:1,n=i&&i.height>0?i.height:1,l=r&&r.width>0?r.width:o,p=r&&r.height>0?r.height:n;e.setFloat2("volDepthRatio",o/l,n/p)}_bindTemporal(e){let i=this._scene,r=this._camera,o=this._configuration;if(!this._scatteringPostProcess)return;let n=this._historyIndex^1,l=this._historyTextures[n];e._bindTexture("volHistorySampler",l?.texture??i.getEngine().emptyTexture),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",r.minZ,r.maxZ),this._bindDepthRatio(e),this._inverseViewProjection.copyFrom(i.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",r.globalPosition),r.getDirectionToRef(i.useRightHandedSystem?qo:Yo,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize());let p=r.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",o.temporalAccumulationFactor,this._temporalClippingWidth,o.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(i.getTransformMatrix()),this._previousCameraPosition.copyFrom(p)}_bindBlur(e,i){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",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.setFloat4("volPassParams",this._idle?1:0,0,0,0),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e);let r=this._ldrEncode?1/255:0;e.setFloat4("volComposeParams",i.intensity,i.extinctionAmount,i.upsampleDepthThreshold,r)}};var M=null,nr=null;function Ei(){return nr}a(Ei,"getVolumetricLightingRenderingPipelineConfiguration");function He(t){nr=t}a(He,"setVolumetricLightingRenderingPipelineConfiguration");function Ma(){return M?.isDisposed&&(M=null),M}a(Ma,"getVolumetricLightingRenderingPipeline");function Ra(t){M=t}a(Ra,"setVolumetricLightingRenderingPipelineRef");function Va(t){let e=t?.getEngine();return e?q.IsSupported(e):!1}a(Va,"isVolumetricLightingSupported");function Ai(){M&&(M.dispose(),M=null)}a(Ai,"disposeVolumetricLightingRenderingPipeline");function ar(t,e,i){return M=new q("VolumetricLightingRenderingPipeline",t,e),M.msaaSamples=i?.msaaSamples??1,M}a(ar,"createVolumetricLightingRenderingPipeline");function Ii(){return M?M.serializeConfiguration():null}a(Ii,"serializeVolumetricLightingRenderingPipeline");function Mi(t,e,i,r){let o=M??ar(t,e,r);o.msaaSamples=r?.msaaSamples??1;let n={...i};return n.fogDensity===void 0&&(n.fogDensity=q.GetDefaultFogDensity(o.scene,o.camera)),n.fogEnd===void 0&&(n.fogEnd=q.GetDefaultFogEnd(o.scene,o.camera)),n.screenSpaceShadowMaxDistance===void 0&&(n.screenSpaceShadowMaxDistance=q.GetDefaultFogEnd(o.scene,o.camera)),o.applyConfiguration(xe(n)),o}a(Mi,"parseVolumetricLightingRenderingPipeline");function Fa(){M?.markLightsDirty()}a(Fa,"markVolumetricLightsDirty");var gt=require("babylonjs");function Na(t){Se.set(t,ei()),fe.set(t,Xt()),ge.set(t,Kt()),ye.set(t,ri()),be.set(t,li()),ve.set(t,qt()),He(Ii())}a(Na,"saveRenderingConfigurationForCamera");function Ri(t,e,i){Jt(),Wt(t.getScene()),jt(),oi(),Ai(),si(),Yt(),kt(t.getScene());let r=Se.get(t);r&&!i?.ssao2Disabled&&ti(t.getScene(),t,r,i);let o=Ei();o&&!i?.volumetricLightingDisabled&&Mi(t.getScene(),t,o,i);let n=fe.get(t);n&&!i?.vlsDisabled&&$t(t.getScene(),n,i);let l=ge.get(t);l&&!i?.ssrDisabled&&Zt(t.getScene(),t,l,i);let p=ye.get(t);p&&!i?.motionBlurDisabled&&ni(t.getScene(),t,p,i);let s=be.get(t);s&&!i?.defaultPipelineDisabled&&ci(t.getScene(),t,s,e,i);let c=ve.get(t);c&&!i?.taaDisabled&&Qt(t.getScene(),t,c,i)}a(Ri,"applyRenderingConfigurationForCamera");function Ga(t){let e=t.getCaps();return e.textureHalfFloatRender||e.textureFloatRender}a(Ga,"canUseHdr");function K(t){let e=t.getCaps();return e.textureHalfFloatRender?gt.Constants.TEXTURETYPE_HALF_FLOAT:e.textureFloatRender?gt.Constants.TEXTURETYPE_FLOAT:gt.Constants.TEXTURETYPE_UNSIGNED_BYTE}a(K,"getHdrTextureType");var ke=require("babylonjs"),sr=require("babylonjs");function lr(t){let e=t.metadata?.physicsAggregate;if(!e)return;let i;F(t)?i=t:Me(t)&&(i=t.sourceMesh);let r=new sr.PhysicsAggregate(t,e.shape.type,{mesh:i,mass:e.massProperties.mass});r.body.setMassProperties({mass:e.massProperties.mass,inertia:e.massProperties.inertia?ke.Vector3.FromArray(e.massProperties.inertia):void 0,centerOfMass:e.massProperties.centerOfMass?ke.Vector3.FromArray(e.massProperties.centerOfMass):void 0,inertiaOrientation:e.massProperties.inertiaOrientation?ke.Quaternion.FromArray(e.massProperties.inertiaOrientation):void 0}),r.shape.density=e.shape.density,r.body.setMotionType(e.body.motionType),r.shape.material=e.material,t.physicsAggregate=r,t.metadata.physicsAggregate=void 0}a(lr,"configurePhysicsAggregate");function cr(t,e){let i=e?.rendering;e.volumetricLightingRenderingPipelineConfiguration&&He(e.volumetricLightingRenderingPipelineConfiguration),(Array.isArray(i)?i:[]).forEach(o=>{let n=t.getCameraById(o.cameraId);n&&(o.ssao2RenderingPipeline&&Se.set(n,o.ssao2RenderingPipeline),o.vlsPostProcess&&fe.set(n,o.vlsPostProcess),o.ssrRenderingPipeline&&ge.set(n,o.ssrRenderingPipeline),o.motionBlurPostProcess&&ye.set(n,o.motionBlurPostProcess),o.defaultRenderingPipeline&&be.set(n,o.defaultRenderingPipeline),o.taaRenderingPipeline&&ve.set(n,o.taaRenderingPipeline))})}a(cr,"applyRenderingConfigurations");var pr=require("babylonjs");function Le(t,e,i){return new Promise((r,o)=>{let n=new pr.WebRequest;n.open("GET",t),n.responseType=e,n.send(),n.addEventListener("progress",l=>{i?.({total:l.total,loaded:l.loaded})}),n.addEventListener("load",()=>{r(e==="text"?n.responseText:n.response)}),n.addEventListener("error",l=>o(l))})}a(Le,"loadFile");async function k(t,e){let i=await Le(t,"text",e);return JSON.parse(i)}a(k,"loadJsonFile");function Vi(t,e,i=null){if(i){let o=i.getNodes().find(n=>n.name===t);if(o)return o}else{let o=e.getNodeByName(t);if(o)return o}let r=e.lights.filter(o=>me(o));for(let o of r){let n=o.lights.find(l=>i?l.name===t&&l._parentContainer===i:l.name===t);if(n)return n}return null}a(Vi,"getNodeByName");function Pe(t,e){let i=e.getNodeById(t);if(i)return i;let r=e.lights.filter(o=>me(o));for(let o of r){let n=o.lights.find(l=>l.id===t);if(n)return n}return null}a(Pe,"getNodeById");var ce=require("babylonjs"),hr=require("babylonjs");function Fi(t){let e=hr.Vector3.FromArray(t);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(Fi,"parseAxis");var mr=require("babylonjs"),Q=require("babylonjs");function dr(t){return t.runtimeConfiguration.forEach(e=>{e.rotationAxis&&(e.rotationAxis=Fi(e.rotationAxis)),e.boneOffsetAxis&&(e.boneOffsetAxis=Fi(e.boneOffsetAxis))}),t}a(dr,"parseRagdollConfiguration");function Ni(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 dr(e)}a(Ni,"copyAndParseRagdollConfiguration");function Ba(t,e){let i=t.getConstraints(),o=t._skeleton?.getChildren()[0],n=[];if(e.forEach(p=>{(p.bone!==void 0?[p.bone]:p.bones).forEach(c=>{c!==o?.name&&n.push(p)})}),n.length!==i.length)return mr.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 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(Ba,"applyRagdollJointLimits");function za(t){return new Promise(e=>{setTimeout(()=>e(),t)})}a(za,"waitMs");async function Gi(t){for(;!t();)await za(150)}a(Gi,"waitUntil");function Bi(t){return t&&JSON.parse(JSON.stringify(t))}a(Bi,"cloneJSObject");var Hi=require("babylonjs"),br=require("babylonjs"),vt=require("babylonjs"),xr=require("babylonjs"),_r=require("babylonjs"),Cr=require("babylonjs"),oe=require("babylonjs"),ur=!1,fr=null,we=[],zi=new Map;function Ha(t,e){let i=(0,oe._GetAudioEngine)(null);return new Cr._WebAudioStaticSound(t,i,e)}a(Ha,"createSoundInstance");function gr(t){if(fr?.remove(),!we.length)return;let e=Hi.Vector3.Zero();fr=t.onBeforeRenderObservable.add(()=>{let i=(0,oe._GetAudioEngine)(null).listener.attachedNode;i&&(i.getWorldMatrix().getTranslationToRef(e),we.forEach(r=>{r.isEnabled(!1)&&r.autoUpdateSpatial&&r.sound?._isSpatial&&r.isPlaying()&&t.activeCamera&&Hi.Vector3.Distance(e,r.getAbsolutePosition())<=r.sound.spatial.maxDistance&&r.sound.spatial.update()}))})}a(gr,"registerUpdateSoundsObserver");function vr(t,e){e.onDisposeObservable.addOnce(()=>{let i=we.indexOf(t);i!==-1&&we.splice(i,1)})}a(vr,"registerSoundInstanceCleanup");function Sr(t){t.sound&&vr(t,t.sound),t.onDisposeObservable.addOnce(()=>{t.sound?.dispose()})}a(Sr,"registerSoundNodeEvents");function ka(t,e){return new Promise(async(i,r)=>{if(!t.offlineProvider||!br.Database.IDBStorageEnabled)return(0,oe.CreateSoundBufferAsync)(e).then(o=>i(o)).catch(o=>r(o));t.offlineProvider.loadFile(e,o=>{(0,oe.CreateSoundBufferAsync)(o).then(n=>i(n)).catch(n=>r(n))},void 0,()=>{r(null)},!0)})}a(ka,"loadSoundBuffer");function ki(t,e){if(!t.soundRelativePath||!t.sound)return;e.onSoundLoadedObservable=new xr.Observable;let i=Ha(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,we.push(e),vr(e,i),gr(e.getScene()),e.onSoundLoadedObservable.notifyObservers(e)}),Sr(e),yr(e,i)}a(ki,"configureSourceNodeFrom");function yr(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===vt.SoundState.Paused,t.isPlaying=()=>e.state===vt.SoundState.Started,t.isStopped=()=>e.state===vt.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,r)=>e.setVolume(i,r),t.getClassName=()=>"SoundNode",t.setSoundSpatial=i=>new Promise(r=>{e._isSpatial=i,setTimeout(()=>{i&&e.spatial.attach(t),r()})}),t.cloneAsync=async(i,r,o)=>new Promise(n=>{let l=t.clone(i,r,o);ki(t,l),l.onSoundLoadedObservable.addOnce(()=>{setTimeout(()=>n(l))})})}a(yr,"configureSoundNodePrototype");function Dr(){ur||(ur=!0,(0,_r.AddParser)("SoundNode",(t,e,i,r)=>{t.transformNodes?.forEach(o=>{if(!o.isSoundNode)return;let n=i.transformNodes?.find(l=>l.id===o.id);if(n&&o.soundRelativePath){let l=`${r}${o.soundRelativePath}`;e.addPendingData(l),zi.has(l)||zi.set(l,ka(e,l)),zi.get(l).then(s=>{(0,oe.CreateSoundAsync)(o.soundRelativePath,s,{spatialAutoUpdate:!1}).then(c=>{if(e.removePendingData(l),n.isDisposed())return c.dispose();c.volume=o.volume,c._isSpatial=o.isSpatial,o.isSpatial&&(c.spatial.attach(n),c.spatial.maxDistance=o.maxDistance,c.spatial.panningModel=o.panningModel,c.spatial.distanceModel=o.distanceModel),n.sound=c,n.soundRelativePath=o.soundRelativePath,n.autoUpdateSpatial=o.autoUpdateSpatial,we.push(n),Sr(n),yr(n,c),gr(e)})})}})}))}a(Dr,"registerAudioParser");var Lr=require("babylonjs");function Oe(t){let e=new Set;[...t.transformNodes,...t.meshes].forEach(r=>{if(r.metadata?.isStaticGroup){let o=r.getDescendants(!1);o.push(r),o.forEach(n=>{if((ne(n)||te(n)&&!n.isWorldMatrixFrozen)&&n.billboardMode===Lr.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(Oe,"configureTransformNodes");var Ue=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(r=>r.name===i)??null}getNodeByName(e){let i=`${e}-${this.namingId}`;for(let r of this.entries.rootNodes){let o=this._recursivelyGetNodeByName(i,r);if(o)return o}return null}_recursivelyGetNodeByName(e,i){if(i.name===e)return i;for(let r of i.getDescendants(!0)){let o=this._recursivelyGetNodeByName(e,r);if(o)return o}return null}getScriptByClassByObjectName(e,i){let r=this.getNodeByName(e);if(r){let o=Te(r,i);if(o?.length===1)return o[0]}return null}};var Ui=require("babylonjs"),We=class{static{a(this,"AdvancedAssetContainer")}container;_rootUrl;_scriptsMap;_originalDescendants=[];_nodesMap=new Map;_animationGroupsMap=new Map;constructor(e,i,r){this.container=e,this._rootUrl=i,this._scriptsMap=r,e.populateRootNodes(),e.rootNodes.forEach(o=>{this._originalDescendants.push(o,...o.getDescendants(!1))}),e.animationGroups.forEach(o=>{this._animationGroupsMap.set(o.name,o)}),this._originalDescendants.forEach(o=>{this._nodesMap.set(o,{node:o,metadata:Bi(o.metadata)})})}removeDefault(){this.container.getNodes().forEach(e=>{U.get(e)?.forEach(r=>{St(e,r)})}),this.container.removeAllFromScene()}getRootNodeByName(e){return this.container.rootNodes.find(i=>i.name===e)??null}getScriptByClassByObjectName(e,i){let r=this.container.getNodes();for(let o of r)if(o.name===e){let n=Te(o,i);if(n?.length===1)return n[0]}return null}instantiate(e){let i=Ui.Tools.RandomId(),r=a(s=>s,"nameFunction"),o=this.container.instantiateModelsToScene(r,!1,{...e,predicate:a(s=>(s.name=`${s.name}@editor-tools@${i}_${s.id}`,e?.predicate?.(s)??!0),"predicate")}),n=new Ue(o,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]}),o.animationGroups.forEach(s=>{let c=s.name.split("@editor-tools@");s.name=`${c[0]}-${i}`});let p=[];return o.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]}-${i}`;let m=this._originalDescendants.find(d=>d.id===h);se(m)&&te(s)&&ki(m,s),s.id=Ui.Tools.RandomId(),s.metadata=Bi(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}-${i}`)}})})})}),p.forEach(s=>{H(this.container.scene,s,this._scriptsMap,{namingId:i,rootUrl:this._rootUrl})}),Oe(this.container.scene),n}};var Pr=require("babylonjs"),wr=require("babylonjs");async function Or(t,e,i){let r=i.iblIntensity,o=i.environmentIntensity,l=t.split("/").pop().replace(".scene",".babylon"),p=await(0,wr.LoadAssetContainerAsync)(l,i,{rootUrl:e,pluginExtension:".babylon"});return i.onDisposeObservable.addOnce(()=>{p.dispose()}),Pr.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(s=>F(s)&&s._checkDelayState()),p.addAllToScene(),i.iblIntensity=r,i.environmentIntensity=o,Oe(i),p}a(Or,"preloadSceneScriptAsset");async function Tr(t,e){return k(`${e}${t}`)}a(Tr,"preloadCommonScriptAsset");var pe=new Map,Xe=new Map;function Ua(t,e){Xe.has(t)&&console.warn(`A parser for the extension '${t}' was already registered. It will be overwritten.`),Xe.set(t,e)}a(Ua,"registerScriptAssetParser");async function Wi(t,e,i){let r=[e,...e.transformNodes,...e.meshes,...e.lights,...e.cameras],o=pe.get(e);o||(o=new Map,pe.set(e,o)),e.onDisposeObservable.addOnce(()=>{pe.delete(e)}),r.filter(s=>s.metadata?.scripts?.length).map(s=>s.metadata.scripts).flat().forEach(s=>{if(i[s.key]?.default?._SceneAssets?.forEach(h=>{o.get(h.sceneName)||o.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&&!o.get(m.value)&&o.set(m.value,null)}});let l=0;for(let s of o.values())s===null&&++l;if(l===0)return l;let p=[];return o.forEach((s,c)=>{o.get(c)||p.push(new Promise(async h=>{try{let m=c.split(".").pop();switch(m){case"scene":let d=await Or(c,t,e);e.onDisposeObservable.addOnce(()=>{d.dispose(),o.delete(c)}),o.set(c,new We(d,t,i));break;default:if(Xe.has(m)){let u=Xe.get(m);o.set(c,await u({key:c,rootUrl:t,scene:e}));break}else o.set(c,await Tr(c,t));break}}catch(m){console.error(m)}h()}))}),await Promise.all(p),l}a(Wi,"_preloadScriptsAssets");var Er=require("babylonjs"),yt=require("babylonjs"),Ar=require("babylonjs"),bt=require("babylonjs"),Ir=require("babylonjs"),Mr=require("babylonjs-gui");function re(t,e){return e?`${t}-${e}`:t}a(re,"formatNameWithId");function Xi(t,e,i,r,o){let n=r.constructor;if(!n)return;n._NodesFromScene?.forEach(s=>{r[s.propertyKey.toString()]=Vi(re(s.nodeName,s.options?.global?void 0:o.namingId),t,s.options?.global?void 0:e._parentContainer)}),n._ComponentsFromScene?.length&&t.getEngine().onBeginFrameObservable.addOnce(()=>{n._ComponentsFromScene?.forEach(s=>{let c=[];if([t,...t.transformNodes,...t.meshes,...t.lights,...t.cameras].forEach(m=>{let d=$i(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()}".`);r[s.propertyKey.toString()]=c[0]??null})}),n._NodesFromDescendants?.forEach(s=>{let c=e.getDescendants?.(s.directDescendantsOnly,h=>h.name===re(s.nodeName,o.namingId))[0];r[s.propertyKey.toString()]=c??null}),n._AnimationGroups?.forEach(s=>{r[s.propertyKey.toString()]=t.getAnimationGroupByName(re(s.animationGroupName,o.namingId))}),n._SoundsFromScene?.forEach(s=>{let c=Vi(re(s.soundName,s.options?.global?void 0:o.namingId),t,s.options?.global?void 0:e._parentContainer);c&&se(c)&&(r[s.propertyKey.toString()]=c??null)}),(n._GuiFromAsset??[]).map(async s=>{let c=`${o.rootUrl}assets/${s.pathInAssets}`;try{let h=await k(c),m=Mr.AdvancedDynamicTexture.CreateFullscreenUI(h.name,!0,t);m.parseSerializedObject(h.content,!1),r[s.propertyKey.toString()]=m,s.onGuiCreated?.(r,m)}catch(h){throw console.error(`Failed to load GUI from asset: ${c}`),h}}),n._ParticleSystemsFromScene?.forEach(s=>{let c=t.particleSystems?.find(h=>h.name!==re(s.particleSystemName,o.namingId)?!1:s.directDescendantsOnly?h.emitter===e:h);r[s.propertyKey.toString()]=c}),(n._VisibleInInspector??[]).forEach(s=>{let c=s.propertyKey.toString(),h=i.values;if(!h)throw new Error(`No values found for script with key "${i.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":r[c]=m;break;case"vector2":r[c]=bt.Vector2.FromArray(m);break;case"vector3":r[c]=bt.Vector3.FromArray(m);break;case"color3":r[c]=yt.Color3.FromArray(m);break;case"color4":r[c]=yt.Color4.FromArray(m);break;case"entity":switch(s.configuration.entityType){case"node":case"sound":r[c]=Pe(m,t)??null;break;case"animationGroup":r[c]=t.getAnimationGroupByName(m)??null;break;case"particleSystem":r[c]=t.particleSystems?.find(u=>u.id===m)??null;break}break;case"texture":m&&(r[c]=Ar.Texture.Parse(m,t,o.rootUrl));break;case"asset":if(m){let u=s.configuration.assetType,g=pe.get(t).get(m);switch(u){case"json":case"gui":case"scene":case"navmesh":case"cinematic":r[c]=g;break;case"ragdoll":r[c]=Ni(g);break;case"nodeParticleSystemSet":let y=Ir.NodeParticleSystemSet.Parse(g);r[c]=y;break;case"material":r[c]=Er.Material.Parse(g,t,o.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=t.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 r[u]?.(h);m=h.pickInfo,m||(m=t.pick(t.pointerX,t.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 r[u]?.(h)})})}if(n._KeyboardEvents?.length&&(p=t.onKeyboardObservable.add(s=>{n._KeyboardEvents.forEach(c=>{c.eventTypes.includes(s.type)&&r[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,o.namingId))||null;r[c.propertyKey.toString()]=h})}if(n._AnimationsFromSprite?.length){if(!Vt(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,o.namingId));h?r[c.propertyKey.toString()]=h??null:console.warn(`Sprite animation named "${re(c.animationName,o.namingId)}" not found on sprite "${e.name}".`)})}return n._SceneAssets?.forEach(s=>{let c=pe.get(t);r[s.propertyKey.toString()]=c.get(s.sceneName)}),{observers:{pointerObserver:l,keyboardObserver:p}}}a(Xi,"applyDecorators");function H(t,e,i,r){e.metadata?.scripts&&(e.metadata.scripts?.forEach(o=>{if(!o.enabled)return;let n=i[o.key];if(!n)return;let l=n,p={};if(n.default){l=new n.default(e);let s=Xi(t,e,o,l,r);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))),ji(e,l,o.key,p)}),e.metadata.scripts=void 0)}a(H,"_applyScriptsForObject");function Wa(t,e,i){if(i??=t.getScene?.(),!i)throw new Error("Cannot apply script on object: no scene available.");let r=new e(t),o={};return Xi(i,t,{values:{}},r,{rootUrl:""}),r.onStart&&(o.onStartObserver=i.onBeforeRenderObservable.addOnce(()=>r.onStart())),r.onUpdate&&i.onBeforeRenderObservable.add(()=>r.onUpdate()),ji(t,r,"runtime",o),r}a(Wa,"applyScriptOnObject");var U=new Map;function ji(t,e,i,r){let o={key:i,observers:r,instance:e};U.has(t)?U.get(t).push(o):U.set(t,[o]),(de(t)||Rt(t)||It(t)||se(t))&&t.onDisposeObservable.addOnce((()=>{U.get(t)?.slice()?.forEach(l=>{St(t,l)}),U.delete(t)}))}a(ji,"_registerScriptInstance");function St(t,e){e.observers.onStartObserver?.remove(),e.observers.onUpdateObserver?.remove(),e.observers.pointerObserver?.remove(),e.observers.keyboardObserver?.remove();try{e.instance.onStop?.(t)}catch(o){console.error(`Failed to call onStop for script ${e.key} on object ${t}`,o)}let i=U.get(t),r=i?.indexOf(e)??-1;r!==-1&&i?.splice(r,1)}a(St,"_removeRegisteredScriptInstance");function Te(t,e){return U.get(t)?.filter(o=>o.instance.constructor===e)?.map(o=>o.instance)??null}a(Te,"getAllScriptsByClassForObject");function $i(t,e){return Te(t,e)?.[0]??null}a($i,"getScriptByClassForObject");var Vr=require("babylonjs"),Rr=!1;function Fr(){Rr||(Rr=!0,(0,Vr.AddParser)("MeshEditorPlugin",(t,e,i,r)=>{t.meshes?.forEach(o=>{o.instances?.forEach(n=>{let l=i.meshes?.find(p=>p.id===n.id);l&&n.billboardMode!==void 0&&(l.billboardMode=n.billboardMode)})})}))}a(Fr,"registerMeshParser");var Nr=!1;function Xa(t){Nr=t}a(Xa,"setUseKtx2CompressedTextures");function $e(){return Nr}a($e,"isUsingKtx2CompressedTextures");function xt(t){return`${t.substring(0,t.lastIndexOf("."))}.ktx2`}a(xt,"_getKtx2TextureName");function $a(t){t.setCompressedTextureExclusions([".env",".hdr",".dds"]),t.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}a($a,"configureEngineToUseCompressedTextures");function _t(t,e){t._excludedCompressedTextures&&!t._excludedCompressedTextures?.includes(e)&&t._excludedCompressedTextures?.push(e)}a(_t,"addExcludedCompressedTexture");function ja(t,e,i){e.loadingTexturesQuality!==t&&(e.loadingTexturesQuality=t,e.textures.forEach(r=>{if(!Re(r)||!r.url)return;let o=Ct(r,e);!o||r.url.includes(o)||r.updateURL(i+o)}))}a(ja,"applyTexturesQuality");function Ct(t,e){if(e.loadingTexturesQuality==="high"||!t.metadata?.baseSize)return t.name;let i=t.metadata.baseSize.width,r=t.metadata.baseSize.height,o=i===N(i)||r===N(r),n="";switch(e.loadingTexturesQuality){case"medium":let d=i*.66>>0,u=r*.66>>0;o&&(d=N(d),u=N(u)),n=`_${d}_${u}`;break;case"low":case"very-low":let S=i*.33>>0,g=r*.33>>0;o&&(S=N(S),g=N(g)),n=`_${S}_${g}`;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(),m=`${s.replace(`.${c}`,"")}${n}.${c}`;return p.push(m),p.join("/")}a(Ct,"getTextureUrl");var Ki=require("babylonjs"),Gr=!1;function Br(){if(Gr)return;Gr=!0;let t=Ki.SerializationHelper._TextureParser;Ki.SerializationHelper._TextureParser=(e,i,r)=>{$e()&&(e.name&&(e.name=xt(e.name)),e.url&&(e.url=xt(e.url)));let o=Ct(e,i);if(!o)return t(e,i,r);let n=e.name;e.name=o;let l=t(e,i,r);return l&&(l.name=n),l}}a(Br,"registerTextureParser");function Zi(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(Zi,"normalizeAtlasJson");function Ka(t,e,i){let o=(t.metadata?.spriteAnimations??[]).find(n=>n.name===e);if(!o)return console.error(`Animation with name "${e}" not found on sprite.`);t.playAnimation(o.from,o.to,o.loop,o.delay,i)}a(Ka,"playSpriteAnimationFromName");var Hr=require("babylonjs"),kr=require("babylonjs"),Ur=require("babylonjs"),Wr=require("babylonjs"),Yi=require("babylonjs"),Ee=require("babylonjs"),Xr=require("babylonjs"),zr=!1;function $r(){zr||(zr=!0,(0,Xr.AddParser)("SpriteMapNode",(t,e,i,r)=>{t.transformNodes?.forEach(o=>{if(!o.isSpriteMap)return;let n=i.transformNodes?.find(s=>s.id===o.id);if(!n)return;n.isSpriteMap=o.isSpriteMap;let l=`${r}${o.atlasJsonRelativePath}`;e.addPendingData(l);let p=new Ur.WebRequest;p.open("GET",l),p.send(),p.addEventListener("load",()=>{e.removePendingData(l);let s=JSON.parse(p.responseText);Zi(s);let c=`${Hr.Tools.GetFolderPath(l)}${s.meta.image}`,h=new Yi.Texture(c,e,!1,!1,Yi.Texture.NEAREST_NEAREST,null,null,null,!1,kr.Engine.TEXTUREFORMAT_RGBA),m=new Wr.SpriteMap(n.name,s,h,{layerCount:o.options.layerCount,stageSize:Ee.Vector2.FromArray(o.options.stageSize??[10,1]),outputSize:Ee.Vector2.FromArray(o.options.outputSize??[100,100]),colorMultiply:Ee.Vector3.FromArray(o.options.colorMultiply??[1,1,1]),flipU:!0},e);o.getClassName=()=>"SpriteMapNode",o.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 Ee.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($r,"registerSpriteMapParser");var Kr=require("babylonjs"),Zr=require("babylonjs"),Dt=require("babylonjs"),Yr=require("babylonjs"),jr=!1;function qr(){if(jr)return;jr=!0,(0,Yr.RegisterShadowGeneratorSceneComponent)(Zr.ShadowGenerator);let t=(0,Dt.GetParser)(Kr.SceneComponentConstants.NAME_SHADOWGENERATOR);(0,Dt.AddParser)("ShadowGeneratorEditorPlugin",(e,i,r,o)=>{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,N(l.mapSize))}}),t?.(e,i,r,o),i.lights.forEach(l=>{let p=l.getShadowGenerator();if(p?.getShadowMap()){let c=p.id,h=n.get(c);h&&(p.originalMapSize=h)}})})}a(qr,"registerShadowGeneratorParser");var en=require("babylonjs"),tn=require("babylonjs"),on=require("babylonjs"),qi=require("babylonjs"),rn=require("babylonjs");function Qr(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 r=tn.Sprite.Parse(i,t);r.uniqueId=i.uniqueId,r.metadata=i.metadata}}a(Qr,"parseSerializedSpriteManager");var Jr=!1;function nn(){Jr||(Jr=!0,(0,rn.AddParser)("SpriteManagerNode",(t,e,i,r)=>{t.transformNodes?.forEach(o=>{if(!o.isSpriteManager)return;let n=i.transformNodes?.find(p=>p.id===o.id);if(!n)return;let l=e.getEngine();if(n.isSpriteManager=o.isSpriteManager,o.atlasJsonRelativePath){let p=`${r}${o.atlasJsonRelativePath}`;e.addPendingData(p);let s=new on.WebRequest;s.open("GET",p),s.send(),s.addEventListener("load",()=>{e.removePendingData(p);let c=JSON.parse(s.responseText),h=`${en.Tools.GetFolderPath(p)}${c.meta.image}`;_t(l,h);let m=new qi.SpriteManager(n.name,h,1e3,64,e,void 0,void 0,!0,c);n.spriteManager=m,n.getClassName=()=>"SpriteManagerNode",o.spriteManager&&Qr(m,o.spriteManager)})}else if(o.spriteManager?.textureUrl){_t(l,o.spriteManager.textureUrl);let p=`${r}${o.spriteManager.textureUrl}`,s=new qi.SpriteManager(n.name,p,1e3,{width:o.spriteManager.cellWidth,height:o.spriteManager.cellHeight},e,void 0,void 0,!1);n.spriteManager=s,n.getClassName=()=>"SpriteManagerNode",o.spriteManager&&Qr(s,o.spriteManager)}})}))}a(nn,"registerSpriteManagerParser");var sn=require("babylonjs"),ln=require("babylonjs"),an=!1;function cn(){an||(an=!0,(0,ln.AddParser)("MorphTargetManagerEditorPlugin",(t,e,i,r)=>{t.morphTargetManagers.forEach(o=>{let l=i.meshes.find(c=>c.id===o.meshId)?.morphTargetManager;if(!l||o.targets.find(c=>!c.delayLoadingFile))return;let s=[];o.targets.forEach(c=>{if(!c.delayLoadingFile)return s.push(Promise.resolve(null));let h=`${r}${c.delayLoadingFile}`;e.addPendingData(h);let m=new sn.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=o.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(cn,"registerMorphTargetManagerParser");var hn=require("babylonjs"),mn=require("babylonjs"),pn=!1;function dn(){pn||(pn=!0,(0,hn.AddParser)("NodeParticleSystemSetEditorPlugin",(t,e,i,r)=>{t.meshes?.forEach(o=>{if(!o.isNodeParticleSystemMesh)return;let n=i.meshes?.find(l=>l.id===o.id);n&&(o.nodeParticleSystemSet.blocks?.forEach(l=>{l.url&&(l.url=`${r}${l.url}`)}),n.nodeParticleSystemSet=mn.NodeParticleSystemSet.Parse(o.nodeParticleSystemSet),n.nodeParticleSystemSet.id=o.nodeParticleSystemSet.id,n.nodeParticleSystemSet.uniqueId=o.uniqueId,e.addPendingData(o.id),n.nodeParticleSystemSet.buildAsync(e,!1).then(l=>{e.removePendingData(o.id),n.particleSystemSet=l,l.systems.forEach(p=>{if(Mt(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(dn,"registerNodeParticleSystemSetParser");var un=require("babylonjs");function fn(t,e){e??=new un.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(r=>{let o=t.getLightById(r);o&&e?.addLight(o)})),e}a(fn,"configureLights");var vn=require("babylonjs"),Ji=require("babylonjs"),Sn=require("babylonjs"),yn=require("babylonjs"),Qi=new Map;async function gn(t,e){let i=t.getWaitingItemsCount();for(;!t.isDisposed&&(!t.isReady()||t.getWaitingItemsCount()>0);){await new Promise(o=>setTimeout(o,150));let r=i-t.getWaitingItemsCount();r===i&&t.textures.forEach(o=>{o.delayLoadState===Ji.Constants.DELAYLOADSTATE_NONE&&(o.delayLoadState=Ji.Constants.DELAYLOADSTATE_LOADED)}),e(r/i)}}a(gn,"waitForWaitingItems");async function Za(t,e,i,r,o){i.loadingQuality=o?.quality??"high",i.loadingTexturesQuality=o?.texturesQuality??i.loadingQuality,i.loadingShadowsQuality=o?.shadowsQuality??i.loadingQuality,i.loadingLodsQuality=o?.lodsQuality??i.loadingQuality,Fr(),Dr(),Br(),qr(),cn(),$r(),nn(),dn();let n=Qi.get(i)??{};if(Qi.set(i,n),i.onDisposeObservable.addOnce(()=>{Qi.delete(i)}),await(0,Sn.AppendSceneAsync)(`${t}${e}`,i,{pluginExtension:".babylon",onProgress:a(p=>{let s=Math.min(p.loaded/p.total*.5);o?.onProgress?.(s)},"onProgress")}),await gn(i,p=>{o?.onProgress?.(.5+p*.25)}),!o?.skipAssetsPreload){let p=0;do p=await Wi(t,i,r);while(p!==0&&!i.isDisposed)}yn.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(p=>F(p)&&p._checkDelayState());let l=fn(i,n.clusteredLightContainer);n.clusteredLightContainer=l,await gn(i,p=>{o?.onProgress?.(.75+p*.25)}),o?.onProgress?.(1),Gt(i),Bt(i.loadingLodsQuality,i),zt(i),tt(i),i.metadata?.rendering&&(cr(i,i.metadata),i.activeCamera&&Ri(i.activeCamera,t,o?.postProcessConfiguration)),i.metadata?.physicsGravity&&i.getPhysicsEngine()?.setGravity(vn.Vector3.FromArray(i.metadata?.physicsGravity)),H(i,i,r,{rootUrl:t}),i.transformNodes.forEach(p=>{H(i,p,r,{rootUrl:t})}),i.meshes.forEach(p=>{lr(p),H(i,p,r,{rootUrl:t})}),i.lights.forEach(p=>{H(i,p,r,{rootUrl:t})}),l.lights.forEach(p=>{H(i,p,r,{rootUrl:t})}),i.cameras.forEach(p=>{H(i,p,r,{rootUrl:t})}),i.spriteManagers?.forEach(p=>{p.sprites.forEach(s=>{H(i,s,r,{rootUrl:t})})}),Oe(i)}a(Za,"loadScene");var bn=require("babylonjs");async function Ya(t,e,i){let r=await k(t+e),n=bn.Tools.Instantiate(r.customType).Parse(r,i,t);return n.id=r.id,n.uniqueId=r.uniqueId,n}a(Ya,"loadMaterialFromFile");function qa(t){return Promise.all(t.materials.map(async e=>{let i=e.getBindedMeshes();await Promise.all(i.map(async r=>{Me(r)||await e.forceCompilationAsync(r,{clipPlane:!!t.clipPlane,useInstances:r.hasInstances})}))}))}a(qa,"forceCompileAllSceneMaterials");var J=require("babylonjs");function je(t){if(!isNaN(parseFloat(t))&&isFinite(t))return J.Animation.ANIMATIONTYPE_FLOAT;switch(t?.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(je,"getAnimationTypeForObject");var xn=require("babylonjs");function Qa(t,e){return function(i,r){let o=i.constructor;o._NodesFromScene??=[],o._NodesFromScene.push({propertyKey:r,nodeName:t,options:e})}}a(Qa,"nodeFromScene");function Ja(t,e=!1){return function(i,r){let o=i.constructor;o._NodesFromDescendants??=[],o._NodesFromDescendants.push({propertyKey:r,nodeName:t,directDescendantsOnly:e})}}a(Ja,"nodeFromDescendants");function es(t){return function(e,i){let r=e.constructor;r._AnimationGroups??=[],r._AnimationGroups.push({animationGroupName:t,propertyKey:i})}}a(es,"animationGroupFromScene");function ts(t){return function(e,i){let r=e.constructor;r._SceneAssets??=[],r._SceneAssets.push({sceneName:t,propertyKey:i})}}a(ts,"sceneAsset");function is(t){return function(e,i){let r=e.constructor;r._ComponentsFromScene??=[],r._ComponentsFromScene.push({propertyKey:i,componentConstructor:t})}}a(is,"componentFromScene");function os(t,e){return function(i,r){let o=i.constructor;o._GuiFromAsset??=[],o._GuiFromAsset.push({propertyKey:r,pathInAssets:t,onGuiCreated:e})}}a(os,"guiFromAsset");function rs(t,e){return function(i,r){let o=i.constructor;o._SoundsFromScene??=[],o._SoundsFromScene.push({propertyKey:r,soundName:t,options:e})}}a(rs,"soundFromScene");function ns(t,e=!1){return function(i,r){let o=i.constructor;o._ParticleSystemsFromScene??=[],o._ParticleSystemsFromScene.push({propertyKey:r,particleSystemName:t,directDescendantsOnly:e})}}a(ns,"particleSystemFromScene");function as(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"boolean"}})}}a(as,"visibleAsBoolean");function ss(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"string"}})}}a(ss,"visibleAsString");function ls(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"number"}})}}a(ls,"visibleAsNumber");function cs(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"vector2"}})}}a(cs,"visibleAsVector2");function ps(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"vector3"}})}}a(ps,"visibleAsVector3");function hs(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"color3"}})}}a(hs,"visibleAsColor3");function ms(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"color4"}})}}a(ms,"visibleAsColor4");function ds(t,e,i){return function(r,o){let n=r.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:o,configuration:{...i,entityType:t,type:"entity"}})}}a(ds,"visibleAsEntity");function us(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"texture"}})}}a(us,"visibleAsTexture");function fs(t,e){return function(i,r){let o=i.constructor;o._VisibleInInspector??=[],o._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...e,type:"keymap"}})}}a(fs,"visibleAsKeyMap");function gs(t,e,i){return function(r,o){let n=r.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:o,configuration:{...i,assetType:t,type:"asset"}})}}a(gs,"visibleAsAsset");function vs(t,e){return function(i,r){let o=i.constructor;o._PointerEvents??=[],o._PointerEvents.push({propertyKey:r,options:{mode:"global",...e??{}},eventTypes:Array.isArray(t)?t:[t]})}}a(vs,"onPointerEvent");function Ss(t){return function(e,i){let r=e.constructor;r._KeyboardEvents??=[],r._KeyboardEvents.push({propertyKey:i,eventTypes:Array.isArray(t)?t:[t]})}}a(Ss,"onKeyboardEvent");function ys(t){return function(e,i){let r=e.constructor;r._SpritesFromSpriteManager??=[],r._SpritesFromSpriteManager.push({propertyKey:i,spriteName:t})}}a(ys,"spriteFromSpriteManager");function bs(t){return function(e,i){let r=e.constructor;r._AnimationsFromSprite??=[],r._AnimationsFromSprite.push({propertyKey:i,animationName:t})}}a(bs,"animationFromSprite");var Lt=require("babylonjs");function oS(t,e){let i;return t===Lt.Animation.ANIMATIONTYPE_FLOAT?i=e.value:i=e.value.clone(),{value:i,frame:e.frame,interpolation:e.interpolation,inTangent:t===Lt.Animation.ANIMATIONTYPE_FLOAT?e.inTangent:e.inTangent?.clone(),outTangent:t===Lt.Animation.ANIMATIONTYPE_FLOAT?e.outTangent:e.outTangent?.clone()}}a(oS,"cloneKey");function Pt(t,e){let i=e.split("."),r=t;for(let o=0;o<i.length;++o)r=r[i[o]];return r}a(Pt,"getPropertyValue");function eo(t,e,i){let r=null;t.onAnimationGroupPlayObservable.add(()=>{r=e.onAfterAnimationsObservable.add(()=>{i()})}),t.onAnimationGroupPauseObservable.add(()=>{r&&(e.onAfterAnimationsObservable.remove(r),r=null)}),t.onAnimationGroupEndObservable.add(()=>{r&&(e.onAfterAnimationsObservable.remove(r),r=null)})}a(eo,"registerAfterAnimationCallback");var ee=require("babylonjs"),wt=require("babylonjs"),X=require("babylonjs");function xs(t,e){return{name:t.name,framesPerSecond:t.framesPerSecond,outputFramesPerSecond:t.outputFramesPerSecond,tracks:t.tracks.map(i=>{let r=null,o=null;if(i.node?(r=Pe(i.node,e),r||(r=e.particleSystems?.find(l=>l.id===i.node)??null)):i.defaultRenderingPipeline?r=Ve():i.volumetricLightScattering&&(r=Ut()),i.propertyPath){let l=Pt(r,i.propertyPath);o=je(l)}let n=null;return i.sound&&(n=Pe(i.sound,e)),{node:r,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:to(i.soundVolume??[],ee.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:Pe(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:r&&o!==null&&to(i.keyFrameAnimations??[],o)}})}}a(xs,"parseCinematic");function W(t,e){if(t===null)return null;if(t!==void 0)switch(e){case ee.Animation.ANIMATIONTYPE_FLOAT:return t;case ee.Animation.ANIMATIONTYPE_VECTOR2:return X.Vector2.FromArray(t);case ee.Animation.ANIMATIONTYPE_VECTOR3:return X.Vector3.FromArray(t);case ee.Animation.ANIMATIONTYPE_QUATERNION:return X.Quaternion.FromArray(t);case ee.Animation.ANIMATIONTYPE_COLOR3:return wt.Color3.FromArray(t);case ee.Animation.ANIMATIONTYPE_COLOR4:return wt.Color4.FromArray(t);case ee.Animation.ANIMATIONTYPE_MATRIX:return X.Matrix.FromArray(t)}}a(W,"parseCinematicKeyValue");function to(t,e){return t?.map(i=>{let r=i.type==="key"?i:null;if(r)return{...r,value:W(r.value,e),inTangent:W(r.inTangent,e),outTangent:W(r.outTangent,e)};let o=i.type==="cut"?i:null;if(o)return{...o,key1:{...o.key1,value:W(o.key1.value,e),inTangent:W(o.key1.inTangent,e),outTangent:W(o.key1.outTangent,e)},key2:{...o.key2,value:W(o.key2.value,e),inTangent:W(o.key2.inTangent,e),outTangent:W(o.key2.outTangent,e)}};throw new Error(`Unknown key frame type: ${i.type}`)})}a(to,"parseKeyFrameAnimations");function _n(t,e){t.onEventObservable.notifyObservers(e.eventName)}a(_n,"handleApplyEvent");function Cn(t){t.node?.setEnabled(t.value)}a(Cn,"handleSetEnabledEvent");var io=require("babylonjs"),Dn=io.Vector3.Zero();function Ln(t,e){let i=e.mesh?[e.mesh]:t.meshes.filter(r=>r.physicsAggregate);e.radius&&(i=i.filter(r=>{let o=r.getBoundingInfo().boundingBox.centerWorld;return io.Vector3.Distance(o,e.contactPoint)<=e.radius})),i.forEach(r=>{if(r.physicsAggregate?.body){let o=e.contactPoint.subtract(r.getBoundingInfo().boundingBox.centerWorld);o.multiplyInPlace(e.force),r.physicsAggregate.body.setLinearVelocity(Dn),r.physicsAggregate.body.setAngularVelocity(Dn),r.physicsAggregate.body.applyImpulse(o.negateInPlace(),e.contactPoint)}})}a(Ln,"handleApplyImpulseEvent");var Pn=require("babylonjs"),wn=require("babylonjs"),Ke=class extends wn.AnimationGroup{static{a(this,"Cinematic")}onEventObservable=new Pn.Observable;onEvent(e,i){this.onEventObservable.add(r=>{e===r&&i()})}};function oo(t){return t.type==="key"}a(oo,"isCinematicKey");function Ae(t){return t.type==="cut"}a(Ae,"isCinematicKeyCut");function _s(t){return t.type==="event"}a(_s,"isCinematicKeyEvent");function Cs(t){return t.type==="group"}a(Cs,"isCinematicGroup");function Ds(t){return t.type==="sound"}a(Ds,"isCinematicSound");var O=require("babylonjs"),Ie=require("babylonjs");function Ls(t,e,i){let r=new Ke(t.name,e);return t.tracks.forEach(o=>{let n=o.animationGroup;if(n&&o.animationGroups?.length){let d=n.clone(`${n.name}-cinematic-temp`),u=e.animationGroups.indexOf(d);u!==-1&&e.animationGroups.splice(u,1),r.onAnimationEndObservable.add(()=>{n.stop(),d.stop()});let S=o.animationGroups.reduce((L,x)=>Math.min(L,x.frame),Number.MAX_VALUE)??0,g=o.animationGroups.reduce((L,x)=>Math.max(L,x.frame+x.endFrame),0)??0,y={frame:S},C=new O.Animation(d.name,"frame",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1);if(C.setKeys([{frame:S,value:0},{frame:g,value:g}]),o.animationGroups.forEach(L=>{C.addEvent(new Ie.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()})}}))}),r.addTargetedAnimation(C,y),(o.animationGroupWeight?.length??0)>=2&&o.animationGroupWeight.find(x=>Ae(x)?x.key1.value!==1||x.key2.value!==1:x.value!==1)){let x={weight:0},R=new O.Animation(`${d.name}-weights`,"weight",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),B=[];o.animationGroupWeight.forEach(v=>{Ae(v)?(B.push(v.key1),B.push(v.key2)):B.push(v)}),R.setKeys(B),r.addTargetedAnimation(R,x),eo(r,e,()=>{d.weight=x.weight})}}let l=o.sound;if(!i?.ignoreSounds&&l&&l.sound?.buffer&&o.sounds?.length){let d={dummy:0,volume:0},u=new O.Animation(l.name,"dummy",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;if(o.sounds?.forEach(g=>{let y=g.endFrame-g.startFrame;S=Math.max(S,g.frame+y),u.addEvent(new Ie.AnimationEvent(g.frame,C=>{let x=(C-g.frame+g.startFrame)/t.framesPerSecond;l.play({startOffset:x})},!1)),u.addEvent(new Ie.AnimationEvent(g.frame+y,()=>{l.stop()}))}),u.setKeys([{frame:0,value:0},{frame:S,value:S}]),r.addTargetedAnimation(u,d),(o.soundVolume?.length??0)>=2){let g=new O.Animation(l.name,"volume",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),y=[];o.soundVolume.forEach(C=>{Ae(C)?(y.push(C.key1),y.push(C.key2)):y.push(C)}),g.setKeys(y),r.addTargetedAnimation(g,d),eo(r,e,()=>{l.volume=d.volume})}}if(o.keyFrameEvents){let d={dummy:0},u=new O.Animation("events","dummy",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;o.keyFrameEvents?.forEach(g=>{S=Math.max(S,g.frame),u.addEvent(new Ie.AnimationEvent(g.frame,()=>{switch(g.data?.type){case"event":_n(r,g.data);break;case"set-enabled":Cn(g.data);break;case"apply-impulse":Ln(e,g.data);break}}))}),u.setKeys([{frame:0,value:0},{frame:S+1,value:S+1}]),r.addTargetedAnimation(u,d)}let p=o.defaultRenderingPipeline?Ve():o.node;if(!p||!o.propertyPath||!o.keyFrameAnimations)return;let s=Pt(p,o.propertyPath),c=je(s);if(c===null)return;let h=new O.Animation(o.propertyPath,o.propertyPath,60,c,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),m=[];o.keyFrameAnimations?.forEach(d=>{if(oo(d))return m.push(d);Ae(d)&&(m.push(d.key1),m.push(d.key2),Je(p)&&o.propertyPath==="position"&&h.addEvent(new Ie.AnimationEvent(d.key1.frame,()=>{let u=ii();if(!u)return;let S=u.motionStrength;u.motionStrength=0,requestAnimationFrame(()=>{u.motionStrength=S})})))}),h.setKeys(m),r.addTargetedAnimation(h,p)}),r.normalize(),r}a(Ls,"generateCinematicAnimationGroup");async function ro(t,e){return new Promise((i,r)=>{let o=indexedDB.open(t,1);o.addEventListener("error",()=>r()),o.addEventListener("blocked",()=>r()),o.addEventListener("upgradeneeded",()=>{try{e(o.result)}catch(n){r(n)}}),o.addEventListener("success",()=>{i(o.result)})})}a(ro,"openIndexDB");function Ze(t,e,i){return new Promise(r=>{let n=t.transaction(e).objectStore(e).get(i);n.addEventListener("error",()=>{r(null)}),n.addEventListener("success",()=>{r(n.result??null)})})}a(Ze,"getFromIndexDB");async function $(t,e,i){let o=t.transaction(e,"readwrite").objectStore(e).put(i);await new Promise((n,l)=>{o.addEventListener("error",()=>l()),o.addEventListener("success",()=>n())})}a($,"putInIndexDB");var On=require("babylonjs");function Ps(t){On.AbstractEngine.OfflineProviderFactory=(e,i,r=!1)=>new Ye(t,e,i,r)}a(Ps,"setupOfflineProvider");async function no(t,e){let i=await new Promise(r=>{let o=new Ye(t,e,n=>r(n?o:null),!1)});return await i?.open(),i}a(no,"createAndOpenDatabase");var Ye=class{static{a(this,"Database")}enableSceneOffline=!0;enableTexturesOffline=!0;name;_database=null;_manifestVersion=null;_loadFilePromises=new Map;constructor(e,i,r,o){this.name=e,o?r(!1):this._checkManifest(i,r)}async _checkManifest(e,i){try{let r=await k(`${e}.manifest?${Date.now()}`);this._manifestVersion=r.version,i(!0)}catch{this.enableSceneOffline=!1,this.enableTexturesOffline=!1,i(!1)}}async open(e,i){try{this._database=await ro(this.name,r=>{r.createObjectStore("files",{keyPath:"url"}),r.createObjectStore("images",{keyPath:"url"}),r.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 r=null;await Gi(()=>this._manifestVersion!==null);let o=this._loadFilePromises.get(e);if(o)return o.then(l=>{l!==null?i.src=l:i.src=e});let n=new Promise(async l=>{if(await this._getFileVersionForUrl(e)!==this._manifestVersion?(r=await Le(e,"blob"),await Promise.all([$(this._database,"images",{url:e,data:r}),$(this._database,"versions",{url:e,version:this._manifestVersion})])):r=(await Ze(this._database,"images",e))?.data??null,r!==null){let s=URL.createObjectURL(r);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 Le(e,"blob");await Promise.all([$(this._database,"images",{url:e,data:i}),$(this._database,"versions",{url:e,version:this._manifestVersion})])}async isFileMatchingVersion(e){return await this._getFileVersionForUrl(e)===this._manifestVersion}async loadFile(e,i,r,o,n){if(!this._database)return o?.();let l=null;await Gi(()=>this._manifestVersion!==null);let p=this._loadFilePromises.get(e);if(p)return p.then(c=>{c!==null?i(c):o?.()});let s=new Promise(async c=>{await this._getFileVersionForUrl(e)!==this._manifestVersion?(l=await Le(e,n?"arraybuffer":"text",r),await Promise.all([$(this._database,"files",{url:e,data:l}),$(this._database,"versions",{url:e,version:this._manifestVersion})])):l=(await Ze(this._database,"files",e))?.data??null,l!==null?i(l):o?.(),c(l)});this._loadFilePromises.set(e,s)}async saveFile(e,i,r){if(!this._database)throw new Error("Database is not available");let o=await Le(e,i?"arraybuffer":"text",r);await Promise.all([$(this._database,"files",{url:e,data:o}),$(this._database,"versions",{url:e,version:this._manifestVersion})])}async _getFileVersionForUrl(e){return(await Ze(this._database,"versions",e))?.version??null}};var Tn=["mp3","wav"],En=["babylonbinarymeshdata"],ws=["ktx","ktx2","jpg","jpeg","png","bmp","webp"],An=["babylon","json"],ao=["jpg","jpeg","png","bmp","webp"],In=["bin","ktx","ktx2",...En,...Tn],Os=[...An,...ao,...In];async function Ts(t,e,i){let r=[],o=await k(`${e}scenes-used-files.json`),n=[];if(i?.scenesFilter){n=i.scenesFilter.map(m=>typeof m=="string"?{sceneName:m,disableSounds:!1,disableTextures:!1,disableGeometries:!1}:m);for(let[m,d]of Object.entries(o))n.find(u=>u.sceneName===m)||delete o[m]}let l=0,p=0,s=i?.engine?.textureFormatInUse?i?.engine?.texturesSupported[0]:null,c=Object.values(o).reduce((m,d)=>m+d.length,0);function h(m){++p,i?.onProgress?.(p/c),m?.()}a(h,"notifyProgress");for(let[m,d]of Object.entries(o)){let u=m.replace(".scene",".babylon"),S=await no(t,`${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(En.includes(x)&&g?.disableGeometries){h();continue}if(ws.includes(x)&&g?.disableTextures){h();continue}if(Tn.includes(x)&&g?.disableSounds){h();continue}if(ao.includes(x)&&g?.disableTextures){h();continue}if(x==="ktx")if(s){if(!L.endsWith(s)){h();continue}}else{h();continue}if(x==="ktx2"&&!$e()){h();continue}if(r.length>300){try{await Promise.all(r)}catch{}r.splice(0,r.length)}let R=`${e}${L}`;Os.includes(x)&&r.push(new Promise(async B=>{if(await S.isFileMatchingVersion(R))return h(B);try{ao.includes(x)?i?.disableImages||(await S.saveImage(R),++l):In.includes(x)?(await S.saveFile(R,!0),++l):An.includes(x)&&(await S.saveFile(R,!1),++l)}catch{}h(B)}))}await Promise.all(r),S.close()}return await Promise.all(r),{loadedCount:l,processedFilesCount:p}}a(Ts,"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,keepRenderingPipelinesOrdered,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,renderingPipelinesOrder,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,sortCameraPostProcesses,soundFromScene,spriteFromSpriteManager,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,supportsVolumetricFloatDepthTexture,taaRenderingPipelineCameraConfigurations,visibleAsAsset,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsKeyMap,visibleAsNumber,visibleAsString,visibleAsTexture,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations,volumetricLightMetadataKey,volumetricLightingPrePassConfigurationName,volumetricTemporalSamplesDivider});
|