babylonjs-editor-tools 5.5.2-alpha.0 → 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 +85 -85
- 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/tools.js +3 -0
- package/build/src/rendering/tools.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/tools/scene.d.ts +2 -1
- package/package.json +1 -1
package/build/index.node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var qe=Object.defineProperty;var Tn=Object.getOwnPropertyDescriptor;var On=Object.getOwnPropertyNames;var En=Object.prototype.hasOwnProperty;var a=(i,e)=>qe(i,"name",{value:e,configurable:!0});var An=(i,e)=>{for(var t in e)qe(i,t,{get:e[t],enumerable:!0})},In=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of On(e))!En.call(i,r)&&r!==t&&qe(i,r,{get:()=>e[r],enumerable:!(o=Tn(e,r))||o.enumerable});return i};var Mn=i=>In(qe({},"__esModule",{value:!0}),i);var Ds={};An(Ds,{AdvancedAssetContainer:()=>Ue,AdvancedAssetContainerInstantiatedEntries:()=>ke,Cinematic:()=>je,Database:()=>Ze,NodeParticleSystemSet:()=>fn.NodeParticleSystemSet,VolumetricDebugMode:()=>mi,VolumetricDepthSource:()=>xi,VolumetricDitherMode:()=>pi,VolumetricFogMode:()=>hi,VolumetricLightingRenderingPipeline:()=>q,VolumetricShadowKind:()=>vi,VolumetricShadowMode:()=>Mo,VolumetricStepDistribution:()=>Lo,VolumetricTransmittanceMode:()=>Si,_applyScriptsForObject:()=>H,_getKtx2TextureName:()=>yt,_preloadScriptsAssets:()=>zi,_registerScriptInstance:()=>Ui,_removeRegisteredScriptInstance:()=>gt,addExcludedCompressedTexture:()=>bt,animationFromSprite:()=>us,animationGroupFromScene:()=>Za,applyMeshesLODQuality:()=>Nt,applyRagdollJointLimits:()=>Ma,applyRenderingConfigurationForCamera:()=>Ei,applyScriptOnObject:()=>Ga,applyShadowsQuality:()=>Hn,applyTexturesQuality:()=>Ha,canUseHdr:()=>Ia,componentFromScene:()=>ja,computeVolumetricBudget:()=>Ve,computeVolumetricShapeKey:()=>ra,configureEngineToUseCompressedTextures:()=>za,configureMeshDistanceOrScreenCoverage:()=>Ft,configureShadowMapRefreshRate:()=>et,configureShadowMapRenderListPredicate:()=>Gt,copyAndParseRagdollConfiguration:()=>Mi,createAndOpenDatabase:()=>to,createDefaultRenderingPipeline:()=>Do,createMotionBlurPostProcess:()=>yo,createSSAO2RenderingPipeline:()=>vo,createSSRRenderingPipeline:()=>mo,createTAARenderingPipeline:()=>fo,createVLSPostProcess:()=>po,createVolumetricLightingPrePassConfiguration:()=>_i,createVolumetricLightingRenderingPipeline:()=>er,defaultPipelineCameraConfigurations:()=>ye,disposeDefaultRenderingPipeline:()=>oi,disposeMotionBlurPostProcess:()=>Jt,disposeSSAO2RenderingPipeline:()=>Zt,disposeSSRRenderingPipeline:()=>Ut,disposeTAARenderingPipeline:()=>$t,disposeVLSPostProcess:()=>zt,disposeVolumetricLightingRenderingPipeline:()=>wi,ensureVolumetricLightConfiguration:()=>To,forceCompileAllSceneMaterials:()=>Xa,generateCinematicAnimationGroup:()=>ys,getAllScriptsByClassForObject:()=>Te,getAllVolumetricCandidateLights:()=>Ro,getAnimationTypeForObject:()=>$e,getDefaultRenderingPipeline:()=>Re,getDefaultVolumetricLightConfiguration:()=>li,getDefaultVolumetricLightingConfiguration:()=>it,getFromIndexDB:()=>Ke,getHdrTextureType:()=>K,getMotionBlurPostProcess:()=>Qt,getPowerOfTwoUntil:()=>N,getSSAO2RenderingPipeline:()=>jn,getSSRRenderingPipeline:()=>Un,getScriptByClassForObject:()=>ki,getTAARenderingPipeline:()=>Xn,getTextureUrl:()=>xt,getVLSPostProcess:()=>Bt,getVolumetricGeometryBufferDepthTexture:()=>Di,getVolumetricGeometryBufferRenderer:()=>Ne,getVolumetricLightConfiguration:()=>ui,getVolumetricLightRange:()=>nt,getVolumetricLightSteps:()=>Po,getVolumetricLightWorldDirection:()=>Fe,getVolumetricLightWorldPosition:()=>rt,getVolumetricLightingRenderingPipeline:()=>wa,getVolumetricLightingRenderingPipelineConfiguration:()=>Pi,getVolumetricPrePassDepthTexture:()=>Ci,getVolumetricPrePassRenderer:()=>xe,getVolumetricSamplingSteps:()=>di,guiFromAsset:()=>qa,isAbstractMesh:()=>ne,isAnyParticleSystem:()=>It,isArcRotateCamera:()=>Nn,isBone:()=>Rn,isCamera:()=>Qe,isCascadedShadowGenerator:()=>Ot,isCinematicGroup:()=>vs,isCinematicKey:()=>Ji,isCinematicKeyCut:()=>Ee,isCinematicKeyEvent:()=>gs,isCinematicSound:()=>Ss,isClusteredLightContainer:()=>me,isDecalMesh:()=>ro,isDirectionalLight:()=>ie,isFreeCamera:()=>Fn,isGPUParticleSystem:()=>Gn,isGaussianSplattingMesh:()=>Rt,isGroundMesh:()=>Vn,isHemisphericLight:()=>Je,isInstancedMesh:()=>Ie,isLight:()=>oo,isMesh:()=>F,isNode:()=>de,isNodeFromStaticGroup:()=>Vt,isParticleSystem:()=>At,isPointLight:()=>wt,isScene:()=>Et,isShadowGenerator:()=>Tt,isSoundNode:()=>se,isSpotLight:()=>ae,isSprite:()=>Mt,isSpriteManagerNode:()=>Bn,isTexture:()=>Me,isTransformNode:()=>te,isUsingKtx2CompressedTextures:()=>Xe,isVolumetricLightEnabled:()=>qn,isVolumetricLightSupported:()=>na,isVolumetricLightingSupported:()=>Oa,loadMaterialFromFile:()=>Wa,loadScene:()=>Ua,markVolumetricLightsDirty:()=>Ea,maxVolumetricArrayLights:()=>Z,maxVolumetricDirectionalLights:()=>ci,maxVolumetricShadowSlots:()=>O,motionBlurPostProcessCameraConfigurations:()=>Se,nodeFromDescendants:()=>Ka,nodeFromScene:()=>$a,normalizeAtlasJson:()=>Xi,normalizeVolumetricLightConfiguration:()=>wo,normalizeVolumetricLightingConfiguration:()=>be,onKeyboardEvent:()=>ms,onPointerEvent:()=>hs,openIndexDB:()=>eo,parseCinematic:()=>fs,parseCinematicKeyValue:()=>W,parseDefaultRenderingPipeline:()=>ni,parseKeyFrameAnimations:()=>qi,parseMotionBlurPostProcess:()=>ti,parseRagdollConfiguration:()=>sr,parseSSAO2RenderingPipeline:()=>qt,parseSSRRenderingPipeline:()=>Xt,parseTAARenderingPipeline:()=>Kt,parseVLSPostProcess:()=>kt,parseVolumetricLightingRenderingPipeline:()=>Oi,particleSystemFromScene:()=>Ja,playSpriteAnimationFromName:()=>ka,preloadAssetsToDatabase:()=>Cs,putInIndexDB:()=>$,registerScriptAssetParser:()=>Na,resolveVolumetricDepthSource:()=>at,resolveVolumetricShadowSlot:()=>Vo,saveRenderingConfigurationForCamera:()=>Aa,sceneAsset:()=>Ya,scriptAssetsCache:()=>pe,scriptAssetsParsers:()=>We,scriptsDictionary:()=>U,selectVolumetricLights:()=>yi,serializeDefaultRenderingPipeline:()=>ri,serializeMotionBlurPostProcess:()=>ei,serializeSSAO2RenderingPipeline:()=>Yt,serializeSSRRenderingPipeline:()=>Wt,serializeTAARenderingPipeline:()=>jt,serializeVLSPostProcess:()=>Ht,serializeVolumetricLightingRenderingPipeline:()=>Ti,setDefaultRenderingPipelineRef:()=>Yn,setMotionBlurPostProcessRef:()=>Zn,setSSAO2RenderingPipelineRef:()=>Kn,setSSRRenderingPipelineRef:()=>Wn,setStaticDecalsEnabled:()=>zn,setTAARenderingPipelineRef:()=>$n,setUseKtx2CompressedTextures:()=>Ba,setVLSPostProcessRef:()=>kn,setVolumetricLightingRenderingPipelineConfiguration:()=>ze,setVolumetricLightingRenderingPipelineRef:()=>Ta,setupOfflineProvider:()=>bs,soundFromScene:()=>Qa,spriteFromSpriteManager:()=>ds,ssaoRenderingPipelineCameraConfigurations:()=>ve,ssrRenderingPipelineCameraConfigurations:()=>fe,supportsVolumetricFloatDepthTexture:()=>No,taaRenderingPipelineCameraConfigurations:()=>ge,visibleAsAsset:()=>ps,visibleAsBoolean:()=>es,visibleAsColor3:()=>ns,visibleAsColor4:()=>as,visibleAsEntity:()=>ss,visibleAsKeyMap:()=>cs,visibleAsNumber:()=>is,visibleAsString:()=>ts,visibleAsTexture:()=>ls,visibleAsVector2:()=>os,visibleAsVector3:()=>rs,vlsPostProcessCameraConfigurations:()=>ue,volumetricLightMetadataKey:()=>le,volumetricLightingPrePassConfigurationName:()=>Fo,volumetricTemporalSamplesDivider:()=>tt});module.exports=Mn(Ds);function ne(i){switch(i.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}a(ne,"isAbstractMesh");function F(i){switch(i.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}a(F,"isMesh");function Ie(i){return i.getClassName?.()==="InstancedMesh"}a(Ie,"isInstancedMesh");function Rn(i){return i.getClassName?.()==="Bone"}a(Rn,"isBone");function Vn(i){return i.getClassName?.()==="GroundMesh"}a(Vn,"isGroundMesh");function te(i){return i.getClassName?.()==="TransformNode"}a(te,"isTransformNode");function Me(i){return i?.getClassName?.()==="Texture"}a(Me,"isTexture");function Qe(i){switch(i.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}a(Qe,"isCamera");function Fn(i){switch(i.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}a(Fn,"isFreeCamera");function Nn(i){return i.getClassName?.()==="ArcRotateCamera"}a(Nn,"isArcRotateCamera");function wt(i){return i.getClassName?.()==="PointLight"}a(wt,"isPointLight");function ie(i){return i.getClassName?.()==="DirectionalLight"}a(ie,"isDirectionalLight");function ae(i){return i.getClassName?.()==="SpotLight"}a(ae,"isSpotLight");function Je(i){return i.getClassName?.()==="HemisphericLight"}a(Je,"isHemisphericLight");function oo(i){switch(i.getClassName?.()){case"Light":case"PointLight":case"SpotLight":case"DirectionalLight":case"HemisphericLight":return!0}return!1}a(oo,"isLight");function Tt(i){return i.getClassName?.()==="ShadowGenerator"}a(Tt,"isShadowGenerator");function Ot(i){return i.getClassName?.()==="CascadedShadowGenerator"}a(Ot,"isCascadedShadowGenerator");function me(i){return i.getClassName?.()==="ClusteredLightContainer"}a(me,"isClusteredLightContainer");function de(i){return ne(i)||te(i)||oo(i)||Qe(i)}a(de,"isNode");function Et(i){return i.getClassName?.()==="Scene"}a(Et,"isScene");function At(i){return i.getClassName?.()==="ParticleSystem"}a(At,"isParticleSystem");function Gn(i){return i.getClassName?.()==="GPUParticleSystem"}a(Gn,"isGPUParticleSystem");function It(i){switch(i.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}a(It,"isAnyParticleSystem");function Bn(i){return i.getClassName?.()==="SpriteManagerNode"}a(Bn,"isSpriteManagerNode");function Mt(i){return i.getClassName?.()==="Sprite"}a(Mt,"isSprite");function se(i){return i.getClassName?.()==="SoundNode"}a(se,"isSoundNode");function Rt(i){return i.getClassName?.()==="GaussianSplattingMesh"}a(Rt,"isGaussianSplattingMesh");function Vt(i){let e=i;for(;e;){if(e.metadata?.isStaticGroup)return!0;e=e.parent}return!1}a(Vt,"isNodeFromStaticGroup");function Ft(i){i.meshes.forEach(e=>{F(e)&&e.getLODLevels().forEach(t=>{t.mesh&&(t.mesh.originalDistanceOrScreenCoverage=t.distanceOrScreenCoverage)})})}a(Ft,"configureMeshDistanceOrScreenCoverage");function Nt(i,e){e.meshes.forEach(t=>{F(t)&&t.getLODLevels().forEach(o=>{if(o.mesh?.originalDistanceOrScreenCoverage)switch(i){case"very-low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.125;break;case"low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.25;break;case"medium":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.5;break;case"high":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage;break}})})}a(Nt,"applyMeshesLODQuality");function ro(i){return(i.metadata?.decal??null)!==null}a(ro,"isDecalMesh");function zn(i,e){e.meshes.forEach(t=>{ro(t)&&Vt(t)&&t.setEnabled(i)})}a(zn,"setStaticDecalsEnabled");function N(i){let e=1;for(;e<=i;)e<<=1;return e>>1}a(N,"getPowerOfTwoUntil");var no=require("babylonjs"),ao=require("babylonjs");function Gt(i){i.lights.forEach(e=>{let t=e.getShadowGenerator()?.getShadowMap();t&&(t.renderListPredicate=o=>Rt(o)?!1:no.Vector3.Distance(o.getAbsolutePosition(),e.getAbsolutePosition())<=e.range)})}a(Gt,"configureShadowMapRenderListPredicate");async function et(i){i.executeWhenReady(()=>{i.lights.forEach(e=>{let t=e.getShadowGenerator()?.getShadowMap();t&&(t.refreshRate=e.metadata?.refreshRate??ao.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}a(et,"configureShadowMapRefreshRate");function Hn(i,e){e.lights.forEach(t=>{let o=t.getShadowGenerator(),r=o?.getShadowMap();if(o?.originalMapSize){let n=o.originalMapSize;switch(i){case"medium":n=n*.5;break;case"low":n=n*.25;break;case"very-low":n=n*.125;break}n=Math.max(128,N(n)),r?.getSize().width!==n&&r.resize(n)}}),et(e)}a(Hn,"applyShadowsQuality");var so=require("babylonjs"),lo=require("babylonjs"),co=require("babylonjs"),w=null,ue=new Map;function Bt(){return w}a(Bt,"getVLSPostProcess");function kn(i){w=i}a(kn,"setVLSPostProcessRef");function zt(i){w&&i.activeCamera&&(w.dispose(i.activeCamera),w=null)}a(zt,"disposeVLSPostProcess");function po(i,e,t){return e??=i.meshes.find(o=>F(o)),w=new co.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,i.activeCamera,e,100,lo.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),w.samples=t?.msaaSamples??1,w}a(po,"createVLSPostProcess");function Ht(){return w?{meshId:w.mesh?.id,exposure:w.exposure,decay:w.decay,weight:w.weight,density:w.density,invert:w.invert,useCustomMeshPosition:w.useCustomMeshPosition,customMeshPosition:w.customMeshPosition.asArray()}:null}a(Ht,"serializeVLSPostProcess");function kt(i,e,t){let o=null;if(e.meshId){let n=i.getMeshById(e.meshId);n&&F(n)&&(o=n)}let r=w??po(i,o,t);return r.samples=t?.msaaSamples??1,r.exposure=e.exposure,r.decay=e.decay,r.weight=e.weight,r.density=e.density,r.invert=e.invert,r.useCustomMeshPosition=e.useCustomMeshPosition,r.customMeshPosition.copyFrom(so.Vector3.FromArray(e.customMeshPosition)),r}a(kt,"parseVLSPostProcess");var ho=require("babylonjs"),D=null,fe=new Map;function Un(){return D}a(Un,"getSSRRenderingPipeline");function Wn(i){D=i}a(Wn,"setSSRRenderingPipelineRef");function Ut(){D&&(D.dispose(),D=null)}a(Ut,"disposeSSRRenderingPipeline");function mo(i,e,t){return D=new ho.SSRRenderingPipeline("SSRRenderingPipeline",i,[e],void 0,K(i.getEngine())),D.samples=t?.msaaSamples??1,D}a(mo,"createSSRRenderingPipeline");function Wt(){return D?{samples:D.samples,step:D.step,thickness:D.thickness,strength:D.strength,reflectionSpecularFalloffExponent:D.reflectionSpecularFalloffExponent,maxSteps:D.maxSteps,maxDistance:D.maxDistance,roughnessFactor:D.roughnessFactor,reflectivityThreshold:D.reflectivityThreshold,blurDispersionStrehgth:D.blurDispersionStrength,clipToFrustum:D.clipToFrustum,enableSmoothReflections:D.enableSmoothReflections,enableAutomaticThicknessComputation:D.enableAutomaticThicknessComputation,attenuateFacingCamera:D.attenuateFacingCamera,attenuateScreenBorders:D.attenuateScreenBorders,attenuateIntersectionDistance:D.attenuateIntersectionDistance,attenuateBackfaceReflection:D.attenuateBackfaceReflection,blurDownsample:D.blurDownsample,selfCollisionNumSkip:D.selfCollisionNumSkip,ssrDownsample:D.ssrDownsample,backfaceDepthTextureDownsample:D.backfaceDepthTextureDownsample}:null}a(Wt,"serializeSSRRenderingPipeline");function Xt(i,e,t,o){let r=D??mo(i,e,o);return r.samples=o?.msaaSamples??1,r.step=t.step,r.thickness=t.thickness,r.strength=t.strength,r.reflectionSpecularFalloffExponent=t.reflectionSpecularFalloffExponent,r.maxSteps=t.maxSteps,r.maxDistance=t.maxDistance,r.roughnessFactor=t.roughnessFactor,r.reflectivityThreshold=t.reflectivityThreshold,r.blurDispersionStrength=t.blurDispersionStrehgth,r.clipToFrustum=t.clipToFrustum,r.enableSmoothReflections=t.enableSmoothReflections,r.enableAutomaticThicknessComputation=t.enableAutomaticThicknessComputation,r.attenuateFacingCamera=t.attenuateFacingCamera,r.attenuateScreenBorders=t.attenuateScreenBorders,r.attenuateIntersectionDistance=t.attenuateIntersectionDistance,r.attenuateBackfaceReflection=t.attenuateBackfaceReflection,r.blurDownsample=t.blurDownsample,r.selfCollisionNumSkip=t.selfCollisionNumSkip,r.ssrDownsample=t.ssrDownsample,r.backfaceDepthTextureDownsample=t.backfaceDepthTextureDownsample,r}a(Xt,"parseSSRRenderingPipeline");var uo=require("babylonjs"),A=null,ge=new Map;function Xn(){return A}a(Xn,"getTAARenderingPipeline");function $n(i){A=i}a($n,"setTAARenderingPipelineRef");function $t(){A&&(A.dispose(),A=null)}a($t,"disposeTAARenderingPipeline");function fo(i,e,t){return A=new uo.TAARenderingPipeline("TAARenderingPipeline",i,[e],K(i.getEngine())),A.msaaSamples=t?.msaaSamples??1,A}a(fo,"createTAARenderingPipeline");function jt(){return A?{factor:A.factor,samples:A.samples,clampHistory:A.clampHistory,reprojectHistory:A.reprojectHistory,disableOnCameraMove:A.disableOnCameraMove}:null}a(jt,"serializeTAARenderingPipeline");function Kt(i,e,t,o){let r=A??fo(i,e,o);return r.msaaSamples=o?.msaaSamples??1,r.factor=t.factor,r.clampHistory=t.clampHistory,r.reprojectHistory=t.reprojectHistory,r.disableOnCameraMove=t.disableOnCameraMove,r}a(Kt,"parseTAARenderingPipeline");var go=require("babylonjs"),P=null,ve=new Map;function jn(){return P}a(jn,"getSSAO2RenderingPipeline");function Kn(i){P=i}a(Kn,"setSSAO2RenderingPipelineRef");function Zt(){P&&(P.dispose(),P=null)}a(Zt,"disposeSSAO2RenderingPipeline");function vo(i,e,t){return P=new go.SSAO2RenderingPipeline("SSAO2RenderingPipeline",i,1,[e],!1,K(i.getEngine())),P.textureSamples=1,P}a(vo,"createSSAO2RenderingPipeline");function Yt(){return P?{radius:P.radius,totalStrength:P.totalStrength,samples:P.samples,maxZ:P.maxZ,minZAspect:P.minZAspect,epsilon:P.epsilon,textureSamples:P.textureSamples,bypassBlur:P.bypassBlur,bilateralSamples:P.bilateralSamples,bilateralSoften:P.bilateralSoften,bilateralTolerance:P.bilateralTolerance,expensiveBlur:P.expensiveBlur}:null}a(Yt,"serializeSSAO2RenderingPipeline");function qt(i,e,t,o){let r=P??vo(i,e,o);return r.textureSamples=1,r.radius=t.radius,r.totalStrength=t.totalStrength,r.samples=t.samples,r.maxZ=t.maxZ,r.minZAspect=t.minZAspect,r.epsilon=t.epsilon,r.bypassBlur=t.bypassBlur,r.bilateralSamples=t.bilateralSamples,r.bilateralSoften=t.bilateralSoften,r.bilateralTolerance=t.bilateralTolerance,r.expensiveBlur=t.expensiveBlur,r}a(qt,"parseSSAO2RenderingPipeline");var So=require("babylonjs"),I=null,Se=new Map;function Qt(){return I}a(Qt,"getMotionBlurPostProcess");function Zn(i){I=i}a(Zn,"setMotionBlurPostProcessRef");function Jt(){I&&(I.dispose(),I=null)}a(Jt,"disposeMotionBlurPostProcess");function yo(i,e,t){return I=new So.MotionBlurPostProcess("MotionBlurPostProcess",i,1,e,void 0,void 0,void 0,K(i.getEngine())),I.samples=t?.msaaSamples??1,I.motionStrength=1,I.isObjectBased=!0,I}a(yo,"createMotionBlurPostProcess");function ei(){return I?{isObjectBased:I.isObjectBased,motionStrength:I.motionStrength,motionBlurSamples:I.motionBlurSamples}:null}a(ei,"serializeMotionBlurPostProcess");function ti(i,e,t,o){let r=I??yo(i,e,o);return r.samples=o?.msaaSamples??1,r.isObjectBased=t.isObjectBased,r.motionStrength=t.motionStrength,r.motionBlurSamples=t.motionBlurSamples,r}a(ti,"parseMotionBlurPostProcess");var bo=require("babylonjs"),ii=require("babylonjs"),xo=require("babylonjs"),_o=require("babylonjs"),Co=require("babylonjs"),f=null,ye=new Map;function Re(){return f}a(Re,"getDefaultRenderingPipeline");function Yn(i){f=i}a(Yn,"setDefaultRenderingPipelineRef");function oi(){f&&(f.dispose(),f=null)}a(oi,"disposeDefaultRenderingPipeline");function Do(i,e,t){return f=new Co.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,i,[e]),f.samples=t?.msaaSamples??1,f.depthOfField.lensSize=512,f.depthOfField.fStop=.25,f.depthOfField.focusDistance=55e3,f}a(Do,"createDefaultRenderingPipeline");function ri(){return f?{samples:f.samples,fxaaEnabled:f.fxaaEnabled,imageProcessingEnabled:f.imageProcessingEnabled,exposure:f.imageProcessing?.exposure,contrast:f.imageProcessing?.contrast,fromLinearSpace:f.imageProcessing?.fromLinearSpace,toneMappingEnabled:f.imageProcessing?.toneMappingEnabled,toneMappingType:f.imageProcessing?.toneMappingType,ditheringEnabled:f.imageProcessing?.ditheringEnabled,ditheringIntensity:f.imageProcessing?.ditheringIntensity,bloomEnabled:f.bloomEnabled,bloomThreshold:f.bloomThreshold,bloomWeight:f.bloomWeight,bloomScale:f.bloomScale,bloomKernel:f.bloomKernel,sharpenEnabled:f.sharpenEnabled,sharpenEdgeAmount:f.sharpen.edgeAmount,sharpenColorAmount:f.sharpen.colorAmount,grainEnabled:f.grainEnabled,grainIntensity:f.grain.intensity,grainAnimated:f.grain.animated,depthOfFieldEnabled:f.depthOfFieldEnabled,depthOfFieldBlurLevel:f.depthOfFieldBlurLevel,lensSize:f.depthOfField.lensSize,fStop:f.depthOfField.fStop,focusDistance:f.depthOfField.focusDistance,focalLength:f.depthOfField.focalLength,vignetteEnabled:f.imageProcessing?.vignetteEnabled,vignetteColor:f.imageProcessing?.vignetteColor.asArray(),vignetteWeight:f.imageProcessing?.vignetteWeight,chromaticAberrationEnabled:f.chromaticAberrationEnabled,aberrationAmount:f.chromaticAberration.aberrationAmount,radialIntensity:f.chromaticAberration.radialIntensity,direction:f.chromaticAberration.direction.asArray(),centerPosition:f.chromaticAberration.centerPosition.asArray(),glowLayerEnabled:f.glowLayerEnabled,glowLayerIntensity:f.glowLayer?.intensity,glowLayerBlurKernelSize:f.glowLayer?.blurKernelSize,colorGradingEnabled:f.imageProcessing.colorGradingEnabled,colorGradingTexture:f.imageProcessing.colorGradingTexture?.serialize(),colorGradingWithGreenDepth:f.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth,colorCurvesEnabled:f.imageProcessing.colorCurvesEnabled,globalHue:f.imageProcessing.colorCurves?.globalHue,globalDensity:f.imageProcessing.colorCurves?.globalDensity,globalExposure:f.imageProcessing.colorCurves?.globalExposure,globalSaturation:f.imageProcessing.colorCurves?.globalSaturation,highlightsHue:f.imageProcessing.colorCurves?.highlightsHue,highlightsDensity:f.imageProcessing.colorCurves?.highlightsDensity,highlightsExposure:f.imageProcessing.colorCurves?.highlightsExposure,highlightsSaturation:f.imageProcessing.colorCurves?.highlightsSaturation,midtonesHue:f.imageProcessing.colorCurves?.midtonesHue,midtonesDensity:f.imageProcessing.colorCurves?.midtonesDensity,midtonesExposure:f.imageProcessing.colorCurves?.midtonesExposure,midtonesSaturation:f.imageProcessing.colorCurves?.midtonesSaturation,shadowsHue:f.imageProcessing.colorCurves?.shadowsHue,shadowsDensity:f.imageProcessing.colorCurves?.shadowsDensity,shadowsExposure:f.imageProcessing.colorCurves?.shadowsExposure,shadowsSaturation:f.imageProcessing.colorCurves?.shadowsSaturation}:null}a(ri,"serializeDefaultRenderingPipeline");function ni(i,e,t,o,r){let n=f??Do(i,e,r);if(n.samples=r?.msaaSamples??1,n.fxaaEnabled=t.fxaaEnabled,n.imageProcessingEnabled=t.imageProcessingEnabled,n.imageProcessing){if(n.imageProcessing.exposure=t.exposure,n.imageProcessing.contrast=t.contrast,n.imageProcessing.fromLinearSpace=t.fromLinearSpace,n.imageProcessing.toneMappingEnabled=t.toneMappingEnabled,n.imageProcessing.toneMappingType=t.toneMappingType,n.imageProcessing.ditheringEnabled=t.ditheringEnabled,n.imageProcessing.ditheringIntensity=t.ditheringIntensity,n.imageProcessing.vignetteEnabled=t.vignetteEnabled??!1,n.imageProcessing.vignetteColor=bo.Color4.FromArray(t.vignetteColor??[0,0,0]),n.imageProcessing.vignetteWeight=t.vignetteWeight??.3,n.imageProcessing.colorGradingEnabled=t.colorGradingEnabled??!1,n.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth=t.colorGradingWithGreenDepth??!0,t.colorGradingTexture){let l=null;if(t.colorGradingTexture.customType==="BABYLON.ColorGradingTexture"){let p=o+t.colorGradingTexture.name;l=new _o.ColorGradingTexture(p,i),l.level=t.colorGradingTexture.level}else{let p=xo.Texture.Parse(t.colorGradingTexture,i,o);Me(p)&&(l=p)}n.imageProcessing.colorGradingTexture=l}n.imageProcessing.colorCurvesEnabled=t.colorCurvesEnabled??!1,n.imageProcessing.colorCurves&&(n.imageProcessing.colorCurves.globalHue=t.globalHue??30,n.imageProcessing.colorCurves.globalDensity=t.globalDensity??0,n.imageProcessing.colorCurves.globalExposure=t.globalExposure??0,n.imageProcessing.colorCurves.globalSaturation=t.globalSaturation??0,n.imageProcessing.colorCurves.highlightsHue=t.highlightsHue??30,n.imageProcessing.colorCurves.highlightsDensity=t.highlightsDensity??0,n.imageProcessing.colorCurves.highlightsExposure=t.highlightsExposure??0,n.imageProcessing.colorCurves.highlightsSaturation=t.highlightsSaturation??0,n.imageProcessing.colorCurves.midtonesHue=t.midtonesHue??30,n.imageProcessing.colorCurves.midtonesDensity=t.midtonesDensity??0,n.imageProcessing.colorCurves.midtonesExposure=t.midtonesExposure??0,n.imageProcessing.colorCurves.midtonesSaturation=t.midtonesSaturation??0,n.imageProcessing.colorCurves.shadowsHue=t.shadowsHue??30,n.imageProcessing.colorCurves.shadowsDensity=t.shadowsDensity??0,n.imageProcessing.colorCurves.shadowsExposure=t.shadowsExposure??0,n.imageProcessing.colorCurves.shadowsSaturation=t.shadowsSaturation??0)}return n.bloomEnabled=t.bloomEnabled,n.bloomThreshold=t.bloomThreshold,n.bloomWeight=t.bloomWeight,n.bloomScale=t.bloomScale,n.bloomKernel=t.bloomKernel,n.sharpenEnabled=t.sharpenEnabled,n.sharpen.edgeAmount=t.sharpenEdgeAmount,n.sharpen.colorAmount=t.sharpenColorAmount,n.grainEnabled=t.grainEnabled,n.grain.intensity=t.grainIntensity,n.grain.animated=t.grainAnimated,n.depthOfFieldEnabled=t.depthOfFieldEnabled,n.depthOfFieldBlurLevel=t.depthOfFieldBlurLevel,n.depthOfField.lensSize=t.lensSize,n.depthOfField.fStop=t.fStop,n.depthOfField.focusDistance=t.focusDistance,n.depthOfField.focalLength=t.focalLength,n.chromaticAberrationEnabled=t.chromaticAberrationEnabled??!1,n.chromaticAberration.aberrationAmount=t.aberrationAmount??10,n.chromaticAberration.radialIntensity=t.radialIntensity??1,n.chromaticAberration.direction=ii.Vector2.FromArray(t.direction??[0,0]),n.chromaticAberration.centerPosition=ii.Vector2.FromArray(t.centerPosition??[0,0]),n.glowLayerEnabled=t.glowLayerEnabled??!1,n.glowLayer&&(n.glowLayer.intensity=t.glowLayerIntensity??1,n.glowLayer.blurKernelSize=t.glowLayerBlurKernelSize??32),n}a(ni,"parseDefaultRenderingPipeline");var le="volumetricLighting",O=8,Z=256,ci=4,tt=3,Lo=(t=>(t[t.Linear=0]="Linear",t[t.Exponential=1]="Exponential",t))(Lo||{}),pi=(o=>(o[o.None=0]="None",o[o.Bayer=1]="Bayer",o[o.InterleavedGradientNoise=2]="InterleavedGradientNoise",o))(pi||{}),hi=(o=>(o[o.Exponential=0]="Exponential",o[o.ExponentialSquared=1]="ExponentialSquared",o[o.Linear=2]="Linear",o))(hi||{}),mi=(r=>(r[r.None=0]="None",r[r.Scattering=1]="Scattering",r[r.Transmittance=2]="Transmittance",r[r.LightCount=3]="LightCount",r))(mi||{});function li(){return{enabled:!1,volumeIntensity:1,anisotropy:.35,useCustomColor:!1,color:[1,1,1],castVolumetricShadows:!1,shadowDarkness:1,rangeMultiplier:1,priority:0}}a(li,"getDefaultVolumetricLightConfiguration");function it(){return{steps:40,lightSteps:0,resolutionScale:.5,stepDistribution:1,ditherMode:2,ditherStrength:1,temporalJitter:!1,temporalAccumulation:!1,temporalAccumulationFactor:.1,fogMode:0,fogDensity:5e-4,fogStart:0,fogEnd:2e3,fogColor:[1,1,1],albedo:1,maxDistance:1e4,heightFogEnabled:!1,heightFogBaseHeight:0,heightFogFalloff:.01,intensity:1.5,lightExtinctionEnabled:!0,lightExtinctionClamp:1e3,extinctionAmount:0,ambientColor:[1,1,1],ambientIntensity:0,screenSpaceShadows:!0,screenSpaceShadowSteps:6,screenSpaceShadowBias:.02,screenSpaceShadowMaxDistance:2e3,screenSpaceShadowThickness:4,blurPasses:2,blurRadius:3,blurDepthThreshold:.02,upsampleDepthThreshold:.02,maxLights:128,maxShadowedLights:4,pcfTaps:4,selectionRefreshRate:2,debugMode:0}}a(it,"getDefaultVolumetricLightingConfiguration");function Po(i){return i.lightSteps>0?i.lightSteps:Math.max(4,Math.min(64,Math.round(i.steps*.3)))}a(Po,"getVolumetricLightSteps");function di(i,e=tt){let t=Po(i);return!i.temporalAccumulation||e<=1?{steps:i.steps,lightSteps:t}:{steps:Math.max(4,Math.ceil(i.steps/e)),lightSteps:Math.max(2,Math.ceil(t/e))}}a(di,"getVolumetricSamplingSteps");function b(i,e,t,o){let r=typeof i=="number"&&isFinite(i)?i:e;return Math.min(o,Math.max(t,r))}a(b,"normalizeNumber");function ai(i,e){return!Array.isArray(i)||i.length<3?e.slice():[b(i[0],e[0],0,100),b(i[1],e[1],0,100),b(i[2],e[2],0,100)]}a(ai,"normalizeColor");function wo(i){let e=li();return!i||typeof i!="object"?e:{enabled:i.enabled??e.enabled,volumeIntensity:b(i.volumeIntensity,e.volumeIntensity,0,1e3),anisotropy:b(i.anisotropy,e.anisotropy,-.95,.95),useCustomColor:i.useCustomColor??e.useCustomColor,color:ai(i.color,e.color),castVolumetricShadows:i.castVolumetricShadows??e.castVolumetricShadows,shadowDarkness:b(i.shadowDarkness,e.shadowDarkness,0,1),rangeMultiplier:b(i.rangeMultiplier,e.rangeMultiplier,0,100),priority:b(i.priority,e.priority,-1e3,1e3)}}a(wo,"normalizeVolumetricLightConfiguration");function be(i){let e=it();return!i||typeof i!="object"?e:{steps:Math.round(b(i.steps,e.steps,4,256)),lightSteps:Math.round(b(i.lightSteps,e.lightSteps,0,128)),resolutionScale:b(i.resolutionScale,e.resolutionScale,.1,1),stepDistribution:Math.round(b(i.stepDistribution,e.stepDistribution,0,1)),ditherMode:Math.round(b(i.ditherMode,e.ditherMode,0,2)),ditherStrength:b(i.ditherStrength,e.ditherStrength,0,1),temporalJitter:i.temporalJitter??e.temporalJitter,temporalAccumulation:i.temporalAccumulation??e.temporalAccumulation,temporalAccumulationFactor:b(i.temporalAccumulationFactor,e.temporalAccumulationFactor,.005,1),fogMode:Math.round(b(i.fogMode,e.fogMode,0,2)),fogDensity:b(i.fogDensity,e.fogDensity,0,100),fogStart:b(i.fogStart,e.fogStart,0,1e6),fogEnd:Math.max(b(i.fogEnd,e.fogEnd,0,1e7),b(i.fogStart,e.fogStart,0,1e6)+.001),fogColor:ai(i.fogColor,e.fogColor),albedo:b(i.albedo,e.albedo,0,1),maxDistance:b(i.maxDistance,e.maxDistance,1,1e6),heightFogEnabled:i.heightFogEnabled??e.heightFogEnabled,heightFogBaseHeight:b(i.heightFogBaseHeight,e.heightFogBaseHeight,-1e6,1e6),heightFogFalloff:b(i.heightFogFalloff,e.heightFogFalloff,0,10),intensity:b(i.intensity,e.intensity,0,100),lightExtinctionEnabled:i.lightExtinctionEnabled??e.lightExtinctionEnabled,lightExtinctionClamp:b(i.lightExtinctionClamp,e.lightExtinctionClamp,0,1e6),extinctionAmount:b(i.extinctionAmount,e.extinctionAmount,0,1),ambientColor:ai(i.ambientColor,e.ambientColor),ambientIntensity:b(i.ambientIntensity,e.ambientIntensity,0,100),screenSpaceShadows:i.screenSpaceShadows??e.screenSpaceShadows,screenSpaceShadowSteps:Math.round(b(i.screenSpaceShadowSteps,e.screenSpaceShadowSteps,1,32)),screenSpaceShadowBias:b(i.screenSpaceShadowBias,e.screenSpaceShadowBias,0,1),screenSpaceShadowMaxDistance:b(i.screenSpaceShadowMaxDistance,e.screenSpaceShadowMaxDistance,1,1e7),screenSpaceShadowThickness:b(i.screenSpaceShadowThickness,e.screenSpaceShadowThickness,.01,1e3),blurPasses:Math.round(b(i.blurPasses,e.blurPasses,0,2)),blurRadius:Math.round(b(i.blurRadius,e.blurRadius,1,6)),blurDepthThreshold:b(i.blurDepthThreshold,e.blurDepthThreshold,1e-4,1),upsampleDepthThreshold:b(i.upsampleDepthThreshold,e.upsampleDepthThreshold,1e-4,1),maxLights:Math.round(b(i.maxLights,e.maxLights,0,Z)),maxShadowedLights:Math.round(b(i.maxShadowedLights,e.maxShadowedLights,0,O)),pcfTaps:b(i.pcfTaps,e.pcfTaps,1,4)>=4?4:1,selectionRefreshRate:Math.round(b(i.selectionRefreshRate,e.selectionRefreshRate,1,60)),debugMode:Math.round(b(i.debugMode,e.debugMode,0,3))}}a(be,"normalizeVolumetricLightingConfiguration");var si=new WeakSet;function To(i){i.metadata??={};let e=i.metadata[le];if(!e||typeof e!="object")return i.metadata[le]=wo(null),si.add(i.metadata[le]),i.metadata[le];if(si.has(e))return e;let t=li();return Object.keys(t).forEach(o=>{e[o]===void 0&&(e[o]=t[o])}),si.add(e),e}a(To,"ensureVolumetricLightConfiguration");function ui(i){let e=i.metadata?.[le];return e&&typeof e=="object"?To(i):null}a(ui,"getVolumetricLightConfiguration");function qn(i){return i.metadata?.[le]?.enabled===!0}a(qn,"isVolumetricLightEnabled");var ot=require("babylonjs"),Io=require("babylonjs"),gi=require("babylonjs"),Y=require("babylonjs"),vi=(o=>(o[o.Texture2D=0]="Texture2D",o[o.Sampler2DShadow=1]="Sampler2DShadow",o[o.Cube=2]="Cube",o))(vi||{}),Mo=(o=>(o[o.Standard=0]="Standard",o[o.Esm=1]="Esm",o[o.CloseEsm=2]="CloseEsm",o))(Mo||{}),Si=(o=>(o[o.Analytic=0]="Analytic",o[o.AnalyticHeight=1]="AnalyticHeight",o[o.Numeric=2]="Numeric",o))(Si||{}),Oo=10,Qn=4,Jn=22,ea=32,ta=.15;function Ve(i,e){let t=i.getCaps(),o=t.maxFragmentUniformVectors||224,r=i.isWebGPU?Math.floor(o/4):o,n=Math.max(224,r)-ea,l=Math.max(8,t.maxTexturesImageUnits||16)-1,p=l>=2,s=p?Jn:0,c=Math.max(0,Math.min(O,e.maxShadowedLights,l-(p?1:0),Math.floor((n-s)/Oo))),h=Math.max(0,Math.min(Z,e.maxLights,Math.floor((n-s-c*Oo)/Qn)));return{maxShadowSlots:c,maxArrayLights:h,maxDirectionalLights:Math.min(ci,h),allowCsm:p}}a(Ve,"computeVolumetricBudget");function Ro(i){let e=[];return i.lights.forEach(t=>{me(t)?t.lights.forEach(o=>{e.push({light:o,isClustered:!0})}):e.push({light:t,isClustered:!1})}),e}a(Ro,"getAllVolumetricCandidateLights");function Vo(i,e){let t=i.getShadowGenerator(e.activeCamera)??i.getShadowGenerator();if(!t||!Tt(t))return null;let o=t.getShadowMapForRendering();if(!o?.isReady())return null;let r=t.getShadowMap()?.getSize().width??1024,n=o.textureType===gi.Constants.TEXTURETYPE_UNSIGNED_BYTE,l=!ie(i),p=i.needCube?.()===!0;switch(t.filter){case Y.ShadowGenerator.FILTER_PCF:case Y.ShadowGenerator.FILTER_PCSS:return{generator:t,kind:p?2:1,mode:0,packed:n,mapSize:r,local:l};case Y.ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP:case Y.ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP:return{generator:t,kind:p?2:0,mode:1,packed:n,mapSize:r,local:l};case Y.ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP:case Y.ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:return{generator:t,kind:p?2:0,mode:2,packed:n,mapSize:r,local:l};default:return{generator:t,kind:p?2:0,mode:0,packed:n,mapSize:r,local:l}}}a(Vo,"resolveVolumetricShadowSlot");function rt(i,e){let t=i;return t.computeTransformedInformation?.()&&t.transformedPosition?e.copyFrom(t.transformedPosition):t.position?e.copyFrom(t.position):e.copyFromFloats(0,0,0),e}a(rt,"getVolumetricLightWorldPosition");function Fe(i,e){let t=i;return t.computeTransformedInformation?.()&&t.transformedDirection?e.copyFrom(t.transformedDirection):t.direction?e.copyFrom(t.direction):e.copyFromFloats(0,0,1),e.normalize()}a(Fe,"getVolumetricLightWorldDirection");function nt(i,e,t){let o=i.range>0&&i.range<Number.MAX_VALUE?i.range:t.maxDistance;return Math.max(.001,Math.min(o*e.rangeMultiplier,34e37))}a(nt,"getVolumetricLightRange");var fi=new ot.Vector3,Eo=new ot.Vector3;function ia(i,e,t){if(rt(i,t),!ae(i))return e;let o=Math.cos(i.angle*.5);if(o<=.5)return e;let r=e/(2*o);return Fe(i,Eo),t.addInPlace(Eo.scaleInPlace(r)),r}a(ia,"computeVolumetricLightBounds");function oa(i,e,t){for(let o=0;o<t.length;++o)if(t[o].dotCoordinate(i)<=-e)return!1;return!0}a(oa,"isSphereInFrustum");function Ao(i){return(i.local?64:0)+i.kind*16+i.mode*4+(i.packed?1:0)}a(Ao,"getShadowSlotSignature");function yi(i,e,t,o,r){let n={candidateCount:0,culledCount:0,shadowedCount:0,unshadowedCount:0,droppedCount:0,perLight:new Map},l=Io.Frustum.GetPlanes(i.getTransformMatrix()),p=e.globalPosition,s=[];Ro(i).forEach(({light:v,isClustered:_})=>{let V=ui(v);if(!V?.enabled)return;if(n.candidateCount++,Je(v)||!v.isEnabled()||v.intensity<=0||V.volumeIntensity<=0){n.perLight.set(v.uniqueId,{state:"disabled",slot:-1,reason:Je(v)?"Hemispheric lights have no position nor direction and can't produce light shafts.":"The light is disabled or its intensity is zero."});return}let j=ie(v),he=V.priority*1e3;if(j)he+=1e6;else{let Ye=Math.min(nt(v,V,t),t.maxDistance),Pt=ia(v,Ye,fi);if(!oa(fi,Pt,l)){n.culledCount++,n.perLight.set(v.uniqueId,{state:"culled",slot:-1,reason:"The light is outside of the frustum of the camera and doesn't reach it."});return}let wn=Math.max(1,ot.Vector3.Distance(fi,p)-Pt);he+=V.volumeIntensity*v.intensity*Math.min(4,Pt/wn)}s.push({light:v,config:V,isClustered:_,typeId:v.getTypeID(),score:he})}),s.sort((v,_)=>_.score-v.score);let c=new Map;r?.shadowed.forEach((v,_)=>{c.set(v.candidate.light.uniqueId,_)});let h=[],m=[],d=new Map,u=null;s.forEach(v=>{let{light:_,config:V}=v;if(!V.castVolumetricShadows){d.set(_.uniqueId,"occlusion is disabled on this light."),m.push(v);return}if(v.isClustered){d.set(_.uniqueId,"clustered lighting doesn't support shadow maps."),m.push(v);return}if(!_.shadowEnabled||!i.shadowsEnabled){d.set(_.uniqueId,"shadows are disabled on this light or on the scene."),m.push(v);return}let j=_.getShadowGenerator(i.activeCamera)??_.getShadowGenerator();if(!j){d.set(_.uniqueId,"the light has no shadow generator."),m.push(v);return}if(Ot(j)&&o.allowCsm){let Ye=j.getShadowMapForRendering();if(!u&&Ye?.isReady()){u={candidate:v,generator:j,cascades:j.numCascades,kind:j.filter===Y.ShadowGenerator.FILTER_PCF||j.filter===Y.ShadowGenerator.FILTER_PCSS?1:0,packed:Ye.textureType===gi.Constants.TEXTURETYPE_UNSIGNED_BYTE};return}d.set(_.uniqueId,u?"another light already uses the single cascaded shadow map slot.":"its cascaded shadow map is not ready yet."),m.push(v);return}let he=Vo(_,i);if(!he){d.set(_.uniqueId,"the shadow map of the light is not ready yet."),m.push(v);return}h.push({candidate:v,shadow:he})});function S(v){let _=v.candidate.score;return c.get(v.candidate.light.uniqueId)===void 0?_:_+Math.abs(_)*ta}a(S,"getHysteresisScore");function g(v){return c.get(v.candidate.light.uniqueId)??Number.MAX_SAFE_INTEGER}a(g,"getPreviousSlot"),h.sort((v,_)=>{let V=S(_)-S(v);return V!==0?V:g(v)-g(_)});let y=h.slice(0,o.maxShadowSlots);y.sort((v,_)=>Ao(v.shadow)-Ao(_.shadow)||g(v)-g(_)),h.slice(o.maxShadowSlots).forEach(v=>{d.set(v.candidate.light.uniqueId,"the shadowed lights budget is full."),m.push(v.candidate)}),m.sort((v,_)=>_.score-v.score);let C=[],L=[],x=[];m.forEach(v=>{ie(v.light)?C.length<o.maxDirectionalLights?C.push(v):x.push({candidate:v,reason:`Not rendered: at most ${o.maxDirectionalLights} directional light(s) without a shadow map can take part in the effect.`}):L.push(v)});let R=Math.max(0,o.maxArrayLights-C.length);L.slice(R).forEach(v=>{x.push({candidate:v,reason:'Not rendered: the lights budget is full. Raise "Max Lights" or lower the priority of the other lights.'})});let B=C.concat(L.slice(0,R));if(y.forEach((v,_)=>{n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:_,reason:`Casting volumetric shadows using slot ${_+1} of ${o.maxShadowSlots}.`})}),u){let v=u;n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:-1,reason:`Casting volumetric shadows using its ${v.cascades} shadow cascades.`})}return B.forEach(v=>{n.unshadowedCount++;let _=v.config.castVolumetricShadows?"Occluded using the depth buffer":"Not occluded by the geometry",V=d.get(v.light.uniqueId)??"the light has no shadow map.";n.perLight.set(v.light.uniqueId,{state:"unshadowed",slot:-1,reason:`${_}: ${V}`})}),x.forEach(({candidate:v,reason:_})=>{n.droppedCount++,n.perLight.set(v.light.uniqueId,{state:"dropped",slot:-1,reason:_})}),{shadowed:y,unshadowed:B,directionalCount:C.length,csm:u,stats:n}}a(yi,"selectVolumetricLights");function ra(i,e,t){let o=i.shadowed.map(n=>`${n.shadow.kind}.${n.shadow.mode}.${n.shadow.packed?1:0}.${n.shadow.local?1:0}`).join("|"),r=i.csm?`${i.csm.kind}.${i.csm.cascades}.${i.csm.packed?1:0}`:"-";return[t.steps,t.lightSteps,e.stepDistribution,e.ditherMode,e.temporalJitter?1:0,e.temporalAccumulation?1:0,e.heightFogEnabled?1:0,e.lightExtinctionEnabled?1:0,e.pcfTaps,e.blurRadius,e.debugMode,e.screenSpaceShadows?e.screenSpaceShadowSteps:0,t.fogMode,t.transmittance,t.depthMode,t.ldrEncode?1:0,t.reverseDepth?1:0,t.ndcHalfZ?1:0,t.linearDepthPacked?1:0,t.arrayLightCapacity,i.directionalCount,o,r].join(",")}a(ra,"computeVolumetricShapeKey");function na(i){return wt(i)||ae(i)||ie(i)}a(na,"isVolumetricLightSupported");var bi=require("babylonjs"),aa=0,xi=(o=>(o[o.DepthRenderer=0]="DepthRenderer",o[o.GeometryBuffer=1]="GeometryBuffer",o[o.PrePass=2]="PrePass",o))(xi||{}),Fo="volumetricLighting";function _i(){return{name:Fo,enabled:!1,texturesRequired:[bi.Constants.PREPASS_DEPTH_TEXTURE_TYPE]}}a(_i,"createVolumetricLightingPrePassConfiguration");function xe(i){return i.prePassRenderer??null}a(xe,"getVolumetricPrePassRenderer");function Ne(i){return i.geometryBufferRenderer??null}a(Ne,"getVolumetricGeometryBufferRenderer");function No(i){let e=i.getCaps();return e.textureFloat&&e.textureFloatLinearFiltering||e.textureHalfFloat&&e.textureHalfFloatLinearFiltering}a(No,"supportsVolumetricFloatDepthTexture");function at(i){return No(i.getEngine())?xe(i)?.isSupported?2:Ne(i)?.isSupported?1:0:0}a(at,"resolveVolumetricDepthSource");function Ci(i){let e=i.getIndex(bi.Constants.PREPASS_DEPTH_TEXTURE_TYPE);return e===void 0||e<0?null:i.getRenderTarget()?.textures?.[e]??null}a(Ci,"getVolumetricPrePassDepthTexture");function Di(i){if(!i.enableDepth)return null;let e=i.getTextureIndex(aa);return e<0?null:i.getGBuffer()?.textures?.[e]??null}a(Di,"getVolumetricGeometryBufferDepthTexture");var Ge=`
|
|
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
2
|
// Stored scaled down by a power of two, which is exact. @see the GLSL version.
|
|
3
3
|
const volLinearDepthScale: f32 = 1.0 / 1024.0;
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ fn volUnpack(color: vec4f) -> f32 {
|
|
|
6
6
|
let bitShift = vec4f(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
|
|
7
7
|
return dot(color, bitShift);
|
|
8
8
|
}
|
|
9
|
-
`,
|
|
9
|
+
`,da=`
|
|
10
10
|
// Loads the texel under the given coordinates rather than filtering: the 32 bits float textures of the prepass
|
|
11
11
|
// renderer are not filterable on WebGPU. @see the GLSL version.
|
|
12
12
|
fn volSampleDepth(uv: vec2f) -> f32 {
|
|
@@ -33,13 +33,13 @@ fn volLinearDepth(d: f32) -> f32 {
|
|
|
33
33
|
return uniforms.volDepthUnpack.x * d + uniforms.volDepthUnpack.y;
|
|
34
34
|
#endif
|
|
35
35
|
}
|
|
36
|
-
`;function
|
|
36
|
+
`;function ct(t){return`
|
|
37
37
|
// Returns the distance along the view axis, in scene units, of the texel at the given coordinates.
|
|
38
38
|
fn volReadLinearDepth(coordinates: vec2i) -> f32 {
|
|
39
39
|
#ifdef VOL_LINEAR_DEPTH_PACKED
|
|
40
|
-
return volUnpack(textureLoad(${
|
|
40
|
+
return volUnpack(textureLoad(${t}, coordinates, 0)) * uniforms.volCameraMinMaxZ.y;
|
|
41
41
|
#else
|
|
42
|
-
return textureLoad(${
|
|
42
|
+
return textureLoad(${t}, coordinates, 0).r * (1.0 / volLinearDepthScale);
|
|
43
43
|
#endif
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ fn volReadLinearDepth(coordinates: vec2i) -> f32 {
|
|
|
48
48
|
fn volScatterToDepthTexel(scatterTexel: vec2i, depthSize: vec2i) -> vec2i {
|
|
49
49
|
return min(vec2i((vec2f(scatterTexel) + 0.5) * uniforms.volDepthRatio), depthSize - 1);
|
|
50
50
|
}
|
|
51
|
-
`}a(
|
|
51
|
+
`}a(ct,"buildLinearDepthHelpers");function ua(){return`
|
|
52
52
|
varying vUV: vec2f;
|
|
53
53
|
|
|
54
54
|
var textureSamplerSampler: sampler;
|
|
@@ -61,8 +61,8 @@ uniform volDepthUnpack: vec2f;
|
|
|
61
61
|
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
62
62
|
uniform volPassParams: vec4f;
|
|
63
63
|
|
|
64
|
-
${
|
|
65
|
-
${
|
|
64
|
+
${Be}
|
|
65
|
+
${da}
|
|
66
66
|
|
|
67
67
|
fn volPack(depth: f32) -> vec4f {
|
|
68
68
|
let bitShift = vec4f(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
|
|
@@ -90,7 +90,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
90
90
|
#endif
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
`}a(
|
|
93
|
+
`}a(ua,"buildVolumetricLightingLinearDepthShaderWGSL");function Wo(t,e){return`
|
|
94
94
|
let chordLength = t1 - t0;
|
|
95
95
|
|
|
96
96
|
// The point of the view ray closest to the light splits the chord in two halves over which both the
|
|
@@ -113,7 +113,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
113
113
|
|
|
114
114
|
let firstWidth = (closest - t0) / f32(max(firstCount, 1));
|
|
115
115
|
let secondWidth = (t1 - closest) / f32(max(count - firstCount, 1));
|
|
116
|
-
let stratum = volStratumOffset(${
|
|
116
|
+
let stratum = volStratumOffset(${t});
|
|
117
117
|
|
|
118
118
|
var result = vec3f(0.0);
|
|
119
119
|
|
|
@@ -140,7 +140,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
return vec4f(result, 1.0);
|
|
143
|
-
`}a(
|
|
143
|
+
`}a(Wo,"buildLocalLightIntegrationWGSL");function fa(t){let e=[],i=[],r=[];for(let o=0;o<t;++o)e.push(`
|
|
144
144
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
145
145
|
#if VOL_SHADOW_KIND{X} == 2
|
|
146
146
|
var volShadowSampler{X}Sampler: sampler;
|
|
@@ -259,11 +259,11 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
259
259
|
// The light clip space position of the points of the view ray is affine in their distance to the camera.
|
|
260
260
|
let clipOrigin = uniforms.volShadowMatrix[{X}] * vec4f(uniforms.volCameraPosition, 1.0);
|
|
261
261
|
let clipDirection = uniforms.volShadowMatrix[{X}] * vec4f(volRayDir, 0.0);
|
|
262
|
-
${
|
|
262
|
+
${Wo("f32({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
|
|
263
263
|
}
|
|
264
264
|
#endif
|
|
265
265
|
#endif
|
|
266
|
-
`.replace(/\{X\}/g,
|
|
266
|
+
`.replace(/\{X\}/g,o.toString())),i.push(`
|
|
267
267
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
268
268
|
#if VOL_SHADOW_LOCAL{X} == 0
|
|
269
269
|
{
|
|
@@ -274,7 +274,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
274
274
|
}
|
|
275
275
|
#endif
|
|
276
276
|
#endif
|
|
277
|
-
`.replace(/\{X\}/g,
|
|
277
|
+
`.replace(/\{X\}/g,o.toString())),r.push(`
|
|
278
278
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
279
279
|
#if VOL_SHADOW_LOCAL{X} == 1
|
|
280
280
|
lightResult = volIntegrateShadowSlot{X}(tStart, tEnd);
|
|
@@ -282,7 +282,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
282
282
|
evaluatedLights += lightResult.w;
|
|
283
283
|
#endif
|
|
284
284
|
#endif
|
|
285
|
-
`.replace(/\{X\}/g,
|
|
285
|
+
`.replace(/\{X\}/g,o.toString()));return`
|
|
286
286
|
varying vUV: vec2f;
|
|
287
287
|
|
|
288
288
|
// Full resolution linear depth of the scene, written by the linear depth pass.
|
|
@@ -363,8 +363,8 @@ var<private> volJitter: f32;
|
|
|
363
363
|
var<private> volClipDirection: vec4f;
|
|
364
364
|
#endif
|
|
365
365
|
|
|
366
|
-
${
|
|
367
|
-
${
|
|
366
|
+
${Be}
|
|
367
|
+
${ct("textureSampler")}
|
|
368
368
|
|
|
369
369
|
fn volMod(x: f32, y: f32) -> f32 {
|
|
370
370
|
return x - y * floor(x / y);
|
|
@@ -831,7 +831,7 @@ ${e.join(`
|
|
|
831
831
|
var scattering = vec3f(0.0);
|
|
832
832
|
var stepLights = 0.0;
|
|
833
833
|
|
|
834
|
-
${
|
|
834
|
+
${i.join("")}
|
|
835
835
|
#ifdef VOL_CSM
|
|
836
836
|
{
|
|
837
837
|
scattering += volEvalDirectionalLight(uniforms.volCsmLightData, uniforms.volCsmLightDiffuse) * mix(1.0, volCsmShadow(t), uniforms.volCsmLightFalloff.w);
|
|
@@ -890,7 +890,7 @@ ${t.join("")}
|
|
|
890
890
|
let lightDepth = dot(data.xyz, uniforms.volCameraForward);
|
|
891
891
|
#endif
|
|
892
892
|
|
|
893
|
-
${
|
|
893
|
+
${Wo("f32(index)",`#ifdef VOL_SCREEN_SHADOWS
|
|
894
894
|
if (occluded) {
|
|
895
895
|
contribution *= volScreenShadowToLight(t, lightClip, lightDepth, distanceToLight);
|
|
896
896
|
}
|
|
@@ -962,7 +962,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
962
962
|
evaluatedLights += lightResult.w;
|
|
963
963
|
#endif
|
|
964
964
|
|
|
965
|
-
${
|
|
965
|
+
${r.join("")}
|
|
966
966
|
|
|
967
967
|
#if VOL_LOCAL_ARRAY_LIGHTS == 1
|
|
968
968
|
let localEnd = VOL_DIRECTIONAL_LIGHT_COUNT + i32(uniforms.volParams.w + 0.5);
|
|
@@ -995,7 +995,7 @@ ${o.join("")}
|
|
|
995
995
|
|
|
996
996
|
fragmentOutputs.color = vec4f(result, finalTransmittance);
|
|
997
997
|
}
|
|
998
|
-
`}a(
|
|
998
|
+
`}a(fa,"buildVolumetricLightingScatteringShaderWGSL");function ga(){return`
|
|
999
999
|
varying vUV: vec2f;
|
|
1000
1000
|
|
|
1001
1001
|
var textureSampler: texture_2d<f32>;
|
|
@@ -1018,8 +1018,8 @@ uniform volTemporalParams: vec4f;
|
|
|
1018
1018
|
// delay of the history may lag behind)
|
|
1019
1019
|
uniform volTemporalMotion: vec2f;
|
|
1020
1020
|
|
|
1021
|
-
${
|
|
1022
|
-
${
|
|
1021
|
+
${Be}
|
|
1022
|
+
${ct("volLinearDepthSampler")}
|
|
1023
1023
|
|
|
1024
1024
|
@fragment
|
|
1025
1025
|
fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
@@ -1084,7 +1084,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1084
1084
|
|
|
1085
1085
|
fragmentOutputs.color = result;
|
|
1086
1086
|
}
|
|
1087
|
-
`}a(
|
|
1087
|
+
`}a(ga,"buildVolumetricLightingTemporalShaderWGSL");function va(){return`
|
|
1088
1088
|
varying vUV: vec2f;
|
|
1089
1089
|
|
|
1090
1090
|
var textureSampler: texture_2d<f32>;
|
|
@@ -1098,8 +1098,8 @@ uniform volBlurParams: vec2f;
|
|
|
1098
1098
|
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
1099
1099
|
uniform volPassParams: vec4f;
|
|
1100
1100
|
|
|
1101
|
-
${
|
|
1102
|
-
${
|
|
1101
|
+
${Be}
|
|
1102
|
+
${ct("volLinearDepthSampler")}
|
|
1103
1103
|
|
|
1104
1104
|
@fragment
|
|
1105
1105
|
fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
@@ -1143,7 +1143,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1143
1143
|
fragmentOutputs.color = result / totalWeight;
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
1146
|
-
`}a(
|
|
1146
|
+
`}a(va,"buildVolumetricLightingBlurShaderWGSL");function Sa(){return`
|
|
1147
1147
|
varying vUV: vec2f;
|
|
1148
1148
|
|
|
1149
1149
|
var textureSampler: texture_2d<f32>;
|
|
@@ -1158,8 +1158,8 @@ uniform volComposeParams: vec4f;
|
|
|
1158
1158
|
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
1159
1159
|
uniform volPassParams: vec4f;
|
|
1160
1160
|
|
|
1161
|
-
${
|
|
1162
|
-
${
|
|
1161
|
+
${Be}
|
|
1162
|
+
${ct("volLinearDepthSampler")}
|
|
1163
1163
|
|
|
1164
1164
|
fn volMod(x: f32, y: f32) -> f32 {
|
|
1165
1165
|
return x - y * floor(x / y);
|
|
@@ -1255,7 +1255,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1255
1255
|
#endif
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
|
-
`}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
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
1260
|
// scenes, with a relative precision of 0.05%.
|
|
1261
1261
|
const float volLinearDepthScale = 1.0 / 1024.0;
|
|
@@ -1264,7 +1264,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1264
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);
|
|
1265
1265
|
return dot(color, bitShift);
|
|
1266
1266
|
}
|
|
1267
|
-
`,
|
|
1267
|
+
`,ya=`
|
|
1268
1268
|
// Reads the texel under the given coordinates rather than filtering: the depth of a silhouette must not be
|
|
1269
1269
|
// averaged with the sky, and the 32 bits float textures of the prepass renderer can't be filtered everywhere.
|
|
1270
1270
|
float volSampleDepth(vec2 uv) {
|
|
@@ -1292,7 +1292,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1292
1292
|
return volDepthUnpack.x * d + volDepthUnpack.y;
|
|
1293
1293
|
#endif
|
|
1294
1294
|
}
|
|
1295
|
-
`,
|
|
1295
|
+
`,pt=`
|
|
1296
1296
|
// Returns the distance along the view axis, in scene units, of the texel at the given coordinates.
|
|
1297
1297
|
float volReadLinearDepth(sampler2D s, ivec2 coordinates) {
|
|
1298
1298
|
#ifdef VOL_LINEAR_DEPTH_PACKED
|
|
@@ -1309,7 +1309,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1309
1309
|
ivec2 volScatterToDepthTexel(ivec2 scatterTexel, ivec2 depthSize) {
|
|
1310
1310
|
return min(ivec2((vec2(scatterTexel) + 0.5) * volDepthRatio), depthSize - 1);
|
|
1311
1311
|
}
|
|
1312
|
-
`;function
|
|
1312
|
+
`;function ba(){return`precision highp float;
|
|
1313
1313
|
precision highp int;
|
|
1314
1314
|
|
|
1315
1315
|
varying vec2 vUV;
|
|
@@ -1323,8 +1323,8 @@ uniform vec2 volDepthUnpack;
|
|
|
1323
1323
|
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
1324
1324
|
uniform vec4 volPassParams;
|
|
1325
1325
|
|
|
1326
|
-
${
|
|
1327
|
-
${
|
|
1326
|
+
${ze}
|
|
1327
|
+
${ya}
|
|
1328
1328
|
|
|
1329
1329
|
vec4 volPack(float depth) {
|
|
1330
1330
|
const vec4 bitShift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
|
|
@@ -1352,7 +1352,7 @@ void main(void) {
|
|
|
1352
1352
|
gl_FragColor = vec4(min(viewZ * volLinearDepthScale, 65504.0), 0.0, 0.0, 1.0);
|
|
1353
1353
|
#endif
|
|
1354
1354
|
}
|
|
1355
|
-
`}a(
|
|
1355
|
+
`}a(ba,"buildVolumetricLightingLinearDepthShader");function $o(t,e){return`
|
|
1356
1356
|
float chordLength = t1 - t0;
|
|
1357
1357
|
|
|
1358
1358
|
// The point of the view ray closest to the light splits the chord in two halves over which both the
|
|
@@ -1369,7 +1369,7 @@ void main(void) {
|
|
|
1369
1369
|
|
|
1370
1370
|
float firstWidth = (closest - t0) / float(max(firstCount, 1));
|
|
1371
1371
|
float secondWidth = (t1 - closest) / float(max(count - firstCount, 1));
|
|
1372
|
-
float stratum = volStratumOffset(${
|
|
1372
|
+
float stratum = volStratumOffset(${t});
|
|
1373
1373
|
|
|
1374
1374
|
vec3 result = vec3(0.0);
|
|
1375
1375
|
|
|
@@ -1395,7 +1395,7 @@ void main(void) {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
1397
|
return vec4(result, 1.0);
|
|
1398
|
-
`}a(
|
|
1398
|
+
`}a($o,"buildLocalLightIntegration");function xa(t){let e=[],i=[],r=[];for(let o=0;o<t;++o)e.push(`
|
|
1399
1399
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
1400
1400
|
#if VOL_SHADOW_KIND{X} == 2
|
|
1401
1401
|
uniform samplerCube volShadowSampler{X};
|
|
@@ -1512,11 +1512,11 @@ void main(void) {
|
|
|
1512
1512
|
// so each sample only costs a multiply-add instead of a matrix product.
|
|
1513
1513
|
vec4 clipOrigin = volShadowMatrix[{X}] * vec4(volCameraPosition, 1.0);
|
|
1514
1514
|
vec4 clipDirection = volShadowMatrix[{X}] * vec4(volRayDir, 0.0);
|
|
1515
|
-
${
|
|
1515
|
+
${$o("float({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
|
|
1516
1516
|
}
|
|
1517
1517
|
#endif
|
|
1518
1518
|
#endif
|
|
1519
|
-
`.replace(/\{X\}/g,
|
|
1519
|
+
`.replace(/\{X\}/g,o.toString())),i.push(`
|
|
1520
1520
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
1521
1521
|
#if VOL_SHADOW_LOCAL{X} == 0
|
|
1522
1522
|
{
|
|
@@ -1528,7 +1528,7 @@ void main(void) {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
#endif
|
|
1530
1530
|
#endif
|
|
1531
|
-
`.replace(/\{X\}/g,
|
|
1531
|
+
`.replace(/\{X\}/g,o.toString())),r.push(`
|
|
1532
1532
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
1533
1533
|
#if VOL_SHADOW_LOCAL{X} == 1
|
|
1534
1534
|
lightResult = volIntegrateShadowSlot{X}(tStart, tEnd);
|
|
@@ -1536,7 +1536,7 @@ void main(void) {
|
|
|
1536
1536
|
evaluatedLights += lightResult.a;
|
|
1537
1537
|
#endif
|
|
1538
1538
|
#endif
|
|
1539
|
-
`.replace(/\{X\}/g,
|
|
1539
|
+
`.replace(/\{X\}/g,o.toString()));return`precision highp float;
|
|
1540
1540
|
precision highp int;
|
|
1541
1541
|
|
|
1542
1542
|
varying vec2 vUV;
|
|
@@ -1617,8 +1617,8 @@ float volJitter;
|
|
|
1617
1617
|
vec4 volClipDirection;
|
|
1618
1618
|
#endif
|
|
1619
1619
|
|
|
1620
|
-
${
|
|
1621
|
-
${
|
|
1620
|
+
${ze}
|
|
1621
|
+
${pt}
|
|
1622
1622
|
|
|
1623
1623
|
float volFallOff(float value, vec2 clipSpaceXY, float frustumEdgeFalloff) {
|
|
1624
1624
|
float mask = smoothstep(1.0 - frustumEdgeFalloff, 1.00000012, clamp(dot(clipSpaceXY, clipSpaceXY), 0.0, 1.0));
|
|
@@ -2136,7 +2136,7 @@ ${e.join(`
|
|
|
2136
2136
|
vec3 scattering = vec3(0.0);
|
|
2137
2137
|
float stepLights = 0.0;
|
|
2138
2138
|
|
|
2139
|
-
${
|
|
2139
|
+
${i.join("")}
|
|
2140
2140
|
#ifdef VOL_CSM
|
|
2141
2141
|
{
|
|
2142
2142
|
scattering += volEvalDirectionalLight(volCsmLightData, volCsmLightDiffuse) * mix(1.0, volCsmShadow(t), volCsmLightFalloff.w);
|
|
@@ -2196,7 +2196,7 @@ ${t.join("")}
|
|
|
2196
2196
|
float lightDepth = dot(data.xyz, volCameraForward);
|
|
2197
2197
|
#endif
|
|
2198
2198
|
|
|
2199
|
-
${
|
|
2199
|
+
${$o("float(index)",`#ifdef VOL_SCREEN_SHADOWS
|
|
2200
2200
|
if (occluded) {
|
|
2201
2201
|
contribution *= volScreenShadowToLight(t, lightClip, lightDepth, distanceToLight);
|
|
2202
2202
|
}
|
|
@@ -2277,7 +2277,7 @@ void main(void) {
|
|
|
2277
2277
|
evaluatedLights += lightResult.a;
|
|
2278
2278
|
#endif
|
|
2279
2279
|
|
|
2280
|
-
${
|
|
2280
|
+
${r.join("")}
|
|
2281
2281
|
|
|
2282
2282
|
#if VOL_LOCAL_ARRAY_LIGHTS == 1
|
|
2283
2283
|
int localEnd = VOL_DIRECTIONAL_LIGHT_COUNT + int(volParams.w + 0.5);
|
|
@@ -2309,7 +2309,7 @@ ${o.join("")}
|
|
|
2309
2309
|
|
|
2310
2310
|
gl_FragColor = vec4(result, finalTransmittance);
|
|
2311
2311
|
}
|
|
2312
|
-
`}a(
|
|
2312
|
+
`}a(xa,"buildVolumetricLightingScatteringShader");function _a(){return`precision highp float;
|
|
2313
2313
|
precision highp int;
|
|
2314
2314
|
|
|
2315
2315
|
varying vec2 vUV;
|
|
@@ -2339,8 +2339,8 @@ uniform vec4 volTemporalParams;
|
|
|
2339
2339
|
// delay of the history may lag behind)
|
|
2340
2340
|
uniform vec2 volTemporalMotion;
|
|
2341
2341
|
|
|
2342
|
-
${
|
|
2343
|
-
${
|
|
2342
|
+
${ze}
|
|
2343
|
+
${pt}
|
|
2344
2344
|
|
|
2345
2345
|
void main(void) {
|
|
2346
2346
|
ivec2 texel = ivec2(gl_FragCoord.xy);
|
|
@@ -2411,7 +2411,7 @@ void main(void) {
|
|
|
2411
2411
|
|
|
2412
2412
|
gl_FragColor = mix(current, clipped, historyWeight);
|
|
2413
2413
|
}
|
|
2414
|
-
`}a(
|
|
2414
|
+
`}a(_a,"buildVolumetricLightingTemporalShader");function Ca(){return`precision highp float;
|
|
2415
2415
|
precision highp int;
|
|
2416
2416
|
|
|
2417
2417
|
varying vec2 vUV;
|
|
@@ -2427,8 +2427,8 @@ uniform vec2 volBlurParams;
|
|
|
2427
2427
|
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
2428
2428
|
uniform vec4 volPassParams;
|
|
2429
2429
|
|
|
2430
|
-
${
|
|
2431
|
-
${
|
|
2430
|
+
${ze}
|
|
2431
|
+
${pt}
|
|
2432
2432
|
|
|
2433
2433
|
void main(void) {
|
|
2434
2434
|
// Nothing to draw this frame: the composition doesn't read the scattering buffer.
|
|
@@ -2473,7 +2473,7 @@ void main(void) {
|
|
|
2473
2473
|
|
|
2474
2474
|
gl_FragColor = result / totalWeight;
|
|
2475
2475
|
}
|
|
2476
|
-
`}a(
|
|
2476
|
+
`}a(Ca,"buildVolumetricLightingBlurShader");function Da(){return`precision highp float;
|
|
2477
2477
|
precision highp int;
|
|
2478
2478
|
|
|
2479
2479
|
varying vec2 vUV;
|
|
@@ -2489,8 +2489,8 @@ uniform vec4 volComposeParams;
|
|
|
2489
2489
|
// (1 when the pipeline has nothing to draw this frame, unused, unused, unused)
|
|
2490
2490
|
uniform vec4 volPassParams;
|
|
2491
2491
|
|
|
2492
|
-
${
|
|
2493
|
-
${
|
|
2492
|
+
${ze}
|
|
2493
|
+
${pt}
|
|
2494
2494
|
|
|
2495
2495
|
float volBayer8(vec2 p) {
|
|
2496
2496
|
vec2 p1 = mod(floor(p), 2.0);
|
|
@@ -2586,35 +2586,35 @@ void main(void) {
|
|
|
2586
2586
|
|
|
2587
2587
|
gl_FragColor = vec4(result, 1.0);
|
|
2588
2588
|
}
|
|
2589
|
-
`}a(Sa,"buildVolumetricLightingComposeShader");var Ho={};function Uo(i){if(!Ho[i]){if(Ho[i]=!0,i===ko.ShaderLanguage.WGSL){let e=Bo();z.ShaderStore.ShadersStoreWGSL[`${ct}PixelShader`]=e.linearDepth,z.ShaderStore.ShadersStoreWGSL[`${pt}PixelShader`]=e.scattering,z.ShaderStore.ShadersStoreWGSL[`${ht}PixelShader`]=e.temporal,z.ShaderStore.ShadersStoreWGSL[`${mt}PixelShader`]=e.blur,z.ShaderStore.ShadersStoreWGSL[`${dt}PixelShader`]=e.compose;return}z.ShaderStore.ShadersStore[`${ct}PixelShader`]=ua(),z.ShaderStore.ShadersStore[`${pt}PixelShader`]=fa(O),z.ShaderStore.ShadersStore[`${ht}PixelShader`]=ga(),z.ShaderStore.ShadersStore[`${mt}PixelShader`]=va(),z.ShaderStore.ShadersStore[`${dt}PixelShader`]=Sa()}}a(Uo,"registerVolumetricLightingShaders");var Ko=require("babylonjs"),Zo=require("babylonjs"),E=require("babylonjs"),G=require("babylonjs"),_e=require("babylonjs"),Yo=require("babylonjs"),qo=require("babylonjs"),Li=require("babylonjs"),Ce=require("babylonjs"),Qo=require("babylonjs"),Wo=new G.Vector3(0,0,1),Xo=new G.Vector3(0,0,-1),ya=32,ba="volumetricLighting_",$o=["resolutionScale","blurPasses","temporalAccumulation"],xa=1,_a=.05,Ca=.6180339887498949,Da=32,La=["volInverseViewProjection","volViewProjection","volCameraPosition","volCameraForward","volCameraMinMaxZ","volDepthRatio","volFrameIndex","volTemporalOffset","volFogInfos","volFogColor","volLinearFogEps","volMedium","volScreenShadowParams","volAmbient","volParams","volPassParams","volLightData","volLightDiffuse","volLightDirection","volLightFalloff","volShadowLightData","volShadowLightDiffuse","volShadowLightDirection","volShadowLightFalloff","volShadowInfo","volShadowMatrix","volCsmLightData","volCsmLightDiffuse","volCsmLightDirection","volCsmLightFalloff","volCsmInfo","volCsmMatrices"],jo=["volCsmSampler"];for(let i=0;i<O;++i)jo.push(`volShadowSampler${i}`);var Pa=["volCameraMinMaxZ","volDepthRatio","volInverseViewProjection","volCameraPosition","volCameraForward","volPreviousViewProjection","volTemporalParams","volTemporalMotion"],q=class i extends Qo.PostProcessRenderPipeline{static{a(this,"VolumetricLightingRenderingPipeline")}static SceneColorEffectName="VolumetricLightingSceneColorEffect";static ScatteringEffectName="VolumetricLightingScatteringEffect";static TemporalEffectName="VolumetricLightingTemporalEffect";static BlurEffectName="VolumetricLightingBlurEffect";static ComposeEffectName="VolumetricLightingComposeEffect";static GetDefaultFogEnd(e,t){return 1/i.GetDefaultFogDensity(e,t)}static GetDefaultFogDensity(e,t){let o=0;if(e.meshes.length){let r=e.getWorldExtends(),n=r.max.subtract(r.min).length();isFinite(n)&&(o=n)}return o<.001&&(o=Math.max(t.globalPosition.length(),t.maxZ*.001,1)),Math.min(1,Math.max(1e-5,1/Math.max(.001,o)))}static IsSupported(e){return e.isWebGPU?!0:(e.webGLVersion??0)>=2}static GetShaderLanguage(e){return e.isWebGPU?Li.ShaderLanguage.WGSL:Li.ShaderLanguage.GLSL}_scene;_camera;_configuration;_configurationProxy;_textureType;_shaderLanguage;_ldrEncode;_linearDepthType;_linearDepthPacked;_msaaSamples=1;_msaaSamplesAssigned=!1;_depthSource=0;_depthRenderer=null;_ownsDepthRenderer=!1;_depthMapRenderedWithCamera=!1;_depthMode=0;_prePassConfiguration=_i();_linearDepthPostProcess=null;_scatteringPostProcess=null;_temporalPostProcess=null;_blurPostProcesses=[];_composePostProcess=null;_temporalSamplesDivider=tt;_temporalClippingWidth=xa;_temporalMotionTolerance=_a;_previousCameraPosition=new G.Vector3;_historyTextures=[null,null];_historyFrames=[-1,-1];_historyEmpty=[!1,!1];_historyIndex=0;_temporalFrame=0;_previousViewProjection=G.Matrix.Identity();_previousViewProjectionRelative=G.Matrix.Identity();_cameraTranslation=G.Matrix.Identity();_selection=null;_budget;_linearDepthDefines="";_scatteringDefines="";_temporalDefines="";_blurDefines="";_composeDefines="";_frameCount=0;_lightsDirty=!0;_disposed=!1;_idle=!1;_depthWarmup=new Set;_beforeCameraRenderObserver=null;_afterCameraRenderObserver=null;_lightAddedObserver=null;_lightRemovedObserver=null;_meshAddedObserver=null;_meshRemovedObserver=null;_inverseViewProjection=G.Matrix.Identity();_temporaryVector=new G.Vector3;_temporaryColor=new Zo.Color3;_lightData=new Float32Array(Z*4);_lightDiffuse=new Float32Array(Z*4);_lightDirection=new Float32Array(Z*4);_lightFalloff=new Float32Array(Z*4);_shadowLightData=new Float32Array(O*4);_shadowLightDiffuse=new Float32Array(O*4);_shadowLightDirection=new Float32Array(O*4);_shadowLightFalloff=new Float32Array(O*4);_shadowInfo=new Float32Array(O*4);_shadowMatrices=new Float32Array(O*16);_csmLightData=new Float32Array(4);_csmLightDiffuse=new Float32Array(4);_csmLightDirection=new Float32Array(4);_csmLightFalloff=new Float32Array(4);_csmMatrices=new Float32Array(64);constructor(e,t,o,r){super(t.getEngine(),e),this._shaderLanguage=i.GetShaderLanguage(t.getEngine()),Uo(this._shaderLanguage),this._scene=t,this._camera=o,this._configuration=be({...it(),fogDensity:r?.fogDensity??i.GetDefaultFogDensity(t,o),fogEnd:r?.fogEnd??i.GetDefaultFogEnd(t,o),screenSpaceShadowMaxDistance:r?.screenSpaceShadowMaxDistance??i.GetDefaultFogEnd(t,o),...r}),this._configurationProxy=new Proxy(this._configuration,{set:a((s,c,h)=>{let m=c;return s[m]===h||(s[m]=h,this._onConfigurationChanged(m)),!0},"set")});let n=t.getEngine(),l=n.getCaps(),p=l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering;this._textureType=p?E.Constants.TEXTURETYPE_HALF_FLOAT:E.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._ldrEncode=!p,this._linearDepthType=l.textureHalfFloatRender?E.Constants.TEXTURETYPE_HALF_FLOAT:l.textureFloatRender?E.Constants.TEXTURETYPE_FLOAT:E.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._linearDepthPacked=this._linearDepthType===E.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._budget=Ve(n,this._configuration),this._depthSource=at(t),this._setupDepthSource(),this._buildRenderEffects(),t.postProcessRenderPipelineManager.addPipeline(this),t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name,o),this._beforeCameraRenderObserver=t.onBeforeCameraRenderObservable.add(s=>{s===this._camera&&(this._updateDepthSource(),this._updateSelection(),this._warmUpDepthRenderer())}),this._afterCameraRenderObserver=t.onAfterCameraRenderObservable.add(s=>{s===this._camera&&this._setDepthMapRenderedWithCamera(!1)}),this._lightAddedObserver=t.onNewLightAddedObservable.add(()=>this.markLightsDirty()),this._lightRemovedObserver=t.onLightRemovedObservable.add(()=>this.markLightsDirty()),this._meshAddedObserver=t.onNewMeshAddedObservable.add(s=>{this._ownsDepthRenderer&&this._depthWarmup.add(s)}),this._meshRemovedObserver=t.onMeshRemovedObservable.add(s=>this._depthWarmup.delete(s))}get isDisposed(){return this._disposed}get scene(){return this._scene}get camera(){return this._camera}get configuration(){return this._configurationProxy}get isIdle(){return this._idle}get depthSource(){return this._depthSource}get msaaSamples(){return this._msaaSamples}set msaaSamples(e){this._msaaSamples=e,this._msaaSamplesAssigned=!0,this._applyMsaaSamples()}getStats(){return this._selection?.stats??null}getBudget(){return this._budget}getClassName(){return"VolumetricLightingRenderingPipeline"}markLightsDirty(){this._lightsDirty=!0}applyConfiguration(e){let t=be({...this._configuration,...e}),o=$o.some(r=>t[r]!==this._configuration[r]);Object.assign(this._configuration,t),this._budget=Ve(this._scene.getEngine(),this._configuration),this._lightsDirty=!0,o&&this._rebuildRenderEffects()}serializeConfiguration(){return{...this._configuration,fogColor:this._configuration.fogColor.slice(),ambientColor:this._configuration.ambientColor.slice()}}dispose(){if(this._disposed)return;this._disposed=!0,this._scene.onBeforeCameraRenderObservable.remove(this._beforeCameraRenderObserver),this._scene.onAfterCameraRenderObservable.remove(this._afterCameraRenderObserver),this._scene.onNewLightAddedObservable.remove(this._lightAddedObserver),this._scene.onLightRemovedObservable.remove(this._lightRemovedObserver),this._scene.onNewMeshAddedObservable.remove(this._meshAddedObserver),this._scene.onMeshRemovedObservable.remove(this._meshRemovedObserver),this._beforeCameraRenderObserver=null,this._afterCameraRenderObserver=null,this._lightAddedObserver=null,this._lightRemovedObserver=null,this._meshAddedObserver=null,this._meshRemovedObserver=null;let e=this._cameras.slice();this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this.name,e),this._disposePostProcesses(e),this._releaseDepthSource(),this._selection=null,this._scene.postProcessRenderPipelineManager.removePipeline(this.name),super.dispose()}_onConfigurationChanged(e){(e==="maxLights"||e==="maxShadowedLights")&&(this._budget=Ve(this._scene.getEngine(),this._configuration)),this._lightsDirty=!0,$o.includes(e)&&this._rebuildRenderEffects()}_setupDepthSource(){switch(this._depthSource){case 2:this._depthMode=1;break;case 1:this._ensureGeometryBufferDepth(),this._depthMode=1;break;default:this._setupDepthRenderer();break}this._applyPrePassConfiguration(),this._applyMsaaSamples()}_releaseDepthSource(){this._ownsDepthRenderer&&this._depthRenderer&&(this._setDepthMapRenderedWithCamera(!1),this._depthRenderer.dispose()),this._depthRenderer=null,this._ownsDepthRenderer=!1,this._depthWarmup.clear(),this._linearDepthPostProcess&&(this._linearDepthPostProcess._prePassEffectConfiguration=void 0)}_updateDepthSource(){if(this._disposed)return;let e=at(this._scene);if(e===this._depthSource){e===1&&this._ensureGeometryBufferDepth(),e===0&&this._hasDepthRendererOfCameraChanged()&&(this._releaseDepthSource(),this._setupDepthSource(),this._lightsDirty=!0);return}this._releaseDepthSource(),this._depthSource=e,this._setupDepthSource(),xe(this._scene)?.markAsDirty(),this._lightsDirty=!0}_ensureGeometryBufferDepth(){let e=Ne(this._scene);e&&!e.enableDepth&&(e.enableDepth=!0)}_applyPrePassConfiguration(){this._linearDepthPostProcess&&this._depthSource===2&&(this._linearDepthPostProcess._prePassEffectConfiguration=this._prePassConfiguration)}_applyMsaaSamples(){if(this._msaaSamplesAssigned){if(this._depthSource===2){let e=xe(this._scene);if(e){e.samples=this._msaaSamples;return}}!this._enableMSAAOnFirstPostProcess(this._msaaSamples)&&this._msaaSamples>1&&console.warn("Volumetric lighting: MSAA is not supported by the engine, the requested samples are ignored.")}}_setupDepthRenderer(){let e=this._scene,t=e._depthRenderer?.[this._camera.uniqueId];if(this._ownsDepthRenderer=!t,t)this._depthRenderer=t;else{let o=this._scene.getEngine().getCaps(),r=o.textureHalfFloatRender?E.Constants.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender?E.Constants.TEXTURETYPE_FLOAT:E.Constants.TEXTURETYPE_UNSIGNED_BYTE;this._depthRenderer=new Yo.DepthRenderer(this._scene,r,this._camera,!1,E.Constants.TEXTURE_NEAREST_SAMPLINGMODE,!1,"VolumetricLightingDepth"),this._depthRenderer.enabled=!this._idle,e._depthRenderer??={},e._depthRenderer[`${ba}${this._scene.getUniqueId()}`]=this._depthRenderer,this._scene.meshes.forEach(n=>this._depthWarmup.add(n))}this._depthRenderer.isPacked?this._depthMode=2:this._depthRenderer.clearColor.r===0?this._depthMode=1:this._depthMode=0}_hasDepthRendererOfCameraChanged(){let e=this._scene._depthRenderer?.[this._camera.uniqueId];return this._ownsDepthRenderer?!!e:e!==this._depthRenderer}_setDepthMapRenderedWithCamera(e){if(e===this._depthMapRenderedWithCamera||!this._depthRenderer)return;this._depthMapRenderedWithCamera=e;let t=this._camera.customRenderTargets,o=this._depthRenderer.getDepthMap(),r=t.indexOf(o);e&&r===-1?t.push(o):!e&&r!==-1&&t.splice(r,1)}_bindDepthUniforms(e){let t=this._camera,o=this._scene.getEngine();if(e.setFloat2("volCameraMinMaxZ",t.minZ,t.maxZ),this._depthMode===1){e.setFloat2("volDepthUnpack",1,0);return}let r=t.mode===Ko.Camera.ORTHOGRAPHIC_CAMERA,n=r?!o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?t.minZ:o.isNDCHalfZRange?0:t.minZ,l=r?o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:t.maxZ,p=this._scene.getProjectionMatrix().m,s=p[10],c=p[14];if(!s){e.setFloat2("volDepthUnpack",t.maxZ,0);return}let h=o.useReverseDepthBuffer?-1:1;e.setFloat2("volDepthUnpack",h*(n+l)/s,(-h*n-c)/s)}_getSamplingSteps(){return di(this._configuration,this._temporalSamplesDivider)}_getDitherMode(){let e=this._configuration;return e.temporalAccumulation&&e.ditherMode===0?2:e.ditherMode}_getEnvironment(){let e=this._configuration,t=this._getSamplingSteps(),o=0;return e.heightFogEnabled&&(o=e.fogMode===0?1:2),{depthMode:this._depthMode,ldrEncode:this._ldrEncode,reverseDepth:this._scene.getEngine().useReverseDepthBuffer,ndcHalfZ:this._scene.getEngine().isNDCHalfZRange,fogMode:e.fogMode,transmittance:o,linearDepthPacked:this._linearDepthPacked,arrayLightCapacity:this._budget.maxArrayLights,steps:t.steps,lightSteps:t.lightSteps}}_buildLinearDepthReadDefines(e){return e.linearDepthPacked?`#define VOL_LINEAR_DEPTH_PACKED
|
|
2590
|
-
`:""}_buildLinearDepthDefines(e){let
|
|
2591
|
-
`:e.depthMode===1&&(
|
|
2592
|
-
`),
|
|
2593
|
-
`,s+=`#define VOL_LIGHT_STEPS ${
|
|
2594
|
-
`,s+=`#define VOL_LOCAL_MAX_STEPS ${Math.max(
|
|
2595
|
-
`,s+=`#define VOL_DISTRIBUTION ${
|
|
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
|
|
2590
|
+
`:""}_buildLinearDepthDefines(e){let i=this._buildLinearDepthReadDefines(e);return e.depthMode===2?i+=`#define VOL_DEPTH_PACKED
|
|
2591
|
+
`:e.depthMode===1&&(i+=`#define VOL_DEPTH_VIEWZ
|
|
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}
|
|
2593
|
+
`,s+=`#define VOL_LIGHT_STEPS ${i.lightSteps}
|
|
2594
|
+
`,s+=`#define VOL_LOCAL_MAX_STEPS ${Math.max(i.lightSteps,i.steps)}
|
|
2595
|
+
`,s+=`#define VOL_DISTRIBUTION ${r.stepDistribution}
|
|
2596
2596
|
`,s+=`#define VOL_DITHER ${this._getDitherMode()}
|
|
2597
|
-
`,s+=`#define VOL_PCF_TAPS ${
|
|
2598
|
-
`,s+=`#define VOL_FOG_MODE ${
|
|
2599
|
-
`,s+=`#define VOL_TRANSMITTANCE ${
|
|
2600
|
-
`,(
|
|
2601
|
-
`),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${
|
|
2602
|
-
`,s+=`#define VOL_DEBUG ${
|
|
2603
|
-
`,s+=`#define VOL_MAX_ARRAY_LIGHTS ${
|
|
2597
|
+
`,s+=`#define VOL_PCF_TAPS ${r.pcfTaps}
|
|
2598
|
+
`,s+=`#define VOL_FOG_MODE ${i.fogMode}
|
|
2599
|
+
`,s+=`#define VOL_TRANSMITTANCE ${i.transmittance}
|
|
2600
|
+
`,(i.transmittance!==0||i.fogMode!==2)&&(s+=`#define VOL_OPTICAL_DEPTH
|
|
2601
|
+
`),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${Ea}
|
|
2602
|
+
`,s+=`#define VOL_DEBUG ${r.debugMode}
|
|
2603
|
+
`,s+=`#define VOL_MAX_ARRAY_LIGHTS ${i.arrayLightCapacity}
|
|
2604
2604
|
`,s+=`#define VOL_DIRECTIONAL_LIGHT_COUNT ${n}
|
|
2605
|
-
`,s+=`#define VOL_LOCAL_ARRAY_LIGHTS ${
|
|
2606
|
-
`,s+=`#define VOL_SHADOW_SLOT_COUNT ${
|
|
2605
|
+
`,s+=`#define VOL_LOCAL_ARRAY_LIGHTS ${i.arrayLightCapacity>n?1:0}
|
|
2606
|
+
`,s+=`#define VOL_SHADOW_SLOT_COUNT ${o.length}
|
|
2607
2607
|
`,s+=`#define VOL_GLOBAL_LIGHT_COUNT ${n+p+(l?1:0)}
|
|
2608
|
-
`,
|
|
2609
|
-
`:
|
|
2610
|
-
`),
|
|
2611
|
-
`),
|
|
2612
|
-
`),
|
|
2613
|
-
`,s+=`#define VOL_SCREEN_SHADOW_STEPS ${
|
|
2614
|
-
`),
|
|
2615
|
-
`),
|
|
2616
|
-
`),
|
|
2617
|
-
`),
|
|
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}
|
|
2614
|
+
`),i.ldrEncode&&(s+=`#define VOL_LDR_ENCODE
|
|
2615
|
+
`),i.reverseDepth&&(s+=`#define VOL_REVERSE_DEPTH
|
|
2616
|
+
`),i.ndcHalfZ&&(s+=`#define VOL_NDC_HALF_Z
|
|
2617
|
+
`),o.forEach((c,h)=>{s+=`#define VOL_SHADOW_KIND${h} ${c.shadow.kind}
|
|
2618
2618
|
`,s+=`#define VOL_SHADOW_MODE${h} ${c.shadow.mode}
|
|
2619
2619
|
`,s+=`#define VOL_SHADOW_LOCAL${h} ${c.shadow.local?1:0}
|
|
2620
2620
|
`,c.shadow.packed&&(s+=`#define VOL_SHADOW_PACKED${h}
|
|
@@ -2623,6 +2623,6 @@ void main(void) {
|
|
|
2623
2623
|
`,s+=`#define VOL_CSM_KIND ${l.kind===1?1:0}
|
|
2624
2624
|
`,l.packed&&(s+=`#define VOL_CSM_PACKED
|
|
2625
2625
|
`)),s}_buildTemporalDefines(e){return this._buildLinearDepthReadDefines(e)}_buildBlurDefines(e){return`${this._buildLinearDepthReadDefines(e)}#define VOL_BLUR_RADIUS ${this._configuration.blurRadius}
|
|
2626
|
-
`}_buildComposeDefines(e){let
|
|
2627
|
-
`,e.ldrEncode&&(
|
|
2628
|
-
`),t}_createPostProcess(e){let t=new qo.PostProcess(e.name,e.shaderName,e.uniforms,e.samplers,e.ratio,null,e.samplingMode,this._scene.getEngine(),!1,e.defines,e.textureType,void 0,void 0,!1,e.textureFormat,this._shaderLanguage);return t.autoClear=e.autoClear??!1,t.alphaMode=E.Constants.ALPHA_DISABLE,t}_buildRenderEffects(){let e=this._scene.getEngine(),t=this._configuration,o=this._getEnvironment();this._linearDepthDefines=this._buildLinearDepthDefines(o),this._scatteringDefines=this._buildScatteringDefines(this._selection,o),this._temporalDefines=this._buildTemporalDefines(o),this._blurDefines=this._buildBlurDefines(o),this._composeDefines=this._buildComposeDefines(o),this._linearDepthPostProcess=this._createPostProcess({name:"VolumetricLightingLinearDepth",shaderName:ct,uniforms:["volCameraMinMaxZ","volDepthUnpack","volPassParams"],samplers:["depthSampler"],ratio:1,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._linearDepthDefines,autoClear:!0}),this._linearDepthPostProcess.onApplyObservable.add(r=>this._bindLinearDepth(r)),this._applyPrePassConfiguration(),this._scatteringPostProcess=this._createPostProcess({name:"VolumetricLightingScattering",shaderName:pt,uniforms:La,samplers:jo,ratio:1,samplingMode:_e.Texture.NEAREST_SAMPLINGMODE,textureType:this._linearDepthType,textureFormat:this._linearDepthPacked?E.Constants.TEXTUREFORMAT_RGBA:E.Constants.TEXTUREFORMAT_R,defines:this._scatteringDefines}),this._scatteringPostProcess.onApplyObservable.add(r=>this._bindScattering(r)),this._temporalPostProcess=null,t.temporalAccumulation&&(this._temporalPostProcess=this._createPostProcess({name:"VolumetricLightingTemporal",shaderName:ht,uniforms:Pa,samplers:["volHistorySampler","volLinearDepthSampler"],ratio:t.resolutionScale,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._temporalDefines}),this._temporalPostProcess.onActivateObservable.add(()=>this._prepareHistory()),this._temporalPostProcess.onApplyObservable.add(r=>this._bindTemporal(r))),this._blurPostProcesses=[];for(let r=0;r<t.blurPasses;++r){let n=this._createPostProcess({name:`VolumetricLightingBlur${r}`,shaderName:mt,uniforms:["volCameraMinMaxZ","volDepthRatio","volBlurDirection","volBlurParams","volPassParams"],samplers:["volLinearDepthSampler"],ratio:t.resolutionScale,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._blurDefines});n.onApplyObservable.add(l=>this._bindBlur(l,r)),this._blurPostProcesses.push(n)}this._composePostProcess=this._createPostProcess({name:"VolumetricLightingCompose",shaderName:dt,uniforms:["volCameraMinMaxZ","volDepthRatio","volComposeParams","volPassParams"],samplers:["volSceneSampler","volLinearDepthSampler"],ratio:t.resolutionScale,samplingMode:_e.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._composeDefines}),this._composePostProcess.onApplyObservable.add(r=>this._bindCompose(r)),this.addEffect(new Ce.PostProcessRenderEffect(e,i.SceneColorEffectName,()=>this._linearDepthPostProcess,!0)),this.addEffect(new Ce.PostProcessRenderEffect(e,i.ScatteringEffectName,()=>this._scatteringPostProcess,!0)),this._temporalPostProcess&&this.addEffect(new Ce.PostProcessRenderEffect(e,i.TemporalEffectName,()=>this._temporalPostProcess,!0)),this._blurPostProcesses.length&&this.addEffect(new Ce.PostProcessRenderEffect(e,i.BlurEffectName,()=>this._blurPostProcesses,!0)),this.addEffect(new Ce.PostProcessRenderEffect(e,i.ComposeEffectName,()=>this._composePostProcess,!0)),this._applyMsaaSamples()}_disposePostProcesses(e){[this._linearDepthPostProcess,this._scatteringPostProcess,this._temporalPostProcess,...this._blurPostProcesses,this._composePostProcess].forEach(o=>{o&&(e.forEach(r=>o.dispose(r)),o.dispose())}),this._linearDepthPostProcess=null,this._scatteringPostProcess=null,this._temporalPostProcess=null,this._blurPostProcesses=[],this._composePostProcess=null,this._disposeHistory()}_disposeHistory(){this._historyTextures.forEach(e=>e?.dispose()),this._historyTextures=[null,null],this._historyFrames=[-1,-1]}_prepareHistory(){let e=this._temporalPostProcess,t=this._blurPostProcesses[0]??this._composePostProcess;if(!e||!t)return;++this._temporalFrame;let o=e.width,r=e.height,n=this._historyTextures[0];if(!n||n.width!==o||n.height!==r){this._disposeHistory();let l=this._scene.getEngine();for(let p=0;p<2;++p)this._historyTextures[p]=l.createRenderTargetTexture({width:o,height:r},{generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,type:this._textureType,format:E.Constants.TEXTUREFORMAT_RGBA,samplingMode:E.Constants.TEXTURE_BILINEAR_SAMPLINGMODE,label:`VolumetricLightingHistory${p}`})}this._historyIndex^=1,t.inputTexture=this._historyTextures[this._historyIndex]}_rebuildRenderEffects(){if(this._disposed)return;let e=this._scene.postProcessRenderPipelineManager,t=this._cameras.slice();try{e.detachCamerasFromRenderPipeline(this.name,t),this._disposePostProcesses(t),Object.keys(this._renderEffects).forEach(o=>{delete this._renderEffects[o]}),this._buildRenderEffects()}catch(o){console.error("Failed to rebuild the volumetric lighting rendering pipeline.",o)}finally{try{e.attachCamerasToRenderPipeline(this.name,t)}catch(o){console.error("Failed to re-attach the cameras to the volumetric lighting rendering pipeline.",o)}}this._lightsDirty=!0}_updateSelection(){if(this._disposed||!this._scatteringPostProcess||(++this._frameCount,!(this._lightsDirty||!this._selection||this._frameCount%this._configuration.selectionRefreshRate===0)))return;this._lightsDirty=!1;let t=this._getEnvironment(),o=yi(this._scene,this._camera,this._configuration,this._budget,this._selection);this._selection=o,this._updateIdleState(o);let r=this._buildScatteringDefines(o,t);r!==this._scatteringDefines&&(this._scatteringDefines=r,this._scatteringPostProcess.updateEffect(r));let n=this._buildTemporalDefines(t);n!==this._temporalDefines&&(this._temporalDefines=n,this._temporalPostProcess?.updateEffect(n));let l=this._buildLinearDepthDefines(t);l!==this._linearDepthDefines&&(this._linearDepthDefines=l,this._linearDepthPostProcess?.updateEffect(l));let p=this._buildBlurDefines(t);p!==this._blurDefines&&(this._blurDefines=p,this._blurPostProcesses.forEach(c=>c.updateEffect(p)));let s=this._buildComposeDefines(t);s!==this._composeDefines&&(this._composeDefines=s,this._composePostProcess?.updateEffect(s))}_updateIdleState(e){let t=this._configuration,o=t.ambientColor,r=e.shadowed.length>0||e.unshadowed.length>0||!!e.csm,n=t.ambientIntensity>0&&(o[0]>0||o[1]>0||o[2]>0),l=!r&&!n&&t.extinctionAmount<=0&&t.debugMode===0;l!==this._idle&&(this._idle=l,this._ownsDepthRenderer&&this._depthRenderer&&(this._depthRenderer.enabled=!l,this._setDepthMapRenderedWithCamera(!l)))}_warmUpDepthRenderer(){let e=this._depthRenderer;if(!this._idle||!this._ownsDepthRenderer||!e||!this._depthWarmup.size)return;let t=this._scene.getEngine().getCaps().instancedArrays,o=[],r=ya;for(let n of this._depthWarmup){if(r--<=0)break;if(this._depthWarmup.delete(n),n.isDisposed()||!n.subMeshes?.length)continue;let l=n.getClassName(),p=n.hasThinInstances||l==="InstancedMesh"||l==="InstancedLinesMesh"||t&&(n.instances?.length??0)>0,s=!0;n.subMeshes.forEach(c=>{let h=c.getMaterial();h&&!h.disableDepthWrite&&c.verticesCount>0&&!e.isReady(c,p)&&(s=!1)}),s||o.push(n)}o.forEach(n=>this._depthWarmup.add(n))}_writeLight(e,t,o,r,n,l){let{light:p,config:s}=e,c=t*4;ie(p)?(Fe(p,this._temporaryVector),o[c]=-this._temporaryVector.x,o[c+1]=-this._temporaryVector.y,o[c+2]=-this._temporaryVector.z,o[c+3]=1):(rt(p,this._temporaryVector).subtractInPlace(this._camera.globalPosition),o[c]=this._temporaryVector.x,o[c+1]=this._temporaryVector.y,o[c+2]=this._temporaryVector.z,o[c+3]=ae(p)?2:0),s.useCustomColor?this._temporaryColor.set(s.color[0],s.color[1],s.color[2]):this._temporaryColor.copyFrom(p.diffuse);let h=p.getScaledIntensity()*s.volumeIntensity*1e-5;r[c]=this._temporaryColor.r*h,r[c+1]=this._temporaryColor.g*h,r[c+2]=this._temporaryColor.b*h,r[c+3]=s.anisotropy,ae(p)?(Fe(p,this._temporaryVector),n[c]=this._temporaryVector.x,n[c+1]=this._temporaryVector.y,n[c+2]=this._temporaryVector.z,n[c+3]=Math.cos(p.angle*.5),l[c+1]=p.exponent):(n[c]=0,n[c+1]=0,n[c+2]=1,n[c+3]=-1,l[c+1]=1),l[c]=nt(p,s,this._configuration),l[c+2]=s.castVolumetricShadows?1:0,l[c+3]=s.shadowDarkness}_bindLinearDepth(e){e.setFloat4("volPassParams",this._idle?1:0,0,0,0);let t=null;switch(this._depthSource){case 2:{let o=xe(this._scene);t=o?Ci(o):null;break}case 1:{let o=Ne(this._scene);t=o?Di(o):null;break}default:t=this._depthRenderer?.getDepthMap()??null;break}t&&(e.setTexture("depthSampler",t),this._bindDepthUniforms(e))}_bindScattering(e){let t=this._scene,o=this._camera,r=this._configuration,n=this._selection;if(!n)return;e.setFloat4("volPassParams",this._idle?1:0,0,0,0),this._inverseViewProjection.copyFrom(t.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",o.globalPosition),o.getDirectionToRef(t.useRightHandedSystem?Xo:Wo,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize()),e.setFloat2("volCameraMinMaxZ",o.minZ,o.maxZ),e.setFloat("volFrameIndex",t.getRenderId()%64),e.setFloat("volTemporalOffset",this._frameCount*Ca%1),this._bindDepthRatio(e),e.setFloat4("volFogInfos",r.fogMode,r.fogStart,r.fogEnd,r.fogDensity),this._temporaryColor.set(r.fogColor[0],r.fogColor[1],r.fogColor[2]),e.setColor3("volFogColor",this._temporaryColor),e.setFloat("volLinearFogEps",Math.max((r.fogEnd-r.fogStart)*.02,1e-4)),e.setFloat4("volMedium",r.albedo,r.heightFogBaseHeight,r.heightFogFalloff,0),r.screenSpaceShadows&&(e.setMatrix("volViewProjection",t.getTransformMatrix()),e.setFloat4("volScreenShadowParams",r.screenSpaceShadowMaxDistance,r.screenSpaceShadowBias,r.screenSpaceShadowThickness,0)),this._temporaryColor.set(r.ambientColor[0],r.ambientColor[1],r.ambientColor[2]).scaleInPlace(r.ambientIntensity),e.setColor3("volAmbient",this._temporaryColor);let l=n.unshadowed.length,p=l-n.directionalCount,s=r.temporalAccumulation?1:r.ditherStrength;e.setFloat4("volParams",r.maxDistance,s,r.lightExtinctionClamp,p);for(let c=0;c<l;++c)this._writeLight(n.unshadowed[c],c,this._lightData,this._lightDiffuse,this._lightDirection,this._lightFalloff);if(l){let c=l*4;e.setFloatArray4("volLightData",this._lightData.subarray(0,c)),e.setFloatArray4("volLightDiffuse",this._lightDiffuse.subarray(0,c)),e.setFloatArray4("volLightDirection",this._lightDirection.subarray(0,c)),e.setFloatArray4("volLightFalloff",this._lightFalloff.subarray(0,c))}if(n.shadowed.forEach((c,h)=>{this._writeLight(c.candidate,h,this._shadowLightData,this._shadowLightDiffuse,this._shadowLightDirection,this._shadowLightFalloff);let{generator:m,kind:d,mode:u,mapSize:S}=c.shadow,g=c.candidate.light,y=h*4;this._shadowLightFalloff[y+2]=m.frustumEdgeFalloff;let C=g.getDepthMinZ?.(t.activeCamera)??0,L=g.getDepthMaxZ?.(t.activeCamera)??1;this._shadowInfo[y]=m.getDarkness(),this._shadowInfo[y+1]=d===1?1/S:u===0?0:m.depthScale,this._shadowInfo[y+2]=C,this._shadowInfo[y+3]=C+L,m.getTransformMatrix().copyToArray(this._shadowMatrices,h*16);let x=m.getShadowMapForRendering();d===1?e.setDepthStencilTexture(`volShadowSampler${h}`,x):e.setTexture(`volShadowSampler${h}`,x)}),n.shadowed.length){let c=n.shadowed.length*4;e.setFloatArray4("volShadowLightData",this._shadowLightData.subarray(0,c)),e.setFloatArray4("volShadowLightDiffuse",this._shadowLightDiffuse.subarray(0,c)),e.setFloatArray4("volShadowLightDirection",this._shadowLightDirection.subarray(0,c)),e.setFloatArray4("volShadowLightFalloff",this._shadowLightFalloff.subarray(0,c)),e.setFloatArray4("volShadowInfo",this._shadowInfo.subarray(0,c)),e.setMatrices("volShadowMatrix",this._shadowMatrices.subarray(0,n.shadowed.length*16))}if(n.csm){let{candidate:c,generator:h,cascades:m,kind:d}=n.csm,u=c.light;this._writeLight(c,0,this._csmLightData,this._csmLightDiffuse,this._csmLightDirection,this._csmLightFalloff),e.setFloat4("volCsmLightData",this._csmLightData[0],this._csmLightData[1],this._csmLightData[2],this._csmLightData[3]),e.setFloat4("volCsmLightDiffuse",this._csmLightDiffuse[0],this._csmLightDiffuse[1],this._csmLightDiffuse[2],this._csmLightDiffuse[3]),e.setFloat4("volCsmLightDirection",this._csmLightDirection[0],this._csmLightDirection[1],this._csmLightDirection[2],this._csmLightDirection[3]),e.setFloat4("volCsmLightFalloff",this._csmLightFalloff[0],this._csmLightFalloff[1],h.frustumEdgeFalloff,c.config.shadowDarkness);let S=u.getDepthMinZ?.(t.activeCamera)??1,g=u.getDepthMaxZ?.(t.activeCamera)??1,y=h.getShadowMap()?.getSize().width??1024;e.setFloat4("volCsmInfo",h.getDarkness(),1/y,S,S+g);for(let L=0;L<m;++L)h.getCascadeTransformMatrix(L)?.copyToArray(this._csmMatrices,L*16);e.setMatrices("volCsmMatrices",this._csmMatrices.subarray(0,m*16));let C=h.getShadowMapForRendering();d===1?e.setDepthStencilTexture("volCsmSampler",C):e.setTexture("volCsmSampler",C)}}_bindDepthRatio(e){let t=this._scatteringPostProcess,o=this._temporalPostProcess??this._blurPostProcesses[0]??this._composePostProcess,r=t&&t.width>0?t.width:1,n=t&&t.height>0?t.height:1,l=o&&o.width>0?o.width:r,p=o&&o.height>0?o.height:n;e.setFloat2("volDepthRatio",r/l,n/p)}_bindTemporal(e){let t=this._scene,o=this._camera,r=this._configuration;if(!this._scatteringPostProcess)return;let n=this._historyIndex^1,l=this._historyTextures[n];e._bindTexture("volHistorySampler",l?.texture??t.getEngine().emptyTexture),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",o.minZ,o.maxZ),this._bindDepthRatio(e),this._inverseViewProjection.copyFrom(t.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",o.globalPosition),o.getDirectionToRef(t.useRightHandedSystem?Xo:Wo,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize());let p=o.globalPosition;G.Matrix.TranslationToRef(p.x,p.y,p.z,this._cameraTranslation),this._cameraTranslation.multiplyToRef(this._previousViewProjection,this._previousViewProjectionRelative),e.setMatrix("volPreviousViewProjection",this._previousViewProjectionRelative);let s=!this._idle&&!!l&&this._historyFrames[n]===this._temporalFrame-1,c=s?this._historyEmpty[n]?2:1:0;e.setFloat4("volTemporalParams",r.temporalAccumulationFactor,this._temporalClippingWidth,r.maxDistance,c);let h=s?G.Vector3.Distance(p,this._previousCameraPosition):0;e.setFloat2("volTemporalMotion",h,this._temporalMotionTolerance),this._historyFrames[this._historyIndex]=this._temporalFrame,this._historyEmpty[this._historyIndex]=this._idle,this._previousViewProjection.copyFrom(t.getTransformMatrix()),this._previousCameraPosition.copyFrom(p)}_bindBlur(e,t){this._scatteringPostProcess&&(e.setFloat4("volPassParams",this._idle?1:0,0,0,0),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e),e.setFloat2("volBlurDirection",t%2===0?1:0,t%2===0?0:1),e.setFloat2("volBlurParams",Math.max(this._configuration.blurRadius*.5,.5),this._configuration.blurDepthThreshold))}_bindCompose(e){if(!this._linearDepthPostProcess||!this._scatteringPostProcess)return;let t=this._configuration;e.setTextureFromPostProcess("volSceneSampler",this._linearDepthPostProcess),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat4("volPassParams",this._idle?1:0,0,0,0),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e);let o=this._ldrEncode?1/255:0;e.setFloat4("volComposeParams",t.intensity,t.extinctionAmount,t.upsampleDepthThreshold,o)}};var M=null,Jo=null;function Pi(){return Jo}a(Pi,"getVolumetricLightingRenderingPipelineConfiguration");function ze(i){Jo=i}a(ze,"setVolumetricLightingRenderingPipelineConfiguration");function wa(){return M?.isDisposed&&(M=null),M}a(wa,"getVolumetricLightingRenderingPipeline");function Ta(i){M=i}a(Ta,"setVolumetricLightingRenderingPipelineRef");function Oa(i){let e=i?.getEngine();return e?q.IsSupported(e):!1}a(Oa,"isVolumetricLightingSupported");function wi(){M&&(M.dispose(),M=null)}a(wi,"disposeVolumetricLightingRenderingPipeline");function er(i,e,t){return M=new q("VolumetricLightingRenderingPipeline",i,e),M.msaaSamples=t?.msaaSamples??1,M}a(er,"createVolumetricLightingRenderingPipeline");function Ti(){return M?M.serializeConfiguration():null}a(Ti,"serializeVolumetricLightingRenderingPipeline");function Oi(i,e,t,o){let r=M??er(i,e,o);r.msaaSamples=o?.msaaSamples??1;let n={...t};return n.fogDensity===void 0&&(n.fogDensity=q.GetDefaultFogDensity(r.scene,r.camera)),n.fogEnd===void 0&&(n.fogEnd=q.GetDefaultFogEnd(r.scene,r.camera)),n.screenSpaceShadowMaxDistance===void 0&&(n.screenSpaceShadowMaxDistance=q.GetDefaultFogEnd(r.scene,r.camera)),r.applyConfiguration(be(n)),r}a(Oi,"parseVolumetricLightingRenderingPipeline");function Ea(){M?.markLightsDirty()}a(Ea,"markVolumetricLightsDirty");var ut=require("babylonjs");function Aa(i){ve.set(i,Yt()),ue.set(i,Ht()),fe.set(i,Wt()),Se.set(i,ei()),ye.set(i,ri()),ge.set(i,jt()),ze(Ti())}a(Aa,"saveRenderingConfigurationForCamera");function Ei(i,e,t){Zt(),zt(i.getScene()),Ut(),Jt(),wi(),oi(),$t();let o=ve.get(i);o&&!t?.ssao2Disabled&&qt(i.getScene(),i,o,t);let r=Pi();r&&!t?.volumetricLightingDisabled&&Oi(i.getScene(),i,r,t);let n=ue.get(i);n&&!t?.vlsDisabled&&kt(i.getScene(),n,t);let l=fe.get(i);l&&!t?.ssrDisabled&&Xt(i.getScene(),i,l,t);let p=Se.get(i);p&&!t?.motionBlurDisabled&&ti(i.getScene(),i,p,t);let s=ye.get(i);s&&!t?.defaultPipelineDisabled&&ni(i.getScene(),i,s,e,t);let c=ge.get(i);c&&!t?.taaDisabled&&Kt(i.getScene(),i,c,t)}a(Ei,"applyRenderingConfigurationForCamera");function Ia(i){let e=i.getCaps();return e.textureHalfFloatRender||e.textureFloatRender}a(Ia,"canUseHdr");function K(i){let e=i.getCaps();return e.textureHalfFloatRender?ut.Constants.TEXTURETYPE_HALF_FLOAT:e.textureFloatRender?ut.Constants.TEXTURETYPE_FLOAT:ut.Constants.TEXTURETYPE_UNSIGNED_BYTE}a(K,"getHdrTextureType");var He=require("babylonjs"),tr=require("babylonjs");function ir(i){let e=i.metadata?.physicsAggregate;if(!e)return;let t;F(i)?t=i:Ie(i)&&(t=i.sourceMesh);let o=new tr.PhysicsAggregate(i,e.shape.type,{mesh:t,mass:e.massProperties.mass});o.body.setMassProperties({mass:e.massProperties.mass,inertia:e.massProperties.inertia?He.Vector3.FromArray(e.massProperties.inertia):void 0,centerOfMass:e.massProperties.centerOfMass?He.Vector3.FromArray(e.massProperties.centerOfMass):void 0,inertiaOrientation:e.massProperties.inertiaOrientation?He.Quaternion.FromArray(e.massProperties.inertiaOrientation):void 0}),o.shape.density=e.shape.density,o.body.setMotionType(e.body.motionType),o.shape.material=e.material,i.physicsAggregate=o,i.metadata.physicsAggregate=void 0}a(ir,"configurePhysicsAggregate");function or(i,e){let t=e?.rendering;e.volumetricLightingRenderingPipelineConfiguration&&ze(e.volumetricLightingRenderingPipelineConfiguration),(Array.isArray(t)?t:[]).forEach(r=>{let n=i.getCameraById(r.cameraId);n&&(r.ssao2RenderingPipeline&&ve.set(n,r.ssao2RenderingPipeline),r.vlsPostProcess&&ue.set(n,r.vlsPostProcess),r.ssrRenderingPipeline&&fe.set(n,r.ssrRenderingPipeline),r.motionBlurPostProcess&&Se.set(n,r.motionBlurPostProcess),r.defaultRenderingPipeline&&ye.set(n,r.defaultRenderingPipeline),r.taaRenderingPipeline&&ge.set(n,r.taaRenderingPipeline))})}a(or,"applyRenderingConfigurations");var rr=require("babylonjs");function De(i,e,t){return new Promise((o,r)=>{let n=new rr.WebRequest;n.open("GET",i),n.responseType=e,n.send(),n.addEventListener("progress",l=>{t?.({total:l.total,loaded:l.loaded})}),n.addEventListener("load",()=>{o(e==="text"?n.responseText:n.response)}),n.addEventListener("error",l=>r(l))})}a(De,"loadFile");async function k(i,e){let t=await De(i,"text",e);return JSON.parse(t)}a(k,"loadJsonFile");function Ai(i,e){let t=e.getNodeByName(i);if(t)return t;let o=e.lights.filter(r=>me(r));for(let r of o){let n=r.lights.find(l=>l.name===i);if(n)return n}return null}a(Ai,"getNodeByName");function Le(i,e){let t=e.getNodeById(i);if(t)return t;let o=e.lights.filter(r=>me(r));for(let r of o){let n=r.lights.find(l=>l.id===i);if(n)return n}return null}a(Le,"getNodeById");var ce=require("babylonjs"),nr=require("babylonjs");function Ii(i){let e=nr.Vector3.FromArray(i);return e.equals(ce.Axis.X)?ce.Axis.X:e.equals(ce.Axis.Y)?ce.Axis.Y:e.equals(ce.Axis.Z)?ce.Axis.Z:e}a(Ii,"parseAxis");var ar=require("babylonjs"),Q=require("babylonjs");function sr(i){return i.runtimeConfiguration.forEach(e=>{e.rotationAxis&&(e.rotationAxis=Ii(e.rotationAxis)),e.boneOffsetAxis&&(e.boneOffsetAxis=Ii(e.boneOffsetAxis))}),i}a(sr,"parseRagdollConfiguration");function Mi(i){let e={rootNodeId:i.rootNodeId,skeletonName:i.skeletonName,scalingFactor:i.scalingFactor,runtimeConfiguration:i.runtimeConfiguration.map(t=>({name:t.name,bones:t.bones,width:t.width,depth:t.depth,height:t.height,size:t.size,joint:t.joint,min:t.min,max:t.max,mass:t.mass??1,boxOffset:t.boxOffset,restitution:t.restitution??0,rotationAxis:t.rotationAxis?.slice(),boneOffsetAxis:t.boneOffsetAxis?.slice()}))};return sr(e)}a(Mi,"copyAndParseRagdollConfiguration");function Ma(i,e){let t=i.getConstraints(),r=i._skeleton?.getChildren()[0],n=[];if(e.forEach(p=>{(p.bone!==void 0?[p.bone]:p.bones).forEach(c=>{c!==r?.name&&n.push(p)})}),n.length!==t.length)return ar.Logger.Warn("Failed to apply the ragdoll joint limits: the constraints of the ragdoll don't match its configuration."),0;let l=0;return t.forEach((p,s)=>{let c=n[s];if((c.joint??Q.PhysicsConstraintType.HINGE)!==Q.PhysicsConstraintType.HINGE||c.min===void 0||c.max===void 0)return;let m=Math.min(c.min,c.max),d=Math.max(c.min,c.max),u=p._physicsPlugin;u&&(u.setAxisMode(p,Q.PhysicsConstraintAxis.ANGULAR_X,Q.PhysicsConstraintAxisLimitMode.LIMITED),u.setAxisMinLimit(p,Q.PhysicsConstraintAxis.ANGULAR_X,m*Math.PI/180),u.setAxisMaxLimit(p,Q.PhysicsConstraintAxis.ANGULAR_X,d*Math.PI/180),++l)}),l}a(Ma,"applyRagdollJointLimits");function Ra(i){return new Promise(e=>{setTimeout(()=>e(),i)})}a(Ra,"waitMs");async function Ri(i){for(;!i();)await Ra(150)}a(Ri,"waitUntil");function Vi(i){return i&&JSON.parse(JSON.stringify(i))}a(Vi,"cloneJSObject");var Ni=require("babylonjs"),ur=require("babylonjs"),ft=require("babylonjs"),fr=require("babylonjs"),gr=require("babylonjs"),vr=require("babylonjs"),oe=require("babylonjs"),lr=!1,cr=null,Pe=[],Fi=new Map;function Va(i,e){let t=(0,oe._GetAudioEngine)(null);return new vr._WebAudioStaticSound(i,t,e)}a(Va,"createSoundInstance");function pr(i){if(cr?.remove(),!Pe.length)return;let e=Ni.Vector3.Zero();cr=i.onBeforeRenderObservable.add(()=>{let t=(0,oe._GetAudioEngine)(null).listener.attachedNode;t&&(t.getWorldMatrix().getTranslationToRef(e),Pe.forEach(o=>{o.isEnabled(!1)&&o.autoUpdateSpatial&&o.sound?._isSpatial&&o.isPlaying()&&i.activeCamera&&Ni.Vector3.Distance(e,o.getAbsolutePosition())<=o.sound.spatial.maxDistance&&o.sound.spatial.update()}))})}a(pr,"registerUpdateSoundsObserver");function hr(i,e){e.onDisposeObservable.addOnce(()=>{let t=Pe.indexOf(i);t!==-1&&Pe.splice(t,1)})}a(hr,"registerSoundInstanceCleanup");function mr(i){i.sound&&hr(i,i.sound),i.onDisposeObservable.addOnce(()=>{i.sound?.dispose()})}a(mr,"registerSoundNodeEvents");function Fa(i,e){return new Promise(async(t,o)=>{if(!i.offlineProvider||!ur.Database.IDBStorageEnabled)return(0,oe.CreateSoundBufferAsync)(e).then(r=>t(r)).catch(r=>o(r));i.offlineProvider.loadFile(e,r=>{(0,oe.CreateSoundBufferAsync)(r).then(n=>t(n)).catch(n=>o(n))},void 0,()=>{o(null)},!0)})}a(Fa,"loadSoundBuffer");function Gi(i,e){if(!i.soundRelativePath||!i.sound)return;e.onSoundLoadedObservable=new fr.Observable;let t=Va(i.soundRelativePath,{spatialAutoUpdate:!1});t._initAsync(i.sound.buffer,{spatialAutoUpdate:!0}).then(()=>{t.volume=i.volume,t._isSpatial=i.sound._isSpatial,t._isSpatial&&(t.spatial.attach(e),t.spatial.maxDistance=i.sound.spatial.maxDistance,t.spatial.panningModel=i.sound.spatial.panningModel,t.spatial.distanceModel=i.sound.spatial.distanceModel),e.sound=t,e.soundRelativePath=i.soundRelativePath,e.autoUpdateSpatial=i.autoUpdateSpatial,Pe.push(e),hr(e,t),pr(e.getScene()),e.onSoundLoadedObservable.notifyObservers(e)}),mr(e),dr(e,t)}a(Gi,"configureSourceNodeFrom");function dr(i,e){Object.defineProperty(i,"volume",{get:a(()=>e.volume,"get"),set:a(t=>{e.volume=t},"set")}),Object.defineProperty(i,"playbackRate",{get:a(()=>e.playbackRate,"get"),set:a(t=>{e.playbackRate=t},"set")}),i.isPaused=()=>e.state===ft.SoundState.Paused,i.isPlaying=()=>e.state===ft.SoundState.Started,i.isStopped=()=>e.state===ft.SoundState.Stopped,i.pause=()=>e.pause(),i.resume=()=>e.resume(),i.stop=t=>e.stop(t),i.play=t=>e.play(t),i.setVolume=(t,o)=>e.setVolume(t,o),i.getClassName=()=>"SoundNode",i.setSoundSpatial=t=>new Promise(o=>{e._isSpatial=t,setTimeout(()=>{t&&e.spatial.attach(i),o()})}),i.cloneAsync=async(t,o,r)=>new Promise(n=>{let l=i.clone(t,o,r);Gi(i,l),l.onSoundLoadedObservable.addOnce(()=>{setTimeout(()=>n(l))})})}a(dr,"configureSoundNodePrototype");function Sr(){lr||(lr=!0,(0,gr.AddParser)("SoundNode",(i,e,t,o)=>{i.transformNodes?.forEach(r=>{if(!r.isSoundNode)return;let n=t.transformNodes?.find(l=>l.id===r.id);if(n&&r.soundRelativePath){let l=`${o}${r.soundRelativePath}`;e.addPendingData(l),Fi.has(l)||Fi.set(l,Fa(e,l)),Fi.get(l).then(s=>{(0,oe.CreateSoundAsync)(r.soundRelativePath,s,{spatialAutoUpdate:!1}).then(c=>{if(e.removePendingData(l),n.isDisposed())return c.dispose();c.volume=r.volume,c._isSpatial=r.isSpatial,r.isSpatial&&(c.spatial.attach(n),c.spatial.maxDistance=r.maxDistance,c.spatial.panningModel=r.panningModel,c.spatial.distanceModel=r.distanceModel),n.sound=c,n.soundRelativePath=r.soundRelativePath,n.autoUpdateSpatial=r.autoUpdateSpatial,Pe.push(n),mr(n),dr(n,c),pr(e)})})}})}))}a(Sr,"registerAudioParser");var yr=require("babylonjs");function we(i){let e=new Set;[...i.transformNodes,...i.meshes].forEach(o=>{if(o.metadata?.isStaticGroup){let r=o.getDescendants(!1);r.push(o),r.forEach(n=>{if((ne(n)||te(n)&&!n.isWorldMatrixFrozen)&&n.billboardMode===yr.AbstractMesh.BILLBOARDMODE_NONE&&n.freezeWorldMatrix(),ne(n)){let l=n.material;l&&!l.isFrozen&&!e.has(l)&&(e.add(l),l.onBindObservable.addOnce(()=>{l.freeze()}))}})}})}a(we,"configureTransformNodes");var ke=class{constructor(e,t){this.entries=e;this.namingId=t}entries;namingId;static{a(this,"AdvancedAssetContainerInstantiatedEntries")}get rootNodes(){return this.entries.rootNodes}get skeletons(){return this.entries.skeletons}get animationGroups(){return this.entries.animationGroups}dispose(){this.entries.dispose()}getRootNodeByName(e){let t=`${e}-${this.namingId}`;return this.entries.rootNodes.find(o=>o.name===t)??null}getNodeByName(e){let t=`${e}-${this.namingId}`;for(let o of this.entries.rootNodes){let r=this._recursivelyGetNodeByName(t,o);if(r)return r}return null}_recursivelyGetNodeByName(e,t){if(t.name===e)return t;for(let o of t.getDescendants(!0)){let r=this._recursivelyGetNodeByName(e,o);if(r)return r}return null}getScriptByClassByObjectName(e,t){let o=this.getNodeByName(e);if(o){let r=Te(o,t);if(r?.length===1)return r[0]}return null}};var Bi=require("babylonjs"),Ue=class{static{a(this,"AdvancedAssetContainer")}container;_rootUrl;_scriptsMap;_originalDescendants=[];_nodesMap=new Map;_animationGroupsMap=new Map;constructor(e,t,o){this.container=e,this._rootUrl=t,this._scriptsMap=o,e.populateRootNodes(),e.rootNodes.forEach(r=>{this._originalDescendants.push(r,...r.getDescendants(!1))}),e.animationGroups.forEach(r=>{this._animationGroupsMap.set(r.name,r)}),this._originalDescendants.forEach(r=>{this._nodesMap.set(r,{node:r,metadata:Vi(r.metadata)})})}removeDefault(){this.container.getNodes().forEach(e=>{U.get(e)?.forEach(o=>{gt(e,o)})}),this.container.removeAllFromScene()}getRootNodeByName(e){return this.container.rootNodes.find(t=>t.name===e)??null}getScriptByClassByObjectName(e,t){let o=this.container.getNodes();for(let r of o)if(r.name===e){let n=Te(r,t);if(n?.length===1)return n[0]}return null}instantiate(e){let t=Bi.Tools.RandomId(),o=a(s=>s,"nameFunction"),r=this.container.instantiateModelsToScene(o,!1,{...e,predicate:a(s=>(s.name=`${s.name}@editor-tools@${t}_${s.id}`,e?.predicate?.(s)??!0),"predicate")}),n=new ke(r,t);[...this.container.transformNodes,...this.container.meshes,...this.container.lights,...this.container.cameras,...this.container.animationGroups,...this.container.skeletons].forEach(s=>{let c=s.name.split("@editor-tools@");s.name=c[0]}),r.animationGroups.forEach(s=>{let c=s.name.split("@editor-tools@");s.name=`${c[0]}-${t}`});let p=[];return r.rootNodes.forEach(s=>{p.push(s,...s.getDescendants(!1))}),p.forEach(s=>{let c=s.name.split("@editor-tools@"),h=c[1].split("_").pop();s.name=`${c[0]}-${t}`;let m=this._originalDescendants.find(d=>d.id===h);se(m)&&te(s)&&Gi(m,s),s.id=Bi.Tools.RandomId(),s.metadata=Vi(this._nodesMap.get(m).metadata),s.metadata??={},s.metadata.originalId=h,p.forEach(d=>{d.metadata.scripts?.forEach(u=>{Object.keys(u.values||{}).forEach(g=>{let y=u.values[g];if(y.type==="entity"){y.value===h&&(y.value=s.id),y.value===m.name&&(y.value=s.name);let C=this._animationGroupsMap.get(y.value);C&&(y.value=`${C.name}-${t}`)}})})})}),p.forEach(s=>{H(this.container.scene,s,this._scriptsMap,{namingId:t,rootUrl:this._rootUrl})}),we(this.container.scene),n}};var br=require("babylonjs"),xr=require("babylonjs");async function _r(i,e,t){let o=t.iblIntensity,r=t.environmentIntensity,l=i.split("/").pop().replace(".scene",".babylon"),p=await(0,xr.LoadAssetContainerAsync)(l,t,{rootUrl:e,pluginExtension:".babylon"});return t.onDisposeObservable.addOnce(()=>{p.dispose()}),br.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&t.meshes.forEach(s=>F(s)&&s._checkDelayState()),p.addAllToScene(),t.iblIntensity=o,t.environmentIntensity=r,we(t),p}a(_r,"preloadSceneScriptAsset");async function Cr(i,e){return k(`${e}${i}`)}a(Cr,"preloadCommonScriptAsset");var pe=new Map,We=new Map;function Na(i,e){We.has(i)&&console.warn(`A parser for the extension '${i}' was already registered. It will be overwritten.`),We.set(i,e)}a(Na,"registerScriptAssetParser");async function zi(i,e,t){let o=[e,...e.transformNodes,...e.meshes,...e.lights,...e.cameras],r=pe.get(e);r||(r=new Map,pe.set(e,r)),e.onDisposeObservable.addOnce(()=>{pe.delete(e)}),o.filter(s=>s.metadata?.scripts?.length).map(s=>s.metadata.scripts).flat().forEach(s=>{if(t[s.key]?.default?._SceneAssets?.forEach(h=>{r.get(h.sceneName)||r.set(h.sceneName,null)}),s.values)for(let h in s.values){if(!s.values.hasOwnProperty(h))continue;let m=s.values[h];m.type==="asset"&&m.value&&!r.get(m.value)&&r.set(m.value,null)}});let l=0;for(let s of r.values())s===null&&++l;if(l===0)return l;let p=[];return r.forEach((s,c)=>{r.get(c)||p.push(new Promise(async h=>{try{let m=c.split(".").pop();switch(m){case"scene":let d=await _r(c,i,e);e.onDisposeObservable.addOnce(()=>{d.dispose(),r.delete(c)}),r.set(c,new Ue(d,i,t));break;default:if(We.has(m)){let u=We.get(m);r.set(c,await u({key:c,rootUrl:i,scene:e}));break}else r.set(c,await Cr(c,i));break}}catch(m){console.error(m)}h()}))}),await Promise.all(p),l}a(zi,"_preloadScriptsAssets");var Dr=require("babylonjs"),vt=require("babylonjs"),Lr=require("babylonjs"),St=require("babylonjs"),Pr=require("babylonjs"),wr=require("babylonjs-gui");function re(i,e){return e?`${i}-${e}`:i}a(re,"formatNameWithId");function Hi(i,e,t,o,r){let n=o.constructor;if(!n)return;n._NodesFromScene?.forEach(s=>{o[s.propertyKey.toString()]=Ai(re(s.nodeName,r.namingId),i)}),n._ComponentsFromScene?.length&&i.getEngine().onBeginFrameObservable.addOnce(()=>{n._ComponentsFromScene?.forEach(s=>{let c=[];if([i,...i.transformNodes,...i.meshes,...i.lights,...i.cameras].forEach(m=>{let d=ki(m,s.componentConstructor);d&&c.push(d)}),c.length>1)throw new Error(`Multiple components of type ${n._ComponentsFromScene[0].componentConstructor.name} found in scene for property "${n._ComponentsFromScene[0].propertyKey.toString()}".`);o[s.propertyKey.toString()]=c[0]??null})}),n._NodesFromDescendants?.forEach(s=>{let c=e.getDescendants?.(s.directDescendantsOnly,h=>h.name===re(s.nodeName,r.namingId))[0];o[s.propertyKey.toString()]=c??null}),n._AnimationGroups?.forEach(s=>{o[s.propertyKey.toString()]=i.getAnimationGroupByName(re(s.animationGroupName,r.namingId))}),n._SoundsFromScene?.forEach(s=>{let c=Ai(re(s.soundName,r.namingId),i);c&&se(c)&&(o[s.propertyKey.toString()]=c??null)}),(n._GuiFromAsset??[]).map(async s=>{let c=`${r.rootUrl}assets/${s.pathInAssets}`;try{let h=await k(c),m=wr.AdvancedDynamicTexture.CreateFullscreenUI(h.name,!0,i);m.parseSerializedObject(h.content,!1),o[s.propertyKey.toString()]=m,s.onGuiCreated?.(o,m)}catch(h){throw console.error(`Failed to load GUI from asset: ${c}`),h}}),n._ParticleSystemsFromScene?.forEach(s=>{let c=i.particleSystems?.find(h=>h.name!==re(s.particleSystemName,r.namingId)?!1:s.directDescendantsOnly?h.emitter===e:h);o[s.propertyKey.toString()]=c}),(n._VisibleInInspector??[]).forEach(s=>{let c=s.propertyKey.toString(),h=t.values;if(!h)throw new Error(`No values found for script with key "${t.key}".`);if(h.hasOwnProperty(c)&&h[c].hasOwnProperty("value")){let m=h[c].value;switch(s.configuration.type){case"number":case"boolean":case"keymap":case"string":o[c]=m;break;case"vector2":o[c]=St.Vector2.FromArray(m);break;case"vector3":o[c]=St.Vector3.FromArray(m);break;case"color3":o[c]=vt.Color3.FromArray(m);break;case"color4":o[c]=vt.Color4.FromArray(m);break;case"entity":switch(s.configuration.entityType){case"node":case"sound":o[c]=Le(m,i)??null;break;case"animationGroup":o[c]=i.getAnimationGroupByName(m)??null;break;case"particleSystem":o[c]=i.particleSystems?.find(u=>u.id===m)??null;break}break;case"texture":m&&(o[c]=Lr.Texture.Parse(m,i,r.rootUrl));break;case"asset":if(m){let u=s.configuration.assetType,g=pe.get(i).get(m);switch(u){case"json":case"gui":case"scene":case"navmesh":case"cinematic":o[c]=g;break;case"ragdoll":o[c]=Mi(g);break;case"nodeParticleSystemSet":let y=Pr.NodeParticleSystemSet.Parse(g);o[c]=y;break;case"material":o[c]=Dr.Material.Parse(g,i,r.rootUrl);break}}}}});let l=null,p=null;if(n._PointerEvents?.length){if(n._PointerEvents.find(h=>h.options.mode==="attachedMeshOnly")&&!ne(e))throw new Error('@onPointerEvent with mode "attachedMeshOnly" can only be used on scripts attached to meshes (extends AbstractMesh).');if(n._PointerEvents.find(h=>h.options.mode!=="global")&&!de(e))throw new Error('@onPointerEvent with mode different from "global" can be used only on scripts attached to Node: Mesh, Light, Camera, TransformNode.');l=i.onPointerObservable.add(h=>{let m=null;n._PointerEvents.forEach(d=>{if(!d.eventTypes.includes(h.type))return;let u=d.propertyKey.toString();if(d.options.mode==="global")return o[u]?.(h);m=h.pickInfo,m||(m=i.pick(i.pointerX,i.pointerY,g=>g.isVisible&&g.isPickable&&g.isEnabled(!0)&&!g._masterMesh,!1));let S=m.pickedMesh;if(S&&(d.options.mode==="attachedMeshOnly"&&S===e||d.options.mode==="includeDescendants"&&de(e)&&[e,...e.getDescendants(!1)].find(C=>C===S)))return o[u]?.(h)})})}if(n._KeyboardEvents?.length&&(p=i.onKeyboardObservable.add(s=>{n._KeyboardEvents.forEach(c=>{c.eventTypes.includes(s.type)&&o[c.propertyKey.toString()]?.(s)})})),n._SpritesFromSpriteManager?.length){let s=e;if(!te(s)||!s.isSpriteManager)return console.error("@spriteFromSpriteManager decorator can only be used on SpriteManagerNode.");if(!s.spriteManager)return console.error(`SpriteManagerNode "${s.name}" has no sprite manager assigned.`);n._SpritesFromSpriteManager?.forEach(c=>{let h=s.spriteManager?.sprites.find(m=>m.name===re(c.spriteName,r.namingId))||null;o[c.propertyKey.toString()]=h})}if(n._AnimationsFromSprite?.length){if(!Mt(e))return console.error("@animationFromSprite decorator can only be used in scripts attached on Sprite.");let s=e.metadata?.spriteAnimations;if(!s?.length)return console.error(`Sprite "${e.name}" has no sprite animations assigned.`);n._AnimationsFromSprite.forEach(c=>{let h=s.find(m=>m.name===re(c.animationName,r.namingId));h?o[c.propertyKey.toString()]=h??null:console.warn(`Sprite animation named "${re(c.animationName,r.namingId)}" not found on sprite "${e.name}".`)})}return n._SceneAssets?.forEach(s=>{let c=pe.get(i);o[s.propertyKey.toString()]=c.get(s.sceneName)}),{observers:{pointerObserver:l,keyboardObserver:p}}}a(Hi,"applyDecorators");function H(i,e,t,o){e.metadata?.scripts&&(e.metadata.scripts?.forEach(r=>{if(!r.enabled)return;let n=t[r.key];if(!n)return;let l=n,p={};if(n.default){l=new n.default(e);let s=Hi(i,e,r,l,o);Object.assign(p,s?.observers??{})}l.onStart&&(p.onStartObserver=i.onBeforeRenderObservable.addOnce(()=>l.onStart(e))),l.onUpdate&&(p.onUpdateObserver=i.onBeforeRenderObservable.add(()=>l.onUpdate(e))),Ui(e,l,r.key,p)}),e.metadata.scripts=void 0)}a(H,"_applyScriptsForObject");function Ga(i,e,t){if(t??=i.getScene?.(),!t)throw new Error("Cannot apply script on object: no scene available.");let o=new e(i),r={};return Hi(t,i,{values:{}},o,{rootUrl:""}),o.onStart&&(r.onStartObserver=t.onBeforeRenderObservable.addOnce(()=>o.onStart())),o.onUpdate&&t.onBeforeRenderObservable.add(()=>o.onUpdate()),Ui(i,o,"runtime",r),o}a(Ga,"applyScriptOnObject");var U=new Map;function Ui(i,e,t,o){let r={key:t,observers:o,instance:e};U.has(i)?U.get(i).push(r):U.set(i,[r]),(de(i)||It(i)||Et(i)||se(i))&&i.onDisposeObservable.addOnce((()=>{U.get(i)?.slice()?.forEach(l=>{gt(i,l)}),U.delete(i)}))}a(Ui,"_registerScriptInstance");function gt(i,e){e.observers.onStartObserver?.remove(),e.observers.onUpdateObserver?.remove(),e.observers.pointerObserver?.remove(),e.observers.keyboardObserver?.remove();try{e.instance.onStop?.(i)}catch(r){console.error(`Failed to call onStop for script ${e.key} on object ${i}`,r)}let t=U.get(i),o=t?.indexOf(e)??-1;o!==-1&&t?.splice(o,1)}a(gt,"_removeRegisteredScriptInstance");function Te(i,e){return U.get(i)?.filter(r=>r.instance.constructor===e)?.map(r=>r.instance)??null}a(Te,"getAllScriptsByClassForObject");function ki(i,e){return Te(i,e)?.[0]??null}a(ki,"getScriptByClassForObject");var Or=require("babylonjs"),Tr=!1;function Er(){Tr||(Tr=!0,(0,Or.AddParser)("MeshEditorPlugin",(i,e,t,o)=>{i.meshes?.forEach(r=>{r.instances?.forEach(n=>{let l=t.meshes?.find(p=>p.id===n.id);l&&n.billboardMode!==void 0&&(l.billboardMode=n.billboardMode)})})}))}a(Er,"registerMeshParser");var Ar=!1;function Ba(i){Ar=i}a(Ba,"setUseKtx2CompressedTextures");function Xe(){return Ar}a(Xe,"isUsingKtx2CompressedTextures");function yt(i){return`${i.substring(0,i.lastIndexOf("."))}.ktx2`}a(yt,"_getKtx2TextureName");function za(i){i.setCompressedTextureExclusions([".env",".hdr",".dds"]),i.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}a(za,"configureEngineToUseCompressedTextures");function bt(i,e){i._excludedCompressedTextures&&!i._excludedCompressedTextures?.includes(e)&&i._excludedCompressedTextures?.push(e)}a(bt,"addExcludedCompressedTexture");function Ha(i,e,t){e.loadingTexturesQuality!==i&&(e.loadingTexturesQuality=i,e.textures.forEach(o=>{if(!Me(o)||!o.url)return;let r=xt(o,e);!r||o.url.includes(r)||o.updateURL(t+r)}))}a(Ha,"applyTexturesQuality");function xt(i,e){if(e.loadingTexturesQuality==="high"||!i.metadata?.baseSize)return i.name;let t=i.metadata.baseSize.width,o=i.metadata.baseSize.height,r=t===N(t)||o===N(o),n="";switch(e.loadingTexturesQuality){case"medium":let d=t*.66>>0,u=o*.66>>0;r&&(d=N(d),u=N(u)),n=`_${d}_${u}`;break;case"low":case"very-low":let S=t*.33>>0,g=o*.33>>0;r&&(S=N(S),g=N(g)),n=`_${S}_${g}`;break}let l=i.name;if(!l||!n)return i.name;let p=l.split("/"),s=p.pop();if(!s)return i.name;let c=s.split(".").pop(),m=`${s.replace(`.${c}`,"")}${n}.${c}`;return p.push(m),p.join("/")}a(xt,"getTextureUrl");var Wi=require("babylonjs"),Ir=!1;function Mr(){if(Ir)return;Ir=!0;let i=Wi.SerializationHelper._TextureParser;Wi.SerializationHelper._TextureParser=(e,t,o)=>{Xe()&&(e.name&&(e.name=yt(e.name)),e.url&&(e.url=yt(e.url)));let r=xt(e,t);if(!r)return i(e,t,o);let n=e.name;e.name=r;let l=i(e,t,o);return l&&(l.name=n),l}}a(Mr,"registerTextureParser");function Xi(i){if(!Array.isArray(i.frames)){let e=[];for(let t of Object.keys(i.frames))e.push({filename:t,...i.frames[t]});i.frames=e}}a(Xi,"normalizeAtlasJson");function ka(i,e,t){let r=(i.metadata?.spriteAnimations??[]).find(n=>n.name===e);if(!r)return console.error(`Animation with name "${e}" not found on sprite.`);i.playAnimation(r.from,r.to,r.loop,r.delay,t)}a(ka,"playSpriteAnimationFromName");var Vr=require("babylonjs"),Fr=require("babylonjs"),Nr=require("babylonjs"),Gr=require("babylonjs"),$i=require("babylonjs"),Oe=require("babylonjs"),Br=require("babylonjs"),Rr=!1;function zr(){Rr||(Rr=!0,(0,Br.AddParser)("SpriteMapNode",(i,e,t,o)=>{i.transformNodes?.forEach(r=>{if(!r.isSpriteMap)return;let n=t.transformNodes?.find(s=>s.id===r.id);if(!n)return;n.isSpriteMap=r.isSpriteMap;let l=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(l);let p=new Nr.WebRequest;p.open("GET",l),p.send(),p.addEventListener("load",()=>{e.removePendingData(l);let s=JSON.parse(p.responseText);Xi(s);let c=`${Vr.Tools.GetFolderPath(l)}${s.meta.image}`,h=new $i.Texture(c,e,!1,!1,$i.Texture.NEAREST_NEAREST,null,null,null,!1,Fr.Engine.TEXTUREFORMAT_RGBA),m=new Gr.SpriteMap(n.name,s,h,{layerCount:r.options.layerCount,stageSize:Oe.Vector2.FromArray(r.options.stageSize??[10,1]),outputSize:Oe.Vector2.FromArray(r.options.outputSize??[100,100]),colorMultiply:Oe.Vector3.FromArray(r.options.colorMultiply??[1,1,1]),flipU:!0},e);r.getClassName=()=>"SpriteMapNode",r.tiles.forEach(u=>{for(let S=0,g=u.repeatCount.x+1;S<g;++S)for(let y=0,C=u.repeatCount.y+1;y<C;++y){let L=S*(u.repeatOffset.x+1),x=y*(u.repeatOffset.y+1);m.changeTiles(u.layer,new Oe.Vector2(u.position.x+L,(m.options.stageSize?.y??0)-1-u.position.y-x),u.tile)}});let d=m._output;d.parent=n,n.spriteMap=m})})}))}a(zr,"registerSpriteMapParser");var kr=require("babylonjs"),Ur=require("babylonjs"),_t=require("babylonjs"),Wr=require("babylonjs"),Hr=!1;function Xr(){if(Hr)return;Hr=!0,(0,Wr.RegisterShadowGeneratorSceneComponent)(Ur.ShadowGenerator);let i=(0,_t.GetParser)(kr.SceneComponentConstants.NAME_SHADOWGENERATOR);(0,_t.AddParser)("ShadowGeneratorEditorPlugin",(e,t,o,r)=>{let n=new Map;e.shadowGenerators?.forEach(l=>{if(n.set(l.id,l.mapSize),t.loadingShadowsQuality!=="high"){switch(t.loadingShadowsQuality){case"medium":l.mapSize=l.mapSize*.5;break;case"low":l.mapSize=l.mapSize*.25;break;case"very-low":l.mapSize=l.mapSize*.125;break}l.mapSize=Math.max(128,N(l.mapSize))}}),i?.(e,t,o,r),t.lights.forEach(l=>{let p=l.getShadowGenerator();if(p?.getShadowMap()){let c=p.id,h=n.get(c);h&&(p.originalMapSize=h)}})})}a(Xr,"registerShadowGeneratorParser");var Kr=require("babylonjs"),Zr=require("babylonjs"),Yr=require("babylonjs"),ji=require("babylonjs"),qr=require("babylonjs");function $r(i,e){e?.fogEnabled!==void 0&&(i.fogEnabled=e?.fogEnabled),e?.blendMode!==void 0&&(i.blendMode=e?.blendMode),e?.disableDepthWrite!==void 0&&(i.disableDepthWrite=e?.disableDepthWrite),e?.pixelPerfect!==void 0&&(i.pixelPerfect=e?.pixelPerfect),e?.useLogarithmicDepth!==void 0&&(i.useLogarithmicDepth=e?.useLogarithmicDepth),e?.metadata!==void 0&&(i.metadata=e?.metadata);for(let t of e?.sprites??[]){let o=Zr.Sprite.Parse(t,i);o.uniqueId=t.uniqueId,o.metadata=t.metadata}}a($r,"parseSerializedSpriteManager");var jr=!1;function Qr(){jr||(jr=!0,(0,qr.AddParser)("SpriteManagerNode",(i,e,t,o)=>{i.transformNodes?.forEach(r=>{if(!r.isSpriteManager)return;let n=t.transformNodes?.find(p=>p.id===r.id);if(!n)return;let l=e.getEngine();if(n.isSpriteManager=r.isSpriteManager,r.atlasJsonRelativePath){let p=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(p);let s=new Yr.WebRequest;s.open("GET",p),s.send(),s.addEventListener("load",()=>{e.removePendingData(p);let c=JSON.parse(s.responseText),h=`${Kr.Tools.GetFolderPath(p)}${c.meta.image}`;bt(l,h);let m=new ji.SpriteManager(n.name,h,1e3,64,e,void 0,void 0,!0,c);n.spriteManager=m,n.getClassName=()=>"SpriteManagerNode",r.spriteManager&&$r(m,r.spriteManager)})}else if(r.spriteManager?.textureUrl){bt(l,r.spriteManager.textureUrl);let p=`${o}${r.spriteManager.textureUrl}`,s=new ji.SpriteManager(n.name,p,1e3,{width:r.spriteManager.cellWidth,height:r.spriteManager.cellHeight},e,void 0,void 0,!1);n.spriteManager=s,n.getClassName=()=>"SpriteManagerNode",r.spriteManager&&$r(s,r.spriteManager)}})}))}a(Qr,"registerSpriteManagerParser");var en=require("babylonjs"),tn=require("babylonjs"),Jr=!1;function on(){Jr||(Jr=!0,(0,tn.AddParser)("MorphTargetManagerEditorPlugin",(i,e,t,o)=>{i.morphTargetManagers.forEach(r=>{let l=t.meshes.find(c=>c.id===r.meshId)?.morphTargetManager;if(!l||r.targets.find(c=>!c.delayLoadingFile))return;let s=[];r.targets.forEach(c=>{if(!c.delayLoadingFile)return s.push(Promise.resolve(null));let h=`${o}${c.delayLoadingFile}`;e.addPendingData(h);let m=new en.WebRequest;m.responseType="arraybuffer",m.open("GET",h),m.send(),s.push(new Promise(d=>{m.addEventListener("load",()=>{e.removePendingData(h),d(m.response)})}))}),Promise.all(s).then(c=>{for(let h=0,m=l.numTargets;h<m;++h){let d=l.getTarget(h),u=r.targets[h],S=c[h];if(u.positionsCount){let g=new Float32Array(S,u.positionsOffset,u.positionsCount);d._positions=g,d.setPositions(g)}if(u.normalsCount){let g=new Float32Array(S,u.normalsOffset,u.normalsCount);d._normals=g,d.setNormals(g)}if(u.tangentsCount){let g=new Float32Array(S,u.tangentsOffset,u.tangentsCount);d._tangents=g,d.setTangents(g)}if(u.uvsCount){let g=new Float32Array(S,u.uvsOffset,u.uvsCount);d._uvs=g,d.setUVs(g)}if(u.uv2sCount){let g=new Float32Array(S,u.uv2sOffset,u.uv2sCount);d._uv2s=g,d.setUV2s(g)}}for(let h=0,m=l.numTargets;h<m;++h)l.getTarget(h)._onDataLayoutChanged.notifyObservers()})})}))}a(on,"registerMorphTargetManagerParser");var nn=require("babylonjs"),an=require("babylonjs"),rn=!1;function sn(){rn||(rn=!0,(0,nn.AddParser)("NodeParticleSystemSetEditorPlugin",(i,e,t,o)=>{i.meshes?.forEach(r=>{if(!r.isNodeParticleSystemMesh)return;let n=t.meshes?.find(l=>l.id===r.id);n&&(r.nodeParticleSystemSet.blocks?.forEach(l=>{l.url&&(l.url=`${o}${l.url}`)}),n.nodeParticleSystemSet=an.NodeParticleSystemSet.Parse(r.nodeParticleSystemSet),n.nodeParticleSystemSet.id=r.nodeParticleSystemSet.id,n.nodeParticleSystemSet.uniqueId=r.uniqueId,e.addPendingData(r.id),n.nodeParticleSystemSet.buildAsync(e,!1).then(l=>{e.removePendingData(r.id),n.particleSystemSet=l,l.systems.forEach(p=>{if(At(p)){let s=p._sizeCreation.process;s&&(p._sizeCreation.process=(c,h)=>{s(c,h),c.scale.x*=100,c.scale.y*=100})}}),l.emitterNode=n,l.start()}))})}))}a(sn,"registerNodeParticleSystemSetParser");var ln=require("babylonjs");function cn(i,e){e??=new ln.ClusteredLightContainer("Clustered Light Container",[],i);let t=i.metadata?.clusteredLight;return t&&(t.lights.length>0&&(e.horizontalTiles=t.horizontalTiles,e.verticalTiles=t.verticalTiles,e.depthSlices=t.depthSlices,e.maxRange=t.maxRange),t.lights.forEach(o=>{let r=i.getLightById(o);r&&e?.addLight(r)})),e}a(cn,"configureLights");var hn=require("babylonjs"),Zi=require("babylonjs"),mn=require("babylonjs"),dn=require("babylonjs"),Ki=new Map;async function pn(i,e){let t=i.getWaitingItemsCount();for(;!i.isDisposed&&(!i.isReady()||i.getWaitingItemsCount()>0);){await new Promise(r=>setTimeout(r,150));let o=t-i.getWaitingItemsCount();o===t&&i.textures.forEach(r=>{r.delayLoadState===Zi.Constants.DELAYLOADSTATE_NONE&&(r.delayLoadState=Zi.Constants.DELAYLOADSTATE_LOADED)}),e(o/t)}}a(pn,"waitForWaitingItems");async function Ua(i,e,t,o,r){t.loadingQuality=r?.quality??"high",t.loadingTexturesQuality=r?.texturesQuality??t.loadingQuality,t.loadingShadowsQuality=r?.shadowsQuality??t.loadingQuality,t.loadingLodsQuality=r?.lodsQuality??t.loadingQuality,Er(),Sr(),Mr(),Xr(),on(),zr(),Qr(),sn();let n=Ki.get(t)??{};if(Ki.set(t,n),t.onDisposeObservable.addOnce(()=>{Ki.delete(t)}),await(0,mn.AppendSceneAsync)(`${i}${e}`,t,{pluginExtension:".babylon",onProgress:a(p=>{let s=Math.min(p.loaded/p.total*.5);r?.onProgress?.(s)},"onProgress")}),await pn(t,p=>{r?.onProgress?.(.5+p*.25)}),!r?.skipAssetsPreload){let p=0;do p=await zi(i,t,o);while(p!==0&&!t.isDisposed)}dn.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&t.meshes.forEach(p=>F(p)&&p._checkDelayState());let l=cn(t,n.clusteredLightContainer);n.clusteredLightContainer=l,await pn(t,p=>{r?.onProgress?.(.75+p*.25)}),r?.onProgress?.(1),Ft(t),Nt(t.loadingLodsQuality,t),Gt(t),et(t),t.metadata?.rendering&&(or(t,t.metadata),t.activeCamera&&Ei(t.activeCamera,i,r?.postProcessConfiguration)),t.metadata?.physicsGravity&&t.getPhysicsEngine()?.setGravity(hn.Vector3.FromArray(t.metadata?.physicsGravity)),H(t,t,o,i),t.transformNodes.forEach(p=>{H(t,p,o,i)}),t.meshes.forEach(p=>{ir(p),H(t,p,o,i)}),t.lights.forEach(p=>{H(t,p,o,i)}),l.lights.forEach(p=>{H(t,p,o,i)}),t.cameras.forEach(p=>{H(t,p,o,i)}),t.spriteManagers?.forEach(p=>{p.sprites.forEach(s=>{H(t,s,o,i)})}),we(t)}a(Ua,"loadScene");var un=require("babylonjs");async function Wa(i,e,t){let o=await k(i+e),n=un.Tools.Instantiate(o.customType).Parse(o,t,i);return n.id=o.id,n.uniqueId=o.uniqueId,n}a(Wa,"loadMaterialFromFile");function Xa(i){return Promise.all(i.materials.map(async e=>{let t=e.getBindedMeshes();await Promise.all(t.map(async o=>{Ie(o)||await e.forceCompilationAsync(o,{clipPlane:!!i.clipPlane,useInstances:o.hasInstances})}))}))}a(Xa,"forceCompileAllSceneMaterials");var J=require("babylonjs");function $e(i){if(!isNaN(parseFloat(i))&&isFinite(i))return J.Animation.ANIMATIONTYPE_FLOAT;switch(i?.getClassName?.()){case"Vector2":return J.Animation.ANIMATIONTYPE_VECTOR2;case"Vector3":return J.Animation.ANIMATIONTYPE_VECTOR3;case"Quaternion":return J.Animation.ANIMATIONTYPE_QUATERNION;case"Color3":return J.Animation.ANIMATIONTYPE_COLOR3;case"Color4":return J.Animation.ANIMATIONTYPE_COLOR4;case"Size":return J.Animation.ANIMATIONTYPE_SIZE;case"Matrix":return J.Animation.ANIMATIONTYPE_MATRIX}return null}a($e,"getAnimationTypeForObject");var fn=require("babylonjs");function $a(i){return function(e,t){let o=e.constructor;o._NodesFromScene??=[],o._NodesFromScene.push({propertyKey:t,nodeName:i})}}a($a,"nodeFromScene");function ja(i){return function(e,t){let o=e.constructor;o._ComponentsFromScene??=[],o._ComponentsFromScene.push({propertyKey:t,componentConstructor:i})}}a(ja,"componentFromScene");function Ka(i,e=!1){return function(t,o){let r=t.constructor;r._NodesFromDescendants??=[],r._NodesFromDescendants.push({propertyKey:o,nodeName:i,directDescendantsOnly:e})}}a(Ka,"nodeFromDescendants");function Za(i){return function(e,t){let o=e.constructor;o._AnimationGroups??=[],o._AnimationGroups.push({animationGroupName:i,propertyKey:t})}}a(Za,"animationGroupFromScene");function Ya(i){return function(e,t){let o=e.constructor;o._SceneAssets??=[],o._SceneAssets.push({sceneName:i,propertyKey:t})}}a(Ya,"sceneAsset");function qa(i,e){return function(t,o){let r=t.constructor;r._GuiFromAsset??=[],r._GuiFromAsset.push({propertyKey:o,pathInAssets:i,onGuiCreated:e})}}a(qa,"guiFromAsset");function Qa(i){return function(e,t){let o=e.constructor;o._SoundsFromScene??=[],o._SoundsFromScene.push({propertyKey:t,soundName:i})}}a(Qa,"soundFromScene");function Ja(i,e=!1){return function(t,o){let r=t.constructor;r._ParticleSystemsFromScene??=[],r._ParticleSystemsFromScene.push({propertyKey:o,particleSystemName:i,directDescendantsOnly:e})}}a(Ja,"particleSystemFromScene");function es(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"boolean"}})}}a(es,"visibleAsBoolean");function ts(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"string"}})}}a(ts,"visibleAsString");function is(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"number"}})}}a(is,"visibleAsNumber");function os(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"vector2"}})}}a(os,"visibleAsVector2");function rs(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"vector3"}})}}a(rs,"visibleAsVector3");function ns(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"color3"}})}}a(ns,"visibleAsColor3");function as(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"color4"}})}}a(as,"visibleAsColor4");function ss(i,e,t){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...t,entityType:i,type:"entity"}})}}a(ss,"visibleAsEntity");function ls(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"texture"}})}}a(ls,"visibleAsTexture");function cs(i,e){return function(t,o){let r=t.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:i,propertyKey:o,configuration:{...e,type:"keymap"}})}}a(cs,"visibleAsKeyMap");function ps(i,e,t){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...t,assetType:i,type:"asset"}})}}a(ps,"visibleAsAsset");function hs(i,e){return function(t,o){let r=t.constructor;r._PointerEvents??=[],r._PointerEvents.push({propertyKey:o,options:{mode:"global",...e??{}},eventTypes:Array.isArray(i)?i:[i]})}}a(hs,"onPointerEvent");function ms(i){return function(e,t){let o=e.constructor;o._KeyboardEvents??=[],o._KeyboardEvents.push({propertyKey:t,eventTypes:Array.isArray(i)?i:[i]})}}a(ms,"onKeyboardEvent");function ds(i){return function(e,t){let o=e.constructor;o._SpritesFromSpriteManager??=[],o._SpritesFromSpriteManager.push({propertyKey:t,spriteName:i})}}a(ds,"spriteFromSpriteManager");function us(i){return function(e,t){let o=e.constructor;o._AnimationsFromSprite??=[],o._AnimationsFromSprite.push({propertyKey:t,animationName:i})}}a(us,"animationFromSprite");var Ct=require("babylonjs");function Iv(i,e){let t;return i===Ct.Animation.ANIMATIONTYPE_FLOAT?t=e.value:t=e.value.clone(),{value:t,frame:e.frame,interpolation:e.interpolation,inTangent:i===Ct.Animation.ANIMATIONTYPE_FLOAT?e.inTangent:e.inTangent?.clone(),outTangent:i===Ct.Animation.ANIMATIONTYPE_FLOAT?e.outTangent:e.outTangent?.clone()}}a(Iv,"cloneKey");function Dt(i,e){let t=e.split("."),o=i;for(let r=0;r<t.length;++r)o=o[t[r]];return o}a(Dt,"getPropertyValue");function Yi(i,e,t){let o=null;i.onAnimationGroupPlayObservable.add(()=>{o=e.onAfterAnimationsObservable.add(()=>{t()})}),i.onAnimationGroupPauseObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)}),i.onAnimationGroupEndObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)})}a(Yi,"registerAfterAnimationCallback");var ee=require("babylonjs"),Lt=require("babylonjs"),X=require("babylonjs");function fs(i,e){return{name:i.name,framesPerSecond:i.framesPerSecond,outputFramesPerSecond:i.outputFramesPerSecond,tracks:i.tracks.map(t=>{let o=null,r=null;if(t.node?(o=Le(t.node,e),o||(o=e.particleSystems?.find(l=>l.id===t.node)??null)):t.defaultRenderingPipeline?o=Re():t.volumetricLightScattering&&(o=Bt()),t.propertyPath){let l=Dt(o,t.propertyPath);r=$e(l)}let n=null;return t.sound&&(n=Le(t.sound,e)),{node:o,sound:n,propertyPath:t.propertyPath,defaultRenderingPipeline:t.defaultRenderingPipeline,volumetricLightScattering:t.volumetricLightScattering,animationGroupWeight:t.animationGroupWeight,animationGroup:t.animationGroup?e.getAnimationGroupByName(t.animationGroup):null,animationGroups:t.animationGroups,sounds:t.sounds,soundVolume:qi(t.soundVolume??[],ee.Animation.ANIMATIONTYPE_FLOAT),keyFrameEvents:t.keyFrameEvents?.map(l=>{let p={...l};switch(l.data?.type){case"set-enabled":p.data={type:"set-enabled",value:l.data.value,node:Le(l.data.node,e)};break;case"apply-impulse":p.data={type:"apply-impulse",radius:l.data.radius,mesh:e.getMeshById(l.data.mesh),force:X.Vector3.FromArray(l.data.force),contactPoint:X.Vector3.FromArray(l.data.contactPoint)};break}return p}),keyFrameAnimations:o&&r!==null&&qi(t.keyFrameAnimations??[],r)}})}}a(fs,"parseCinematic");function W(i,e){if(i===null)return null;if(i!==void 0)switch(e){case ee.Animation.ANIMATIONTYPE_FLOAT:return i;case ee.Animation.ANIMATIONTYPE_VECTOR2:return X.Vector2.FromArray(i);case ee.Animation.ANIMATIONTYPE_VECTOR3:return X.Vector3.FromArray(i);case ee.Animation.ANIMATIONTYPE_QUATERNION:return X.Quaternion.FromArray(i);case ee.Animation.ANIMATIONTYPE_COLOR3:return Lt.Color3.FromArray(i);case ee.Animation.ANIMATIONTYPE_COLOR4:return Lt.Color4.FromArray(i);case ee.Animation.ANIMATIONTYPE_MATRIX:return X.Matrix.FromArray(i)}}a(W,"parseCinematicKeyValue");function qi(i,e){return i?.map(t=>{let o=t.type==="key"?t:null;if(o)return{...o,value:W(o.value,e),inTangent:W(o.inTangent,e),outTangent:W(o.outTangent,e)};let r=t.type==="cut"?t:null;if(r)return{...r,key1:{...r.key1,value:W(r.key1.value,e),inTangent:W(r.key1.inTangent,e),outTangent:W(r.key1.outTangent,e)},key2:{...r.key2,value:W(r.key2.value,e),inTangent:W(r.key2.inTangent,e),outTangent:W(r.key2.outTangent,e)}};throw new Error(`Unknown key frame type: ${t.type}`)})}a(qi,"parseKeyFrameAnimations");function gn(i,e){i.onEventObservable.notifyObservers(e.eventName)}a(gn,"handleApplyEvent");function vn(i){i.node?.setEnabled(i.value)}a(vn,"handleSetEnabledEvent");var Qi=require("babylonjs"),Sn=Qi.Vector3.Zero();function yn(i,e){let t=e.mesh?[e.mesh]:i.meshes.filter(o=>o.physicsAggregate);e.radius&&(t=t.filter(o=>{let r=o.getBoundingInfo().boundingBox.centerWorld;return Qi.Vector3.Distance(r,e.contactPoint)<=e.radius})),t.forEach(o=>{if(o.physicsAggregate?.body){let r=e.contactPoint.subtract(o.getBoundingInfo().boundingBox.centerWorld);r.multiplyInPlace(e.force),o.physicsAggregate.body.setLinearVelocity(Sn),o.physicsAggregate.body.setAngularVelocity(Sn),o.physicsAggregate.body.applyImpulse(r.negateInPlace(),e.contactPoint)}})}a(yn,"handleApplyImpulseEvent");var bn=require("babylonjs"),xn=require("babylonjs"),je=class extends xn.AnimationGroup{static{a(this,"Cinematic")}onEventObservable=new bn.Observable;onEvent(e,t){this.onEventObservable.add(o=>{e===o&&t()})}};function Ji(i){return i.type==="key"}a(Ji,"isCinematicKey");function Ee(i){return i.type==="cut"}a(Ee,"isCinematicKeyCut");function gs(i){return i.type==="event"}a(gs,"isCinematicKeyEvent");function vs(i){return i.type==="group"}a(vs,"isCinematicGroup");function Ss(i){return i.type==="sound"}a(Ss,"isCinematicSound");var T=require("babylonjs"),Ae=require("babylonjs");function ys(i,e,t){let o=new je(i.name,e);return i.tracks.forEach(r=>{let n=r.animationGroup;if(n&&r.animationGroups?.length){let d=n.clone(`${n.name}-cinematic-temp`),u=e.animationGroups.indexOf(d);u!==-1&&e.animationGroups.splice(u,1),o.onAnimationEndObservable.add(()=>{n.stop(),d.stop()});let S=r.animationGroups.reduce((L,x)=>Math.min(L,x.frame),Number.MAX_VALUE)??0,g=r.animationGroups.reduce((L,x)=>Math.max(L,x.frame+x.endFrame),0)??0,y={frame:S},C=new T.Animation(d.name,"frame",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1);if(C.setKeys([{frame:S,value:0},{frame:g,value:g}]),r.animationGroups.forEach(L=>{C.addEvent(new Ae.AnimationEvent(L.frame,()=>{let x=L.repeatCount??0;if(d.to=L.endFrame,d.speedRatio=L.speed,d.stop(),d.play(x>0),d.from!==L.startFrame&&d.goToFrame(L.startFrame),x){let R=0;d.onAnimationGroupLoopObservable.add(()=>{++R,R>x&&d.stop()})}}))}),o.addTargetedAnimation(C,y),(r.animationGroupWeight?.length??0)>=2&&r.animationGroupWeight.find(x=>Ee(x)?x.key1.value!==1||x.key2.value!==1:x.value!==1)){let x={weight:0},R=new T.Animation(`${d.name}-weights`,"weight",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),B=[];r.animationGroupWeight.forEach(v=>{Ee(v)?(B.push(v.key1),B.push(v.key2)):B.push(v)}),R.setKeys(B),o.addTargetedAnimation(R,x),Yi(o,e,()=>{d.weight=x.weight})}}let l=r.sound;if(!t?.ignoreSounds&&l&&l.sound?.buffer&&r.sounds?.length){let d={dummy:0,volume:0},u=new T.Animation(l.name,"dummy",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;if(r.sounds?.forEach(g=>{let y=g.endFrame-g.startFrame;S=Math.max(S,g.frame+y),u.addEvent(new Ae.AnimationEvent(g.frame,C=>{let x=(C-g.frame+g.startFrame)/i.framesPerSecond;l.play({startOffset:x})},!1)),u.addEvent(new Ae.AnimationEvent(g.frame+y,()=>{l.stop()}))}),u.setKeys([{frame:0,value:0},{frame:S,value:S}]),o.addTargetedAnimation(u,d),(r.soundVolume?.length??0)>=2){let g=new T.Animation(l.name,"volume",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),y=[];r.soundVolume.forEach(C=>{Ee(C)?(y.push(C.key1),y.push(C.key2)):y.push(C)}),g.setKeys(y),o.addTargetedAnimation(g,d),Yi(o,e,()=>{l.volume=d.volume})}}if(r.keyFrameEvents){let d={dummy:0},u=new T.Animation("events","dummy",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;r.keyFrameEvents?.forEach(g=>{S=Math.max(S,g.frame),u.addEvent(new Ae.AnimationEvent(g.frame,()=>{switch(g.data?.type){case"event":gn(o,g.data);break;case"set-enabled":vn(g.data);break;case"apply-impulse":yn(e,g.data);break}}))}),u.setKeys([{frame:0,value:0},{frame:S+1,value:S+1}]),o.addTargetedAnimation(u,d)}let p=r.defaultRenderingPipeline?Re():r.node;if(!p||!r.propertyPath||!r.keyFrameAnimations)return;let s=Dt(p,r.propertyPath),c=$e(s);if(c===null)return;let h=new T.Animation(r.propertyPath,r.propertyPath,60,c,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),m=[];r.keyFrameAnimations?.forEach(d=>{if(Ji(d))return m.push(d);Ee(d)&&(m.push(d.key1),m.push(d.key2),Qe(p)&&r.propertyPath==="position"&&h.addEvent(new Ae.AnimationEvent(d.key1.frame,()=>{let u=Qt();if(!u)return;let S=u.motionStrength;u.motionStrength=0,requestAnimationFrame(()=>{u.motionStrength=S})})))}),h.setKeys(m),o.addTargetedAnimation(h,p)}),o.normalize(),o}a(ys,"generateCinematicAnimationGroup");async function eo(i,e){return new Promise((t,o)=>{let r=indexedDB.open(i,1);r.addEventListener("error",()=>o()),r.addEventListener("blocked",()=>o()),r.addEventListener("upgradeneeded",()=>{try{e(r.result)}catch(n){o(n)}}),r.addEventListener("success",()=>{t(r.result)})})}a(eo,"openIndexDB");function Ke(i,e,t){return new Promise(o=>{let n=i.transaction(e).objectStore(e).get(t);n.addEventListener("error",()=>{o(null)}),n.addEventListener("success",()=>{o(n.result??null)})})}a(Ke,"getFromIndexDB");async function $(i,e,t){let r=i.transaction(e,"readwrite").objectStore(e).put(t);await new Promise((n,l)=>{r.addEventListener("error",()=>l()),r.addEventListener("success",()=>n())})}a($,"putInIndexDB");var _n=require("babylonjs");function bs(i){_n.AbstractEngine.OfflineProviderFactory=(e,t,o=!1)=>new Ze(i,e,t,o)}a(bs,"setupOfflineProvider");async function to(i,e){let t=await new Promise(o=>{let r=new Ze(i,e,n=>o(n?r:null),!1)});return await t?.open(),t}a(to,"createAndOpenDatabase");var Ze=class{static{a(this,"Database")}enableSceneOffline=!0;enableTexturesOffline=!0;name;_database=null;_manifestVersion=null;_loadFilePromises=new Map;constructor(e,t,o,r){this.name=e,r?o(!1):this._checkManifest(t,o)}async _checkManifest(e,t){try{let o=await k(`${e}.manifest?${Date.now()}`);this._manifestVersion=o.version,t(!0)}catch{this.enableSceneOffline=!1,this.enableTexturesOffline=!1,t(!1)}}async open(e,t){try{this._database=await eo(this.name,o=>{o.createObjectStore("files",{keyPath:"url"}),o.createObjectStore("images",{keyPath:"url"}),o.createObjectStore("versions",{keyPath:"url"})}),e?.()}catch{t?.()}}close(){this._database?.close(),this._database=null,this._loadFilePromises.clear()}async loadImage(e,t){if(!this._database){t.src=e;return}let o=null;await Ri(()=>this._manifestVersion!==null);let r=this._loadFilePromises.get(e);if(r)return r.then(l=>{l!==null?t.src=l:t.src=e});let n=new Promise(async l=>{if(await this._getFileVersionForUrl(e)!==this._manifestVersion?(o=await De(e,"blob"),await Promise.all([$(this._database,"images",{url:e,data:o}),$(this._database,"versions",{url:e,version:this._manifestVersion})])):o=(await Ke(this._database,"images",e))?.data??null,o!==null){let s=URL.createObjectURL(o);t.src=s}else t.src=e;l(t.src)});this._loadFilePromises.set(e,n)}async saveImage(e){if(!this._database)throw new Error("Database is not available");let t=await De(e,"blob");await Promise.all([$(this._database,"images",{url:e,data:t}),$(this._database,"versions",{url:e,version:this._manifestVersion})])}async isFileMatchingVersion(e){return await this._getFileVersionForUrl(e)===this._manifestVersion}async loadFile(e,t,o,r,n){if(!this._database)return r?.();let l=null;await Ri(()=>this._manifestVersion!==null);let p=this._loadFilePromises.get(e);if(p)return p.then(c=>{c!==null?t(c):r?.()});let s=new Promise(async c=>{await this._getFileVersionForUrl(e)!==this._manifestVersion?(l=await De(e,n?"arraybuffer":"text",o),await Promise.all([$(this._database,"files",{url:e,data:l}),$(this._database,"versions",{url:e,version:this._manifestVersion})])):l=(await Ke(this._database,"files",e))?.data??null,l!==null?t(l):r?.(),c(l)});this._loadFilePromises.set(e,s)}async saveFile(e,t,o){if(!this._database)throw new Error("Database is not available");let r=await De(e,t?"arraybuffer":"text",o);await Promise.all([$(this._database,"files",{url:e,data:r}),$(this._database,"versions",{url:e,version:this._manifestVersion})])}async _getFileVersionForUrl(e){return(await Ke(this._database,"versions",e))?.version??null}};var Cn=["mp3","wav"],Dn=["babylonbinarymeshdata"],xs=["ktx","ktx2","jpg","jpeg","png","bmp","webp"],Ln=["babylon","json"],io=["jpg","jpeg","png","bmp","webp"],Pn=["bin","ktx","ktx2",...Dn,...Cn],_s=[...Ln,...io,...Pn];async function Cs(i,e,t){let o=[],r=await k(`${e}scenes-used-files.json`),n=[];if(t?.scenesFilter){n=t.scenesFilter.map(m=>typeof m=="string"?{sceneName:m,disableSounds:!1,disableTextures:!1,disableGeometries:!1}:m);for(let[m,d]of Object.entries(r))n.find(u=>u.sceneName===m)||delete r[m]}let l=0,p=0,s=t?.engine?.textureFormatInUse?t?.engine?.texturesSupported[0]:null,c=Object.values(r).reduce((m,d)=>m+d.length,0);function h(m){++p,t?.onProgress?.(p/c),m?.()}a(h,"notifyProgress");for(let[m,d]of Object.entries(r)){let u=m.replace(".scene",".babylon"),S=await to(i,`${e}${u}`);if(!S)continue;let g=n.find(y=>y.sceneName===m);for(let y=0,C=d.length;y<C;++y){let L=d[y],x=L.split(".").pop()?.toLowerCase();if(!x){h();continue}if(Dn.includes(x)&&g?.disableGeometries){h();continue}if(xs.includes(x)&&g?.disableTextures){h();continue}if(Cn.includes(x)&&g?.disableSounds){h();continue}if(io.includes(x)&&g?.disableTextures){h();continue}if(x==="ktx")if(s){if(!L.endsWith(s)){h();continue}}else{h();continue}if(x==="ktx2"&&!Xe()){h();continue}if(o.length>300){try{await Promise.all(o)}catch{}o.splice(0,o.length)}let R=`${e}${L}`;_s.includes(x)&&o.push(new Promise(async B=>{if(await S.isFileMatchingVersion(R))return h(B);try{io.includes(x)?t?.disableImages||(await S.saveImage(R),++l):Pn.includes(x)?(await S.saveFile(R,!0),++l):Ln.includes(x)&&(await S.saveFile(R,!1),++l)}catch{}h(B)}))}await Promise.all(o),S.close()}return await Promise.all(o),{loadedCount:l,processedFilesCount:p}}a(Cs,"preloadAssetsToDatabase");0&&(module.exports={AdvancedAssetContainer,AdvancedAssetContainerInstantiatedEntries,Cinematic,Database,NodeParticleSystemSet,VolumetricDebugMode,VolumetricDepthSource,VolumetricDitherMode,VolumetricFogMode,VolumetricLightingRenderingPipeline,VolumetricShadowKind,VolumetricShadowMode,VolumetricStepDistribution,VolumetricTransmittanceMode,_applyScriptsForObject,_getKtx2TextureName,_preloadScriptsAssets,_registerScriptInstance,_removeRegisteredScriptInstance,addExcludedCompressedTexture,animationFromSprite,animationGroupFromScene,applyMeshesLODQuality,applyRagdollJointLimits,applyRenderingConfigurationForCamera,applyScriptOnObject,applyShadowsQuality,applyTexturesQuality,canUseHdr,componentFromScene,computeVolumetricBudget,computeVolumetricShapeKey,configureEngineToUseCompressedTextures,configureMeshDistanceOrScreenCoverage,configureShadowMapRefreshRate,configureShadowMapRenderListPredicate,copyAndParseRagdollConfiguration,createAndOpenDatabase,createDefaultRenderingPipeline,createMotionBlurPostProcess,createSSAO2RenderingPipeline,createSSRRenderingPipeline,createTAARenderingPipeline,createVLSPostProcess,createVolumetricLightingPrePassConfiguration,createVolumetricLightingRenderingPipeline,defaultPipelineCameraConfigurations,disposeDefaultRenderingPipeline,disposeMotionBlurPostProcess,disposeSSAO2RenderingPipeline,disposeSSRRenderingPipeline,disposeTAARenderingPipeline,disposeVLSPostProcess,disposeVolumetricLightingRenderingPipeline,ensureVolumetricLightConfiguration,forceCompileAllSceneMaterials,generateCinematicAnimationGroup,getAllScriptsByClassForObject,getAllVolumetricCandidateLights,getAnimationTypeForObject,getDefaultRenderingPipeline,getDefaultVolumetricLightConfiguration,getDefaultVolumetricLightingConfiguration,getFromIndexDB,getHdrTextureType,getMotionBlurPostProcess,getPowerOfTwoUntil,getSSAO2RenderingPipeline,getSSRRenderingPipeline,getScriptByClassForObject,getTAARenderingPipeline,getTextureUrl,getVLSPostProcess,getVolumetricGeometryBufferDepthTexture,getVolumetricGeometryBufferRenderer,getVolumetricLightConfiguration,getVolumetricLightRange,getVolumetricLightSteps,getVolumetricLightWorldDirection,getVolumetricLightWorldPosition,getVolumetricLightingRenderingPipeline,getVolumetricLightingRenderingPipelineConfiguration,getVolumetricPrePassDepthTexture,getVolumetricPrePassRenderer,getVolumetricSamplingSteps,guiFromAsset,isAbstractMesh,isAnyParticleSystem,isArcRotateCamera,isBone,isCamera,isCascadedShadowGenerator,isCinematicGroup,isCinematicKey,isCinematicKeyCut,isCinematicKeyEvent,isCinematicSound,isClusteredLightContainer,isDecalMesh,isDirectionalLight,isFreeCamera,isGPUParticleSystem,isGaussianSplattingMesh,isGroundMesh,isHemisphericLight,isInstancedMesh,isLight,isMesh,isNode,isNodeFromStaticGroup,isParticleSystem,isPointLight,isScene,isShadowGenerator,isSoundNode,isSpotLight,isSprite,isSpriteManagerNode,isTexture,isTransformNode,isUsingKtx2CompressedTextures,isVolumetricLightEnabled,isVolumetricLightSupported,isVolumetricLightingSupported,loadMaterialFromFile,loadScene,markVolumetricLightsDirty,maxVolumetricArrayLights,maxVolumetricDirectionalLights,maxVolumetricShadowSlots,motionBlurPostProcessCameraConfigurations,nodeFromDescendants,nodeFromScene,normalizeAtlasJson,normalizeVolumetricLightConfiguration,normalizeVolumetricLightingConfiguration,onKeyboardEvent,onPointerEvent,openIndexDB,parseCinematic,parseCinematicKeyValue,parseDefaultRenderingPipeline,parseKeyFrameAnimations,parseMotionBlurPostProcess,parseRagdollConfiguration,parseSSAO2RenderingPipeline,parseSSRRenderingPipeline,parseTAARenderingPipeline,parseVLSPostProcess,parseVolumetricLightingRenderingPipeline,particleSystemFromScene,playSpriteAnimationFromName,preloadAssetsToDatabase,putInIndexDB,registerScriptAssetParser,resolveVolumetricDepthSource,resolveVolumetricShadowSlot,saveRenderingConfigurationForCamera,sceneAsset,scriptAssetsCache,scriptAssetsParsers,scriptsDictionary,selectVolumetricLights,serializeDefaultRenderingPipeline,serializeMotionBlurPostProcess,serializeSSAO2RenderingPipeline,serializeSSRRenderingPipeline,serializeTAARenderingPipeline,serializeVLSPostProcess,serializeVolumetricLightingRenderingPipeline,setDefaultRenderingPipelineRef,setMotionBlurPostProcessRef,setSSAO2RenderingPipelineRef,setSSRRenderingPipelineRef,setStaticDecalsEnabled,setTAARenderingPipelineRef,setUseKtx2CompressedTextures,setVLSPostProcessRef,setVolumetricLightingRenderingPipelineConfiguration,setVolumetricLightingRenderingPipelineRef,setupOfflineProvider,soundFromScene,spriteFromSpriteManager,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,supportsVolumetricFloatDepthTexture,taaRenderingPipelineCameraConfigurations,visibleAsAsset,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsKeyMap,visibleAsNumber,visibleAsString,visibleAsTexture,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations,volumetricLightMetadataKey,volumetricLightingPrePassConfigurationName,volumetricTemporalSamplesDivider});
|
|
2626
|
+
`}_buildComposeDefines(e){let i=this._buildLinearDepthReadDefines(e);return i+=`#define VOL_DEBUG ${this._configuration.debugMode}
|
|
2627
|
+
`,e.ldrEncode&&(i+=`#define VOL_LDR_ENCODE
|
|
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});
|