babylonjs-editor-tools 5.5.1-alpha.0 → 5.5.1-alpha.1
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 +67 -55
- package/build/src/decorators/inspector.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 +3 -0
- package/build/src/loading/loader.js.map +1 -1
- package/build/src/loading/script/preload/plugins/navmesh.js +3 -0
- package/build/src/loading/script/preload/plugins/navmesh.js.map +1 -1
- package/build/src/loading/sound.js +17 -2
- package/build/src/loading/sound.js.map +1 -1
- package/build/src/rendering/default-pipeline.js +5 -8
- package/build/src/rendering/default-pipeline.js.map +1 -1
- package/build/src/rendering/motion-blur.js +7 -7
- package/build/src/rendering/motion-blur.js.map +1 -1
- package/build/src/rendering/ssao.js +9 -9
- package/build/src/rendering/ssao.js.map +1 -1
- package/build/src/rendering/ssr.js +7 -9
- package/build/src/rendering/ssr.js.map +1 -1
- package/build/src/rendering/taa.js +7 -9
- package/build/src/rendering/taa.js.map +1 -1
- package/build/src/rendering/tools.js +32 -7
- package/build/src/rendering/tools.js.map +1 -1
- package/build/src/rendering/vls.js +13 -11
- package/build/src/rendering/vls.js.map +1 -1
- package/build/src/rendering/volumetric/depth.js +110 -0
- package/build/src/rendering/volumetric/depth.js.map +1 -0
- package/build/src/rendering/volumetric/pipeline.js +164 -9
- package/build/src/rendering/volumetric/pipeline.js.map +1 -1
- package/build/src/rendering/volumetric/shaders-wgsl.js +12 -7
- package/build/src/rendering/volumetric/shaders-wgsl.js.map +1 -1
- package/build/src/rendering/volumetric/shaders.js +17 -10
- package/build/src/rendering/volumetric/shaders.js.map +1 -1
- package/build/src/rendering/volumetric-lighting.js +5 -3
- package/build/src/rendering/volumetric-lighting.js.map +1 -1
- package/build/src/tools/ragdoll.js +54 -0
- package/build/src/tools/ragdoll.js.map +1 -1
- package/declaration/src/decorators/inspector.d.ts +1 -0
- package/declaration/src/index.d.ts +1 -0
- package/declaration/src/rendering/default-pipeline.d.ts +3 -2
- package/declaration/src/rendering/motion-blur.d.ts +3 -2
- package/declaration/src/rendering/ssao.d.ts +3 -2
- package/declaration/src/rendering/ssr.d.ts +3 -2
- package/declaration/src/rendering/taa.d.ts +3 -2
- package/declaration/src/rendering/tools.d.ts +17 -1
- package/declaration/src/rendering/vls.d.ts +3 -2
- package/declaration/src/rendering/volumetric/depth.d.ts +68 -0
- package/declaration/src/rendering/volumetric/pipeline.d.ts +55 -2
- package/declaration/src/rendering/volumetric/shaders.d.ts +1 -1
- package/declaration/src/rendering/volumetric-lighting.d.ts +3 -2
- package/declaration/src/tools/ragdoll.d.ts +20 -1
- package/package.json +2 -2
package/build/index.node.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
var We=Object.defineProperty;var nn=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames;var sn=Object.prototype.hasOwnProperty;var n=(t,e)=>We(t,"name",{value:e,configurable:!0});var ln=(t,e)=>{for(var i in e)We(t,i,{get:e[i],enumerable:!0})},cn=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of an(e))!sn.call(t,r)&&r!==i&&We(t,r,{get:()=>e[r],enumerable:!(o=nn(e,r))||o.enumerable});return t};var pn=t=>cn(We({},"__esModule",{value:!0}),t);var Wa={};ln(Wa,{AdvancedAssetContainer:()=>Fe,AdvancedAssetContainerInstantiatedEntries:()=>Ve,Cinematic:()=>ze,Database:()=>ke,NodeParticleSystemSet:()=>Xr.NodeParticleSystemSet,VolumetricDebugMode:()=>lo,VolumetricDitherMode:()=>Jt,VolumetricFogMode:()=>ei,VolumetricLightingRenderingPipeline:()=>Y,VolumetricShadowKind:()=>ni,VolumetricShadowMode:()=>go,VolumetricStepDistribution:()=>so,VolumetricTransmittanceMode:()=>ai,_applyScriptsForObject:()=>B,_getKtx2TextureName:()=>lt,_preloadScriptsAssets:()=>Di,_registerScriptInstance:()=>Pi,_removeRegisteredScriptInstance:()=>nt,addExcludedCompressedTexture:()=>ct,animationFromSprite:()=>Ra,animationGroupFromScene:()=>ua,applyMeshesLODQuality:()=>wt,applyRenderingConfigurationForCamera:()=>fi,applyScriptOnObject:()=>ra,applyShadowsQuality:()=>vn,applyTexturesQuality:()=>sa,componentFromScene:()=>da,computeVolumetricBudget:()=>Ae,computeVolumetricShapeKey:()=>Rn,configureEngineToUseCompressedTextures:()=>aa,configureMeshDistanceOrScreenCoverage:()=>_t,configureShadowMapRefreshRate:()=>Ke,configureShadowMapRenderListPredicate:()=>Pt,copyAndParseRagdollConfiguration:()=>vi,createAndOpenDatabase:()=>Gi,createDefaultRenderingPipeline:()=>ao,createMotionBlurPostProcess:()=>to,createSSAO2RenderingPipeline:()=>Ji,createSSRRenderingPipeline:()=>Zi,createTAARenderingPipeline:()=>qi,createVLSPostProcess:()=>Ki,createVolumetricLightingRenderingPipeline:()=>Io,defaultPipelineCameraConfigurations:()=>ue,disposeDefaultRenderingPipeline:()=>$t,disposeMotionBlurPostProcess:()=>kt,disposeSSAO2RenderingPipeline:()=>Gt,disposeSSRRenderingPipeline:()=>It,disposeTAARenderingPipeline:()=>Vt,disposeVLSPostProcess:()=>Et,disposeVolumetricLightingRenderingPipeline:()=>mi,ensureVolumetricLightConfiguration:()=>po,forceCompileAllSceneMaterials:()=>ma,generateCinematicAnimationGroup:()=>Ba,getAllScriptsByClassForObject:()=>Ce,getAllVolumetricCandidateLights:()=>vo,getAnimationTypeForObject:()=>Be,getDefaultRenderingPipeline:()=>Ee,getDefaultVolumetricLightConfiguration:()=>qt,getDefaultVolumetricLightingConfiguration:()=>je,getFromIndexDB:()=>He,getMotionBlurPostProcess:()=>Ht,getPowerOfTwoUntil:()=>F,getSSAO2RenderingPipeline:()=>Cn,getSSRRenderingPipeline:()=>yn,getScriptByClassForObject:()=>wi,getTAARenderingPipeline:()=>xn,getTextureUrl:()=>pt,getVLSPostProcess:()=>Ot,getVolumetricLightConfiguration:()=>ii,getVolumetricLightRange:()=>qe,getVolumetricLightSteps:()=>ti,getVolumetricLightWorldDirection:()=>Te,getVolumetricLightWorldPosition:()=>Ye,getVolumetricLightingRenderingPipeline:()=>To,guiFromAsset:()=>va,isAbstractMesh:()=>ie,isAnyParticleSystem:()=>xt,isArcRotateCamera:()=>fn,isBone:()=>mn,isCamera:()=>Xe,isCascadedShadowGenerator:()=>St,isCinematicGroup:()=>Na,isCinematicKey:()=>Fi,isCinematicKeyCut:()=>_e,isCinematicKeyEvent:()=>Fa,isCinematicSound:()=>Ga,isClusteredLightContainer:()=>le,isDecalMesh:()=>Hi,isDirectionalLight:()=>ee,isFreeCamera:()=>dn,isGPUParticleSystem:()=>un,isGaussianSplattingMesh:()=>Ct,isGroundMesh:()=>hn,isHemisphericLight:()=>$e,isInstancedMesh:()=>Pe,isLight:()=>zi,isMesh:()=>V,isNode:()=>ce,isNodeFromStaticGroup:()=>Dt,isParticleSystem:()=>bt,isPointLight:()=>gt,isScene:()=>yt,isShadowGenerator:()=>vt,isSoundNode:()=>re,isSpotLight:()=>oe,isSprite:()=>Lt,isTexture:()=>Oe,isTransformNode:()=>J,isUsingKtx2CompressedTextures:()=>Ge,isVolumetricLightEnabled:()=>Pn,isVolumetricLightSupported:()=>Vn,isVolumetricLightingSupported:()=>qn,loadMaterialFromFile:()=>pa,loadScene:()=>ca,markVolumetricLightsDirty:()=>Qn,maxVolumetricArrayLights:()=>$,maxVolumetricDirectionalLights:()=>Qt,maxVolumetricShadowSlots:()=>A,motionBlurPostProcessCameraConfigurations:()=>fe,nodeFromDescendants:()=>fa,nodeFromScene:()=>ha,normalizeAtlasJson:()=>Ei,normalizeVolumetricLightConfiguration:()=>co,normalizeVolumetricLightingConfiguration:()=>ge,onKeyboardEvent:()=>Ia,onPointerEvent:()=>Ta,openIndexDB:()=>Ni,parseCinematic:()=>Va,parseCinematicKeyValue:()=>k,parseDefaultRenderingPipeline:()=>jt,parseKeyFrameAnimations:()=>Ri,parseMotionBlurPostProcess:()=>Wt,parseRagdollConfiguration:()=>Go,parseSSAO2RenderingPipeline:()=>zt,parseSSRRenderingPipeline:()=>Rt,parseTAARenderingPipeline:()=>Nt,parseVLSPostProcess:()=>Tt,parseVolumetricLightingRenderingPipeline:()=>di,particleSystemFromScene:()=>ya,playSpriteAnimationFromName:()=>la,preloadAssetsToDatabase:()=>Ua,putInIndexDB:()=>W,registerScriptAssetParser:()=>oa,resolveVolumetricShadowSlot:()=>So,saveRenderingConfigurationForCamera:()=>Jn,sceneAsset:()=>ga,scriptAssetsCache:()=>I,scriptAssetsParsers:()=>Ne,scriptsDictionary:()=>H,selectVolumetricLights:()=>si,serializeDefaultRenderingPipeline:()=>Kt,serializeMotionBlurPostProcess:()=>Ut,serializeSSAO2RenderingPipeline:()=>Bt,serializeSSRRenderingPipeline:()=>Mt,serializeTAARenderingPipeline:()=>Ft,serializeVLSPostProcess:()=>At,serializeVolumetricLightingRenderingPipeline:()=>hi,setDefaultRenderingPipelineRef:()=>wn,setMotionBlurPostProcessRef:()=>_n,setSSAO2RenderingPipelineRef:()=>Dn,setSSRRenderingPipelineRef:()=>bn,setStaticDecalsEnabled:()=>gn,setTAARenderingPipelineRef:()=>Ln,setUseKtx2CompressedTextures:()=>na,setVLSPostProcessRef:()=>Sn,setVolumetricLightingRenderingPipelineRef:()=>Yn,setupOfflineProvider:()=>za,soundFromScene:()=>Sa,spriteFromSpriteManager:()=>Ma,ssaoRenderingPipelineCameraConfigurations:()=>de,ssrRenderingPipelineCameraConfigurations:()=>me,taaRenderingPipelineCameraConfigurations:()=>he,visibleAsAsset:()=>Aa,visibleAsBoolean:()=>ba,visibleAsColor3:()=>_a,visibleAsColor4:()=>wa,visibleAsEntity:()=>Pa,visibleAsKeyMap:()=>Ea,visibleAsNumber:()=>La,visibleAsString:()=>xa,visibleAsTexture:()=>Oa,visibleAsVector2:()=>Ca,visibleAsVector3:()=>Da,vlsPostProcessCameraConfigurations:()=>pe,volumetricLightMetadataKey:()=>ne,volumetricLightingRenderingPipelineCameraConfigurations:()=>Se});module.exports=pn(Wa);function ie(t){switch(t.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}n(ie,"isAbstractMesh");function V(t){switch(t.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}n(V,"isMesh");function Pe(t){return t.getClassName?.()==="InstancedMesh"}n(Pe,"isInstancedMesh");function mn(t){return t.getClassName?.()==="Bone"}n(mn,"isBone");function hn(t){return t.getClassName?.()==="GroundMesh"}n(hn,"isGroundMesh");function J(t){return t.getClassName?.()==="TransformNode"}n(J,"isTransformNode");function Oe(t){return t?.getClassName?.()==="Texture"}n(Oe,"isTexture");function Xe(t){switch(t.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}n(Xe,"isCamera");function dn(t){switch(t.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}n(dn,"isFreeCamera");function fn(t){return t.getClassName?.()==="ArcRotateCamera"}n(fn,"isArcRotateCamera");function gt(t){return t.getClassName?.()==="PointLight"}n(gt,"isPointLight");function ee(t){return t.getClassName?.()==="DirectionalLight"}n(ee,"isDirectionalLight");function oe(t){return t.getClassName?.()==="SpotLight"}n(oe,"isSpotLight");function $e(t){return t.getClassName?.()==="HemisphericLight"}n($e,"isHemisphericLight");function zi(t){switch(t.getClassName?.()){case"Light":case"PointLight":case"SpotLight":case"DirectionalLight":case"HemisphericLight":return!0}return!1}n(zi,"isLight");function vt(t){return t.getClassName?.()==="ShadowGenerator"}n(vt,"isShadowGenerator");function St(t){return t.getClassName?.()==="CascadedShadowGenerator"}n(St,"isCascadedShadowGenerator");function le(t){return t.getClassName?.()==="ClusteredLightContainer"}n(le,"isClusteredLightContainer");function ce(t){return ie(t)||J(t)||zi(t)||Xe(t)}n(ce,"isNode");function yt(t){return t.getClassName?.()==="Scene"}n(yt,"isScene");function bt(t){return t.getClassName?.()==="ParticleSystem"}n(bt,"isParticleSystem");function un(t){return t.getClassName?.()==="GPUParticleSystem"}n(un,"isGPUParticleSystem");function xt(t){switch(t.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}n(xt,"isAnyParticleSystem");function Lt(t){return t.getClassName?.()==="Sprite"}n(Lt,"isSprite");function re(t){return t.getClassName?.()==="SoundNode"}n(re,"isSoundNode");function Ct(t){return t.getClassName?.()==="GaussianSplattingMesh"}n(Ct,"isGaussianSplattingMesh");function Dt(t){let e=t;for(;e;){if(e.metadata?.isStaticGroup)return!0;e=e.parent}return!1}n(Dt,"isNodeFromStaticGroup");function _t(t){t.meshes.forEach(e=>{V(e)&&e.getLODLevels().forEach(i=>{i.mesh&&(i.mesh.originalDistanceOrScreenCoverage=i.distanceOrScreenCoverage)})})}n(_t,"configureMeshDistanceOrScreenCoverage");function wt(t,e){e.meshes.forEach(i=>{V(i)&&i.getLODLevels().forEach(o=>{if(o.mesh?.originalDistanceOrScreenCoverage)switch(t){case"very-low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.125;break;case"low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.25;break;case"medium":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.5;break;case"high":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage;break}})})}n(wt,"applyMeshesLODQuality");function Hi(t){return(t.metadata?.decal??null)!==null}n(Hi,"isDecalMesh");function gn(t,e){e.meshes.forEach(i=>{Hi(i)&&Dt(i)&&i.setEnabled(t)})}n(gn,"setStaticDecalsEnabled");function F(t){let e=1;for(;e<=t;)e<<=1;return e>>1}n(F,"getPowerOfTwoUntil");var ki=require("babylonjs"),Ui=require("babylonjs");function Pt(t){t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.renderListPredicate=o=>Ct(o)?!1:ki.Vector3.Distance(o.getAbsolutePosition(),e.getAbsolutePosition())<=e.range)})}n(Pt,"configureShadowMapRenderListPredicate");async function Ke(t){t.executeWhenReady(()=>{t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.refreshRate=e.metadata?.refreshRate??Ui.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}n(Ke,"configureShadowMapRefreshRate");function vn(t,e){e.lights.forEach(i=>{let o=i.getShadowGenerator(),r=o?.getShadowMap();if(o?.originalMapSize){let a=o.originalMapSize;switch(t){case"medium":a=a*.5;break;case"low":a=a*.25;break;case"very-low":a=a*.125;break}a=Math.max(128,F(a)),r?.getSize().width!==a&&r.resize(a)}}),Ke(e)}n(vn,"applyShadowsQuality");var Wi=require("babylonjs"),Xi=require("babylonjs"),$i=require("babylonjs"),O=null,pe=new Map;function Ot(){return O}n(Ot,"getVLSPostProcess");function Sn(t){O=t}n(Sn,"setVLSPostProcessRef");function Et(t){O&&t.activeCamera&&(O.dispose(t.activeCamera),O=null)}n(Et,"disposeVLSPostProcess");function Ki(t,e){return e??=t.meshes.find(i=>V(i)),O=new $i.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,t.activeCamera,e,100,Xi.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),O}n(Ki,"createVLSPostProcess");function At(){return O?{meshId:O.mesh?.id,exposure:O.exposure,decay:O.decay,weight:O.weight,density:O.density,invert:O.invert,useCustomMeshPosition:O.useCustomMeshPosition,customMeshPosition:O.customMeshPosition.asArray()}:null}n(At,"serializeVLSPostProcess");function Tt(t,e){let i=null;if(e.meshId){let r=t.getMeshById(e.meshId);r&&V(r)&&(i=r)}let o=Ki(t,i);return 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(Wi.Vector3.FromArray(e.customMeshPosition)),o}n(Tt,"parseVLSPostProcess");var ji=require("babylonjs"),D=null,me=new Map;function yn(){return D}n(yn,"getSSRRenderingPipeline");function bn(t){D=t}n(bn,"setSSRRenderingPipelineRef");function It(){D&&(D.dispose(),D=null)}n(It,"disposeSSRRenderingPipeline");function Zi(t,e){return D=new ji.SSRRenderingPipeline("SSRRenderingPipeline",t,[e]),D.samples=4,D}n(Zi,"createSSRRenderingPipeline");function Mt(){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}n(Mt,"serializeSSRRenderingPipeline");function Rt(t,e,i){if(D)return D;let o=Zi(t,e);return o.samples=i.samples,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}n(Rt,"parseSSRRenderingPipeline");var Yi=require("babylonjs"),E=null,he=new Map;function xn(){return E}n(xn,"getTAARenderingPipeline");function Ln(t){E=t}n(Ln,"setTAARenderingPipelineRef");function Vt(){E&&(E.dispose(),E=null)}n(Vt,"disposeTAARenderingPipeline");function qi(t,e){return E=new Yi.TAARenderingPipeline("TAARenderingPipeline",t,[e]),E.samples=4,E}n(qi,"createTAARenderingPipeline");function Ft(){return E?{factor:E.factor,samples:E.samples,clampHistory:E.clampHistory,reprojectHistory:E.reprojectHistory,disableOnCameraMove:E.disableOnCameraMove}:null}n(Ft,"serializeTAARenderingPipeline");function Nt(t,e,i){if(E)return E;let o=qi(t,e);return o.factor=i.factor,o.samples=i.samples,o.clampHistory=i.clampHistory,o.reprojectHistory=i.reprojectHistory,o.disableOnCameraMove=i.disableOnCameraMove,o}n(Nt,"parseTAARenderingPipeline");var Qi=require("babylonjs"),w=null,de=new Map;function Cn(){return w}n(Cn,"getSSAO2RenderingPipeline");function Dn(t){w=t}n(Dn,"setSSAO2RenderingPipelineRef");function Gt(){w&&(w.dispose(),w=null)}n(Gt,"disposeSSAO2RenderingPipeline");function Ji(t,e){return w=new Qi.SSAO2RenderingPipeline("SSAO2RenderingPipeline",t,1,[e]),w.samples=4,w}n(Ji,"createSSAO2RenderingPipeline");function Bt(){return w?{radius:w.radius,totalStrength:w.totalStrength,samples:w.samples,maxZ:w.maxZ,minZAspect:w.minZAspect,epsilon:w.epsilon,textureSamples:w.textureSamples,bypassBlur:w.bypassBlur,bilateralSamples:w.bilateralSamples,bilateralSoften:w.bilateralSoften,bilateralTolerance:w.bilateralTolerance,expensiveBlur:w.expensiveBlur}:null}n(Bt,"serializeSSAO2RenderingPipeline");function zt(t,e,i){if(w)return w;let o=Ji(t,e);return 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.textureSamples=i.textureSamples,o.bypassBlur=i.bypassBlur,o.bilateralSamples=i.bilateralSamples,o.bilateralSoften=i.bilateralSoften,o.bilateralTolerance=i.bilateralTolerance,o.expensiveBlur=i.expensiveBlur,o}n(zt,"parseSSAO2RenderingPipeline");var eo=require("babylonjs"),T=null,fe=new Map;function Ht(){return T}n(Ht,"getMotionBlurPostProcess");function _n(t){T=t}n(_n,"setMotionBlurPostProcessRef");function kt(){T&&(T.dispose(),T=null)}n(kt,"disposeMotionBlurPostProcess");function to(t,e){return T=new eo.MotionBlurPostProcess("MotionBlurPostProcess",t,1,e),T.motionStrength=1,T.isObjectBased=!0,T}n(to,"createMotionBlurPostProcess");function Ut(){return T?{isObjectBased:T.isObjectBased,motionStrength:T.motionStrength,motionBlurSamples:T.motionBlurSamples}:null}n(Ut,"serializeMotionBlurPostProcess");function Wt(t,e,i){if(T)return T;let o=to(t,e);return o.isObjectBased=i.isObjectBased,o.motionStrength=i.motionStrength,o.motionBlurSamples=i.motionBlurSamples,o}n(Wt,"parseMotionBlurPostProcess");var io=require("babylonjs"),Xt=require("babylonjs"),oo=require("babylonjs"),ro=require("babylonjs"),no=require("babylonjs"),u=null,ue=new Map;function Ee(){return u}n(Ee,"getDefaultRenderingPipeline");function wn(t){u=t}n(wn,"setDefaultRenderingPipelineRef");function $t(){u&&(u.dispose(),u=null)}n($t,"disposeDefaultRenderingPipeline");function ao(t,e){return u=new no.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,t,[e]),u.samples=4,u.depthOfField.lensSize=512,u.depthOfField.fStop=.25,u.depthOfField.focusDistance=55e3,u}n(ao,"createDefaultRenderingPipeline");function Kt(){return u?{samples:u.samples,fxaaEnabled:u.fxaaEnabled,imageProcessingEnabled:u.imageProcessingEnabled,exposure:u.imageProcessing?.exposure,contrast:u.imageProcessing?.contrast,fromLinearSpace:u.imageProcessing?.fromLinearSpace,toneMappingEnabled:u.imageProcessing?.toneMappingEnabled,toneMappingType:u.imageProcessing?.toneMappingType,ditheringEnabled:u.imageProcessing?.ditheringEnabled,ditheringIntensity:u.imageProcessing?.ditheringIntensity,bloomEnabled:u.bloomEnabled,bloomThreshold:u.bloomThreshold,bloomWeight:u.bloomWeight,bloomScale:u.bloomScale,bloomKernel:u.bloomKernel,sharpenEnabled:u.sharpenEnabled,sharpenEdgeAmount:u.sharpen.edgeAmount,sharpenColorAmount:u.sharpen.colorAmount,grainEnabled:u.grainEnabled,grainIntensity:u.grain.intensity,grainAnimated:u.grain.animated,depthOfFieldEnabled:u.depthOfFieldEnabled,depthOfFieldBlurLevel:u.depthOfFieldBlurLevel,lensSize:u.depthOfField.lensSize,fStop:u.depthOfField.fStop,focusDistance:u.depthOfField.focusDistance,focalLength:u.depthOfField.focalLength,vignetteEnabled:u.imageProcessing?.vignetteEnabled,vignetteColor:u.imageProcessing?.vignetteColor.asArray(),vignetteWeight:u.imageProcessing?.vignetteWeight,chromaticAberrationEnabled:u.chromaticAberrationEnabled,aberrationAmount:u.chromaticAberration.aberrationAmount,radialIntensity:u.chromaticAberration.radialIntensity,direction:u.chromaticAberration.direction.asArray(),centerPosition:u.chromaticAberration.centerPosition.asArray(),glowLayerEnabled:u.glowLayerEnabled,glowLayerIntensity:u.glowLayer?.intensity,glowLayerBlurKernelSize:u.glowLayer?.blurKernelSize,colorGradingEnabled:u.imageProcessing.colorGradingEnabled,colorGradingTexture:u.imageProcessing.colorGradingTexture?.serialize(),colorGradingWithGreenDepth:u.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth,colorCurvesEnabled:u.imageProcessing.colorCurvesEnabled,globalHue:u.imageProcessing.colorCurves?.globalHue,globalDensity:u.imageProcessing.colorCurves?.globalDensity,globalExposure:u.imageProcessing.colorCurves?.globalExposure,globalSaturation:u.imageProcessing.colorCurves?.globalSaturation,highlightsHue:u.imageProcessing.colorCurves?.highlightsHue,highlightsDensity:u.imageProcessing.colorCurves?.highlightsDensity,highlightsExposure:u.imageProcessing.colorCurves?.highlightsExposure,highlightsSaturation:u.imageProcessing.colorCurves?.highlightsSaturation,midtonesHue:u.imageProcessing.colorCurves?.midtonesHue,midtonesDensity:u.imageProcessing.colorCurves?.midtonesDensity,midtonesExposure:u.imageProcessing.colorCurves?.midtonesExposure,midtonesSaturation:u.imageProcessing.colorCurves?.midtonesSaturation,shadowsHue:u.imageProcessing.colorCurves?.shadowsHue,shadowsDensity:u.imageProcessing.colorCurves?.shadowsDensity,shadowsExposure:u.imageProcessing.colorCurves?.shadowsExposure,shadowsSaturation:u.imageProcessing.colorCurves?.shadowsSaturation}:null}n(Kt,"serializeDefaultRenderingPipeline");function jt(t,e,i,o){if(u)return u;let r=ao(t,e);if(r.samples=i.samples,r.fxaaEnabled=i.fxaaEnabled,r.imageProcessingEnabled=i.imageProcessingEnabled,r.imageProcessing){if(r.imageProcessing.exposure=i.exposure,r.imageProcessing.contrast=i.contrast,r.imageProcessing.fromLinearSpace=i.fromLinearSpace,r.imageProcessing.toneMappingEnabled=i.toneMappingEnabled,r.imageProcessing.toneMappingType=i.toneMappingType,r.imageProcessing.ditheringEnabled=i.ditheringEnabled,r.imageProcessing.ditheringIntensity=i.ditheringIntensity,r.imageProcessing.vignetteEnabled=i.vignetteEnabled??!1,r.imageProcessing.vignetteColor=io.Color4.FromArray(i.vignetteColor??[0,0,0]),r.imageProcessing.vignetteWeight=i.vignetteWeight??.3,r.imageProcessing.colorGradingEnabled=i.colorGradingEnabled??!1,r.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth=i.colorGradingWithGreenDepth??!0,i.colorGradingTexture){let a=null;if(i.colorGradingTexture.customType==="BABYLON.ColorGradingTexture"){let l=o+i.colorGradingTexture.name;a=new ro.ColorGradingTexture(l,t),a.level=i.colorGradingTexture.level}else{let l=oo.Texture.Parse(i.colorGradingTexture,t,o);Oe(l)&&(a=l)}r.imageProcessing.colorGradingTexture=a}r.imageProcessing.colorCurvesEnabled=i.colorCurvesEnabled??!1,r.imageProcessing.colorCurves&&(r.imageProcessing.colorCurves.globalHue=i.globalHue??30,r.imageProcessing.colorCurves.globalDensity=i.globalDensity??0,r.imageProcessing.colorCurves.globalExposure=i.globalExposure??0,r.imageProcessing.colorCurves.globalSaturation=i.globalSaturation??0,r.imageProcessing.colorCurves.highlightsHue=i.highlightsHue??30,r.imageProcessing.colorCurves.highlightsDensity=i.highlightsDensity??0,r.imageProcessing.colorCurves.highlightsExposure=i.highlightsExposure??0,r.imageProcessing.colorCurves.highlightsSaturation=i.highlightsSaturation??0,r.imageProcessing.colorCurves.midtonesHue=i.midtonesHue??30,r.imageProcessing.colorCurves.midtonesDensity=i.midtonesDensity??0,r.imageProcessing.colorCurves.midtonesExposure=i.midtonesExposure??0,r.imageProcessing.colorCurves.midtonesSaturation=i.midtonesSaturation??0,r.imageProcessing.colorCurves.shadowsHue=i.shadowsHue??30,r.imageProcessing.colorCurves.shadowsDensity=i.shadowsDensity??0,r.imageProcessing.colorCurves.shadowsExposure=i.shadowsExposure??0,r.imageProcessing.colorCurves.shadowsSaturation=i.shadowsSaturation??0)}return r.bloomEnabled=i.bloomEnabled,r.bloomThreshold=i.bloomThreshold,r.bloomWeight=i.bloomWeight,r.bloomScale=i.bloomScale,r.bloomKernel=i.bloomKernel,r.sharpenEnabled=i.sharpenEnabled,r.sharpen.edgeAmount=i.sharpenEdgeAmount,r.sharpen.colorAmount=i.sharpenColorAmount,r.grainEnabled=i.grainEnabled,r.grain.intensity=i.grainIntensity,r.grain.animated=i.grainAnimated,r.depthOfFieldEnabled=i.depthOfFieldEnabled,r.depthOfFieldBlurLevel=i.depthOfFieldBlurLevel,r.depthOfField.lensSize=i.lensSize,r.depthOfField.fStop=i.fStop,r.depthOfField.focusDistance=i.focusDistance,r.depthOfField.focalLength=i.focalLength,r.chromaticAberrationEnabled=i.chromaticAberrationEnabled??!1,r.chromaticAberration.aberrationAmount=i.aberrationAmount??10,r.chromaticAberration.radialIntensity=i.radialIntensity??1,r.chromaticAberration.direction=Xt.Vector2.FromArray(i.direction??[0,0]),r.chromaticAberration.centerPosition=Xt.Vector2.FromArray(i.centerPosition??[0,0]),r.glowLayerEnabled=i.glowLayerEnabled??!1,r.glowLayer&&(r.glowLayer.intensity=i.glowLayerIntensity??1,r.glowLayer.blurKernelSize=i.glowLayerBlurKernelSize??32),r}n(jt,"parseDefaultRenderingPipeline");var ne="volumetricLighting",A=8,$=256,Qt=4,so=(i=>(i[i.Linear=0]="Linear",i[i.Exponential=1]="Exponential",i))(so||{}),Jt=(o=>(o[o.None=0]="None",o[o.Bayer=1]="Bayer",o[o.InterleavedGradientNoise=2]="InterleavedGradientNoise",o))(Jt||{}),ei=(o=>(o[o.Exponential=0]="Exponential",o[o.ExponentialSquared=1]="ExponentialSquared",o[o.Linear=2]="Linear",o))(ei||{}),lo=(r=>(r[r.None=0]="None",r[r.Scattering=1]="Scattering",r[r.Transmittance=2]="Transmittance",r[r.LightCount=3]="LightCount",r))(lo||{});function qt(){return{enabled:!1,volumeIntensity:1,anisotropy:.35,useCustomColor:!1,color:[1,1,1],castVolumetricShadows:!0,shadowDarkness:1,rangeMultiplier:1,priority:0}}n(qt,"getDefaultVolumetricLightConfiguration");function je(){return{steps:40,lightSteps:0,resolutionScale:.5,stepDistribution:1,ditherMode:2,ditherStrength:1,temporalJitter:!1,fogMode:0,fogDensity:5e-4,fogStart:0,fogEnd:2e3,fogColor:[1,1,1],albedo:1,maxDistance:1e4,heightFogEnabled:!1,heightFogBaseHeight:0,heightFogFalloff:.01,intensity:1.5,lightExtinctionEnabled:!0,lightExtinctionClamp:1e3,extinctionAmount:0,ambientColor:[1,1,1],ambientIntensity:0,screenSpaceShadows:!0,screenSpaceShadowSteps:6,screenSpaceShadowBias:.02,screenSpaceShadowMaxDistance:2e3,screenSpaceShadowThickness:4,blurPasses:2,blurRadius:3,blurDepthThreshold:.02,upsampleDepthThreshold:.02,maxLights:128,maxShadowedLights:4,pcfTaps:4,selectionRefreshRate:2,debugMode:0}}n(je,"getDefaultVolumetricLightingConfiguration");function ti(t){return t.lightSteps>0?t.lightSteps:Math.max(4,Math.min(64,Math.round(t.steps*.3)))}n(ti,"getVolumetricLightSteps");function y(t,e,i,o){let r=typeof t=="number"&&isFinite(t)?t:e;return Math.min(o,Math.max(i,r))}n(y,"normalizeNumber");function Zt(t,e){return!Array.isArray(t)||t.length<3?e.slice():[y(t[0],e[0],0,100),y(t[1],e[1],0,100),y(t[2],e[2],0,100)]}n(Zt,"normalizeColor");function co(t){let e=qt();return!t||typeof t!="object"?e:{enabled:t.enabled??e.enabled,volumeIntensity:y(t.volumeIntensity,e.volumeIntensity,0,1e3),anisotropy:y(t.anisotropy,e.anisotropy,-.95,.95),useCustomColor:t.useCustomColor??e.useCustomColor,color:Zt(t.color,e.color),castVolumetricShadows:t.castVolumetricShadows??e.castVolumetricShadows,shadowDarkness:y(t.shadowDarkness,e.shadowDarkness,0,1),rangeMultiplier:y(t.rangeMultiplier,e.rangeMultiplier,0,100),priority:y(t.priority,e.priority,-1e3,1e3)}}n(co,"normalizeVolumetricLightConfiguration");function ge(t){let e=je();return!t||typeof t!="object"?e:{steps:Math.round(y(t.steps,e.steps,4,256)),lightSteps:Math.round(y(t.lightSteps,e.lightSteps,0,128)),resolutionScale:y(t.resolutionScale,e.resolutionScale,.1,1),stepDistribution:Math.round(y(t.stepDistribution,e.stepDistribution,0,1)),ditherMode:Math.round(y(t.ditherMode,e.ditherMode,0,2)),ditherStrength:y(t.ditherStrength,e.ditherStrength,0,1),temporalJitter:t.temporalJitter??e.temporalJitter,fogMode:Math.round(y(t.fogMode,e.fogMode,0,2)),fogDensity:y(t.fogDensity,e.fogDensity,0,100),fogStart:y(t.fogStart,e.fogStart,0,1e6),fogEnd:Math.max(y(t.fogEnd,e.fogEnd,0,1e7),y(t.fogStart,e.fogStart,0,1e6)+.001),fogColor:Zt(t.fogColor,e.fogColor),albedo:y(t.albedo,e.albedo,0,1),maxDistance:y(t.maxDistance,e.maxDistance,1,1e6),heightFogEnabled:t.heightFogEnabled??e.heightFogEnabled,heightFogBaseHeight:y(t.heightFogBaseHeight,e.heightFogBaseHeight,-1e6,1e6),heightFogFalloff:y(t.heightFogFalloff,e.heightFogFalloff,0,10),intensity:y(t.intensity,e.intensity,0,100),lightExtinctionEnabled:t.lightExtinctionEnabled??e.lightExtinctionEnabled,lightExtinctionClamp:y(t.lightExtinctionClamp,e.lightExtinctionClamp,0,1e6),extinctionAmount:y(t.extinctionAmount,e.extinctionAmount,0,1),ambientColor:Zt(t.ambientColor,e.ambientColor),ambientIntensity:y(t.ambientIntensity,e.ambientIntensity,0,100),screenSpaceShadows:t.screenSpaceShadows??e.screenSpaceShadows,screenSpaceShadowSteps:Math.round(y(t.screenSpaceShadowSteps,e.screenSpaceShadowSteps,1,32)),screenSpaceShadowBias:y(t.screenSpaceShadowBias,e.screenSpaceShadowBias,0,1),screenSpaceShadowMaxDistance:y(t.screenSpaceShadowMaxDistance,e.screenSpaceShadowMaxDistance,1,1e7),screenSpaceShadowThickness:y(t.screenSpaceShadowThickness,e.screenSpaceShadowThickness,.01,1e3),blurPasses:Math.round(y(t.blurPasses,e.blurPasses,0,2)),blurRadius:Math.round(y(t.blurRadius,e.blurRadius,1,6)),blurDepthThreshold:y(t.blurDepthThreshold,e.blurDepthThreshold,1e-4,1),upsampleDepthThreshold:y(t.upsampleDepthThreshold,e.upsampleDepthThreshold,1e-4,1),maxLights:Math.round(y(t.maxLights,e.maxLights,0,$)),maxShadowedLights:Math.round(y(t.maxShadowedLights,e.maxShadowedLights,0,A)),pcfTaps:y(t.pcfTaps,e.pcfTaps,1,4)>=4?4:1,selectionRefreshRate:Math.round(y(t.selectionRefreshRate,e.selectionRefreshRate,1,60)),debugMode:Math.round(y(t.debugMode,e.debugMode,0,3))}}n(ge,"normalizeVolumetricLightingConfiguration");var Yt=new WeakSet;function po(t){t.metadata??={};let e=t.metadata[ne];if(!e||typeof e!="object")return t.metadata[ne]=co(null),Yt.add(t.metadata[ne]),t.metadata[ne];if(Yt.has(e))return e;let i=qt();return Object.keys(i).forEach(o=>{e[o]===void 0&&(e[o]=i[o])}),Yt.add(e),e}n(po,"ensureVolumetricLightConfiguration");function ii(t){let e=t.metadata?.[ne];return e&&typeof e=="object"?po(t):null}n(ii,"getVolumetricLightConfiguration");function Pn(t){return t.metadata?.[ne]?.enabled===!0}n(Pn,"isVolumetricLightEnabled");var Ze=require("babylonjs"),uo=require("babylonjs"),ri=require("babylonjs"),K=require("babylonjs"),ni=(o=>(o[o.Texture2D=0]="Texture2D",o[o.Sampler2DShadow=1]="Sampler2DShadow",o[o.Cube=2]="Cube",o))(ni||{}),go=(o=>(o[o.Standard=0]="Standard",o[o.Esm=1]="Esm",o[o.CloseEsm=2]="CloseEsm",o))(go||{}),ai=(o=>(o[o.Analytic=0]="Analytic",o[o.AnalyticHeight=1]="AnalyticHeight",o[o.Numeric=2]="Numeric",o))(ai||{}),mo=10,On=4,En=22,An=32,Tn=.15;function Ae(t,e){let i=t.getCaps(),o=i.maxFragmentUniformVectors||224,r=t.isWebGPU?Math.floor(o/4):o,a=Math.max(224,r)-An,l=Math.max(8,i.maxTexturesImageUnits||16)-1,p=l>=2,s=p?En:0,c=Math.max(0,Math.min(A,e.maxShadowedLights,l-(p?1:0),Math.floor((a-s)/mo))),m=Math.max(0,Math.min($,e.maxLights,Math.floor((a-s-c*mo)/On)));return{maxShadowSlots:c,maxArrayLights:m,maxDirectionalLights:Math.min(Qt,m),allowCsm:p}}n(Ae,"computeVolumetricBudget");function vo(t){let e=[];return t.lights.forEach(i=>{le(i)?i.lights.forEach(o=>{e.push({light:o,isClustered:!0})}):e.push({light:i,isClustered:!1})}),e}n(vo,"getAllVolumetricCandidateLights");function So(t,e){let i=t.getShadowGenerator(e.activeCamera)??t.getShadowGenerator();if(!i||!vt(i))return null;let o=i.getShadowMapForRendering();if(!o?.isReady())return null;let r=i.getShadowMap()?.getSize().width??1024,a=o.textureType===ri.Constants.TEXTURETYPE_UNSIGNED_BYTE,l=!ee(t),p=t.needCube?.()===!0;switch(i.filter){case K.ShadowGenerator.FILTER_PCF:case K.ShadowGenerator.FILTER_PCSS:return{generator:i,kind:p?2:1,mode:0,packed:a,mapSize:r,local:l};case K.ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP:case K.ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:1,packed:a,mapSize:r,local:l};case K.ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP:case K.ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:2,packed:a,mapSize:r,local:l};default:return{generator:i,kind:p?2:0,mode:0,packed:a,mapSize:r,local:l}}}n(So,"resolveVolumetricShadowSlot");function Ye(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}n(Ye,"getVolumetricLightWorldPosition");function Te(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()}n(Te,"getVolumetricLightWorldDirection");function qe(t,e,i){let o=t.range>0&&t.range<Number.MAX_VALUE?t.range:i.maxDistance;return Math.max(.001,Math.min(o*e.rangeMultiplier,34e37))}n(qe,"getVolumetricLightRange");var oi=new Ze.Vector3,ho=new Ze.Vector3;function In(t,e,i){if(Ye(t,i),!oe(t))return e;let o=Math.cos(t.angle*.5);if(o<=.5)return e;let r=e/(2*o);return Te(t,ho),i.addInPlace(ho.scaleInPlace(r)),r}n(In,"computeVolumetricLightBounds");function Mn(t,e,i){for(let o=0;o<i.length;++o)if(i[o].dotCoordinate(t)<=-e)return!1;return!0}n(Mn,"isSphereInFrustum");function fo(t){return(t.local?64:0)+t.kind*16+t.mode*4+(t.packed?1:0)}n(fo,"getShadowSlotSignature");function si(t,e,i,o,r){let a={candidateCount:0,culledCount:0,shadowedCount:0,unshadowedCount:0,droppedCount:0,perLight:new Map},l=uo.Frustum.GetPlanes(t.getTransformMatrix()),p=e.globalPosition,s=[];vo(t).forEach(({light:v,isClustered:L})=>{let R=ii(v);if(!R?.enabled)return;if(a.candidateCount++,$e(v)||!v.isEnabled()||v.intensity<=0||R.volumeIntensity<=0){a.perLight.set(v.uniqueId,{state:"disabled",slot:-1,reason:$e(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 X=ee(v),se=R.priority*1e3;if(X)se+=1e6;else{let Ue=Math.min(qe(v,R,i),i.maxDistance),ut=In(v,Ue,oi);if(!Mn(oi,ut,l)){a.culledCount++,a.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 rn=Math.max(1,Ze.Vector3.Distance(oi,p)-ut);se+=R.volumeIntensity*v.intensity*Math.min(4,ut/rn)}s.push({light:v,config:R,isClustered:L,typeId:v.getTypeID(),score:se})}),s.sort((v,L)=>L.score-v.score);let c=new Map;r?.shadowed.forEach((v,L)=>{c.set(v.candidate.light.uniqueId,L)});let m=[],h=[],d=new Map,f=null;s.forEach(v=>{let{light:L,config:R}=v;if(!R.castVolumetricShadows){d.set(L.uniqueId,"occlusion is disabled on this light."),h.push(v);return}if(v.isClustered){d.set(L.uniqueId,"clustered lighting doesn't support shadow maps."),h.push(v);return}if(!L.shadowEnabled||!t.shadowsEnabled){d.set(L.uniqueId,"shadows are disabled on this light or on the scene."),h.push(v);return}let X=L.getShadowGenerator(t.activeCamera)??L.getShadowGenerator();if(!X){d.set(L.uniqueId,"the light has no shadow generator."),h.push(v);return}if(St(X)&&o.allowCsm){let Ue=X.getShadowMapForRendering();if(!f&&Ue?.isReady()){f={candidate:v,generator:X,cascades:X.numCascades,kind:X.filter===K.ShadowGenerator.FILTER_PCF||X.filter===K.ShadowGenerator.FILTER_PCSS?1:0,packed:Ue.textureType===ri.Constants.TEXTURETYPE_UNSIGNED_BYTE};return}d.set(L.uniqueId,f?"another light already uses the single cascaded shadow map slot.":"its cascaded shadow map is not ready yet."),h.push(v);return}let se=So(L,t);if(!se){d.set(L.uniqueId,"the shadow map of the light is not ready yet."),h.push(v);return}m.push({candidate:v,shadow:se})});function S(v){let L=v.candidate.score;return c.get(v.candidate.light.uniqueId)===void 0?L:L+Math.abs(L)*Tn}n(S,"getHysteresisScore");function g(v){return c.get(v.candidate.light.uniqueId)??Number.MAX_SAFE_INTEGER}n(g,"getPreviousSlot"),m.sort((v,L)=>{let R=S(L)-S(v);return R!==0?R:g(v)-g(L)});let b=m.slice(0,o.maxShadowSlots);b.sort((v,L)=>fo(v.shadow)-fo(L.shadow)||g(v)-g(L)),m.slice(o.maxShadowSlots).forEach(v=>{d.set(v.candidate.light.uniqueId,"the shadowed lights budget is full."),h.push(v.candidate)}),h.sort((v,L)=>L.score-v.score);let C=[],_=[],x=[];h.forEach(v=>{ee(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.`}):_.push(v)});let M=Math.max(0,o.maxArrayLights-C.length);_.slice(M).forEach(v=>{x.push({candidate:v,reason:'Not rendered: the lights budget is full. Raise "Max Lights" or lower the priority of the other lights.'})});let G=C.concat(_.slice(0,M));if(b.forEach((v,L)=>{a.shadowedCount++,a.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:L,reason:`Casting volumetric shadows using slot ${L+1} of ${o.maxShadowSlots}.`})}),f){let v=f;a.shadowedCount++,a.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:-1,reason:`Casting volumetric shadows using its ${v.cascades} shadow cascades.`})}return G.forEach(v=>{a.unshadowedCount++;let L=v.config.castVolumetricShadows?"Occluded using the depth buffer":"Not occluded by the geometry",R=d.get(v.light.uniqueId)??"the light has no shadow map.";a.perLight.set(v.light.uniqueId,{state:"unshadowed",slot:-1,reason:`${L}: ${R}`})}),x.forEach(({candidate:v,reason:L})=>{a.droppedCount++,a.perLight.set(v.light.uniqueId,{state:"dropped",slot:-1,reason:L})}),{shadowed:b,unshadowed:G,directionalCount:C.length,csm:f,stats:a}}n(si,"selectVolumetricLights");function Rn(t,e,i){let o=t.shadowed.map(a=>`${a.shadow.kind}.${a.shadow.mode}.${a.shadow.packed?1:0}.${a.shadow.local?1:0}`).join("|"),r=t.csm?`${t.csm.kind}.${t.csm.cascades}.${t.csm.packed?1:0}`:"-";return[e.steps,i.lightSteps,e.stepDistribution,e.ditherMode,e.temporalJitter?1:0,e.heightFogEnabled?1:0,e.lightExtinctionEnabled?1:0,e.pcfTaps,e.blurRadius,e.debugMode,e.screenSpaceShadows?e.screenSpaceShadowSteps:0,i.fogMode,i.transmittance,i.depthMode,i.ldrEncode?1:0,i.reverseDepth?1:0,i.ndcHalfZ?1:0,i.linearDepthPacked?1:0,i.arrayLightCapacity,t.directionalCount,o,r].join(",")}n(Rn,"computeVolumetricShapeKey");function Vn(t){return gt(t)||oe(t)||ee(t)}n(Vn,"isVolumetricLightSupported");var Qe=`
|
|
1
|
+
var je=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var bn=Object.getOwnPropertyNames;var xn=Object.prototype.hasOwnProperty;var a=(t,e)=>je(t,"name",{value:e,configurable:!0});var Cn=(t,e)=>{for(var i in e)je(t,i,{get:e[i],enumerable:!0})},Ln=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of bn(e))!xn.call(t,r)&&r!==i&&je(t,r,{get:()=>e[r],enumerable:!(o=yn(e,r))||o.enumerable});return t};var Dn=t=>Ln(je({},"__esModule",{value:!0}),t);var ls={};Cn(ls,{AdvancedAssetContainer:()=>ze,AdvancedAssetContainerInstantiatedEntries:()=>Be,Cinematic:()=>We,Database:()=>$e,NodeParticleSystemSet:()=>an.NodeParticleSystemSet,VolumetricDebugMode:()=>xo,VolumetricDepthSource:()=>ui,VolumetricDitherMode:()=>ni,VolumetricFogMode:()=>ai,VolumetricLightingRenderingPipeline:()=>q,VolumetricShadowKind:()=>mi,VolumetricShadowMode:()=>Oo,VolumetricStepDistribution:()=>bo,VolumetricTransmittanceMode:()=>hi,_applyScriptsForObject:()=>B,_getKtx2TextureName:()=>ft,_preloadScriptsAssets:()=>Vi,_registerScriptInstance:()=>Gi,_removeRegisteredScriptInstance:()=>mt,addExcludedCompressedTexture:()=>ut,animationFromSprite:()=>Qa,animationGroupFromScene:()=>Ma,applyMeshesLODQuality:()=>It,applyRagdollJointLimits:()=>va,applyRenderingConfigurationForCamera:()=>_i,applyScriptOnObject:()=>Ca,applyShadowsQuality:()=>An,applyTexturesQuality:()=>_a,canUseHdr:()=>ga,componentFromScene:()=>Aa,computeVolumetricBudget:()=>Me,computeVolumetricShapeKey:()=>jn,configureEngineToUseCompressedTextures:()=>Da,configureMeshDistanceOrScreenCoverage:()=>At,configureShadowMapRefreshRate:()=>qe,configureShadowMapRenderListPredicate:()=>Mt,copyAndParseRagdollConfiguration:()=>Oi,createAndOpenDatabase:()=>Yi,createDefaultRenderingPipeline:()=>yo,createMotionBlurPostProcess:()=>fo,createSSAO2RenderingPipeline:()=>mo,createSSRRenderingPipeline:()=>so,createTAARenderingPipeline:()=>co,createVLSPostProcess:()=>no,createVolumetricLightingPrePassConfiguration:()=>gi,createVolumetricLightingRenderingPipeline:()=>Xo,defaultPipelineCameraConfigurations:()=>ve,disposeDefaultRenderingPipeline:()=>Qt,disposeMotionBlurPostProcess:()=>jt,disposeSSAO2RenderingPipeline:()=>Wt,disposeSSRRenderingPipeline:()=>Gt,disposeTAARenderingPipeline:()=>Ht,disposeVLSPostProcess:()=>Vt,disposeVolumetricLightingRenderingPipeline:()=>Ci,ensureVolumetricLightConfiguration:()=>Lo,forceCompileAllSceneMaterials:()=>Ea,generateCinematicAnimationGroup:()=>os,getAllScriptsByClassForObject:()=>Pe,getAllVolumetricCandidateLights:()=>Eo,getAnimationTypeForObject:()=>Ue,getDefaultRenderingPipeline:()=>Ie,getDefaultVolumetricLightConfiguration:()=>oi,getDefaultVolumetricLightingConfiguration:()=>Qe,getFromIndexDB:()=>Xe,getHdrTextureType:()=>$,getMotionBlurPostProcess:()=>Kt,getPowerOfTwoUntil:()=>N,getSSAO2RenderingPipeline:()=>Nn,getSSRRenderingPipeline:()=>Mn,getScriptByClassForObject:()=>Ni,getTAARenderingPipeline:()=>Vn,getTextureUrl:()=>gt,getVLSPostProcess:()=>Rt,getVolumetricGeometryBufferDepthTexture:()=>Si,getVolumetricGeometryBufferRenderer:()=>Ve,getVolumetricLightConfiguration:()=>li,getVolumetricLightRange:()=>tt,getVolumetricLightSteps:()=>si,getVolumetricLightWorldDirection:()=>Re,getVolumetricLightWorldPosition:()=>et,getVolumetricLightingRenderingPipeline:()=>ma,getVolumetricPrePassDepthTexture:()=>vi,getVolumetricPrePassRenderer:()=>ye,guiFromAsset:()=>Va,isAbstractMesh:()=>re,isAnyParticleSystem:()=>wt,isArcRotateCamera:()=>On,isBone:()=>_n,isCamera:()=>Ze,isCascadedShadowGenerator:()=>Dt,isCinematicGroup:()=>ts,isCinematicKey:()=>ji,isCinematicKeyCut:()=>Oe,isCinematicKeyEvent:()=>es,isCinematicSound:()=>is,isClusteredLightContainer:()=>pe,isDecalMesh:()=>Ji,isDirectionalLight:()=>ie,isFreeCamera:()=>wn,isGPUParticleSystem:()=>En,isGaussianSplattingMesh:()=>Et,isGroundMesh:()=>Pn,isHemisphericLight:()=>Ye,isInstancedMesh:()=>Te,isLight:()=>Qi,isMesh:()=>F,isNode:()=>me,isNodeFromStaticGroup:()=>Tt,isParticleSystem:()=>Pt,isPointLight:()=>Ct,isScene:()=>_t,isShadowGenerator:()=>Lt,isSoundNode:()=>ae,isSpotLight:()=>ne,isSprite:()=>Ot,isTexture:()=>Ae,isTransformNode:()=>te,isUsingKtx2CompressedTextures:()=>ke,isVolumetricLightEnabled:()=>Hn,isVolumetricLightSupported:()=>Zn,isVolumetricLightingSupported:()=>da,loadMaterialFromFile:()=>Oa,loadScene:()=>wa,markVolumetricLightsDirty:()=>fa,maxVolumetricArrayLights:()=>K,maxVolumetricDirectionalLights:()=>ri,maxVolumetricShadowSlots:()=>E,motionBlurPostProcessCameraConfigurations:()=>ge,nodeFromDescendants:()=>Ia,nodeFromScene:()=>Ta,normalizeAtlasJson:()=>zi,normalizeVolumetricLightConfiguration:()=>Co,normalizeVolumetricLightingConfiguration:()=>Se,onKeyboardEvent:()=>Ya,onPointerEvent:()=>Za,openIndexDB:()=>Zi,parseCinematic:()=>Ja,parseCinematicKeyValue:()=>k,parseDefaultRenderingPipeline:()=>ei,parseKeyFrameAnimations:()=>$i,parseMotionBlurPostProcess:()=>Yt,parseRagdollConfiguration:()=>Qo,parseSSAO2RenderingPipeline:()=>$t,parseSSRRenderingPipeline:()=>zt,parseTAARenderingPipeline:()=>Ut,parseVLSPostProcess:()=>Nt,parseVolumetricLightingRenderingPipeline:()=>Di,particleSystemFromScene:()=>Na,playSpriteAnimationFromName:()=>Pa,preloadAssetsToDatabase:()=>ss,putInIndexDB:()=>W,registerScriptAssetParser:()=>xa,resolveVolumetricDepthSource:()=>it,resolveVolumetricShadowSlot:()=>To,saveRenderingConfigurationForCamera:()=>ua,sceneAsset:()=>Ra,scriptAssetsCache:()=>I,scriptAssetsParsers:()=>He,scriptsDictionary:()=>H,selectVolumetricLights:()=>di,serializeDefaultRenderingPipeline:()=>Jt,serializeMotionBlurPostProcess:()=>Zt,serializeSSAO2RenderingPipeline:()=>Xt,serializeSSRRenderingPipeline:()=>Bt,serializeTAARenderingPipeline:()=>kt,serializeVLSPostProcess:()=>Ft,serializeVolumetricLightingRenderingPipeline:()=>Li,setDefaultRenderingPipelineRef:()=>zn,setMotionBlurPostProcessRef:()=>Bn,setSSAO2RenderingPipelineRef:()=>Gn,setSSRRenderingPipelineRef:()=>Rn,setStaticDecalsEnabled:()=>Tn,setTAARenderingPipelineRef:()=>Fn,setUseKtx2CompressedTextures:()=>La,setVLSPostProcessRef:()=>In,setVolumetricLightingRenderingPipelineRef:()=>ha,setupOfflineProvider:()=>rs,soundFromScene:()=>Fa,spriteFromSpriteManager:()=>qa,ssaoRenderingPipelineCameraConfigurations:()=>ue,ssrRenderingPipelineCameraConfigurations:()=>de,supportsVolumetricFloatDepthTexture:()=>Io,taaRenderingPipelineCameraConfigurations:()=>fe,visibleAsAsset:()=>ja,visibleAsBoolean:()=>Ga,visibleAsColor3:()=>Ua,visibleAsColor4:()=>Wa,visibleAsEntity:()=>Xa,visibleAsKeyMap:()=>Ka,visibleAsNumber:()=>za,visibleAsString:()=>Ba,visibleAsTexture:()=>$a,visibleAsVector2:()=>Ha,visibleAsVector3:()=>ka,vlsPostProcessCameraConfigurations:()=>he,volumetricLightMetadataKey:()=>se,volumetricLightingPrePassConfigurationName:()=>Ao,volumetricLightingRenderingPipelineCameraConfigurations:()=>xe});module.exports=Dn(ls);function re(t){switch(t.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}a(re,"isAbstractMesh");function F(t){switch(t.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}a(F,"isMesh");function Te(t){return t.getClassName?.()==="InstancedMesh"}a(Te,"isInstancedMesh");function _n(t){return t.getClassName?.()==="Bone"}a(_n,"isBone");function Pn(t){return t.getClassName?.()==="GroundMesh"}a(Pn,"isGroundMesh");function te(t){return t.getClassName?.()==="TransformNode"}a(te,"isTransformNode");function Ae(t){return t?.getClassName?.()==="Texture"}a(Ae,"isTexture");function Ze(t){switch(t.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}a(Ze,"isCamera");function wn(t){switch(t.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}a(wn,"isFreeCamera");function On(t){return t.getClassName?.()==="ArcRotateCamera"}a(On,"isArcRotateCamera");function Ct(t){return t.getClassName?.()==="PointLight"}a(Ct,"isPointLight");function ie(t){return t.getClassName?.()==="DirectionalLight"}a(ie,"isDirectionalLight");function ne(t){return t.getClassName?.()==="SpotLight"}a(ne,"isSpotLight");function Ye(t){return t.getClassName?.()==="HemisphericLight"}a(Ye,"isHemisphericLight");function Qi(t){switch(t.getClassName?.()){case"Light":case"PointLight":case"SpotLight":case"DirectionalLight":case"HemisphericLight":return!0}return!1}a(Qi,"isLight");function Lt(t){return t.getClassName?.()==="ShadowGenerator"}a(Lt,"isShadowGenerator");function Dt(t){return t.getClassName?.()==="CascadedShadowGenerator"}a(Dt,"isCascadedShadowGenerator");function pe(t){return t.getClassName?.()==="ClusteredLightContainer"}a(pe,"isClusteredLightContainer");function me(t){return re(t)||te(t)||Qi(t)||Ze(t)}a(me,"isNode");function _t(t){return t.getClassName?.()==="Scene"}a(_t,"isScene");function Pt(t){return t.getClassName?.()==="ParticleSystem"}a(Pt,"isParticleSystem");function En(t){return t.getClassName?.()==="GPUParticleSystem"}a(En,"isGPUParticleSystem");function wt(t){switch(t.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}a(wt,"isAnyParticleSystem");function Ot(t){return t.getClassName?.()==="Sprite"}a(Ot,"isSprite");function ae(t){return t.getClassName?.()==="SoundNode"}a(ae,"isSoundNode");function Et(t){return t.getClassName?.()==="GaussianSplattingMesh"}a(Et,"isGaussianSplattingMesh");function Tt(t){let e=t;for(;e;){if(e.metadata?.isStaticGroup)return!0;e=e.parent}return!1}a(Tt,"isNodeFromStaticGroup");function At(t){t.meshes.forEach(e=>{F(e)&&e.getLODLevels().forEach(i=>{i.mesh&&(i.mesh.originalDistanceOrScreenCoverage=i.distanceOrScreenCoverage)})})}a(At,"configureMeshDistanceOrScreenCoverage");function It(t,e){e.meshes.forEach(i=>{F(i)&&i.getLODLevels().forEach(o=>{if(o.mesh?.originalDistanceOrScreenCoverage)switch(t){case"very-low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.125;break;case"low":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.25;break;case"medium":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage*.5;break;case"high":o.distanceOrScreenCoverage=o.mesh.originalDistanceOrScreenCoverage;break}})})}a(It,"applyMeshesLODQuality");function Ji(t){return(t.metadata?.decal??null)!==null}a(Ji,"isDecalMesh");function Tn(t,e){e.meshes.forEach(i=>{Ji(i)&&Tt(i)&&i.setEnabled(t)})}a(Tn,"setStaticDecalsEnabled");function N(t){let e=1;for(;e<=t;)e<<=1;return e>>1}a(N,"getPowerOfTwoUntil");var eo=require("babylonjs"),to=require("babylonjs");function Mt(t){t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.renderListPredicate=o=>Et(o)?!1:eo.Vector3.Distance(o.getAbsolutePosition(),e.getAbsolutePosition())<=e.range)})}a(Mt,"configureShadowMapRenderListPredicate");async function qe(t){t.executeWhenReady(()=>{t.lights.forEach(e=>{let i=e.getShadowGenerator()?.getShadowMap();i&&(i.refreshRate=e.metadata?.refreshRate??to.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}a(qe,"configureShadowMapRefreshRate");function An(t,e){e.lights.forEach(i=>{let o=i.getShadowGenerator(),r=o?.getShadowMap();if(o?.originalMapSize){let n=o.originalMapSize;switch(t){case"medium":n=n*.5;break;case"low":n=n*.25;break;case"very-low":n=n*.125;break}n=Math.max(128,N(n)),r?.getSize().width!==n&&r.resize(n)}}),qe(e)}a(An,"applyShadowsQuality");var io=require("babylonjs"),oo=require("babylonjs"),ro=require("babylonjs"),w=null,he=new Map;function Rt(){return w}a(Rt,"getVLSPostProcess");function In(t){w=t}a(In,"setVLSPostProcessRef");function Vt(t){w&&t.activeCamera&&(w.dispose(t.activeCamera),w=null)}a(Vt,"disposeVLSPostProcess");function no(t,e,i){return e??=t.meshes.find(o=>F(o)),w=new ro.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,t.activeCamera,e,100,oo.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),w.samples=i?.msaaSamples??1,w}a(no,"createVLSPostProcess");function Ft(){return w?{meshId:w.mesh?.id,exposure:w.exposure,decay:w.decay,weight:w.weight,density:w.density,invert:w.invert,useCustomMeshPosition:w.useCustomMeshPosition,customMeshPosition:w.customMeshPosition.asArray()}:null}a(Ft,"serializeVLSPostProcess");function Nt(t,e,i){let o=null;if(e.meshId){let n=t.getMeshById(e.meshId);n&&F(n)&&(o=n)}let r=w??no(t,o,i);return r.samples=i?.msaaSamples??1,r.exposure=e.exposure,r.decay=e.decay,r.weight=e.weight,r.density=e.density,r.invert=e.invert,r.useCustomMeshPosition=e.useCustomMeshPosition,r.customMeshPosition.copyFrom(io.Vector3.FromArray(e.customMeshPosition)),r}a(Nt,"parseVLSPostProcess");var ao=require("babylonjs"),D=null,de=new Map;function Mn(){return D}a(Mn,"getSSRRenderingPipeline");function Rn(t){D=t}a(Rn,"setSSRRenderingPipelineRef");function Gt(){D&&(D.dispose(),D=null)}a(Gt,"disposeSSRRenderingPipeline");function so(t,e,i){return D=new ao.SSRRenderingPipeline("SSRRenderingPipeline",t,[e],void 0,$(t.getEngine())),D.samples=i?.msaaSamples??1,D}a(so,"createSSRRenderingPipeline");function Bt(){return D?{samples:D.samples,step:D.step,thickness:D.thickness,strength:D.strength,reflectionSpecularFalloffExponent:D.reflectionSpecularFalloffExponent,maxSteps:D.maxSteps,maxDistance:D.maxDistance,roughnessFactor:D.roughnessFactor,reflectivityThreshold:D.reflectivityThreshold,blurDispersionStrehgth:D.blurDispersionStrength,clipToFrustum:D.clipToFrustum,enableSmoothReflections:D.enableSmoothReflections,enableAutomaticThicknessComputation:D.enableAutomaticThicknessComputation,attenuateFacingCamera:D.attenuateFacingCamera,attenuateScreenBorders:D.attenuateScreenBorders,attenuateIntersectionDistance:D.attenuateIntersectionDistance,attenuateBackfaceReflection:D.attenuateBackfaceReflection,blurDownsample:D.blurDownsample,selfCollisionNumSkip:D.selfCollisionNumSkip,ssrDownsample:D.ssrDownsample,backfaceDepthTextureDownsample:D.backfaceDepthTextureDownsample}:null}a(Bt,"serializeSSRRenderingPipeline");function zt(t,e,i,o){let r=D??so(t,e,o);return r.samples=o?.msaaSamples??1,r.step=i.step,r.thickness=i.thickness,r.strength=i.strength,r.reflectionSpecularFalloffExponent=i.reflectionSpecularFalloffExponent,r.maxSteps=i.maxSteps,r.maxDistance=i.maxDistance,r.roughnessFactor=i.roughnessFactor,r.reflectivityThreshold=i.reflectivityThreshold,r.blurDispersionStrength=i.blurDispersionStrehgth,r.clipToFrustum=i.clipToFrustum,r.enableSmoothReflections=i.enableSmoothReflections,r.enableAutomaticThicknessComputation=i.enableAutomaticThicknessComputation,r.attenuateFacingCamera=i.attenuateFacingCamera,r.attenuateScreenBorders=i.attenuateScreenBorders,r.attenuateIntersectionDistance=i.attenuateIntersectionDistance,r.attenuateBackfaceReflection=i.attenuateBackfaceReflection,r.blurDownsample=i.blurDownsample,r.selfCollisionNumSkip=i.selfCollisionNumSkip,r.ssrDownsample=i.ssrDownsample,r.backfaceDepthTextureDownsample=i.backfaceDepthTextureDownsample,r}a(zt,"parseSSRRenderingPipeline");var lo=require("babylonjs"),T=null,fe=new Map;function Vn(){return T}a(Vn,"getTAARenderingPipeline");function Fn(t){T=t}a(Fn,"setTAARenderingPipelineRef");function Ht(){T&&(T.dispose(),T=null)}a(Ht,"disposeTAARenderingPipeline");function co(t,e,i){return T=new lo.TAARenderingPipeline("TAARenderingPipeline",t,[e],$(t.getEngine())),T.msaaSamples=i?.msaaSamples??1,T}a(co,"createTAARenderingPipeline");function kt(){return T?{factor:T.factor,samples:T.samples,clampHistory:T.clampHistory,reprojectHistory:T.reprojectHistory,disableOnCameraMove:T.disableOnCameraMove}:null}a(kt,"serializeTAARenderingPipeline");function Ut(t,e,i,o){let r=T??co(t,e,o);return r.msaaSamples=o?.msaaSamples??1,r.factor=i.factor,r.clampHistory=i.clampHistory,r.reprojectHistory=i.reprojectHistory,r.disableOnCameraMove=i.disableOnCameraMove,r}a(Ut,"parseTAARenderingPipeline");var po=require("babylonjs"),P=null,ue=new Map;function Nn(){return P}a(Nn,"getSSAO2RenderingPipeline");function Gn(t){P=t}a(Gn,"setSSAO2RenderingPipelineRef");function Wt(){P&&(P.dispose(),P=null)}a(Wt,"disposeSSAO2RenderingPipeline");function mo(t,e,i){return P=new po.SSAO2RenderingPipeline("SSAO2RenderingPipeline",t,1,[e],void 0,$(t.getEngine())),P.textureSamples=1,P}a(mo,"createSSAO2RenderingPipeline");function Xt(){return P?{radius:P.radius,totalStrength:P.totalStrength,samples:P.samples,maxZ:P.maxZ,minZAspect:P.minZAspect,epsilon:P.epsilon,textureSamples:P.textureSamples,bypassBlur:P.bypassBlur,bilateralSamples:P.bilateralSamples,bilateralSoften:P.bilateralSoften,bilateralTolerance:P.bilateralTolerance,expensiveBlur:P.expensiveBlur}:null}a(Xt,"serializeSSAO2RenderingPipeline");function $t(t,e,i,o){let r=P??mo(t,e,o);return r.textureSamples=1,r.radius=i.radius,r.totalStrength=i.totalStrength,r.samples=i.samples,r.maxZ=i.maxZ,r.minZAspect=i.minZAspect,r.epsilon=i.epsilon,r.bypassBlur=i.bypassBlur,r.bilateralSamples=i.bilateralSamples,r.bilateralSoften=i.bilateralSoften,r.bilateralTolerance=i.bilateralTolerance,r.expensiveBlur=i.expensiveBlur,r}a($t,"parseSSAO2RenderingPipeline");var ho=require("babylonjs"),A=null,ge=new Map;function Kt(){return A}a(Kt,"getMotionBlurPostProcess");function Bn(t){A=t}a(Bn,"setMotionBlurPostProcessRef");function jt(){A&&(A.dispose(),A=null)}a(jt,"disposeMotionBlurPostProcess");function fo(t,e,i){return A=new ho.MotionBlurPostProcess("MotionBlurPostProcess",t,1,e,void 0,void 0,void 0,$(t.getEngine())),A.samples=i?.msaaSamples??1,A.motionStrength=1,A.isObjectBased=!0,A}a(fo,"createMotionBlurPostProcess");function Zt(){return A?{isObjectBased:A.isObjectBased,motionStrength:A.motionStrength,motionBlurSamples:A.motionBlurSamples}:null}a(Zt,"serializeMotionBlurPostProcess");function Yt(t,e,i,o){let r=A??fo(t,e,o);return r.samples=o?.msaaSamples??1,r.isObjectBased=i.isObjectBased,r.motionStrength=i.motionStrength,r.motionBlurSamples=i.motionBlurSamples,r}a(Yt,"parseMotionBlurPostProcess");var uo=require("babylonjs"),qt=require("babylonjs"),go=require("babylonjs"),vo=require("babylonjs"),So=require("babylonjs"),u=null,ve=new Map;function Ie(){return u}a(Ie,"getDefaultRenderingPipeline");function zn(t){u=t}a(zn,"setDefaultRenderingPipelineRef");function Qt(){u&&(u.dispose(),u=null)}a(Qt,"disposeDefaultRenderingPipeline");function yo(t,e,i){return u=new So.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,t,[e]),u.samples=i?.msaaSamples??1,u.depthOfField.lensSize=512,u.depthOfField.fStop=.25,u.depthOfField.focusDistance=55e3,u}a(yo,"createDefaultRenderingPipeline");function Jt(){return u?{samples:u.samples,fxaaEnabled:u.fxaaEnabled,imageProcessingEnabled:u.imageProcessingEnabled,exposure:u.imageProcessing?.exposure,contrast:u.imageProcessing?.contrast,fromLinearSpace:u.imageProcessing?.fromLinearSpace,toneMappingEnabled:u.imageProcessing?.toneMappingEnabled,toneMappingType:u.imageProcessing?.toneMappingType,ditheringEnabled:u.imageProcessing?.ditheringEnabled,ditheringIntensity:u.imageProcessing?.ditheringIntensity,bloomEnabled:u.bloomEnabled,bloomThreshold:u.bloomThreshold,bloomWeight:u.bloomWeight,bloomScale:u.bloomScale,bloomKernel:u.bloomKernel,sharpenEnabled:u.sharpenEnabled,sharpenEdgeAmount:u.sharpen.edgeAmount,sharpenColorAmount:u.sharpen.colorAmount,grainEnabled:u.grainEnabled,grainIntensity:u.grain.intensity,grainAnimated:u.grain.animated,depthOfFieldEnabled:u.depthOfFieldEnabled,depthOfFieldBlurLevel:u.depthOfFieldBlurLevel,lensSize:u.depthOfField.lensSize,fStop:u.depthOfField.fStop,focusDistance:u.depthOfField.focusDistance,focalLength:u.depthOfField.focalLength,vignetteEnabled:u.imageProcessing?.vignetteEnabled,vignetteColor:u.imageProcessing?.vignetteColor.asArray(),vignetteWeight:u.imageProcessing?.vignetteWeight,chromaticAberrationEnabled:u.chromaticAberrationEnabled,aberrationAmount:u.chromaticAberration.aberrationAmount,radialIntensity:u.chromaticAberration.radialIntensity,direction:u.chromaticAberration.direction.asArray(),centerPosition:u.chromaticAberration.centerPosition.asArray(),glowLayerEnabled:u.glowLayerEnabled,glowLayerIntensity:u.glowLayer?.intensity,glowLayerBlurKernelSize:u.glowLayer?.blurKernelSize,colorGradingEnabled:u.imageProcessing.colorGradingEnabled,colorGradingTexture:u.imageProcessing.colorGradingTexture?.serialize(),colorGradingWithGreenDepth:u.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth,colorCurvesEnabled:u.imageProcessing.colorCurvesEnabled,globalHue:u.imageProcessing.colorCurves?.globalHue,globalDensity:u.imageProcessing.colorCurves?.globalDensity,globalExposure:u.imageProcessing.colorCurves?.globalExposure,globalSaturation:u.imageProcessing.colorCurves?.globalSaturation,highlightsHue:u.imageProcessing.colorCurves?.highlightsHue,highlightsDensity:u.imageProcessing.colorCurves?.highlightsDensity,highlightsExposure:u.imageProcessing.colorCurves?.highlightsExposure,highlightsSaturation:u.imageProcessing.colorCurves?.highlightsSaturation,midtonesHue:u.imageProcessing.colorCurves?.midtonesHue,midtonesDensity:u.imageProcessing.colorCurves?.midtonesDensity,midtonesExposure:u.imageProcessing.colorCurves?.midtonesExposure,midtonesSaturation:u.imageProcessing.colorCurves?.midtonesSaturation,shadowsHue:u.imageProcessing.colorCurves?.shadowsHue,shadowsDensity:u.imageProcessing.colorCurves?.shadowsDensity,shadowsExposure:u.imageProcessing.colorCurves?.shadowsExposure,shadowsSaturation:u.imageProcessing.colorCurves?.shadowsSaturation}:null}a(Jt,"serializeDefaultRenderingPipeline");function ei(t,e,i,o,r){let n=u??yo(t,e,r);if(n.samples=r?.msaaSamples??1,n.fxaaEnabled=i.fxaaEnabled,n.imageProcessingEnabled=i.imageProcessingEnabled,n.imageProcessing){if(n.imageProcessing.exposure=i.exposure,n.imageProcessing.contrast=i.contrast,n.imageProcessing.fromLinearSpace=i.fromLinearSpace,n.imageProcessing.toneMappingEnabled=i.toneMappingEnabled,n.imageProcessing.toneMappingType=i.toneMappingType,n.imageProcessing.ditheringEnabled=i.ditheringEnabled,n.imageProcessing.ditheringIntensity=i.ditheringIntensity,n.imageProcessing.vignetteEnabled=i.vignetteEnabled??!1,n.imageProcessing.vignetteColor=uo.Color4.FromArray(i.vignetteColor??[0,0,0]),n.imageProcessing.vignetteWeight=i.vignetteWeight??.3,n.imageProcessing.colorGradingEnabled=i.colorGradingEnabled??!1,n.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth=i.colorGradingWithGreenDepth??!0,i.colorGradingTexture){let l=null;if(i.colorGradingTexture.customType==="BABYLON.ColorGradingTexture"){let p=o+i.colorGradingTexture.name;l=new vo.ColorGradingTexture(p,t),l.level=i.colorGradingTexture.level}else{let p=go.Texture.Parse(i.colorGradingTexture,t,o);Ae(p)&&(l=p)}n.imageProcessing.colorGradingTexture=l}n.imageProcessing.colorCurvesEnabled=i.colorCurvesEnabled??!1,n.imageProcessing.colorCurves&&(n.imageProcessing.colorCurves.globalHue=i.globalHue??30,n.imageProcessing.colorCurves.globalDensity=i.globalDensity??0,n.imageProcessing.colorCurves.globalExposure=i.globalExposure??0,n.imageProcessing.colorCurves.globalSaturation=i.globalSaturation??0,n.imageProcessing.colorCurves.highlightsHue=i.highlightsHue??30,n.imageProcessing.colorCurves.highlightsDensity=i.highlightsDensity??0,n.imageProcessing.colorCurves.highlightsExposure=i.highlightsExposure??0,n.imageProcessing.colorCurves.highlightsSaturation=i.highlightsSaturation??0,n.imageProcessing.colorCurves.midtonesHue=i.midtonesHue??30,n.imageProcessing.colorCurves.midtonesDensity=i.midtonesDensity??0,n.imageProcessing.colorCurves.midtonesExposure=i.midtonesExposure??0,n.imageProcessing.colorCurves.midtonesSaturation=i.midtonesSaturation??0,n.imageProcessing.colorCurves.shadowsHue=i.shadowsHue??30,n.imageProcessing.colorCurves.shadowsDensity=i.shadowsDensity??0,n.imageProcessing.colorCurves.shadowsExposure=i.shadowsExposure??0,n.imageProcessing.colorCurves.shadowsSaturation=i.shadowsSaturation??0)}return n.bloomEnabled=i.bloomEnabled,n.bloomThreshold=i.bloomThreshold,n.bloomWeight=i.bloomWeight,n.bloomScale=i.bloomScale,n.bloomKernel=i.bloomKernel,n.sharpenEnabled=i.sharpenEnabled,n.sharpen.edgeAmount=i.sharpenEdgeAmount,n.sharpen.colorAmount=i.sharpenColorAmount,n.grainEnabled=i.grainEnabled,n.grain.intensity=i.grainIntensity,n.grain.animated=i.grainAnimated,n.depthOfFieldEnabled=i.depthOfFieldEnabled,n.depthOfFieldBlurLevel=i.depthOfFieldBlurLevel,n.depthOfField.lensSize=i.lensSize,n.depthOfField.fStop=i.fStop,n.depthOfField.focusDistance=i.focusDistance,n.depthOfField.focalLength=i.focalLength,n.chromaticAberrationEnabled=i.chromaticAberrationEnabled??!1,n.chromaticAberration.aberrationAmount=i.aberrationAmount??10,n.chromaticAberration.radialIntensity=i.radialIntensity??1,n.chromaticAberration.direction=qt.Vector2.FromArray(i.direction??[0,0]),n.chromaticAberration.centerPosition=qt.Vector2.FromArray(i.centerPosition??[0,0]),n.glowLayerEnabled=i.glowLayerEnabled??!1,n.glowLayer&&(n.glowLayer.intensity=i.glowLayerIntensity??1,n.glowLayer.blurKernelSize=i.glowLayerBlurKernelSize??32),n}a(ei,"parseDefaultRenderingPipeline");var se="volumetricLighting",E=8,K=256,ri=4,bo=(i=>(i[i.Linear=0]="Linear",i[i.Exponential=1]="Exponential",i))(bo||{}),ni=(o=>(o[o.None=0]="None",o[o.Bayer=1]="Bayer",o[o.InterleavedGradientNoise=2]="InterleavedGradientNoise",o))(ni||{}),ai=(o=>(o[o.Exponential=0]="Exponential",o[o.ExponentialSquared=1]="ExponentialSquared",o[o.Linear=2]="Linear",o))(ai||{}),xo=(r=>(r[r.None=0]="None",r[r.Scattering=1]="Scattering",r[r.Transmittance=2]="Transmittance",r[r.LightCount=3]="LightCount",r))(xo||{});function oi(){return{enabled:!1,volumeIntensity:1,anisotropy:.35,useCustomColor:!1,color:[1,1,1],castVolumetricShadows:!0,shadowDarkness:1,rangeMultiplier:1,priority:0}}a(oi,"getDefaultVolumetricLightConfiguration");function Qe(){return{steps:40,lightSteps:0,resolutionScale:.5,stepDistribution:1,ditherMode:2,ditherStrength:1,temporalJitter:!1,fogMode:0,fogDensity:5e-4,fogStart:0,fogEnd:2e3,fogColor:[1,1,1],albedo:1,maxDistance:1e4,heightFogEnabled:!1,heightFogBaseHeight:0,heightFogFalloff:.01,intensity:1.5,lightExtinctionEnabled:!0,lightExtinctionClamp:1e3,extinctionAmount:0,ambientColor:[1,1,1],ambientIntensity:0,screenSpaceShadows:!0,screenSpaceShadowSteps:6,screenSpaceShadowBias:.02,screenSpaceShadowMaxDistance:2e3,screenSpaceShadowThickness:4,blurPasses:2,blurRadius:3,blurDepthThreshold:.02,upsampleDepthThreshold:.02,maxLights:128,maxShadowedLights:4,pcfTaps:4,selectionRefreshRate:2,debugMode:0}}a(Qe,"getDefaultVolumetricLightingConfiguration");function si(t){return t.lightSteps>0?t.lightSteps:Math.max(4,Math.min(64,Math.round(t.steps*.3)))}a(si,"getVolumetricLightSteps");function y(t,e,i,o){let r=typeof t=="number"&&isFinite(t)?t:e;return Math.min(o,Math.max(i,r))}a(y,"normalizeNumber");function ti(t,e){return!Array.isArray(t)||t.length<3?e.slice():[y(t[0],e[0],0,100),y(t[1],e[1],0,100),y(t[2],e[2],0,100)]}a(ti,"normalizeColor");function Co(t){let e=oi();return!t||typeof t!="object"?e:{enabled:t.enabled??e.enabled,volumeIntensity:y(t.volumeIntensity,e.volumeIntensity,0,1e3),anisotropy:y(t.anisotropy,e.anisotropy,-.95,.95),useCustomColor:t.useCustomColor??e.useCustomColor,color:ti(t.color,e.color),castVolumetricShadows:t.castVolumetricShadows??e.castVolumetricShadows,shadowDarkness:y(t.shadowDarkness,e.shadowDarkness,0,1),rangeMultiplier:y(t.rangeMultiplier,e.rangeMultiplier,0,100),priority:y(t.priority,e.priority,-1e3,1e3)}}a(Co,"normalizeVolumetricLightConfiguration");function Se(t){let e=Qe();return!t||typeof t!="object"?e:{steps:Math.round(y(t.steps,e.steps,4,256)),lightSteps:Math.round(y(t.lightSteps,e.lightSteps,0,128)),resolutionScale:y(t.resolutionScale,e.resolutionScale,.1,1),stepDistribution:Math.round(y(t.stepDistribution,e.stepDistribution,0,1)),ditherMode:Math.round(y(t.ditherMode,e.ditherMode,0,2)),ditherStrength:y(t.ditherStrength,e.ditherStrength,0,1),temporalJitter:t.temporalJitter??e.temporalJitter,fogMode:Math.round(y(t.fogMode,e.fogMode,0,2)),fogDensity:y(t.fogDensity,e.fogDensity,0,100),fogStart:y(t.fogStart,e.fogStart,0,1e6),fogEnd:Math.max(y(t.fogEnd,e.fogEnd,0,1e7),y(t.fogStart,e.fogStart,0,1e6)+.001),fogColor:ti(t.fogColor,e.fogColor),albedo:y(t.albedo,e.albedo,0,1),maxDistance:y(t.maxDistance,e.maxDistance,1,1e6),heightFogEnabled:t.heightFogEnabled??e.heightFogEnabled,heightFogBaseHeight:y(t.heightFogBaseHeight,e.heightFogBaseHeight,-1e6,1e6),heightFogFalloff:y(t.heightFogFalloff,e.heightFogFalloff,0,10),intensity:y(t.intensity,e.intensity,0,100),lightExtinctionEnabled:t.lightExtinctionEnabled??e.lightExtinctionEnabled,lightExtinctionClamp:y(t.lightExtinctionClamp,e.lightExtinctionClamp,0,1e6),extinctionAmount:y(t.extinctionAmount,e.extinctionAmount,0,1),ambientColor:ti(t.ambientColor,e.ambientColor),ambientIntensity:y(t.ambientIntensity,e.ambientIntensity,0,100),screenSpaceShadows:t.screenSpaceShadows??e.screenSpaceShadows,screenSpaceShadowSteps:Math.round(y(t.screenSpaceShadowSteps,e.screenSpaceShadowSteps,1,32)),screenSpaceShadowBias:y(t.screenSpaceShadowBias,e.screenSpaceShadowBias,0,1),screenSpaceShadowMaxDistance:y(t.screenSpaceShadowMaxDistance,e.screenSpaceShadowMaxDistance,1,1e7),screenSpaceShadowThickness:y(t.screenSpaceShadowThickness,e.screenSpaceShadowThickness,.01,1e3),blurPasses:Math.round(y(t.blurPasses,e.blurPasses,0,2)),blurRadius:Math.round(y(t.blurRadius,e.blurRadius,1,6)),blurDepthThreshold:y(t.blurDepthThreshold,e.blurDepthThreshold,1e-4,1),upsampleDepthThreshold:y(t.upsampleDepthThreshold,e.upsampleDepthThreshold,1e-4,1),maxLights:Math.round(y(t.maxLights,e.maxLights,0,K)),maxShadowedLights:Math.round(y(t.maxShadowedLights,e.maxShadowedLights,0,E)),pcfTaps:y(t.pcfTaps,e.pcfTaps,1,4)>=4?4:1,selectionRefreshRate:Math.round(y(t.selectionRefreshRate,e.selectionRefreshRate,1,60)),debugMode:Math.round(y(t.debugMode,e.debugMode,0,3))}}a(Se,"normalizeVolumetricLightingConfiguration");var ii=new WeakSet;function Lo(t){t.metadata??={};let e=t.metadata[se];if(!e||typeof e!="object")return t.metadata[se]=Co(null),ii.add(t.metadata[se]),t.metadata[se];if(ii.has(e))return e;let i=oi();return Object.keys(i).forEach(o=>{e[o]===void 0&&(e[o]=i[o])}),ii.add(e),e}a(Lo,"ensureVolumetricLightConfiguration");function li(t){let e=t.metadata?.[se];return e&&typeof e=="object"?Lo(t):null}a(li,"getVolumetricLightConfiguration");function Hn(t){return t.metadata?.[se]?.enabled===!0}a(Hn,"isVolumetricLightEnabled");var Je=require("babylonjs"),wo=require("babylonjs"),pi=require("babylonjs"),j=require("babylonjs"),mi=(o=>(o[o.Texture2D=0]="Texture2D",o[o.Sampler2DShadow=1]="Sampler2DShadow",o[o.Cube=2]="Cube",o))(mi||{}),Oo=(o=>(o[o.Standard=0]="Standard",o[o.Esm=1]="Esm",o[o.CloseEsm=2]="CloseEsm",o))(Oo||{}),hi=(o=>(o[o.Analytic=0]="Analytic",o[o.AnalyticHeight=1]="AnalyticHeight",o[o.Numeric=2]="Numeric",o))(hi||{}),Do=10,kn=4,Un=22,Wn=32,Xn=.15;function Me(t,e){let i=t.getCaps(),o=i.maxFragmentUniformVectors||224,r=t.isWebGPU?Math.floor(o/4):o,n=Math.max(224,r)-Wn,l=Math.max(8,i.maxTexturesImageUnits||16)-1,p=l>=2,s=p?Un:0,c=Math.max(0,Math.min(E,e.maxShadowedLights,l-(p?1:0),Math.floor((n-s)/Do))),m=Math.max(0,Math.min(K,e.maxLights,Math.floor((n-s-c*Do)/kn)));return{maxShadowSlots:c,maxArrayLights:m,maxDirectionalLights:Math.min(ri,m),allowCsm:p}}a(Me,"computeVolumetricBudget");function Eo(t){let e=[];return t.lights.forEach(i=>{pe(i)?i.lights.forEach(o=>{e.push({light:o,isClustered:!0})}):e.push({light:i,isClustered:!1})}),e}a(Eo,"getAllVolumetricCandidateLights");function To(t,e){let i=t.getShadowGenerator(e.activeCamera)??t.getShadowGenerator();if(!i||!Lt(i))return null;let o=i.getShadowMapForRendering();if(!o?.isReady())return null;let r=i.getShadowMap()?.getSize().width??1024,n=o.textureType===pi.Constants.TEXTURETYPE_UNSIGNED_BYTE,l=!ie(t),p=t.needCube?.()===!0;switch(i.filter){case j.ShadowGenerator.FILTER_PCF:case j.ShadowGenerator.FILTER_PCSS:return{generator:i,kind:p?2:1,mode:0,packed:n,mapSize:r,local:l};case j.ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP:case j.ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:1,packed:n,mapSize:r,local:l};case j.ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP:case j.ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:return{generator:i,kind:p?2:0,mode:2,packed:n,mapSize:r,local:l};default:return{generator:i,kind:p?2:0,mode:0,packed:n,mapSize:r,local:l}}}a(To,"resolveVolumetricShadowSlot");function et(t,e){let i=t;return i.computeTransformedInformation?.()&&i.transformedPosition?e.copyFrom(i.transformedPosition):i.position?e.copyFrom(i.position):e.copyFromFloats(0,0,0),e}a(et,"getVolumetricLightWorldPosition");function Re(t,e){let i=t;return i.computeTransformedInformation?.()&&i.transformedDirection?e.copyFrom(i.transformedDirection):i.direction?e.copyFrom(i.direction):e.copyFromFloats(0,0,1),e.normalize()}a(Re,"getVolumetricLightWorldDirection");function tt(t,e,i){let o=t.range>0&&t.range<Number.MAX_VALUE?t.range:i.maxDistance;return Math.max(.001,Math.min(o*e.rangeMultiplier,34e37))}a(tt,"getVolumetricLightRange");var ci=new Je.Vector3,_o=new Je.Vector3;function $n(t,e,i){if(et(t,i),!ne(t))return e;let o=Math.cos(t.angle*.5);if(o<=.5)return e;let r=e/(2*o);return Re(t,_o),i.addInPlace(_o.scaleInPlace(r)),r}a($n,"computeVolumetricLightBounds");function Kn(t,e,i){for(let o=0;o<i.length;++o)if(i[o].dotCoordinate(t)<=-e)return!1;return!0}a(Kn,"isSphereInFrustum");function Po(t){return(t.local?64:0)+t.kind*16+t.mode*4+(t.packed?1:0)}a(Po,"getShadowSlotSignature");function di(t,e,i,o,r){let n={candidateCount:0,culledCount:0,shadowedCount:0,unshadowedCount:0,droppedCount:0,perLight:new Map},l=wo.Frustum.GetPlanes(t.getTransformMatrix()),p=e.globalPosition,s=[];Eo(t).forEach(({light:v,isClustered:C})=>{let V=li(v);if(!V?.enabled)return;if(n.candidateCount++,Ye(v)||!v.isEnabled()||v.intensity<=0||V.volumeIntensity<=0){n.perLight.set(v.uniqueId,{state:"disabled",slot:-1,reason:Ye(v)?"Hemispheric lights have no position nor direction and can't produce light shafts.":"The light is disabled or its intensity is zero."});return}let X=ie(v),ce=V.priority*1e3;if(X)ce+=1e6;else{let Ke=Math.min(tt(v,V,i),i.maxDistance),xt=$n(v,Ke,ci);if(!Kn(ci,xt,l)){n.culledCount++,n.perLight.set(v.uniqueId,{state:"culled",slot:-1,reason:"The light is outside of the frustum of the camera and doesn't reach it."});return}let Sn=Math.max(1,Je.Vector3.Distance(ci,p)-xt);ce+=V.volumeIntensity*v.intensity*Math.min(4,xt/Sn)}s.push({light:v,config:V,isClustered:C,typeId:v.getTypeID(),score:ce})}),s.sort((v,C)=>C.score-v.score);let c=new Map;r?.shadowed.forEach((v,C)=>{c.set(v.candidate.light.uniqueId,C)});let m=[],h=[],d=new Map,f=null;s.forEach(v=>{let{light:C,config:V}=v;if(!V.castVolumetricShadows){d.set(C.uniqueId,"occlusion is disabled on this light."),h.push(v);return}if(v.isClustered){d.set(C.uniqueId,"clustered lighting doesn't support shadow maps."),h.push(v);return}if(!C.shadowEnabled||!t.shadowsEnabled){d.set(C.uniqueId,"shadows are disabled on this light or on the scene."),h.push(v);return}let X=C.getShadowGenerator(t.activeCamera)??C.getShadowGenerator();if(!X){d.set(C.uniqueId,"the light has no shadow generator."),h.push(v);return}if(Dt(X)&&o.allowCsm){let Ke=X.getShadowMapForRendering();if(!f&&Ke?.isReady()){f={candidate:v,generator:X,cascades:X.numCascades,kind:X.filter===j.ShadowGenerator.FILTER_PCF||X.filter===j.ShadowGenerator.FILTER_PCSS?1:0,packed:Ke.textureType===pi.Constants.TEXTURETYPE_UNSIGNED_BYTE};return}d.set(C.uniqueId,f?"another light already uses the single cascaded shadow map slot.":"its cascaded shadow map is not ready yet."),h.push(v);return}let ce=To(C,t);if(!ce){d.set(C.uniqueId,"the shadow map of the light is not ready yet."),h.push(v);return}m.push({candidate:v,shadow:ce})});function S(v){let C=v.candidate.score;return c.get(v.candidate.light.uniqueId)===void 0?C:C+Math.abs(C)*Xn}a(S,"getHysteresisScore");function g(v){return c.get(v.candidate.light.uniqueId)??Number.MAX_SAFE_INTEGER}a(g,"getPreviousSlot"),m.sort((v,C)=>{let V=S(C)-S(v);return V!==0?V:g(v)-g(C)});let b=m.slice(0,o.maxShadowSlots);b.sort((v,C)=>Po(v.shadow)-Po(C.shadow)||g(v)-g(C)),m.slice(o.maxShadowSlots).forEach(v=>{d.set(v.candidate.light.uniqueId,"the shadowed lights budget is full."),h.push(v.candidate)}),h.sort((v,C)=>C.score-v.score);let L=[],_=[],x=[];h.forEach(v=>{ie(v.light)?L.length<o.maxDirectionalLights?L.push(v):x.push({candidate:v,reason:`Not rendered: at most ${o.maxDirectionalLights} directional light(s) without a shadow map can take part in the effect.`}):_.push(v)});let R=Math.max(0,o.maxArrayLights-L.length);_.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 G=L.concat(_.slice(0,R));if(b.forEach((v,C)=>{n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:C,reason:`Casting volumetric shadows using slot ${C+1} of ${o.maxShadowSlots}.`})}),f){let v=f;n.shadowedCount++,n.perLight.set(v.candidate.light.uniqueId,{state:"shadowed",slot:-1,reason:`Casting volumetric shadows using its ${v.cascades} shadow cascades.`})}return G.forEach(v=>{n.unshadowedCount++;let C=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:`${C}: ${V}`})}),x.forEach(({candidate:v,reason:C})=>{n.droppedCount++,n.perLight.set(v.light.uniqueId,{state:"dropped",slot:-1,reason:C})}),{shadowed:b,unshadowed:G,directionalCount:L.length,csm:f,stats:n}}a(di,"selectVolumetricLights");function jn(t,e,i){let o=t.shadowed.map(n=>`${n.shadow.kind}.${n.shadow.mode}.${n.shadow.packed?1:0}.${n.shadow.local?1:0}`).join("|"),r=t.csm?`${t.csm.kind}.${t.csm.cascades}.${t.csm.packed?1:0}`:"-";return[e.steps,i.lightSteps,e.stepDistribution,e.ditherMode,e.temporalJitter?1:0,e.heightFogEnabled?1:0,e.lightExtinctionEnabled?1:0,e.pcfTaps,e.blurRadius,e.debugMode,e.screenSpaceShadows?e.screenSpaceShadowSteps:0,i.fogMode,i.transmittance,i.depthMode,i.ldrEncode?1:0,i.reverseDepth?1:0,i.ndcHalfZ?1:0,i.linearDepthPacked?1:0,i.arrayLightCapacity,t.directionalCount,o,r].join(",")}a(jn,"computeVolumetricShapeKey");function Zn(t){return Ct(t)||ne(t)||ie(t)}a(Zn,"isVolumetricLightSupported");var fi=require("babylonjs"),Yn=0,ui=(o=>(o[o.DepthRenderer=0]="DepthRenderer",o[o.GeometryBuffer=1]="GeometryBuffer",o[o.PrePass=2]="PrePass",o))(ui||{}),Ao="volumetricLighting";function gi(){return{name:Ao,enabled:!1,texturesRequired:[fi.Constants.PREPASS_DEPTH_TEXTURE_TYPE]}}a(gi,"createVolumetricLightingPrePassConfiguration");function ye(t){return t.prePassRenderer??null}a(ye,"getVolumetricPrePassRenderer");function Ve(t){return t.geometryBufferRenderer??null}a(Ve,"getVolumetricGeometryBufferRenderer");function Io(t){let e=t.getCaps();return e.textureFloat&&e.textureFloatLinearFiltering||e.textureHalfFloat&&e.textureHalfFloatLinearFiltering}a(Io,"supportsVolumetricFloatDepthTexture");function it(t){return Io(t.getEngine())?ye(t)?.isSupported?2:Ve(t)?.isSupported?1:0:0}a(it,"resolveVolumetricDepthSource");function vi(t){let e=t.getIndex(fi.Constants.PREPASS_DEPTH_TEXTURE_TYPE);return e===void 0||e<0?null:t.getRenderTarget()?.textures?.[e]??null}a(vi,"getVolumetricPrePassDepthTexture");function Si(t){if(!t.enableDepth)return null;let e=t.getTextureIndex(Yn);return e<0?null:t.getGBuffer()?.textures?.[e]??null}a(Si,"getVolumetricGeometryBufferDepthTexture");var ot=`
|
|
2
2
|
fn volUnpack(color: vec4f) -> f32 {
|
|
3
3
|
let bitShift = vec4f(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
|
|
4
4
|
return dot(color, bitShift);
|
|
5
5
|
}
|
|
6
|
-
`,
|
|
6
|
+
`,qn=`
|
|
7
|
+
// Loads the texel under the given coordinates rather than filtering: the 32 bits float textures of the prepass
|
|
8
|
+
// renderer are not filterable on WebGPU. @see the GLSL version.
|
|
7
9
|
fn volSampleDepth(uv: vec2f) -> f32 {
|
|
10
|
+
let size = vec2i(textureDimensions(depthSampler));
|
|
11
|
+
let coordinates = min(vec2i(uv * vec2f(size)), size - 1);
|
|
12
|
+
|
|
8
13
|
#ifdef VOL_DEPTH_PACKED
|
|
9
|
-
return volUnpack(
|
|
14
|
+
return volUnpack(textureLoad(depthSampler, coordinates, 0));
|
|
10
15
|
#else
|
|
11
|
-
return
|
|
16
|
+
return textureLoad(depthSampler, coordinates, 0).r;
|
|
12
17
|
#endif
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
// Converts the raw value stored in the depth map into a distance along the view axis, in scene units.
|
|
16
21
|
fn volLinearDepth(d: f32) -> f32 {
|
|
17
22
|
#ifdef VOL_DEPTH_VIEWZ
|
|
18
|
-
// The
|
|
19
|
-
|
|
23
|
+
// The view space Z is stored directly, negative in a right handed scene. The sky is cleared to 0.
|
|
24
|
+
let viewZ = abs(d);
|
|
25
|
+
return select(viewZ, uniforms.volCameraMinMaxZ.y, viewZ <= 0.0);
|
|
20
26
|
#else
|
|
21
27
|
// The depth renderer stores "(clipZ + minZ) / (minZ + maxZ)", which is affine in the view space Z
|
|
22
28
|
// for both the perspective and the orthographic projections. "volDepthUnpack" holds the two
|
|
@@ -24,7 +30,7 @@ fn volLinearDepth(d: f32) -> f32 {
|
|
|
24
30
|
return uniforms.volDepthUnpack.x * d + uniforms.volDepthUnpack.y;
|
|
25
31
|
#endif
|
|
26
32
|
}
|
|
27
|
-
`;function
|
|
33
|
+
`;function yi(t){return`
|
|
28
34
|
// Returns the distance along the view axis, in scene units, of the texel at the given coordinates.
|
|
29
35
|
fn volReadLinearDepth(coordinates: vec2i) -> f32 {
|
|
30
36
|
#ifdef VOL_LINEAR_DEPTH_PACKED
|
|
@@ -39,19 +45,18 @@ fn volReadLinearDepth(coordinates: vec2i) -> f32 {
|
|
|
39
45
|
fn volScatterToDepthTexel(scatterTexel: vec2i, depthSize: vec2i) -> vec2i {
|
|
40
46
|
return min(vec2i((vec2f(scatterTexel) + 0.5) * uniforms.volDepthRatio), depthSize - 1);
|
|
41
47
|
}
|
|
42
|
-
`}
|
|
48
|
+
`}a(yi,"buildLinearDepthHelpers");function Qn(){return`
|
|
43
49
|
varying vUV: vec2f;
|
|
44
50
|
|
|
45
51
|
var textureSamplerSampler: sampler;
|
|
46
52
|
var textureSampler: texture_2d<f32>;
|
|
47
|
-
var depthSamplerSampler: sampler;
|
|
48
53
|
var depthSampler: texture_2d<f32>;
|
|
49
54
|
|
|
50
55
|
uniform volCameraMinMaxZ: vec2f;
|
|
51
56
|
uniform volDepthUnpack: vec2f;
|
|
52
57
|
|
|
53
|
-
${
|
|
54
|
-
${
|
|
58
|
+
${ot}
|
|
59
|
+
${qn}
|
|
55
60
|
|
|
56
61
|
fn volPack(depth: f32) -> vec4f {
|
|
57
62
|
let bitShift = vec4f(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
|
|
@@ -73,7 +78,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
73
78
|
fragmentOutputs.color = vec4f(viewZ, 0.0, 0.0, 1.0);
|
|
74
79
|
#endif
|
|
75
80
|
}
|
|
76
|
-
`}
|
|
81
|
+
`}a(Qn,"buildVolumetricLightingLinearDepthShaderWGSL");function Mo(t,e){return`
|
|
77
82
|
let chordLength = t1 - t0;
|
|
78
83
|
|
|
79
84
|
// The point of the view ray closest to the light splits the chord in two halves over which both the
|
|
@@ -123,7 +128,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
123
128
|
}
|
|
124
129
|
|
|
125
130
|
return vec4f(result, 1.0);
|
|
126
|
-
`}
|
|
131
|
+
`}a(Mo,"buildLocalLightIntegrationWGSL");function Jn(t){let e=[],i=[],o=[];for(let r=0;r<t;++r)e.push(`
|
|
127
132
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
128
133
|
#if VOL_SHADOW_KIND{X} == 2
|
|
129
134
|
var volShadowSampler{X}Sampler: sampler;
|
|
@@ -242,7 +247,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
242
247
|
// The light clip space position of the points of the view ray is affine in their distance to the camera.
|
|
243
248
|
let clipOrigin = uniforms.volShadowMatrix[{X}] * vec4f(uniforms.volCameraPosition, 1.0);
|
|
244
249
|
let clipDirection = uniforms.volShadowMatrix[{X}] * vec4f(volRayDir, 0.0);
|
|
245
|
-
${
|
|
250
|
+
${Mo("f32({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
|
|
246
251
|
}
|
|
247
252
|
#endif
|
|
248
253
|
#endif
|
|
@@ -340,8 +345,8 @@ var<private> volJitter: f32;
|
|
|
340
345
|
var<private> volClipDirection: vec4f;
|
|
341
346
|
#endif
|
|
342
347
|
|
|
343
|
-
${
|
|
344
|
-
${
|
|
348
|
+
${ot}
|
|
349
|
+
${yi("textureSampler")}
|
|
345
350
|
|
|
346
351
|
fn volMod(x: f32, y: f32) -> f32 {
|
|
347
352
|
return x - y * floor(x / y);
|
|
@@ -867,7 +872,7 @@ ${i.join("")}
|
|
|
867
872
|
let lightDepth = dot(data.xyz, uniforms.volCameraForward);
|
|
868
873
|
#endif
|
|
869
874
|
|
|
870
|
-
${
|
|
875
|
+
${Mo("f32(index)",`#ifdef VOL_SCREEN_SHADOWS
|
|
871
876
|
if (occluded) {
|
|
872
877
|
contribution *= volScreenShadowToLight(t, lightClip, lightDepth, distanceToLight);
|
|
873
878
|
}
|
|
@@ -966,7 +971,7 @@ ${o.join("")}
|
|
|
966
971
|
|
|
967
972
|
fragmentOutputs.color = vec4f(result, finalTransmittance);
|
|
968
973
|
}
|
|
969
|
-
`}
|
|
974
|
+
`}a(Jn,"buildVolumetricLightingScatteringShaderWGSL");function ea(){return`
|
|
970
975
|
varying vUV: vec2f;
|
|
971
976
|
|
|
972
977
|
var textureSampler: texture_2d<f32>;
|
|
@@ -977,8 +982,8 @@ uniform volDepthRatio: vec2f;
|
|
|
977
982
|
uniform volBlurDirection: vec2f;
|
|
978
983
|
uniform volBlurParams: vec2f;
|
|
979
984
|
|
|
980
|
-
${
|
|
981
|
-
${
|
|
985
|
+
${ot}
|
|
986
|
+
${yi("volLinearDepthSampler")}
|
|
982
987
|
|
|
983
988
|
@fragment
|
|
984
989
|
fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
@@ -1017,7 +1022,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1017
1022
|
|
|
1018
1023
|
fragmentOutputs.color = result / totalWeight;
|
|
1019
1024
|
}
|
|
1020
|
-
`}
|
|
1025
|
+
`}a(ea,"buildVolumetricLightingBlurShaderWGSL");function ta(){return`
|
|
1021
1026
|
varying vUV: vec2f;
|
|
1022
1027
|
|
|
1023
1028
|
var textureSampler: texture_2d<f32>;
|
|
@@ -1029,8 +1034,8 @@ uniform volCameraMinMaxZ: vec2f;
|
|
|
1029
1034
|
uniform volDepthRatio: vec2f;
|
|
1030
1035
|
uniform volComposeParams: vec4f;
|
|
1031
1036
|
|
|
1032
|
-
${
|
|
1033
|
-
${
|
|
1037
|
+
${ot}
|
|
1038
|
+
${yi("volLinearDepthSampler")}
|
|
1034
1039
|
|
|
1035
1040
|
fn volMod(x: f32, y: f32) -> f32 {
|
|
1036
1041
|
return x - y * floor(x / y);
|
|
@@ -1120,25 +1125,31 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1120
1125
|
fragmentOutputs.color = vec4f(result, 1.0);
|
|
1121
1126
|
#endif
|
|
1122
1127
|
}
|
|
1123
|
-
`}
|
|
1128
|
+
`}a(ta,"buildVolumetricLightingComposeShaderWGSL");function Ro(){return{linearDepth:Qn(),scattering:Jn(E),blur:ea(),compose:ta()}}a(Ro,"getVolumetricLightingShadersWGSL");var Z=require("babylonjs"),No=require("babylonjs"),nt="volumetricLightingLinearDepth",at="volumetricLightingScattering",st="volumetricLightingBlur",lt="volumetricLightingCompose",rt=`
|
|
1124
1129
|
float volUnpack(vec4 color) {
|
|
1125
1130
|
const vec4 bitShift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
|
|
1126
1131
|
return dot(color, bitShift);
|
|
1127
1132
|
}
|
|
1128
|
-
`,
|
|
1129
|
-
|
|
1133
|
+
`,ia=`
|
|
1134
|
+
// Reads the texel under the given coordinates rather than filtering: the depth of a silhouette must not be
|
|
1135
|
+
// averaged with the sky, and the 32 bits float textures of the prepass renderer can't be filtered everywhere.
|
|
1136
|
+
float volSampleDepth(vec2 uv) {
|
|
1137
|
+
ivec2 size = textureSize(depthSampler, 0);
|
|
1138
|
+
ivec2 coordinates = min(ivec2(uv * vec2(size)), size - 1);
|
|
1139
|
+
|
|
1130
1140
|
#ifdef VOL_DEPTH_PACKED
|
|
1131
|
-
return volUnpack(
|
|
1141
|
+
return volUnpack(texelFetch(depthSampler, coordinates, 0));
|
|
1132
1142
|
#else
|
|
1133
|
-
return
|
|
1143
|
+
return texelFetch(depthSampler, coordinates, 0).r;
|
|
1134
1144
|
#endif
|
|
1135
1145
|
}
|
|
1136
1146
|
|
|
1137
1147
|
// Converts the raw value stored in the depth map into a distance along the view axis, in scene units.
|
|
1138
1148
|
float volLinearDepth(float d) {
|
|
1139
1149
|
#ifdef VOL_DEPTH_VIEWZ
|
|
1140
|
-
// The
|
|
1141
|
-
|
|
1150
|
+
// The view space Z is stored directly, negative in a right handed scene. The sky is cleared to 0.
|
|
1151
|
+
float viewZ = abs(d);
|
|
1152
|
+
return (viewZ <= 0.0) ? volCameraMinMaxZ.y : viewZ;
|
|
1142
1153
|
#else
|
|
1143
1154
|
// The depth renderer stores "(clipZ + minZ) / (minZ + maxZ)", which is affine in the view space Z
|
|
1144
1155
|
// for both the perspective and the orthographic projections. "volDepthUnpack" holds the two
|
|
@@ -1147,7 +1158,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1147
1158
|
return volDepthUnpack.x * d + volDepthUnpack.y;
|
|
1148
1159
|
#endif
|
|
1149
1160
|
}
|
|
1150
|
-
`,
|
|
1161
|
+
`,bi=`
|
|
1151
1162
|
// Returns the distance along the view axis, in scene units, of the texel at the given coordinates.
|
|
1152
1163
|
float volReadLinearDepth(sampler2D s, ivec2 coordinates) {
|
|
1153
1164
|
#ifdef VOL_LINEAR_DEPTH_PACKED
|
|
@@ -1164,18 +1175,19 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
|
|
|
1164
1175
|
ivec2 volScatterToDepthTexel(ivec2 scatterTexel, ivec2 depthSize) {
|
|
1165
1176
|
return min(ivec2((vec2(scatterTexel) + 0.5) * volDepthRatio), depthSize - 1);
|
|
1166
1177
|
}
|
|
1167
|
-
`;function
|
|
1178
|
+
`;function oa(){return`precision highp float;
|
|
1179
|
+
precision highp int;
|
|
1168
1180
|
|
|
1169
1181
|
varying vec2 vUV;
|
|
1170
1182
|
|
|
1171
1183
|
uniform sampler2D textureSampler;
|
|
1172
|
-
uniform sampler2D depthSampler;
|
|
1184
|
+
uniform highp sampler2D depthSampler;
|
|
1173
1185
|
|
|
1174
1186
|
uniform vec2 volCameraMinMaxZ;
|
|
1175
1187
|
uniform vec2 volDepthUnpack;
|
|
1176
1188
|
|
|
1177
|
-
${
|
|
1178
|
-
${
|
|
1189
|
+
${rt}
|
|
1190
|
+
${ia}
|
|
1179
1191
|
|
|
1180
1192
|
vec4 volPack(float depth) {
|
|
1181
1193
|
const vec4 bitShift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
|
|
@@ -1188,7 +1200,7 @@ vec4 volPack(float depth) {
|
|
|
1188
1200
|
}
|
|
1189
1201
|
|
|
1190
1202
|
void main(void) {
|
|
1191
|
-
float viewZ = volLinearDepth(volSampleDepth(
|
|
1203
|
+
float viewZ = volLinearDepth(volSampleDepth(vUV));
|
|
1192
1204
|
|
|
1193
1205
|
#ifdef VOL_LINEAR_DEPTH_PACKED
|
|
1194
1206
|
gl_FragColor = volPack(clamp(viewZ / volCameraMinMaxZ.y, 0.0, 0.9999999));
|
|
@@ -1196,7 +1208,7 @@ void main(void) {
|
|
|
1196
1208
|
gl_FragColor = vec4(viewZ, 0.0, 0.0, 1.0);
|
|
1197
1209
|
#endif
|
|
1198
1210
|
}
|
|
1199
|
-
`}
|
|
1211
|
+
`}a(oa,"buildVolumetricLightingLinearDepthShader");function Vo(t,e){return`
|
|
1200
1212
|
float chordLength = t1 - t0;
|
|
1201
1213
|
|
|
1202
1214
|
// The point of the view ray closest to the light splits the chord in two halves over which both the
|
|
@@ -1239,7 +1251,7 @@ void main(void) {
|
|
|
1239
1251
|
}
|
|
1240
1252
|
|
|
1241
1253
|
return vec4(result, 1.0);
|
|
1242
|
-
`}
|
|
1254
|
+
`}a(Vo,"buildLocalLightIntegration");function ra(t){let e=[],i=[],o=[];for(let r=0;r<t;++r)e.push(`
|
|
1243
1255
|
#if VOL_SHADOW_SLOT_COUNT > {X}
|
|
1244
1256
|
#if VOL_SHADOW_KIND{X} == 2
|
|
1245
1257
|
uniform samplerCube volShadowSampler{X};
|
|
@@ -1356,7 +1368,7 @@ void main(void) {
|
|
|
1356
1368
|
// so each sample only costs a multiply-add instead of a matrix product.
|
|
1357
1369
|
vec4 clipOrigin = volShadowMatrix[{X}] * vec4(volCameraPosition, 1.0);
|
|
1358
1370
|
vec4 clipDirection = volShadowMatrix[{X}] * vec4(volRayDir, 0.0);
|
|
1359
|
-
${
|
|
1371
|
+
${Vo("float({X}) + 0.5","contribution *= mix(1.0, volShadow{X}(position, clipOrigin + clipDirection * t), falloff.w);")}
|
|
1360
1372
|
}
|
|
1361
1373
|
#endif
|
|
1362
1374
|
#endif
|
|
@@ -1455,8 +1467,8 @@ float volJitter;
|
|
|
1455
1467
|
vec4 volClipDirection;
|
|
1456
1468
|
#endif
|
|
1457
1469
|
|
|
1458
|
-
${
|
|
1459
|
-
${
|
|
1470
|
+
${rt}
|
|
1471
|
+
${bi}
|
|
1460
1472
|
|
|
1461
1473
|
float volFallOff(float value, vec2 clipSpaceXY, float frustumEdgeFalloff) {
|
|
1462
1474
|
float mask = smoothstep(1.0 - frustumEdgeFalloff, 1.00000012, clamp(dot(clipSpaceXY, clipSpaceXY), 0.0, 1.0));
|
|
@@ -2034,7 +2046,7 @@ ${i.join("")}
|
|
|
2034
2046
|
float lightDepth = dot(data.xyz, volCameraForward);
|
|
2035
2047
|
#endif
|
|
2036
2048
|
|
|
2037
|
-
${
|
|
2049
|
+
${Vo("float(index)",`#ifdef VOL_SCREEN_SHADOWS
|
|
2038
2050
|
if (occluded) {
|
|
2039
2051
|
contribution *= volScreenShadowToLight(t, lightClip, lightDepth, distanceToLight);
|
|
2040
2052
|
}
|
|
@@ -2133,7 +2145,7 @@ ${o.join("")}
|
|
|
2133
2145
|
|
|
2134
2146
|
gl_FragColor = vec4(result, finalTransmittance);
|
|
2135
2147
|
}
|
|
2136
|
-
`}
|
|
2148
|
+
`}a(ra,"buildVolumetricLightingScatteringShader");function na(){return`precision highp float;
|
|
2137
2149
|
precision highp int;
|
|
2138
2150
|
|
|
2139
2151
|
varying vec2 vUV;
|
|
@@ -2146,8 +2158,8 @@ uniform vec2 volDepthRatio;
|
|
|
2146
2158
|
uniform vec2 volBlurDirection;
|
|
2147
2159
|
uniform vec2 volBlurParams;
|
|
2148
2160
|
|
|
2149
|
-
${
|
|
2150
|
-
${
|
|
2161
|
+
${rt}
|
|
2162
|
+
${bi}
|
|
2151
2163
|
|
|
2152
2164
|
void main(void) {
|
|
2153
2165
|
// The blur runs at the resolution of the scattering buffer and every tap is an exact texel, compared using
|
|
@@ -2186,7 +2198,7 @@ void main(void) {
|
|
|
2186
2198
|
|
|
2187
2199
|
gl_FragColor = result / totalWeight;
|
|
2188
2200
|
}
|
|
2189
|
-
`}
|
|
2201
|
+
`}a(na,"buildVolumetricLightingBlurShader");function aa(){return`precision highp float;
|
|
2190
2202
|
precision highp int;
|
|
2191
2203
|
|
|
2192
2204
|
varying vec2 vUV;
|
|
@@ -2199,8 +2211,8 @@ uniform vec2 volCameraMinMaxZ;
|
|
|
2199
2211
|
uniform vec2 volDepthRatio;
|
|
2200
2212
|
uniform vec4 volComposeParams;
|
|
2201
2213
|
|
|
2202
|
-
${
|
|
2203
|
-
${
|
|
2214
|
+
${rt}
|
|
2215
|
+
${bi}
|
|
2204
2216
|
|
|
2205
2217
|
float volBayer8(vec2 p) {
|
|
2206
2218
|
vec2 p1 = mod(floor(p), 2.0);
|
|
@@ -2289,10 +2301,10 @@ void main(void) {
|
|
|
2289
2301
|
|
|
2290
2302
|
gl_FragColor = vec4(result, 1.0);
|
|
2291
2303
|
}
|
|
2292
|
-
`}
|
|
2304
|
+
`}a(aa,"buildVolumetricLightingComposeShader");var Fo={};function Go(t){if(!Fo[t]){if(Fo[t]=!0,t===No.ShaderLanguage.WGSL){let e=Ro();Z.ShaderStore.ShadersStoreWGSL[`${nt}PixelShader`]=e.linearDepth,Z.ShaderStore.ShadersStoreWGSL[`${at}PixelShader`]=e.scattering,Z.ShaderStore.ShadersStoreWGSL[`${st}PixelShader`]=e.blur,Z.ShaderStore.ShadersStoreWGSL[`${lt}PixelShader`]=e.compose;return}Z.ShaderStore.ShadersStore[`${nt}PixelShader`]=oa(),Z.ShaderStore.ShadersStore[`${at}PixelShader`]=ra(E),Z.ShaderStore.ShadersStore[`${st}PixelShader`]=na(),Z.ShaderStore.ShadersStore[`${lt}PixelShader`]=aa()}}a(Go,"registerVolumetricLightingShaders");var Ho=require("babylonjs"),ko=require("babylonjs"),Y=require("babylonjs"),be=require("babylonjs"),Fe=require("babylonjs"),Uo=require("babylonjs"),xi=require("babylonjs"),Ne=require("babylonjs"),Wo=require("babylonjs"),sa=new be.Vector3(0,0,1),la=new be.Vector3(0,0,-1),Bo=["resolutionScale","blurPasses"],ca=32,pa=["volInverseViewProjection","volViewProjection","volCameraPosition","volCameraForward","volCameraMinMaxZ","volDepthRatio","volFrameIndex","volFogInfos","volFogColor","volLinearFogEps","volMedium","volScreenShadowParams","volAmbient","volParams","volLightData","volLightDiffuse","volLightDirection","volLightFalloff","volShadowLightData","volShadowLightDiffuse","volShadowLightDirection","volShadowLightFalloff","volShadowInfo","volShadowMatrix","volCsmLightData","volCsmLightDiffuse","volCsmLightDirection","volCsmLightFalloff","volCsmInfo","volCsmMatrices"],zo=["volCsmSampler"];for(let t=0;t<E;++t)zo.push(`volShadowSampler${t}`);var q=class t extends Wo.PostProcessRenderPipeline{static{a(this,"VolumetricLightingRenderingPipeline")}static SceneColorEffectName="VolumetricLightingSceneColorEffect";static ScatteringEffectName="VolumetricLightingScatteringEffect";static BlurEffectName="VolumetricLightingBlurEffect";static ComposeEffectName="VolumetricLightingComposeEffect";static GetDefaultFogEnd(e,i){return 1/t.GetDefaultFogDensity(e,i)}static GetDefaultFogDensity(e,i){let o=0;if(e.meshes.length){let r=e.getWorldExtends(),n=r.max.subtract(r.min).length();isFinite(n)&&(o=n)}return o<.001&&(o=Math.max(i.globalPosition.length(),i.maxZ*.001,1)),Math.min(1,Math.max(1e-5,1/Math.max(.001,o)))}static IsSupported(e){return e.isWebGPU?!0:(e.webGLVersion??0)>=2}static GetShaderLanguage(e){return e.isWebGPU?xi.ShaderLanguage.WGSL:xi.ShaderLanguage.GLSL}_scene;_camera;_configuration;_configurationProxy;_textureType;_shaderLanguage;_ldrEncode;_linearDepthPacked;_msaaSamples=1;_msaaSamplesAssigned=!1;_depthSource=0;_depthRenderer=null;_ownsDepthRenderer=!1;_depthMode=0;_prePassConfiguration=gi();_linearDepthPostProcess=null;_scatteringPostProcess=null;_blurPostProcesses=[];_composePostProcess=null;_selection=null;_budget;_linearDepthDefines="";_scatteringDefines="";_blurDefines="";_composeDefines="";_frameCount=0;_lightsDirty=!0;_disposed=!1;_beforeCameraRenderObserver=null;_lightAddedObserver=null;_lightRemovedObserver=null;_inverseViewProjection=be.Matrix.Identity();_temporaryVector=new be.Vector3;_temporaryColor=new ko.Color3;_lightData=new Float32Array(K*4);_lightDiffuse=new Float32Array(K*4);_lightDirection=new Float32Array(K*4);_lightFalloff=new Float32Array(K*4);_shadowLightData=new Float32Array(E*4);_shadowLightDiffuse=new Float32Array(E*4);_shadowLightDirection=new Float32Array(E*4);_shadowLightFalloff=new Float32Array(E*4);_shadowInfo=new Float32Array(E*4);_shadowMatrices=new Float32Array(E*16);_csmLightData=new Float32Array(4);_csmLightDiffuse=new Float32Array(4);_csmLightDirection=new Float32Array(4);_csmLightFalloff=new Float32Array(4);_csmMatrices=new Float32Array(64);constructor(e,i,o,r){super(i.getEngine(),e),this._shaderLanguage=t.GetShaderLanguage(i.getEngine()),Go(this._shaderLanguage),this._scene=i,this._camera=o,this._configuration=Se({...Qe(),fogDensity:r?.fogDensity??t.GetDefaultFogDensity(i,o),fogEnd:r?.fogEnd??t.GetDefaultFogEnd(i,o),screenSpaceShadowMaxDistance:r?.screenSpaceShadowMaxDistance??t.GetDefaultFogEnd(i,o),...r}),this._configurationProxy=new Proxy(this._configuration,{set:a((s,c,m)=>{let h=c;return s[h]===m||(s[h]=m,this._onConfigurationChanged(h)),!0},"set")});let n=i.getEngine(),l=n.getCaps(),p=l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering;this._textureType=p?Y.Constants.TEXTURETYPE_HALF_FLOAT:Y.Constants.TEXTURETYPE_UNSIGNED_BYTE,this._ldrEncode=!p,this._linearDepthPacked=!l.textureFloatRender,this._budget=Me(n,this._configuration),this._depthSource=it(i),this._setupDepthSource(),this._buildRenderEffects(),i.postProcessRenderPipelineManager.addPipeline(this),i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name,o),this._beforeCameraRenderObserver=i.onBeforeCameraRenderObservable.add(s=>{s===this._camera&&(this._updateDepthSource(),this._updateSelection())}),this._lightAddedObserver=i.onNewLightAddedObservable.add(()=>this.markLightsDirty()),this._lightRemovedObserver=i.onLightRemovedObservable.add(()=>this.markLightsDirty())}get isDisposed(){return this._disposed}get scene(){return this._scene}get camera(){return this._camera}get configuration(){return this._configurationProxy}get depthSource(){return this._depthSource}get msaaSamples(){return this._msaaSamples}set msaaSamples(e){this._msaaSamples=e,this._msaaSamplesAssigned=!0,this._applyMsaaSamples()}getStats(){return this._selection?.stats??null}getBudget(){return this._budget}getClassName(){return"VolumetricLightingRenderingPipeline"}markLightsDirty(){this._lightsDirty=!0}applyConfiguration(e){let i=Se({...this._configuration,...e}),o=Bo.some(r=>i[r]!==this._configuration[r]);Object.assign(this._configuration,i),this._budget=Me(this._scene.getEngine(),this._configuration),this._lightsDirty=!0,o&&this._rebuildRenderEffects()}serializeConfiguration(){return{...this._configuration,fogColor:this._configuration.fogColor.slice(),ambientColor:this._configuration.ambientColor.slice()}}dispose(){if(this._disposed)return;this._disposed=!0,this._scene.onBeforeCameraRenderObservable.remove(this._beforeCameraRenderObserver),this._scene.onNewLightAddedObservable.remove(this._lightAddedObserver),this._scene.onLightRemovedObservable.remove(this._lightRemovedObserver),this._beforeCameraRenderObserver=null,this._lightAddedObserver=null,this._lightRemovedObserver=null;let e=this._cameras.slice();this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this.name,e),this._disposePostProcesses(e),this._releaseDepthSource(),this._selection=null,this._scene.postProcessRenderPipelineManager.removePipeline(this.name),super.dispose()}_onConfigurationChanged(e){(e==="maxLights"||e==="maxShadowedLights")&&(this._budget=Me(this._scene.getEngine(),this._configuration)),this._lightsDirty=!0,Bo.includes(e)&&this._rebuildRenderEffects()}_setupDepthSource(){switch(this._depthSource){case 2:this._depthMode=1;break;case 1:this._ensureGeometryBufferDepth(),this._depthMode=1;break;default:this._setupDepthRenderer();break}this._applyPrePassConfiguration(),this._applyMsaaSamples()}_releaseDepthSource(){this._ownsDepthRenderer&&this._scene.disableDepthRenderer(this._camera),this._depthRenderer=null,this._ownsDepthRenderer=!1,this._linearDepthPostProcess&&(this._linearDepthPostProcess._prePassEffectConfiguration=void 0)}_updateDepthSource(){if(this._disposed)return;let e=it(this._scene);if(e===this._depthSource){e===1&&this._ensureGeometryBufferDepth();return}this._releaseDepthSource(),this._depthSource=e,this._setupDepthSource(),ye(this._scene)?.markAsDirty(),this._lightsDirty=!0}_ensureGeometryBufferDepth(){let e=Ve(this._scene);e&&!e.enableDepth&&(e.enableDepth=!0)}_applyPrePassConfiguration(){this._linearDepthPostProcess&&this._depthSource===2&&(this._linearDepthPostProcess._prePassEffectConfiguration=this._prePassConfiguration)}_applyMsaaSamples(){if(this._msaaSamplesAssigned){if(this._depthSource===2){let e=ye(this._scene);if(e){e.samples=this._msaaSamples;return}}!this._enableMSAAOnFirstPostProcess(this._msaaSamples)&&this._msaaSamples>1&&console.warn("Volumetric lighting: MSAA is not supported by the engine, the requested samples are ignored.")}}_setupDepthRenderer(){let e=this._scene._depthRenderer?.[this._camera.uniqueId];this._ownsDepthRenderer=!e,this._depthRenderer=e??this._scene.enableDepthRenderer(this._camera,!1,!1,Y.Constants.TEXTURE_NEAREST_SAMPLINGMODE,!1),this._depthRenderer.isPacked?this._depthMode=2:this._depthRenderer.clearColor.r===0?this._depthMode=1:this._depthMode=0}_bindDepthUniforms(e){let i=this._camera,o=this._scene.getEngine();if(e.setFloat2("volCameraMinMaxZ",i.minZ,i.maxZ),this._depthMode===1){e.setFloat2("volDepthUnpack",1,0);return}let r=i.mode===Ho.Camera.ORTHOGRAPHIC_CAMERA,n=r?!o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?i.minZ:o.isNDCHalfZRange?0:i.minZ,l=r?o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:1:o.useReverseDepthBuffer&&o.isNDCHalfZRange?0:i.maxZ,p=this._scene.getProjectionMatrix().m,s=p[10],c=p[14];if(!s){e.setFloat2("volDepthUnpack",i.maxZ,0);return}let m=o.useReverseDepthBuffer?-1:1;e.setFloat2("volDepthUnpack",m*(n+l)/s,(-m*n-c)/s)}_getEnvironment(){let e=this._configuration,i=0;return e.heightFogEnabled&&(i=e.fogMode===0?1:2),{depthMode:this._depthMode,ldrEncode:this._ldrEncode,reverseDepth:this._scene.getEngine().useReverseDepthBuffer,ndcHalfZ:this._scene.getEngine().isNDCHalfZRange,fogMode:e.fogMode,transmittance:i,linearDepthPacked:this._linearDepthPacked,arrayLightCapacity:this._budget.maxArrayLights,lightSteps:si(e)}}_buildLinearDepthReadDefines(e){return e.linearDepthPacked?`#define VOL_LINEAR_DEPTH_PACKED
|
|
2293
2305
|
`:""}_buildLinearDepthDefines(e){let i=this._buildLinearDepthReadDefines(e);return e.depthMode===2?i+=`#define VOL_DEPTH_PACKED
|
|
2294
2306
|
`:e.depthMode===1&&(i+=`#define VOL_DEPTH_VIEWZ
|
|
2295
|
-
`),i}_buildScatteringDefines(e,i){let o=this._configuration,r=e?.shadowed??[],
|
|
2307
|
+
`),i}_buildScatteringDefines(e,i){let o=this._configuration,r=e?.shadowed??[],n=e?.directionalCount??0,l=e?.csm??null,p=r.filter(c=>!c.shadow.local).length,s=this._buildLinearDepthReadDefines(i);return s+=`#define VOL_STEPS ${o.steps}
|
|
2296
2308
|
`,s+=`#define VOL_LIGHT_STEPS ${i.lightSteps}
|
|
2297
2309
|
`,s+=`#define VOL_LOCAL_MAX_STEPS ${Math.max(i.lightSteps,o.steps)}
|
|
2298
2310
|
`,s+=`#define VOL_DISTRIBUTION ${o.stepDistribution}
|
|
@@ -2301,13 +2313,13 @@ void main(void) {
|
|
|
2301
2313
|
`,s+=`#define VOL_FOG_MODE ${i.fogMode}
|
|
2302
2314
|
`,s+=`#define VOL_TRANSMITTANCE ${i.transmittance}
|
|
2303
2315
|
`,(i.transmittance!==0||i.fogMode!==2)&&(s+=`#define VOL_OPTICAL_DEPTH
|
|
2304
|
-
`),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${
|
|
2316
|
+
`),s+=`#define VOL_TRANSMITTANCE_SAMPLES ${ca}
|
|
2305
2317
|
`,s+=`#define VOL_DEBUG ${o.debugMode}
|
|
2306
2318
|
`,s+=`#define VOL_MAX_ARRAY_LIGHTS ${i.arrayLightCapacity}
|
|
2307
|
-
`,s+=`#define VOL_DIRECTIONAL_LIGHT_COUNT ${
|
|
2308
|
-
`,s+=`#define VOL_LOCAL_ARRAY_LIGHTS ${i.arrayLightCapacity>
|
|
2319
|
+
`,s+=`#define VOL_DIRECTIONAL_LIGHT_COUNT ${n}
|
|
2320
|
+
`,s+=`#define VOL_LOCAL_ARRAY_LIGHTS ${i.arrayLightCapacity>n?1:0}
|
|
2309
2321
|
`,s+=`#define VOL_SHADOW_SLOT_COUNT ${r.length}
|
|
2310
|
-
`,s+=`#define VOL_GLOBAL_LIGHT_COUNT ${
|
|
2322
|
+
`,s+=`#define VOL_GLOBAL_LIGHT_COUNT ${n+p+(l?1:0)}
|
|
2311
2323
|
`,o.ditherMode!==0&&o.temporalJitter&&(s+=`#define VOL_TEMPORAL_JITTER
|
|
2312
2324
|
`),o.heightFogEnabled&&(s+=`#define VOL_HEIGHT_FOG
|
|
2313
2325
|
`),o.lightExtinctionEnabled&&(s+=`#define VOL_LIGHT_EXTINCTION
|
|
@@ -2327,4 +2339,4 @@ void main(void) {
|
|
|
2327
2339
|
`)),s}_buildBlurDefines(e){return`${this._buildLinearDepthReadDefines(e)}#define VOL_BLUR_RADIUS ${this._configuration.blurRadius}
|
|
2328
2340
|
`}_buildComposeDefines(e){let i=this._buildLinearDepthReadDefines(e);return i+=`#define VOL_DEBUG ${this._configuration.debugMode}
|
|
2329
2341
|
`,e.ldrEncode&&(i+=`#define VOL_LDR_ENCODE
|
|
2330
|
-
`),i}_createPostProcess(e){let i=new Eo.PostProcess(e.name,e.shaderName,e.uniforms,e.samplers,e.ratio,null,e.samplingMode,this._scene.getEngine(),!1,e.defines,e.textureType,void 0,void 0,!1,e.textureFormat,this._shaderLanguage);return i.autoClear=!1,i.alphaMode=Z.Constants.ALPHA_DISABLE,i}_buildRenderEffects(){let e=this._scene.getEngine(),i=this._configuration,o=this._getEnvironment();this._linearDepthDefines=this._buildLinearDepthDefines(o),this._scatteringDefines=this._buildScatteringDefines(this._selection,o),this._blurDefines=this._buildBlurDefines(o),this._composeDefines=this._buildComposeDefines(o),this._linearDepthPostProcess=this._createPostProcess({name:"VolumetricLightingLinearDepth",shaderName:et,uniforms:["volCameraMinMaxZ","volDepthUnpack"],samplers:["depthSampler"],ratio:1,samplingMode:Ie.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._linearDepthDefines}),this._linearDepthPostProcess.onApplyObservable.add(r=>this._bindLinearDepth(r)),this._scatteringPostProcess=this._createPostProcess({name:"VolumetricLightingScattering",shaderName:tt,uniforms:Zn,samplers:wo,ratio:1,samplingMode:Ie.Texture.NEAREST_SAMPLINGMODE,textureType:this._linearDepthPacked?Z.Constants.TEXTURETYPE_UNSIGNED_BYTE:Z.Constants.TEXTURETYPE_FLOAT,textureFormat:this._linearDepthPacked?Z.Constants.TEXTUREFORMAT_RGBA:Z.Constants.TEXTUREFORMAT_R,defines:this._scatteringDefines}),this._scatteringPostProcess.onApplyObservable.add(r=>this._bindScattering(r)),this._blurPostProcesses=[];for(let r=0;r<i.blurPasses;++r){let a=this._createPostProcess({name:`VolumetricLightingBlur${r}`,shaderName:it,uniforms:["volCameraMinMaxZ","volDepthRatio","volBlurDirection","volBlurParams"],samplers:["volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Ie.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._blurDefines});a.onApplyObservable.add(l=>this._bindBlur(l,r)),this._blurPostProcesses.push(a)}this._composePostProcess=this._createPostProcess({name:"VolumetricLightingCompose",shaderName:ot,uniforms:["volCameraMinMaxZ","volDepthRatio","volComposeParams"],samplers:["volSceneSampler","volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Ie.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._composeDefines}),this._composePostProcess.onApplyObservable.add(r=>this._bindCompose(r)),this.addEffect(new Me.PostProcessRenderEffect(e,t.SceneColorEffectName,()=>this._linearDepthPostProcess,!0)),this.addEffect(new Me.PostProcessRenderEffect(e,t.ScatteringEffectName,()=>this._scatteringPostProcess,!0)),this._blurPostProcesses.length&&this.addEffect(new Me.PostProcessRenderEffect(e,t.BlurEffectName,()=>this._blurPostProcesses,!0)),this.addEffect(new Me.PostProcessRenderEffect(e,t.ComposeEffectName,()=>this._composePostProcess,!0))}_disposePostProcesses(e){[this._linearDepthPostProcess,this._scatteringPostProcess,...this._blurPostProcesses,this._composePostProcess].forEach(o=>{o&&(e.forEach(r=>o.dispose(r)),o.dispose())}),this._linearDepthPostProcess=null,this._scatteringPostProcess=null,this._blurPostProcesses=[],this._composePostProcess=null}_rebuildRenderEffects(){if(this._disposed)return;let e=this._scene.postProcessRenderPipelineManager,i=this._cameras.slice();try{e.detachCamerasFromRenderPipeline(this.name,i),this._disposePostProcesses(i),Object.keys(this._renderEffects).forEach(o=>{delete this._renderEffects[o]}),this._buildRenderEffects()}catch(o){console.error("Failed to rebuild the volumetric lighting rendering pipeline.",o)}finally{try{e.attachCamerasToRenderPipeline(this.name,i)}catch(o){console.error("Failed to re-attach the cameras to the volumetric lighting rendering pipeline.",o)}}this._lightsDirty=!0}_updateSelection(){if(this._disposed||!this._scatteringPostProcess||(++this._frameCount,!(this._lightsDirty||!this._selection||this._frameCount%this._configuration.selectionRefreshRate===0)))return;this._lightsDirty=!1;let i=this._getEnvironment(),o=si(this._scene,this._camera,this._configuration,this._budget,this._selection);this._selection=o;let r=this._buildScatteringDefines(o,i);r!==this._scatteringDefines&&(this._scatteringDefines=r,this._scatteringPostProcess.updateEffect(r));let a=this._buildLinearDepthDefines(i);a!==this._linearDepthDefines&&(this._linearDepthDefines=a,this._linearDepthPostProcess?.updateEffect(a));let l=this._buildBlurDefines(i);l!==this._blurDefines&&(this._blurDefines=l,this._blurPostProcesses.forEach(s=>s.updateEffect(l)));let p=this._buildComposeDefines(i);p!==this._composeDefines&&(this._composeDefines=p,this._composePostProcess?.updateEffect(p))}_writeLight(e,i,o,r,a,l){let{light:p,config:s}=e,c=i*4;ee(p)?(Te(p,this._temporaryVector),o[c]=-this._temporaryVector.x,o[c+1]=-this._temporaryVector.y,o[c+2]=-this._temporaryVector.z,o[c+3]=1):(Ye(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]=oe(p)?2:0),s.useCustomColor?this._temporaryColor.set(s.color[0],s.color[1],s.color[2]):this._temporaryColor.copyFrom(p.diffuse);let m=p.getScaledIntensity()*s.volumeIntensity*1e-5;r[c]=this._temporaryColor.r*m,r[c+1]=this._temporaryColor.g*m,r[c+2]=this._temporaryColor.b*m,r[c+3]=s.anisotropy,oe(p)?(Te(p,this._temporaryVector),a[c]=this._temporaryVector.x,a[c+1]=this._temporaryVector.y,a[c+2]=this._temporaryVector.z,a[c+3]=Math.cos(p.angle*.5),l[c+1]=p.exponent):(a[c]=0,a[c+1]=0,a[c+2]=1,a[c+3]=-1,l[c+1]=1),l[c]=qe(p,s,this._configuration),l[c+2]=s.castVolumetricShadows?1:0,l[c+3]=s.shadowDarkness}_bindLinearDepth(e){this._depthRenderer&&(e.setTexture("depthSampler",this._depthRenderer.getDepthMap()),this._bindDepthUniforms(e))}_bindScattering(e){let i=this._scene,o=this._camera,r=this._configuration,a=this._selection;if(!a)return;this._inverseViewProjection.copyFrom(i.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",o.globalPosition),o.getDirectionToRef(i.useRightHandedSystem?Kn:$n,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize()),e.setFloat2("volCameraMinMaxZ",o.minZ,o.maxZ),e.setFloat("volFrameIndex",i.getRenderId()%64),this._bindDepthRatio(e),e.setFloat4("volFogInfos",r.fogMode,r.fogStart,r.fogEnd,r.fogDensity),this._temporaryColor.set(r.fogColor[0],r.fogColor[1],r.fogColor[2]),e.setColor3("volFogColor",this._temporaryColor),e.setFloat("volLinearFogEps",Math.max((r.fogEnd-r.fogStart)*.02,1e-4)),e.setFloat4("volMedium",r.albedo,r.heightFogBaseHeight,r.heightFogFalloff,0),r.screenSpaceShadows&&(e.setMatrix("volViewProjection",i.getTransformMatrix()),e.setFloat4("volScreenShadowParams",r.screenSpaceShadowMaxDistance,r.screenSpaceShadowBias,r.screenSpaceShadowThickness,0)),this._temporaryColor.set(r.ambientColor[0],r.ambientColor[1],r.ambientColor[2]).scaleInPlace(r.ambientIntensity),e.setColor3("volAmbient",this._temporaryColor);let l=a.unshadowed.length,p=l-a.directionalCount;e.setFloat4("volParams",r.maxDistance,r.ditherStrength,r.lightExtinctionClamp,p);for(let s=0;s<l;++s)this._writeLight(a.unshadowed[s],s,this._lightData,this._lightDiffuse,this._lightDirection,this._lightFalloff);if(l){let s=l*4;e.setFloatArray4("volLightData",this._lightData.subarray(0,s)),e.setFloatArray4("volLightDiffuse",this._lightDiffuse.subarray(0,s)),e.setFloatArray4("volLightDirection",this._lightDirection.subarray(0,s)),e.setFloatArray4("volLightFalloff",this._lightFalloff.subarray(0,s))}if(a.shadowed.forEach((s,c)=>{this._writeLight(s.candidate,c,this._shadowLightData,this._shadowLightDiffuse,this._shadowLightDirection,this._shadowLightFalloff);let{generator:m,kind:h,mode:d,mapSize:f}=s.shadow,S=s.candidate.light,g=c*4;this._shadowLightFalloff[g+2]=m.frustumEdgeFalloff;let b=S.getDepthMinZ?.(i.activeCamera)??0,C=S.getDepthMaxZ?.(i.activeCamera)??1;this._shadowInfo[g]=m.getDarkness(),this._shadowInfo[g+1]=h===1?1/f:d===0?0:m.depthScale,this._shadowInfo[g+2]=b,this._shadowInfo[g+3]=b+C,m.getTransformMatrix().copyToArray(this._shadowMatrices,c*16);let _=m.getShadowMapForRendering();h===1?e.setDepthStencilTexture(`volShadowSampler${c}`,_):e.setTexture(`volShadowSampler${c}`,_)}),a.shadowed.length){let s=a.shadowed.length*4;e.setFloatArray4("volShadowLightData",this._shadowLightData.subarray(0,s)),e.setFloatArray4("volShadowLightDiffuse",this._shadowLightDiffuse.subarray(0,s)),e.setFloatArray4("volShadowLightDirection",this._shadowLightDirection.subarray(0,s)),e.setFloatArray4("volShadowLightFalloff",this._shadowLightFalloff.subarray(0,s)),e.setFloatArray4("volShadowInfo",this._shadowInfo.subarray(0,s)),e.setMatrices("volShadowMatrix",this._shadowMatrices.subarray(0,a.shadowed.length*16))}if(a.csm){let{candidate:s,generator:c,cascades:m,kind:h}=a.csm,d=s.light;this._writeLight(s,0,this._csmLightData,this._csmLightDiffuse,this._csmLightDirection,this._csmLightFalloff),e.setFloat4("volCsmLightData",this._csmLightData[0],this._csmLightData[1],this._csmLightData[2],this._csmLightData[3]),e.setFloat4("volCsmLightDiffuse",this._csmLightDiffuse[0],this._csmLightDiffuse[1],this._csmLightDiffuse[2],this._csmLightDiffuse[3]),e.setFloat4("volCsmLightDirection",this._csmLightDirection[0],this._csmLightDirection[1],this._csmLightDirection[2],this._csmLightDirection[3]),e.setFloat4("volCsmLightFalloff",this._csmLightFalloff[0],this._csmLightFalloff[1],c.frustumEdgeFalloff,s.config.shadowDarkness);let f=d.getDepthMinZ?.(i.activeCamera)??1,S=d.getDepthMaxZ?.(i.activeCamera)??1,g=c.getShadowMap()?.getSize().width??1024;e.setFloat4("volCsmInfo",c.getDarkness(),1/g,f,f+S);for(let C=0;C<m;++C)c.getCascadeTransformMatrix(C)?.copyToArray(this._csmMatrices,C*16);e.setMatrices("volCsmMatrices",this._csmMatrices.subarray(0,m*16));let b=c.getShadowMapForRendering();h===1?e.setDepthStencilTexture("volCsmSampler",b):e.setTexture("volCsmSampler",b)}}_bindDepthRatio(e){let i=this._scatteringPostProcess,o=this._blurPostProcesses[0]??this._composePostProcess,r=i&&i.width>0?i.width:1,a=i&&i.height>0?i.height:1,l=o&&o.width>0?o.width:r,p=o&&o.height>0?o.height:a;e.setFloat2("volDepthRatio",r/l,a/p)}_bindBlur(e,i){this._scatteringPostProcess&&(e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e),e.setFloat2("volBlurDirection",i%2===0?1:0,i%2===0?0:1),e.setFloat2("volBlurParams",Math.max(this._configuration.blurRadius*.5,.5),this._configuration.blurDepthThreshold))}_bindCompose(e){if(!this._linearDepthPostProcess||!this._scatteringPostProcess)return;let i=this._configuration;e.setTextureFromPostProcess("volSceneSampler",this._linearDepthPostProcess),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e);let o=this._ldrEncode?1/255:0;e.setFloat4("volComposeParams",i.intensity,i.extinctionAmount,i.upsampleDepthThreshold,o)}};var N=null,Se=new Map;function To(){return N?.isDisposed&&(N=null),N}n(To,"getVolumetricLightingRenderingPipeline");function Yn(t){N=t}n(Yn,"setVolumetricLightingRenderingPipelineRef");function qn(t){let e=t?.getEngine();return e?Y.IsSupported(e):!1}n(qn,"isVolumetricLightingSupported");function mi(){N&&(N.dispose(),N=null)}n(mi,"disposeVolumetricLightingRenderingPipeline");function Io(t,e){return N=new Y("VolumetricLightingRenderingPipeline",t,e),N}n(Io,"createVolumetricLightingRenderingPipeline");function hi(){return N?N.serializeConfiguration():null}n(hi,"serializeVolumetricLightingRenderingPipeline");function di(t,e,i){let o=To()??Io(t,e),r={...i};return r.fogDensity===void 0&&(r.fogDensity=Y.GetDefaultFogDensity(o.scene,o.camera)),r.fogEnd===void 0&&(r.fogEnd=Y.GetDefaultFogEnd(o.scene,o.camera)),r.screenSpaceShadowMaxDistance===void 0&&(r.screenSpaceShadowMaxDistance=Y.GetDefaultFogEnd(o.scene,o.camera)),o.applyConfiguration(ge(r)),o}n(di,"parseVolumetricLightingRenderingPipeline");function Qn(){N?.markLightsDirty()}n(Qn,"markVolumetricLightsDirty");function Jn(t){de.set(t,Bt()),pe.set(t,At()),me.set(t,Mt()),fe.set(t,Ut()),Se.set(t,hi()),ue.set(t,Kt()),he.set(t,Ft())}n(Jn,"saveRenderingConfigurationForCamera");function fi(t,e,i){Gt(),Et(t.getScene()),It(),kt(),mi(),$t(),Vt();let o=de.get(t);o&&!i?.ssao2Disabled&&zt(t.getScene(),t,o);let r=Se.get(t);r&&!i?.volumetricLightingDisabled&&di(t.getScene(),t,r);let a=pe.get(t);a&&!i?.vlsDisabled&&Tt(t.getScene(),a);let l=me.get(t);l&&!i?.ssrDisabled&&Rt(t.getScene(),t,l);let p=fe.get(t);p&&!i?.motionBlurDisabled&&Wt(t.getScene(),t,p);let s=ue.get(t);s&&!i?.defaultPipelineDisabled&&jt(t.getScene(),t,s,e);let c=he.get(t);c&&!i?.taaDisabled&&Nt(t.getScene(),t,c)}n(fi,"applyRenderingConfigurationForCamera");var Re=require("babylonjs"),Mo=require("babylonjs");function Ro(t){let e=t.metadata?.physicsAggregate;if(!e)return;let i;V(t)?i=t:Pe(t)&&(i=t.sourceMesh);let o=new Mo.PhysicsAggregate(t,e.shape.type,{mesh:i,mass:e.massProperties.mass});o.body.setMassProperties({mass:e.massProperties.mass,inertia:e.massProperties.inertia?Re.Vector3.FromArray(e.massProperties.inertia):void 0,centerOfMass:e.massProperties.centerOfMass?Re.Vector3.FromArray(e.massProperties.centerOfMass):void 0,inertiaOrientation:e.massProperties.inertiaOrientation?Re.Quaternion.FromArray(e.massProperties.inertiaOrientation):void 0}),o.shape.density=e.shape.density,o.body.setMotionType(e.body.motionType),o.shape.material=e.material,t.physicsAggregate=o,t.metadata.physicsAggregate=void 0}n(Ro,"configurePhysicsAggregate");function Vo(t,e){(Array.isArray(e)?e:[]).forEach(o=>{let r=t.getCameraById(o.cameraId);r&&(o.ssao2RenderingPipeline&&de.set(r,o.ssao2RenderingPipeline),o.vlsPostProcess&&pe.set(r,o.vlsPostProcess),o.ssrRenderingPipeline&&me.set(r,o.ssrRenderingPipeline),o.motionBlurPostProcess&&fe.set(r,o.motionBlurPostProcess),o.volumetricLightingRenderingPipeline&&Se.set(r,o.volumetricLightingRenderingPipeline),o.defaultRenderingPipeline&&ue.set(r,o.defaultRenderingPipeline),o.taaRenderingPipeline&&he.set(r,o.taaRenderingPipeline))})}n(Vo,"applyRenderingConfigurations");var Fo=require("babylonjs");function ye(t,e,i){return new Promise((o,r)=>{let a=new Fo.WebRequest;a.open("GET",t),a.responseType=e,a.send(),a.addEventListener("progress",l=>{i?.({total:l.total,loaded:l.loaded})}),a.addEventListener("load",()=>{o(e==="text"?a.responseText:a.response)}),a.addEventListener("error",l=>r(l))})}n(ye,"loadFile");async function z(t,e){let i=await ye(t,"text",e);return JSON.parse(i)}n(z,"loadJsonFile");function ui(t,e){let i=e.getNodeByName(t);if(i)return i;let o=e.lights.filter(r=>le(r));for(let r of o){let a=r.lights.find(l=>l.name===t);if(a)return a}return null}n(ui,"getNodeByName");function be(t,e){let i=e.getNodeById(t);if(i)return i;let o=e.lights.filter(r=>le(r));for(let r of o){let a=r.lights.find(l=>l.id===t);if(a)return a}return null}n(be,"getNodeById");var ae=require("babylonjs"),No=require("babylonjs");function gi(t){let e=No.Vector3.FromArray(t);return e.equals(ae.Axis.X)?ae.Axis.X:e.equals(ae.Axis.Y)?ae.Axis.Y:e.equals(ae.Axis.Z)?ae.Axis.Z:e}n(gi,"parseAxis");function Go(t){return t.runtimeConfiguration.forEach(e=>{e.rotationAxis&&(e.rotationAxis=gi(e.rotationAxis)),e.boneOffsetAxis&&(e.boneOffsetAxis=gi(e.boneOffsetAxis))}),t}n(Go,"parseRagdollConfiguration");function vi(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,boxOffset:i.boxOffset,rotationAxis:i.rotationAxis?.slice(),boneOffsetAxis:i.boneOffsetAxis?.slice()}))};return Go(e)}n(vi,"copyAndParseRagdollConfiguration");function ea(t){return new Promise(e=>{setTimeout(()=>e(),t)})}n(ea,"waitMs");async function Si(t){for(;!t();)await ea(150)}n(Si,"waitUntil");function yi(t){return t&&JSON.parse(JSON.stringify(t))}n(yi,"cloneJSObject");var xi=require("babylonjs"),Wo=require("babylonjs"),rt=require("babylonjs"),Xo=require("babylonjs"),$o=require("babylonjs"),Ko=require("babylonjs"),te=require("babylonjs"),Bo=!1,zo=null,xe=[],bi=new Map;function ta(t,e){let i=(0,te._GetAudioEngine)(null);return new Ko._WebAudioStaticSound(t,i,e)}n(ta,"createSoundInstance");function Ho(t){if(zo?.remove(),!xe.length)return;let e=xi.Vector3.Zero();zo=t.onBeforeRenderObservable.add(()=>{let i=(0,te._GetAudioEngine)(null).listener.attachedNode;i&&(i.getWorldMatrix().getTranslationToRef(e),xe.forEach(o=>{o.isEnabled(!1)&&o.autoUpdateSpatial&&o.sound?._isSpatial&&o.isPlaying()&&t.activeCamera&&xi.Vector3.Distance(e,o.getAbsolutePosition())<=o.sound.spatial.maxDistance&&o.sound.spatial.update()}))})}n(Ho,"registerUpdateSoundsObserver");function ko(t){t.sound?.onDisposeObservable.addOnce(()=>{let e=xe.indexOf(t);e!==-1&&xe.splice(e,1)}),t.onDisposeObservable.addOnce(()=>{t.sound?.dispose()})}n(ko,"registerSoundNodeEvents");function ia(t,e){return new Promise(async(i,o)=>{if(!t.offlineProvider||!Wo.Database.IDBStorageEnabled)return(0,te.CreateSoundBufferAsync)(e).then(r=>i(r)).catch(r=>o(r));t.offlineProvider.loadFile(e,r=>{(0,te.CreateSoundBufferAsync)(r).then(a=>i(a)).catch(a=>o(a))},void 0,()=>{o(null)},!0)})}n(ia,"loadSoundBuffer");function Li(t,e){if(!t.soundRelativePath||!t.sound)return;e.onSoundLoadedObservable=new Xo.Observable;let i=ta(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,xe.push(e),Ho(e.getScene()),e.onSoundLoadedObservable.notifyObservers(e)}),ko(e),Uo(e,i)}n(Li,"configureSourceNodeFrom");function Uo(t,e){Object.defineProperty(t,"volume",{get:n(()=>e.volume,"get"),set:n(i=>{e.volume=i},"set")}),Object.defineProperty(t,"playbackRate",{get:n(()=>e.playbackRate,"get"),set:n(i=>{e.playbackRate=i},"set")}),t.isPaused=()=>e.state===rt.SoundState.Paused,t.isPlaying=()=>e.state===rt.SoundState.Started,t.isStopped=()=>e.state===rt.SoundState.Stopped,t.pause=()=>e.pause(),t.resume=()=>e.resume(),t.stop=i=>e.stop(i),t.play=i=>e.play(i),t.setVolume=(i,o)=>e.setVolume(i,o),t.getClassName=()=>"SoundNode",t.setSoundSpatial=i=>new Promise(o=>{e._isSpatial=i,setTimeout(()=>{i&&e.spatial.attach(t),o()})}),t.cloneAsync=async(i,o,r)=>new Promise(a=>{let l=t.clone(i,o,r);Li(t,l),l.onSoundLoadedObservable.addOnce(()=>{setTimeout(()=>a(l))})})}n(Uo,"configureSoundNodePrototype");function jo(){Bo||(Bo=!0,(0,$o.AddParser)("SoundNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSoundNode)return;let a=i.transformNodes?.find(l=>l.id===r.id);if(a&&r.soundRelativePath){let l=`${o}${r.soundRelativePath}`;e.addPendingData(l),bi.has(l)||bi.set(l,ia(e,l)),bi.get(l).then(s=>{(0,te.CreateSoundAsync)(r.soundRelativePath,s,{spatialAutoUpdate:!1}).then(c=>{if(e.removePendingData(l),a.isDisposed())return c.dispose();c.volume=r.volume,c._isSpatial=r.isSpatial,r.isSpatial&&(c.spatial.attach(a),c.spatial.maxDistance=r.maxDistance,c.spatial.panningModel=r.panningModel,c.spatial.distanceModel=r.distanceModel),a.sound=c,a.soundRelativePath=r.soundRelativePath,a.autoUpdateSpatial=r.autoUpdateSpatial,xe.push(a),ko(a),Uo(a,c),Ho(e)})})}})}))}n(jo,"registerAudioParser");var Zo=require("babylonjs");function Le(t){let e=new Set;[...t.transformNodes,...t.meshes].forEach(o=>{if(o.metadata?.isStaticGroup){let r=o.getDescendants(!1);r.push(o),r.forEach(a=>{if((ie(a)||J(a)&&!a.isWorldMatrixFrozen)&&a.billboardMode===Zo.AbstractMesh.BILLBOARDMODE_NONE&&a.freezeWorldMatrix(),ie(a)){let l=a.material;l&&!l.isFrozen&&!e.has(l)&&(e.add(l),l.onBindObservable.addOnce(()=>{l.freeze()}))}})}})}n(Le,"configureTransformNodes");var Ve=class{constructor(e,i){this.entries=e;this.namingId=i}entries;namingId;static{n(this,"AdvancedAssetContainerInstantiatedEntries")}get rootNodes(){return this.entries.rootNodes}get skeletons(){return this.entries.skeletons}get animationGroups(){return this.entries.animationGroups}dispose(){this.entries.dispose()}getRootNodeByName(e){let i=`${e}-${this.namingId}`;return this.entries.rootNodes.find(o=>o.name===i)??null}getNodeByName(e){let i=`${e}-${this.namingId}`;for(let o of this.entries.rootNodes){let r=this._recursivelyGetNodeByName(i,o);if(r)return r}return null}_recursivelyGetNodeByName(e,i){if(i.name===e)return i;for(let o of i.getDescendants(!0)){let r=this._recursivelyGetNodeByName(e,o);if(r)return r}return null}getScriptByClassByObjectName(e,i){let o=this.getNodeByName(e);if(o){let r=Ce(o,i);if(r?.length===1)return r[0]}return null}};var Ci=require("babylonjs"),Fe=class{static{n(this,"AdvancedAssetContainer")}container;_rootUrl;_scriptsMap;_originalDescendants=[];_nodesMap=new Map;_animationGroupsMap=new Map;constructor(e,i,o){this.container=e,this._rootUrl=i,this._scriptsMap=o,e.populateRootNodes(),e.rootNodes.forEach(r=>{this._originalDescendants.push(r,...r.getDescendants(!1))}),e.animationGroups.forEach(r=>{this._animationGroupsMap.set(r.name,r)}),this._originalDescendants.forEach(r=>{this._nodesMap.set(r,{node:r,metadata:yi(r.metadata)})})}removeDefault(){this.container.getNodes().forEach(e=>{H.get(e)?.forEach(o=>{nt(e,o)})}),this.container.removeAllFromScene()}getRootNodeByName(e){return this.container.rootNodes.find(i=>i.name===e)??null}getScriptByClassByObjectName(e,i){let o=this.container.getNodes();for(let r of o)if(r.name===e){let a=Ce(r,i);if(a?.length===1)return a[0]}return null}instantiate(e){let i=Ci.Tools.RandomId(),o=n(s=>s,"nameFunction"),r=this.container.instantiateModelsToScene(o,!1,{...e,predicate:n(s=>(s.name=`${s.name}@editor-tools@${i}_${s.id}`,e?.predicate?.(s)??!0),"predicate")}),a=new Ve(r,i);[...this.container.transformNodes,...this.container.meshes,...this.container.lights,...this.container.cameras,...this.container.animationGroups,...this.container.skeletons].forEach(s=>{let c=s.name.split("@editor-tools@");s.name=c[0]}),r.animationGroups.forEach(s=>{let c=s.name.split("@editor-tools@");s.name=`${c[0]}-${i}`});let p=[];return r.rootNodes.forEach(s=>{p.push(s,...s.getDescendants(!1))}),p.forEach(s=>{let c=s.name.split("@editor-tools@"),m=c[1].split("_").pop();s.name=`${c[0]}-${i}`;let h=this._originalDescendants.find(d=>d.id===m);re(h)&&J(s)&&Li(h,s),s.id=Ci.Tools.RandomId(),s.metadata=yi(this._nodesMap.get(h).metadata),s.metadata??={},s.metadata.originalId=m,p.forEach(d=>{d.metadata.scripts?.forEach(f=>{Object.keys(f.values||{}).forEach(g=>{let b=f.values[g];if(b.type==="entity"){b.value===m&&(b.value=s.id),b.value===h.name&&(b.value=s.name);let C=this._animationGroupsMap.get(b.value);C&&(b.value=`${C.name}-${i}`)}})})})}),p.forEach(s=>{B(this.container.scene,s,this._scriptsMap,this._rootUrl)}),Le(this.container.scene),a}};var Yo=require("babylonjs"),qo=require("babylonjs");async function Qo(t,e,i){let o=i.iblIntensity,r=i.environmentIntensity,l=t.split("/").pop().replace(".scene",".babylon"),p=await(0,qo.LoadAssetContainerAsync)(l,i,{rootUrl:e,pluginExtension:".babylon"});return Yo.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(s=>V(s)&&s._checkDelayState()),p.addAllToScene(),i.iblIntensity=o,i.environmentIntensity=r,Le(i),p}n(Qo,"preloadSceneScriptAsset");async function Jo(t,e){return z(`${e}${t}`)}n(Jo,"preloadCommonScriptAsset");var I=new Map,Ne=new Map;function oa(t,e){Ne.has(t)&&console.warn(`A parser for the extension '${t}' was already registered. It will be overwritten.`),Ne.set(t,e)}n(oa,"registerScriptAssetParser");async function Di(t,e,i){[e,...e.transformNodes,...e.meshes,...e.lights,...e.cameras].filter(p=>p.metadata?.scripts?.length).map(p=>p.metadata.scripts).flat().forEach(p=>{if(i[p.key]?.default?._SceneAssets?.forEach(c=>{I.get(c.sceneName)||I.set(c.sceneName,null)}),p.values)for(let c in p.values){if(!p.values.hasOwnProperty(c))continue;let m=p.values[c];m.type==="asset"&&m.value&&!I.get(m.value)&&I.set(m.value,null)}});let a=0;for(let p of I.values())p===null&&++a;if(a===0)return a;let l=[];return I.forEach((p,s)=>{I.get(s)||l.push(new Promise(async c=>{try{let m=s.split(".").pop();switch(m){case"scene":let h=await Qo(s,t,e);e.onDisposeObservable.addOnce(()=>{h.dispose(),I.delete(s)}),I.set(s,new Fe(h,t,i));break;default:if(Ne.has(m)){let d=Ne.get(m);I.set(s,await d({key:s,rootUrl:t,scene:e}));break}else I.set(s,await Jo(s,t));break}}catch(m){console.error(m)}c()}))}),await Promise.all(l),a}n(Di,"_preloadScriptsAssets");var er=require("babylonjs"),at=require("babylonjs"),tr=require("babylonjs"),st=require("babylonjs"),ir=require("babylonjs"),or=require("babylonjs-gui");function _i(t,e,i,o,r){let a=o.constructor;if(!a)return;a._NodesFromScene?.forEach(s=>{o[s.propertyKey.toString()]=ui(s.nodeName,t)}),a._ComponentsFromScene?.length&&t.getEngine().onBeginFrameObservable.addOnce(()=>{a._ComponentsFromScene?.forEach(s=>{let c=[];if([t,...t.transformNodes,...t.meshes,...t.lights,...t.cameras].forEach(h=>{let d=wi(h,s.componentConstructor);d&&c.push(d)}),c.length>1)throw new Error(`Multiple components of type ${a._ComponentsFromScene[0].componentConstructor.name} found in scene for property "${a._ComponentsFromScene[0].propertyKey.toString()}".`);o[s.propertyKey.toString()]=c[0]??null})}),a._NodesFromDescendants?.forEach(s=>{let c=e.getDescendants?.(s.directDescendantsOnly,m=>m.name===s.nodeName)[0];o[s.propertyKey.toString()]=c??null}),a._AnimationGroups?.forEach(s=>{o[s.propertyKey.toString()]=t.getAnimationGroupByName(s.animationGroupName)}),a._SoundsFromScene?.forEach(s=>{let c=ui(s.soundName,t);c&&re(c)&&(o[s.propertyKey.toString()]=c??null)}),(a._GuiFromAsset??[]).map(async s=>{let c=`${r}assets/${s.pathInAssets}`;try{let m=await z(c),h=or.AdvancedDynamicTexture.CreateFullscreenUI(m.name,!0,t);h.parseSerializedObject(m.content,!1),o[s.propertyKey.toString()]=h,s.onGuiCreated?.(o,h)}catch(m){throw console.error(`Failed to load GUI from asset: ${c}`),m}}),a._ParticleSystemsFromScene?.forEach(s=>{let c=t.particleSystems?.find(m=>m.name!==s.particleSystemName?!1:s.directDescendantsOnly?m.emitter===e:m);o[s.propertyKey.toString()]=c}),(a._VisibleInInspector??[]).forEach(s=>{let c=s.propertyKey.toString(),m=i.values;if(!m)throw new Error(`No values found for script with key "${i.key}".`);if(m.hasOwnProperty(c)&&m[c].hasOwnProperty("value")){let h=m[c].value;switch(s.configuration.type){case"number":case"boolean":case"keymap":case"string":o[c]=h;break;case"vector2":o[c]=st.Vector2.FromArray(h);break;case"vector3":o[c]=st.Vector3.FromArray(h);break;case"color3":o[c]=at.Color3.FromArray(h);break;case"color4":o[c]=at.Color4.FromArray(h);break;case"entity":switch(s.configuration.entityType){case"node":case"sound":o[c]=be(h,t)??null;break;case"animationGroup":o[c]=t.getAnimationGroupByName(h)??null;break;case"particleSystem":o[c]=t.particleSystems?.find(f=>f.id===h)??null;break}break;case"texture":h&&(o[c]=tr.Texture.Parse(h,t,r));break;case"asset":if(h){let f=s.configuration.assetType,S=I.get(h);switch(f){case"json":case"gui":case"scene":case"navmesh":case"cinematic":o[c]=S;break;case"ragdoll":o[c]=vi(S);break;case"nodeParticleSystemSet":let g=ir.NodeParticleSystemSet.Parse(S);o[c]=g;break;case"material":o[c]=er.Material.Parse(S,t,r);break}}}}});let l=null,p=null;if(a._PointerEvents?.length){if(a._PointerEvents.find(m=>m.options.mode==="attachedMeshOnly")&&!ie(e))throw new Error('@onPointerEvent with mode "attachedMeshOnly" can only be used on scripts attached to meshes (extends AbstractMesh).');if(a._PointerEvents.find(m=>m.options.mode!=="global")&&!ce(e))throw new Error('@onPointerEvent with mode different from "global" can be used only on scripts attached to Node: Mesh, Light, Camera, TransformNode.');l=t.onPointerObservable.add(m=>{let h=null;a._PointerEvents.forEach(d=>{if(!d.eventTypes.includes(m.type))return;let f=d.propertyKey.toString();if(d.options.mode==="global")return o[f]?.(m);h=m.pickInfo,h||(h=t.pick(t.pointerX,t.pointerY,g=>g.isVisible&&g.isPickable&&g.isEnabled(!0)&&!g._masterMesh,!1));let S=h.pickedMesh;if(S&&(d.options.mode==="attachedMeshOnly"&&S===e||d.options.mode==="includeDescendants"&&ce(e)&&[e,...e.getDescendants(!1)].find(C=>C===S)))return o[f]?.(m)})})}if(a._KeyboardEvents?.length&&(p=t.onKeyboardObservable.add(s=>{a._KeyboardEvents.forEach(c=>{c.eventTypes.includes(s.type)&&o[c.propertyKey.toString()]?.(s)})})),a._SpritesFromSpriteManager?.length){let s=e;if(!J(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.`);a._SpritesFromSpriteManager?.forEach(c=>{let m=s.spriteManager?.sprites.find(h=>h.name===c.spriteName)||null;o[c.propertyKey.toString()]=m})}if(a._AnimationsFromSprite?.length){if(!Lt(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.`);a._AnimationsFromSprite.forEach(c=>{let m=s.find(h=>h.name===c.animationName);m?o[c.propertyKey.toString()]=m??null:console.warn(`Sprite animation named "${c.animationName}" not found on sprite "${e.name}".`)})}return a._SceneAssets?.forEach(s=>{o[s.propertyKey.toString()]=I.get(s.sceneName)}),{observers:{pointerObserver:l,keyboardObserver:p}}}n(_i,"applyDecorators");function B(t,e,i,o){e.metadata?.scripts&&(e.metadata.scripts?.forEach(r=>{if(!r.enabled)return;let a=i[r.key];if(!a)return;let l=a,p={};if(a.default){l=new a.default(e);let s=_i(t,e,r,l,o);Object.assign(p,s?.observers??{})}l.onStart&&(p.onStartObserver=t.onBeforeRenderObservable.addOnce(()=>l.onStart(e))),l.onUpdate&&(p.onUpdateObserver=t.onBeforeRenderObservable.add(()=>l.onUpdate(e))),Pi(e,l,r.key,p)}),e.metadata.scripts=void 0)}n(B,"_applyScriptsForObject");function ra(t,e,i){if(i??=t.getScene?.(),!i)throw new Error("Cannot apply script on object: no scene available.");let o=new e(t),r={};return _i(i,t,{values:{}},o,""),o.onStart&&(r.onStartObserver=i.onBeforeRenderObservable.addOnce(()=>o.onStart())),o.onUpdate&&i.onBeforeRenderObservable.add(()=>o.onUpdate()),Pi(t,o,"runtime",r),o}n(ra,"applyScriptOnObject");var H=new Map;function Pi(t,e,i,o){let r={key:i,observers:o,instance:e};H.has(t)?H.get(t).push(r):H.set(t,[r]),(ce(t)||xt(t)||yt(t)||re(t))&&t.onDisposeObservable.addOnce((()=>{H.get(t)?.slice()?.forEach(l=>{nt(t,l)}),H.delete(t)}))}n(Pi,"_registerScriptInstance");function nt(t,e){e.observers.onStartObserver?.remove(),e.observers.onUpdateObserver?.remove(),e.observers.pointerObserver?.remove(),e.observers.keyboardObserver?.remove();try{e.instance.onStop?.(t)}catch(r){console.error(`Failed to call onStop for script ${e.key} on object ${t}`,r)}let i=H.get(t),o=i?.indexOf(e)??-1;o!==-1&&i?.splice(o,1)}n(nt,"_removeRegisteredScriptInstance");function Ce(t,e){return H.get(t)?.filter(r=>r.instance.constructor===e)?.map(r=>r.instance)??null}n(Ce,"getAllScriptsByClassForObject");function wi(t,e){return Ce(t,e)?.[0]??null}n(wi,"getScriptByClassForObject");var nr=require("babylonjs"),rr=!1;function ar(){rr||(rr=!0,(0,nr.AddParser)("MeshEditorPlugin",(t,e,i,o)=>{t.meshes?.forEach(r=>{r.instances?.forEach(a=>{let l=i.meshes?.find(p=>p.id===a.id);l&&a.billboardMode!==void 0&&(l.billboardMode=a.billboardMode)})})}))}n(ar,"registerMeshParser");var sr=!1;function na(t){sr=t}n(na,"setUseKtx2CompressedTextures");function Ge(){return sr}n(Ge,"isUsingKtx2CompressedTextures");function lt(t){return`${t.substring(0,t.lastIndexOf("."))}.ktx2`}n(lt,"_getKtx2TextureName");function aa(t){t.setCompressedTextureExclusions([".env",".hdr",".dds"]),t.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}n(aa,"configureEngineToUseCompressedTextures");function ct(t,e){t._excludedCompressedTextures&&!t._excludedCompressedTextures?.includes(e)&&t._excludedCompressedTextures?.push(e)}n(ct,"addExcludedCompressedTexture");function sa(t,e,i){e.loadingTexturesQuality!==t&&(e.loadingTexturesQuality=t,e.textures.forEach(o=>{if(!Oe(o)||!o.url)return;let r=pt(o,e);!r||o.url.includes(r)||o.updateURL(i+r)}))}n(sa,"applyTexturesQuality");function pt(t,e){if(e.loadingTexturesQuality==="high"||!t.metadata?.baseSize)return t.name;let i=t.metadata.baseSize.width,o=t.metadata.baseSize.height,r=i===F(i)||o===F(o),a="";switch(e.loadingTexturesQuality){case"medium":let d=i*.66>>0,f=o*.66>>0;r&&(d=F(d),f=F(f)),a=`_${d}_${f}`;break;case"low":case"very-low":let S=i*.33>>0,g=o*.33>>0;r&&(S=F(S),g=F(g)),a=`_${S}_${g}`;break}let l=t.name;if(!l||!a)return t.name;let p=l.split("/"),s=p.pop();if(!s)return t.name;let c=s.split(".").pop(),h=`${s.replace(`.${c}`,"")}${a}.${c}`;return p.push(h),p.join("/")}n(pt,"getTextureUrl");var Oi=require("babylonjs"),lr=!1;function cr(){if(lr)return;lr=!0;let t=Oi.SerializationHelper._TextureParser;Oi.SerializationHelper._TextureParser=(e,i,o)=>{Ge()&&(e.name&&(e.name=lt(e.name)),e.url&&(e.url=lt(e.url)));let r=pt(e,i);if(!r)return t(e,i,o);let a=e.name;e.name=r;let l=t(e,i,o);return l&&(l.name=a),l}}n(cr,"registerTextureParser");function Ei(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}}n(Ei,"normalizeAtlasJson");function la(t,e,i){let r=(t.metadata?.spriteAnimations??[]).find(a=>a.name===e);if(!r)return console.error(`Animation with name "${e}" not found on sprite.`);t.playAnimation(r.from,r.to,r.loop,r.delay,i)}n(la,"playSpriteAnimationFromName");var mr=require("babylonjs"),hr=require("babylonjs"),dr=require("babylonjs"),fr=require("babylonjs"),Ai=require("babylonjs"),De=require("babylonjs"),ur=require("babylonjs"),pr=!1;function gr(){pr||(pr=!0,(0,ur.AddParser)("SpriteMapNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSpriteMap)return;let a=i.transformNodes?.find(s=>s.id===r.id);if(!a)return;a.isSpriteMap=r.isSpriteMap;let l=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(l);let p=new dr.WebRequest;p.open("GET",l),p.send(),p.addEventListener("load",()=>{e.removePendingData(l);let s=JSON.parse(p.responseText);Ei(s);let c=`${mr.Tools.GetFolderPath(l)}${s.meta.image}`,m=new Ai.Texture(c,e,!1,!1,Ai.Texture.NEAREST_NEAREST,null,null,null,!1,hr.Engine.TEXTUREFORMAT_RGBA),h=new fr.SpriteMap(a.name,s,m,{layerCount:r.options.layerCount,stageSize:De.Vector2.FromArray(r.options.stageSize??[10,1]),outputSize:De.Vector2.FromArray(r.options.outputSize??[100,100]),colorMultiply:De.Vector3.FromArray(r.options.colorMultiply??[1,1,1]),flipU:!0},e);r.getClassName=()=>"SpriteMapNode",r.tiles.forEach(f=>{for(let S=0,g=f.repeatCount.x+1;S<g;++S)for(let b=0,C=f.repeatCount.y+1;b<C;++b){let _=S*(f.repeatOffset.x+1),x=b*(f.repeatOffset.y+1);h.changeTiles(f.layer,new De.Vector2(f.position.x+_,(h.options.stageSize?.y??0)-1-f.position.y-x),f.tile)}});let d=h._output;d.parent=a,a.spriteMap=h})})}))}n(gr,"registerSpriteMapParser");var Sr=require("babylonjs"),yr=require("babylonjs"),mt=require("babylonjs"),br=require("babylonjs"),vr=!1;function xr(){if(vr)return;vr=!0,(0,br.RegisterShadowGeneratorSceneComponent)(yr.ShadowGenerator);let t=(0,mt.GetParser)(Sr.SceneComponentConstants.NAME_SHADOWGENERATOR);(0,mt.AddParser)("ShadowGeneratorEditorPlugin",(e,i,o,r)=>{let a=new Map;e.shadowGenerators?.forEach(l=>{if(a.set(l.id,l.mapSize),i.loadingShadowsQuality!=="high"){switch(i.loadingShadowsQuality){case"medium":l.mapSize=l.mapSize*.5;break;case"low":l.mapSize=l.mapSize*.25;break;case"very-low":l.mapSize=l.mapSize*.125;break}l.mapSize=Math.max(128,F(l.mapSize))}}),t?.(e,i,o,r),i.lights.forEach(l=>{let p=l.getShadowGenerator();if(p?.getShadowMap()){let c=p.id,m=a.get(c);m&&(p.originalMapSize=m)}})})}n(xr,"registerShadowGeneratorParser");var Dr=require("babylonjs"),_r=require("babylonjs"),wr=require("babylonjs"),Ti=require("babylonjs"),Pr=require("babylonjs");function Lr(t,e){e?.fogEnabled!==void 0&&(t.fogEnabled=e?.fogEnabled),e?.blendMode!==void 0&&(t.blendMode=e?.blendMode),e?.disableDepthWrite!==void 0&&(t.disableDepthWrite=e?.disableDepthWrite),e?.pixelPerfect!==void 0&&(t.pixelPerfect=e?.pixelPerfect),e?.useLogarithmicDepth!==void 0&&(t.useLogarithmicDepth=e?.useLogarithmicDepth),e?.metadata!==void 0&&(t.metadata=e?.metadata);for(let i of e?.sprites??[]){let o=_r.Sprite.Parse(i,t);o.uniqueId=i.uniqueId,o.metadata=i.metadata}}n(Lr,"parseSerializedSpriteManager");var Cr=!1;function Or(){Cr||(Cr=!0,(0,Pr.AddParser)("SpriteManagerNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSpriteManager)return;let a=i.transformNodes?.find(p=>p.id===r.id);if(!a)return;let l=e.getEngine();if(a.isSpriteManager=r.isSpriteManager,r.atlasJsonRelativePath){let p=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(p);let s=new wr.WebRequest;s.open("GET",p),s.send(),s.addEventListener("load",()=>{e.removePendingData(p);let c=JSON.parse(s.responseText),m=`${Dr.Tools.GetFolderPath(p)}${c.meta.image}`;ct(l,m);let h=new Ti.SpriteManager(a.name,m,1e3,64,e,void 0,void 0,!0,c);a.spriteManager=h,a.getClassName=()=>"SpriteManagerNode",r.spriteManager&&Lr(h,r.spriteManager)})}else if(r.spriteManager?.textureUrl){ct(l,r.spriteManager.textureUrl);let p=`${o}${r.spriteManager.textureUrl}`,s=new Ti.SpriteManager(a.name,p,1e3,{width:r.spriteManager.cellWidth,height:r.spriteManager.cellHeight},e,void 0,void 0,!1);a.spriteManager=s,a.getClassName=()=>"SpriteManagerNode",r.spriteManager&&Lr(s,r.spriteManager)}})}))}n(Or,"registerSpriteManagerParser");var Ar=require("babylonjs"),Tr=require("babylonjs"),Er=!1;function Ir(){Er||(Er=!0,(0,Tr.AddParser)("MorphTargetManagerEditorPlugin",(t,e,i,o)=>{t.morphTargetManagers.forEach(r=>{let l=i.meshes.find(c=>c.id===r.meshId)?.morphTargetManager;if(!l||r.targets.find(c=>!c.delayLoadingFile))return;let s=[];r.targets.forEach(c=>{if(!c.delayLoadingFile)return s.push(Promise.resolve(null));let m=`${o}${c.delayLoadingFile}`;e.addPendingData(m);let h=new Ar.WebRequest;h.responseType="arraybuffer",h.open("GET",m),h.send(),s.push(new Promise(d=>{h.addEventListener("load",()=>{e.removePendingData(m),d(h.response)})}))}),Promise.all(s).then(c=>{for(let m=0,h=l.numTargets;m<h;++m){let d=l.getTarget(m),f=r.targets[m],S=c[m];if(f.positionsCount){let g=new Float32Array(S,f.positionsOffset,f.positionsCount);d._positions=g,d.setPositions(g)}if(f.normalsCount){let g=new Float32Array(S,f.normalsOffset,f.normalsCount);d._normals=g,d.setNormals(g)}if(f.tangentsCount){let g=new Float32Array(S,f.tangentsOffset,f.tangentsCount);d._tangents=g,d.setTangents(g)}if(f.uvsCount){let g=new Float32Array(S,f.uvsOffset,f.uvsCount);d._uvs=g,d.setUVs(g)}if(f.uv2sCount){let g=new Float32Array(S,f.uv2sOffset,f.uv2sCount);d._uv2s=g,d.setUV2s(g)}}for(let m=0,h=l.numTargets;m<h;++m)l.getTarget(m)._onDataLayoutChanged.notifyObservers()})})}))}n(Ir,"registerMorphTargetManagerParser");var Rr=require("babylonjs"),Vr=require("babylonjs"),Mr=!1;function Fr(){Mr||(Mr=!0,(0,Rr.AddParser)("NodeParticleSystemSetEditorPlugin",(t,e,i,o)=>{t.meshes?.forEach(r=>{if(!r.isNodeParticleSystemMesh)return;let a=i.meshes?.find(l=>l.id===r.id);a&&(r.nodeParticleSystemSet.blocks?.forEach(l=>{l.url&&(l.url=`${o}${l.url}`)}),a.nodeParticleSystemSet=Vr.NodeParticleSystemSet.Parse(r.nodeParticleSystemSet),a.nodeParticleSystemSet.id=r.nodeParticleSystemSet.id,a.nodeParticleSystemSet.uniqueId=r.uniqueId,e.addPendingData(r.id),a.nodeParticleSystemSet.buildAsync(e,!1).then(l=>{e.removePendingData(r.id),a.particleSystemSet=l,l.systems.forEach(p=>{if(bt(p)){let s=p._sizeCreation.process;s&&(p._sizeCreation.process=(c,m)=>{s(c,m),c.scale.x*=100,c.scale.y*=100})}}),l.emitterNode=a,l.start()}))})}))}n(Fr,"registerNodeParticleSystemSetParser");var Nr=require("babylonjs");function Gr(t,e){e??=new Nr.ClusteredLightContainer("Clustered Light Container",[],t);let i=t.metadata?.clusteredLight;return i&&(i.lights.length>0&&(e.horizontalTiles=i.horizontalTiles,e.verticalTiles=i.verticalTiles,e.depthSlices=i.depthSlices,e.maxRange=i.maxRange),i.lights.forEach(o=>{let r=t.getLightById(o);r&&e?.addLight(r)})),e}n(Gr,"configureLights");var Hr=require("babylonjs"),Ii=require("babylonjs"),kr=require("babylonjs"),Ur=require("babylonjs"),Br=new Map;async function zr(t,e){let i=t.getWaitingItemsCount();for(;!t.isDisposed&&(!t.isReady()||t.getWaitingItemsCount()>0);){await new Promise(r=>setTimeout(r,150));let o=i-t.getWaitingItemsCount();o===i&&t.textures.forEach(r=>{r.delayLoadState===Ii.Constants.DELAYLOADSTATE_NONE&&(r.delayLoadState=Ii.Constants.DELAYLOADSTATE_LOADED)}),e(o/i)}}n(zr,"waitForWaitingItems");async function ca(t,e,i,o,r){i.loadingQuality=r?.quality??"high",i.loadingTexturesQuality=r?.texturesQuality??i.loadingQuality,i.loadingShadowsQuality=r?.shadowsQuality??i.loadingQuality,i.loadingLodsQuality=r?.lodsQuality??i.loadingQuality,ar(),jo(),cr(),xr(),Ir(),gr(),Or(),Fr();let a=Br.get(i)??{};if(Br.set(i,a),await(0,kr.AppendSceneAsync)(`${t}${e}`,i,{pluginExtension:".babylon",onProgress:n(p=>{let s=Math.min(p.loaded/p.total*.5);r?.onProgress?.(s)},"onProgress")}),await zr(i,p=>{r?.onProgress?.(.5+p*.25)}),!r?.skipAssetsPreload){let p=0;do p=await Di(t,i,o);while(p!==0&&!i.isDisposed)}Ur.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(p=>V(p)&&p._checkDelayState());let l=Gr(i,a.clusteredLightContainer);a.clusteredLightContainer=l,await zr(i,p=>{r?.onProgress?.(.75+p*.25)}),r?.onProgress?.(1),_t(i),wt(i.loadingLodsQuality,i),Pt(i),Ke(i),i.metadata?.rendering&&(Vo(i,i.metadata.rendering),i.activeCamera&&fi(i.activeCamera,t,r?.postProcessConfiguration)),i.metadata?.physicsGravity&&i.getPhysicsEngine()?.setGravity(Hr.Vector3.FromArray(i.metadata?.physicsGravity)),B(i,i,o,t),i.transformNodes.forEach(p=>{B(i,p,o,t)}),i.meshes.forEach(p=>{Ro(p),B(i,p,o,t)}),i.lights.forEach(p=>{B(i,p,o,t)}),l.lights.forEach(p=>{B(i,p,o,t)}),i.cameras.forEach(p=>{B(i,p,o,t)}),i.spriteManagers?.forEach(p=>{p.sprites.forEach(s=>{B(i,s,o,t)})}),Le(i)}n(ca,"loadScene");var Wr=require("babylonjs");async function pa(t,e,i){let o=await z(t+e),a=Wr.Tools.Instantiate(o.customType).Parse(o,i,t);return a.id=o.id,a.uniqueId=o.uniqueId,a}n(pa,"loadMaterialFromFile");function ma(t){return Promise.all(t.materials.map(async e=>{let i=e.getBindedMeshes();await Promise.all(i.map(async o=>{Pe(o)||await e.forceCompilationAsync(o,{clipPlane:!!t.clipPlane,useInstances:o.hasInstances})}))}))}n(ma,"forceCompileAllSceneMaterials");var q=require("babylonjs");function Be(t){if(!isNaN(parseFloat(t))&&isFinite(t))return q.Animation.ANIMATIONTYPE_FLOAT;switch(t?.getClassName?.()){case"Vector2":return q.Animation.ANIMATIONTYPE_VECTOR2;case"Vector3":return q.Animation.ANIMATIONTYPE_VECTOR3;case"Quaternion":return q.Animation.ANIMATIONTYPE_QUATERNION;case"Color3":return q.Animation.ANIMATIONTYPE_COLOR3;case"Color4":return q.Animation.ANIMATIONTYPE_COLOR4;case"Size":return q.Animation.ANIMATIONTYPE_SIZE;case"Matrix":return q.Animation.ANIMATIONTYPE_MATRIX}return null}n(Be,"getAnimationTypeForObject");var Xr=require("babylonjs");function ha(t){return function(e,i){let o=e.constructor;o._NodesFromScene??=[],o._NodesFromScene.push({propertyKey:i,nodeName:t})}}n(ha,"nodeFromScene");function da(t){return function(e,i){let o=e.constructor;o._ComponentsFromScene??=[],o._ComponentsFromScene.push({propertyKey:i,componentConstructor:t})}}n(da,"componentFromScene");function fa(t,e=!1){return function(i,o){let r=i.constructor;r._NodesFromDescendants??=[],r._NodesFromDescendants.push({propertyKey:o,nodeName:t,directDescendantsOnly:e})}}n(fa,"nodeFromDescendants");function ua(t){return function(e,i){let o=e.constructor;o._AnimationGroups??=[],o._AnimationGroups.push({animationGroupName:t,propertyKey:i})}}n(ua,"animationGroupFromScene");function ga(t){return function(e,i){let o=e.constructor;o._SceneAssets??=[],o._SceneAssets.push({sceneName:t,propertyKey:i})}}n(ga,"sceneAsset");function va(t,e){return function(i,o){let r=i.constructor;r._GuiFromAsset??=[],r._GuiFromAsset.push({propertyKey:o,pathInAssets:t,onGuiCreated:e})}}n(va,"guiFromAsset");function Sa(t){return function(e,i){let o=e.constructor;o._SoundsFromScene??=[],o._SoundsFromScene.push({propertyKey:i,soundName:t})}}n(Sa,"soundFromScene");function ya(t,e=!1){return function(i,o){let r=i.constructor;r._ParticleSystemsFromScene??=[],r._ParticleSystemsFromScene.push({propertyKey:o,particleSystemName:t,directDescendantsOnly:e})}}n(ya,"particleSystemFromScene");function ba(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"boolean"}})}}n(ba,"visibleAsBoolean");function xa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"string"}})}}n(xa,"visibleAsString");function La(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"number"}})}}n(La,"visibleAsNumber");function Ca(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector2"}})}}n(Ca,"visibleAsVector2");function Da(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector3"}})}}n(Da,"visibleAsVector3");function _a(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color3"}})}}n(_a,"visibleAsColor3");function wa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color4"}})}}n(wa,"visibleAsColor4");function Pa(t,e,i){return function(o,r){let a=o.constructor;a._VisibleInInspector??=[],a._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...i,entityType:t,type:"entity"}})}}n(Pa,"visibleAsEntity");function Oa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"texture"}})}}n(Oa,"visibleAsTexture");function Ea(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"keymap"}})}}n(Ea,"visibleAsKeyMap");function Aa(t,e,i){return function(o,r){let a=o.constructor;a._VisibleInInspector??=[],a._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...i,assetType:t,type:"asset"}})}}n(Aa,"visibleAsAsset");function Ta(t,e){return function(i,o){let r=i.constructor;r._PointerEvents??=[],r._PointerEvents.push({propertyKey:o,options:{mode:"global",...e??{}},eventTypes:Array.isArray(t)?t:[t]})}}n(Ta,"onPointerEvent");function Ia(t){return function(e,i){let o=e.constructor;o._KeyboardEvents??=[],o._KeyboardEvents.push({propertyKey:i,eventTypes:Array.isArray(t)?t:[t]})}}n(Ia,"onKeyboardEvent");function Ma(t){return function(e,i){let o=e.constructor;o._SpritesFromSpriteManager??=[],o._SpritesFromSpriteManager.push({propertyKey:i,spriteName:t})}}n(Ma,"spriteFromSpriteManager");function Ra(t){return function(e,i){let o=e.constructor;o._AnimationsFromSprite??=[],o._AnimationsFromSprite.push({propertyKey:i,animationName:t})}}n(Ra,"animationFromSprite");var ht=require("babylonjs");function Cg(t,e){let i;return t===ht.Animation.ANIMATIONTYPE_FLOAT?i=e.value:i=e.value.clone(),{value:i,frame:e.frame,interpolation:e.interpolation,inTangent:t===ht.Animation.ANIMATIONTYPE_FLOAT?e.inTangent:e.inTangent?.clone(),outTangent:t===ht.Animation.ANIMATIONTYPE_FLOAT?e.outTangent:e.outTangent?.clone()}}n(Cg,"cloneKey");function dt(t,e){let i=e.split("."),o=t;for(let r=0;r<i.length;++r)o=o[i[r]];return o}n(dt,"getPropertyValue");function Mi(t,e,i){let o=null;t.onAnimationGroupPlayObservable.add(()=>{o=e.onAfterAnimationsObservable.add(()=>{i()})}),t.onAnimationGroupPauseObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)}),t.onAnimationGroupEndObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)})}n(Mi,"registerAfterAnimationCallback");var Q=require("babylonjs"),ft=require("babylonjs"),U=require("babylonjs");function Va(t,e){return{name:t.name,framesPerSecond:t.framesPerSecond,outputFramesPerSecond:t.outputFramesPerSecond,tracks:t.tracks.map(i=>{let o=null,r=null;if(i.node?(o=be(i.node,e),o||(o=e.particleSystems?.find(l=>l.id===i.node)??null)):i.defaultRenderingPipeline?o=Ee():i.volumetricLightScattering&&(o=Ot()),i.propertyPath){let l=dt(o,i.propertyPath);r=Be(l)}let a=null;return i.sound&&(a=be(i.sound,e)),{node:o,sound:a,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:Ri(i.soundVolume??[],Q.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:be(l.data.node,e)};break;case"apply-impulse":p.data={type:"apply-impulse",radius:l.data.radius,mesh:e.getMeshById(l.data.mesh),force:U.Vector3.FromArray(l.data.force),contactPoint:U.Vector3.FromArray(l.data.contactPoint)};break}return p}),keyFrameAnimations:o&&r!==null&&Ri(i.keyFrameAnimations??[],r)}})}}n(Va,"parseCinematic");function k(t,e){if(t===null)return null;if(t!==void 0)switch(e){case Q.Animation.ANIMATIONTYPE_FLOAT:return t;case Q.Animation.ANIMATIONTYPE_VECTOR2:return U.Vector2.FromArray(t);case Q.Animation.ANIMATIONTYPE_VECTOR3:return U.Vector3.FromArray(t);case Q.Animation.ANIMATIONTYPE_QUATERNION:return U.Quaternion.FromArray(t);case Q.Animation.ANIMATIONTYPE_COLOR3:return ft.Color3.FromArray(t);case Q.Animation.ANIMATIONTYPE_COLOR4:return ft.Color4.FromArray(t);case Q.Animation.ANIMATIONTYPE_MATRIX:return U.Matrix.FromArray(t)}}n(k,"parseCinematicKeyValue");function Ri(t,e){return t?.map(i=>{let o=i.type==="key"?i:null;if(o)return{...o,value:k(o.value,e),inTangent:k(o.inTangent,e),outTangent:k(o.outTangent,e)};let r=i.type==="cut"?i:null;if(r)return{...r,key1:{...r.key1,value:k(r.key1.value,e),inTangent:k(r.key1.inTangent,e),outTangent:k(r.key1.outTangent,e)},key2:{...r.key2,value:k(r.key2.value,e),inTangent:k(r.key2.inTangent,e),outTangent:k(r.key2.outTangent,e)}};throw new Error(`Unknown key frame type: ${i.type}`)})}n(Ri,"parseKeyFrameAnimations");function $r(t,e){t.onEventObservable.notifyObservers(e.eventName)}n($r,"handleApplyEvent");function Kr(t){t.node?.setEnabled(t.value)}n(Kr,"handleSetEnabledEvent");var Vi=require("babylonjs"),jr=Vi.Vector3.Zero();function Zr(t,e){let i=e.mesh?[e.mesh]:t.meshes.filter(o=>o.physicsAggregate);e.radius&&(i=i.filter(o=>{let r=o.getBoundingInfo().boundingBox.centerWorld;return Vi.Vector3.Distance(r,e.contactPoint)<=e.radius})),i.forEach(o=>{if(o.physicsAggregate?.body){let r=e.contactPoint.subtract(o.getBoundingInfo().boundingBox.centerWorld);r.multiplyInPlace(e.force),o.physicsAggregate.body.setLinearVelocity(jr),o.physicsAggregate.body.setAngularVelocity(jr),o.physicsAggregate.body.applyImpulse(r.negateInPlace(),e.contactPoint)}})}n(Zr,"handleApplyImpulseEvent");var Yr=require("babylonjs"),qr=require("babylonjs"),ze=class extends qr.AnimationGroup{static{n(this,"Cinematic")}onEventObservable=new Yr.Observable;onEvent(e,i){this.onEventObservable.add(o=>{e===o&&i()})}};function Fi(t){return t.type==="key"}n(Fi,"isCinematicKey");function _e(t){return t.type==="cut"}n(_e,"isCinematicKeyCut");function Fa(t){return t.type==="event"}n(Fa,"isCinematicKeyEvent");function Na(t){return t.type==="group"}n(Na,"isCinematicGroup");function Ga(t){return t.type==="sound"}n(Ga,"isCinematicSound");var P=require("babylonjs"),we=require("babylonjs");function Ba(t,e,i){let o=new ze(t.name,e);return t.tracks.forEach(r=>{let a=r.animationGroup;if(a&&r.animationGroups?.length){let d=a.clone(`${a.name}-cinematic-temp`),f=e.animationGroups.indexOf(d);f!==-1&&e.animationGroups.splice(f,1),o.onAnimationEndObservable.add(()=>{a.stop(),d.stop()});let S=r.animationGroups.reduce((_,x)=>Math.min(_,x.frame),Number.MAX_VALUE)??0,g=r.animationGroups.reduce((_,x)=>Math.max(_,x.frame+x.endFrame),0)??0,b={frame:S},C=new P.Animation(d.name,"frame",60,P.Animation.ANIMATIONTYPE_FLOAT,P.Animation.ANIMATIONLOOPMODE_CYCLE,!1);if(C.setKeys([{frame:S,value:0},{frame:g,value:g}]),r.animationGroups.forEach(_=>{C.addEvent(new we.AnimationEvent(_.frame,()=>{let x=_.repeatCount??0;if(d.to=_.endFrame,d.speedRatio=_.speed,d.stop(),d.play(x>0),d.from!==_.startFrame&&d.goToFrame(_.startFrame),x){let M=0;d.onAnimationGroupLoopObservable.add(()=>{++M,M>x&&d.stop()})}}))}),o.addTargetedAnimation(C,b),(r.animationGroupWeight?.length??0)>=2&&r.animationGroupWeight.find(x=>_e(x)?x.key1.value!==1||x.key2.value!==1:x.value!==1)){let x={weight:0},M=new P.Animation(`${d.name}-weights`,"weight",60,P.Animation.ANIMATIONTYPE_FLOAT,P.Animation.ANIMATIONLOOPMODE_CYCLE,!1),G=[];r.animationGroupWeight.forEach(v=>{_e(v)?(G.push(v.key1),G.push(v.key2)):G.push(v)}),M.setKeys(G),o.addTargetedAnimation(M,x),Mi(o,e,()=>{d.weight=x.weight})}}let l=r.sound;if(!i?.ignoreSounds&&l&&l.sound?.buffer&&r.sounds?.length){let d={dummy:0,volume:0},f=new P.Animation(l.name,"dummy",60,P.Animation.ANIMATIONTYPE_FLOAT,P.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;if(r.sounds?.forEach(g=>{let b=g.endFrame-g.startFrame;S=Math.max(S,g.frame+b),f.addEvent(new we.AnimationEvent(g.frame,C=>{let x=(C-g.frame+g.startFrame)/t.framesPerSecond;l.play({startOffset:x})},!1)),f.addEvent(new we.AnimationEvent(g.frame+b,()=>{l.stop()}))}),f.setKeys([{frame:0,value:0},{frame:S,value:S}]),o.addTargetedAnimation(f,d),(r.soundVolume?.length??0)>=2){let g=new P.Animation(l.name,"volume",60,P.Animation.ANIMATIONTYPE_FLOAT,P.Animation.ANIMATIONLOOPMODE_CYCLE,!1),b=[];r.soundVolume.forEach(C=>{_e(C)?(b.push(C.key1),b.push(C.key2)):b.push(C)}),g.setKeys(b),o.addTargetedAnimation(g,d),Mi(o,e,()=>{l.volume=d.volume})}}if(r.keyFrameEvents){let d={dummy:0},f=new P.Animation("events","dummy",60,P.Animation.ANIMATIONTYPE_FLOAT,P.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;r.keyFrameEvents?.forEach(g=>{S=Math.max(S,g.frame),f.addEvent(new we.AnimationEvent(g.frame,()=>{switch(g.data?.type){case"event":$r(o,g.data);break;case"set-enabled":Kr(g.data);break;case"apply-impulse":Zr(e,g.data);break}}))}),f.setKeys([{frame:0,value:0},{frame:S+1,value:S+1}]),o.addTargetedAnimation(f,d)}let p=r.defaultRenderingPipeline?Ee():r.node;if(!p||!r.propertyPath||!r.keyFrameAnimations)return;let s=dt(p,r.propertyPath),c=Be(s);if(c===null)return;let m=new P.Animation(r.propertyPath,r.propertyPath,60,c,P.Animation.ANIMATIONLOOPMODE_CYCLE,!1),h=[];r.keyFrameAnimations?.forEach(d=>{if(Fi(d))return h.push(d);_e(d)&&(h.push(d.key1),h.push(d.key2),Xe(p)&&r.propertyPath==="position"&&m.addEvent(new we.AnimationEvent(d.key1.frame,()=>{let f=Ht();if(!f)return;let S=f.motionStrength;f.motionStrength=0,requestAnimationFrame(()=>{f.motionStrength=S})})))}),m.setKeys(h),o.addTargetedAnimation(m,p)}),o.normalize(),o}n(Ba,"generateCinematicAnimationGroup");async function Ni(t,e){return new Promise((i,o)=>{let r=indexedDB.open(t,1);r.addEventListener("error",()=>o()),r.addEventListener("blocked",()=>o()),r.addEventListener("upgradeneeded",()=>{try{e(r.result)}catch(a){o(a)}}),r.addEventListener("success",()=>{i(r.result)})})}n(Ni,"openIndexDB");function He(t,e,i){return new Promise(o=>{let a=t.transaction(e).objectStore(e).get(i);a.addEventListener("error",()=>{o(null)}),a.addEventListener("success",()=>{o(a.result??null)})})}n(He,"getFromIndexDB");async function W(t,e,i){let r=t.transaction(e,"readwrite").objectStore(e).put(i);await new Promise((a,l)=>{r.addEventListener("error",()=>l()),r.addEventListener("success",()=>a())})}n(W,"putInIndexDB");var Qr=require("babylonjs");function za(t){Qr.AbstractEngine.OfflineProviderFactory=(e,i,o=!1)=>new ke(t,e,i,o)}n(za,"setupOfflineProvider");async function Gi(t,e){let i=await new Promise(o=>{let r=new ke(t,e,a=>o(a?r:null),!1)});return await i?.open(),i}n(Gi,"createAndOpenDatabase");var ke=class{static{n(this,"Database")}enableSceneOffline=!0;enableTexturesOffline=!0;name;_database=null;_manifestVersion=null;_loadFilePromises=new Map;constructor(e,i,o,r){this.name=e,r?o(!1):this._checkManifest(i,o)}async _checkManifest(e,i){try{let o=await z(`${e}.manifest?${Date.now()}`);this._manifestVersion=o.version,i(!0)}catch{this.enableSceneOffline=!1,this.enableTexturesOffline=!1,i(!1)}}async open(e,i){try{this._database=await Ni(this.name,o=>{o.createObjectStore("files",{keyPath:"url"}),o.createObjectStore("images",{keyPath:"url"}),o.createObjectStore("versions",{keyPath:"url"})}),e?.()}catch{i?.()}}close(){this._database?.close(),this._database=null,this._loadFilePromises.clear()}async loadImage(e,i){if(!this._database){i.src=e;return}let o=null;await Si(()=>this._manifestVersion!==null);let r=this._loadFilePromises.get(e);if(r)return r.then(l=>{l!==null?i.src=l:i.src=e});let a=new Promise(async l=>{if(await this._getFileVersionForUrl(e)!==this._manifestVersion?(o=await ye(e,"blob"),await Promise.all([W(this._database,"images",{url:e,data:o}),W(this._database,"versions",{url:e,version:this._manifestVersion})])):o=(await He(this._database,"images",e))?.data??null,o!==null){let s=URL.createObjectURL(o);i.src=s}else i.src=e;l(i.src)});this._loadFilePromises.set(e,a)}async saveImage(e){if(!this._database)throw new Error("Database is not available");let i=await ye(e,"blob");await Promise.all([W(this._database,"images",{url:e,data:i}),W(this._database,"versions",{url:e,version:this._manifestVersion})])}async isFileMatchingVersion(e){return await this._getFileVersionForUrl(e)===this._manifestVersion}async loadFile(e,i,o,r,a){if(!this._database)return r?.();let l=null;await Si(()=>this._manifestVersion!==null);let p=this._loadFilePromises.get(e);if(p)return p.then(c=>{c!==null?i(c):r?.()});let s=new Promise(async c=>{await this._getFileVersionForUrl(e)!==this._manifestVersion?(l=await ye(e,a?"arraybuffer":"text",o),await Promise.all([W(this._database,"files",{url:e,data:l}),W(this._database,"versions",{url:e,version:this._manifestVersion})])):l=(await He(this._database,"files",e))?.data??null,l!==null?i(l):r?.(),c(l)});this._loadFilePromises.set(e,s)}async saveFile(e,i,o){if(!this._database)throw new Error("Database is not available");let r=await ye(e,i?"arraybuffer":"text",o);await Promise.all([W(this._database,"files",{url:e,data:r}),W(this._database,"versions",{url:e,version:this._manifestVersion})])}async _getFileVersionForUrl(e){return(await He(this._database,"versions",e))?.version??null}};var Jr=["mp3","wav"],en=["babylonbinarymeshdata"],Ha=["ktx","ktx2","jpg","jpeg","png","bmp","webp"],tn=["babylon","json"],Bi=["jpg","jpeg","png","bmp","webp"],on=["bin","ktx","ktx2",...en,...Jr],ka=[...tn,...Bi,...on];async function Ua(t,e,i){let o=[],r=await z(`${e}scenes-used-files.json`),a=[];if(i?.scenesFilter){a=i.scenesFilter.map(h=>typeof h=="string"?{sceneName:h,disableSounds:!1,disableTextures:!1,disableGeometries:!1}:h);for(let[h,d]of Object.entries(r))a.find(f=>f.sceneName===h)||delete r[h]}let l=0,p=0,s=i?.engine?.textureFormatInUse?i?.engine?.texturesSupported[0]:null,c=Object.values(r).reduce((h,d)=>h+d.length,0);function m(h){++p,i?.onProgress?.(p/c),h?.()}n(m,"notifyProgress");for(let[h,d]of Object.entries(r)){let f=h.replace(".scene",".babylon"),S=await Gi(t,`${e}${f}`);if(!S)continue;let g=a.find(b=>b.sceneName===h);for(let b=0,C=d.length;b<C;++b){let _=d[b],x=_.split(".").pop()?.toLowerCase();if(!x){m();continue}if(en.includes(x)&&g?.disableGeometries){m();continue}if(Ha.includes(x)&&g?.disableTextures){m();continue}if(Jr.includes(x)&&g?.disableSounds){m();continue}if(Bi.includes(x)&&g?.disableTextures){m();continue}if(x==="ktx")if(s){if(!_.endsWith(s)){m();continue}}else{m();continue}if(x==="ktx2"&&!Ge()){m();continue}if(o.length>300){try{await Promise.all(o)}catch{}o.splice(0,o.length)}let M=`${e}${_}`;ka.includes(x)&&o.push(new Promise(async G=>{if(await S.isFileMatchingVersion(M))return m(G);try{Bi.includes(x)?i?.disableImages||(await S.saveImage(M),++l):on.includes(x)?(await S.saveFile(M,!0),++l):tn.includes(x)&&(await S.saveFile(M,!1),++l)}catch{}m(G)}))}await Promise.all(o),S.close()}return await Promise.all(o),{loadedCount:l,processedFilesCount:p}}n(Ua,"preloadAssetsToDatabase");0&&(module.exports={AdvancedAssetContainer,AdvancedAssetContainerInstantiatedEntries,Cinematic,Database,NodeParticleSystemSet,VolumetricDebugMode,VolumetricDitherMode,VolumetricFogMode,VolumetricLightingRenderingPipeline,VolumetricShadowKind,VolumetricShadowMode,VolumetricStepDistribution,VolumetricTransmittanceMode,_applyScriptsForObject,_getKtx2TextureName,_preloadScriptsAssets,_registerScriptInstance,_removeRegisteredScriptInstance,addExcludedCompressedTexture,animationFromSprite,animationGroupFromScene,applyMeshesLODQuality,applyRenderingConfigurationForCamera,applyScriptOnObject,applyShadowsQuality,applyTexturesQuality,componentFromScene,computeVolumetricBudget,computeVolumetricShapeKey,configureEngineToUseCompressedTextures,configureMeshDistanceOrScreenCoverage,configureShadowMapRefreshRate,configureShadowMapRenderListPredicate,copyAndParseRagdollConfiguration,createAndOpenDatabase,createDefaultRenderingPipeline,createMotionBlurPostProcess,createSSAO2RenderingPipeline,createSSRRenderingPipeline,createTAARenderingPipeline,createVLSPostProcess,createVolumetricLightingRenderingPipeline,defaultPipelineCameraConfigurations,disposeDefaultRenderingPipeline,disposeMotionBlurPostProcess,disposeSSAO2RenderingPipeline,disposeSSRRenderingPipeline,disposeTAARenderingPipeline,disposeVLSPostProcess,disposeVolumetricLightingRenderingPipeline,ensureVolumetricLightConfiguration,forceCompileAllSceneMaterials,generateCinematicAnimationGroup,getAllScriptsByClassForObject,getAllVolumetricCandidateLights,getAnimationTypeForObject,getDefaultRenderingPipeline,getDefaultVolumetricLightConfiguration,getDefaultVolumetricLightingConfiguration,getFromIndexDB,getMotionBlurPostProcess,getPowerOfTwoUntil,getSSAO2RenderingPipeline,getSSRRenderingPipeline,getScriptByClassForObject,getTAARenderingPipeline,getTextureUrl,getVLSPostProcess,getVolumetricLightConfiguration,getVolumetricLightRange,getVolumetricLightSteps,getVolumetricLightWorldDirection,getVolumetricLightWorldPosition,getVolumetricLightingRenderingPipeline,guiFromAsset,isAbstractMesh,isAnyParticleSystem,isArcRotateCamera,isBone,isCamera,isCascadedShadowGenerator,isCinematicGroup,isCinematicKey,isCinematicKeyCut,isCinematicKeyEvent,isCinematicSound,isClusteredLightContainer,isDecalMesh,isDirectionalLight,isFreeCamera,isGPUParticleSystem,isGaussianSplattingMesh,isGroundMesh,isHemisphericLight,isInstancedMesh,isLight,isMesh,isNode,isNodeFromStaticGroup,isParticleSystem,isPointLight,isScene,isShadowGenerator,isSoundNode,isSpotLight,isSprite,isTexture,isTransformNode,isUsingKtx2CompressedTextures,isVolumetricLightEnabled,isVolumetricLightSupported,isVolumetricLightingSupported,loadMaterialFromFile,loadScene,markVolumetricLightsDirty,maxVolumetricArrayLights,maxVolumetricDirectionalLights,maxVolumetricShadowSlots,motionBlurPostProcessCameraConfigurations,nodeFromDescendants,nodeFromScene,normalizeAtlasJson,normalizeVolumetricLightConfiguration,normalizeVolumetricLightingConfiguration,onKeyboardEvent,onPointerEvent,openIndexDB,parseCinematic,parseCinematicKeyValue,parseDefaultRenderingPipeline,parseKeyFrameAnimations,parseMotionBlurPostProcess,parseRagdollConfiguration,parseSSAO2RenderingPipeline,parseSSRRenderingPipeline,parseTAARenderingPipeline,parseVLSPostProcess,parseVolumetricLightingRenderingPipeline,particleSystemFromScene,playSpriteAnimationFromName,preloadAssetsToDatabase,putInIndexDB,registerScriptAssetParser,resolveVolumetricShadowSlot,saveRenderingConfigurationForCamera,sceneAsset,scriptAssetsCache,scriptAssetsParsers,scriptsDictionary,selectVolumetricLights,serializeDefaultRenderingPipeline,serializeMotionBlurPostProcess,serializeSSAO2RenderingPipeline,serializeSSRRenderingPipeline,serializeTAARenderingPipeline,serializeVLSPostProcess,serializeVolumetricLightingRenderingPipeline,setDefaultRenderingPipelineRef,setMotionBlurPostProcessRef,setSSAO2RenderingPipelineRef,setSSRRenderingPipelineRef,setStaticDecalsEnabled,setTAARenderingPipelineRef,setUseKtx2CompressedTextures,setVLSPostProcessRef,setVolumetricLightingRenderingPipelineRef,setupOfflineProvider,soundFromScene,spriteFromSpriteManager,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,taaRenderingPipelineCameraConfigurations,visibleAsAsset,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsKeyMap,visibleAsNumber,visibleAsString,visibleAsTexture,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations,volumetricLightMetadataKey,volumetricLightingRenderingPipelineCameraConfigurations});
|
|
2342
|
+
`),i}_createPostProcess(e){let i=new Uo.PostProcess(e.name,e.shaderName,e.uniforms,e.samplers,e.ratio,null,e.samplingMode,this._scene.getEngine(),!1,e.defines,e.textureType,void 0,void 0,!1,e.textureFormat,this._shaderLanguage);return i.autoClear=!1,i.alphaMode=Y.Constants.ALPHA_DISABLE,i}_buildRenderEffects(){let e=this._scene.getEngine(),i=this._configuration,o=this._getEnvironment();this._linearDepthDefines=this._buildLinearDepthDefines(o),this._scatteringDefines=this._buildScatteringDefines(this._selection,o),this._blurDefines=this._buildBlurDefines(o),this._composeDefines=this._buildComposeDefines(o),this._linearDepthPostProcess=this._createPostProcess({name:"VolumetricLightingLinearDepth",shaderName:nt,uniforms:["volCameraMinMaxZ","volDepthUnpack"],samplers:["depthSampler"],ratio:1,samplingMode:Fe.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._linearDepthDefines}),this._linearDepthPostProcess.onApplyObservable.add(r=>this._bindLinearDepth(r)),this._applyPrePassConfiguration(),this._scatteringPostProcess=this._createPostProcess({name:"VolumetricLightingScattering",shaderName:at,uniforms:pa,samplers:zo,ratio:1,samplingMode:Fe.Texture.NEAREST_SAMPLINGMODE,textureType:this._linearDepthPacked?Y.Constants.TEXTURETYPE_UNSIGNED_BYTE:Y.Constants.TEXTURETYPE_FLOAT,textureFormat:this._linearDepthPacked?Y.Constants.TEXTUREFORMAT_RGBA:Y.Constants.TEXTUREFORMAT_R,defines:this._scatteringDefines}),this._scatteringPostProcess.onApplyObservable.add(r=>this._bindScattering(r)),this._blurPostProcesses=[];for(let r=0;r<i.blurPasses;++r){let n=this._createPostProcess({name:`VolumetricLightingBlur${r}`,shaderName:st,uniforms:["volCameraMinMaxZ","volDepthRatio","volBlurDirection","volBlurParams"],samplers:["volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Fe.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._blurDefines});n.onApplyObservable.add(l=>this._bindBlur(l,r)),this._blurPostProcesses.push(n)}this._composePostProcess=this._createPostProcess({name:"VolumetricLightingCompose",shaderName:lt,uniforms:["volCameraMinMaxZ","volDepthRatio","volComposeParams"],samplers:["volSceneSampler","volLinearDepthSampler"],ratio:i.resolutionScale,samplingMode:Fe.Texture.BILINEAR_SAMPLINGMODE,textureType:this._textureType,defines:this._composeDefines}),this._composePostProcess.onApplyObservable.add(r=>this._bindCompose(r)),this.addEffect(new Ne.PostProcessRenderEffect(e,t.SceneColorEffectName,()=>this._linearDepthPostProcess,!0)),this.addEffect(new Ne.PostProcessRenderEffect(e,t.ScatteringEffectName,()=>this._scatteringPostProcess,!0)),this._blurPostProcesses.length&&this.addEffect(new Ne.PostProcessRenderEffect(e,t.BlurEffectName,()=>this._blurPostProcesses,!0)),this.addEffect(new Ne.PostProcessRenderEffect(e,t.ComposeEffectName,()=>this._composePostProcess,!0)),this._applyMsaaSamples()}_disposePostProcesses(e){[this._linearDepthPostProcess,this._scatteringPostProcess,...this._blurPostProcesses,this._composePostProcess].forEach(o=>{o&&(e.forEach(r=>o.dispose(r)),o.dispose())}),this._linearDepthPostProcess=null,this._scatteringPostProcess=null,this._blurPostProcesses=[],this._composePostProcess=null}_rebuildRenderEffects(){if(this._disposed)return;let e=this._scene.postProcessRenderPipelineManager,i=this._cameras.slice();try{e.detachCamerasFromRenderPipeline(this.name,i),this._disposePostProcesses(i),Object.keys(this._renderEffects).forEach(o=>{delete this._renderEffects[o]}),this._buildRenderEffects()}catch(o){console.error("Failed to rebuild the volumetric lighting rendering pipeline.",o)}finally{try{e.attachCamerasToRenderPipeline(this.name,i)}catch(o){console.error("Failed to re-attach the cameras to the volumetric lighting rendering pipeline.",o)}}this._lightsDirty=!0}_updateSelection(){if(this._disposed||!this._scatteringPostProcess||(++this._frameCount,!(this._lightsDirty||!this._selection||this._frameCount%this._configuration.selectionRefreshRate===0)))return;this._lightsDirty=!1;let i=this._getEnvironment(),o=di(this._scene,this._camera,this._configuration,this._budget,this._selection);this._selection=o;let r=this._buildScatteringDefines(o,i);r!==this._scatteringDefines&&(this._scatteringDefines=r,this._scatteringPostProcess.updateEffect(r));let n=this._buildLinearDepthDefines(i);n!==this._linearDepthDefines&&(this._linearDepthDefines=n,this._linearDepthPostProcess?.updateEffect(n));let l=this._buildBlurDefines(i);l!==this._blurDefines&&(this._blurDefines=l,this._blurPostProcesses.forEach(s=>s.updateEffect(l)));let p=this._buildComposeDefines(i);p!==this._composeDefines&&(this._composeDefines=p,this._composePostProcess?.updateEffect(p))}_writeLight(e,i,o,r,n,l){let{light:p,config:s}=e,c=i*4;ie(p)?(Re(p,this._temporaryVector),o[c]=-this._temporaryVector.x,o[c+1]=-this._temporaryVector.y,o[c+2]=-this._temporaryVector.z,o[c+3]=1):(et(p,this._temporaryVector).subtractInPlace(this._camera.globalPosition),o[c]=this._temporaryVector.x,o[c+1]=this._temporaryVector.y,o[c+2]=this._temporaryVector.z,o[c+3]=ne(p)?2:0),s.useCustomColor?this._temporaryColor.set(s.color[0],s.color[1],s.color[2]):this._temporaryColor.copyFrom(p.diffuse);let m=p.getScaledIntensity()*s.volumeIntensity*1e-5;r[c]=this._temporaryColor.r*m,r[c+1]=this._temporaryColor.g*m,r[c+2]=this._temporaryColor.b*m,r[c+3]=s.anisotropy,ne(p)?(Re(p,this._temporaryVector),n[c]=this._temporaryVector.x,n[c+1]=this._temporaryVector.y,n[c+2]=this._temporaryVector.z,n[c+3]=Math.cos(p.angle*.5),l[c+1]=p.exponent):(n[c]=0,n[c+1]=0,n[c+2]=1,n[c+3]=-1,l[c+1]=1),l[c]=tt(p,s,this._configuration),l[c+2]=s.castVolumetricShadows?1:0,l[c+3]=s.shadowDarkness}_bindLinearDepth(e){let i=null;switch(this._depthSource){case 2:{let o=ye(this._scene);i=o?vi(o):null;break}case 1:{let o=Ve(this._scene);i=o?Si(o):null;break}default:i=this._depthRenderer?.getDepthMap()??null;break}i&&(e.setTexture("depthSampler",i),this._bindDepthUniforms(e))}_bindScattering(e){let i=this._scene,o=this._camera,r=this._configuration,n=this._selection;if(!n)return;this._inverseViewProjection.copyFrom(i.getTransformMatrix()),this._inverseViewProjection.invert(),e.setMatrix("volInverseViewProjection",this._inverseViewProjection),e.setVector3("volCameraPosition",o.globalPosition),o.getDirectionToRef(i.useRightHandedSystem?la:sa,this._temporaryVector),e.setVector3("volCameraForward",this._temporaryVector.normalize()),e.setFloat2("volCameraMinMaxZ",o.minZ,o.maxZ),e.setFloat("volFrameIndex",i.getRenderId()%64),this._bindDepthRatio(e),e.setFloat4("volFogInfos",r.fogMode,r.fogStart,r.fogEnd,r.fogDensity),this._temporaryColor.set(r.fogColor[0],r.fogColor[1],r.fogColor[2]),e.setColor3("volFogColor",this._temporaryColor),e.setFloat("volLinearFogEps",Math.max((r.fogEnd-r.fogStart)*.02,1e-4)),e.setFloat4("volMedium",r.albedo,r.heightFogBaseHeight,r.heightFogFalloff,0),r.screenSpaceShadows&&(e.setMatrix("volViewProjection",i.getTransformMatrix()),e.setFloat4("volScreenShadowParams",r.screenSpaceShadowMaxDistance,r.screenSpaceShadowBias,r.screenSpaceShadowThickness,0)),this._temporaryColor.set(r.ambientColor[0],r.ambientColor[1],r.ambientColor[2]).scaleInPlace(r.ambientIntensity),e.setColor3("volAmbient",this._temporaryColor);let l=n.unshadowed.length,p=l-n.directionalCount;e.setFloat4("volParams",r.maxDistance,r.ditherStrength,r.lightExtinctionClamp,p);for(let s=0;s<l;++s)this._writeLight(n.unshadowed[s],s,this._lightData,this._lightDiffuse,this._lightDirection,this._lightFalloff);if(l){let s=l*4;e.setFloatArray4("volLightData",this._lightData.subarray(0,s)),e.setFloatArray4("volLightDiffuse",this._lightDiffuse.subarray(0,s)),e.setFloatArray4("volLightDirection",this._lightDirection.subarray(0,s)),e.setFloatArray4("volLightFalloff",this._lightFalloff.subarray(0,s))}if(n.shadowed.forEach((s,c)=>{this._writeLight(s.candidate,c,this._shadowLightData,this._shadowLightDiffuse,this._shadowLightDirection,this._shadowLightFalloff);let{generator:m,kind:h,mode:d,mapSize:f}=s.shadow,S=s.candidate.light,g=c*4;this._shadowLightFalloff[g+2]=m.frustumEdgeFalloff;let b=S.getDepthMinZ?.(i.activeCamera)??0,L=S.getDepthMaxZ?.(i.activeCamera)??1;this._shadowInfo[g]=m.getDarkness(),this._shadowInfo[g+1]=h===1?1/f:d===0?0:m.depthScale,this._shadowInfo[g+2]=b,this._shadowInfo[g+3]=b+L,m.getTransformMatrix().copyToArray(this._shadowMatrices,c*16);let _=m.getShadowMapForRendering();h===1?e.setDepthStencilTexture(`volShadowSampler${c}`,_):e.setTexture(`volShadowSampler${c}`,_)}),n.shadowed.length){let s=n.shadowed.length*4;e.setFloatArray4("volShadowLightData",this._shadowLightData.subarray(0,s)),e.setFloatArray4("volShadowLightDiffuse",this._shadowLightDiffuse.subarray(0,s)),e.setFloatArray4("volShadowLightDirection",this._shadowLightDirection.subarray(0,s)),e.setFloatArray4("volShadowLightFalloff",this._shadowLightFalloff.subarray(0,s)),e.setFloatArray4("volShadowInfo",this._shadowInfo.subarray(0,s)),e.setMatrices("volShadowMatrix",this._shadowMatrices.subarray(0,n.shadowed.length*16))}if(n.csm){let{candidate:s,generator:c,cascades:m,kind:h}=n.csm,d=s.light;this._writeLight(s,0,this._csmLightData,this._csmLightDiffuse,this._csmLightDirection,this._csmLightFalloff),e.setFloat4("volCsmLightData",this._csmLightData[0],this._csmLightData[1],this._csmLightData[2],this._csmLightData[3]),e.setFloat4("volCsmLightDiffuse",this._csmLightDiffuse[0],this._csmLightDiffuse[1],this._csmLightDiffuse[2],this._csmLightDiffuse[3]),e.setFloat4("volCsmLightDirection",this._csmLightDirection[0],this._csmLightDirection[1],this._csmLightDirection[2],this._csmLightDirection[3]),e.setFloat4("volCsmLightFalloff",this._csmLightFalloff[0],this._csmLightFalloff[1],c.frustumEdgeFalloff,s.config.shadowDarkness);let f=d.getDepthMinZ?.(i.activeCamera)??1,S=d.getDepthMaxZ?.(i.activeCamera)??1,g=c.getShadowMap()?.getSize().width??1024;e.setFloat4("volCsmInfo",c.getDarkness(),1/g,f,f+S);for(let L=0;L<m;++L)c.getCascadeTransformMatrix(L)?.copyToArray(this._csmMatrices,L*16);e.setMatrices("volCsmMatrices",this._csmMatrices.subarray(0,m*16));let b=c.getShadowMapForRendering();h===1?e.setDepthStencilTexture("volCsmSampler",b):e.setTexture("volCsmSampler",b)}}_bindDepthRatio(e){let i=this._scatteringPostProcess,o=this._blurPostProcesses[0]??this._composePostProcess,r=i&&i.width>0?i.width:1,n=i&&i.height>0?i.height:1,l=o&&o.width>0?o.width:r,p=o&&o.height>0?o.height:n;e.setFloat2("volDepthRatio",r/l,n/p)}_bindBlur(e,i){this._scatteringPostProcess&&(e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e),e.setFloat2("volBlurDirection",i%2===0?1:0,i%2===0?0:1),e.setFloat2("volBlurParams",Math.max(this._configuration.blurRadius*.5,.5),this._configuration.blurDepthThreshold))}_bindCompose(e){if(!this._linearDepthPostProcess||!this._scatteringPostProcess)return;let i=this._configuration;e.setTextureFromPostProcess("volSceneSampler",this._linearDepthPostProcess),e.setTextureFromPostProcess("volLinearDepthSampler",this._scatteringPostProcess),e.setFloat2("volCameraMinMaxZ",this._camera.minZ,this._camera.maxZ),this._bindDepthRatio(e);let o=this._ldrEncode?1/255:0;e.setFloat4("volComposeParams",i.intensity,i.extinctionAmount,i.upsampleDepthThreshold,o)}};var M=null,xe=new Map;function ma(){return M?.isDisposed&&(M=null),M}a(ma,"getVolumetricLightingRenderingPipeline");function ha(t){M=t}a(ha,"setVolumetricLightingRenderingPipelineRef");function da(t){let e=t?.getEngine();return e?q.IsSupported(e):!1}a(da,"isVolumetricLightingSupported");function Ci(){M&&(M.dispose(),M=null)}a(Ci,"disposeVolumetricLightingRenderingPipeline");function Xo(t,e,i){return M=new q("VolumetricLightingRenderingPipeline",t,e),M.msaaSamples=i?.msaaSamples??1,M}a(Xo,"createVolumetricLightingRenderingPipeline");function Li(){return M?M.serializeConfiguration():null}a(Li,"serializeVolumetricLightingRenderingPipeline");function Di(t,e,i,o){let r=M??Xo(t,e,o);r.msaaSamples=o?.msaaSamples??1;let n={...i};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(Se(n)),r}a(Di,"parseVolumetricLightingRenderingPipeline");function fa(){M?.markLightsDirty()}a(fa,"markVolumetricLightsDirty");var ct=require("babylonjs");function ua(t){ue.set(t,Xt()),he.set(t,Ft()),de.set(t,Bt()),ge.set(t,Zt()),xe.set(t,Li()),ve.set(t,Jt()),fe.set(t,kt())}a(ua,"saveRenderingConfigurationForCamera");function _i(t,e,i){Wt(),Vt(t.getScene()),Gt(),jt(),Ci(),Qt(),Ht();let o=ue.get(t);o&&!i?.ssao2Disabled&&$t(t.getScene(),t,o,i);let r=xe.get(t);r&&!i?.volumetricLightingDisabled&&Di(t.getScene(),t,r,i);let n=he.get(t);n&&!i?.vlsDisabled&&Nt(t.getScene(),n,i);let l=de.get(t);l&&!i?.ssrDisabled&&zt(t.getScene(),t,l,i);let p=ge.get(t);p&&!i?.motionBlurDisabled&&Yt(t.getScene(),t,p,i);let s=ve.get(t);s&&!i?.defaultPipelineDisabled&&ei(t.getScene(),t,s,e,i);let c=fe.get(t);c&&!i?.taaDisabled&&Ut(t.getScene(),t,c,i)}a(_i,"applyRenderingConfigurationForCamera");function ga(t){let e=t.getCaps();return e.textureHalfFloatRender||e.textureFloatRender}a(ga,"canUseHdr");function $(t){let e=t.getCaps();return e.textureHalfFloatRender?ct.Constants.TEXTURETYPE_HALF_FLOAT:e.textureFloatRender?ct.Constants.TEXTURETYPE_FLOAT:ct.Constants.TEXTURETYPE_UNSIGNED_BYTE}a($,"getHdrTextureType");var Ge=require("babylonjs"),$o=require("babylonjs");function Ko(t){let e=t.metadata?.physicsAggregate;if(!e)return;let i;F(t)?i=t:Te(t)&&(i=t.sourceMesh);let o=new $o.PhysicsAggregate(t,e.shape.type,{mesh:i,mass:e.massProperties.mass});o.body.setMassProperties({mass:e.massProperties.mass,inertia:e.massProperties.inertia?Ge.Vector3.FromArray(e.massProperties.inertia):void 0,centerOfMass:e.massProperties.centerOfMass?Ge.Vector3.FromArray(e.massProperties.centerOfMass):void 0,inertiaOrientation:e.massProperties.inertiaOrientation?Ge.Quaternion.FromArray(e.massProperties.inertiaOrientation):void 0}),o.shape.density=e.shape.density,o.body.setMotionType(e.body.motionType),o.shape.material=e.material,t.physicsAggregate=o,t.metadata.physicsAggregate=void 0}a(Ko,"configurePhysicsAggregate");function jo(t,e){(Array.isArray(e)?e:[]).forEach(o=>{let r=t.getCameraById(o.cameraId);r&&(o.ssao2RenderingPipeline&&ue.set(r,o.ssao2RenderingPipeline),o.vlsPostProcess&&he.set(r,o.vlsPostProcess),o.ssrRenderingPipeline&&de.set(r,o.ssrRenderingPipeline),o.motionBlurPostProcess&&ge.set(r,o.motionBlurPostProcess),o.volumetricLightingRenderingPipeline&&xe.set(r,o.volumetricLightingRenderingPipeline),o.defaultRenderingPipeline&&ve.set(r,o.defaultRenderingPipeline),o.taaRenderingPipeline&&fe.set(r,o.taaRenderingPipeline))})}a(jo,"applyRenderingConfigurations");var Zo=require("babylonjs");function Ce(t,e,i){return new Promise((o,r)=>{let n=new Zo.WebRequest;n.open("GET",t),n.responseType=e,n.send(),n.addEventListener("progress",l=>{i?.({total:l.total,loaded:l.loaded})}),n.addEventListener("load",()=>{o(e==="text"?n.responseText:n.response)}),n.addEventListener("error",l=>r(l))})}a(Ce,"loadFile");async function z(t,e){let i=await Ce(t,"text",e);return JSON.parse(i)}a(z,"loadJsonFile");function Pi(t,e){let i=e.getNodeByName(t);if(i)return i;let o=e.lights.filter(r=>pe(r));for(let r of o){let n=r.lights.find(l=>l.name===t);if(n)return n}return null}a(Pi,"getNodeByName");function Le(t,e){let i=e.getNodeById(t);if(i)return i;let o=e.lights.filter(r=>pe(r));for(let r of o){let n=r.lights.find(l=>l.id===t);if(n)return n}return null}a(Le,"getNodeById");var le=require("babylonjs"),Yo=require("babylonjs");function wi(t){let e=Yo.Vector3.FromArray(t);return e.equals(le.Axis.X)?le.Axis.X:e.equals(le.Axis.Y)?le.Axis.Y:e.equals(le.Axis.Z)?le.Axis.Z:e}a(wi,"parseAxis");var qo=require("babylonjs"),Q=require("babylonjs");function Qo(t){return t.runtimeConfiguration.forEach(e=>{e.rotationAxis&&(e.rotationAxis=wi(e.rotationAxis)),e.boneOffsetAxis&&(e.boneOffsetAxis=wi(e.boneOffsetAxis))}),t}a(Qo,"parseRagdollConfiguration");function Oi(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 Qo(e)}a(Oi,"copyAndParseRagdollConfiguration");function va(t,e){let i=t.getConstraints(),r=t._skeleton?.getChildren()[0],n=[];if(e.forEach(p=>{(p.bone!==void 0?[p.bone]:p.bones).forEach(c=>{c!==r?.name&&n.push(p)})}),n.length!==i.length)return qo.Logger.Warn("Failed to apply the ragdoll joint limits: the constraints of the ragdoll don't match its configuration."),0;let l=0;return i.forEach((p,s)=>{let c=n[s];if((c.joint??Q.PhysicsConstraintType.HINGE)!==Q.PhysicsConstraintType.HINGE||c.min===void 0||c.max===void 0)return;let h=Math.min(c.min,c.max),d=Math.max(c.min,c.max),f=p._physicsPlugin;f&&(f.setAxisMode(p,Q.PhysicsConstraintAxis.ANGULAR_X,Q.PhysicsConstraintAxisLimitMode.LIMITED),f.setAxisMinLimit(p,Q.PhysicsConstraintAxis.ANGULAR_X,h*Math.PI/180),f.setAxisMaxLimit(p,Q.PhysicsConstraintAxis.ANGULAR_X,d*Math.PI/180),++l)}),l}a(va,"applyRagdollJointLimits");function Sa(t){return new Promise(e=>{setTimeout(()=>e(),t)})}a(Sa,"waitMs");async function Ei(t){for(;!t();)await Sa(150)}a(Ei,"waitUntil");function Ti(t){return t&&JSON.parse(JSON.stringify(t))}a(Ti,"cloneJSObject");var Ii=require("babylonjs"),nr=require("babylonjs"),pt=require("babylonjs"),ar=require("babylonjs"),sr=require("babylonjs"),lr=require("babylonjs"),oe=require("babylonjs"),Jo=!1,er=null,De=[],Ai=new Map;function ya(t,e){let i=(0,oe._GetAudioEngine)(null);return new lr._WebAudioStaticSound(t,i,e)}a(ya,"createSoundInstance");function tr(t){if(er?.remove(),!De.length)return;let e=Ii.Vector3.Zero();er=t.onBeforeRenderObservable.add(()=>{let i=(0,oe._GetAudioEngine)(null).listener.attachedNode;i&&(i.getWorldMatrix().getTranslationToRef(e),De.forEach(o=>{o.isEnabled(!1)&&o.autoUpdateSpatial&&o.sound?._isSpatial&&o.isPlaying()&&t.activeCamera&&Ii.Vector3.Distance(e,o.getAbsolutePosition())<=o.sound.spatial.maxDistance&&o.sound.spatial.update()}))})}a(tr,"registerUpdateSoundsObserver");function ir(t,e){e.onDisposeObservable.addOnce(()=>{let i=De.indexOf(t);i!==-1&&De.splice(i,1)})}a(ir,"registerSoundInstanceCleanup");function or(t){t.sound&&ir(t,t.sound),t.onDisposeObservable.addOnce(()=>{t.sound?.dispose()})}a(or,"registerSoundNodeEvents");function ba(t,e){return new Promise(async(i,o)=>{if(!t.offlineProvider||!nr.Database.IDBStorageEnabled)return(0,oe.CreateSoundBufferAsync)(e).then(r=>i(r)).catch(r=>o(r));t.offlineProvider.loadFile(e,r=>{(0,oe.CreateSoundBufferAsync)(r).then(n=>i(n)).catch(n=>o(n))},void 0,()=>{o(null)},!0)})}a(ba,"loadSoundBuffer");function Mi(t,e){if(!t.soundRelativePath||!t.sound)return;e.onSoundLoadedObservable=new ar.Observable;let i=ya(t.soundRelativePath,{spatialAutoUpdate:!1});i._initAsync(t.sound.buffer,{spatialAutoUpdate:!0}).then(()=>{i.volume=t.volume,i._isSpatial=t.sound._isSpatial,i._isSpatial&&(i.spatial.attach(e),i.spatial.maxDistance=t.sound.spatial.maxDistance,i.spatial.panningModel=t.sound.spatial.panningModel,i.spatial.distanceModel=t.sound.spatial.distanceModel),e.sound=i,e.soundRelativePath=t.soundRelativePath,e.autoUpdateSpatial=t.autoUpdateSpatial,De.push(e),ir(e,i),tr(e.getScene()),e.onSoundLoadedObservable.notifyObservers(e)}),or(e),rr(e,i)}a(Mi,"configureSourceNodeFrom");function rr(t,e){Object.defineProperty(t,"volume",{get:a(()=>e.volume,"get"),set:a(i=>{e.volume=i},"set")}),Object.defineProperty(t,"playbackRate",{get:a(()=>e.playbackRate,"get"),set:a(i=>{e.playbackRate=i},"set")}),t.isPaused=()=>e.state===pt.SoundState.Paused,t.isPlaying=()=>e.state===pt.SoundState.Started,t.isStopped=()=>e.state===pt.SoundState.Stopped,t.pause=()=>e.pause(),t.resume=()=>e.resume(),t.stop=i=>e.stop(i),t.play=i=>e.play(i),t.setVolume=(i,o)=>e.setVolume(i,o),t.getClassName=()=>"SoundNode",t.setSoundSpatial=i=>new Promise(o=>{e._isSpatial=i,setTimeout(()=>{i&&e.spatial.attach(t),o()})}),t.cloneAsync=async(i,o,r)=>new Promise(n=>{let l=t.clone(i,o,r);Mi(t,l),l.onSoundLoadedObservable.addOnce(()=>{setTimeout(()=>n(l))})})}a(rr,"configureSoundNodePrototype");function cr(){Jo||(Jo=!0,(0,sr.AddParser)("SoundNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSoundNode)return;let n=i.transformNodes?.find(l=>l.id===r.id);if(n&&r.soundRelativePath){let l=`${o}${r.soundRelativePath}`;e.addPendingData(l),Ai.has(l)||Ai.set(l,ba(e,l)),Ai.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,De.push(n),or(n),rr(n,c),tr(e)})})}})}))}a(cr,"registerAudioParser");var pr=require("babylonjs");function _e(t){let e=new Set;[...t.transformNodes,...t.meshes].forEach(o=>{if(o.metadata?.isStaticGroup){let r=o.getDescendants(!1);r.push(o),r.forEach(n=>{if((re(n)||te(n)&&!n.isWorldMatrixFrozen)&&n.billboardMode===pr.AbstractMesh.BILLBOARDMODE_NONE&&n.freezeWorldMatrix(),re(n)){let l=n.material;l&&!l.isFrozen&&!e.has(l)&&(e.add(l),l.onBindObservable.addOnce(()=>{l.freeze()}))}})}})}a(_e,"configureTransformNodes");var Be=class{constructor(e,i){this.entries=e;this.namingId=i}entries;namingId;static{a(this,"AdvancedAssetContainerInstantiatedEntries")}get rootNodes(){return this.entries.rootNodes}get skeletons(){return this.entries.skeletons}get animationGroups(){return this.entries.animationGroups}dispose(){this.entries.dispose()}getRootNodeByName(e){let i=`${e}-${this.namingId}`;return this.entries.rootNodes.find(o=>o.name===i)??null}getNodeByName(e){let i=`${e}-${this.namingId}`;for(let o of this.entries.rootNodes){let r=this._recursivelyGetNodeByName(i,o);if(r)return r}return null}_recursivelyGetNodeByName(e,i){if(i.name===e)return i;for(let o of i.getDescendants(!0)){let r=this._recursivelyGetNodeByName(e,o);if(r)return r}return null}getScriptByClassByObjectName(e,i){let o=this.getNodeByName(e);if(o){let r=Pe(o,i);if(r?.length===1)return r[0]}return null}};var Ri=require("babylonjs"),ze=class{static{a(this,"AdvancedAssetContainer")}container;_rootUrl;_scriptsMap;_originalDescendants=[];_nodesMap=new Map;_animationGroupsMap=new Map;constructor(e,i,o){this.container=e,this._rootUrl=i,this._scriptsMap=o,e.populateRootNodes(),e.rootNodes.forEach(r=>{this._originalDescendants.push(r,...r.getDescendants(!1))}),e.animationGroups.forEach(r=>{this._animationGroupsMap.set(r.name,r)}),this._originalDescendants.forEach(r=>{this._nodesMap.set(r,{node:r,metadata:Ti(r.metadata)})})}removeDefault(){this.container.getNodes().forEach(e=>{H.get(e)?.forEach(o=>{mt(e,o)})}),this.container.removeAllFromScene()}getRootNodeByName(e){return this.container.rootNodes.find(i=>i.name===e)??null}getScriptByClassByObjectName(e,i){let o=this.container.getNodes();for(let r of o)if(r.name===e){let n=Pe(r,i);if(n?.length===1)return n[0]}return null}instantiate(e){let i=Ri.Tools.RandomId(),o=a(s=>s,"nameFunction"),r=this.container.instantiateModelsToScene(o,!1,{...e,predicate:a(s=>(s.name=`${s.name}@editor-tools@${i}_${s.id}`,e?.predicate?.(s)??!0),"predicate")}),n=new Be(r,i);[...this.container.transformNodes,...this.container.meshes,...this.container.lights,...this.container.cameras,...this.container.animationGroups,...this.container.skeletons].forEach(s=>{let c=s.name.split("@editor-tools@");s.name=c[0]}),r.animationGroups.forEach(s=>{let c=s.name.split("@editor-tools@");s.name=`${c[0]}-${i}`});let p=[];return r.rootNodes.forEach(s=>{p.push(s,...s.getDescendants(!1))}),p.forEach(s=>{let c=s.name.split("@editor-tools@"),m=c[1].split("_").pop();s.name=`${c[0]}-${i}`;let h=this._originalDescendants.find(d=>d.id===m);ae(h)&&te(s)&&Mi(h,s),s.id=Ri.Tools.RandomId(),s.metadata=Ti(this._nodesMap.get(h).metadata),s.metadata??={},s.metadata.originalId=m,p.forEach(d=>{d.metadata.scripts?.forEach(f=>{Object.keys(f.values||{}).forEach(g=>{let b=f.values[g];if(b.type==="entity"){b.value===m&&(b.value=s.id),b.value===h.name&&(b.value=s.name);let L=this._animationGroupsMap.get(b.value);L&&(b.value=`${L.name}-${i}`)}})})})}),p.forEach(s=>{B(this.container.scene,s,this._scriptsMap,this._rootUrl)}),_e(this.container.scene),n}};var mr=require("babylonjs"),hr=require("babylonjs");async function dr(t,e,i){let o=i.iblIntensity,r=i.environmentIntensity,l=t.split("/").pop().replace(".scene",".babylon"),p=await(0,hr.LoadAssetContainerAsync)(l,i,{rootUrl:e,pluginExtension:".babylon"});return mr.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(s=>F(s)&&s._checkDelayState()),p.addAllToScene(),i.iblIntensity=o,i.environmentIntensity=r,_e(i),p}a(dr,"preloadSceneScriptAsset");async function fr(t,e){return z(`${e}${t}`)}a(fr,"preloadCommonScriptAsset");var I=new Map,He=new Map;function xa(t,e){He.has(t)&&console.warn(`A parser for the extension '${t}' was already registered. It will be overwritten.`),He.set(t,e)}a(xa,"registerScriptAssetParser");async function Vi(t,e,i){[e,...e.transformNodes,...e.meshes,...e.lights,...e.cameras].filter(p=>p.metadata?.scripts?.length).map(p=>p.metadata.scripts).flat().forEach(p=>{if(i[p.key]?.default?._SceneAssets?.forEach(c=>{I.get(c.sceneName)||I.set(c.sceneName,null)}),p.values)for(let c in p.values){if(!p.values.hasOwnProperty(c))continue;let m=p.values[c];m.type==="asset"&&m.value&&!I.get(m.value)&&I.set(m.value,null)}});let n=0;for(let p of I.values())p===null&&++n;if(n===0)return n;let l=[];return I.forEach((p,s)=>{I.get(s)||l.push(new Promise(async c=>{try{let m=s.split(".").pop();switch(m){case"scene":let h=await dr(s,t,e);e.onDisposeObservable.addOnce(()=>{h.dispose(),I.delete(s)}),I.set(s,new ze(h,t,i));break;default:if(He.has(m)){let d=He.get(m);I.set(s,await d({key:s,rootUrl:t,scene:e}));break}else I.set(s,await fr(s,t));break}}catch(m){console.error(m)}c()}))}),await Promise.all(l),n}a(Vi,"_preloadScriptsAssets");var ur=require("babylonjs"),ht=require("babylonjs"),gr=require("babylonjs"),dt=require("babylonjs"),vr=require("babylonjs"),Sr=require("babylonjs-gui");function Fi(t,e,i,o,r){let n=o.constructor;if(!n)return;n._NodesFromScene?.forEach(s=>{o[s.propertyKey.toString()]=Pi(s.nodeName,t)}),n._ComponentsFromScene?.length&&t.getEngine().onBeginFrameObservable.addOnce(()=>{n._ComponentsFromScene?.forEach(s=>{let c=[];if([t,...t.transformNodes,...t.meshes,...t.lights,...t.cameras].forEach(h=>{let d=Ni(h,s.componentConstructor);d&&c.push(d)}),c.length>1)throw new Error(`Multiple components of type ${n._ComponentsFromScene[0].componentConstructor.name} found in scene for property "${n._ComponentsFromScene[0].propertyKey.toString()}".`);o[s.propertyKey.toString()]=c[0]??null})}),n._NodesFromDescendants?.forEach(s=>{let c=e.getDescendants?.(s.directDescendantsOnly,m=>m.name===s.nodeName)[0];o[s.propertyKey.toString()]=c??null}),n._AnimationGroups?.forEach(s=>{o[s.propertyKey.toString()]=t.getAnimationGroupByName(s.animationGroupName)}),n._SoundsFromScene?.forEach(s=>{let c=Pi(s.soundName,t);c&&ae(c)&&(o[s.propertyKey.toString()]=c??null)}),(n._GuiFromAsset??[]).map(async s=>{let c=`${r}assets/${s.pathInAssets}`;try{let m=await z(c),h=Sr.AdvancedDynamicTexture.CreateFullscreenUI(m.name,!0,t);h.parseSerializedObject(m.content,!1),o[s.propertyKey.toString()]=h,s.onGuiCreated?.(o,h)}catch(m){throw console.error(`Failed to load GUI from asset: ${c}`),m}}),n._ParticleSystemsFromScene?.forEach(s=>{let c=t.particleSystems?.find(m=>m.name!==s.particleSystemName?!1:s.directDescendantsOnly?m.emitter===e:m);o[s.propertyKey.toString()]=c}),(n._VisibleInInspector??[]).forEach(s=>{let c=s.propertyKey.toString(),m=i.values;if(!m)throw new Error(`No values found for script with key "${i.key}".`);if(m.hasOwnProperty(c)&&m[c].hasOwnProperty("value")){let h=m[c].value;switch(s.configuration.type){case"number":case"boolean":case"keymap":case"string":o[c]=h;break;case"vector2":o[c]=dt.Vector2.FromArray(h);break;case"vector3":o[c]=dt.Vector3.FromArray(h);break;case"color3":o[c]=ht.Color3.FromArray(h);break;case"color4":o[c]=ht.Color4.FromArray(h);break;case"entity":switch(s.configuration.entityType){case"node":case"sound":o[c]=Le(h,t)??null;break;case"animationGroup":o[c]=t.getAnimationGroupByName(h)??null;break;case"particleSystem":o[c]=t.particleSystems?.find(f=>f.id===h)??null;break}break;case"texture":h&&(o[c]=gr.Texture.Parse(h,t,r));break;case"asset":if(h){let f=s.configuration.assetType,S=I.get(h);switch(f){case"json":case"gui":case"scene":case"navmesh":case"cinematic":o[c]=S;break;case"ragdoll":o[c]=Oi(S);break;case"nodeParticleSystemSet":let g=vr.NodeParticleSystemSet.Parse(S);o[c]=g;break;case"material":o[c]=ur.Material.Parse(S,t,r);break}}}}});let l=null,p=null;if(n._PointerEvents?.length){if(n._PointerEvents.find(m=>m.options.mode==="attachedMeshOnly")&&!re(e))throw new Error('@onPointerEvent with mode "attachedMeshOnly" can only be used on scripts attached to meshes (extends AbstractMesh).');if(n._PointerEvents.find(m=>m.options.mode!=="global")&&!me(e))throw new Error('@onPointerEvent with mode different from "global" can be used only on scripts attached to Node: Mesh, Light, Camera, TransformNode.');l=t.onPointerObservable.add(m=>{let h=null;n._PointerEvents.forEach(d=>{if(!d.eventTypes.includes(m.type))return;let f=d.propertyKey.toString();if(d.options.mode==="global")return o[f]?.(m);h=m.pickInfo,h||(h=t.pick(t.pointerX,t.pointerY,g=>g.isVisible&&g.isPickable&&g.isEnabled(!0)&&!g._masterMesh,!1));let S=h.pickedMesh;if(S&&(d.options.mode==="attachedMeshOnly"&&S===e||d.options.mode==="includeDescendants"&&me(e)&&[e,...e.getDescendants(!1)].find(L=>L===S)))return o[f]?.(m)})})}if(n._KeyboardEvents?.length&&(p=t.onKeyboardObservable.add(s=>{n._KeyboardEvents.forEach(c=>{c.eventTypes.includes(s.type)&&o[c.propertyKey.toString()]?.(s)})})),n._SpritesFromSpriteManager?.length){let s=e;if(!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 m=s.spriteManager?.sprites.find(h=>h.name===c.spriteName)||null;o[c.propertyKey.toString()]=m})}if(n._AnimationsFromSprite?.length){if(!Ot(e))return console.error("@animationFromSprite decorator can only be used in scripts attached on Sprite.");let s=e.metadata?.spriteAnimations;if(!s?.length)return console.error(`Sprite "${e.name}" has no sprite animations assigned.`);n._AnimationsFromSprite.forEach(c=>{let m=s.find(h=>h.name===c.animationName);m?o[c.propertyKey.toString()]=m??null:console.warn(`Sprite animation named "${c.animationName}" not found on sprite "${e.name}".`)})}return n._SceneAssets?.forEach(s=>{o[s.propertyKey.toString()]=I.get(s.sceneName)}),{observers:{pointerObserver:l,keyboardObserver:p}}}a(Fi,"applyDecorators");function B(t,e,i,o){e.metadata?.scripts&&(e.metadata.scripts?.forEach(r=>{if(!r.enabled)return;let n=i[r.key];if(!n)return;let l=n,p={};if(n.default){l=new n.default(e);let s=Fi(t,e,r,l,o);Object.assign(p,s?.observers??{})}l.onStart&&(p.onStartObserver=t.onBeforeRenderObservable.addOnce(()=>l.onStart(e))),l.onUpdate&&(p.onUpdateObserver=t.onBeforeRenderObservable.add(()=>l.onUpdate(e))),Gi(e,l,r.key,p)}),e.metadata.scripts=void 0)}a(B,"_applyScriptsForObject");function Ca(t,e,i){if(i??=t.getScene?.(),!i)throw new Error("Cannot apply script on object: no scene available.");let o=new e(t),r={};return Fi(i,t,{values:{}},o,""),o.onStart&&(r.onStartObserver=i.onBeforeRenderObservable.addOnce(()=>o.onStart())),o.onUpdate&&i.onBeforeRenderObservable.add(()=>o.onUpdate()),Gi(t,o,"runtime",r),o}a(Ca,"applyScriptOnObject");var H=new Map;function Gi(t,e,i,o){let r={key:i,observers:o,instance:e};H.has(t)?H.get(t).push(r):H.set(t,[r]),(me(t)||wt(t)||_t(t)||ae(t))&&t.onDisposeObservable.addOnce((()=>{H.get(t)?.slice()?.forEach(l=>{mt(t,l)}),H.delete(t)}))}a(Gi,"_registerScriptInstance");function mt(t,e){e.observers.onStartObserver?.remove(),e.observers.onUpdateObserver?.remove(),e.observers.pointerObserver?.remove(),e.observers.keyboardObserver?.remove();try{e.instance.onStop?.(t)}catch(r){console.error(`Failed to call onStop for script ${e.key} on object ${t}`,r)}let i=H.get(t),o=i?.indexOf(e)??-1;o!==-1&&i?.splice(o,1)}a(mt,"_removeRegisteredScriptInstance");function Pe(t,e){return H.get(t)?.filter(r=>r.instance.constructor===e)?.map(r=>r.instance)??null}a(Pe,"getAllScriptsByClassForObject");function Ni(t,e){return Pe(t,e)?.[0]??null}a(Ni,"getScriptByClassForObject");var br=require("babylonjs"),yr=!1;function xr(){yr||(yr=!0,(0,br.AddParser)("MeshEditorPlugin",(t,e,i,o)=>{t.meshes?.forEach(r=>{r.instances?.forEach(n=>{let l=i.meshes?.find(p=>p.id===n.id);l&&n.billboardMode!==void 0&&(l.billboardMode=n.billboardMode)})})}))}a(xr,"registerMeshParser");var Cr=!1;function La(t){Cr=t}a(La,"setUseKtx2CompressedTextures");function ke(){return Cr}a(ke,"isUsingKtx2CompressedTextures");function ft(t){return`${t.substring(0,t.lastIndexOf("."))}.ktx2`}a(ft,"_getKtx2TextureName");function Da(t){t.setCompressedTextureExclusions([".env",".hdr",".dds"]),t.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}a(Da,"configureEngineToUseCompressedTextures");function ut(t,e){t._excludedCompressedTextures&&!t._excludedCompressedTextures?.includes(e)&&t._excludedCompressedTextures?.push(e)}a(ut,"addExcludedCompressedTexture");function _a(t,e,i){e.loadingTexturesQuality!==t&&(e.loadingTexturesQuality=t,e.textures.forEach(o=>{if(!Ae(o)||!o.url)return;let r=gt(o,e);!r||o.url.includes(r)||o.updateURL(i+r)}))}a(_a,"applyTexturesQuality");function gt(t,e){if(e.loadingTexturesQuality==="high"||!t.metadata?.baseSize)return t.name;let i=t.metadata.baseSize.width,o=t.metadata.baseSize.height,r=i===N(i)||o===N(o),n="";switch(e.loadingTexturesQuality){case"medium":let d=i*.66>>0,f=o*.66>>0;r&&(d=N(d),f=N(f)),n=`_${d}_${f}`;break;case"low":case"very-low":let S=i*.33>>0,g=o*.33>>0;r&&(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(),h=`${s.replace(`.${c}`,"")}${n}.${c}`;return p.push(h),p.join("/")}a(gt,"getTextureUrl");var Bi=require("babylonjs"),Lr=!1;function Dr(){if(Lr)return;Lr=!0;let t=Bi.SerializationHelper._TextureParser;Bi.SerializationHelper._TextureParser=(e,i,o)=>{ke()&&(e.name&&(e.name=ft(e.name)),e.url&&(e.url=ft(e.url)));let r=gt(e,i);if(!r)return t(e,i,o);let n=e.name;e.name=r;let l=t(e,i,o);return l&&(l.name=n),l}}a(Dr,"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 Pa(t,e,i){let r=(t.metadata?.spriteAnimations??[]).find(n=>n.name===e);if(!r)return console.error(`Animation with name "${e}" not found on sprite.`);t.playAnimation(r.from,r.to,r.loop,r.delay,i)}a(Pa,"playSpriteAnimationFromName");var Pr=require("babylonjs"),wr=require("babylonjs"),Or=require("babylonjs"),Er=require("babylonjs"),Hi=require("babylonjs"),we=require("babylonjs"),Tr=require("babylonjs"),_r=!1;function Ar(){_r||(_r=!0,(0,Tr.AddParser)("SpriteMapNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSpriteMap)return;let n=i.transformNodes?.find(s=>s.id===r.id);if(!n)return;n.isSpriteMap=r.isSpriteMap;let l=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(l);let p=new Or.WebRequest;p.open("GET",l),p.send(),p.addEventListener("load",()=>{e.removePendingData(l);let s=JSON.parse(p.responseText);zi(s);let c=`${Pr.Tools.GetFolderPath(l)}${s.meta.image}`,m=new Hi.Texture(c,e,!1,!1,Hi.Texture.NEAREST_NEAREST,null,null,null,!1,wr.Engine.TEXTUREFORMAT_RGBA),h=new Er.SpriteMap(n.name,s,m,{layerCount:r.options.layerCount,stageSize:we.Vector2.FromArray(r.options.stageSize??[10,1]),outputSize:we.Vector2.FromArray(r.options.outputSize??[100,100]),colorMultiply:we.Vector3.FromArray(r.options.colorMultiply??[1,1,1]),flipU:!0},e);r.getClassName=()=>"SpriteMapNode",r.tiles.forEach(f=>{for(let S=0,g=f.repeatCount.x+1;S<g;++S)for(let b=0,L=f.repeatCount.y+1;b<L;++b){let _=S*(f.repeatOffset.x+1),x=b*(f.repeatOffset.y+1);h.changeTiles(f.layer,new we.Vector2(f.position.x+_,(h.options.stageSize?.y??0)-1-f.position.y-x),f.tile)}});let d=h._output;d.parent=n,n.spriteMap=h})})}))}a(Ar,"registerSpriteMapParser");var Mr=require("babylonjs"),Rr=require("babylonjs"),vt=require("babylonjs"),Vr=require("babylonjs"),Ir=!1;function Fr(){if(Ir)return;Ir=!0,(0,Vr.RegisterShadowGeneratorSceneComponent)(Rr.ShadowGenerator);let t=(0,vt.GetParser)(Mr.SceneComponentConstants.NAME_SHADOWGENERATOR);(0,vt.AddParser)("ShadowGeneratorEditorPlugin",(e,i,o,r)=>{let n=new Map;e.shadowGenerators?.forEach(l=>{if(n.set(l.id,l.mapSize),i.loadingShadowsQuality!=="high"){switch(i.loadingShadowsQuality){case"medium":l.mapSize=l.mapSize*.5;break;case"low":l.mapSize=l.mapSize*.25;break;case"very-low":l.mapSize=l.mapSize*.125;break}l.mapSize=Math.max(128,N(l.mapSize))}}),t?.(e,i,o,r),i.lights.forEach(l=>{let p=l.getShadowGenerator();if(p?.getShadowMap()){let c=p.id,m=n.get(c);m&&(p.originalMapSize=m)}})})}a(Fr,"registerShadowGeneratorParser");var Br=require("babylonjs"),zr=require("babylonjs"),Hr=require("babylonjs"),ki=require("babylonjs"),kr=require("babylonjs");function Nr(t,e){e?.fogEnabled!==void 0&&(t.fogEnabled=e?.fogEnabled),e?.blendMode!==void 0&&(t.blendMode=e?.blendMode),e?.disableDepthWrite!==void 0&&(t.disableDepthWrite=e?.disableDepthWrite),e?.pixelPerfect!==void 0&&(t.pixelPerfect=e?.pixelPerfect),e?.useLogarithmicDepth!==void 0&&(t.useLogarithmicDepth=e?.useLogarithmicDepth),e?.metadata!==void 0&&(t.metadata=e?.metadata);for(let i of e?.sprites??[]){let o=zr.Sprite.Parse(i,t);o.uniqueId=i.uniqueId,o.metadata=i.metadata}}a(Nr,"parseSerializedSpriteManager");var Gr=!1;function Ur(){Gr||(Gr=!0,(0,kr.AddParser)("SpriteManagerNode",(t,e,i,o)=>{t.transformNodes?.forEach(r=>{if(!r.isSpriteManager)return;let n=i.transformNodes?.find(p=>p.id===r.id);if(!n)return;let l=e.getEngine();if(n.isSpriteManager=r.isSpriteManager,r.atlasJsonRelativePath){let p=`${o}${r.atlasJsonRelativePath}`;e.addPendingData(p);let s=new Hr.WebRequest;s.open("GET",p),s.send(),s.addEventListener("load",()=>{e.removePendingData(p);let c=JSON.parse(s.responseText),m=`${Br.Tools.GetFolderPath(p)}${c.meta.image}`;ut(l,m);let h=new ki.SpriteManager(n.name,m,1e3,64,e,void 0,void 0,!0,c);n.spriteManager=h,n.getClassName=()=>"SpriteManagerNode",r.spriteManager&&Nr(h,r.spriteManager)})}else if(r.spriteManager?.textureUrl){ut(l,r.spriteManager.textureUrl);let p=`${o}${r.spriteManager.textureUrl}`,s=new ki.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&&Nr(s,r.spriteManager)}})}))}a(Ur,"registerSpriteManagerParser");var Xr=require("babylonjs"),$r=require("babylonjs"),Wr=!1;function Kr(){Wr||(Wr=!0,(0,$r.AddParser)("MorphTargetManagerEditorPlugin",(t,e,i,o)=>{t.morphTargetManagers.forEach(r=>{let l=i.meshes.find(c=>c.id===r.meshId)?.morphTargetManager;if(!l||r.targets.find(c=>!c.delayLoadingFile))return;let s=[];r.targets.forEach(c=>{if(!c.delayLoadingFile)return s.push(Promise.resolve(null));let m=`${o}${c.delayLoadingFile}`;e.addPendingData(m);let h=new Xr.WebRequest;h.responseType="arraybuffer",h.open("GET",m),h.send(),s.push(new Promise(d=>{h.addEventListener("load",()=>{e.removePendingData(m),d(h.response)})}))}),Promise.all(s).then(c=>{for(let m=0,h=l.numTargets;m<h;++m){let d=l.getTarget(m),f=r.targets[m],S=c[m];if(f.positionsCount){let g=new Float32Array(S,f.positionsOffset,f.positionsCount);d._positions=g,d.setPositions(g)}if(f.normalsCount){let g=new Float32Array(S,f.normalsOffset,f.normalsCount);d._normals=g,d.setNormals(g)}if(f.tangentsCount){let g=new Float32Array(S,f.tangentsOffset,f.tangentsCount);d._tangents=g,d.setTangents(g)}if(f.uvsCount){let g=new Float32Array(S,f.uvsOffset,f.uvsCount);d._uvs=g,d.setUVs(g)}if(f.uv2sCount){let g=new Float32Array(S,f.uv2sOffset,f.uv2sCount);d._uv2s=g,d.setUV2s(g)}}for(let m=0,h=l.numTargets;m<h;++m)l.getTarget(m)._onDataLayoutChanged.notifyObservers()})})}))}a(Kr,"registerMorphTargetManagerParser");var Zr=require("babylonjs"),Yr=require("babylonjs"),jr=!1;function qr(){jr||(jr=!0,(0,Zr.AddParser)("NodeParticleSystemSetEditorPlugin",(t,e,i,o)=>{t.meshes?.forEach(r=>{if(!r.isNodeParticleSystemMesh)return;let n=i.meshes?.find(l=>l.id===r.id);n&&(r.nodeParticleSystemSet.blocks?.forEach(l=>{l.url&&(l.url=`${o}${l.url}`)}),n.nodeParticleSystemSet=Yr.NodeParticleSystemSet.Parse(r.nodeParticleSystemSet),n.nodeParticleSystemSet.id=r.nodeParticleSystemSet.id,n.nodeParticleSystemSet.uniqueId=r.uniqueId,e.addPendingData(r.id),n.nodeParticleSystemSet.buildAsync(e,!1).then(l=>{e.removePendingData(r.id),n.particleSystemSet=l,l.systems.forEach(p=>{if(Pt(p)){let s=p._sizeCreation.process;s&&(p._sizeCreation.process=(c,m)=>{s(c,m),c.scale.x*=100,c.scale.y*=100})}}),l.emitterNode=n,l.start()}))})}))}a(qr,"registerNodeParticleSystemSetParser");var Qr=require("babylonjs");function Jr(t,e){e??=new Qr.ClusteredLightContainer("Clustered Light Container",[],t);let i=t.metadata?.clusteredLight;return i&&(i.lights.length>0&&(e.horizontalTiles=i.horizontalTiles,e.verticalTiles=i.verticalTiles,e.depthSlices=i.depthSlices,e.maxRange=i.maxRange),i.lights.forEach(o=>{let r=t.getLightById(o);r&&e?.addLight(r)})),e}a(Jr,"configureLights");var tn=require("babylonjs"),Wi=require("babylonjs"),on=require("babylonjs"),rn=require("babylonjs"),Ui=new Map;async function en(t,e){let i=t.getWaitingItemsCount();for(;!t.isDisposed&&(!t.isReady()||t.getWaitingItemsCount()>0);){await new Promise(r=>setTimeout(r,150));let o=i-t.getWaitingItemsCount();o===i&&t.textures.forEach(r=>{r.delayLoadState===Wi.Constants.DELAYLOADSTATE_NONE&&(r.delayLoadState=Wi.Constants.DELAYLOADSTATE_LOADED)}),e(o/i)}}a(en,"waitForWaitingItems");async function wa(t,e,i,o,r){i.loadingQuality=r?.quality??"high",i.loadingTexturesQuality=r?.texturesQuality??i.loadingQuality,i.loadingShadowsQuality=r?.shadowsQuality??i.loadingQuality,i.loadingLodsQuality=r?.lodsQuality??i.loadingQuality,xr(),cr(),Dr(),Fr(),Kr(),Ar(),Ur(),qr();let n=Ui.get(i)??{};if(Ui.set(i,n),i.onDisposeObservable.addOnce(()=>{Ui.delete(i)}),await(0,on.AppendSceneAsync)(`${t}${e}`,i,{pluginExtension:".babylon",onProgress:a(p=>{let s=Math.min(p.loaded/p.total*.5);r?.onProgress?.(s)},"onProgress")}),await en(i,p=>{r?.onProgress?.(.5+p*.25)}),!r?.skipAssetsPreload){let p=0;do p=await Vi(t,i,o);while(p!==0&&!i.isDisposed)}rn.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&i.meshes.forEach(p=>F(p)&&p._checkDelayState());let l=Jr(i,n.clusteredLightContainer);n.clusteredLightContainer=l,await en(i,p=>{r?.onProgress?.(.75+p*.25)}),r?.onProgress?.(1),At(i),It(i.loadingLodsQuality,i),Mt(i),qe(i),i.metadata?.rendering&&(jo(i,i.metadata.rendering),i.activeCamera&&_i(i.activeCamera,t,r?.postProcessConfiguration)),i.metadata?.physicsGravity&&i.getPhysicsEngine()?.setGravity(tn.Vector3.FromArray(i.metadata?.physicsGravity)),B(i,i,o,t),i.transformNodes.forEach(p=>{B(i,p,o,t)}),i.meshes.forEach(p=>{Ko(p),B(i,p,o,t)}),i.lights.forEach(p=>{B(i,p,o,t)}),l.lights.forEach(p=>{B(i,p,o,t)}),i.cameras.forEach(p=>{B(i,p,o,t)}),i.spriteManagers?.forEach(p=>{p.sprites.forEach(s=>{B(i,s,o,t)})}),_e(i)}a(wa,"loadScene");var nn=require("babylonjs");async function Oa(t,e,i){let o=await z(t+e),n=nn.Tools.Instantiate(o.customType).Parse(o,i,t);return n.id=o.id,n.uniqueId=o.uniqueId,n}a(Oa,"loadMaterialFromFile");function Ea(t){return Promise.all(t.materials.map(async e=>{let i=e.getBindedMeshes();await Promise.all(i.map(async o=>{Te(o)||await e.forceCompilationAsync(o,{clipPlane:!!t.clipPlane,useInstances:o.hasInstances})}))}))}a(Ea,"forceCompileAllSceneMaterials");var J=require("babylonjs");function Ue(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(Ue,"getAnimationTypeForObject");var an=require("babylonjs");function Ta(t){return function(e,i){let o=e.constructor;o._NodesFromScene??=[],o._NodesFromScene.push({propertyKey:i,nodeName:t})}}a(Ta,"nodeFromScene");function Aa(t){return function(e,i){let o=e.constructor;o._ComponentsFromScene??=[],o._ComponentsFromScene.push({propertyKey:i,componentConstructor:t})}}a(Aa,"componentFromScene");function Ia(t,e=!1){return function(i,o){let r=i.constructor;r._NodesFromDescendants??=[],r._NodesFromDescendants.push({propertyKey:o,nodeName:t,directDescendantsOnly:e})}}a(Ia,"nodeFromDescendants");function Ma(t){return function(e,i){let o=e.constructor;o._AnimationGroups??=[],o._AnimationGroups.push({animationGroupName:t,propertyKey:i})}}a(Ma,"animationGroupFromScene");function Ra(t){return function(e,i){let o=e.constructor;o._SceneAssets??=[],o._SceneAssets.push({sceneName:t,propertyKey:i})}}a(Ra,"sceneAsset");function Va(t,e){return function(i,o){let r=i.constructor;r._GuiFromAsset??=[],r._GuiFromAsset.push({propertyKey:o,pathInAssets:t,onGuiCreated:e})}}a(Va,"guiFromAsset");function Fa(t){return function(e,i){let o=e.constructor;o._SoundsFromScene??=[],o._SoundsFromScene.push({propertyKey:i,soundName:t})}}a(Fa,"soundFromScene");function Na(t,e=!1){return function(i,o){let r=i.constructor;r._ParticleSystemsFromScene??=[],r._ParticleSystemsFromScene.push({propertyKey:o,particleSystemName:t,directDescendantsOnly:e})}}a(Na,"particleSystemFromScene");function Ga(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"boolean"}})}}a(Ga,"visibleAsBoolean");function Ba(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"string"}})}}a(Ba,"visibleAsString");function za(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"number"}})}}a(za,"visibleAsNumber");function Ha(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector2"}})}}a(Ha,"visibleAsVector2");function ka(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"vector3"}})}}a(ka,"visibleAsVector3");function Ua(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color3"}})}}a(Ua,"visibleAsColor3");function Wa(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"color4"}})}}a(Wa,"visibleAsColor4");function Xa(t,e,i){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...i,entityType:t,type:"entity"}})}}a(Xa,"visibleAsEntity");function $a(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"texture"}})}}a($a,"visibleAsTexture");function Ka(t,e){return function(i,o){let r=i.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:t,propertyKey:o,configuration:{...e,type:"keymap"}})}}a(Ka,"visibleAsKeyMap");function ja(t,e,i){return function(o,r){let n=o.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...i,assetType:t,type:"asset"}})}}a(ja,"visibleAsAsset");function Za(t,e){return function(i,o){let r=i.constructor;r._PointerEvents??=[],r._PointerEvents.push({propertyKey:o,options:{mode:"global",...e??{}},eventTypes:Array.isArray(t)?t:[t]})}}a(Za,"onPointerEvent");function Ya(t){return function(e,i){let o=e.constructor;o._KeyboardEvents??=[],o._KeyboardEvents.push({propertyKey:i,eventTypes:Array.isArray(t)?t:[t]})}}a(Ya,"onKeyboardEvent");function qa(t){return function(e,i){let o=e.constructor;o._SpritesFromSpriteManager??=[],o._SpritesFromSpriteManager.push({propertyKey:i,spriteName:t})}}a(qa,"spriteFromSpriteManager");function Qa(t){return function(e,i){let o=e.constructor;o._AnimationsFromSprite??=[],o._AnimationsFromSprite.push({propertyKey:i,animationName:t})}}a(Qa,"animationFromSprite");var St=require("babylonjs");function hv(t,e){let i;return t===St.Animation.ANIMATIONTYPE_FLOAT?i=e.value:i=e.value.clone(),{value:i,frame:e.frame,interpolation:e.interpolation,inTangent:t===St.Animation.ANIMATIONTYPE_FLOAT?e.inTangent:e.inTangent?.clone(),outTangent:t===St.Animation.ANIMATIONTYPE_FLOAT?e.outTangent:e.outTangent?.clone()}}a(hv,"cloneKey");function yt(t,e){let i=e.split("."),o=t;for(let r=0;r<i.length;++r)o=o[i[r]];return o}a(yt,"getPropertyValue");function Xi(t,e,i){let o=null;t.onAnimationGroupPlayObservable.add(()=>{o=e.onAfterAnimationsObservable.add(()=>{i()})}),t.onAnimationGroupPauseObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)}),t.onAnimationGroupEndObservable.add(()=>{o&&(e.onAfterAnimationsObservable.remove(o),o=null)})}a(Xi,"registerAfterAnimationCallback");var ee=require("babylonjs"),bt=require("babylonjs"),U=require("babylonjs");function Ja(t,e){return{name:t.name,framesPerSecond:t.framesPerSecond,outputFramesPerSecond:t.outputFramesPerSecond,tracks:t.tracks.map(i=>{let o=null,r=null;if(i.node?(o=Le(i.node,e),o||(o=e.particleSystems?.find(l=>l.id===i.node)??null)):i.defaultRenderingPipeline?o=Ie():i.volumetricLightScattering&&(o=Rt()),i.propertyPath){let l=yt(o,i.propertyPath);r=Ue(l)}let n=null;return i.sound&&(n=Le(i.sound,e)),{node:o,sound:n,propertyPath:i.propertyPath,defaultRenderingPipeline:i.defaultRenderingPipeline,volumetricLightScattering:i.volumetricLightScattering,animationGroupWeight:i.animationGroupWeight,animationGroup:i.animationGroup?e.getAnimationGroupByName(i.animationGroup):null,animationGroups:i.animationGroups,sounds:i.sounds,soundVolume:$i(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: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:U.Vector3.FromArray(l.data.force),contactPoint:U.Vector3.FromArray(l.data.contactPoint)};break}return p}),keyFrameAnimations:o&&r!==null&&$i(i.keyFrameAnimations??[],r)}})}}a(Ja,"parseCinematic");function k(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 U.Vector2.FromArray(t);case ee.Animation.ANIMATIONTYPE_VECTOR3:return U.Vector3.FromArray(t);case ee.Animation.ANIMATIONTYPE_QUATERNION:return U.Quaternion.FromArray(t);case ee.Animation.ANIMATIONTYPE_COLOR3:return bt.Color3.FromArray(t);case ee.Animation.ANIMATIONTYPE_COLOR4:return bt.Color4.FromArray(t);case ee.Animation.ANIMATIONTYPE_MATRIX:return U.Matrix.FromArray(t)}}a(k,"parseCinematicKeyValue");function $i(t,e){return t?.map(i=>{let o=i.type==="key"?i:null;if(o)return{...o,value:k(o.value,e),inTangent:k(o.inTangent,e),outTangent:k(o.outTangent,e)};let r=i.type==="cut"?i:null;if(r)return{...r,key1:{...r.key1,value:k(r.key1.value,e),inTangent:k(r.key1.inTangent,e),outTangent:k(r.key1.outTangent,e)},key2:{...r.key2,value:k(r.key2.value,e),inTangent:k(r.key2.inTangent,e),outTangent:k(r.key2.outTangent,e)}};throw new Error(`Unknown key frame type: ${i.type}`)})}a($i,"parseKeyFrameAnimations");function sn(t,e){t.onEventObservable.notifyObservers(e.eventName)}a(sn,"handleApplyEvent");function ln(t){t.node?.setEnabled(t.value)}a(ln,"handleSetEnabledEvent");var Ki=require("babylonjs"),cn=Ki.Vector3.Zero();function pn(t,e){let i=e.mesh?[e.mesh]:t.meshes.filter(o=>o.physicsAggregate);e.radius&&(i=i.filter(o=>{let r=o.getBoundingInfo().boundingBox.centerWorld;return Ki.Vector3.Distance(r,e.contactPoint)<=e.radius})),i.forEach(o=>{if(o.physicsAggregate?.body){let r=e.contactPoint.subtract(o.getBoundingInfo().boundingBox.centerWorld);r.multiplyInPlace(e.force),o.physicsAggregate.body.setLinearVelocity(cn),o.physicsAggregate.body.setAngularVelocity(cn),o.physicsAggregate.body.applyImpulse(r.negateInPlace(),e.contactPoint)}})}a(pn,"handleApplyImpulseEvent");var mn=require("babylonjs"),hn=require("babylonjs"),We=class extends hn.AnimationGroup{static{a(this,"Cinematic")}onEventObservable=new mn.Observable;onEvent(e,i){this.onEventObservable.add(o=>{e===o&&i()})}};function ji(t){return t.type==="key"}a(ji,"isCinematicKey");function Oe(t){return t.type==="cut"}a(Oe,"isCinematicKeyCut");function es(t){return t.type==="event"}a(es,"isCinematicKeyEvent");function ts(t){return t.type==="group"}a(ts,"isCinematicGroup");function is(t){return t.type==="sound"}a(is,"isCinematicSound");var O=require("babylonjs"),Ee=require("babylonjs");function os(t,e,i){let o=new We(t.name,e);return t.tracks.forEach(r=>{let n=r.animationGroup;if(n&&r.animationGroups?.length){let d=n.clone(`${n.name}-cinematic-temp`),f=e.animationGroups.indexOf(d);f!==-1&&e.animationGroups.splice(f,1),o.onAnimationEndObservable.add(()=>{n.stop(),d.stop()});let S=r.animationGroups.reduce((_,x)=>Math.min(_,x.frame),Number.MAX_VALUE)??0,g=r.animationGroups.reduce((_,x)=>Math.max(_,x.frame+x.endFrame),0)??0,b={frame:S},L=new O.Animation(d.name,"frame",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1);if(L.setKeys([{frame:S,value:0},{frame:g,value:g}]),r.animationGroups.forEach(_=>{L.addEvent(new Ee.AnimationEvent(_.frame,()=>{let x=_.repeatCount??0;if(d.to=_.endFrame,d.speedRatio=_.speed,d.stop(),d.play(x>0),d.from!==_.startFrame&&d.goToFrame(_.startFrame),x){let R=0;d.onAnimationGroupLoopObservable.add(()=>{++R,R>x&&d.stop()})}}))}),o.addTargetedAnimation(L,b),(r.animationGroupWeight?.length??0)>=2&&r.animationGroupWeight.find(x=>Oe(x)?x.key1.value!==1||x.key2.value!==1:x.value!==1)){let x={weight:0},R=new O.Animation(`${d.name}-weights`,"weight",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),G=[];r.animationGroupWeight.forEach(v=>{Oe(v)?(G.push(v.key1),G.push(v.key2)):G.push(v)}),R.setKeys(G),o.addTargetedAnimation(R,x),Xi(o,e,()=>{d.weight=x.weight})}}let l=r.sound;if(!i?.ignoreSounds&&l&&l.sound?.buffer&&r.sounds?.length){let d={dummy:0,volume:0},f=new O.Animation(l.name,"dummy",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;if(r.sounds?.forEach(g=>{let b=g.endFrame-g.startFrame;S=Math.max(S,g.frame+b),f.addEvent(new Ee.AnimationEvent(g.frame,L=>{let x=(L-g.frame+g.startFrame)/t.framesPerSecond;l.play({startOffset:x})},!1)),f.addEvent(new Ee.AnimationEvent(g.frame+b,()=>{l.stop()}))}),f.setKeys([{frame:0,value:0},{frame:S,value:S}]),o.addTargetedAnimation(f,d),(r.soundVolume?.length??0)>=2){let g=new O.Animation(l.name,"volume",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),b=[];r.soundVolume.forEach(L=>{Oe(L)?(b.push(L.key1),b.push(L.key2)):b.push(L)}),g.setKeys(b),o.addTargetedAnimation(g,d),Xi(o,e,()=>{l.volume=d.volume})}}if(r.keyFrameEvents){let d={dummy:0},f=new O.Animation("events","dummy",60,O.Animation.ANIMATIONTYPE_FLOAT,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),S=0;r.keyFrameEvents?.forEach(g=>{S=Math.max(S,g.frame),f.addEvent(new Ee.AnimationEvent(g.frame,()=>{switch(g.data?.type){case"event":sn(o,g.data);break;case"set-enabled":ln(g.data);break;case"apply-impulse":pn(e,g.data);break}}))}),f.setKeys([{frame:0,value:0},{frame:S+1,value:S+1}]),o.addTargetedAnimation(f,d)}let p=r.defaultRenderingPipeline?Ie():r.node;if(!p||!r.propertyPath||!r.keyFrameAnimations)return;let s=yt(p,r.propertyPath),c=Ue(s);if(c===null)return;let m=new O.Animation(r.propertyPath,r.propertyPath,60,c,O.Animation.ANIMATIONLOOPMODE_CYCLE,!1),h=[];r.keyFrameAnimations?.forEach(d=>{if(ji(d))return h.push(d);Oe(d)&&(h.push(d.key1),h.push(d.key2),Ze(p)&&r.propertyPath==="position"&&m.addEvent(new Ee.AnimationEvent(d.key1.frame,()=>{let f=Kt();if(!f)return;let S=f.motionStrength;f.motionStrength=0,requestAnimationFrame(()=>{f.motionStrength=S})})))}),m.setKeys(h),o.addTargetedAnimation(m,p)}),o.normalize(),o}a(os,"generateCinematicAnimationGroup");async function Zi(t,e){return new Promise((i,o)=>{let r=indexedDB.open(t,1);r.addEventListener("error",()=>o()),r.addEventListener("blocked",()=>o()),r.addEventListener("upgradeneeded",()=>{try{e(r.result)}catch(n){o(n)}}),r.addEventListener("success",()=>{i(r.result)})})}a(Zi,"openIndexDB");function Xe(t,e,i){return new Promise(o=>{let n=t.transaction(e).objectStore(e).get(i);n.addEventListener("error",()=>{o(null)}),n.addEventListener("success",()=>{o(n.result??null)})})}a(Xe,"getFromIndexDB");async function W(t,e,i){let r=t.transaction(e,"readwrite").objectStore(e).put(i);await new Promise((n,l)=>{r.addEventListener("error",()=>l()),r.addEventListener("success",()=>n())})}a(W,"putInIndexDB");var dn=require("babylonjs");function rs(t){dn.AbstractEngine.OfflineProviderFactory=(e,i,o=!1)=>new $e(t,e,i,o)}a(rs,"setupOfflineProvider");async function Yi(t,e){let i=await new Promise(o=>{let r=new $e(t,e,n=>o(n?r:null),!1)});return await i?.open(),i}a(Yi,"createAndOpenDatabase");var $e=class{static{a(this,"Database")}enableSceneOffline=!0;enableTexturesOffline=!0;name;_database=null;_manifestVersion=null;_loadFilePromises=new Map;constructor(e,i,o,r){this.name=e,r?o(!1):this._checkManifest(i,o)}async _checkManifest(e,i){try{let o=await z(`${e}.manifest?${Date.now()}`);this._manifestVersion=o.version,i(!0)}catch{this.enableSceneOffline=!1,this.enableTexturesOffline=!1,i(!1)}}async open(e,i){try{this._database=await Zi(this.name,o=>{o.createObjectStore("files",{keyPath:"url"}),o.createObjectStore("images",{keyPath:"url"}),o.createObjectStore("versions",{keyPath:"url"})}),e?.()}catch{i?.()}}close(){this._database?.close(),this._database=null,this._loadFilePromises.clear()}async loadImage(e,i){if(!this._database){i.src=e;return}let o=null;await Ei(()=>this._manifestVersion!==null);let r=this._loadFilePromises.get(e);if(r)return r.then(l=>{l!==null?i.src=l:i.src=e});let n=new Promise(async l=>{if(await this._getFileVersionForUrl(e)!==this._manifestVersion?(o=await Ce(e,"blob"),await Promise.all([W(this._database,"images",{url:e,data:o}),W(this._database,"versions",{url:e,version:this._manifestVersion})])):o=(await Xe(this._database,"images",e))?.data??null,o!==null){let s=URL.createObjectURL(o);i.src=s}else i.src=e;l(i.src)});this._loadFilePromises.set(e,n)}async saveImage(e){if(!this._database)throw new Error("Database is not available");let i=await Ce(e,"blob");await Promise.all([W(this._database,"images",{url:e,data:i}),W(this._database,"versions",{url:e,version:this._manifestVersion})])}async isFileMatchingVersion(e){return await this._getFileVersionForUrl(e)===this._manifestVersion}async loadFile(e,i,o,r,n){if(!this._database)return r?.();let l=null;await Ei(()=>this._manifestVersion!==null);let p=this._loadFilePromises.get(e);if(p)return p.then(c=>{c!==null?i(c):r?.()});let s=new Promise(async c=>{await this._getFileVersionForUrl(e)!==this._manifestVersion?(l=await Ce(e,n?"arraybuffer":"text",o),await Promise.all([W(this._database,"files",{url:e,data:l}),W(this._database,"versions",{url:e,version:this._manifestVersion})])):l=(await Xe(this._database,"files",e))?.data??null,l!==null?i(l):r?.(),c(l)});this._loadFilePromises.set(e,s)}async saveFile(e,i,o){if(!this._database)throw new Error("Database is not available");let r=await Ce(e,i?"arraybuffer":"text",o);await Promise.all([W(this._database,"files",{url:e,data:r}),W(this._database,"versions",{url:e,version:this._manifestVersion})])}async _getFileVersionForUrl(e){return(await Xe(this._database,"versions",e))?.version??null}};var fn=["mp3","wav"],un=["babylonbinarymeshdata"],ns=["ktx","ktx2","jpg","jpeg","png","bmp","webp"],gn=["babylon","json"],qi=["jpg","jpeg","png","bmp","webp"],vn=["bin","ktx","ktx2",...un,...fn],as=[...gn,...qi,...vn];async function ss(t,e,i){let o=[],r=await z(`${e}scenes-used-files.json`),n=[];if(i?.scenesFilter){n=i.scenesFilter.map(h=>typeof h=="string"?{sceneName:h,disableSounds:!1,disableTextures:!1,disableGeometries:!1}:h);for(let[h,d]of Object.entries(r))n.find(f=>f.sceneName===h)||delete r[h]}let l=0,p=0,s=i?.engine?.textureFormatInUse?i?.engine?.texturesSupported[0]:null,c=Object.values(r).reduce((h,d)=>h+d.length,0);function m(h){++p,i?.onProgress?.(p/c),h?.()}a(m,"notifyProgress");for(let[h,d]of Object.entries(r)){let f=h.replace(".scene",".babylon"),S=await Yi(t,`${e}${f}`);if(!S)continue;let g=n.find(b=>b.sceneName===h);for(let b=0,L=d.length;b<L;++b){let _=d[b],x=_.split(".").pop()?.toLowerCase();if(!x){m();continue}if(un.includes(x)&&g?.disableGeometries){m();continue}if(ns.includes(x)&&g?.disableTextures){m();continue}if(fn.includes(x)&&g?.disableSounds){m();continue}if(qi.includes(x)&&g?.disableTextures){m();continue}if(x==="ktx")if(s){if(!_.endsWith(s)){m();continue}}else{m();continue}if(x==="ktx2"&&!ke()){m();continue}if(o.length>300){try{await Promise.all(o)}catch{}o.splice(0,o.length)}let R=`${e}${_}`;as.includes(x)&&o.push(new Promise(async G=>{if(await S.isFileMatchingVersion(R))return m(G);try{qi.includes(x)?i?.disableImages||(await S.saveImage(R),++l):vn.includes(x)?(await S.saveFile(R,!0),++l):gn.includes(x)&&(await S.saveFile(R,!1),++l)}catch{}m(G)}))}await Promise.all(o),S.close()}return await Promise.all(o),{loadedCount:l,processedFilesCount:p}}a(ss,"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,getVolumetricPrePassDepthTexture,getVolumetricPrePassRenderer,guiFromAsset,isAbstractMesh,isAnyParticleSystem,isArcRotateCamera,isBone,isCamera,isCascadedShadowGenerator,isCinematicGroup,isCinematicKey,isCinematicKeyCut,isCinematicKeyEvent,isCinematicSound,isClusteredLightContainer,isDecalMesh,isDirectionalLight,isFreeCamera,isGPUParticleSystem,isGaussianSplattingMesh,isGroundMesh,isHemisphericLight,isInstancedMesh,isLight,isMesh,isNode,isNodeFromStaticGroup,isParticleSystem,isPointLight,isScene,isShadowGenerator,isSoundNode,isSpotLight,isSprite,isTexture,isTransformNode,isUsingKtx2CompressedTextures,isVolumetricLightEnabled,isVolumetricLightSupported,isVolumetricLightingSupported,loadMaterialFromFile,loadScene,markVolumetricLightsDirty,maxVolumetricArrayLights,maxVolumetricDirectionalLights,maxVolumetricShadowSlots,motionBlurPostProcessCameraConfigurations,nodeFromDescendants,nodeFromScene,normalizeAtlasJson,normalizeVolumetricLightConfiguration,normalizeVolumetricLightingConfiguration,onKeyboardEvent,onPointerEvent,openIndexDB,parseCinematic,parseCinematicKeyValue,parseDefaultRenderingPipeline,parseKeyFrameAnimations,parseMotionBlurPostProcess,parseRagdollConfiguration,parseSSAO2RenderingPipeline,parseSSRRenderingPipeline,parseTAARenderingPipeline,parseVLSPostProcess,parseVolumetricLightingRenderingPipeline,particleSystemFromScene,playSpriteAnimationFromName,preloadAssetsToDatabase,putInIndexDB,registerScriptAssetParser,resolveVolumetricDepthSource,resolveVolumetricShadowSlot,saveRenderingConfigurationForCamera,sceneAsset,scriptAssetsCache,scriptAssetsParsers,scriptsDictionary,selectVolumetricLights,serializeDefaultRenderingPipeline,serializeMotionBlurPostProcess,serializeSSAO2RenderingPipeline,serializeSSRRenderingPipeline,serializeTAARenderingPipeline,serializeVLSPostProcess,serializeVolumetricLightingRenderingPipeline,setDefaultRenderingPipelineRef,setMotionBlurPostProcessRef,setSSAO2RenderingPipelineRef,setSSRRenderingPipelineRef,setStaticDecalsEnabled,setTAARenderingPipelineRef,setUseKtx2CompressedTextures,setVLSPostProcessRef,setVolumetricLightingRenderingPipelineRef,setupOfflineProvider,soundFromScene,spriteFromSpriteManager,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,supportsVolumetricFloatDepthTexture,taaRenderingPipelineCameraConfigurations,visibleAsAsset,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsKeyMap,visibleAsNumber,visibleAsString,visibleAsTexture,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations,volumetricLightMetadataKey,volumetricLightingPrePassConfigurationName,volumetricLightingRenderingPipelineCameraConfigurations});
|