From 139f5b522d52b31cfc7bacf402c79a0a8aba333e Mon Sep 17 00:00:00 2001 From: jiawanlong Date: Tue, 14 May 2024 10:34:07 +0800 Subject: [PATCH] Create babylon.js --- babylon/babylon.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 babylon/babylon.js diff --git a/babylon/babylon.js b/babylon/babylon.js new file mode 100644 index 00000000..0850f72e --- /dev/null +++ b/babylon/babylon.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("babylonjs",[],t):"object"==typeof exports?exports.babylonjs=t():e.BABYLON=t()}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(()=>(()=>{"use strict";var e={d:(t,i)=>{for(var r in i)e.o(i,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:i[r]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.d(t,{default:()=>YD});var i={};e.r(i),e.d(i,{AxesViewer:()=>Nh,BoneAxesViewer:()=>Fh,DebugLayer:()=>Lh,DebugLayerTab:()=>Mh,DirectionalLightFrustumViewer:()=>sp,PhysicsViewer:()=>np,RayHelper:()=>op,SkeletonViewer:()=>ap});var r={};e.r(r),e.d(r,{AbstractActionManager:()=>h,AbstractAssetTask:()=>YR,AbstractEngine:()=>Mi,AbstractMesh:()=>Uo,AbstractScene:()=>c,AcquireNativeObjectAsync:()=>df,Action:()=>ee,ActionEvent:()=>te,ActionManager:()=>be,AddBlock:()=>Ab,AddressMode:()=>Rf,AdvancedTimer:()=>jg,AlignBlock:()=>zS,AlphaState:()=>Ci,AmmoJSPlugin:()=>Bv,AnaglyphArcRotateCamera:()=>eu,AnaglyphFreeCamera:()=>tu,AnaglyphGamepadCamera:()=>iu,AnaglyphPostProcess:()=>Jc,AnaglyphUniversalCamera:()=>ru,Analyser:()=>ka,AndOrNotEvaluator:()=>Xe,Angle:()=>En,Animatable:()=>gn,AnimatedInputBlockTypes:()=>Zs,Animation:()=>at,AnimationAssetTask:()=>ZR,AnimationEvent:()=>kn,AnimationGroup:()=>zn,AnimationGroupMask:()=>Hn,AnimationGroupMaskMode:()=>bn,AnimationKeyInterpolation:()=>ge,AnimationPropertiesOverride:()=>yn,AnimationRange:()=>Se,AnisotropyBlock:()=>dT,ApplyPostProcess:()=>Rp,Arc2:()=>Sn,ArcFollowCamera:()=>Gc,ArcRotateCamera:()=>Nc,ArcRotateCameraGamepadInput:()=>lc,ArcRotateCameraInputsManager:()=>dc,ArcRotateCameraKeyboardMoveInput:()=>cc,ArcRotateCameraMouseWheelInput:()=>uc,ArcRotateCameraPointersInput:()=>hc,ArcRotateCameraVRDeviceOrientationInput:()=>pc,ArcTan2Block:()=>Kb,AssetContainer:()=>Va,AssetTaskState:()=>HR,AssetsManager:()=>oP,AssetsProgressEvent:()=>KR,AsyncLoop:()=>or,AttachToBoxBehavior:()=>cs,AudioEngine:()=>Oo,AudioSceneComponent:()=>Wa,AutoLayoutMode:()=>Uf,AutoReleaseWorkerPool:()=>yg,AutoRotationBehavior:()=>os,AxesViewer:()=>Nh,Axis:()=>_n,AxisDragGizmo:()=>Dh,AxisScaleGizmo:()=>mm,BRDFTextureTools:()=>Gm,BabylonFileLoaderConfiguration:()=>Hv,BackEase:()=>In,BackgroundMaterial:()=>Lm,BakedVertexAnimationManager:()=>Xa,BallAndSocketConstraint:()=>GA,BaseCameraMouseWheelInput:()=>tc,BaseCameraPointersInput:()=>ic,BaseError:()=>vt,BaseParticleSystem:()=>vl,BaseSixDofDragBehavior:()=>ys,BaseTexture:()=>Ya,BasisFileInfo:()=>Ry,BasisTools:()=>Uy,BasisToolsOptions:()=>Iy,BasisTranscodeConfiguration:()=>Py,BezierCurve:()=>Tn,BezierCurveEase:()=>Vn,BiPlanarBlock:()=>PT,BinaryFileAssetTask:()=>$R,BindBonesParameters:()=>na,BindFogParameters:()=>Qo,BindLight:()=>aa,BindLightProperties:()=>oa,BindLights:()=>sa,BindLogDepth:()=>Ko,BindMorphTargetParameters:()=>$o,BindSceneUniformBuffer:()=>ea,BindTextureMatrix:()=>ia,BlackAndWhitePostProcess:()=>gC,BlendFactor:()=>Wf,BlendOperation:()=>Hf,BloomEffect:()=>TC,BloomMergePostProcess:()=>bC,BlurPostProcess:()=>Om,Bone:()=>mn,BoneAxesViewer:()=>Fh,BoneIKController:()=>Zl,BoneLookController:()=>Jl,BonesBlock:()=>qy,BooleanGeometryBlock:()=>cx,BooleanGeometryOperations:()=>sx,BounceEase:()=>Mn,BouncingBehavior:()=>as,BoundingBlock:()=>lx,BoundingBox:()=>to,BoundingBoxGizmo:()=>gm,BoundingBoxRenderer:()=>cR,BoundingInfo:()=>so,BoundingSphere:()=>io,BoxBlock:()=>iS,BoxBuilder:()=>Vh,BoxParticleEmitter:()=>Dx,Buffer:()=>Dr,BufferBindingType:()=>Df,BufferMapState:()=>yf,BufferUsage:()=>bf,CSG:()=>EE,Camera:()=>$n,CameraGizmo:()=>Mm,CameraInputTypes:()=>rc,CameraInputsManager:()=>nc,CannonJSPlugin:()=>Lv,CanvasAlphaMode:()=>e_,CapsuleBlock:()=>dS,CapsuleBuilder:()=>Xh,CascadedShadowGenerator:()=>Tv,ChromaticAberrationPostProcess:()=>EC,CircleEase:()=>Pn,CircleOfConfusionPostProcess:()=>SC,ClampBlock:()=>Rb,ClearCoatBlock:()=>fT,ClipPlanesBlock:()=>Tb,ClipboardEventTypes:()=>fm,ClipboardInfo:()=>_m,CloudBlock:()=>xT,CloudPoint:()=>mA,Collider:()=>fh,Color3:()=>Z,Color3Gradient:()=>jx,Color4:()=>J,ColorCorrectionPostProcess:()=>xC,ColorCurves:()=>ur,ColorGradient:()=>Xx,ColorGradingTexture:()=>oy,ColorMergerBlock:()=>Db,ColorSplitterBlock:()=>yl,ColorWrite:()=>zf,CombineAction:()=>fe,CompareFunction:()=>Mf,CompatibilityOptions:()=>go,CompilationMessageType:()=>wf,CompleteGreasedLineColorTable:()=>QE,CompleteGreasedLineWidthTable:()=>KE,ComputeBindingType:()=>mh,ComputeEffect:()=>gh,ComputeNormalsBlock:()=>OS,ComputePassTimestampLocation:()=>Qf,ComputeShader:()=>yh,ComputeShaderParticleSystem:()=>Hx,Condition:()=>ie,ConditionBlock:()=>AS,ConditionBlockTests:()=>ES,ConditionalBlock:()=>ST,ConditionalBlockConditions:()=>TT,ConeParticleEmitter:()=>Nx,Constants:()=>u,ContainerAssetTask:()=>QR,ConversionMode:()=>PR,ConvolutionPostProcess:()=>AC,Coordinate:()=>fn,CopyTextureToTexture:()=>OR,CopyTools:()=>Za,CreateBox:()=>Uh,CreateBoxVertexData:()=>wh,CreateCapsule:()=>Hh,CreateCapsuleVertexData:()=>Wh,CreateCylinder:()=>xh,CreateCylinderVertexData:()=>Sh,CreateDashedLines:()=>_d,CreateDashedLinesVertexData:()=>dd,CreateDecal:()=>Wd,CreateDisc:()=>qh,CreateDiscVertexData:()=>Qh,CreateEnvTextureAsync:()=>Gp,CreateGeodesic:()=>Qd,CreateGoldberg:()=>Jd,CreateGoldbergVertexData:()=>Zd,CreateGreasedLine:()=>jE,CreateGreasedLineMaterial:()=>XE,CreateGround:()=>ih,CreateGroundFromHeightMap:()=>nh,CreateGroundFromHeightMapVertexData:()=>th,CreateGroundVertexData:()=>$u,CreateHemisphere:()=>Cm,CreateIcoSphere:()=>Bl,CreateIcoSphereVertexData:()=>wl,CreateImageBitmapFromSource:()=>Ao,CreateImageDataArrayBufferViews:()=>Wp,CreateLathe:()=>Id,CreateLineSystem:()=>pd,CreateLineSystemVertexData:()=>hd,CreateLines:()=>fd,CreatePlane:()=>fs,CreatePlaneVertexData:()=>ps,CreatePolygon:()=>Ed,CreatePolygonVertexData:()=>Td,CreatePolyhedron:()=>Fd,CreatePolyhedronVertexData:()=>Nd,CreateResizedCopy:()=>Cp,CreateRibbon:()=>Yh,CreateRibbonVertexData:()=>jh,CreateScreenshot:()=>PP,CreateScreenshotAsync:()=>IP,CreateScreenshotUsingRenderTarget:()=>OP,CreateScreenshotUsingRenderTargetAsync:()=>DP,CreateScreenshotWithResizeAsync:()=>MP,CreateSegmentedBoxVertexData:()=>Bh,CreateSphere:()=>Gh,CreateSphereVertexData:()=>kh,CreateText:()=>ip,CreateTextShapePaths:()=>tp,CreateTiledBox:()=>id,CreateTiledBoxVertexData:()=>td,CreateTiledGround:()=>rh,CreateTiledGroundVertexData:()=>eh,CreateTiledPlane:()=>$h,CreateTiledPlaneVertexData:()=>Jh,CreateTorus:()=>sh,CreateTorusKnot:()=>od,CreateTorusKnotVertexData:()=>nd,CreateTorusVertexData:()=>ah,CreateTube:()=>Od,CrossBlock:()=>Pb,CubeMapToSphericalPolynomialTools:()=>Lp,CubeTexture:()=>Nm,CubeTextureAssetTask:()=>iP,CubicEase:()=>On,CullMode:()=>Gf,CurrentScreenBlock:()=>nl,Curve3:()=>Cn,CurveBlock:()=>FT,CurveBlockTypes:()=>DT,CustomBlock:()=>Ib,CustomOptimization:()=>mP,CustomParticleEmitter:()=>kx,CustomProceduralTexture:()=>Wy,CylinderBlock:()=>hS,CylinderBuilder:()=>Ah,CylinderDirectedParticleEmitter:()=>Lx,CylinderParticleEmitter:()=>Fx,DDSTools:()=>hg,DataBuffer:()=>vr,DataReader:()=>BP,DataStorage:()=>UP,Database:()=>Ox,DebugBlock:()=>JS,DebugLayer:()=>Lh,DebugLayerTab:()=>Mh,DecalBuilder:()=>Hd,DecalMapConfiguration:()=>zT,DecalMapDefines:()=>GT,Decode:()=>St,DecodeBase64ToBinary:()=>Ct,DecodeBase64ToString:()=>At,DecodeBase64UrlToBinary:()=>Hi,DecodeBase64UrlToString:()=>ji,DeepCopier:()=>ye,DefaultCollisionCoordinator:()=>_h,DefaultKTX2DecoderOptions:()=>Eg,DefaultLoadingScreen:()=>xv,DefaultRenderingPipeline:()=>jC,Deferred:()=>aP,DepthCullingState:()=>Si,DepthOfFieldBlurPostProcess:()=>CC,DepthOfFieldEffect:()=>IC,DepthOfFieldEffectBlurLevel:()=>RC,DepthOfFieldMergePostProcess:()=>PC,DepthPeelingRenderer:()=>dR,DepthPeelingSceneComponent:()=>pR,DepthReducer:()=>_v,DepthRenderer:()=>pv,DepthRendererSceneComponent:()=>uR,DepthSortedParticle:()=>pA,DerivativeBlock:()=>ob,DesaturateBlock:()=>uT,DetailMapConfiguration:()=>Lu,DeviceInputEventType:()=>Mr,DeviceLostReason:()=>t_,DeviceOrientationCamera:()=>Fc,DeviceSource:()=>en,DeviceSourceManager:()=>rn,DeviceType:()=>Sr,DirectionalLight:()=>Am,DirectionalLightFrustumViewer:()=>sp,DiscBlock:()=>pS,DiscBuilder:()=>Zh,DiscardBlock:()=>rb,DisplayPassPostProcess:()=>MC,DistanceBlock:()=>Wb,DistanceConstraint:()=>zA,DistanceJoint:()=>Rs,DivideBlock:()=>Lb,DoNothingAction:()=>pe,DomManagement:()=>ft,DotBlock:()=>Mb,DracoCompression:()=>_E,DrawWrapper:()=>ho,DualSenseInput:()=>Rr,DualShockButton:()=>zc,DualShockDpad:()=>Wc,DualShockInput:()=>Cr,DualShockPad:()=>Xc,DumpTools:()=>Rl,DynamicFloat32Array:()=>YP,DynamicTexture:()=>Gu,EasingFunction:()=>Rn,EdgesRenderer:()=>_R,Effect:()=>Ei,EffectFallbacks:()=>ll,EffectLayer:()=>iv,EffectLayerSceneComponent:()=>rv,EffectRenderer:()=>Tl,EffectWrapper:()=>El,ElasticEase:()=>Dn,ElbowBlock:()=>CT,EncodeArrayBufferToBase64:()=>xt,EndsWith:()=>Tt,Engine:()=>Do,EngineFactory:()=>pm,EngineFormat:()=>mg,EngineInstrumentation:()=>ev,EngineStore:()=>M,EngineView:()=>pp,EnvironmentHelper:()=>wm,EnvironmentTextureTools:()=>Qp,Epsilon:()=>A,EquiRectangularCubeTexture:()=>ay,EquiRectangularCubeTextureAssetTask:()=>nP,ErrorCodes:()=>yt,ErrorFilter:()=>i_,EventConstants:()=>Qr,EventState:()=>d,ExecuteCodeAction:()=>_e,ExitFullscreen:()=>Po,ExitPointerlock:()=>Mo,ExponentialEase:()=>Nn,ExternalTexture:()=>w_,ExtractHighlightsPostProcess:()=>yC,ExtrudePolygon:()=>Sd,ExtrudeShape:()=>Ad,ExtrudeShapeCustom:()=>Cd,FactorGradient:()=>Yx,FadeInOutBehavior:()=>us,FeatureName:()=>vf,FileTools:()=>Xi,FileToolsOptions:()=>Li,FilesInput:()=>lP,FilesInputStore:()=>mt,FilterMode:()=>Pf,FilterPostProcess:()=>OC,FlowGraph:()=>SM,FlowGraphAbsBlock:()=>IO,FlowGraphAcosBlock:()=>aD,FlowGraphAcoshBlock:()=>pD,FlowGraphAddBlock:()=>vO,FlowGraphAsinBlock:()=>oD,FlowGraphAsinhBlock:()=>dD,FlowGraphAtan2Block:()=>lD,FlowGraphAtanBlock:()=>sD,FlowGraphAtanhBlock:()=>fD,FlowGraphBitwiseAndBlock:()=>DD,FlowGraphBitwiseLeftShiftBlock:()=>LD,FlowGraphBitwiseNotBlock:()=>OD,FlowGraphBitwiseOrBlock:()=>ND,FlowGraphBitwiseRightShiftBlock:()=>wD,FlowGraphBitwiseXorBlock:()=>FD,FlowGraphBlock:()=>fM,FlowGraphBranchBlock:()=>NM,FlowGraphCeilBlock:()=>NO,FlowGraphClampBlock:()=>zO,FlowGraphConditionalDataBlock:()=>QM,FlowGraphConnection:()=>YI,FlowGraphConnectionType:()=>HI,FlowGraphConsoleLogBlock:()=>RM,FlowGraphConstantBlock:()=>JM,FlowGraphContext:()=>yM,FlowGraphContextLogger:()=>AM,FlowGraphCoordinateTransformBlock:()=>ZM,FlowGraphCoordinator:()=>xM,FlowGraphCosBlock:()=>rD,FlowGraphCoshBlock:()=>uD,FlowGraphCountLeadingZerosBlock:()=>BD,FlowGraphCountOneBitsBlock:()=>VD,FlowGraphCountTrailingZerosBlock:()=>UD,FlowGraphCounterBlock:()=>GM,FlowGraphCrossBlock:()=>xD,FlowGraphCubeRootBlock:()=>bD,FlowGraphDataConnection:()=>cM,FlowGraphDebounceBlock:()=>WM,FlowGraphDegToRadBlock:()=>eD,FlowGraphDeterminantBlock:()=>PD,FlowGraphDivideBlock:()=>TO,FlowGraphDoNBlock:()=>FM,FlowGraphDotBlock:()=>SO,FlowGraphEBlock:()=>xO,FlowGraphEqBlock:()=>jO,FlowGraphEventBlock:()=>vM,FlowGraphExecutionBlock:()=>mM,FlowGraphExpBlock:()=>_D,FlowGraphFlipFlopBlock:()=>HM,FlowGraphFloorBlock:()=>DO,FlowGraphForLoopBlock:()=>LM,FlowGraphFractBlock:()=>FO,FlowGraphGetPropertyBlock:()=>$M,FlowGraphGetVariableBlock:()=>qM,FlowGraphGreaterThanBlock:()=>qO,FlowGraphGreaterThanOrEqualBlock:()=>ZO,FlowGraphInfBlock:()=>CO,FlowGraphInterpolateBlock:()=>XO,FlowGraphInvertMatrixBlock:()=>ID,FlowGraphIsInfBlock:()=>$O,FlowGraphIsNanBlock:()=>JO,FlowGraphLengthBlock:()=>ED,FlowGraphLessThanBlock:()=>KO,FlowGraphLessThanOrEqualBlock:()=>QO,FlowGraphLog10Block:()=>vD,FlowGraphLog2Block:()=>gD,FlowGraphLogBlock:()=>mD,FlowGraphLogicAndBlock:()=>cO,FlowGraphLogicNotBlock:()=>hO,FlowGraphLogicOrBlock:()=>uO,FlowGraphMatMulBlock:()=>MD,FlowGraphMaxBlock:()=>VO,FlowGraphMeshPickEventBlock:()=>EM,FlowGraphMinBlock:()=>UO,FlowGraphMultiGateBlock:()=>UM,FlowGraphMultiplyBlock:()=>bO,FlowGraphNaNBlock:()=>RO,FlowGraphNegBlock:()=>LO,FlowGraphNormalizeBlock:()=>SD,FlowGraphPauseAnimationBlock:()=>KM,FlowGraphPiBlock:()=>AO,FlowGraphPlayAnimationBlock:()=>jM,FlowGraphPowBlock:()=>TD,FlowGraphRadToDegBlock:()=>tD,FlowGraphRandomBlock:()=>EO,FlowGraphReceiveCustomEventBlock:()=>GD,FlowGraphRemainderBlock:()=>BO,FlowGraphRotate2DBlock:()=>AD,FlowGraphRotate3DBlock:()=>CD,FlowGraphSaturateBlock:()=>HO,FlowGraphSceneReadyEventBlock:()=>kD,FlowGraphSceneTickEventBlock:()=>zD,FlowGraphSendCustomEventBlock:()=>DM,FlowGraphSequenceBlock:()=>XM,FlowGraphSetPropertyBlock:()=>OM,FlowGraphSetVariableBlock:()=>PM,FlowGraphSignBlock:()=>MO,FlowGraphSignalConnection:()=>_M,FlowGraphSinBlock:()=>iD,FlowGraphSinhBlock:()=>cD,FlowGraphSqrtBlock:()=>yD,FlowGraphState:()=>TM,FlowGraphStopAnimationBlock:()=>YM,FlowGraphSubtractBlock:()=>yO,FlowGraphSwitchBlock:()=>VM,FlowGraphTanBlock:()=>nD,FlowGraphTanhBlock:()=>hD,FlowGraphThrottleBlock:()=>wM,FlowGraphTimerBlock:()=>BM,FlowGraphTransposeBlock:()=>RD,FlowGraphTruncBlock:()=>OO,FlowGraphWaitAllBlock:()=>kM,FlowGraphWhileLoopBlock:()=>zM,FluidRenderer:()=>wR,FluidRendererSceneComponent:()=>LR,FluidRenderingDebug:()=>SR,FluidRenderingObject:()=>AR,FluidRenderingObjectCustomParticles:()=>MR,FluidRenderingObjectParticleSystem:()=>CR,FluidRenderingTargetRenderer:()=>IR,FlyCamera:()=>wc,FlyCameraInputsManager:()=>Lc,FlyCameraKeyboardInput:()=>fc,FlyCameraMouseInput:()=>_c,FogBlock:()=>fb,FollowBehavior:()=>Es,FollowCamera:()=>kc,FollowCameraInputsManager:()=>Bc,FollowCameraKeyboardMoveInput:()=>mc,FollowCameraMouseWheelInput:()=>gc,FollowCameraPointersInput:()=>vc,FragCoordBlock:()=>ab,FragDepthBlock:()=>hb,FragmentOutputBlock:()=>qs,FramingBehavior:()=>ss,FreeCamera:()=>Oc,FreeCameraDeviceOrientationInput:()=>Ac,FreeCameraGamepadInput:()=>Rc,FreeCameraInputsManager:()=>xc,FreeCameraKeyboardMoveInput:()=>yc,FreeCameraMouseInput:()=>Tc,FreeCameraMouseWheelInput:()=>Ec,FreeCameraTouchInput:()=>Sc,FreeCameraVirtualJoystickInput:()=>Ic,FresnelBlock:()=>kb,FresnelParameters:()=>$v,FromHalfFloat:()=>Ip,FrontFace:()=>kf,FrontFacingBlock:()=>nb,Frustum:()=>ln,FxaaPostProcess:()=>DC,GIRSM:()=>kR,GIRSMManager:()=>GR,GIRSMRenderPluginMaterial:()=>WR,GPUParticleSystem:()=>sA,GUID:()=>qi,Gamepad:()=>ac,GamepadCamera:()=>Qc,GamepadManager:()=>jc,GamepadSystemSceneComponent:()=>Yc,GaussianSplattingMaterial:()=>aE,GaussianSplattingMesh:()=>Px,GenerateBase64StringFromPixelData:()=>Ka,GenerateBase64StringFromTexture:()=>Qa,GenerateBase64StringFromTextureAsync:()=>qa,GenericPad:()=>sc,GeodesicData:()=>Kd,Geometry:()=>vo,GeometryArcTan2Block:()=>ux,GeometryBufferRenderer:()=>BC,GeometryBufferRendererSceneComponent:()=>VC,GeometryClampBlock:()=>gx,GeometryCollectionBlock:()=>IS,GeometryCrossBlock:()=>yx,GeometryCurveBlock:()=>bx,GeometryCurveBlockTypes:()=>vx,GeometryDesaturateBlock:()=>Tx,GeometryDistanceBlock:()=>xx,GeometryDotBlock:()=>Ax,GeometryElbowBlock:()=>MS,GeometryInfoBlock:()=>ex,GeometryInputBlock:()=>tS,GeometryLengthBlock:()=>Cx,GeometryLerpBlock:()=>hx,GeometryModBlock:()=>_x,GeometryNLerpBlock:()=>dx,GeometryOptimizeBlock:()=>nS,GeometryOutputBlock:()=>$E,GeometryPosterizeBlock:()=>Ex,GeometryPowBlock:()=>mx,GeometryReplaceColorBlock:()=>Sx,GeometryRotate2dBlock:()=>Rx,GeometrySmoothStepBlock:()=>fx,GeometryStepBlock:()=>px,GeometryTextureBlock:()=>ox,GeometryTextureFetchBlock:()=>ax,GeometryTransformBlock:()=>BS,GeometryTrigonometryBlock:()=>wS,GeometryTrigonometryBlockOperations:()=>FS,GetClass:()=>s,GetClassName:()=>l,GetDOMTextContent:()=>dt,GetEnvInfo:()=>Vp,GetEnvironmentBRDFTexture:()=>km,GetFogState:()=>ha,GetFontOffset:()=>xo,GetInternalFormatFromBasisFormat:()=>My,GetPointsCount:()=>YE,GetTGAHeader:()=>by,GetTextureDataAsync:()=>Op,Gizmo:()=>Oh,GizmoAnchorPoint:()=>Rh,GizmoCoordinatesMode:()=>Ph,GizmoManager:()=>Sm,GlowLayer:()=>nv,GoldbergMesh:()=>qd,GradientBlock:()=>iT,GradientBlockColorStep:()=>tT,GradientHelper:()=>Kx,GrainPostProcess:()=>NC,GreasedLineBaseMesh:()=>BE,GreasedLineMaterialDefaults:()=>qT,GreasedLineMesh:()=>UE,GreasedLineMeshColorDistribution:()=>VE,GreasedLineMeshColorDistributionType:()=>BT,GreasedLineMeshColorMode:()=>wT,GreasedLineMeshMaterialType:()=>LT,GreasedLineMeshWidthDistribution:()=>kE,GreasedLinePluginMaterial:()=>$T,GreasedLineRibbonAutoDirectionMode:()=>LE,GreasedLineRibbonFacesMode:()=>FE,GreasedLineRibbonMesh:()=>HE,GreasedLineRibbonPointsMode:()=>NE,GreasedLineSimpleMaterial:()=>tE,GreasedLineTools:()=>ZT,GridBlock:()=>cS,GroundBuilder:()=>oh,GroundMesh:()=>Ju,HDRCubeTexture:()=>Pv,HDRCubeTextureAssetTask:()=>rP,HDRFiltering:()=>Rv,HDRTools:()=>Cv,Halton2DSequence:()=>cE,HandConstraintBehavior:()=>ql,HandConstraintOrientation:()=>Wl,HandConstraintVisibility:()=>Hl,HandConstraintZone:()=>zl,HandPart:()=>Vl,HandleFallbacksForShadows:()=>ua,HardwareScalingOptimization:()=>dP,HavokPlugin:()=>iC,HeightToNormalBlock:()=>ub,HemisphereBuilder:()=>Rm,HemisphericLight:()=>Ch,HemisphericParticleEmitter:()=>wx,HighlightLayer:()=>av,HighlightsPostProcess:()=>FC,Hinge2Joint:()=>Ms,HingeConstraint:()=>WA,HingeJoint:()=>Is,HtmlElementTexture:()=>sy,IWebXRControllerPhysicsOptions:()=>lI,IcoSphereBlock:()=>sS,IcoSphereBuilder:()=>Gl,ImageAssetTask:()=>eP,ImageProcessingBlock:()=>eb,ImageProcessingConfiguration:()=>pr,ImageProcessingPostProcess:()=>LC,ImageSourceBlock:()=>mb,IncrementValueAction:()=>ue,IndexFormat:()=>jf,InputBlock:()=>rl,InspectableType:()=>FP,InstancedLinesMesh:()=>ud,InstancedMesh:()=>La,InstancesBlock:()=>Zy,InstantiateBlock:()=>KS,InstantiateLinearBlock:()=>QS,InstantiateOnFacesBlock:()=>XS,InstantiateOnVerticesBlock:()=>HS,InstantiateOnVolumeBlock:()=>jS,InstantiateRadialBlock:()=>qS,InstantiatedEntries:()=>Ua,IntFloatConverterBlock:()=>ZS,InternalTexture:()=>Pi,InternalTextureSource:()=>Ti,InterpolateValueAction:()=>st,IntersectionInfo:()=>eo,IsBase64DataUrl:()=>zi,IsDocumentAvailable:()=>ht,IsFileURL:()=>Gi,IsNavigatorAvailable:()=>ut,IsWindowObjectExist:()=>ct,IsWrapper:()=>fr,JoystickAxis:()=>Cc,KeepAssets:()=>Ba,KeyboardEventTypes:()=>Xr,KeyboardInfo:()=>jr,KeyboardInfoPre:()=>Yr,KhronosTextureContainer:()=>gg,KhronosTextureContainer2:()=>Sg,LatheBuilder:()=>Md,Layer:()=>lv,LayerSceneComponent:()=>sv,LengthBlock:()=>Hb,LensFlare:()=>cv,LensFlareSystem:()=>uv,LensFlareSystemSceneComponent:()=>hv,LensFlaresOptimization:()=>_P,LensRenderingPipeline:()=>YC,LerpBlock:()=>Fb,Light:()=>wa,LightBlock:()=>_b,LightGizmo:()=>Im,LightInformationBlock:()=>$y,LineEdgesRenderer:()=>mR,LinesBuilder:()=>md,LinesMesh:()=>cd,LoadFile:()=>Vi,LoadFileError:()=>Di,LoadImage:()=>Bi,LoadOp:()=>Zf,LoadTextureFromTranscodeResult:()=>By,LockConstraint:()=>XA,Logger:()=>ae,MapMode:()=>Tf,MapRangeBlock:()=>SS,MappingBlock:()=>tx,MappingTypes:()=>$S,Material:()=>Ca,MaterialAnisotropicDefines:()=>Km,MaterialClearCoatDefines:()=>Hm,MaterialDefines:()=>Gs,MaterialDetailMapDefines:()=>Fu,MaterialFlags:()=>xu,MaterialGreasedLineDefines:()=>JT,MaterialHelper:()=>ey,MaterialIridescenceDefines:()=>jm,MaterialPluginBase:()=>Nu,MaterialPluginEvent:()=>Vo,MaterialPluginManager:()=>Cu,MaterialSheenDefines:()=>qm,MaterialSubSurfaceDefines:()=>Jm,MathBlock:()=>TS,MathBlockOperations:()=>yS,Matrix:()=>z,MatrixBuilderBlock:()=>ET,MatrixComposeBlock:()=>ix,MatrixDeterminantBlock:()=>IT,MatrixTransposeBlock:()=>OT,MaxBlock:()=>Gb,MergeGeometryBlock:()=>PS,MergeMeshesOptimization:()=>yP,Mesh:()=>Fa,MeshAssetTask:()=>qR,MeshAttributeExistsBlock:()=>NT,MeshAttributeExistsBlockTypes:()=>MT,MeshBlock:()=>aS,MeshBuilder:()=>rp,MeshDebugMode:()=>eE,MeshDebugPluginMaterial:()=>nE,MeshExploder:()=>sP,MeshLODLevel:()=>Pa,MeshParticleEmitter:()=>Gx,MeshUVSpaceRenderer:()=>SE,MeshoptCompression:()=>mE,MinBlock:()=>zb,MinMaxReducer:()=>fv,MipmapFilterMode:()=>If,MirrorTexture:()=>Dm,ModBlock:()=>bT,ModelShape:()=>dA,MorphTarget:()=>Iv,MorphTargetManager:()=>Ov,MorphTargetsBlock:()=>Jy,MotionBlurPostProcess:()=>kC,MotorEnabledJoint:()=>Ps,MultiMaterial:()=>Ra,MultiObserver:()=>cP,MultiPointerScaleBehavior:()=>vs,MultiRenderTarget:()=>ky,MultiplyBlock:()=>ml,NLerpBlock:()=>rT,NativeDataStream:()=>gp,NativeEngine:()=>mf,NativePointerInput:()=>Ar,NativeXRFrame:()=>jI,NativeXRLayerRenderTargetTextureProvider:()=>Qu,NativeXRLayerWrapper:()=>Ku,NativeXRRenderTarget:()=>qu,NegateBlock:()=>Xb,Node:()=>qe,NodeGeometry:()=>rS,NodeGeometryBlock:()=>JE,NodeGeometryBlockConnectionPointTypes:()=>GE,NodeGeometryBuildState:()=>eS,NodeGeometryConnectionPoint:()=>ZE,NodeGeometryConnectionPointCompatibilityStates:()=>zE,NodeGeometryConnectionPointDirection:()=>WE,NodeGeometryContextualSources:()=>qE,NodeMaterial:()=>Ll,NodeMaterialBlock:()=>Ws,NodeMaterialBlockConnectionPointMode:()=>Ks,NodeMaterialBlockConnectionPointTypes:()=>Ns,NodeMaterialBlockTargets:()=>Fs,NodeMaterialConnectionPoint:()=>zs,NodeMaterialConnectionPointCompatibilityStates:()=>Bs,NodeMaterialConnectionPointCustomObject:()=>Qy,NodeMaterialConnectionPointDirection:()=>Us,NodeMaterialDefines:()=>Fl,NodeMaterialModes:()=>fl,NodeMaterialOptimizer:()=>UT,NodeMaterialSystemValues:()=>Qs,NodeMaterialTeleportInBlock:()=>Sb,NodeMaterialTeleportOutBlock:()=>xb,NoiseBlock:()=>RS,NoiseProceduralTexture:()=>Hy,NormalBlendBlock:()=>aT,NormalizeBlock:()=>Ob,NormalizeVectorBlock:()=>NS,NullBlock:()=>fS,NullEngine:()=>cp,NullEngineOptions:()=>lp,Observable:()=>f,Observer:()=>p,OcclusionMaterial:()=>ty,Octree:()=>Th,OctreeBlock:()=>bh,OctreeSceneComponent:()=>Eh,OimoJSPlugin:()=>wv,OnAfterEnteringVRObservableEvent:()=>hh,OneMinusBlock:()=>Ub,Orientation:()=>vn,OutlineRenderer:()=>xR,PBRAnisotropicConfiguration:()=>Qm,PBRBaseMaterial:()=>ig,PBRBaseSimpleMaterial:()=>iy,PBRClearCoatConfiguration:()=>Xm,PBRIridescenceConfiguration:()=>Ym,PBRMaterial:()=>rg,PBRMaterialDefines:()=>tg,PBRMetallicRoughnessBlock:()=>yT,PBRMetallicRoughnessMaterial:()=>ry,PBRSheenConfiguration:()=>Zm,PBRSpecularGlossinessMaterial:()=>ny,PBRSubSurfaceConfiguration:()=>$m,PHI:()=>x,PadNumber:()=>Rt,PanoramaToCubeMapTools:()=>Av,Particle:()=>Qx,ParticleBlendMultiplyBlock:()=>sl,ParticleHelper:()=>cA,ParticleRampGradientBlock:()=>al,ParticleSystem:()=>aA,ParticleSystemSet:()=>lA,ParticleTextureBlock:()=>ol,ParticlesOptimization:()=>gP,PassCubePostProcess:()=>Zc,PassPostProcess:()=>qc,Path2:()=>xn,Path3D:()=>An,PathCursor:()=>Wn,PerfCollectionStrategy:()=>eI,PerfCounter:()=>an,PerformanceConfigurator:()=>I,PerformanceMonitor:()=>yo,PerformanceViewerCollector:()=>JP,PerturbNormalBlock:()=>ib,PhotoDome:()=>Um,Physics6DoFConstraint:()=>kA,Physics6DoFLimit:()=>VA,PhysicsActivationControl:()=>CA,PhysicsAggregate:()=>KA,PhysicsBody:()=>IA,PhysicsConstraint:()=>UA,PhysicsConstraintAxis:()=>bA,PhysicsConstraintAxisLimitMode:()=>yA,PhysicsConstraintMotorType:()=>SA,PhysicsConstraintType:()=>TA,PhysicsEngine:()=>Fv,PhysicsEngineV2:()=>RA,PhysicsEventType:()=>xA,PhysicsHelper:()=>sC,PhysicsImpostor:()=>Ds,PhysicsJoint:()=>Cs,PhysicsMaterialCombineMode:()=>PA,PhysicsMotionType:()=>AA,PhysicsRadialExplosionEventOptions:()=>dC,PhysicsRadialImpulseFalloff:()=>nC,PhysicsRaycastResult:()=>Nv,PhysicsShape:()=>MA,PhysicsShapeBox:()=>FA,PhysicsShapeCapsule:()=>DA,PhysicsShapeContainer:()=>BA,PhysicsShapeConvexHull:()=>LA,PhysicsShapeCylinder:()=>NA,PhysicsShapeMesh:()=>wA,PhysicsShapeSphere:()=>OA,PhysicsShapeType:()=>EA,PhysicsUpdraftEventOptions:()=>pC,PhysicsUpdraftMode:()=>oC,PhysicsViewer:()=>np,PhysicsVortexEventOptions:()=>fC,PickingInfo:()=>Fr,PipelineErrorReason:()=>Bf,PivotTools:()=>ds,Plane:()=>sn,PlaneBlock:()=>oS,PlaneBuilder:()=>_s,PlaneDragGizmo:()=>bm,PlaneRotationGizmo:()=>vm,PlayAnimationAction:()=>he,PlaySoundAction:()=>Te,PointColor:()=>uA,PointLight:()=>Sv,PointParticleEmitter:()=>Bx,PointerDragBehavior:()=>gs,PointerEventTypes:()=>Gr,PointerInfo:()=>Hr,PointerInfoBase:()=>zr,PointerInfoPre:()=>Wr,PointerInput:()=>xr,PointsCloudSystem:()=>vA,PointsGroup:()=>gA,Polar:()=>sE,Polygon:()=>yd,PolygonBuilder:()=>xd,PolygonMeshBuilder:()=>bd,PolyhedronBuilder:()=>Ld,PolyhedronData:()=>Yd,PositionGizmo:()=>Tm,PositionNormalTextureVertex:()=>$s,PositionNormalVertex:()=>Js,PostProcess:()=>hl,PostProcessManager:()=>Lr,PostProcessRenderEffect:()=>vC,PostProcessRenderPipeline:()=>WC,PostProcessRenderPipelineManager:()=>HC,PostProcessRenderPipelineManagerSceneComponent:()=>XC,PostProcessesOptimization:()=>fP,PosterizeBlock:()=>$b,PowBlock:()=>jb,PowerEase:()=>Fn,PowerPreference:()=>gf,PrePassOutputBlock:()=>pb,PrePassRenderer:()=>vR,PrePassRendererSceneComponent:()=>yR,PrePassTextureBlock:()=>Eb,PrecisionDate:()=>_t,PredicateCondition:()=>ne,PrepareAttributesForBakedVertexAnimation:()=>ra,PrepareAttributesForBones:()=>la,PrepareAttributesForInstances:()=>ca,PrepareAttributesForMorphTargets:()=>Zo,PrepareAttributesForMorphTargetsInfluencers:()=>qo,PrepareDefinesForAttributes:()=>ya,PrepareDefinesForBakedVertexAnimation:()=>va,PrepareDefinesForBones:()=>ma,PrepareDefinesForCamera:()=>Sa,PrepareDefinesForFrameBoundValues:()=>_a,PrepareDefinesForLight:()=>fa,PrepareDefinesForLights:()=>pa,PrepareDefinesForMergedUV:()=>ta,PrepareDefinesForMisc:()=>da,PrepareDefinesForMorphTargets:()=>ga,PrepareDefinesForMultiview:()=>ba,PrepareDefinesForOIT:()=>Ta,PrepareDefinesForPrePass:()=>Ea,PrepareUniformsAndSamplersForLight:()=>xa,PrepareUniformsAndSamplersList:()=>Aa,PressureObserverWrapper:()=>jP,PrimitiveTopology:()=>Vf,PrismaticConstraint:()=>jA,ProceduralTexture:()=>Ol,ProceduralTextureSceneComponent:()=>Il,PropertyTypeForEdition:()=>Xs,ProximityCastResult:()=>_C,PushAttributesForInstances:()=>Jo,PushMaterial:()=>ws,QuadraticEase:()=>Ln,QuadraticErrorSimplification:()=>DE,QuarticEase:()=>wn,Quaternion:()=>G,QueryType:()=>$f,QueueNewFrame:()=>Ii,QuinticEase:()=>Bn,RGBDTextureTools:()=>Np,RSMCreatePluginMaterial:()=>VR,Ragdoll:()=>qA,RagdollBoneProperties:()=>QA,RandomBlock:()=>CS,RandomBlockLocks:()=>xS,RandomGUID:()=>Qi,RandomNumberBlock:()=>Yb,RawCubeTexture:()=>Xy,RawTexture:()=>is,RawTexture2DArray:()=>Mv,RawTexture3D:()=>jy,Ray:()=>hs,RayHelper:()=>op,ReadFile:()=>Ui,ReadFileError:()=>Fi,RecastJSCrowd:()=>Mx,RecastJSPlugin:()=>Ix,ReciprocalBlock:()=>qb,ReflectBlock:()=>lT,ReflectionBlock:()=>pT,ReflectionProbe:()=>Uv,ReflectionTextureBaseBlock:()=>vb,ReflectionTextureBlock:()=>yb,ReflectiveShadowMap:()=>BR,Reflector:()=>XP,RefractBlock:()=>cT,RefractionBlock:()=>mT,RefractionPostProcess:()=>GC,RefractionTexture:()=>Yy,RegisterClass:()=>a,RegisterMaterialPlugin:()=>Mu,RegisterNativeTypeAsync:()=>pf,RemapBlock:()=>pl,RenderPassTimestampLocation:()=>qf,RenderTargetTexture:()=>Pl,RenderTargetWrapper:()=>cl,RenderTargetsOptimization:()=>vP,RenderingGroup:()=>wr,RenderingGroupInfo:()=>Br,RenderingManager:()=>Ur,ReplaceColorBlock:()=>Zb,RequestFile:()=>ki,RequestFileError:()=>Ni,RequestFullscreen:()=>Ro,RequestPointerlock:()=>Io,ResizeImageBitmap:()=>Co,RetryStrategy:()=>gt,RibbonBuilder:()=>Kh,RichType:()=>QI,RichTypeAny:()=>qI,RichTypeBoolean:()=>$I,RichTypeColor3:()=>nM,RichTypeColor4:()=>oM,RichTypeFlowGraphInteger:()=>sM,RichTypeMatrix:()=>rM,RichTypeNumber:()=>JI,RichTypeQuaternion:()=>aM,RichTypeString:()=>ZI,RichTypeVector2:()=>eM,RichTypeVector3:()=>tM,RichTypeVector4:()=>iM,RollingAverage:()=>bo,Rotate2dBlock:()=>sT,RotationGizmo:()=>ym,RotationXBlock:()=>US,RotationYBlock:()=>VS,RotationZBlock:()=>kS,RuntimeAnimation:()=>lt,RuntimeError:()=>bt,SSAO2RenderingPipeline:()=>QC,SSAORenderingPipeline:()=>qC,SSRRenderingPipeline:()=>rR,SamplerBindingType:()=>Nf,Scalar:()=>j,ScaleBlock:()=>Cb,ScaleGizmo:()=>Em,ScalingBlock:()=>GS,Scene:()=>pn,SceneComponentConstants:()=>Vr,SceneDepthBlock:()=>bb,SceneInstrumentation:()=>tv,SceneLoader:()=>Ls,SceneLoaderAnimationGroupLoadingMode:()=>Os,SceneLoaderFlags:()=>mo,SceneOptimization:()=>uP,SceneOptimizer:()=>TP,SceneOptimizerOptions:()=>bP,ScenePerformancePriority:()=>Kr,SceneRecorder:()=>VP,SceneSerializer:()=>AP,ScreenSizeBlock:()=>sb,ScreenSpaceBlock:()=>lb,ScreenSpaceCurvaturePostProcess:()=>lR,ScreenSpaceReflectionPostProcess:()=>JC,ScreenshotTools:()=>LP,SerializationHelper:()=>Ke,SetBasisTranscoderWorker:()=>Fy,SetColorsBlock:()=>vS,SetCorsBehavior:()=>wi,SetMaterialIDBlock:()=>LS,SetNormalsBlock:()=>mS,SetParentAction:()=>me,SetPositionsBlock:()=>_S,SetStateAction:()=>le,SetTangentsBlock:()=>bS,SetUVsBlock:()=>gS,SetValueAction:()=>ce,ShaderCodeInliner:()=>tf,ShaderLanguage:()=>pt,ShaderMaterial:()=>ld,ShaderStage:()=>Of,ShaderStore:()=>li,ShadowDepthWrapper:()=>kT,ShadowGenerator:()=>dv,ShadowGeneratorSceneComponent:()=>Ev,ShadowLight:()=>xm,ShadowMapBlock:()=>db,ShadowsOptimization:()=>pP,ShapeBuilder:()=>Pd,ShapeCastResult:()=>mC,SharpenPostProcess:()=>zC,SheenBlock:()=>hT,SimplexPerlin3DBlock:()=>oT,SimplicationQueueSceneComponent:()=>wE,SimplificationQueue:()=>RE,SimplificationSettings:()=>CE,SimplificationType:()=>xE,SineEase:()=>Un,SixDofDragBehavior:()=>bs,Size:()=>Ze,Skeleton:()=>rs,SkeletonViewer:()=>ap,SliderConstraint:()=>HA,SmartArray:()=>ar,SmartArrayNoDuplicate:()=>sr,SmoothStepBlock:()=>Qb,SolidParticle:()=>hA,SolidParticleSystem:()=>_A,SolidParticleVertex:()=>fA,Sound:()=>Ga,SoundTrack:()=>za,SourceTextureFormat:()=>fg,Space:()=>dn,SphereBlock:()=>lS,SphereBuilder:()=>zh,SphereDirectedParticleEmitter:()=>Vx,SphereParticleEmitter:()=>Ux,Spherical:()=>lE,SphericalHarmonics:()=>Ep,SphericalPolynomial:()=>Sp,SpotLight:()=>Pm,SpringConstraint:()=>YA,Sprite:()=>Vv,SpriteManager:()=>zv,SpriteMap:()=>XR,SpritePackedManager:()=>jR,SpriteSceneComponent:()=>kv,Stage:()=>kr,StandardMaterial:()=>Uu,StandardMaterialDefines:()=>Bu,StandardRenderingPipeline:()=>$C,StartsWith:()=>Et,StateCondition:()=>oe,StencilOperation:()=>Xf,StencilState:()=>Ai,StencilStateComposer:()=>xi,StepBlock:()=>Bb,StereoscopicArcRotateCamera:()=>su,StereoscopicFreeCamera:()=>lu,StereoscopicGamepadCamera:()=>cu,StereoscopicInterlacePostProcess:()=>ou,StereoscopicInterlacePostProcessI:()=>nu,StereoscopicScreenUniversalCamera:()=>hu,StereoscopicUniversalCamera:()=>uu,StickValues:()=>oc,StopAnimationAction:()=>de,StopSoundAction:()=>Ee,StorageBuffer:()=>$l,StorageTextureAccess:()=>Lf,StoreOp:()=>Jf,StringDictionary:()=>lr,StringTools:()=>Pt,SubEmitter:()=>Jx,SubEmitterType:()=>qx,SubMesh:()=>po,SubSurfaceBlock:()=>gT,SubSurfaceSceneComponent:()=>ER,SubtractBlock:()=>wb,SurfaceMagnetismBehavior:()=>Ts,SwitchBooleanAction:()=>se,SwitchInput:()=>Ir,TAARenderingPipeline:()=>nR,TBNBlock:()=>tb,TGATools:()=>Ey,Tags:()=>je,TargetCamera:()=>Mc,TargetedAnimation:()=>Gn,TeleportInBlock:()=>rx,TeleportOutBlock:()=>nx,TestBase64DataUrl:()=>Wi,TextFileAssetTask:()=>JR,Texture:()=>Ja,TextureAspect:()=>Af,TextureAssetTask:()=>tP,TextureBlock:()=>gb,TextureDimension:()=>Ef,TextureFormat:()=>Cf,TextureOptimization:()=>hP,TexturePacker:()=>zy,TexturePackerFrame:()=>Gy,TextureSampleType:()=>Ff,TextureSampler:()=>Ri,TextureTools:()=>Dp,TextureUsage:()=>Sf,TextureViewDimension:()=>xf,ThinEngine:()=>Er,ThinRenderTargetTexture:()=>Ky,ThinTexture:()=>ja,TiledBoxBuilder:()=>rd,TiledPlaneBuilder:()=>ed,TimerState:()=>Gg,TmpColors:()=>$,TmpVectors:()=>H,ToGammaSpace:()=>E,ToHalfFloat:()=>Pp,ToLinearSpace:()=>S,TonemapPostProcess:()=>aR,TonemappingOperator:()=>oR,Tools:()=>rr,TorusBlock:()=>uS,TorusBuilder:()=>lh,TorusKnotBuilder:()=>ad,TouchCamera:()=>Dc,TrailMesh:()=>AE,Trajectory:()=>kP,TrajectoryClassifier:()=>HP,TranscodeAsync:()=>Ly,TranscodeTarget:()=>_g,TransformBlock:()=>Hs,TransformNode:()=>Fo,TranslationBlock:()=>WS,TriPlanarBlock:()=>RT,TrigonometryBlock:()=>Dl,TrigonometryBlockOperations:()=>Ml,TubeBuilder:()=>Dd,TwirlBlock:()=>cb,UniformBuffer:()=>Or,UniversalCamera:()=>Kc,UnregisterAllMaterialPlugins:()=>Du,UnregisterMaterialPlugin:()=>Ou,UploadContent:()=>Ty,UploadEnvLevelsAsync:()=>Hp,UploadEnvSpherical:()=>Yp,UploadLevelsAsync:()=>jp,UtilityLayerRenderer:()=>Ih,VRCameraMetrics:()=>pu,VRDeviceOrientationArcRotateCamera:()=>bu,VRDeviceOrientationFreeCamera:()=>Tu,VRDeviceOrientationGamepadCamera:()=>Eu,VRDistortionCorrectionPostProcess:()=>fu,VRExperienceHelper:()=>dh,VRMultiviewToSingleviewPostProcess:()=>vu,ValidatedNativeDataStream:()=>r_,ValueCondition:()=>re,Vector2:()=>U,Vector2ToFixed:()=>uE,Vector3:()=>V,Vector3ToFixed:()=>hE,Vector4:()=>k,Vector4ToFixed:()=>dE,VectorConverterBlock:()=>DS,VectorMergerBlock:()=>dl,VectorSplitterBlock:()=>Nb,VertexAnimationBaker:()=>ns,VertexBuffer:()=>Nr,VertexData:()=>_o,VertexDataMaterialInfo:()=>fo,VertexFormat:()=>Yf,VertexOutputBlock:()=>js,VertexStepMode:()=>Kf,VideoDome:()=>$g,VideoRecorder:()=>CP,VideoTexture:()=>Jg,ViewDirectionBlock:()=>Vb,Viewport:()=>Jn,VirtualJoystick:()=>Pc,VirtualJoysticksCamera:()=>du,VolumetricLightScatteringPostProcess:()=>sR,VoronoiNoiseBlock:()=>AT,WaveBlock:()=>eT,WaveBlockKind:()=>Jb,WebGL2ParticleSystem:()=>Wx,WebGL2ShaderProcessor:()=>gr,WebGLDataBuffer:()=>yr,WebGLHardwareTexture:()=>br,WebGLPipelineContext:()=>ci,WebGPUCacheBindGroups:()=>k_,WebGPUCacheRenderPipeline:()=>O_,WebGPUCacheRenderPipelineTree:()=>N_,WebGPUCacheSampler:()=>R_,WebGPUDataBuffer:()=>E_,WebGPUDrawContext:()=>U_,WebGPUEngine:()=>sm,WebGPURenderTargetWrapper:()=>dm,WebGPUTintWASM:()=>em,WebRequest:()=>Je,WebXRAbstractFeature:()=>As,WebXRAbstractMotionController:()=>Pg,WebXRAnchorSystem:()=>nI,WebXRBackgroundRemover:()=>sI,WebXRCamera:()=>Ag,WebXRControllerComponent:()=>Rg,WebXRControllerMovement:()=>gI,WebXRControllerPhysics:()=>cI,WebXRControllerPointerSelection:()=>Vg,WebXRDefaultExperience:()=>Qg,WebXRDefaultExperienceOptions:()=>Kg,WebXRDepthSensing:()=>DI,WebXRDomOverlay:()=>mI,WebXREnterExitUI:()=>Hg,WebXREnterExitUIButton:()=>zg,WebXREnterExitUIOptions:()=>Wg,WebXRExperienceHelper:()=>Cg,WebXREyeTracking:()=>yI,WebXRFeatureName:()=>Ss,WebXRFeaturePointSystem:()=>hI,WebXRFeaturesManager:()=>xs,WebXRGenericHandController:()=>BI,WebXRGenericTriggerMotionController:()=>Ig,WebXRHTCViveMotionController:()=>WI,WebXRHand:()=>Yl,WebXRHandJoint:()=>kl,WebXRHandTracking:()=>Kl,WebXRHitTest:()=>uI,WebXRHitTestLegacy:()=>iI,WebXRImageTracking:()=>_I,WebXRInput:()=>Ug,WebXRInputSource:()=>Bg,WebXRLayerRenderTargetTextureProvider:()=>Wu,WebXRLayers:()=>OI,WebXRLightEstimation:()=>vI,WebXRManagedOutputCanvas:()=>Yu,WebXRManagedOutputCanvasOptions:()=>ju,WebXRMeshDetector:()=>fI,WebXRMicrosoftMixedRealityController:()=>VI,WebXRMotionControllerManager:()=>Ng,WebXRMotionControllerTeleportation:()=>Yg,WebXRNearControllerMode:()=>Lg,WebXRNearInteraction:()=>kg,WebXROculusTouchMotionController:()=>GI,WebXRPlaneDetector:()=>aI,WebXRProfiledMotionController:()=>Og,WebXRRawCameraAccess:()=>wI,WebXRSessionManager:()=>Zu,WebXRSpaceWarp:()=>LI,WebXRSpaceWarpRenderTargetTextureProvider:()=>FI,WebXRState:()=>Vu,WebXRTrackingState:()=>ku,WebXRWalkingLocomotion:()=>xI,WeightedSound:()=>Ha,WorkerPool:()=>vg,WorleyNoise3DBlock:()=>nT,XRSpaceWarpRenderTarget:()=>NI,Xbox360Button:()=>Uc,Xbox360Dpad:()=>Vc,Xbox360Pad:()=>Hc,XboxInput:()=>Pr,_BabylonLoaderRegistered:()=>Wv,_BasisTextureLoader:()=>Vy,_CommonDispose:()=>So,_CommonInit:()=>Eo,_CreationDataStorage:()=>Ia,_DDSTextureLoader:()=>dg,_ENVTextureLoader:()=>pg,_HDRTextureLoader:()=>xy,_InstancesBatch:()=>Oa,_KTXTextureLoader:()=>xg,_MeshCollisionData:()=>Lo,_OcclusionDataStorage:()=>up,_PrimaryIsoTriangle:()=>jd,_TGATextureLoader:()=>Sy,_TimeToken:()=>hp,_UpdateRGBDAsync:()=>Kp,_forceSceneHelpersToBundle:()=>qg,_forceTransformFeedbackToBundle:()=>dp,_injectLTSFileTools:()=>Yi,_staticOffsetValueColor3:()=>rt,_staticOffsetValueColor4:()=>nt,_staticOffsetValueQuaternion:()=>$e,_staticOffsetValueSize:()=>it,_staticOffsetValueVector2:()=>tt,_staticOffsetValueVector3:()=>et,addClipPlaneUniforms:()=>Go,allocateAndCopyTypedBuffer:()=>To,bindClipPlane:()=>Ho,captureEquirectangularFromScene:()=>tI,className:()=>nr,createDetailMapPlugin:()=>QT,createPBRAnisotropicPlugin:()=>WT,createPBRBRDFPlugin:()=>HT,createPBRClearCoatPlugin:()=>XT,createPBRIridescencePlugin:()=>jT,createPBRSheenPlugin:()=>YT,createPBRSubSurfacePlugin:()=>KT,createYieldingScheduler:()=>jn,editableInPropertyPage:()=>Ys,expandToProperty:()=>Pe,extractMinAndMax:()=>uo,extractMinAndMaxIndexed:()=>co,getRichTypeFromValue:()=>lM,inlineScheduler:()=>Xn,makeAsyncFunction:()=>Zn,makeSyncFunction:()=>qn,nativeOverride:()=>ze,normalizeEnvInfo:()=>kp,prepareDefinesForClipPlanes:()=>Wo,prepareStringDefinesForClipPlanes:()=>zo,runCoroutine:()=>Yn,runCoroutineAsync:()=>Qn,runCoroutineSync:()=>Kn,serialize:()=>Ie,serializeAsCameraReference:()=>Ge,serializeAsColor3:()=>Oe,serializeAsColor4:()=>Be,serializeAsColorCurves:()=>we,serializeAsFresnelParameters:()=>De,serializeAsImageProcessingConfiguration:()=>Ue,serializeAsMatrix:()=>ke,serializeAsMeshReference:()=>Le,serializeAsQuaternion:()=>Ve,serializeAsTexture:()=>Me,serializeAsVector2:()=>Ne,serializeAsVector3:()=>Fe,setAndStartTimer:()=>Xg,setStereoscopicAnaglyphRigMode:()=>$c,setStereoscopicRigMode:()=>au,setVRRigMode:()=>yu});var n={};e.r(n),e.d(n,{AbstractActionManager:()=>h,AbstractAssetTask:()=>YR,AbstractEngine:()=>Mi,AbstractMesh:()=>Uo,AbstractScene:()=>c,AcquireNativeObjectAsync:()=>df,Action:()=>ee,ActionEvent:()=>te,ActionManager:()=>be,AddBlock:()=>Ab,AddressMode:()=>Rf,AdvancedTimer:()=>jg,AlignBlock:()=>zS,AlphaState:()=>Ci,AmmoJSPlugin:()=>Bv,AnaglyphArcRotateCamera:()=>eu,AnaglyphFreeCamera:()=>tu,AnaglyphGamepadCamera:()=>iu,AnaglyphPostProcess:()=>Jc,AnaglyphUniversalCamera:()=>ru,Analyser:()=>ka,AndOrNotEvaluator:()=>Xe,Angle:()=>En,Animatable:()=>gn,AnimatedInputBlockTypes:()=>Zs,Animation:()=>at,AnimationAssetTask:()=>ZR,AnimationEvent:()=>kn,AnimationGroup:()=>zn,AnimationGroupMask:()=>Hn,AnimationGroupMaskMode:()=>bn,AnimationKeyInterpolation:()=>ge,AnimationPropertiesOverride:()=>yn,AnimationRange:()=>Se,AnisotropyBlock:()=>dT,ApplyPostProcess:()=>Rp,Arc2:()=>Sn,ArcFollowCamera:()=>Gc,ArcRotateCamera:()=>Nc,ArcRotateCameraGamepadInput:()=>lc,ArcRotateCameraInputsManager:()=>dc,ArcRotateCameraKeyboardMoveInput:()=>cc,ArcRotateCameraMouseWheelInput:()=>uc,ArcRotateCameraPointersInput:()=>hc,ArcRotateCameraVRDeviceOrientationInput:()=>pc,ArcTan2Block:()=>Kb,AssetContainer:()=>Va,AssetTaskState:()=>HR,AssetsManager:()=>oP,AssetsProgressEvent:()=>KR,AsyncLoop:()=>or,AttachToBoxBehavior:()=>cs,AudioEngine:()=>Oo,AudioSceneComponent:()=>Wa,AutoLayoutMode:()=>Uf,AutoReleaseWorkerPool:()=>yg,AutoRotationBehavior:()=>os,AxesViewer:()=>Nh,Axis:()=>_n,AxisDragGizmo:()=>Dh,AxisScaleGizmo:()=>mm,BRDFTextureTools:()=>Gm,BabylonFileLoaderConfiguration:()=>Hv,BackEase:()=>In,BackgroundMaterial:()=>Lm,BakedVertexAnimationManager:()=>Xa,BallAndSocketConstraint:()=>GA,BaseCameraMouseWheelInput:()=>tc,BaseCameraPointersInput:()=>ic,BaseError:()=>vt,BaseParticleSystem:()=>vl,BaseSixDofDragBehavior:()=>ys,BaseTexture:()=>Ya,BasisFileInfo:()=>Ry,BasisTools:()=>Uy,BasisToolsOptions:()=>Iy,BasisTranscodeConfiguration:()=>Py,BezierCurve:()=>Tn,BezierCurveEase:()=>Vn,BiPlanarBlock:()=>PT,BinaryFileAssetTask:()=>$R,BindBonesParameters:()=>na,BindFogParameters:()=>Qo,BindLight:()=>aa,BindLightProperties:()=>oa,BindLights:()=>sa,BindLogDepth:()=>Ko,BindMorphTargetParameters:()=>$o,BindSceneUniformBuffer:()=>ea,BindTextureMatrix:()=>ia,BlackAndWhitePostProcess:()=>gC,BlendFactor:()=>Wf,BlendOperation:()=>Hf,BloomEffect:()=>TC,BloomMergePostProcess:()=>bC,BlurPostProcess:()=>Om,Bone:()=>mn,BoneAxesViewer:()=>Fh,BoneIKController:()=>Zl,BoneLookController:()=>Jl,BonesBlock:()=>qy,BooleanGeometryBlock:()=>cx,BooleanGeometryOperations:()=>sx,BounceEase:()=>Mn,BouncingBehavior:()=>as,BoundingBlock:()=>lx,BoundingBox:()=>to,BoundingBoxGizmo:()=>gm,BoundingBoxRenderer:()=>cR,BoundingInfo:()=>so,BoundingSphere:()=>io,BoxBlock:()=>iS,BoxBuilder:()=>Vh,BoxParticleEmitter:()=>Dx,Buffer:()=>Dr,BufferBindingType:()=>Df,BufferMapState:()=>yf,BufferUsage:()=>bf,CSG:()=>EE,Camera:()=>$n,CameraGizmo:()=>Mm,CameraInputTypes:()=>rc,CameraInputsManager:()=>nc,CannonJSPlugin:()=>Lv,CanvasAlphaMode:()=>e_,CapsuleBlock:()=>dS,CapsuleBuilder:()=>Xh,CascadedShadowGenerator:()=>Tv,ChromaticAberrationPostProcess:()=>EC,CircleEase:()=>Pn,CircleOfConfusionPostProcess:()=>SC,ClampBlock:()=>Rb,ClearCoatBlock:()=>fT,ClipPlanesBlock:()=>Tb,ClipboardEventTypes:()=>fm,ClipboardInfo:()=>_m,CloudBlock:()=>xT,CloudPoint:()=>mA,Collider:()=>fh,Color3:()=>Z,Color3Gradient:()=>jx,Color4:()=>J,ColorCorrectionPostProcess:()=>xC,ColorCurves:()=>ur,ColorGradient:()=>Xx,ColorGradingTexture:()=>oy,ColorMergerBlock:()=>Db,ColorSplitterBlock:()=>yl,ColorWrite:()=>zf,CombineAction:()=>fe,CompareFunction:()=>Mf,CompatibilityOptions:()=>go,CompilationMessageType:()=>wf,CompleteGreasedLineColorTable:()=>QE,CompleteGreasedLineWidthTable:()=>KE,ComputeBindingType:()=>mh,ComputeEffect:()=>gh,ComputeNormalsBlock:()=>OS,ComputePassTimestampLocation:()=>Qf,ComputeShader:()=>yh,ComputeShaderParticleSystem:()=>Hx,Condition:()=>ie,ConditionBlock:()=>AS,ConditionBlockTests:()=>ES,ConditionalBlock:()=>ST,ConditionalBlockConditions:()=>TT,ConeParticleEmitter:()=>Nx,Constants:()=>u,ContainerAssetTask:()=>QR,ConversionMode:()=>PR,ConvolutionPostProcess:()=>AC,Coordinate:()=>fn,CopyTextureToTexture:()=>OR,CopyTools:()=>Za,CreateBox:()=>Uh,CreateBoxVertexData:()=>wh,CreateCapsule:()=>Hh,CreateCapsuleVertexData:()=>Wh,CreateCylinder:()=>xh,CreateCylinderVertexData:()=>Sh,CreateDashedLines:()=>_d,CreateDashedLinesVertexData:()=>dd,CreateDecal:()=>Wd,CreateDisc:()=>qh,CreateDiscVertexData:()=>Qh,CreateEnvTextureAsync:()=>Gp,CreateGeodesic:()=>Qd,CreateGoldberg:()=>Jd,CreateGoldbergVertexData:()=>Zd,CreateGreasedLine:()=>jE,CreateGreasedLineMaterial:()=>XE,CreateGround:()=>ih,CreateGroundFromHeightMap:()=>nh,CreateGroundFromHeightMapVertexData:()=>th,CreateGroundVertexData:()=>$u,CreateHemisphere:()=>Cm,CreateIcoSphere:()=>Bl,CreateIcoSphereVertexData:()=>wl,CreateImageBitmapFromSource:()=>Ao,CreateImageDataArrayBufferViews:()=>Wp,CreateLathe:()=>Id,CreateLineSystem:()=>pd,CreateLineSystemVertexData:()=>hd,CreateLines:()=>fd,CreatePlane:()=>fs,CreatePlaneVertexData:()=>ps,CreatePolygon:()=>Ed,CreatePolygonVertexData:()=>Td,CreatePolyhedron:()=>Fd,CreatePolyhedronVertexData:()=>Nd,CreateResizedCopy:()=>Cp,CreateRibbon:()=>Yh,CreateRibbonVertexData:()=>jh,CreateScreenshot:()=>PP,CreateScreenshotAsync:()=>IP,CreateScreenshotUsingRenderTarget:()=>OP,CreateScreenshotUsingRenderTargetAsync:()=>DP,CreateScreenshotWithResizeAsync:()=>MP,CreateSegmentedBoxVertexData:()=>Bh,CreateSphere:()=>Gh,CreateSphereVertexData:()=>kh,CreateText:()=>ip,CreateTextShapePaths:()=>tp,CreateTiledBox:()=>id,CreateTiledBoxVertexData:()=>td,CreateTiledGround:()=>rh,CreateTiledGroundVertexData:()=>eh,CreateTiledPlane:()=>$h,CreateTiledPlaneVertexData:()=>Jh,CreateTorus:()=>sh,CreateTorusKnot:()=>od,CreateTorusKnotVertexData:()=>nd,CreateTorusVertexData:()=>ah,CreateTube:()=>Od,CrossBlock:()=>Pb,CubeMapToSphericalPolynomialTools:()=>Lp,CubeTexture:()=>Nm,CubeTextureAssetTask:()=>iP,CubicEase:()=>On,CullMode:()=>Gf,CurrentScreenBlock:()=>nl,Curve3:()=>Cn,CurveBlock:()=>FT,CurveBlockTypes:()=>DT,CustomBlock:()=>Ib,CustomOptimization:()=>mP,CustomParticleEmitter:()=>kx,CustomProceduralTexture:()=>Wy,CylinderBlock:()=>hS,CylinderBuilder:()=>Ah,CylinderDirectedParticleEmitter:()=>Lx,CylinderParticleEmitter:()=>Fx,DDSTools:()=>hg,DataBuffer:()=>vr,DataReader:()=>BP,DataStorage:()=>UP,Database:()=>Ox,Debug:()=>jD,DebugBlock:()=>JS,DebugLayer:()=>Lh,DebugLayerTab:()=>Mh,DecalBuilder:()=>Hd,DecalMapConfiguration:()=>zT,DecalMapDefines:()=>GT,Decode:()=>St,DecodeBase64ToBinary:()=>Ct,DecodeBase64ToString:()=>At,DecodeBase64UrlToBinary:()=>Hi,DecodeBase64UrlToString:()=>ji,DeepCopier:()=>ye,DefaultCollisionCoordinator:()=>_h,DefaultKTX2DecoderOptions:()=>Eg,DefaultLoadingScreen:()=>xv,DefaultRenderingPipeline:()=>jC,Deferred:()=>aP,DepthCullingState:()=>Si,DepthOfFieldBlurPostProcess:()=>CC,DepthOfFieldEffect:()=>IC,DepthOfFieldEffectBlurLevel:()=>RC,DepthOfFieldMergePostProcess:()=>PC,DepthPeelingRenderer:()=>dR,DepthPeelingSceneComponent:()=>pR,DepthReducer:()=>_v,DepthRenderer:()=>pv,DepthRendererSceneComponent:()=>uR,DepthSortedParticle:()=>pA,DerivativeBlock:()=>ob,DesaturateBlock:()=>uT,DetailMapConfiguration:()=>Lu,DeviceInputEventType:()=>Mr,DeviceLostReason:()=>t_,DeviceOrientationCamera:()=>Fc,DeviceSource:()=>en,DeviceSourceManager:()=>rn,DeviceType:()=>Sr,DirectionalLight:()=>Am,DirectionalLightFrustumViewer:()=>sp,DiscBlock:()=>pS,DiscBuilder:()=>Zh,DiscardBlock:()=>rb,DisplayPassPostProcess:()=>MC,DistanceBlock:()=>Wb,DistanceConstraint:()=>zA,DistanceJoint:()=>Rs,DivideBlock:()=>Lb,DoNothingAction:()=>pe,DomManagement:()=>ft,DotBlock:()=>Mb,DracoCompression:()=>_E,DrawWrapper:()=>ho,DualSenseInput:()=>Rr,DualShockButton:()=>zc,DualShockDpad:()=>Wc,DualShockInput:()=>Cr,DualShockPad:()=>Xc,DumpTools:()=>Rl,DynamicFloat32Array:()=>YP,DynamicTexture:()=>Gu,EasingFunction:()=>Rn,EdgesRenderer:()=>_R,Effect:()=>Ei,EffectFallbacks:()=>ll,EffectLayer:()=>iv,EffectLayerSceneComponent:()=>rv,EffectRenderer:()=>Tl,EffectWrapper:()=>El,ElasticEase:()=>Dn,ElbowBlock:()=>CT,EncodeArrayBufferToBase64:()=>xt,EndsWith:()=>Tt,Engine:()=>Do,EngineFactory:()=>pm,EngineFormat:()=>mg,EngineInstrumentation:()=>ev,EngineStore:()=>M,EngineView:()=>pp,EnvironmentHelper:()=>wm,EnvironmentTextureTools:()=>Qp,Epsilon:()=>A,EquiRectangularCubeTexture:()=>ay,EquiRectangularCubeTextureAssetTask:()=>nP,ErrorCodes:()=>yt,ErrorFilter:()=>i_,EventConstants:()=>Qr,EventState:()=>d,ExecuteCodeAction:()=>_e,ExitFullscreen:()=>Po,ExitPointerlock:()=>Mo,ExponentialEase:()=>Nn,ExternalTexture:()=>w_,ExtractHighlightsPostProcess:()=>yC,ExtrudePolygon:()=>Sd,ExtrudeShape:()=>Ad,ExtrudeShapeCustom:()=>Cd,FactorGradient:()=>Yx,FadeInOutBehavior:()=>us,FeatureName:()=>vf,FileTools:()=>Xi,FileToolsOptions:()=>Li,FilesInput:()=>lP,FilesInputStore:()=>mt,FilterMode:()=>Pf,FilterPostProcess:()=>OC,FlowGraph:()=>SM,FlowGraphAbsBlock:()=>IO,FlowGraphAcosBlock:()=>aD,FlowGraphAcoshBlock:()=>pD,FlowGraphAddBlock:()=>vO,FlowGraphAsinBlock:()=>oD,FlowGraphAsinhBlock:()=>dD,FlowGraphAtan2Block:()=>lD,FlowGraphAtanBlock:()=>sD,FlowGraphAtanhBlock:()=>fD,FlowGraphBitwiseAndBlock:()=>DD,FlowGraphBitwiseLeftShiftBlock:()=>LD,FlowGraphBitwiseNotBlock:()=>OD,FlowGraphBitwiseOrBlock:()=>ND,FlowGraphBitwiseRightShiftBlock:()=>wD,FlowGraphBitwiseXorBlock:()=>FD,FlowGraphBlock:()=>fM,FlowGraphBranchBlock:()=>NM,FlowGraphCeilBlock:()=>NO,FlowGraphClampBlock:()=>zO,FlowGraphConditionalDataBlock:()=>QM,FlowGraphConnection:()=>YI,FlowGraphConnectionType:()=>HI,FlowGraphConsoleLogBlock:()=>RM,FlowGraphConstantBlock:()=>JM,FlowGraphContext:()=>yM,FlowGraphContextLogger:()=>AM,FlowGraphCoordinateTransformBlock:()=>ZM,FlowGraphCoordinator:()=>xM,FlowGraphCosBlock:()=>rD,FlowGraphCoshBlock:()=>uD,FlowGraphCountLeadingZerosBlock:()=>BD,FlowGraphCountOneBitsBlock:()=>VD,FlowGraphCountTrailingZerosBlock:()=>UD,FlowGraphCounterBlock:()=>GM,FlowGraphCrossBlock:()=>xD,FlowGraphCubeRootBlock:()=>bD,FlowGraphDataConnection:()=>cM,FlowGraphDebounceBlock:()=>WM,FlowGraphDegToRadBlock:()=>eD,FlowGraphDeterminantBlock:()=>PD,FlowGraphDivideBlock:()=>TO,FlowGraphDoNBlock:()=>FM,FlowGraphDotBlock:()=>SO,FlowGraphEBlock:()=>xO,FlowGraphEqBlock:()=>jO,FlowGraphEventBlock:()=>vM,FlowGraphExecutionBlock:()=>mM,FlowGraphExpBlock:()=>_D,FlowGraphFlipFlopBlock:()=>HM,FlowGraphFloorBlock:()=>DO,FlowGraphForLoopBlock:()=>LM,FlowGraphFractBlock:()=>FO,FlowGraphGetPropertyBlock:()=>$M,FlowGraphGetVariableBlock:()=>qM,FlowGraphGreaterThanBlock:()=>qO,FlowGraphGreaterThanOrEqualBlock:()=>ZO,FlowGraphInfBlock:()=>CO,FlowGraphInterpolateBlock:()=>XO,FlowGraphInvertMatrixBlock:()=>ID,FlowGraphIsInfBlock:()=>$O,FlowGraphIsNanBlock:()=>JO,FlowGraphLengthBlock:()=>ED,FlowGraphLessThanBlock:()=>KO,FlowGraphLessThanOrEqualBlock:()=>QO,FlowGraphLog10Block:()=>vD,FlowGraphLog2Block:()=>gD,FlowGraphLogBlock:()=>mD,FlowGraphLogicAndBlock:()=>cO,FlowGraphLogicNotBlock:()=>hO,FlowGraphLogicOrBlock:()=>uO,FlowGraphMatMulBlock:()=>MD,FlowGraphMaxBlock:()=>VO,FlowGraphMeshPickEventBlock:()=>EM,FlowGraphMinBlock:()=>UO,FlowGraphMultiGateBlock:()=>UM,FlowGraphMultiplyBlock:()=>bO,FlowGraphNaNBlock:()=>RO,FlowGraphNegBlock:()=>LO,FlowGraphNormalizeBlock:()=>SD,FlowGraphPauseAnimationBlock:()=>KM,FlowGraphPiBlock:()=>AO,FlowGraphPlayAnimationBlock:()=>jM,FlowGraphPowBlock:()=>TD,FlowGraphRadToDegBlock:()=>tD,FlowGraphRandomBlock:()=>EO,FlowGraphReceiveCustomEventBlock:()=>GD,FlowGraphRemainderBlock:()=>BO,FlowGraphRotate2DBlock:()=>AD,FlowGraphRotate3DBlock:()=>CD,FlowGraphSaturateBlock:()=>HO,FlowGraphSceneReadyEventBlock:()=>kD,FlowGraphSceneTickEventBlock:()=>zD,FlowGraphSendCustomEventBlock:()=>DM,FlowGraphSequenceBlock:()=>XM,FlowGraphSetPropertyBlock:()=>OM,FlowGraphSetVariableBlock:()=>PM,FlowGraphSignBlock:()=>MO,FlowGraphSignalConnection:()=>_M,FlowGraphSinBlock:()=>iD,FlowGraphSinhBlock:()=>cD,FlowGraphSqrtBlock:()=>yD,FlowGraphState:()=>TM,FlowGraphStopAnimationBlock:()=>YM,FlowGraphSubtractBlock:()=>yO,FlowGraphSwitchBlock:()=>VM,FlowGraphTanBlock:()=>nD,FlowGraphTanhBlock:()=>hD,FlowGraphThrottleBlock:()=>wM,FlowGraphTimerBlock:()=>BM,FlowGraphTransposeBlock:()=>RD,FlowGraphTruncBlock:()=>OO,FlowGraphWaitAllBlock:()=>kM,FlowGraphWhileLoopBlock:()=>zM,FluidRenderer:()=>wR,FluidRendererSceneComponent:()=>LR,FluidRenderingDebug:()=>SR,FluidRenderingObject:()=>AR,FluidRenderingObjectCustomParticles:()=>MR,FluidRenderingObjectParticleSystem:()=>CR,FluidRenderingTargetRenderer:()=>IR,FlyCamera:()=>wc,FlyCameraInputsManager:()=>Lc,FlyCameraKeyboardInput:()=>fc,FlyCameraMouseInput:()=>_c,FogBlock:()=>fb,FollowBehavior:()=>Es,FollowCamera:()=>kc,FollowCameraInputsManager:()=>Bc,FollowCameraKeyboardMoveInput:()=>mc,FollowCameraMouseWheelInput:()=>gc,FollowCameraPointersInput:()=>vc,FragCoordBlock:()=>ab,FragDepthBlock:()=>hb,FragmentOutputBlock:()=>qs,FramingBehavior:()=>ss,FreeCamera:()=>Oc,FreeCameraDeviceOrientationInput:()=>Ac,FreeCameraGamepadInput:()=>Rc,FreeCameraInputsManager:()=>xc,FreeCameraKeyboardMoveInput:()=>yc,FreeCameraMouseInput:()=>Tc,FreeCameraMouseWheelInput:()=>Ec,FreeCameraTouchInput:()=>Sc,FreeCameraVirtualJoystickInput:()=>Ic,FresnelBlock:()=>kb,FresnelParameters:()=>$v,FromHalfFloat:()=>Ip,FrontFace:()=>kf,FrontFacingBlock:()=>nb,Frustum:()=>ln,FxaaPostProcess:()=>DC,GIRSM:()=>kR,GIRSMManager:()=>GR,GIRSMRenderPluginMaterial:()=>WR,GPUParticleSystem:()=>sA,GUID:()=>qi,Gamepad:()=>ac,GamepadCamera:()=>Qc,GamepadManager:()=>jc,GamepadSystemSceneComponent:()=>Yc,GaussianSplattingMaterial:()=>aE,GaussianSplattingMesh:()=>Px,GenerateBase64StringFromPixelData:()=>Ka,GenerateBase64StringFromTexture:()=>Qa,GenerateBase64StringFromTextureAsync:()=>qa,GenericPad:()=>sc,GeodesicData:()=>Kd,Geometry:()=>vo,GeometryArcTan2Block:()=>ux,GeometryBufferRenderer:()=>BC,GeometryBufferRendererSceneComponent:()=>VC,GeometryClampBlock:()=>gx,GeometryCollectionBlock:()=>IS,GeometryCrossBlock:()=>yx,GeometryCurveBlock:()=>bx,GeometryCurveBlockTypes:()=>vx,GeometryDesaturateBlock:()=>Tx,GeometryDistanceBlock:()=>xx,GeometryDotBlock:()=>Ax,GeometryElbowBlock:()=>MS,GeometryInfoBlock:()=>ex,GeometryInputBlock:()=>tS,GeometryLengthBlock:()=>Cx,GeometryLerpBlock:()=>hx,GeometryModBlock:()=>_x,GeometryNLerpBlock:()=>dx,GeometryOptimizeBlock:()=>nS,GeometryOutputBlock:()=>$E,GeometryPosterizeBlock:()=>Ex,GeometryPowBlock:()=>mx,GeometryReplaceColorBlock:()=>Sx,GeometryRotate2dBlock:()=>Rx,GeometrySmoothStepBlock:()=>fx,GeometryStepBlock:()=>px,GeometryTextureBlock:()=>ox,GeometryTextureFetchBlock:()=>ax,GeometryTransformBlock:()=>BS,GeometryTrigonometryBlock:()=>wS,GeometryTrigonometryBlockOperations:()=>FS,GetClass:()=>s,GetClassName:()=>l,GetDOMTextContent:()=>dt,GetEnvInfo:()=>Vp,GetEnvironmentBRDFTexture:()=>km,GetFogState:()=>ha,GetFontOffset:()=>xo,GetInternalFormatFromBasisFormat:()=>My,GetPointsCount:()=>YE,GetTGAHeader:()=>by,GetTextureDataAsync:()=>Op,Gizmo:()=>Oh,GizmoAnchorPoint:()=>Rh,GizmoCoordinatesMode:()=>Ph,GizmoManager:()=>Sm,GlowLayer:()=>nv,GoldbergMesh:()=>qd,GradientBlock:()=>iT,GradientBlockColorStep:()=>tT,GradientHelper:()=>Kx,GrainPostProcess:()=>NC,GreasedLineBaseMesh:()=>BE,GreasedLineMaterialDefaults:()=>qT,GreasedLineMesh:()=>UE,GreasedLineMeshColorDistribution:()=>VE,GreasedLineMeshColorDistributionType:()=>BT,GreasedLineMeshColorMode:()=>wT,GreasedLineMeshMaterialType:()=>LT,GreasedLineMeshWidthDistribution:()=>kE,GreasedLinePluginMaterial:()=>$T,GreasedLineRibbonAutoDirectionMode:()=>LE,GreasedLineRibbonFacesMode:()=>FE,GreasedLineRibbonMesh:()=>HE,GreasedLineRibbonPointsMode:()=>NE,GreasedLineSimpleMaterial:()=>tE,GreasedLineTools:()=>ZT,GridBlock:()=>cS,GroundBuilder:()=>oh,GroundMesh:()=>Ju,HDRCubeTexture:()=>Pv,HDRCubeTextureAssetTask:()=>rP,HDRFiltering:()=>Rv,HDRTools:()=>Cv,Halton2DSequence:()=>cE,HandConstraintBehavior:()=>ql,HandConstraintOrientation:()=>Wl,HandConstraintVisibility:()=>Hl,HandConstraintZone:()=>zl,HandPart:()=>Vl,HandleFallbacksForShadows:()=>ua,HardwareScalingOptimization:()=>dP,HavokPlugin:()=>iC,HeightToNormalBlock:()=>ub,HemisphereBuilder:()=>Rm,HemisphericLight:()=>Ch,HemisphericParticleEmitter:()=>wx,HighlightLayer:()=>av,HighlightsPostProcess:()=>FC,Hinge2Joint:()=>Ms,HingeConstraint:()=>WA,HingeJoint:()=>Is,HtmlElementTexture:()=>sy,IWebXRControllerPhysicsOptions:()=>lI,IcoSphereBlock:()=>sS,IcoSphereBuilder:()=>Gl,ImageAssetTask:()=>eP,ImageProcessingBlock:()=>eb,ImageProcessingConfiguration:()=>pr,ImageProcessingPostProcess:()=>LC,ImageSourceBlock:()=>mb,IncrementValueAction:()=>ue,IndexFormat:()=>jf,InputBlock:()=>rl,InspectableType:()=>FP,InstancedLinesMesh:()=>ud,InstancedMesh:()=>La,InstancesBlock:()=>Zy,InstantiateBlock:()=>KS,InstantiateLinearBlock:()=>QS,InstantiateOnFacesBlock:()=>XS,InstantiateOnVerticesBlock:()=>HS,InstantiateOnVolumeBlock:()=>jS,InstantiateRadialBlock:()=>qS,InstantiatedEntries:()=>Ua,IntFloatConverterBlock:()=>ZS,InternalTexture:()=>Pi,InternalTextureSource:()=>Ti,InterpolateValueAction:()=>st,IntersectionInfo:()=>eo,IsBase64DataUrl:()=>zi,IsDocumentAvailable:()=>ht,IsFileURL:()=>Gi,IsNavigatorAvailable:()=>ut,IsWindowObjectExist:()=>ct,IsWrapper:()=>fr,JoystickAxis:()=>Cc,KeepAssets:()=>Ba,KeyboardEventTypes:()=>Xr,KeyboardInfo:()=>jr,KeyboardInfoPre:()=>Yr,KhronosTextureContainer:()=>gg,KhronosTextureContainer2:()=>Sg,LatheBuilder:()=>Md,Layer:()=>lv,LayerSceneComponent:()=>sv,LengthBlock:()=>Hb,LensFlare:()=>cv,LensFlareSystem:()=>uv,LensFlareSystemSceneComponent:()=>hv,LensFlaresOptimization:()=>_P,LensRenderingPipeline:()=>YC,LerpBlock:()=>Fb,Light:()=>wa,LightBlock:()=>_b,LightGizmo:()=>Im,LightInformationBlock:()=>$y,LineEdgesRenderer:()=>mR,LinesBuilder:()=>md,LinesMesh:()=>cd,LoadFile:()=>Vi,LoadFileError:()=>Di,LoadImage:()=>Bi,LoadOp:()=>Zf,LoadTextureFromTranscodeResult:()=>By,LockConstraint:()=>XA,Logger:()=>ae,MapMode:()=>Tf,MapRangeBlock:()=>SS,MappingBlock:()=>tx,MappingTypes:()=>$S,Material:()=>Ca,MaterialAnisotropicDefines:()=>Km,MaterialClearCoatDefines:()=>Hm,MaterialDefines:()=>Gs,MaterialDetailMapDefines:()=>Fu,MaterialFlags:()=>xu,MaterialGreasedLineDefines:()=>JT,MaterialHelper:()=>ey,MaterialIridescenceDefines:()=>jm,MaterialPluginBase:()=>Nu,MaterialPluginEvent:()=>Vo,MaterialPluginManager:()=>Cu,MaterialSheenDefines:()=>qm,MaterialSubSurfaceDefines:()=>Jm,MathBlock:()=>TS,MathBlockOperations:()=>yS,Matrix:()=>z,MatrixBuilderBlock:()=>ET,MatrixComposeBlock:()=>ix,MatrixDeterminantBlock:()=>IT,MatrixTransposeBlock:()=>OT,MaxBlock:()=>Gb,MergeGeometryBlock:()=>PS,MergeMeshesOptimization:()=>yP,Mesh:()=>Fa,MeshAssetTask:()=>qR,MeshAttributeExistsBlock:()=>NT,MeshAttributeExistsBlockTypes:()=>MT,MeshBlock:()=>aS,MeshBuilder:()=>rp,MeshDebugMode:()=>eE,MeshDebugPluginMaterial:()=>nE,MeshExploder:()=>sP,MeshLODLevel:()=>Pa,MeshParticleEmitter:()=>Gx,MeshUVSpaceRenderer:()=>SE,MeshoptCompression:()=>mE,MinBlock:()=>zb,MinMaxReducer:()=>fv,MipmapFilterMode:()=>If,MirrorTexture:()=>Dm,ModBlock:()=>bT,ModelShape:()=>dA,MorphTarget:()=>Iv,MorphTargetManager:()=>Ov,MorphTargetsBlock:()=>Jy,MotionBlurPostProcess:()=>kC,MotorEnabledJoint:()=>Ps,MultiMaterial:()=>Ra,MultiObserver:()=>cP,MultiPointerScaleBehavior:()=>vs,MultiRenderTarget:()=>ky,MultiplyBlock:()=>ml,NLerpBlock:()=>rT,NativeDataStream:()=>gp,NativeEngine:()=>mf,NativePointerInput:()=>Ar,NativeXRFrame:()=>jI,NativeXRLayerRenderTargetTextureProvider:()=>Qu,NativeXRLayerWrapper:()=>Ku,NativeXRRenderTarget:()=>qu,NegateBlock:()=>Xb,Node:()=>qe,NodeGeometry:()=>rS,NodeGeometryBlock:()=>JE,NodeGeometryBlockConnectionPointTypes:()=>GE,NodeGeometryBuildState:()=>eS,NodeGeometryConnectionPoint:()=>ZE,NodeGeometryConnectionPointCompatibilityStates:()=>zE,NodeGeometryConnectionPointDirection:()=>WE,NodeGeometryContextualSources:()=>qE,NodeMaterial:()=>Ll,NodeMaterialBlock:()=>Ws,NodeMaterialBlockConnectionPointMode:()=>Ks,NodeMaterialBlockConnectionPointTypes:()=>Ns,NodeMaterialBlockTargets:()=>Fs,NodeMaterialConnectionPoint:()=>zs,NodeMaterialConnectionPointCompatibilityStates:()=>Bs,NodeMaterialConnectionPointCustomObject:()=>Qy,NodeMaterialConnectionPointDirection:()=>Us,NodeMaterialDefines:()=>Fl,NodeMaterialModes:()=>fl,NodeMaterialOptimizer:()=>UT,NodeMaterialSystemValues:()=>Qs,NodeMaterialTeleportInBlock:()=>Sb,NodeMaterialTeleportOutBlock:()=>xb,NoiseBlock:()=>RS,NoiseProceduralTexture:()=>Hy,NormalBlendBlock:()=>aT,NormalizeBlock:()=>Ob,NormalizeVectorBlock:()=>NS,NullBlock:()=>fS,NullEngine:()=>cp,NullEngineOptions:()=>lp,Observable:()=>f,Observer:()=>p,OcclusionMaterial:()=>ty,Octree:()=>Th,OctreeBlock:()=>bh,OctreeSceneComponent:()=>Eh,OimoJSPlugin:()=>wv,OnAfterEnteringVRObservableEvent:()=>hh,OneMinusBlock:()=>Ub,Orientation:()=>vn,OutlineRenderer:()=>xR,PBRAnisotropicConfiguration:()=>Qm,PBRBaseMaterial:()=>ig,PBRBaseSimpleMaterial:()=>iy,PBRClearCoatConfiguration:()=>Xm,PBRIridescenceConfiguration:()=>Ym,PBRMaterial:()=>rg,PBRMaterialDefines:()=>tg,PBRMetallicRoughnessBlock:()=>yT,PBRMetallicRoughnessMaterial:()=>ry,PBRSheenConfiguration:()=>Zm,PBRSpecularGlossinessMaterial:()=>ny,PBRSubSurfaceConfiguration:()=>$m,PHI:()=>x,PadNumber:()=>Rt,PanoramaToCubeMapTools:()=>Av,Particle:()=>Qx,ParticleBlendMultiplyBlock:()=>sl,ParticleHelper:()=>cA,ParticleRampGradientBlock:()=>al,ParticleSystem:()=>aA,ParticleSystemSet:()=>lA,ParticleTextureBlock:()=>ol,ParticlesOptimization:()=>gP,PassCubePostProcess:()=>Zc,PassPostProcess:()=>qc,Path2:()=>xn,Path3D:()=>An,PathCursor:()=>Wn,PerfCollectionStrategy:()=>eI,PerfCounter:()=>an,PerformanceConfigurator:()=>I,PerformanceMonitor:()=>yo,PerformanceViewerCollector:()=>JP,PerturbNormalBlock:()=>ib,PhotoDome:()=>Um,Physics6DoFConstraint:()=>kA,Physics6DoFLimit:()=>VA,PhysicsActivationControl:()=>CA,PhysicsAggregate:()=>KA,PhysicsBody:()=>IA,PhysicsConstraint:()=>UA,PhysicsConstraintAxis:()=>bA,PhysicsConstraintAxisLimitMode:()=>yA,PhysicsConstraintMotorType:()=>SA,PhysicsConstraintType:()=>TA,PhysicsEngine:()=>Fv,PhysicsEngineV2:()=>RA,PhysicsEventType:()=>xA,PhysicsHelper:()=>sC,PhysicsImpostor:()=>Ds,PhysicsJoint:()=>Cs,PhysicsMaterialCombineMode:()=>PA,PhysicsMotionType:()=>AA,PhysicsRadialExplosionEventOptions:()=>dC,PhysicsRadialImpulseFalloff:()=>nC,PhysicsRaycastResult:()=>Nv,PhysicsShape:()=>MA,PhysicsShapeBox:()=>FA,PhysicsShapeCapsule:()=>DA,PhysicsShapeContainer:()=>BA,PhysicsShapeConvexHull:()=>LA,PhysicsShapeCylinder:()=>NA,PhysicsShapeMesh:()=>wA,PhysicsShapeSphere:()=>OA,PhysicsShapeType:()=>EA,PhysicsUpdraftEventOptions:()=>pC,PhysicsUpdraftMode:()=>oC,PhysicsViewer:()=>np,PhysicsVortexEventOptions:()=>fC,PickingInfo:()=>Fr,PipelineErrorReason:()=>Bf,PivotTools:()=>ds,Plane:()=>sn,PlaneBlock:()=>oS,PlaneBuilder:()=>_s,PlaneDragGizmo:()=>bm,PlaneRotationGizmo:()=>vm,PlayAnimationAction:()=>he,PlaySoundAction:()=>Te,PointColor:()=>uA,PointLight:()=>Sv,PointParticleEmitter:()=>Bx,PointerDragBehavior:()=>gs,PointerEventTypes:()=>Gr,PointerInfo:()=>Hr,PointerInfoBase:()=>zr,PointerInfoPre:()=>Wr,PointerInput:()=>xr,PointsCloudSystem:()=>vA,PointsGroup:()=>gA,Polar:()=>sE,Polygon:()=>yd,PolygonBuilder:()=>xd,PolygonMeshBuilder:()=>bd,PolyhedronBuilder:()=>Ld,PolyhedronData:()=>Yd,PositionGizmo:()=>Tm,PositionNormalTextureVertex:()=>$s,PositionNormalVertex:()=>Js,PostProcess:()=>hl,PostProcessManager:()=>Lr,PostProcessRenderEffect:()=>vC,PostProcessRenderPipeline:()=>WC,PostProcessRenderPipelineManager:()=>HC,PostProcessRenderPipelineManagerSceneComponent:()=>XC,PostProcessesOptimization:()=>fP,PosterizeBlock:()=>$b,PowBlock:()=>jb,PowerEase:()=>Fn,PowerPreference:()=>gf,PrePassOutputBlock:()=>pb,PrePassRenderer:()=>vR,PrePassRendererSceneComponent:()=>yR,PrePassTextureBlock:()=>Eb,PrecisionDate:()=>_t,PredicateCondition:()=>ne,PrepareAttributesForBakedVertexAnimation:()=>ra,PrepareAttributesForBones:()=>la,PrepareAttributesForInstances:()=>ca,PrepareAttributesForMorphTargets:()=>Zo,PrepareAttributesForMorphTargetsInfluencers:()=>qo,PrepareDefinesForAttributes:()=>ya,PrepareDefinesForBakedVertexAnimation:()=>va,PrepareDefinesForBones:()=>ma,PrepareDefinesForCamera:()=>Sa,PrepareDefinesForFrameBoundValues:()=>_a,PrepareDefinesForLight:()=>fa,PrepareDefinesForLights:()=>pa,PrepareDefinesForMergedUV:()=>ta,PrepareDefinesForMisc:()=>da,PrepareDefinesForMorphTargets:()=>ga,PrepareDefinesForMultiview:()=>ba,PrepareDefinesForOIT:()=>Ta,PrepareDefinesForPrePass:()=>Ea,PrepareUniformsAndSamplersForLight:()=>xa,PrepareUniformsAndSamplersList:()=>Aa,PressureObserverWrapper:()=>jP,PrimitiveTopology:()=>Vf,PrismaticConstraint:()=>jA,ProceduralTexture:()=>Ol,ProceduralTextureSceneComponent:()=>Il,PropertyTypeForEdition:()=>Xs,ProximityCastResult:()=>_C,PushAttributesForInstances:()=>Jo,PushMaterial:()=>ws,QuadraticEase:()=>Ln,QuadraticErrorSimplification:()=>DE,QuarticEase:()=>wn,Quaternion:()=>G,QueryType:()=>$f,QueueNewFrame:()=>Ii,QuinticEase:()=>Bn,RGBDTextureTools:()=>Np,RSMCreatePluginMaterial:()=>VR,Ragdoll:()=>qA,RagdollBoneProperties:()=>QA,RandomBlock:()=>CS,RandomBlockLocks:()=>xS,RandomGUID:()=>Qi,RandomNumberBlock:()=>Yb,RawCubeTexture:()=>Xy,RawTexture:()=>is,RawTexture2DArray:()=>Mv,RawTexture3D:()=>jy,Ray:()=>hs,RayHelper:()=>op,ReadFile:()=>Ui,ReadFileError:()=>Fi,RecastJSCrowd:()=>Mx,RecastJSPlugin:()=>Ix,ReciprocalBlock:()=>qb,ReflectBlock:()=>lT,ReflectionBlock:()=>pT,ReflectionProbe:()=>Uv,ReflectionTextureBaseBlock:()=>vb,ReflectionTextureBlock:()=>yb,ReflectiveShadowMap:()=>BR,Reflector:()=>XP,RefractBlock:()=>cT,RefractionBlock:()=>mT,RefractionPostProcess:()=>GC,RefractionTexture:()=>Yy,RegisterClass:()=>a,RegisterMaterialPlugin:()=>Mu,RegisterNativeTypeAsync:()=>pf,RemapBlock:()=>pl,RenderPassTimestampLocation:()=>qf,RenderTargetTexture:()=>Pl,RenderTargetWrapper:()=>cl,RenderTargetsOptimization:()=>vP,RenderingGroup:()=>wr,RenderingGroupInfo:()=>Br,RenderingManager:()=>Ur,ReplaceColorBlock:()=>Zb,RequestFile:()=>ki,RequestFileError:()=>Ni,RequestFullscreen:()=>Ro,RequestPointerlock:()=>Io,ResizeImageBitmap:()=>Co,RetryStrategy:()=>gt,RibbonBuilder:()=>Kh,RichType:()=>QI,RichTypeAny:()=>qI,RichTypeBoolean:()=>$I,RichTypeColor3:()=>nM,RichTypeColor4:()=>oM,RichTypeFlowGraphInteger:()=>sM,RichTypeMatrix:()=>rM,RichTypeNumber:()=>JI,RichTypeQuaternion:()=>aM,RichTypeString:()=>ZI,RichTypeVector2:()=>eM,RichTypeVector3:()=>tM,RichTypeVector4:()=>iM,RollingAverage:()=>bo,Rotate2dBlock:()=>sT,RotationGizmo:()=>ym,RotationXBlock:()=>US,RotationYBlock:()=>VS,RotationZBlock:()=>kS,RuntimeAnimation:()=>lt,RuntimeError:()=>bt,SSAO2RenderingPipeline:()=>QC,SSAORenderingPipeline:()=>qC,SSRRenderingPipeline:()=>rR,SamplerBindingType:()=>Nf,Scalar:()=>j,ScaleBlock:()=>Cb,ScaleGizmo:()=>Em,ScalingBlock:()=>GS,Scene:()=>pn,SceneComponentConstants:()=>Vr,SceneDepthBlock:()=>bb,SceneInstrumentation:()=>tv,SceneLoader:()=>Ls,SceneLoaderAnimationGroupLoadingMode:()=>Os,SceneLoaderFlags:()=>mo,SceneOptimization:()=>uP,SceneOptimizer:()=>TP,SceneOptimizerOptions:()=>bP,ScenePerformancePriority:()=>Kr,SceneRecorder:()=>VP,SceneSerializer:()=>AP,ScreenSizeBlock:()=>sb,ScreenSpaceBlock:()=>lb,ScreenSpaceCurvaturePostProcess:()=>lR,ScreenSpaceReflectionPostProcess:()=>JC,ScreenshotTools:()=>LP,SerializationHelper:()=>Ke,SetBasisTranscoderWorker:()=>Fy,SetColorsBlock:()=>vS,SetCorsBehavior:()=>wi,SetMaterialIDBlock:()=>LS,SetNormalsBlock:()=>mS,SetParentAction:()=>me,SetPositionsBlock:()=>_S,SetStateAction:()=>le,SetTangentsBlock:()=>bS,SetUVsBlock:()=>gS,SetValueAction:()=>ce,ShaderCodeInliner:()=>tf,ShaderLanguage:()=>pt,ShaderMaterial:()=>ld,ShaderStage:()=>Of,ShaderStore:()=>li,ShadowDepthWrapper:()=>kT,ShadowGenerator:()=>dv,ShadowGeneratorSceneComponent:()=>Ev,ShadowLight:()=>xm,ShadowMapBlock:()=>db,ShadowsOptimization:()=>pP,ShapeBuilder:()=>Pd,ShapeCastResult:()=>mC,SharpenPostProcess:()=>zC,SheenBlock:()=>hT,SimplexPerlin3DBlock:()=>oT,SimplicationQueueSceneComponent:()=>wE,SimplificationQueue:()=>RE,SimplificationSettings:()=>CE,SimplificationType:()=>xE,SineEase:()=>Un,SixDofDragBehavior:()=>bs,Size:()=>Ze,Skeleton:()=>rs,SkeletonViewer:()=>ap,SliderConstraint:()=>HA,SmartArray:()=>ar,SmartArrayNoDuplicate:()=>sr,SmoothStepBlock:()=>Qb,SolidParticle:()=>hA,SolidParticleSystem:()=>_A,SolidParticleVertex:()=>fA,Sound:()=>Ga,SoundTrack:()=>za,SourceTextureFormat:()=>fg,Space:()=>dn,SphereBlock:()=>lS,SphereBuilder:()=>zh,SphereDirectedParticleEmitter:()=>Vx,SphereParticleEmitter:()=>Ux,Spherical:()=>lE,SphericalHarmonics:()=>Ep,SphericalPolynomial:()=>Sp,SpotLight:()=>Pm,SpringConstraint:()=>YA,Sprite:()=>Vv,SpriteManager:()=>zv,SpriteMap:()=>XR,SpritePackedManager:()=>jR,SpriteSceneComponent:()=>kv,Stage:()=>kr,StandardMaterial:()=>Uu,StandardMaterialDefines:()=>Bu,StandardRenderingPipeline:()=>$C,StartsWith:()=>Et,StateCondition:()=>oe,StencilOperation:()=>Xf,StencilState:()=>Ai,StencilStateComposer:()=>xi,StepBlock:()=>Bb,StereoscopicArcRotateCamera:()=>su,StereoscopicFreeCamera:()=>lu,StereoscopicGamepadCamera:()=>cu,StereoscopicInterlacePostProcess:()=>ou,StereoscopicInterlacePostProcessI:()=>nu,StereoscopicScreenUniversalCamera:()=>hu,StereoscopicUniversalCamera:()=>uu,StickValues:()=>oc,StopAnimationAction:()=>de,StopSoundAction:()=>Ee,StorageBuffer:()=>$l,StorageTextureAccess:()=>Lf,StoreOp:()=>Jf,StringDictionary:()=>lr,StringTools:()=>Pt,SubEmitter:()=>Jx,SubEmitterType:()=>qx,SubMesh:()=>po,SubSurfaceBlock:()=>gT,SubSurfaceSceneComponent:()=>ER,SubtractBlock:()=>wb,SurfaceMagnetismBehavior:()=>Ts,SwitchBooleanAction:()=>se,SwitchInput:()=>Ir,TAARenderingPipeline:()=>nR,TBNBlock:()=>tb,TGATools:()=>Ey,Tags:()=>je,TargetCamera:()=>Mc,TargetedAnimation:()=>Gn,TeleportInBlock:()=>rx,TeleportOutBlock:()=>nx,TestBase64DataUrl:()=>Wi,TextFileAssetTask:()=>JR,Texture:()=>Ja,TextureAspect:()=>Af,TextureAssetTask:()=>tP,TextureBlock:()=>gb,TextureDimension:()=>Ef,TextureFormat:()=>Cf,TextureOptimization:()=>hP,TexturePacker:()=>zy,TexturePackerFrame:()=>Gy,TextureSampleType:()=>Ff,TextureSampler:()=>Ri,TextureTools:()=>Dp,TextureUsage:()=>Sf,TextureViewDimension:()=>xf,ThinEngine:()=>Er,ThinRenderTargetTexture:()=>Ky,ThinTexture:()=>ja,TiledBoxBuilder:()=>rd,TiledPlaneBuilder:()=>ed,TimerState:()=>Gg,TmpColors:()=>$,TmpVectors:()=>H,ToGammaSpace:()=>E,ToHalfFloat:()=>Pp,ToLinearSpace:()=>S,TonemapPostProcess:()=>aR,TonemappingOperator:()=>oR,Tools:()=>rr,TorusBlock:()=>uS,TorusBuilder:()=>lh,TorusKnotBuilder:()=>ad,TouchCamera:()=>Dc,TrailMesh:()=>AE,Trajectory:()=>kP,TrajectoryClassifier:()=>HP,TranscodeAsync:()=>Ly,TranscodeTarget:()=>_g,TransformBlock:()=>Hs,TransformNode:()=>Fo,TranslationBlock:()=>WS,TriPlanarBlock:()=>RT,TrigonometryBlock:()=>Dl,TrigonometryBlockOperations:()=>Ml,TubeBuilder:()=>Dd,TwirlBlock:()=>cb,UniformBuffer:()=>Or,UniversalCamera:()=>Kc,UnregisterAllMaterialPlugins:()=>Du,UnregisterMaterialPlugin:()=>Ou,UploadContent:()=>Ty,UploadEnvLevelsAsync:()=>Hp,UploadEnvSpherical:()=>Yp,UploadLevelsAsync:()=>jp,UtilityLayerRenderer:()=>Ih,VRCameraMetrics:()=>pu,VRDeviceOrientationArcRotateCamera:()=>bu,VRDeviceOrientationFreeCamera:()=>Tu,VRDeviceOrientationGamepadCamera:()=>Eu,VRDistortionCorrectionPostProcess:()=>fu,VRExperienceHelper:()=>dh,VRMultiviewToSingleviewPostProcess:()=>vu,ValidatedNativeDataStream:()=>r_,ValueCondition:()=>re,Vector2:()=>U,Vector2ToFixed:()=>uE,Vector3:()=>V,Vector3ToFixed:()=>hE,Vector4:()=>k,Vector4ToFixed:()=>dE,VectorConverterBlock:()=>DS,VectorMergerBlock:()=>dl,VectorSplitterBlock:()=>Nb,VertexAnimationBaker:()=>ns,VertexBuffer:()=>Nr,VertexData:()=>_o,VertexDataMaterialInfo:()=>fo,VertexFormat:()=>Yf,VertexOutputBlock:()=>js,VertexStepMode:()=>Kf,VideoDome:()=>$g,VideoRecorder:()=>CP,VideoTexture:()=>Jg,ViewDirectionBlock:()=>Vb,Viewport:()=>Jn,VirtualJoystick:()=>Pc,VirtualJoysticksCamera:()=>du,VolumetricLightScatteringPostProcess:()=>sR,VoronoiNoiseBlock:()=>AT,WaveBlock:()=>eT,WaveBlockKind:()=>Jb,WebGL2ParticleSystem:()=>Wx,WebGL2ShaderProcessor:()=>gr,WebGLDataBuffer:()=>yr,WebGLHardwareTexture:()=>br,WebGLPipelineContext:()=>ci,WebGPUCacheBindGroups:()=>k_,WebGPUCacheRenderPipeline:()=>O_,WebGPUCacheRenderPipelineTree:()=>N_,WebGPUCacheSampler:()=>R_,WebGPUDataBuffer:()=>E_,WebGPUDrawContext:()=>U_,WebGPUEngine:()=>sm,WebGPURenderTargetWrapper:()=>dm,WebGPUTintWASM:()=>em,WebRequest:()=>Je,WebXRAbstractFeature:()=>As,WebXRAbstractMotionController:()=>Pg,WebXRAnchorSystem:()=>nI,WebXRBackgroundRemover:()=>sI,WebXRCamera:()=>Ag,WebXRControllerComponent:()=>Rg,WebXRControllerMovement:()=>gI,WebXRControllerPhysics:()=>cI,WebXRControllerPointerSelection:()=>Vg,WebXRDefaultExperience:()=>Qg,WebXRDefaultExperienceOptions:()=>Kg,WebXRDepthSensing:()=>DI,WebXRDomOverlay:()=>mI,WebXREnterExitUI:()=>Hg,WebXREnterExitUIButton:()=>zg,WebXREnterExitUIOptions:()=>Wg,WebXRExperienceHelper:()=>Cg,WebXREyeTracking:()=>yI,WebXRFeatureName:()=>Ss,WebXRFeaturePointSystem:()=>hI,WebXRFeaturesManager:()=>xs,WebXRGenericHandController:()=>BI,WebXRGenericTriggerMotionController:()=>Ig,WebXRHTCViveMotionController:()=>WI,WebXRHand:()=>Yl,WebXRHandJoint:()=>kl,WebXRHandTracking:()=>Kl,WebXRHitTest:()=>uI,WebXRHitTestLegacy:()=>iI,WebXRImageTracking:()=>_I,WebXRInput:()=>Ug,WebXRInputSource:()=>Bg,WebXRLayerRenderTargetTextureProvider:()=>Wu,WebXRLayers:()=>OI,WebXRLightEstimation:()=>vI,WebXRManagedOutputCanvas:()=>Yu,WebXRManagedOutputCanvasOptions:()=>ju,WebXRMeshDetector:()=>fI,WebXRMicrosoftMixedRealityController:()=>VI,WebXRMotionControllerManager:()=>Ng,WebXRMotionControllerTeleportation:()=>Yg,WebXRNearControllerMode:()=>Lg,WebXRNearInteraction:()=>kg,WebXROculusTouchMotionController:()=>GI,WebXRPlaneDetector:()=>aI,WebXRProfiledMotionController:()=>Og,WebXRRawCameraAccess:()=>wI,WebXRSessionManager:()=>Zu,WebXRSpaceWarp:()=>LI,WebXRSpaceWarpRenderTargetTextureProvider:()=>FI,WebXRState:()=>Vu,WebXRTrackingState:()=>ku,WebXRWalkingLocomotion:()=>xI,WeightedSound:()=>Ha,WorkerPool:()=>vg,WorleyNoise3DBlock:()=>nT,XRSpaceWarpRenderTarget:()=>NI,Xbox360Button:()=>Uc,Xbox360Dpad:()=>Vc,Xbox360Pad:()=>Hc,XboxInput:()=>Pr,_BabylonLoaderRegistered:()=>Wv,_BasisTextureLoader:()=>Vy,_CommonDispose:()=>So,_CommonInit:()=>Eo,_CreationDataStorage:()=>Ia,_DDSTextureLoader:()=>dg,_ENVTextureLoader:()=>pg,_HDRTextureLoader:()=>xy,_InstancesBatch:()=>Oa,_KTXTextureLoader:()=>xg,_MeshCollisionData:()=>Lo,_OcclusionDataStorage:()=>up,_PrimaryIsoTriangle:()=>jd,_TGATextureLoader:()=>Sy,_TimeToken:()=>hp,_UpdateRGBDAsync:()=>Kp,_forceSceneHelpersToBundle:()=>qg,_forceTransformFeedbackToBundle:()=>dp,_injectLTSFileTools:()=>Yi,_staticOffsetValueColor3:()=>rt,_staticOffsetValueColor4:()=>nt,_staticOffsetValueQuaternion:()=>$e,_staticOffsetValueSize:()=>it,_staticOffsetValueVector2:()=>tt,_staticOffsetValueVector3:()=>et,addClipPlaneUniforms:()=>Go,allocateAndCopyTypedBuffer:()=>To,bindClipPlane:()=>Ho,captureEquirectangularFromScene:()=>tI,className:()=>nr,createDetailMapPlugin:()=>QT,createPBRAnisotropicPlugin:()=>WT,createPBRBRDFPlugin:()=>HT,createPBRClearCoatPlugin:()=>XT,createPBRIridescencePlugin:()=>jT,createPBRSheenPlugin:()=>YT,createPBRSubSurfacePlugin:()=>KT,createYieldingScheduler:()=>jn,editableInPropertyPage:()=>Ys,expandToProperty:()=>Pe,extractMinAndMax:()=>uo,extractMinAndMaxIndexed:()=>co,getRichTypeFromValue:()=>lM,inlineScheduler:()=>Xn,makeAsyncFunction:()=>Zn,makeSyncFunction:()=>qn,nativeOverride:()=>ze,normalizeEnvInfo:()=>kp,prepareDefinesForClipPlanes:()=>Wo,prepareStringDefinesForClipPlanes:()=>zo,runCoroutine:()=>Yn,runCoroutineAsync:()=>Qn,runCoroutineSync:()=>Kn,serialize:()=>Ie,serializeAsCameraReference:()=>Ge,serializeAsColor3:()=>Oe,serializeAsColor4:()=>Be,serializeAsColorCurves:()=>we,serializeAsFresnelParameters:()=>De,serializeAsImageProcessingConfiguration:()=>Ue,serializeAsMatrix:()=>ke,serializeAsMeshReference:()=>Le,serializeAsQuaternion:()=>Ve,serializeAsTexture:()=>Me,serializeAsVector2:()=>Ne,serializeAsVector3:()=>Fe,setAndStartTimer:()=>Xg,setStereoscopicAnaglyphRigMode:()=>$c,setStereoscopicRigMode:()=>au,setVRRigMode:()=>yu});var o={};function a(e,t){o[e]=t}function s(e){return o[e]}function l(e){for(var t in o)if(e instanceof o[t]&&!t.includes("Abstract"))return t;return"Unknown"}var c=function(){function e(){this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[]}return e.AddParser=function(e,t){this._BabylonFileParsers[e]=t},e.GetParser=function(e){return this._BabylonFileParsers[e]?this._BabylonFileParsers[e]:null},e.AddIndividualParser=function(e,t){this._IndividualBabylonFileParsers[e]=t},e.GetIndividualParser=function(e){return this._IndividualBabylonFileParsers[e]?this._IndividualBabylonFileParsers[e]:null},e.Parse=function(e,t,i,r){for(var n in this._BabylonFileParsers)Object.prototype.hasOwnProperty.call(this._BabylonFileParsers,n)&&this._BabylonFileParsers[n](e,t,i,r)},Object.defineProperty(e.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture=e},enumerable:!1,configurable:!0}),e.prototype.getNodes=function(){var e=[];return e=(e=(e=(e=e.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes),this.skeletons.forEach((function(t){return e=e.concat(t.bones)})),e},e._BabylonFileParsers={},e._IndividualBabylonFileParsers={},e}();a("BABYLON.AbstractScene",c);var u=function(){function e(){}return e.ALPHA_DISABLE=0,e.ALPHA_ADD=1,e.ALPHA_COMBINE=2,e.ALPHA_SUBTRACT=3,e.ALPHA_MULTIPLY=4,e.ALPHA_MAXIMIZED=5,e.ALPHA_ONEONE=6,e.ALPHA_PREMULTIPLIED=7,e.ALPHA_PREMULTIPLIED_PORTERDUFF=8,e.ALPHA_INTERPOLATE=9,e.ALPHA_SCREENMODE=10,e.ALPHA_ONEONE_ONEONE=11,e.ALPHA_ALPHATOCOLOR=12,e.ALPHA_REVERSEONEMINUS=13,e.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,e.ALPHA_ONEONE_ONEZERO=15,e.ALPHA_EXCLUSION=16,e.ALPHA_LAYER_ACCUMULATE=17,e.ALPHA_EQUATION_ADD=0,e.ALPHA_EQUATION_SUBSTRACT=1,e.ALPHA_EQUATION_REVERSE_SUBTRACT=2,e.ALPHA_EQUATION_MAX=3,e.ALPHA_EQUATION_MIN=4,e.ALPHA_EQUATION_DARKEN=5,e.DELAYLOADSTATE_NONE=0,e.DELAYLOADSTATE_LOADED=1,e.DELAYLOADSTATE_LOADING=2,e.DELAYLOADSTATE_NOTLOADED=4,e.NEVER=512,e.ALWAYS=519,e.LESS=513,e.EQUAL=514,e.LEQUAL=515,e.GREATER=516,e.GEQUAL=518,e.NOTEQUAL=517,e.KEEP=7680,e.ZERO=0,e.REPLACE=7681,e.INCR=7682,e.DECR=7683,e.INVERT=5386,e.INCR_WRAP=34055,e.DECR_WRAP=34056,e.TEXTURE_CLAMP_ADDRESSMODE=0,e.TEXTURE_WRAP_ADDRESSMODE=1,e.TEXTURE_MIRROR_ADDRESSMODE=2,e.TEXTURE_CREATIONFLAG_STORAGE=1,e.TEXTUREFORMAT_ALPHA=0,e.TEXTUREFORMAT_LUMINANCE=1,e.TEXTUREFORMAT_LUMINANCE_ALPHA=2,e.TEXTUREFORMAT_RGB=4,e.TEXTUREFORMAT_RGBA=5,e.TEXTUREFORMAT_RED=6,e.TEXTUREFORMAT_R=6,e.TEXTUREFORMAT_RG=7,e.TEXTUREFORMAT_RED_INTEGER=8,e.TEXTUREFORMAT_R_INTEGER=8,e.TEXTUREFORMAT_RG_INTEGER=9,e.TEXTUREFORMAT_RGB_INTEGER=10,e.TEXTUREFORMAT_RGBA_INTEGER=11,e.TEXTUREFORMAT_BGRA=12,e.TEXTUREFORMAT_DEPTH24_STENCIL8=13,e.TEXTUREFORMAT_DEPTH32_FLOAT=14,e.TEXTUREFORMAT_DEPTH16=15,e.TEXTUREFORMAT_DEPTH24=16,e.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17,e.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18,e.TEXTUREFORMAT_STENCIL8=19,e.TEXTUREFORMAT_UNDEFINED=4294967295,e.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492,e.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493,e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495,e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494,e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779,e.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919,e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778,e.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918,e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777,e.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776,e.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917,e.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916,e.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808,e.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840,e.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196,e.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492,e.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493,e.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494,e.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495,e.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496,e.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497,e.TEXTURETYPE_UNSIGNED_BYTE=0,e.TEXTURETYPE_UNSIGNED_INT=0,e.TEXTURETYPE_FLOAT=1,e.TEXTURETYPE_HALF_FLOAT=2,e.TEXTURETYPE_BYTE=3,e.TEXTURETYPE_SHORT=4,e.TEXTURETYPE_UNSIGNED_SHORT=5,e.TEXTURETYPE_INT=6,e.TEXTURETYPE_UNSIGNED_INTEGER=7,e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,e.TEXTURETYPE_UNSIGNED_INT_24_8=12,e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,e.TEXTURETYPE_UNDEFINED=16,e.TEXTURE_2D=3553,e.TEXTURE_2D_ARRAY=35866,e.TEXTURE_CUBE_MAP=34067,e.TEXTURE_CUBE_MAP_ARRAY=3735928559,e.TEXTURE_3D=32879,e.TEXTURE_NEAREST_SAMPLINGMODE=1,e.TEXTURE_NEAREST_NEAREST=1,e.TEXTURE_BILINEAR_SAMPLINGMODE=2,e.TEXTURE_LINEAR_LINEAR=2,e.TEXTURE_TRILINEAR_SAMPLINGMODE=3,e.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,e.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,e.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,e.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,e.TEXTURE_NEAREST_LINEAR=7,e.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,e.TEXTURE_LINEAR_NEAREST=12,e.TEXTURE_EXPLICIT_MODE=0,e.TEXTURE_SPHERICAL_MODE=1,e.TEXTURE_PLANAR_MODE=2,e.TEXTURE_CUBIC_MODE=3,e.TEXTURE_PROJECTION_MODE=4,e.TEXTURE_SKYBOX_MODE=5,e.TEXTURE_INVCUBIC_MODE=6,e.TEXTURE_EQUIRECTANGULAR_MODE=7,e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,e.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,e.TEXTURE_FILTERING_QUALITY_HIGH=64,e.TEXTURE_FILTERING_QUALITY_MEDIUM=16,e.TEXTURE_FILTERING_QUALITY_LOW=8,e.SCALEMODE_FLOOR=1,e.SCALEMODE_NEAREST=2,e.SCALEMODE_CEILING=3,e.MATERIAL_TextureDirtyFlag=1,e.MATERIAL_LightDirtyFlag=2,e.MATERIAL_FresnelDirtyFlag=4,e.MATERIAL_AttributesDirtyFlag=8,e.MATERIAL_MiscDirtyFlag=16,e.MATERIAL_PrePassDirtyFlag=32,e.MATERIAL_AllDirtyFlag=63,e.MATERIAL_TriangleFillMode=0,e.MATERIAL_WireFrameFillMode=1,e.MATERIAL_PointFillMode=2,e.MATERIAL_PointListDrawMode=3,e.MATERIAL_LineListDrawMode=4,e.MATERIAL_LineLoopDrawMode=5,e.MATERIAL_LineStripDrawMode=6,e.MATERIAL_TriangleStripDrawMode=7,e.MATERIAL_TriangleFanDrawMode=8,e.MATERIAL_ClockWiseSideOrientation=0,e.MATERIAL_CounterClockWiseSideOrientation=1,e.ACTION_NothingTrigger=0,e.ACTION_OnPickTrigger=1,e.ACTION_OnLeftPickTrigger=2,e.ACTION_OnRightPickTrigger=3,e.ACTION_OnCenterPickTrigger=4,e.ACTION_OnPickDownTrigger=5,e.ACTION_OnDoublePickTrigger=6,e.ACTION_OnPickUpTrigger=7,e.ACTION_OnPickOutTrigger=16,e.ACTION_OnLongPressTrigger=8,e.ACTION_OnPointerOverTrigger=9,e.ACTION_OnPointerOutTrigger=10,e.ACTION_OnEveryFrameTrigger=11,e.ACTION_OnIntersectionEnterTrigger=12,e.ACTION_OnIntersectionExitTrigger=13,e.ACTION_OnKeyDownTrigger=14,e.ACTION_OnKeyUpTrigger=15,e.PARTICLES_BILLBOARDMODE_Y=2,e.PARTICLES_BILLBOARDMODE_ALL=7,e.PARTICLES_BILLBOARDMODE_STRETCHED=8,e.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9,e.MESHES_CULLINGSTRATEGY_STANDARD=0,e.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,e.SCENELOADER_NO_LOGGING=0,e.SCENELOADER_MINIMAL_LOGGING=1,e.SCENELOADER_SUMMARY_LOGGING=2,e.SCENELOADER_DETAILED_LOGGING=3,e.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,e.PREPASS_POSITION_TEXTURE_TYPE=1,e.PREPASS_VELOCITY_TEXTURE_TYPE=2,e.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,e.PREPASS_COLOR_TEXTURE_TYPE=4,e.PREPASS_DEPTH_TEXTURE_TYPE=5,e.PREPASS_NORMAL_TEXTURE_TYPE=6,e.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7,e.BUFFER_CREATIONFLAG_READ=1,e.BUFFER_CREATIONFLAG_WRITE=2,e.BUFFER_CREATIONFLAG_READWRITE=3,e.BUFFER_CREATIONFLAG_UNIFORM=4,e.BUFFER_CREATIONFLAG_VERTEX=8,e.BUFFER_CREATIONFLAG_INDEX=16,e.BUFFER_CREATIONFLAG_STORAGE=32,e.BUFFER_CREATIONFLAG_INDIRECT=64,e.RENDERPASS_MAIN=0,e.INPUT_ALT_KEY=18,e.INPUT_CTRL_KEY=17,e.INPUT_META_KEY1=91,e.INPUT_META_KEY2=92,e.INPUT_META_KEY3=93,e.INPUT_SHIFT_KEY=16,e.SNAPSHOTRENDERING_STANDARD=0,e.SNAPSHOTRENDERING_FAST=1,e.PERSPECTIVE_CAMERA=0,e.ORTHOGRAPHIC_CAMERA=1,e.FOVMODE_VERTICAL_FIXED=0,e.FOVMODE_HORIZONTAL_FIXED=1,e.RIG_MODE_NONE=0,e.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,e.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,e.RIG_MODE_STEREOSCOPIC_INTERLACED=14,e.RIG_MODE_VR=20,e.RIG_MODE_CUSTOM=22,e.MAX_SUPPORTED_UV_SETS=6,e.GL_ALPHA_EQUATION_ADD=32774,e.GL_ALPHA_EQUATION_MIN=32775,e.GL_ALPHA_EQUATION_MAX=32776,e.GL_ALPHA_EQUATION_SUBTRACT=32778,e.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779,e.GL_ALPHA_FUNCTION_SRC=768,e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769,e.GL_ALPHA_FUNCTION_SRC_ALPHA=770,e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771,e.GL_ALPHA_FUNCTION_DST_ALPHA=772,e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773,e.GL_ALPHA_FUNCTION_DST_COLOR=774,e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775,e.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776,e.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769,e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770,e.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771,e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772,e.SnippetUrl="https://snippet.babylonjs.com",e.FOGMODE_NONE=0,e.FOGMODE_EXP=1,e.FOGMODE_EXP2=2,e.FOGMODE_LINEAR=3,e.BYTE=5120,e.UNSIGNED_BYTE=5121,e.SHORT=5122,e.UNSIGNED_SHORT=5123,e.INT=5124,e.UNSIGNED_INT=5125,e.FLOAT=5126,e.PositionKind="position",e.NormalKind="normal",e.TangentKind="tangent",e.UVKind="uv",e.UV2Kind="uv2",e.UV3Kind="uv3",e.UV4Kind="uv4",e.UV5Kind="uv5",e.UV6Kind="uv6",e.ColorKind="color",e.ColorInstanceKind="instanceColor",e.MatricesIndicesKind="matricesIndices",e.MatricesWeightsKind="matricesWeights",e.MatricesIndicesExtraKind="matricesIndicesExtra",e.MatricesWeightsExtraKind="matricesWeightsExtra",e}(),h=function(){function e(){this.hoverCursor="",this.actions=[],this.isRecursive=!1}return Object.defineProperty(e,"HasTriggers",{get:function(){for(var t in e.Triggers)if(Object.prototype.hasOwnProperty.call(e.Triggers,t))return!0;return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e,"HasPickTriggers",{get:function(){for(var t in e.Triggers)if(Object.prototype.hasOwnProperty.call(e.Triggers,t)){var i=parseInt(t);if(i>=u.ACTION_OnPickTrigger&&i<=u.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),e.HasSpecificTrigger=function(t){for(var i in e.Triggers)if(Object.prototype.hasOwnProperty.call(e.Triggers,i)&&parseInt(i)===t)return!0;return!1},e.Triggers={},e}(),d=function(){function e(e,t,i,r){void 0===t&&(t=!1),this.initialize(e,t,i,r)}return e.prototype.initialize=function(e,t,i,r){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=r,this},e}(),p=function(){function e(e,t,i){void 0===i&&(i=null),this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}return e.prototype.remove=function(){this._remove&&this._remove()},e}(),f=function(){function e(e,t){void 0===t&&(t=!1),this.notifyIfTriggered=t,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new d(0),e&&(this._onObserverAdded=e)}return e.FromPromise=function(t,i){var r=new e;return t.then((function(e){r.notifyObservers(e)})).catch((function(e){if(!i)throw e;i.notifyObservers(e)})),r},Object.defineProperty(e.prototype,"observers",{get:function(){return this._observers},enumerable:!1,configurable:!0}),e.prototype.add=function(e,t,i,r,n){var o=this;if(void 0===t&&(t=-1),void 0===i&&(i=!1),void 0===r&&(r=null),void 0===n&&(n=!1),!e)return null;var a=new p(e,t,r);return a.unregisterOnNextCall=n,i?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&void 0!==this._lastNotifiedValue&&this.notifyObserver(a,this._lastNotifiedValue),a._remove=function(){o.remove(a)},a},e.prototype.addOnce=function(e){return this.add(e,void 0,void 0,void 0,!0)},e.prototype.remove=function(e){return!!e&&(e._remove=null,-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0))},e.prototype.removeCallback=function(e,t){for(var i=0;i0},e.prototype.clear=function(){for(;this._observers.length;){var e=this._observers.pop();e&&(e._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()},e.prototype.cleanLastNotifiedState=function(){this._hasNotified=!1,this._lastNotifiedValue=void 0},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e.prototype.hasSpecificMask=function(e){void 0===e&&(e=-1);for(var t=0,i=this._observers;t=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}function y(e,t,i,r){return new(i||(i=Promise))((function(n,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function b(e,t){var i,r,n,o,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(i=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]i.x?t.x:i.x,t.y>i.y?t.y:i.y)},e.Transform=function(t,i){return e.TransformToRef(t,i,new e)},e.TransformToRef=function(e,t,i){var r=t.m,n=e.x*r[0]+e.y*r[4]+r[12],o=e.x*r[1]+e.y*r[5]+r[13];return i.x=n,i.y=o,i},e.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=n<0?-1:1,a=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,s=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return a>0&&s>0&&a+s<2*n*o},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},e.Center=function(t,i){return e.CenterToRef(t,i,new e)},e.CenterToRef=function(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)},e.DistanceOfPointFromSegment=function(t,i,r){var n=e.DistanceSquared(i,r);if(0===n)return e.Distance(t,i);var o=r.subtract(i),a=Math.max(0,Math.min(1,e.Dot(t.subtract(i),o)/n)),s=i.add(o.multiplyByFloats(a,a));return e.Distance(t,s)},e._ZeroReadOnly=e.Zero(),e}();Object.defineProperties(U.prototype,{dimension:{value:[2]},rank:{value:1}});var V=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this._isDirty=!0,this._x=e,this._y=t,this._z=i}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"{X: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(this._z,"}")},e.prototype.getClassName=function(){return"Vector3"},e.prototype.getHashCode=function(){var e=B(this._x);return 397*(e=397*e^B(this._y))^B(this._z)},e.prototype.asArray=function(){return[this._x,this._y,this._z]},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toQuaternion=function(){return G.RotationYawPitchRoll(this._y,this._x,this._z)},e.prototype.addInPlace=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._isDirty=!0,this},e.prototype.addInPlaceFromFloats=function(e,t,i){return this._x+=e,this._y+=t,this._z+=i,this._isDirty=!0,this},e.prototype.add=function(t){return new e(this._x+t._x,this._y+t._y,this._z+t._z)},e.prototype.addToRef=function(e,t){return t.copyFromFloats(this._x+e._x,this._y+e._y,this._z+e._z)},e.prototype.subtractInPlace=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this},e.prototype.subtract=function(t){return new e(this._x-t._x,this._y-t._y,this._z-t._z)},e.prototype.subtractToRef=function(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)},e.prototype.subtractFromFloats=function(t,i,r){return new e(this._x-t,this._y-i,this._z-r)},e.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.copyFromFloats(this._x-e,this._y-t,this._z-i)},e.prototype.negate=function(){return new e(-this._x,-this._y,-this._z)},e.prototype.negateInPlace=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this._x,-1*this._y,-1*this._z)},e.prototype.scaleInPlace=function(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this},e.prototype.scale=function(t){return new e(this._x*t,this._y*t,this._z*t)},e.prototype.scaleToRef=function(e,t){return t.copyFromFloats(this._x*e,this._y*e,this._z*e)},e.prototype.getNormalToRef=function(e){var t=this.length(),i=Math.acos(this.y/t),r=Math.atan2(this.z,this.x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;var n=t*Math.sin(i)*Math.cos(r),o=t*Math.cos(i),a=t*Math.sin(i)*Math.sin(r);return e.set(n,o,a),e},e.prototype.applyRotationQuaternionToRef=function(e,t){var i=this._x,r=this._y,n=this._z,o=e._x,a=e._y,s=e._z,l=e._w,c=2*(a*n-s*r),u=2*(s*i-o*n),h=2*(o*r-a*i);return t._x=i+l*c+a*h-s*u,t._y=r+l*u+s*c-o*h,t._z=n+l*h+o*u-a*c,t._isDirty=!0,t},e.prototype.applyRotationQuaternionInPlace=function(e){return this.applyRotationQuaternionToRef(e,this)},e.prototype.applyRotationQuaternion=function(t){return this.applyRotationQuaternionToRef(t,new e)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this._x*e,this._y*e,this._z*e)},e.prototype.projectOnPlane=function(t,i){return this.projectOnPlaneToRef(t,i,new e)},e.prototype.projectOnPlaneToRef=function(t,i,r){var n=t.normal,o=t.d,a=W.Vector3[0];this.subtractToRef(i,a),a.normalize();var s=e.Dot(a,n);if(Math.abs(s)<1e-10)r.setAll(1/0);else{var l=-(e.Dot(i,n)+o)/s,c=a.scaleInPlace(l);i.addToRef(c,r)}return r},e.prototype.equals=function(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=A),e&&O(this._x,e._x,t)&&O(this._y,e._y,t)&&O(this._z,e._z,t)},e.prototype.equalsToFloats=function(e,t,i){return this._x===e&&this._y===t&&this._z===i},e.prototype.multiplyInPlace=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._isDirty=!0,this},e.prototype.multiply=function(e){return this.multiplyByFloats(e._x,e._y,e._z)},e.prototype.multiplyToRef=function(e,t){return t.copyFromFloats(this._x*e._x,this._y*e._y,this._z*e._z)},e.prototype.multiplyByFloats=function(t,i,r){return new e(this._x*t,this._y*i,this._z*r)},e.prototype.divide=function(t){return new e(this._x/t._x,this._y/t._y,this._z/t._z)},e.prototype.divideToRef=function(e,t){return t.copyFromFloats(this._x/e._x,this._y/e._y,this._z/e._z)},e.prototype.divideInPlace=function(e){return this._x=this._x/e._x,this._y=this._y/e._y,this._z=this._z/e._z,this._isDirty=!0,this},e.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.minimizeInPlaceFromFloats=function(e,t,i){return ethis._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this._x),i=Math.abs(this._y);if(!O(t,i,e))return!0;var r=Math.abs(this._z);return!O(t,r,e)||!O(i,r,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this._x);return e!==Math.abs(this._y)||e!==Math.abs(this._z)},enumerable:!1,configurable:!0}),e.prototype.floorToRef=function(e){return e._x=Math.floor(this._x),e._y=Math.floor(this._y),e._z=Math.floor(this._z),e._isDirty=!0,e},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},e.prototype.fractToRef=function(e){return e._x=this.x-Math.floor(this._x),e._y=this.y-Math.floor(this._y),e._z=this.z-Math.floor(this._z),e._isDirty=!0,e},e.prototype.fract=function(){return new e(this.x-Math.floor(this._x),this.y-Math.floor(this._y),this.z-Math.floor(this._z))},e.prototype.length=function(){return Math.sqrt(this.lengthSquared())},e.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z},Object.defineProperty(e.prototype,"hasAZeroComponent",{get:function(){return this._x*this._y*this._z==0},enumerable:!1,configurable:!0}),e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.reorderInPlace=function(e){if("xyz"===(e=e.toLowerCase()))return this;var t=W.Vector3[0].copyFrom(this);return this.x=t[e[0]],this.y=t[e[1]],this.z=t[e[2]],this},e.prototype.rotateByQuaternionToRef=function(t,i){return t.toRotationMatrix(W.Matrix[0]),e.TransformCoordinatesToRef(this,W.Matrix[0],i),i},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,i){return this.subtractToRef(t,W.Vector3[0]),W.Vector3[0].rotateByQuaternionToRef(e,W.Vector3[0]),t.addToRef(W.Vector3[0],i),i},e.prototype.cross=function(t){return e.CrossToRef(this,t,new e)},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){return this.normalizeToRef(new e)},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFrom(this):this.scaleToRef(1/t,e)},e.prototype.clone=function(){return new e(this._x,this._y,this._z)},e.prototype.copyFrom=function(e){return this.copyFromFloats(e._x,e._y,e._z)},e.prototype.copyFromFloats=function(e,t,i){return this._x=e,this._y=t,this._z=i,this._isDirty=!0,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.setAll=function(e){return this._x=this._y=this._z=e,this._isDirty=!0,this},e.GetClipFactor=function(t,i,r,n){var o=e.Dot(t,r);return(o-n)/(o-e.Dot(i,r))},e.GetAngleBetweenVectors=function(t,i,r){var n=t.normalizeToRef(W.Vector3[1]),o=i.normalizeToRef(W.Vector3[2]),a=e.Dot(n,o);a=F(a,-1,1);var s=Math.acos(a),l=W.Vector3[3];return e.CrossToRef(n,o,l),e.Dot(l,r)>0?isNaN(s)?0:s:isNaN(s)?-Math.PI:-Math.acos(a)},e.GetAngleBetweenVectorsOnPlane=function(t,i,r){W.Vector3[0].copyFrom(t);var n=W.Vector3[0];W.Vector3[1].copyFrom(i);var o=W.Vector3[1];W.Vector3[2].copyFrom(r);var a=W.Vector3[2],s=W.Vector3[3],l=W.Vector3[4];return n.normalize(),o.normalize(),a.normalize(),e.CrossToRef(a,n,s),e.CrossToRef(s,a,l),L(Math.atan2(e.Dot(o,s),e.Dot(o,l)))},e.PitchYawRollToMoveBetweenPointsToRef=function(e,t,i){var r=H.Vector3[0];return t.subtractToRef(e,r),i._y=Math.atan2(r.x,r.z)||0,i._x=Math.atan2(Math.sqrt(Math.pow(r.x,2)+Math.pow(r.z,2)),r.y)||0,i._z=0,i._isDirty=!0,i},e.PitchYawRollToMoveBetweenPoints=function(t,i){var r=e.Zero();return e.PitchYawRollToMoveBetweenPointsToRef(t,i,r)},e.SlerpToRef=function(t,i,r,n){r=F(r,0,1);var o=W.Vector3[0],a=W.Vector3[1];o.copyFrom(t);var s=o.length();o.normalizeFromLength(s),a.copyFrom(i);var l=a.length();a.normalizeFromLength(l);var c,u,h=e.Dot(o,a);if(h<1-A){var d=Math.acos(h),p=1/Math.sin(d);c=Math.sin((1-r)*d)*p,u=Math.sin(r*d)*p}else c=1-r,u=r;return o.scaleInPlace(c),a.scaleInPlace(u),n.copyFrom(o).addInPlace(a),n.scaleInPlace(N(s,l,r)),n},e.SmoothToRef=function(t,i,r,n,o){return e.SlerpToRef(t,i,0===n?1:r/n,o),o},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromFloatArray=function(t,i){return e.FromArray(t,i)},e.FromArrayToRef=function(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._isDirty=!0,i},e.FromFloatArrayToRef=function(t,i,r){return e.FromArrayToRef(t,i,r)},e.FromFloatsToRef=function(e,t,i,r){return r.copyFromFloats(e,t,i),r},e.Zero=function(){return new e(0,0,0)},e.One=function(){return new e(1,1,1)},e.Up=function(){return new e(0,1,0)},Object.defineProperty(e,"UpReadOnly",{get:function(){return e._UpReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DownReadOnly",{get:function(){return e._DownReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RightReadOnly",{get:function(){return e._RightReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LeftReadOnly",{get:function(){return e._LeftReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LeftHandedForwardReadOnly",{get:function(){return e._LeftHandedForwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RightHandedForwardReadOnly",{get:function(){return e._RightHandedForwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LeftHandedBackwardReadOnly",{get:function(){return e._LeftHandedBackwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RightHandedBackwardReadOnly",{get:function(){return e._RightHandedBackwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"OneReadOnly",{get:function(){return e._OneReadOnly},enumerable:!1,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(t){return void 0===t&&(t=!1),new e(0,0,t?-1:1)},e.Backward=function(t){return void 0===t&&(t=!1),new e(0,0,t?1:-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.Random=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=1),new e(D(t,i),D(t,i),D(t,i))},e.RandomToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.copyFromFloats(D(e,t),D(e,t),D(e,t))},e.TransformCoordinates=function(t,i){var r=e.Zero();return e.TransformCoordinatesToRef(t,i,r),r},e.TransformCoordinatesToRef=function(t,i,r){return e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,i,r),r},e.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=r.m,a=e*o[0]+t*o[4]+i*o[8]+o[12],s=e*o[1]+t*o[5]+i*o[9]+o[13],l=e*o[2]+t*o[6]+i*o[10]+o[14],c=1/(e*o[3]+t*o[7]+i*o[11]+o[15]);return n._x=a*c,n._y=s*c,n._z=l*c,n._isDirty=!0,n},e.TransformNormal=function(t,i){var r=e.Zero();return e.TransformNormalToRef(t,i,r),r},e.TransformNormalToRef=function(e,t,i){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i),i},e.TransformNormalFromFloatsToRef=function(e,t,i,r,n){var o=r.m;return n._x=e*o[0]+t*o[4]+i*o[8],n._y=e*o[1]+t*o[5]+i*o[9],n._z=e*o[2]+t*o[6]+i*o[10],n._isDirty=!0,n},e.CatmullRom=function(t,i,r,n,o){var a=o*o,s=o*a;return new e(.5*(2*i._x+(-t._x+r._x)*o+(2*t._x-5*i._x+4*r._x-n._x)*a+(-t._x+3*i._x-3*r._x+n._x)*s),.5*(2*i._y+(-t._y+r._y)*o+(2*t._y-5*i._y+4*r._y-n._y)*a+(-t._y+3*i._y-3*r._y+n._y)*s),.5*(2*i._z+(-t._z+r._z)*o+(2*t._z-5*i._z+4*r._z-n._z)*a+(-t._z+3*i._z-3*r._z+n._z)*s))},e.Clamp=function(t,i,r){var n=new e;return e.ClampToRef(t,i,r,n),n},e.ClampToRef=function(e,t,i,r){var n=e._x;n=(n=n>i._x?i._x:n)i._y?i._y:o)i._z?i._z:a)0&&C<0?(M.copyFrom(a),R=i,P=r):C>0&&I<0?(M.copyFrom(l),R=r,P=n):(M.copyFrom(s).scaleInPlace(-1),R=n,P=i);var O=W.Vector3[9],D=W.Vector3[4];if(R.subtractToRef(v,E),P.subtractToRef(v,O),e.CrossToRef(E,O,D),!(e.Dot(D,c)<0))return o.copyFrom(v),Math.abs(_*m);var N=W.Vector3[5];e.CrossToRef(M,D,N),N.normalize();var L=W.Vector3[9];L.copyFrom(R).subtractInPlace(v);var w=L.length();if(wthis.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},e.prototype.minimizeInPlaceFromFloats=function(e,t,i,r){return this.x=Math.min(e,this.x),this.y=Math.min(t,this.y),this.z=Math.min(i,this.z),this.w=Math.min(r,this.w),this},e.prototype.maximizeInPlaceFromFloats=function(e,t,i,r){return this.x=Math.max(e,this.x),this.y=Math.max(t,this.y),this.z=Math.max(i,this.z),this.w=Math.max(r,this.w),this},e.prototype.floorToRef=function(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e.z=Math.floor(this.z),e.w=Math.floor(this.w),e},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fractToRef=function(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e.z=this.z-Math.floor(this.z),e.w=this.w-Math.floor(this.w),e},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){return this.normalizeToRef(new e)},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?(e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w,e):this.scaleToRef(1/t,e)},e.prototype.toVector3=function(){return new V(this.x,this.y,this.z)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){return i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3],i},e.FromFloatArrayToRef=function(t,i,r){return e.FromArrayToRef(t,i,r),r},e.FromFloatsToRef=function(e,t,i,r,n){return n.x=e,n.y=t,n.z=i,n.w=r,n},e.Zero=function(){return new e(0,0,0,0)},e.One=function(){return new e(1,1,1,1)},e.Random=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=1),new e(D(t,i),D(t,i),D(t,i),D(t,i))},e.RandomToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.x=D(e,t),i.y=D(e,t),i.z=D(e,t),i.w=D(e,t),i},e.Clamp=function(t,i,r){return e.ClampToRef(t,i,r,new e)},e.ClampToRef=function(e,t,i,r){return r.x=F(e.x,t.x,i.x),r.y=F(e.y,t.y,i.y),r.z=F(e.z,t.z,i.z),r.w=F(e.w,t.w,i.w),r},e.CheckExtends=function(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)},Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!1,configurable:!0}),e.Normalize=function(t){return e.NormalizeToRef(t,new e)},e.NormalizeToRef=function(e,t){return e.normalizeToRef(t),t},e.Minimize=function(t,i){var r=new e;return r.copyFrom(t),r.minimizeInPlace(i),r},e.Maximize=function(t,i){var r=new e;return r.copyFrom(t),r.maximizeInPlace(i),r},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},e.Center=function(t,i){return e.CenterToRef(t,i,new e)},e.CenterToRef=function(e,t,i){return i.x=(e.x+t.x)/2,i.y=(e.y+t.y)/2,i.z=(e.z+t.z)/2,i.w=(e.w+t.w)/2,i},e.TransformCoordinates=function(t,i){return e.TransformCoordinatesToRef(t,i,new e)},e.TransformCoordinatesToRef=function(t,i,r){return e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,i,r),r},e.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=r.m,a=e*o[0]+t*o[4]+i*o[8]+o[12],s=e*o[1]+t*o[5]+i*o[9]+o[13],l=e*o[2]+t*o[6]+i*o[10]+o[14],c=e*o[3]+t*o[7]+i*o[11]+o[15];return n.x=a,n.y=s,n.z=l,n.w=c,n},e.TransformNormal=function(t,i){return e.TransformNormalToRef(t,i,new e)},e.TransformNormalToRef=function(e,t,i){var r=t.m,n=e.x*r[0]+e.y*r[4]+e.z*r[8],o=e.x*r[1]+e.y*r[5]+e.z*r[9],a=e.x*r[2]+e.y*r[6]+e.z*r[10];return i.x=n,i.y=o,i.z=a,i.w=e.w,i},e.TransformNormalFromFloatsToRef=function(e,t,i,r,n,o){var a=n.m;return o.x=e*a[0]+t*a[4]+i*a[8],o.y=e*a[1]+t*a[5]+i*a[9],o.z=e*a[2]+t*a[6]+i*a[10],o.w=r,o},e.FromVector3=function(t,i){return void 0===i&&(i=0),new e(t._x,t._y,t._z,i)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},e._ZeroReadOnly=e.Zero(),e}();Object.defineProperties(k.prototype,{dimension:{value:[4]},rank:{value:1}});var G=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=r}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"w",{get:function(){return this._w},set:function(e){this._w=e,this._isDirty=!0},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"{X: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(this._z," W: ").concat(this._w,"}")},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=B(this._x);return 397*(e=397*(e=397*e^B(this._y))^B(this._z))^B(this._w)},e.prototype.asArray=function(){return[this._x,this._y,this._z,this._w]},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this)},e.prototype.equals=function(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=A),e&&O(this._x,e._x,t)&&O(this._y,e._y,t)&&O(this._z,e._z,t)&&O(this._w,e._w,t)},e.prototype.clone=function(){return new e(this._x,this._y,this._z,this._w)},e.prototype.copyFrom=function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._isDirty=!0,this},e.prototype.copyFromFloats=function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._isDirty=!0,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.setAll=function(e){return this.copyFromFloats(e,e,e,e)},e.prototype.add=function(t){return new e(this._x+t._x,this._y+t._y,this._z+t._z,this._w+t._w)},e.prototype.addInPlace=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._isDirty=!0,this},e.prototype.addToRef=function(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._w=this._w+e._w,t._isDirty=!0,t},e.prototype.addInPlaceFromFloats=function(e,t,i,r){return this._x+=e,this._y+=t,this._z+=i,this._w+=r,this._isDirty=!0,this},e.prototype.subtractToRef=function(e,t){return t._x=this._x-e._x,t._y=this._y-e._y,t._z=this._z-e._z,t._w=this._w-e._w,t._isDirty=!0,t},e.prototype.subtractFromFloats=function(t,i,r,n){return this.subtractFromFloatsToRef(t,i,r,n,new e)},e.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n._x=this._x-e,n._y=this._y-t,n._z=this._z-i,n._w=this._w-r,n._isDirty=!0,n},e.prototype.subtract=function(t){return new e(this._x-t._x,this._y-t._y,this._z-t._z,this._w-t._w)},e.prototype.subtractInPlace=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._isDirty=!0,this},e.prototype.scale=function(t){return new e(this._x*t,this._y*t,this._z*t,this._w*t)},e.prototype.scaleToRef=function(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._w=this._w*e,t._isDirty=!0,t},e.prototype.scaleInPlace=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._isDirty=!0,this},e.prototype.scaleAndAddToRef=function(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._w+=this._w*e,t._isDirty=!0,t},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,r=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,n=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,o=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,r,n,o),t},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this)},e.prototype.multiplyByFloats=function(e,t,i,r){return this._x*=e,this._y*=t,this._z*=i,this._w*=r,this._isDirty=!0,this},e.prototype.divide=function(e){throw new ReferenceError("Can not divide a quaternion")},e.prototype.divideToRef=function(e,t){throw new ReferenceError("Can not divide a quaternion")},e.prototype.divideInPlace=function(e){throw new ReferenceError("Can not divide a quaternion")},e.prototype.minimizeInPlace=function(){throw new ReferenceError("Can not minimize a quaternion")},e.prototype.minimizeInPlaceFromFloats=function(){throw new ReferenceError("Can not minimize a quaternion")},e.prototype.maximizeInPlace=function(){throw new ReferenceError("Can not maximize a quaternion")},e.prototype.maximizeInPlaceFromFloats=function(){throw new ReferenceError("Can not maximize a quaternion")},e.prototype.negate=function(){return this.negateToRef(new e)},e.prototype.negateInPlace=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this},e.prototype.negateToRef=function(e){return e._x=-this._x,e._y=-this._y,e._z=-this._z,e._w=-this._w,e._isDirty=!0,e},e.prototype.equalsToFloats=function(e,t,i,r){return this._x===e&&this._y===t&&this._z===i&&this._w===r},e.prototype.floorToRef=function(e){throw new ReferenceError("Can not floor a quaternion")},e.prototype.floor=function(){throw new ReferenceError("Can not floor a quaternion")},e.prototype.fractToRef=function(e){throw new ReferenceError("Can not fract a quaternion")},e.prototype.fract=function(){throw new ReferenceError("Can not fract a quaternion")},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),e},e.prototype.conjugateInPlace=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this},e.prototype.conjugate=function(){return new e(-this._x,-this._y,-this._z,this._w)},e.prototype.invert=function(){var e=this.conjugate(),t=this.lengthSquared();return 0==t||1==t||e.scaleInPlace(1/t),e},e.prototype.invertInPlace=function(){this.conjugateInPlace();var e=this.lengthSquared();return 0==e||1==e||this.scaleInPlace(1/e),this},e.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},e.prototype.length=function(){return Math.sqrt(this.lengthSquared())},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){var t=new e(0,0,0,1);return this.normalizeToRef(t),t},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/t,e)},e.prototype.toEulerAngles=function(){var e=V.Zero();return this.toEulerAnglesToRef(e),e},e.prototype.toEulerAnglesToRef=function(e){var t=this._z,i=this._x,r=this._y,n=this._w,o=r*t-i*n,a=.4999999;if(o<-a)e._y=2*Math.atan2(r,n),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(o>a)e._y=2*Math.atan2(r,n),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{var s=n*n,l=t*t,c=i*i,u=r*r;e._z=Math.atan2(2*(i*r+t*n),-l-c+u+s),e._x=Math.asin(-2*o),e._y=Math.atan2(2*(t*i+r*n),l-c-u+s),e._isDirty=!0}return e},e.prototype.toRotationMatrix=function(e){return z.FromQuaternionToRef(this,e),e},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.prototype.dot=function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],a=r[8],s=r[1],l=r[5],c=r[9],u=r[2],h=r[6],d=r[10],p=n+l+d;return p>0?(i=.5/Math.sqrt(p+1),t._w=.25/i,t._x=(h-c)*i,t._y=(a-u)*i,t._z=(s-o)*i,t._isDirty=!0):n>l&&n>d?(i=2*Math.sqrt(1+n-l-d),t._w=(h-c)/i,t._x=.25*i,t._y=(o+s)/i,t._z=(a+u)/i,t._isDirty=!0):l>d?(i=2*Math.sqrt(1+l-n-d),t._w=(a-u)/i,t._x=(o+s)/i,t._y=.25*i,t._z=(c+h)/i,t._isDirty=!0):(i=2*Math.sqrt(1+d-n-l),t._w=(s-o)/i,t._x=(a+u)/i,t._y=(c+h)/i,t._z=.25*i,t._isDirty=!0),t},e.Dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.AreClose=function(t,i,r){void 0===r&&(r=.1);var n=e.Dot(t,i);return 1-n*n<=r},e.SmoothToRef=function(t,i,r,n,o){var a=0===n?1:r/n;return a=F(a,0,1),e.SlerpToRef(t,i,a,o),o},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t._x,-t._y,-t._z,t._w)},e.InverseToRef=function(e,t){return t.set(-e._x,-e._y,-e._z,e._w),t},e.Identity=function(){return new e(0,0,0,1)},e.IsIdentity=function(e){return e&&0===e._x&&0===e._y&&0===e._z&&1===e._w},e.RotationAxis=function(t,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i._w=Math.cos(t/2),i._x=e._x*r,i._y=e._y*r,i._z=e._z*r,i._isDirty=!0,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._w=e[t+3],i._isDirty=!0,i},e.FromFloatsToRef=function(e,t,i,r,n){return n.copyFromFloats(e,t,i,r),n},e.FromEulerAngles=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(i,t,r,n),n},e.FromEulerAnglesToRef=function(t,i,r,n){return e.RotationYawPitchRollToRef(i,t,r,n),n},e.FromEulerVector=function(t){var i=new e;return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.FromEulerVectorToRef=function(t,i){return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.FromUnitVectorsToRef=function(e,t,i,r){void 0===r&&(r=A);var n=V.Dot(e,t)+1;return nMath.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(V.CrossToRef(e,t,H.Vector3[0]),i.set(H.Vector3[0].x,H.Vector3[0].y,H.Vector3[0].z,n)),i.normalize()},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,a=.5*e,s=Math.sin(n),l=Math.cos(n),c=Math.sin(o),u=Math.cos(o),h=Math.sin(a),d=Math.cos(a);return r._x=d*c*l+h*u*s,r._y=h*u*l-d*c*s,r._z=d*u*s-h*c*l,r._w=d*u*l+h*c*s,r._isDirty=!0,r},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),a=.5*t;return r._x=Math.cos(o)*Math.sin(a),r._y=Math.sin(o)*Math.sin(a),r._z=Math.sin(n)*Math.cos(a),r._w=Math.cos(n)*Math.cos(a),r._isDirty=!0,r},e.RotationQuaternionFromAxis=function(t,i,r){var n=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,i,r,n),n},e.RotationQuaternionFromAxisToRef=function(t,i,r,n){var o=W.Matrix[0];return z.FromXYZAxesToRef(t.normalize(),i.normalize(),r.normalize(),o),e.FromRotationMatrixToRef(o,n),n},e.FromLookDirectionLH=function(t,i){var r=new e;return e.FromLookDirectionLHToRef(t,i,r),r},e.FromLookDirectionLHToRef=function(t,i,r){var n=W.Matrix[0];return z.LookDirectionLHToRef(t,i,n),e.FromRotationMatrixToRef(n,r),r},e.FromLookDirectionRH=function(t,i){var r=new e;return e.FromLookDirectionRHToRef(t,i,r),r},e.FromLookDirectionRHToRef=function(t,i,r){var n=W.Matrix[0];return z.LookDirectionRHToRef(t,i,n),e.FromRotationMatrixToRef(n,r)},e.Slerp=function(t,i,r){var n=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,a=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,s=!1;if(a<0&&(s=!0,a=-a),a>.999999)o=1-i,n=s?-i:i;else{var l=Math.acos(a),c=1/Math.sin(l);o=Math.sin((1-i)*l)*c,n=s?-Math.sin(i*l)*c:Math.sin(i*l)*c}return r._x=o*e._x+n*t._x,r._y=o*e._y+n*t._y,r._z=o*e._z+n*t._z,r._w=o*e._w+n*t._w,r._isDirty=!0,r},e.Hermite=function(t,i,r,n,o){var a=o*o,s=o*a,l=2*s-3*a+1,c=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t._x*l+r._x*c+i._x*u+n._x*h,t._y*l+r._y*c+i._y*u+n._y*h,t._z*l+r._z*c+i._z*u+n._z*h,t._w*l+r._w*c+i._w*u+n._w*h)},e.Hermite1stDerivative=function(t,i,r,n,o){var a=new e;return this.Hermite1stDerivativeToRef(t,i,r,n,o,a),a},e.Hermite1stDerivativeToRef=function(e,t,i,r,n,o){var a=n*n;return o._x=6*(a-n)*e._x+(3*a-4*n+1)*t._x+6*(-a+n)*i._x+(3*a-2*n)*r._x,o._y=6*(a-n)*e._y+(3*a-4*n+1)*t._y+6*(-a+n)*i._y+(3*a-2*n)*r._y,o._z=6*(a-n)*e._z+(3*a-4*n+1)*t._z+6*(-a+n)*i._z+(3*a-2*n)*r._z,o._w=6*(a-n)*e._w+(3*a-4*n+1)*t._w+6*(-a+n)*i._w+(3*a-2*n)*r._w,o._isDirty=!0,o},e.Normalize=function(t){var i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){return e.normalizeToRef(t),t},e.Clamp=function(t,i,r){var n=new e;return e.ClampToRef(t,i,r,n),n},e.ClampToRef=function(e,t,i,r){return r.copyFromFloats(F(e.x,t.x,i.x),F(e.y,t.y,i.y),F(e.z,t.z,i.z),F(e.w,t.w,i.w))},e.Random=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=1),new e(D(t,i),D(t,i),D(t,i),D(t,i))},e.RandomToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.copyFromFloats(D(e,t),D(e,t),D(e,t),D(e,t))},e.Minimize=function(){throw new ReferenceError("Quaternion.Minimize does not make sense")},e.Maximize=function(){throw new ReferenceError("Quaternion.Maximize does not make sense")},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},e.Center=function(t,i){return e.CenterToRef(t,i,e.Zero())},e.CenterToRef=function(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)},e}();Object.defineProperties(G.prototype,{dimension:{value:[4]},rank:{value:1}});var z=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,I.MatrixTrackPrecisionChange&&I.MatrixTrackedMatrices.push(this),this._m=new I.MatrixCurrentType(16),this.markAsUpdated()}return Object.defineProperty(e,"Use64Bits",{get:function(){return I.MatrixUse64Bits},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!1,configurable:!0}),e.prototype.markAsUpdated=function(){this.updateFlag=e._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},e.prototype._updateIdentityStatus=function(e,t,i,r){void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!0),this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=!this._isIdentity&&t,this._isIdentity3x2Dirty=!this._isIdentity3x2&&r},e.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity},e.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==this._m[1]||0!==this._m[2]||0!==this._m[3]||0!==this._m[4]||0!==this._m[6]||0!==this._m[7]||0!==this._m[8]||0!==this._m[9]||0!==this._m[10]||0!==this._m[11]||0!==this._m[12]||0!==this._m[13]||0!==this._m[14]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},e.prototype.determinant=function(){if(!0===this._isIdentity)return 1;var e=this._m,t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],p=e[12],f=e[13],_=e[14],m=e[15],g=h*m-_*d,v=u*m-f*d,y=u*_-f*h,b=c*m-p*d,T=c*_-h*p,E=c*f-p*u;return t*+(a*g-s*v+l*y)+i*-(o*g-s*b+l*T)+r*+(o*v-a*b+l*E)+n*-(o*y-a*T+s*E)},e.prototype.toString=function(){return"{".concat(this.m[0],", ").concat(this.m[1],", ").concat(this.m[2],", ").concat(this.m[3],"\n").concat(this.m[4],", ").concat(this.m[5],", ").concat(this.m[6],", ").concat(this.m[7],"\n").concat(this.m[8],", ").concat(this.m[9],", ").concat(this.m[10],", ").concat(this.m[11],"\n").concat(this.m[12],", ").concat(this.m[13],", ").concat(this.m[14],", ").concat(this.m[15],"}")},e.prototype.toArray=function(e,t){if(void 0===e&&(e=null),void 0===t&&(t=0),!e)return this._m;for(var i=this._m,r=0;r<16;r++)e[t+r]=i[r];return this},e.prototype.asArray=function(){return this._m},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this)},e.prototype.copyFromFloats=function(){for(var t=[],i=0;i3)return null;var t=4*e;return new k(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])},e.prototype.getRowToRef=function(e,t){if(e>=0&&e<=3){var i=4*e;t.x=this._m[i+0],t.y=this._m[i+1],t.z=this._m[i+2],t.w=this._m[i+3]}return t},e.prototype.setRow=function(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)},e.prototype.transpose=function(){var t=new e;return e.TransposeToRef(this,t),t},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),t},e.prototype.setRowFromFloats=function(e,t,i,r,n){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=i,this._m[o+2]=r,this._m[o+3]=n,this.markAsUpdated(),this},e.prototype.scale=function(t){var i=new e;return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]=this._m[i]*e;return t.markAsUpdated(),t},e.prototype.scaleAndAddToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t.markAsUpdated(),t},e.prototype.scaleInPlace=function(e){for(var t=this._m,i=0;i<16;i++)t[i]*=e;return this.markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var i=W.Matrix[0];this.invertToRef(i),i.transposeToRef(t);var r=t._m;return e.FromValuesToRef(r[0],r[1],r[2],0,r[4],r[5],r[6],0,r[8],r[9],r[10],0,0,0,0,1,t),t},e.prototype.getRotationMatrix=function(){var t=new e;return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var i=W.Vector3[0];if(!this.decompose(i))return e.IdentityToRef(t),t;var r=this._m,n=1/i._x,o=1/i._y,a=1/i._z;return e.FromValuesToRef(r[0]*n,r[1]*n,r[2]*n,0,r[4]*o,r[5]*o,r[6]*o,0,r[8]*a,r[9]*a,r[10]*a,0,0,0,0,1,t),t},e.prototype.toggleModelMatrixHandInPlace=function(){var e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this},e.prototype.toggleProjectionMatrixHandInPlace=function(){var e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this},e.FromArray=function(t,i){void 0===i&&(i=0);var r=new e;return e.FromArrayToRef(t,i,r),r},e.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i._m[r]=e[r+t];return i.markAsUpdated(),i},e.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r._m[n]=e[n+t]*i;return r.markAsUpdated(),r},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._IdentityReadOnly},enumerable:!1,configurable:!0}),e.FromValuesToRef=function(e,t,i,r,n,o,a,s,l,c,u,h,d,p,f,_,m){var g=m._m;g[0]=e,g[1]=t,g[2]=i,g[3]=r,g[4]=n,g[5]=o,g[6]=a,g[7]=s,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=p,g[14]=f,g[15]=_,m.markAsUpdated()},e.FromValues=function(t,i,r,n,o,a,s,l,c,u,h,d,p,f,_,m){var g=new e,v=g._m;return v[0]=t,v[1]=i,v[2]=r,v[3]=n,v[4]=o,v[5]=a,v[6]=s,v[7]=l,v[8]=c,v[9]=u,v[10]=h,v[11]=d,v[12]=p,v[13]=f,v[14]=_,v[15]=m,g.markAsUpdated(),g},e.Compose=function(t,i,r){var n=new e;return e.ComposeToRef(t,i,r,n),n},e.ComposeToRef=function(e,t,i,r){var n=r._m,o=t._x,a=t._y,s=t._z,l=t._w,c=o+o,u=a+a,h=s+s,d=o*c,p=o*u,f=o*h,_=a*u,m=a*h,g=s*h,v=l*c,y=l*u,b=l*h,T=e._x,E=e._y,S=e._z;return n[0]=(1-(_+g))*T,n[1]=(p+b)*T,n[2]=(f-y)*T,n[3]=0,n[4]=(p-b)*E,n[5]=(1-(d+g))*E,n[6]=(m+v)*E,n[7]=0,n[8]=(f+y)*S,n[9]=(m-v)*S,n[10]=(1-(d+_))*S,n[11]=0,n[12]=i._x,n[13]=i._y,n[14]=i._z,n[15]=1,r.markAsUpdated(),r},e.Identity=function(){var t=e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return t._updateIdentityStatus(!0),t},e.IdentityToRef=function(t){return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(!0),t},e.Zero=function(){var t=e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return t._updateIdentityStatus(!1),t},e.RotationX=function(t){var i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);return e.FromValuesToRef(1,0,0,0,0,n,r,0,0,-r,n,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r),i},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);return e.FromValuesToRef(n,0,-r,0,0,1,0,0,r,0,n,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r),i},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);return e.FromValuesToRef(n,r,0,0,-r,n,0,0,0,0,1,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r),i},e.RotationAxis=function(t,i){var r=new e;return e.RotationAxisToRef(t,i,r),r},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize();var a=i._m;return a[0]=e._x*e._x*o+n,a[1]=e._x*e._y*o-e._z*r,a[2]=e._x*e._z*o+e._y*r,a[3]=0,a[4]=e._y*e._x*o+e._z*r,a[5]=e._y*e._y*o+n,a[6]=e._y*e._z*o-e._x*r,a[7]=0,a[8]=e._z*e._x*o-e._y*r,a[9]=e._z*e._y*o+e._x*r,a[10]=e._z*e._z*o+n,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i.markAsUpdated(),i},e.RotationAlignToRef=function(e,t,i,r){void 0===r&&(r=!1);var n=V.Dot(t,e),o=i._m;if(n<-1+A)o[0]=-1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=r?1:-1,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=r?-1:1,o[11]=0;else{var a=V.Cross(t,e),s=1/(1+n);o[0]=a._x*a._x*s+n,o[1]=a._y*a._x*s-a._z,o[2]=a._z*a._x*s+a._y,o[3]=0,o[4]=a._x*a._y*s+a._z,o[5]=a._y*a._y*s+n,o[6]=a._z*a._y*s-a._x,o[7]=0,o[8]=a._x*a._z*s-a._y,o[9]=a._y*a._z*s+a._x,o[10]=a._z*a._z*s+n,o[11]=0}return o[12]=0,o[13]=0,o[14]=0,o[15]=1,i.markAsUpdated(),i},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){return G.RotationYawPitchRollToRef(e,t,i,W.Quaternion[0]),W.Quaternion[0].toRotationMatrix(r),r},e.Scaling=function(t,i,r){var n=new e;return e.ScalingToRef(t,i,r,n),n},e.ScalingToRef=function(t,i,r,n){return e.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,n),n._updateIdentityStatus(1===t&&1===i&&1===r),n},e.Translation=function(t,i,r){var n=new e;return e.TranslationToRef(t,i,r,n),n},e.TranslationToRef=function(t,i,r,n){return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1,n),n._updateIdentityStatus(0===t&&0===i&&0===r),n},e.Lerp=function(t,i,r){var n=new e;return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){for(var n=r._m,o=e.m,a=t.m,s=0;s<16;s++)n[s]=o[s]*(1-i)+a[s]*i;return r.markAsUpdated(),r},e.DecomposeLerp=function(t,i,r){var n=new e;return e.DecomposeLerpToRef(t,i,r,n),n},e.DecomposeLerpToRef=function(t,i,r,n){var o=W.Vector3[0],a=W.Quaternion[0],s=W.Vector3[1];t.decompose(o,a,s);var l=W.Vector3[2],c=W.Quaternion[1],u=W.Vector3[3];i.decompose(l,c,u);var h=W.Vector3[4];V.LerpToRef(o,l,r,h);var d=W.Quaternion[2];G.SlerpToRef(a,c,r,d);var p=W.Vector3[5];return V.LerpToRef(s,u,r,p),e.ComposeToRef(h,d,p,n),n},e.LookAtLH=function(t,i,r){var n=new e;return e.LookAtLHToRef(t,i,r,n),n},e.LookAtLHToRef=function(t,i,r,n){var o=W.Vector3[0],a=W.Vector3[1],s=W.Vector3[2];i.subtractToRef(t,s),s.normalize(),V.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),V.CrossToRef(s,o,a),a.normalize();var c=-V.Dot(o,t),u=-V.Dot(a,t),h=-V.Dot(s,t);return e.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,c,u,h,1,n),n},e.LookAtRH=function(t,i,r){var n=new e;return e.LookAtRHToRef(t,i,r,n),n},e.LookAtRHToRef=function(t,i,r,n){var o=W.Vector3[0],a=W.Vector3[1],s=W.Vector3[2];t.subtractToRef(i,s),s.normalize(),V.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),V.CrossToRef(s,o,a),a.normalize();var c=-V.Dot(o,t),u=-V.Dot(a,t),h=-V.Dot(s,t);return e.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,c,u,h,1,n),n},e.LookDirectionLH=function(t,i){var r=new e;return e.LookDirectionLHToRef(t,i,r),r},e.LookDirectionLHToRef=function(t,i,r){var n=W.Vector3[0];n.copyFrom(t),n.scaleInPlace(-1);var o=W.Vector3[1];return V.CrossToRef(i,n,o),e.FromValuesToRef(o._x,o._y,o._z,0,i._x,i._y,i._z,0,n._x,n._y,n._z,0,0,0,0,1,r),r},e.LookDirectionRH=function(t,i){var r=new e;return e.LookDirectionRHToRef(t,i,r),r},e.LookDirectionRHToRef=function(t,i,r){var n=W.Vector3[2];return V.CrossToRef(i,t,n),e.FromValuesToRef(n._x,n._y,n._z,0,i._x,i._y,i._z,0,t._x,t._y,t._z,0,0,0,0,1,r),r},e.OrthoLH=function(t,i,r,n,o){var a=new e;return e.OrthoLHToRef(t,i,r,n,a,o),a},e.OrthoLHToRef=function(t,i,r,n,o,a){var s=2/t,l=2/i,c=2/(n-r),u=-(n+r)/(n-r);return e.FromValuesToRef(s,0,0,0,0,l,0,0,0,0,c,0,0,0,u,1,o),a&&o.multiplyToRef(X,o),o._updateIdentityStatus(1===s&&1===l&&1===c&&0===u),o},e.OrthoOffCenterLH=function(t,i,r,n,o,a,s){var l=new e;return e.OrthoOffCenterLHToRef(t,i,r,n,o,a,l,s),l},e.OrthoOffCenterLHToRef=function(t,i,r,n,o,a,s,l){var c=2/(i-t),u=2/(n-r),h=2/(a-o),d=-(a+o)/(a-o),p=(t+i)/(t-i),f=(n+r)/(r-n);return e.FromValuesToRef(c,0,0,0,0,u,0,0,0,0,h,0,p,f,d,1,s),l&&s.multiplyToRef(X,s),s.markAsUpdated(),s},e.ObliqueOffCenterLHToRef=function(t,i,r,n,o,a,s,l,c,u,h){var d=-s*Math.cos(l),p=-s*Math.sin(l);return e.TranslationToRef(0,0,-c,W.Matrix[1]),e.FromValuesToRef(1,0,0,0,0,1,0,0,d,p,1,0,0,0,0,1,W.Matrix[0]),W.Matrix[1].multiplyToRef(W.Matrix[0],W.Matrix[0]),e.TranslationToRef(0,0,c,W.Matrix[1]),W.Matrix[0].multiplyToRef(W.Matrix[1],W.Matrix[0]),e.OrthoOffCenterLHToRef(t,i,r,n,o,a,u,h),W.Matrix[0].multiplyToRef(u,u),u},e.OrthoOffCenterRH=function(t,i,r,n,o,a,s){var l=new e;return e.OrthoOffCenterRHToRef(t,i,r,n,o,a,l,s),l},e.OrthoOffCenterRHToRef=function(t,i,r,n,o,a,s,l){return e.OrthoOffCenterLHToRef(t,i,r,n,o,a,s,l),s._m[10]*=-1,s},e.ObliqueOffCenterRHToRef=function(t,i,r,n,o,a,s,l,c,u,h){var d=s*Math.cos(l),p=s*Math.sin(l);return e.TranslationToRef(0,0,c,W.Matrix[1]),e.FromValuesToRef(1,0,0,0,0,1,0,0,d,p,1,0,0,0,0,1,W.Matrix[0]),W.Matrix[1].multiplyToRef(W.Matrix[0],W.Matrix[0]),e.TranslationToRef(0,0,-c,W.Matrix[1]),W.Matrix[0].multiplyToRef(W.Matrix[1],W.Matrix[0]),e.OrthoOffCenterRHToRef(t,i,r,n,o,a,u,h),W.Matrix[0].multiplyToRef(u,u),u},e.PerspectiveLH=function(t,i,r,n,o,a){void 0===a&&(a=0);var s=new e,l=2*r/t,c=2*r/i,u=(n+r)/(n-r),h=-2*n*r/(n-r),d=Math.tan(a);return e.FromValuesToRef(l,0,0,0,0,c,0,d,0,0,u,1,0,0,h,0,s),o&&s.multiplyToRef(X,s),s._updateIdentityStatus(!1),s},e.PerspectiveFovLH=function(t,i,r,n,o,a,s){void 0===a&&(a=0),void 0===s&&(s=!1);var l=new e;return e.PerspectiveFovLHToRef(t,i,r,n,l,!0,o,a,s),l},e.PerspectiveFovLHToRef=function(t,i,r,n,o,a,s,l,c){void 0===a&&(a=!0),void 0===l&&(l=0),void 0===c&&(c=!1);var u=r,h=n,d=1/Math.tan(.5*t),p=a?d/i:d,f=a?d:d*i,_=c&&0===u?-1:0!==h?(h+u)/(h-u):1,m=c&&0===u?2*h:0!==h?-2*h*u/(h-u):-2*u,g=Math.tan(l);return e.FromValuesToRef(p,0,0,0,0,f,0,g,0,0,_,1,0,0,m,0,o),s&&o.multiplyToRef(X,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovReverseLHToRef=function(t,i,r,n,o,a,s,l){void 0===a&&(a=!0),void 0===l&&(l=0);var c=1/Math.tan(.5*t),u=a?c/i:c,h=a?c:c*i,d=Math.tan(l);return e.FromValuesToRef(u,0,0,0,0,h,0,d,0,0,-r,1,0,0,1,0,o),s&&o.multiplyToRef(X,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovRH=function(t,i,r,n,o,a,s){void 0===a&&(a=0),void 0===s&&(s=!1);var l=new e;return e.PerspectiveFovRHToRef(t,i,r,n,l,!0,o,a,s),l},e.PerspectiveFovRHToRef=function(t,i,r,n,o,a,s,l,c){void 0===a&&(a=!0),void 0===l&&(l=0),void 0===c&&(c=!1);var u=r,h=n,d=1/Math.tan(.5*t),p=a?d/i:d,f=a?d:d*i,_=c&&0===u?1:0!==h?-(h+u)/(h-u):-1,m=c&&0===u?2*h:0!==h?-2*h*u/(h-u):-2*u,g=Math.tan(l);return e.FromValuesToRef(p,0,0,0,0,f,0,g,0,0,_,-1,0,0,m,0,o),s&&o.multiplyToRef(X,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovReverseRHToRef=function(t,i,r,n,o,a,s,l){void 0===a&&(a=!0),void 0===l&&(l=0);var c=1/Math.tan(.5*t),u=a?c/i:c,h=a?c:c*i,d=Math.tan(l);return e.FromValuesToRef(u,0,0,0,0,h,0,d,0,0,-r,-1,0,0,-1,0,o),s&&o.multiplyToRef(X,o),o._updateIdentityStatus(!1),o},e.GetFinalMatrix=function(t,i,r,n,o,a){var s=t.width,l=t.height,c=t.x,u=t.y,h=e.FromValues(s/2,0,0,0,0,-l/2,0,0,0,0,a-o,0,c+s/2,l/2+u,o,1),d=new e;return i.multiplyToRef(r,d),d.multiplyToRef(n,d),d.multiplyToRef(h,d)},e.GetAsMatrix2x2=function(e){var t=e.m,i=[t[0],t[1],t[4],t[5]];return I.MatrixUse64Bits?i:new Float32Array(i)},e.GetAsMatrix3x3=function(e){var t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return I.MatrixUse64Bits?i:new Float32Array(i)},e.Transpose=function(t){var i=new e;return e.TransposeToRef(t,i),i},e.TransposeToRef=function(e,t){var i=e.m,r=i[0],n=i[4],o=i[8],a=i[12],s=i[1],l=i[5],c=i[9],u=i[13],h=i[2],d=i[6],p=i[10],f=i[14],_=i[3],m=i[7],g=i[11],v=i[15],y=t._m;return y[0]=r,y[1]=n,y[2]=o,y[3]=a,y[4]=s,y[5]=l,y[6]=c,y[7]=u,y[8]=h,y[9]=d,y[10]=p,y[11]=f,y[12]=_,y[13]=m,y[14]=g,y[15]=v,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.ReflectionToRef=function(t,i){t.normalize();var r=t.normal.x,n=t.normal.y,o=t.normal.z,a=-2*r,s=-2*n,l=-2*o;return e.FromValuesToRef(a*r+1,s*r,l*r,0,a*n,s*n+1,l*n,0,a*o,s*o,l*o+1,0,a*t.d,s*t.d,l*t.d,1,i),i},e.FromXYZAxesToRef=function(t,i,r,n){return e.FromValuesToRef(t._x,t._y,t._z,0,i._x,i._y,i._z,0,r._x,r._y,r._z,0,0,0,0,1,n),n},e.FromQuaternionToRef=function(e,t){var i=e._x*e._x,r=e._y*e._y,n=e._z*e._z,o=e._x*e._y,a=e._z*e._w,s=e._z*e._x,l=e._y*e._w,c=e._y*e._z,u=e._x*e._w;return t._m[0]=1-2*(r+n),t._m[1]=2*(o+a),t._m[2]=2*(s-l),t._m[3]=0,t._m[4]=2*(o-a),t._m[5]=1-2*(n+i),t._m[6]=2*(c+u),t._m[7]=0,t._m[8]=2*(s+l),t._m[9]=2*(c-u),t._m[10]=1-2*(r+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t},e._UpdateFlagSeed=0,e._IdentityReadOnly=e.Identity(),e}();Object.defineProperties(z.prototype,{dimension:{value:[4,4]},rank:{value:2}});var W=function(){function e(){}return e.Vector3=C.BuildTuple(11,V.Zero),e.Matrix=C.BuildTuple(2,z.Identity),e.Quaternion=C.BuildTuple(3,G.Zero),e}(),H=function(){function e(){}return e.Vector2=C.BuildTuple(3,U.Zero),e.Vector3=C.BuildTuple(13,V.Zero),e.Vector4=C.BuildTuple(3,k.Zero),e.Quaternion=C.BuildTuple(2,G.Zero),e.Matrix=C.BuildTuple(8,z.Identity),e}();a("BABYLON.Vector2",U),a("BABYLON.Vector3",V),a("BABYLON.Vector4",k),a("BABYLON.Matrix",z);var X=z.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1),j=function(){function e(){}return e.Sign=function(e){return 0==(e=+e)||isNaN(e)?e:e>0?1:-1},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.ILog2=function(e){if(Math.log2)return Math.floor(Math.log2(e));if(e<0)return NaN;if(0===e)return-1/0;var t=0;if(e<1){for(;e<1;)t++,e*=2;t=-t}else if(e>1)for(;e>1;)t++,e=Math.floor(e/2);return t},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var r=e.Repeat(i-t,360);return r>180&&(r-=360),r},e.PingPong=function(t,i){var r=e.Repeat(t,2*i);return i-Math.abs(r-i)},e.SmoothStep=function(t,i,r){var n=e.Clamp(r);return i*(n=-2*n*n*n+3*n*n)+t*(1-n)},e.MoveTowards=function(t,i,r){return Math.abs(i-t)<=r?i:t+e.Sign(i-t)*r},e.MoveTowardsAngle=function(t,i,r){var n=e.DeltaAngle(t,i),o=0;return-r180&&(n-=360),t+n*F(r)},e.InverseLerp=function(e,t,i){return e!=t?F((i-e)/(t-e)):0},e.Hermite=function(e,t,i,r,n){var o=n*n,a=n*o;return e*(2*a-3*o+1)+i*(-2*a+3*o)+t*(a-2*o+n)+r*(a-o)},e.Hermite1stDerivative=function(e,t,i,r,n){var o=n*n;return 6*(o-n)*e+(3*o-4*n+1)*t+6*(-o+n)*i+(3*o-2*n)*r},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.HCF=function(t,i){var r=t%i;return 0===r?i:e.HCF(i,r)},e.TwoPi=2*Math.PI,e.WithinEpsilon=O,e.ToHex=w,e.Clamp=F,e.Lerp=N,e.RandomRange=D,e.NormalizeRadians=L,e}();function Y(e){return Math.pow(e,S)}function K(e){return e<=.04045?.0773993808*e:Math.pow(.947867299*(e+.055),2.4)}function Q(e){return Math.pow(e,E)}function q(e){return e<=.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var Z=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},e.prototype.getClassName=function(){return"Color3"},e.prototype.getHashCode=function(){var e=255*this.r|0;return 397*(e=397*e^255*this.g)^255*this.b},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new J(this.r,this.g,this.b,e)},e.prototype.asArray=function(){return[this.r,this.g,this.b]},e.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t},e.prototype.multiplyInPlace=function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},e.prototype.multiplyByFloats=function(t,i,r){return new e(this.r*t,this.g*i,this.b*r)},e.prototype.divide=function(e){throw new ReferenceError("Can not divide a color")},e.prototype.divideToRef=function(e,t){throw new ReferenceError("Can not divide a color")},e.prototype.divideInPlace=function(e){throw new ReferenceError("Can not divide a color")},e.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e.r,e.g,e.b)},e.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e.r,e.g,e.b)},e.prototype.minimizeInPlaceFromFloats=function(e,t,i){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this},e.prototype.maximizeInPlaceFromFloats=function(e,t,i){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this},e.prototype.floorToRef=function(e){throw new ReferenceError("Can not floor a color")},e.prototype.floor=function(){throw new ReferenceError("Can not floor a color")},e.prototype.fractToRef=function(e){throw new ReferenceError("Can not fract a color")},e.prototype.fract=function(){throw new ReferenceError("Can not fract a color")},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},e.prototype.equalsFloats=function(e,t,i){return this.equalsToFloats(e,t,i)},e.prototype.equalsToFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=A),j.WithinEpsilon(this.r,e.r,t)&&j.WithinEpsilon(this.g,e.g,t)&&j.WithinEpsilon(this.b,e.b,t)},e.prototype.negate=function(){throw new ReferenceError("Can not negate a color")},e.prototype.negateInPlace=function(){throw new ReferenceError("Can not negate a color")},e.prototype.negateToRef=function(e){throw new ReferenceError("Can not negate a color")},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t)},e.prototype.scaleInPlace=function(e){return this.r*=e,this.g*=e,this.b*=e,this},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=F(this.r,e,t),i.g=F(this.g,e,t),i.b=F(this.b,e,t),i},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},e.prototype.addInPlaceFromFloats=function(e,t,i){return this.r+=e,this.g+=t,this.b+=i,this},e.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t},e.prototype.subtractInPlace=function(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this},e.prototype.subtractFromFloats=function(t,i,r){return new e(this.r-t,this.g-i,this.b-r)},e.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-i,r},e.prototype.clone=function(){return new e(this.r,this.g,this.b)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.setAll=function(e){return this.r=this.g=this.b=e,this},e.prototype.toHexString=function(){var e=Math.round(255*this.r),t=Math.round(255*this.g),i=Math.round(255*this.b);return"#"+w(e)+w(t)+w(i)},e.prototype.toHSV=function(){return this.toHSVToRef(new e)},e.prototype.toHSVToRef=function(e){var t=this.r,i=this.g,r=this.b,n=Math.max(t,i,r),o=Math.min(t,i,r),a=0,s=0,l=n,c=n-o;return 0!==n&&(s=c/n),n!=o&&(n==t?(a=(i-r)/c,i=0&&o<=1?(s=n,l=a):o>=1&&o<=2?(s=a,l=n):o>=2&&o<=3?(l=n,c=a):o>=3&&o<=4?(l=a,c=n):o>=4&&o<=5?(s=a,c=n):o>=5&&o<=6&&(s=n,c=a);var u=i-n;return r.r=s+u,r.g=l+u,r.b=c+u,r},e.FromHSV=function(t,i,r){var n=new e(0,0,0);return e.HSVtoRGBToRef(t,i,r,n),n},e.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new e(0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);return e.FromInts(i,r,n)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2]},e.FromInts=function(t,i,r){return new e(t/255,i/255,r/255)},e.Lerp=function(t,i,r){var n=new e(0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i},e.Hermite=function(t,i,r,n,o){var a=o*o,s=o*a,l=2*s-3*a+1,c=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t.r*l+r.r*c+i.r*u+n.r*h,t.g*l+r.g*c+i.g*u+n.g*h,t.b*l+r.b*c+i.b*u+n.b*h)},e.Hermite1stDerivative=function(t,i,r,n,o){var a=e.Black();return this.Hermite1stDerivativeToRef(t,i,r,n,o,a),a},e.Hermite1stDerivativeToRef=function(e,t,i,r,n,o){var a=n*n;o.r=6*(a-n)*e.r+(3*a-4*n+1)*t.r+6*(-a+n)*i.r+(3*a-2*n)*r.r,o.g=6*(a-n)*e.g+(3*a-4*n+1)*t.g+6*(-a+n)*i.g+(3*a-2*n)*r.g,o.b=6*(a-n)*e.b+(3*a-4*n+1)*t.b+6*(-a+n)*i.b+(3*a-2*n)*r.b},e.Red=function(){return new e(1,0,0)},e.Green=function(){return new e(0,1,0)},e.Blue=function(){return new e(0,0,1)},e.Black=function(){return new e(0,0,0)},Object.defineProperty(e,"BlackReadOnly",{get:function(){return e._BlackReadOnly},enumerable:!1,configurable:!0}),e.White=function(){return new e(1,1,1)},e.Purple=function(){return new e(.5,0,.5)},e.Magenta=function(){return new e(1,0,1)},e.Yellow=function(){return new e(1,1,0)},e.Gray=function(){return new e(.5,.5,.5)},e.Teal=function(){return new e(0,1,1)},e.Random=function(){return new e(Math.random(),Math.random(),Math.random())},e._BlackReadOnly=e.Black(),e}();Object.defineProperties(Z.prototype,{dimension:{value:[3]},rank:{value:1}});var J=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.r=e,this.g=t,this.b=i,this.a=r}return e.prototype.asArray=function(){return[this.r,this.g,this.b,this.a]},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this.a=e[t+3],this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t.a=this.a+e.a,t},e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.addInPlaceFromFloats=function(e,t,i,r){return this.r+=e,this.g+=t,this.b+=i,this.a+=r,this},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,t},e.prototype.subtractInPlace=function(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this.a-=e.a,this},e.prototype.subtractFromFloats=function(t,i,r,n){return new e(this.r-t,this.g-i,this.b-r,this.a-n)},e.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n.r=this.r-e,n.g=this.g-t,n.b=this.b-i,n.a=this.a-r,n},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleInPlace=function(e){return this.r*=e,this.g*=e,this.b*=e,this.a*=e,this},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,t},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,t},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=F(this.r,e,t),i.g=F(this.g,e,t),i.b=F(this.b,e,t),i.a=F(this.a,e,t),i},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.multiplyInPlace=function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this.a*=e.a,this},e.prototype.multiplyByFloats=function(t,i,r,n){return new e(this.r*t,this.g*i,this.b*r,this.a*n)},e.prototype.divide=function(e){throw new ReferenceError("Can not divide a color")},e.prototype.divideToRef=function(e,t){throw new ReferenceError("Can not divide a color")},e.prototype.divideInPlace=function(e){throw new ReferenceError("Can not divide a color")},e.prototype.minimizeInPlace=function(e){return this.r=Math.min(this.r,e.r),this.g=Math.min(this.g,e.g),this.b=Math.min(this.b,e.b),this.a=Math.min(this.a,e.a),this},e.prototype.maximizeInPlace=function(e){return this.r=Math.max(this.r,e.r),this.g=Math.max(this.g,e.g),this.b=Math.max(this.b,e.b),this.a=Math.max(this.a,e.a),this},e.prototype.minimizeInPlaceFromFloats=function(e,t,i,r){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this.a=Math.min(r,this.a),this},e.prototype.maximizeInPlaceFromFloats=function(e,t,i,r){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this.a=Math.max(r,this.a),this},e.prototype.floorToRef=function(e){throw new ReferenceError("Can not floor a color")},e.prototype.floor=function(){throw new ReferenceError("Can not floor a color")},e.prototype.fractToRef=function(e){throw new ReferenceError("Can not fract a color")},e.prototype.fract=function(){throw new ReferenceError("Can not fract a color")},e.prototype.negate=function(){throw new ReferenceError("Can not negate a color")},e.prototype.negateInPlace=function(){throw new ReferenceError("Can not negate a color")},e.prototype.negateToRef=function(e){throw new ReferenceError("Can not negate a color")},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=A),j.WithinEpsilon(this.r,e.r,t)&&j.WithinEpsilon(this.g,e.g,t)&&j.WithinEpsilon(this.b,e.b,t)&&j.WithinEpsilon(this.a,e.a,t)},e.prototype.equalsToFloats=function(e,t,i,r){return this.r===e&&this.g===t&&this.b===i&&this.a===r},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=255*this.r|0;return 397*(e=397*(e=397*e^255*this.g)^255*this.b)^255*this.a},e.prototype.clone=function(){return(new e).copyFrom(this)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.r=e,this.g=t,this.b=i,this.a=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.setAll=function(e){return this.r=this.g=this.b=this.a=e,this},e.prototype.toHexString=function(e){void 0===e&&(e=!1);var t=Math.round(255*this.r),i=Math.round(255*this.g),r=Math.round(255*this.b);if(e)return"#"+w(t)+w(i)+w(r);var n=Math.round(255*this.a);return"#"+w(t)+w(i)+w(r)+w(n)},e.prototype.toLinearSpace=function(t){void 0===t&&(t=!1);var i=new e;return this.toLinearSpaceToRef(i,t),i},e.prototype.toLinearSpaceToRef=function(e,t){return void 0===t&&(t=!1),t?(e.r=K(this.r),e.g=K(this.g),e.b=K(this.b)):(e.r=Y(this.r),e.g=Y(this.g),e.b=Y(this.b)),e.a=this.a,this},e.prototype.toGammaSpace=function(t){void 0===t&&(t=!1);var i=new e;return this.toGammaSpaceToRef(i,t),i},e.prototype.toGammaSpaceToRef=function(e,t){return void 0===t&&(t=!1),t?(e.r=q(this.r),e.g=q(this.g),e.b=q(this.b)):(e.r=Q(this.r),e.g=Q(this.g),e.b=Q(this.b)),e.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length&&7!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),o=9===t.length?parseInt(t.substring(7,9),16):255;return e.FromInts(i,r,n,o)},e.Lerp=function(t,i,r){return e.LerpToRef(t,i,r,new e)},e.LerpToRef=function(e,t,i,r){return r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i,r},e.Hermite=function(t,i,r,n,o){var a=o*o,s=o*a,l=2*s-3*a+1,c=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t.r*l+r.r*c+i.r*u+n.r*h,t.g*l+r.g*c+i.g*u+n.g*h,t.b*l+r.b*c+i.b*u+n.b*h,t.a*l+r.a*c+i.a*u+n.a*h)},e.Hermite1stDerivative=function(t,i,r,n,o){var a=new e;return this.Hermite1stDerivativeToRef(t,i,r,n,o,a),a},e.Hermite1stDerivativeToRef=function(e,t,i,r,n,o){var a=n*n;o.r=6*(a-n)*e.r+(3*a-4*n+1)*t.r+6*(-a+n)*i.r+(3*a-2*n)*r.r,o.g=6*(a-n)*e.g+(3*a-4*n+1)*t.g+6*(-a+n)*i.g+(3*a-2*n)*r.g,o.b=6*(a-n)*e.b+(3*a-4*n+1)*t.b+6*(-a+n)*i.b+(3*a-2*n)*r.b,o.a=6*(a-n)*e.a+(3*a-4*n+1)*t.a+6*(-a+n)*i.a+(3*a-2*n)*r.a},e.FromColor3=function(t,i){return void 0===i&&(i=1),new e(t.r,t.g,t.b,i)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]},e.FromInts=function(t,i,r,n){return new e(t/255,i/255,r/255,n/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],r=0;rthis.value;case t.IsLesser:return this._effectiveTarget[this._property]").concat(o,"
");e._AddLogEntry(l),e._GenerateLimitMessage(n,t)}},Object.defineProperty(e,"LogCache",{get:function(){return e._LogCache},enumerable:!1,configurable:!0}),e.ClearLogCache=function(){e._LogCache="",e._LogLimitOutputs={},e.errorsCount=0},Object.defineProperty(e,"LogLevels",{set:function(t){var i=this;e.Log=e._LogDisabled,e.Warn=e._LogDisabled,e.Error=e._LogDisabled,[e.MessageLogLevel,e.WarningLogLevel,e.ErrorLogLevel].forEach((function(r){(t&r)===r&&(e[i._Levels[r].name]=e._LogEnabled.bind(e,r))}))},enumerable:!1,configurable:!0}),e.NoneLogLevel=0,e.MessageLogLevel=1,e.WarningLogLevel=2,e.ErrorLogLevel=4,e.AllLogLevel=7,e.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",e._LogCache="",e._LogLimitOutputs={},e._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],e.errorsCount=0,e.Log=e._LogEnabled.bind(e,e.MessageLogLevel),e.Warn=e._LogEnabled.bind(e,e.WarningLogLevel),e.Error=e._LogEnabled.bind(e,e.ErrorLogLevel),e}(),se=function(e){function t(t,i,r,n){var o=e.call(this,t,n)||this;return o.propertyPath=r,o._target=o._effectiveTarget=i,o}return m(t,e),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[ee._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},t)},t}(ee),le=function(e){function t(t,i,r,n){var o=e.call(this,t,n)||this;return o.value=r,o._target=i,o}return m(t,e),t.prototype.execute=function(){this._target.state=this.value},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetStateAction",properties:[ee._GetTargetProperty(this._target),{name:"value",value:this.value}]},t)},t}(ee),ce=function(e){function t(t,i,r,n,o){var a=e.call(this,t,o)||this;return a.propertyPath=r,a.value=n,a._target=a._effectiveTarget=i,a}return m(t,e),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetValueAction",properties:[ee._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:ee._SerializeValueAsString(this.value)}]},t)},t}(ee),ue=function(e){function t(t,i,r,n,o){var a=e.call(this,t,o)||this;return a.propertyPath=r,a.value=n,a._target=a._effectiveTarget=i,a}return m(t,e),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&ae.Warn("Warning: IncrementValueAction can only be used with number values")},t.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[ee._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:ee._SerializeValueAsString(this.value)}]},t)},t}(ee),he=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,a)||this;return s.from=r,s.to=n,s.loop=o,s._target=i,s}return m(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[ee._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:ee._SerializeValueAsString(this.loop)||!1}]},t)},t}(ee),de=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._target=i,n}return m(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[ee._GetTargetProperty(this._target)]},t)},t}(ee),pe=function(e){function t(t,i){return void 0===t&&(t=u.ACTION_NothingTrigger),e.call(this,t,i)||this}return m(t,e),t.prototype.execute=function(){},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},t)},t}(ee),fe=function(e){function t(t,i,r,n){void 0===n&&(n=!0);var o=e.call(this,t,r)||this;return o.children=i,o.enableChildrenConditions=n,o}return m(t,e),t.prototype._prepare=function(){for(var e=0;e0)if("object"==typeof c[0])for(var h=0;h-1&&this._scene.actionManagers.splice(i,1);for(var o=0,a=this._scene.meshes.filter((function(t){return t.actionManager===e}));o-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,t){for(var i=0;i=t.OnPickTrigger&&i.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t.OnPickTrigger&&i.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(ae.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),this.getScene()._registeredActions++,t.Triggers[e.trigger]?t.Triggers[e.trigger]++:t.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)},t.prototype.unregisterAction=function(e){var i=this.actions.indexOf(e);return-1!==i&&(this.actions.splice(i,1),t.Triggers[e.trigger]-=1,0===t.Triggers[e.trigger]&&delete t.Triggers[e.trigger],e._actionManager=null,this.getScene()._registeredActions--,!0)},t.prototype.processTrigger=function(e,i){for(var r=0;r0;if(2===e.type?h.push(n):h.push(i),f){for(var _=[],m=0;m0){var h=u.properties[0].value,d=null===u.properties[0].targetType?h:r.getMeshByName(h);d._meshId&&(d.mesh=r.getMeshById(d._meshId)),c={trigger:t[u.name],parameter:d}}else c=t[u.name];for(var p=0;p1)for(var l=0;l0||e.CustomRequestModifiers.length>0},enumerable:!1,configurable:!0}),e.prototype._injectCustomRequestHeaders=function(){if(!this._shouldSkipRequestModifications(this._requestURL))for(var t in e.CustomRequestHeaders){var i=e.CustomRequestHeaders[t];i&&this._xhr.setRequestHeader(t,i)}},e.prototype._shouldSkipRequestModifications=function(t){return e.SkipRequestModificationForBabylonCDN&&(t.includes("preview.babylonjs.com")||t.includes("cdn.babylonjs.com"))},Object.defineProperty(e.prototype,"onprogress",{get:function(){return this._xhr.onprogress},set:function(e){this._xhr.onprogress=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._xhr.readyState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._xhr.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statusText",{get:function(){return this._xhr.statusText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"response",{get:function(){return this._xhr.response},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseURL",{get:function(){return this._xhr.responseURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseText",{get:function(){return this._xhr.responseText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseType",{get:function(){return this._xhr.responseType},set:function(e){this._xhr.responseType=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timeout",{get:function(){return this._xhr.timeout},set:function(e){this._xhr.timeout=e},enumerable:!1,configurable:!0}),e.prototype.addEventListener=function(e,t,i){this._xhr.addEventListener(e,t,i)},e.prototype.removeEventListener=function(e,t,i){this._xhr.removeEventListener(e,t,i)},e.prototype.abort=function(){this._xhr.abort()},e.prototype.send=function(t){e.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(t)},e.prototype.open=function(t,i){for(var r=0,n=e.CustomRequestModifiers;r=0?l.referenceFrame:0,h=0,d=c._keys[0],p=c._keys.length-1,f=c._keys[p],_={referenceValue:d.value,referencePosition:H.Vector3[0],referenceQuaternion:H.Quaternion[0],referenceScaling:H.Vector3[1],keyPosition:H.Vector3[2],keyQuaternion:H.Quaternion[1],keyScaling:H.Vector3[3]},m=d.frame,g=f.frame;if(l.range){var v=c.getRange(l.range);v&&(m=v.from,g=v.to)}else m=null!==(a=l.fromFrame)&&void 0!==a?a:m,g=null!==(s=l.toFrame)&&void 0!==s?s:g;if(m!==d.frame&&(h=c.createKeyForFrame(m)),g!==f.frame&&(p=c.createKeyForFrame(g)),1===c._keys.length){var y=c._getKeyValue(c._keys[0]);_.referenceValue=y.clone?y.clone():y}else u<=d.frame?(y=c._getKeyValue(d.value),_.referenceValue=y.clone?y.clone():y):u>=f.frame?(y=c._getKeyValue(f.value),_.referenceValue=y.clone?y.clone():y):(ot.key=0,y=c._interpolate(u,ot),_.referenceValue=y.clone?y.clone():y);c.dataType===e.ANIMATIONTYPE_QUATERNION?_.referenceValue.normalize().conjugateInPlace():c.dataType===e.ANIMATIONTYPE_MATRIX&&(_.referenceValue.decompose(_.referenceScaling,_.referenceQuaternion,_.referencePosition),_.referenceQuaternion.normalize().conjugateInPlace());for(var b=Number.MAX_VALUE,T=l.clipKeys?[]:null,E=h;E<=p;E++){var S=c._keys[E];if(T&&(S={frame:S.frame,value:S.value.clone?S.value.clone():S.value,inTangent:S.inTangent,outTangent:S.outTangent,interpolation:S.interpolation,lockedTangent:S.lockedTangent},b===Number.MAX_VALUE&&(b=S.frame),S.frame-=b,T.push(S)),!E||c.dataType===e.ANIMATIONTYPE_FLOAT||S.value!==d.value)switch(c.dataType){case e.ANIMATIONTYPE_MATRIX:S.value.decompose(_.keyScaling,_.keyQuaternion,_.keyPosition),_.keyPosition.subtractInPlace(_.referencePosition),_.keyScaling.divideInPlace(_.referenceScaling),_.referenceQuaternion.multiplyToRef(_.keyQuaternion,_.keyQuaternion),z.ComposeToRef(_.keyScaling,_.keyQuaternion,_.keyPosition,S.value);break;case e.ANIMATIONTYPE_QUATERNION:_.referenceValue.multiplyToRef(S.value,S.value);break;case e.ANIMATIONTYPE_VECTOR2:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:case e.ANIMATIONTYPE_COLOR4:S.value.subtractToRef(_.referenceValue,S.value);break;case e.ANIMATIONTYPE_SIZE:S.value.width-=_.referenceValue.width,S.value.height-=_.referenceValue.height;break;default:S.value-=_.referenceValue}}return T&&c.setKeys(T,!0),c},e.TransitionTo=function(e,t,i,r,n,o,a,s){if(void 0===s&&(s=null),a<=0)return i[e]=t,s&&s(),null;var l=n*(a/1e3);o.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:l,value:t}]),i.animations||(i.animations=[]),i.animations.push(o);var c=r.beginAnimation(i,0,l,!1);return c.onAnimationEnd=s,c},Object.defineProperty(e.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var e=0,t=this._runtimeAnimations;e=0;o--)this._keys[o].frame>=r&&this._keys[o].frame<=n&&this._keys.splice(o,1);this._ranges[e]=null}},e.prototype.getRange=function(e){return this._ranges[e]},e.prototype.getKeys=function(){return this._keys},e.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t0)return i.highLimitValue.clone?i.highLimitValue.clone():i.highLimitValue;for(var o=this._keys,a=o.length,s=i.key;s>=0&&t=o[s+1].frame;)++s;if(i.key=s,s<0)return r?void 0:this._getKeyValue(o[0].value);if(s+1>a-1)return r?void 0:this._getKeyValue(o[a-1].value);var l=o[s],c=o[s+1];if(!r||t!==l.frame&&t!==c.frame){var u=this._getKeyValue(l.value),h=this._getKeyValue(c.value);if(l.interpolation===ge.STEP)return c.frame>t?u:h;var d=void 0!==l.outTangent&&void 0!==c.inTangent,p=c.frame-l.frame,f=(t-l.frame)/p,_=l.easingFunction||this.getEasingFunction();switch(null!==_&&(f=_.ease(f)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var m=d?this.floatInterpolateFunctionWithTangents(u,l.outTangent*p,h,c.inTangent*p,f):this.floatInterpolateFunction(u,h,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return m;case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return(null!==(n=i.offsetValue)&&void 0!==n?n:0)*i.repeatCount+m}break;case e.ANIMATIONTYPE_QUATERNION:var g=d?this.quaternionInterpolateFunctionWithTangents(u,l.outTangent.scale(p),h,c.inTangent.scale(p),f):this.quaternionInterpolateFunction(u,h,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return g;case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.addInPlace((i.offsetValue||$e).scale(i.repeatCount))}return g;case e.ANIMATIONTYPE_VECTOR3:var v=d?this.vector3InterpolateFunctionWithTangents(u,l.outTangent.scale(p),h,c.inTangent.scale(p),f):this.vector3InterpolateFunction(u,h,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return v;case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return v.add((i.offsetValue||et).scale(i.repeatCount))}break;case e.ANIMATIONTYPE_VECTOR2:var y=d?this.vector2InterpolateFunctionWithTangents(u,l.outTangent.scale(p),h,c.inTangent.scale(p),f):this.vector2InterpolateFunction(u,h,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return y;case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return y.add((i.offsetValue||tt).scale(i.repeatCount))}break;case e.ANIMATIONTYPE_SIZE:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(u,h,f);case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(u,h,f).add((i.offsetValue||it).scale(i.repeatCount))}break;case e.ANIMATIONTYPE_COLOR3:var b=d?this.color3InterpolateFunctionWithTangents(u,l.outTangent.scale(p),h,c.inTangent.scale(p),f):this.color3InterpolateFunction(u,h,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return b;case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return b.add((i.offsetValue||rt).scale(i.repeatCount))}break;case e.ANIMATIONTYPE_COLOR4:var T=d?this.color4InterpolateFunctionWithTangents(u,l.outTangent.scale(p),h,c.inTangent.scale(p),f):this.color4InterpolateFunction(u,h,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return T;case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return T.add((i.offsetValue||nt).scale(i.repeatCount))}break;case e.ANIMATIONTYPE_MATRIX:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return e.AllowMatricesInterpolation?this.matrixInterpolateFunction(u,h,f,i.workValue):u;case e.ANIMATIONLOOPMODE_RELATIVE:case e.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return u}}return 0}},e.prototype.matrixInterpolateFunction=function(t,i,r,n){return e.AllowMatrixDecomposeForInterpolation?n?(z.DecomposeLerpToRef(t,i,r,n),n):z.DecomposeLerp(t,i,r):n?(z.LerpToRef(t,i,r,n),n):z.Lerp(t,i,r)},e.prototype.clone=function(){var t=new e(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys),this._ranges)for(var i in t._ranges={},this._ranges){var r=this._ranges[i];r&&(t._ranges[i]=r.clone())}return t},e.prototype.setKeys=function(e,t){void 0===t&&(t=!1),this._keys=t?e:e.slice(0)},e.prototype.createKeyForFrame=function(e){ot.key=0;var t=this._interpolate(e,ot,!0);if(!t)return this._keys[ot.key].frame===e?ot.key:ot.key+1;var i={frame:e,value:t.clone?t.clone():t};return this._keys.splice(ot.key+1,0,i),ot.key+1},e.prototype.serialize=function(){var t={};t.name=this.name,t.property=this.targetProperty,t.framePerSecond=this.framePerSecond,t.dataType=this.dataType,t.loopBehavior=this.loopMode,t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed;var i=this.dataType;t.keys=[];for(var r=this.getKeys(),n=0;n=2&&(l=s.values[1]),s.values.length>=3&&(c=s.values[2]),s.values.length>=4&&(u=s.values[3]);break;case e.ANIMATIONTYPE_QUATERNION:if(i=G.FromArray(s.values),s.values.length>=8){var h=G.FromArray(s.values.slice(4,8));h.equals(G.Zero())||(l=h)}if(s.values.length>=12){var d=G.FromArray(s.values.slice(8,12));d.equals(G.Zero())||(c=d)}s.values.length>=13&&(u=s.values[12]);break;case e.ANIMATIONTYPE_MATRIX:i=z.FromArray(s.values),s.values.length>=17&&(u=s.values[16]);break;case e.ANIMATIONTYPE_COLOR3:i=Z.FromArray(s.values),s.values[3]&&(l=Z.FromArray(s.values[3])),s.values[4]&&(c=Z.FromArray(s.values[4])),s.values[5]&&(u=s.values[5]);break;case e.ANIMATIONTYPE_COLOR4:i=J.FromArray(s.values),s.values[4]&&(l=J.FromArray(s.values[4])),s.values[5]&&(c=J.FromArray(s.values[5])),s.values[6]&&(u=J.FromArray(s.values[6]));break;case e.ANIMATIONTYPE_VECTOR3:default:i=V.FromArray(s.values),s.values[3]&&(l=V.FromArray(s.values[3])),s.values[4]&&(c=V.FromArray(s.values[4])),s.values[5]&&(u=s.values[5])}var p={};p.frame=s.frame,p.value=i,null!=l&&(p.inTangent=l),null!=c&&(p.outTangent=c),null!=u&&(p.interpolation=u),a.push(p)}if(n.setKeys(a),t.ranges)for(r=0;r0&&u.forEach((function(e){n._events.push(e._clone())})),this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}return Object.defineProperty(e.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._currentActiveTarget},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAdditive",{get:function(){return this._host&&this._host.isAdditive},enumerable:!1,configurable:!0}),e.prototype._preparePath=function(e,t){void 0===t&&(t=0);var i=this._animation.targetPropertyPath;if(i.length>1){for(var r=e,n=0;n-1&&this._animation.runtimeAnimations.splice(e,1)},e.prototype.setValue=function(e,t){if(this._targetIsArray)for(var i=0;it[t.length-1].frame&&(e=t[t.length-1].frame);var i=this._events;if(i.length)for(var r=0;rthis._maxFrame)&&(t=this._minFrame),(ithis._maxFrame)&&(i=this._maxFrame);var c,u,h=i-t,d=e*(a.framePerSecond*n)/1e3+this._absoluteFrameOffset,p=0,f=!1,_=r&&this._animationState.loopMode===at.ANIMATIONLOOPMODE_YOYO;if(_){var m=(d-t)/h,g=Math.sin(m*Math.PI);d=Math.abs(g)*h+t;var v=g>=0?1:-1;this._yoyoDirection!==v&&(f=!0),this._yoyoDirection=v}if(this._previousElapsedTime=e,this._previousAbsoluteFrame=d,!r&&i>=t&&(d>=h&&n>0||d<=0&&n<0))l=!1,p=a._getKeyValue(this._maxValue);else if(!r&&t>=i&&(d<=h&&n<0||d>=0&&n>0))l=!1,p=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==at.ANIMATIONLOOPMODE_CYCLE){var y=i.toString()+t.toString();if(!this._offsetsCache[y]){this._animationState.repeatCount=0,this._animationState.loopMode=at.ANIMATIONLOOPMODE_CYCLE;var b=a._interpolate(t,this._animationState),T=a._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case at.ANIMATIONTYPE_FLOAT:this._offsetsCache[y]=T-b;break;case at.ANIMATIONTYPE_QUATERNION:case at.ANIMATIONTYPE_VECTOR3:case at.ANIMATIONTYPE_VECTOR2:case at.ANIMATIONTYPE_SIZE:case at.ANIMATIONTYPE_COLOR3:this._offsetsCache[y]=T.subtract(b)}this._highLimitsCache[y]=T}p=this._highLimitsCache[y],c=this._offsetsCache[y]}if(void 0===c)switch(a.dataType){case at.ANIMATIONTYPE_FLOAT:c=0;break;case at.ANIMATIONTYPE_QUATERNION:c=$e;break;case at.ANIMATIONTYPE_VECTOR3:c=et;break;case at.ANIMATIONTYPE_VECTOR2:c=tt;break;case at.ANIMATIONTYPE_SIZE:c=it;break;case at.ANIMATIONTYPE_COLOR3:c=rt;break;case at.ANIMATIONTYPE_COLOR4:c=nt}if(this._host&&this._host.syncRoot){var E=this._host.syncRoot;u=t+h*((E.masterFrame-E.fromFrame)/(E.toFrame-E.fromFrame))}else u=d>0&&t>i||d<0&&t0&&this.currentFrame>u||n<0&&this.currentFrame0?0:a.getKeys().length-1}this._currentFrame=u,this._animationState.repeatCount=0===h?0:d/h|0,this._animationState.highLimitValue=p,this._animationState.offsetValue=c;var A=a._interpolate(u,this._animationState);if(this.setValue(A,o),S.length)for(x=0;x=0&&u>=S[x].frame&&S[x].frame>=t||h<0&&u<=S[x].frame&&S[x].frame<=t){var C=S[x];C.isDone||(C.onlyOnce&&(S.splice(x,1),x--),C.isDone=!0,C.action(u))}return l||(this._stopped=!0),l},e}();function ct(){return"undefined"!=typeof window}function ut(){return"undefined"!=typeof navigator}function ht(){return"undefined"!=typeof document}function dt(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t}var pt,ft={IsWindowObjectExist:ct,IsNavigatorAvailable:ut,IsDocumentAvailable:ht,GetDOMTextContent:dt},_t=function(){function e(){}return Object.defineProperty(e,"Now",{get:function(){return ct()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),e}(),mt=function(){function e(){}return e.FilesToLoad={},e}(),gt=function(){function e(){}return e.ExponentialBackoff=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=500),function(i,r,n){return 0!==r.status||n>=e||-1!==i.indexOf("file:")?-1:Math.pow(2,n)*t}},e}(),vt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),yt={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002},bt=function(e){function t(i,r,n){var o=e.call(this,i)||this;return o.errorCode=r,o.innerError=n,o.name="RuntimeError",vt._setPrototypeOf(o,t.prototype),o}return m(t,e),t}(vt),Tt=function(e,t){return e.endsWith(t)},Et=function(e,t){return!!e&&e.startsWith(t)},St=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",i=0;i>2,o=(3&t)<<4|(i=u>4,a=(15&i)<<2|(r=u>6,s=63&r,isNaN(i)?a=s=64:isNaN(r)&&(s=64),c+=l.charAt(n)+l.charAt(o)+l.charAt(a)+l.charAt(s);return c},At=function(e){return atob(e)},Ct=function(e){for(var t=At(e),i=t.length,r=new Uint8Array(new ArrayBuffer(i)),n=0;n1&&this._lines.push(n);else for(var a=r.split(";"),s=0;s1){for(o();-1!==n&&e._OperatorPriority[s()]>=e._OperatorPriority[d];)r.push(l());a(d),c++}else u+=h;c++}for(o();-1!==n;)"("===s()?l():r.push(l());return e._InfixToPostfixCache.size>=e.InfixToPostfixCacheLimitSize&&e.ClearCache(),e._InfixToPostfixCache.set(t,{result:r,accessTime:Date.now()}),r},e.ClearCache=function(){for(var t=Array.from(e._InfixToPostfixCache.entries()).sort((function(e,t){return e[1].accessTime-t[1].accessTime})),i=0;i":i=r>n;break;case"<":i=r=":i=r>=n;break;case"==":i=r===n;break;case"!=":i=r!==n}return i},t}(Nt);!function(e){e[e.GLSL=0]="GLSL",e[e.WGSL=1]="WGSL"}(pt||(pt={}));var Ut={};function Vt(e,t,i){return void 0===i&&(i=""),i+(t?t+"\n":"")+e}function kt(e,t,i,r,n,o,a){var s=a||Ut.loadFile;if(s)return s(e,t,i,r,n,o);throw He("FileTools")}function Gt(e,t,i,r){if(e)return t?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,i?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,void(r?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS);var n="";return t&&(n+="#define IS_NDC_HALF_ZRANGE"),i&&(n&&(n+="\n"),n+="#define USE_REVERSE_DEPTHBUFFER"),r&&(n&&(n+="\n"),n+="#define USE_EXACT_SRGB_CONVERSIONS"),n}var zt=/defined\s*?\((.+?)\)/g,Wt=/defined\s*?\[(.+?)\]/g,Ht=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,Xt=/__decl__/,jt=/light\{X\}.(\w*)/g,Yt=/\{X\}/g,Kt=[],Qt=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function qt(e){e.processor&&e.processor.initializeShaders&&e.processor.initializeShaders(e.processingContext)}function Zt(e,t,i,r){var n;(null===(n=t.processor)||void 0===n?void 0:n.preProcessShaderCode)&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),oi(e,t,(function(e){t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e));var n=function(e,t,i){var r=function(e,t){var i;if(null===(i=t.processor)||void 0===i?void 0:i.noPrecision)return e;var r=t.shouldUseHighPrecisionShader;return-1===e.indexOf("precision highp float")?e=r?"precision highp float;\n"+e:"precision mediump float;\n"+e:r||(e=e.replace("precision highp float","precision mediump float")),e}(e,t);if(!t.processor)return r;if(t.processor.shaderLanguage===pt.GLSL&&-1!==r.indexOf("#version 3")&&(r=r.replace("#version 300 es",""),!t.processor.parseGLES3))return r;var n=t.defines,o=ni(t,i);return t.processor.preProcessor&&(r=t.processor.preProcessor(r,n,t.isFragment,t.processingContext)),r=ri(r,o,t),t.processor.postProcessor&&(r=t.processor.postProcessor(r,n,t.isFragment,t.processingContext,i?{drawBuffersExtensionDisabled:!i.getCaps().drawBuffersExtension}:{})),(null==i?void 0:i._features.needShaderCodeInlining)&&(r=i.inlineShaderCode(r)),r}(e,t,r);i(n,e)}))}function Jt(e,t,i){return i.processor&&i.processor.finalizeShaders?i.processor.finalizeShaders(e,t,i.processingContext):{vertexCode:e,fragmentCode:t}}function $t(e){var t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new Ft(t[1].trim(),"!"===e[0]);for(var i="",r=0,n=0,o=["==","!=",">=","<=","<",">"];n-1));n++);if(-1===r)return new Ft(e);var a=e.substring(0,r).trim(),s=e.substring(r+i.length).trim();return new Bt(a,i,s)}function ei(e,t){var i=new Dt,r=e.substring(0,t),n=e.substring(t);return n=n.substring(0,(n.indexOf("//")+1||n.length+1)-1).trim(),i.testExpression="#ifdef"===r?new Ft(n):"#ifndef"===r?new Ft(n,!0):function(e){e=e.replace(zt,"defined[$1]");for(var t=[],i=0,r=Nt.infixToPostfix(e);i=2){var o=t[t.length-1],a=t[t.length-2];t.length-=2;var s="&&"==n?new wt:new Lt;"string"==typeof o&&(o=o.replace(Wt,"defined($1)")),"string"==typeof a&&(a=a.replace(Wt,"defined($1)")),s.leftOperand="string"==typeof a?$t(a):a,s.rightOperand="string"==typeof o?$t(o):o,t.push(s)}}var l=t[t.length-1];return"string"==typeof l&&(l=l.replace(Wt,"defined($1)")),"string"==typeof l?$t(l):l}(n),i}function ti(e,t,i){for(var r=e.currentLine;ii(e,i);){var n=(r=e.currentLine).substring(0,5).toLowerCase();if("#else"===n){var o=new It;return t.children.push(o),void ii(e,o)}if("#elif"===n){var a=ei(r,5);t.children.push(a),i=a}}}function ii(e,t){for(;e.canRead;){e.lineIndex++;var i=e.currentLine;if(i.indexOf("#")>=0){var r=Qt.exec(i);if(r&&r.length){switch(r[0]){case"#ifdef":var n=new Ot;t.children.push(n);var o=ei(i,6);n.children.push(o),ti(e,n,o);break;case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":n=new Ot,t.children.push(n),o=ei(i,7),n.children.push(o),ti(e,n,o);break;case"#if":n=new Ot,o=ei(i,3),t.children.push(n),n.children.push(o),ti(e,n,o)}continue}}var a=new It;if(a.line=i,t.children.push(a),"#"===i[0]&&"d"===i[1]){var s=i.replace(";","").split(" ");a.additionalDefineKey=s[1],3===s.length&&(a.additionalDefineValue=s[2])}}return!1}function ri(e,t,i){var r=new It,n=new Mt;return n.lineIndex=-1,n.lines=e.split("\n"),ii(n,r),r.process(t,i)}function ni(e,t){for(var i,r={},n=0,o=e.defines;n1?a[1]:""}return(null===(i=e.processor)||void 0===i?void 0:i.shaderLanguage)===pt.GLSL&&(r.GL_ES="true"),r.__VERSION__=e.version,r[e.platformName]="true",Gt(r,null==t?void 0:t.isNDCHalfZRange,null==t?void 0:t.useReverseDepthBuffer,null==t?void 0:t.useExactSrgbConversions),r}function oi(e,t,i){var r;for(Kt.length=0;null!==(r=Ht.exec(e));)Kt.push(r);for(var n=String(e),o=[e],a=!1,s=function(e){var r=e[1];if(-1!==r.indexOf("__decl__")&&(r=r.replace(Xt,""),t.supportsUniformBuffers&&(r=r.replace("Vertex","Ubo").replace("Fragment","Ubo")),r+="Declaration"),!t.includesShadersStore[r]){var n=t.shadersRepository+"ShadersInclude/"+r+".fx";return ai.loadFile(n,(function(e){t.includesShadersStore[r]=e,oi(o.join(""),t,i)})),{value:void 0}}var s=t.includesShadersStore[r];if(e[2])for(var l=e[3].split(","),c=0;c=0||s.indexOf("#include <")>=0},l=0,c=Kt;l1?"#version 300 es\n#define WEBGL2 \n":"";return a(e,gi(t,"vertex",r,c,n,l._contextWasLost),gi(i,"fragment",r,c,n,l._contextWasLost),n,o,l.validateShaderPrograms)}function _i(e,t,i,r,n,o){void 0===n&&(n=null);var a=r.createProgram();if(e.program=a,!a)throw new Error("Unable to create program");return r.attachShader(a,t),r.attachShader(a,i),r.linkProgram(a),e.context=r,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||mi(e,r,o),a}function mi(e,t,i){var r=e.context,n=e.vertexShader,o=e.fragmentShader,a=e.program;if(!r.getProgramParameter(a,r.LINK_STATUS)){var s,l;if(!t.getShaderParameter(n,t.COMPILE_STATUS)&&(s=t.getShaderInfoLog(n)))throw e.vertexCompilationError=s,new Error("VERTEX SHADER "+s);if(!t.getShaderParameter(o,t.COMPILE_STATUS)&&(s=t.getShaderInfoLog(o)))throw e.fragmentCompilationError=s,new Error("FRAGMENT SHADER "+s);if(l=r.getProgramInfoLog(a))throw e.programLinkError=l,new Error(l)}if(i&&(r.validateProgram(a),!r.getProgramParameter(a,r.VALIDATE_STATUS)&&(l=r.getProgramInfoLog(a))))throw e.programValidationError=l,new Error(l);r.deleteShader(n),r.deleteShader(o),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)}function gi(e,t,i,r,n,o){return vi(Vt(e,i,r),t,n,o)}function vi(e,t,i,r){var n=i.createShader("vertex"===t?i.VERTEX_SHADER:i.FRAGMENT_SHADER);if(!n){for(var o=i.NO_ERROR,a=i.NO_ERROR;(a=i.getError())!==i.NO_ERROR;)o=a;throw new Error("Something went wrong while creating a gl ".concat(t," shader object. gl error=").concat(o,", gl isContextLost=").concat(i.isContextLost(),", _contextWasLost=").concat(r))}return i.shaderSource(n,e),i.compileShader(n),n}function yi(e){var t=e._name,i=e.context;if(t&&i){var r=di(i),n=r.cachedPipelines[t];null==n||n.dispose(),delete r.cachedPipelines[t]}}function bi(e,t,i,r,n,o){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)r(dt(e));else if("source:"!==e.substr(0,7))if("base64:"!==e.substr(0,7)){var a=li.GetShadersStore(n);if(a[e+t+"Shader"])r(a[e+t+"Shader"]);else if(i&&a[e+i+"Shader"])r(a[e+i+"Shader"]);else{var s;if(s="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:li.GetShadersRepository(n)+e,!(o=o||kt))throw new Error("loadFileInjection is not defined");o(s+"."+t.toLowerCase()+".fx",r)}}else r(window.atob(e.substr(7)));else r(e.substr(7))}var Ti,Ei=function(){function e(t,i,r,n,o,a,s,l,c,u,h,d){var p,_,m,g;void 0===n&&(n=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=""),void 0===d&&(d=pt.GLSL),this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new f,this.onErrorObservable=new f,this._onBindObservable=null,this._isDisposed=!1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this.name=t,this._key=h;var v,y=this._key.replace(/\r/g,"").replace(/\n/g,"|"),b=void 0;if(i.attributes){var T=i;if(this._engine=r,this._attributesNames=T.attributes,this._uniformsNames=T.uniformsNames.concat(T.samplers),this._samplerList=T.samplers.slice(),this.defines=T.defines,this.onError=T.onError,this.onCompiled=T.onCompiled,this._fallbacks=T.fallbacks,this._indexParameters=T.indexParameters,this._transformFeedbackVaryings=T.transformFeedbackVaryings||null,this._multiTarget=!!T.multiTarget,this._shaderLanguage=null!==(p=T.shaderLanguage)&&void 0!==p?p:pt.GLSL,T.uniformBuffersNames){this._uniformBuffersNamesList=T.uniformBuffersNames.slice();for(var E=0;E=a&&(n="Offending line [".concat(a,"] in ").concat(i?"fragment":"vertex"," code: ").concat(s[a-1]))}}return[e,n]},e.prototype._processCompilationErrors=function(t,i){var r,n,o,a,s,l=this;void 0===i&&(i=null),this._compilationError=t.message;var c=this._attributesNames,u=this._fallbacks;if(ae.Error("Unable to compile effect:"),ae.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),ae.Error("Attributes: "+c.map((function(e){return" "+e}))),ae.Error("Defines:\n"+this.defines),e.LogShaderCodeOnCompilationError){var h=null,d=null,p=null;(null===(o=this._pipelineContext)||void 0===o?void 0:o._getVertexShaderCode())&&(p=(r=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],h=r[1],p&&(ae.Error("Vertex code:"),ae.Error(p))),(null===(a=this._pipelineContext)||void 0===a?void 0:a._getFragmentShaderCode())&&(p=(n=this._getShaderCodeAndErrorLine(null===(s=this._pipelineContext)||void 0===s?void 0:s._getFragmentShaderCode(),this._compilationError,!0))[0],d=n[1],p&&(ae.Error("Fragment code:"),ae.Error(p))),h&&ae.Error(h),d&&ae.Error(d)}ae.Error("Error: "+this._compilationError);var f=function(){l.onError&&l.onError(l,l._compilationError),l.onErrorObservable.notifyObservers(l)};i&&(this._pipelineContext=i,this._isReady=!0,f()),u?(this._pipelineContext=null,u.hasMoreFallbacks?(this._allFallbacksProcessed=!1,ae.Error("Trying next fallback."),this.defines=u.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,f(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,i||f())},Object.defineProperty(e.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!1,configurable:!0}),e.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers[e],t,e)},e.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)},e.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers[e],this._uniforms[e],t,e)},e.prototype.setTextureArray=function(e,t){var i=e+"Ex";if(-1===this._samplerList.indexOf(i+"0")){for(var r=this._samplerList.indexOf(e),n=1;n=0&&(this._activeRenderLoops.splice(t,1),0==this._activeRenderLoops.length&&this._cancelFrame())},e.prototype._cancelFrame=function(){if(0!==this._frameHandler){var e=this._frameHandler;if(this._frameHandler=0,ct()){var t=(this.getHostWindow()||window).cancelAnimationFrame;if("function"==typeof t)return t(e)}else if("function"==typeof cancelAnimationFrame)return cancelAnimationFrame(e);return clearTimeout(e)}},e.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this)},e.prototype.endFrame=function(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)},e.prototype._renderLoop=function(){if(this._frameHandler=0,!this._contextWasLost){var e=!0;if((this._isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e){this.beginFrame();for(var t=0;t0&&0===this._frameHandler&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))},e.prototype._queueNewFrame=function(e,t){return Ii(e,t)},e.prototype.runRenderLoop=function(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),1===this._activeRenderLoops.length&&0===this._frameHandler&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},e.prototype.getDepthBuffer=function(){return this._depthCullingState.depthTest},e.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},e.prototype.setZOffset=function(e){this._depthCullingState.zOffset=this.useReverseDepthBuffer?-e:e},e.prototype.getZOffset=function(){var e=this._depthCullingState.zOffset;return this.useReverseDepthBuffer?-e:e},e.prototype.setZOffsetUnits=function(e){this._depthCullingState.zOffsetUnits=this.useReverseDepthBuffer?-e:e},e.prototype.getZOffsetUnits=function(){var e=this._depthCullingState.zOffsetUnits;return this.useReverseDepthBuffer?-e:e},e.prototype.getHostWindow=function(){return ct()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},Object.defineProperty(e.prototype,"compatibilityMode",{get:function(){return this._compatibilityMode},set:function(e){this._compatibilityMode=!0},enumerable:!1,configurable:!0}),e.prototype._rebuildTextures=function(){for(var e=0,t=this.scenes;e-1?t.substring(x).toLowerCase():""),C=null;A.indexOf("?")>-1&&(A=A.split("?")[0]);for(var R=0,P=e._TextureLoaders;R=0&&M.Instances.splice(r,1),M.Instances.length||M.OnEnginesDisposedObservable.notifyObservers(this),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},e.DefaultLoadingScreenFactory=function(e){throw He("LoadingScreen")},e._TextureLoaders=[],e._RenderPassIdCounter=0,e._RescalePostProcessFactory=null,e}(),Oi=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i),Di=function(e){function t(i,r){var n=e.call(this,i,yt.LoadFileError)||this;return n.name="LoadFileError",vt._setPrototypeOf(n,t.prototype),r instanceof Je?n.request=r:n.file=r,n}return m(t,e),t}(bt),Ni=function(e){function t(i,r){var n=e.call(this,i,yt.RequestFileError)||this;return n.request=r,n.name="RequestFileError",vt._setPrototypeOf(n,t.prototype),n}return m(t,e),t}(bt),Fi=function(e){function t(i,r){var n=e.call(this,i,yt.ReadFileError)||this;return n.file=r,n.name="ReadFileError",vt._setPrototypeOf(n,t.prototype),n}return m(t,e),t}(bt),Li={DefaultRetryStrategy:gt.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:function(e){return e},ScriptBaseUrl:"",ScriptPreprocessUrl:function(e){return e},CleanUrl:function(e){return e.replace(/#/gm,"%23")}},wi=function(e,t){if((!e||0!==e.indexOf("data:"))&&Li.CorsBehavior)if("string"==typeof Li.CorsBehavior||Li.CorsBehavior instanceof String)t.crossOrigin=Li.CorsBehavior;else{var i=Li.CorsBehavior(e);i&&(t.crossOrigin=i)}},Bi=function(e,t,i,r,n,o){void 0===n&&(n="");var a,s=M.LastCreatedEngine;if("undefined"==typeof HTMLImageElement&&!(null==s?void 0:s._features.forceBitmapOverHTMLImageElement))return i("LoadImage is only supported in web or BabylonNative environments."),null;var l=!1;e instanceof ArrayBuffer||ArrayBuffer.isView(e)?"undefined"!=typeof Blob&&"undefined"!=typeof URL?(a=URL.createObjectURL(new Blob([e],{type:n})),l=!0):a="data:".concat(n,";base64,")+xt(e):e instanceof Blob?(a=URL.createObjectURL(e),l=!0):(a=Li.CleanUrl(e),a=Li.PreprocessUrl(e));var c=function(t){if(i){var r=a||e.toString();i("Error while trying to load image: ".concat(0===r.indexOf("http")||r.length<=128?r:r.slice(0,128)+"..."),t)}};if(null==s?void 0:s._features.forceBitmapOverHTMLImageElement)return Vi(a,(function(r){s.createImageBitmap(new Blob([r],{type:n}),g({premultiplyAlpha:"none"},o)).then((function(e){t(e),l&&URL.revokeObjectURL(a)})).catch((function(t){i&&i("Error while trying to load image: "+e,t)}))}),void 0,r||void 0,!0,(function(e,t){c(t)})),null;var u=new Image;wi(a,u);var h=[],d=function(){h.forEach((function(e){e.target.removeEventListener(e.name,e.handler)})),h.length=0};h.push({target:u,name:"load",handler:function(){d(),t(u),l&&u.src&&URL.revokeObjectURL(u.src)}}),h.push({target:u,name:"error",handler:function(e){d(),c(e),l&&u.src&&URL.revokeObjectURL(u.src)}}),h.push({target:document,name:"securitypolicyviolation",handler:function(e){if(e.blockedURI===u.src){d();var t=new Error("CSP violation of policy ".concat(e.effectiveDirective," ").concat(e.blockedURI,". Current policy is ").concat(e.originalPolicy));M.UseFallbackTexture=!1,c(t),l&&u.src&&URL.revokeObjectURL(u.src),u.src=""}}}),h.forEach((function(e){e.target.addEventListener(e.name,e.handler)}));var p="blob:"===a.substring(0,5),f="data:"===a.substring(0,5),_=function(){p||f||!Je.IsCustomRequestAvailable?u.src=a:Vi(a,(function(e,t,i){var r=new Blob([e],{type:!n&&i?i:n}),o=URL.createObjectURL(r);l=!0,u.src=o}),void 0,r||void 0,!0,(function(e,t){c(t)}))};if(!p&&!f&&r&&r.enableTexturesOffline)r.open((function(){r&&r.loadImage(a,u)}),_);else{if(-1!==a.indexOf("file:")){var m=decodeURIComponent(a.substring(5).toLowerCase());if(mt.FilesToLoad[m]&&"undefined"!=typeof URL){try{var v=void 0;try{v=URL.createObjectURL(mt.FilesToLoad[m])}catch(e){v=URL.createObjectURL(mt.FilesToLoad[m])}u.src=v,l=!0}catch(e){u.src=""}return u}}_()}return u},Ui=function(e,t,i,r,n){var o=new FileReader,a={onCompleteObservable:new f,abort:function(){return o.abort()}};return o.onloadend=function(){return a.onCompleteObservable.notifyObservers(a)},n&&(o.onerror=function(){n(new Fi("Unable to read ".concat(e.name),e))}),o.onload=function(e){t(e.target.result)},i&&(o.onprogress=i),r?o.readAsArrayBuffer(e):o.readAsText(e),a},Vi=function(e,t,i,r,n,o,a){if(e.name)return Ui(e,t,i,n,o?function(e){o(void 0,e)}:void 0);var s=e;if(-1!==s.indexOf("file:")){var l=decodeURIComponent(s.substring(5).toLowerCase());0===l.indexOf("./")&&(l=l.substring(2));var c=mt.FilesToLoad[l];if(c)return Ui(c,t,i,n,o?function(e){return o(void 0,new Di(e.message,e.file))}:void 0)}var u=Wi(s),h=u.match,d=u.type;if(h){var p={onCompleteObservable:new f,abort:function(){return function(){}}};try{var _=n?Hi(s):ji(s);t(_,void 0,d)}catch(e){o?o(void 0,e):ae.Error(e.message||"Failed to parse the Data URL")}return si.SetImmediate((function(){p.onCompleteObservable.notifyObservers(p)})),p}return ki(s,(function(e,i){t(e,null==i?void 0:i.responseURL,null==i?void 0:i.getResponseHeader("content-type"))}),i,r,n,o?function(e){o(e.request,new Di(e.message,e.request))}:void 0,a)},ki=function(e,t,i,r,n,o,a){e=Li.CleanUrl(e),e=Li.PreprocessUrl(e);var s=Li.BaseUrl+e,l=!1,c={onCompleteObservable:new f,abort:function(){return l=!0}},u=function(){var e,r=new Je,u=null,h=function(){r&&(i&&r.removeEventListener("progress",i),e&&r.removeEventListener("readystatechange",e),r.removeEventListener("loadend",d))},d=function(){h(),c.onCompleteObservable.notifyObservers(c),c.onCompleteObservable.clear(),i=void 0,e=null,d=null,o=void 0,a=void 0,t=void 0};c.abort=function(){l=!0,d&&d(),r&&r.readyState!==(XMLHttpRequest.DONE||4)&&r.abort(),null!==u&&(clearTimeout(u),u=null),r=null};var p=function(e){var t=e.message||"Unknown error";o&&r?o(new Ni(t,r)):ae.Error(t)},f=function(c){if(r){if(r.open("GET",s),a)try{a(r)}catch(e){return void p(e)}n&&(r.responseType="arraybuffer"),i&&r.addEventListener("progress",i),d&&r.addEventListener("loadend",d),e=function(){if(!l&&r&&r.readyState===(XMLHttpRequest.DONE||4)){if(e&&r.removeEventListener("readystatechange",e),r.status>=200&&r.status<300||0===r.status&&(!ct()||Gi())){try{t&&t(n?r.response:r.responseText,r)}catch(e){p(e)}return}var i=Li.DefaultRetryStrategy;if(i){var a=i(s,r,c);if(-1!==a)return h(),r=new Je,void(u=setTimeout((function(){return f(c+1)}),a))}var d=new Ni("Error status: "+r.status+" "+r.statusText+" - Unable to load "+s,r);o&&o(d)}},r.addEventListener("readystatechange",e),r.send()}};f(0)};if(r&&r.enableSceneOffline){var h=function(e){e&&e.status>400?o&&o(e):u()};r.open((function(){r&&r.loadFile(Li.BaseUrl+e,(function(e){!l&&t&&t(e),c.onCompleteObservable.notifyObservers(c)}),i?function(e){!l&&i&&i(e)}:void 0,h,n)}),h)}else u();return c},Gi=function(){return"undefined"!=typeof location&&"file:"===location.protocol},zi=function(e){return Oi.test(e)},Wi=function(e){var t=Oi.exec(e);return null===t||0===t.length?{match:!1,type:""}:{match:!0,type:t[0].replace("data:","").replace("base64,","")}};function Hi(e){return Ct(e.split(",")[1])}var Xi,ji=function(e){return At(e.split(",")[1])};Mi._FileToolsLoadImage=Bi,Ut.loadFile=Vi,ai.loadFile=Vi;var Yi=function(e,t,i,r,n,o,a,s,l,c){Xi={DecodeBase64UrlToBinary:e,DecodeBase64UrlToString:t,DefaultRetryStrategy:i.DefaultRetryStrategy,BaseUrl:i.BaseUrl,CorsBehavior:i.CorsBehavior,PreprocessUrl:i.PreprocessUrl,IsBase64DataUrl:r,IsFileURL:n,LoadFile:o,LoadImage:a,ReadFile:s,RequestFile:l,SetCorsBehavior:c},Object.defineProperty(Xi,"DefaultRetryStrategy",{get:function(){return i.DefaultRetryStrategy},set:function(e){i.DefaultRetryStrategy=e}}),Object.defineProperty(Xi,"BaseUrl",{get:function(){return i.BaseUrl},set:function(e){i.BaseUrl=e}}),Object.defineProperty(Xi,"PreprocessUrl",{get:function(){return i.PreprocessUrl},set:function(e){i.PreprocessUrl=e}}),Object.defineProperty(Xi,"CorsBehavior",{get:function(){return i.CorsBehavior},set:function(e){i.CorsBehavior=e}})};Yi(Hi,ji,Li,zi,Gi,Vi,Bi,Ui,ki,wi);var Ki=function(){function e(){}return e.Instantiate=function(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];var t=s(e);if(t)return t;ae.Warn(e+" not found, you may have missed an import.");for(var i=e.split("."),r=window||this,n=0,o=i.length;ne-i?i:t}function er(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function tr(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)}function ir(e,t,i){var r;switch(void 0===i&&(i=u.SCALEMODE_NEAREST),i){case u.SCALEMODE_FLOOR:r=tr(e);break;case u.SCALEMODE_NEAREST:r=$i(e);break;case u.SCALEMODE_CEILING:default:r=er(e)}return Math.min(r,t)}var rr=function(){function e(){}return Object.defineProperty(e,"BaseUrl",{get:function(){return Li.BaseUrl},set:function(e){Li.BaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanUrl",{get:function(){return Li.CleanUrl},set:function(e){Li.CleanUrl=e},enumerable:!1,configurable:!0}),e.IsAbsoluteUrl=function(e){return 0===e.indexOf("//")||-1!==e.indexOf("://")&&-1!==e.indexOf(".")&&-1!==e.indexOf("/")&&!(e.indexOf(":")>e.indexOf("/"))&&(e.indexOf("://")=t)break;if(r(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),n)},e}();rr.Mix=Ji,rr.IsExponentOfTwo=Zi,M.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z";var ar=function(){function e(t){this.length=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.indexOf(e)},e._GlobalId=0,e}(),sr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return m(t,e),t.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},t.prototype.pushNoDuplicate=function(e){return!(e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId||(this.push(e),0))},t.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},t.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t0&&parseInt(m[m.length-1])>=_)continue}for(var g=0,v=p;g1?new gr:new _r;var T="Babylon.js v".concat(t.Version);ae.Log(T+" - ".concat(a.description)),a._renderingCanvas&&a._renderingCanvas.setAttribute&&a._renderingCanvas.setAttribute("data-engine",T);var E=di(a._gl);return E.validateShaderPrograms=a.validateShaderPrograms,E.parallelShaderCompile=a._caps.parallelShaderCompile,a}return m(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this._webGLVersion},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ShadersRepository",{get:function(){return Ei.ShadersRepository},set:function(e){Ei.ShadersRepository=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framebufferDimensionsObject",{set:function(e){this._framebufferDimensionsObject=e},enumerable:!1,configurable:!0}),t.prototype.snapshotRenderingReset=function(){this.snapshotRendering=!1},t.prototype._clearEmptyResources=function(){this._dummyFramebuffer=null,e.prototype._clearEmptyResources.call(this)},t.prototype._getShaderProcessingContext=function(e){return null},t.prototype.areAllEffectsReady=function(){for(var e in this._compiledEffects)if(!this._compiledEffects[e].isReady())return!1;return!0},t.prototype._initGLContext=function(){var e;this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),fragmentDepthSupported:this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:1!==this._webGLVersion,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);var t=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=t&&(this._glRenderer=this._gl.getParameter(t.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(t.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),36193!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=36193),34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=(null!==(e=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT))&&void 0!==e?e:0)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),this._caps.bptc&&(this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),this._caps.s3tc_srgb&&(this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),this._caps.etc2&&(this._gl.COMPRESSED_SRGB8_ETC2=this._caps.etc2.COMPRESSED_SRGB8_ETC2,this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC),this._webGLVersion>1&&5131!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=null!==this._maxMSAASamplesOverride?this._maxMSAASamplesOverride:this._gl.getParameter(this._gl.MAX_SAMPLES);else{var i=this._gl.getExtension("WEBGL_draw_buffers");if(null!==i){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=i.drawBuffersWEBGL.bind(i),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var r=0;r<16;r++)this._gl["COLOR_ATTACHMENT"+r+"_WEBGL"]=i["COLOR_ATTACHMENT"+r+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var n=this._gl.getExtension("WEBGL_depth_texture");null!=n&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=n.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var o=this._gl.getExtension("OES_vertex_array_object");null!=o&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=o.createVertexArrayOES.bind(o),this._gl.bindVertexArray=o.bindVertexArrayOES.bind(o),this._gl.deleteVertexArray=o.deleteVertexArrayOES.bind(o))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var a=this._gl.getExtension("ANGLE_instanced_arrays");null!=a?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=a.drawArraysInstancedANGLE.bind(a),this._gl.drawElementsInstanced=a.drawElementsInstancedANGLE.bind(a),this._gl.vertexAttribDivisor=a.vertexAttribDivisorANGLE.bind(a)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){var s=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),l=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);s&&l&&(this._caps.highPrecisionShaderSupported=0!==s.precision&&0!==l.precision)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{var c=this._gl.getExtension("EXT_blend_minmax");null!=c&&(this._caps.blendMinMax=!0,this._gl.MAX=c.MAX_EXT,this._gl.MIN=c.MIN_EXT)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:WebGL2RenderingContext.SRGB,SRGB8:WebGL2RenderingContext.SRGB8,SRGB8_ALPHA8:WebGL2RenderingContext.SRGB8_ALPHA8};else{var u=this._gl.getExtension("EXT_sRGB");null!=u&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:u.SRGB_EXT,SRGB8:u.SRGB_ALPHA_EXT,SRGB8_ALPHA8:u.SRGB_ALPHA_EXT})}this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&!(!this._creationOptions||!this._creationOptions.forceSRGBBufferSupportState)}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var h=0;h=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)},t.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ARRAY_BUFFER)},t.prototype.bindUniformBlock=function(e,t,i){var r=e.program,n=this._gl.getUniformBlockIndex(r,t);this._gl.uniformBlockBinding(r,n,i)},t.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},t.prototype._bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)},t.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},t.prototype._vertexAttribPointer=function(e,t,i,r,n,o,a){var s=this._currentBufferPointers[t];if(s){var l=!1;s.active?(s.buffer!==e&&(s.buffer=e,l=!0),s.size!==i&&(s.size=i,l=!0),s.type!==r&&(s.type=r,l=!0),s.normalized!==n&&(s.normalized=n,l=!0),s.stride!==o&&(s.stride=o,l=!0),s.offset!==a&&(s.offset=a,l=!0)):(l=!0,s.active=!0,s.index=t,s.size=i,s.type=r,s.normalized=n,s.stride=o,s.offset=a,s.buffer=e),(l||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),r===this._gl.UNSIGNED_INT||r===this._gl.INT?this._gl.vertexAttribIPointer(t,i,r,o,a):this._gl.vertexAttribPointer(t,i,r,n,o,a))}},t.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},t.prototype._bindVertexBuffersAttributes=function(e,t,i){var r=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var n=0;n=0){var a=r[n],s=null;if(i&&(s=i[a]),s||(s=e[a]),!s)continue;this._gl.enableVertexAttribArray(o),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[o]=!0);var l=s.getBuffer();l&&(this._vertexAttribPointer(l,o,s.getSize(),s.type,s.normalized,s.byteStride,s.byteOffset),s.getIsInstanced()&&(this._gl.vertexAttribDivisor(o,s.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(o),this._currentInstanceBuffers.push(l))))}}},t.prototype.recordVertexArrayObject=function(e,t,i,r){var n=this._gl.createVertexArray();if(!n)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(n),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i,r),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),n},t.prototype.bindVertexArrayObject=function(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)},t.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var a=0,s=0;s=0&&(this._gl.enableVertexAttribArray(l),this._vertexAttribArraysEnabled[l]=!0,this._vertexAttribPointer(e,l,i[s],this._gl.FLOAT,!1,r,a)),a+=4*i[s]}}this._bindIndexBufferWithCache(t)},t.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},t.prototype.bindBuffers=function(e,t,i,r){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===i||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i,r)),this._bindIndexBufferWithCache(t)},t.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1||this.isWebGPU)),(s!==u.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(s!==u.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(l=u.TEXTURE_NEAREST_SAMPLINGMODE),s!==u.TEXTURETYPE_FLOAT||this._caps.textureFloat||(s=u.TEXTURETYPE_UNSIGNED_INT,ae.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));var p=this._gl,f=new Pi(this,r),_=e.width||e,m=e.height||e,g=e.depth||0,v=e.layers||0,y=this._getSamplingParameters(l,a),b=0!==v?p.TEXTURE_2D_ARRAY:0!==g?p.TEXTURE_3D:p.TEXTURE_2D,T=this._getRGBABufferInternalSizedFormat(s,c,h),E=this._getInternalFormat(c),S=this._getWebGLTextureType(s);return this._bindTextureDirectly(b,f),0!==v?(f.is2DArray=!0,p.texImage3D(b,0,T,_,m,v,0,E,S,null)):0!==g?(f.is3D=!0,p.texImage3D(b,0,T,_,m,g,0,E,S,null)):p.texImage2D(b,0,T,_,m,0,E,S,null),p.texParameteri(b,p.TEXTURE_MAG_FILTER,y.mag),p.texParameteri(b,p.TEXTURE_MIN_FILTER,y.min),p.texParameteri(b,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(b,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),a&&this._gl.generateMipmap(b),this._bindTextureDirectly(b,null),f._useSRGBBuffer=h,f.baseWidth=_,f.baseHeight=m,f.width=_,f.height=m,f.depth=v,f.isReady=!0,f.samples=d,f.generateMipMaps=a,f.samplingMode=l,f.type=s,f.format=c,f.label=o,this._internalTexturesCache.push(f),f},t.prototype._getUseSRGBBuffer=function(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)},t.prototype.createTexture=function(e,t,i,r,n,o,a,s,l,c,h,d,p,f,_){var m=this;return void 0===n&&(n=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=null),this._createTextureBase(e,t,i,r,n,o,a,(function(){for(var e=[],t=0;tu||i.height>u||!m._supportsHardwareTextureRescaling)return m._prepareWorkingCanvas(),!(!m._workingCanvas||!m._workingContext||(m._workingCanvas.width=e,m._workingCanvas.height=t,m._workingContext.drawImage(i,0,0,i.width,i.height,0,0,e,t),s.texImage2D(s.TEXTURE_2D,0,c.internalFormat,c.format,c.type,m._workingCanvas),o.width=e,o.height=t,1));var h=new Pi(m,Ti.Temp);return m._bindTextureDirectly(s.TEXTURE_2D,h,!0),s.texImage2D(s.TEXTURE_2D,0,c.internalFormat,c.format,c.type,i),m._rescaleTexture(h,o,r,c.format,(function(){m._releaseTexture(h),m._bindTextureDirectly(s.TEXTURE_2D,o,!0),a()})),!0}),s,l,c,h,d,p,_)},t.prototype._getTexImageParametersForCreateTexture=function(e,t){var i,r;return 1===this.webGLVersion?r=i=this._getInternalFormat(e,t):(i=this._getInternalFormat(e,!1),r=this._getRGBABufferInternalSizedFormat(u.TEXTURETYPE_UNSIGNED_BYTE,e,t)),{internalFormat:r,format:i,type:this._gl.UNSIGNED_BYTE}},t.prototype._rescaleTexture=function(e,t,i,r,n){},t.prototype.createRawTexture=function(e,t,i,r,n,o,a,s,l,c,h){throw void 0===s&&(s=null),void 0===l&&(l=u.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=0),void 0===h&&(h=!1),He("Engine.RawTexture")},t.prototype.createRawCubeTexture=function(e,t,i,r,n,o,a,s){throw void 0===s&&(s=null),He("Engine.RawTexture")},t.prototype.createRawTexture3D=function(e,t,i,r,n,o,a,s,l,c){throw void 0===l&&(l=null),void 0===c&&(c=u.TEXTURETYPE_UNSIGNED_INT),He("Engine.RawTexture")},t.prototype.createRawTexture2DArray=function(e,t,i,r,n,o,a,s,l,c){throw void 0===l&&(l=null),void 0===c&&(c=u.TEXTURETYPE_UNSIGNED_INT),He("Engine.RawTexture")},t.prototype.createPrefilteredCubeTexture=function(e,t,i,r,n,o,a,s,l){throw He("Misc/dds")},t.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},t.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},t.prototype._getTextureTarget=function(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D},t.prototype.updateTextureSamplingMode=function(e,t,i){void 0===i&&(i=!1);var r=this._getTextureTarget(t),n=this._getSamplingParameters(e,t.useMipMaps||i);this._setTextureParameterInteger(r,this._gl.TEXTURE_MAG_FILTER,n.mag,t),this._setTextureParameterInteger(r,this._gl.TEXTURE_MIN_FILTER,n.min),i&&(t.generateMipMaps=!0,this._gl.generateMipmap(r)),this._bindTextureDirectly(r,null),t.samplingMode=e},t.prototype.updateTextureDimensions=function(e,t,i,r){void 0===r&&(r=1)},t.prototype.updateTextureWrappingMode=function(e,t,i,r){void 0===i&&(i=null),void 0===r&&(r=null);var n=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==i&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&null!==r&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(r),e),e._cachedWrapR=r),this._bindTextureDirectly(n,null)},t.prototype._setupDepthStencilTexture=function(e,t,i,r,n,o){void 0===o&&(o=1);var a=t.width||t,s=t.height||t,l=t.layers||0,c=t.depth||0;e.baseWidth=a,e.baseHeight=s,e.width=a,e.height=s,e.is2DArray=l>0,e.depth=l||c,e.isReady=!0,e.samples=o,e.generateMipMaps=!1,e.samplingMode=r?u.TEXTURE_BILINEAR_SAMPLINGMODE:u.TEXTURE_NEAREST_SAMPLINGMODE,e.type=u.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=n;var h=this._gl,d=this._getTextureTarget(e),p=this._getSamplingParameters(e.samplingMode,!1);h.texParameteri(d,h.TEXTURE_MAG_FILTER,p.mag),h.texParameteri(d,h.TEXTURE_MIN_FILTER,p.min),h.texParameteri(d,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(d,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),this.webGLVersion>1&&(0===n?(h.texParameteri(d,h.TEXTURE_COMPARE_FUNC,u.LEQUAL),h.texParameteri(d,h.TEXTURE_COMPARE_MODE,h.NONE)):(h.texParameteri(d,h.TEXTURE_COMPARE_FUNC,n),h.texParameteri(d,h.TEXTURE_COMPARE_MODE,h.COMPARE_REF_TO_TEXTURE)))},t.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,a){void 0===o&&(o=0),void 0===a&&(a=0);var s=this._gl,l=s.TEXTURE_2D;if(e.isCube&&(l=s.TEXTURE_CUBE_MAP_POSITIVE_X+o),e._useSRGBBuffer)switch(t){case u.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:case u.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:this._caps.etc2?t=s.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case u.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:this._caps.etc2?t=s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case u.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:t=s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case u.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:t=s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case u.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:this._caps.s3tc_srgb?t=s.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case u.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:this._caps.s3tc_srgb?t=s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case u.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:this._caps.s3tc_srgb?t=s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1}this._gl.compressedTexImage2D(l,a,t,i,r,0,n)},t.prototype._uploadDataToTextureDirectly=function(e,t,i,r,n,o){void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=!1);var a=this._gl,s=this._getWebGLTextureType(e.type),l=this._getInternalFormat(e.format),c=void 0===n?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(n,e._useSRGBBuffer);this._unpackFlipY(e.invertY);var u=a.TEXTURE_2D;e.isCube&&(u=a.TEXTURE_CUBE_MAP_POSITIVE_X+i);var h=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),p=o?e.width:Math.pow(2,Math.max(h-r,0)),f=o?e.height:Math.pow(2,Math.max(d-r,0));a.texImage2D(u,r,c,p,f,0,l,s,t)},t.prototype.updateTextureData=function(e,t,i,r,n,o,a,s,l){void 0===a&&(a=0),void 0===s&&(s=0),void 0===l&&(l=!1);var c=this._gl,u=this._getWebGLTextureType(e.type),h=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);var d=c.TEXTURE_2D,p=c.TEXTURE_2D;e.isCube&&(p=c.TEXTURE_CUBE_MAP_POSITIVE_X+a,d=c.TEXTURE_CUBE_MAP),this._bindTextureDirectly(d,e,!0),c.texSubImage2D(p,s,i,r,n,o,h,u,t),l&&this._gl.generateMipmap(p),this._bindTextureDirectly(d,null)},t.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(o,null,!0)},t.prototype._prepareWebGLTextureContinuation=function(e,t,i,r,n){var o=this._gl;if(o){var a=this._getSamplingParameters(n,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,a.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,a.min),i||r||o.generateMipmap(o.TEXTURE_2D),this._bindTextureDirectly(o.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},t.prototype._prepareWebGLTexture=function(e,t,i,r,n,o,a,s,l,c){var h=this,d=this.getCaps().maxTextureSize,p=Math.min(d,this.needPOTTextures?ir(r.width,d):r.width),f=Math.min(d,this.needPOTTextures?ir(r.height,d):r.height),_=this._gl;_&&(e._hardwareTexture?(this._bindTextureDirectly(_.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===n||!!n),e.baseWidth=r.width,e.baseHeight=r.height,e.width=p,e.height=f,e.isReady=!0,e.type=-1!==e.type?e.type:u.TEXTURETYPE_UNSIGNED_BYTE,e.format=-1!==e.format?e.format:null!=c?c:".jpg"!==t||e._useSRGBBuffer?u.TEXTUREFORMAT_RGBA:u.TEXTUREFORMAT_RGB,s(p,f,r,t,e,(function(){h._prepareWebGLTextureContinuation(e,i,o,a,l)}))||this._prepareWebGLTextureContinuation(e,i,o,a,l)):i&&i.removePendingData(e))},t.prototype._setupFramebufferDepthAttachments=function(e,t,i,r,n){void 0===n&&(n=1);var o=this._gl;if(e&&t)return this._createRenderBuffer(i,r,n,o.DEPTH_STENCIL,o.DEPTH24_STENCIL8,o.DEPTH_STENCIL_ATTACHMENT);if(t){var a=o.DEPTH_COMPONENT16;return this._webGLVersion>1&&(a=o.DEPTH_COMPONENT32F),this._createRenderBuffer(i,r,n,a,a,o.DEPTH_ATTACHMENT)}return e?this._createRenderBuffer(i,r,n,o.STENCIL_INDEX8,o.STENCIL_INDEX8,o.STENCIL_ATTACHMENT):null},t.prototype._createRenderBuffer=function(e,t,i,r,n,o,a){void 0===a&&(a=!0);var s=this._gl.createRenderbuffer();return this._updateRenderBuffer(s,e,t,i,r,n,o,a)},t.prototype._updateRenderBuffer=function(e,t,i,r,n,o,a,s){void 0===s&&(s=!0);var l=this._gl;return l.bindRenderbuffer(l.RENDERBUFFER,e),r>1&&l.renderbufferStorageMultisample?l.renderbufferStorageMultisample(l.RENDERBUFFER,r,o,t,i):l.renderbufferStorage(l.RENDERBUFFER,n,t,i),l.framebufferRenderbuffer(l.FRAMEBUFFER,a,l.RENDERBUFFER,e),s&&l.bindRenderbuffer(l.RENDERBUFFER,null),e},t.prototype._releaseTexture=function(e){var t;this._deleteTexture(null===(t=e._hardwareTexture)||void 0===t?void 0:t.underlyingResource),this.unbindAllTextures();var i=this._internalTexturesCache.indexOf(e);-1!==i&&this._internalTexturesCache.splice(i,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()},t.prototype._deleteTexture=function(e){e&&this._gl.deleteTexture(e)},t.prototype._setProgram=function(e){this._currentProgram!==e&&(function(e,t){t.useProgram(e)}(e,this._gl),this._currentProgram=e)},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.program);for(var i=e.getSamplers(),r=0;r-1;if(i&&s&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||r){if(this._activateCurrentTexture(),t&&t.isMultiview)throw ae.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,null!==(o=null===(n=null==t?void 0:t._hardwareTexture)||void 0===n?void 0:n.underlyingResource)&&void 0!==o?o:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else i&&(a=!0,this._activateCurrentTexture());return s&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),a},t.prototype._bindTexture=function(e,t,i){if(void 0!==e){t&&(t._associatedChannel=e),this._activeChannel=e;var r=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(r,t)}},t.prototype.unbindAllTextures=function(){for(var e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},t.prototype.setTexture=function(e,t,i,r){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},t.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i&&i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},t.prototype._getTextureWrapMode=function(e){switch(e){case u.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case u.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case u.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},t.prototype._setTexture=function(e,t,i,r,n){if(void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=""),!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video){this._activeChannel=e;var o=t.getInternalTexture();o&&(o._associatedChannel=e),t.update()}else if(t.delayLoadState===u.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var a;a=r?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!i&&a&&(a._associatedChannel=e);var s=!0;this._boundTexturesCache[e]===a&&(i||this._bindSamplerUniformToChannel(a._associatedChannel,e),s=!1),this._activeChannel=e;var l=this._getTextureTarget(a);if(s&&this._bindTextureDirectly(l,a,i),a&&!a.isMultiview){if(a.isCube&&a._cachedCoordinatesMode!==t.coordinatesMode){a._cachedCoordinatesMode=t.coordinatesMode;var c=t.coordinatesMode!==u.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==u.TEXTURE_SKYBOX_MODE?u.TEXTURE_WRAP_ADDRESSMODE:u.TEXTURE_CLAMP_ADDRESSMODE;t.wrapU=c,t.wrapV=c}a._cachedWrapU!==t.wrapU&&(a._cachedWrapU=t.wrapU,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),a)),a._cachedWrapV!==t.wrapV&&(a._cachedWrapV=t.wrapV,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),a)),a.is3D&&a._cachedWrapR!==t.wrapR&&(a._cachedWrapR=t.wrapR,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),a)),this._setAnisotropicLevel(l,a,t.anisotropicFilteringLevel)}return!0},t.prototype.setTextureArray=function(e,t,i,r){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var n=0;n=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}},t.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}},t.prototype.dispose=function(){var t,i;e.prototype.dispose.call(this),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},ct()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&(null===(t=this._gl.getExtension("WEBGL_lose_context"))||void 0===t||t.loseContext()),i=this._gl,ui.delete(i)},t.prototype.attachContextLostEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},t.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},t.prototype.getError=function(){return this._gl.getError()},t.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.TEXTURETYPE_FLOAT)},t.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.TEXTURETYPE_HALF_FLOAT)},t.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((i=(i=i&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var a=t.RGBA,s=t.UNSIGNED_BYTE,l=new Uint8Array(4);t.readPixels(0,0,1,1,a,s,l),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},t.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case u.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case u.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case u.TEXTURETYPE_BYTE:return this._gl.BYTE;case u.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.TEXTURETYPE_SHORT:return this._gl.SHORT;case u.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case u.TEXTURETYPE_INT:return this._gl.INT;case u.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case u.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case u.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case u.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case u.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case u.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case u.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case u.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},t.prototype._getInternalFormat=function(e,t){void 0===t&&(t=!1);var i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case u.TEXTUREFORMAT_ALPHA:i=this._gl.ALPHA;break;case u.TEXTUREFORMAT_LUMINANCE:i=this._gl.LUMINANCE;break;case u.TEXTUREFORMAT_LUMINANCE_ALPHA:i=this._gl.LUMINANCE_ALPHA;break;case u.TEXTUREFORMAT_RED:i=this._gl.RED;break;case u.TEXTUREFORMAT_RG:i=this._gl.RG;break;case u.TEXTUREFORMAT_RGB:i=t?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case u.TEXTUREFORMAT_RGBA:i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA}if(this._webGLVersion>1)switch(e){case u.TEXTUREFORMAT_RED_INTEGER:i=this._gl.RED_INTEGER;break;case u.TEXTUREFORMAT_RG_INTEGER:i=this._gl.RG_INTEGER;break;case u.TEXTUREFORMAT_RGB_INTEGER:i=this._gl.RGB_INTEGER;break;case u.TEXTUREFORMAT_RGBA_INTEGER:i=this._gl.RGBA_INTEGER}return i},t.prototype._getRGBABufferInternalSizedFormat=function(e,t,i){if(void 0===i&&(i=!1),1===this._webGLVersion){if(void 0!==t)switch(t){case u.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case u.TEXTUREFORMAT_RGB:return i?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case u.TEXTURETYPE_BYTE:switch(t){case u.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case u.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case u.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case u.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case u.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case u.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case u.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case u.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case u.TEXTUREFORMAT_RED:return this._gl.R8;case u.TEXTUREFORMAT_RG:return this._gl.RG8;case u.TEXTUREFORMAT_RGB:return i?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case u.TEXTUREFORMAT_RGBA:return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case u.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case u.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case u.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case u.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case u.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case u.TEXTURETYPE_SHORT:switch(t){case u.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case u.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case u.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case u.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case u.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case u.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case u.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case u.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case u.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case u.TEXTURETYPE_INT:switch(t){case u.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case u.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case u.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case u.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case u.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case u.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case u.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case u.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case u.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case u.TEXTURETYPE_FLOAT:switch(t){case u.TEXTUREFORMAT_RED:return this._gl.R32F;case u.TEXTUREFORMAT_RG:return this._gl.RG32F;case u.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case u.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case u.TEXTURETYPE_HALF_FLOAT:switch(t){case u.TEXTUREFORMAT_RED:return this._gl.R16F;case u.TEXTUREFORMAT_RG:return this._gl.RG16F;case u.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case u.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case u.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case u.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case u.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case u.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case u.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case u.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case u.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case u.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8},t.prototype.readPixels=function(e,t,i,r,n,o){void 0===n&&(n=!0),void 0===o&&(o=!0);var a=n?4:3,s=n?this._gl.RGBA:this._gl.RGB,l=new Uint8Array(r*i*a);return o&&this.flushFramebuffer(),this._gl.readPixels(e,t,i,r,s,this._gl.UNSIGNED_BYTE,l),Promise.resolve(l)},t.prototype.generateMipMapsForCubemap=function(e,t){},Object.defineProperty(t,"IsSupportedAsync",{get:function(){return Promise.resolve(this.isSupported())},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),t.isSupported=function(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{var e=Mi._CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=null!=t&&!!window.WebGLRenderingContext}catch(e){this._IsSupported=!1}return this._IsSupported},Object.defineProperty(t,"HasMajorPerformanceCaveat",{get:function(){if(null===this._HasMajorPerformanceCaveat)try{var e=Mi._CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch(e){this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat},enumerable:!1,configurable:!0}),t._TempClearColorUint32=new Uint32Array(4),t._TempClearColorInt32=new Int32Array(4),t.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/12\\d\\..+?Mobile",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:".*AppleWebKit.*(15.4).*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]},{key:".*(15.4).*AppleWebKit.*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]}],t.CollisionsEpsilon=.001,t._ConcatenateShader=Vt,t._IsSupported=null,t._HasMajorPerformanceCaveat=null,t.CeilingPOT=er,t.FloorPOT=tr,t.NearestPOT=$i,t.GetExponentOfTwo=ir,t.QueueNewFrame=Ii,t}(Mi);Er.prototype.createUniformBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error("Unable to create uniform buffer");var r=new yr(i);return this.bindUniformBuffer(r),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),r.references=1,r},Er.prototype.createDynamicUniformBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error("Unable to create dynamic uniform buffer");var r=new yr(i);return this.bindUniformBuffer(r),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),r.references=1,r},Er.prototype.updateUniformBuffer=function(e,t,i,r){this.bindUniformBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(i,i+r)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(i,i+r)),this.bindUniformBuffer(null)},Er.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e?e.underlyingResource:null)},Er.prototype.bindUniformBufferBase=function(e,t,i){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e?e.underlyingResource:null)},Er.prototype.bindUniformBlock=function(e,t,i){var r=e.program,n=this._gl.getUniformBlockIndex(r,t);4294967295!==n&&this._gl.uniformBlockBinding(r,n,i)};var Sr,xr,Ar,Cr,Rr,Pr,Ir,Mr,Or=function(){function e(e,t,i,r,n){void 0===n&&(n=!1),this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||n,this._dynamic=i,this._name=null!=r?r:"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._engine._features.trackUbosInFrame&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}return Object.defineProperty(e.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!1,configurable:!0}),e.prototype.isDynamic=function(){return void 0!==this._dynamic},e.prototype.getData=function(){return this._bufferData},e.prototype.getBuffer=function(){return this._buffer},e.prototype._fillAlignment=function(e){var t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){var i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;for(var r=this._uniformLocationPointer-i,n=0;n0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;this._fillAlignment(4),this._uniformArraySizes[e]={strideSize:t,arraySize:i},16==t?t*=i:t=t*i+(4-t)*i,r=[];for(var n=0;n1&&this._buffers[this._bufferIndex][1]){if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1]))return this._needSync=!1,void(this._createBufferOnWrite=this._engine._features.trackUbosInFrame);this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1])}this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(e._UpdatedUbosInFrame[this._name]||(e._UpdatedUbosInFrame[this._name]=0),e._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._engine._features.trackUbosInFrame}else this._createBufferOnWrite=this._engine._features.trackUbosInFrame;else this.create()},e.prototype._createNewBuffer=function(){this._bufferIndex+10?(this._needSync=0!==this._bufferIndex,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)},e.prototype.updateUniform=function(e,t,i){this._checkNewFrame();var r=this._uniformLocations[e];if(void 0===r){if(this._buffer)return void ae.Error("Cannot add an uniform after UBO has been created. uniformName="+e);this.addUniform(e,i),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(o=0;o0)return void(this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label));ae.Warn('Missing data for buffer "'.concat(this._label,'" ').concat(this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":"",". Buffer reconstruction failed.")),this._buffer=null}},e.prototype.update=function(e){this.create(e)},e.prototype.updateDirectly=function(e,t,i,r){void 0===r&&(r=!1),this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,r?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),this._data=0===t&&void 0===i?e:null)},e.prototype._increaseReferences=function(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)},e.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._isDisposed=!0,this._data=null,this._buffer=null)},e}(),Nr=function(){function e(t,i,r,n,o,a,s,l,c,u,h,d,p,f){var _,m,g,v,y;void 0===h&&(h=!1),void 0===d&&(d=!1),void 0===p&&(p=1),void 0===f&&(f=!1),this._isDisposed=!1;var b=!1;if(this.engine=t,"object"==typeof n&&null!==n?(b=null!==(_=n.updatable)&&void 0!==_&&_,o=n.postponeInternalCreation,a=n.stride,s=n.instanced,l=n.offset,c=n.size,u=n.type,h=null!==(m=n.normalized)&&void 0!==m&&m,d=null!==(g=n.useBytes)&&void 0!==g&&g,p=null!==(v=n.divisor)&&void 0!==v?v:1,f=null!==(y=n.takeBufferOwnership)&&void 0!==y&&y,this._label=n.label):b=!!n,i instanceof Dr?(this._buffer=i,this._ownsBuffer=f):(this._buffer=new Dr(t,i,b,a,o,s,d,p,this._label),this._ownsBuffer=!0),this.uniqueId=e._Counter++,this._kind=r,void 0===u){var T=this.getData();this.type=T?e.GetDataType(T):e.FLOAT}else this.type=u;var E=e.GetTypeByteLength(this.type);d?(this._size=c||(a?a/E:e.DeduceStride(r)),this.byteStride=a||this._buffer.byteStride||this._size*E,this.byteOffset=l||0):(this._size=c||a||e.DeduceStride(r),this.byteStride=a?a*E:this._buffer.byteStride||this._size*E,this.byteOffset=(l||0)*E),this.normalized=h,this._instanced=void 0!==s&&s,this._instanceDivisor=s?p:0,this._alignBuffer(),this._computeHashCode()}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(e){var t=0!=e;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_maxVerticesCount",{get:function(){var e=this.getData();return e?Array.isArray(e)?e.length/(this.byteStride/4)-this.byteOffset/4:(e.byteLength-this.byteOffset)/this.byteStride:0},enumerable:!1,configurable:!0}),e.prototype._computeHashCode=function(){this.hashCode=(this.type-5120|0)+((this.normalized?1:0)<<3)+(this._size<<4)+((this._instanced?1:0)<<6)+(this.byteStride<<12)},e.prototype._rebuild=function(){var e;null===(e=this._buffer)||void 0===e||e._rebuild()},e.prototype.getKind=function(){return this._kind},e.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},e.prototype.getData=function(){return this._buffer.getData()},e.prototype.getFloatData=function(t,i){var r=this.getData();return r?e.GetFloatData(r,this._size,this.type,this.byteOffset,this.byteStride,this.normalized,t,i):null},e.prototype.getBuffer=function(){return this._buffer.getBuffer()},e.prototype.getWrapperBuffer=function(){return this._buffer},e.prototype.getStrideSize=function(){return this.byteStride/e.GetTypeByteLength(this.type)},e.prototype.getOffset=function(){return this.byteOffset/e.GetTypeByteLength(this.type)},e.prototype.getSize=function(t){return void 0===t&&(t=!1),t?this._size*e.GetTypeByteLength(this.type):this._size},e.prototype.getIsInstanced=function(){return this._instanced},e.prototype.getInstanceDivisor=function(){return this._instanceDivisor},e.prototype.create=function(e){this._buffer.create(e),this._alignBuffer()},e.prototype.update=function(e){this._buffer.update(e),this._alignBuffer()},e.prototype.updateDirectly=function(e,t,i){void 0===i&&(i=!1),this._buffer.updateDirectly(e,t,void 0,i),this._alignBuffer()},e.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose(),this._isDisposed=!0},e.prototype.forEach=function(t,i){e.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,t,this.normalized,i)},e.prototype._alignBuffer=function(){},e.DeduceStride=function(t){switch(t){case e.UVKind:case e.UV2Kind:case e.UV3Kind:case e.UV4Kind:case e.UV5Kind:case e.UV6Kind:return 2;case e.NormalKind:case e.PositionKind:return 3;case e.ColorKind:case e.ColorInstanceKind:case e.MatricesIndicesKind:case e.MatricesIndicesExtraKind:case e.MatricesWeightsKind:case e.MatricesWeightsExtraKind:case e.TangentKind:return 4;default:throw new Error("Invalid kind '"+t+"'")}},e.GetDataType=function(t){return t instanceof Int8Array?e.BYTE:t instanceof Uint8Array?e.UNSIGNED_BYTE:t instanceof Int16Array?e.SHORT:t instanceof Uint16Array?e.UNSIGNED_SHORT:t instanceof Int32Array?e.INT:t instanceof Uint32Array?e.UNSIGNED_INT:e.FLOAT},e.GetTypeByteLength=function(t){switch(t){case e.BYTE:case e.UNSIGNED_BYTE:return 1;case e.SHORT:case e.UNSIGNED_SHORT:return 2;case e.INT:case e.UNSIGNED_INT:case e.FLOAT:return 4;default:throw new Error("Invalid type '".concat(t,"'"))}},e.ForEach=function(t,i,r,n,o,a,s,l){if(t instanceof Array)for(var c=i/4,u=r/4,h=0;h0&&i.negateInPlace()}return i.normalize(),i},e.prototype.getTextureCoordinates=function(e){if(void 0===e&&(e=Nr.UVKind),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;var t=this.pickedMesh.getIndices();if(!t)return null;var i=this.pickedMesh.getVerticesData(e);if(!i)return null;var r=U.FromArray(i,2*t[3*this.faceId]),n=U.FromArray(i,2*t[3*this.faceId+1]),o=U.FromArray(i,2*t[3*this.faceId+2]);return r=r.scale(this.bu),n=n.scale(this.bv),o=o.scale(1-this.bu-this.bv),new U(r.x+n.x+o.x,r.y+n.y+o.y)},e}(),Lr=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[Nr.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[Nr.PositionKind]=new Nr(this._scene.getEngine(),e,Nr.PositionKind,!1,!1,2),this._buildIndexBuffer()}},e.prototype._buildIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},e.prototype._rebuild=function(){var e=this._vertexBuffers[Nr.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())},e.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;return!(!i||!(t=t||i._postProcesses.filter((function(e){return null!=e})))||0===t.length||!this._scene.postProcessesEnabled||(t[0].activate(i,e,null!=t),0))},e.prototype.directRender=function(e,t,i,r,n,o){var a;void 0===t&&(t=null),void 0===i&&(i=!1),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=!1);for(var s=this._scene.getEngine(),l=0;li._alphaIndex?1:t._alphaIndext._distanceToCamera?-1:0},e.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},e.PainterSortCompare=function(e,t){var i=e.getMesh(),r=t.getMesh();return i.material&&r.material?i.material.uniqueId-r.material.uniqueId:i.uniqueId-r.uniqueId},e.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0},e.prototype.prepareSprites=function(){this._spriteManagers.reset()},e.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},e.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!=i&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTesting()?(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)},e.prototype.dispatchSprites=function(e){this._spriteManagers.push(e),this._empty=!1},e.prototype.dispatchParticles=function(e){this._particleSystems.push(e),this._empty=!1},e.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var i=0;i=xr.LeftClick&&i<=xr.RightClick&&(s.type=1===r?"pointerdown":"pointerup",s.button=i-2),s},e._CreateWheelEvent=function(e,t,i,r,n,o){var a=this._CreateMouseEvent(e,t,i,r,n,o);switch(a.pointerId=1,a.type="wheel",a.deltaMode=Qr.DOM_DELTA_PIXEL,a.deltaX=0,a.deltaY=0,a.deltaZ=0,i){case xr.MouseWheelX:a.deltaX=r;break;case xr.MouseWheelY:a.deltaY=r;break;case xr.MouseWheelZ:a.deltaZ=r}return a},e._CreateMouseEvent=function(e,t,i,r,n,o){var a=this._CreateEvent(o),s=n.pollInput(e,t,xr.Horizontal),l=n.pollInput(e,t,xr.Vertical);return o?(a.movementX=0,a.movementY=0,a.offsetX=a.movementX-o.getBoundingClientRect().x,a.offsetY=a.movementY-o.getBoundingClientRect().y):(a.movementX=n.pollInput(e,t,Ar.DeltaHorizontal),a.movementY=n.pollInput(e,t,Ar.DeltaVertical),a.offsetX=0,a.offsetY=0),this._CheckNonCharacterKeys(a,n),a.clientX=s,a.clientY=l,a.x=s,a.y=l,a.deviceType=e,a.deviceSlot=t,a.inputIndex=i,a},e._CreateKeyboardEvent=function(e,t,i,r){var n=this._CreateEvent(r);return this._CheckNonCharacterKeys(n,i),n.deviceType=Sr.Keyboard,n.deviceSlot=0,n.inputIndex=e,n.type=1===t?"keydown":"keyup",n.key=String.fromCharCode(e),n.keyCode=e,n},e._CheckNonCharacterKeys=function(e,t){var i=t.isDeviceAvailable(Sr.Keyboard),r=i&&1===t.pollInput(Sr.Keyboard,0,u.INPUT_ALT_KEY),n=i&&1===t.pollInput(Sr.Keyboard,0,u.INPUT_CTRL_KEY),o=i&&(1===t.pollInput(Sr.Keyboard,0,u.INPUT_META_KEY1)||1===t.pollInput(Sr.Keyboard,0,u.INPUT_META_KEY2)||1===t.pollInput(Sr.Keyboard,0,u.INPUT_META_KEY3)),a=i&&1===t.pollInput(Sr.Keyboard,0,u.INPUT_SHIFT_KEY);e.altKey=r,e.ctrlKey=n,e.metaKey=o,e.shiftKey=a},e._CreateEvent=function(e){var t={preventDefault:function(){}};return t.target=e,t},e}(),Zr=function(){function e(e,t,i){var r=this;this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(function(e,t,n,o){var a=qr.CreateDeviceEvent(e,t,n,o,r);i(e,t,a)})):this._createDummyNativeInput()}return e.prototype.pollInput=function(e,t,i){return this._nativeInput.pollInput(e,t,i)},e.prototype.isDeviceAvailable=function(e){return e===Sr.Mouse||e===Sr.Touch},e.prototype.dispose=function(){this._nativeInput.dispose()},e.prototype._createDummyNativeInput=function(){return{pollInput:function(){return 0},isDeviceAvailable:function(){return!1},dispose:function(){}}},e}(),Jr=Object.keys(xr).length/2,$r=function(){function e(e,t,i,r){var n=this;this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=rr.IsSafari(),this._usingMacOS=ut()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=function(e){},this._keyboardUpEvent=function(e){},this._keyboardBlurEvent=function(e){},this._pointerMoveEvent=function(e){},this._pointerDownEvent=function(e){},this._pointerUpEvent=function(e){},this._pointerCancelEvent=function(e){},this._pointerWheelEvent=function(e){},this._pointerBlurEvent=function(e){},this._pointerMacOSChromeOutEvent=function(e){},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=ut()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Firefox"),this._isUsingChromium=ut()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Chrome"),this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=function(e){},this._gamepadDisconnectedEvent=function(e){},this._eventPrefix=rr.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=i,this._onInputChanged=r,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOS&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=function(){n._enableEvents()})}return e.prototype.pollInput=function(e,t,i){var r=this._inputs[e][t];if(!r)throw"Unable to find device ".concat(Sr[e]);e>=Sr.DualShock&&e<=Sr.DualSense&&this._updateDevice(e,t,i);var n=r[i];if(void 0===n)throw"Unable to find input ".concat(i," for device ").concat(Sr[e]," in slot ").concat(t);return i===xr.Move&&rr.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),n},e.prototype.isDeviceAvailable=function(e){return void 0!==this._inputs[e]},e.prototype.dispose=function(){this._onDeviceConnected=function(){},this._onDeviceDisconnected=function(){},this._onInputChanged=function(){},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()},e.prototype._enableEvents=function(){var e=null==this?void 0:this._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs)for(var t=0,i=this._inputs;t0){for(var n=0,o=e._metaKeys;n=0))return void rr.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(e._maxTouchPoints));r=n,e._activeTouchIds[n]=t.pointerId,e._onDeviceConnected(i,r)}e._inputs[i]||(e._inputs[i]={}),e._inputs[i][r]||e._addPointerDevice(i,r,t.clientX,t.clientY);var o=e._inputs[i][r];if(o){var a=t;a.inputIndex=xr.Move,o[xr.Horizontal]=t.clientX,o[xr.Vertical]=t.clientY,i===Sr.Touch&&0===o[xr.LeftClick]&&(o[xr.LeftClick]=1),void 0===t.pointerId&&(t.pointerId=e._mouseId),e._onInputChanged(i,r,a),e._usingSafari||-1===t.button||(a.inputIndex=t.button+2,o[t.button+2]=o[t.button+2]?0:1,e._onInputChanged(i,r,a))}},this._pointerDownEvent=function(t){var i=e._getPointerType(t),r=i===Sr.Mouse?0:t.pointerId;if(i===Sr.Touch){var n=e._activeTouchIds.indexOf(-1);if(!(n>=0))return void rr.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(e._maxTouchPoints));r=n,e._activeTouchIds[n]=t.pointerId}e._inputs[i]||(e._inputs[i]={}),e._inputs[i][r]?i===Sr.Touch&&e._onDeviceConnected(i,r):e._addPointerDevice(i,r,t.clientX,t.clientY);var o=e._inputs[i][r];if(o){var a=o[xr.Horizontal],s=o[xr.Vertical];if(i===Sr.Mouse){if(void 0===t.pointerId&&(t.pointerId=e._mouseId),!document.pointerLockElement)try{e._elementToAttachTo.setPointerCapture(e._mouseId)}catch(e){}}else if(t.pointerId&&!document.pointerLockElement)try{e._elementToAttachTo.setPointerCapture(t.pointerId)}catch(e){}o[xr.Horizontal]=t.clientX,o[xr.Vertical]=t.clientY,o[t.button+2]=1;var l=t;l.inputIndex=t.button+2,e._onInputChanged(i,r,l),a===t.clientX&&s===t.clientY||(l.inputIndex=xr.Move,e._onInputChanged(i,r,l))}},this._pointerUpEvent=function(t){var i,r,n,o,a,s=e._getPointerType(t),l=s===Sr.Mouse?0:e._activeTouchIds.indexOf(t.pointerId);if(s===Sr.Touch){if(-1===l)return;e._activeTouchIds[l]=-1}var c=null===(i=e._inputs[s])||void 0===i?void 0:i[l];if(c&&0!==c[t.button+2]){var u=c[xr.Horizontal],h=c[xr.Vertical];c[xr.Horizontal]=t.clientX,c[xr.Vertical]=t.clientY,c[t.button+2]=0;var d=t;void 0===t.pointerId&&(t.pointerId=e._mouseId),u===t.clientX&&h===t.clientY||(d.inputIndex=xr.Move,e._onInputChanged(s,l,d)),d.inputIndex=t.button+2,s===Sr.Mouse&&e._mouseId>=0&&(null===(n=(r=e._elementToAttachTo).hasPointerCapture)||void 0===n?void 0:n.call(r,e._mouseId))?e._elementToAttachTo.releasePointerCapture(e._mouseId):t.pointerId&&(null===(a=(o=e._elementToAttachTo).hasPointerCapture)||void 0===a?void 0:a.call(o,t.pointerId))&&e._elementToAttachTo.releasePointerCapture(t.pointerId),e._onInputChanged(s,l,d),s===Sr.Touch&&e._onDeviceDisconnected(s,l)}},this._pointerCancelEvent=function(t){var i,r,n,o;if("mouse"===t.pointerType){var a=e._inputs[Sr.Mouse][0];e._mouseId>=0&&(null===(r=(i=e._elementToAttachTo).hasPointerCapture)||void 0===r?void 0:r.call(i,e._mouseId))&&e._elementToAttachTo.releasePointerCapture(e._mouseId);for(var s=xr.LeftClick;s<=xr.BrowserForward;s++)if(1===a[s]){a[s]=0;var l=qr.CreateDeviceEvent(Sr.Mouse,0,s,0,e,e._elementToAttachTo);e._onInputChanged(Sr.Mouse,0,l)}}else{var c=e._activeTouchIds.indexOf(t.pointerId);if(-1===c)return;(null===(o=(n=e._elementToAttachTo).hasPointerCapture)||void 0===o?void 0:o.call(n,t.pointerId))&&e._elementToAttachTo.releasePointerCapture(t.pointerId),e._inputs[Sr.Touch][c][xr.LeftClick]=0,l=qr.CreateDeviceEvent(Sr.Touch,c,xr.LeftClick,0,e,e._elementToAttachTo,t.pointerId),e._onInputChanged(Sr.Touch,c,l),e._activeTouchIds[c]=-1,e._onDeviceDisconnected(Sr.Touch,c)}},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";var i=!1,r=function(){};try{var n=Object.defineProperty({},"passive",{get:function(){i=!0}});this._elementToAttachTo.addEventListener("test",r,n),this._elementToAttachTo.removeEventListener("test",r,n)}catch(e){}this._pointerBlurEvent=function(){var t,i,r,n,o;if(e.isDeviceAvailable(Sr.Mouse)){var a=e._inputs[Sr.Mouse][0];e._mouseId>=0&&(null===(i=(t=e._elementToAttachTo).hasPointerCapture)||void 0===i?void 0:i.call(t,e._mouseId))&&e._elementToAttachTo.releasePointerCapture(e._mouseId);for(var s=xr.LeftClick;s<=xr.BrowserForward;s++)if(1===a[s]){a[s]=0;var l=qr.CreateDeviceEvent(Sr.Mouse,0,s,0,e,e._elementToAttachTo);e._onInputChanged(Sr.Mouse,0,l)}}if(e.isDeviceAvailable(Sr.Touch)){a=e._inputs[Sr.Touch];for(var c=0;c1&&e._pointerCancelEvent(t)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOSChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,!!i&&{passive:!1}),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add((function(){if(e.isDeviceAvailable(Sr.Mouse)){var t=e._inputs[Sr.Mouse][0];t[xr.MouseWheelX]=0,t[xr.MouseWheelY]=0,t[xr.MouseWheelZ]=0}}))},e.prototype._handleGamepadActions=function(){var e=this;this._gamepadConnectedEvent=function(t){e._addGamePad(t.gamepad)},this._gamepadDisconnectedEvent=function(t){if(e._gamepads){var i=e._getGamepadDeviceType(t.gamepad.id),r=t.gamepad.index;e._unregisterDevice(i,r),delete e._gamepads[r]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)},e.prototype._updateDevice=function(e,t,i){var r=navigator.getGamepads()[t];if(r&&e===this._gamepads[t]){var n=this._inputs[e][t];i>=r.buttons.length?n[i]=r.axes[i-r.buttons.length].valueOf():n[i]=r.buttons[i].value}},e.prototype._getGamepadDeviceType=function(e){return-1!==e.indexOf("054c")?-1!==e.indexOf("0ce6")?Sr.DualSense:Sr.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?Sr.Xbox:-1!==e.indexOf("057e")?Sr.Switch:Sr.Generic},e.prototype._getPointerType=function(e){var t=Sr.Mouse;return("touch"===e.pointerType||"pen"===e.pointerType||e.touches)&&(t=Sr.Touch),t},e}(),en=function(){function e(e,t,i){void 0===i&&(i=0),this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new f,this._deviceInputSystem=e}return e.prototype.getInput=function(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)},e}(),tn=function(){function e(e){var t=this;this._registeredManagers=new Array,this._refCount=0,this.registerManager=function(e){for(var i=0;i-1&&t._registeredManagers.splice(i,1)};var i=Object.keys(Sr).length/2;this._devices=new Array(i);var r=function(e,i){t._devices[e]||(t._devices[e]=new Array),t._devices[e][i]||(t._devices[e][i]=i);for(var r=0,n=t._registeredManagers;r=xr.MouseWheelX&&t.inputIndex<=xr.MouseWheelZ?Gr.POINTERWHEEL:Gr.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,u)),e?(c=new Hr(u,t,e),this._setRayOnPointerInfo(e,t)):(c=new Hr(u,t,null,this),this._movePointerInfo=c),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(c,u)},e.prototype._setRayOnPointerInfo=function(e,t){var i=this._scene;e&&i._pickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,z.Identity(),i.activeCamera)))},e.prototype._addCameraPointerObserver=function(e,t){return this._cameraObserverCount++,this._scene.onPointerObservable.add(e,t)},e.prototype._removeCameraPointerObserver=function(e){return this._cameraObserverCount--,this._scene.onPointerObservable.remove(e)},e.prototype._checkForPicking=function(){return!!(this._scene.onPointerObservable.observers.length>this._cameraObserverCount||this._scene.onPointerPick)},e.prototype._checkPrePointerObservable=function(e,t,i){var r=this._scene,n=new Wr(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(n.originalPickingInfo=e,n.ray=e.ray,"xr-near"===t.pointerType&&e.originMesh&&(n.nearInteractionPickingInfo=e)),r.onPrePointerObservable.notifyObservers(n,i),!!n.skipOnPointerObservable},e.prototype._pickMove=function(e){var t=this._scene,i=t.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,t.pointerMovePredicate,t.pointerMoveFastCheck,t.cameraToUseForPointers,t.pointerMoveTrianglePredicate);return this._setCursorAndPointerOverMesh(i,e,t),i},e.prototype._setCursorAndPointerOverMesh=function(e,t,i){var r=i.getEngine().getInputElement();if(null==e?void 0:e.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&r&&this._pointerOverMesh){var n=this._pointerOverMesh._getActionManagerForTrigger();n&&n.hasPointerTriggers&&(r.style.cursor=n.hoverCursor||i.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)},e.prototype.simulatePointerMove=function(e,t){var i=new PointerEvent("pointermove",t);i.inputIndex=xr.Move,this._checkPrePointerObservable(e,i,Gr.POINTERMOVE)||this._processPointerMove(e,i)},e.prototype.simulatePointerDown=function(e,t){var i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,this._checkPrePointerObservable(e,i,Gr.POINTERDOWN)||this._processPointerDown(e,i)},e.prototype._processPointerDown=function(t,i){var r,n=this,o=this._scene;if(null==t?void 0:t.pickedMesh){this._pickedDownMesh=t.pickedMesh;var a=t.pickedMesh._getActionManagerForTrigger();if(a){if(a.hasPickTriggers)switch(a.processTrigger(u.ACTION_OnPickDownTrigger,te.CreateNew(t.pickedMesh,i,t)),i.button){case 0:a.processTrigger(u.ACTION_OnLeftPickTrigger,te.CreateNew(t.pickedMesh,i,t));break;case 1:a.processTrigger(u.ACTION_OnCenterPickTrigger,te.CreateNew(t.pickedMesh,i,t));break;case 2:a.processTrigger(u.ACTION_OnRightPickTrigger,te.CreateNew(t.pickedMesh,i,t))}a.hasSpecificTrigger(u.ACTION_OnLongPressTrigger)&&window.setTimeout((function(){var t=o.pick(n._unTranslatedPointerX,n._unTranslatedPointerY,(function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(u.ACTION_OnLongPressTrigger)&&e===n._pickedDownMesh}),!1,o.cameraToUseForPointers);(null==t?void 0:t.pickedMesh)&&a&&0!==n._totalPointersPressed&&Date.now()-n._startingPointerTime>e.LongPressDelay&&!n._isPointerSwiping()&&(n._startingPointerTime=0,a.processTrigger(u.ACTION_OnLongPressTrigger,te.CreateNew(t.pickedMesh,i)))}),e.LongPressDelay)}}else for(var s=0,l=o._pointerDownStage;sthis._cameraObserverCount)){var n=Gr.POINTERPICK,o=new Hr(n,t,e);this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(o,n)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!i.ignore){a.processTrigger(u.ACTION_OnPickUpTrigger,te.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&a.processTrigger(u.ACTION_OnPickTrigger,te.CreateNew(e.pickedMesh,t,e));var s=e.pickedMesh._getActionManagerForTrigger(u.ACTION_OnDoublePickTrigger);i.doubleClick&&s&&s.processTrigger(u.ACTION_OnDoublePickTrigger,te.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(var l=0,c=r._pointerUpStage;le.DoubleClickDelay&&!o._doubleClickOccured||t!==o._previousButtonPressed)&&(o._doubleClickOccured=!1,i.singleClick=!0,i.ignore=!1,o._delayedClicks[t])){var n=o._delayedClicks[t].evt,s=Gr.POINTERTAP,l=new Hr(s,n,o._currentPickResult);a.onPointerObservable.hasObservers()&&a.onPointerObservable.hasSpecificMask(s)&&a.onPointerObservable.notifyObservers(l,s),o._delayedClicks[t]=null}},this._initClickEvent=function(t,i,r,n){var a,s,l=new nn;o._currentPickResult=null;var c=null,d=t.hasSpecificMask(Gr.POINTERPICK)||i.hasSpecificMask(Gr.POINTERPICK)||t.hasSpecificMask(Gr.POINTERTAP)||i.hasSpecificMask(Gr.POINTERTAP)||t.hasSpecificMask(Gr.POINTERDOUBLETAP)||i.hasSpecificMask(Gr.POINTERDOUBLETAP);!d&&h&&(c=o._initActionManager(c,l))&&(d=c.hasPickTriggers);var p=!1;if(d){var f=r.button;if(l.hasSwiped=o._isPointerSwiping(),!l.hasSwiped){var _=!e.ExclusiveDoubleClickMode;if(_||(_=!t.hasSpecificMask(Gr.POINTERDOUBLETAP)&&!i.hasSpecificMask(Gr.POINTERDOUBLETAP))&&!h.HasSpecificTrigger(u.ACTION_OnDoublePickTrigger)&&(c=o._initActionManager(c,l))&&(_=!c.hasSpecificTrigger(u.ACTION_OnDoublePickTrigger)),_)(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay||f!==o._previousButtonPressed)&&(l.singleClick=!0,n(l,o._currentPickResult),p=!0);else{var m={evt:r,clickInfo:l,timeoutId:window.setTimeout(o._delayedSimpleClick.bind(o,f,l,n),e.DoubleClickDelay)};o._delayedClicks[f]=m}var g=t.hasSpecificMask(Gr.POINTERDOUBLETAP)||i.hasSpecificMask(Gr.POINTERDOUBLETAP);!g&&h.HasSpecificTrigger(u.ACTION_OnDoublePickTrigger)&&(c=o._initActionManager(c,l))&&(g=c.hasSpecificTrigger(u.ACTION_OnDoublePickTrigger)),g&&(f===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTimee.DragMovementThreshold||Math.abs(o._startingPointerPosition.y-o._pointerY)>e.DragMovementThreshold),s.isPointerLock&&s._verifyPointerLock(),!o._checkPrePointerObservable(null,t,t.inputIndex>=xr.MouseWheelX&&t.inputIndex<=xr.MouseWheelZ?Gr.POINTERWHEEL:Gr.POINTERMOVE)&&(a.cameraToUseForPointers||a.activeCamera))if(a.skipPointerMovePicking)o._processPointerMove(new Fr,t);else{a.pointerMovePredicate||(a.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||a.constantlyUpdateMeshUnderPointer||null!==e._getActionManagerForTrigger())&&(!a.cameraToUseForPointers||!!(a.cameraToUseForPointers.layerMask&e.layerMask))});var i=a._registeredActions>0||a.constantlyUpdateMeshUnderPointer?o._pickMove(t):null;o._processPointerMove(i,t)}},this._onPointerDown=function(t){var i,r;if(o._totalPointersPressed++,o._pickedDownMesh=null,o._meshPickProceed=!1,e.ExclusiveDoubleClickMode)for(var s=0;s1&&(o._isMultiTouchGesture=!0)):t&&0===e.getInput(n.inputIndex)&&(o._onPointerUp(n),0===o._totalPointersPressed&&(o._isMultiTouchGesture=!1))),r&&n.inputIndex===xr.Move&&o._onPointerMove(n)})):e.deviceType===Sr.Keyboard&&e.onInputChangedObservable.add((function(e){"keydown"===e.type?o._onKeyDown(e):"keyup"===e.type&&o._onKeyUp(e)}))})),this._alreadyAttached=!0},e.prototype.detachControl=function(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)},e.prototype.setPointerOverMesh=function(e,t,i,r){if(void 0===t&&(t=0),this._meshUnderPointerId[t]!==e||e&&e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting){var n,o=this._meshUnderPointerId[t];o&&(n=o._getActionManagerForTrigger(u.ACTION_OnPointerOutTrigger))&&n.processTrigger(u.ACTION_OnPointerOutTrigger,te.CreateNew(o,r,{pointerId:t})),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,(n=e._getActionManagerForTrigger(u.ACTION_OnPointerOverTrigger))&&n.processTrigger(u.ACTION_OnPointerOverTrigger,te.CreateNew(e,r,{pointerId:t,pickResult:i}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null)}},e.prototype.getPointerOverMesh=function(){return this.meshUnderPointer},e.prototype._invalidateMesh=function(e){for(var t in this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null),this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]},e.DragMovementThreshold=10,e.LongPressDelay=500,e.DoubleClickDelay=300,e.ExclusiveDoubleClickMode=!1,e}(),an=function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!1,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(t,i){e.Enabled&&(this._current+=t,i&&this._fetchResult())},e.prototype.beginMonitoring=function(){e.Enabled&&(this._startMonitoringTime=_t.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=_t.Now;this._current=i-this._startMonitoringTime,t&&this._fetchResult()}},e.prototype.endFrame=function(){this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=_t.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}(),sn=function(){function e(e,t,i,r){this.normal=new V(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return 397*e^this.d},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=e._TmpMatrix;t.invertToRef(i);var r=i.m,n=this.normal.x,o=this.normal.y,a=this.normal.z,s=this.d;return new e(n*r[0]+o*r[1]+a*r[2]+s*r[3],n*r[4]+o*r[5]+a*r[6]+s*r[7],n*r[8]+o*r[9]+a*r[10]+s*r[11],n*r[12]+o*r[13]+a*r[14]+s*r[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,a=t.z-e.z,s=i.x-e.x,l=i.y-e.y,c=i.z-e.z,u=o*c-a*l,h=a*s-n*c,d=n*l-o*s,p=Math.sqrt(u*u+h*h+d*d);return r=0!==p?1/p:0,this.normal.x=u*r,this.normal.y=h*r,this.normal.z=d*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return V.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return V.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return this.FromPositionAndNormalToRef(t,i,r)},e.FromPositionAndNormalToRef=function(e,t,i){return i.normal.copyFrom(t),i.normal.normalize(),i.d=-e.dot(i.normal),i},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return V.Dot(i,t)+r},e._TmpMatrix=z.Identity(),e}(),ln=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new sn(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetNearPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[2],t.normal.y=i[7]+i[6],t.normal.z=i[11]+i[10],t.d=i[15]+i[14],t.normalize()},e.GetFarPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[2],t.normal.y=i[7]-i[6],t.normal.z=i[11]-i[10],t.d=i[15]-i[14],t.normalize()},e.GetLeftPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[0],t.normal.y=i[7]+i[4],t.normal.z=i[11]+i[8],t.d=i[15]+i[12],t.normalize()},e.GetRightPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[0],t.normal.y=i[7]-i[4],t.normal.z=i[11]-i[8],t.d=i[15]-i[12],t.normalize()},e.GetTopPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[1],t.normal.y=i[7]-i[5],t.normal.z=i[11]-i[9],t.d=i[15]-i[13],t.normalize()},e.GetBottomPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[1],t.normal.y=i[7]+i[5],t.normal.z=i[11]+i[9],t.d=i[15]+i[13],t.normalize()},e.GetPlanesToRef=function(t,i){e.GetNearPlaneToRef(t,i[0]),e.GetFarPlaneToRef(t,i[1]),e.GetLeftPlaneToRef(t,i[2]),e.GetRightPlaneToRef(t,i[3]),e.GetTopPlaneToRef(t,i[4]),e.GetBottomPlaneToRef(t,i[5])},e.IsPointInFrustum=function(e,t){for(var i=0;i<6;i++)if(t[i].dotCoordinate(e)<0)return!1;return!0},e}(),cn=function(){function e(){}return Object.defineProperty(e,"UniqueId",{get:function(){var e=this._UniqueIdCounter;return this._UniqueIdCounter++,e},enumerable:!1,configurable:!0}),e._UniqueIdCounter=1,e}(),un=function(){function e(){}return e.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},e.FALLOFF_DEFAULT=0,e.FALLOFF_PHYSICAL=1,e.FALLOFF_GLTF=2,e.FALLOFF_STANDARD=3,e.LIGHTMAP_DEFAULT=0,e.LIGHTMAP_SPECULAR=1,e.LIGHTMAP_SHADOWSONLY=2,e.INTENSITYMODE_AUTOMATIC=0,e.INTENSITYMODE_LUMINOUSPOWER=1,e.INTENSITYMODE_LUMINOUSINTENSITY=2,e.INTENSITYMODE_ILLUMINANCE=3,e.INTENSITYMODE_LUMINANCE=4,e.LIGHTTYPEID_POINTLIGHT=0,e.LIGHTTYPEID_DIRECTIONALLIGHT=1,e.LIGHTTYPEID_SPOTLIGHT=2,e.LIGHTTYPEID_HEMISPHERICLIGHT=3,e}(),hn=function(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1};!function(e){e[e.BackwardCompatible=0]="BackwardCompatible",e[e.Intermediate=1]="Intermediate",e[e.Aggressive=2]="Aggressive"}(Kr||(Kr={}));var dn,pn=function(e){function t(i,r){var n=e.call(this)||this;n._inputManager=new on(n),n.cameraToUseForPointers=null,n._isScene=!0,n._blockEntityCollection=!1,n.autoClear=!0,n.autoClearDepthAndStencil=!0,n.clearColor=new J(.2,.2,.3,1),n.ambientColor=new Z(0,0,0),n.environmentIntensity=1,n._performancePriority=Kr.BackwardCompatible,n.onScenePerformancePriorityChangedObservable=new f,n._forceWireframe=!1,n._skipFrustumClipping=!1,n._forcePointsCloud=!1,n.animationsEnabled=!0,n._animationPropertiesOverride=null,n.useConstantAnimationDeltaTime=!1,n.constantlyUpdateMeshUnderPointer=!1,n.hoverCursor="pointer",n.defaultCursor="",n.doNotHandleCursors=!1,n.preventDefaultOnPointerDown=!0,n.preventDefaultOnPointerUp=!0,n.metadata=null,n.reservedDataStore=null,n.disableOfflineSupportExceptionRules=[],n.onDisposeObservable=new f,n._onDisposeObserver=null,n.onBeforeRenderObservable=new f,n._onBeforeRenderObserver=null,n.onAfterRenderObservable=new f,n.onAfterRenderCameraObservable=new f,n._onAfterRenderObserver=null,n.onBeforeAnimationsObservable=new f,n.onAfterAnimationsObservable=new f,n.onBeforeDrawPhaseObservable=new f,n.onAfterDrawPhaseObservable=new f,n.onReadyObservable=new f,n.onBeforeCameraRenderObservable=new f,n._onBeforeCameraRenderObserver=null,n.onAfterCameraRenderObservable=new f,n._onAfterCameraRenderObserver=null,n.onBeforeActiveMeshesEvaluationObservable=new f,n.onAfterActiveMeshesEvaluationObservable=new f,n.onBeforeParticlesRenderingObservable=new f,n.onAfterParticlesRenderingObservable=new f,n.onDataLoadedObservable=new f,n.onNewCameraAddedObservable=new f,n.onCameraRemovedObservable=new f,n.onNewLightAddedObservable=new f,n.onLightRemovedObservable=new f,n.onNewGeometryAddedObservable=new f,n.onGeometryRemovedObservable=new f,n.onNewTransformNodeAddedObservable=new f,n.onTransformNodeRemovedObservable=new f,n.onNewMeshAddedObservable=new f,n.onMeshRemovedObservable=new f,n.onNewSkeletonAddedObservable=new f,n.onSkeletonRemovedObservable=new f,n.onNewMaterialAddedObservable=new f,n.onNewMultiMaterialAddedObservable=new f,n.onMaterialRemovedObservable=new f,n.onMultiMaterialRemovedObservable=new f,n.onNewTextureAddedObservable=new f,n.onTextureRemovedObservable=new f,n.onBeforeRenderTargetsRenderObservable=new f,n.onAfterRenderTargetsRenderObservable=new f,n.onBeforeStepObservable=new f,n.onAfterStepObservable=new f,n.onActiveCameraChanged=new f,n.onActiveCamerasChanged=new f,n.onBeforeRenderingGroupObservable=new f,n.onAfterRenderingGroupObservable=new f,n.onMeshImportedObservable=new f,n.onAnimationFileImportedObservable=new f,n._registeredForLateAnimationBindings=new sr(256),n._pointerPickingConfiguration=new hn,n.onPrePointerObservable=new f,n.onPointerObservable=new f,n.onPreKeyboardObservable=new f,n.onKeyboardObservable=new f,n._useRightHandedSystem=!1,n._timeAccumulator=0,n._currentStepId=0,n._currentInternalStep=0,n._fogEnabled=!0,n._fogMode=t.FOGMODE_NONE,n.fogColor=new Z(.2,.2,.3),n.fogDensity=.1,n.fogStart=0,n.fogEnd=1e3,n.needsPreviousWorldMatrices=!1,n._shadowsEnabled=!0,n._lightsEnabled=!0,n._unObserveActiveCameras=null,n._texturesEnabled=!0,n.physicsEnabled=!0,n.particlesEnabled=!0,n.spritesEnabled=!0,n._skeletonsEnabled=!0,n.lensFlaresEnabled=!0,n.collisionsEnabled=!0,n.gravity=new V(0,-9.807,0),n.postProcessesEnabled=!0,n.renderTargetsEnabled=!0,n.dumpNextRenderTargets=!1,n.customRenderTargets=[],n.importedMeshesFiles=[],n.probesEnabled=!0,n._meshesForIntersections=new sr(256),n.proceduralTexturesEnabled=!0,n._totalVertices=new an,n._activeIndices=new an,n._activeParticles=new an,n._activeBones=new an,n._animationTime=0,n.animationTimeScale=1,n._renderId=0,n._frameId=0,n._executeWhenReadyTimeoutId=null,n._intermediateRendering=!1,n._defaultFrameBufferCleared=!1,n._viewUpdateFlag=-1,n._projectionUpdateFlag=-1,n._toBeDisposed=new Array(256),n._activeRequests=new Array,n._pendingData=new Array,n._isDisposed=!1,n.dispatchAllSubMeshesOfActiveMeshes=!1,n._activeMeshes=new ar(256),n._processedMaterials=new ar(256),n._renderTargets=new sr(256),n._materialsRenderTargets=new sr(256),n._activeParticleSystems=new ar(256),n._activeSkeletons=new sr(32),n._softwareSkinnedMeshes=new sr(32),n._activeAnimatables=new Array,n._transformMatrix=z.Zero(),n.requireLightSorting=!1,n._components=[],n._serializableComponents=[],n._transientComponents=[],n._beforeCameraUpdateStage=kr.Create(),n._beforeClearStage=kr.Create(),n._beforeRenderTargetClearStage=kr.Create(),n._gatherRenderTargetsStage=kr.Create(),n._gatherActiveCameraRenderTargetsStage=kr.Create(),n._isReadyForMeshStage=kr.Create(),n._beforeEvaluateActiveMeshStage=kr.Create(),n._evaluateSubMeshStage=kr.Create(),n._preActiveMeshStage=kr.Create(),n._cameraDrawRenderTargetStage=kr.Create(),n._beforeCameraDrawStage=kr.Create(),n._beforeRenderTargetDrawStage=kr.Create(),n._beforeRenderingGroupDrawStage=kr.Create(),n._beforeRenderingMeshStage=kr.Create(),n._afterRenderingMeshStage=kr.Create(),n._afterRenderingGroupDrawStage=kr.Create(),n._afterCameraDrawStage=kr.Create(),n._afterCameraPostProcessStage=kr.Create(),n._afterRenderTargetDrawStage=kr.Create(),n._afterRenderTargetPostProcessStage=kr.Create(),n._afterRenderStage=kr.Create(),n._pointerMoveStage=kr.Create(),n._pointerDownStage=kr.Create(),n._pointerUpStage=kr.Create(),n._geometriesByUniqueId=null,n._defaultMeshCandidates={data:[],length:0},n._defaultSubMeshCandidates={data:[],length:0},n._preventFreeActiveMeshesAndRenderingGroups=!1,n._activeMeshesFrozen=!1,n._activeMeshesFrozenButKeepClipping=!1,n._skipEvaluateActiveMeshesCompletely=!1,n._allowPostProcessClearColor=!0,n.getDeterministicFrameTime=function(){return n._engine.getTimeStep()},n._registeredActions=0,n._blockMaterialDirtyMechanism=!1,n._perfCollector=null,n.activeCameras=[];var o=g({useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1},r);return i=n._engine=i||M.LastCreatedEngine,o.virtual?i._virtualScenes.push(n):(M._LastCreatedScene=n,i.scenes.push(n)),n._uid=null,n._renderingManager=new Ur(n),Lr&&(n.postProcessManager=new Lr(n)),ct()&&n.attachControl(),n._createUbo(),pr&&(n._imageProcessingConfiguration=new pr),n.setDefaultCandidateProviders(),o.useGeometryUniqueIdsMap&&(n._geometriesByUniqueId={}),n.useMaterialMeshMap=o.useMaterialMeshMap,n.useClonedMeshMap=o.useClonedMeshMap,r&&r.virtual||i.onNewSceneAddedObservable.notifyObservers(n),n}return m(t,e),t.DefaultMaterialFactory=function(e){throw He("StandardMaterial")},t.CollisionCoordinatorFactory=function(){throw He("DefaultCollisionCoordinator")},Object.defineProperty(t.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"performancePriority",{get:function(){return this._performancePriority},set:function(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case Kr.BackwardCompatible:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case Kr.Intermediate:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case Kr.Aggressive:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(u.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skipFrustumClipping",{get:function(){return this._skipFrustumClipping},set:function(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(u.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerDownPredicate",{get:function(){return this._pointerPickingConfiguration.pointerDownPredicate},set:function(e){this._pointerPickingConfiguration.pointerDownPredicate=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerUpPredicate",{get:function(){return this._pointerPickingConfiguration.pointerUpPredicate},set:function(e){this._pointerPickingConfiguration.pointerUpPredicate=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerMovePredicate",{get:function(){return this._pointerPickingConfiguration.pointerMovePredicate},set:function(e){this._pointerPickingConfiguration.pointerMovePredicate=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerDownFastCheck",{get:function(){return this._pointerPickingConfiguration.pointerDownFastCheck},set:function(e){this._pointerPickingConfiguration.pointerDownFastCheck=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerUpFastCheck",{get:function(){return this._pointerPickingConfiguration.pointerUpFastCheck},set:function(e){this._pointerPickingConfiguration.pointerUpFastCheck=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerMoveFastCheck",{get:function(){return this._pointerPickingConfiguration.pointerMoveFastCheck},set:function(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skipPointerMovePicking",{get:function(){return this._pointerPickingConfiguration.skipPointerMovePicking},set:function(e){this._pointerPickingConfiguration.skipPointerMovePicking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skipPointerDownPicking",{get:function(){return this._pointerPickingConfiguration.skipPointerDownPicking},set:function(e){this._pointerPickingConfiguration.skipPointerDownPicking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skipPointerUpPicking",{get:function(){return this._pointerPickingConfiguration.skipPointerUpPicking},set:function(e){this._pointerPickingConfiguration.skipPointerUpPicking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unTranslatedPointer",{get:function(){return this._inputManager.unTranslatedPointer},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DragMovementThreshold",{get:function(){return on.DragMovementThreshold},set:function(e){on.DragMovementThreshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LongPressDelay",{get:function(){return on.LongPressDelay},set:function(e){on.LongPressDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DoubleClickDelay",{get:function(){return on.DoubleClickDelay},set:function(e){on.DoubleClickDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ExclusiveDoubleClickMode",{get:function(){return on.ExclusiveDoubleClickMode},set:function(e){on.ExclusiveDoubleClickMode=e},enumerable:!1,configurable:!0}),t.prototype.bindEyePosition=function(e,t,i){void 0===t&&(t="vEyePosition"),void 0===i&&(i=!1);var r=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:this.activeCamera.globalPosition,n=this.useRightHandedSystem===(null!=this._mirroredCameraPosition);return H.Vector4[0].set(r.x,r.y,r.z,n?-1:1),e&&(i?e.setFloat3(t,H.Vector4[0].x,H.Vector4[0].y,H.Vector4[0].z):e.setVector4(t,H.Vector4[0])),H.Vector4[0]},t.prototype.finalizeSceneUbo=function(){var e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null);return e.updateFloat4("vEyePosition",t.x,t.y,t.z,t.w),e.update(),e},Object.defineProperty(t.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(u.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),t.prototype.setStepId=function(e){this._currentStepId=e},t.prototype.getStepId=function(){return this._currentStepId},t.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(u.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fogMode",{get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(u.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"prePass",{get:function(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(u.MATERIAL_LightDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(u.MATERIAL_LightDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeCameras",{get:function(){return this._activeCameras},set:function(e){var t=this;this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=P(e,(function(){t.onActiveCamerasChanged.notifyObservers(t)}))),this._activeCameras=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeCamera",{get:function(){return this._activeCamera},set:function(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=t.DefaultMaterialFactory(this)),this._defaultMaterial},set:function(e){this._defaultMaterial=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(u.MATERIAL_AttributesDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionCoordinator",{get:function(){return this._collisionCoordinator||(this._collisionCoordinator=t.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingManager",{get:function(){return this._renderingManager},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!1,configurable:!0}),t.prototype._registerTransientComponents=function(){if(this._transientComponents.length>0){for(var e=0,t=this._transientComponents;e0&&(s=!1),null===(r=this.prePassRenderer)||void 0===r||r.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&s&&(s=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),n=0;n0,h=0,d=this._isReadyForMeshStage;h0)for(var g=0,v=this.activeCameras;g0},enumerable:!1,configurable:!0}),t.prototype.executeWhenReady=function(e,t){void 0===t&&(t=!1),this.onReadyObservable.addOnce(e),null===this._executeWhenReadyTimeoutId&&this._checkIsReady(t)},t.prototype.whenReadyAsync=function(e){var t=this;return void 0===e&&(e=!1),new Promise((function(i){t.executeWhenReady((function(){i()}),e)}))},t.prototype._checkIsReady=function(e){var t=this;return void 0===e&&(e=!1),this._registerTransientComponents(),this.isReady(e)?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):void(this._executeWhenReadyTimeoutId=setTimeout((function(){t.incrementRenderId(),t._checkIsReady(e)}),100))},Object.defineProperty(t.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!1,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=_t.Now},t.prototype.getViewMatrix=function(){return this._viewMatrix},t.prototype.getProjectionMatrix=function(){return this._projectionMatrix},t.prototype.getTransformMatrix=function(){return this._transformMatrix},t.prototype.setTransformMatrix=function(e,t,i,r){i||r||!this._multiviewSceneUbo||(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?ln.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=ln.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,r):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))},t.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},t.prototype.createSceneUniformBuffer=function(e){var t=new Or(this._engine,void 0,!1,null!=e?e:"scene");return t.addUniform("viewProjection",16),t.addUniform("view",16),t.addUniform("projection",16),t.addUniform("vEyePosition",4),t},t.prototype.setSceneUniformBuffer=function(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1},t.prototype.getUniqueId=function(){return cn.UniqueId},t.prototype.addMesh=function(e,t){var i=this;void 0===t&&(t=!1),this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.addMesh(e)})))},t.prototype.removeMesh=function(e,t){var i=this;void 0===t&&(t=!1);var r=this.meshes.indexOf(e);return-1!==r&&(this.meshes[r]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.removeMesh(e)})),r},t.prototype.addTransformNode=function(e){this._blockEntityCollection||e.getScene()===this&&-1!==e._indexInSceneTransformNodesArray||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))},t.prototype.removeTransformNode=function(e){var t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){var i=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=i,i._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t},t.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t},t.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},t.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var i=0,r=this.meshes;i0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},t.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),t},t.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},t.prototype.stopAnimation=function(e,t,i){},t.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},t.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t},t.prototype.removeMaterial=function(e){var t=e._indexInSceneMaterialArray;if(-1!==t&&t=0;i--)if(this.materials[i].id===e)return this.materials[i];if(t)for(i=this.multiMaterials.length-1;i>=0;i--)if(this.multiMaterials[i].id===e)return this.multiMaterials[i];return null},t.prototype.getTextureByUniqueId=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},t.prototype.getLastTransformNodeById=function(e){for(var t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null},t.prototype.getLastEntryById=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},t.prototype.getNodeById=function(e){var t=this.getMeshById(e);if(t)return t;var i=this.getTransformNodeById(e);if(i)return i;var r=this.getLightById(e);if(r)return r;var n=this.getCameraById(e);return n||(this.getBoneById(e)||null)},t.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getTransformNodeByName(e);if(i)return i;var r=this.getLightByName(e);if(r)return r;var n=this.getCameraByName(e);return n||(this.getBoneByName(e)||null)},t.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.prototype.getSkeletonByUniqueId=function(e){for(var t=0;t0&&(null===(e=this.activeCamera)||void 0===e||e._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset());else if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely)for(var t=this._activeMeshes.length,i=0;i0&&l.layerMask&this.activeCamera.layerMask&&(this._skipFrustumClipping||l.alwaysSelectAsActiveMesh||l.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(l),this.activeCamera._activeMeshes.push(l),c!==l&&c._activate(this._renderId,!1);for(var h=0,d=this._preActiveMeshStage;h0){var r=this.getActiveSubMeshCandidates(t),n=r.length;i=i||1===n;for(var o=0;o0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(var h=0,d=this._gatherActiveCameraRenderTargetsStage;h0){rr.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var f=0;f0),this._renderId++}for(var g=0,v=this._cameraDrawRenderTargetStage;g-1&&(i.trigger===u.ACTION_OnIntersectionExitTrigger&&i._executeCurrent(te.CreateNew(t,void 0,n)),t.actionManager.hasSpecificTrigger(u.ACTION_OnIntersectionExitTrigger,(function(e){var t=e.mesh?e.mesh:e;return n===t}))&&i.trigger!==u.ACTION_OnIntersectionExitTrigger||t._intersectionsInProgress.splice(a,1))}},r=0;t.actionManager&&r0&&n0)for(var s=0;s0),this._intermediateRendering=!0;for(var p=0;p0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=null!==(n=null==d?void 0:d.renderPassId)&&void 0!==n?n:u.RENDERPASS_MAIN,this.activeCamera=d,this._activeCamera&&this._activeCamera.cameraRigMode!==u.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var _=0,m=this._beforeClearStage;_0)for(s=0;s0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}this._checkIntersections();for(var y=0,b=this._afterRenderStage;y-1&&this._engine.scenes.splice(n,1),M._LastCreatedScene===this&&(this._engine.scenes.length>0?M._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:M._LastCreatedScene=null),(n=this._engine._virtualScenes.indexOf(this))>-1&&this._engine._virtualScenes.splice(n,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this._isDisposed=!0}},t.prototype._disposeList=function(e,t){t=null!=t?t:function(e){return e.dispose()};for(var i=0,r=e.slice(0);i-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this},e.prototype.getAnimations=function(){return this._runtimeAnimations},e.prototype.appendAnimations=function(e,t){for(var i=this,r=0;r-1){for(var n=(a=this._runtimeAnimations).length-1;n>=0;n--){var o=a[n];e&&o.animation.name!=e||t&&!t(o.target)||(o.dispose(),a.splice(n,1))}0==a.length&&(i||this._scene._activeAnimatables.splice(r,1),this._raiseOnAnimationEnd())}}else if((n=this._scene._activeAnimatables.indexOf(this))>-1){i||this._scene._activeAnimatables.splice(n,1);for(var a=this._runtimeAnimations,s=0;s0)return;this._animationTimeLast=t}this.deltaTime=void 0!==e?e:this.useConstantAnimationDeltaTime?16:(t-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=t;var i=this._activeAnimatables;if(0!==i.length){this._animationTime+=this.deltaTime;for(var r=this._animationTime,n=0;ni&&n>0&&(n*=-1),s&&this.stopAnimation(e,void 0,l),a||(a=new gn(this,e,t,i,r,n,o,void 0,c,u));var h=!l||l(e);if(e.animations&&h&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),p=0;pr&&o>0)o*=-1;else if(r>i&&o<0){var c=r;r=i,i=c}return new gn(this,e,i,r,n,o,a,t,s,l)},pn.prototype.beginDirectHierarchyAnimation=function(e,t,i,r,n,o,a,s,l,c){void 0===c&&(c=!1);var u=e.getDescendants(t),h=[];h.push(this.beginDirectAnimation(e,i,r,n,o,a,s,l,c));for(var d=0,p=u;d0?l:-l,n),h.scaleAndAddToRef(l,i)}n.normalize()}for(u=0;u0)n.copyFrom(r);else if(1===e.animations.length){if(G.SlerpToRef(r,i.currentValue,Math.min(1,e.totalWeight),n),0===e.totalAdditiveWeight)return n}else if(e.animations.length>1){var o=1,a=void 0,s=void 0;if(e.totalWeight<1){var l=1-e.totalWeight;s=[],(a=[]).push(r),s.push(l)}else{if(2===e.animations.length&&(G.SlerpToRef(e.animations[0].currentValue,e.animations[1].currentValue,e.animations[1].weight/e.totalWeight,t),0===e.totalAdditiveWeight))return t;a=[],s=[],o=e.totalWeight}for(var c=0;c=c&&a.frame<=u&&(r?(l=a.value.clone(),_?(s=l.getTranslation(),l.setTranslation(s.scaleInPlace(m))):g&&n?(s=l.getTranslation(),l.setTranslation(s.multiplyInPlace(n))):l=a.value):l=a.value,v.push({frame:a.frame+i,value:l}));return this.animations[0].createRange(t,c+i,u+i),!0};var vn,yn=function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=at.ANIMATIONLOOPMODE_CYCLE};!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(vn||(vn={}));var bn,Tn=function(){function e(){}return e.Interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,a=3*r-6*t,s=3*t,l=e,c=0;c<5;c++){var u=l*l;l-=1/(3*o*u+2*a*l+s)*(o*(u*l)+a*u+s*l-e),l=Math.min(1,Math.max(0,l))}return 3*Math.pow(1-l,2)*l*i+3*(1-l)*Math.pow(l,2)*n+Math.pow(l,3)},e}(),En=function(){function e(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.prototype.degrees=function(){return 180*this._radians/Math.PI},e.prototype.radians=function(){return this._radians},e.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new e(Math.atan2(r.y,r.x))},e.BetweenTwoVectors=function(t,i){var r=t.lengthSquared()*i.lengthSquared();if(0===r)return new e(Math.PI/2);r=Math.sqrt(r);var n=t.dot(i)/r;return n=j.Clamp(n,-1,1),new e(Math.acos(n))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}(),Sn=function(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),n=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,o=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,a=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new U((n*(t.y-i.y)-o*(e.y-t.y))/a,((e.x-t.x)*o-(t.x-i.x)*n)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=En.BetweenTwoPoints(this.centerPoint,this.startPoint);var s=this.startAngle.degrees(),l=En.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),c=En.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();l-s>180&&(l-=360),l-s<-180&&(l+=360),c-l>180&&(c-=360),c-l<-180&&(c+=360),this.orientation=l-s<0?vn.CW:vn.CCW,this.angle=En.FromDegrees(this.orientation===vn.CW?s-c:c-s)},xn=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new U(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new U(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this},e.prototype.addArcTo=function(e,t,i,r,n){if(void 0===n&&(n=36),this.closed)return this;var o=this._points[this._points.length-1],a=new U(e,t),s=new U(i,r),l=new Sn(o,a,s),c=l.angle.radians()/n;l.orientation===vn.CW&&(c*=-1);for(var u=l.startAngle.radians()+c,h=0;hNumber.EPSILON){if(l<0&&(o=this._points[n],s=-s,a=this._points[r],l=-l),e.ya.y)continue;if(e.y===o.y&&e.x===o.x)return!0;var c=l*(e.x-o.x)-s*(e.y-o.y);if(0===c)return!0;if(c<0)continue;t=!t}else{if(e.y!==o.y)continue;if(a.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=a.x)return!0}}return t},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},e.prototype.area=function(){for(var e=this._points.length,t=0,i=e-1,r=0;r1)return U.Zero();for(var t=e*this.length(),i=0,r=0;r=i&&t<=s){var l=a.normalize(),c=t-i;return new U(o.x+l.x*c,o.y+l.y*c)}i=s}return U.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}(),An=function(){function e(e,t,i,r){void 0===t&&(t=null),void 0===r&&(r=!1),this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array,this._pointAtData={id:0,point:V.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:z.Identity()};for(var n=0;ni){var r=t;t=i,i=r}var n=this.getCurve(),o=this.getPointAt(t),a=this.getPreviousPointIndexAt(t),s=this.getPointAt(i),l=this.getPreviousPointIndexAt(i)+1,c=[];return 0!==t&&(a++,c.push(o)),c.push.apply(c,n.slice(a,l)),1===i&&1!==t||c.push(s),new e(c,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1);for(var r=0;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},e.prototype._normalVector=function(e,t){var i,r=e.length();if(0===r&&(r=1),null==t){var n;n=j.WithinEpsilon(Math.abs(e.y)/r,1,A)?j.WithinEpsilon(Math.abs(e.x)/r,1,A)?j.WithinEpsilon(Math.abs(e.z)/r,1,A)?V.Zero():new V(0,0,1):new V(1,0,0):new V(0,-1,0),i=V.Cross(e,n)}else i=V.Cross(e,t),V.CrossToRef(i,e,i);return i.normalize(),i},e.prototype._updatePointAtData=function(e,t){if(void 0===t&&(t=!1),this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;var i=this.getPoints();if(e<=0)return this._setPointAtData(0,0,i[0],0,t);if(e>=1)return this._setPointAtData(1,1,i[i.length-1],i.length-1,t);for(var r,n=i[0],o=0,a=e*this.length(),s=1;sa){var c=(o-a)/l,u=n.subtract(r),h=r.add(u.scaleInPlace(c));return this._setPointAtData(e,1-c,h,s-1,t)}n=r}return this._pointAtData},e.prototype._setPointAtData=function(e,t,i,r,n){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=r,this._pointAtData.interpolateReady=n,n&&this._updateInterpolationMatrix(),this._pointAtData},e.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=z.Identity();var e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){var t=e+1,i=this._tangents[e].clone(),r=this._normals[e].clone(),n=this._binormals[e].clone(),o=this._tangents[t].clone(),a=this._normals[t].clone(),s=this._binormals[t].clone(),l=G.RotationQuaternionFromAxis(r,n,i),c=G.RotationQuaternionFromAxis(a,s,o);G.Slerp(l,c,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),Cn=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,r,n){n=n>2?n:3;for(var o=[],a=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},s=0;s<=n;s++)o.push(new V(a(s/n,t.x,i.x,r.x),a(s/n,t.y,i.y,r.y),a(s/n,t.z,i.z,r.z)));return new e(o)},e.CreateCubicBezier=function(t,i,r,n,o){o=o>3?o:4;for(var a=[],s=function(e,t,i,r,n){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*r+e*e*e*n},l=0;l<=o;l++)a.push(new V(s(l/o,t.x,i.x,r.x,n.x),s(l/o,t.y,i.y,r.y,n.y),s(l/o,t.z,i.z,r.z,n.z)));return new e(a)},e.CreateHermiteSpline=function(t,i,r,n,o){for(var a=[],s=1/o,l=0;l<=o;l++)a.push(V.Hermite(t,i,r,n,l*s));return new e(a)},e.CreateCatmullRomSpline=function(t,i,r){var n=[],o=1/i,a=0;if(r){for(var s=t.length,l=0;l=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e.EASINGMODE_EASEIN=0,e.EASINGMODE_EASEOUT=1,e.EASINGMODE_EASEINOUT=2,e}(),Pn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(Rn),In=function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return m(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t}(Rn),Mn=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return m(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,a=e*o,s=Math.log(-a*(1-i)+1)/Math.log(i),l=Math.floor(s),c=l+1,u=(1-Math.pow(i,l))/(n*o),h=.5*(u+(1-Math.pow(i,c))/(n*o)),d=e-h,p=h-u;return-Math.pow(1/i,t-l)/(p*p)*(d-p)*(d+p)},t}(Rn),On=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(Rn),Dn=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return m(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t}(Rn),Nn=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return m(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(Rn),Fn=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return m(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(Rn),Ln=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.easeInCore=function(e){return e*e},t}(Rn),wn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(Rn),Bn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(Rn),Un=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(Rn),Vn=function(e){function t(t,i,r,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=e.call(this)||this;return o.x1=t,o.y1=i,o.x2=r,o.y2=n,o}return m(t,e),t.prototype.easeInCore=function(e){return Tn.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(Rn),kn=function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)},e}(),Gn=function(){function e(){}return e.prototype.getClassName=function(){return"TargetedAnimation"},e.prototype.serialize=function(){var e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e},e}(),zn=function(){function e(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=-1),void 0===r&&(r=0),this.name=e,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this._loopAnimation=!1,this._isAdditive=!1,this._weight=-1,this._playOrder=0,this._enableBlending=null,this._blendingSpeed=null,this._numActiveAnimatables=0,this._parentContainer=null,this.onAnimationEndObservable=new f,this.onAnimationLoopObservable=new f,this.onAnimationGroupLoopObservable=new f,this.onAnimationGroupEndObservable=new f,this.onAnimationGroupPauseObservable=new f,this.onAnimationGroupPlayObservable=new f,this.metadata=null,this._mask=null,this._animationLoopFlags=[],this._scene=t||M.LastCreatedScene,this._weight=i,this._playOrder=r,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}return Object.defineProperty(e.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask!==e&&(this._mask=e,this.syncWithMask(!0))},enumerable:!1,configurable:!0}),e.prototype.syncWithMask=function(e){if(void 0===e&&(e=!1),this.mask||e){this._numActiveAnimatables=0;for(var t=0;t0)){for(var t=0;ta&&(a=d.to);for(var c=new e(t[0].name+"_merged",t[0]._scene,n),u=0,h=t;ur[0].frame&&(this._from=r[0].frame),this._to-1;t--)this._targetedAnimations[t].animation===e&&this._targetedAnimations.splice(t,1)},e.prototype.normalize=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),null==e&&(e=this._from),null==t&&(t=this._to);for(var i=0;ie){var a={frame:e,value:n.value,inTangent:n.inTangent,outTangent:n.outTangent,interpolation:n.interpolation};r.splice(0,0,a)}o.frame0&&(this._scene._activeAnimatables[i++]=r)}return this._scene._activeAnimatables.length=i,this._isStarted=!1,this},e.prototype.setWeightForAllAnimatables=function(e){for(var t=0;t-1&&this._scene.animationGroups.splice(e,1),this._parentContainer){var t=this._parentContainer.animationGroups.indexOf(this);t>-1&&this._parentContainer.animationGroups.splice(t,1),this._parentContainer=null}this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()},e.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);t>-1&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},e.prototype.clone=function(t,i,r){void 0===r&&(r=!1);var n=new e(t||this.name,this._scene,this._weight,this._playOrder);n._from=this.from,n._to=this.to,n._speedRatio=this.speedRatio,n._loopAnimation=this.loopAnimation,n._isAdditive=this.isAdditive,n._enableBlending=this.enableBlending,n._blendingSpeed=this.blendingSpeed,n.metadata=this.metadata,n.mask=this.mask;for(var o=0,a=this._targetedAnimations;op[0].frame&&(c=p[0].frame),u=t&&f<=i||n&&_.frame>=t&&_.frame<=i){var m={frame:_.frame,value:_.value.clone?_.value.clone():_.value,inTangent:_.inTangent,outTangent:_.outTangent,interpolation:_.interpolation,lockedTangent:_.lockedTangent};p===Number.MAX_VALUE&&(p=m.frame),m.frame-=p,d.push(m)}}0!==d.length?(o>d[0].frame&&(o=d[0].frame),a1)throw"step size should be less than 1.";return this.value+=e,this._ensureLimits(),this._raiseOnChange(),this},e.prototype._ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},e.prototype._raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},e.prototype.onchange=function(e){return this._onchange.push(e),this},e}();!function(e){e[e.Include=0]="Include",e[e.Exclude=1]="Exclude"}(bn||(bn={}));var Hn=function(){function e(e,t){void 0===t&&(t=bn.Include),this.mode=t,this.disabled=!1,this._targetNames=new Set,e&&this.addTargetName(e)}return e.prototype.addTargetName=function(e){if(Array.isArray(e))for(var t=0,i=e;te?(t=o,setTimeout((function(){Xn(i,r,n)}),0)):Xn(i,r,n)}}function Yn(e,t,i,r,n){var o=function(){var a,s=function(e){e.done?i(e.value):void 0===a?a=!0:o()};do{a=void 0,n&&n.aborted?r(new Error("Aborted")):t(e,s,r),void 0===a&&(a=!1)}while(a)};o()}function Kn(e,t){var i;return Yn(e,Xn,(function(e){return i=e}),(function(e){throw e}),t),i}function Qn(e,t,i){return new Promise((function(r,n){Yn(e,t,r,n,i)}))}function qn(e,t){return function(){for(var i=[],r=0;r-1?(ae.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},t.prototype._getViewMatrix=function(){return z.Identity()},t.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()||(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix)),this._computedViewMatrix},t.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},t.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},t.prototype.getProjectionMatrix=function(e){var i,r,n,o,a,s,l,c,u,h,d,p,f,_,m,g,v,y,b;if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var T=this.getEngine(),E=this.getScene(),S=T.useReverseDepthBuffer;if(this.mode===t.PERSPECTIVE_CAMERA)this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=T.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1),(E.useRightHandedSystem?z.PerspectiveFovRHToRef:z.PerspectiveFovLHToRef)(this.fov,T.getAspectRatio(this),S?this.maxZ:this.minZ,S?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED,T.isNDCHalfZRange,this.projectionPlaneTilt,S);else{var x=T.getRenderWidth()/2,A=T.getRenderHeight()/2;E.useRightHandedSystem?this.oblique?z.ObliqueOffCenterRHToRef(null!==(i=this.orthoLeft)&&void 0!==i?i:-x,null!==(r=this.orthoRight)&&void 0!==r?r:x,null!==(n=this.orthoBottom)&&void 0!==n?n:-A,null!==(o=this.orthoTop)&&void 0!==o?o:A,S?this.maxZ:this.minZ,S?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,T.isNDCHalfZRange):z.OrthoOffCenterRHToRef(null!==(a=this.orthoLeft)&&void 0!==a?a:-x,null!==(s=this.orthoRight)&&void 0!==s?s:x,null!==(l=this.orthoBottom)&&void 0!==l?l:-A,null!==(c=this.orthoTop)&&void 0!==c?c:A,S?this.maxZ:this.minZ,S?this.minZ:this.maxZ,this._projectionMatrix,T.isNDCHalfZRange):this.oblique?z.ObliqueOffCenterLHToRef(null!==(u=this.orthoLeft)&&void 0!==u?u:-x,null!==(h=this.orthoRight)&&void 0!==h?h:x,null!==(d=this.orthoBottom)&&void 0!==d?d:-A,null!==(p=this.orthoTop)&&void 0!==p?p:A,S?this.maxZ:this.minZ,S?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,T.isNDCHalfZRange):z.OrthoOffCenterLHToRef(null!==(f=this.orthoLeft)&&void 0!==f?f:-x,null!==(_=this.orthoRight)&&void 0!==_?_:x,null!==(m=this.orthoBottom)&&void 0!==m?m:-A,null!==(g=this.orthoTop)&&void 0!==g?g:A,S?this.maxZ:this.minZ,S?this.minZ:this.maxZ,this._projectionMatrix,T.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=null===(v=this.oblique)||void 0===v?void 0:v.angle,this._cache.obliqueLength=null===(y=this.oblique)||void 0===y?void 0:y.length,this._cache.obliqueOffset=null===(b=this.oblique)||void 0===b?void 0:b.offset,this._cache.renderWidth=T.getRenderWidth(),this._cache.renderHeight=T.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},t.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},t.prototype._computeObliqueDistance=function(e){return(this.radius||(this.target?V.Distance(this.position,this.target):this.position.length()))+e},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?ln.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=ln.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e,t){if(void 0===t&&(t=!1),this._updateFrustumPlanes(),t&&this.rigCameras.length>0){var i=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),i=i||e.isInFrustum(t._frustumPlanes)})),i}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,i){throw void 0===e&&(e=100),He("Ray")},t.prototype.getForwardRayToRef=function(e,t,i,r){throw void 0===t&&(t=100),He("Ray")},t.prototype.dispose=function(i,r){for(void 0===r&&(r=!1),this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){var n=this._rigCameras.pop();n&&n.dispose()}if(this._parentContainer){var o=this._parentContainer.cameras.indexOf(this);o>-1&&this._parentContainer.cameras.splice(o,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==t.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else for(var a=this._postProcesses.length;--a>=0;){var s=this._postProcesses[a];s&&s.dispose(this)}for(var l=this.customRenderTargets.length;--l>=0;)this.customRenderTargets[l].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),e.prototype.dispose.call(this,i,r)},Object.defineProperty(t.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!1,configurable:!0}),t.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},t.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},t.prototype.setCameraRigMode=function(e,i){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var r=this._rigCameras.pop();r&&r.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=i.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=rr.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var n=this.createRigCamera(this.name+"_L",0);n&&(n._isLeftCamera=!0);var o=this.createRigCamera(this.name+"_R",1);o&&(o._isRightCamera=!0),n&&o&&(this._rigCameras.push(n),this._rigCameras.push(o))}this._setRigMode(i),this._cascadePostProcessesToRigCams(),this.update()}},t.prototype._setRigMode=function(e){},t.prototype._getVRProjectionMatrix=function(){return z.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=rr.ToRadians(t/.0637))},t.prototype.createRigCamera=function(e,t){return null},t.prototype._updateRigCameras=function(){for(var e=0;ec-r||s-uu-n||l-hh-o)},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var i=this.minimumWorld,r=this.maximumWorld,n=i.x,o=i.y,a=i.z,s=r.x,l=r.y,c=r.z,u=e.x,h=e.y,d=e.z,p=t.x,f=t.y,_=t.z;return!(sp||lf||c_)},e.prototype.dispose=function(){var e,t;null===(e=this._drawWrapperFront)||void 0===e||e.dispose(),null===(t=this._drawWrapperBack)||void 0===t||t.dispose()},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,i,r,n){var o=e._TmpVector3[0];return V.ClampToRef(r,t,i,o),V.DistanceSquared(r,o)<=n*n},e.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;++i)for(var r=t[i],n=0;n<8;++n)if(r.dotCoordinate(e[n])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var i=0;i<6;++i){for(var r=!0,n=t[i],o=0;o<8;++o)if(n.dotCoordinate(e[o])>=0){r=!1;break}if(r)return!1}return!0},e._TmpVector3=C.BuildArray(3,V.Zero),e}(),io=function(){function e(e,t,i){this.center=V.Zero(),this.centerWorld=V.Zero(),this.minimum=V.Zero(),this.maximum=V.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var r=V.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*r,this._update(i||z.IdentityReadOnly)},e.prototype.scale=function(t){var i=this.radius*t,r=e._TmpVector3,n=r[0].setAll(i),o=this.center.subtractToRef(n,r[1]),a=this.center.addToRef(n,r[2]);return this.reConstruct(o,a,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(t){if(t.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{V.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e._TmpVector3[0];V.TransformNormalFromFloatsToRef(1,1,1,t,i),this.radiusWorld=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,i=this.radiusWorld,r=0;r<6;r++)if(e[r].dotCoordinate(t)<=-i)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=V.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorldno.max||no.min>ro.max)},so=function(){function e(e,t,i){this._isLocked=!1,this.boundingBox=new to(e,t,i),this.boundingSphere=new io(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)},Object.defineProperty(e.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!1,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,i){var r=e._TmpVector3[0].copyFrom(t).subtractInPlace(i),n=e._TmpVector3[1].copyFrom(t).addInPlace(i);return this.boundingBox.reConstruct(r,n,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(r,n,this.boundingBox.getWorldMatrix()),this},e.prototype.encapsulate=function(e){var t=V.Minimize(this.minimum,e),i=V.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this},e.prototype.encapsulateBoundingInfo=function(e){var t=H.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);var i=H.Vector3[0];return V.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i),this.encapsulate(i),V.TransformCoordinatesToRef(e.boundingBox.maximumWorld,t,i),this.encapsulate(i),this},e.prototype.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},e.prototype.isInFrustum=function(e,t){return void 0===t&&(t=u.MESHES_CULLINGSTRATEGY_STANDARD),!(t!==u.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&t!==u.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(t!==u.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&t!==u.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,"diagonalLength",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,e._TmpVector3[0]).length()},enumerable:!1,configurable:!0}),e.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},e.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},e.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e)},e.prototype.intersects=function(e,t){if(!io.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!to.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,r=e.boundingBox;return!!(ao(i.directions[0],i,r)&&ao(i.directions[1],i,r)&&ao(i.directions[2],i,r)&&ao(r.directions[0],i,r)&&ao(r.directions[1],i,r)&&ao(r.directions[2],i,r)&&ao(V.Cross(i.directions[0],r.directions[0]),i,r)&&ao(V.Cross(i.directions[0],r.directions[1]),i,r)&&ao(V.Cross(i.directions[0],r.directions[2]),i,r)&&ao(V.Cross(i.directions[1],r.directions[0]),i,r)&&ao(V.Cross(i.directions[1],r.directions[1]),i,r)&&ao(V.Cross(i.directions[1],r.directions[2]),i,r)&&ao(V.Cross(i.directions[2],r.directions[0]),i,r)&&ao(V.Cross(i.directions[2],r.directions[1]),i,r)&&ao(V.Cross(i.directions[2],r.directions[2]),i,r))},e._TmpVector3=C.BuildArray(2,V.Zero),e}(),lo=function(){function e(){}return e.extractMinAndMaxIndexed=function(e,t,i,r,n,o){for(var a=i;al&&(l=h)}return new e(t,s,l-s+1,i,r,n,o,a)},e}(),fo=function(){},_o=function(){function e(){this.uniqueId=0,this.metadata={},this._applyTo=qn(this._applyToCoroutine.bind(this)),this.uniqueId=e._UniqueIDGenerator,e._UniqueIDGenerator++}return e.prototype.set=function(e,t){switch(e.length||ae.Warn("Setting vertex data kind '".concat(t,"' with an empty array")),t){case Nr.PositionKind:this.positions=e;break;case Nr.NormalKind:this.normals=e;break;case Nr.TangentKind:this.tangents=e;break;case Nr.UVKind:this.uvs=e;break;case Nr.UV2Kind:this.uvs2=e;break;case Nr.UV3Kind:this.uvs3=e;break;case Nr.UV4Kind:this.uvs4=e;break;case Nr.UV5Kind:this.uvs5=e;break;case Nr.UV6Kind:this.uvs6=e;break;case Nr.ColorKind:this.colors=e;break;case Nr.MatricesIndicesKind:this.matricesIndices=e;break;case Nr.MatricesWeightsKind:this.matricesWeights=e;break;case Nr.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case Nr.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}},e.prototype.applyToMesh=function(e,t){return this._applyTo(e,t,!1),this},e.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t,!1),this},e.prototype.updateMesh=function(e){return this._update(e),this},e.prototype.updateGeometry=function(e){return this._update(e),this},e.prototype._applyToCoroutine=function(e,t,i){var r,n,o,a;return void 0===t&&(t=!1),b(this,(function(s){switch(s.label){case 0:return this.positions?(e.setVerticesData(Nr.PositionKind,this.positions,t),i?[4]:[3,2]):[3,2];case 1:s.sent(),s.label=2;case 2:return this.normals?(e.setVerticesData(Nr.NormalKind,this.normals,t),i?[4]:[3,4]):[3,4];case 3:s.sent(),s.label=4;case 4:return this.tangents?(e.setVerticesData(Nr.TangentKind,this.tangents,t),i?[4]:[3,6]):[3,6];case 5:s.sent(),s.label=6;case 6:return this.uvs?(e.setVerticesData(Nr.UVKind,this.uvs,t),i?[4]:[3,8]):[3,8];case 7:s.sent(),s.label=8;case 8:return this.uvs2?(e.setVerticesData(Nr.UV2Kind,this.uvs2,t),i?[4]:[3,10]):[3,10];case 9:s.sent(),s.label=10;case 10:return this.uvs3?(e.setVerticesData(Nr.UV3Kind,this.uvs3,t),i?[4]:[3,12]):[3,12];case 11:s.sent(),s.label=12;case 12:return this.uvs4?(e.setVerticesData(Nr.UV4Kind,this.uvs4,t),i?[4]:[3,14]):[3,14];case 13:s.sent(),s.label=14;case 14:return this.uvs5?(e.setVerticesData(Nr.UV5Kind,this.uvs5,t),i?[4]:[3,16]):[3,16];case 15:s.sent(),s.label=16;case 16:return this.uvs6?(e.setVerticesData(Nr.UV6Kind,this.uvs6,t),i?[4]:[3,18]):[3,18];case 17:s.sent(),s.label=18;case 18:return this.colors?(e.setVerticesData(Nr.ColorKind,this.colors,t),this.hasVertexAlpha&&void 0!==e.hasVertexAlpha&&(e.hasVertexAlpha=!0),i?[4]:[3,20]):[3,20];case 19:s.sent(),s.label=20;case 20:return this.matricesIndices?(e.setVerticesData(Nr.MatricesIndicesKind,this.matricesIndices,t),i?[4]:[3,22]):[3,22];case 21:s.sent(),s.label=22;case 22:return this.matricesWeights?(e.setVerticesData(Nr.MatricesWeightsKind,this.matricesWeights,t),i?[4]:[3,24]):[3,24];case 23:s.sent(),s.label=24;case 24:return this.matricesIndicesExtra?(e.setVerticesData(Nr.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i?[4]:[3,26]):[3,26];case 25:s.sent(),s.label=26;case 26:return this.matricesWeightsExtra?(e.setVerticesData(Nr.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),i?[4]:[3,28]):[3,28];case 27:s.sent(),s.label=28;case 28:return this.indices?(e.setIndices(this.indices,null,t),i?[4]:[3,30]):[3,31];case 29:s.sent(),s.label=30;case 30:return[3,32];case 31:e.setIndices([],null),s.label=32;case 32:if(e.subMeshes&&this.materialInfos&&this.materialInfos.length>1)for((r=e).subMeshes=[],n=0,o=this.materialInfos;nr?1:i===r?0:-1})),I=0,M=y;I0))return[3,4];U=null!==(q=null==B?void 0:B.length)&&void 0!==q?q:0,B||(B=new Array(L)),B.length!==L&&(Array.isArray(B)?B.length=L:((V=r||B instanceof Uint32Array?new Uint32Array(L):new Uint16Array(L)).set(B),B=V),t&&t.determinant()<0&&e._FlipFaces(B,0,U)),k=c.positions?c.positions.length/3:0,G=0,z=i,b.label=1;case 1:if(!(G65535);for(var r=0,n=this._meshes;r0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype._notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(var t=0,i=this._meshes;t0){for(var t=0;t0){for(t=0;t0){for(t=0;t-1&&this._parentContainer.geometries.splice(n,1),this._parentContainer=null}this._isDisposed=!0},e.prototype.copy=function(t){var i=new _o;i.indices=[];var r=this.getIndices();if(r)for(var n=0;n0){var l=new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);i.setVerticesData(Nr.PositionKind,l,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var c=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);i.setVerticesData(Nr.NormalKind,c,!1)}if(s.tangetsAttrDesc&&s.tangetsAttrDesc.count>0){var u=new Float32Array(t,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);i.setVerticesData(Nr.TangentKind,u,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var h=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);if(go.UseOpenGLOrientationForUV)for(var d=1;d0){var p=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);if(go.UseOpenGLOrientationForUV)for(d=1;d0){var f=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);if(go.UseOpenGLOrientationForUV)for(d=1;d0){var _=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);if(go.UseOpenGLOrientationForUV)for(d=1;d<_.length;d+=2)_[d]=1-_[d];i.setVerticesData(Nr.UV4Kind,_,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var m=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);if(go.UseOpenGLOrientationForUV)for(d=1;d0){var g=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);if(go.UseOpenGLOrientationForUV)for(d=1;d0){var v=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(Nr.ColorKind,v,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){for(var y=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count),b=[],T=0;T>8),b.push((16711680&d)>>16),b.push(d>>24&255);i.setVerticesData(Nr.MatricesIndicesKind,b,!1)}if(s.matricesIndicesExtraAttrDesc&&s.matricesIndicesExtraAttrDesc.count>0){for(y=new Int32Array(t,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count),b=[],T=0;T>8),b.push((16711680&d)>>16),b.push(d>>24&255);i.setVerticesData(Nr.MatricesIndicesExtraKind,b,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var E=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(Nr.MatricesWeightsKind,E,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){var S=new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);i.setIndices(S,null)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){var x=new Int32Array(t,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);for(i.subMeshes=[],T=0;T>8),b.push((16711680&M)>>16),b.push(M>>24&255)}i.setVerticesData(Nr.MatricesIndicesKind,b,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(Nr.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(b=[],T=0;T>8),b.push((16711680&M)>>16),b.push(M>>24&255);i.setVerticesData(Nr.MatricesIndicesExtraKind,b,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,i),i.setVerticesData(Nr.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&i.setVerticesData(Nr.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),i.setIndices(t.indices,null)}if(t.subMeshes){i.subMeshes=[];for(var O=0;O-1){var n=t.getScene().getLastSkeletonById(e.skeletonId);if(n){r=n.bones.length;for(var o=t.getVerticesData(Nr.MatricesIndicesKind),a=t.getVerticesData(Nr.MatricesIndicesExtraKind),s=e.matricesWeights,l=e.matricesWeightsExtra,c=e.numBoneInfluencer,u=s.length,h=0;hc-1)&&(p=c-1),d>i){var m=1/d;for(f=0;f<4;f++)s[h+f]*=m;if(l)for(f=0;f<4;f++)l[h+f]*=m}else p>=4?(l[h+p-4]=1-d,a[h+p-4]=r):(s[h+p]=1-d,o[h+p]=r)}t.setVerticesData(Nr.MatricesIndicesKind,o),e.matricesWeightsExtra&&t.setVerticesData(Nr.MatricesIndicesExtraKind,a)}}}},e.Parse=function(t,i,r){var n=new e(t.id,i,void 0,t.updatable);return n._loadedUniqueId=t.uniqueId,je&&je.AddTagsTo(n,t.tags),t.delayLoadingFile?(n.delayLoadState=u.DELAYLOADSTATE_NOTLOADED,n.delayLoadingFile=r+t.delayLoadingFile,n._boundingInfo=new so(V.FromArray(t.boundingBoxMinimum),V.FromArray(t.boundingBoxMaximum)),n._delayInfo=[],t.hasUVs&&n._delayInfo.push(Nr.UVKind),t.hasUVs2&&n._delayInfo.push(Nr.UV2Kind),t.hasUVs3&&n._delayInfo.push(Nr.UV3Kind),t.hasUVs4&&n._delayInfo.push(Nr.UV4Kind),t.hasUVs5&&n._delayInfo.push(Nr.UV5Kind),t.hasUVs6&&n._delayInfo.push(Nr.UV6Kind),t.hasColors&&n._delayInfo.push(Nr.ColorKind),t.hasMatricesIndices&&n._delayInfo.push(Nr.MatricesIndicesKind),t.hasMatricesWeights&&n._delayInfo.push(Nr.MatricesWeightsKind),n._delayLoadingFunction=_o.ImportVertexData):_o.ImportVertexData(t,n),i.pushGeometry(n,!0),n},e}(),yo=function(){function e(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new bo(e)}return e.prototype.sampleFrame=function(e){if(void 0===e&&(e=_t.Now),this._enabled){if(null!=this._lastFrameTimeMs){var t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}},Object.defineProperty(e.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFPS",{get:function(){var e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!1,configurable:!0}),e.prototype.enable=function(){this._enabled=!0},e.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()},e}(),bo=function(){function e(e){this._samples=new Array(e),this.reset()}return e.prototype.add=function(e){var t;if(this.isSaturated()){var i=this._samples[this._pos];t=i-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(i-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length},e.prototype.history=function(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e}();function To(e,t,i,r){switch(void 0===i&&(i=!1),e){case u.TEXTURETYPE_BYTE:var n=(ArrayBuffer,new Int8Array(t));return r&&n.set(new Int8Array(r)),n;case u.TEXTURETYPE_UNSIGNED_BYTE:var o=(ArrayBuffer,new Uint8Array(t));return r&&o.set(new Uint8Array(r)),o;case u.TEXTURETYPE_SHORT:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(i?t/2:t);return r&&a.set(new Int16Array(r)),a;case u.TEXTURETYPE_UNSIGNED_SHORT:case u.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:case u.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:case u.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:case u.TEXTURETYPE_HALF_FLOAT:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(i?t/2:t);return r&&s.set(new Uint16Array(r)),s;case u.TEXTURETYPE_INT:var l=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(i?t/4:t);return r&&l.set(new Int32Array(r)),l;case u.TEXTURETYPE_UNSIGNED_INTEGER:case u.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:case u.TEXTURETYPE_UNSIGNED_INT_24_8:case u.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:case u.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:case u.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:var c=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(i?t/4:t);return r&&c.set(new Uint32Array(r)),c;case u.TEXTURETYPE_FLOAT:var h=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(i?t/4:t);return r&&h.set(new Float32Array(r)),h}var d=(ArrayBuffer,new Uint8Array(t));return r&&d.set(new Uint8Array(r)),d}function Eo(e,t,i){e._onCanvasFocus=function(){e.onCanvasFocusObservable.notifyObservers(e)},e._onCanvasBlur=function(){e.onCanvasBlurObservable.notifyObservers(e)},e._onCanvasContextMenu=function(t){e.disableContextMenu&&t.preventDefault()},t.addEventListener("focus",e._onCanvasFocus),t.addEventListener("blur",e._onCanvasBlur),t.addEventListener("contextmenu",e._onCanvasContextMenu),e._onBlur=function(){e.disablePerformanceMonitorInBackground&&e.performanceMonitor.disable(),e._windowIsBackground=!0},e._onFocus=function(){e.disablePerformanceMonitorInBackground&&e.performanceMonitor.enable(),e._windowIsBackground=!1},e._onCanvasPointerOut=function(i){document.elementFromPoint(i.clientX,i.clientY)!==t&&e.onCanvasPointerOutObservable.notifyObservers(i)};var r=e.getHostWindow();r&&"function"==typeof r.addEventListener&&(r.addEventListener("blur",e._onBlur),r.addEventListener("focus",e._onFocus)),t.addEventListener("pointerout",e._onCanvasPointerOut),i.doNotHandleTouchAction||function(e){e&&e.setAttribute&&(e.setAttribute("touch-action","none"),e.style.touchAction="none",e.style.webkitTapHighlightColor="transparent")}(t),!Mi.audioEngine&&i.audioEngine&&Mi.AudioEngineFactory&&(Mi.audioEngine=Mi.AudioEngineFactory(e.getRenderingCanvas(),e.getAudioContext(),e.getAudioDestination())),ht()&&(e._onFullscreenChange=function(){e.isFullscreen=!!document.fullscreenElement,e.isFullscreen&&e._pointerLockRequested&&t&&Io(t)},document.addEventListener("fullscreenchange",e._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",e._onFullscreenChange,!1),e._onPointerLockChange=function(){e.isPointerLock=document.pointerLockElement===t},document.addEventListener("pointerlockchange",e._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",e._onPointerLockChange,!1)),e.enableOfflineSupport=void 0!==Mi.OfflineProviderFactory,e._deterministicLockstep=!!i.deterministicLockstep,e._lockstepMaxSteps=i.lockstepMaxSteps||0,e._timeStep=i.timeStep||1/60}function So(e,t){1===M.Instances.length&&Mi.audioEngine&&(Mi.audioEngine.dispose(),Mi.audioEngine=null);var i=e.getHostWindow();i&&"function"==typeof i.removeEventListener&&(i.removeEventListener("blur",e._onBlur),i.removeEventListener("focus",e._onFocus)),t&&(t.removeEventListener("focus",e._onCanvasFocus),t.removeEventListener("blur",e._onCanvasBlur),t.removeEventListener("pointerout",e._onCanvasPointerOut),t.removeEventListener("contextmenu",e._onCanvasContextMenu)),ht()&&(document.removeEventListener("fullscreenchange",e._onFullscreenChange),document.removeEventListener("mozfullscreenchange",e._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",e._onFullscreenChange),document.removeEventListener("msfullscreenchange",e._onFullscreenChange),document.removeEventListener("pointerlockchange",e._onPointerLockChange),document.removeEventListener("mspointerlockchange",e._onPointerLockChange),document.removeEventListener("mozpointerlockchange",e._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",e._onPointerLockChange))}function xo(e){var t=document.createElement("span");t.innerHTML="Hg",t.setAttribute("style","font: ".concat(e," !important"));var i=document.createElement("div");i.style.display="inline-block",i.style.width="1px",i.style.height="0px",i.style.verticalAlign="bottom";var r=document.createElement("div");r.style.whiteSpace="nowrap",r.appendChild(t),r.appendChild(i),document.body.appendChild(r);var n=0,o=0;try{o=i.getBoundingClientRect().top-t.getBoundingClientRect().top,i.style.verticalAlign="baseline",n=i.getBoundingClientRect().top-t.getBoundingClientRect().top}finally{document.body.removeChild(r)}return{ascent:n,height:o,descent:o-n}}function Ao(e,t,i){return new Promise((function(r,n){var o=new Image;o.onload=function(){o.decode().then((function(){e.createImageBitmap(o,i).then((function(e){r(e)}))}))},o.onerror=function(){n("Error loading image ".concat(o.src))},o.src=t}))}function Co(e,t,i,r){var n=e.createCanvas(i,r).getContext("2d");if(!n)throw new Error("Unable to get 2d context for resizeImageBitmap");return n.drawImage(t,0,0),n.getImageData(0,0,i,r).data}function Ro(e){var t=e.requestFullscreen||e.webkitRequestFullscreen;t&&t.call(e)}function Po(){var e=document;document.exitFullscreen?document.exitFullscreen():e.webkitCancelFullScreen&&e.webkitCancelFullScreen()}function Io(e){if(e.requestPointerLock){var t=e.requestPointerLock();t instanceof Promise?t.then((function(){e.focus()})).catch((function(){})):e.focus()}}function Mo(){document.exitPointerLock&&document.exitPointerLock()}Er.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case u.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case u.ALPHA_PREMULTIPLIED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_PREMULTIPLIED_PORTERDUFF:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case u.ALPHA_COMBINE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_SUBTRACT:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_INTERPOLATE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case u.ALPHA_SCREENMODE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case u.ALPHA_ONEONE_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_ALPHATOCOLOR:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case u.ALPHA_REVERSEONEMINUS:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE_MINUS_DST_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case u.ALPHA_SRC_DSTONEMINUSSRCALPHA:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case u.ALPHA_ONEONE_ONEZERO:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case u.ALPHA_EXCLUSION:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case u.ALPHA_LAYER_ACCUMULATE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}t||(this.depthCullingState.depthMask=e===u.ALPHA_DISABLE),this._alphaMode=e}else if(!t){var i=e===u.ALPHA_DISABLE;this.depthCullingState.depthMask!==i&&(this.depthCullingState.depthMask=i)}},Er.prototype._readTexturePixelsSync=function(e,t,i,r,n,o,a,s,l,c){var u,h;void 0===r&&(r=-1),void 0===n&&(n=0),void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===l&&(l=0),void 0===c&&(c=0);var d=this._gl;if(!d)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var p=d.createFramebuffer();if(!p)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=p}d.bindFramebuffer(d.FRAMEBUFFER,this._dummyFramebuffer),r>-1?d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_CUBE_MAP_POSITIVE_X+r,null===(u=e._hardwareTexture)||void 0===u?void 0:u.underlyingResource,n):d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,null===(h=e._hardwareTexture)||void 0===h?void 0:h.underlyingResource,n);var f=void 0!==e.type?this._getWebGLTextureType(e.type):d.UNSIGNED_BYTE;return s?o||(o=To(e.type,4*t*i)):f===d.UNSIGNED_BYTE?(o||(o=new Uint8Array(4*t*i)),f=d.UNSIGNED_BYTE):(o||(o=new Float32Array(4*t*i)),f=d.FLOAT),a&&this.flushFramebuffer(),d.readPixels(l,c,t,i,d.RGBA,f,o),d.bindFramebuffer(d.FRAMEBUFFER,this._currentFramebuffer),o},Er.prototype._readTexturePixels=function(e,t,i,r,n,o,a,s,l,c){return void 0===r&&(r=-1),void 0===n&&(n=0),void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===l&&(l=0),void 0===c&&(c=0),Promise.resolve(this._readTexturePixelsSync(e,t,i,r,n,o,a,s,l,c))},Er.prototype.updateDynamicIndexBuffer=function(e,t,i){var r;void 0===i&&(i=0),this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),r=e.is32Bits?t instanceof Uint32Array?t:new Uint32Array(t):t instanceof Uint16Array?t:new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},Er.prototype.updateDynamicVertexBuffer=function(e,t,i,r){this.bindArrayBuffer(e),void 0===i&&(i=0);var n=t.byteLength||t.length;void 0===r||r>=n&&0===i?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+r)):(t=t instanceof ArrayBuffer?new Uint8Array(t,i,r):new Uint8Array(t.buffer,t.byteOffset+i,r),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()},Mi.prototype.displayLoadingUI=function(){if(ct()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},Mi.prototype.hideLoadingUI=function(){if(ct()){var e=this._loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(Mi.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=Mi.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(Mi.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(Mi.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),Mi.prototype.getInputElement=function(){return this._renderingCanvas},Mi.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},Mi.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},Mi.prototype.getAspectRatio=function(e,t){void 0===t&&(t=!1);var i=e.viewport;return this.getRenderWidth(t)*i.width/(this.getRenderHeight(t)*i.height)},Mi.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},Mi.prototype._verifyPointerLock=function(){var e;null===(e=this._onPointerLockChange)||void 0===e||e.call(this)},Mi.prototype.getInputElement=function(){return this._renderingCanvas},Mi.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},Mi.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},Mi.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(u.GREATER)},Mi.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(u.GEQUAL)},Mi.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(u.LESS)},Mi.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(u.LEQUAL)},Mi.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},Mi.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},Mi.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},Mi.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},Mi.prototype.getStencilMask=function(){return this._stencilState.stencilMask},Mi.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},Mi.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},Mi.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},Mi.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},Mi.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},Mi.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},Mi.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},Mi.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},Mi.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},Mi.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},Mi.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},Mi.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},Mi.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},Mi.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()},Mi.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)},Mi.prototype.setAlphaConstants=function(e,t,i,r){this._alphaState.setAlphaBlendConstants(e,t,i,r)},Mi.prototype.getAlphaMode=function(){return this._alphaMode},Mi.prototype.getAlphaEquation=function(){return this._alphaEquation},Mi.prototype.getRenderPassNames=function(){return this._renderPassNames},Mi.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]},Mi.prototype.createRenderPassId=function(e){var t=++Mi._RenderPassIdCounter;return this._renderPassNames[t]=null!=e?e:"NONAME",t},Mi.prototype.releaseRenderPassId=function(e){this._renderPassNames[e]=void 0;for(var t=0;t0&&0===this._frameHandler&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))},t.prototype._renderViews=function(){return!1},t.prototype.enterPointerlock=function(){this._renderingCanvas&&Io(this._renderingCanvas)},t.prototype.exitPointerlock=function(){Mo()},t.prototype.beginFrame=function(){this._measureFps(),e.prototype.beginFrame.call(this)},t.prototype._deletePipelineContext=function(t){var i=t;i&&i.program&&i.transformFeedback&&(this.deleteTransformFeedback(i.transformFeedback),i.transformFeedback=null),e.prototype._deletePipelineContext.call(this,t)},t.prototype.createShaderProgram=function(t,i,r,n,o,a){void 0===a&&(a=null),o=o||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var s=e.prototype.createShaderProgram.call(this,t,i,r,n,o,a);return this.onAfterShaderCompilationObservable.notifyObservers(this),s},t.prototype._createShaderProgram=function(e,t,i,r,n){void 0===n&&(n=null);var o=r.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");if(r.attachShader(o,t),r.attachShader(o,i),this.webGLVersion>1&&n){var a=this.createTransformFeedback();this.bindTransformFeedback(a),this.setTranformFeedbackVaryings(o,n),e.transformFeedback=a}return r.linkProgram(o),this.webGLVersion>1&&n&&this.bindTransformFeedback(null),e.context=r,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},t.prototype._releaseTexture=function(t){e.prototype._releaseTexture.call(this,t)},t.prototype._releaseRenderTargetWrapper=function(t){e.prototype._releaseRenderTargetWrapper.call(this,t),this.scenes.forEach((function(e){e.postProcesses.forEach((function(e){e._outputTexture===t&&(e._outputTexture=null)})),e.cameras.forEach((function(e){e._postProcesses.forEach((function(e){e&&e._outputTexture===t&&(e._outputTexture=null)}))}))}))},t.prototype._rescaleTexture=function(e,i,r,n,o){var a=this;this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);var s=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:u.TEXTURETYPE_UNSIGNED_INT,samplingMode:u.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&t._RescalePostProcessFactory&&(this._rescalePostProcess=t._RescalePostProcessFactory(this)),this._rescalePostProcess&&(this._rescalePostProcess.externalTextureSamplerBinding=!0,this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(t){t._bindTexture("textureSampler",e)};var t=r;t||(t=a.scenes[a.scenes.length-1]),t.postProcessManager.directRender([a._rescalePostProcess],s,!0),a._bindTextureDirectly(a._gl.TEXTURE_2D,i,!0),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,n,0,0,i.width,i.height,0),a.unBindFramebuffer(s),s.dispose(),o&&o()})))},t.prototype.wrapWebGLTexture=function(e,t,i,r,n){void 0===t&&(t=!1),void 0===i&&(i=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===r&&(r=0),void 0===n&&(n=0);var o=new br(e,this._gl),a=new Pi(this,Ti.Unknown,!0);return a._hardwareTexture=o,a.baseWidth=r,a.baseHeight=n,a.width=r,a.height=n,a.isReady=!0,a.useMipMaps=t,this.updateTextureSamplingMode(i,a),a},t.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),s=this._getRGBABufferInternalSizedFormat(e.type,a),l=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(l,e,!0),this._unpackFlipY(e.invertY);var c=n.TEXTURE_2D;e.isCube&&(c=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(c,r,s,a,o,t),this._bindTextureDirectly(l,null,!0)},t.prototype.updateTextureComparisonFunction=function(e,t){if(1!==this.webGLVersion){var i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,u.LEQUAL),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,u.LEQUAL),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}else ae.Error("WebGL 1 does not support texture comparison.")},t.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");var i=new yr(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i.references=1,i},t.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},t.prototype._clientWaitAsync=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=10);var r=this._gl;return new Promise((function(n,o){var a=function(){var s=r.clientWaitSync(e,t,0);s!=r.WAIT_FAILED?s!=r.TIMEOUT_EXPIRED?n():setTimeout(a,i):o()};a()}))},t.prototype._readPixelsAsync=function(e,t,i,r,n,o,a){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");var s=this._gl,l=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,l),s.bufferData(s.PIXEL_PACK_BUFFER,a.byteLength,s.STREAM_READ),s.readPixels(e,t,i,r,n,o,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null);var c=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);return c?(s.flush(),this._clientWaitAsync(c,0,10).then((function(){return s.deleteSync(c),s.bindBuffer(s.PIXEL_PACK_BUFFER,l),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,a),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),s.deleteBuffer(l),a}))):null},t.prototype.dispose=function(){this._rescalePostProcess&&this._rescalePostProcess.dispose(),So(this,this._renderingCanvas),e.prototype.dispose.call(this)},t.ALPHA_DISABLE=u.ALPHA_DISABLE,t.ALPHA_ADD=u.ALPHA_ADD,t.ALPHA_COMBINE=u.ALPHA_COMBINE,t.ALPHA_SUBTRACT=u.ALPHA_SUBTRACT,t.ALPHA_MULTIPLY=u.ALPHA_MULTIPLY,t.ALPHA_MAXIMIZED=u.ALPHA_MAXIMIZED,t.ALPHA_ONEONE=u.ALPHA_ONEONE,t.ALPHA_PREMULTIPLIED=u.ALPHA_PREMULTIPLIED,t.ALPHA_PREMULTIPLIED_PORTERDUFF=u.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHA_INTERPOLATE=u.ALPHA_INTERPOLATE,t.ALPHA_SCREENMODE=u.ALPHA_SCREENMODE,t.DELAYLOADSTATE_NONE=u.DELAYLOADSTATE_NONE,t.DELAYLOADSTATE_LOADED=u.DELAYLOADSTATE_LOADED,t.DELAYLOADSTATE_LOADING=u.DELAYLOADSTATE_LOADING,t.DELAYLOADSTATE_NOTLOADED=u.DELAYLOADSTATE_NOTLOADED,t.NEVER=u.NEVER,t.ALWAYS=u.ALWAYS,t.LESS=u.LESS,t.EQUAL=u.EQUAL,t.LEQUAL=u.LEQUAL,t.GREATER=u.GREATER,t.GEQUAL=u.GEQUAL,t.NOTEQUAL=u.NOTEQUAL,t.KEEP=u.KEEP,t.REPLACE=u.REPLACE,t.INCR=u.INCR,t.DECR=u.DECR,t.INVERT=u.INVERT,t.INCR_WRAP=u.INCR_WRAP,t.DECR_WRAP=u.DECR_WRAP,t.TEXTURE_CLAMP_ADDRESSMODE=u.TEXTURE_CLAMP_ADDRESSMODE,t.TEXTURE_WRAP_ADDRESSMODE=u.TEXTURE_WRAP_ADDRESSMODE,t.TEXTURE_MIRROR_ADDRESSMODE=u.TEXTURE_MIRROR_ADDRESSMODE,t.TEXTUREFORMAT_ALPHA=u.TEXTUREFORMAT_ALPHA,t.TEXTUREFORMAT_LUMINANCE=u.TEXTUREFORMAT_LUMINANCE,t.TEXTUREFORMAT_LUMINANCE_ALPHA=u.TEXTUREFORMAT_LUMINANCE_ALPHA,t.TEXTUREFORMAT_RGB=u.TEXTUREFORMAT_RGB,t.TEXTUREFORMAT_RGBA=u.TEXTUREFORMAT_RGBA,t.TEXTUREFORMAT_RED=u.TEXTUREFORMAT_RED,t.TEXTUREFORMAT_R=u.TEXTUREFORMAT_R,t.TEXTUREFORMAT_RG=u.TEXTUREFORMAT_RG,t.TEXTUREFORMAT_RED_INTEGER=u.TEXTUREFORMAT_RED_INTEGER,t.TEXTUREFORMAT_R_INTEGER=u.TEXTUREFORMAT_R_INTEGER,t.TEXTUREFORMAT_RG_INTEGER=u.TEXTUREFORMAT_RG_INTEGER,t.TEXTUREFORMAT_RGB_INTEGER=u.TEXTUREFORMAT_RGB_INTEGER,t.TEXTUREFORMAT_RGBA_INTEGER=u.TEXTUREFORMAT_RGBA_INTEGER,t.TEXTURETYPE_UNSIGNED_BYTE=u.TEXTURETYPE_UNSIGNED_BYTE,t.TEXTURETYPE_UNSIGNED_INT=u.TEXTURETYPE_UNSIGNED_INT,t.TEXTURETYPE_FLOAT=u.TEXTURETYPE_FLOAT,t.TEXTURETYPE_HALF_FLOAT=u.TEXTURETYPE_HALF_FLOAT,t.TEXTURETYPE_BYTE=u.TEXTURETYPE_BYTE,t.TEXTURETYPE_SHORT=u.TEXTURETYPE_SHORT,t.TEXTURETYPE_UNSIGNED_SHORT=u.TEXTURETYPE_UNSIGNED_SHORT,t.TEXTURETYPE_INT=u.TEXTURETYPE_INT,t.TEXTURETYPE_UNSIGNED_INTEGER=u.TEXTURETYPE_UNSIGNED_INTEGER,t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=u.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=u.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=u.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=u.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,t.TEXTURETYPE_UNSIGNED_INT_24_8=u.TEXTURETYPE_UNSIGNED_INT_24_8,t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=u.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=u.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=u.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,t.TEXTURE_NEAREST_SAMPLINGMODE=u.TEXTURE_NEAREST_SAMPLINGMODE,t.TEXTURE_BILINEAR_SAMPLINGMODE=u.TEXTURE_BILINEAR_SAMPLINGMODE,t.TEXTURE_TRILINEAR_SAMPLINGMODE=u.TEXTURE_TRILINEAR_SAMPLINGMODE,t.TEXTURE_NEAREST_NEAREST_MIPLINEAR=u.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR_MIPNEAREST=u.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TEXTURE_LINEAR_LINEAR_MIPLINEAR=u.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_NEAREST_MIPNEAREST=u.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPNEAREST=u.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPLINEAR=u.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_LINEAR=u.TEXTURE_NEAREST_LINEAR,t.TEXTURE_NEAREST_NEAREST=u.TEXTURE_NEAREST_NEAREST,t.TEXTURE_LINEAR_NEAREST_MIPNEAREST=u.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.TEXTURE_LINEAR_NEAREST_MIPLINEAR=u.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR=u.TEXTURE_LINEAR_LINEAR,t.TEXTURE_LINEAR_NEAREST=u.TEXTURE_LINEAR_NEAREST,t.TEXTURE_EXPLICIT_MODE=u.TEXTURE_EXPLICIT_MODE,t.TEXTURE_SPHERICAL_MODE=u.TEXTURE_SPHERICAL_MODE,t.TEXTURE_PLANAR_MODE=u.TEXTURE_PLANAR_MODE,t.TEXTURE_CUBIC_MODE=u.TEXTURE_CUBIC_MODE,t.TEXTURE_PROJECTION_MODE=u.TEXTURE_PROJECTION_MODE,t.TEXTURE_SKYBOX_MODE=u.TEXTURE_SKYBOX_MODE,t.TEXTURE_INVCUBIC_MODE=u.TEXTURE_INVCUBIC_MODE,t.TEXTURE_EQUIRECTANGULAR_MODE=u.TEXTURE_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=u.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=u.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.SCALEMODE_FLOOR=u.SCALEMODE_FLOOR,t.SCALEMODE_NEAREST=u.SCALEMODE_NEAREST,t.SCALEMODE_CEILING=u.SCALEMODE_CEILING,t}(Er),No=z.Compose(V.One(),G.FromEulerAngles(0,Math.PI,0),V.Zero()),Fo=function(e){function t(i,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=e.call(this,i,r,!1)||this;return o._forward=new V(0,0,1),o._up=new V(0,1,0),o._right=new V(1,0,0),o._position=V.Zero(),o._rotation=V.Zero(),o._rotationQuaternion=null,o._scaling=V.One(),o._transformToBoneReferal=null,o._isAbsoluteSynced=!1,o._billboardMode=t.BILLBOARDMODE_NONE,o._preserveParentRotationForBillboard=!1,o.scalingDeterminant=1,o._infiniteDistance=!1,o.ignoreNonUniformScaling=!1,o.reIntegrateRotationIntoRotationQuaternion=!1,o._poseMatrix=null,o._localMatrix=z.Zero(),o._usePivotMatrix=!1,o._absolutePosition=V.Zero(),o._absoluteScaling=V.Zero(),o._absoluteRotationQuaternion=G.Identity(),o._pivotMatrix=z.Identity(),o._postMultiplyPivotMatrix=!1,o._isWorldMatrixFrozen=!1,o._indexInSceneTransformNodesArray=-1,o.onAfterWorldMatrixUpdateObservable=new f,o._nonUniformScaling=!1,n&&o.getScene().addTransformNode(o),o}return m(t,e),Object.defineProperty(t.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=!!(this._billboardMode&t.BILLBOARDMODE_USE_POSITION),this._computeUseBillboardPath())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"preserveParentRotationForBillboard",{get:function(){return this._preserveParentRotationForBillboard},set:function(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e,this._computeUseBillboardPath())},enumerable:!1,configurable:!0}),t.prototype._computeUseBillboardPath=function(){this._cache.useBillboardPath=this._billboardMode!==t.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard},Object.defineProperty(t.prototype,"infiniteDistance",{get:function(){return this._infiniteDistance},set:function(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TransformNode"},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._isDirty=!0},enumerable:!1,configurable:!0}),t.prototype.isUsingPivotMatrix=function(){return this._usePivotMatrix},t.prototype.isUsingPostMultiplyPivotMatrix=function(){return this._postMultiplyPivotMatrix},Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._rotationQuaternion=null,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forward",{get:function(){return V.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"up",{get:function(){return V.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return V.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()},enumerable:!1,configurable:!0}),t.prototype.updatePoseMatrix=function(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)},t.prototype.getPoseMatrix=function(){return this._poseMatrix||(this._poseMatrix=z.Identity()),this._poseMatrix},t.prototype._isSynchronized=function(){var e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==t.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)},t.prototype._initCache=function(){e.prototype._initCache.call(this);var t=this._cache;t.localMatrixUpdated=!1,t.billboardMode=-1,t.infiniteDistance=!1,t.useBillboardPosition=!1,t.useBillboardPath=!1},Object.defineProperty(t.prototype,"absolutePosition",{get:function(){return this.getAbsolutePosition()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"absoluteScaling",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"absoluteRotationQuaternion",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion},enumerable:!1,configurable:!0}),t.prototype.setPreTransformMatrix=function(e){return this.setPivotMatrix(e,!1)},t.prototype.setPivotMatrix=function(e,t){return void 0===t&&(t=!0),this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=z.Invert(this._pivotMatrix)),this},t.prototype.getPivotMatrix=function(){return this._pivotMatrix},t.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var r=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);r&&i&&i(this,r);for(var n=0,o=this.getChildTransformNodes(!0);n-1&&this._parentContainer.transformNodes.splice(r,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),t)for(var n=0,o=this.getChildTransformNodes(!0);nDo.CollisionsEpsilon&&n.position.addInPlace(n._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),i&&n.onCollideObservable.notifyObservers(i),n.onCollisionPositionChangeObservable.notifyObservers(n.position)},(r=n.getScene()).addMesh(n),n._resyncLightSources(),n._uniformBuffer=new Or(n.getScene().getEngine(),void 0,void 0,i,!n.getScene().getEngine().isWebGPU),n._buildUniformLayout(),r.performancePriority){case Kr.Aggressive:n.doNotSyncBoundingInfo=!0;case Kr.Intermediate:n.alwaysSelectAsActiveMesh=!0,n.isPickable=!1}return n}return m(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return Fo.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return Fo.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return Fo.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return Fo.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return Fo.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return Fo.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionRetryCount",{get:function(){return this._internalAbstractMeshDataInfo._collisionRetryCount},set:function(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"morphTargetManager",{get:function(){return this._internalAbstractMeshDataInfo._morphTargetManager},set:function(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bakedVertexAnimationManager",{get:function(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager},set:function(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),t.prototype._syncGeometryWithMorphTargetManager=function(){},t.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,"rawBoundingInfo",{get:function(){return this._internalAbstractMeshDataInfo._rawBoundingInfo},set:function(e){this._internalAbstractMeshDataInfo._rawBoundingInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCollide",{set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){if(this._internalAbstractMeshDataInfo._visibility!==e){var t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(1===t&&1!==e||1!==t&&1===e)&&this._markSubMeshesAsDirty((function(e){e.markAsMiscDirty(),e.markAsPrePassDirty()}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerOverDisableMeshTesting",{get:function(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting},set:function(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._internalAbstractMeshDataInfo._renderingGroupId},set:function(e){this._internalAbstractMeshDataInfo._renderingGroupId=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._internalAbstractMeshDataInfo._material},set:function(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(),this._unBindEffect()))},enumerable:!1,configurable:!0}),t.prototype.getMaterialForRenderPass=function(e){var t;return null===(t=this._internalAbstractMeshDataInfo._materialForRenderPass)||void 0===t?void 0:t[e]},t.prototype.setMaterialForRenderPass=function(e,t){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t},Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasVertexAlpha",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useVertexColors",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numBoneInfluencers",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"applyFog",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableDistantPicking",{get:function(){return this._internalAbstractMeshDataInfo._enableDistantPicking},set:function(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerMask",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionResponse",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surroundingMeshes",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_positions",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(e){var t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!1,configurable:!0}),t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e){var t=this._uniformBuffer;t.updateMatrix("world",e),t.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),t.update()},t.prototype.getMeshUniformBuffer=function(){return this._uniformBuffer},t.prototype.getClassName=function(){return"AbstractMesh"},t.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);var i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=", skeleton: "+i.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t},t.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==Fo.BILLBOARDMODE_NONE?this._masterMesh:e.prototype._getEffectiveParent.call(this)},t.prototype._getActionManagerForTrigger=function(e,t){if(void 0===t&&(t=!0),this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},t.prototype._rebuild=function(e){if(void 0===e&&(e=!1),this.onRebuildObservable.notifyObservers(this),null!==this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes){for(var t=0,i=this.subMeshes;t4,m=_?this.getVerticesData(Nr.MatricesIndicesExtraKind):null,g=_?this.getVerticesData(Nr.MatricesWeightsExtraKind):null,v=this.skeleton.getTransformMatrices(this),y=H.Vector3[0],b=H.Matrix[0],T=H.Matrix[1],E=0;for(d=0;d0&&(z.FromFloat32ArrayToRefScaled(v,Math.floor(16*p[E+S]),x,T),b.addToSelf(T));if(_)for(S=0;S<4;S++)(x=g[E+S])>0&&(z.FromFloat32ArrayToRefScaled(v,Math.floor(16*m[E+S]),x,T),b.addToSelf(T));r===Nr.NormalKind?V.TransformNormalFromFloatsToRef(i[d],i[d+1],i[d+2],b,y):V.TransformCoordinatesFromFloatsToRef(i[d],i[d+1],i[d+2],b,y),y.toArray(i,d),r===Nr.PositionKind&&this._positions&&this._positions[d/3].copyFrom(y)}}}return i},t.prototype.getNormalsData=function(e,t){return void 0===e&&(e=!1),void 0===t&&(t=!1),this._getData(e,t,null,Nr.NormalKind)},t.prototype.getPositionData=function(e,t,i){return void 0===e&&(e=!1),void 0===t&&(t=!1),this._getData(e,t,i,Nr.PositionKind)},t.prototype._getPositionData=function(e,t){var i,r=this.getVerticesData(Nr.PositionKind);if(this._internalAbstractMeshDataInfo._positions&&(this._internalAbstractMeshDataInfo._positions=null),r&&(e&&this.skeleton||t&&this.morphTargetManager)){if(r=r.slice(),this._generatePointsArray(),this._positions){var n=this._positions;this._internalAbstractMeshDataInfo._positions=new Array(n.length);for(var o=0;o1||!r.IsGlobal)&&r.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)},t.prototype.isInFrustum=function(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return this.getBoundingInfo().isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,t,i){void 0===t&&(t=!1);var r=this.getBoundingInfo(),n=e.getBoundingInfo();if(r.intersects(n,t))return!0;if(i)for(var o=0,a=this.getChildMeshes();o1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},t.prototype._shouldConvertRHS=function(){return!1},t.prototype._checkCollision=function(e){if(!this.getBoundingInfo()._checkCollision(e))return this;var t=H.Matrix[0],i=H.Matrix[1];return z.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,t,i,r,n,o){void 0===r&&(r=!1),void 0===o&&(o=!1);var a=new Fr,s=this.getClassName(),l="InstancedLinesMesh"===s||"LinesMesh"===s||"GreasedLineMesh"===s?this.intersectionThreshold:0,c=this.getBoundingInfo();if(!this.subMeshes)return a;if(!(o||e.intersectsSphere(c.boundingSphere,l)&&e.intersectsBox(c.boundingBox,l)))return a;if(r)return a.hit=!o,a.pickedMesh=o?null:this,a.distance=o?0:V.Distance(e.origin,c.boundingSphere.center),a.subMeshId=0,a;if(!this._generatePointsArray())return a;for(var h=null,d=this._scene.getIntersectingSubMeshCandidates(this,e),p=d.length,f=!1,_=0;_1)||o||g.canIntersects(e)){var v=g.intersects(e,this._positions,this.getIndices(),t,i);if(v&&(t||!h||v.distance-1&&this._parentContainer.meshes.splice(c,1),this._parentContainer=null}if(i&&this.material&&("MultiMaterial"===this.material.getClassName()?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!t)for(r=0;r65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var s=this.getScene().activeCamera;e.facetDepthSortFrom=s?s.position:V.Zero()}e.depthSortedFacets=[];for(var l=0;lA?n.maximum.x-n.minimum.x:A,e.bbSize.y=n.maximum.y-n.minimum.y>A?n.maximum.y-n.minimum.y:A,e.bbSize.z=n.maximum.z-n.minimum.z>A?n.maximum.z-n.minimum.z:A;var u=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(u=u>e.bbSize.z?u:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/u),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/u),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/u),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=n,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),V.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,r&&_o.ComputeNormals(t,i,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var h=e.depthSortedIndices.length/3|0;for(l=0;ln.subDiv.max||a<0||a>n.subDiv.max||s<0||s>n.subDiv.max?null:n.facetPartitioning[o+n.subDiv.max*a+n.subDiv.max*n.subDiv.max*s]},t.prototype.getClosestFacetAtCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var a=this.getWorldMatrix(),s=H.Matrix[5];a.invertToRef(s);var l=H.Vector3[8];V.TransformCoordinatesFromFloatsToRef(e,t,i,s,l);var c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,r,n,o);return r&&V.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,a,r),c},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var a=null,s=0,l=0,c=0,u=0,h=0,d=0,p=0,f=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var v,y,b,T=Number.MAX_VALUE,E=T,S=0;S=0||n&&!o&&u<=0)&&(u=y.x*b.x+y.y*b.y+y.z*b.z,h=-(y.x*e+y.y*t+y.z*i-u)/(y.x*y.x+y.y*y.y+y.z*y.z),(E=(s=(d=e+y.x*h)-e)*s+(l=(p=t+y.y*h)-t)*l+(c=(f=i+y.z*h)-i)*c)=0){var r=i.activeCamera;r.mode===u.ORTHOGRAPHIC_CAMERA&&ae.Error("Logarithmic depth is not compatible with orthographic cameras!",20),t.setFloat("logarithmicDepthConstant",2/(Math.log(r.maxZ+1)/Math.LN2))}}function Qo(e,t,i,r){void 0===r&&(r=!1),i&&e.fogEnabled&&(!t||t.applyFog)&&e.fogMode!==u.FOGMODE_NONE&&(i.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),r?(e.fogColor.toLinearSpaceToRef(jo,e.getEngine().useExactSrgbConversions),i.setColor3("vFogColor",jo)):i.setColor3("vFogColor",e.fogColor))}function qo(e,t,i){Yo.NUM_MORPH_INFLUENCERS=i,Zo(e,t,Yo)}function Zo(e,t,i){var r=i.NUM_MORPH_INFLUENCERS;if(r>0&&M.LastCreatedEngine){var n=M.LastCreatedEngine.getCaps().maxVertexAttribs,o=t.morphTargetManager;if(null==o?void 0:o.isUsingTextureForTargets)return;for(var a=o&&o.supportsNormals&&i.NORMAL,s=o&&o.supportsTangents&&i.TANGENT,l=o&&o.supportsUVs&&i.UV1,c=0;cn&&ae.Error("Cannot add more vertex attributes for mesh "+t.name)}}function Jo(e,t){void 0===t&&(t=!1),e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"),t&&(e.push("previousWorld0"),e.push("previousWorld1"),e.push("previousWorld2"),e.push("previousWorld3"))}function $o(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)}function ea(e,t){t.bindToEffect(e,"Scene")}function ta(e,t,i){t._needUVs=!0,t[i]=!0,e.optimizeUVAllocation&&e.getTextureMatrix().isIdentityAs3x2()?(t[i+"DIRECTUV"]=e.coordinatesIndex+1,t["MAINUV"+(e.coordinatesIndex+1)]=!0):t[i+"DIRECTUV"]=0}function ia(e,t,i){var r=e.getTextureMatrix();t.updateMatrix(i+"Matrix",r)}function ra(e,t,i){i.BAKED_VERTEX_ANIMATION_TEXTURE&&i.INSTANCES&&e.push("bakedVertexAnimationSettingsInstanced")}function na(e,t,i){var r;if(t&&e&&(e.computeBonesUsingShaders&&t._bonesComputationForcedToCPU&&(e.computeBonesUsingShaders=!1),e.useBones&&e.computeBonesUsingShaders&&e.skeleton)){var n=e.skeleton;if(n.isUsingTextureForMatrices&&t.getUniformIndex("boneTextureWidth")>-1){var o=n.getTransformMatrixTexture(e);t.setTexture("boneSampler",o),t.setFloat("boneTextureWidth",4*(n.bones.length+1))}else{var a=n.getTransformMatrices(e);a&&(t.setMatrices("mBones",a),i&&e.getScene().prePassRenderer&&e.getScene().prePassRenderer.getIndex(u.PREPASS_VELOCITY_TEXTURE_TYPE)&&(i.previousBones[e.uniqueId]||(i.previousBones[e.uniqueId]=a.slice()),t.setMatrices("mPreviousBones",i.previousBones[e.uniqueId]),r=a,i.previousBones[e.uniqueId].set(r)))}}}function oa(e,t,i){e.transferToEffect(t,i+"")}function aa(e,t,i,r,n,o){void 0===o&&(o=!0),e._bindLight(t,i,r,n,o)}function sa(e,t,i,r,n){void 0===n&&(n=4);for(var o=Math.min(t.lightSources.length,n),a=0;a0&&(r.addCPUSkinningFallback(0,t),e.push(u.MatricesIndicesKind),e.push(u.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(e.push(u.MatricesIndicesExtraKind),e.push(u.MatricesWeightsExtraKind)))}function ca(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&Jo(e,!!t.PREPASS_VELOCITY),t.INSTANCESCOLOR&&e.push(u.ColorInstanceKind)}function ua(e,t,i,r){void 0===i&&(i=4),void 0===r&&(r=0);for(var n=0,o=0;o0&&(n=r+o,t.addFallback(n,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(r,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(r,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o),e["SHADOWCLOSEESM"+o]&&t.addFallback(r,"SHADOWCLOSEESM"+o));return n++}function ha(e,t){return t.fogEnabled&&e.applyFog&&t.fogMode!==u.FOGMODE_NONE}function da(e,t,i,r,n,o,a,s){void 0===s&&(s=!1),a._areMiscDirty&&(a.LOGARITHMICDEPTH=i,a.POINTSIZE=r,a.FOG=n&&ha(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=o,a.DECAL_AFTER_DETAIL=s)}function pa(e,t,i,r,n,o){if(void 0===n&&(n=4),void 0===o&&(o=!1),!i._areLightsDirty)return i._needNormals;var a=0,s={needNormals:i._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var l=0,c=t.lightSources;l0&&(a.shadowEnabled=!0,l.prepareDefines(n,r))}}i.lightmapMode!=un.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,n["LIGHTMAPEXCLUDED"+r]=!0,n["LIGHTMAPNOSPECULAR"+r]=i.lightmapMode==un.LIGHTMAP_SHADOWSONLY):(n["LIGHTMAPEXCLUDED"+r]=!1,n["LIGHTMAPNOSPECULAR"+r]=!1)}function _a(e,t,i,r,n,o,a){void 0===o&&(o=null),void 0===a&&(a=!1);var s=Sa(e,r);!1!==o&&(s=Wo(i,e,r)),r.DEPTHPREPASS!==!t.getColorWrite()&&(r.DEPTHPREPASS=!r.DEPTHPREPASS,s=!0),r.INSTANCES!==n&&(r.INSTANCES=n,s=!0),r.THIN_INSTANCES!==a&&(r.THIN_INSTANCES=a,s=!0),s&&r.markAsUnprocessed()}function ma(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;var i=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&i)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!i&&void 0;var r=e.getScene().prePassRenderer;if(r&&r.enabled){var n=-1===r.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=n}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,void 0!==t.BONETEXTURE&&(t.BONETEXTURE=!1)}function ga(e,t){var i=e.morphTargetManager;i?(t.MORPHTARGETS_UV=i.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=i.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=i.supportsNormals&&t.NORMAL,t.NUM_MORPH_INFLUENCERS=i.numMaxInfluencers||i.numInfluencers,t.MORPHTARGETS=t.NUM_MORPH_INFLUENCERS>0,t.MORPHTARGETS_TEXTURE=i.isUsingTextureForTargets):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)}function va(e,t){var i=e.bakedVertexAnimationManager;t.BAKED_VERTEX_ANIMATION_TEXTURE=!(!i||!i.isEnabled)}function ya(e,t,i,r,n,o,a){if(void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===a&&(a=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(u.NormalKind),t._needNormals&&e.isVerticesDataPresent(u.TangentKind)&&(t.TANGENT=!0);for(var s=1;s<=u.MAX_SUPPORTED_UV_SETS;++s)t["UV"+s]=!!t._needUVs&&e.isVerticesDataPresent("uv".concat(1===s?"":s));if(i){var l=e.useVertexColors&&e.isVerticesDataPresent(u.ColorKind);t.VERTEXCOLOR=l,t.VERTEXALPHA=e.hasVertexAlpha&&l&&o}return e.isVerticesDataPresent(u.ColorInstanceKind)&&(e.hasInstances||e.hasThinInstances)&&(t.INSTANCESCOLOR=!0),r&&ma(e,t),n&&ga(e,t),a&&va(e,t),!0}function ba(e,t){if(e.activeCamera){var i=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=i&&t.markAsUnprocessed()}}function Ta(e,t,i){var r=t.ORDER_INDEPENDENT_TRANSPARENCY,n=t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;t.ORDER_INDEPENDENT_TRANSPARENCY=e.useOrderIndependentTransparency&&i,t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!e.getEngine().getCaps().textureFloatLinearFiltering,r===t.ORDER_INDEPENDENT_TRANSPARENCY&&n===t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS||t.markAsUnprocessed()}function Ea(e,t,i){var r=t.PREPASS;if(t._arePrePassDirty){var n=[{type:u.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:u.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:u.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:u.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:u.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:u.PREPASS_DEPTH_TEXTURE_TYPE,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:u.PREPASS_NORMAL_TEXTURE_TYPE,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&i){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount,t.PREPASS_NORMAL_WORLDSPACE=e.prePassRenderer.generateNormalsInWorldSpace;for(var o=0;o-1&&this._parentContainer.materials.splice(n,1),this._parentContainer=null}if(!0!==i)if(this.meshMap)for(var o in this.meshMap)(l=this.meshMap[o])&&(l.material=null,this.releaseVertexArrayObject(l,e));else for(var a=0,s=r.meshes;a=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.getActiveTextures=function(){var t;return(t=e.prototype.getActiveTextures.call(this)).concat.apply(t,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})))},t.prototype.hasTexture=function(t){var i;if(e.prototype.hasTexture.call(this,t))return!0;for(var r=0;r=0&&n.multiMaterials.splice(s,1),e.prototype.dispose.call(this,t,i)}},t.ParseMultiMaterial=function(e,i){var r=new t(e.name,i);return r.id=e.id,r._loadedUniqueId=e.uniqueId,je&&je.AddTagsTo(r,e.tags),e.materialsUniqueIds?r._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach((function(e){return r.subMaterials.push(i.getLastMaterialById(e))})),r},t}(Ca);a("BABYLON.MultiMaterial",Ra);var Pa=function(e,t){this.distanceOrScreenCoverage=e,this.mesh=t},Ia=function(){},Ma=function(){this.visibleInstances={},this.batchCache=new Oa,this.batchCacheReplacementModeInFrozenMode=new Oa,this.instancesBufferSize=2048},Oa=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]},Da=function(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null},Na=function(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._useLODScreenCoverage=!1,this._effectiveMaterial=null,this._forcedInstanceCount=0,this._overrideRenderingFillMode=null},Fa=function(e){function t(i,r,n,o,a,s){void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=!0);var l=e.call(this,i,r)||this;if(l._internalMeshDataInfo=new Na,l.delayLoadState=u.DELAYLOADSTATE_NONE,l.instances=[],l._creationDataStorage=null,l._geometry=null,l._instanceDataStorage=new Ma,l._thinInstanceDataStorage=new Da,l._shouldGenerateFlatShading=!1,l._originalBuilderSideOrientation=t.DEFAULTSIDE,l.overrideMaterialSideOrientation=null,l.ignoreCameraMaxZ=!1,r=l.getScene(),l._onBeforeDraw=function(e,t,i){e&&i&&(l._uniformBuffer?l.transferToEffect(t):i.bindOnlyWorldMatrix(t))},o){if(o._geometry&&o._geometry.applyToMesh(l),ye.DeepCopy(o,l,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","worldMatrixInstancedBuffer","previousWorldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap","hasBoundingInfo","physicsBody","physicsImpostor"],["_poseMatrix"]),l._internalMeshDataInfo._source=o,r.useClonedMeshMap&&(o._internalMeshDataInfo.meshMap||(o._internalMeshDataInfo.meshMap={}),o._internalMeshDataInfo.meshMap[l.uniqueId]=l),l._originalBuilderSideOrientation=o._originalBuilderSideOrientation,l._creationDataStorage=o._creationDataStorage,o._ranges){var c=o._ranges;for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&c[h]&&l.createAnimationRange(h,c[h].from,c[h].to)}if(o.metadata&&o.metadata.clone?l.metadata=o.metadata.clone():l.metadata=o.metadata,l._internalMetadata=o._internalMetadata,je&&je.HasTags(o)&&je.AddTagsTo(l,je.GetTags(o,!0)),l.setEnabled(o.isEnabled(!1)),l.parent=o.parent,l.setPivotMatrix(o.getPivotMatrix(),l._postMultiplyPivotMatrix),l.id=i+"."+o.id,l.material=o.material,!a)for(var d=o.getDescendants(!0),p=0;p0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasThinInstances",{get:function(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forcedInstanceCount",{get:function(){return this._internalMeshDataInfo._forcedInstanceCount},set:function(e){this._internalMeshDataInfo._forcedInstanceCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"overrideRenderingFillMode",{get:function(){return this._internalMeshDataInfo._overrideRenderingFillMode},set:function(e){this._internalMeshDataInfo._overrideRenderingFillMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cloneMeshMap",{get:function(){return this._internalMeshDataInfo.meshMap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previousWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesPreviousData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfPreviousWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.previousManualUpdate},set:function(e){this._instanceDataStorage.previousManualUpdate=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forceWorldMatrixInstancedBufferUpdate",{get:function(){return this._instanceDataStorage.forceMatrixUpdates},set:function(e){this._instanceDataStorage.forceMatrixUpdates=e},enumerable:!1,configurable:!0}),t.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var r=0===this.getTotalVertices()||t&&t.doNotInstantiate&&(!0===t.doNotInstantiate||t.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));r.parent=e||this.parent,r.position=this.position.clone(),r.scaling=this.scaling.clone(),this.rotationQuaternion?r.rotationQuaternion=this.rotationQuaternion.clone():r.rotation=this.rotation.clone(),i&&i(this,r);for(var n=0,o=this.getChildTransformNodes(!0);n0},enumerable:!1,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){var e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort((function(t,i){return t.distanceOrScreenCoveragei.distanceOrScreenCoverage?-e:0}))},t.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return ae.Warn("You cannot use a mesh as LOD level twice"),this;var i=new Pa(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,i=0;ia*o)return this.onLODLevelSelection&&this.onLODLevelSelection(o,this,this),this;for(var c=0;c0||this.hasThinInstances);this.computeWorldMatrix();var f=this.material||d.defaultMaterial;if(f)if(f._storeEffectOnSubMeshes)for(var _=0,m=this.subMeshes;_0){var i=this.getIndices();if(!i)return null;var r=i.length,n=!1;if(e)n=!0;else for(var o=0,a=this.subMeshes;or){n=!0;break}if(s.verticesStart+s.verticesCount>t){n=!0;break}}if(!n)return this.subMeshes[0]}return this.releaseSubMeshes(),new po(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),i=t/e|0,r=0;i%3!=0;)i++;this.releaseSubMeshes();for(var n=0;n=t);n++)po.CreateFromIndices(0,r,n===e-1?t-r:i,this,void 0,!1),r+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,i,r){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,r);else{var n=new _o;n.set(t,e);var o=this.getScene();new vo(vo.RandomId(),o,n,i,this)}return this},t.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},t.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e,t){return void 0===t&&(t=!0),this._geometry||(this._geometry=vo.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,t),this},t.prototype.updateVerticesData=function(e,t,i,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var i=this.getVerticesData(Nr.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(Nr.PositionKind,i,!1,!1),t){var r=this.getIndices(),n=this.getVerticesData(Nr.NormalKind);if(!n)return this;_o.ComputeNormals(i,r,n),this.updateVerticesData(Nr.NormalKind,n,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;var e=this._geometry,t=this._geometry.copy(vo.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndexBuffer=function(e,t,i){var r=this._geometry;r||(r=new vo(vo.RandomId(),this.getScene(),void 0,void 0,this)),r.setIndexBuffer(e,t,i)},t.prototype.setIndices=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._geometry)this._geometry.setIndices(e,t,i);else{var r=new _o;r.indices=e;var n=this.getScene();new vo(vo.RandomId(),n,r,i,this)}return this},t.prototype.updateIndices=function(e,t,i){return void 0===i&&(i=!1),this._geometry?(this._geometry.updateIndices(e,t,i),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,i,r){if(void 0===r&&(r=!0),!this._geometry)return this;var n,o=this.getScene().getEngine();if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(t),this._unIndexed)n=null;else switch(this._getRenderingFillMode(i)){case Ca.PointFillMode:n=null;break;case Ca.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),o);break;default:case Ca.TriangleFillMode:n=this._geometry.getIndexBuffer()}return r&&this._userInstancedBuffersStorage&&!this.hasThinInstances?this._geometry._bind(t,n,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects):this._geometry._bind(t,n),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var r=this.getScene().getEngine();return this._unIndexed||t==Ca.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==Ca.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):r.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i),this},t.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},t.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},t.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},t.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},t.prototype._getInstancesRenderList=function(e,t){if(void 0===t&&(t=!1),this._instanceDataStorage.isFrozen){if(t)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}var i=this.getScene(),r=i._isInIntermediateRendering(),n=r?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!n&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var a=this._instanceDataStorage.visibleInstances,s=i.getRenderId(),l=r?a.intermediateDefaultRenderId:a.defaultRenderId;o.visibleInstances[e]=a[s],!o.visibleInstances[e]&&l&&(o.visibleInstances[e]=a[l])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==o.visibleInstances[e]&&void 0!==o.visibleInstances[e],this._instanceDataStorage.previousBatch=o,o},t.prototype._renderWithInstances=function(e,i,r,n,o){for(var a,s=r.visibleInstances[e._id],l=s?s.length:0,c=this._instanceDataStorage,u=c.instancesBufferSize,h=c.instancesBuffer,d=c.instancesPreviousBuffer,p=16*(l+1)*4;c.instancesBufferSizet._distanceToCamera?-1:e._distanceToCamera1&&s.activeCamera===s.activeCameras[0]||l<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;var c=this._getInstancesRenderList(e._id,!!i);if(c.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var u=s.getEngine(),h=0,d=null;this.ignoreCameraMaxZ&&s.activeCamera&&!s._isInIntermediateRendering()&&(h=s.activeCamera.maxZ,d=s.activeCamera,s.activeCamera.maxZ=0,s.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);var p,f=e.getRenderingMesh(),_=c.hardwareInstancedRendering[e._id]||f.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,m=this._instanceDataStorage,g=e.getMaterial();if(!g)return d&&(d.maxZ=h,s.updateTransformMatrix(!0)),this;if(m.isFrozen&&this._internalMeshDataInfo._effectiveMaterial&&this._internalMeshDataInfo._effectiveMaterial===g){if(g._storeEffectOnSubMeshes&&!(null===(o=e._drawWrapper)||void 0===o?void 0:o._wasPreviouslyReady)||!g._storeEffectOnSubMeshes&&!g._getDrawWrapper()._wasPreviouslyReady)return d&&(d.maxZ=h,s.updateTransformMatrix(!0)),this}else{if(g._storeEffectOnSubMeshes){if(!g.isReadyForSubMesh(this,e,_))return d&&(d.maxZ=h,s.updateTransformMatrix(!0)),this}else if(!g.isReady(this,_))return d&&(d.maxZ=h,s.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=g}t&&u.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);for(var v=null!==(a=null==(p=this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?e._drawWrapper:this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper())?void 0:p.effect)&&void 0!==a?a:null,y=0,b=s._beforeRenderingMeshStage;yu&&r++,0!==f&&d++,h+=f,u=f}if(l[d]++,d>o&&(o=d),0===h)n++;else{var _=1/h,m=0;for(p=0;p.001&&a++}}var g=this.skeleton.bones.length,v=this.getVerticesData(Nr.MatricesIndicesKind),y=this.getVerticesData(Nr.MatricesIndicesExtraKind),b=0;for(c=0;c=g||T<0)&&b++}return{skinned:!0,valid:0===n&&0===a&&0===b,report:"Number of Weights = "+i/4+"\nMaximum influences = "+o+"\nMissing Weights = "+n+"\nNot Sorted = "+r+"\nNot Normalized = "+a+"\nWeightCounts = ["+l+"]\nNumber of bones = "+g+"\nBad Bone Indices = "+b}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===u.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=u.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var t=this;e.addPendingData(this);var i=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return rr.LoadFile(this.delayLoadingFile,(function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=u.DELAYLOADSTATE_LOADED,e.removePendingData(t)}),(function(){}),e.offlineProvider,i),this},t.prototype.isInFrustum=function(t){return this.delayLoadState!==u.DELAYLOADSTATE_LOADING&&!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0)},t.prototype.setMaterialById=function(e){var t,i=this.getScene().materials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},t.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(Nr.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,r=this.getVerticesData(Nr.PositionKind),n=V.Zero();for(i=0;i-1&&(n.morphTargetManager=i.getMorphTargetManagerById(e.morphTargetManagerId)),void 0!==e.skeletonId&&null!==e.skeletonId&&(n.skeleton=i.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(n.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,u=c?this.getVerticesData(Nr.MatricesIndicesExtraKind):null,h=c?this.getVerticesData(Nr.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),p=V.Zero(),f=new z,_=new z,m=0,g=0;g0&&(z.FromFloat32ArrayToRefScaled(d,Math.floor(16*a[m+l]),v,_),f.addToSelf(_));if(c)for(l=0;l<4;l++)(v=h[m+l])>0&&(z.FromFloat32ArrayToRefScaled(d,Math.floor(16*u[m+l]),v,_),f.addToSelf(_));V.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g],i._sourcePositions[g+1],i._sourcePositions[g+2],f,p),p.toArray(n,g),t&&(V.TransformNormalFromFloatsToRef(i._sourceNormals[g],i._sourceNormals[g+1],i._sourceNormals[g+2],f,p),p.toArray(o,g)),f.reset()}return this.updateVerticesData(Nr.PositionKind,n),t&&this.updateVerticesData(Nr.NormalKind,o),this},t.MinMax=function(e){var t=null,i=null;return e.forEach((function(e){var r=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(r.minimumWorld),i.maximizeInPlace(r.maximumWorld)):(t=r.minimumWorld,i=r.maximumWorld)})),t&&i?{min:t,max:i}:{min:V.Zero(),max:V.Zero()}},t.Center=function(e){var i=e instanceof Array?t.MinMax(e):e;return V.Center(i.min,i.max)},t.MergeMeshes=function(e,i,r,n,o,a){return void 0===i&&(i=!0),Kn(t._MergeMeshesCoroutine(e,i,r,n,o,a,!1))},t.MergeMeshesAsync=function(e,i,r,n,o,a){return void 0===i&&(i=!0),Qn(t._MergeMeshesCoroutine(e,i,r,n,o,a,!0),jn())},t._MergeMeshesCoroutine=function(e,i,r,n,o,a,s){var l,c,u,h,d,p,f,_,m,g,v,y,T,E,S,x,A,C,R,P,I,M,O,D,N,F;return void 0===i&&(i=!0),b(this,(function(b){switch(b.label){case 0:if(0===(e=e.filter(Boolean)).length)return[2,null];if(!r)for(c=0,l=0;l=65536)return ae.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),[2,null];for(a&&(o=!1),u=new Array,h=new Array,d=new Array,p=e[0].overrideMaterialSideOrientation,l=0;l=0!=this._getWorldMatrixDeterminant()>=0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,t),i){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1},t.prototype._postActivate=function(){this._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)},t.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==Fo.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new z);var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,H.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(H.Vector3[7]),this._currentLOD._masterMesh=t,this._billboardWorldMatrix}return e.prototype.getWorldMatrix.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.getLOD=function(e){if(!e)return this;var t=this.sourceMesh.getLODLevels();if(t&&0!==t.length){var i=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,i.boundingSphere)}else this._currentLOD=this.sourceMesh;return this._currentLOD},t.prototype._preActivateForIntermediateRendering=function(e){return this.sourceMesh._preActivateForIntermediateRendering(e)},t.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e0&&-1===this.includedOnlyMeshes.indexOf(e)||this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)||!(0===this.includeOnlyWithLayerMask||this.includeOnlyWithLayerMask&e.layerMask)||0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask))},t.prototype.dispose=function(t,i){if(void 0===i&&(i=!1),this._shadowGenerators){for(var r=this._shadowGenerators.values(),n=r.next();!0!==n.done;n=r.next())n.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){var o=this._parentContainer.lights.indexOf(this);o>-1&&this._parentContainer.lights.splice(o,1),this._parentContainer=null}for(var a=0,s=this.getScene().meshes;a0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((function(t){e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(t){e.includedOnlyMeshesIds.push(t.id)}))),Ke.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e},t.GetConstructorFromName=function(e,t,i){return qe.Construct("Light_Type_"+e,t,i)||null},t.Parse=function(e,i){var r=t.GetConstructorFromName(e.type,e.name,i);if(!r)return null;var n=Ke.Parse(r,e,i);if(e.excludedMeshesIds&&(n._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(n._includedOnlyMeshesIds=e.includedOnlyMeshesIds),void 0!==e.parentId&&(n._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(n._waitingParentInstanceIndex=e.parentInstanceIndex),void 0!==e.falloffType&&(n.falloffType=e.falloffType),void 0!==e.lightmapMode&&(n.lightmapMode=e.lightmapMode),e.animations){for(var o=0;o0;){var E=T.shift();g.push(E);for(var S=o.dependedBy.get(E.uniqueId),x=0,A=Array.from(S.values());x0&&(ae.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach((function(e){return ae.Error(e.name)}))),g},t.prototype._addNodeAndDescendantsToList=function(e,t,i,r){if(i&&(!r||r(i))&&!t.has(i.uniqueId)){e.push(i),t.add(i.uniqueId);for(var n=0,o=i.getDescendants(!0);n-1&&t.animations.splice(o,1)}},n=0,o=e.animations;n0;){var r=t.pop();if(r instanceof Fa?(r.geometry&&-1===this.geometries.indexOf(r.geometry)&&this.geometries.push(r.geometry),this.meshes.push(r)):r instanceof Fo?this.transformNodes.push(r):r instanceof wa?this.lights.push(r):r instanceof $n&&this.cameras.push(r),r instanceof Uo){if(r.material&&-1===this.materials.indexOf(r.material)){this.materials.push(r.material);for(var n=0,o=r.material.getActiveTextures();n0&&(_=!0,this._soundLoaded(i));break;case"AudioBuffer":this._audioBufferLoaded(i);break;case"String":p.push(i);case"Array":0===p.length&&(p=i);for(var m=function(e){var t=p[e];if(_=o&&o.skipCodecCheck||-1!==t.indexOf(".mp3",t.length-4)&&Do.audioEngine.isMP3supported||-1!==t.indexOf(".ogg",t.length-4)&&Do.audioEngine.isOGGsupported||-1!==t.indexOf(".wav",t.length-4)||-1!==t.indexOf(".m4a",t.length-4)||-1!==t.indexOf(".mp4",t.length-4)||-1!==t.indexOf("blob:"))return g._streaming?(g._htmlAudioElement=new Audio(t),g._htmlAudioElement.controls=!1,g._htmlAudioElement.loop=g.loop,rr.SetCorsBehavior(t,g._htmlAudioElement),g._htmlAudioElement.preload="auto",g._htmlAudioElement.addEventListener("canplaythrough",(function(){h._isReadyToPlay=!0,h.autoplay&&h.play(0,h._offset,h._length),h._readyToPlayCallback&&h._readyToPlayCallback()})),document.body.appendChild(g._htmlAudioElement),g._htmlAudioElement.load()):g._scene._loadFile(t,(function(e){h._soundLoaded(e)}),void 0,!0,!0,(function(e){e&&ae.Error("XHR "+e.status+" error on: "+t+"."),ae.Error("Sound creation aborted."),h._scene.mainSoundTrack.removeSound(h)})),"break"},g=this,v=0;v0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if((null===(t=Do.audioEngine)||void 0===t?void 0:t.audioContext)&&this._soundSource){var r=e?Do.audioEngine.audioContext.currentTime+e:void 0;this._soundSource.onended=function(){i.isPlaying=!1,i.isPaused=!1,i._startTime=0,i._currentTime=0,i._soundSource&&(i._soundSource.onended=function(){}),i._onended()},this._soundSource.stop(r)}else this.isPlaying=!1;else this.isPaused&&(this.isPaused=!1,this._startTime=0,this._currentTime=0)},e.prototype.pause=function(){var e;this.isPlaying&&(this._clearTimeoutsAndObservers(),this._streaming?(this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect(),this.isPlaying=!1,this.isPaused=!0):(null===(e=Do.audioEngine)||void 0===e?void 0:e.audioContext)&&this._soundSource&&(this._soundSource.onended=function(){},this._soundSource.stop(),this.isPlaying=!1,this.isPaused=!0,this._currentTime+=Do.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){var i;(null===(i=Do.audioEngine)||void 0===i?void 0:i.canUseWebAudio)&&this._soundGain&&(t&&Do.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(Do.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,Do.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,Do.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},e.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},e.prototype.getPlaybackRate=function(){return this._playbackRate},e.prototype.getVolume=function(){return this._volume},e.prototype.attachToMesh=function(e){var t=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,this._spatialSound||(this._spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length))),this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},e.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},e.prototype._onRegisterAfterWorldMatrixUpdate=function(e){var t;if(e.getBoundingInfo){var i=e.getBoundingInfo();this.setPosition(i.boundingSphere.centerWorld)}else this.setPosition(e.absolutePosition);(null===(t=Do.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._isDirectional&&this.isPlaying&&this._updateDirection()},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var i=function(){t._isReadyToPlay?(n._audioBuffer=t.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play(0,t._offset,t._length)):setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this._spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new e(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.getSoundSource=function(){return this._soundSource},e.prototype.getSoundGain=function(){return this._soundGain},e.prototype.serialize=function(){var e={name:this.name,url:this._url,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this._spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId,metadata:this.metadata};return this._spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},e.Parse=function(t,i,r,n){var o,a=t.name;o=t.url?r+t.url:r+a;var s,l={autoplay:t.autoplay,loop:t.loop,volume:t.volume,spatialSound:t.spatialSound,maxDistance:t.maxDistance,rolloffFactor:t.rolloffFactor,refDistance:t.refDistance,distanceModel:t.distanceModel,playbackRate:t.playbackRate};if(n){var c=function(){n._isReadyToPlay?(s._audioBuffer=n.getAudioBuffer(),s._isReadyToPlay=!0,s.autoplay&&s.play(0,s._offset,s._length)):setTimeout(c,300)};s=new e(a,new ArrayBuffer(0),i,null,l),c()}else s=new e(a,o,i,(function(){i.removePendingData(s)}),l),i.addPendingData(s);if(t.position){var u=V.FromArray(t.position);s.setPosition(u)}if(t.isDirectional&&(s.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var h=V.FromArray(t.localDirectionToMesh);s.setLocalDirectionToMesh(h)}if(t.connectedMeshId){var d=i.getMeshById(t.connectedMeshId);d&&s.attachToMesh(d)}return t.metadata&&(s.metadata=t.metadata),s},e.prototype._setOffset=function(e){this._offset!==e&&(this.isPaused&&(this.stop(),this.isPaused=!1),this._offset=e)},e.prototype._clearTimeoutsAndObservers=function(){var e;this._tryToPlayTimeout&&(clearTimeout(this._tryToPlayTimeout),this._tryToPlayTimeout=null),this._audioUnlockedObserver&&(null===(e=Do.audioEngine)||void 0===e||e.onAudioUnlockedObservable.remove(this._audioUnlockedObserver),this._audioUnlockedObserver=null)},e._SceneComponentInitialization=function(e){throw He("AudioSceneComponent")},e}();a("BABYLON.Sound",Ga);var za=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,(e=e||M.LastCreatedScene)&&(this._scene=e,this.soundCollection=[],this._options=t,!this._options.mainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1))}return e.prototype._initializeSoundTrackAudioGraph=function(){var e;(null===(e=Do.audioEngine)||void 0===e?void 0:e.canUseWebAudio)&&Do.audioEngine.audioContext&&(this._outputAudioNode=Do.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Do.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(Do.audioEngine&&Do.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},e.prototype.addSound=function(e){var t;this._isInitialized||this._initializeSoundTrackAudioGraph(),(null===(t=Do.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._outputAudioNode&&e.connectToSoundTrackAudioNode(this._outputAudioNode),void 0!==e.soundTrackId&&(-1===e.soundTrackId?this._scene.mainSoundTrack.removeSound(e):this._scene.soundTracks&&this._scene.soundTracks[e.soundTrackId].removeSound(e)),this.soundCollection.push(e),e.soundTrackId=this.id},e.prototype.removeSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},e.prototype.setVolume=function(e){var t;(null===(t=Do.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){var e;if(null===(e=Do.audioEngine)||void 0===e?void 0:e.canUseWebAudio)for(var t=0;t0&&(n=i.activeCameras[0]),this.audioListenerPositionProvider){var o=this.audioListenerPositionProvider();r.audioContext.listener.setPosition(o.x||0,o.y||0,o.z||0)}else n?this._cachedCameraPosition.equals(n.globalPosition)||(this._cachedCameraPosition.copyFrom(n.globalPosition),r.audioContext.listener.setPosition(n.globalPosition.x,n.globalPosition.y,n.globalPosition.z)):r.audioContext.listener.setPosition(0,0,0);if(this.audioListenerRotationProvider){var a=this.audioListenerRotationProvider();r.audioContext.listener.setOrientation(a.x||0,a.y||0,a.z||0,0,1,0)}else n?(n.rigCameras&&n.rigCameras.length>0&&(n=n.rigCameras[0]),n.getViewMatrix().invertToRef(this._invertMatrixTemp),V.TransformNormalToRef(e._CameraDirection,this._invertMatrixTemp,this._cameraDirectionTemp),this._cameraDirectionTemp.normalize(),isNaN(this._cameraDirectionTemp.x)||isNaN(this._cameraDirectionTemp.y)||isNaN(this._cameraDirectionTemp.z)||this._cachedCameraDirection.equals(this._cameraDirectionTemp)||(this._cachedCameraDirection.copyFrom(this._cameraDirectionTemp),r.audioContext.listener.setOrientation(this._cameraDirectionTemp.x,this._cameraDirectionTemp.y,this._cameraDirectionTemp.z,0,1,0))):r.audioContext.listener.setOrientation(0,0,0,0,1,0);var s=void 0;for(s=0;s0?1/n:0,l=0;l=0&&this._scene.textures.splice(t,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){var i=this._parentContainer.textures.indexOf(this);i>-1&&this._parentContainer.textures.splice(i,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,e.prototype.dispose.call(this)},t.prototype.serialize=function(e){if(void 0===e&&(e=!1),!this.name&&!e)return null;var t=Ke.Serialize(this);return Ke.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var r=0;r=0;){var s=e[o];s<0?s=0:s>1&&(s=1),a[o]=255*s}e=a}var l=document.createElement("canvas");l.width=r,l.height=n;var c=l.getContext("2d");if(!c)return null;var u=c.createImageData(r,n);if(u.data.set(e),c.putImageData(u,0,0),i){var h=document.createElement("canvas");h.width=r,h.height=n;var d=h.getContext("2d");return d?(d.translate(0,n),d.scale(1,-1),d.drawImage(l,0,0),h.toDataURL("image/png")):null}return l.toDataURL("image/png")}function Qa(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0);var r=e.getInternalTexture();if(!r)return null;var n=e._readPixelsSync(t,i);return n?Ka(n,e.getSize(),r.invertY):null}function qa(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=0),y(this,void 0,void 0,(function(){var r,n;return b(this,(function(o){switch(o.label){case 0:return(r=e.getInternalTexture())?[4,e.readPixels(t,i)]:[2,null];case 1:return(n=o.sent())?[2,Ka(n,e.getSize(),r.invertY)]:[2,null]}}))}))}var Za={GenerateBase64StringFromPixelData:Ka,GenerateBase64StringFromTexture:Qa,GenerateBase64StringFromTextureAsync:qa},Ja=function(e){function t(i,r,n,o,a,s,l,c,h,d,p,_,m,g){void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=!1);var v,y,b,T,E,S,x,A,C,R,P,I=this;(I=e.call(this,r)||this).url=null,I.uOffset=0,I.vOffset=0,I.uScale=1,I.vScale=1,I.uAng=0,I.vAng=0,I.wAng=0,I.uRotationCenter=.5,I.vRotationCenter=.5,I.wRotationCenter=.5,I.homogeneousRotationInUVTransform=!1,I.inspectableCustomProperties=null,I._noMipmap=!1,I._invertY=!1,I._rowGenerationMatrix=null,I._cachedTextureMatrix=null,I._projectionModeMatrix=null,I._t0=null,I._t1=null,I._t2=null,I._cachedUOffset=-1,I._cachedVOffset=-1,I._cachedUScale=0,I._cachedVScale=0,I._cachedUAng=-1,I._cachedVAng=-1,I._cachedWAng=-1,I._cachedReflectionProjectionMatrixId=-1,I._cachedURotationCenter=-1,I._cachedVRotationCenter=-1,I._cachedWRotationCenter=-1,I._cachedHomogeneousRotationInUVTransform=!1,I._cachedIdentity3x2=!0,I._cachedReflectionTextureMatrix=null,I._cachedReflectionUOffset=-1,I._cachedReflectionVOffset=-1,I._cachedReflectionUScale=0,I._cachedReflectionVScale=0,I._cachedReflectionCoordinatesMode=-1,I._buffer=null,I._deleteBuffer=!1,I._format=null,I._delayedOnLoad=null,I._delayedOnError=null,I.onLoadObservable=new f,I._isBlocking=!0,I.name=i||"",I.url=i;var M=!1,O=null,D=!0;"object"==typeof n&&null!==n?(P=null!==(v=n.noMipmap)&&void 0!==v&&v,o=null!==(y=n.invertY)&&void 0!==y?y:!go.UseOpenGLOrientationForUV,a=null!==(b=n.samplingMode)&&void 0!==b?b:t.TRILINEAR_SAMPLINGMODE,s=null!==(T=n.onLoad)&&void 0!==T?T:null,l=null!==(E=n.onError)&&void 0!==E?E:null,c=null!==(S=n.buffer)&&void 0!==S?S:null,h=null!==(x=n.deleteBuffer)&&void 0!==x&&x,d=n.format,p=n.mimeType,_=n.loaderOptions,m=n.creationFlags,M=null!==(A=n.useSRGBBuffer)&&void 0!==A&&A,O=null!==(C=n.internalTexture)&&void 0!==C?C:null,D=null!==(R=n.gammaSpace)&&void 0!==R?R:D):P=!!n,I._gammaSpace=D,I._noMipmap=P,I._invertY=void 0===o?!go.UseOpenGLOrientationForUV:o,I._initialSamplingMode=a,I._buffer=c,I._deleteBuffer=h,I._mimeType=p,I._loaderOptions=_,I._creationFlags=m,I._useSRGBBuffer=M,I._forcedExtension=g,d&&(I._format=d);var N=I.getScene(),F=I._getEngine();if(!F)return I;F.onBeforeTextureInitObservable.notifyObservers(I);var L=function(){I._texture&&(I._texture._invertVScale&&(I.vScale*=-1,I.vOffset+=1),null!==I._texture._cachedWrapU&&(I.wrapU=I._texture._cachedWrapU,I._texture._cachedWrapU=null),null!==I._texture._cachedWrapV&&(I.wrapV=I._texture._cachedWrapV,I._texture._cachedWrapV=null),null!==I._texture._cachedWrapR&&(I.wrapR=I._texture._cachedWrapR,I._texture._cachedWrapR=null)),I.onLoadObservable.hasObservers()&&I.onLoadObservable.notifyObservers(I),s&&s(),!I.isBlocking&&N&&N.resetCachedMaterial()},w=function(e,i){I._loadingError=!0,I._errorObject={message:e,exception:i},l&&l(e,i),t.OnTextureLoadErrorObservable.notifyObservers(I)};if(!I.url&&!O)return I._delayedOnLoad=L,I._delayedOnError=w,I;if(I._texture=null!=O?O:I._getFromCache(I.url,P,a,I._invertY,M,I.isCube),I._texture)if(I._texture.isReady)si.SetImmediate((function(){return L()}));else{var B=I._texture.onLoadedObservable.add(L);I._texture.onErrorObservable.add((function(e){var t;w(e.message,e.exception),null===(t=I._texture)||void 0===t||t.onLoadedObservable.remove(B)}))}else if(N&&N.useDelayedTextureLoading)I.delayLoadState=u.DELAYLOADSTATE_NOTLOADED,I._delayedOnLoad=L,I._delayedOnError=w;else{try{I._texture=F.createTexture(I.url,P,I._invertY,N,a,L,w,I._buffer,void 0,I._format,I._forcedExtension,p,_,m,M)}catch(e){throw w("error loading",e),e}h&&(I._buffer=null)}return I}return m(t,e),t._CreateVideoTexture=function(e,i,r,n,o,a,s,l,c){throw void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===s&&(s={}),void 0===c&&(c=u.TEXTUREFORMAT_RGBA),He("VideoTexture")},Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mimeType",{get:function(){return this._mimeType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"invertY",{get:function(){return this._invertY},enumerable:!1,configurable:!0}),t.prototype.updateURL=function(e,t,i,r){var n=this;void 0===t&&(t=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(n)}))),this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=r,this.delayLoadState=u.DELAYLOADSTATE_NOTLOADED,i&&(this._delayedOnLoad=i),this.delayLoad()},t.prototype.delayLoad=function(){if(this.delayLoadState===u.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=u.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?si.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}},t.prototype._prepareRowForTextureGeneration=function(e,t,i,r){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,i-=this.wRotationCenter,V.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,r),r.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,r.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,r.z+=this.wRotationCenter},t.prototype.getTextureMatrix=function(e){var t=this;if(void 0===e&&(e=1),this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=z.Zero(),this._rowGenerationMatrix=new z,this._t0=V.Zero(),this._t1=V.Zero(),this._t2=V.Zero()),z.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(z.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,H.Matrix[0]),z.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,H.Matrix[1]),z.ScalingToRef(this._cachedUScale,this._cachedVScale,0,H.Matrix[2]),z.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,H.Matrix[3]),H.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(H.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(H.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(H.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),z.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));var i=this.getScene();if(!i)return this._cachedTextureMatrix;var r=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&r!==this._cachedIdentity3x2&&i.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(t)})),this._cachedTextureMatrix},t.prototype.getReflectionTextureMatrix=function(){var e=this,i=this.getScene();if(!i)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode){if(this.coordinatesMode!==t.PROJECTION_MODE)return this._cachedReflectionTextureMatrix;if(this._cachedReflectionProjectionMatrixId===i.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=z.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=z.Zero());var r=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case t.PLANAR_MODE:z.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break;case t.PROJECTION_MODE:z.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var n=i.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=n.updateFlag,n.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break;default:z.IdentityToRef(this._cachedReflectionTextureMatrix)}return r&&i.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(t){return t.hasTexture(e)})),this._cachedReflectionTextureMatrix},t.prototype.clone=function(){var e=this,i={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return Ke.Clone((function(){return new t(e._texture?e._texture.url:null,e.getScene(),i)}),this)},t.prototype.serialize=function(){var i,r,n=this.name;t.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");var o=e.prototype.serialize.call(this,t._SerializeInternalTextureUniqueId);return o?((t.SerializeBuffers||t.ForceSerializeBuffers)&&("string"==typeof this._buffer&&"data:"===this._buffer.substr(0,5)?(o.base64String=this._buffer,o.name=o.name.replace("data:","")):this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array?o.base64String="data:image/png;base64,"+xt(this._buffer):(t.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(o.base64String=!this._engine||this._engine._features.supportSyncTextureRead?Qa(this):qa(this))),o.invertY=this._invertY,o.samplingMode=this.samplingMode,o._creationFlags=this._creationFlags,o._useSRGBBuffer=this._useSRGBBuffer,t._SerializeInternalTextureUniqueId&&(o.internalTextureUniqueId=null!==(r=null===(i=this._texture)||void 0===i?void 0:i.uniqueId)&&void 0!==r?r:void 0),o.noMipmap=this._noMipmap,this.name=n,o):null},t.prototype.getClassName=function(){return"Texture"},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null},t.Parse=function(e,i,r){if(e.customType){var n=Ki.Instantiate(e.customType).Parse(e,i,r);return e.samplingMode&&n.updateSamplingMode&&n._samplingMode&&n._samplingMode!==e.samplingMode&&n.updateSamplingMode(e.samplingMode),n}if(e.isCube&&!e.isRenderTarget)return t._CubeTextureParser(e,i,r);var o,a=void 0!==e.internalTextureUniqueId;if(!e.name&&!e.isRenderTarget&&!a)return null;if(a)for(var l=0,c=i.getEngine().getLoadedTexturesCache();l0||e.name.startsWith("data:"))?e.name:r+e.name,e.url&&(e.url.startsWith("data:")||t.UseSerializedUrlIfAny)&&(m=e.url);var g={noMipmap:!c,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:function(){h(l)},internalTexture:o};l=new t(m,i,g)}return l}),e,i);return d},t.CreateFromBase64String=function(e,i,r,n,o,a,s,l,c,h,d){return void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=u.TEXTUREFORMAT_RGBA),new t("data:"+i,r,n,o,a,s,l,e,!1,c,void 0,void 0,h,d)},t.LoadFromDataString=function(e,i,r,n,o,a,s,l,c,h,d,p){return void 0===n&&(n=!1),void 0===a&&(a=!0),void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=u.TEXTUREFORMAT_RGBA),"data:"!==e.substr(0,5)&&(e="data:"+e),new t(e,r,o,a,s,l,c,i,n,h,void 0,void 0,d,p)},t.SerializeBuffers=!0,t.ForceSerializeBuffers=!1,t.OnTextureLoadErrorObservable=new f,t._SerializeInternalTextureUniqueId=!1,t._CubeTextureParser=function(e,t,i){throw He("CubeTexture")},t._CreateMirror=function(e,t,i,r){throw He("MirrorTexture")},t._CreateRenderTargetTexture=function(e,t,i,r,n){throw He("RenderTargetTexture")},t.NEAREST_SAMPLINGMODE=u.TEXTURE_NEAREST_SAMPLINGMODE,t.NEAREST_NEAREST_MIPLINEAR=u.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.BILINEAR_SAMPLINGMODE=u.TEXTURE_BILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPNEAREST=u.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TRILINEAR_SAMPLINGMODE=u.TEXTURE_TRILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPLINEAR=u.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.NEAREST_NEAREST_MIPNEAREST=u.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.NEAREST_LINEAR_MIPNEAREST=u.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.NEAREST_LINEAR_MIPLINEAR=u.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.NEAREST_LINEAR=u.TEXTURE_NEAREST_LINEAR,t.NEAREST_NEAREST=u.TEXTURE_NEAREST_NEAREST,t.LINEAR_NEAREST_MIPNEAREST=u.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.LINEAR_NEAREST_MIPLINEAR=u.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.LINEAR_LINEAR=u.TEXTURE_LINEAR_LINEAR,t.LINEAR_NEAREST=u.TEXTURE_LINEAR_NEAREST,t.EXPLICIT_MODE=u.TEXTURE_EXPLICIT_MODE,t.SPHERICAL_MODE=u.TEXTURE_SPHERICAL_MODE,t.PLANAR_MODE=u.TEXTURE_PLANAR_MODE,t.CUBIC_MODE=u.TEXTURE_CUBIC_MODE,t.PROJECTION_MODE=u.TEXTURE_PROJECTION_MODE,t.SKYBOX_MODE=u.TEXTURE_SKYBOX_MODE,t.INVCUBIC_MODE=u.TEXTURE_INVCUBIC_MODE,t.EQUIRECTANGULAR_MODE=u.TEXTURE_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MODE=u.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=u.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.CLAMP_ADDRESSMODE=u.TEXTURE_CLAMP_ADDRESSMODE,t.WRAP_ADDRESSMODE=u.TEXTURE_WRAP_ADDRESSMODE,t.MIRROR_ADDRESSMODE=u.TEXTURE_MIRROR_ADDRESSMODE,t.UseSerializedUrlIfAny=!1,v([Ie()],t.prototype,"url",void 0),v([Ie()],t.prototype,"uOffset",void 0),v([Ie()],t.prototype,"vOffset",void 0),v([Ie()],t.prototype,"uScale",void 0),v([Ie()],t.prototype,"vScale",void 0),v([Ie()],t.prototype,"uAng",void 0),v([Ie()],t.prototype,"vAng",void 0),v([Ie()],t.prototype,"wAng",void 0),v([Ie()],t.prototype,"uRotationCenter",void 0),v([Ie()],t.prototype,"vRotationCenter",void 0),v([Ie()],t.prototype,"wRotationCenter",void 0),v([Ie()],t.prototype,"homogeneousRotationInUVTransform",void 0),v([Ie()],t.prototype,"isBlocking",null),t}(Ya);function $a(e,t,i,r){var n,o=1;r===u.TEXTURETYPE_FLOAT?n=new Float32Array(t*i*4):r===u.TEXTURETYPE_HALF_FLOAT?(n=new Uint16Array(t*i*4),o=15360):n=r===u.TEXTURETYPE_UNSIGNED_INTEGER?new Uint32Array(t*i*4):new Uint8Array(t*i*4);for(var a=0;a>v,b=0;b<6;b++){var T=g[v][b];m&&(T=$a(T,y,y,n)),f.texImage2D(b,v,h,y,y,0,u,c,T)}p._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else p.updateRawCubeTexture(_,o,r,n,d);_.isReady=!0,null==t||t.removePendingData(_),_.onLoadedObservable.notifyObservers(_),_.onLoadedObservable.clear(),l&&l()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t.removePendingData(_),c&&e&&c(e.status+" "+e.statusText,i)})),_},Er.prototype.createRawTexture2DArray=es(!1),Er.prototype.createRawTexture3D=es(!0),Er.prototype.updateRawTexture2DArray=ts(!1),Er.prototype.updateRawTexture3D=ts(!0);var is=function(e){function t(t,i,r,n,o,a,s,l,c,h,d){void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===l&&(l=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=u.TEXTURETYPE_UNSIGNED_INT);var p=e.call(this,null,o,!a,s,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,h)||this;return p.format=n,p._engine?(p._engine._caps.textureFloatLinearFiltering||c!==u.TEXTURETYPE_FLOAT||(l=u.TEXTURE_NEAREST_SAMPLINGMODE),p._engine._caps.textureHalfFloatLinearFiltering||c!==u.TEXTURETYPE_HALF_FLOAT||(l=u.TEXTURE_NEAREST_SAMPLINGMODE),p._texture=p._engine.createRawTexture(t,i,r,n,a,s,l,null,c,null!=h?h:0,null!=d&&d),p.wrapU=Ja.CLAMP_ADDRESSMODE,p.wrapV=Ja.CLAMP_ADDRESSMODE,p):p}return m(t,e),t.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,this._texture._useSRGBBuffer)},t.CreateLuminanceTexture=function(e,i,r,n,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=u.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,u.TEXTUREFORMAT_LUMINANCE,n,o,a,s)},t.CreateLuminanceAlphaTexture=function(e,i,r,n,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=u.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,u.TEXTUREFORMAT_LUMINANCE_ALPHA,n,o,a,s)},t.CreateAlphaTexture=function(e,i,r,n,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=u.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,u.TEXTUREFORMAT_ALPHA,n,o,a,s)},t.CreateRGBTexture=function(e,i,r,n,o,a,s,l,c,h){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=u.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=0),void 0===h&&(h=!1),new t(e,i,r,u.TEXTUREFORMAT_RGB,n,o,a,s,l,c,h)},t.CreateRGBATexture=function(e,i,r,n,o,a,s,l,c,h){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=u.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=0),void 0===h&&(h=!1),new t(e,i,r,u.TEXTUREFORMAT_RGBA,n,o,a,s,l,c,h)},t.CreateRGBAStorageTexture=function(e,i,r,n,o,a,s,l,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=u.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),new t(e,i,r,u.TEXTUREFORMAT_RGBA,n,o,a,s,l,u.TEXTURE_CREATIONFLAG_STORAGE,c)},t.CreateRTexture=function(e,i,r,n,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Ja.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=u.TEXTURETYPE_FLOAT),new t(e,i,r,u.TEXTUREFORMAT_R,n,o,a,s,l)},t.CreateRStorageTexture=function(e,i,r,n,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Ja.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=u.TEXTURETYPE_FLOAT),new t(e,i,r,u.TEXTUREFORMAT_R,n,o,a,s,l,u.TEXTURE_CREATIONFLAG_STORAGE)},t}(Ja),rs=function(){function e(e,t,i){this.name=e,this.id=t,this.bones=[],this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=z.Identity(),this._currentRenderId=-1,this._ranges={},this._absoluteTransformIsDirty=!0,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._parentContainer=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new f,this.bones=[],this._scene=i||M.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var r=this._scene.getEngine().getCaps();this._canUseTextureForBones=r.textureFloat&&r.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,"useTextureToStoreBoneMatrices",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"Skeleton"},e.prototype.getChildren=function(){return this.bones.filter((function(e){return!e.getParent()}))},e.prototype.getTransformMatrices=function(e){if(this.needInitialSkinMatrix){if(!e)throw new Error("getTransformMatrices: When using the needInitialSkinMatrix flag, a mesh must be provided");return e._bonesTransformMatrices||this.prepare(!0),e._bonesTransformMatrices}return this._transformMatrices&&!this._isDirty||this.prepare(!this._transformMatrices),this._transformMatrices},e.prototype.getTransformMatrixTexture=function(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture},e.prototype.getScene=function(){return this._scene},e.prototype.toString=function(e){var t="Name: ".concat(this.name,", nBones: ").concat(this.bones.length);if(t+=", nAnimationRanges: ".concat(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0)for(var i=0,r=this.bones;i-1&&this._parentContainer.skeletons.splice(e,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)},e.prototype.serialize=function(){var e,t={};t.name=this.name,t.id=this.id,this.dimensionsAtRest&&(t.dimensionsAtRest=this.dimensionsAtRest.asArray()),t.bones=[],t.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var i=0;i0&&(o.animation=r.animations[0].serialize()),t.ranges=[],this._ranges){var s=this._ranges[a];if(s){var l={};l.name=a,l.from=s.from,l.to=s.to,t.ranges.push(l)}}}return t},e.Parse=function(t,i){var r,n=new e(t.name,t.id,i);for(t.dimensionsAtRest&&(n.dimensionsAtRest=V.FromArray(t.dimensionsAtRest)),n.needInitialSkinMatrix=t.needInitialSkinMatrix,r=0;r-1&&(s=n.bones[o.parentBoneIndex]);var l=o.rest?z.FromArray(o.rest):null,c=new mn(o.name,n,s,z.FromArray(o.matrix),l,null,a);void 0!==o.id&&null!==o.id&&(c.id=o.id),o.length&&(c.length=o.length),o.metadata&&(c.metadata=o.metadata),o.animation&&c.animations.push(at.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(n._hasWaitingData=!0,c._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=[],t=new Array(this.bones.length),i=0;i0},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var i=this._attachedCamera.getScene();this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==Gr.POINTERDOWN?e.type===Gr.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){if(!t._reachTargetAlpha()){var e=_t.Now,i=0;null!=t._lastFrameTime&&(i=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var r=e-t._lastInteractionTime-t._idleRotationWaitTime,n=Math.max(Math.min(r/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*n,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(i/1e3))}}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},e.prototype.resetLastInteractionTime=function(e){this._lastInteractionTime=null!=e?e:_t.Now},e.prototype._reachTargetAlpha=function(){return!(!this._attachedCamera||!this.targetAlpha)&&Math.abs(this._attachedCamera.alpha-this.targetAlpha)r.upperRadiusLimit?r.upperRadiusLimit:n),n},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var i=_t.Now-this._lastInteractionTime,r=.5*Math.PI-this._defaultElevation,n=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>n&&i>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=at.CreateAnimation("beta",at.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=at.TransitionTo("beta",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){t._clearAnimationLocks(),t.stopAllAnimations()}));o&&this._animatables.push(o)}}},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=_t.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(e.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!1,configurable:!0}),e.EasingFunction=new Nn,e.EasingMode=Rn.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),ls=function(e,t,i,r){void 0===t&&(t=new V),void 0===i&&(i=0),void 0===r&&(r=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=r},cs=function(){function e(e){this._ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new ls(V.Up()),new ls(V.Down()),new ls(V.Left()),new ls(V.Right()),new ls(V.Forward()),new ls(V.Forward().scaleInPlace(-1))],this._tmpMatrix=new z,this._tmpVector=new V,this._zeroVector=V.Zero(),this._lookAtTmpMatrix=new z}return e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach((function(i){t._target.rotationQuaternion||(t._target.rotationQuaternion=G.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),V.TransformCoordinatesToRef(i.direction,t._tmpMatrix,i.rotatedDirection),i.diff=V.GetAngleBetweenVectors(i.rotatedDirection,e,V.Cross(i.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore||e.diff1){if(e._setAllVisibility(e._ownerNode,1),e._hoverValue>e._time)return e._hoverValue=e._time,void e._detachObserver()}else if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return e._hoverValue=0,void e._detachObserver();e._attachObserver()}}}return Object.defineProperty(e.prototype,"delay",{get:function(){return this.fadeInDelay},set:function(e){this.fadeInDelay=e,this.fadeOutDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){void 0===e&&(e=!0),this._delay=e?this.fadeInDelay:this.fadeOutDelay,this._time=e?this.fadeInTime:this.fadeOutTime,this._detachObserver(),this._ownerNode&&(e&&this._ownerNode.visibility>=1||!e&&this._ownerNode.visibility<=0)||(this._hovered=e,this._hovered||(this._delay*=-1),this._ownerNode.visibility>=1?this._hoverValue=this._time:this._ownerNode.visibility<=0&&(this._hoverValue=0),this._update())},e.prototype.fadeOut=function(){this.fadeIn(!1)},e.prototype._setAllVisibility=function(e,t){var i=this;e.visibility=t,e.getChildMeshes().forEach((function(e){i._setAllVisibility(e,t)}))},e.prototype._attachObserver=function(){var e;this._onBeforeRenderObserver||(this._onBeforeRenderObserver=null===(e=this._ownerNode)||void 0===e?void 0:e.getScene().onBeforeRenderObservable.add(this._update))},e.prototype._detachObserver=function(){var e;this._onBeforeRenderObserver&&(null===(e=this._ownerNode)||void 0===e||e.getScene().onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=null)},e}(),hs=function(){function e(e,t,i,r){void 0===i&&(i=Number.MAX_VALUE),void 0===r&&(r=A),this.origin=e,this.direction=t,this.length=i,this.epsilon=r}return e.prototype.clone=function(){return new e(this.origin.clone(),this.direction.clone(),this.length)},e.prototype.intersectsBoxMinMax=function(t,i,r){void 0===r&&(r=0);var n,o,a,s,l=e._TmpVector3[0].copyFromFloats(t.x-r,t.y-r,t.z-r),c=e._TmpVector3[1].copyFromFloats(i.x+r,i.y+r,i.z+r),u=0,h=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xc.x)return!1}else if(n=1/this.direction.x,o=(l.x-this.origin.x)*n,(a=(c.x-this.origin.x)*n)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yc.y)return!1}else if(n=1/this.direction.y,o=(l.y-this.origin.y)*n,(a=(c.y-this.origin.y)*n)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zc.z)return!1}else if(n=1/this.direction.z,o=(l.z-this.origin.z)*n,(a=(c.z-this.origin.z)*n)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var i=e.center.x-this.origin.x,r=e.center.y-this.origin.y,n=e.center.z-this.origin.z,o=i*i+r*r+n*n,a=e.radius+t,s=a*a;if(o<=s)return!0;var l=i*this.direction.x+r*this.direction.y+n*this.direction.z;return!(l<0)&&o-l*l<=s},e.prototype.intersectsTriangle=function(t,i,r){var n=e._TmpVector3[0],o=e._TmpVector3[1],a=e._TmpVector3[2],s=e._TmpVector3[3],l=e._TmpVector3[4];i.subtractToRef(t,n),r.subtractToRef(t,o),V.CrossToRef(this.direction,o,a);var c=V.Dot(n,a);if(0===c)return null;var u=1/c;this.origin.subtractToRef(t,s);var h=V.Dot(s,a)*u;if(h<-this.epsilon||h>1+this.epsilon)return null;V.CrossToRef(s,n,l);var d=V.Dot(this.direction,l)*u;if(d<-this.epsilon||h+d>1+this.epsilon)return null;var p=V.Dot(o,l)*u;return p>this.length?null:new eo(1-h-d,h,p)},e.prototype.intersectsPlane=function(e){var t,i=V.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var r=V.Dot(e.normal,this.origin);return(t=(-e.d-r)/i)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case"y":return(i=(this.origin.y-t)/this.direction.y)>0?null:new V(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i);case"x":return(i=(this.origin.x-t)/this.direction.x)>0?null:new V(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i);case"z":var i;return(i=(this.origin.z-t)/this.direction.z)>0?null:new V(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t);default:return null}},e.prototype.intersectsMesh=function(t,i,r,n,o,a){void 0===n&&(n=!1),void 0===a&&(a=!1);var s=H.Matrix[0];return t.getWorldMatrix().invertToRef(s),this._tmpRay?e.TransformToRef(this,s,this._tmpRay):this._tmpRay=e.Transform(this,s),t.intersects(this._tmpRay,i,r,n,o,a)},e.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;rt.distance?1:0},e.prototype.intersectionSegment=function(t,i,r){var n=this.origin,o=H.Vector3[0],a=H.Vector3[1],s=H.Vector3[2],l=H.Vector3[3];i.subtractToRef(t,o),this.direction.scaleToRef(e._Rayl,s),n.addToRef(s,a),t.subtractToRef(n,l);var c,u,h=V.Dot(o,o),d=V.Dot(o,s),p=V.Dot(s,s),f=V.Dot(o,l),_=V.Dot(s,l),m=h*p-d*d,g=m,v=m;mg&&(c=g,u=_+d,v=p)),u<0?(u=0,-f<0?c=0:-f>h?c=g:(c=-f,g=h)):u>v&&(u=v,-f+d<0?c=0:-f+d>h?c=g:(c=-f+d,g=h));var y=Math.abs(c)0&&b<=this.length&&S.lengthSquared()=e.distance?null:c:null},pn.prototype._internalPick=function(e,t,i,r,n){for(var o=null,a=!!(this.activeCameras&&this.activeCameras.length>1&&this.cameraToUseForPointers!==this.activeCamera),s=this.cameraToUseForPointers||this.activeCamera,l=0;l1&&this.cameraToUseForPointers!==this.activeCamera),o=this.cameraToUseForPointers||this.activeCamera,a=0;a1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(e.prototype,"currentDraggingPointerID",{get:function(){return this.currentDraggingPointerId},set:function(e){this.currentDraggingPointerId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){e!=this._enabled&&this.onEnabledObservable.notifyObservers(e),this._enabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t,i){var r=this;this._scene=t.getScene(),t.isNearGrabbable=!0,this.attachedNode=t,e._PlaneScene||(this._debugMode?e._PlaneScene=this._scene:(e._PlaneScene=new pn(this._scene.getEngine(),{virtual:!0}),e._PlaneScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._PlaneScene.dispose(),e._PlaneScene=null})))),this._dragPlane=fs("pointerDragPlane",{size:this._debugMode?1:1e4,updatable:!1,sideOrientation:Fa.DOUBLESIDE},e._PlaneScene),this.lastDragPosition=new V(0,0,0);var n=i||function(e){return r.attachedNode==e||e.isDescendantOf(r.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t){if(r.enabled){if(t.type==Gr.POINTERDOWN)r.startAndReleaseDragOnPointerEvents&&!r.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&n(t.pickInfo.pickedMesh)&&-1===r._activeDragButton&&-1!==r.dragButtons.indexOf(t.event.button)&&(r._activeDragButton=t.event.button,r._activePointerInfo=t,r._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint));else if(t.type==Gr.POINTERUP)!r.startAndReleaseDragOnPointerEvents||r.currentDraggingPointerId!=t.event.pointerId||r._activeDragButton!==t.event.button&&-1!==r._activeDragButton||r.releaseDrag();else if(t.type==Gr.POINTERMOVE){var i=t.event.pointerId;if(r.currentDraggingPointerId===e._AnyMouseId&&i!==e._AnyMouseId){var o=t.event;("mouse"===o.pointerType||!r._scene.getEngine().hostInformation.isMobile&&o instanceof MouseEvent)&&(r._lastPointerRay[r.currentDraggingPointerId]&&(r._lastPointerRay[i]=r._lastPointerRay[r.currentDraggingPointerId],delete r._lastPointerRay[r.currentDraggingPointerId]),r.currentDraggingPointerId=i)}r._lastPointerRay[i]||(r._lastPointerRay[i]=new hs(new V,new V)),t.pickInfo&&t.pickInfo.ray&&(r._lastPointerRay[i].origin.copyFrom(t.pickInfo.ray.origin),r._lastPointerRay[i].direction.copyFrom(t.pickInfo.ray.direction),r.currentDraggingPointerId==i&&r.dragging&&r._moveDrag(t.pickInfo.ray))}}else r._attachedToElement&&r.releaseDrag()})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){if(r._moving&&r.moveAttached){var e=!1;ds._RemoveAndStorePivotPoint(r.attachedNode),r._targetPosition.subtractToRef(r.attachedNode.absolutePosition,r._tmpVector),r._tmpVector.scaleInPlace(r.dragDeltaRatio),r.attachedNode.getAbsolutePosition().addToRef(r._tmpVector,r._tmpVector),r.validateDrag(r._tmpVector)&&(r.attachedNode.setAbsolutePosition(r._tmpVector),e=!0),ds._RestorePivotPoint(r.attachedNode),e&&r.attachedNode.computeWorldMatrix()}}))},e.prototype.releaseDrag=function(){if(this.dragging&&(this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerId,pointerInfo:this._activePointerInfo})),this.currentDraggingPointerId=-1,this._activeDragButton=-1,this._activePointerInfo=null,this._moving=!1,this.detachCameraControls&&this._attachedToElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera){if("ArcRotateCamera"===this._scene.activeCamera.getClassName()){var e=this._scene.activeCamera;e.attachControl(!e.inputs||e.inputs.noPreventDefault,e._useCtrlForPanning,e._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},e.prototype.startDrag=function(t,i,r){void 0===t&&(t=e._AnyMouseId),this._startDrag(t,i,r);var n=this._lastPointerRay[t];t===e._AnyMouseId&&(n=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),n&&this._moveDrag(n)},e.prototype._startDrag=function(e,t,i){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){ds._RemoveAndStorePivotPoint(this.attachedNode),t?(this._startDragRay.direction.copyFrom(t.direction),this._startDragRay.origin.copyFrom(t.origin)):(this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),this._tmpVector.subtractToRef(this._scene.activeCamera.position,this._startDragRay.direction)),this._updateDragPlanePosition(this._startDragRay,i||this._tmpVector);var r=this._pickWithRayOnDragPlane(this._startDragRay);r?(this.dragging=!0,this.currentDraggingPointerId=e,this.lastDragPosition.copyFrom(r),this.onDragStartObservable.notifyObservers({dragPlanePoint:r,pointerId:this.currentDraggingPointerId,pointerInfo:this._activePointerInfo}),this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()),this.detachCameraControls&&this._scene.activeCamera&&this._scene.activeCamera.inputs&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedToElement?(this._scene.activeCamera.detachControl(),this._attachedToElement=!0):this._attachedToElement=!1)):this.releaseDrag(),ds._RestorePivotPoint(this.attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){ds._RemoveAndStorePivotPoint(this.attachedNode),this.updateDragPlane&&this._updateDragPlanePosition(e,t);var i=0;this._options.dragAxis?(this.useObjectOrientationForDragging?V.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=V.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(i,this._dragDelta)):(i=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:i,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerId,pointerInfo:this._activePointerInfo}),this.lastDragPosition.copyFrom(t),ds._RestorePivotPoint(this.attachedNode)}},e.prototype._pickWithRayOnDragPlane=function(e){if(!e)return null;var t=Math.acos(V.Dot(this._dragPlane.forward,e.direction));if(t>Math.PI/2&&(t=Math.PI-t),this.maxDragAngle>0&&t>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(e.direction),this.attachedNode.absolutePosition.subtractToRef(e.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*V.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var i=V.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-i,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var r=this._dragPlane.forward,n=this._dragPlane.position,o=e.direction.dot(r);if(Math.abs(o).999?Math.abs(V.Dot(V.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(V.Right()):this._lookAt.copyFrom(V.UpReadOnly):(V.CrossToRef(this._localAxis,this._pointC,this._lookAt),V.CrossToRef(this._localAxis,this._lookAt,this._lookAt),this._lookAt.normalize()),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrientationForDragging?V.TransformCoordinatesToRef(this._options.dragPlaneNormal,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(e.origin)),this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition()),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._lastPointerRay={},this.attachedNode&&(this.attachedNode.isNearGrabbable=!1),this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this._dragPlane&&this._dragPlane.dispose(),this.releaseDrag()},e._AnyMouseId=-2,e}(),vs=function(){function e(){this._startDistance=0,this._initialScale=new V(0,0,0),this._targetScale=new V(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new gs({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new gs({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},e.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add((function(){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerId==t._dragBehaviorB.currentDraggingPointerId?t._dragBehaviorA.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),this._dragBehaviorB.onDragStartObservable.add((function(){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerId==t._dragBehaviorB.currentDraggingPointerId?t._dragBehaviorB.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(e){e.onDragObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var e=t._getCurrentDistance()/t._startDistance;t._initialScale.scaleToRef(e,t._targetScale)}}))})),e.addBehavior(this._dragBehaviorA),e.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var i=t._targetScale.subtract(e.scaling).scaleInPlace(.1);i.length()>.01&&e.scaling.addInPlace(i)}}))},e.prototype.detach=function(){var e=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(t){t.onDragStartObservable.clear(),t.onDragObservable.clear(),e._ownerNode.removeBehavior(t)}))},e}(),ys=function(){function e(){this._attachedToElement=!1,this._virtualMeshesInfo={},this._tmpVector=new V,this._tmpQuaternion=new G,this._dragType={NONE:0,DRAG:1,DRAG_WITH_CONTROLLER:2,NEAR_DRAG:3},this._moving=!1,this._dragging=this._dragType.NONE,this.draggableMeshes=null,this.zDragFactor=3,this.currentDraggingPointerIds=[],this.detachCameraControls=!0,this.onDragStartObservable=new f,this.onDragObservable=new f,this.onDragEndObservable=new f,this.allowMultiPointer=!0}return Object.defineProperty(e.prototype,"currentDraggingPointerId",{get:function(){return void 0!==this.currentDraggingPointerIds[0]?this.currentDraggingPointerIds[0]:-1},set:function(e){this.currentDraggingPointerIds[0]=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentDraggingPointerID",{get:function(){return this.currentDraggingPointerId},set:function(e){this.currentDraggingPointerId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"BaseSixDofDrag"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isMoving",{get:function(){return this._moving},enumerable:!1,configurable:!0}),e.prototype.init=function(){},Object.defineProperty(e.prototype,"_pointerCamera",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!1,configurable:!0}),e.prototype._createVirtualMeshInfo=function(){var t=new Uo("",e._virtualScene);t.rotationQuaternion=new G;var i=new Uo("",e._virtualScene);i.rotationQuaternion=new G;var r=new Uo("",e._virtualScene);return r.rotationQuaternion=new G,{dragging:!1,moving:!1,dragMesh:t,originMesh:i,pivotMesh:r,startingPivotPosition:new V,startingPivotOrientation:new G,startingPosition:new V,startingOrientation:new G,lastOriginPosition:new V,lastDragPosition:new V}},e.prototype._resetVirtualMeshesPosition=function(){for(var e=0;eh&&(h=Math.min(.01-u,0)),c.scaleInPlace(h),c.addToRef(n.pivotMesh.absolutePosition,this._tmpVector),n.pivotMesh.setAbsolutePosition(this._tmpVector),c.addToRef(n.dragMesh.absolutePosition,this._tmpVector),n.dragMesh.setAbsolutePosition(this._tmpVector)}},e.prototype.attach=function(t){var i=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new pn(this._scene.getEngine(),{virtual:!0}),e._virtualScene.detachControl()),this._pointerObserver=this._scene.onPointerObservable.add((function(e){var t=e.event.pointerId;i._virtualMeshesInfo[t]||(i._virtualMeshesInfo[t]=i._createVirtualMeshInfo());var r,n=i._virtualMeshesInfo[t],o="xr-near"===e.event.pointerType||"xr"===e.event.pointerType;if(e.type==Gr.POINTERDOWN){if(!n.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.pickedPoint&&e.pickInfo.ray&&(!o||e.pickInfo.aimTransform)&&(r=e.pickInfo.pickedMesh,i._ownerNode===r||r.isDescendantOf(i._ownerNode)&&(!i.draggableMeshes||-1!==i.draggableMeshes.indexOf(r)))){if((!i.allowMultiPointer||o)&&i.currentDraggingPointerIds.length>0)return;!i._pointerCamera||i._pointerCamera.cameraRigMode!==$n.RIG_MODE_NONE||i._pointerCamera._isLeftCamera||i._pointerCamera._isRightCamera||e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),i._ownerNode.computeWorldMatrix(!0);var a=i._virtualMeshesInfo[t];o?(i._dragging=e.pickInfo.originMesh?i._dragType.NEAR_DRAG:i._dragType.DRAG_WITH_CONTROLLER,a.originMesh.position.copyFrom(e.pickInfo.aimTransform.position),i._dragging===i._dragType.NEAR_DRAG&&e.pickInfo.gripTransform?a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.gripTransform.rotationQuaternion):a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.aimTransform.rotationQuaternion)):(i._dragging=i._dragType.DRAG,a.originMesh.position.copyFrom(e.pickInfo.ray.origin)),a.lastOriginPosition.copyFrom(a.originMesh.position),a.dragMesh.position.copyFrom(e.pickInfo.pickedPoint),a.lastDragPosition.copyFrom(e.pickInfo.pickedPoint),a.pivotMesh.position.copyFrom(i._ownerNode.getAbsolutePivotPoint()),a.pivotMesh.rotationQuaternion.copyFrom(i._ownerNode.absoluteRotationQuaternion),a.startingPosition.copyFrom(a.dragMesh.position),a.startingPivotPosition.copyFrom(a.pivotMesh.position),a.startingOrientation.copyFrom(a.dragMesh.rotationQuaternion),a.startingPivotOrientation.copyFrom(a.pivotMesh.rotationQuaternion),o?(a.originMesh.addChild(a.dragMesh),a.originMesh.addChild(a.pivotMesh)):a.originMesh.lookAt(a.dragMesh.position),a.dragging=!0,-1===i.currentDraggingPointerIds.indexOf(t)&&i.currentDraggingPointerIds.push(t),i.detachCameraControls&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.inputs&&i._pointerCamera.inputs.attachedToElement?(i._pointerCamera.detachControl(),i._attachedToElement=!0):i.allowMultiPointer&&0!==i.currentDraggingPointerIds.length||(i._attachedToElement=!1)),i._targetDragStart(a.pivotMesh.position,a.pivotMesh.rotationQuaternion,t),i.onDragStartObservable.notifyObservers({position:a.pivotMesh.position})}}else if(e.type==Gr.POINTERUP||e.type==Gr.POINTERDOUBLETAP){var s=i.currentDraggingPointerIds.indexOf(t);n.dragging=!1,-1!==s&&(i.currentDraggingPointerIds.splice(s,1),0===i.currentDraggingPointerIds.length&&(i._moving=!1,i._dragging=i._dragType.NONE,i.detachCameraControls&&i._attachedToElement&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._reattachCameraControls(),i._attachedToElement=!1)),n.originMesh.removeChild(n.dragMesh),n.originMesh.removeChild(n.pivotMesh),i._targetDragEnd(t),i.onDragEndObservable.notifyObservers({}))}else if(e.type==Gr.POINTERMOVE&&-1!==(s=i.currentDraggingPointerIds.indexOf(t))&&n.dragging&&e.pickInfo&&(e.pickInfo.ray||e.pickInfo.aimTransform)){var l=i.zDragFactor;(i.currentDraggingPointerIds.length>1||e.pickInfo.originMesh)&&(l=0),i._ownerNode.computeWorldMatrix(!0),o?i._pointerUpdateXR(e.pickInfo.aimTransform,e.pickInfo.gripTransform,t,l):i._pointerUpdate2D(e.pickInfo.ray,t,l),i._tmpQuaternion.copyFrom(n.startingPivotOrientation),i._tmpQuaternion.x=-i._tmpQuaternion.x,i._tmpQuaternion.y=-i._tmpQuaternion.y,i._tmpQuaternion.z=-i._tmpQuaternion.z,n.pivotMesh.absoluteRotationQuaternion.multiplyToRef(i._tmpQuaternion,i._tmpQuaternion),n.pivotMesh.absolutePosition.subtractToRef(n.startingPivotPosition,i._tmpVector),i.onDragObservable.notifyObservers({delta:i._tmpVector,position:n.pivotMesh.position,pickInfo:e.pickInfo}),i._targetDrag(i._tmpVector,i._tmpQuaternion,t),n.lastDragPosition.copyFrom(n.dragMesh.absolutePosition),i._moving=!0}}))},e.prototype._applyZOffset=function(e,t,i){e.position.z-=e.position.z<1?t*i:t*i*e.position.z,e.position.z<0&&(e.position.z=0)},e.prototype._targetDragStart=function(e,t,i){},e.prototype._targetDrag=function(e,t,i){},e.prototype._targetDragEnd=function(e){},e.prototype._reattachCameraControls=function(){if(this._pointerCamera)if("ArcRotateCamera"===this._pointerCamera.getClassName()){var e=this._pointerCamera;e.attachControl(!e.inputs||e.inputs.noPreventDefault,e._useCtrlForPanning,e._panningMouseButton)}else this._pointerCamera.attachControl(!this._pointerCamera.inputs||this._pointerCamera.inputs.noPreventDefault)},e.prototype.detach=function(){for(var e in this._scene&&(this.detachCameraControls&&this._attachedToElement&&this._pointerCamera&&!this._pointerCamera.leftCamera&&(this._reattachCameraControls(),this._attachedToElement=!1),this._scene.onPointerObservable.remove(this._pointerObserver)),this._virtualMeshesInfo)this._virtualMeshesInfo[e].originMesh.dispose(),this._virtualMeshesInfo[e].dragMesh.dispose();this.onDragEndObservable.clear(),this.onDragObservable.clear(),this.onDragStartObservable.clear()},e}(),bs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._sceneRenderObserver=null,t._targetPosition=new V(0,0,0),t._targetOrientation=new G,t._targetScaling=new V(1,1,1),t._startingPosition=new V(0,0,0),t._startingOrientation=new G,t._startingScaling=new V(1,1,1),t.onPositionChangedObservable=new f,t.dragDeltaRatio=.2,t.rotateDraggedObject=!0,t.rotateAroundYOnly=!1,t.rotateWithMotionController=!0,t.disableMovement=!1,t.faceCameraOnDragStart=!1,t}return m(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!1,configurable:!0}),t.prototype.attach=function(t){var i=this;e.prototype.attach.call(this,t),t.isNearGrabbable=!0,t.getChildMeshes().forEach((function(e){e.isNearGrabbable=!0})),this._virtualTransformNode=new Fo("virtual_sixDof",ys._virtualScene),this._virtualTransformNode.rotationQuaternion=G.Identity(),this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(1===i.currentDraggingPointerIds.length&&i._moving&&!i.disableMovement){var e=H.Vector3[0];e.copyFrom(i._targetPosition).subtractInPlace(t.absolutePosition).scaleInPlace(i.dragDeltaRatio);var r=H.Vector3[1];if(r.copyFrom(e),t.parent){var n=H.Matrix[0];t.parent.absoluteRotationQuaternion.toRotationMatrix(n),n.invert(),V.TransformNormalToRef(e,n,r)}if(t.position.addInPlace(r),i.onPositionChangedObservable.notifyObservers({position:t.absolutePosition}),!t.parent||t.parent.scaling&&!t.parent.scaling.isNonUniformWithinEpsilon(.001)){var o=H.Quaternion[0];if(o.copyFrom(i._targetOrientation),t.parent){var a=H.Quaternion[0];a.copyFrom(t.parent.absoluteRotationQuaternion),a.invertInPlace(),a.multiplyToRef(i._targetOrientation,o)}G.SlerpToRef(t.rotationQuaternion,o,i.dragDeltaRatio,t.rotationQuaternion)}}}))},t.prototype._getPositionOffsetAround=function(e,t,i){var r=H.Matrix[0],n=H.Matrix[1],o=H.Matrix[2],a=H.Matrix[3],s=H.Matrix[4];return z.TranslationToRef(e.x,e.y,e.z,r),z.TranslationToRef(-e.x,-e.y,-e.z,n),z.FromQuaternionToRef(i,o),z.ScalingToRef(t,t,t,a),n.multiplyToRef(o,s),s.multiplyToRef(a,s),s.multiplyToRef(r,s),s.getTranslation()},t.prototype._onePointerPositionUpdated=function(e,t){H.Vector3[0].setAll(0),this._dragging===this._dragType.DRAG?this.rotateDraggedObject&&(this.rotateAroundYOnly?G.RotationYawPitchRollToRef(t.toEulerAngles().y,0,0,H.Quaternion[0]):H.Quaternion[0].copyFrom(t),H.Quaternion[0].multiplyToRef(this._startingOrientation,this._targetOrientation)):(this._dragging===this._dragType.NEAR_DRAG||this._dragging===this._dragType.DRAG_WITH_CONTROLLER&&this.rotateWithMotionController)&&t.multiplyToRef(this._startingOrientation,this._targetOrientation),this._targetPosition.copyFrom(this._startingPosition).addInPlace(e)},t.prototype._twoPointersPositionUpdated=function(){var e=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition,t=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition,i=H.Vector3[0];e.addToRef(t,i),i.scaleInPlace(.5);var r=H.Vector3[1];t.subtractToRef(e,r);var n=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition,o=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition,a=H.Vector3[2];n.addToRef(o,a),a.scaleInPlace(.5);var s=H.Vector3[3];o.subtractToRef(n,s);var l=s.length()/r.length(),c=a.subtract(i),u=G.FromEulerAngles(0,V.GetAngleBetweenVectorsOnPlane(r.normalize(),s.normalize(),V.UpReadOnly),0),h=this._ownerNode.parent;this._ownerNode.setParent(null);var d=this._getPositionOffsetAround(i.subtract(this._virtualTransformNode.getAbsolutePivotPoint()),l,u);this._virtualTransformNode.rotationQuaternion.multiplyToRef(u,this._ownerNode.rotationQuaternion),this._virtualTransformNode.scaling.scaleToRef(l,this._ownerNode.scaling),this._virtualTransformNode.position.addToRef(c.addInPlace(d),this._ownerNode.position),this.onPositionChangedObservable.notifyObservers({position:this._ownerNode.position}),this._ownerNode.setParent(h)},t.prototype._targetDragStart=function(){var e=this.currentDraggingPointerIds.length;this._ownerNode.rotationQuaternion||(this._ownerNode.rotationQuaternion=G.RotationYawPitchRoll(this._ownerNode.rotation.y,this._ownerNode.rotation.x,this._ownerNode.rotation.z));var t=this._ownerNode.getAbsolutePivotPoint();if(1===e){if(this._targetPosition.copyFrom(this._ownerNode.absolutePosition),this._targetOrientation.copyFrom(this._ownerNode.absoluteRotationQuaternion),this._targetScaling.copyFrom(this._ownerNode.absoluteScaling),this.faceCameraOnDragStart&&this._scene.activeCamera){var i=H.Vector3[0];this._scene.activeCamera.position.subtractToRef(t,i),i.normalize();var r=H.Quaternion[0];this._scene.useRightHandedSystem?G.FromLookDirectionRHToRef(i,new V(0,1,0),r):G.FromLookDirectionLHToRef(i,new V(0,1,0),r),r.normalize(),G.RotationYawPitchRollToRef(r.toEulerAngles().y,0,0,H.Quaternion[0]),this._targetOrientation.copyFrom(H.Quaternion[0])}this._startingPosition.copyFrom(this._targetPosition),this._startingOrientation.copyFrom(this._targetOrientation),this._startingScaling.copyFrom(this._targetScaling)}else 2===e&&(this._virtualTransformNode.setPivotPoint(new V(0,0,0),dn.LOCAL),this._virtualTransformNode.position.copyFrom(this._ownerNode.absolutePosition),this._virtualTransformNode.scaling.copyFrom(this._ownerNode.absoluteScaling),this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.absoluteRotationQuaternion),this._virtualTransformNode.setPivotPoint(t,dn.WORLD),this._resetVirtualMeshesPosition())},t.prototype._targetDrag=function(e,t){1===this.currentDraggingPointerIds.length?this._onePointerPositionUpdated(e,t):2===this.currentDraggingPointerIds.length&&this._twoPointersPositionUpdated()},t.prototype._targetDragEnd=function(){if(1===this.currentDraggingPointerIds.length){this._resetVirtualMeshesPosition();var e=this.faceCameraOnDragStart;this.faceCameraOnDragStart=!1,this._targetDragStart(),this.faceCameraOnDragStart=e}},t.prototype.detach=function(){e.prototype.detach.call(this),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualTransformNode&&this._virtualTransformNode.dispose()},t}(ys),Ts=function(){function e(){this._attachPointLocalOffset=new V,this._workingPosition=new V,this._workingQuaternion=new G,this._lastTick=-1,this._hit=!1,this.hitNormalOffset=.05,this.meshes=[],this.interpolatePose=!0,this.lerpTime=250,this.keepOrientationVertical=!0,this.enabled=!0,this.maxStickingDistance=.8}return Object.defineProperty(e.prototype,"name",{get:function(){return"SurfaceMagnetism"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e,t){this._attachedMesh=e,this._scene=t||e.getScene(),this._attachedMesh.rotationQuaternion||(this._attachedMesh.rotationQuaternion=G.RotationYawPitchRoll(this._attachedMesh.rotation.y,this._attachedMesh.rotation.x,this._attachedMesh.rotation.z)),this.updateAttachPoint(),this._workingPosition.copyFrom(this._attachedMesh.position),this._workingQuaternion.copyFrom(this._attachedMesh.rotationQuaternion),this._addObservables()},e.prototype.detach=function(){this._attachedMesh=null,this._removeObservables()},e.prototype._getTargetPose=function(e){if(!this._attachedMesh)return null;if(e&&e.hit){var t=e.getNormal(!0,!0),i=e.pickedPoint;if(!t||!i)return null;t.normalize();var r=H.Vector3[0];return r.copyFrom(t),r.scaleInPlace(this.hitNormalOffset),r.addInPlace(i),this._attachedMesh.parent&&(H.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),V.TransformNormalToRef(r,H.Matrix[0],r)),{position:r,quaternion:G.RotationYawPitchRoll(-Math.atan2(t.x,-t.z),this.keepOrientationVertical?0:Math.atan2(t.y,Math.sqrt(t.z*t.z+t.x*t.x)),0)}}return null},e.prototype.updateAttachPoint=function(){this._getAttachPointOffsetToRef(this._attachPointLocalOffset)},e.prototype.findAndUpdateTarget=function(e){if(this._hit=!1,!e.ray)return!1;var t=e.ray.intersectsMeshes(this.meshes)[0];if(this._attachedMesh&&t&&t.hit&&t.pickedMesh){var i=this._getTargetPose(t);i&&V.Distance(this._attachedMesh.position,i.position)c&&(G.RotationAxisToRef(r,-l+c,a),t.rotateByQuaternionToRef(a,t),o=!0)}var u=this._angleBetweenVectorAndPlane(t,r)*(this._scene.useRightHandedSystem?-1:1),h=this.maxViewHorizontalDegrees*Math.PI/180*.5;return u<-h?(G.RotationAxisToRef(n,-u-h,a),t.rotateByQuaternionToRef(a,t),o=!0):u>h&&(G.RotationAxisToRef(n,-u+h,a),t.rotateByQuaternionToRef(a,t),o=!0),o},e.prototype._orientationClamp=function(e,t){var i,r=this._tmpVectors[0];r.copyFrom(e).scaleInPlace(-1).normalize();var n=this._tmpVectors[1],o=this._tmpVectors[2];n.copyFromFloats(0,1,0),V.CrossToRef(r,n,o);var a=o.length();athis.orientToCameraDeadzoneDegrees},e.prototype._updateLeashing=function(e){if(this.attachedNode&&this._enabled){var t=this.attachedNode.parent;this.attachedNode.setParent(null);var i=this.attachedNode.getWorldMatrix(),r=this._workingPosition,n=this._workingQuaternion,o=this.attachedNode.getPivotPoint(),a=this._tmpInvertView;a.copyFrom(e.getViewMatrix()),a.invert(),V.TransformCoordinatesToRef(o,i,r);var s=this._tmpPosition;s.copyFromFloats(0,0,0),V.TransformCoordinatesToRef(s,i,s),s.scaleInPlace(-1).subtractInPlace(o),r.subtractInPlace(e.globalPosition),this.ignoreCameraPitchAndRoll&&this._applyPitchOffset(a);var l=!1,c=this._tmpForward;c.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),V.TransformNormalToRef(c,a,c);var u=this._tmpNodeForward;if(u.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),V.TransformNormalToRef(u,i,u),this._recenterNextUpdate)r.copyFrom(c).scaleInPlace(this.defaultDistance);else if(this.ignoreAngleClamp){var h=r.length();r.copyFrom(c).scaleInPlace(h)}else l=this._angularClamp(a,r);var d=!1;this.ignoreDistanceClamp||(d=this._distanceClamp(r,l),this._applyVerticalClamp(r)),this.useFixedVerticalOffset&&(r.y=s.y-e.globalPosition.y+this.fixedVerticalOffset),(l||d||this._passedOrientationDeadzone(r,u)||this._recenterNextUpdate)&&this._orientationClamp(r,n),this._workingPosition.subtractInPlace(o),this._recenterNextUpdate=!1,this.attachedNode.setParent(t)}},e.prototype._updateTransformToGoal=function(e){if(this.attachedNode&&this.followedCamera&&this._enabled){this.attachedNode.rotationQuaternion||(this.attachedNode.rotationQuaternion=G.Identity());var t=this.attachedNode.parent;if(this.attachedNode.setParent(null),!this.interpolatePose)return this.attachedNode.position.copyFrom(this.followedCamera.globalPosition).addInPlace(this._workingPosition),void this.attachedNode.rotationQuaternion.copyFrom(this._workingQuaternion);var i=new V;i.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),V.SmoothToRef(i,this._workingPosition,e,this.lerpTime,i),i.addInPlace(this.followedCamera.globalPosition),this.attachedNode.position.copyFrom(i);var r=new G;r.copyFrom(this.attachedNode.rotationQuaternion),G.SmoothToRef(r,this._workingQuaternion,e,this.lerpTime,this.attachedNode.rotationQuaternion),this.attachedNode.setParent(t)}},e.prototype._addObservables=function(){var e=this;this._lastTick=Date.now(),this._onBeforeRender=this._scene.onBeforeRenderObservable.add((function(){if(e.followedCamera){var t=Date.now();e._updateLeashing(e.followedCamera),e._updateTransformToGoal(t-e._lastTick),e._lastTick=t}}))},e.prototype._removeObservables=function(){this._onBeforeRender&&this._scene.onBeforeRenderObservable.remove(this._onBeforeRender)},e}(),Ss=function(){function e(){}return e.ANCHOR_SYSTEM="xr-anchor-system",e.BACKGROUND_REMOVER="xr-background-remover",e.HIT_TEST="xr-hit-test",e.MESH_DETECTION="xr-mesh-detection",e.PHYSICS_CONTROLLERS="xr-physics-controller",e.PLANE_DETECTION="xr-plane-detection",e.POINTER_SELECTION="xr-controller-pointer-selection",e.TELEPORTATION="xr-controller-teleportation",e.FEATURE_POINTS="xr-feature-points",e.HAND_TRACKING="xr-hand-tracking",e.IMAGE_TRACKING="xr-image-tracking",e.NEAR_INTERACTION="xr-near-interaction",e.DOM_OVERLAY="xr-dom-overlay",e.MOVEMENT="xr-controller-movement",e.LIGHT_ESTIMATION="xr-light-estimation",e.EYE_TRACKING="xr-eye-tracking",e.WALKING_LOCOMOTION="xr-walking-locomotion",e.LAYERS="xr-layers",e.DEPTH_SENSING="xr-depth-sensing",e.SPACE_WARP="xr-space-warp",e.RAW_CAMERA_ACCESS="xr-raw-camera-access",e}(),xs=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];!i.enabled||i.featureImplementation.attached||i.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];i.enabled&&i.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,i,r){void 0===i&&(i=1),void 0===r&&(r=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:i},i>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=i),r&&(this._AvailableFeatures[e].stable=i),this._AvailableFeatures[e][i]=t},e.ConstructFeature=function(e,t,i,r){void 0===t&&(t=1);var n=this._AvailableFeatures[e][t];if(!n)throw new Error("feature not found");return n(i,r)},e.GetAvailableFeatures=function(){return Object.keys(this._AvailableFeatures)},e.GetAvailableVersions=function(e){return Object.keys(this._AvailableFeatures[e])},e.GetLatestVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].latest||-1},e.GetStableVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].stable||-1},e.prototype.attachFeature=function(e){var t=this._features[e];t&&t.enabled&&!t.featureImplementation.attached&&(t.featureImplementation.attach()||rr.Warn("Feature ".concat(e," failed to attach")))},e.prototype.detachFeature=function(e){var t=this._features[e];t&&t.featureImplementation.attached&&(t.featureImplementation.detach()||rr.Warn("Feature ".concat(e," failed to detach")))},e.prototype.disableFeature=function(e){var t="string"==typeof e?e:e.Name,i=this._features[t];return!(!i||!i.enabled||(i.enabled=!1,this.detachFeature(t),i.featureImplementation.dispose(),delete this._features[t],0))},e.prototype.dispose=function(){var e=this;this.getEnabledFeatures().forEach((function(t){e.disableFeature(t)}))},e.prototype.enableFeature=function(t,i,r,n,o){var a=this;void 0===i&&(i="latest"),void 0===r&&(r={}),void 0===n&&(n=!0),void 0===o&&(o=!0);var s="string"==typeof t?t:t.Name,l=0;if("string"==typeof i){if(!i)throw new Error("Error in provided version - ".concat(s," (").concat(i,")"));if(-1===(l="stable"===i?e.GetStableVersionOfFeature(s):"latest"===i?e.GetLatestVersionOfFeature(s):+i)||isNaN(l))throw new Error("feature not found - ".concat(s," (").concat(i,")"))}else l=i;var c=e._ConflictingFeatures[s];if(void 0!==c&&-1!==this.getEnabledFeatures().indexOf(c))throw new Error("Feature ".concat(s," cannot be enabled while ").concat(c," is enabled."));var u=this._features[s],h=e.ConstructFeature(s,l,this._xrSessionManager,r);if(!h)throw new Error("feature not found - ".concat(s));u&&this.disableFeature(s);var d=h();if(d.dependsOn){var p=d.dependsOn.every((function(e){return!!a._features[e]}));if(!p)throw new Error("Dependant features missing. Make sure the following features are enabled - ".concat(d.dependsOn.join(", ")))}if(d.isCompatible())return this._features[s]={featureImplementation:d,enabled:!0,version:l,required:o},n?this._xrSessionManager.session&&!this._features[s].featureImplementation.attached&&this.attachFeature(s):this._features[s].featureImplementation.disableAutoAttach=!0,this._features[s].featureImplementation;if(o)throw new Error("required feature not compatible");return rr.Warn("Feature ".concat(s," not compatible with the current environment/browser and was not enabled.")),d},e.prototype.getEnabledFeature=function(e){return this._features[e]&&this._features[e].featureImplementation},e.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},e.prototype._extendXRSessionInitObject=function(e){return y(this,void 0,void 0,(function(){var t,i,r,n,o,a,s;return b(this,(function(l){switch(l.label){case 0:t=this.getEnabledFeatures(),i=0,r=t,l.label=1;case 1:return i100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=G.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new G),this._options.mass=void 0===r.mass?0:r.mass,this._options.friction=void 0===r.friction?.2:r.friction,this._options.restitution=void 0===r.restitution?.2:r.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===r.pressure?200:r.pressure,this._options.stiffness=void 0===r.stiffness?1:r.stiffness,this._options.velocityIterations=void 0===r.velocityIterations?20:r.velocityIterations,this._options.positionIterations=void 0===r.positionIterations?20:r.positionIterations,this._options.fixedPoints=void 0===r.fixedPoints?0:r.fixedPoints,this._options.margin=void 0===r.margin?0:r.margin,this._options.damping=void 0===r.damping?0:r.damping,this._options.path=void 0===r.path?null:r.path,this._options.shape=void 0===r.shape?null:r.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&ae.Warn("You must affect impostors to children before affecting impostor to parent.")):ae.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):ae.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pressure",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.setBodyPressure?e.getBodyPressure(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPressure&&t.setBodyPressure(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stiffness",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyStiffness?e.getBodyStiffness(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyStiffness&&t.setBodyStiffness(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"velocityIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyVelocityIterations?e.getBodyVelocityIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyVelocityIterations&&t.setBodyVelocityIterations(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyPositionIterations?e.getBodyPositionIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPositionIterations&&t.setBodyPositionIterations(this,e)}},enumerable:!1,configurable:!0}),e.prototype._init=function(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this._isDisposed||this.parent&&!this._options.ignoreParent||this._physicsEngine.addImpostor(this))},e.prototype._getPhysicsParent=function(){return this.object.parent instanceof Uo?this.object.parent.physicsImpostor:null},e.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&(!this._parent||!!this._options.ignoreParent)},e.prototype.setScalingUpdated=function(){this.forceUpdate()},e.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(e.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtents=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion,i=this.object.scaling.clone();this.object.rotationQuaternion=e.IDENTITY_QUATERNION;var r=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);r&&r.decompose(i,void 0,void 0);var n=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);return n.x=Math.abs(n.x),n.y=Math.abs(n.y),n.z=Math.abs(n.z),this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),n}return e.DEFAULT_OBJECT_SIZE},e.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},e.prototype.getParam=function(e){return this._options[e]},e.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},e.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},e.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):V.Zero()},e.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},e.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):V.Zero()},e.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},e.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},e.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},e.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):ae.Warn("Function to remove was not found")},e.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},e.prototype.unregisterAfterPhysicsStep=function(e){var t=this._onAfterPhysicsStepCallbacks.indexOf(e);t>-1?this._onAfterPhysicsStepCallbacks.splice(t,1):ae.Warn("Function to remove was not found")},e.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e],r=-1;this._onPhysicsCollideCallbacks.some((function(e,n){if(e.callback===t&&e.otherImpostors.length===i.length){var o=e.otherImpostors.every((function(e){return i.indexOf(e)>-1}));return o&&(r=n),o}return!1}))?this._onPhysicsCollideCallbacks.splice(r,1):ae.Warn("Function to remove was not found")},e.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):G.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat},e.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},e.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},e.prototype.createJoint=function(e,t,i){var r=new Cs(t,i);return this.addJoint(e,r),this},e.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},e.prototype.addAnchor=function(e,t,i,r,n){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,i,r,n),this):this},e.prototype.addHook=function(e,t,i,r){if(!this._physicsEngine)return this;var n=this._physicsEngine.getPhysicsPlugin();return n.appendAnchor?(this._physicsEngine&&n.appendHook(this,e,t,i,r),this):this},e.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},e.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},e.prototype.clone=function(t){return t?new e(t,this.type,this._options,this._scene):null},e.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},e.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},e.prototype.setDeltaRotation=function(e){this._deltaRotation||(this._deltaRotation=new G),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},e.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},e.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},e.prototype.syncBoneWithImpostor=function(t,i,r,n,o){var a=e._TmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var l=e._TmpQuat;s.rotationQuaternion.multiplyToRef(o,l),t.setRotationQuaternion(l,dn.WORLD,i)}else t.setRotationQuaternion(s.rotationQuaternion,dn.WORLD,i);a.x=0,a.y=0,a.z=0,r&&(a.x=r.x,a.y=r.y,a.z=r.z,t.getDirectionToRef(a,i,a),null==n&&(n=r.length()),a.x*=n,a.y*=n,a.z*=n),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,i)):(i.setAbsolutePosition(s.getAbsolutePosition()),i.position.x-=a.x,i.position.y-=a.y,i.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,i,r,n,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var l=e._TmpQuat;t.getRotationQuaternionToRef(dn.WORLD,i,l),l.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(dn.WORLD,i,s.rotationQuaternion);var c=e._TmpVecs[0],u=e._TmpVecs[1];a||((a=e._TmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,i,u),t.getAbsolutePositionToRef(i,c),null==n&&r&&(n=r.length()),null!=n&&(c.x+=u.x*n,c.y+=u.y*n,c.z+=u.z*n),s.setAbsolutePosition(c)},e.DEFAULT_OBJECT_SIZE=new V(1,1,1),e.IDENTITY_QUATERNION=G.Identity(),e._TmpVecs=C.BuildArray(3,V.Zero),e._TmpQuat=G.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CapsuleImpostor=6,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e.ConvexHullImpostor=10,e.CustomImpostor=100,e.RopeImpostor=101,e.ClothImpostor=102,e.SoftbodyImpostor=103,e}();!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(Os||(Os={}));var Ns,Fs,Ls=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return mo.ForceFullSceneLoadingForIncremental},set:function(e){mo.ForceFullSceneLoadingForIncremental=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return mo.ShowLoadingScreen},set:function(e){mo.ShowLoadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return mo.loggingLevel},set:function(e){mo.loggingLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return mo.CleanBoneMatrixWeights},set:function(e){mo.CleanBoneMatrixWeights=e},enumerable:!1,configurable:!0}),e.GetDefaultPlugin=function(){return e._RegisteredPlugins[".babylon"]},e._GetPluginForExtension=function(t){return e._RegisteredPlugins[t]||(ae.Warn("Unable to find a plugin to load "+t+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"),e.GetDefaultPlugin())},e._GetPluginForDirectLoad=function(t){for(var i in e._RegisteredPlugins){var r=e._RegisteredPlugins[i].plugin;if(r.canDirectLoad&&r.canDirectLoad(t))return e._RegisteredPlugins[i]}return e.GetDefaultPlugin()},e._GetPluginForFilename=function(t){var i=t.indexOf("?");-1!==i&&(t=t.substring(0,i));var r=t.lastIndexOf("."),n=t.substring(r,t.length).toLowerCase();return e._GetPluginForExtension(n)},e._GetDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},e._FormatErrorMessage=function(e,t,i){var r="Unable to load from "+(e.rawData?"binary data":e.url);return t?r+=": ".concat(t):i&&(r+=": ".concat(i)),r},e._LoadData=function(t,i,r,n,o,a,s,l){var c=e._GetDirectLoad(t.url);if(t.rawData&&!s)throw"When using ArrayBufferView to load data the file extension must be provided.";var u,h=s?e._GetPluginForExtension(s):c?e._GetPluginForDirectLoad(t.url):e._GetPluginForFilename(t.url);if(t.rawData&&!h.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";if(!(u=void 0!==h.plugin.createPlugin?h.plugin.createPlugin():h.plugin))throw"The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";if(e.OnPluginActivatedObservable.notifyObservers(u),c&&(u.canDirectLoad&&u.canDirectLoad(t.url)||!zi(t.url))){if(u.directLoad){var d=u.directLoad(i,c);d.then?d.then((function(e){r(u,e)})).catch((function(e){o("Error in directLoad of _loadData: "+e,e)})):r(u,d)}else r(u,c);return u}var p=h.isBinary,f=function(e,t){i.isDisposed?o("Scene has been disposed"):r(u,e,t)},_=null,m=!1,g=u.onDisposeObservable;g&&g.add((function(){m=!0,_&&(_.abort(),_=null),a()}));var v=function(){if(!m){var e=function(e,t){o(null==e?void 0:e.statusText,t)};if(!u.loadFile&&t.rawData)throw"Plugin does not support loading ArrayBufferView.";_=u.loadFile?u.loadFile(i,t.rawData||t.file||t.url,t.rootUrl,f,n,p,e,l):i._loadFile(t.file||t.url,f,n,!0,p,e)}},y=i.getEngine(),b=y.enableOfflineSupport;if(b){for(var T=!1,E=0,S=i.disableOfflineSupportExceptionRules;E FragmentOutputs {\n").concat(this.compilationString):"\n".concat(t?"//Entry point\n":"","@vertex\nfn main(input: VertexInputs) -> FragmentInputs{\n").concat(this.compilationString):this.compilationString="\n".concat(t?"//Entry point\n":"","void main(void) {\n").concat(this.compilationString),this._constantDeclaration&&(this.compilationString="\n".concat(t?"//Constants\n":"").concat(this._constantDeclaration,"\n").concat(this.compilationString));var r="";for(var n in this.functions)r+=this.functions[n]+"\n";if(this.compilationString="\n".concat(r,"\n").concat(this.compilationString),!i&&this._varyingTransfer&&(this.compilationString="".concat(this.compilationString,"\n").concat(this._varyingTransfer)),this._injectAtEnd&&(this.compilationString="".concat(this.compilationString,"\n").concat(this._injectAtEnd)),this.compilationString="".concat(this.compilationString,"\n}"),this.sharedData.varyingDeclaration&&(this.compilationString="\n".concat(t?"//Varyings\n":"").concat(this.sharedData.varyingDeclaration,"\n").concat(this.compilationString)),this._samplerDeclaration&&(this.compilationString="\n".concat(t?"//Samplers\n":"").concat(this._samplerDeclaration,"\n").concat(this.compilationString)),this._uniformDeclaration&&(this.compilationString="\n".concat(t?"//Uniforms\n":"").concat(this._uniformDeclaration,"\n").concat(this.compilationString)),this._attributeDeclaration&&!i&&(this.compilationString="\n".concat(t?"//Attributes\n":"").concat(this._attributeDeclaration,"\n").concat(this.compilationString)),this.shaderLanguage!==pt.WGSL)for(var o in this.compilationString="precision highp float;\n"+this.compilationString,this.compilationString="#if defined(WEBGL2) || defines(WEBGPU)\nprecision highp sampler2DArray;\n#endif\n"+this.compilationString,i&&(this.compilationString="#if defined(PREPASS)\r\n#extension GL_EXT_draw_buffers : require\r\nlayout(location = 0) out highp vec4 glFragData[SCENE_MRT_COUNT];\r\nhighp vec4 gl_FragColor;\r\n#endif\r\n"+this.compilationString),this.extensions){var a=this.extensions[o];this.compilationString="\n".concat(a,"\n").concat(this.compilationString)}this._builtCompilationString=this.compilationString},Object.defineProperty(e.prototype,"_repeatableContentAnchor",{get:function(){return"###___ANCHOR".concat(this._repeatableContentAnchorIndex++,"___###")},enumerable:!1,configurable:!0}),e.prototype._getFreeVariableName=function(e){return e=e.replace(/[^a-zA-Z_]+/g,""),void 0===this.sharedData.variableNames[e]?(this.sharedData.variableNames[e]=0,"output"===e||"texture"===e?e+this.sharedData.variableNames[e]:e):(this.sharedData.variableNames[e]++,e+this.sharedData.variableNames[e])},e.prototype._getFreeDefineName=function(e){return void 0===this.sharedData.defineNames[e]?this.sharedData.defineNames[e]=0:this.sharedData.defineNames[e]++,e+this.sharedData.defineNames[e]},e.prototype._excludeVariableName=function(e){this.sharedData.variableNames[e]=0},e.prototype._emit2DSampler=function(e,t){void 0===t&&(t=""),this.samplers.indexOf(e)<0&&(this.shaderLanguage===pt.WGSL?(this._samplerDeclaration+="var ".concat(e,": sampler;\n"),this._samplerDeclaration+="var ".concat(t,": texture_2d;\n")):this._samplerDeclaration+="uniform sampler2D ".concat(e,";\n"),this.samplers.push(e))},e.prototype._emit2DArraySampler=function(e){this.samplers.indexOf(e)<0&&(this._samplerDeclaration+="uniform sampler2DArray ".concat(e,";\n"),this.samplers.push(e))},e.prototype._getGLType=function(e){switch(e){case Ns.Float:return"float";case Ns.Int:return"int";case Ns.Vector2:return"vec2";case Ns.Color3:case Ns.Vector3:return"vec3";case Ns.Color4:case Ns.Vector4:return"vec4";case Ns.Matrix:return"mat4"}return""},e.prototype._getShaderType=function(e){var t=this.shaderLanguage===pt.WGSL;switch(e){case Ns.Float:return t?"f32":"float";case Ns.Int:return t?"i32":"int";case Ns.Vector2:return t?"vec2":"vec2";case Ns.Color3:case Ns.Vector3:return t?"vec3":"vec3";case Ns.Color4:case Ns.Vector4:return t?"vec4":"vec4";case Ns.Matrix:return t?"mat4x4":"mat4"}return""},e.prototype._emitExtension=function(e,t,i){void 0===i&&(i=""),this.extensions[e]||(i&&(t="#if ".concat(i,"\n").concat(t,"\n#endif")),this.extensions[e]=t)},e.prototype._emitFunction=function(e,t,i){this.functions[e]||(this.sharedData.emitComments&&(t=i+"\n"+t),this.functions[e]=t)},e.prototype._emitCodeFromInclude=function(e,t,i){if(i&&i.repeatKey)return"#include<".concat(e,">").concat(i.substitutionVars?"("+i.substitutionVars+")":"","[0..").concat(i.repeatKey,"]\n");var r=Ei.IncludesShadersStore[e]+"\n";if(this.sharedData.emitComments&&(r=t+"\n"+r),!i)return r;if(i.replaceStrings)for(var n=0;n").concat(i.substitutionVars?"("+i.substitutionVars+")":"","[0..").concat(i.repeatKey,"]\n"):this.functions[n]="#include<".concat(e,">").concat((null==i?void 0:i.substitutionVars)?"("+(null==i?void 0:i.substitutionVars)+")":"","\n"),void(this.sharedData.emitComments&&(this.functions[n]=t+"\n"+this.functions[n]));var o=li.GetIncludesShadersStore(this.shaderLanguage);if(this.functions[n]=o[e],this.sharedData.emitComments&&(this.functions[n]=t+"\n"+this.functions[n]),i.removeIfDef&&(this.functions[n]=this.functions[n].replace(/^\s*?#ifdef.+$/gm,""),this.functions[n]=this.functions[n].replace(/^\s*?#endif.*$/gm,""),this.functions[n]=this.functions[n].replace(/^\s*?#else.*$/gm,""),this.functions[n]=this.functions[n].replace(/^\s*?#elif.*$/gm,"")),i.removeAttributes&&(this.functions[n]=this.functions[n].replace(/\s*?attribute .+?;/g,"\n")),i.removeUniforms&&(this.functions[n]=this.functions[n].replace(/\s*?uniform .*?;/g,"\n")),i.removeVaryings&&(this.functions[n]=this.functions[n].replace(/\s*?(varying|in) .+?;/g,"\n")),i.replaceStrings)for(var a=0;a")},e.prototype._convertFunctionsToWGSL=function(e){var t=e.match(/var\s+(\w+)\s*:\s*(\w+)\((.*)\)/);if(t){var i=t[1],r=t[2],n=t[3].replace(/var\s/g,"");return e.replace(t[0],"fn ".concat(i,"(").concat(n,") -> ").concat(r))}return e},e.prototype._babylonSLtoWGSL=function(e){return e=this._convertVariableDeclarationToWGSL("void","voidnull",e),e=this._convertVariableDeclarationToWGSL("int","i32",e),e=this._convertVariableDeclarationToWGSL("uint","u32",e),e=this._convertVariableDeclarationToWGSL("float","f32",e),e=this._convertVariableDeclarationToWGSL("vec2","vec2f",e),e=this._convertVariableDeclarationToWGSL("vec3","vec3f",e),e=this._convertVariableDeclarationToWGSL("vec4","vec4f",e),e=this._convertVariableDeclarationToWGSL("mat2","mat2x2f",e),e=this._convertVariableDeclarationToWGSL("mat3","mat3x3f",e),e=this._convertVariableDeclarationToWGSL("mat4","mat4x4f",e),e=this._convertVariableConstructorsToWGSL("float","f32",e),e=this._convertVariableConstructorsToWGSL("vec2","vec2f",e),e=this._convertVariableConstructorsToWGSL("vec3","vec3f",e),e=this._convertVariableConstructorsToWGSL("vec4","vec4f",e),e=this._convertVariableConstructorsToWGSL("mat2","mat2x2f",e),e=this._convertVariableConstructorsToWGSL("mat3","mat3x3f",e),e=this._convertVariableConstructorsToWGSL("mat4","mat4x4f",e),e=(e=this._convertOutParametersToWGSL(e)).replace(/\[\*\]/g,"*"),(e=this._convertFunctionsToWGSL(e)).replace(/\s->\svoidnull/g,"")},e.prototype._babylonSLtoGLSL=function(e){return e.replace(/\[\*\]/g,"")},e}(),ks=function(){function e(){this.temps=[],this.varyings=[],this.varyingDeclaration="",this.inputBlocks=[],this.textureBlocks=[],this.bindableBlocks=[],this.forcedBindableBlocks=[],this.blocksWithFallbacks=[],this.blocksWithDefines=[],this.repeatableContentBlocks=[],this.dynamicUniformBlocks=[],this.blockingBlocks=[],this.animatedInputs=[],this.variableNames={},this.defineNames={},this.hints={needWorldViewMatrix:!1,needWorldViewProjectionMatrix:!1,needAlphaBlending:!1,needAlphaTesting:!1},this.checks={emitVertex:!1,emitFragment:!1,notConnectedNonOptionalInputs:new Array},this.allowEmptyVertexProgram=!1,this.variableNames.position=0,this.variableNames.normal=0,this.variableNames.tangent=0,this.variableNames.uv=0,this.variableNames.uv2=0,this.variableNames.uv3=0,this.variableNames.uv4=0,this.variableNames.uv5=0,this.variableNames.uv6=0,this.variableNames.color=0,this.variableNames.matricesIndices=0,this.variableNames.matricesWeights=0,this.variableNames.matricesIndicesExtra=0,this.variableNames.matricesWeightsExtra=0,this.variableNames.diffuseBase=0,this.variableNames.specularBase=0,this.variableNames.worldPos=0,this.variableNames.shadow=0,this.variableNames.view=0,this.variableNames.vTBN=0,this.defineNames.MAINUV0=0,this.defineNames.MAINUV1=0,this.defineNames.MAINUV2=0,this.defineNames.MAINUV3=0,this.defineNames.MAINUV4=0,this.defineNames.MAINUV5=0,this.defineNames.MAINUV6=0,this.defineNames.MAINUV7=0}return e.prototype.emitErrors=function(){var e="";this.checks.emitVertex||this.allowEmptyVertexProgram||(e+="NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\n"),this.checks.emitFragment||(e+="NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\n");for(var t=0,i=this.checks.notConnectedNonOptionalInputs;t0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDirectlyConnectedToVertexOutput",{get:function(){if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t},e.prototype.dispose=function(){this.onConnectionObservable.clear(),this.onDisconnectionObservable.clear(),this.onTypeChangedObservable.clear(),this._connectedPoint=null,this._typeConnectionSource=null,this._linkedConnectionSource=null},e.prototype._updateTypeDependentState=function(e){var t=this.type;e(),this.type!==t&&this._notifyTypeChanged()},e.prototype._notifyTypeChanged=function(){this._isTypeChangeObservableNotifying||(this._isTypeChangeObservableNotifying=!0,this.onTypeChangedObservable.notifyObservers(this.type),this._isTypeChangeObservableNotifying=!1)},e}(),Ws=function(){function e(e,t,i){void 0===t&&(t=Fs.Vertex),void 0===i&&(i=!1),this._isFinalMerger=!1,this._isInput=!1,this._isTeleportOut=!1,this._isTeleportIn=!1,this._name="",this._isUnique=!1,this.inputsAreExclusive=!1,this._codeVariableName="",this._inputs=new Array,this._outputs=new Array,this.comments="",this.visibleInInspector=!1,this.visibleOnFrame=!1,this._target=t,this._originalTargetIsNeutral=t===Fs.Neutral,this._isFinalMerger=i,this._isInput="InputBlock"===this.getClassName(),this._isTeleportOut="NodeMaterialTeleportOutBlock"===this.getClassName(),this._isTeleportIn="NodeMaterialTeleportInBlock"===this.getClassName(),this._name=e,this.uniqueId=cn.UniqueId}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this.validateBlockName(e)&&(this._name=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnique",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFinalMerger",{get:function(){return this._isFinalMerger},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTeleportOut",{get:function(){return this._isTeleportOut},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTeleportIn",{get:function(){return this._isTeleportIn},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buildId",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(e){this._target&e||(this._target=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputs",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outputs",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),e.prototype.getInputByName=function(e){var t=this._inputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.getOutputByName=function(e){var t=this._outputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype._setInitialTarget=function(e){this._target=e,this._originalTargetIsNeutral=e===Fs.Neutral},e.prototype.initialize=function(e){},e.prototype.bind=function(e,t,i,r){},e.prototype._writeVariable=function(e){return e.connectedPoint?"".concat(e.associatedVariableName):"0."},e.prototype._writeFloat=function(e){var t=e.toString();return-1===t.indexOf(".")&&(t+=".0"),"".concat(t)},e.prototype.getClassName=function(){return"NodeMaterialBlock"},e.prototype.isConnectedInFragmentShader=function(){return this.outputs.some((function(e){return e.isConnectedInFragmentShader}))},e.prototype.registerInput=function(e,t,i,r,n){return void 0===i&&(i=!1),(n=null!=n?n:new zs(e,this,Us.Input)).type=t,n.isOptional=i,r&&(n.target=r),this._inputs.push(n),this},e.prototype.registerOutput=function(e,t,i,r){return(r=null!=r?r:new zs(e,this,Us.Output)).type=t,i&&(r.target=i),this._outputs.push(r),this},e.prototype.getFirstAvailableInput=function(e){void 0===e&&(e=null);for(var t=0,i=this._inputs;t=this._outputs.length?null:this._outputs[t+1]},e.prototype.isAnAncestorOf=function(e){for(var t=0,i=this._outputs;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),r=0;r0&&(n.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(r=0;r0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is3D",{get:function(){return this.depth>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._size.width||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._size.height||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layers",{get:function(){return this._size.layers||0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth",{get:function(){return this._size.depth||0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){var e,t;return null!==(t=null===(e=this._textures)||void 0===e?void 0:e[0])&&void 0!==t?t:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceIndices",{get:function(){return this._faceIndices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layerIndices",{get:function(){return this._layerIndices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},enumerable:!1,configurable:!0}),e.prototype.setSamples=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),this.samples===e&&!i)return e;var r=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,r},e.prototype.setTextures=function(e){Array.isArray(e)?this._textures=e:this._textures=e?[e]:null},e.prototype.setTexture=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=!0),this._textures||(this._textures=[]),this._textures[t]!==e&&(this._textures[t]&&i&&this._textures[t].dispose(),this._textures[t]=e)},e.prototype.setLayerAndFaceIndices=function(e,t){this._layerIndices=e,this._faceIndices=t},e.prototype.setLayerAndFaceIndex=function(e,t,i){void 0===e&&(e=0),this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),void 0!==t&&t>=0&&(this._layerIndices[e]=t),void 0!==i&&i>=0&&(this._faceIndices[e]=i)},e.prototype.createDepthStencilTexture=function(e,t,i,r,n,o){var a;return void 0===e&&(e=0),void 0===t&&(t=!0),void 0===i&&(i=!1),void 0===r&&(r=1),void 0===n&&(n=u.TEXTUREFORMAT_DEPTH32_FLOAT),null===(a=this._depthStencilTexture)||void 0===a||a.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTextureLabel=o,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:r,depthTextureFormat:n,label:o},this),this._depthStencilTexture},e.prototype._shareDepth=function(e){this.shareDepth(e)},e.prototype.shareDepth=function(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,e._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())},e.prototype._swapAndDie=function(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)},e.prototype._cloneRenderTargetWrapper=function(){var e,t,i,r,n,o,a,s,l=null;if(this._isMulti){var c=this.textures;if(c&&c.length>0){var h=!1,d=c.length,p=-1,f=c[c.length-1]._source;f!==Ti.Depth&&f!==Ti.DepthStencil||(h=!0,p=c[c.length-1].format,d--);for(var _=[],m=[],g=[],v=[],y=[],b=[],T=[],E={},S=0;S1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}},e.prototype.releaseTextures=function(){var e,t;if(this._textures)for(var i=0;null!==(t=i<(null===(e=this._textures)||void 0===e?void 0:e.length))&&void 0!==t&&t;++i)this._textures[i].dispose();this._textures=null},e.prototype.dispose=function(e){var t;void 0===e&&(e=!1),e||(null===(t=this._depthStencilTexture)||void 0===t||t.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)},e}(),ul=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,r,n)||this;return a._framebuffer=null,a._depthStencilBuffer=null,a._MSAAFramebuffer=null,a._colorTextureArray=null,a._depthStencilTextureArray=null,a._disposeOnlyFramebuffers=!1,a._currentLOD=0,a._context=o,a}return m(t,e),t.prototype._cloneRenderTargetWrapper=function(){var t=null;return this._colorTextureArray&&this._depthStencilTextureArray?(t=this._engine.createMultiviewRenderTargetTexture(this.width,this.height)).texture.isReady=!0:t=e.prototype._cloneRenderTargetWrapper.call(this),t},t.prototype._swapRenderTargetWrapper=function(t){e.prototype._swapRenderTargetWrapper.call(this,t),t._framebuffer=this._framebuffer,t._depthStencilBuffer=this._depthStencilBuffer,t._MSAAFramebuffer=this._MSAAFramebuffer,t._colorTextureArray=this._colorTextureArray,t._depthStencilTextureArray=this._depthStencilTextureArray,this._framebuffer=this._depthStencilBuffer=this._MSAAFramebuffer=this._colorTextureArray=this._depthStencilTextureArray=null},t.prototype.createDepthStencilTexture=function(t,i,r,n,o,a){if(void 0===t&&(t=0),void 0===i&&(i=!0),void 0===r&&(r=!1),void 0===n&&(n=1),void 0===o&&(o=u.TEXTUREFORMAT_DEPTH32_FLOAT),this._depthStencilBuffer){var s=this._engine,l=s._currentFramebuffer,c=this._context;s._bindUnboundFramebuffer(this._framebuffer),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,null),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,null),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.STENCIL_ATTACHMENT,c.RENDERBUFFER,null),s._bindUnboundFramebuffer(l),c.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return e.prototype.createDepthStencilTexture.call(this,t,i,r,n,o,a)},t.prototype.shareDepth=function(t){e.prototype.shareDepth.call(this,t);var i=this._context,r=this._depthStencilBuffer,n=t._MSAAFramebuffer||t._framebuffer,o=this._engine;t._depthStencilBuffer&&t._depthStencilBuffer!==r&&i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=r;var a=t._generateStencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;o._bindUnboundFramebuffer(n),i.framebufferRenderbuffer(i.FRAMEBUFFER,a,i.RENDERBUFFER,r),o._bindUnboundFramebuffer(null)},t.prototype._bindTextureRenderTarget=function(e,t,i,r){var n,o,a,s;if(void 0===t&&(t=0),void 0===r&&(r=0),e._hardwareTexture){var l=this._framebuffer,c=this._engine,u=c._currentFramebuffer;if(c._bindUnboundFramebuffer(l),c.webGLVersion>1){var h=(d=this._context)["COLOR_ATTACHMENT"+t];e.is2DArray||e.is3D?(i=null!==(o=null!=i?i:null===(n=this.layerIndices)||void 0===n?void 0:n[t])&&void 0!==o?o:0,d.framebufferTextureLayer(d.FRAMEBUFFER,h,e._hardwareTexture.underlyingResource,r,i)):e.isCube?(i=null!==(s=null!=i?i:null===(a=this.faceIndices)||void 0===a?void 0:a[t])&&void 0!==s?s:0,d.framebufferTexture2D(d.FRAMEBUFFER,h,d.TEXTURE_CUBE_MAP_POSITIVE_X+i,e._hardwareTexture.underlyingResource,r)):d.framebufferTexture2D(d.FRAMEBUFFER,h,d.TEXTURE_2D,e._hardwareTexture.underlyingResource,r)}else{h=(d=this._context)["COLOR_ATTACHMENT"+t+"_WEBGL"];var d,p=void 0!==i?d.TEXTURE_CUBE_MAP_POSITIVE_X+i:d.TEXTURE_2D;d.framebufferTexture2D(d.FRAMEBUFFER,h,p,e._hardwareTexture.underlyingResource,r)}c._bindUnboundFramebuffer(u)}},t.prototype.setTexture=function(t,i,r){void 0===i&&(i=0),void 0===r&&(r=!0),e.prototype.setTexture.call(this,t,i,r),this._bindTextureRenderTarget(t,i)},t.prototype.setLayerAndFaceIndices=function(t,i){var r,n;if(e.prototype.setLayerAndFaceIndices.call(this,t,i),this.textures&&this.layerIndices&&this.faceIndices)for(var o=null!==(n=null===(r=this._attachments)||void 0===r?void 0:r.length)&&void 0!==n?n:this.textures.length,a=0;a1&&(a.format===u.TEXTUREFORMAT_DEPTH16?d=i.DEPTH_COMPONENT16:a.format===u.TEXTUREFORMAT_DEPTH24?d=i.DEPTH_COMPONENT24:a.format===u.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||a.format===u.TEXTUREFORMAT_DEPTH24_STENCIL8?d=i.DEPTH24_STENCIL8:a.format===u.TEXTUREFORMAT_DEPTH32_FLOAT?d=i.DEPTH_COMPONENT32F:a.format===u.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8&&(d=i.DEPTH32F_STENCIL8)),a.is2DArray?i.texImage3D(o,0,d,a.width,a.height,r,0,h,c,null):a.is3D?i.texImage3D(o,0,d,a.width,a.height,n,0,h,c,null):i.texImage2D(o,0,d,a.width,a.height,0,h,c,null),this._bindTextureDirectly(o,null),this._internalTexturesCache.push(a),a},Er.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||!e.texture)return 1;if(e.samples===t)return t;var i=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(i.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null);var r=e.texture._hardwareTexture;if(r.releaseMSAARenderBuffers(),t>1&&"function"==typeof i.renderbufferStorageMultisample){var n=i.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=n,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var o=this._createRenderBuffer(e.texture.width,e.texture.height,t,-1,this._getRGBABufferInternalSizedFormat(e.texture.type,e.texture.format,e.texture._useSRGBBuffer),i.COLOR_ATTACHMENT0,!1);if(!o)throw new Error("Unable to create multi sampled framebuffer");r.addMSAARenderBuffer(o)}else this._bindUnboundFramebuffer(e._framebuffer);return e.texture.samples=t,e._samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.texture.width,e.texture.height,t),this._bindUnboundFramebuffer(null),t};var hl=function(){function e(e,t,i,r,n,o,a,s,l,c,h,d,p,_,m,g){var v,y,b,T,E,S,x,A,C,R,P,I;void 0===a&&(a=u.TEXTURE_NEAREST_SAMPLINGMODE),void 0===c&&(c=null),void 0===h&&(h=u.TEXTURETYPE_UNSIGNED_INT),void 0===d&&(d="postprocess"),void 0===_&&(_=!1),void 0===m&&(m=u.TEXTUREFORMAT_RGBA),void 0===g&&(g=pt.GLSL),this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.alphaMode=u.ALPHA_DISABLE,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=u.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new ar(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new U(1,1),this._texelSize=U.Zero(),this.onActivateObservable=new f,this.onSizeChangedObservable=new f,this.onApplyObservable=new f,this.onBeforeRenderObservable=new f,this.onAfterRenderObservable=new f,this.name=e;var M=1,O=null;if(i&&!Array.isArray(i)){var D=i;i=null!==(v=D.uniforms)&&void 0!==v?v:null,r=null!==(y=D.samplers)&&void 0!==y?y:null,M=null!==(b=D.size)&&void 0!==b?b:1,o=null!==(T=D.camera)&&void 0!==T?T:null,a=null!==(E=D.samplingMode)&&void 0!==E?E:u.TEXTURE_NEAREST_SAMPLINGMODE,s=D.engine,l=D.reusable,c=null!==(S=D.defines)&&void 0!==S?S:null,h=null!==(x=D.textureType)&&void 0!==x?x:u.TEXTURETYPE_UNSIGNED_INT,d=null!==(A=D.vertexUrl)&&void 0!==A?A:"postprocess",p=D.indexParameters,_=null!==(C=D.blockCompilation)&&void 0!==C&&C,m=null!==(R=D.textureFormat)&&void 0!==R?R:u.TEXTUREFORMAT_RGBA,g=null!==(P=D.shaderLanguage)&&void 0!==P?P:pt.GLSL,O=null!==(I=D.uniformBuffers)&&void 0!==I?I:null}else n&&(M="number"==typeof n?n:{width:n.width,height:n.height});null!=o?(this._camera=o,this._scene=o.getScene(),o.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):s&&(this._engine=s,this._engine.postProcesses.push(this)),this._options=M,this.renderTargetSamplingMode=a||u.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=l||!1,this._textureType=h,this._textureFormat=m,this._shaderLanguage=g,this._samplers=r||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=d,this._parameters=i||[],this._parameters.push("scale"),this._uniformBuffers=O||[],this._indexParameters=p,this._drawWrapper=new ho(this._engine),_||this.updateEffect(c)}return e.RegisterShaderCodeProcessing=function(t,i){i?e._CustomShaderCodeProcessing[null!=t?t:""]=i:delete e._CustomShaderCodeProcessing[null!=t?t:""]},e._GetShaderCodeProcessing=function(t){var i;return null!==(i=e._CustomShaderCodeProcessing[t])&&void 0!==i?i:e._CustomShaderCodeProcessing[""]},Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){var t=this;this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((function(e){e.setSamples(t._samples)}))},enumerable:!1,configurable:!0}),e.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(e.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!1,configurable:!0}),e.prototype.restoreDefaultInputTexture=function(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())},e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"PostProcess"},e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._drawWrapper.effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new ar(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(t,i,r,n,o,a,s,l){var c,u,h=this;void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null);var d=e._GetShaderCodeProcessing(this.name);if(null==d?void 0:d.defineCustomBindings){var p=null!==(c=null==i?void 0:i.slice())&&void 0!==c?c:[];p.push.apply(p,this._parameters);var f=null!==(u=null==r?void 0:r.slice())&&void 0!==u?u:[];f.push.apply(f,this._samplers),t=d.defineCustomBindings(this.name,t,p,f),i=p,r=f}this._postProcessDefines=t,this._drawWrapper.effect=this._engine.createEffect({vertex:null!=s?s:this._vertexUrl,fragment:null!=l?l:this._fragmentUrl},{attributes:["position"],uniformsNames:i||this._parameters,uniformBuffersNames:this._uniformBuffers,samplers:r||this._samplers,defines:null!==t?t:"",fallbacks:null,onCompiled:null!=o?o:null,onError:null!=a?a:null,indexParameters:n||this._indexParameters,processCodeAfterIncludes:(null==d?void 0:d.processCodeAfterIncludes)?function(e,t){return d.processCodeAfterIncludes(h.name,e,t)}:null,processFinalCode:(null==d?void 0:d.processFinalCode)?function(e,t){return d.processFinalCode(h.name,e,t)}:null,shaderLanguage:this._shaderLanguage},this._engine)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype._createRenderTargetTexture=function(e,t,i){void 0===i&&(i=0);for(var r=0;r=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){for(var i=!1,r=0;r0&&this._textures.reset(),this.width=e,this.height=t;var o=null;if(i)for(var a=0;a=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0},e.prototype.setPrePassRenderer=function(e){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)},e.prototype.dispose=function(e){var t;if(e=e||this._camera,this._disposeTextures(),this._scene&&-1!==(t=this._scene.postProcesses.indexOf(this))&&this._scene.postProcesses.splice(t,1),this._parentContainer){var i=this._parentContainer.postProcesses.indexOf(this);i>-1&&this._parentContainer.postProcesses.splice(i,1),this._parentContainer=null}if(-1!==(t=this._engine.postProcesses.indexOf(this))&&this._engine.postProcesses.splice(t,1),e){if(e.detachPostProcess(this),0===(t=e._postProcesses.indexOf(this))&&e._postProcesses.length>0){var r=this._camera._getFirstPostProcess();r&&r.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e.prototype.serialize=function(){var e=Ke.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType="BABYLON."+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e},e.prototype.clone=function(){var t=this.serialize();t._engine=this._engine,t.cameraId=null;var i=e.Parse(t,this._scene,"");return i?(i.onActivateObservable=this.onActivateObservable.clone(),i.onSizeChangedObservable=this.onSizeChangedObservable.clone(),i.onApplyObservable=this.onApplyObservable.clone(),i.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),i.onAfterRenderObservable=this.onAfterRenderObservable.clone(),i._prePassEffectConfiguration=this._prePassEffectConfiguration,i):null},e.Parse=function(e,t,i){var r=s(e.customType);if(!r||!r._Parse)return null;var n=t?t.getCameraById(e.cameraId):null;return r._Parse(e,n,t,i)},e._Parse=function(t,i,r,n){return Ke.Parse((function(){return new e(t.name,t.fragmentUrl,t.parameters,t.samplers,t.options,i,t.renderTargetSamplingMode,t._engine,t.reusable,t.defines,t.textureType,t.vertexUrl,t.indexParameters,!1,t.textureFormat)}),t,r,n)},e._CustomShaderCodeProcessing={},v([Ie()],e.prototype,"uniqueId",void 0),v([Ie()],e.prototype,"name",void 0),v([Ie()],e.prototype,"width",void 0),v([Ie()],e.prototype,"height",void 0),v([Ie()],e.prototype,"renderTargetSamplingMode",void 0),v([Be()],e.prototype,"clearColor",void 0),v([Ie()],e.prototype,"autoClear",void 0),v([Ie()],e.prototype,"forceAutoClearInAlphaMode",void 0),v([Ie()],e.prototype,"alphaMode",void 0),v([Ie()],e.prototype,"alphaConstants",void 0),v([Ie()],e.prototype,"enablePixelPerfectMode",void 0),v([Ie()],e.prototype,"forceFullscreenViewport",void 0),v([Ie()],e.prototype,"scaleMode",void 0),v([Ie()],e.prototype,"alwaysForcePOT",void 0),v([Ie("samples")],e.prototype,"_samples",void 0),v([Ie()],e.prototype,"adaptScaleToCurrentViewport",void 0),e}();a("BABYLON.PostProcess",hl);var dl=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.xSwizzle="x",i.ySwizzle="y",i.zSwizzle="z",i.wSwizzle="w",i.registerInput("xyzw ",Ns.Vector4,!0),i.registerInput("xyz ",Ns.Vector3,!0),i.registerInput("xy ",Ns.Vector2,!0),i.registerInput("zw ",Ns.Vector2,!0),i.registerInput("x",Ns.Float,!0),i.registerInput("y",Ns.Float,!0),i.registerInput("z",Ns.Float,!0),i.registerInput("w",Ns.Float,!0),i.registerOutput("xyzw",Ns.Vector4),i.registerOutput("xyz",Ns.Vector3),i.registerOutput("xy",Ns.Vector2),i.registerOutput("zw",Ns.Vector2),i}return m(t,e),t.prototype.getClassName=function(){return"VectorMergerBlock"},Object.defineProperty(t.prototype,"xyzwIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwIn",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"w",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwOut",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xy",{get:function(){return this.xyOut},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this.xyzOut},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return"xyzw "===e?"xyzwIn":"xyz "===e?"xyzIn":"xy "===e?"xyIn":"zw "===e?"zwIn":e},t.prototype._buildSwizzle=function(e){return"."+(this.xSwizzle+this.ySwizzle+this.zSwizzle+this.wSwizzle).substr(0,e)},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.x,r=this.y,n=this.z,o=this.w,a=this.xyIn,s=this.zwIn,l=this.xyzIn,c=this.xyzwIn,u=this._outputs[0],h=this._outputs[1],d=this._outputs[2],p=this._outputs[3],f=t._getShaderType(Ns.Vector4),_=t._getShaderType(Ns.Vector3),m=t._getShaderType(Ns.Vector2);return c.isConnected?(u.hasEndpoints&&(t.compilationString+=t._declareOutput(u)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(4),";\n")),h.hasEndpoints&&(t.compilationString+=t._declareOutput(h)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(3),";\n")),d.hasEndpoints&&(t.compilationString+=t._declareOutput(d)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(2),";\n"))):l.isConnected?(u.hasEndpoints&&(t.compilationString+=t._declareOutput(u)+" = ".concat(f,"(").concat(l.associatedVariableName,", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(4),";\n")),h.hasEndpoints&&(t.compilationString+=t._declareOutput(h)+" = ".concat(l.associatedVariableName).concat(this._buildSwizzle(3),";\n")),d.hasEndpoints&&(t.compilationString+=t._declareOutput(d)+" = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2),";\n"))):a.isConnected?(u.hasEndpoints&&(s.isConnected?t.compilationString+=t._declareOutput(u)+" = ".concat(f,"(").concat(a.associatedVariableName,", ").concat(s.associatedVariableName,")").concat(this._buildSwizzle(4),";\n"):t.compilationString+=t._declareOutput(u)+" = ".concat(f,"(").concat(a.associatedVariableName,", ").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(4),";\n")),h.hasEndpoints&&(t.compilationString+=t._declareOutput(h)+" = ".concat(_,"(").concat(a.associatedVariableName,", ").concat(n.isConnected?this._writeVariable(n):"0.0",")").concat(this._buildSwizzle(3),";\n")),d.hasEndpoints&&(t.compilationString+=t._declareOutput(d)+" = ".concat(a.associatedVariableName).concat(this._buildSwizzle(2),";\n")),p.hasEndpoints&&(s.isConnected?t.compilationString+=t._declareOutput(p)+" = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2),";\n"):t.compilationString+=t._declareOutput(p)+" = ".concat(m,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(2),";\n"))):(u.hasEndpoints&&(s.isConnected?t.compilationString+=t._declareOutput(u)+" = ".concat(f,"(").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(r.isConnected?this._writeVariable(r):"0.0",", ").concat(s.associatedVariableName,")").concat(this._buildSwizzle(4),";\n"):t.compilationString+=t._declareOutput(u)+" = ".concat(f,"(").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(r.isConnected?this._writeVariable(r):"0.0",", ").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(4),";\n")),h.hasEndpoints&&(t.compilationString+=t._declareOutput(h)+" = ".concat(_,"(").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(r.isConnected?this._writeVariable(r):"0.0",", ").concat(n.isConnected?this._writeVariable(n):"0.0",")").concat(this._buildSwizzle(3),";\n")),d.hasEndpoints&&(t.compilationString+=t._declareOutput(d)+" = ".concat(m,"(").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(r.isConnected?this._writeVariable(r):"0.0",")").concat(this._buildSwizzle(2),";\n")),p.hasEndpoints&&(s.isConnected?t.compilationString+=t._declareOutput(p)+" = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2),";\n"):t.compilationString+=t._declareOutput(p)+" = ".concat(m,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(2),";\n"))),this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.xSwizzle=this.xSwizzle,t.ySwizzle=this.ySwizzle,t.zSwizzle=this.zSwizzle,t.wSwizzle=this.wSwizzle,t},t.prototype._deserialize=function(t,i,r){var n,o,a,s;e.prototype._deserialize.call(this,t,i,r),this.xSwizzle=null!==(n=t.xSwizzle)&&void 0!==n?n:"x",this.ySwizzle=null!==(o=t.ySwizzle)&&void 0!==o?o:"y",this.zSwizzle=null!==(a=t.zSwizzle)&&void 0!==a?a:"z",this.wSwizzle=null!==(s=t.wSwizzle)&&void 0!==s?s:"w"},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return t+="".concat(this._codeVariableName,'.xSwizzle = "').concat(this.xSwizzle,'";\n'),t+="".concat(this._codeVariableName,'.ySwizzle = "').concat(this.ySwizzle,'";\n'),(t+="".concat(this._codeVariableName,'.zSwizzle = "').concat(this.zSwizzle,'";\n'))+"".concat(this._codeVariableName,'.wSwizzle = "').concat(this.wSwizzle,'";\n')},t}(Ws);a("BABYLON.VectorMergerBlock",dl);var pl=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.sourceRange=new U(-1,1),i.targetRange=new U(0,1),i.registerInput("input",Ns.AutoDetect),i.registerInput("sourceMin",Ns.Float,!0),i.registerInput("sourceMax",Ns.Float,!0),i.registerInput("targetMin",Ns.Float,!0),i.registerInput("targetMax",Ns.Float,!0),i.registerOutput("output",Ns.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return m(t,e),t.prototype.getClassName=function(){return"RemapBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMin",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMax",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMin",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMax",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],r=this.sourceMin.isConnected?this.sourceMin.associatedVariableName:this._writeFloat(this.sourceRange.x),n=this.sourceMax.isConnected?this.sourceMax.associatedVariableName:this._writeFloat(this.sourceRange.y),o=this.targetMin.isConnected?this.targetMin.associatedVariableName:this._writeFloat(this.targetRange.x),a=this.targetMax.isConnected?this.targetMax.associatedVariableName:this._writeFloat(this.targetRange.y);return t.compilationString+=t._declareOutput(i)+" = ".concat(o," + (").concat(this._inputs[0].associatedVariableName," - ").concat(r,") * (").concat(a," - ").concat(o,") / (").concat(n," - ").concat(r,");\n"),this},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".sourceRange = new BABYLON.Vector2(").concat(this.sourceRange.x,", ").concat(this.sourceRange.y,");\n")+"".concat(this._codeVariableName,".targetRange = new BABYLON.Vector2(").concat(this.targetRange.x,", ").concat(this.targetRange.y,");\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.sourceRange=this.sourceRange.asArray(),t.targetRange=this.targetRange.asArray(),t},t.prototype._deserialize=function(t,i,r){e.prototype._deserialize.call(this,t,i,r),this.sourceRange=U.FromArray(t.sourceRange),this.targetRange=U.FromArray(t.targetRange)},v([Ys("From",Xs.Vector2)],t.prototype,"sourceRange",void 0),v([Ys("To",Xs.Vector2)],t.prototype,"targetRange",void 0),t}(Ws);a("BABYLON.RemapBlock",pl);var fl,_l=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.registerInput("left",Ns.AutoDetect),i.registerInput("right",Ns.AutoDetect),i.registerOutput("output",Ns.BasedOnInput),i.output._typeConnectionSource=i.left,i._linkConnectionTypes(0,1,!0),i.left.acceptedConnectionPointTypes.push(Ns.Float),i.right.acceptedConnectionPointTypes.push(Ns.Float),i._connectionObservers=[i.left.onTypeChangedObservable.add((function(){return i._updateInputOutputTypes()})),i.right.onTypeChangedObservable.add((function(){return i._updateInputOutputTypes()}))],i}return m(t,e),Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._updateInputOutputTypes=function(){if(this.output._typeConnectionSource=this.left,this.left.isConnected&&this.right.isConnected?(this.left.type===Ns.Int||this.left.type===Ns.Float&&this.right.type!==Ns.Int)&&(this.output._typeConnectionSource=this.right):this.left.isConnected!==this.right.isConnected&&(this.output._typeConnectionSource=this.left.isConnected?this.left:this.right),this.left.isConnected||this.right.isConnected)for(var e=0,t=[[this.left,this.right],[this.right,this.left]];e0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},e.prototype.getDragGradients=function(){return this._dragGradients},e.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},e.prototype.getColorGradients=function(){return this._colorGradients},e.prototype.getSizeGradients=function(){return this._sizeGradients},e.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},e.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},e.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},e.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},e.prototype.getVelocityGradients=function(){return this._velocityGradients},e.prototype.getStartSizeGradients=function(){return this._startSizeGradients},e.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(e.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:V.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:V.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:V.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:V.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(!e&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=e)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var r=0,n=0,o=t;n0||0===r)&&(null===(i=R.getScene())||void 0===i||i.meshes.forEach((function(e){e._markSubMeshesAsLightDirty()})))},R.renderParticles=!0,R.renderSprites=!1,R.forceLayerMaskCheck=!1,R.ignoreCameraViewport=!1,R.onBeforeBindObservable=new f,R.onAfterUnbindObservable=new f,R.onBeforeRenderObservable=new f,R.onAfterRenderObservable=new f,R.onClearObservable=new f,R.onResizeObservable=new f,R._cleared=!1,R.skipInitialClear=!1,R._currentRefreshId=-1,R._refreshRate=1,R._samples=1,R._canRescale=!0,R._renderTarget=null,R.boundingBoxPosition=V.Zero(),!(r=R.getScene()))return R;var O=R.getScene().getEngine();return R._gammaSpace=I,R._coordinatesMode=Ja.PROJECTION_MODE,R.renderList=[],R.name=t,R.isRenderTarget=!0,R._initialSizeParameter=i,R._renderPassIds=[],R._isCubeData=s,R._processSizeParameter(i),R.renderPassId=R._renderPassIds[0],R._resizeObserver=O.onResizeObservable.add((function(){})),R._generateMipMaps=!!n,R._doNotChangeAspectRatio=o,R._renderingManager=new Ur(r),R._renderingManager._useSceneAutoClearSetup=!0,d||(R._renderTargetOptions={generateMipMaps:n,type:a,format:null!==(C=R._format)&&void 0!==C?C:void 0,samplingMode:R.samplingMode,generateDepthBuffer:c,generateStencilBuffer:h,samples:m,creationFlags:g,noColorAttachment:v,useSRGBBuffer:y,colorAttachment:P,label:R.name},R.samplingMode===Ja.NEAREST_SAMPLINGMODE&&(R.wrapU=Ja.CLAMP_ADDRESSMODE,R.wrapV=Ja.CLAMP_ADDRESSMODE),_||(s?(R._renderTarget=r.getEngine().createRenderTargetCubeTexture(R.getRenderSize(),R._renderTargetOptions),R.coordinatesMode=Ja.INVCUBIC_MODE,R._textureMatrix=z.Identity()):R._renderTarget=r.getEngine().createRenderTargetTexture(R._size,R._renderTargetOptions),R._texture=R._renderTarget.texture,void 0!==m&&(R.samples=m))),R}return m(t,e),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=P(e,this._renderListHasChanged)),this._renderList=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"postProcesses",{get:function(){return this._postProcesses},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_prePassEnabled",{get:function(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderPassIds",{get:function(){return this._renderPassIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentRefreshId",{get:function(){return this._currentRefreshId},enumerable:!1,configurable:!0}),t.prototype.setMaterialForRendering=function(e,t){var i;i=Array.isArray(e)?e:[e];for(var r=0;r0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},t.prototype.getRenderSize=function(){return this.getRenderWidth()},t.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},t.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},t.prototype.getRenderLayers=function(){var e=this._size.layers;return e||(this._size.depth||0)},t.prototype.disableRescaling=function(){this._canRescale=!1},Object.defineProperty(t.prototype,"canRescale",{get:function(){return this._canRescale},enumerable:!1,configurable:!0}),t.prototype.scale=function(e){var t=Math.max(1,this.getRenderSize()*e);this.resize(t)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:e.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){var t,i=this.isCube;null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null;var r=this.getScene();r&&(this._processSizeParameter(e,!1),this._renderTarget=i?r.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):r.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==this._renderTargetOptions.samples&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1),this._render(e,t)},t.prototype.isReadyForRendering=function(){return this._render(!1,!1,!0)},t.prototype._render=function(e,t,i){var r;void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1);var n=this.getScene();if(!n)return i;var o=n.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){if(!this.renderListPredicate){this.renderList=[];for(var a=0;a=0&&i.customRenderTargets.splice(r,1);for(var n=0,o=i.cameras;n=0&&a.customRenderTargets.splice(r,1)}null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null,this._texture=null,e.prototype.dispose.call(this)}},t.prototype._rebuild=function(){this.refreshRate===t.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=t.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},t.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},t.prototype.getViewCount=function(){return 1},t.REFRESHRATE_RENDER_ONCE=0,t.REFRESHRATE_RENDER_ONEVERYFRAME=1,t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,t}(Ja);Ja._CreateRenderTargetTexture=function(e,t,i,r,n){return new Pl(e,t,i,r)};var Il=function(){function e(e){this.name=Vr.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=[]}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(Vr.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){rr.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var e=0;e0)}},e}();li.ShadersStore.proceduralVertexShader="attribute vec2 position;varying vec2 vPosition;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvPosition=position;vUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";var Ml,Ol=function(e){function t(t,i,r,n,o,a,s,l){void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===l&&(l=u.TEXTURETYPE_UNSIGNED_INT);var c,h=this;(h=e.call(this,null,n,!a)||this).isEnabled=!0,h.autoClear=!0,h.onGeneratedObservable=new f,h.onBeforeGenerationObservable=new f,h.nodeMaterialSource=null,h._textures={},h._currentRefreshId=-1,h._frameId=-1,h._refreshRate=1,h._vertexBuffers={},h._uniforms=new Array,h._samplers=new Array,h._floats={},h._ints={},h._floatsArrays={},h._colors3={},h._colors4={},h._vectors2={},h._vectors3={},h._vectors4={},h._matrices={},h._fallbackTextureUsed=!1,h._cachedDefines=null,h._contentUpdateId=-1,h._rtWrapper=null,null===o||o instanceof Ja?(h._options={},h._fallbackTexture=o):(h._options=o,h._fallbackTexture=null!==(c=o.fallbackTexture)&&void 0!==c?c:null);var d=(n=h.getScene()||M.LastCreatedScene)._getComponent(Vr.NAME_PROCEDURALTEXTURE);d||(d=new Il(n),n._addComponent(d)),n.proceduralTextures.push(h),h._fullEngine=n.getEngine(),h.name=t,h.isRenderTarget=!0,h._size=i,h._textureType=l,h._generateMipMaps=a,h._drawWrapper=new ho(h._fullEngine),h.setFragment(r);var p=h._createRtWrapper(s,i,a,l);h._texture=p.texture;var _=[];return _.push(1,1),_.push(-1,1),_.push(-1,-1),_.push(1,-1),h._vertexBuffers[Nr.PositionKind]=new Nr(h._fullEngine,_,Nr.PositionKind,!1,!1,2),h._createIndexBuffer(),h}return m(t,e),t.prototype._createRtWrapper=function(e,t,i,r){return e?(this._rtWrapper=this._fullEngine.createRenderTargetCubeTexture(t,g({generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:r},this._options)),this.setFloat("face",0)):this._rtWrapper=this._fullEngine.createRenderTargetTexture(t,g({generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:r},this._options)),this._rtWrapper},t.prototype.getEffect=function(){return this._drawWrapper.effect},t.prototype._setEffect=function(e){this._drawWrapper.effect=e},t.prototype.getContent=function(){var e=this;return this._contentData&&this._frameId===this._contentUpdateId||(this._contentData?this._contentData.then((function(t){e._contentData=e.readPixels(0,0,t),e._contentUpdateId=e._frameId})):(this._contentData=this.readPixels(0,0),this._contentUpdateId=this._frameId)),this._contentData},t.prototype._createIndexBuffer=function(){var e=this._fullEngine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},t.prototype._rebuild=function(){var e=this._vertexBuffers[Nr.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===Pl.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Pl.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){var e;null===(e=this._drawWrapper.effect)||void 0===e||e.dispose(),this._drawWrapper.effect=null,this._cachedDefines=null},t.prototype._getDefines=function(){return""},t.prototype.executeWhenReady=function(e){var t=this;if(this.isReady())e(this);else{var i=this.getEffect();i&&i.executeWhenCompiled((function(){e(t)}))}},t.prototype.isReady=function(){var e=this,t=this._fullEngine;if(this.nodeMaterialSource)return this._drawWrapper.effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;if(!this._texture)return!1;var i=this._getDefines();if(this._drawWrapper.effect&&i===this._cachedDefines&&this._drawWrapper.effect.isReady())return!0;var r={vertex:"procedural",fragmentElement:this._fragment.fragmentElement,fragmentSource:this._fragment.fragmentSource,fragment:"string"==typeof this._fragment?this._fragment:void 0};return this._cachedDefines!==i&&(this._cachedDefines=i,this._drawWrapper.effect=t.createEffect(r,[Nr.PositionKind],this._uniforms,this._samplers,i,void 0,void 0,(function(){var t;null===(t=e._rtWrapper)||void 0===t||t.dispose(),e._rtWrapper=e._texture=null,e._fallbackTexture&&(e._texture=e._fallbackTexture._texture,e._texture&&e._texture.incrementReferences()),e._fallbackTextureUsed=!0}))),this._drawWrapper.effect.isReady()},t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},t.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!1,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,this._frameId++,!0):(this._currentRefreshId++,!1)):(this._texture&&(this._texture.isReady=!1),!1)},t.prototype.getRenderSize=function(){return this._size},t.prototype.resize=function(e,t){if(!this._fallbackTextureUsed&&this._rtWrapper&&this._texture){var i=this._texture.isCube;this._rtWrapper.dispose();var r=this._createRtWrapper(i,e,t,this._textureType);this._texture=r.texture,this._size=e,this._generateMipMaps=t}},t.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.render=function(e){var t,i,r=this.getScene();if(r){var n=this._fullEngine;if(n.enableEffect(this._drawWrapper),this.onBeforeGenerationObservable.notifyObservers(this),n.setState(!1),!this.nodeMaterialSource){for(var o in this._textures)this._drawWrapper.effect.setTexture(o,this._textures[o]);for(var a in this._ints)this._drawWrapper.effect.setInt(a,this._ints[a]);for(var s in this._floats)this._drawWrapper.effect.setFloat(s,this._floats[s]);for(var l in this._floatsArrays)this._drawWrapper.effect.setArray(l,this._floatsArrays[l]);for(var c in this._colors3)this._drawWrapper.effect.setColor3(c,this._colors3[c]);for(var u in this._colors4){var h=this._colors4[u];this._drawWrapper.effect.setFloat4(u,h.r,h.g,h.b,h.a)}for(var d in this._vectors2)this._drawWrapper.effect.setVector2(d,this._vectors2[d]);for(var p in this._vectors3)this._drawWrapper.effect.setVector3(p,this._vectors3[p]);for(var f in this._vectors4)this._drawWrapper.effect.setVector4(f,this._vectors4[f]);for(var _ in this._matrices)this._drawWrapper.effect.setMatrix(_,this._matrices[_])}if(this._texture&&this._rtWrapper){null===(t=n._debugPushGroup)||void 0===t||t.call(n,"procedural texture generation for ".concat(this.name),1);var m=n.currentViewport;if(this.isCube)for(var g=0;g<6;g++)n.bindFramebuffer(this._rtWrapper,g,void 0,void 0,!0),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._drawWrapper.effect.setFloat("face",g),this.autoClear&&n.clear(r.clearColor,!0,!1,!1),n.drawElementsType(Ca.TriangleFillMode,0,6);else n.bindFramebuffer(this._rtWrapper,0,void 0,void 0,!0),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this.autoClear&&n.clear(r.clearColor,!0,!1,!1),n.drawElementsType(Ca.TriangleFillMode,0,6);n.unBindFramebuffer(this._rtWrapper,this.isCube),m&&n.setViewport(m),this.isCube&&n.generateMipMapsForCubemap(this._texture,!0),null===(i=n._debugPopGroup)||void 0===i||i.call(n,1),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,i},t.prototype.dispose=function(){var t=this.getScene();if(t){var i=t.proceduralTextures.indexOf(this);i>=0&&t.proceduralTextures.splice(i,1);var r=this._vertexBuffers[Nr.PositionKind];r&&(r.dispose(),this._vertexBuffers[Nr.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),e.prototype.dispose.call(this)}},v([Ie()],t.prototype,"isEnabled",void 0),v([Ie()],t.prototype,"autoClear",void 0),v([Ie()],t.prototype,"_generateMipMaps",void 0),v([Ie()],t.prototype,"_size",void 0),v([Ie()],t.prototype,"refreshRate",null),t}(Ja);a("BABYLON.ProceduralTexture",Ol),function(e){e[e.Cos=0]="Cos",e[e.Sin=1]="Sin",e[e.Abs=2]="Abs",e[e.Exp=3]="Exp",e[e.Exp2=4]="Exp2",e[e.Round=5]="Round",e[e.Floor=6]="Floor",e[e.Ceiling=7]="Ceiling",e[e.Sqrt=8]="Sqrt",e[e.Log=9]="Log",e[e.Tan=10]="Tan",e[e.ArcTan=11]="ArcTan",e[e.ArcCos=12]="ArcCos",e[e.ArcSin=13]="ArcSin",e[e.Fract=14]="Fract",e[e.Sign=15]="Sign",e[e.Radians=16]="Radians",e[e.Degrees=17]="Degrees",e[e.Set=18]="Set"}(Ml||(Ml={}));var Dl=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.operation=Ml.Cos,i.registerInput("input",Ns.AutoDetect),i.registerOutput("output",Ns.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return m(t,e),t.prototype.getClassName=function(){return"TrigonometryBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],r="";switch(this.operation){case Ml.Cos:r="cos";break;case Ml.Sin:r="sin";break;case Ml.Abs:r="abs";break;case Ml.Exp:r="exp";break;case Ml.Exp2:r="exp2";break;case Ml.Round:r="round";break;case Ml.Floor:r="floor";break;case Ml.Ceiling:r="ceil";break;case Ml.Sqrt:r="sqrt";break;case Ml.Log:r="log";break;case Ml.Tan:r="tan";break;case Ml.ArcTan:r="atan";break;case Ml.ArcCos:r="acos";break;case Ml.ArcSin:r="asin";break;case Ml.Fract:r="fract";break;case Ml.Sign:r="sign";break;case Ml.Radians:r="radians";break;case Ml.Degrees:r="degrees";break;case Ml.Set:r=""}return t.compilationString+=t._declareOutput(i)+" = ".concat(r,"(").concat(this.input.associatedVariableName,");\n"),this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.operation=this.operation,t},t.prototype._deserialize=function(t,i,r){e.prototype._deserialize.call(this,t,i,r),this.operation=t.operation},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".operation = BABYLON.TrigonometryBlockOperations.").concat(Ml[this.operation],";\n")},t}(Ws);a("BABYLON.TrigonometryBlock",Dl);var Nl={effect:null,subMesh:null},Fl=function(e){function t(){var t=e.call(this)||this;return t.NORMAL=!1,t.TANGENT=!1,t.VERTEXCOLOR_NME=!1,t.UV1=!1,t.UV2=!1,t.UV3=!1,t.UV4=!1,t.UV5=!1,t.UV6=!1,t.PREPASS=!1,t.PREPASS_NORMAL=!1,t.PREPASS_NORMAL_INDEX=-1,t.PREPASS_POSITION=!1,t.PREPASS_POSITION_INDEX=-1,t.PREPASS_DEPTH=!1,t.PREPASS_DEPTH_INDEX=-1,t.SCENE_MRT_COUNT=0,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_UV=!1,t.NUM_MORPH_INFLUENCERS=0,t.MORPHTARGETS_TEXTURE=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=0,t.CONTRAST=!1,t.EXPOSURE=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.DITHER=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.SKIPFINALCOLORCLAMP=!1,t.BUMPDIRECTUV=0,t.CAMERA_ORTHOGRAPHIC=!1,t.CAMERA_PERSPECTIVE=!1,t.rebuild(),t}return m(t,e),t.prototype.setValue=function(e,t,i){void 0===i&&(i=!1),void 0===this[e]&&this._keys.push(e),i&&this[e]!==t&&this.markAsUnprocessed(),this[e]=t},t}(Gs),Ll=function(e){function t(i,r,n){void 0===n&&(n={});var o=e.call(this,i,r||M.LastCreatedScene)||this;return o._buildId=t._BuildIdGenerator++,o._buildWasSuccessful=!1,o._cachedWorldViewMatrix=new z,o._cachedWorldViewProjectionMatrix=new z,o._optimizers=new Array,o._animationFrame=-1,o.BJSNODEMATERIALEDITOR=o._getGlobalNodeMaterialEditor(),o.editorData=null,o.ignoreAlpha=!1,o.maxSimultaneousLights=4,o.onBuildObservable=new f,o._vertexOutputNodes=new Array,o._fragmentOutputNodes=new Array,o.attachedBlocks=[],o._mode=fl.Material,o.forceAlphaBlending=!1,o._options=g({emitComments:!1,shaderLanguage:pt.GLSL},n),o._attachImageProcessingConfiguration(null),o}return m(t,e),t._BlockIsTextureBlock=function(e){return"TextureBlock"===e.getClassName()||"ReflectionTextureBaseBlock"===e.getClassName()||"ReflectionTextureBlock"===e.getClassName()||"ReflectionBlock"===e.getClassName()||"RefractionBlock"===e.getClassName()||"CurrentScreenBlock"===e.getClassName()||"ParticleTextureBlock"===e.getClassName()||"ImageSourceBlock"===e.getClassName()||"TriPlanarBlock"===e.getClassName()||"BiPlanarBlock"===e.getClassName()||"PrePassTextureBlock"===e.getClassName()},t.prototype._getGlobalNodeMaterialEditor=function(){return"undefined"!=typeof NODEEDITOR?NODEEDITOR:"undefined"!=typeof BABYLON&&void 0!==BABYLON.NodeEditor?BABYLON:void 0},Object.defineProperty(t.prototype,"shaderLanguage",{get:function(){return this._options.shaderLanguage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buildId",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"NodeMaterial"},t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){t._markAllSubMeshesAsImageProcessingDirty()}))))},t.prototype.getBlockByName=function(e){for(var t=null,i=0,r=this.attachedBlocks;i-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var t=this._optimizers.indexOf(e);if(-1!==t)return this._optimizers.splice(t,1),this},t.prototype.addOutputNode=function(e){if(null===e.target)throw"This node is not meant to be an output node. You may want to explicitly set its target value.";return e.target&Fs.Vertex&&this._addVertexOutputNode(e),e.target&Fs.Fragment&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(e.target&Fs.Vertex&&this._removeVertexOutputNode(e),e.target&Fs.Fragment&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=Fs.Vertex,this._vertexOutputNodes.push(e),this},t.prototype._removeVertexOutputNode=function(e){var t=this._vertexOutputNodes.indexOf(e);if(-1!==t)return this._vertexOutputNodes.splice(t,1),this},t.prototype._addFragmentOutputNode=function(e){if(-1===this._fragmentOutputNodes.indexOf(e))return e.target=Fs.Fragment,this._fragmentOutputNodes.push(e),this},t.prototype._removeFragmentOutputNode=function(e){var t=this._fragmentOutputNodes.indexOf(e);if(-1!==t)return this._fragmentOutputNodes.splice(t,1),this},t.prototype.needAlphaBlending=function(){return!this.ignoreAlpha&&(this.forceAlphaBlending||this.alpha<1||this._sharedData&&this._sharedData.hints.needAlphaBlending)},t.prototype.needAlphaTesting=function(){return this._sharedData&&this._sharedData.hints.needAlphaTesting},t.prototype._processInitializeOnLink=function(e,t,i,r){void 0===r&&(r=!0),(e.target===Fs.VertexAndFragment||t.target===Fs.Fragment&&e.target===Fs.Vertex&&e._preparationId!==this._buildId)&&i.push(e),this._initializeBlock(e,t,i,r)},t.prototype._initializeBlock=function(e,t,i,r){if(void 0===r&&(r=!0),e.initialize(t),r&&e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var n=e.getClassName(),o=0,a=this.attachedBlocks;o-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e,i,r){void 0===e&&(e=!1),void 0===i&&(i=!0),void 0===r&&(r=!1),this._vertexCompilationState||r||(r=!0),this._buildWasSuccessful=!1;var n=this.getScene().getEngine(),o=this._mode===fl.Particle;if(0===this._vertexOutputNodes.length&&!o)throw"You must define at least one vertexOutputNode";if(0===this._fragmentOutputNodes.length)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new Vs,this._vertexCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._vertexCompilationState.target=Fs.Vertex,this._fragmentCompilationState=new Vs,this._fragmentCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._fragmentCompilationState.target=Fs.Fragment,this._sharedData=new ks,this._sharedData.nodeMaterial=this,this._sharedData.fragmentOutputNodes=this._fragmentOutputNodes,this._vertexCompilationState.sharedData=this._sharedData,this._fragmentCompilationState.sharedData=this._sharedData,this._sharedData.buildId=this._buildId,this._sharedData.emitComments=this._options.emitComments,this._sharedData.verbose=e,this._sharedData.scene=this.getScene(),this._sharedData.allowEmptyVertexProgram=o;for(var a=[],s=[],l=0,c=this._vertexOutputNodes;l1){var i=e.getEffectConfiguration("nodeMaterial");i||(i=e.addEffectConfiguration({enabled:!0,needsImageProcessing:!1,name:"nodeMaterial",texturesRequired:[]}));for(var r=0,n=t;r1},t.prototype.createPostProcess=function(e,t,i,r,n,o,a){return void 0===t&&(t=1),void 0===i&&(i=u.TEXTURE_NEAREST_SAMPLINGMODE),void 0===o&&(o=u.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=u.TEXTUREFORMAT_RGBA),this.mode!==fl.PostProcess?(ae.Log("Incompatible material mode"),null):this._createEffectForPostProcess(null,e,t,i,r,n,o,a)},t.prototype.createEffectForPostProcess=function(e){this._createEffectForPostProcess(e)},t.prototype._createEffectForPostProcess=function(e,t,i,r,n,o,a,s){var l=this;void 0===i&&(i=1),void 0===r&&(r=u.TEXTURE_NEAREST_SAMPLINGMODE),void 0===a&&(a=u.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=u.TEXTUREFORMAT_RGBA);var c=this.name+this._buildId,h=new Fl,d=new Uo(c+"PostProcess",this.getScene()),p=this._buildId;return this._processDefines(d,h),Ei.RegisterShader(c,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString),e?e.updateEffect(h.toString(),this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,{maxSimultaneousLights:this.maxSimultaneousLights},void 0,void 0,c,c):e=new hl(this.name+"PostProcess",c,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,t,r,n,o,h.toString(),a,c,{maxSimultaneousLights:this.maxSimultaneousLights},!1,s),e.nodeMaterialSource=this,e.onApplyObservable.add((function(t){p!==l._buildId&&(delete Ei.ShadersStore[c+"VertexShader"],delete Ei.ShadersStore[c+"PixelShader"],c=l.name+l._buildId,h.markAllAsDirty(),p=l._buildId),l._processDefines(d,h)&&(Ei.RegisterShader(c,l._fragmentCompilationState._builtCompilationString,l._vertexCompilationState._builtCompilationString),si.SetImmediate((function(){return e.updateEffect(h.toString(),l._fragmentCompilationState.uniforms,l._fragmentCompilationState.samplers,{maxSimultaneousLights:l.maxSimultaneousLights},void 0,void 0,c,c)}))),l._checkInternals(t)})),e},t.prototype.createProceduralTexture=function(e,t){var i=this;if(this.mode!==fl.ProceduralTexture)return ae.Log("Incompatible material mode"),null;var r=this.name+this._buildId,n=new Ol(r,e,null,t),o=new Uo(r+"Procedural",this.getScene());o.reservedDataStore={hidden:!0};var a=new Fl,s=this._processDefines(o,a);Ei.RegisterShader(r,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString);var l=this.getScene().getEngine().createEffect({vertexElement:r,fragmentElement:r},[Nr.PositionKind],this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,a.toString(),null==s?void 0:s.fallbacks,void 0);n.nodeMaterialSource=this,n._setEffect(l);var c=this._buildId;return n.onBeforeGenerationObservable.add((function(){c!==i._buildId&&(delete Ei.ShadersStore[r+"VertexShader"],delete Ei.ShadersStore[r+"PixelShader"],r=i.name+i._buildId,a.markAllAsDirty(),c=i._buildId);var e=i._processDefines(o,a);e&&(Ei.RegisterShader(r,i._fragmentCompilationState._builtCompilationString,i._vertexCompilationState._builtCompilationString),si.SetImmediate((function(){l=i.getScene().getEngine().createEffect({vertexElement:r,fragmentElement:r},[Nr.PositionKind],i._fragmentCompilationState.uniforms,i._fragmentCompilationState.samplers,a.toString(),null==e?void 0:e.fallbacks,void 0),n._setEffect(l)}))),i._checkInternals(l)})),n},t.prototype._createEffectForParticles=function(e,t,i,r,n,o,a,s){var l=this;void 0===s&&(s="");var c=this.name+this._buildId+"_"+t;o||(o=new Fl),a||(a=this.getScene().getMeshByName(this.name+"Particle"))||((a=new Uo(this.name+"Particle",this.getScene())).reservedDataStore={hidden:!0});var u=this._buildId,h=[],d=s;if(!n){var p=this._processDefines(a,o);Ei.RegisterShader(c,this._fragmentCompilationState._builtCompilationString),e.fillDefines(h,t),d=h.join("\n"),n=this.getScene().getEngine().createEffectForParticles(c,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,o.toString()+"\n"+d,null==p?void 0:p.fallbacks,i,r,e),e.setCustomEffect(n,t)}n.onBindObservable.add((function(n){u!==l._buildId&&(delete Ei.ShadersStore[c+"PixelShader"],c=l.name+l._buildId+"_"+t,o.markAllAsDirty(),u=l._buildId),h.length=0,e.fillDefines(h,t);var p=h.join("\n");p!==d&&(o.markAllAsDirty(),d=p);var f=l._processDefines(a,o);if(f)return Ei.RegisterShader(c,l._fragmentCompilationState._builtCompilationString),n=l.getScene().getEngine().createEffectForParticles(c,l._fragmentCompilationState.uniforms,l._fragmentCompilationState.samplers,o.toString()+"\n"+d,null==f?void 0:f.fallbacks,i,r,e),e.setCustomEffect(n,t),void l._createEffectForParticles(e,t,i,r,n,o,a,s);l._checkInternals(n)}))},t.prototype._checkInternals=function(e){if(this._sharedData.animatedInputs){var t=this.getScene(),i=t.getFrameId();if(this._animationFrame!==i){for(var r=0,n=this._sharedData.animatedInputs;r0&&a.lengthSquared()-l2*this.palmUpStrictness-1&&(t=!0)}}this._node.setEnabled(t&&i)},e.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver)},e.prototype.linkToXRExperience=function(e){var t=e.featuresManager?e.featuresManager:e;if(t){try{this._eyeTracking=t.getEnabledFeature(Ss.EYE_TRACKING)}catch(e){}try{this._handTracking=t.getEnabledFeature(Ss.HAND_TRACKING)}catch(e){rr.Error("Hand tracking must be enabled for the Hand Menu to work")}}else rr.Error("XR features manager must be available or provided directly for the Hand Menu to work")},e}(),Zl=function(){function e(e,t,i){this.targetPosition=V.Zero(),this.poleTargetPosition=V.Zero(),this.poleTargetLocalOffset=V.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=G.Identity(),this._bone1Mat=z.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=V.Right(),this._slerping=!1,this._adjustRoll=0,this._notEnoughInformation=!1,this._bone2=t;var r=t.getParent();if(!r)return this._notEnoughInformation=!0,void ae.Error("BoneIKController: bone must have a parent for IK to work.");if(this._bone1=r,0===this._bone2.children.length&&!this._bone2.length)return this._notEnoughInformation=!0,void ae.Error("BoneIKController: bone must not be a leaf or it should have a length for IK to work.");this.mesh=e,t.getSkeleton().computeAbsoluteMatrices();var n=t.getPosition();if(t.getAbsoluteMatrix().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length&&this._bone2.length){var o=this._bone1.getScale(),a=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*a.y*this.mesh.scaling.y}else if(this._bone2.children[0]){e.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(e),l=this._bone2.getAbsolutePosition(e),c=this._bone1.getAbsolutePosition(e);this._bone2Length=V.Distance(s,l),this._bone1Length=V.Distance(l,c)}else e.computeWorldMatrix(!0),a=this._bone2.getScale(),this._bone2Length=this._bone2.length*a.y*this.mesh.scaling.y,l=this._bone2.getAbsolutePosition(e),c=this._bone1.getAbsolutePosition(e),this._bone1Length=V.Distance(l,c);this._bone1.getRotationMatrixToRef(dn.WORLD,e,this._bone1Mat),this.maxAngle=Math.PI,i&&(i.targetMesh&&(this.targetMesh=i.targetMesh,this.targetMesh.computeWorldMatrix(!0)),i.poleTargetMesh?(this.poleTargetMesh=i.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):i.poleTargetBone?this.poleTargetBone=i.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),i.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),i.poleAngle&&(this.poleAngle=i.poleAngle),i.bendAxis&&this._bendAxis.copyFrom(i.bendAxis),i.maxAngle&&(this.maxAngle=i.maxAngle),i.slerpAmount&&(this.slerpAmount=i.slerpAmount))}return Object.defineProperty(e.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!1,configurable:!0}),e.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},e.prototype.update=function(){if(!this._notEnoughInformation){var t=this.targetPosition,i=this.poleTargetPosition,r=e._TmpMats[0],n=e._TmpMats[1];this.targetMesh&&t.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,i):this.poleTargetMesh&&V.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),i);var o=e._TmpVecs[0],a=e._TmpVecs[1],s=e._TmpVecs[2],l=e._TmpVecs[3],c=e._TmpVecs[4],u=e._TmpQuat;this._bone1.getAbsolutePositionToRef(this.mesh,o),i.subtractToRef(o,c),0==c.x&&0==c.y&&0==c.z?c.y=1:c.normalize(),t.subtractToRef(o,l),l.normalize(),V.CrossToRef(l,c,a),a.normalize(),V.CrossToRef(l,a,s),s.normalize(),z.FromXYZAxesToRef(s,l,a,r);var h=this._bone1Length,d=this._bone2Length,p=V.Distance(o,t);this._maxReach>0&&(p=Math.min(this._maxReach,p));var f=(d*d+p*p-h*h)/(2*d*p),_=(p*p+h*h-d*d)/(2*p*h);f>1&&(f=1),_>1&&(_=1),f<-1&&(f=-1),_<-1&&(_=-1);var m=Math.acos(f),g=Math.acos(_),v=-m-g;if(this._rightHandedSystem)z.RotationYawPitchRollToRef(0,0,this._adjustRoll,n),n.multiplyToRef(r,r),z.RotationAxisToRef(this._bendAxis,g,n),n.multiplyToRef(r,r);else{var y=e._TmpVecs[5];y.copyFrom(this._bendAxis),y.x*=-1,z.RotationAxisToRef(y,-g,n),n.multiplyToRef(r,r)}this.poleAngle&&(z.RotationAxisToRef(l,this.poleAngle,n),r.multiplyToRef(n,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||G.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),G.FromRotationMatrixToRef(r,u),G.SlerpToRef(this._bone1Quat,u,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,dn.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,dn.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1),this._updateLinkedTransformRotation(this._bone1)),this._bone2.setAxisAngle(this._bendAxis,v,dn.LOCAL),this._updateLinkedTransformRotation(this._bone2),this._bone2Ang=v}},e.prototype._updateLinkedTransformRotation=function(e){e._linkedTransformNode&&(e._linkedTransformNode.rotationQuaternion||(e._linkedTransformNode.rotationQuaternion=new G),e.getRotationQuaternionToRef(dn.LOCAL,null,e._linkedTransformNode.rotationQuaternion))},e._TmpVecs=[V.Zero(),V.Zero(),V.Zero(),V.Zero(),V.Zero(),V.Zero()],e._TmpQuat=G.Identity(),e._TmpMats=[z.Identity(),z.Identity()],e}(),Jl=function(){function e(e,t,i,r){if(this.upAxis=V.Up(),this.upAxisSpace=dn.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=G.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=V.Forward(),this.useAbsoluteValueForYaw=!1,this.mesh=e,this.bone=t,this.target=i,r){if(r.adjustYaw&&(this.adjustYaw=r.adjustYaw),r.adjustPitch&&(this.adjustPitch=r.adjustPitch),r.adjustRoll&&(this.adjustRoll=r.adjustRoll),null!=r.maxYaw?this.maxYaw=r.maxYaw:this.maxYaw=Math.PI,null!=r.minYaw?this.minYaw=r.minYaw:this.minYaw=-Math.PI,null!=r.maxPitch?this.maxPitch=r.maxPitch:this.maxPitch=Math.PI,null!=r.minPitch?this.minPitch=r.minPitch:this.minPitch=-Math.PI,null!=r.slerpAmount&&(this.slerpAmount=r.slerpAmount),null!=r.upAxis&&(this.upAxis=r.upAxis),null!=r.upAxisSpace&&(this.upAxisSpace=r.upAxisSpace),null!=r.yawAxis||null!=r.pitchAxis){var n=_n.Y,o=_n.X;null!=r.yawAxis&&(n=r.yawAxis.clone()).normalize(),null!=r.pitchAxis&&(o=r.pitchAxis.clone()).normalize();var a=V.Cross(o,n);this._transformYawPitch=z.Identity(),z.FromXYZAxesToRef(o,n,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}void 0!==r.useAbsoluteValueForYaw&&(this.useAbsoluteValueForYaw=r.useAbsoluteValueForYaw)}t.getParent()||this.upAxisSpace!=dn.BONE||(this.upAxisSpace=dn.LOCAL)}return Object.defineProperty(e.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,i=e._TmpVecs[0];t.getAbsolutePositionToRef(this.mesh,i);var r=this.target,n=e._TmpMats[0],o=e._TmpMats[1],a=this.mesh,s=t.getParent(),l=e._TmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==dn.BONE&&s?(this._transformYawPitch&&V.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),s.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==dn.LOCAL&&(a.getDirectionToRef(l,l),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||l.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var h=e._TmpMats[2],d=e._TmpMats[3];if(this.upAxisSpace==dn.BONE&&1==l.y&&s)s.getRotationMatrixToRef(dn.WORLD,this.mesh,h);else if(this.upAxisSpace!=dn.LOCAL||1!=l.y||s){var p=e._TmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&V.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),s?s.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var f=V.Cross(l,p);f.normalize(),p=V.Cross(f,l),z.FromXYZAxesToRef(f,l,p,h)}else h.copyFrom(a.getWorldMatrix());h.invertToRef(d);var _=null;if(u){var m=e._TmpVecs[3];r.subtractToRef(i,m),V.TransformCoordinatesToRef(m,d,m),_=Math.sqrt(m.x*m.x+m.z*m.z);var g=Math.atan2(m.y,_),v=g;g>this._maxPitch?(m.y=this._maxPitchTan*_,v=this._maxPitch):gthis._maxYaw||bMath.PI?this._isAngleBetween(y,this._maxYaw,this._midYawConstraint)?(m.z=this._maxYawCos*_,m.x=this._maxYawSin*_,T=this._maxYaw):this._isAngleBetween(y,this._midYawConstraint,this._minYaw)&&(m.z=this._minYawCos*_,m.x=this._minYawSin*_,T=this._minYaw):b>this._maxYaw?(m.z=this._maxYawCos*_,m.x=this._maxYawSin*_,y<0&&this.useAbsoluteValueForYaw&&(m.x*=-1),T=this._maxYaw):bMath.PI){var E=e._TmpVecs[8];E.copyFrom(_n.Z),this._transformYawPitch&&V.TransformCoordinatesToRef(E,this._transformYawPitchInv,E);var S=e._TmpMats[4];this._boneQuat.toRotationMatrix(S),this.mesh.getWorldMatrix().multiplyToRef(S,S),V.TransformCoordinatesToRef(E,S,E),V.TransformCoordinatesToRef(E,d,E);var x=Math.atan2(E.x,E.z);if(this._getAngleBetween(x,y)>this._getAngleBetween(x,this._midYawConstraint)){null==_&&(_=Math.sqrt(m.x*m.x+m.z*m.z));var A=this._getAngleBetween(x,this._maxYaw);this._getAngleBetween(x,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},e.prototype._getAngleBetween=function(e,t){var i=0;return(i=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(i=2*Math.PI-i),i},e.prototype._isAngleBetween=function(e,t,i){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(i=(i%=2*Math.PI)<0?i+2*Math.PI:i)){if(e>t&&ei&&e=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!1,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!1,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e.DUALSHOCK=4,e}(),sc=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.onButtonDownObservable=new f,n.onButtonUpObservable=new f,n.type=ac.GENERIC,n._buttons=new Array(r.buttons.length),n}return m(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},e.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},v([Ie()],e.prototype,"gamepadRotationSensibility",void 0),v([Ie()],e.prototype,"gamepadMoveSensibility",void 0),e}();rc.ArcRotateCameraGamepadInput=lc;var cc=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=rr.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var r,n=i.event;n.metaKey||(i.type===Xr.KEYDOWN?(t._ctrlPressed=n.ctrlKey,t._altPressed=n.altKey,(-1!==t.keysUp.indexOf(n.keyCode)||-1!==t.keysDown.indexOf(n.keyCode)||-1!==t.keysLeft.indexOf(n.keyCode)||-1!==t.keysRight.indexOf(n.keyCode)||-1!==t.keysReset.indexOf(n.keyCode))&&(-1===(r=t._keys.indexOf(n.keyCode))&&t._keys.push(n.keyCode),n.preventDefault&&(e||n.preventDefault()))):-1===t.keysUp.indexOf(n.keyCode)&&-1===t.keysDown.indexOf(n.keyCode)&&-1===t.keysLeft.indexOf(n.keyCode)&&-1===t.keysRight.indexOf(n.keyCode)&&-1===t.keysReset.indexOf(n.keyCode)||((r=t._keys.indexOf(n.keyCode))>=0&&t._keys.splice(r,1),n.preventDefault&&(e||n.preventDefault())))})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t0?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e){var t=this;e=rr.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i){if(i.type===Gr.POINTERWHEEL){var r=i.event,n=0,o=r.deltaMode===Qr.DOM_DELTA_LINE?40:1,a=-r.deltaY*o;if(t.customComputeDeltaFromMouseWheel)n=t.customComputeDeltaFromMouseWheel(a,t,r);else if(t.wheelDeltaPercentage){if((n=t._computeDeltaFromMouseWheelLegacyEvent(a,t.camera.radius))>0){for(var s=t.camera.radius,l=t.camera.inertialRadiusOffset+n,c=0;c<20&&Math.abs(l)>.001;c++)s-=l,l*=t.camera.inertia;s=j.Clamp(s,0,Number.MAX_VALUE),n=t._computeDeltaFromMouseWheelLegacyEvent(a,s)}}else n=a/(40*t.wheelPrecision);n&&(t.zoomToMouseLocation?(t._hitPlane||t._updateHitPlane(),t._zoomToMouse(n)):t.camera.inertialRadiusOffset+=n),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,Gr.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)},e.prototype.detachControl=function(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)},e.prototype.checkInputs=function(){if(this.zoomToMouseLocation){var e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},e.prototype._updateHitPlane=function(){var e=this.camera,t=e.target.subtract(e.position);this._hitPlane=sn.FromPositionAndNormal(e.target,t)},e.prototype._getPosition=function(){var e,t=this.camera,i=t.getScene(),r=i.createPickingRay(i.pointerX,i.pointerY,z.Identity(),t,!1);0===t.targetScreenOffset.x&&0===t.targetScreenOffset.y||(this._viewOffset.set(t.targetScreenOffset.x,t.targetScreenOffset.y,0),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),this._globalOffset=V.TransformNormal(this._viewOffset,t._cameraTransformMatrix),r.origin.addInPlace(this._globalOffset));var n=0;return this._hitPlane&&(n=null!==(e=r.intersectsPlane(this._hitPlane))&&void 0!==e?e:0),r.origin.addInPlace(r.direction.scaleInPlace(n))},e.prototype._zoomToMouse=function(e){var t,i,r=this.camera,n=1-r.inertia;if(r.lowerRadiusLimit){var o=null!==(t=r.lowerRadiusLimit)&&void 0!==t?t:0;r.radius-(r.inertialRadiusOffset+e)/na&&(e=(r.radius-a)*n-r.inertialRadiusOffset)}var s=e/n/r.radius,l=this._getPosition(),c=H.Vector3[6];l.subtractToRef(r.target,c),c.scaleInPlace(s),c.scaleInPlace(n),this._inertialPanning.addInPlace(c),r.inertialRadiusOffset+=e},e.prototype._zeroIfClose=function(e){Math.abs(e.x)this.camera.pinchToPanMaxDistance?(this._computePinchZoom(i,r),this._isPinching=!0):this._computeMultiTouchPanning(n,o)):this.multiTouchPanning?this._computeMultiTouchPanning(n,o):this.pinchZoom&&this._computePinchZoom(i,r))},t.prototype.onButtonDown=function(e){this._isPanClick=e.button===this.camera._panningMouseButton},t.prototype.onButtonUp=function(e){this._twoFingerActivityCount=0,this._isPinching=!1},t.prototype.onLostFocus=function(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1},t.MinimumRadiusForPinch=.001,v([Ie()],t.prototype,"buttons",void 0),v([Ie()],t.prototype,"angularSensibilityX",void 0),v([Ie()],t.prototype,"angularSensibilityY",void 0),v([Ie()],t.prototype,"pinchPrecision",void 0),v([Ie()],t.prototype,"pinchDeltaPercentage",void 0),v([Ie()],t.prototype,"useNaturalPinchZoom",void 0),v([Ie()],t.prototype,"pinchZoom",void 0),v([Ie()],t.prototype,"panningSensibility",void 0),v([Ie()],t.prototype,"multiTouchPanning",void 0),v([Ie()],t.prototype,"multiTouchPanAndZoom",void 0),t}(ic);rc.ArcRotateCameraPointersInput=hc;var dc=function(e){function t(t){return e.call(this,t)||this}return m(t,e),t.prototype.addMouseWheel=function(){return this.add(new uc),this},t.prototype.addPointers=function(){return this.add(new hc),this},t.prototype.addKeyboard=function(){return this.add(new cc),this},t}(nc);dc.prototype.addVRDeviceOrientation=function(){return this.add(new pc),this};var pc=function(){function e(){var e=this;this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=function(t){return e._onOrientationEvent(t)}}return e.prototype.attachControl=function(e){var t=this;e=rr.BackCompatCameraNoPreventDefault(arguments),this.camera.attachControl(e);var i=this.camera.getScene().getEngine().getHostWindow();i&&("undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i.addEventListener("deviceorientation",t._deviceOrientationHandler):rr.Warn("Permission not granted.")})).catch((function(e){rr.Error(e)})):i.addEventListener("deviceorientation",this._deviceOrientationHandler))},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=(0|+e.alpha)*this.alphaCorrection),null!==e.gamma&&(this._gamma=(0|+e.gamma)*this.gammaCorrection),this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();rc.ArcRotateCameraVRDeviceOrientationInput=pc;var fc=function(){function e(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=rr.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var r,n=i.event;i.type===Xr.KEYDOWN?-1===t.keysForward.indexOf(n.keyCode)&&-1===t.keysBackward.indexOf(n.keyCode)&&-1===t.keysUp.indexOf(n.keyCode)&&-1===t.keysDown.indexOf(n.keyCode)&&-1===t.keysLeft.indexOf(n.keyCode)&&-1===t.keysRight.indexOf(n.keyCode)||(-1===(r=t._keys.indexOf(n.keyCode))&&t._keys.push(n.keyCode),e||n.preventDefault()):-1===t.keysForward.indexOf(n.keyCode)&&-1===t.keysBackward.indexOf(n.keyCode)&&-1===t.keysUp.indexOf(n.keyCode)&&-1===t.keysDown.indexOf(n.keyCode)&&-1===t.keysLeft.indexOf(n.keyCode)&&-1===t.keysRight.indexOf(n.keyCode)||((r=t._keys.indexOf(n.keyCode))>=0&&t._keys.splice(r,1),e||n.preventDefault())})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.getClassName=function(){return"FlyCameraKeyboardInput"},e.prototype._onLostFocus=function(){this._keys.length=0},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t=0&&t._keys.splice(r,1),n.preventDefault&&(e||n.preventDefault())))})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.checkInputs=function(){var e=this;this._onKeyboardObserver&&this._keys.forEach((function(t){-1!==e.keysHeightOffsetIncr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset+=e.heightSensibility:-1!==e.keysHeightOffsetDecr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset-=e.heightSensibility:-1!==e.keysRotationOffsetIncr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset+=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRotationOffsetDecr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset-=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRadiusIncr.indexOf(t)&&e._modifierRadius()?e.camera.radius+=e.radiusSensibility:-1!==e.keysRadiusDecr.indexOf(t)&&e._modifierRadius()&&(e.camera.radius-=e.radiusSensibility)}))},e.prototype.getClassName=function(){return"FollowCameraKeyboardMoveInput"},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype._modifierHeightOffset=function(){return this.keysHeightOffsetModifierAlt===this._altPressed&&this.keysHeightOffsetModifierCtrl===this._ctrlPressed&&this.keysHeightOffsetModifierShift===this._shiftPressed},e.prototype._modifierRotationOffset=function(){return this.keysRotationOffsetModifierAlt===this._altPressed&&this.keysRotationOffsetModifierCtrl===this._ctrlPressed&&this.keysRotationOffsetModifierShift===this._shiftPressed},e.prototype._modifierRadius=function(){return this.keysRadiusModifierAlt===this._altPressed&&this.keysRadiusModifierCtrl===this._ctrlPressed&&this.keysRadiusModifierShift===this._shiftPressed},v([Ie()],e.prototype,"keysHeightOffsetIncr",void 0),v([Ie()],e.prototype,"keysHeightOffsetDecr",void 0),v([Ie()],e.prototype,"keysHeightOffsetModifierAlt",void 0),v([Ie()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),v([Ie()],e.prototype,"keysHeightOffsetModifierShift",void 0),v([Ie()],e.prototype,"keysRotationOffsetIncr",void 0),v([Ie()],e.prototype,"keysRotationOffsetDecr",void 0),v([Ie()],e.prototype,"keysRotationOffsetModifierAlt",void 0),v([Ie()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),v([Ie()],e.prototype,"keysRotationOffsetModifierShift",void 0),v([Ie()],e.prototype,"keysRadiusIncr",void 0),v([Ie()],e.prototype,"keysRadiusDecr",void 0),v([Ie()],e.prototype,"keysRadiusModifierAlt",void 0),v([Ie()],e.prototype,"keysRadiusModifierCtrl",void 0),v([Ie()],e.prototype,"keysRadiusModifierShift",void 0),v([Ie()],e.prototype,"heightSensibility",void 0),v([Ie()],e.prototype,"rotationSensibility",void 0),v([Ie()],e.prototype,"radiusSensibility",void 0),e}();rc.FollowCameraKeyboardMoveInput=mc;var gc=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e){var t=this;e=rr.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i){if(i.type===Gr.POINTERWHEEL){var r=i.event,n=0,o=Math.max(-1,Math.min(1,r.deltaY));t.wheelDeltaPercentage?(+t.axisControlRadius+ +t.axisControlHeight+ +t.axisControlRotation&&ae.Warn("wheelDeltaPercentage only usable when mouse wheel controls ONE axis. Currently enabled: axisControlRadius: "+t.axisControlRadius+", axisControlHeightOffset: "+t.axisControlHeight+", axisControlRotationOffset: "+t.axisControlRotation),t.axisControlRadius?n=.01*o*t.wheelDeltaPercentage*t.camera.radius:t.axisControlHeight?n=.01*o*t.wheelDeltaPercentage*t.camera.heightOffset:t.axisControlRotation&&(n=.01*o*t.wheelDeltaPercentage*t.camera.rotationOffset)):n=o*t.wheelPrecision,n&&(t.axisControlRadius?t.camera.radius+=n:t.axisControlHeight?t.camera.heightOffset-=n:t.axisControlRotation&&(t.camera.rotationOffset-=n)),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,Gr.POINTERWHEEL)},e.prototype.detachControl=function(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},v([Ie()],e.prototype,"axisControlRadius",void 0),v([Ie()],e.prototype,"axisControlHeight",void 0),v([Ie()],e.prototype,"axisControlRotation",void 0),v([Ie()],e.prototype,"wheelPrecision",void 0),v([Ie()],e.prototype,"wheelDeltaPercentage",void 0),e}();rc.FollowCameraMouseWheelInput=gc;var vc=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.angularSensibilityX=1,t.angularSensibilityY=1,t.pinchPrecision=1e4,t.pinchDeltaPercentage=0,t.axisXControlRadius=!1,t.axisXControlHeight=!1,t.axisXControlRotation=!0,t.axisYControlRadius=!1,t.axisYControlHeight=!0,t.axisYControlRotation=!1,t.axisPinchControlRadius=!0,t.axisPinchControlHeight=!1,t.axisPinchControlRotation=!1,t.warningEnable=!0,t._warningCounter=0,t}return m(t,e),t.prototype.getClassName=function(){return"FollowCameraPointersInput"},t.prototype.onTouch=function(e,t,i){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=i/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=i/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=i/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,i,r,n,o){if(!(0===i&&null===n||0===r&&null===o)){var a=(r-i)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(a*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=a*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=a*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=a*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=a),this.axisPinchControlHeight&&(this.camera.heightOffset+=a),this.axisPinchControlRadius&&(this.camera.radius-=a))}},t.prototype._warning=function(){if(this.warningEnable&&this._warningCounter++%100==0){var e="It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: ";+this.axisXControlRotation+ +this.axisXControlHeight+ +this.axisXControlRadius<=1&&ae.Warn(e+"axisXControlRotation: "+this.axisXControlRotation+", axisXControlHeight: "+this.axisXControlHeight+", axisXControlRadius: "+this.axisXControlRadius),+this.axisYControlRotation+ +this.axisYControlHeight+ +this.axisYControlRadius<=1&&ae.Warn(e+"axisYControlRotation: "+this.axisYControlRotation+", axisYControlHeight: "+this.axisYControlHeight+", axisYControlRadius: "+this.axisYControlRadius),+this.axisPinchControlRotation+ +this.axisPinchControlHeight+ +this.axisPinchControlRadius<=1&&ae.Warn(e+"axisPinchControlRotation: "+this.axisPinchControlRotation+", axisPinchControlHeight: "+this.axisPinchControlHeight+", axisPinchControlRadius: "+this.axisPinchControlRadius)}},v([Ie()],t.prototype,"angularSensibilityX",void 0),v([Ie()],t.prototype,"angularSensibilityY",void 0),v([Ie()],t.prototype,"pinchPrecision",void 0),v([Ie()],t.prototype,"pinchDeltaPercentage",void 0),v([Ie()],t.prototype,"axisXControlRadius",void 0),v([Ie()],t.prototype,"axisXControlHeight",void 0),v([Ie()],t.prototype,"axisXControlRotation",void 0),v([Ie()],t.prototype,"axisYControlRadius",void 0),v([Ie()],t.prototype,"axisYControlHeight",void 0),v([Ie()],t.prototype,"axisYControlRotation",void 0),v([Ie()],t.prototype,"axisPinchControlRadius",void 0),v([Ie()],t.prototype,"axisPinchControlHeight",void 0),v([Ie()],t.prototype,"axisPinchControlRotation",void 0),t}(ic);rc.FollowCameraPointersInput=vc;var yc=function(){function e(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this.rotationSpeed=.5,this.keysRotateLeft=[],this.keysRotateRight=[],this.keysRotateUp=[],this.keysRotateDown=[],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=rr.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var r,n=i.event;n.metaKey||(i.type===Xr.KEYDOWN?-1===t.keysUp.indexOf(n.keyCode)&&-1===t.keysDown.indexOf(n.keyCode)&&-1===t.keysLeft.indexOf(n.keyCode)&&-1===t.keysRight.indexOf(n.keyCode)&&-1===t.keysUpward.indexOf(n.keyCode)&&-1===t.keysDownward.indexOf(n.keyCode)&&-1===t.keysRotateLeft.indexOf(n.keyCode)&&-1===t.keysRotateRight.indexOf(n.keyCode)&&-1===t.keysRotateUp.indexOf(n.keyCode)&&-1===t.keysRotateDown.indexOf(n.keyCode)||(-1===(r=t._keys.indexOf(n.keyCode))&&t._keys.push(n.keyCode),e||n.preventDefault()):-1===t.keysUp.indexOf(n.keyCode)&&-1===t.keysDown.indexOf(n.keyCode)&&-1===t.keysLeft.indexOf(n.keyCode)&&-1===t.keysRight.indexOf(n.keyCode)&&-1===t.keysUpward.indexOf(n.keyCode)&&-1===t.keysDownward.indexOf(n.keyCode)&&-1===t.keysRotateLeft.indexOf(n.keyCode)&&-1===t.keysRotateRight.indexOf(n.keyCode)&&-1===t.keysRotateUp.indexOf(n.keyCode)&&-1===t.keysRotateDown.indexOf(n.keyCode)||((r=t._keys.indexOf(n.keyCode))>=0&&t._keys.splice(r,1),e||n.preventDefault()))})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t1)e.cameraRotation.x=-this._offsetY/this.touchAngularSensibility;else{var i=e._computeLocalCameraSpeed(),r=new V(0,0,0!==this.touchMoveSensibility?i*this._offsetY/this.touchMoveSensibility:0);z.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(V.TransformCoordinates(r,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},v([Ie()],e.prototype,"touchAngularSensibility",void 0),v([Ie()],e.prototype,"touchMoveSensibility",void 0),e}();rc.FreeCameraTouchInput=Sc;var xc=function(e){function t(t){var i=e.call(this,t)||this;return i._mouseInput=null,i._mouseWheelInput=null,i}return m(t,e),t.prototype.addKeyboard=function(){return this.add(new yc),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new Tc(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addMouseWheel=function(){return this._mouseWheelInput||(this._mouseWheelInput=new Ec,this.add(this._mouseWheelInput)),this},t.prototype.removeMouseWheel=function(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this},t.prototype.addTouch=function(){return this.add(new Sc),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}(nc);xc.prototype.addDeviceOrientation=function(e){return this._deviceOrientationInput||(this._deviceOrientationInput=new Ac,e&&(this._deviceOrientationInput.smoothFactor=e),this.add(this._deviceOrientationInput)),this};var Ac=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new G,this._alpha=0,this._beta=0,this._gamma=0,this.smoothFactor=0,this._onDeviceOrientationChangedObservable=new f,this._orientationChanged=function(){e._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,e._screenOrientationAngle=-rr.ToRadians(e._screenOrientationAngle/2),e._screenQuaternion.copyFromFloats(0,Math.sin(e._screenOrientationAngle),0,Math.cos(e._screenOrientationAngle))},this._deviceOrientation=function(t){e.smoothFactor?(e._alpha=null!==t.alpha?rr.SmoothAngleChange(e._alpha,t.alpha,e.smoothFactor):0,e._beta=null!==t.beta?rr.SmoothAngleChange(e._beta,t.beta,e.smoothFactor):0,e._gamma=null!==t.gamma?rr.SmoothAngleChange(e._gamma,t.gamma,e.smoothFactor):0):(e._alpha=null!==t.alpha?t.alpha:0,e._beta=null!==t.beta?t.beta:0,e._gamma=null!==t.gamma?t.gamma:0),null!==t.alpha&&e._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTranform=new G(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return e.WaitForOrientationChangeAsync=function(e){return new Promise((function(t,i){var r=!1,n=function(){window.removeEventListener("deviceorientation",n),r=!0,t()};e&&setTimeout((function(){r||(window.removeEventListener("deviceorientation",n),i("WaitForOrientationChangeAsync timed out"))}),e),"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e?window.addEventListener("deviceorientation",n):rr.Warn("Permission not granted.")})).catch((function(e){rr.Error(e)})):window.addEventListener("deviceorientation",n)}))},Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},set:function(e){var t=this;this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new G),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().getEngine().getHostWindow();if(t){var i=function(){t.addEventListener("orientationchange",e._orientationChanged),t.addEventListener("deviceorientation",e._deviceOrientation),e._orientationChanged()};"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i():rr.Warn("Permission not granted.")})).catch((function(e){rr.Error(e)})):i()}},e.prototype.detachControl=function(){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation),this._alpha=0},e.prototype.checkInputs=function(){this._alpha&&(G.RotationYawPitchRollToRef(rr.ToRadians(this._alpha),rr.ToRadians(this._beta),-rr.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},e.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"deviceOrientation"},e}();rc.FreeCameraDeviceOrientationInput=Ac;var Cc,Rc=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this.deadzoneDelta=.1,this._yAxisScale=1,this._cameraTransform=z.Identity(),this._deltaTransform=V.Zero(),this._vector3=V.Zero(),this._vector2=U.Zero()}return Object.defineProperty(e.prototype,"invertYAxis",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add((function(t){t.type!==ac.POSE_ENABLED&&(e.gamepad&&t.type!==ac.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(ac.XBOX),!this.gamepad&&t.gamepads.length&&(this.gamepad=t.gamepads[0])},e.prototype.detachControl=function(){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick;0!==this.gamepadMoveSensibility&&(t.x=Math.abs(t.x)>this.deadzoneDelta?t.x/this.gamepadMoveSensibility:0,t.y=Math.abs(t.y)>this.deadzoneDelta?t.y/this.gamepadMoveSensibility:0);var i=this.gamepad.rightStick;i&&0!==this.gamepadAngularSensibility?(i.x=Math.abs(i.x)>this.deadzoneDelta?i.x/this.gamepadAngularSensibility:0,i.y=(Math.abs(i.y)>this.deadzoneDelta?i.y/this.gamepadAngularSensibility:0)*this._yAxisScale):i={x:0,y:0},e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):z.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var r=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*r,0,-t.y*r),V.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(i.y,i.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},v([Ie()],e.prototype,"gamepadAngularSensibility",void 0),v([Ie()],e.prototype,"gamepadMoveSensibility",void 0),e}();rc.FreeCameraGamepadInput=Rc,function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(Cc||(Cc={}));var Pc=function(){function e(t,i){var r=this;this._released=!1;var n=g(g({},e._GetDefaultOptions()),i);if(this._leftJoystick=!!t,e._GlobalJoystickIndex++,this._axisTargetedByLeftAndRight=Cc.X,this._axisTargetedByUpAndDown=Cc.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new lr,this.deltaPosition=V.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(){e._VJCanvasWidth=window.innerWidth,e._VJCanvasHeight=window.innerHeight,e.Canvas&&(e.Canvas.width=e._VJCanvasWidth,e.Canvas.height=e._VJCanvasHeight),e._HalfWidth=e._VJCanvasWidth/2},!e.Canvas){window.addEventListener("resize",this._onResize,!1),e.Canvas=document.createElement("canvas"),e._VJCanvasWidth=window.innerWidth,e._VJCanvasHeight=window.innerHeight,e.Canvas.width=window.innerWidth,e.Canvas.height=window.innerHeight,e.Canvas.style.width="100%",e.Canvas.style.height="100%",e.Canvas.style.position="absolute",e.Canvas.style.backgroundColor="transparent",e.Canvas.style.top="0px",e.Canvas.style.left="0px",e.Canvas.style.zIndex="5",e.Canvas.style.touchAction="none",e.Canvas.setAttribute("touch-action","none");var o=e.Canvas.getContext("2d");if(!o)throw new Error("Unable to create canvas for virtual joystick");e._VJCanvasContext=o,e._VJCanvasContext.strokeStyle="#ffffff",e._VJCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e._HalfWidth=e.Canvas.width/2,this.pressed=!1,this.limitToContainer=n.limitToContainer,this._joystickColor=n.color,this.containerSize=n.containerSize,this.puckSize=n.puckSize,n.position&&this.setPosition(n.position.x,n.position.y),n.puckImage&&this.setPuckImage(n.puckImage),n.containerImage&&this.setContainerImage(n.containerImage),n.alwaysVisible&&e._AlwaysVisibleSticks++,this.alwaysVisible=n.alwaysVisible,this._joystickPointerId=-1,this._joystickPointerPos=new U(0,0),this._joystickPreviousPointerPos=new U(0,0),this._joystickPointerStartPos=new U(0,0),this._deltaJoystickVector=new U(0,0),this._onPointerDownHandlerRef=function(e){r._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){r._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){r._onPointerUp(e)},e.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){r._drawVirtualJoystick()}))}return e._GetDefaultOptions=function(){return{puckSize:40,containerSize:60,color:"cyan",puckImage:void 0,containerImage:void 0,position:void 0,alwaysVisible:!1,limitToContainer:!1}},e.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},e.prototype._onPointerDown=function(t){t.preventDefault(),(!0===this._leftJoystick?t.clientXe._HalfWidth)&&this._joystickPointerId<0?(this._joystickPointerId=t.pointerId,this._joystickPosition?(this._joystickPointerStartPos=this._joystickPosition.clone(),this._joystickPointerPos=this._joystickPosition.clone(),this._joystickPreviousPointerPos=this._joystickPosition.clone(),this._onPointerMove(t)):(this._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone()),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):e._GlobalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},e.prototype._onPointerMove=function(t){if(this._joystickPointerId==t.pointerId){if(this.limitToContainer){var i=new U(t.clientX-this._joystickPointerStartPos.x,t.clientY-this._joystickPointerStartPos.y),r=i.length();r>this.containerSize&&i.scaleInPlace(this.containerSize/r),this._joystickPointerPos.x=this._joystickPointerStartPos.x+i.x,this._joystickPointerPos.y=this._joystickPointerStartPos.y+i.y}else this._joystickPointerPos.x=t.clientX,this._joystickPointerPos.y=t.clientY;this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos),0=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&G.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},Object.defineProperty(t.prototype,"target",{get:function(){return this.getTarget()},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),t.prototype.getTarget=function(){return this._currentTarget},t.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(H.Matrix[0]),V.TransformNormalToRef(this.cameraDirection,H.Matrix[0],H.Vector3[0]),this._deferredPositionUpdate.addInPlace(H.Vector3[0]),void(this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate));this._deferredPositionUpdate.addInPlace(this.cameraDirection),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate)},t.prototype._checkInputs=function(){var t=this.invertRotation?-this.inverseRotationSpeed:1,i=this._decideIfNeedsToMove(),r=this.cameraRotation.x||this.cameraRotation.y;if(this._deferredUpdated=!1,this._deferredRotationUpdate.copyFrom(this.rotation),this._deferredPositionUpdate.copyFrom(this.position),this.rotationQuaternion&&this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion),i&&this._updatePosition(),r){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate),this._deferredRotationUpdate.x+=this.cameraRotation.x*t,this._deferredRotationUpdate.y+=this.cameraRotation.y*t,!this.noRotationConstraint){var n=1.570796;this._deferredRotationUpdate.x>n&&(this._deferredRotationUpdate.x=n),this._deferredRotationUpdate.x<-n&&(this._deferredRotationUpdate.x=-n)}this._deferOnly?this._deferredUpdated=!0:this.rotation.copyFrom(this._deferredRotationUpdate),this.rotationQuaternion&&this._deferredRotationUpdate.lengthSquared()&&(G.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate))}i&&(Math.abs(this.cameraDirection.x)Do.CollisionsEpsilon&&(o.position.addToRef(o._diffPosition,o._deferredPositionUpdate),o._deferOnly?o._deferredUpdated=!0:o.position.copyFrom(o._deferredPositionUpdate),o.onCollide&&i&&o.onCollide(i))},o.inputs=new xc(o),o.inputs.addKeyboard().addMouse(),o}return m(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUpward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUpward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDownward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDownward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRotateLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRotateRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRotateUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRotateDown=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=rr.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new V(0,0,0),this.cameraRotation=new U(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?V.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=V.Zero(),this._transformedDirection=V.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},Object.defineProperty(t.prototype,"needMoveForGravity",{get:function(){return this._needMoveForGravity},set:function(e){this._needMoveForGravity=e},enumerable:!1,configurable:!0}),t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FreeCamera"},v([Fe()],t.prototype,"ellipsoid",void 0),v([Fe()],t.prototype,"ellipsoidOffset",void 0),v([Ie()],t.prototype,"checkCollisions",void 0),v([Ie()],t.prototype,"applyGravity",void 0),t}(Mc);a("BABYLON.FreeCamera",Oc),qe.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new Dc(e,V.Zero(),t)}}));var Dc=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return m(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.touch,t=this.inputs.attached.mouse;t?t.touchEnabled=!1:e.allowMouse=!0},t}(Oc);qe.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new Nc(e,0,0,1,V.Zero(),t)}}));var Nc=function(e){function t(t,i,r,n,o,a,s){void 0===s&&(s=!0);var l=e.call(this,t,V.Zero(),a,s)||this;return l.inertialAlphaOffset=0,l.inertialBetaOffset=0,l.inertialRadiusOffset=0,l.lowerAlphaLimit=null,l.upperAlphaLimit=null,l.lowerBetaLimit=.01,l.upperBetaLimit=Math.PI-.01,l.lowerRadiusLimit=null,l.upperRadiusLimit=null,l.inertialPanningX=0,l.inertialPanningY=0,l.pinchToPanMaxDistance=20,l.panningDistanceLimit=null,l.panningOriginTarget=V.Zero(),l.panningInertia=.9,l.zoomOnFactor=1,l.targetScreenOffset=U.Zero(),l.allowUpsideDown=!0,l.useInputToRestoreState=!0,l._viewMatrix=new z,l.panningAxis=new V(1,1,0),l._transformedDirection=new V,l.mapPanning=!1,l.onMeshTargetChangedObservable=new f,l.checkCollisions=!1,l.collisionRadius=new V(.5,.5,.5),l._previousPosition=V.Zero(),l._collisionVelocity=V.Zero(),l._newPosition=V.Zero(),l._computationVector=V.Zero(),l._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),i?(l.setPosition(t),l.onCollide&&l.onCollide(i)):l._previousPosition.copyFrom(l._position);var r=Math.cos(l.alpha),n=Math.sin(l.alpha),o=Math.cos(l.beta),a=Math.sin(l.beta);0===a&&(a=1e-4);var s=l._getTargetPosition();l._computationVector.copyFromFloats(l.radius*r*a,l.radius*o,l.radius*n*a),s.addToRef(l._computationVector,l._newPosition),l._position.copyFrom(l._newPosition);var c=l.upVector;l.allowUpsideDown&&l.beta<0&&(c=(c=c.clone()).negate()),l._computeViewMatrix(l._position,s,c),l._viewMatrix.addAtIndex(12,l.targetScreenOffset.x),l._viewMatrix.addAtIndex(13,l.targetScreenOffset.y),l._collisionTriggered=!1},l._target=V.Zero(),o&&l.setTarget(o),l.alpha=i,l.beta=r,l.radius=n,l.getViewMatrix(),l.inputs=new dc(l),l.inputs.addKeyboard().addMouseWheel().addPointers(),l}return m(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetHost",{get:function(){return this._targetHost},set:function(e){e&&this.setTarget(e)},enumerable:!1,configurable:!0}),t.prototype.getTarget=function(){return this.target},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._yToUpMatrix=new z,this._upToYMatrix=new z,this._upVector=V.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),t.prototype.setMatUp=function(){z.RotationAlignToRef(V.UpReadOnly,this._upVector,this._yToUpMatrix),z.RotationAlignToRef(this._upVector,V.UpReadOnly,this._upToYMatrix)},Object.defineProperty(t.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useNaturalPinchZoom",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomToMouseLocation",{get:function(){var e=this.inputs.attached.mousewheel;return!!e&&e.zoomToMouseLocation},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new as,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new ss,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new os,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!1,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new V(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=U.Zero()},t.prototype._updateCache=function(t){t||e.prototype._updateCache.call(this),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},t.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}return this._getLockedTargetPosition()||this._target},t.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.prototype._restoreStateValues.call(this)&&(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)},t.prototype._isSynchronizedViewMatrix=function(){return!!e.prototype._isSynchronizedViewMatrix.call(this)&&this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset)},t.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2);var o=arguments;t=rr.BackCompatCameraNoPreventDefault(o),this._useCtrlForPanning=i,this._panningMouseButton=r,"boolean"==typeof o[0]&&(o.length>1&&(this._useCtrlForPanning=o[1]),o.length>2&&(this._panningMouseButton=o[2])),this.inputs.attachElement(t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.inertialRadiusOffset=0,n.inertialPanningX=0,n.inertialPanningY=0}},t.prototype.detachControl=function(){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var t=this.invertRotation?-1:1,i=this._calculateHandednessMultiplier(),r=this.inertialAlphaOffset*i;this.beta<0&&(r*=-1),this.alpha+=r*t,this.beta+=this.inertialBetaOffset*t,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||V.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);var e=this.alpha;0===this._computationVector.x&&0===this._computationVector.z?this.alpha=Math.PI/2:this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha);var t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()},t.prototype.setPosition=function(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())},t.prototype.setTarget=function(e,t,i,r){var n;if(void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),r=null!==(n=this.overrideCloneAlphaBetaRadius)&&void 0!==n?n:r,e.computeWorldMatrix)t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.centerWorld.clone():this._targetBoundingCenter=null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var o=e,a=this._getTargetPosition();if(a&&!i&&a.equals(o))return;this._targetHost=null,this._target=o,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}r||this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),r=Math.sin(this.beta);0===r&&(r=1e-4),0===this.radius&&(this.radius=1e-4);var n=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*i,this.radius*t*r),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||V.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),n.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var o=this.getScene().collisionCoordinator;this._collider||(this._collider=o.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,o.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var a=this.upVector;this.allowUpsideDown&&r<0&&(a=a.negate()),this._computeViewMatrix(this._position,n,a),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=n,this._viewMatrix},t.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var i=Fa.MinMax(e),r=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);r=Math.max(Math.min(r,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=r*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:r},t)},t.prototype.focusOn=function(e,t){var i,r;if(void 0===t&&(t=!1),void 0===e.min){var n=e||this.getScene().meshes;i=Fa.MinMax(n),r=V.Distance(i.min,i.max)}else i=e,r=e.distance;this._target=Fa.Center(i),t||(this.maxZ=2*r)},t.prototype.createRigCamera=function(e,i){var r=0;switch(this.cameraRigMode){case $n.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case $n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case $n.RIG_MODE_STEREOSCOPIC_OVERUNDER:case $n.RIG_MODE_STEREOSCOPIC_INTERLACED:case $n.RIG_MODE_VR:r=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case $n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var n=new t(e,this.alpha+r,this.beta,this.radius,this._target,this.getScene());return n._cameraRigParams={},n.isRigCamera=!0,n.rigParent=this,n.upVector=this.upVector,n.mode=this.mode,n.orthoLeft=this.orthoLeft,n.orthoRight=this.orthoRight,n.orthoBottom=this.orthoBottom,n.orthoTop=this.orthoTop,n},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(t.beta=i.beta=this.beta,this.cameraRigMode){case $n.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case $n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case $n.RIG_MODE_STEREOSCOPIC_OVERUNDER:case $n.RIG_MODE_STEREOSCOPIC_INTERLACED:case $n.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case $n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}e.prototype._updateRigCameras.call(this)},t.prototype._calculateLowerRadiusFromModelBoundingSphere=function(e,t,i){void 0===i&&(i=1);var r=V.Distance(e,t),n=this.getScene().getEngine().getAspectRatio(this),o=Math.tan(this.fov/2),a=o*n,s=.5*r*i,l=s*Math.sqrt(1+1/(a*a)),c=s*Math.sqrt(1+1/(o*o));return Math.max(l,c)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"ArcRotateCamera"},v([Ie()],t.prototype,"alpha",void 0),v([Ie()],t.prototype,"beta",void 0),v([Ie()],t.prototype,"radius",void 0),v([Ie()],t.prototype,"overrideCloneAlphaBetaRadius",void 0),v([Fe("target")],t.prototype,"_target",void 0),v([Le("targetHost")],t.prototype,"_targetHost",void 0),v([Ie()],t.prototype,"inertialAlphaOffset",void 0),v([Ie()],t.prototype,"inertialBetaOffset",void 0),v([Ie()],t.prototype,"inertialRadiusOffset",void 0),v([Ie()],t.prototype,"lowerAlphaLimit",void 0),v([Ie()],t.prototype,"upperAlphaLimit",void 0),v([Ie()],t.prototype,"lowerBetaLimit",void 0),v([Ie()],t.prototype,"upperBetaLimit",void 0),v([Ie()],t.prototype,"lowerRadiusLimit",void 0),v([Ie()],t.prototype,"upperRadiusLimit",void 0),v([Ie()],t.prototype,"inertialPanningX",void 0),v([Ie()],t.prototype,"inertialPanningY",void 0),v([Ie()],t.prototype,"pinchToPanMaxDistance",void 0),v([Ie()],t.prototype,"panningDistanceLimit",void 0),v([Fe()],t.prototype,"panningOriginTarget",void 0),v([Ie()],t.prototype,"panningInertia",void 0),v([Ie()],t.prototype,"zoomToMouseLocation",null),v([Ie()],t.prototype,"zoomOnFactor",void 0),v([Ne()],t.prototype,"targetScreenOffset",void 0),v([Ie()],t.prototype,"allowUpsideDown",void 0),v([Ie()],t.prototype,"useInputToRestoreState",void 0),t}(Mc);a("BABYLON.ArcRotateCamera",Nc),qe.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new Fc(e,V.Zero(),t)}}));var Fc=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n._tmpDragQuaternion=new G,n._disablePointerInputWhenUsingDeviceOrientation=!0,n._dragFactor=0,n._quaternionCache=new G,n.inputs.addDeviceOrientation(),n.inputs._deviceOrientationInput&&n.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function(){n._disablePointerInputWhenUsingDeviceOrientation&&n.inputs._mouseInput&&(n.inputs._mouseInput._allowCameraRotation=!1,n.inputs._mouseInput.onPointerMovedObservable.add((function(e){0!=n._dragFactor&&(n._initialQuaternion||(n._initialQuaternion=new G),G.FromEulerAnglesToRef(0,e.offsetX*n._dragFactor,0,n._tmpDragQuaternion),n._initialQuaternion.multiplyToRef(n._tmpDragQuaternion,n._initialQuaternion))})))})),n}return m(t,e),Object.defineProperty(t.prototype,"disablePointerInputWhenUsingDeviceOrientation",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e},enumerable:!1,configurable:!0}),t.prototype.enableHorizontalDragging=function(e){void 0===e&&(e=1/300),this._dragFactor=e},t.prototype.getClassName=function(){return"DeviceOrientationCamera"},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},t.prototype.resetToCurrentRotation=function(e){var t=this;void 0===e&&(e=_n.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new G),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach((function(i){e[i]?t._initialQuaternion[i]*=-1:t._initialQuaternion[i]=0})),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(Oc),Lc=function(e){function t(t){return e.call(this,t)||this}return m(t,e),t.prototype.addKeyboard=function(){return this.add(new fc),this},t.prototype.addMouse=function(){return this.add(new _c),this},t}(nc),wc=function(e){function t(t,i,r,n){void 0===n&&(n=!0);var o=e.call(this,t,i,r,n)||this;return o.ellipsoid=new V(1,1,1),o.ellipsoidOffset=new V(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o.cameraDirection=V.Zero(),o._trackRoll=0,o.rollCorrect=100,o.bankedTurn=!1,o.bankedTurnLimit=Math.PI/2,o.bankedTurnMultiplier=1,o._needMoveForGravity=!1,o._oldPosition=V.Zero(),o._diffPosition=V.Zero(),o._newPosition=V.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,i){var r;void 0===i&&(i=null),r=t,o._newPosition.copyFrom(r),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>Do.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new Lc(o),o.inputs.addKeyboard().addMouse(),o}return m(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysForward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysForward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysForward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysBackward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysBackward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysBackward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=rr.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new V(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?V.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=V.Zero(),this._transformedDirection=V.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},Object.defineProperty(t.prototype,"needMoveForGravity",{get:function(){return this._needMoveForGravity},set:function(e){this._needMoveForGravity=e},enumerable:!1,configurable:!0}),t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.restoreRoll=function(e){var t=this._trackRoll,i=t-this.rotation.z;Math.abs(i)>=.001&&(this.rotation.z+=i/e,Math.abs(t-this.rotation.z)<=.001&&(this.rotation.z=t))},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FlyCamera"},v([Fe()],t.prototype,"ellipsoid",void 0),v([Fe()],t.prototype,"ellipsoidOffset",void 0),v([Ie()],t.prototype,"checkCollisions",void 0),v([Ie()],t.prototype,"applyGravity",void 0),t}(Mc);a("BABYLON.FlyCamera",wc);var Bc=function(e){function t(t){return e.call(this,t)||this}return m(t,e),t.prototype.addKeyboard=function(){return this.add(new mc),this},t.prototype.addMouseWheel=function(){return this.add(new gc),this},t.prototype.addPointers=function(){return this.add(new vc),this},t.prototype.addVRDeviceOrientation=function(){return ae.Warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(nc);qe.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new kc(e,V.Zero(),t)}})),qe.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new Gc(e,0,0,1,null,t)}}));var Uc,Vc,kc=function(e){function t(t,i,r,n){void 0===n&&(n=null);var o=e.call(this,t,i,r)||this;return o.radius=12,o.lowerRadiusLimit=null,o.upperRadiusLimit=null,o.rotationOffset=0,o.lowerRotationOffsetLimit=null,o.upperRotationOffsetLimit=null,o.heightOffset=4,o.lowerHeightOffsetLimit=null,o.upperHeightOffsetLimit=null,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o.inputs=new Bc(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return m(t,e),t.prototype._follow=function(e){if(e){var t=H.Matrix[0];e.absoluteRotationQuaternion.toRotationMatrix(t);var i=Math.atan2(t.m[8],t.m[10]),r=rr.ToRadians(this.rotationOffset)+i,n=e.getAbsolutePosition(),o=n.x+Math.sin(r)*this.radius,a=n.z+Math.cos(r)*this.radius,s=o-this.position.x,l=n.y+this.heightOffset-this.position.y,c=a-this.position.z,u=s*this.cameraAcceleration*2,h=l*this.cameraAcceleration,d=c*this.cameraAcceleration*2;(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new V(this.position.x+u,this.position.y+h,this.position.z+d),this.setTarget(n)}},t.prototype.attachControl=function(e,t){t=rr.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t),this._reset=function(){}},t.prototype.detachControl=function(){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),e.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),null!==this.lowerHeightOffsetLimit&&this.heightOffsetthis.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),null!==this.lowerRotationOffsetLimit&&this.rotationOffsetthis.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},v([Ie()],t.prototype,"radius",void 0),v([Ie()],t.prototype,"lowerRadiusLimit",void 0),v([Ie()],t.prototype,"upperRadiusLimit",void 0),v([Ie()],t.prototype,"rotationOffset",void 0),v([Ie()],t.prototype,"lowerRotationOffsetLimit",void 0),v([Ie()],t.prototype,"upperRotationOffsetLimit",void 0),v([Ie()],t.prototype,"heightOffset",void 0),v([Ie()],t.prototype,"lowerHeightOffsetLimit",void 0),v([Ie()],t.prototype,"upperHeightOffsetLimit",void 0),v([Ie()],t.prototype,"cameraAcceleration",void 0),v([Ie()],t.prototype,"maxCameraSpeed",void 0),v([Le("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Mc),Gc=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,V.Zero(),a)||this;return s.alpha=i,s.beta=r,s.radius=n,s._cartesianCoordinates=V.Zero(),s.setMeshTarget(o),s}return m(t,e),t.prototype.setMeshTarget=function(e){this._meshTarget=e,this._follow()},t.prototype._follow=function(){if(this._meshTarget){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this._meshTarget.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return"ArcFollowCamera"},t}(Mc);a("BABYLON.FollowCamera",kc),a("BABYLON.ArcFollowCamera",Gc),function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(Uc||(Uc={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Vc||(Vc={}));var zc,Wc,Hc=function(e){function t(t,i,r,n){void 0===n&&(n=!1);var o=e.call(this,t,i,r,0,1,2,3)||this;return o._leftTrigger=0,o._rightTrigger=0,o.onButtonDownObservable=new f,o.onButtonUpObservable=new f,o.onPadDownObservable=new f,o.onPadUpObservable=new f,o._buttonA=0,o._buttonB=0,o._buttonX=0,o._buttonY=0,o._buttonBack=0,o._buttonStart=0,o._buttonLB=0,o._buttonRB=0,o._buttonLeftStick=0,o._buttonRightStick=0,o._dPadUp=0,o._dPadDown=0,o._dPadLeft=0,o._dPadRight=0,o._isXboxOnePad=!1,o.type=ac.XBOX,o._isXboxOnePad=n,o}return m(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,Uc.A)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,Uc.B)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,Uc.X)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,Uc.Y)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,Uc.Start)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,Uc.Back)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,Uc.LB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,Uc.RB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Uc.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Uc.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Vc.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Vc.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Vc.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Vc.Right)},enumerable:!1,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this._isXboxOnePad,this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ac);!function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(zc||(zc={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Wc||(Wc={}));var Xc=function(e){function t(t,i,r){var n=e.call(this,t.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),i,r,0,1,2,3)||this;return n._leftTrigger=0,n._rightTrigger=0,n.onButtonDownObservable=new f,n.onButtonUpObservable=new f,n.onPadDownObservable=new f,n.onPadUpObservable=new f,n._buttonCross=0,n._buttonCircle=0,n._buttonSquare=0,n._buttonTriangle=0,n._buttonShare=0,n._buttonOptions=0,n._buttonL1=0,n._buttonR1=0,n._buttonLeftStick=0,n._buttonRightStick=0,n._dPadUp=0,n._dPadDown=0,n._dPadLeft=0,n._dPadRight=0,n.type=ac.DUALSHOCK,n}return m(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,"buttonCross",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,zc.Cross)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonCircle",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,zc.Circle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonSquare",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,zc.Square)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonTriangle",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,zc.Triangle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonOptions",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,zc.Options)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonShare",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,zc.Share)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonL1",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,zc.L1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonR1",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,zc.R1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,zc.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,zc.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Wc.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Wc.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Wc.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Wc.Right)},enumerable:!1,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this.buttonCross=this.browserGamepad.buttons[0].value,this.buttonCircle=this.browserGamepad.buttons[1].value,this.buttonSquare=this.browserGamepad.buttons[2].value,this.buttonTriangle=this.browserGamepad.buttons[3].value,this.buttonL1=this.browserGamepad.buttons[4].value,this.buttonR1=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonShare=this.browserGamepad.buttons[8].value,this.buttonOptions=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ac),jc=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new f,ct()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator&&navigator.getGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new f((function(e){for(var i in t._babylonGamepads){var r=t._babylonGamepads[i];r&&r._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,r)}})),this._onGamepadConnectedEvent=function(e){var i,r=e.gamepad;r.index in t._babylonGamepads&&t._babylonGamepads[r.index].isConnected||(t._babylonGamepads[r.index]?((i=t._babylonGamepads[r.index]).browserGamepad=r,i._isConnected=!0):i=t._addNewGamepad(r),t.onGamepadConnectedObservable.notifyObservers(i),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var i=e.gamepad;for(var r in t._babylonGamepads)if(t._babylonGamepads[r].index===i.index){var n=t._babylonGamepads[r];n._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(n),n.dispose&&n.dispose();break}},this._gamepadSupport)if(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported){var i=this._scene?this._scene.getEngine().getHostWindow():window;i&&(i.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),i.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1))}else this._startMonitoringGamepads()}return Object.defineProperty(e.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!1,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=ac.XBOX);for(var t=0,i=this._babylonGamepads;t5))switch(this._face=e,this._face){case 0:this.updateEffect("#define POSITIVEX");break;case 1:this.updateEffect("#define NEGATIVEX");break;case 2:this.updateEffect("#define POSITIVEY");break;case 3:this.updateEffect("#define NEGATIVEY");break;case 4:this.updateEffect("#define POSITIVEZ");break;case 5:this.updateEffect("#define NEGATIVEZ")}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PassCubePostProcess"},t._Parse=function(e,i,r,n){return Ke.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)}),e,r,n)},t}(hl);Mi._RescalePostProcessFactory=function(e){return new qc("rescale",1,null,u.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,u.TEXTURETYPE_UNSIGNED_INT)};li.ShadersStore.anaglyphPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D leftSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 leftFrag=texture2D(leftSampler,vUV);leftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);vec4 rightFrag=texture2D(textureSampler,vUV);rightFrag=vec4(rightFrag.r,1.0,1.0,1.0);gl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);}";var Jc=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,a)||this;return s._passedProcess=r[0]._rigPostProcess,s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",s._passedProcess)})),s}return m(t,e),t.prototype.getClassName=function(){return"AnaglyphPostProcess"},t}(hl);function $c(e){e._rigCameras[0]._rigPostProcess=new qc(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new Jc(e.name+"_anaglyph",1,e._rigCameras)}a("BABYLON.AnaglyphPostProcess",Jc),qe.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,i){return function(){return new eu(e,0,0,1,V.Zero(),i.interaxial_distance,t)}}));var eu=function(e){function t(t,i,r,n,o,a,s){var l=e.call(this,t,i,r,n,o,s)||this;return l._setRigMode=function(){return $c(l)},l.interaxialDistance=a,l.setCameraRigMode($n.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),l}return m(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(Nc);qe.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,i){return function(){return new tu(e,V.Zero(),i.interaxial_distance,t)}}));var tu=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o._setRigMode=function(){return $c(o)},o.interaxialDistance=r,o.setCameraRigMode($n.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return m(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(Oc);qe.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,i){return function(){return new iu(e,V.Zero(),i.interaxial_distance,t)}}));var iu=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o._setRigMode=function(){return $c(o)},o.interaxialDistance=r,o.setCameraRigMode($n.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return m(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(Qc);qe.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,i){return function(){return new ru(e,V.Zero(),i.interaxial_distance,t)}}));var ru=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o._setRigMode=function(){return $c(o)},o.interaxialDistance=r,o.setCameraRigMode($n.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return m(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(Kc);li.ShadersStore.stereoscopicInterlacePixelShader="const vec3 TWO=vec3(2.0,2.0,2.0);varying vec2 vUV;uniform sampler2D camASampler;uniform sampler2D textureSampler;uniform vec2 stepSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{bool useCamA;bool useCamB;vec2 texCoord1;vec2 texCoord2;vec3 frag1;vec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;useCamA=!useCamB;texCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);texCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\n#ifdef IS_STEREOSCOPIC_INTERLACED\nfloat rowNum=floor(vUV.y/stepSize.y);useCamA=mod(rowNum,2.0)==1.0;useCamB=mod(rowNum,2.0)==0.0;texCoord1=vec2(vUV.x,vUV.y);texCoord2=vec2(vUV.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;useCamA=!useCamB;texCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);texCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n#endif\nif (useCamB){frag1=texture2D(textureSampler,texCoord1).rgb;frag2=texture2D(textureSampler,texCoord2).rgb;}else if (useCamA){frag1=texture2D(camASampler ,texCoord1).rgb;frag2=texture2D(camASampler ,texCoord2).rgb;}else {discard;}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);}\n";var nu=function(e){function t(t,i,r,n,o,a,s){var l=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,i[1],o,a,s,n?"#define IS_STEREOSCOPIC_INTERLACED 1":r?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=i[0]._rigPostProcess,l._stepSize=new U(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new U(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)})),l}return m(t,e),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcessI"},t}(hl),ou=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,i[1],n,o,a,r?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return s._passedProcess=i[0]._rigPostProcess,s._stepSize=new U(1/s.width,1/s.height),s.onSizeChangedObservable.add((function(){s._stepSize=new U(1/s.width,1/s.height)})),s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",s._passedProcess),e.setFloat2("stepSize",s._stepSize.x,s._stepSize.y)})),s}return m(t,e),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcess"},t}(hl);function au(e){var t=e.cameraRigMode===$n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===$n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,i=e.cameraRigMode===$n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e.cameraRigMode===$n.RIG_MODE_STEREOSCOPIC_INTERLACED?(e._rigCameras[0]._rigPostProcess=new qc(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new nu(e.name+"_stereoInterlace",e._rigCameras,!1,!0)):(e._rigCameras[i?1:0].viewport=new Jn(0,0,t?.5:1,t?1:.5),e._rigCameras[i?0:1].viewport=new Jn(t?.5:0,t?0:.5,t?.5:1,t?1:.5))}qe.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,i){return function(){return new su(e,0,0,1,V.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var su=function(e){function t(t,i,r,n,o,a,s,l){var c=e.call(this,t,i,r,n,o,l)||this;return c._setRigMode=function(){return au(c)},c.interaxialDistance=a,c.isStereoscopicSideBySide=s,c.setCameraRigMode(s?$n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:$n.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),c}return m(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(Nc);qe.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new lu(e,V.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var lu=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,o)||this;return a._setRigMode=function(){return au(a)},a.interaxialDistance=r,a.isStereoscopicSideBySide=n,a.setCameraRigMode(n?$n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:$n.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return m(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(Oc);qe.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,i){return function(){return new cu(e,V.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var cu=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,o)||this;return a._setRigMode=function(){return au(a)},a.interaxialDistance=r,a.isStereoscopicSideBySide=n,a.setCameraRigMode(n?$n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:$n.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return m(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(Qc);qe.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new uu(e,V.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var uu=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,o)||this;return a._setRigMode=function(){return au(a)},a.interaxialDistance=r,a.isStereoscopicSideBySide=n,a.setCameraRigMode(n?$n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:$n.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return m(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(Kc),hu=function(e){function t(t,i,r,n,o){void 0===n&&(n=1),void 0===o&&(o=.065);var a=e.call(this,t,i,r)||this;return a._distanceBetweenEyes=o,a._distanceToProjectionPlane=n,a.setCameraRigMode($n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,{stereoHalfAngle:0}),a._cameraRigParams.stereoHalfAngle=0,a._cameraRigParams.interaxialDistance=o,a}return m(t,e),Object.defineProperty(t.prototype,"distanceBetweenEyes",{get:function(){return this._distanceBetweenEyes},set:function(e){this._distanceBetweenEyes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"distanceToProjectionPlane",{get:function(){return this._distanceToProjectionPlane},set:function(e){this._distanceToProjectionPlane=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t.prototype.createRigCamera=function(e){var t=new Mc(e,V.Zero(),this.getScene()),i=new Fo("tm_"+e,this.getScene());return t.parent=i,i.setPivotMatrix(z.Identity(),!1),t.isRigCamera=!0,t.rigParent=this,t},t.prototype._updateRigCameras=function(){for(var e=0;e1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);else{gl_FragColor=texture2D(textureSampler,tc);}}";var fu=function(e){function t(t,i,r,n){var o=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,n.postProcessScaleFactor,i,Ja.BILINEAR_SAMPLINGMODE)||this;return o._isRightEye=r,o._distortionFactors=n.distortionK,o._postProcessScaleFactor=n.postProcessScaleFactor,o._lensCenterOffset=n.lensCenterOffset,o.adaptScaleToCurrentViewport=!0,o.onSizeChangedObservable.add((function(){o._scaleIn=new U(2,2/o.aspectRatio),o._scaleFactor=new U(1/o._postProcessScaleFactor*.5,1/o._postProcessScaleFactor*.5*o.aspectRatio),o._lensCenter=new U(o._isRightEye?.5-.5*o._lensCenterOffset:.5+.5*o._lensCenterOffset,.5)})),o.onApplyObservable.add((function(e){e.setFloat2("LensCenter",o._lensCenter.x,o._lensCenter.y),e.setFloat2("Scale",o._scaleFactor.x,o._scaleFactor.y),e.setFloat2("ScaleIn",o._scaleIn.x,o._scaleIn.y),e.setFloat4("HmdWarpParam",o._distortionFactors[0],o._distortionFactors[1],o._distortionFactors[2],o._distortionFactors[3])})),o}return m(t,e),t.prototype.getClassName=function(){return"VRDistortionCorrectionPostProcess"},t}(hl);li.ShadersStore.vrMultiviewToSingleviewPixelShader="precision mediump sampler2DArray;varying vec2 vUV;uniform sampler2DArray multiviewSampler;uniform int imageIndex;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));}";var _u=function(e){function t(t,i){void 0===i&&(i=512);var r=e.call(this,"multiview rtt",i,t,!1,!0,u.TEXTURETYPE_UNSIGNED_INT,!1,void 0,!1,!1,!0,void 0,!0)||this;return r._renderTarget=r.getScene().getEngine().createMultiviewRenderTargetTexture(r.getRenderWidth(),r.getRenderHeight()),r._texture=r._renderTarget.texture,r._texture.isMultiview=!0,r._texture.format=u.TEXTUREFORMAT_RGBA,r.samples=r._getEngine().getCaps().maxSamples||r.samples,r._texture.samples=r._samples,r}return m(t,e),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples=e},enumerable:!1,configurable:!0}),t.prototype._bindFrameBuffer=function(){this._renderTarget&&this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)},t.prototype.getViewCount=function(){return 2},t}(Pl);function mu(e,t){var i=new Or(e,void 0,!0,t);return i.addUniform("viewProjection",16),i.addUniform("viewProjectionR",16),i.addUniform("view",16),i.addUniform("projection",16),i.addUniform("vEyePosition",4),i}Do.prototype.createMultiviewRenderTargetTexture=function(e,t,i,r){var n=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var o=this._createHardwareRenderTargetWrapper(!1,!1,{width:e,height:t});o._framebuffer=n.createFramebuffer();var a=new Pi(this,Ti.Unknown,!0);return a.width=e,a.height=t,a.isMultiview=!0,i||(i=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,i),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.RGBA8,e,t,2)),o._colorTextureArray=i,r||(r=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,r),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.DEPTH24_STENCIL8,e,t,2)),o._depthStencilTextureArray=r,a.isReady=!0,o.setTextures(a),o._depthStencilTexture=a,o},Do.prototype.bindMultiviewFramebuffer=function(e){var t=e,i=this._gl,r=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(t,void 0,void 0,void 0,!0),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,t._framebuffer),!t._colorTextureArray||!t._depthStencilTextureArray)throw"Invalid multiview frame buffer";this.getCaps().oculusMultiview?(r.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,t._colorTextureArray,0,t.samples,0,2),r.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,t._depthStencilTextureArray,0,t.samples,0,2)):(r.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,t._colorTextureArray,0,0,2),r.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,t._depthStencilTextureArray,0,0,2))},Do.prototype.bindSpaceWarpFramebuffer=function(e){var t=e,i=this._gl,r=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(t,void 0,void 0,void 0,!0),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,t._framebuffer),!t._colorTextureArray||!t._depthStencilTextureArray)throw new Error("Invalid Space Warp framebuffer");r.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,t._colorTextureArray,0,0,2),r.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER,i.DEPTH_ATTACHMENT,t._depthStencilTextureArray,0,0,2)},$n.prototype._useMultiviewToSingleView=!1,$n.prototype._multiviewTexture=null,$n.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new _u(this.getScene(),{width:e,height:t})):this._multiviewTexture=new _u(this.getScene(),{width:e,height:t})};var gu=pn.prototype.createSceneUniformBuffer;pn.prototype._transformMatrixR=z.Zero(),pn.prototype._multiviewSceneUbo=null,pn.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=mu(this.getEngine(),"scene_multiview")},pn.prototype.createSceneUniformBuffer=function(e){return this._multiviewSceneUbo?mu(this.getEngine(),e):gu.bind(this)(e)},pn.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,H.Matrix[0]),ln.GetRightPlaneToRef(H.Matrix[0],this._frustumPlanes[3])),this._multiviewSceneUbo&&(this._multiviewSceneUbo.updateMatrix("viewProjection",this.getTransformMatrix()),this._multiviewSceneUbo.updateMatrix("viewProjectionR",this._transformMatrixR),this._multiviewSceneUbo.updateMatrix("view",this._viewMatrix),this._multiviewSceneUbo.updateMatrix("projection",this._projectionMatrix))},pn.prototype._renderMultiviewToSingleView=function(e){e._resizeOrCreateMultiviewTexture(e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.width>0?e._rigPostProcess.width:this.getEngine().getRenderWidth(!0),e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.height>0?e._rigPostProcess.height:this.getEngine().getRenderHeight(!0)),this._multiviewSceneUbo||this._createMultiviewUbo(),e.outputRenderTarget=e._multiviewTexture,this._renderForCamera(e),e.outputRenderTarget=null;for(var t=0;t0&&(i=a.uniforms).push.apply(i,this._uniformList),this._samplerList.length>0&&(r=a.samplers).push.apply(r,this._samplerList),this._uboList.length>0&&(n=a.uniformBuffersNames).push.apply(n,this._uboList),a.customCode=this._injectCustomCode(a,a.customCode);break;case Vo.PrepareUniformBuffer:a=t,this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];for(var y=0,b=this._plugins;y0?"[".concat(A,"]"):"",";\n")}this._uniformList.push(x.name)}T.vertex&&(this._vertexDeclaration+=T.vertex+"\n"),T.fragment&&(this._fragmentDeclaration+=T.fragment+"\n")}v.getSamplers(this._samplerList),v.getUniformBuffersNames(this._uboList)}}},e.prototype._collectPointNames=function(e,t){if(t)for(var i in t)this._codeInjectionPoints[e]||(this._codeInjectionPoints[e]={}),this._codeInjectionPoints[e][i]=!0},e.prototype._injectCustomCode=function(e,t){var i=this;return function(r,n){var o,a;t&&(n=t(r,n)),i._uboDeclaration&&(n=n.replace("#define ADDITIONAL_UBO_DECLARATION",i._uboDeclaration)),i._vertexDeclaration&&(n=n.replace("#define ADDITIONAL_VERTEX_DECLARATION",i._vertexDeclaration)),i._fragmentDeclaration&&(n=n.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",i._fragmentDeclaration));var s=null===(o=i._codeInjectionPoints)||void 0===o?void 0:o[r];if(!s)return n;var l=null;for(var c in s){for(var u="",h=function(t){var n=null===(a=t.getCustomCode(r))||void 0===a?void 0:a[c];if(!n)return"continue";if(t.resolveIncludes){if(null===l){var o=pt.GLSL;l={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:i._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:i._engine.supportsUniformBuffers,shadersRepository:li.GetShadersRepository(o),includesShadersStore:li.GetIncludesShadersStore(o),version:void 0,platformName:i._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:i._engine.isNDCHalfZRange,useReverseDepthBuffer:i._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}}l.isFragment="fragment"===r,oi(n,l,(function(e){return n=e}))}u+=n+"\n"},d=0,p=i._activePlugins;d0)if("!"===c.charAt(0)){var f="g";if("!"===(c=c.substring(1)).charAt(0))f="",c=c.substring(1);else{var _=Au.exec(c);_&&_.length>=2&&(f=_[1],c=c.substring(f.length+1))}f.indexOf("g")<0&&(f+="g");for(var m=n,g=new RegExp(c,f),v=g.exec(m);null!==v;){for(var y=u,b=0;b0?i[0][1]=t:Ru.push([e,t])}function Ou(e){for(var t=0;t0&&e.push(this._texture)},t.prototype.dispose=function(e){var t;e&&(null===(t=this._texture)||void 0===t||t.dispose())},t.prototype.getClassName=function(){return"DetailMapConfiguration"},t.prototype.getSamplers=function(e){e.push("detailSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}},v([Me("detailTexture"),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),v([Ie()],t.prototype,"diffuseBlendLevel",void 0),v([Ie()],t.prototype,"roughnessBlendLevel",void 0),v([Ie()],t.prototype,"bumpLevel",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"normalBlendMethod",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),t}(Nu),wu={effect:null,subMesh:null},Bu=function(e){function t(t){var i=e.call(this,t)||this;return i.MAINUV1=!1,i.MAINUV2=!1,i.MAINUV3=!1,i.MAINUV4=!1,i.MAINUV5=!1,i.MAINUV6=!1,i.DIFFUSE=!1,i.DIFFUSEDIRECTUV=0,i.BAKED_VERTEX_ANIMATION_TEXTURE=!1,i.AMBIENT=!1,i.AMBIENTDIRECTUV=0,i.OPACITY=!1,i.OPACITYDIRECTUV=0,i.OPACITYRGB=!1,i.REFLECTION=!1,i.EMISSIVE=!1,i.EMISSIVEDIRECTUV=0,i.SPECULAR=!1,i.SPECULARDIRECTUV=0,i.BUMP=!1,i.BUMPDIRECTUV=0,i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.SPECULAROVERALPHA=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.ALPHAFROMDIFFUSE=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!1,i.DIFFUSEFRESNEL=!1,i.OPACITYFRESNEL=!1,i.REFLECTIONFRESNEL=!1,i.REFRACTIONFRESNEL=!1,i.EMISSIVEFRESNEL=!1,i.FRESNEL=!1,i.NORMAL=!1,i.TANGENT=!1,i.UV1=!1,i.UV2=!1,i.UV3=!1,i.UV4=!1,i.UV5=!1,i.UV6=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.BONETEXTURE=!1,i.BONES_VELOCITY_ENABLED=!1,i.INSTANCES=!1,i.THIN_INSTANCES=!1,i.INSTANCESCOLOR=!1,i.GLOSSINESS=!1,i.ROUGHNESS=!1,i.EMISSIVEASILLUMINATION=!1,i.LINKEMISSIVEWITHDIFFUSE=!1,i.REFLECTIONFRESNELFROMSPECULAR=!1,i.LIGHTMAP=!1,i.LIGHTMAPDIRECTUV=0,i.OBJECTSPACE_NORMALMAP=!1,i.USELIGHTMAPASSHADOWMAP=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFRACTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.INVERTCUBICMAP=!1,i.LOGARITHMICDEPTH=!1,i.REFRACTION=!1,i.REFRACTIONMAP_3D=!1,i.REFLECTIONOVERALPHA=!1,i.TWOSIDEDLIGHTING=!1,i.SHADOWFLOAT=!1,i.MORPHTARGETS=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_UV=!1,i.NUM_MORPH_INFLUENCERS=0,i.MORPHTARGETS_TEXTURE=!1,i.NONUNIFORMSCALING=!1,i.PREMULTIPLYALPHA=!1,i.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,i.ALPHABLEND=!0,i.PREPASS=!1,i.PREPASS_IRRADIANCE=!1,i.PREPASS_IRRADIANCE_INDEX=-1,i.PREPASS_ALBEDO_SQRT=!1,i.PREPASS_ALBEDO_SQRT_INDEX=-1,i.PREPASS_DEPTH=!1,i.PREPASS_DEPTH_INDEX=-1,i.PREPASS_NORMAL=!1,i.PREPASS_NORMAL_INDEX=-1,i.PREPASS_NORMAL_WORLDSPACE=!1,i.PREPASS_POSITION=!1,i.PREPASS_POSITION_INDEX=-1,i.PREPASS_VELOCITY=!1,i.PREPASS_VELOCITY_INDEX=-1,i.PREPASS_REFLECTIVITY=!1,i.PREPASS_REFLECTIVITY_INDEX=-1,i.SCENE_MRT_COUNT=0,i.RGBDLIGHTMAP=!1,i.RGBDREFLECTION=!1,i.RGBDREFRACTION=!1,i.IMAGEPROCESSING=!1,i.VIGNETTE=!1,i.VIGNETTEBLENDMODEMULTIPLY=!1,i.VIGNETTEBLENDMODEOPAQUE=!1,i.TONEMAPPING=0,i.CONTRAST=!1,i.COLORCURVES=!1,i.COLORGRADING=!1,i.COLORGRADING3D=!1,i.SAMPLER3DGREENDEPTH=!1,i.SAMPLER3DBGRMAP=!1,i.DITHER=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.MULTIVIEW=!1,i.ORDER_INDEPENDENT_TRANSPARENCY=!1,i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,i.CAMERA_ORTHOGRAPHIC=!1,i.CAMERA_PERSPECTIVE=!1,i.IS_REFLECTION_LINEAR=!1,i.IS_REFRACTION_LINEAR=!1,i.EXPOSURE=!1,i.DECAL_AFTER_DETAIL=!1,i.rebuild(),i}return m(t,e),t.prototype.setReflectionMode=function(e){for(var t=0,i=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];t0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===Ja.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,a.REFLECTIONMAP_OPPOSITEZ=a.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!this._reflectionTexture.invertZ:this._reflectionTexture.invertZ,a.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case Ja.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case Ja.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case Ja.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case Ja.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case Ja.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case Ja.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case Ja.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case Ja.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case Ja.CUBIC_MODE:case Ja.INVCUBIC_MODE:default:a.setReflectionMode("REFLECTIONMAP_CUBIC")}a.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else a.REFLECTION=!1,a.REFLECTIONMAP_OPPOSITEZ=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;ta(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;ta(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,a.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else a.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;ta(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;ta(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAX_RHS=o.useRightHandedSystem,a.PARALLAXOCCLUSION=this._useParallaxOcclusion,a.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else a.BUMP=!1,a.PARALLAX=!1,a.PARALLAX_RHS=!1,a.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube,a.RGBDREFRACTION=this._refractionTexture.isRGBD,a.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=this.alphaMode===u.ALPHA_PREMULTIPLIED||this.alphaMode===u.ALPHA_PREMULTIPLIED_PORTERDUFF,a.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,a.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=a,this._eventInfo.subMesh=i,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(a._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a),a.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,a.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}a._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),da(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,a,this._applyDecalMapAfterDetailMap),_a(o,s,this,a,r,null,i.getRenderingMesh().hasThinInstances),this._eventInfo.defines=a,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),ya(e,a,!0,!0,!0),this._callbackPluginEventPrepareDefines(this._eventInfo);var h=!1;if(a.isDirty){var d=a._areLightsDisposed;a.markAsProcessed();var p=new ll;a.REFLECTION&&p.addFallback(0,"REFLECTION"),a.SPECULAR&&p.addFallback(0,"SPECULAR"),a.BUMP&&p.addFallback(0,"BUMP"),a.PARALLAX&&p.addFallback(1,"PARALLAX"),a.PARALLAX_RHS&&p.addFallback(1,"PARALLAX_RHS"),a.PARALLAXOCCLUSION&&p.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&p.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&p.addFallback(1,"FOG"),a.POINTSIZE&&p.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&p.addFallback(0,"LOGARITHMICDEPTH"),ua(a,p,this._maxSimultaneousLights),a.SPECULARTERM&&p.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&p.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&p.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&p.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&p.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&p.addFallback(4,"FRESNEL"),a.MULTIVIEW&&p.addFallback(0,"MULTIVIEW");var f=[Nr.PositionKind];for(a.NORMAL&&f.push(Nr.NormalKind),a.TANGENT&&f.push(Nr.TangentKind),c=1;c<=u.MAX_SUPPORTED_UV_SETS;++c)a["UV"+c]&&f.push("uv".concat(1===c?"":c));a.VERTEXCOLOR&&f.push(Nr.ColorKind),la(f,e,a,p),ca(f,a),Zo(f,e,a),ra(f,0,a);var _="default",m=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","vRefractionPosition","vRefractionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth","morphTargetTextureInfo","morphTargetTextureIndices"],g=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],v=["Material","Scene","Mesh"],y={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=p,this._eventInfo.fallbackRank=0,this._eventInfo.defines=a,this._eventInfo.uniforms=m,this._eventInfo.attributes=f,this._eventInfo.samplers=g,this._eventInfo.uniformBuffersNames=v,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=y,this._callbackPluginEventGeneric(Vo.PrepareEffect,this._eventInfo),Su.AddUniforms(m),Su.AddSamplers(g),pr&&(pr.PrepareUniforms(m,a),pr.PrepareSamplers(g,a)),Aa({uniformsNames:m,uniformBuffersNames:v,samplers:g,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),Go(m);var b={};this.customShaderNameResolve&&(_=this.customShaderNameResolve(_,m,v,g,a,f,b));var T=a.toString(),E=i.effect,S=o.getEngine().createEffect(_,{attributes:f,uniformsNames:m,uniformBuffersNames:v,samplers:g,defines:T,fallbacks:p,onCompiled:this.onCompiled,onError:this.onError,indexParameters:y,processFinalCode:b.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:a.PREPASS},s);if(this._eventInfo.customCode=void 0,S)if(this._onEffectCreatedObservable&&(wu.effect=S,wu.subMesh=i,this._onEffectCreatedObservable.notifyObservers(wu)),this.allowShaderHotSwapping&&E&&!S.isReady()){if(S=E,a.markAsUnprocessed(),h=this.isFrozen,d)return a._areLightsDisposed=!0,!1}else o.resetCachedMaterial(),i.setEffect(S,a,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(a._renderId=o.getRenderId(),n._wasPreviouslyReady=!h,n._wasPreviouslyUsingInstances=r,this._checkScenePerformancePriority(),0))},t.prototype.buildUniformLayout=function(){var t=this._uniformBuffer;t.addUniform("diffuseLeftColor",4),t.addUniform("diffuseRightColor",4),t.addUniform("opacityParts",4),t.addUniform("reflectionLeftColor",4),t.addUniform("reflectionRightColor",4),t.addUniform("refractionLeftColor",4),t.addUniform("refractionRightColor",4),t.addUniform("emissiveLeftColor",4),t.addUniform("emissiveRightColor",4),t.addUniform("vDiffuseInfos",2),t.addUniform("vAmbientInfos",2),t.addUniform("vOpacityInfos",2),t.addUniform("vReflectionInfos",2),t.addUniform("vReflectionPosition",3),t.addUniform("vReflectionSize",3),t.addUniform("vEmissiveInfos",2),t.addUniform("vLightmapInfos",2),t.addUniform("vSpecularInfos",2),t.addUniform("vBumpInfos",3),t.addUniform("diffuseMatrix",16),t.addUniform("ambientMatrix",16),t.addUniform("opacityMatrix",16),t.addUniform("reflectionMatrix",16),t.addUniform("emissiveMatrix",16),t.addUniform("lightmapMatrix",16),t.addUniform("specularMatrix",16),t.addUniform("bumpMatrix",16),t.addUniform("vTangentSpaceParams",2),t.addUniform("pointSize",1),t.addUniform("alphaCutOff",1),t.addUniform("refractionMatrix",16),t.addUniform("vRefractionInfos",4),t.addUniform("vRefractionPosition",3),t.addUniform("vRefractionSize",3),t.addUniform("vSpecularColor",4),t.addUniform("vEmissiveColor",3),t.addUniform("vDiffuseColor",4),t.addUniform("vAmbientColor",3),e.prototype.buildUniformLayout.call(this)},t.prototype.bindForSubMesh=function(e,i,r){var n,o=this.getScene(),a=r.materialDefines;if(a){var s=r.effect;if(s){this._activeEffect=s,i.getMeshUniformBuffer().bindToEffect(s,"Mesh"),i.transferToEffect(e),this._uniformBuffer.bindToEffect(s,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,o,i,e,this.isFrozen),this._eventInfo.subMesh=r,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),a.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(o,s,r,i.visibility);na(i,s);var c=this._uniformBuffer;if(l){if(this.bindViewProjection(s),!c.useUbo||!this.isFrozen||!c.isSync||r._drawWrapper._forceRebindOnNextCall){if(t.FresnelEnabled&&a.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(c.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),c.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&c.updateColor4("opacityParts",new Z(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(c.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),c.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(c.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),c.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(c.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),c.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(c.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),ia(this._diffuseTexture,c,"diffuse")),this._ambientTexture&&t.AmbientTextureEnabled&&(c.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),ia(this._ambientTexture,c,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(c.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ia(this._opacityTexture,c,"opacity")),this._hasAlphaChannel()&&c.updateFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&t.ReflectionTextureEnabled&&(c.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),c.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var u=this._reflectionTexture;c.updateVector3("vReflectionPosition",u.boundingBoxPosition),c.updateVector3("vReflectionSize",u.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(c.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ia(this._emissiveTexture,c,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(c.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ia(this._lightmapTexture,c,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(c.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),ia(this._specularTexture,c,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(c.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),ia(this._bumpTexture,c,"bump"),o._mirroredCameraPosition?c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var h=1;this._refractionTexture.isCube||(c.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(h=this._refractionTexture.depth)),c.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,h,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize&&(u=this._refractionTexture,c.updateVector3("vRefractionPosition",u.boundingBoxPosition),c.updateVector3("vRefractionSize",u.boundingBoxSize))}}this.pointsCloud&&c.updateFloat("pointSize",this.pointSize),a.SPECULARTERM&&c.updateColor4("vSpecularColor",this.specularColor,this.specularPower),c.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:Z.BlackReadOnly),c.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),c.updateColor3("vAmbientColor",this._globalAmbientColor)}o.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&s.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&s.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&s.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?s.setTexture("reflectionCubeSampler",this._reflectionTexture):s.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&s.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&s.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&s.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&s.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled&&(this._refractionTexture.isCube?s.setTexture("refractionCubeSampler",this._refractionTexture):s.setTexture("refraction2DSampler",this._refractionTexture))),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(i)&&this.getScene().depthPeelingRenderer.bind(s),this._eventInfo.subMesh=r,this._callbackPluginEventBindForSubMesh(this._eventInfo),Ho(s,this,o),this.bindEyePosition(s)}else o.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!l&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&sa(o,i,s,a,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==pn.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||i.receiveShadows||a.PREPASS)&&this.bindView(s),Qo(o,i,s),a.NUM_MORPH_INFLUENCERS&&$o(i,s),a.BAKED_VERTEX_ANIMATION_TEXTURE&&(null===(n=i.bakedVertexAnimationManager)||void 0===n||n.bind(s,a.INSTANCES)),this.useLogarithmicDepth&&Ko(a,s,o),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(i,this._activeEffect,r),c.update()}}},t.prototype.getAnimatables=function(){var t=e.prototype.getAnimatables.call(this);return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&t.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&t.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&t.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&t.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&t.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&t.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&t.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&t.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&t.push(this._refractionTexture),t},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this._diffuseTexture===t||this._ambientTexture===t||this._opacityTexture===t||this._reflectionTexture===t||this._emissiveTexture===t||this._specularTexture===t||this._bumpTexture===t||this._lightmapTexture===t||this._refractionTexture===t},t.prototype.dispose=function(t,i){var r,n,o,a,s,l,c,u,h;i&&(null===(r=this._diffuseTexture)||void 0===r||r.dispose(),null===(n=this._ambientTexture)||void 0===n||n.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(l=this._specularTexture)||void 0===l||l.dispose(),null===(c=this._bumpTexture)||void 0===c||c.dispose(),null===(u=this._lightmapTexture)||void 0===u||u.dispose(),null===(h=this._refractionTexture)||void 0===h||h.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.prototype.clone=function(e,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r="");var o=Ke.Clone((function(){return new t(e,n.getScene())}),this,{cloneTexturesOnlyOnce:i});return o.name=e,o.id=e,this.stencil.copyTo(o.stencil),this._clonePlugins(o,r),o},t.Parse=function(e,i,r){var n=Ke.Parse((function(){return new t(e.name,i)}),e,i,r);return e.stencil&&n.stencil.parse(e.stencil,i,r),Ca._ParsePlugins(e,n,i,r),n},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return xu.DiffuseTextureEnabled},set:function(e){xu.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DetailTextureEnabled",{get:function(){return xu.DetailTextureEnabled},set:function(e){xu.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return xu.AmbientTextureEnabled},set:function(e){xu.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return xu.OpacityTextureEnabled},set:function(e){xu.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return xu.ReflectionTextureEnabled},set:function(e){xu.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return xu.EmissiveTextureEnabled},set:function(e){xu.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return xu.SpecularTextureEnabled},set:function(e){xu.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return xu.BumpTextureEnabled},set:function(e){xu.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return xu.LightmapTextureEnabled},set:function(e){xu.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return xu.RefractionTextureEnabled},set:function(e){xu.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return xu.ColorGradingTextureEnabled},set:function(e){xu.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return xu.FresnelEnabled},set:function(e){xu.FresnelEnabled=e},enumerable:!1,configurable:!0}),v([Me("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),v([Me("ambientTexture")],t.prototype,"_ambientTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),v([Me("opacityTexture")],t.prototype,"_opacityTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),v([Me("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),v([Me("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),v([Me("specularTexture")],t.prototype,"_specularTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),v([Me("bumpTexture")],t.prototype,"_bumpTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),v([Me("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),v([Me("refractionTexture")],t.prototype,"_refractionTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),v([Oe("ambient")],t.prototype,"ambientColor",void 0),v([Oe("diffuse")],t.prototype,"diffuseColor",void 0),v([Oe("specular")],t.prototype,"specularColor",void 0),v([Oe("emissive")],t.prototype,"emissiveColor",void 0),v([Ie()],t.prototype,"specularPower",void 0),v([Ie("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),v([Ie("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),v([Ie("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),v([Ie("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),v([Ie("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),v([Ie("disableLighting")],t.prototype,"_disableLighting",void 0),v([Pe("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),v([Ie("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),v([Ie("useParallax")],t.prototype,"_useParallax",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),v([Ie("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),v([Ie()],t.prototype,"parallaxScaleBias",void 0),v([Ie("roughness")],t.prototype,"_roughness",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),v([Ie()],t.prototype,"indexOfRefraction",void 0),v([Ie()],t.prototype,"invertRefractionY",void 0),v([Ie()],t.prototype,"alphaCutOff",void 0),v([Ie("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),v([De("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),v([Pe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),v([De("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),v([Pe("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),v([De("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),v([Pe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),v([De("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),v([Pe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),v([De("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),v([Pe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),v([Ie("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),v([Pe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),v([Ie("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),v([Ie("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),v([Pe("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),v([Ie("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),v([Ie("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),v([Ie("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),v([Ie("applyDecalMapAfterDetailMap")],t.prototype,"_applyDecalMapAfterDetailMap",void 0),v([Pe("_markAllSubMeshesAsMiscDirty")],t.prototype,"applyDecalMapAfterDetailMap",void 0),t}(ws);a("BABYLON.StandardMaterial",Uu),pn.DefaultMaterialFactory=function(e){return new Uu("default material",e)},Er.prototype.createDynamicTexture=function(e,t,i,r){var n=new Pi(this,Ti.Dynamic);return n.baseWidth=e,n.baseHeight=t,i&&(e=this.needPOTTextures?ir(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?ir(t,this._caps.maxTextureSize):t),n.width=e,n.height=t,n.isReady=!1,n.generateMipMaps=i,n.samplingMode=r,this.updateTextureSamplingMode(r,n),this._internalTexturesCache.push(n),n},Er.prototype.updateDynamicTexture=function(e,t,i,r,n,o,a){if(void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),e){var s=this._gl,l=s.TEXTURE_2D,c=this._bindTextureDirectly(l,e,!0,o);this._unpackFlipY(void 0===i?e.invertY:i),r&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var u=this._getWebGLTextureType(e.type),h=this._getInternalFormat(n||e.format),d=this._getRGBABufferInternalSizedFormat(e.type,h);s.texImage2D(l,0,d,h,u,t),e.generateMipMaps&&s.generateMipmap(l),c||this._bindTextureDirectly(l,null),r&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),n&&(e.format=n),e._dynamicTextureSource=t,e._premulAlpha=r,e.invertY=i||!1,e.isReady=!0}};var Vu,ku,Gu=function(e){function t(t,i,r,n,o,a,s){void 0===r&&(r=null),void 0===n&&(n=!1),void 0===o&&(o=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===a&&(a=u.TEXTUREFORMAT_RGBA);var l=e.call(this,null,r,!n,s,o,void 0,void 0,void 0,void 0,a)||this;l.name=t,l.wrapU=Ja.CLAMP_ADDRESSMODE,l.wrapV=Ja.CLAMP_ADDRESSMODE,l._generateMipMaps=n;var c=l._getEngine();if(!c)return l;i.getContext?(l._canvas=i,l._ownCanvas=!1,l._texture=c.createDynamicTexture(i.width,i.height,n,o)):(l._canvas=c.createCanvas(1,1),l._ownCanvas=!0,i.width||0===i.width?l._texture=c.createDynamicTexture(i.width,i.height,n,o):l._texture=c.createDynamicTexture(i,i,n,o));var h=l.getSize();return l._canvas.width!==h.width&&(l._canvas.width=h.width),l._canvas.height!==h.height&&(l._canvas.height=h.height),l._context=l._canvas.getContext("2d"),l}return m(t,e),t.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)},t.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},t.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},t.prototype.getContext=function(){return this._context},t.prototype.clear=function(e){var t=this.getSize();e&&(this._context.fillStyle=e),this._context.clearRect(0,0,t.width,t.height)},t.prototype.update=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=!1),this._getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0,void 0,i)},t.prototype.drawText=function(e,t,i,r,n,o,a,s){void 0===s&&(s=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null==t){var c=this._context.measureText(e);t=(l.width-c.width)/2}if(null==i){var u=parseInt(r.replace(/\D/g,""));i=l.height/2+u/3.65}this._context.fillStyle=n||"",this._context.fillText(e,t,i),s&&this.update(a)},t.prototype.dispose=function(){var t,i;e.prototype.dispose.call(this),this._ownCanvas&&(null===(i=null===(t=this._canvas)||void 0===t?void 0:t.remove)||void 0===i||i.call(t)),this._canvas=null,this._context=null},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),r=new t(this.name,i,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r},t.prototype.serialize=function(){var i=this.getScene();i&&!i.isReady()&&ae.Warn("The scene must be ready before serializing the dynamic texture");var r=e.prototype.serialize.call(this);return t._IsCanvasElement(this._canvas)&&(r.base64String=this._canvas.toDataURL()),r.invertY=this._invertY,r.samplingMode=this.samplingMode,r},t._IsCanvasElement=function(e){return void 0!==e.toDataURL},t.prototype._rebuild=function(){this.update()},t}(Ja),zu=function(){function e(e,t,i,r,n){this.getWidth=e,this.getHeight=t,this.layer=i,this.layerType=r,this._createRenderTargetTextureProvider=n,this._rttWrapper=null}return Object.defineProperty(e.prototype,"isFixedFoveationSupported",{get:function(){return"XRWebGLLayer"==this.layerType&&"number"==typeof this.layer.fixedFoveation},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fixedFoveation",{get:function(){return this.isFixedFoveationSupported?this.layer.fixedFoveation:null},set:function(e){if(this.isFixedFoveationSupported){var t=Math.max(0,Math.min(1,e||0));this.layer.fixedFoveation=t}},enumerable:!1,configurable:!0}),e.prototype.createRenderTargetTextureProvider=function(e){return this._rttWrapper=this._createRenderTargetTextureProvider(e),this._rttWrapper},e.prototype.dispose=function(){this._rttWrapper&&(this._rttWrapper.dispose(),this._rttWrapper=null)},e}(),Wu=function(){function e(e,t){this._scene=e,this.layerWrapper=t,this._renderTargetTextures=new Array,this._engine=e.getEngine()}return e.prototype._createInternalTexture=function(e,t){var i=new Pi(this._engine,Ti.Unknown,!0);return i.width=e.width,i.height=e.height,i._hardwareTexture=new br(t,this._engine._gl),i.isReady=!0,i},e.prototype._createRenderTargetTexture=function(e,t,i,r,n,o){if(!this._engine)throw new Error("Engine is disposed");var a={width:e,height:t},s=o?new _u(this._scene,a):new Pl("XR renderTargetTexture",a,this._scene),l=s.renderTarget;if(l._samples=s.samples,!i&&r||(l._framebuffer=i),r)if(o)l._colorTextureArray=r;else{var c=this._createInternalTexture(a,r);l.setTexture(c,0),s._texture=c}return n&&(o?l._depthStencilTextureArray=n:l._depthStencilTexture=this._createInternalTexture(a,n)),s.disableRescaling(),this._renderTargetTextures.push(s),s},e.prototype._destroyRenderTargetTexture=function(e){this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(e),1),e.dispose()},e.prototype.getFramebufferDimensions=function(){return this._framebufferDimensions},e.prototype.dispose=function(){this._renderTargetTextures.forEach((function(e){return e.dispose()})),this._renderTargetTextures.length=0},e}(),Hu=function(e){function t(t){var i=e.call(this,(function(){return t.framebufferWidth}),(function(){return t.framebufferHeight}),t,"XRWebGLLayer",(function(e){return new Xu(e.scene,i)}))||this;return i.layer=t,i}return m(t,e),t}(zu),Xu=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.layerWrapper=i,r._layer=i.layer,r._framebufferDimensions={framebufferWidth:r._layer.framebufferWidth,framebufferHeight:r._layer.framebufferHeight},r}return m(t,e),t.prototype.trySetViewportForView=function(e,t){var i=this._layer.getViewport(t);if(!i)return!1;var r=this._framebufferDimensions.framebufferWidth,n=this._framebufferDimensions.framebufferHeight;return e.x=i.x/r,e.y=i.y/n,e.width=i.width/r,e.height=i.height/n,!0},t.prototype.getRenderTargetTextureForEye=function(e){var t=this._layer.framebufferWidth,i=this._layer.framebufferHeight,r=this._layer.framebuffer;return this._rtt&&t===this._framebufferDimensions.framebufferWidth&&i===this._framebufferDimensions.framebufferHeight&&r===this._framebuffer||(this._rtt=this._createRenderTargetTexture(t,i,r),this._framebufferDimensions.framebufferWidth=t,this._framebufferDimensions.framebufferHeight=i,this._framebuffer=r),this._rtt},t.prototype.getRenderTargetTextureForView=function(e){return this.getRenderTargetTextureForEye(e.eye)},t}(Wu),ju=function(){function e(){}return e.GetDefaults=function(t){var i=new e;return i.canvasOptions={antialias:!0,depth:!0,stencil:!t||t.isStencilEnable,alpha:!0,framebufferScaleFactor:1},i.newCanvasCssStyle="position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",i},e}(),Yu=function(){function e(e,t){void 0===t&&(t=ju.GetDefaults());var i=this;if(this._options=t,this._canvas=null,this._engine=null,this.xrLayer=null,this._xrLayerWrapper=null,this.onXRLayerInitObservable=new f,this._engine=e.scene.getEngine(),this._engine.onDisposeObservable.addOnce((function(){i._engine=null})),t.canvasElement)this._setManagedOutputCanvas(t.canvasElement);else{var r=document.createElement("canvas");r.style.cssText=this._options.newCanvasCssStyle||"position:absolute; bottom:0px;right:0px;",this._setManagedOutputCanvas(r)}e.onXRSessionInit.add((function(){i._addCanvas()})),e.onXRSessionEnded.add((function(){i._removeCanvas()})),this._makeCanvasCompatibleAsync()}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype._makeCanvasCompatibleAsync=function(){var e=this;this._canvasCompatiblePromise=new Promise((function(t){e.canvasContext&&e.canvasContext.makeXRCompatible?e.canvasContext.makeXRCompatible().then((function(){t()})):t()}))},e.prototype.initializeXRLayerAsync=function(e){return y(this,void 0,void 0,(function(){var t,i=this;return b(this,(function(r){return t=function(){return i.xrLayer=new XRWebGLLayer(e,i.canvasContext,i._options.canvasOptions),i._xrLayerWrapper=new Hu(i.xrLayer),i.onXRLayerInitObservable.notifyObservers(i.xrLayer),i.xrLayer},[2,this._canvasCompatiblePromise.then((function(){}),(function(){rr.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.")})).then((function(){return t()}))]}))}))},e.prototype._addCanvas=function(){var e=this;this._canvas&&this._engine&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.appendChild(this._canvas),this.xrLayer?this._setCanvasSize(!0):this.onXRLayerInitObservable.addOnce((function(){e._setCanvasSize(!0)}))},e.prototype._removeCanvas=function(){this._canvas&&this._engine&&document.body.contains(this._canvas)&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.removeChild(this._canvas),this._setCanvasSize(!1)},e.prototype._setCanvasSize=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=this._xrLayerWrapper),this._canvas&&this._engine&&(e?t&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=t.getWidth()+"px",this._canvas.style.height=t.getHeight()+"px"):this._engine.setSize(t.getWidth(),t.getHeight())):this._originalCanvasSize&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=this._originalCanvasSize.width+"px",this._canvas.style.height=this._originalCanvasSize.height+"px"):this._engine.setSize(this._originalCanvasSize.width,this._originalCanvasSize.height)))},e.prototype._setManagedOutputCanvas=function(e){this._removeCanvas(),e?(this._originalCanvasSize={width:e.offsetWidth,height:e.offsetHeight},this._canvas=e,this.canvasContext=this._canvas.getContext("webgl2"),this.canvasContext||(this.canvasContext=this._canvas.getContext("webgl"))):(this._canvas=null,this.canvasContext=null)},e}(),Ku=function(e){function t(t){var i=e.call(this,(function(){return t.framebufferWidth}),(function(){return t.framebufferHeight}),t,"XRWebGLLayer",(function(e){return new Qu(e,i)}))||this;return i.layer=t,i}return m(t,e),t}(zu),Qu=function(e){function t(t,i){var r=e.call(this,t.scene,i)||this;return r.layerWrapper=i,r._nativeRTTProvider=navigator.xr.getNativeRenderTargetProvider(t.session,r._createRenderTargetTexture.bind(r),r._destroyRenderTargetTexture.bind(r)),r._nativeLayer=i.layer,r}return m(t,e),t.prototype.trySetViewportForView=function(e){return e.x=0,e.y=0,e.width=1,e.height=1,!0},t.prototype.getRenderTargetTextureForEye=function(e){return this._nativeRTTProvider.getRenderTargetForEye(e)},t.prototype.getRenderTargetTextureForView=function(e){return this._nativeRTTProvider.getRenderTargetForEye(e.eye)},t.prototype.getFramebufferDimensions=function(){return{framebufferWidth:this._nativeLayer.framebufferWidth,framebufferHeight:this._nativeLayer.framebufferHeight}},t}(Wu),qu=function(){function e(e){this._nativeRenderTarget=navigator.xr.getWebXRRenderTarget(e.scene.getEngine())}return e.prototype.initializeXRLayerAsync=function(e){return y(this,void 0,void 0,(function(){return b(this,(function(t){switch(t.label){case 0:return[4,this._nativeRenderTarget.initializeXRLayerAsync(e)];case 1:return t.sent(),this.xrLayer=this._nativeRenderTarget.xrLayer,[2,this.xrLayer]}}))}))},e.prototype.dispose=function(){},e}(),Zu=function(){function e(e){var t=this;this.scene=e,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new f,this.onXRReferenceSpaceChanged=new f,this.onXRSessionEnded=new f,this.onXRSessionInit=new f,this.onXRReferenceSpaceInitialized=new f,this.onXRReady=new f,this.inXRFrameLoop=!1,this.inXRSession=!1,this._worldScalingFactor=1,this.onWorldScaleFactorChangedObservable=new f(void 0,!0),this._engine=e.getEngine(),this._onEngineDisposedObserver=this._engine.onDisposeObservable.addOnce((function(){t._engine=null})),e.onDisposeObservable.addOnce((function(){t.dispose()}))}return Object.defineProperty(e.prototype,"worldScalingFactor",{get:function(){return this._worldScalingFactor},set:function(e){var t=this._worldScalingFactor;this._worldScalingFactor=e,this.onWorldScaleFactorChangedObservable.notifyObservers({previousScaleFactor:t,newScaleFactor:e})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"referenceSpace",{get:function(){return this._referenceSpace},set:function(e){this._referenceSpace=e,this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionMode",{get:function(){return this._sessionMode},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){var e;this.inXRSession&&this.exitXRAsync(),this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear(),this.onXRReferenceSpaceChanged.clear(),this.onXRSessionInit.clear(),this.onWorldScaleFactorChangedObservable.clear(),null===(e=this._engine)||void 0===e||e.onDisposeObservable.remove(this._onEngineDisposedObserver),this._engine=null},e.prototype.exitXRAsync=function(){return y(this,void 0,void 0,(function(){return b(this,(function(e){switch(e.label){case 0:if(!this.session||!this.inXRSession)return[3,4];this.inXRSession=!1,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.session.end()];case 2:return[2,e.sent()];case 3:return e.sent(),ae.Warn("Could not end XR session."),[3,4];case 4:return[2,Promise.resolve()]}}))}))},e.prototype.trySetViewportForView=function(e,t){var i;return(null===(i=this._baseLayerRTTProvider)||void 0===i?void 0:i.trySetViewportForView(e,t))||!1},e.prototype.getRenderTargetTextureForEye=function(e){var t;return(null===(t=this._baseLayerRTTProvider)||void 0===t?void 0:t.getRenderTargetTextureForEye(e))||null},e.prototype.getRenderTargetTextureForView=function(e){var t;return(null===(t=this._baseLayerRTTProvider)||void 0===t?void 0:t.getRenderTargetTextureForView(e))||null},e.prototype.getWebXRRenderTarget=function(e){var t=this.scene.getEngine();return this._xrNavigator.xr.native?new qu(this):((e=e||ju.GetDefaults(t)).canvasElement=e.canvasElement||t.getRenderingCanvas()||void 0,new Yu(this,e))},e.prototype.initializeAsync=function(){return this._xrNavigator=navigator,this._xrNavigator.xr?Promise.resolve():Promise.reject("WebXR not available")},e.prototype.initializeSessionAsync=function(e,t){var i=this;return void 0===e&&(e="immersive-vr"),void 0===t&&(t={}),this._xrNavigator.xr.requestSession(e,t).then((function(t){return i.session=t,i._sessionMode=e,i.inXRSession=!0,i.onXRSessionInit.notifyObservers(t),i.session.addEventListener("end",(function(){var e;i.inXRSession=!1,i.onXRSessionEnded.notifyObservers(null),i._engine&&(i._engine.framebufferDimensionsObject=null,i._engine.restoreDefaultFramebuffer(),i._engine.customAnimationFrameRequester=null,i._engine._renderLoop()),i.isNative&&(null===(e=i._baseLayerRTTProvider)||void 0===e||e.dispose()),i._baseLayerRTTProvider=null,i._baseLayerWrapper=null}),{once:!0}),i.session}))},e.prototype.isSessionSupportedAsync=function(t){return e.IsSessionSupportedAsync(t)},e.prototype.resetReferenceSpace=function(){this.referenceSpace=this.baseReferenceSpace},e.prototype.runXRRenderLoop=function(){var e,t=this;this.inXRSession&&this._engine&&(this._engine.customAnimationFrameRequester={requestAnimationFrame:function(e){return t.session.requestAnimationFrame(e)},renderFunction:function(e,i){var r;if(t.inXRSession&&t._engine&&(t.currentFrame=i,t.currentTimestamp=e,i)){t.inXRFrameLoop=!0;var n=(null===(r=t._baseLayerRTTProvider)||void 0===r?void 0:r.getFramebufferDimensions())||null;t._engine.framebufferDimensionsObject!==n&&(t._engine.framebufferDimensionsObject=n),t.onXRFrameObservable.notifyObservers(i),t._engine._renderLoop(),t._engine.framebufferDimensionsObject=null,t.inXRFrameLoop=!1}}},this._engine.framebufferDimensionsObject=(null===(e=this._baseLayerRTTProvider)||void 0===e?void 0:e.getFramebufferDimensions())||null,this.onXRFrameObservable.addOnce((function(){t.onXRReady.notifyObservers(t)})),"undefined"!=typeof window&&window.cancelAnimationFrame&&window.cancelAnimationFrame(this._engine._frameHandler),this._engine._renderLoop())},e.prototype.setReferenceSpaceTypeAsync=function(e){var t=this;return void 0===e&&(e="local-floor"),this.session.requestReferenceSpace(e).then((function(e){return e}),(function(e){return ae.Error("XR.requestReferenceSpace failed for the following reason: "),ae.Error(e),ae.Log('Defaulting to universally-supported "viewer" reference space type.'),t.session.requestReferenceSpace("viewer").then((function(e){var i=new XRRigidTransform({x:0,y:-t.defaultHeightCompensation,z:0});return e.getOffsetReferenceSpace(i)}),(function(e){throw ae.Error(e),'XR initialization failed: required "viewer" reference space type not supported.'}))})).then((function(e){return t.session.requestReferenceSpace("viewer").then((function(i){return t.viewerReferenceSpace=i,e}))})).then((function(e){return t.referenceSpace=t.baseReferenceSpace=e,t.onXRReferenceSpaceInitialized.notifyObservers(e),t.referenceSpace}))},e.prototype.updateRenderStateAsync=function(e){return Promise.resolve(this.session.updateRenderState(e))},e.prototype._setBaseLayerWrapper=function(e){var t,i;this.isNative&&(null===(t=this._baseLayerRTTProvider)||void 0===t||t.dispose()),this._baseLayerWrapper=e,this._baseLayerRTTProvider=(null===(i=this._baseLayerWrapper)||void 0===i?void 0:i.createRenderTargetTextureProvider(this))||null},e.prototype._getBaseLayerWrapper=function(){return this._baseLayerWrapper},e.prototype.updateRenderState=function(e){e.baseLayer&&this._setBaseLayerWrapper(this.isNative?new Ku(e.baseLayer):new Hu(e.baseLayer)),this.session.updateRenderState(e)},e.IsSessionSupportedAsync=function(e){if(!navigator.xr)return Promise.resolve(!1);var t=navigator.xr.isSessionSupported||navigator.xr.supportsSession;return t?t.call(navigator.xr,e).then((function(e){var t=void 0===e||e;return Promise.resolve(t)})).catch((function(e){return ae.Warn(e),Promise.resolve(!1)})):Promise.resolve(!1)},Object.defineProperty(e.prototype,"isNative",{get:function(){var e;return null!==(e=this._xrNavigator.xr.native)&&void 0!==e&&e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentFrameRate",{get:function(){var e;return null===(e=this.session)||void 0===e?void 0:e.frameRate},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportedFrameRates",{get:function(){var e;return null===(e=this.session)||void 0===e?void 0:e.supportedFrameRates},enumerable:!1,configurable:!0}),e.prototype.updateTargetFrameRate=function(e){return this.session.updateTargetFrameRate(e)},e.prototype.runInXRFrame=function(e,t){void 0===t&&(t=!0),this.inXRFrameLoop?e():!this.inXRSession&&t||this.onXRFrameObservable.addOnce(e)},Object.defineProperty(e.prototype,"isFixedFoveationSupported",{get:function(){var e;return(null===(e=this._baseLayerWrapper)||void 0===e?void 0:e.isFixedFoveationSupported)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fixedFoveation",{get:function(){var e;return(null===(e=this._baseLayerWrapper)||void 0===e?void 0:e.fixedFoveation)||null},set:function(e){var t=Math.max(0,Math.min(1,e||0));this._baseLayerWrapper&&(this._baseLayerWrapper.fixedFoveation=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enabledFeatures",{get:function(){var e,t;return null!==(t=null===(e=this.session)||void 0===e?void 0:e.enabledFeatures)&&void 0!==t?t:null},enumerable:!1,configurable:!0}),e}();!function(e){e[e.ENTERING_XR=0]="ENTERING_XR",e[e.EXITING_XR=1]="EXITING_XR",e[e.IN_XR=2]="IN_XR",e[e.NOT_IN_XR=3]="NOT_IN_XR"}(Vu||(Vu={})),function(e){e[e.NOT_TRACKING=0]="NOT_TRACKING",e[e.TRACKING_LOST=1]="TRACKING_LOST",e[e.TRACKING=2]="TRACKING"}(ku||(ku={})),Fa._GroundMeshParser=function(e,t){return Ju.Parse(e,t)};var Ju=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.generateOctree=!1,r}return m(t,e),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!1,configurable:!0}),t.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e),this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},t.prototype.getHeightAtCoordinates=function(e,t){var i=this.getWorldMatrix(),r=H.Matrix[5];i.invertToRef(r);var n=H.Vector3[8];if(V.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var o=this._getFacetAt(e,t),a=-(o.x*e+o.z*t+o.w)/o.y;return V.TransformCoordinatesFromFloatsToRef(0,a,0,i,n),n.y},t.prototype.getNormalAtCoordinates=function(e,t){var i=new V(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var r=this.getWorldMatrix(),n=H.Matrix[5];r.invertToRef(n);var o=H.Vector3[8];if(V.TransformCoordinatesFromFloatsToRef(e,0,t,n,o),e=o.x,t=o.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(e,t);return V.TransformNormalFromFloatsToRef(a.x,a.y,a.z,r,i),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,t){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return te.maxHeight){c=!0;var u=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=u}for(t=0;t<=e.subdivisions;t++)for(i=0;i<=e.subdivisions;i++){var h=new V(i*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),d=4*(((h.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(h.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),p=e.buffer[d]/255,f=e.buffer[d+1]/255,_=e.buffer[d+2]/255,m=e.buffer[d+3]/255;c&&(p=1-p,f=1-f,_=1-_);var g=p*s.r+f*s.g+_*s.b;h.y=m>=l?e.minHeight+(e.maxHeight-e.minHeight)*g:e.minHeight-A,e.heightBuffer&&(e.heightBuffer[t*(e.subdivisions+1)+i]=h.y),n.push(h.x,h.y,h.z),o.push(0,0,0),a.push(i/e.subdivisions,1-t/e.subdivisions)}for(t=0;t=e.minHeight,S=n[3*y+1]>=e.minHeight,x=n[3*b+1]>=e.minHeight;E&&S&&x&&(r.push(v),r.push(y),r.push(b)),n[3*T+1]>=e.minHeight&&E&&x&&(r.push(T),r.push(v),r.push(b))}_o.ComputeNormals(n,r,o);var C=new _o;return C.indices=r,C.positions=n,C.normals=o,C.uvs=a,C}function ih(e,t,i){void 0===t&&(t={});var r=new Ju(e,i);return r._setReady(!1),r._subdivisionsX=t.subdivisionsX||t.subdivisions||1,r._subdivisionsY=t.subdivisionsY||t.subdivisions||1,r._width=t.width||1,r._height=t.height||1,r._maxX=r._width/2,r._maxZ=r._height/2,r._minX=-r._maxX,r._minZ=-r._maxZ,$u(t).applyToMesh(r,t.updatable),r._setReady(!0),r}function rh(e,t,i){void 0===i&&(i=null);var r=new Fa(e,i);return eh(t).applyToMesh(r,t.updatable),r}function nh(e,t,i,r){void 0===i&&(i={}),void 0===r&&(r=null);var n=i.width||10,o=i.height||10,a=i.subdivisions||1,s=i.minHeight||0,l=i.maxHeight||1,c=i.colorFilter||new Z(.3,.59,.11),u=i.alphaFilter||0,h=i.updatable,d=i.onReady;r=r||M.LastCreatedScene;var p,f=new Ju(e,r);f._subdivisionsX=a,f._subdivisionsY=a,f._width=n,f._height=o,f._maxX=f._width/2,f._maxZ=f._height/2,f._minX=-f._maxX,f._minZ=-f._maxZ,f._setReady(!1),i.passHeightBufferInCallback&&(p=new Float32Array((a+1)*(a+1)));var _=function(e,t,i){th({width:n,height:o,subdivisions:a,minHeight:s,maxHeight:l,colorFilter:c,buffer:e,bufferWidth:t,bufferHeight:i,alphaFilter:u,heightBuffer:p}).applyToMesh(f,h),d&&d(f,p),f._setReady(!0)};return"string"==typeof t?rr.LoadImage(t,(function(e){var t=e.width,i=e.height;if(!r.isDisposed){var n=null==r?void 0:r.getEngine().resizeImageBitmap(e,t,i);_(n,t,i)}}),i.onError?i.onError:function(){},r.offlineProvider):_(t.data,t.width,t.height),f}var oh={CreateGround:ih,CreateGroundFromHeightMap:nh,CreateTiledGround:rh};function ah(e){for(var t=[],i=[],r=[],n=[],o=e.diameter||1,a=e.thickness||.5,s=0|(e.tessellation||16),l=0===e.sideOrientation?0:e.sideOrientation||_o.DEFAULTSIDE,c=s+1,u=0;u<=s;u++)for(var h=u/s,d=u*Math.PI*2/s-Math.PI/2,p=z.Translation(o/2,0,0).multiply(z.RotationY(d)),f=0;f<=s;f++){var _=1-f/s,m=f*Math.PI*2/s+Math.PI,g=Math.cos(m),v=Math.sin(m),y=new V(g,v,0),b=y.scale(a/2),T=new U(h,_);b=V.TransformCoordinates(b,p),y=V.TransformNormal(y,p),i.push(b.x,b.y,b.z),r.push(y.x,y.y,y.z),n.push(T.x,go.UseOpenGLOrientationForUV?1-T.y:T.y);var E=(u+1)%c,S=(f+1)%c;t.push(u*c+f),t.push(u*c+S),t.push(E*c+f),t.push(u*c+S),t.push(E*c+S),t.push(E*c+f)}_o._ComputeSides(l,i,t,r,n,e.frontUVs,e.backUVs);var x=new _o;return x.indices=t,x.positions=i,x.normals=r,x.uvs=n,x}function sh(e,t,i){void 0===t&&(t={});var r=new Fa(e,i);return t.sideOrientation=Fa._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,ah(t).applyToMesh(r,t.updatable),r}_o.CreateGround=$u,_o.CreateTiledGround=eh,_o.CreateGroundFromHeightMap=th,Fa.CreateGround=function(e,t,i,r,n,o){return ih(e,{width:t,height:i,subdivisions:r,updatable:o},n)},Fa.CreateTiledGround=function(e,t,i,r,n,o,a,s,l){return rh(e,{xmin:t,zmin:i,xmax:r,zmax:n,subdivisions:o,precision:a,updatable:l},s)},Fa.CreateGroundFromHeightMap=function(e,t,i,r,n,o,a,s,l,c,u){return nh(e,t,{width:i,height:r,subdivisions:n,minHeight:o,maxHeight:a,updatable:l,onReady:c,alphaFilter:u},s)};var lh={CreateTorus:sh};_o.CreateTorus=ah,Fa.CreateTorus=function(e,t,i,r,n,o,a){return sh(e,{diameter:t,thickness:i,tessellation:r,sideOrientation:a,updatable:o},n)};var ch,uh=function(e){function t(t,i){var r=e.call(this,i)||this;return r._getCamera=t,r}return m(t,e),t.prototype._getForwardRay=function(e){var t=this._getCamera();return t?t.getForwardRay(e):new hs(V.Zero(),V.Forward())},t}(function(){function e(t,i){if(void 0===i&&(i=null),this.scene=t,this._pointerDownOnMeshAsked=!1,this._isActionableMesh=!1,this._teleportationRequestInitiated=!1,this._teleportationBackRequestInitiated=!1,this._rotationRightAsked=!1,this._rotationLeftAsked=!1,this._dpadPressed=!0,this._activePointer=!1,this._id=e._IdCounter++,i)this._gazeTracker=i.clone("gazeTracker");else{this._gazeTracker=sh("gazeTracker",{diameter:.0035,thickness:.0025,tessellation:20,updatable:!1},t),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var r=new Uu("targetMat",t);r.specularColor=Z.Black(),r.emissiveColor=new Z(.7,.7,.7),r.backFaceCulling=!1,this._gazeTracker.material=r}}return e.prototype._getForwardRay=function(e){return new hs(V.Zero(),new V(0,0,e))},e.prototype._selectionPointerDown=function(){this._pointerDownOnMeshAsked=!0,this._currentHit&&this.scene.simulatePointerDown(this._currentHit,{pointerId:this._id})},e.prototype._selectionPointerUp=function(){this._currentHit&&this.scene.simulatePointerUp(this._currentHit,{pointerId:this._id}),this._pointerDownOnMeshAsked=!1},e.prototype._activatePointer=function(){this._activePointer=!0},e.prototype._deactivatePointer=function(){this._activePointer=!1},e.prototype._updatePointerDistance=function(e){void 0===e&&(e=100)},e.prototype.dispose=function(){this._interactionsEnabled=!1,this._teleportationEnabled=!1,this._gazeTracker&&this._gazeTracker.dispose()},e._IdCounter=0,e}()),hh=function(){},dh=function(){function e(t,i){void 0===i&&(i={});var r=this;if(this.webVROptions=i,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new f,this.onAfterEnteringVRObservable=new f,this.onExitingVRObservable=new f,this._useCustomVRButton=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._teleportationMode=e.TELEPORTATIONMODE_CONSTANTTIME,this._teleportationTime=122,this._teleportationSpeed=20,this._rotationAllowed=!0,this._teleportBackwardsVector=new V(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new V(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._pickedLaserColor=new Z(.2,.2,1),this._pickedGazeColor=new Z(0,0,1),this.onNewMeshSelected=new f,this.onNewMeshPicked=new f,this.onBeforeCameraTeleport=new f,this.onAfterCameraTeleport=new f,this.onSelectedMeshUnselected=new f,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._displayGaze=!0,this._displayLaserPointer=!0,this.updateGazeTrackerScale=!0,this.updateGazeTrackerColor=!0,this.updateControllerLaserColor=!0,this.requestPointerLockOnFullScreen=!0,this.xrTestDone=!1,this._onResize=function(){r._moveButtonToBottomRight()},this._onFullscreenChange=function(){r._fullscreenVRpresenting=!!document.fullscreenElement,!r._fullscreenVRpresenting&&r._inputElement&&(r.exitVR(),!r._useCustomVRButton&&r._btnVR&&(r._btnVR.style.top=r._inputElement.offsetTop+r._inputElement.offsetHeight-70+"px",r._btnVR.style.left=r._inputElement.offsetLeft+r._inputElement.offsetWidth-100+"px",r._updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this._beforeRender=function(){r._scene.getEngine().isPointerLock||r.enableGazeEvenWhenNoPointerLock||(r._cameraGazer._gazeTracker.isVisible=!1)},this._onNewGamepadConnected=function(e){e.type!==ac.POSE_ENABLED&&(e.leftStick&&e.onleftstickchanged((function(e){r._teleportationInitialized&&r.teleportationEnabled&&(r._checkTeleportWithRay(e,r._cameraGazer),r._checkTeleportBackwards(e,r._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){r._teleportationInitialized&&r._checkRotate(e,r._cameraGazer)})),e.type===ac.XBOX&&(e.onbuttondown((function(e){r._interactionsEnabled&&e===Uc.A&&r._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){r._interactionsEnabled&&e===Uc.A&&r._cameraGazer._selectionPointerUp()}))))},this._workingVector=V.Zero(),this._workingQuaternion=G.Identity(),this._workingMatrix=z.Identity(),ae.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||void 0!==i.useXR||(i.useXR=!0),void 0===i.createFallbackVRDeviceOrientationFreeCamera&&(i.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===i.createDeviceOrientationCamera&&(i.createDeviceOrientationCamera=!0),void 0===i.laserToggle&&(i.laserToggle=!0),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new V(0,this._defaultHeight,0),i.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new Fc("deviceOrientationVRHelper",this._position.clone(),t),this._scene.activeCamera&&(this._deviceOrientationCamera.minZ=this._scene.activeCamera.minZ,this._deviceOrientationCamera.maxZ=this._scene.activeCamera.maxZ,this._scene.activeCamera instanceof Mc&&this._scene.activeCamera.rotation)){var n=this._scene.activeCamera;n.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(n.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(G.RotationYawPitchRoll(n.rotation.y,n.rotation.x,n.rotation.z)),this._deviceOrientationCamera.rotation=n.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._inputElement&&this._scene.activeCamera.attachControl()}else this._existingCamera=this._scene.activeCamera;this.webVROptions.useXR&&navigator.xr?Zu.IsSessionSupportedAsync("immersive-vr").then((function(e){e?(ae.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),t.createDefaultXRExperienceAsync({floorMeshes:i.floorMeshes||[]}).then((function(e){r.xr=e,r.xrTestDone=!0,r._cameraGazer=new uh((function(){return r.xr.baseExperience.camera}),t),r.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case Vu.ENTERING_XR:r.onEnteringVRObservable.notifyObservers(r),r._interactionsEnabled||r.xr.pointerSelection.detach(),r.xr.pointerSelection.displayLaserPointer=r._displayLaserPointer;break;case Vu.EXITING_XR:r.onExitingVRObservable.notifyObservers(r),r._scene.getEngine().resize();break;case Vu.IN_XR:r._hasEnteredVR=!0;break;case Vu.NOT_IN_XR:r._hasEnteredVR=!1}}))}))):r._completeVRInit(t,i)})):this._completeVRInit(t,i)}return Object.defineProperty(e.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"teleportationTarget",{get:function(){return this._teleportationTarget},set:function(e){e&&(e.name="teleportationTarget",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"gazeTrackerMesh",{get:function(){return this._cameraGazer._gazeTracker},set:function(e){e&&(this._cameraGazer._gazeTracker&&this._cameraGazer._gazeTracker.dispose(),this._cameraGazer._gazeTracker=e,this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),this._cameraGazer._gazeTracker.isPickable=!1,this._cameraGazer._gazeTracker.isVisible=!1,this._cameraGazer._gazeTracker.name="gazeTracker")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayGaze",{get:function(){return this._displayGaze},set:function(e){this._displayGaze=e,e||(this._cameraGazer._gazeTracker.isVisible=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(e){this._displayLaserPointer=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentVRCamera",{get:function(){return this._scene.activeCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vrButton",{get:function(){return this._btnVR},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_teleportationRequestInitiated",{get:function(){return this._cameraGazer._teleportationRequestInitiated},enumerable:!1,configurable:!0}),e.prototype._completeVRInit=function(e,t){var i=this;if(this.xrTestDone=!0,t.createFallbackVRDeviceOrientationFreeCamera&&(this._vrDeviceOrientationCamera=new Tu("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._cameraGazer=new uh((function(){return i.currentVRCamera}),e),!this._useCustomVRButton){this._btnVR=document.createElement("BUTTON"),this._btnVR.className="babylonVRicon",this._btnVR.id="babylonVRiconbtn",this._btnVR.title="Click to switch to VR";var r=".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A":"https://cdn.babylonjs.com/Assets/vrButton.png")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";r+=".babylonVRicon.vrdisplaypresenting { display: none; }";var n=document.createElement("style");n.appendChild(document.createTextNode(r)),document.getElementsByTagName("head")[0].appendChild(n),this._moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){i.isInVRMode||i.enterVR()}));var o=this._scene.getEngine().getHostWindow();o&&(o.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),t.createFallbackVRDeviceOrientationFreeCamera&&this._displayVRButton(),this._onKeyDown=function(e){27===e.keyCode&&i.isInVRMode&&i.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add((function(){i._hasEnteredVR&&i.exitVROnDoubleTap&&(i.exitVR(),i._fullscreenVRpresenting&&i._scene.getEngine().exitFullscreen())}),Gr.POINTERDOUBLETAP,!1),e.onDisposeObservable.add((function(){i.dispose()})),this._updateButtonVisibility(),this._circleEase=new Pn,this._circleEase.setEasingMode(Rn.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){i._interactionsEnabled&&e.activeCamera===i.vrDeviceOrientationCamera&&"mouse"===t.event.pointerType&&(t.type===Gr.POINTERDOWN?i._cameraGazer._selectionPointerDown():t.type===Gr.POINTERUP&&i._cameraGazer._selectionPointerUp())})),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes}))},Object.defineProperty(e.prototype,"isInVRMode",{get:function(){return this.xr&&this.webVROptions.useXR&&this.xr.baseExperience.state===Vu.IN_XR||this._fullscreenVRpresenting},enumerable:!1,configurable:!0}),e.prototype._moveButtonToBottomRight=function(){if(this._inputElement&&!this._useCustomVRButton&&this._btnVR){var e=this._inputElement.getBoundingClientRect();this._btnVR.style.top=e.top+e.height-70+"px",this._btnVR.style.left=e.left+e.width-100+"px"}},e.prototype._displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||!this._btnVR||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},e.prototype._updateButtonVisibility=function(){this._btnVR&&!this._useCustomVRButton&&(this._btnVR.className="babylonVRicon",this.isInVRMode&&(this._btnVR.className+=" vrdisplaypresenting"))},e.prototype.enterVR=function(){var e=this;if(this.xr)this.xr.baseExperience.enterXRAsync("immersive-vr","local-floor",this.xr.renderTarget);else{if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(e){ae.Warn("Error in your custom logic onEnteringVR: "+e)}this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=G.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this._existingCamera=this._scene.activeCamera,this._existingCamera.angularSensibilityX&&(this._cachedAngularSensibility.angularSensibilityX=this._existingCamera.angularSensibilityX,this._existingCamera.angularSensibilityX=Number.MAX_VALUE),this._existingCamera.angularSensibilityY&&(this._cachedAngularSensibility.angularSensibilityY=this._existingCamera.angularSensibilityY,this._existingCamera.angularSensibilityY=Number.MAX_VALUE),this._existingCamera.angularSensibility&&(this._cachedAngularSensibility.angularSensibility=this._existingCamera.angularSensibility,this._existingCamera.angularSensibility=Number.MAX_VALUE)),this._vrDeviceOrientationCamera&&(this._vrDeviceOrientationCamera.position=this._position,this._scene.activeCamera&&(this._vrDeviceOrientationCamera.minZ=this._scene.activeCamera.minZ),this._scene.activeCamera=this._vrDeviceOrientationCamera,this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen),this._updateButtonVisibility(),this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce((function(){e.onAfterEnteringVRObservable.notifyObservers({success:!0})}))),this._scene.activeCamera&&this._inputElement&&this._scene.activeCamera.attachControl(),this._interactionsEnabled&&this._scene.registerBeforeRender(this._beforeRender),this._hasEnteredVR=!0}},e.prototype.exitVR=function(){if(this.xr)this.xr.baseExperience.exitXRAsync();else if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){ae.Warn("Error in your custom logic onExitingVR: "+e)}this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone()),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._cachedAngularSensibility.angularSensibilityX&&(this._deviceOrientationCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._deviceOrientationCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._deviceOrientationCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera,this._inputElement&&this._scene.activeCamera.attachControl(),this._cachedAngularSensibility.angularSensibilityX&&(this._existingCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._existingCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._existingCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)),this._updateButtonVisibility(),this._interactionsEnabled&&(this._scene.unregisterBeforeRender(this._beforeRender),this._cameraGazer._gazeTracker.isVisible=!1),this._scene.getEngine().resize(),this._hasEnteredVR=!1}},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._scene.activeCamera&&(this._scene.activeCamera.position=e)},enumerable:!1,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;if(!this._interactionsEnabled){if(this.xr)return void(this.xr.baseExperience.state===Vu.IN_XR&&this.xr.pointerSelection.attach());this.raySelectionPredicate=function(t){return t.isVisible&&(t.isPickable||t.name===e._floorMeshName)},this.meshSelectionPredicate=function(){return!0},this._raySelectionPredicate=function(t){return!!(e._isTeleportationFloor(t)||-1===t.name.indexOf("gazeTracker")&&-1===t.name.indexOf("teleportationTarget")&&-1===t.name.indexOf("torusTeleportation"))&&e.raySelectionPredicate(t)},this._interactionsEnabled=!0}},e.prototype._isTeleportationFloor=function(e){for(var t=0;t-1||this._floorMeshesCollection.push(e))},e.prototype.removeFloorMesh=function(e){if(this._floorMeshesCollection){var t=this._floorMeshesCollection.indexOf(e);-1!==t&&this._floorMeshesCollection.splice(t,1)}},e.prototype.enableTeleportation=function(e){var t=this;if(void 0===e&&(e={}),!this._teleportationInitialized){if(this.enableInteractions(),this.webVROptions.useXR&&(e.floorMeshes||e.floorMeshName)){var i=e.floorMeshes||[];if(!i.length){var r=this._scene.getMeshByName(e.floorMeshName);r&&i.push(r)}if(this.xr)return i.forEach((function(e){t.xr.teleportation.addFloorMesh(e)})),void(this.xr.teleportation.attached||this.xr.teleportation.attach());if(!this.xrTestDone){var n=function(){t.xrTestDone&&(t._scene.unregisterBeforeRender(n),t.xr?t.xr.teleportation.attached||t.xr.teleportation.attach():t.enableTeleportation(e))};return void this._scene.registerBeforeRender(n)}}e.floorMeshName&&(this._floorMeshName=e.floorMeshName),e.floorMeshes&&(this._floorMeshesCollection=e.floorMeshes),e.teleportationMode&&(this._teleportationMode=e.teleportationMode),e.teleportationTime&&e.teleportationTime>0&&(this._teleportationTime=e.teleportationTime),e.teleportationSpeed&&e.teleportationSpeed>0&&(this._teleportationSpeed=e.teleportationSpeed),void 0!==e.easingFunction&&(this._teleportationEasing=e.easingFunction);var o=new pr;o.vignetteColor=new J(0,0,0,0),o.vignetteEnabled=!0,this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&this._createTeleportationCircles()}},e.prototype._checkTeleportWithRay=function(e,t){this._teleportationRequestInitiated&&!t._teleportationRequestInitiated||(t._teleportationRequestInitiated?Math.sqrt(e.y*e.y+e.x*e.x)-this._padSensibilityDown&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.xthis._padSensibilityUp&&t._dpadPressed&&(t._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},e.prototype._checkTeleportBackwards=function(e,t){if(!t._teleportationRequestInitiated)if(e.y>this._padSensibilityUp&&t._dpadPressed){if(!t._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var i=G.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),r=this.currentVRCamera.position;i.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,G.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),V.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var n=new hs(r,this._workingVector),o=this._scene.pickWithRay(n,this._raySelectionPredicate);o&&o.pickedPoint&&o.pickedMesh&&this._isTeleportationFloor(o.pickedMesh)&&o.distance<5&&this.teleportCamera(o.pickedPoint),t._teleportationBackRequestInitiated=!0}}else t._teleportationBackRequestInitiated=!1},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=ih("teleportationTarget",{width:2,height:2,subdivisions:2},this._scene),this._teleportationTarget.isPickable=!1;var e=new Gu("DynamicTexture",512,this._scene,!0);e.hasAlpha=!0;var t=e.getContext();t.beginPath(),t.arc(256,256,200,0,2*Math.PI,!1),t.fillStyle=this._teleportationFillColor,t.fill(),t.lineWidth=10,t.strokeStyle=this._teleportationBorderColor,t.stroke(),t.closePath(),e.update();var i=new Uu("TextPlaneMaterial",this._scene);i.diffuseTexture=e,this._teleportationTarget.material=i;var r=sh("torusTeleportation",{diameter:.75,thickness:.1,tessellation:25,updatable:!1},this._scene);r.isPickable=!1,r.parent=this._teleportationTarget;var n=new at("animationInnerCircle","position.y",30,at.ANIMATIONTYPE_FLOAT,at.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),n.setKeys(o);var a=new Un;a.setEasingMode(Rn.EASINGMODE_EASEINOUT),n.setEasingFunction(a),r.animations=[],r.animations.push(n),this._scene.beginAnimation(r,0,60,!0),this._hideTeleportationTarget()},e.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},e.prototype._rotateCamera=function(e){if(this.currentVRCamera instanceof Oc){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var t=G.FromRotationMatrix(z.RotationY(Math.PI/4*this._rotationAngle)),i=new at("animationRotation","rotationQuaternion",90,at.ANIMATIONTYPE_QUATERNION,at.ANIMATIONLOOPMODE_CONSTANT),r=[];r.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),r.push({frame:6,value:t}),i.setKeys(r),i.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(i),this._postProcessMove.animations=[];var n=new at("animationPP","vignetteWeight",90,at.ANIMATIONTYPE_FLOAT,at.ANIMATIONLOOPMODE_CONSTANT),o=[];o.push({frame:0,value:0}),o.push({frame:3,value:4}),o.push({frame:6,value:0}),n.setKeys(o),n.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(n);var a=new at("animationPP2","vignetteStretch",90,at.ANIMATIONTYPE_FLOAT,at.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:3,value:10}),s.push({frame:6,value:0}),a.setKeys(s),a.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(a),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},e.prototype.teleportCamera=function(t){var i=this;if(this.currentVRCamera instanceof Oc){var r,n;if(this._workingVector.copyFrom(t),this.isInVRMode||(this._workingVector.y+=this._defaultHeight),this.onBeforeCameraTeleport.notifyObservers(this._workingVector),this._teleportationMode==e.TELEPORTATIONMODE_CONSTANTSPEED){n=90;var o=V.Distance(this.currentVRCamera.position,this._workingVector);r=this._teleportationSpeed/o}else n=Math.round(90*this._teleportationTime/1e3),r=1;this.currentVRCamera.animations=[];var a=new at("animationCameraTeleportation","position",90,at.ANIMATIONTYPE_VECTOR3,at.ANIMATIONLOOPMODE_CONSTANT),s=[{frame:0,value:this.currentVRCamera.position},{frame:n,value:this._workingVector}];a.setKeys(s),a.setEasingFunction(this._teleportationEasing),this.currentVRCamera.animations.push(a),this._postProcessMove.animations=[];var l=Math.round(n/2),c=new at("animationPP","vignetteWeight",90,at.ANIMATIONTYPE_FLOAT,at.ANIMATIONLOOPMODE_CONSTANT),u=[];u.push({frame:0,value:0}),u.push({frame:l,value:8}),u.push({frame:n,value:0}),c.setKeys(u),this._postProcessMove.animations.push(c);var h=new at("animationPP2","vignetteStretch",90,at.ANIMATIONTYPE_FLOAT,at.ANIMATIONLOOPMODE_CONSTANT),d=[];d.push({frame:0,value:0}),d.push({frame:l,value:10}),d.push({frame:n,value:0}),h.setKeys(d),this._postProcessMove.animations.push(h),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._scene.beginAnimation(this.currentVRCamera,0,n,!1,r,(function(){i.onAfterCameraTeleport.notifyObservers(i._workingVector)})),this._hideTeleportationTarget()}},e.prototype.setLaserColor=function(e,t){void 0===t&&(t=this._pickedLaserColor),this._pickedLaserColor=t},e.prototype.setLaserLightingState=function(e){void 0===e&&(e=!0)},e.prototype.setGazeColor=function(e,t){void 0===t&&(t=this._pickedGazeColor),this._pickedGazeColor=t},e.prototype.changeLaserColor=function(e){this.updateControllerLaserColor},e.prototype.changeGazeColor=function(e){this.updateGazeTrackerColor&&this._cameraGazer._gazeTracker.material&&(this._cameraGazer._gazeTracker.material.emissiveColor=e)},e.prototype.dispose=function(){this.isInVRMode&&this.exitVR(),this._postProcessMove&&this._postProcessMove.dispose(),this._vrDeviceOrientationCamera&&this._vrDeviceOrientationCamera.dispose(),!this._useCustomVRButton&&this._btnVR&&this._btnVR.parentNode&&document.body.removeChild(this._btnVR),this._deviceOrientationCamera&&this._scene.activeCamera!=this._deviceOrientationCamera&&this._deviceOrientationCamera.dispose(),this._cameraGazer&&this._cameraGazer.dispose(),this._teleportationTarget&&this._teleportationTarget.dispose(),this.xr&&this.xr.dispose(),this._floorMeshesCollection.length=0,document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChangeBind),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFullscreenChange),this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),this._scene.unregisterBeforeRender(this._beforeRender)},e.prototype.getClassName=function(){return"VRExperienceHelper"},e.TELEPORTATIONMODE_CONSTANTTIME=0,e.TELEPORTATIONMODE_CONSTANTSPEED=1,e}(),ph=(ch={root:0,found:!1},function(e,t,i,r){ch.root=0,ch.found=!1;var n=t*t-4*e*i;if(n<0)return ch;var o=Math.sqrt(n),a=(-t-o)/(2*e),s=(-t+o)/(2*e);if(a>s){var l=s;s=a,a=l}return a>0&&a0&&s=0))},e.prototype._canDoCollision=function(e,t,i,r){var n=V.Distance(this._basePointWorld,e),o=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(n>this._velocityWorldLength+o+t||!function(e,t,i,r){return!(e.x>i.x+r||i.x-r>t.x||e.y>i.y+r||i.y-r>t.y||e.z>i.z+r||i.z-r>t.z)}(i,r,this._basePointWorld,this._velocityWorldLength+o))},e.prototype._testTriangle=function(t,i,r,n,o,a,s){var l,c=!1;i||(i=[]),i[t]||(i[t]=new sn(0,0,0,0),i[t].copyFromPoints(r,n,o));var u=i[t];if(a||u.isFrontFacingTo(this._normalizedVelocity,0)){var h=u.signedDistanceTo(this._basePoint),d=V.Dot(u.normal,this._velocity);if(!(e.DoubleSidedCheck&&d>1e-4)){if(0==d){if(Math.abs(h)>=1)return;c=!0,l=0}else{var p=(1-h)/d;if((l=(-1-h)/d)>p){var f=p;p=l,l=f}if(l>1||p<0)return;l<0&&(l=0),l>1&&(l=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(c||(this._basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(l,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,r,n,o,u.normal)&&(_=!0,m=l,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this._velocitySquaredLength;this._basePoint.subtractToRef(r,this._tempVector);var v=2*V.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,b=ph(g,v,y,m);b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(r)),this._basePoint.subtractToRef(n,this._tempVector),v=2*V.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=ph(g,v,y,m)).found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(o,this._tempVector),v=2*V.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=ph(g,v,y,m)).found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(o)),n.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex);var T,E=this._edge.lengthSquared(),S=V.Dot(this._edge,this._velocity),x=V.Dot(this._edge,this._baseToVertex);g=E*-this._velocitySquaredLength+S*S,v=2*(E*V.Dot(this._velocity,this._baseToVertex)-S*x),y=E*(1-this._baseToVertex.lengthSquared())+x*x,(b=ph(g,v,y,m)).found&&(T=(S*b.root-x)/E)>=0&&T<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(T),r.addToRef(this._edge,this._collisionPoint)),o.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=V.Dot(this._edge,this._velocity),x=V.Dot(this._edge,this._baseToVertex),g=E*-this._velocitySquaredLength+S*S,v=2*(E*V.Dot(this._velocity,this._baseToVertex)-S*x),y=E*(1-this._baseToVertex.lengthSquared())+x*x,(b=ph(g,v,y,m)).found&&(T=(S*b.root-x)/E)>=0&&T<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(T),n.addToRef(this._edge,this._collisionPoint)),r.subtractToRef(o,this._edge),o.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=V.Dot(this._edge,this._velocity),x=V.Dot(this._edge,this._baseToVertex),g=E*-this._velocitySquaredLength+S*S,v=2*(E*V.Dot(this._velocity,this._baseToVertex)-S*x),y=E*(1-this._baseToVertex.lengthSquared())+x*x,(b=ph(g,v,y,m)).found&&(T=(S*b.root-x)/E)>=0&&T<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(T),o.addToRef(this._edge,this._collisionPoint))}if(_){var A=m*m*this._velocitySquaredLength;(!this.collisionFound||A=r)n.copyFrom(e);else{var s=o?o.collisionMask:i.collisionMask;i._initialize(e,t,a);for(var l=o&&o.surroundingMeshes||this._scene.meshes,c=0;c-1?e:this._shaderRepository+e,this._engine._loadFile(n+"."+t.toLowerCase()+".fx",r)):r(window.atob(e.substr(7))):r(e.substr(7))},Object.defineProperty(e.prototype,"computeSourceCode",{get:function(){var e,t;return this._computeSourceCodeOverride?this._computeSourceCodeOverride:null!==(t=null===(e=this._pipelineContext)||void 0===e?void 0:e._getComputeShaderCode())&&void 0!==t?t:this._computeSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawComputeSourceCode",{get:function(){return this._rawComputeSourceCode},enumerable:!1,configurable:!0}),e.prototype._prepareEffect=function(){var e=this,t=this.defines,i=this._pipelineContext;this._isReady=!1;try{var r=this._engine;this._pipelineContext=r.createComputePipelineContext(),this._pipelineContext._name=this._key,r._prepareComputePipelineContext(this._pipelineContext,this._computeSourceCodeOverride?this._computeSourceCodeOverride:this._computeSourceCode,this._rawComputeSourceCode,this._computeSourceCodeOverride?null:t,this._entryPoint),r._executeWhenComputeStateIsCompiled(this._pipelineContext,(function(t){t&&t.numErrors>0?e._processCompilationErrors(t,i):(e._compilationError="",e._isReady=!0,e.onCompiled&&e.onCompiled(e),e.onCompileObservable.notifyObservers(e),e.onCompileObservable.clear(),i&&e.getEngine()._deleteComputePipelineContext(i))})),this._pipelineContext.isAsync&&this._checkIsReady(i)}catch(e){this._processCompilationErrors(e,i)}},e.prototype._processCompilationErrors=function(t,i){var r;if(void 0===i&&(i=null),this._compilationError="",ae.Error("Unable to compile compute effect:"),this.defines&&ae.Error("Defines:\n"+this.defines),e.LogShaderCodeOnCompilationError){var n=null===(r=this._pipelineContext)||void 0===r?void 0:r._getComputeShaderCode();n&&(ae.Error("Compute code:"),ae.Error(n))}if("string"==typeof t)this._compilationError=t,ae.Error("Error: "+this._compilationError);else for(var o=0,a=t.messages;othis.capacity&&this._depth-1&&this.entries.splice(i,1)}},e.prototype.addEntries=function(e){for(var t=0;t1)?1:e.arc||1,h=0===e.sideOrientation?0:e.sideOrientation||_o.DEFAULTSIDE,d=e.faceUV||new Array(3),p=e.faceColors,f=2+(1+(1!==u&&l?2:0))*(s?a:1);for(n=0;n0)):!i._pointerCaptures[s.pointerId]&&o.distance>=a.distance&&(i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(a.pickedMesh)?(i._notifyObservers(t,a,s),t.skipOnPointerObservable=!0):(t.type!==Gr.POINTERMOVE&&t.type!==Gr.POINTERUP||i._lastPointerEvents[s.pointerId]&&(i.onPointerOutObservable.notifyObservers(s.pointerId),delete i._lastPointerEvents[s.pointerId]),i._notifyObservers(t,o,s))),t.type===Gr.POINTERUP&&i._pointerCaptures[s.pointerId]&&(i._pointerCaptures[s.pointerId]=!1))}}}})),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterRenderCameraObservable.add((function(e){i.shouldRender&&e==i.getRenderCamera()&&i.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){i.dispose()})),this._updateCamera()}return e.prototype.getRenderCamera=function(e){if(this._renderCamera)return this._renderCamera;var t;return t=this.originalScene.activeCameras&&this.originalScene.activeCameras.length>1?this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.originalScene.activeCamera,e&&t&&t.isRigCamera?t.rigParent:t},e.prototype.setRenderCamera=function(e){this._renderCamera=e},e.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new Ch("shared gizmo light",new V(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=Z.Gray()),this._sharedGizmoLight},Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer?e._CreateDefaultUtilityLayerFromScene(M.LastCreatedScene):e._DefaultUtilityLayer},enumerable:!1,configurable:!0}),e._CreateDefaultUtilityLayerFromScene=function(t){return e._DefaultUtilityLayer=new e(t),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null})),e._DefaultUtilityLayer},Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(M.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),e.prototype._notifyObservers=function(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new Hr(e.type,e.event,t),e.type),this._lastPointerEvents[i.pointerId]=!0)},e.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}},e.prototype.dispose=function(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()},e.prototype._updateCamera=function(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e}();!function(e){e[e.Origin=0]="Origin",e[e.Pivot=1]="Pivot"}(Rh||(Rh={})),function(e){e[e.World=0]="World",e[e.Local=1]="Local"}(Ph||(Ph={}));var Mh,Oh=function(){function e(e){void 0===e&&(e=Ih.DefaultUtilityLayer);var t=this;this.gizmoLayer=e,this._attachedMesh=null,this._attachedNode=null,this._customRotationQuaternion=null,this._scaleRatio=1,this._isHovered=!1,this._customMeshSet=!1,this._updateGizmoRotationToMatchAttachedMesh=!0,this._updateGizmoPositionToMatchAttachedMesh=!0,this._anchorPoint=Rh.Origin,this._updateScale=!0,this._coordinatesMode=Ph.Local,this._interactionsEnabled=!0,this._rightHandtoLeftHandMatrix=z.RotationY(Math.PI),this._rootMesh=new Fa("gizmoRootNode",e.utilityLayerScene),this._rootMesh.rotationQuaternion=G.Identity(),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add((function(){t._update()}))}return Object.defineProperty(e.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHovered",{get:function(){return this._isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e,e&&(this._attachedNode=e),this._rootMesh.setEnabled(!!e),this._attachedNodeChanged(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attachedNode",{get:function(){return this._attachedNode},set:function(e){this._attachedNode=e,this._attachedMesh=null,this._rootMesh.setEnabled(!!e),this._attachedNodeChanged(e)},enumerable:!1,configurable:!0}),e.prototype.setCustomMesh=function(e){if(e.getScene()!=this.gizmoLayer.utilityLayerScene)throw"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";this._rootMesh.getChildMeshes().forEach((function(e){e.dispose()})),e.parent=this._rootMesh,this._customMeshSet=!0},Object.defineProperty(e.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){this._additionalTransformNode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"updateGizmoPositionToMatchAttachedMesh",{get:function(){return this._updateGizmoPositionToMatchAttachedMesh},set:function(e){this._updateGizmoPositionToMatchAttachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(e){this._anchorPoint=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(e){this._coordinatesMode=e;var t=e==Ph.Local;this.updateGizmoRotationToMatchAttachedMesh=t,this.updateGizmoPositionToMatchAttachedMesh=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"updateScale",{get:function(){return this._updateScale},set:function(e){this._updateScale=e},enumerable:!1,configurable:!0}),e.prototype._attachedNodeChanged=function(e){},Object.defineProperty(e.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(e){this._customRotationQuaternion=e},enumerable:!1,configurable:!0}),e.prototype._update=function(){if(this.attachedNode){var t=this.attachedNode;if(this.attachedMesh&&(t=this.attachedMesh||this.attachedNode),this.updateGizmoPositionToMatchAttachedMesh)if(this.anchorPoint==Rh.Pivot&&t.getAbsolutePivotPoint){var i=t.getAbsolutePivotPoint();this._rootMesh.position.copyFrom(i)}else{var r=t.getWorldMatrix().getRow(3);i=r?r.toVector3():new V(0,0,0),this._rootMesh.position.copyFrom(i)}if(this.updateGizmoRotationToMatchAttachedMesh){var n=t._isMesh||"AbstractMesh"===t.getClassName()||"TransformNode"===t.getClassName()||"InstancedMesh"===t.getClassName()?t:void 0;t.getWorldMatrix().decompose(void 0,this._rootMesh.rotationQuaternion,void 0,e.PreserveScaling?n:void 0),this._rootMesh.rotationQuaternion.normalize()}else this._customRotationQuaternion?this._rootMesh.rotationQuaternion.copyFrom(this._customRotationQuaternion):this._rootMesh.rotationQuaternion.set(0,0,0,1);if(this.updateScale){var o=this.gizmoLayer.utilityLayerScene.activeCamera,a=o.globalPosition;this._rootMesh.position.subtractToRef(a,H.Vector3[0]);var s=this.scaleRatio;if(o.mode==$n.ORTHOGRAPHIC_CAMERA)o.orthoTop&&o.orthoBottom&&(s*=o.orthoTop-o.orthoBottom);else{var l=o.getScene().useRightHandedSystem?V.RightHandedForwardReadOnly:V.LeftHandedForwardReadOnly,c=o.getDirection(l);s*=V.Dot(H.Vector3[0],c)}this._rootMesh.scaling.setAll(s),t._getWorldMatrixDeterminant()<0&&!e.PreserveScaling&&(this._rootMesh.scaling.y*=-1)}else this._rootMesh.scaling.setAll(this.scaleRatio)}this.additionalTransformNode&&(this._rootMesh.computeWorldMatrix(!0),this._rootMesh.getWorldMatrix().multiplyToRef(this.additionalTransformNode.getWorldMatrix(),H.Matrix[0]),H.Matrix[0].decompose(this._rootMesh.scaling,this._rootMesh.rotationQuaternion,this._rootMesh.position))},e.prototype._handlePivotMatrixInverse=function(e,t,i){if(e.isUsingPivotMatrix()&&!e.isUsingPostMultiplyPivotMatrix())return e.getPivotMatrix().invertToRef(H.Matrix[5]),void H.Matrix[5].multiplyToRef(t,i);i.copyFrom(t)},e.prototype._matrixChanged=function(){if(this._attachedNode)if(this._attachedNode._isCamera){var t=this._attachedNode,i=void 0,r=void 0;if(t.parent){var n=H.Matrix[1];t.parent._worldMatrix.invertToRef(n),this._attachedNode._worldMatrix.multiplyToRef(n,H.Matrix[0]),i=H.Matrix[0]}else i=this._attachedNode._worldMatrix;if(t.getScene().useRightHandedSystem?(this._rightHandtoLeftHandMatrix.multiplyToRef(i,H.Matrix[1]),r=H.Matrix[1]):r=i,r.decompose(H.Vector3[1],H.Quaternion[0],H.Vector3[0]),"FreeCamera"===this._attachedNode.getClassName()||"FlyCamera"===this._attachedNode.getClassName()||"ArcFollowCamera"===this._attachedNode.getClassName()||"TargetCamera"===this._attachedNode.getClassName()||"TouchCamera"===this._attachedNode.getClassName()||"UniversalCamera"===this._attachedNode.getClassName()){var o=this._attachedNode;o.rotation=H.Quaternion[0].toEulerAngles(),o.rotationQuaternion&&(o.rotationQuaternion.copyFrom(H.Quaternion[0]),o.rotationQuaternion.normalize())}t.position.copyFrom(H.Vector3[0])}else if(this._attachedNode._isMesh||"AbstractMesh"===this._attachedNode.getClassName()||"TransformNode"===this._attachedNode.getClassName()||"InstancedMesh"===this._attachedNode.getClassName()){var a=this._attachedNode;if(a.parent){n=H.Matrix[0];var s=H.Matrix[1];a.parent.getWorldMatrix().invertToRef(n),this._attachedNode.getWorldMatrix().multiplyToRef(n,s);var l=H.Matrix[4];if(this._handlePivotMatrixInverse(a,s,l),l.decompose(H.Vector3[0],H.Quaternion[0],a.position,e.PreserveScaling?a:void 0,e.UseAbsoluteScaling),H.Quaternion[0].normalize(),a.isUsingPivotMatrix()){var c=H.Quaternion[1];G.RotationYawPitchRollToRef(a.rotation.y,a.rotation.x,a.rotation.z,c);var u=H.Matrix[2];z.ScalingToRef(a.scaling.x,a.scaling.y,a.scaling.z,u);var h=H.Matrix[2];c.toRotationMatrix(h);var d=a.getPivotMatrix(),p=H.Matrix[3];d.invertToRef(p),d.multiplyToRef(u,H.Matrix[4]),H.Matrix[4].multiplyToRef(h,H.Matrix[5]),H.Matrix[5].multiplyToRef(p,H.Matrix[6]),H.Matrix[6].getTranslationToRef(H.Vector3[1]),a.position.subtractInPlace(H.Vector3[1])}}else l=H.Matrix[4],this._handlePivotMatrixInverse(a,this._attachedNode._worldMatrix,l),l.decompose(H.Vector3[0],H.Quaternion[0],a.position,e.PreserveScaling?a:void 0,e.UseAbsoluteScaling);H.Vector3[0].scaleInPlace(1/a.scalingDeterminant),a.scaling.copyFrom(H.Vector3[0]),a.billboardMode||(a.rotationQuaternion?(a.rotationQuaternion.copyFrom(H.Quaternion[0]),a.rotationQuaternion.normalize()):a.rotation=H.Quaternion[0].toEulerAngles())}else if("Bone"===this._attachedNode.getClassName()){var f=this._attachedNode,_=f.getParent();if(_){var m=H.Matrix[0],g=H.Matrix[1];_.getFinalMatrix().invertToRef(m),f.getFinalMatrix().multiplyToRef(m,g),f.getLocalMatrix().copyFrom(g)}else f.getLocalMatrix().copyFrom(f.getFinalMatrix());f.markAsDirty()}else{var v=this._attachedNode;if(v.getTypeID){var y=v.getTypeID();if(y===wa.LIGHTTYPEID_DIRECTIONALLIGHT||y===wa.LIGHTTYPEID_SPOTLIGHT||y===wa.LIGHTTYPEID_POINTLIGHT){var b=v.parent;if(b){m=H.Matrix[0];var T=H.Matrix[1];b.getWorldMatrix().invertToRef(m),v.getWorldMatrix().multiplyToRef(m,T),T.decompose(void 0,H.Quaternion[0],H.Vector3[0])}else this._attachedNode._worldMatrix.decompose(void 0,H.Quaternion[0],H.Vector3[0]);v.position=new V(H.Vector3[0].x,H.Vector3[0].y,H.Vector3[0].z),v.direction&&(v.direction=new V(v.direction.x,v.direction.y,v.direction.z))}}}},e.prototype._setGizmoMeshMaterial=function(e,t){e&&e.forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))},e.GizmoAxisPointerObserver=function(e,t){var i=!1,r=e.utilityLayerScene.onPointerObservable.add((function(e){var r,n;if(e.pickInfo){if(e.type===Gr.POINTERMOVE){if(i)return;t.forEach((function(t){var i,r;if(t.colliderMeshes&&t.gizmoMeshes){var n=-1!=(null===(i=t.colliderMeshes)||void 0===i?void 0:i.indexOf(null===(r=null==e?void 0:e.pickInfo)||void 0===r?void 0:r.pickedMesh)),o=t.dragBehavior.enabled?n||t.active?t.hoverMaterial:t.material:t.disableMaterial;t.gizmoMeshes.forEach((function(e){e.material=o,e.color&&(e.color=o.diffuseColor)}))}}))}e.type===Gr.POINTERDOWN&&t.has(null===(r=e.pickInfo.pickedMesh)||void 0===r?void 0:r.parent)&&(i=!0,t.get(null===(n=e.pickInfo.pickedMesh)||void 0===n?void 0:n.parent).active=!0,t.forEach((function(t){var i,r,n=(-1!=(null===(i=t.colliderMeshes)||void 0===i?void 0:i.indexOf(null===(r=null==e?void 0:e.pickInfo)||void 0===r?void 0:r.pickedMesh))||t.active)&&t.dragBehavior.enabled?t.hoverMaterial:t.disableMaterial;t.gizmoMeshes.forEach((function(e){e.material=n,e.color&&(e.color=n.diffuseColor)}))}))),e.type===Gr.POINTERUP&&t.forEach((function(e){e.active=!1,i=!1,e.gizmoMeshes.forEach((function(t){t.material=e.dragBehavior.enabled?e.material:e.disableMaterial,t.color&&(t.color=e.material.diffuseColor)}))}))}}));return r},e.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},e.PreserveScaling=!1,e.UseAbsoluteScaling=!0,e}(),Dh=function(e){function t(i,r,n,o,a,s,l){void 0===r&&(r=Z.Gray()),void 0===n&&(n=Ih.DefaultUtilityLayer),void 0===o&&(o=null),void 0===a&&(a=1),void 0===s&&(s=Z.Yellow()),void 0===l&&(l=Z.Gray());var c,u=this;(u=e.call(this,n)||this)._pointerObserver=null,u.snapDistance=0,u.onSnapObservable=new f,u._isEnabled=!0,u._parent=null,u._dragging=!1,u._parent=o,u._coloredMaterial=new Uu("",n.utilityLayerScene),u._coloredMaterial.diffuseColor=r,u._coloredMaterial.specularColor=r.subtract(new Z(.1,.1,.1)),u._hoverMaterial=new Uu("",n.utilityLayerScene),u._hoverMaterial.diffuseColor=s,u._disableMaterial=new Uu("",n.utilityLayerScene),u._disableMaterial.diffuseColor=l,u._disableMaterial.alpha=.4;var h=t._CreateArrow(n.utilityLayerScene,u._coloredMaterial,a),d=t._CreateArrow(n.utilityLayerScene,u._coloredMaterial,a+4,!0);u._gizmoMesh=new Fa("",n.utilityLayerScene),u._gizmoMesh.addChild(h),u._gizmoMesh.addChild(d),u._gizmoMesh.lookAt(u._rootMesh.position.add(i)),u._gizmoMesh.scaling.scaleInPlace(1/3),u._gizmoMesh.parent=u._rootMesh;var p=0,_={snapDistance:0};u.dragBehavior=new gs({dragAxis:i}),u.dragBehavior.moveAttached=!1,u.dragBehavior.updateDragPlane=!1,u._rootMesh.addBehavior(u.dragBehavior),u.dragBehavior.onDragObservable.add((function(e){if(u.attachedNode){var t=!1;if(0==u.snapDistance)u.attachedNode.getWorldMatrix().getTranslationToRef(H.Vector3[2]),H.Vector3[2].addInPlace(e.delta),u.dragBehavior.validateDrag(H.Vector3[2])&&(u.attachedNode.position&&u.attachedNode.position.addInPlaceFromFloats(e.delta.x,e.delta.y,e.delta.z),u.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z),u.attachedNode.updateCache(),t=!0);else if(p+=e.dragDistance,Math.abs(p)>u.snapDistance){var i=Math.floor(Math.abs(p)/u.snapDistance);p%=u.snapDistance,e.delta.normalizeToRef(H.Vector3[1]),H.Vector3[1].scaleInPlace(u.snapDistance*i),u.attachedNode.getWorldMatrix().getTranslationToRef(H.Vector3[2]),H.Vector3[2].addInPlace(H.Vector3[1]),u.dragBehavior.validateDrag(H.Vector3[2])&&(u.attachedNode.getWorldMatrix().addTranslationFromFloats(H.Vector3[1].x,H.Vector3[1].y,H.Vector3[1].z),u.attachedNode.updateCache(),_.snapDistance=u.snapDistance*i*Math.sign(p),u.onSnapObservable.notifyObservers(_),t=!0)}t&&u._matrixChanged()}})),u.dragBehavior.onDragStartObservable.add((function(){u._dragging=!0})),u.dragBehavior.onDragEndObservable.add((function(){u._dragging=!1}));var m=n._getSharedGizmoLight();m.includedOnlyMeshes=m.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));var g={gizmoMeshes:h.getChildMeshes(),colliderMeshes:d.getChildMeshes(),material:u._coloredMaterial,hoverMaterial:u._hoverMaterial,disableMaterial:u._disableMaterial,active:!1,dragBehavior:u.dragBehavior};return null===(c=u._parent)||void 0===c||c.addToAxisCache(d,g),u._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!u._customMeshSet&&(u._isHovered=!(-1==g.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!u._parent)){var i=u.dragBehavior.enabled?u._isHovered||u._dragging?u._hoverMaterial:u._coloredMaterial:u._disableMaterial;u._setGizmoMeshMaterial(g.gizmoMeshes,i)}})),u.dragBehavior.onEnabledObservable.add((function(e){u._setGizmoMeshMaterial(g.gizmoMeshes,e?g.material:g.disableMaterial)})),u}return m(t,e),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),t._CreateArrow=function(e,t,i,r){void 0===i&&(i=1),void 0===r&&(r=!1);var n=new Fo("arrow",e),o=xh("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(i-1)/4),tessellation:96},e),a=xh("cylinder",{diameterTop:.005*i,height:.275,diameterBottom:.005*i,tessellation:96},e);return o.parent=n,o.material=t,o.rotation.x=Math.PI/2,o.position.z+=.3,a.parent=n,a.material=t,a.position.z+=.1375,a.rotation.x=Math.PI/2,r&&(a.visibility=0,o.visibility=0),n},t._CreateArrowInstance=function(e,t){for(var i=new Fo("arrow",e),r=0,n=t.getChildMeshes();r0;)f.unshift(f.pop()),m.unshift(m.pop()),h--;for(;d>0;)_.unshift(_.pop()),g.unshift(g.pop()),d--;f=f.flat(),_=_.flat(),p=p.concat(f).concat(_),i.push(m[0],m[2],m[3],m[0],m[1],m[2]),i.push(g[0],g[2],g[3],g[0],g[1],g[2])}var v=[o/2,a/2,s/2];t=p.reduce((function(e,t,i){return e.concat(t*v[i%3])}),[]);for(var y=0===e.sideOrientation?0:e.sideOrientation||_o.DEFAULTSIDE,b=e.faceUV||new Array(6),T=e.faceColors,E=[],S=0;S<6;S++)void 0===b[S]&&(b[S]=new k(0,0,1,1)),T&&void 0===T[S]&&(T[S]=new J(1,1,1,1));for(var x=0;x<6;x++)if(n.push(b[x].z,go.UseOpenGLOrientationForUV?1-b[x].w:b[x].w),n.push(b[x].x,go.UseOpenGLOrientationForUV?1-b[x].w:b[x].w),n.push(b[x].x,go.UseOpenGLOrientationForUV?1-b[x].y:b[x].y),n.push(b[x].z,go.UseOpenGLOrientationForUV?1-b[x].y:b[x].y),T)for(var A=0;A<4;A++)E.push(T[x].r,T[x].g,T[x].b,T[x].a);_o._ComputeSides(y,t,i,r,n,e.frontUVs,e.backUVs);var C=new _o;if(C.indices=i,C.positions=t,C.normals=r,C.uvs=n,T){var R=y===_o.DOUBLESIDE?E.concat(E):E;C.colors=R}return C}function Bh(e){var t=e.width||e.size||1,i=e.height||e.size||1,r=e.depth||e.size||1,n=0|(e.widthSegments||e.segments||1),o=0|(e.heightSegments||e.segments||1),a=0|(e.depthSegments||e.segments||1),s=new z,l=new z,c=new z,u=$u({width:t,height:r,subdivisionsX:n,subdivisionsY:a});z.TranslationToRef(0,-i/2,0,l),z.RotationZToRef(Math.PI,s),s.multiplyToRef(l,c),u.transform(c);var h=$u({width:t,height:r,subdivisionsX:n,subdivisionsY:a});z.TranslationToRef(0,i/2,0,c),h.transform(c);var d=$u({width:i,height:r,subdivisionsX:o,subdivisionsY:a});z.TranslationToRef(-t/2,0,0,l),z.RotationZToRef(Math.PI/2,s),s.multiplyToRef(l,c),d.transform(c);var p=$u({width:i,height:r,subdivisionsX:o,subdivisionsY:a});z.TranslationToRef(t/2,0,0,l),z.RotationZToRef(-Math.PI/2,s),s.multiplyToRef(l,c),p.transform(c);var f=$u({width:t,height:i,subdivisionsX:n,subdivisionsY:o});z.TranslationToRef(0,0,-r/2,l),z.RotationXToRef(-Math.PI/2,s),s.multiplyToRef(l,c),f.transform(c);var _=$u({width:t,height:i,subdivisionsX:n,subdivisionsY:o});return z.TranslationToRef(0,0,r/2,l),z.RotationXToRef(Math.PI/2,s),s.multiplyToRef(l,c),_.transform(c),u.merge([h,p,d,f,_],!0),u}function Uh(e,t,i){void 0===t&&(t={}),void 0===i&&(i=null);var r=new Fa(e,i);return t.sideOrientation=Fa._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,wh(t).applyToMesh(r,t.updatable),r}var Vh={CreateBox:Uh};function kh(e){for(var t=0|(e.segments||32),i=e.diameterX||e.diameter||1,r=e.diameterY||e.diameter||1,n=e.diameterZ||e.diameter||1,o=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,a=e.slice&&e.slice<=0?1:e.slice||1,s=0===e.sideOrientation?0:e.sideOrientation||_o.DEFAULTSIDE,l=!!e.dedupTopBottomIndices,c=new V(i/2,r/2,n/2),u=2+t,h=2*u,d=[],p=[],f=[],_=[],m=0;m<=u;m++){for(var g=m/u,v=g*Math.PI*a,y=0;y<=h;y++){var b=y/h,T=b*Math.PI*2*o,E=z.RotationZ(-v),S=z.RotationY(T),x=V.TransformCoordinates(V.Up(),E),A=V.TransformCoordinates(x,S),C=A.multiply(c),R=A.divide(c).normalize();p.push(C.x,C.y,C.z),f.push(R.x,R.y,R.z),_.push(b,go.UseOpenGLOrientationForUV?1-g:g)}if(m>0)for(var P=p.length/3,I=P-2*(h+1);I+h+21&&(d.push(I),d.push(I+1),d.push(I+h+1)),(mo?o:Math.floor(a);var s,l,c,u,h=0===e.sideOrientation?0:e.sideOrientation||_o.DEFAULTSIDE,d=e.uvs,p=e.colors,f=[],_=[],m=[],g=[],v=[],y=[],b=[],T=[],E=[],S=[];if(t.length<2){var x=[],A=[];for(c=0;c0&&(P=C[u].subtract(C[u-1]).length()+b[l],v[l].push(P),b[l]=P),u++;r&&(u--,f.push(C[0].x,C[0].y,C[0].z),P=C[u].subtract(C[0]).length()+b[l],v[l].push(P),b[l]=P),E[l]=R+D,S[l]=O,O+=R+D}var F,L,w=null,B=null;for(c=0;c1)?1:e.arc||1,l=0===e.sideOrientation?0:e.sideOrientation||_o.DEFAULTSIDE;t.push(0,0,0),n.push(.5,.5);for(var c=2*Math.PI*s,u=1===s?c/a:c/(a-1),h=0,d=0;d0||h>0){switch(m=-d,g=-p,v=d,y=p,n){case Fa.CENTER:m-=l/=2,v+=l;break;case Fa.LEFT:v+=l,f=-l/2;break;case Fa.RIGHT:m-=l,f=l/2}switch(o){case Fa.CENTER:g-=h/=2,y+=h;break;case Fa.BOTTOM:y+=h,_=-h/2;break;case Fa.TOP:g-=h,_=h/2}}var b=[],T=[],E=[];E[0]=[0,0,1,0,1,1,0,1],E[1]=[0,0,1,0,1,1,0,1],t!==Fa.ROTATE_TILE&&t!==Fa.ROTATE_ROW||(E[1]=[1,1,0,1,0,0,1,0]),t!==Fa.FLIP_TILE&&t!==Fa.FLIP_ROW||(E[1]=[1,0,0,0,0,1,1,1]),t!==Fa.FLIP_N_ROTATE_TILE&&t!==Fa.FLIP_N_ROTATE_ROW||(E[1]=[0,1,1,1,1,0,0,0]);for(var S=[],x=[],A=[],C=0,R=0;R0||h>0){var I=h>0&&(o===Fa.CENTER||o===Fa.TOP),M=h>0&&(o===Fa.CENTER||o===Fa.BOTTOM),O=l>0&&(n===Fa.CENTER||n===Fa.RIGHT),D=l>0&&(n===Fa.CENTER||n===Fa.LEFT),N=[],F=void 0,L=void 0,w=void 0,B=void 0;if(I&&O&&(b.push(m+f,g+_,0),b.push(-d+f,g+_,0),b.push(-d+f,g+h+_,0),b.push(m+f,g+h+_,0),A.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,N=[F=1-l/i,L=1-h/r,w=1,L,w,B=1,F,B],t===Fa.ROTATE_ROW&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),t===Fa.FLIP_ROW&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),t===Fa.FLIP_N_ROTATE_ROW&&(N=[F,1-L,w,1-L,w,1-B,F,1-B]),S=S.concat(N),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),I&&D&&(b.push(d+f,g+_,0),b.push(v+f,g+_,0),b.push(v+f,g+h+_,0),b.push(d+f,g+h+_,0),A.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,N=[F=0,L=1-h/r,w=l/i,L,w,B=1,F,B],(t===Fa.ROTATE_ROW||t===Fa.ROTATE_TILE&&s%2==0)&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),(t===Fa.FLIP_ROW||t===Fa.FLIP_TILE&&s%2==0)&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),(t===Fa.FLIP_N_ROTATE_ROW||t===Fa.FLIP_N_ROTATE_TILE&&s%2==0)&&(N=[F,1-L,w,1-L,w,1-B,F,1-B]),S=S.concat(N),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),M&&O&&(b.push(m+f,p+_,0),b.push(-d+f,p+_,0),b.push(-d+f,y+_,0),b.push(m+f,y+_,0),A.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,N=[F=1-l/i,L=0,w=1,L,w,B=h/r,F,B],(t===Fa.ROTATE_ROW&&u%2==1||t===Fa.ROTATE_TILE&&u%1==0)&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),(t===Fa.FLIP_ROW&&u%2==1||t===Fa.FLIP_TILE&&u%2==0)&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),(t===Fa.FLIP_N_ROTATE_ROW&&u%2==1||t===Fa.FLIP_N_ROTATE_TILE&&u%2==0)&&(N=[F,1-L,w,1-L,w,1-B,F,1-B]),S=S.concat(N),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),M&&D&&(b.push(d+f,p+_,0),b.push(v+f,p+_,0),b.push(v+f,y+_,0),b.push(d+f,y+_,0),A.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,N=[F=0,L=0,w=l/i,L,w,B=h/r,F,B],(t===Fa.ROTATE_ROW&&u%2==1||t===Fa.ROTATE_TILE&&(u+s)%2==1)&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),(t===Fa.FLIP_ROW&&u%2==1||t===Fa.FLIP_TILE&&(u+s)%2==1)&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),(t===Fa.FLIP_N_ROTATE_ROW&&u%2==1||t===Fa.FLIP_N_ROTATE_TILE&&(u+s)%2==1)&&(N=[F,1-L,w,1-L,w,1-B,F,1-B]),S=S.concat(N),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),I){var U=[];for(F=0,L=1-h/r,w=1,B=1,U[0]=[F,L,w,L,w,B,F,B],U[1]=[F,L,w,L,w,B,F,B],t!==Fa.ROTATE_TILE&&t!==Fa.ROTATE_ROW||(U[1]=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),t!==Fa.FLIP_TILE&&t!==Fa.FLIP_ROW||(U[1]=[1-F,L,1-w,L,1-w,B,1-F,B]),t!==Fa.FLIP_N_ROTATE_TILE&&t!==Fa.FLIP_N_ROTATE_ROW||(U[1]=[F,1-L,w,1-L,w,1-B,F,1-B]),P=0;P=0&&this.options.defines.splice(r,1),("boolean"!=typeof t||t)&&this.options.defines.push(i+t),this},t.prototype.isReadyForSubMesh=function(e,t,i){return this.isReady(e,i,t)},t.prototype.isReady=function(e,t,i){var r,n,o,a,s=i&&this._storeEffectOnSubMeshes;if(this.isFrozen){var l=s?i._drawWrapper:this._drawWrapper;if(l.effect&&l._wasPreviouslyReady&&l._wasPreviouslyUsingInstances===t)return!0}var c=this.getScene(),u=c.getEngine(),h=[],d=[],p=new ll,f=this._shaderPath,_=this._options.uniforms,m=this._options.uniformBuffers,g=this._options.samplers;u.getCaps().multiview&&c.activeCamera&&c.activeCamera.outputRenderTarget&&c.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,h.push("#define MULTIVIEW"),-1!==_.indexOf("viewProjection")&&-1===_.indexOf("viewProjectionR")&&_.push("viewProjectionR"));for(var v=0;v4&&(d.push(Nr.MatricesIndicesExtraKind),d.push(Nr.MatricesWeightsExtraKind));var b=e.skeleton;h.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),p.addCPUSkinningFallback(0,e),b.isUsingTextureForMatrices?(h.push("#define BONETEXTURE"),-1===_.indexOf("boneTextureWidth")&&_.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(h.push("#define BonesPerMesh "+(b.bones.length+1)),-1===_.indexOf("mBones")&&_.push("mBones"))}else h.push("#define NUM_BONE_INFLUENCERS 0");var T=0,E=e?e.morphTargetManager:null;if(E){var S=E.supportsUVs&&-1!==h.indexOf("#define UV1"),x=E.supportsTangents&&-1!==h.indexOf("#define TANGENT"),A=E.supportsNormals&&-1!==h.indexOf("#define NORMAL");for(T=E.numMaxInfluencers||E.numInfluencers,S&&h.push("#define MORPHTARGETS_UV"),x&&h.push("#define MORPHTARGETS_TANGENT"),A&&h.push("#define MORPHTARGETS_NORMAL"),T>0&&h.push("#define MORPHTARGETS"),E.isUsingTextureForTargets&&(h.push("#define MORPHTARGETS_TEXTURE"),-1===_.indexOf("morphTargetTextureIndices")&&_.push("morphTargetTextureIndices"),-1===this._options.samplers.indexOf("morphTargets")&&this._options.samplers.push("morphTargets")),h.push("#define NUM_MORPH_INFLUENCERS "+T),v=0;v0&&((_=_.slice()).push("morphTargetInfluences"),_.push("morphTargetCount"),_.push("morphTargetTextureInfo"),_.push("morphTargetTextureIndices"))}else h.push("#define NUM_MORPH_INFLUENCERS 0");if(e){var C=e.bakedVertexAnimationManager;C&&C.isEnabled&&(h.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),-1===_.indexOf("bakedVertexAnimationSettings")&&_.push("bakedVertexAnimationSettings"),-1===_.indexOf("bakedVertexAnimationTextureSizeInverted")&&_.push("bakedVertexAnimationTextureSizeInverted"),-1===_.indexOf("bakedVertexAnimationTime")&&_.push("bakedVertexAnimationTime"),-1===this._options.samplers.indexOf("bakedVertexAnimationTexture")&&this._options.samplers.push("bakedVertexAnimationTexture")),ra(d,0,h)}for(var R in this._textures)if(!this._textures[R].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&h.push("#define ALPHATEST"),!1!==this._options.useClipPlane&&(Go(_),zo(this,c,h)),c.fogEnabled&&(null==e?void 0:e.applyFog)&&c.fogMode!==pn.FOGMODE_NONE&&(h.push("#define FOG"),-1===_.indexOf("view")&&_.push("view"),-1===_.indexOf("vFogInfos")&&_.push("vFogInfos"),-1===_.indexOf("vFogColor")&&_.push("vFogColor")),this._useLogarithmicDepth&&(h.push("#define LOGARITHMICDEPTH"),-1===_.indexOf("logarithmicDepthConstant")&&_.push("logarithmicDepthConstant")),this.customShaderNameResolve&&(_=_.slice(),m=m.slice(),g=g.slice(),f=this.customShaderNameResolve(this.name,_,m,g,h,d));var P=s?i._getDrawWrapper(void 0,!0):this._drawWrapper,I=null!==(r=null==P?void 0:P.effect)&&void 0!==r?r:null,M=null!==(n=null==P?void 0:P.defines)&&void 0!==n?n:null,O=h.join("\n"),D=I;return M!==O&&(D=u.createEffect(f,{attributes:d,uniformsNames:_,uniformBuffersNames:m,samplers:g,defines:O,fallbacks:p,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:T},shaderLanguage:this._options.shaderLanguage},u),s?i.setEffect(D,O,this._materialContext):P&&P.setEffect(D,O),this._onEffectCreatedObservable&&(sd.effect=D,sd.subMesh=null!==(o=null!=i?i:null==e?void 0:e.subMeshes[0])&&void 0!==o?o:null,this._onEffectCreatedObservable.notifyObservers(sd))),P._wasPreviouslyUsingInstances=!!t,null!==(a=!(null==D?void 0:D.isReady()))&&void 0!==a&&!a&&(I!==D&&c.resetCachedMaterial(),P._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e,t){var i=this.getScene(),r=null!=t?t:this.getEffect();r&&(-1!==this._options.uniforms.indexOf("world")&&r.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(i.getViewMatrix(),this._cachedWorldViewMatrix),r.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(i.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),r.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),-1!==this._options.uniforms.indexOf("view")&&r.setMatrix("view",i.getViewMatrix()))},t.prototype.bindForSubMesh=function(e,t,i){var r;this.bind(e,t,null===(r=i._drawWrapperOverride)||void 0===r?void 0:r.effect,i)},t.prototype.bind=function(e,t,i,r){var n,o=r&&this._storeEffectOnSubMeshes,a=null!=i?i:o?r.effect:this.getEffect();if(a){var s=this.getScene();this._activeEffect=a,this.bindOnlyWorldMatrix(e,i);var l=this._options.uniformBuffers,c=!1;if(a&&l&&l.length>0&&s.getEngine().supportsUniformBuffers)for(var u=0;u0&&$o(t,a);var b=t.bakedVertexAnimationManager;if(b&&b.isEnabled){var T=o?r._drawWrapper:this._drawWrapper;null===(n=t.bakedVertexAnimationManager)||void 0===n||n.bind(a,!!T._wasPreviouslyUsingInstances)}}this._afterBind(t,a,r)}},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var i in this._textures)t.push(this._textures[i]);for(var r in this._textureArrays)for(var n=this._textureArrays[r],o=0;o\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n#include(color,gl_FragColor)\n#define CUSTOM_FRAGMENT_MAIN_END\n}";li.ShadersStore.colorVertexShader="attribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n#include\n#include\n#ifdef FOG\nuniform mat4 view;\n#endif\n#include\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#include\n#include\n#include\n#define CUSTOM_VERTEX_MAIN_END\n}",Fa._LinesMeshParser=function(e,t){return cd.Parse(e,t)};var cd=function(e){function t(t,i,r,n,o,a,s,l){void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null);var c=e.call(this,t,i,r,n,o)||this;c.useVertexColor=a,c.useVertexAlpha=s,c.color=new Z(1,1,1),c.alpha=1,n&&(c.color=n.color.clone(),c.alpha=n.alpha,c.useVertexColor=n.useVertexColor,c.useVertexAlpha=n.useVertexAlpha),c.intersectionThreshold=.1;var u={attributes:[Nr.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:[],useClipPlane:null};return!1===s?u.needAlphaBlending=!1:u.defines.push("#define VERTEXALPHA"),a?(u.defines.push("#define VERTEXCOLOR"),u.attributes.push(Nr.ColorKind)):(u.uniforms.push("color"),c._color4=new J),l?c.material=l:(c.material=new ld("colorShader",c.getScene(),"color",u,!1),c.material.doNotSerialize=!0),c}return m(t,e),t.prototype._isShaderMaterial=function(e){return"ShaderMaterial"===e.getClassName()},t.prototype.isReady=function(){return!!this._lineMaterial.isReady(this,!!this._userInstancedBuffersStorage||this.hasThinInstances)&&e.prototype.isReady.call(this)},t.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(t.prototype,"material",{get:function(){return this._lineMaterial},set:function(e){this._lineMaterial=e,this._lineMaterial.fillMode=Ca.LineListDrawMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),t.prototype._bind=function(e,t){if(!this._geometry)return this;var i=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(t,i):this._geometry._bind(t,i,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),!this.useVertexColor&&this._isShaderMaterial(this._lineMaterial)){var r=this.color,n=r.r,o=r.g,a=r.b;this._color4.set(n,o,a,this.alpha),this._lineMaterial.setColor4("color",this._color4)}return this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var r=this.getScene().getEngine();return this._unIndexed?r.drawArraysType(Ca.LineListDrawMode,e.verticesStart,e.verticesCount,i):r.drawElementsType(Ca.LineListDrawMode,e.indexStart,e.indexCount,i),this},t.prototype.dispose=function(t,i,r){void 0===i&&(i=!1),r||this._lineMaterial.dispose(!1,!1,!0),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e,i,r){return void 0===i&&(i=null),new t(e,this.getScene(),i,this,r)},t.prototype.createInstance=function(e){var t=new ud(e,this);if(this.instancedBuffers)for(var i in t.instancedBuffers={},this.instancedBuffers)t.instancedBuffers[i]=this.instancedBuffers[i];return t},t.prototype.serialize=function(t){e.prototype.serialize.call(this,t),t.color=this.color.asArray(),t.alpha=this.alpha},t.Parse=function(e,i){var r=new t(e.name,i);return r.color=Z.FromArray(e.color),r.alpha=e.alpha,r},t}(Fa),ud=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.intersectionThreshold=i.intersectionThreshold,r}return m(t,e),t.prototype.getClassName=function(){return"InstancedLinesMesh"},t}(La);function hd(e){for(var t=[],i=[],r=e.lines,n=e.colors,o=[],a=0,s=0;s0&&(t.push(a-1),t.push(a)),a++}var y=new _o;return y.indices=t,y.positions=i,n&&(y.colors=o),y}function dd(e){var t,i,r=e.dashSize||3,n=e.gapSize||1,o=e.dashNb||200,a=e.points,s=[],l=[],c=V.Zero(),u=0,h=0,d=0,p=0,f=0;for(f=0;ft.x&&(t.x=i.x),i.yt.y&&(t.y=i.y)})),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),yd=function(){function e(){}return e.Rectangle=function(e,t,i,r){return[new U(e,t),new U(i,t),new U(i,r),new U(e,r)]},e.Circle=function(e,t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=32);for(var n=[],o=0,a=2*Math.PI/r,s=0;s0){var h=o.length/3;this._points.elements.forEach((function(t){n.push(0,-1,0),o.push(t.x,-e,t.y),a.push(1-(t.x-s.min.x)/s.width,1-(t.y-s.min.y)/s.height)}));var d=l.length;for(u=0;ul?El?S0){var m=h[_-1];V.Dot(m,h[_])<0&&h[_].scaleInPlace(-1),m=d[_-1],V.Dot(m,d[_])<0&&d[_].scaleInPlace(-1),m=p[_-1],V.Dot(m,p[_])<0&&p[_].scaleInPlace(-1)}var g=0,v=c&&s?s:function(){return null!==o?o:0},y=c&&a?a:function(){return null!==n?n:1},b=l===Fa.NO_CAP||l===Fa.CAP_END?0:2,T=H.Matrix[0];for(_=0;_3?0:c;var x=Yh(e,{pathArray:T=E(t,i,b=v?new An(i,v):new An(i),new Array,r,n,o,a,c,u,y),closeArray:s,closePath:l,updatable:d,sideOrientation:p,invertUV:_,frontUVs:m||void 0,backUVs:g||void 0},h);return x._creationDataStorage.pathArray=T,x._creationDataStorage.path3D=b,x._creationDataStorage.cap=c,x}_o.CreatePolygon=Td,Fa.CreatePolygon=function(e,t,i,r,n,o,a){return void 0===a&&(a=earcut),Ed(e,{shape:t,holes:r,updatable:n,sideOrientation:o},i,a)},Fa.ExtrudePolygon=function(e,t,i,r,n,o,a,s){return void 0===s&&(s=earcut),Sd(e,{shape:t,holes:n,depth:i,updatable:o,sideOrientation:a},r,s)};var Pd={ExtrudeShape:Ad,ExtrudeShapeCustom:Cd};function Id(e,t,i){void 0===i&&(i=null);var r,n,o=t.arc?t.arc<=0||t.arc>1?1:t.arc:1,a=void 0===t.closed||t.closed,s=t.shape,l=t.radius||1,c=t.tessellation||64,u=t.clip||0,h=t.updatable,d=Fa._GetDefaultSideOrientation(t.sideOrientation),p=t.cap||Fa.NO_CAP,f=2*Math.PI,_=[],m=t.invertUV||!1,g=0,v=0,y=f/c*o;for(g=0;g<=c-u;g++){for(n=[],p!=Fa.CAP_START&&p!=Fa.CAP_ALL||(n.push(new V(0,s[0].y,0)),n.push(new V(Math.cos(g*y)*s[0].x*l,s[0].y,Math.sin(g*y)*s[0].x*l))),v=0;v1)?1:t.arc||1;var d,p,f=function(e,t,i,r,n,o,a,s){for(var l,c,u,h,d=t.getTangents(),p=t.getNormals(),f=t.getDistances(),_=2*Math.PI/n*s,m=o||function(){return r},g=H.Matrix[0],v=a===Fa.NO_CAP||a===Fa.CAP_END?0:2,y=0;y3?0:l;var g=Yh(e,{pathArray:p=f(r,d=new An(r),new Array,o,a,s,l,t.arc),closePath:!0,closeArray:!1,updatable:u,sideOrientation:h,invertUV:c,frontUVs:t.frontUVs,backUVs:t.backUVs},i);return g._creationDataStorage.pathArray=p,g._creationDataStorage.path3D=d,g._creationDataStorage.tessellation=a,g._creationDataStorage.cap=l,g._creationDataStorage.arc=t.arc,g._creationDataStorage.radius=o,g}Fa.CreateLathe=function(e,t,i,r,n,o,a){return Id(e,{shape:t,radius:i,tessellation:r,sideOrientation:a,updatable:o},n)};var Dd={CreateTube:Od};function Nd(e){var t=[];t[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},t[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},t[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},t[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},t[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},t[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},t[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},t[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},t[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},t[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},t[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},t[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},t[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},t[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},t[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var i,r,n,o,a,s,l=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,c=e.size,u=e.sizeX||c||1,h=e.sizeY||c||1,d=e.sizeZ||c||1,p=e.custom||t[l],f=p.face.length,_=e.faceUV||new Array(f),m=e.faceColors,g=void 0===e.flat||e.flat,v=0===e.sideOrientation?0:e.sideOrientation||_o.DEFAULTSIDE,y=[],b=[],T=[],E=[],S=[],x=0,A=0,C=[],R=0,P=0;if(g)for(P=0;P0){var B=r(D,I[P+w],O,4);C[L]=I[P+w],R[L]=j.Lerp(M[P+w],B>=0?F[B]:0,A),L++}for(w=0;w<4&&L<4;++w){var k=D[O+w];-1===r(I,k,P,4)&&(C[L]=k,R[L]=j.Lerp(0,F[O+w],A),L++)}var G=R[0]+R[1]+R[2]+R[3];R[0]/=G,R[1]/=G,R[2]/=G,R[3]/=G}var z=e.localPositionOverride?e.localPositionOverride[0]:null!==(c=null==p?void 0:p[e.vertexIdx])&&void 0!==c?c:0,W=e.localPositionOverride?e.localPositionOverride[1]:null!==(u=null==p?void 0:p[e.vertexIdx+1])&&void 0!==u?u:0,H=e.localPositionOverride?e.localPositionOverride[2]:null!==(h=null==p?void 0:p[e.vertexIdx+2])&&void 0!==h?h:0,X=n.localPositionOverride?n.localPositionOverride[0]:null!==(d=null==p?void 0:p[n.vertexIdx])&&void 0!==d?d:0,Y=n.localPositionOverride?n.localPositionOverride[1]:null!==(_=null==p?void 0:p[n.vertexIdx+1])&&void 0!==_?_:0,K=n.localPositionOverride?n.localPositionOverride[2]:null!==(v=null==p?void 0:p[n.vertexIdx+2])&&void 0!==v?v:0,Q=e.localNormalOverride?e.localNormalOverride[0]:null!==(y=null==f?void 0:f[e.vertexIdx])&&void 0!==y?y:0,q=e.localNormalOverride?e.localNormalOverride[1]:null!==(b=null==f?void 0:f[e.vertexIdx+1])&&void 0!==b?b:0,Z=e.localNormalOverride?e.localNormalOverride[2]:null!==(T=null==f?void 0:f[e.vertexIdx+2])&&void 0!==T?T:0,J=Q+((n.localNormalOverride?n.localNormalOverride[0]:null!==(E=null==f?void 0:f[n.vertexIdx])&&void 0!==E?E:0)-Q)*A,$=q+((n.localNormalOverride?n.localNormalOverride[1]:null!==(S=null==f?void 0:f[n.vertexIdx+1])&&void 0!==S?S:0)-q)*A,ee=Z+((n.localNormalOverride?n.localNormalOverride[2]:null!==(x=null==f?void 0:f[n.vertexIdx+2])&&void 0!==x?x:0)-Z)*A,te=Math.sqrt(J*J+$*$+ee*ee);return new zd(V.Lerp(e.position,n.position,A),V.Lerp(e.normal,n.normal,A).normalize(),U.Lerp(e.uv,n.uv,A),-1,-1,p?[z+(X-z)*A,W+(Y-W)*A,H+(K-H)*A]:null,f?[J/te,$/te,ee/te]:null,C,R)},o=null;e.length>3&&(o=[]);for(var a=0;a0,d=V.Dot(e[a+1].position,t)-i>0,_=V.Dot(e[a+2].position,t)-i>0;switch((h?1:0)+(d?1:0)+(_?1:0)){case 0:e.length>3?(o.push(e[a]),o.push(e[a+1]),o.push(e[a+2])):o=e;break;case 1:if(o=null!=o?o:new Array,h&&(s=e[a+1],l=e[a+2],c=n(e[a],s),u=n(e[a],l)),d){s=e[a],l=e[a+2],c=n(e[a+1],s),u=n(e[a+1],l),o.push(c),o.push(l.clone()),o.push(s.clone()),o.push(l.clone()),o.push(c.clone()),o.push(u);break}_&&(s=e[a],l=e[a+1],c=n(e[a+2],s),u=n(e[a+2],l)),s&&l&&c&&u&&(o.push(s.clone()),o.push(l.clone()),o.push(c),o.push(u),o.push(c.clone()),o.push(l.clone()));break;case 2:o=null!=o?o:new Array,h||(l=n(s=e[a].clone(),e[a+1]),c=n(s,e[a+2]),o.push(s),o.push(l),o.push(c)),d||(l=n(s=e[a+1].clone(),e[a+2]),c=n(s,e[a]),o.push(s),o.push(l),o.push(c)),_||(l=n(s=e[a+2].clone(),e[a]),c=n(s,e[a+1]),o.push(s),o.push(l),o.push(c))}}return o},L=t instanceof Fa?t:null,w=null==L?void 0:L._thinInstanceDataStorage.matrixData,B=(null==L?void 0:L.thinInstanceCount)||1,k=H.Matrix[0];k.copyFrom(z.IdentityReadOnly);for(var G=0;G2?E[l[d]]=[-S[i][0],S[i][1],l[d]]:E[l[d]]=[T[S[i][0]],S[i][1],l[d]]};this.IDATA.edgematch=[[1,"B"],[2,"B"],[3,"B"],[4,"B"],[0,"B"],[10,"O",14,"A"],[11,"O",10,"A"],[12,"O",11,"A"],[13,"O",12,"A"],[14,"O",13,"A"],[0,"O"],[1,"O"],[2,"O"],[3,"O"],[4,"O"],[19,"B",5,"A"],[15,"B",6,"A"],[16,"B",7,"A"],[17,"B",8,"A"],[18,"B",9,"A"]];for(var A=0;A<20;A++){if(n=(T=this.IDATA.face[A])[2],o=T[1],a=T[0],f=_.x+"|"+_.y,(d=A+"|"+f)in l||(l[d]=n,E[n]=[T[S[f][0]],S[f][1]]),f=m.x+"|"+m.y,(d=A+"|"+f)in l||(l[d]=o,E[o]=[T[S[f][0]],S[f][1]]),f=g.x+"|"+g.y,(d=A+"|"+f)in l||(l[d]=a,E[a]=[T[S[f][0]],S[f][1]]),i=this.IDATA.edgematch[A][0],"B"===(r=this.IDATA.edgematch[A][1]))for(var C=1;C2?E[l[d]]=[-S[f][0],S[f][1],l[d]]:E[l[d]]=[T[S[f][0]],S[f][1],l[d]])}this.closestTo=E,this.vecToidx=l},e.prototype.calcCoeffs=function(){var e=this.m,t=this.n,i=Math.sqrt(3)/3,r=e*e+t*t+e*t;this.coau=(e+t)/r,this.cobu=-t/r,this.coav=-i*(e-t)/r,this.cobv=i*(2*e+t)/r},e.prototype.createInnerFacets=function(){for(var e=this.m,t=this.n,i=0;i0&&r0){for(var l=j.HCF(e,t),c=e/l,u=t/l,h=1;h-1?r[i][1]>0&&t[r[i][0]].push([i,r[i][1]]):t[12].push([i,r[i][0]]);var n=[];for(i=0;i<12;i++)n[i]=i;var o=12;for(i=0;i<12;i++){t[i].sort((function(e,t){return e[1]-t[1]}));for(var a=0;a0;)n=t[s],this.face[n].indexOf(a)>-1?(o=(this.face[n].indexOf(a)+1)%3,a=this.face[n][o],i.push(a),r.push(n),t.splice(s,1),s=0):s++;return this.adjacentFaces.push(i),r},t.prototype.toGoldbergPolyhedronData=function(){var e=this,t=new Yd("GeoDual","Goldberg",[],[]);t.name="GD dual";for(var i=this.vertex.length,r=new Array(i),n=0;nr){var o=n;n=r,r=o,ae.Warn("n > m therefore m and n swapped")}var a=new jd;return a.build(r,n),Fd(e,{custom:Kd.BuildGeodesicData(a),size:t.size,sizeX:t.sizeX,sizeY:t.sizeY,sizeZ:t.sizeZ,faceUV:t.faceUV,faceColors:t.faceColors,flat:t.flat,updatable:t.updatable,sideOrientation:t.sideOrientation,frontUVs:t.frontUVs,backUVs:t.backUVs},i)}Fa._GoldbergMeshParser=function(e,t){return qd.Parse(e,t)};var qd=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.goldbergData={faceColors:[],faceCenters:[],faceZaxis:[],faceXaxis:[],faceYaxis:[],nbSharedFaces:0,nbUnsharedFaces:0,nbFaces:0,nbFacesAtPole:0,adjacentFaces:[]},t}return m(t,e),t.prototype.relatedGoldbergFace=function(e,t){return void 0===t?(e>this.goldbergData.nbUnsharedFaces-1&&(ae.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(ae.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&(ae.Warn("Maximum number of faces at a pole used"),t=this.goldbergData.nbFacesAtPole-1),12+e*this.goldbergData.nbFacesAtPole+t)},t.prototype._changeGoldbergFaceColors=function(e){for(var t=0;t1&&(u=1),l.push(u,h);for(d=0;d<6;d++)u=o.x+a*Math.cos(s+d*Math.PI/3),h=o.y+a*Math.sin(s+d*Math.PI/3),u<0&&(u=0),u>1&&(u=1),c.push(u,h);for(var p=r;ps){var c=l;l=s,s=c,ae.Warn("n > m therefore m and n swapped")}var u=new jd;u.build(s,l);var h=Kd.BuildGeodesicData(u),d=h.toGoldbergPolyhedronData(),p=new qd(e,i);t.sideOrientation=Fa._GetDefaultSideOrientation(t.sideOrientation),p._originalBuilderSideOrientation=t.sideOrientation,Zd(t,d).applyToMesh(p,t.updatable),p.goldbergData.nbSharedFaces=h.sharedNodes,p.goldbergData.nbUnsharedFaces=h.poleNodes,p.goldbergData.adjacentFaces=h.adjacentFaces,p.goldbergData.nbFaces=p.goldbergData.nbSharedFaces+p.goldbergData.nbUnsharedFaces,p.goldbergData.nbFacesAtPole=(p.goldbergData.nbUnsharedFaces-12)/12;for(var f=0;f0?this._holes.push(i):this._paths.push(i)}if(!this._paths.length&&this._holes.length){var r=this._holes;this._holes=this._paths,this._paths=r}this._tempPaths.length=0},Object.defineProperty(e.prototype,"paths",{get:function(){return this._paths},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"holes",{get:function(){return this._holes},enumerable:!1,configurable:!0}),e}();function ep(e,t,i,r,n,o){var a=o.glyphs[e]||o.glyphs["?"];if(!a)return null;var s=new $d(n);if(a.o)for(var l=a.o.split(" "),c=0,u=l.length;cA&&(e.x=1*Math.sign(e.x)),Math.abs(e.y-1)>A&&(e.y=1*Math.sign(e.y)),Math.abs(e.z-1)>A&&(e.z=1*Math.sign(e.z))},e.prototype._updateDebugConstraint=function(e,t){var i=this;if(e._initOptions){var r=e._initOptions,n=r.pivotA,o=r.pivotB,a=r.axisA,s=r.axisB,l=r.perpAxisA,c=r.perpAxisB;n&&o&&a&&s&&l&&c&&t.getDescendants(!0).forEach((function(e){var t=e.getDescendants(!0)[0],r=e.getDescendants(!0)[1],u=t.metadata,h=u.parentBody,d=u.parentBodyIndex,p=r.metadata,f=p.childBody,_=p.childBodyIndex,m=i._getTransformFromBodyToRef(h,H.Matrix[0],d),g=i._getTransformFromBodyToRef(f,H.Matrix[1],_);m.decomposeToTransformNode(t),i._makeScalingUnitInPlace(t.scaling),g.decomposeToTransformNode(r),i._makeScalingUnitInPlace(r.scaling);var v=t.getDescendants(!0)[0];v.position.copyFrom(n);var y=r.getDescendants(!0)[0];y.position.copyFrom(o),G.FromRotationMatrixToRef(z.FromXYZAxesToRef(a,l,V.CrossToRef(a,l,H.Vector3[0]),H.Matrix[0]),v.rotationQuaternion),G.FromRotationMatrixToRef(z.FromXYZAxesToRef(s,c,V.CrossToRef(s,c,H.Vector3[1]),H.Matrix[1]),y.rotationQuaternion)}))}},e.prototype.showImpostor=function(e,t){var i=this;if(!this._scene)return null;for(var r=0;r-1&&this._debugMeshMeshes.splice(o,1),this._numMeshes--,this._numMeshes>0?(this._meshes[r]=this._meshes[this._numMeshes],this._impostors[r]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)}},e.prototype.hideBody=function(e){if(e&&this._scene&&this._utilityLayer){for(var t=!1,i=this._utilityLayer.utilityLayerScene,r=0;r0?(this._bodyMeshes[r]=this._bodyMeshes[this._numBodies],this._bodies[r]=this._bodies[this._numBodies],this._bodyMeshes[this._numBodies]=null,this._bodies[this._numBodies]=null):(this._bodyMeshes[0]=null,this._bodies[0]=null),t=!0;break}t&&0===this._numBodies&&this._scene.unregisterBeforeRender(this._renderFunction)}},e.prototype.hideInertia=function(e){if(e&&this._scene&&this._utilityLayer){for(var t=!1,i=this._utilityLayer.utilityLayerScene,r=0;r0?(this._constraints[r]=this._constraints[this._numConstraints],this._constraintMeshes[r]=this._constraintMeshes[this._numConstraints],this._constraints[this._numConstraints]=null,this._constraintMeshes[this._numConstraints]=null):(this._constraints[0]=null,this._constraintMeshes[0]=null),t=!0;break}t&&0===this._numConstraints&&this._scene.unregisterBeforeRender(this._constraintRenderFunction)}},e.prototype._getDebugMaterial=function(e){return this._debugMaterial||(this._debugMaterial=new Uu("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=Z.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugInertiaMaterial=function(e){return this._debugInertiaMaterial||(this._debugInertiaMaterial=new Uu("",e),this._debugInertiaMaterial.disableLighting=!0,this._debugInertiaMaterial.alpha=0),this._debugInertiaMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=Uh("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=G.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(e),this._debugBoxMesh.setEnabled(!1)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugSphereMesh=function(e){return this._debugSphereMesh||(this._debugSphereMesh=Gh("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=G.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodySphereViewInstance")},e.prototype._getDebugCapsuleMesh=function(e){return this._debugCapsuleMesh||(this._debugCapsuleMesh=Hh("physicsBodyCapsuleViewMesh",{height:1},e),this._debugCapsuleMesh.rotationQuaternion=G.Identity(),this._debugCapsuleMesh.material=this._getDebugMaterial(e),this._debugCapsuleMesh.setEnabled(!1)),this._debugCapsuleMesh.createInstance("physicsBodyCapsuleViewInstance")},e.prototype._getDebugCylinderMesh=function(e){return this._debugCylinderMesh||(this._debugCylinderMesh=xh("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=G.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyCylinderViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var i=new Fa(e.name,t,null,e);return i.setParent(e),i.position=V.Zero(),i.material=this._getDebugMaterial(t),this._debugMeshMeshes.push(i),i},e.prototype._getDebugMesh=function(e,t){var i=this;if(!this._utilityLayer)return null;if(t&&t.parent&&t.parent.physicsImpostor)return null;var r=null,n=this._utilityLayer.utilityLayerScene;if(!e.physicsBody)return ae.Warn("Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor."),null;switch(e.type){case Ds.BoxImpostor:r=this._getDebugBoxMesh(n),e.getBoxSizeToRef(r.scaling);break;case Ds.SphereImpostor:r=this._getDebugSphereMesh(n);var o=e.getRadius();r.scaling.x=2*o,r.scaling.y=2*o,r.scaling.z=2*o;break;case Ds.CapsuleImpostor:r=this._getDebugCapsuleMesh(n);var a=e.object.getBoundingInfo();r.scaling.x=2*(a.boundingBox.maximum.x-a.boundingBox.minimum.x)*e.object.scaling.x,r.scaling.y=(a.boundingBox.maximum.y-a.boundingBox.minimum.y)*e.object.scaling.y,r.scaling.z=2*(a.boundingBox.maximum.z-a.boundingBox.minimum.z)*e.object.scaling.z;break;case Ds.MeshImpostor:t&&(r=this._getDebugMeshMesh(t,n));break;case Ds.NoImpostor:t?t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){if(e.physicsImpostor&&"Mesh"===e.getClassName()){var t=e.getBoundingInfo(),o=t.boundingBox.minimum,a=t.boundingBox.maximum;switch(e.physicsImpostor.type){case Ds.BoxImpostor:(r=i._getDebugBoxMesh(n)).position.copyFrom(o),r.position.addInPlace(a),r.position.scaleInPlace(.5);break;case Ds.SphereImpostor:r=i._getDebugSphereMesh(n);break;case Ds.CylinderImpostor:r=i._getDebugCylinderMesh(n);break;default:r=null}r&&(r.scaling.x=a.x-o.x,r.scaling.y=a.y-o.y,r.scaling.z=a.z-o.z,r.parent=e)}})):ae.Warn("No target mesh parameter provided for NoImpostor. Skipping."),r=null;break;case Ds.CylinderImpostor:r=this._getDebugCylinderMesh(n),a=e.object.getBoundingInfo(),r.scaling.x=(a.boundingBox.maximum.x-a.boundingBox.minimum.x)*e.object.scaling.x,r.scaling.y=(a.boundingBox.maximum.y-a.boundingBox.minimum.y)*e.object.scaling.y,r.scaling.z=(a.boundingBox.maximum.z-a.boundingBox.minimum.z)*e.object.scaling.z}return r},e.prototype._getDebugBodyMesh=function(e){if(!this._utilityLayer)return null;var t=this._utilityLayer.utilityLayerScene,i=new Fa("custom",t),r=new _o,n=e.getGeometry();if(r.positions=n.positions,r.indices=n.indices,r.applyToMesh(i),e._pluginDataInstances){var o=new Float32Array(16*e._pluginDataInstances.length);i.thinInstanceSetBuffer("matrix",o,16,!1)}return i.material=this._getDebugMaterial(t),i},e.prototype._getMeshDebugInertiaMatrixToRef=function(e,t){var i,r,n,o=null!==(i=e.inertiaOrientation)&&void 0!==i?i:G.Identity(),a=null!==(r=e.inertia)&&void 0!==r?r:V.Zero(),s=null!==(n=e.centerOfMass)&&void 0!==n?n:V.Zero(),l=6*(a.x-a.y+a.z),c=Math.sqrt(Math.max(l,0)),u=12*a.x-l,h=Math.sqrt(Math.max(u,0)),d=12*a.z-l,p=Math.sqrt(Math.max(d,0)),f=H.Vector3[0];f.set(p,c,h);var _=z.ScalingToRef(f.x,f.y,f.z,H.Matrix[0]),m=o.toRotationMatrix(H.Matrix[1]),g=z.TranslationToRef(s.x,s.y,s.z,H.Matrix[2]);return _.multiplyToRef(m,t),t.multiplyToRef(g,t),t},e.prototype._getDebugInertiaMesh=function(e){if(!this._utilityLayer)return null;var t=this._utilityLayer.utilityLayerScene,i=rp.CreateBox("custom",{size:1},t),r=z.Identity();if(e._pluginDataInstances.length){for(var n=new Float32Array(16*e._pluginDataInstances.length),o=0;o=0?z.FromArrayToRef(r._thinInstanceDataStorage.matrixData,i,t):t.copyFrom(r.getWorldMatrix())},e.prototype._getDebugConstraintMesh=function(e){if(!this._utilityLayer)return null;var t=this._utilityLayer.utilityLayerScene;if(!e._initOptions)return null;var i=e._initOptions,r=i.pivotA,n=i.pivotB,o=i.axisA,a=i.axisB,s=i.perpAxisA,l=i.perpAxisB;if(!(r&&n&&o&&a&&s&&l))return null;for(var c=new Fa("parentingDebugConstraint",t),u=0,h=e.getBodiesUsingConstraint();u=0;e--)this.hideImpostor(this._impostors[0]);for(e=this._numBodies-1;e>=0;e--)this.hideBody(this._bodies[0]);for(e=this._numInertiaBodies-1;e>=0;e--)this.hideInertia(this._inertiaBodies[0]);this._debugBoxMesh&&this._debugBoxMesh.dispose(),this._debugSphereMesh&&this._debugSphereMesh.dispose(),this._debugCylinderMesh&&this._debugCylinderMesh.dispose(),this._debugMaterial&&this._debugMaterial.dispose(),this._impostors.length=0,this._scene=null,this._physicsEnginePlugin=null,this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null)},e}(),op=function(){function e(e){this.ray=e}return e.CreateAndShow=function(t,i,r){var n=new e(t);return n.show(i,r),n},e.prototype.show=function(e,t){var i=this;if(!this._renderFunction&&this.ray){var r=this.ray;this._renderFunction=function(){return i._render()},this._scene=e,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=fd("ray",{points:this._renderPoints,updatable:!0},e),this._renderLine.isPickable=!1,this._renderFunction&&this._scene.registerBeforeRender(this._renderFunction)}t&&this._renderLine&&this._renderLine.color.copyFrom(t)},e.prototype.hide=function(){this._renderFunction&&this._scene&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine&&(this._renderLine.dispose(),this._renderLine=null),this._renderPoints=[])},e.prototype._render=function(){var e,t=this.ray;if(t){var i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),this._renderPoints[0].copyFrom(t.origin),fd("ray",{points:this._renderPoints,updatable:!0,instance:this._renderLine},this._scene),null===(e=this._renderLine)||void 0===e||e.refreshBoundingInfo()}},e.prototype.attachToMesh=function(e,t,i,r){var n=this;this._attachedToMesh=e;var o=this.ray;o&&(o.direction||(o.direction=V.Zero()),o.origin||(o.origin=V.Zero()),r&&(o.length=r),i||(i=V.Zero()),t||(t=new V(0,0,-1)),this._scene||(this._scene=e.getScene()),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(t),this._meshSpaceOrigin.copyFrom(i)):(this._meshSpaceDirection=t.clone(),this._meshSpaceOrigin=i.clone()),this._onAfterRenderObserver||(this._onAfterRenderObserver=this._scene.onBeforeRenderObservable.add((function(){return n._updateToMesh()})),this._onAfterStepObserver=this._scene.onAfterStepObservable.add((function(){return n._updateToMesh()}))),this._attachedToMesh.computeWorldMatrix(!0),this._updateToMesh())},e.prototype.detachFromMesh=function(){this._attachedToMesh&&this._scene&&(this._onAfterRenderObserver&&(this._scene.onBeforeRenderObservable.remove(this._onAfterRenderObserver),this._scene.onAfterStepObservable.remove(this._onAfterStepObserver)),this._attachedToMesh=null,this._onAfterRenderObserver=null,this._onAfterStepObserver=null,this._scene=null)},e.prototype._updateToMesh=function(){var e=this.ray;this._attachedToMesh&&e&&(this._attachedToMesh.isDisposed()?this.detachFromMesh():(this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,e.direction),V.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),e.origin)))},e.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},e}(),ap=function(){function e(t,i,r,n,o,a){var s,l,c,u,h,d,p,f,_,m,g,v,y,b;if(void 0===n&&(n=!0),void 0===o&&(o=3),void 0===a&&(a={}),this.skeleton=t,this.mesh=i,this.autoUpdateBonesMatrices=n,this.renderingGroupId=o,this.options=a,this.color=Z.White(),this._debugLines=new Array,this._localAxes=null,this._isEnabled=!0,this._obs=null,this._scene=r,this._ready=!1,a.pauseAnimations=null===(s=a.pauseAnimations)||void 0===s||s,a.returnToRest=null!==(l=a.returnToRest)&&void 0!==l&&l,a.displayMode=null!==(c=a.displayMode)&&void 0!==c?c:e.DISPLAY_LINES,a.displayOptions=null!==(u=a.displayOptions)&&void 0!==u?u:{},a.displayOptions.midStep=null!==(h=a.displayOptions.midStep)&&void 0!==h?h:.235,a.displayOptions.midStepFactor=null!==(d=a.displayOptions.midStepFactor)&&void 0!==d?d:.155,a.displayOptions.sphereBaseSize=null!==(p=a.displayOptions.sphereBaseSize)&&void 0!==p?p:.15,a.displayOptions.sphereScaleUnit=null!==(f=a.displayOptions.sphereScaleUnit)&&void 0!==f?f:2,a.displayOptions.sphereFactor=null!==(_=a.displayOptions.sphereFactor)&&void 0!==_?_:.865,a.displayOptions.spurFollowsChild=null!==(m=a.displayOptions.spurFollowsChild)&&void 0!==m&&m,a.displayOptions.showLocalAxes=null!==(g=a.displayOptions.showLocalAxes)&&void 0!==g&&g,a.displayOptions.localAxesSize=null!==(v=a.displayOptions.localAxesSize)&&void 0!==v?v:.075,a.computeBonesUsingShaders=null===(y=a.computeBonesUsingShaders)||void 0===y||y,a.useAllBones=null===(b=a.useAllBones)||void 0===b||b,this._boneIndices=new Set,!a.useAllBones){var T=null==i?void 0:i.getVerticesData(Nr.MatricesIndicesKind),E=null==i?void 0:i.getVerticesData(Nr.MatricesWeightsKind);if(T&&E)for(var S=0;Se.DISPLAY_SPHERE_AND_SPURS&&(A=e.DISPLAY_LINES),this.displayMode=A,this.update(),this._bindObs()}return e.CreateBoneWeightShader=function(e,t){var i,r,n,o,a,s,l=e.skeleton,c=null!==(i=e.colorBase)&&void 0!==i?i:Z.Black(),u=null!==(r=e.colorZero)&&void 0!==r?r:Z.Blue(),h=null!==(n=e.colorQuarter)&&void 0!==n?n:Z.Green(),d=null!==(o=e.colorHalf)&&void 0!==o?o:Z.Yellow(),p=null!==(a=e.colorFull)&&void 0!==a?a:Z.Red(),f=null!==(s=e.targetBoneIndex)&&void 0!==s?s:0;Ei.ShadersStore["boneWeights:"+l.name+"VertexShader"]="precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n\n #include\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include\n\n #include\n\n varying vec3 vColor;\n\n uniform vec3 colorBase;\n uniform vec3 colorZero;\n uniform vec3 colorQuarter;\n uniform vec3 colorHalf;\n uniform vec3 colorFull;\n\n uniform float targetBoneIndex;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include\n #include\n #include\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n vec3 color = colorBase;\n float totalWeight = 0.;\n if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){\n totalWeight += matricesWeights[0];\n }\n if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){\n totalWeight += matricesWeights[1];\n }\n if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){\n totalWeight += matricesWeights[2];\n }\n if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){\n totalWeight += matricesWeights[3];\n }\n\n color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));\n color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));\n color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));\n color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));\n vColor = color;\n\n gl_Position = projection * view * worldPos;\n }",Ei.ShadersStore["boneWeights:"+l.name+"FragmentShader"]="\n precision highp float;\n varying vec3 vPosition;\n\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4(vColor, 1.0);\n gl_FragColor = color;\n }\n ";var _=new ld("boneWeight:"+l.name,t,{vertex:"boneWeights:"+l.name,fragment:"boneWeights:"+l.name},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorBase","colorZero","colorQuarter","colorHalf","colorFull","targetBoneIndex"]});return _.setColor3("colorBase",c),_.setColor3("colorZero",u),_.setColor3("colorQuarter",h),_.setColor3("colorHalf",d),_.setColor3("colorFull",p),_.setFloat("targetBoneIndex",f),_.getClassName=function(){return"BoneWeightShader"},_.transparencyMode=Ca.MATERIAL_OPAQUE,_},e.CreateSkeletonMapShader=function(t,i){var r,n=t.skeleton,o=null!==(r=t.colorMap)&&void 0!==r?r:[{color:new Z(1,.38,.18),location:0},{color:new Z(.59,.18,1),location:.2},{color:new Z(.59,1,.18),location:.4},{color:new Z(1,.87,.17),location:.6},{color:new Z(1,.17,.42),location:.8},{color:new Z(.17,.68,1),location:1}],a=n.bones.length+1,s=e._CreateBoneMapColorBuffer(a,o,i),l=new ld("boneWeights:"+n.name,i,{vertexSource:"precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n uniform float colorMap["+4*n.bones.length+"];\n\n #include\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include\n #include\n\n varying vec3 vColor;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include\n #include\n #include\n\n vec3 color = vec3(0.);\n bool first = true;\n\n for (int i = 0; i < 4; i++) {\n int boneIdx = int(matricesIndices[i]);\n float boneWgt = matricesWeights[i];\n\n vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);\n\n if (boneWgt > 0.) {\n if (first) {\n first = false;\n color = c;\n } else {\n color = mix(color, c, boneWgt);\n }\n }\n }\n\n vColor = color;\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n gl_Position = projection * view * worldPos;\n }",fragmentSource:"\n precision highp float;\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4( vColor, 1.0 );\n gl_FragColor = color;\n }\n "},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorMap"]});return l.setFloats("colorMap",s),l.getClassName=function(){return"SkeletonMapShader"},l.transparencyMode=Ca.MATERIAL_OPAQUE,l},e._CreateBoneMapColorBuffer=function(e,t,i){var r=new Gu("temp",{width:e,height:1},i,!1),n=r.getContext(),o=n.createLinearGradient(0,0,e,0);t.forEach((function(e){o.addColorStop(e.location,e.color.toHexString())})),n.fillStyle=o,n.fillRect(0,0,e,1),r.update();for(var a=[],s=n.getImageData(0,0,e,1).data,l=1/255,c=0;ce.DISPLAY_SPHERE_AND_SPURS&&(t=e.DISPLAY_LINES),this.options.displayMode=t},enumerable:!1,configurable:!0}),e.prototype._bindObs=function(){var t=this;this.displayMode===e.DISPLAY_LINES&&(this._obs=this.scene.onBeforeRenderObservable.add((function(){t._displayLinesUpdate()})))},e.prototype.update=function(){switch(this.displayMode){case e.DISPLAY_LINES:this._displayLinesUpdate();break;case e.DISPLAY_SPHERES:this._buildSpheresAndSpurs(!0);break;case e.DISPLAY_SPHERE_AND_SPURS:this._buildSpheresAndSpurs(!1)}this._buildLocalAxes()},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this.isEnabled!==e&&(this._isEnabled=e,this.debugMesh&&this.debugMesh.setEnabled(e),e&&!this._obs?this._bindObs():!e&&this._obs&&(this.scene.onBeforeRenderObservable.remove(this._obs),this._obs=null))},enumerable:!1,configurable:!0}),e.prototype._getBonePosition=function(e,t,i,r,n,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=0);var a=H.Matrix[0],s=t.getParent();if(a.copyFrom(t.getLocalMatrix()),0!==r||0!==n||0!==o){var l=H.Matrix[1];z.IdentityToRef(l),l.setTranslationFromFloats(r,n,o),l.multiplyToRef(a,a)}s&&a.multiplyToRef(s.getAbsoluteMatrix(),a),a.multiplyToRef(i,a),e.x=a.m[12],e.y=a.m[13],e.z=a.m[14]},e.prototype._getLinesForBonesWithLength=function(e,t){var i,r,n=e.length;t?(i=t.getWorldMatrix(),r=t.position):(i=new z,r=e[0].position);for(var o=0,a=0;a=0;a--){var s=e[a],l=s.getParent();if(l&&(this._boneIndices.has(s.getIndex())||this.options.useAllBones)){var c=this._debugLines[n];c||(c=[V.Zero(),V.Zero()],this._debugLines[n]=c),s.getAbsolutePositionToRef(t,c[0]),l.getAbsolutePositionToRef(t,c[1]),c[0].subtractInPlace(i),c[1].subtractInPlace(i),n++}}o||t.dispose()},e.prototype._revert=function(e){this.options.pauseAnimations&&(this.scene.animationsEnabled=e,this.utilityLayer.utilityLayerScene.animationsEnabled=e)},e.prototype._getAbsoluteBindPoseToRef=function(e,t){null!==e&&-1!==e._index?(this._getAbsoluteBindPoseToRef(e.getParent(),t),e.getBindMatrix().multiplyToRef(t,t)):t.copyFrom(z.Identity())},e.prototype._createSpur=function(e,t,i,r,n,o){for(var a=i.subtract(e),s=a.length(),l=a.normalize().scale(s),c=n.midStep||.165,u=n.midStepFactor||.215,h=l.scale(c),d=Cd("skeletonViewer",{shape:[new V(1,-1,0),new V(1,1,0),new V(-1,1,0),new V(-1,-1,0),new V(1,-1,0)],path:[V.Zero(),h,l],scaleFunction:function(e){switch(e){case 0:case 2:return 0;case 1:return s*u}return 0},sideOrientation:Fa.DEFAULTSIDE,updatable:!1},o),p=d.getTotalVertices(),f=[],_=[],m=0;m9?_.push(r.getIndex(),0,0,0):_.push(t.getIndex(),0,0,0);return d.position=e.clone(),d.setVerticesData(Nr.MatricesWeightsKind,f,!1),d.setVerticesData(Nr.MatricesIndicesKind,_,!1),d.convertToFlatShadedMesh(),d},e.prototype._getBoundingSphereForBone=function(e){if(!this.mesh)return null;var t=this.mesh.getVerticesData(Nr.PositionKind),i=this.mesh.getIndices(),r=this.mesh.getVerticesData(Nr.MatricesWeightsKind),n=this.mesh.getVerticesData(Nr.MatricesIndicesKind);if(!(t&&i&&r&&n))return null;for(var o=new V(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new V(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),s=0,l=0;l1e-5){V.FromArrayToRef(t,3*c,H.Vector3[0]),o.minimizeInPlace(H.Vector3[0]),a.maximizeInPlace(H.Vector3[0]),s++;break}}return s>1?{center:V.Center(o,a),radius:V.Distance(o,a)/2}:null},e.prototype._buildSpheresAndSpurs=function(e){var t,i,r,n=this;void 0===e&&(e=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var o=null===(i=this.utilityLayer)||void 0===i?void 0:i.utilityLayerScene,a=this.skeleton.bones,s=[],l=[],c=this.scene.animationsEnabled;try{this.options.pauseAnimations&&(this.scene.animationsEnabled=!1,o.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteMatrices();for(var u=Number.NEGATIVE_INFINITY,h=this.options.displayOptions||{},d=function(t){var i=a[t];if(-1===i._index||!p._boneIndices.has(i.getIndex())&&!p.options.useAllBones)return"continue";var r=new z;p._getAbsoluteBindPoseToRef(i,r);var c=new V;if(r.decompose(void 0,void 0,c),i.children.length>0)i.children.forEach((function(t){var a=new z;t.getLocalMatrix().multiplyToRef(r,a);var s=new V;a.decompose(void 0,void 0,s);var d=V.Distance(c,s);d>u&&(u=d),e||l.push(n._createSpur(c,i,s,t,h,o))}));else{var d=p._getBoundingSphereForBone(i.getIndex());if(d&&(d.radius>u&&(u=d.radius),!e)){var f=void 0,_=i.getParent();_?(p._getAbsoluteBindPoseToRef(_,r),r.decompose(void 0,void 0,H.Vector3[0]),f=c.subtract(H.Vector3[0]).normalize().scale(d.radius).add(c)):f=d.center.subtract(c).normalize().scale(d.radius).add(c),l.push(p._createSpur(c,i,f,null,h,o))}}for(var m=Gh("skeletonViewer",{segments:6,diameter:h.sphereBaseSize||.2,updatable:!0},o),g=m.getTotalVertices(),v=[],y=[],b=0;b=6&&e._showPlanes)})),this._oldPosition.set(Number.NaN,Number.NaN,Number.NaN),this._visible=!0},e.prototype.hide=function(){this._lightHelperFrustumMeshes.forEach((function(e){e.setEnabled(!1)})),this._visible=!1},e.prototype.update=function(){var e,t,i,r,n,o;if(this._visible&&(!this._oldPosition.equals(this._light.position)||!this._oldDirection.equals(this._light.direction)||this._oldAutoCalc!==this._light.autoCalcShadowZBounds||this._oldMinZ!==this._light.shadowMinZ||this._oldMaxZ!==this._light.shadowMaxZ)){this._oldPosition.copyFrom(this._light.position),this._oldDirection.copyFrom(this._light.direction),this._oldAutoCalc=this._light.autoCalcShadowZBounds,this._oldMinZ=this._light.shadowMinZ,this._oldMaxZ=this._light.shadowMaxZ,H.Vector3[0].set(this._light.orthoLeft,this._light.orthoBottom,void 0!==this._light.shadowMinZ?this._light.shadowMinZ:this._camera.minZ),H.Vector3[1].set(this._light.orthoRight,this._light.orthoTop,void 0!==this._light.shadowMaxZ?this._light.shadowMaxZ:this._camera.maxZ);var a=this._getInvertViewMatrix();H.Vector3[2].copyFromFloats(H.Vector3[1].x,H.Vector3[1].y,H.Vector3[0].z),H.Vector3[3].copyFromFloats(H.Vector3[1].x,H.Vector3[0].y,H.Vector3[0].z),H.Vector3[4].copyFromFloats(H.Vector3[0].x,H.Vector3[0].y,H.Vector3[0].z),H.Vector3[5].copyFromFloats(H.Vector3[0].x,H.Vector3[1].y,H.Vector3[0].z),V.TransformCoordinatesToRef(H.Vector3[2],a,H.Vector3[2]),V.TransformCoordinatesToRef(H.Vector3[3],a,H.Vector3[3]),V.TransformCoordinatesToRef(H.Vector3[4],a,H.Vector3[4]),V.TransformCoordinatesToRef(H.Vector3[5],a,H.Vector3[5]),H.Vector3[6].copyFromFloats(H.Vector3[1].x,H.Vector3[1].y,H.Vector3[1].z),H.Vector3[7].copyFromFloats(H.Vector3[1].x,H.Vector3[0].y,H.Vector3[1].z),H.Vector3[8].copyFromFloats(H.Vector3[0].x,H.Vector3[0].y,H.Vector3[1].z),H.Vector3[9].copyFromFloats(H.Vector3[0].x,H.Vector3[1].y,H.Vector3[1].z),V.TransformCoordinatesToRef(H.Vector3[6],a,H.Vector3[6]),V.TransformCoordinatesToRef(H.Vector3[7],a,H.Vector3[7]),V.TransformCoordinatesToRef(H.Vector3[8],a,H.Vector3[8]),V.TransformCoordinatesToRef(H.Vector3[9],a,H.Vector3[9]),fd("nearlines",{updatable:!0,points:this._nearLinesPoints,instance:this._lightHelperFrustumMeshes[0]},this._scene),fd("farlines",{updatable:!0,points:this._farLinesPoints,instance:this._lightHelperFrustumMeshes[1]},this._scene),fd("trlines",{updatable:!0,points:this._trLinesPoints,instance:this._lightHelperFrustumMeshes[2]},this._scene),fd("brlines",{updatable:!0,points:this._brLinesPoints,instance:this._lightHelperFrustumMeshes[3]},this._scene),fd("tllines",{updatable:!0,points:this._tlLinesPoints,instance:this._lightHelperFrustumMeshes[4]},this._scene),fd("bllines",{updatable:!0,points:this._blLinesPoints,instance:this._lightHelperFrustumMeshes[5]},this._scene),H.Vector3[2].toArray(this._nearPlaneVertices,0),H.Vector3[3].toArray(this._nearPlaneVertices,3),H.Vector3[4].toArray(this._nearPlaneVertices,6),H.Vector3[5].toArray(this._nearPlaneVertices,9),null===(e=this._lightHelperFrustumMeshes[6].geometry)||void 0===e||e.updateVerticesDataDirectly("position",this._nearPlaneVertices,0),H.Vector3[6].toArray(this._farPlaneVertices,0),H.Vector3[7].toArray(this._farPlaneVertices,3),H.Vector3[8].toArray(this._farPlaneVertices,6),H.Vector3[9].toArray(this._farPlaneVertices,9),null===(t=this._lightHelperFrustumMeshes[7].geometry)||void 0===t||t.updateVerticesDataDirectly("position",this._farPlaneVertices,0),H.Vector3[2].toArray(this._rightPlaneVertices,0),H.Vector3[6].toArray(this._rightPlaneVertices,3),H.Vector3[7].toArray(this._rightPlaneVertices,6),H.Vector3[3].toArray(this._rightPlaneVertices,9),null===(i=this._lightHelperFrustumMeshes[8].geometry)||void 0===i||i.updateVerticesDataDirectly("position",this._rightPlaneVertices,0),H.Vector3[5].toArray(this._leftPlaneVertices,0),H.Vector3[9].toArray(this._leftPlaneVertices,3),H.Vector3[8].toArray(this._leftPlaneVertices,6),H.Vector3[4].toArray(this._leftPlaneVertices,9),null===(r=this._lightHelperFrustumMeshes[9].geometry)||void 0===r||r.updateVerticesDataDirectly("position",this._leftPlaneVertices,0),H.Vector3[2].toArray(this._topPlaneVertices,0),H.Vector3[6].toArray(this._topPlaneVertices,3),H.Vector3[9].toArray(this._topPlaneVertices,6),H.Vector3[5].toArray(this._topPlaneVertices,9),null===(n=this._lightHelperFrustumMeshes[10].geometry)||void 0===n||n.updateVerticesDataDirectly("position",this._topPlaneVertices,0),H.Vector3[3].toArray(this._bottomPlaneVertices,0),H.Vector3[7].toArray(this._bottomPlaneVertices,3),H.Vector3[8].toArray(this._bottomPlaneVertices,6),H.Vector3[4].toArray(this._bottomPlaneVertices,9),null===(o=this._lightHelperFrustumMeshes[11].geometry)||void 0===o||o.updateVerticesDataDirectly("position",this._bottomPlaneVertices,0)}},e.prototype.dispose=function(){this._lightHelperFrustumMeshes.forEach((function(e){var t;null===(t=e.material)||void 0===t||t.dispose(),e.dispose()})),this._rootNode.dispose()},e.prototype._createGeometry=function(){var e=this;this._rootNode=new Fo("directionalLightHelperRoot_"+this._light.name,this._scene),this._rootNode.parent=this._light.parent,this._nearLinesPoints=[H.Vector3[0],H.Vector3[1],H.Vector3[2],H.Vector3[3],H.Vector3[4]];var t=fd("nearlines",{updatable:!0,points:this._nearLinesPoints},this._scene);t.parent=this._rootNode,t.alwaysSelectAsActiveMesh=!0,this._farLinesPoints=[H.Vector3[5],H.Vector3[6],H.Vector3[7],H.Vector3[8],H.Vector3[9]];var i=fd("farlines",{updatable:!0,points:this._farLinesPoints},this._scene);i.parent=this._rootNode,i.alwaysSelectAsActiveMesh=!0,this._trLinesPoints=[H.Vector3[10],H.Vector3[11]];var r=fd("trlines",{updatable:!0,points:this._trLinesPoints},this._scene);r.parent=this._rootNode,r.alwaysSelectAsActiveMesh=!0,this._brLinesPoints=[H.Vector3[12],H.Vector3[0]];var n=fd("brlines",{updatable:!0,points:this._brLinesPoints},this._scene);n.parent=this._rootNode,n.alwaysSelectAsActiveMesh=!0,this._tlLinesPoints=[H.Vector3[1],H.Vector3[2]];var o=fd("tllines",{updatable:!0,points:this._tlLinesPoints},this._scene);o.parent=this._rootNode,o.alwaysSelectAsActiveMesh=!0,this._blLinesPoints=[H.Vector3[3],H.Vector3[4]];var a=fd("bllines",{updatable:!0,points:this._blLinesPoints},this._scene);a.parent=this._rootNode,a.alwaysSelectAsActiveMesh=!0,this._lightHelperFrustumMeshes.push(t,i,r,n,o,a);var s=function(t,i,r){var n=new Fa(t+"plane",e._scene),o=new Uu(t+"PlaneMat",e._scene);n.material=o,n.parent=e._rootNode,n.alwaysSelectAsActiveMesh=!0,o.emissiveColor=i,o.alpha=e.transparency,o.backFaceCulling=!1,o.disableLighting=!0;var a=new _o;a.positions=r,a.indices=[0,1,2,0,2,3],a.applyToMesh(n,!0),e._lightHelperFrustumMeshes.push(n)};this._nearPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._farPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._rightPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._leftPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._topPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._bottomPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],s("near",new Z(1,0,0),this._nearPlaneVertices),s("far",new Z(.3,0,0),this._farPlaneVertices),s("right",new Z(0,1,0),this._rightPlaneVertices),s("left",new Z(0,.3,0),this._leftPlaneVertices),s("top",new Z(0,0,1),this._topPlaneVertices),s("bottom",new Z(0,0,.3),this._bottomPlaneVertices),this._nearLinesPoints[0]=H.Vector3[2],this._nearLinesPoints[1]=H.Vector3[3],this._nearLinesPoints[2]=H.Vector3[4],this._nearLinesPoints[3]=H.Vector3[5],this._nearLinesPoints[4]=H.Vector3[2],this._farLinesPoints[0]=H.Vector3[6],this._farLinesPoints[1]=H.Vector3[7],this._farLinesPoints[2]=H.Vector3[8],this._farLinesPoints[3]=H.Vector3[9],this._farLinesPoints[4]=H.Vector3[6],this._trLinesPoints[0]=H.Vector3[2],this._trLinesPoints[1]=H.Vector3[6],this._brLinesPoints[0]=H.Vector3[3],this._brLinesPoints[1]=H.Vector3[7],this._tlLinesPoints[0]=H.Vector3[4],this._tlLinesPoints[1]=H.Vector3[8],this._blLinesPoints[0]=H.Vector3[5],this._blLinesPoints[1]=H.Vector3[9]},e.prototype._getInvertViewMatrix=function(){return z.LookAtLHToRef(this._light.position,this._light.position.add(this._light.direction),V.UpReadOnly,this._inverseViewMatrix),this._inverseViewMatrix.invertToRef(this._inverseViewMatrix),this._inverseViewMatrix},e}(),lp=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},cp=function(t){function i(i){void 0===i&&(i=new lp);var r=t.call(this,null)||this;void 0===i.deterministicLockstep&&(i.deterministicLockstep=!1),void 0!==i.timeStep&&(r._timeStep=i.timeStep),void 0===i.lockstepMaxSteps&&(i.lockstepMaxSteps=4),r._options=i,I.SetMatrixPrecision(!!i.useHighPrecisionMatrix),r._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,maxFragmentUniformVectors:16,maxVertexUniformVectors:16,standardDerivatives:!1,astc:null,pvrtc:null,etc1:null,etc2:null,bptc:null,maxAnisotropy:0,uintIndices:!1,fragmentDepthSupported:!1,highPrecisionShaderSupported:!0,colorBufferFloat:!1,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!1,texelFetch:!1,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!1,instancedArrays:!1,supportOcclusionQuery:!1,canUseTimestampForTimerQuery:!1,maxMSAASamples:1,blendMinMax:!1,canUseGLInstanceID:!1,canUseGLVertexID:!1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:!1,textureMaxLevel:!1,texture2DArrayMaxLayerCount:128,disableMorphTargetTexture:!1},r._features={forceBitmapOverHTMLImageElement:!1,supportRenderAndCopyToLodForFloatTextures:!1,supportDepthStencilTexture:!1,supportShadowSamplers:!1,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:!1,trackUbosInFrame:!1,checkUbosContentBeforeUpload:!1,supportCSM:!1,basisNeedsPOT:!1,support3DTextures:!1,needTypeSuffixInShaderConstants:!1,supportMSAA:!1,supportSSAO2:!1,supportExtendedTextureFormats:!1,supportSwitchCaseInShader:!1,supportSyncTextureRead:!1,needsInvertingBitmap:!1,useUBOBindingCache:!1,needShaderCodeInlining:!1,needToAlwaysBindUniformBuffers:!1,supportRenderPasses:!0,supportSpriteInstancing:!1,forceVertexBufferStrideAndOffsetMultiple4Bytes:!1,_collectUbosUpdatedInFrame:!1},ae.Log("Babylon.js v".concat(Do.Version," - Null engine"));var n="undefined"!=typeof self?self:void 0!==e.g?e.g:window;return"undefined"==typeof URL&&(n.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(n.Blob=function(){}),r}return m(i,t),i.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},i.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},i.prototype.getHardwareScalingLevel=function(){return 1},i.prototype.createVertexBuffer=function(e){var t=new vr;return t.references=1,t},i.prototype.createIndexBuffer=function(e){var t=new vr;return t.references=1,t},i.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1)},i.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},i.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},i.prototype.setViewport=function(e,t,i){this._cachedViewport=e},i.prototype.createShaderProgram=function(e,t,i,r,n){return{__SPECTOR_rebuildProgram:null}},i.prototype.getUniforms=function(e,t){return[]},i.prototype.getAttributes=function(e,t){return[]},i.prototype.bindSamplers=function(e){this._currentEffect=null},i.prototype.enableEffect=function(e){e=null!==e&&fr(e)?e.effect:e,this._currentEffect=e,e&&(e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))},i.prototype.setState=function(e,t,i,r,n,o,a){void 0===t&&(t=0),void 0===r&&(r=!1),void 0===a&&(a=0)},i.prototype.setIntArray=function(e,t){return!0},i.prototype.setIntArray2=function(e,t){return!0},i.prototype.setIntArray3=function(e,t){return!0},i.prototype.setIntArray4=function(e,t){return!0},i.prototype.setFloatArray=function(e,t){return!0},i.prototype.setFloatArray2=function(e,t){return!0},i.prototype.setFloatArray3=function(e,t){return!0},i.prototype.setFloatArray4=function(e,t){return!0},i.prototype.setArray=function(e,t){return!0},i.prototype.setArray2=function(e,t){return!0},i.prototype.setArray3=function(e,t){return!0},i.prototype.setArray4=function(e,t){return!0},i.prototype.setMatrices=function(e,t){return!0},i.prototype.setMatrix3x3=function(e,t){return!0},i.prototype.setMatrix2x2=function(e,t){return!0},i.prototype.setFloat=function(e,t){return!0},i.prototype.setFloat2=function(e,t,i){return!0},i.prototype.setFloat3=function(e,t,i,r){return!0},i.prototype.setBool=function(e,t){return!0},i.prototype.setFloat4=function(e,t,i,r,n){return!0},i.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(this.alphaState.alphaBlend=e!==u.ALPHA_DISABLE,t||this.setDepthWrite(e===u.ALPHA_DISABLE),this._alphaMode=e)},i.prototype.bindBuffers=function(e,t,i){},i.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilStateComposer.reset(),this.depthCullingState.reset(),this.alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},i.prototype.draw=function(e,t,i,r){},i.prototype.drawElementsType=function(e,t,i,r){},i.prototype.drawArraysType=function(e,t,i,r){},i.prototype._createTexture=function(){return{}},i.prototype._releaseTexture=function(e){},i.prototype.createTexture=function(e,t,i,r,n,o,a,s,l,c,h,d){void 0===n&&(n=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=null);var p=new Pi(this,Ti.Url),f=String(e);return p.url=f,p.generateMipMaps=!t,p.samplingMode=n,p.invertY=i,p.baseWidth=this._options.textureSize,p.baseHeight=this._options.textureSize,p.width=this._options.textureSize,p.height=this._options.textureSize,c&&(p.format=c),p.isReady=!0,o&&setTimeout((function(){o(p)})),this._internalTexturesCache.push(p),p},i.prototype._createHardwareRenderTargetWrapper=function(e,t,i){var r=new cl(e,t,i,this);return this._renderTargetWrapperCache.push(r),r},i.prototype.createRenderTargetTexture=function(e,t){var i=this._createHardwareRenderTargetWrapper(!1,!1,e),r={};void 0!==t&&"object"==typeof t?(r.generateMipMaps=t.generateMipMaps,r.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,r.generateStencilBuffer=r.generateDepthBuffer&&t.generateStencilBuffer,r.type=void 0===t.type?u.TEXTURETYPE_UNSIGNED_INT:t.type,r.samplingMode=void 0===t.samplingMode?u.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode):(r.generateMipMaps=t,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.type=u.TEXTURETYPE_UNSIGNED_INT,r.samplingMode=u.TEXTURE_TRILINEAR_SAMPLINGMODE);var n=new Pi(this,Ti.RenderTarget),o=e.width||e,a=e.height||e;return i._generateDepthBuffer=r.generateDepthBuffer,i._generateStencilBuffer=!!r.generateStencilBuffer,n.baseWidth=o,n.baseHeight=a,n.width=o,n.height=a,n.isReady=!0,n.samples=1,n.generateMipMaps=!!r.generateMipMaps,n.samplingMode=r.samplingMode,n.type=r.type,this._internalTexturesCache.push(n),i},i.prototype.createRenderTargetCubeTexture=function(e,t){var i=this._createHardwareRenderTargetWrapper(!1,!0,e),r=g({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:u.TEXTURETYPE_UNSIGNED_INT,samplingMode:u.TEXTURE_TRILINEAR_SAMPLINGMODE,format:u.TEXTUREFORMAT_RGBA},t);r.generateStencilBuffer=r.generateDepthBuffer&&r.generateStencilBuffer,(r.type!==u.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(r.type!==u.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(r.samplingMode=u.TEXTURE_NEAREST_SAMPLINGMODE),i._generateDepthBuffer=r.generateDepthBuffer,i._generateStencilBuffer=!!r.generateStencilBuffer;var n=new Pi(this,Ti.RenderTarget);return n.baseWidth=e,n.baseHeight=e,n.width=e,n.height=e,n.isReady=!0,n.isCube=!0,n.samples=1,n.generateMipMaps=!!r.generateMipMaps,n.samplingMode=r.samplingMode,n.type=r.type,this._internalTexturesCache.push(n),i},i.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},i.prototype.createRawTexture=function(e,t,i,r,n,o,a,s,l,c,h){void 0===s&&(s=null),void 0===l&&(l=u.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=0),void 0===h&&(h=!1);var d=new Pi(this,Ti.Raw);return d.baseWidth=t,d.baseHeight=i,d.width=t,d.height=i,d.format=r,d.generateMipMaps=n,d.samplingMode=a,d.invertY=o,d._compression=s,d.type=l,d._useSRGBBuffer=h,this._doNotHandleContextLost||(d._bufferView=e),d},i.prototype.updateRawTexture=function(e,t,i,r,n,o,a){void 0===n&&(n=null),void 0===o&&(o=u.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1),e&&(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n,e.type=o,e._useSRGBBuffer=a)},i.prototype.bindFramebuffer=function(e,t,i,r,n){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=null,this._cachedViewport&&!n&&this.setViewport(this._cachedViewport,i,r)},i.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&i(),this._currentFramebuffer=null},i.prototype.createDynamicVertexBuffer=function(e){var t=new vr;return t.references=1,t.capacity=1,t},i.prototype.updateDynamicTexture=function(e,t,i,r,n){void 0===r&&(r=!1)},i.prototype.areAllEffectsReady=function(){return!0},i.prototype.getError=function(){return 0},i.prototype._getUnpackAlignement=function(){return 1},i.prototype._unpackFlipY=function(e){},i.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},i.prototype.updateDynamicVertexBuffer=function(e,t,i,r){},i.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},i.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},i.prototype._deleteBuffer=function(e){},i.prototype.releaseEffects=function(){},i.prototype.displayLoadingUI=function(){},i.prototype.hideLoadingUI=function(){},Object.defineProperty(i.prototype,"loadingUIText",{set:function(e){},enumerable:!1,configurable:!0}),i.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,a){void 0===o&&(o=0),void 0===a&&(a=0)},i.prototype._uploadDataToTextureDirectly=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},i.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},i.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},i}(Do);Mi.prototype._partialLoadFile=function(e,t,i,r,n){void 0===n&&(n=null),this._loadFile(e,(function(e){i[t]=e,i._internalCount++,6===i._internalCount&&r(i)}),void 0,void 0,!0,(function(e,t){n&&e&&n(e.status+" "+e.statusText,t)}))},Mi.prototype._cascadeLoadFiles=function(e,t,i,r){void 0===r&&(r=null);var n=[];n._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(i[o],o,n,t,r)},Mi.prototype._cascadeLoadImgs=function(e,t,i,r,n,o){void 0===n&&(n=null);var a=[];a._internalCount=0;for(var s=0;s<6;s++)this._partialLoadImg(r[s],s,a,e,t,i,n,o)},Mi.prototype._partialLoadImg=function(e,t,i,r,n,o,a,s){void 0===a&&(a=null);var l=Qi();Bi(e,(function(e){i[t]=e,i._internalCount++,r&&r.removePendingData(l),6===i._internalCount&&o&&o(n,i)}),(function(e,t){r&&r.removePendingData(l),a&&a(e,t)}),r?r.offlineProvider:null,s),r&&r.addPendingData(l)},Mi.prototype.createCubeTextureBase=function(e,t,i,r,n,o,a,s,l,c,u,h,d,p,f){var _=this;void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!1),void 0===c&&(c=0),void 0===u&&(u=0),void 0===h&&(h=null),void 0===d&&(d=null),void 0===p&&(p=null),void 0===f&&(f=!1);var m=h||new Pi(this,Ti.Cube);m.isCube=!0,m.url=e,m.generateMipMaps=!r,m._lodGenerationScale=c,m._lodGenerationOffset=u,m._useSRGBBuffer=!!f&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!r),m!==h&&(m.label=e.substring(0,60)),this._doNotHandleContextLost||(m._extension=s,m._files=i);var g=e;this._transformTextureUrl&&!h&&(e=this._transformTextureUrl(e));for(var v=e.split("?")[0],y=v.lastIndexOf("."),b=s||(y>-1?v.substring(y).toLowerCase():""),T=null,E=0,S=Mi._TextureLoaders;E0)}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return e.occlusionType!==Uo.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==Uo.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var r=this.getScene();if(r.getBoundingBoxRenderer){var n=r.getBoundingBoxRenderer();null===this._occlusionQuery&&(this._occlusionQuery=t.createQuery()),this._occlusionQuery&&t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery)&&(n.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0)}return e.isOccluded},Mi.prototype.setAlphaEquation=function(e){if(this._alphaEquation!==e){switch(e){case u.ALPHA_EQUATION_ADD:this._alphaState.setAlphaEquationParameters(u.GL_ALPHA_EQUATION_ADD,u.GL_ALPHA_EQUATION_ADD);break;case u.ALPHA_EQUATION_SUBSTRACT:this._alphaState.setAlphaEquationParameters(u.GL_ALPHA_EQUATION_SUBTRACT,u.GL_ALPHA_EQUATION_SUBTRACT);break;case u.ALPHA_EQUATION_REVERSE_SUBTRACT:this._alphaState.setAlphaEquationParameters(u.GL_ALPHA_EQUATION_REVERSE_SUBTRACT,u.GL_ALPHA_EQUATION_REVERSE_SUBTRACT);break;case u.ALPHA_EQUATION_MAX:this._alphaState.setAlphaEquationParameters(u.GL_ALPHA_EQUATION_MAX,u.GL_ALPHA_EQUATION_MAX);break;case u.ALPHA_EQUATION_MIN:this._alphaState.setAlphaEquationParameters(u.GL_ALPHA_EQUATION_MIN,u.GL_ALPHA_EQUATION_MIN);break;case u.ALPHA_EQUATION_DARKEN:this._alphaState.setAlphaEquationParameters(u.GL_ALPHA_EQUATION_MIN,u.GL_ALPHA_EQUATION_ADD)}this._alphaEquation=e}},Mi.prototype._debugPushGroup=function(e,t){},Mi.prototype._debugPopGroup=function(e){},Mi.prototype._debugInsertMarker=function(e,t){},Mi.prototype._debugFlushPendingCommands=function(){};var hp=function(){this._timeElapsedQueryEnded=!1};Do.prototype.createQuery=function(){var e=this._gl.createQuery();if(!e)throw new Error("Unable to create Occlusion Query");return e},Do.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},Do.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},Do.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},Do.prototype.beginOcclusionQuery=function(e,t){var i=this._getGlAlgorithmType(e);return this._gl.beginQuery(i,t),!0},Do.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},Do.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},Do.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},Do.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},Do.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},Do.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var i=new hp;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),e.canUseTimestampForTimerQuery)i._startTimeQuery=this._createTimeQuery(),i._startTimeQuery&&t.queryCounterEXT(i._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;i._timeElapsedQuery=this._createTimeQuery(),i._timeElapsedQuery&&(t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,i._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,i._timeElapsedQuery)),this._currentNonTimestampToken=i}return i},Do.prototype.endTimeQuery=function(e){var t=this.getCaps(),i=t.timerQuery;if(!i||!e)return-1;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),e._endTimeQuery&&i.queryCounterEXT(e._endTimeQuery,i.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;i.endQueryEXT?i.endQueryEXT(i.TIME_ELAPSED_EXT):(this._gl.endQuery(i.TIME_ELAPSED_EXT),this._currentNonTimestampToken=null),e._timeElapsedQueryEnded=!0}var r=this._gl.getParameter(i.GPU_DISJOINT_EXT),n=!1;if(e._endTimeQuery?n=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(n=this._getTimeQueryAvailability(e._timeElapsedQuery)),n&&!r){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var a=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-a,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;o=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1}return o}return-1},Do.prototype._captureGPUFrameTime=!1,Do.prototype._gpuFrameTime=new an,Do.prototype.getGPUFrameTimeCounter=function(){return this._gpuFrameTime},Do.prototype.captureGPUFrameTime=function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.onBeginFrameObservable.add((function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.startTimeQuery())})),this._onEndFrameObserver=this.onEndFrameObservable.add((function(){if(t._gpuFrameTimeToken){var e=t.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}}))):(this.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},Do.prototype._getGlAlgorithmType=function(e){return e===Uo.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED};var dp=!0;Do.prototype.createTransformFeedback=function(){var e=this._gl.createTransformFeedback();if(!e)throw new Error("Unable to create Transform Feedback");return e},Do.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},Do.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},Do.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},Do.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},Do.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},Do.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)},Er.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){var r=this._getInternalFormat(e.format),n=this._getRGBABufferInternalSizedFormat(u.TEXTURETYPE_UNSIGNED_BYTE,e.format),o=this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0);this._unpackFlipY(!i);try{if(void 0===this._videoTextureSupported&&(this._gl.getError(),this._gl.texImage2D(this._gl.TEXTURE_2D,0,n,r,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported)this._gl.texImage2D(this._gl.TEXTURE_2D,0,n,r,this._gl.UNSIGNED_BYTE,t);else{if(!e._workingCanvas){e._workingCanvas=this.createCanvas(e.width,e.height);var a=e._workingCanvas.getContext("2d");if(!a)throw new Error("Unable to get 2d context");e._workingContext=a,e._workingCanvas.width=e.width,e._workingCanvas.height=e.height}e._workingContext.clearRect(0,0,e.width,e.height),e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e.width,e.height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,n,r,this._gl.UNSIGNED_BYTE,e._workingCanvas)}e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),o||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},Er.prototype.restoreSingleAttachment=function(){var e=this._gl;this.bindAttachments([e.BACK])},Er.prototype.restoreSingleAttachmentForRenderTarget=function(){var e=this._gl;this.bindAttachments([e.COLOR_ATTACHMENT0])},Er.prototype.buildTextureLayout=function(e){for(var t=this._gl,i=[],r=0;r1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],r.readBuffer(n[a]),r.drawBuffers(n),r.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,r.COLOR_BUFFER_BIT,r.NEAREST)}for(a=0;a1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];r.drawBuffers(n)}for(a=0;a1&&(t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH24_STENCIL8||t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH24||t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH32_FLOAT||t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8)&&(c=t.depthTextureFormat)),x.label=null!==(r=null==t?void 0:t.label)&&void 0!==r?r:"MultiRenderTargetWrapper";var A=this._gl,C=A.createFramebuffer();this._bindUnboundFramebuffer(C);var R=e.width||e,P=e.height||e,I=[],M=[],O=this.webGLVersion>1&&l&&(t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH24_STENCIL8||t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||t.depthTextureFormat===u.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8),D=this._setupFramebufferDepthAttachments(!O&&s,!l&&a,R,P);x._framebuffer=C,x._depthStencilBuffer=D,x._generateDepthBuffer=!l&&a,x._generateStencilBuffer=!O&&s,x._attachments=M;for(var N=0;N1||this.isWebGPU);var G=this.webGLVersion>1,z=A[G?"COLOR_ATTACHMENT"+N:"COLOR_ATTACHMENT"+N+"_WEBGL"];if(M.push(z),-1!==U){var W=new Pi(this,Ti.MultiRenderTarget);I[N]=W,A.activeTexture(A["TEXTURE"+N]),A.bindTexture(U,W._hardwareTexture.underlyingResource),A.texParameteri(U,A.TEXTURE_MAG_FILTER,k.mag),A.texParameteri(U,A.TEXTURE_MIN_FILTER,k.min),A.texParameteri(U,A.TEXTURE_WRAP_S,A.CLAMP_TO_EDGE),A.texParameteri(U,A.TEXTURE_WRAP_T,A.CLAMP_TO_EDGE);var H=this._getRGBABufferInternalSizedFormat(L,B,w),X=this._getInternalFormat(B),j=this._getWebGLTextureType(L);if(!G||U!==u.TEXTURE_2D_ARRAY&&U!==u.TEXTURE_3D)if(U===u.TEXTURE_CUBE_MAP){for(var Y=0;Y<6;Y++)A.texImage2D(A.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,H,R,P,0,X,j,null);W.isCube=!0}else A.texImage2D(A.TEXTURE_2D,0,H,R,P,0,X,j,null);else U===u.TEXTURE_2D_ARRAY?W.is2DArray=!0:W.is3D=!0,W.baseDepth=W.depth=V,A.texImage3D(U,0,H,R,P,V,0,X,j,null);o&&A.generateMipmap(U),this._bindTextureDirectly(U,null),W.baseWidth=R,W.baseHeight=P,W.width=R,W.height=P,W.isReady=!0,W.samples=1,W.generateMipMaps=o,W.samplingMode=F,W.type=L,W._useSRGBBuffer=w,W.format=B,this._internalTexturesCache.push(W)}}if(l&&this._caps.depthTextureExtension){var K=new Pi(this,Ti.Depth),Q=u.TEXTURETYPE_UNSIGNED_SHORT,q=A.DEPTH_COMPONENT16,Z=A.DEPTH_COMPONENT,J=A.UNSIGNED_SHORT,$=A.DEPTH_ATTACHMENT;this.webGLVersion<2?q=A.DEPTH_COMPONENT:c===u.TEXTUREFORMAT_DEPTH32_FLOAT?(Q=u.TEXTURETYPE_FLOAT,J=A.FLOAT,q=A.DEPTH_COMPONENT32F):c===u.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8?(Q=u.TEXTURETYPE_UNSIGNED_INT,J=A.FLOAT_32_UNSIGNED_INT_24_8_REV,q=A.DEPTH32F_STENCIL8,Z=A.DEPTH_STENCIL,$=A.DEPTH_STENCIL_ATTACHMENT):c===u.TEXTUREFORMAT_DEPTH24?(Q=u.TEXTURETYPE_UNSIGNED_INT,J=A.UNSIGNED_INT,q=A.DEPTH_COMPONENT24,$=A.DEPTH_ATTACHMENT):c!==u.TEXTUREFORMAT_DEPTH24_STENCIL8&&c!==u.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||(Q=u.TEXTURETYPE_UNSIGNED_INT_24_8,J=A.UNSIGNED_INT_24_8,q=A.DEPTH24_STENCIL8,Z=A.DEPTH_STENCIL,$=A.DEPTH_STENCIL_ATTACHMENT),A.activeTexture(A.TEXTURE0),A.bindTexture(A.TEXTURE_2D,K._hardwareTexture.underlyingResource),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MAG_FILTER,A.NEAREST),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MIN_FILTER,A.NEAREST),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_S,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_T,A.CLAMP_TO_EDGE),A.texImage2D(A.TEXTURE_2D,0,q,R,P,0,Z,J,null),A.framebufferTexture2D(A.FRAMEBUFFER,$,A.TEXTURE_2D,K._hardwareTexture.underlyingResource,0),K.baseWidth=R,K.baseHeight=P,K.width=R,K.height=P,K.isReady=!0,K.samples=1,K.generateMipMaps=o,K.samplingMode=u.TEXTURE_NEAREST_SAMPLINGMODE,K.format=c,K.type=Q,I[h]=K,this._internalTexturesCache.push(K)}return x.setTextures(I),i&&A.drawBuffers(M),this._bindUnboundFramebuffer(null),x.setLayerAndFaceIndices(E,T),this.resetTextureCache(),x},Er.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t,i){if(void 0===i&&(i=!0),this.webGLVersion<2||!e||!e.texture)return 1;if(e.samples===t)return t;var r=e._attachments.length;if(0===r)return 1;var n=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples);var o=!!e._depthStencilBuffer;if(o&&(n.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(n.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),t>1&&"function"==typeof n.renderbufferStorageMultisample){var a=n.createFramebuffer();if(!a)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=a,this._bindUnboundFramebuffer(a);for(var s=[],l=0;l1?"COLOR_ATTACHMENT"+l:"COLOR_ATTACHMENT"+l+"_WEBGL"],d=this._createRenderBuffer(c.width,c.height,t,-1,this._getRGBABufferInternalSizedFormat(c.type,c.format,c._useSRGBBuffer),h);if(!d)throw new Error("Unable to create multi sampled framebuffer");u.addMSAARenderBuffer(d),c.samples=t,s.push(h)}i&&n.drawBuffers(s)}else this._bindUnboundFramebuffer(e._framebuffer);return o&&(e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.texture.width,e.texture.height,t)),this._bindUnboundFramebuffer(null),t},Er.prototype._createDepthStencilCubeTexture=function(e,t){var i=new Pi(this,Ti.DepthStencil);if(i.isCube=!0,1===this.webGLVersion)return ae.Error("Depth cube texture is not supported by WebGL 1."),i;var r=g({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),n=this._gl;this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,i,!0),this._setupDepthStencilTexture(i,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction);for(var o=0;o<6;o++)r.generateStencil?n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,n.DEPTH24_STENCIL8,e,e,0,n.DEPTH_STENCIL,n.UNSIGNED_INT_24_8,null):n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,n.DEPTH_COMPONENT24,e,e,0,n.DEPTH_COMPONENT,n.UNSIGNED_INT,null);return this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(i),i},Er.prototype._setCubeMapTextureParams=function(e,t,i){var r=this._gl;r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,t?r.LINEAR_MIPMAP_LINEAR:r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),e.samplingMode=t?u.TEXTURE_TRILINEAR_SAMPLINGMODE:u.TEXTURE_LINEAR_LINEAR,t&&this.getCaps().textureMaxLevel&&void 0!==i&&i>0&&(r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAX_LEVEL,i),e._maxLodLevel=i),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null)},Er.prototype.createCubeTexture=function(e,t,i,r,n,o,a,s,l,c,u,h,d,p){var f=this;void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!1),void 0===c&&(c=0),void 0===u&&(u=0),void 0===h&&(h=null),void 0===p&&(p=!1);var _=this._gl;return this.createCubeTextureBase(e,t,i,!!r,n,o,a,s,l,c,u,h,(function(e){return f._bindTextureDirectly(_.TEXTURE_CUBE_MAP,e,!0)}),(function(e,t){var i=f.needPOTTextures?ir(t[0].width,f._caps.maxCubemapTextureSize):t[0].width,o=i,s=[_.TEXTURE_CUBE_MAP_POSITIVE_X,_.TEXTURE_CUBE_MAP_POSITIVE_Y,_.TEXTURE_CUBE_MAP_POSITIVE_Z,_.TEXTURE_CUBE_MAP_NEGATIVE_X,_.TEXTURE_CUBE_MAP_NEGATIVE_Y,_.TEXTURE_CUBE_MAP_NEGATIVE_Z];f._bindTextureDirectly(_.TEXTURE_CUBE_MAP,e,!0),f._unpackFlipY(!1);var l=a?f._getInternalFormat(a,e._useSRGBBuffer):e._useSRGBBuffer?f._glSRGBExtensionValues.SRGB8_ALPHA8:_.RGBA,c=a?f._getInternalFormat(a):_.RGBA;e._useSRGBBuffer&&1===f.webGLVersion&&(c=l);for(var u=0;u-1?e.substring(i,e.length):"";return(t>-1?e.substring(0,t):e)+this._textureFormatInUse+r}Object.defineProperty(Do.prototype,"onBeforeViewRenderObservable",{get:function(){return fp}}),Object.defineProperty(Do.prototype,"onAfterViewRenderObservable",{get:function(){return _p}}),Object.defineProperty(Do.prototype,"inputElement",{get:function(){return this._inputElement},set:function(e){var t;this._inputElement!==e&&(this._inputElement=e,null===(t=this._onEngineViewChanged)||void 0===t||t.call(this))}}),Do.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},Do.prototype.registerView=function(e,t,i){var r=this;this.views||(this.views=[]);for(var n=0,o=this.views;nthis._length&&this._flush()},e.prototype._flush=function(){this._nativeDataStream.writeBuffer(this._uint32s.buffer,this._position),this._position=0},e.DEFAULT_BUFFER_SIZE=65536,e}(),vp=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],yp=[function(){return 1},function(e){return e.y},function(e){return e.z},function(e){return e.x},function(e){return e.x*e.y},function(e){return e.y*e.z},function(e){return 3*e.z*e.z-1},function(e){return e.x*e.z},function(e){return e.x*e.x-e.y*e.y}],bp=function(e,t){return vp[e]*yp[e](t)},Tp=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4],Ep=function(){function e(){this.preScaled=!1,this.l00=V.Zero(),this.l1_1=V.Zero(),this.l10=V.Zero(),this.l11=V.Zero(),this.l2_2=V.Zero(),this.l2_1=V.Zero(),this.l20=V.Zero(),this.l21=V.Zero(),this.l22=V.Zero()}return e.prototype.addLight=function(e,t,i){H.Vector3[0].set(t.r,t.g,t.b);var r=H.Vector3[0],n=H.Vector3[1];r.scaleToRef(i,n),n.scaleToRef(bp(0,e),H.Vector3[2]),this.l00.addInPlace(H.Vector3[2]),n.scaleToRef(bp(1,e),H.Vector3[2]),this.l1_1.addInPlace(H.Vector3[2]),n.scaleToRef(bp(2,e),H.Vector3[2]),this.l10.addInPlace(H.Vector3[2]),n.scaleToRef(bp(3,e),H.Vector3[2]),this.l11.addInPlace(H.Vector3[2]),n.scaleToRef(bp(4,e),H.Vector3[2]),this.l2_2.addInPlace(H.Vector3[2]),n.scaleToRef(bp(5,e),H.Vector3[2]),this.l2_1.addInPlace(H.Vector3[2]),n.scaleToRef(bp(6,e),H.Vector3[2]),this.l20.addInPlace(H.Vector3[2]),n.scaleToRef(bp(7,e),H.Vector3[2]),this.l21.addInPlace(H.Vector3[2]),n.scaleToRef(bp(8,e),H.Vector3[2]),this.l22.addInPlace(H.Vector3[2])},e.prototype.scaleInPlace=function(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)},e.prototype.convertIncidentRadianceToIrradiance=function(){this.l00.scaleInPlace(Tp[0]),this.l1_1.scaleInPlace(Tp[1]),this.l10.scaleInPlace(Tp[2]),this.l11.scaleInPlace(Tp[3]),this.l2_2.scaleInPlace(Tp[4]),this.l2_1.scaleInPlace(Tp[5]),this.l20.scaleInPlace(Tp[6]),this.l21.scaleInPlace(Tp[7]),this.l22.scaleInPlace(Tp[8])},e.prototype.convertIrradianceToLambertianRadiance=function(){this.scaleInPlace(1/Math.PI)},e.prototype.preScaleForRendering=function(){this.preScaled=!0,this.l00.scaleInPlace(vp[0]),this.l1_1.scaleInPlace(vp[1]),this.l10.scaleInPlace(vp[2]),this.l11.scaleInPlace(vp[3]),this.l2_2.scaleInPlace(vp[4]),this.l2_1.scaleInPlace(vp[5]),this.l20.scaleInPlace(vp[6]),this.l21.scaleInPlace(vp[7]),this.l22.scaleInPlace(vp[8])},e.prototype.updateFromArray=function(e){return V.FromArrayToRef(e[0],0,this.l00),V.FromArrayToRef(e[1],0,this.l1_1),V.FromArrayToRef(e[2],0,this.l10),V.FromArrayToRef(e[3],0,this.l11),V.FromArrayToRef(e[4],0,this.l2_2),V.FromArrayToRef(e[5],0,this.l2_1),V.FromArrayToRef(e[6],0,this.l20),V.FromArrayToRef(e[7],0,this.l21),V.FromArrayToRef(e[8],0,this.l22),this},e.prototype.updateFromFloatsArray=function(e){return V.FromFloatsToRef(e[0],e[1],e[2],this.l00),V.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),V.FromFloatsToRef(e[6],e[7],e[8],this.l10),V.FromFloatsToRef(e[9],e[10],e[11],this.l11),V.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),V.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),V.FromFloatsToRef(e[18],e[19],e[20],this.l20),V.FromFloatsToRef(e[21],e[22],e[23],this.l21),V.FromFloatsToRef(e[24],e[25],e[26],this.l22),this},e.FromArray=function(t){return(new e).updateFromArray(t)},e.FromPolynomial=function(t){var i=new e;return i.l00=t.xx.scale(.376127).add(t.yy.scale(.376127)).add(t.zz.scale(.376126)),i.l1_1=t.y.scale(.977204),i.l10=t.z.scale(.977204),i.l11=t.x.scale(.977204),i.l2_2=t.xy.scale(1.16538),i.l2_1=t.yz.scale(1.16538),i.l20=t.zz.scale(1.34567).subtract(t.xx.scale(.672834)).subtract(t.yy.scale(.672834)),i.l21=t.zx.scale(1.16538),i.l22=t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)),i.l1_1.scaleInPlace(-1),i.l11.scaleInPlace(-1),i.l2_1.scaleInPlace(-1),i.l21.scaleInPlace(-1),i.scaleInPlace(Math.PI),i},e}(),Sp=function(){function e(){this.x=V.Zero(),this.y=V.Zero(),this.z=V.Zero(),this.xx=V.Zero(),this.yy=V.Zero(),this.zz=V.Zero(),this.xy=V.Zero(),this.yz=V.Zero(),this.zx=V.Zero()}return Object.defineProperty(e.prototype,"preScaledHarmonics",{get:function(){return this._harmonics||(this._harmonics=Ep.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics},enumerable:!1,configurable:!0}),e.prototype.addAmbient=function(e){H.Vector3[0].copyFromFloats(e.r,e.g,e.b);var t=H.Vector3[0];this.xx.addInPlace(t),this.yy.addInPlace(t),this.zz.addInPlace(t)},e.prototype.scaleInPlace=function(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)},e.prototype.updateFromHarmonics=function(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),H.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),H.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(H.Vector3[0]).addInPlace(H.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(H.Vector3[0]).subtractInPlace(H.Vector3[1]),this.zz.copyFrom(e.l00),H.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(H.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this},e.FromHarmonics=function(t){return(new e).updateFromHarmonics(t)},e.FromArray=function(t){var i=new e;return V.FromArrayToRef(t[0],0,i.x),V.FromArrayToRef(t[1],0,i.y),V.FromArrayToRef(t[2],0,i.z),V.FromArrayToRef(t[3],0,i.xx),V.FromArrayToRef(t[4],0,i.yy),V.FromArrayToRef(t[5],0,i.zz),V.FromArrayToRef(t[6],0,i.yz),V.FromArrayToRef(t[7],0,i.zx),V.FromArrayToRef(t[8],0,i.xy),i},e}();li.ShadersStore.rgbdDecodePixelShader="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);}";li.ShadersStore.lodPixelShader="#extension GL_EXT_shader_texture_lod : enable\nprecision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform sampler2D textureSampler;uniform float lod;uniform vec2 texSize;uniform bool gamma;void main(void)\n{gl_FragColor=textureLod(textureSampler,vUV,lod);if (!gamma) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}\n";var xp,Ap;function Cp(e,t,i,r){void 0===r&&(r=!0);var n=e.getScene(),o=n.getEngine(),a=new Pl("resized"+e.name,{width:t,height:i},n,!e.noMipmap,!0,e._texture.type,!1,e.samplingMode,!1);a.wrapU=e.wrapU,a.wrapV=e.wrapV,a.uOffset=e.uOffset,a.vOffset=e.vOffset,a.uScale=e.uScale,a.vScale=e.vScale,a.uAng=e.uAng,a.vAng=e.vAng,a.wAng=e.wAng,a.coordinatesIndex=e.coordinatesIndex,a.level=e.level,a.anisotropicFilteringLevel=e.anisotropicFilteringLevel,a._texture.isReady=!1,e.wrapU=Ja.CLAMP_ADDRESSMODE,e.wrapV=Ja.CLAMP_ADDRESSMODE;var s=new qc("pass",1,null,r?Ja.BILINEAR_SAMPLINGMODE:Ja.NEAREST_SAMPLINGMODE,o,!1,u.TEXTURETYPE_UNSIGNED_INT);return s.externalTextureSamplerBinding=!0,s.getEffect().executeWhenCompiled((function(){s.onApply=function(t){t.setTexture("textureSampler",e)};var t=a.renderTarget;t&&(n.postProcessManager.directRender([s],t),o.unBindFramebuffer(t),a.disposeFramebufferObjects(),s.dispose(),a.getInternalTexture().isReady=!0)})),a}function Rp(e,t,i,r,n,o,a,s){var l=t.getEngine();return t.isReady=!1,n=null!=n?n:t.samplingMode,r=null!=r?r:t.type,o=null!=o?o:t.format,a=null!=a?a:t.width,s=null!=s?s:t.height,-1===r&&(r=u.TEXTURETYPE_UNSIGNED_BYTE),new Promise((function(c){var h=new hl("postprocess",e,null,null,1,null,n,l,!1,void 0,r,void 0,null,!1,o);h.externalTextureSamplerBinding=!0;var d=l.createRenderTargetTexture({width:a,height:s},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:n,type:r,format:o});h.getEffect().executeWhenCompiled((function(){h.onApply=function(e){e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},i.postProcessManager.directRender([h],d,!0),l.restoreDefaultFramebuffer(),l._releaseTexture(t),h&&h.dispose(),d._swapAndDie(t),t.type=r,t.format=u.TEXTUREFORMAT_RGBA,t.isReady=!0,c(t)}))}))}function Pp(e){xp||(xp=new Float32Array(1),Ap=new Int32Array(xp.buffer)),xp[0]=e;var t=Ap[0],i=t>>16&32768,r=t>>12&2047,n=t>>23&255;return n<103?i:n>142?(i|=31744,i|=(255==n?0:1)&&8388607&t):n<113?i|=((r|=2048)>>114-n)+(r>>113-n&1):(i|=n-112<<10|r>>1,i+=1&r)}function Ip(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))}li.ShadersStore.lodCubePixelShader="precision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform samplerCube textureSampler;uniform float lod;uniform bool gamma;void main(void)\n{vec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x),lod);\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x),lod);\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x),lod);\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x),lod);\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001),lod);\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001),lod);\n#endif\nif (!gamma) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}\n";var Mp=function(e,t,i,r,n){return y(void 0,void 0,void 0,(function(){var o,a,s,l,c,u,h,d,p;return b(this,(function(f){switch(f.label){case 0:return o=e.getScene(),a=o.getEngine(),e.isCube?(l=["#define POSITIVEX","#define NEGATIVEX","#define POSITIVEY","#define NEGATIVEY","#define POSITIVEZ","#define NEGATIVEZ"],s=new hl("lodCube","lodCube",["lod","gamma"],null,1,null,Ja.NEAREST_NEAREST_MIPNEAREST,a,!1,l[r])):s=new hl("lod","lod",["lod","gamma"],null,1,null,Ja.NEAREST_NEAREST_MIPNEAREST,a),[4,new Promise((function(e){s.getEffect().executeWhenCompiled((function(){e(0)}))}))];case 1:f.sent(),c=new Pl("temp",{width:t,height:i},o,!1),s.onApply=function(t){t.setTexture("textureSampler",e),t.setFloat("lod",n),t.setBool("gamma",e.gammaSpace)},u=e.getInternalTexture(),f.label=2;case 2:return f.trys.push([2,,6,7]),c.renderTarget&&u?(h=u.samplingMode,0!==n?e.updateSamplingMode(Ja.NEAREST_NEAREST_MIPNEAREST):e.updateSamplingMode(Ja.NEAREST_NEAREST),o.postProcessManager.directRender([s],c.renderTarget,!0),e.updateSamplingMode(h),[4,a.readPixels(0,0,t,i)]):[3,4];case 3:return d=f.sent(),p=new Uint8Array(d.buffer,0,d.byteLength),a.unBindFramebuffer(c.renderTarget),[2,p];case 4:throw Error("Render to texture failed.");case 5:return[3,7];case 6:return c.dispose(),s.dispose(),[7];case 7:return[2]}}))}))};function Op(e,t,i,r,n){return void 0===r&&(r=0),void 0===n&&(n=0),y(this,void 0,void 0,(function(){return b(this,(function(o){switch(o.label){case 0:return e.isReady()||!e._texture?[3,2]:[4,new Promise((function(t,i){null!==e._texture?e._texture.onLoadedObservable.addOnce((function(){t(0)})):i(0)}))];case 1:o.sent(),o.label=2;case 2:return[4,Mp(e,t,i,r,n)];case 3:return[2,o.sent()]}}))}))}var Dp={CreateResizedCopy:Cp,ApplyPostProcess:Rp,ToHalfFloat:Pp,FromHalfFloat:Ip,GetTextureDataAsync:Op},Np=function(){function e(){}return e.ExpandRGBDTexture=function(e){var t=e._texture;if(t&&e.isRGBD){var i=t.getEngine(),r=i.getCaps(),n=t.isReady,o=!1;r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?(o=!0,t.type=u.TEXTURETYPE_HALF_FLOAT):r.textureFloatRender&&r.textureFloatLinearFiltering&&(o=!0,t.type=u.TEXTURETYPE_FLOAT),o&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1);var a=function(){var r=new hl("rgbdDecode","rgbdDecode",null,null,1,null,u.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!1,void 0,t.type,void 0,null,!1);r.externalTextureSamplerBinding=!0;var n=i.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:u.TEXTUREFORMAT_RGBA});r.getEffect().executeWhenCompiled((function(){r.onApply=function(e){e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([r],n,!0),i.restoreDefaultFramebuffer(),i._releaseTexture(t),r&&r.dispose(),n._swapAndDie(t),t.isReady=!0}))};o&&(n?a():e.onLoadObservable.addOnce(a))}},e.EncodeTextureToRGBD=function(e,t,i){return void 0===i&&(i=u.TEXTURETYPE_UNSIGNED_BYTE),Rp("rgbdEncode",e,t,i,u.TEXTURE_NEAREST_SAMPLINGMODE,u.TEXTUREFORMAT_RGBA)},e}(),Fp=function(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r},Lp=function(){function e(){}return e.ConvertCubeMapTextureToSphericalPolynomial=function(e){var t,i=this;if(!e.isCube)return null;null===(t=e.getScene())||void 0===t||t.getEngine().flushFramebuffer();var r,n,o=e.getSize().width,a=e.readPixels(0,void 0,void 0,!1),s=e.readPixels(1,void 0,void 0,!1);e.isRenderTarget?(r=e.readPixels(3,void 0,void 0,!1),n=e.readPixels(2,void 0,void 0,!1)):(r=e.readPixels(2,void 0,void 0,!1),n=e.readPixels(3,void 0,void 0,!1));var l=e.readPixels(4,void 0,void 0,!1),c=e.readPixels(5,void 0,void 0,!1),h=e.gammaSpace,d=u.TEXTUREFORMAT_RGBA,p=u.TEXTURETYPE_UNSIGNED_INT;return e.textureType!=u.TEXTURETYPE_FLOAT&&e.textureType!=u.TEXTURETYPE_HALF_FLOAT||(p=u.TEXTURETYPE_FLOAT),new Promise((function(e){Promise.all([s,a,r,n,l,c]).then((function(t){var r=t[0],n=t[1],a=t[2],s=t[3],l=t[4],c=t[5],u={size:o,right:n,left:r,up:a,down:s,front:l,back:c,format:d,type:p,gammaSpace:h};e(i.ConvertCubeMapToSphericalPolynomial(u))}))}))},e._AreaElement=function(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))},e.ConvertCubeMapToSphericalPolynomial=function(e){for(var t=new Ep,i=0,r=2/e.size,n=r,o=.5*r,a=o-1,s=0;s<6;s++)for(var l=this._FileFaces[s],c=e[l.name],h=a,d=e.format===u.TEXTUREFORMAT_RGBA?4:3,p=0;pT){var x=T/E;v*=x,y*=x,b*=x}}else v=j.Clamp(v,0,T),y=j.Clamp(y,0,T),b=j.Clamp(b,0,T);var A=new Z(v,y,b);t.addLight(m,A,g),i+=g,f+=r}h+=n}var C=4*Math.PI*6/6/i;return t.scaleInPlace(C),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),Sp.FromHarmonics(t)},e._FileFaces=[new Fp("right",new V(1,0,0),new V(0,0,-1),new V(0,-1,0)),new Fp("left",new V(-1,0,0),new V(0,0,1),new V(0,-1,0)),new Fp("up",new V(0,1,0),new V(1,0,0),new V(0,0,1)),new Fp("down",new V(0,-1,0),new V(1,0,0),new V(0,0,-1)),new Fp("front",new V(0,0,1),new V(1,0,0),new V(0,-1,0)),new Fp("back",new V(0,0,-1),new V(-1,0,0),new V(0,-1,0))],e.MAX_HDRI_VALUE=4096,e.PRESERVE_CLAMPED_COLORS=!1,e}();Ya.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)},Object.defineProperty(Ya.prototype,"sphericalPolynomial",{get:function(){var e=this;if(this._texture){if(this._texture._sphericalPolynomial||this._texture._sphericalPolynomialComputed)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomialPromise||(this._texture._sphericalPolynomialPromise=Lp.ConvertCubeMapTextureToSphericalPolynomial(this),null===this._texture._sphericalPolynomialPromise?this._texture._sphericalPolynomialComputed=!0:this._texture._sphericalPolynomialPromise.then((function(t){e._texture._sphericalPolynomial=t,e._texture._sphericalPolynomialComputed=!0}))),null}return null},set:function(e){this._texture&&(this._texture._sphericalPolynomial=e)},enumerable:!0,configurable:!0});li.ShadersStore.rgbdEncodePixelShader="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}";var wp="image/png",Bp=2,Up=[134,22,135,150,246,214,150,54];function Vp(e){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0,r=0;rBp)throw new Error('Unsupported babylon environment map version "'.concat(e.version,'". Latest supported version is "').concat(Bp,'".'));return 2===e.version?e:e=g(g({},e),{version:2,imageType:wp})}function Gp(e,t){var i,r;return void 0===t&&(t={}),y(this,void 0,void 0,(function(){var n,o,a,s,l,c,h,d,p,f,_,m,g,v,y,T,E,S,x,A,C,R,P,I,M,O,D,N,F,L,w,B,U;return b(this,(function(b){switch(b.label){case 0:if(!(n=e.getInternalTexture()))return[2,Promise.reject("The cube texture is invalid.")];if(o=null!==(i=t.imageType)&&void 0!==i?i:wp,a=n.getEngine(),e.textureType!==u.TEXTURETYPE_HALF_FLOAT&&e.textureType!==u.TEXTURETYPE_FLOAT&&e.textureType!==u.TEXTURETYPE_UNSIGNED_BYTE&&e.textureType!==u.TEXTURETYPE_UNSIGNED_INT&&e.textureType!==u.TEXTURETYPE_UNSIGNED_INTEGER&&-1!==e.textureType)return[2,Promise.reject("The cube texture should allow HDR (Full Float or Half Float).")];if(s=u.TEXTURETYPE_FLOAT,!a.getCaps().textureFloatRender&&(s=u.TEXTURETYPE_HALF_FLOAT,!a.getCaps().textureHalfFloatRender))return[2,Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];e.sphericalPolynomial,l=null===(r=e.getInternalTexture())||void 0===r?void 0:r._sphericalPolynomialPromise,c=n.width,h=new pn(a),d={},a.flushFramebuffer(),p=j.ILog2(n.width),w=0,b.label=1;case 1:if(!(w<=p))return[3,9];f=Math.pow(2,p-w),B=0,b.label=2;case 2:return B<6?[4,e.readPixels(B,w,void 0,!1)]:[3,8];case 3:if((_=b.sent())&&_.byteLength===_.length){for(m=new Float32Array(4*_.byteLength),g=0;g<_.byteLength;g++)m[g]=_[g]/255,m[g]=Math.pow(m[g],2.2);_=m}else if(_&&e.gammaSpace)for(v=_,y=0;y=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||95==t}function $p(e){for(var t=0,i="",r=!1,n=[];t=0&&e.charAt(t)!==i&&(!r||e.charAt(t)!==r);)t--;return t}var tf=function(){function e(e,t){void 0===t&&(t=20),this.debug=!1,this._sourceCode=e,this._numMaxIterations=t,this._functionDescr=[],this.inlineToken="#define inline"}return Object.defineProperty(e.prototype,"code",{get:function(){return this._sourceCode},enumerable:!1,configurable:!0}),e.prototype.processCode=function(){this.debug&&ae.Log("Start inlining process (code size=".concat(this._sourceCode.length,")...")),this._collectFunctions(),this._processInlining(this._numMaxIterations),this.debug&&ae.Log("End of inlining process.")},e.prototype._collectFunctions=function(){for(var t,i=0;i=0&&f.push(m.substring(g+1))}"void"!==a&&f.push("return"),this._functionDescr.push({name:s,type:a,parameters:f,body:d,callIndex:0}),i=h+1;var v=r>0?this._sourceCode.substring(0,r):"",y=h+1=0},e.prototype._replaceFunctionCallsByCode=function(){for(var e=!1,t=0,i=this._functionDescr;t0?this._sourceCode.substring(0,c):"",b=h+1=0){var l=o[a],c=null;if(n&&(c=n[l]),c||(c=t[l]),c){var u=c.getBuffer();u&&u.nativeVertexBuffer&&this._engine.recordVertexBuffer(e,u.nativeVertexBuffer,s,c.byteOffset,c.byteStride,c.getSize(),cf(c.type),c.normalized,c.getInstanceDivisor())}}}},t.prototype.bindBuffers=function(e,t,i){this._boundBuffersVertexArray&&this._deleteVertexArray(this._boundBuffersVertexArray),this._boundBuffersVertexArray=this._engine.createVertexArray(),this._recordVertexArrayObject(this._boundBuffersVertexArray,e,t,i),this.bindVertexArrayObject(this._boundBuffersVertexArray)},t.prototype.recordVertexArrayObject=function(e,t,i,r){var n=this._engine.createVertexArray();return this._recordVertexArrayObject(n,e,t,i,r),n},t.prototype._deleteVertexArray=function(e){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.bindVertexArrayObject=function(e){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.releaseVertexArrayObject=function(e){this._deleteVertexArray(e)},t.prototype.getAttributes=function(e,t){var i=e;return this._engine.getAttributes(i.program,t)},t.prototype.drawElementsType=function(e,t,i,r){this._drawCalls.addCount(1,!1),r&&_native.Engine.COMMAND_DRAWINDEXEDINSTANCED?(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXEDINSTANCED),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.encodeCommandArgAsUInt32(r)):(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(i)),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.drawArraysType=function(e,t,i,r){this._drawCalls.addCount(1,!1),r&&_native.Engine.COMMAND_DRAWINSTANCED?(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINSTANCED),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.encodeCommandArgAsUInt32(r)):(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(i)),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.createPipelineContext=function(){var e=!(!this._caps.parallelShaderCompile||!this._engine.createProgramAsync);return new rf(this,e)},t.prototype.createMaterialContext=function(){},t.prototype.createDrawContext=function(){},t.prototype._preparePipelineContext=function(e,t,i,r,n,o,a,s){r?this.createRawShaderProgram():this.createShaderProgram(e,t,i,s)},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var i=e;if(i.isAsync)if(i.onCompiled){var r=i.onCompiled;i.onCompiled=function(){r(),t()}}else i.onCompiled=t;else t()},t.prototype.createRawShaderProgram=function(){throw new Error("Not Supported")},t.prototype.createShaderProgram=function(e,t,i,r){var n=this,o=e;this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=new tf(t);a.processCode(),t=a.code;var s=new tf(i);s.processCode(),i=s.code,t=Er._ConcatenateShader(t,r),i=Er._ConcatenateShader(i,r);var l=function(){var e;o.isCompiled=!0,null===(e=o.onCompiled)||void 0===e||e.call(o),n.onAfterShaderCompilationObservable.notifyObservers(n)};if(e.isAsync)o.program=this._engine.createProgramAsync(t,i,l,(function(e){o.compilationError=e}));else try{o.program=this._engine.createProgram(t,i),l()}catch(e){var c=null==e?void 0:e.message;throw new Error("SHADER ERROR"+("string"==typeof c?"\n"+c:""))}return o.program},t.prototype.inlineShaderCode=function(e){var t=new tf(e);return t.debug=!1,t.processCode(),t.code},t.prototype._setProgram=function(e){this._currentProgram!==e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand(),this._currentProgram=e)},t.prototype._deletePipelineContext=function(e){var t=e;t&&t.program&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),this._commandBufferEncoder.encodeCommandArgAsNativeData(t.program),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.getUniforms=function(e,t){var i=e;return this._engine.getUniforms(i.program,t)},t.prototype.bindUniformBlock=function(e,t,i){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.program);for(var i=e.getSamplers(),r=0;r-1?e.substring(T).toLowerCase():""),S=null,x=0,A=Mi._TextureLoaders;x-1?e.substring(g).toLowerCase():""))){if(i&&6===i.length)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,(function(e){!function(e){var t=Vp(e);m.width=t.width,m.height=t.width,Yp(m,t);var i=t.specular;if(!i)throw new Error("Nothing else parsed so far");m._lodGenerationScale=i.lodGenerationScale;var r=Wp(e,t);m.format=u.TEXTUREFORMAT_RGBA,m.type=u.TEXTURETYPE_UNSIGNED_INT,m.generateMipMaps=!0,m.getEngine().updateTextureSamplingMode(Ja.TRILINEAR_SAMPLINGMODE,m),m._isRGBD=!0,m.invertY=!0,_._engine.loadCubeTextureWithMips(m._hardwareTexture.underlyingResource,r,!1,m._useSRGBBuffer,(function(){m.isReady=!0,n&&n()}),(function(){throw new Error("Could not load a native cube texture.")}))}(new Uint8Array(e,0,e.byteLength))}),void 0,void 0,!0,(function(e,t){o&&e&&o(e.status+" "+e.statusText,t)}))}else{if(!i||6!==i.length)throw new Error("Cannot load cubemap because 6 files were not defined");var v=[i[0],i[3],i[1],i[4],i[2],i[5]];Promise.all(v.map((function(e){return _._loadFileAsync(e,void 0,!0).then((function(e){return new Uint8Array(e,0,e.byteLength)}))}))).then((function(e){return new Promise((function(t,i){_._engine.loadCubeTexture(m._hardwareTexture.underlyingResource,e,!r,!0,m._useSRGBBuffer,t,i)}))})).then((function(){m.isReady=!0,n&&n()}),(function(e){o&&o("Failed to load cubemap: ".concat(e.message),e)}))}return this._internalTexturesCache.push(m),m},t.prototype._createHardwareTexture=function(){return new of(this._createTexture(),this._engine)},t.prototype._createHardwareRenderTargetWrapper=function(e,t,i){var r=new nf(e,t,i,this);return this._renderTargetWrapperCache.push(r),r},t.prototype._createInternalTexture=function(e,t,i,r){var n,o,a;void 0===i&&(i=!0),void 0===r&&(r=Ti.Unknown);var s,l=!1,c=u.TEXTURETYPE_UNSIGNED_INT,h=u.TEXTURE_TRILINEAR_SAMPLINGMODE,d=u.TEXTUREFORMAT_RGBA,p=!1,f=1;void 0!==t&&"object"==typeof t?(l=!!t.generateMipMaps,c=void 0===t.type?u.TEXTURETYPE_UNSIGNED_INT:t.type,h=void 0===t.samplingMode?u.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,d=void 0===t.format?u.TEXTUREFORMAT_RGBA:t.format,p=void 0!==t.useSRGBBuffer&&t.useSRGBBuffer,f=null!==(n=t.samples)&&void 0!==n?n:1,s=t.label):l=!!t,p=this._getUseSRGBBuffer(p,!l),(c!==u.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(c!==u.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(h=u.TEXTURE_NEAREST_SAMPLINGMODE),c!==u.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c=u.TEXTURETYPE_UNSIGNED_INT,ae.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));var _=new Pi(this,r),m=null!==(o=e.width)&&void 0!==o?o:e,g=null!==(a=e.height)&&void 0!==a?a:e,v=e.layers||0;if(0!==v)throw new Error("Texture layers are not supported in Babylon Native");var y=_._hardwareTexture.underlyingResource,b=af(d,c);return this._engine.initializeTexture(y,m,g,l,b,!0,p,f),this._setTextureSampling(y,sf(h)),_._useSRGBBuffer=p,_.baseWidth=m,_.baseHeight=g,_.width=m,_.height=g,_.depth=v,_.isReady=!0,_.samples=f,_.generateMipMaps=l,_.samplingMode=h,_.type=c,_.format=d,_.label=s,this._internalTexturesCache.push(_),_},t.prototype.createRenderTargetTexture=function(e,t){var i,r,n,o,a=this._createHardwareRenderTargetWrapper(!1,!1,e),s=!0,l=!1,c=!1,u=void 0,h=1;void 0!==t&&"object"==typeof t&&(s=null===(i=t.generateDepthBuffer)||void 0===i||i,l=!!t.generateStencilBuffer,c=!!t.noColorAttachment,u=t.colorAttachment,h=null!==(r=t.samples)&&void 0!==r?r:1);var d=u||(c?null:this._createInternalTexture(e,t,!0,Ti.RenderTarget)),p=null!==(n=e.width)&&void 0!==n?n:e,f=null!==(o=e.height)&&void 0!==o?o:e,_=this._engine.createFrameBuffer(d?d._hardwareTexture.underlyingResource:null,p,f,l,s,h);return a._framebuffer=_,a._generateDepthBuffer=s,a._generateStencilBuffer=l,a._samples=h,a.setTextures(d),a},t.prototype.updateRenderTargetTextureSampleCount=function(e,t){return ae.Warn("Updating render target sample count is not currently supported"),e.samples},t.prototype.updateTextureSamplingMode=function(e,t){if(t._hardwareTexture){var i=sf(e);this._setTextureSampling(t._hardwareTexture.underlyingResource,i)}t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,i,r,n){var o=e;if(this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,t)throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");if(i||r)throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");o._framebufferDepthStencil?this._bindUnboundFramebuffer(o._framebufferDepthStencil):this._bindUnboundFramebuffer(o._framebuffer)},t.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&i(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){return this.createVertexBuffer(e,!0)},t.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0);var r=e,n=this._normalizeIndexData(t);r.is32Bits=4===n.BYTES_PER_ELEMENT,this._engine.updateDynamicIndexBuffer(r.nativeIndexBuffer,n.buffer,n.byteOffset,n.byteLength,i)},t.prototype.updateDynamicVertexBuffer=function(e,t,i,r){void 0===i&&(i=0);var n=e,o=t instanceof Array?new Float32Array(t):t instanceof ArrayBuffer?new Uint8Array(t):t,a=new Uint8Array(o.buffer,o.byteOffset,null!=r?r:o.byteLength);this._engine.updateDynamicVertexBuffer(n.nativeVertexBuffer,a.buffer,a.byteOffset,a.byteLength,i)},t.prototype._setTexture=function(e,t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n,o=this._boundUniforms[e];if(!o)return!1;if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._boundTexturesCache[e]=null),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===u.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;return n=r?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,this._activeChannel=e,!(!n||!n._hardwareTexture||(this._setTextureWrapMode(n._hardwareTexture.underlyingResource,lf(t.wrapU),lf(t.wrapV),lf(t.wrapR)),this._updateAnisotropicLevel(t),this._setTextureCore(o,n._hardwareTexture.underlyingResource),0))},t.prototype._setTextureSampling=function(e,t){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._setTextureWrapMode=function(e,t,i,r){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.encodeCommandArgAsUInt32(r),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._setTextureCore=function(e,t){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsNativeData(t),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._updateAnisotropicLevel=function(e){var t=e.getInternalTexture(),i=e.anisotropicFilteringLevel;t&&t._hardwareTexture&&t._cachedAnisotropicFilteringLevel!==i&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL),this._commandBufferEncoder.encodeCommandArgAsNativeData(t._hardwareTexture.underlyingResource),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.finishEncodingCommand(),t._cachedAnisotropicFilteringLevel=i)},t.prototype._bindTexture=function(e,t){var i=this._boundUniforms[e];if(i&&t&&t._hardwareTexture){var r=t._hardwareTexture.underlyingResource;this._setTextureCore(i,r)}},t.prototype._deleteBuffer=function(e){e.nativeIndexBuffer&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeIndexBuffer),this._commandBufferEncoder.finishEncodingCommand(),delete e.nativeIndexBuffer),e.nativeVertexBuffer&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeVertexBuffer),this._commandBufferEncoder.finishEncodingCommand(),delete e.nativeVertexBuffer)},t.prototype.createCanvas=function(e,t){if(!_native.Canvas)throw new Error("Native Canvas plugin not available.");var i=new _native.Canvas;return i.width=e,i.height=t,i},t.prototype.createCanvasImage=function(){if(!_native.Canvas)throw new Error("Native Canvas plugin not available.");return new _native.Image},t.prototype.updateTextureData=function(e,t,i,r,n,o,a,s,l){throw void 0===a&&(a=0),void 0===s&&(s=0),void 0===l&&(l=!1),new Error("updateTextureData not implemented.")},t.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,a){throw void 0===o&&(o=0),void 0===a&&(a=0),new Error("_uploadCompressedDataToTextureDirectly not implemented.")},t.prototype._uploadDataToTextureDirectly=function(e,t,i,r){throw void 0===i&&(i=0),void 0===r&&(r=0),new Error("_uploadDataToTextureDirectly not implemented.")},t.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){throw void 0===i&&(i=0),void 0===r&&(r=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._uploadImageToTexture=function(e,t,i,r){throw void 0===i&&(i=0),void 0===r&&(r=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype.getFontOffset=function(e){return{ascent:0,height:0,descent:0}},t.prototype.flushFramebuffer=function(){},t.prototype._readTexturePixels=function(e,t,i,r,n,o,a,s,l,c){var u,h,d,p;if(void 0!==r&&-1!==r)throw new Error("Reading cubemap faces is not supported, but faceIndex is ".concat(r,"."));return this._engine.readTexture(null===(u=e._hardwareTexture)||void 0===u?void 0:u.underlyingResource,null!=n?n:0,null!=l?l:0,null!=c?c:0,t,i,null!==(h=null==o?void 0:o.buffer)&&void 0!==h?h:null,null!==(d=null==o?void 0:o.byteOffset)&&void 0!==d?d:0,null!==(p=null==o?void 0:o.byteLength)&&void 0!==p?p:0).then((function(e){return o||(o=new Uint8Array(e)),o}))},t.PROTOCOL_VERSION=8,t}(Do);mf._createNativeDataStream=function(){return _native.NativeDataStream.VALIDATION_ENABLED?new r_:new gp};var gf,vf,yf,bf,Tf,Ef,Sf,xf,Af,Cf,Rf,Pf,If,Mf,Of,Df,Nf,Ff,Lf,wf,Bf,Uf,Vf,kf,Gf,zf,Wf,Hf,Xf,jf,Yf,Kf,Qf,qf,Zf,Jf,$f,e_,t_,i_,r_=function(e){function t(){return e.call(this)||this}return m(t,e),t.prototype.writeUint32=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_UINT_32),e.prototype.writeUint32.call(this,t)},t.prototype.writeInt32=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_INT_32),e.prototype.writeInt32.call(this,t)},t.prototype.writeFloat32=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_FLOAT_32),e.prototype.writeFloat32.call(this,t)},t.prototype.writeUint32Array=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_UINT_32_ARRAY),e.prototype.writeUint32Array.call(this,t)},t.prototype.writeInt32Array=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_INT_32_ARRAY),e.prototype.writeInt32Array.call(this,t)},t.prototype.writeFloat32Array=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY),e.prototype.writeFloat32Array.call(this,t)},t.prototype.writeNativeData=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_NATIVE_DATA),e.prototype.writeNativeData.call(this,t)},t.prototype.writeBoolean=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_BOOLEAN),e.prototype.writeBoolean.call(this,t)},t}(gp);!function(e){e.LowPower="low-power",e.HighPerformance="high-performance"}(gf||(gf={})),function(e){e.DepthClipControl="depth-clip-control",e.Depth32FloatStencil8="depth32float-stencil8",e.TextureCompressionBC="texture-compression-bc",e.TextureCompressionETC2="texture-compression-etc2",e.TextureCompressionASTC="texture-compression-astc",e.TimestampQuery="timestamp-query",e.IndirectFirstInstance="indirect-first-instance",e.ShaderF16="shader-f16",e.RG11B10UFloatRenderable="rg11b10ufloat-renderable",e.BGRA8UnormStorage="bgra8unorm-storage",e.Float32Filterable="float32-filterable"}(vf||(vf={})),function(e){e.Unmapped="unmapped",e.Pending="pending",e.Mapped="mapped"}(yf||(yf={})),function(e){e[e.MapRead=1]="MapRead",e[e.MapWrite=2]="MapWrite",e[e.CopySrc=4]="CopySrc",e[e.CopyDst=8]="CopyDst",e[e.Index=16]="Index",e[e.Vertex=32]="Vertex",e[e.Uniform=64]="Uniform",e[e.Storage=128]="Storage",e[e.Indirect=256]="Indirect",e[e.QueryResolve=512]="QueryResolve"}(bf||(bf={})),function(e){e[e.Read=1]="Read",e[e.Write=2]="Write"}(Tf||(Tf={})),function(e){e.E1d="1d",e.E2d="2d",e.E3d="3d"}(Ef||(Ef={})),function(e){e[e.CopySrc=1]="CopySrc",e[e.CopyDst=2]="CopyDst",e[e.TextureBinding=4]="TextureBinding",e[e.StorageBinding=8]="StorageBinding",e[e.RenderAttachment=16]="RenderAttachment"}(Sf||(Sf={})),function(e){e.E1d="1d",e.E2d="2d",e.E2dArray="2d-array",e.Cube="cube",e.CubeArray="cube-array",e.E3d="3d"}(xf||(xf={})),function(e){e.All="all",e.StencilOnly="stencil-only",e.DepthOnly="depth-only"}(Af||(Af={})),function(e){e.R8Unorm="r8unorm",e.R8Snorm="r8snorm",e.R8Uint="r8uint",e.R8Sint="r8sint",e.R16Uint="r16uint",e.R16Sint="r16sint",e.R16Float="r16float",e.RG8Unorm="rg8unorm",e.RG8Snorm="rg8snorm",e.RG8Uint="rg8uint",e.RG8Sint="rg8sint",e.R32Uint="r32uint",e.R32Sint="r32sint",e.R32Float="r32float",e.RG16Uint="rg16uint",e.RG16Sint="rg16sint",e.RG16Float="rg16float",e.RGBA8Unorm="rgba8unorm",e.RGBA8UnormSRGB="rgba8unorm-srgb",e.RGBA8Snorm="rgba8snorm",e.RGBA8Uint="rgba8uint",e.RGBA8Sint="rgba8sint",e.BGRA8Unorm="bgra8unorm",e.BGRA8UnormSRGB="bgra8unorm-srgb",e.RGB9E5UFloat="rgb9e5ufloat",e.RGB10A2UINT="rgb10a2uint",e.RGB10A2Unorm="rgb10a2unorm",e.RG11B10UFloat="rg11b10ufloat",e.RG32Uint="rg32uint",e.RG32Sint="rg32sint",e.RG32Float="rg32float",e.RGBA16Uint="rgba16uint",e.RGBA16Sint="rgba16sint",e.RGBA16Float="rgba16float",e.RGBA32Uint="rgba32uint",e.RGBA32Sint="rgba32sint",e.RGBA32Float="rgba32float",e.Stencil8="stencil8",e.Depth16Unorm="depth16unorm",e.Depth24Plus="depth24plus",e.Depth24PlusStencil8="depth24plus-stencil8",e.Depth32Float="depth32float",e.BC1RGBAUnorm="bc1-rgba-unorm",e.BC1RGBAUnormSRGB="bc1-rgba-unorm-srgb",e.BC2RGBAUnorm="bc2-rgba-unorm",e.BC2RGBAUnormSRGB="bc2-rgba-unorm-srgb",e.BC3RGBAUnorm="bc3-rgba-unorm",e.BC3RGBAUnormSRGB="bc3-rgba-unorm-srgb",e.BC4RUnorm="bc4-r-unorm",e.BC4RSnorm="bc4-r-snorm",e.BC5RGUnorm="bc5-rg-unorm",e.BC5RGSnorm="bc5-rg-snorm",e.BC6HRGBUFloat="bc6h-rgb-ufloat",e.BC6HRGBFloat="bc6h-rgb-float",e.BC7RGBAUnorm="bc7-rgba-unorm",e.BC7RGBAUnormSRGB="bc7-rgba-unorm-srgb",e.ETC2RGB8Unorm="etc2-rgb8unorm",e.ETC2RGB8UnormSRGB="etc2-rgb8unorm-srgb",e.ETC2RGB8A1Unorm="etc2-rgb8a1unorm",e.ETC2RGB8A1UnormSRGB="etc2-rgb8a1unorm-srgb",e.ETC2RGBA8Unorm="etc2-rgba8unorm",e.ETC2RGBA8UnormSRGB="etc2-rgba8unorm-srgb",e.EACR11Unorm="eac-r11unorm",e.EACR11Snorm="eac-r11snorm",e.EACRG11Unorm="eac-rg11unorm",e.EACRG11Snorm="eac-rg11snorm",e.ASTC4x4Unorm="astc-4x4-unorm",e.ASTC4x4UnormSRGB="astc-4x4-unorm-srgb",e.ASTC5x4Unorm="astc-5x4-unorm",e.ASTC5x4UnormSRGB="astc-5x4-unorm-srgb",e.ASTC5x5Unorm="astc-5x5-unorm",e.ASTC5x5UnormSRGB="astc-5x5-unorm-srgb",e.ASTC6x5Unorm="astc-6x5-unorm",e.ASTC6x5UnormSRGB="astc-6x5-unorm-srgb",e.ASTC6x6Unorm="astc-6x6-unorm",e.ASTC6x6UnormSRGB="astc-6x6-unorm-srgb",e.ASTC8x5Unorm="astc-8x5-unorm",e.ASTC8x5UnormSRGB="astc-8x5-unorm-srgb",e.ASTC8x6Unorm="astc-8x6-unorm",e.ASTC8x6UnormSRGB="astc-8x6-unorm-srgb",e.ASTC8x8Unorm="astc-8x8-unorm",e.ASTC8x8UnormSRGB="astc-8x8-unorm-srgb",e.ASTC10x5Unorm="astc-10x5-unorm",e.ASTC10x5UnormSRGB="astc-10x5-unorm-srgb",e.ASTC10x6Unorm="astc-10x6-unorm",e.ASTC10x6UnormSRGB="astc-10x6-unorm-srgb",e.ASTC10x8Unorm="astc-10x8-unorm",e.ASTC10x8UnormSRGB="astc-10x8-unorm-srgb",e.ASTC10x10Unorm="astc-10x10-unorm",e.ASTC10x10UnormSRGB="astc-10x10-unorm-srgb",e.ASTC12x10Unorm="astc-12x10-unorm",e.ASTC12x10UnormSRGB="astc-12x10-unorm-srgb",e.ASTC12x12Unorm="astc-12x12-unorm",e.ASTC12x12UnormSRGB="astc-12x12-unorm-srgb",e.Depth32FloatStencil8="depth32float-stencil8"}(Cf||(Cf={})),function(e){e.ClampToEdge="clamp-to-edge",e.Repeat="repeat",e.MirrorRepeat="mirror-repeat"}(Rf||(Rf={})),function(e){e.Nearest="nearest",e.Linear="linear"}(Pf||(Pf={})),function(e){e.Nearest="nearest",e.Linear="linear"}(If||(If={})),function(e){e.Never="never",e.Less="less",e.Equal="equal",e.LessEqual="less-equal",e.Greater="greater",e.NotEqual="not-equal",e.GreaterEqual="greater-equal",e.Always="always"}(Mf||(Mf={})),function(e){e[e.Vertex=1]="Vertex",e[e.Fragment=2]="Fragment",e[e.Compute=4]="Compute"}(Of||(Of={})),function(e){e.Uniform="uniform",e.Storage="storage",e.ReadOnlyStorage="read-only-storage"}(Df||(Df={})),function(e){e.Filtering="filtering",e.NonFiltering="non-filtering",e.Comparison="comparison"}(Nf||(Nf={})),function(e){e.Float="float",e.UnfilterableFloat="unfilterable-float",e.Depth="depth",e.Sint="sint",e.Uint="uint"}(Ff||(Ff={})),function(e){e.WriteOnly="write-only",e.ReadOnly="read-only",e.ReadWrite="read-write"}(Lf||(Lf={})),function(e){e.Error="error",e.Warning="warning",e.Info="info"}(wf||(wf={})),function(e){e.Validation="validation",e.Internal="internal"}(Bf||(Bf={})),function(e){e.Auto="auto"}(Uf||(Uf={})),function(e){e.PointList="point-list",e.LineList="line-list",e.LineStrip="line-strip",e.TriangleList="triangle-list",e.TriangleStrip="triangle-strip"}(Vf||(Vf={})),function(e){e.CCW="ccw",e.CW="cw"}(kf||(kf={})),function(e){e.None="none",e.Front="front",e.Back="back"}(Gf||(Gf={})),function(e){e[e.Red=1]="Red",e[e.Green=2]="Green",e[e.Blue=4]="Blue",e[e.Alpha=8]="Alpha",e[e.All=15]="All"}(zf||(zf={})),function(e){e.Zero="zero",e.One="one",e.Src="src",e.OneMinusSrc="one-minus-src",e.SrcAlpha="src-alpha",e.OneMinusSrcAlpha="one-minus-src-alpha",e.Dst="dst",e.OneMinusDst="one-minus-dst",e.DstAlpha="dst-alpha",e.OneMinusDstAlpha="one-minus-dst-alpha",e.SrcAlphaSaturated="src-alpha-saturated",e.Constant="constant",e.OneMinusConstant="one-minus-constant"}(Wf||(Wf={})),function(e){e.Add="add",e.Subtract="subtract",e.ReverseSubtract="reverse-subtract",e.Min="min",e.Max="max"}(Hf||(Hf={})),function(e){e.Keep="keep",e.Zero="zero",e.Replace="replace",e.Invert="invert",e.IncrementClamp="increment-clamp",e.DecrementClamp="decrement-clamp",e.IncrementWrap="increment-wrap",e.DecrementWrap="decrement-wrap"}(Xf||(Xf={})),function(e){e.Uint16="uint16",e.Uint32="uint32"}(jf||(jf={})),function(e){e.Uint8x2="uint8x2",e.Uint8x4="uint8x4",e.Sint8x2="sint8x2",e.Sint8x4="sint8x4",e.Unorm8x2="unorm8x2",e.Unorm8x4="unorm8x4",e.Snorm8x2="snorm8x2",e.Snorm8x4="snorm8x4",e.Uint16x2="uint16x2",e.Uint16x4="uint16x4",e.Sint16x2="sint16x2",e.Sint16x4="sint16x4",e.Unorm16x2="unorm16x2",e.Unorm16x4="unorm16x4",e.Snorm16x2="snorm16x2",e.Snorm16x4="snorm16x4",e.Float16x2="float16x2",e.Float16x4="float16x4",e.Float32="float32",e.Float32x2="float32x2",e.Float32x3="float32x3",e.Float32x4="float32x4",e.Uint32="uint32",e.Uint32x2="uint32x2",e.Uint32x3="uint32x3",e.Uint32x4="uint32x4",e.Sint32="sint32",e.Sint32x2="sint32x2",e.Sint32x3="sint32x3",e.Sint32x4="sint32x4",e.UNORM10x10x10x2="unorm10-10-10-2"}(Yf||(Yf={})),function(e){e.Vertex="vertex",e.Instance="instance"}(Kf||(Kf={})),function(e){e.Beginning="beginning",e.End="end"}(Qf||(Qf={})),function(e){e.Beginning="beginning",e.End="end"}(qf||(qf={})),function(e){e.Load="load",e.Clear="clear"}(Zf||(Zf={})),function(e){e.Store="store",e.Discard="discard"}(Jf||(Jf={})),function(e){e.Occlusion="occlusion",e.Timestamp="timestamp"}($f||($f={})),function(e){e.Opaque="opaque",e.Premultiplied="premultiplied"}(e_||(e_={})),function(e){e.Unknown="unknown",e.Destroyed="destroyed"}(t_||(t_={})),function(e){e.Validation="validation",e.OutOfMemory="out-of-memory",e.Internal="internal"}(i_||(i_={}));var n_=function(){function e(){this.shaderLanguage=pt.GLSL,this.vertexBufferKindToNumberOfComponents={}}return e.prototype._addUniformToLeftOverUBO=function(e,t,i){var r,n;e=(r=this._getArraySize(e,t,i))[0],t=r[1],n=r[2];for(var o=0;o=0&&(m.push(a[c]),g.push(v))}this.shaderProcessingContext.attributeNamesFromEffect=m,this.shaderProcessingContext.attributeLocationsFromEffect=g},e.prototype.buildUniformLayout=function(){if(this.shaderProcessingContext.leftOverUniforms.length){this.uniformBuffer=new Or(this.engine,void 0,void 0,"leftOver-"+this._name);for(var e=0,t=this.shaderProcessingContext.leftOverUniforms;e)?$/,"$1"),n=n_.UniformSizes[r];this.uniformBuffer.addUniform(i.name,n,i.length),this._leftOverUniformsByName[i.name]=i.type}this.uniformBuffer.create()}},e.prototype.setEngine=function(e){this.engine=e},e.prototype.dispose=function(){this.uniformBuffer&&this.uniformBuffer.dispose()},e.prototype.setInt=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt(e,t)},e.prototype.setInt2=function(e,t,i){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt2(e,t,i)},e.prototype.setInt3=function(e,t,i,r){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt3(e,t,i,r)},e.prototype.setInt4=function(e,t,i,r,n){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt4(e,t,i,r,n)},e.prototype.setIntArray=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateIntArray(e,t)},e.prototype.setIntArray2=function(e,t){this.setIntArray(e,t)},e.prototype.setIntArray3=function(e,t){this.setIntArray(e,t)},e.prototype.setIntArray4=function(e,t){this.setIntArray(e,t)},e.prototype.setUInt=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateUInt(e,t)},e.prototype.setUInt2=function(e,t,i){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateUInt2(e,t,i)},e.prototype.setUInt3=function(e,t,i,r){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateUInt3(e,t,i,r)},e.prototype.setUInt4=function(e,t,i,r,n){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateUInt4(e,t,i,r,n)},e.prototype.setUIntArray=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateUIntArray(e,t)},e.prototype.setUIntArray2=function(e,t){this.setUIntArray(e,t)},e.prototype.setUIntArray3=function(e,t){this.setUIntArray(e,t)},e.prototype.setUIntArray4=function(e,t){this.setUIntArray(e,t)},e.prototype.setArray=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateArray(e,t)},e.prototype.setArray2=function(e,t){this.setArray(e,t)},e.prototype.setArray3=function(e,t){this.setArray(e,t)},e.prototype.setArray4=function(e,t){this.setArray(e,t)},e.prototype.setMatrices=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrices(e,t)},e.prototype.setMatrix=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrix(e,t)},e.prototype.setMatrix3x3=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrix3x3(e,t)},e.prototype.setMatrix2x2=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrix2x2(e,t)},e.prototype.setFloat=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat(e,t)},e.prototype.setVector2=function(e,t){this.setFloat2(e,t.x,t.y)},e.prototype.setFloat2=function(e,t,i){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat2(e,t,i)},e.prototype.setVector3=function(e,t){this.setFloat3(e,t.x,t.y,t.z)},e.prototype.setFloat3=function(e,t,i,r){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat3(e,t,i,r)},e.prototype.setVector4=function(e,t){this.setFloat4(e,t.x,t.y,t.z,t.w)},e.prototype.setQuaternion=function(e,t){this.setFloat4(e,t.x,t.y,t.z,t.w)},e.prototype.setFloat4=function(e,t,i,r,n){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat4(e,t,i,r,n)},e.prototype.setColor3=function(e,t){this.setFloat3(e,t.r,t.g,t.b)},e.prototype.setColor4=function(e,t,i){this.setFloat4(e,t.r,t.g,t.b,i)},e.prototype.setDirectColor4=function(e,t){this.setFloat4(e,t.r,t.g,t.b,t.a)},e.prototype._getVertexShaderCode=function(){var e;return null===(e=this.sources)||void 0===e?void 0:e.vertex},e.prototype._getFragmentShaderCode=function(){var e;return null===(e=this.sources)||void 0===e?void 0:e.fragment},e}(),a_={mat2:2,mat3:3,mat4:4,mat2x2:2,mat3x3:3,mat4x4:4},s_=function(){function e(e){this.shaderLanguage=e,this._attributeNextLocation=0,this._varyingNextLocation=0,this.freeGroupIndex=0,this.freeBindingIndex=0,this.availableVaryings={},this.availableAttributes={},this.availableBuffers={},this.availableTextures={},this.availableSamplers={},this.orderedAttributes=[],this.bindGroupLayoutEntries=[],this.bindGroupLayoutEntryInfo=[],this.bindGroupEntries=[],this.bufferNames=[],this.textureNames=[],this.samplerNames=[],this.leftOverUniforms=[],this._findStartingGroupBinding()}return Object.defineProperty(e,"KnownUBOs",{get:function(){return e._SimplifiedKnownBindings?e._SimplifiedKnownUBOs:e._KnownUBOs},enumerable:!1,configurable:!0}),e.prototype._findStartingGroupBinding=function(){var t=e.KnownUBOs,i=[];for(var r in t){var n=t[r].binding;-1!==n.groupIndex&&(void 0===i[n.groupIndex]?i[n.groupIndex]=n.bindingIndex:i[n.groupIndex]=Math.max(i[n.groupIndex],n.bindingIndex))}this.freeGroupIndex=i.length-1,0===this.freeGroupIndex?(this.freeGroupIndex++,this.freeBindingIndex=0):this.freeBindingIndex=i[i.length-1]+1},e.prototype.getAttributeNextLocation=function(e,t){var i;void 0===t&&(t=0);var r=this._attributeNextLocation;return this._attributeNextLocation+=(null!==(i=a_[e])&&void 0!==i?i:1)*(t||1),r},e.prototype.getVaryingNextLocation=function(e,t){var i;void 0===t&&(t=0);var r=this._varyingNextLocation;return this._varyingNextLocation+=(null!==(i=a_[e])&&void 0!==i?i:1)*(t||1),r},e.prototype.getNextFreeUBOBinding=function(){return this._getNextFreeBinding(1)},e.prototype._getNextFreeBinding=function(e){if(this.freeBindingIndex>65536-e&&(this.freeGroupIndex++,this.freeBindingIndex=0),4===this.freeGroupIndex)throw"Too many textures or UBOs have been declared and it is not supported in WebGPU.";var t={groupIndex:this.freeGroupIndex,bindingIndex:this.freeBindingIndex};return this.freeBindingIndex+=e,t},e._SimplifiedKnownBindings=!0,e._SimplifiedKnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:-1,bindingIndex:-1}},Light1:{binding:{groupIndex:-1,bindingIndex:-1}},Light2:{binding:{groupIndex:-1,bindingIndex:-1}},Light3:{binding:{groupIndex:-1,bindingIndex:-1}},Light4:{binding:{groupIndex:-1,bindingIndex:-1}},Light5:{binding:{groupIndex:-1,bindingIndex:-1}},Light6:{binding:{groupIndex:-1,bindingIndex:-1}},Light7:{binding:{groupIndex:-1,bindingIndex:-1}},Light8:{binding:{groupIndex:-1,bindingIndex:-1}},Light9:{binding:{groupIndex:-1,bindingIndex:-1}},Light10:{binding:{groupIndex:-1,bindingIndex:-1}},Light11:{binding:{groupIndex:-1,bindingIndex:-1}},Light12:{binding:{groupIndex:-1,bindingIndex:-1}},Light13:{binding:{groupIndex:-1,bindingIndex:-1}},Light14:{binding:{groupIndex:-1,bindingIndex:-1}},Light15:{binding:{groupIndex:-1,bindingIndex:-1}},Light16:{binding:{groupIndex:-1,bindingIndex:-1}},Light17:{binding:{groupIndex:-1,bindingIndex:-1}},Light18:{binding:{groupIndex:-1,bindingIndex:-1}},Light19:{binding:{groupIndex:-1,bindingIndex:-1}},Light20:{binding:{groupIndex:-1,bindingIndex:-1}},Light21:{binding:{groupIndex:-1,bindingIndex:-1}},Light22:{binding:{groupIndex:-1,bindingIndex:-1}},Light23:{binding:{groupIndex:-1,bindingIndex:-1}},Light24:{binding:{groupIndex:-1,bindingIndex:-1}},Light25:{binding:{groupIndex:-1,bindingIndex:-1}},Light26:{binding:{groupIndex:-1,bindingIndex:-1}},Light27:{binding:{groupIndex:-1,bindingIndex:-1}},Light28:{binding:{groupIndex:-1,bindingIndex:-1}},Light29:{binding:{groupIndex:-1,bindingIndex:-1}},Light30:{binding:{groupIndex:-1,bindingIndex:-1}},Light31:{binding:{groupIndex:-1,bindingIndex:-1}},Material:{binding:{groupIndex:-1,bindingIndex:-1}},Mesh:{binding:{groupIndex:-1,bindingIndex:-1}},Internals:{binding:{groupIndex:-1,bindingIndex:-1}}},e._KnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:1,bindingIndex:0}},Light1:{binding:{groupIndex:1,bindingIndex:1}},Light2:{binding:{groupIndex:1,bindingIndex:2}},Light3:{binding:{groupIndex:1,bindingIndex:3}},Light4:{binding:{groupIndex:1,bindingIndex:4}},Light5:{binding:{groupIndex:1,bindingIndex:5}},Light6:{binding:{groupIndex:1,bindingIndex:6}},Light7:{binding:{groupIndex:1,bindingIndex:7}},Light8:{binding:{groupIndex:1,bindingIndex:8}},Light9:{binding:{groupIndex:1,bindingIndex:9}},Light10:{binding:{groupIndex:1,bindingIndex:10}},Light11:{binding:{groupIndex:1,bindingIndex:11}},Light12:{binding:{groupIndex:1,bindingIndex:12}},Light13:{binding:{groupIndex:1,bindingIndex:13}},Light14:{binding:{groupIndex:1,bindingIndex:14}},Light15:{binding:{groupIndex:1,bindingIndex:15}},Light16:{binding:{groupIndex:1,bindingIndex:16}},Light17:{binding:{groupIndex:1,bindingIndex:17}},Light18:{binding:{groupIndex:1,bindingIndex:18}},Light19:{binding:{groupIndex:1,bindingIndex:19}},Light20:{binding:{groupIndex:1,bindingIndex:20}},Light21:{binding:{groupIndex:1,bindingIndex:21}},Light22:{binding:{groupIndex:1,bindingIndex:22}},Light23:{binding:{groupIndex:1,bindingIndex:23}},Light24:{binding:{groupIndex:1,bindingIndex:24}},Light25:{binding:{groupIndex:1,bindingIndex:25}},Light26:{binding:{groupIndex:1,bindingIndex:26}},Light27:{binding:{groupIndex:1,bindingIndex:27}},Light28:{binding:{groupIndex:1,bindingIndex:28}},Light29:{binding:{groupIndex:1,bindingIndex:29}},Light30:{binding:{groupIndex:1,bindingIndex:30}},Light31:{binding:{groupIndex:1,bindingIndex:31}},Material:{binding:{groupIndex:2,bindingIndex:0}},Mesh:{binding:{groupIndex:2,bindingIndex:1}},Internals:{binding:{groupIndex:2,bindingIndex:2}}},e}(),l_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._missingVaryings=[],t._textureArrayProcessing=[],t._vertexIsGLES3=!1,t._fragmentIsGLES3=!1,t.shaderLanguage=pt.GLSL,t.parseGLES3=!0,t}return m(t,e),t.prototype._getArraySize=function(e,t,i){var r=0,n=e.indexOf("["),o=e.indexOf("]");if(n>0&&o>0){var a=e.substring(n+1,o);r=+a,isNaN(r)&&(r=+i[a.trim()]),e=e.substr(0,n)}return[e,t,r]},t.prototype.initializeShaders=function(e){this._webgpuProcessingContext=e,this._missingVaryings.length=0,this._textureArrayProcessing.length=0,this.attributeKeywordName=void 0,this.varyingVertexKeywordName=void 0,this.varyingFragmentKeywordName=void 0},t.prototype.preProcessShaderCode=function(e,t){var i="// Internals UBO\nuniform ".concat(n_.InternalsUBOName," {\nfloat yFactor_;\nfloat textureOutputHeight_;\n};\n"),r=-1!==e.indexOf("// Internals UBO");return t?(this._fragmentIsGLES3=-1!==e.indexOf("#version 3"),this._fragmentIsGLES3&&(this.varyingFragmentKeywordName="in"),r?e:i+"##INJECTCODE##\n"+e):(this._vertexIsGLES3=-1!==e.indexOf("#version 3"),this._vertexIsGLES3&&(this.attributeKeywordName="in",this.varyingVertexKeywordName="out"),r?e:i+e)},t.prototype.varyingCheck=function(e,t){return(t&&this._fragmentIsGLES3?/(flat\s)?\s*\bin\b/:!t&&this._vertexIsGLES3?/(flat\s)?\s*\bout\b/:/(flat\s)?\s*\bvarying\b/).test(e)},t.prototype.varyingProcessor=function(e,t,i){var r;this._preProcessors=i;var n=(t&&this._fragmentIsGLES3?/\s*(flat)?\s*in\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm:!t&&this._vertexIsGLES3?/\s*(flat)?\s*out\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm:/\s*(flat)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm).exec(e);if(null!==n){var o,a=null!==(r=n[1])&&void 0!==r?r:"",s=n[2],l=n[3];t?(o=this._webgpuProcessingContext.availableVaryings[l],this._missingVaryings[o]="",void 0===o&&ae.Warn('Invalid fragment shader: The varying named "'.concat(l,'" is not declared in the vertex shader! This declaration will be ignored.'))):(o=this._webgpuProcessingContext.getVaryingNextLocation(s,this._getArraySize(l,s,i)[2]),this._webgpuProcessingContext.availableVaryings[l]=o,this._missingVaryings[o]="layout(location = ".concat(o,") ").concat(a," in ").concat(s," ").concat(l,";")),e=e.replace(n[0],void 0===o?"":"layout(location = ".concat(o,") ").concat(a," ").concat(t?"in":"out"," ").concat(s," ").concat(l,";"))}return e},t.prototype.attributeProcessor=function(e,t){this._preProcessors=t;var i=(this._vertexIsGLES3?/\s*in\s+(\S+)\s+(\S+)\s*;/gm:/\s*attribute\s+(\S+)\s+(\S+)\s*;/gm).exec(e);if(null!==i){var r=i[1],n=i[2],o=this._webgpuProcessingContext.getAttributeNextLocation(r,this._getArraySize(n,r,t)[2]);this._webgpuProcessingContext.availableAttributes[n]=o,this._webgpuProcessingContext.orderedAttributes[o]=n;var a=this.vertexBufferKindToNumberOfComponents[n];if(void 0!==a){var s=a<0?-1===a?"int":"ivec"+-a:1===a?"uint":"uvec"+a,l="_int_".concat(n,"_");e=e.replace(i[0],"layout(location = ".concat(o,") in ").concat(s," ").concat(l,"; ").concat(r," ").concat(n," = ").concat(r,"(").concat(l,");"))}else e=e.replace(i[0],"layout(location = ".concat(o,") in ").concat(r," ").concat(n,";"))}return e},t.prototype.uniformProcessor=function(e,t,i){var r,n;this._preProcessors=i;var o=/\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);if(null!==o){var a=o[1],s=o[2];if(0===a.indexOf("sampler")||1===a.indexOf("sampler")){var l=0;s=(r=this._getArraySize(s,a,i))[0],a=r[1],l=r[2];var c=this._webgpuProcessingContext.availableTextures[s];if(!c){c={autoBindSampler:!0,isTextureArray:l>0,isStorageTexture:!1,textures:[],sampleType:Ff.Float};for(var u=0;u<(l||1);++u)c.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())}var h=null!==(n=n_._SamplerTypeByWebGLSamplerType[a])&&void 0!==n?n:"sampler",d=!!n_._IsComparisonSamplerByWebGPUSamplerType[h],p=d?Nf.Comparison:Nf.Filtering,f=s+n_.AutoSamplerSuffix,_=this._webgpuProcessingContext.availableSamplers[f];_||(_={binding:this._webgpuProcessingContext.getNextFreeUBOBinding(),type:p});var m="u"===a.charAt(0)?"u":"i"===a.charAt(0)?"i":"";m&&(a=a.substr(1));var g=d?Ff.Depth:"u"===m?Ff.Uint:"i"===m?Ff.Sint:Ff.Float;c.sampleType=g;var v=l>0,y=_.binding.groupIndex,b=_.binding.bindingIndex,T=n_._SamplerFunctionByWebGLSamplerType[a],E=n_._TextureTypeByWebGLSamplerType[a],S=n_._GpuTextureViewDimensionByWebGPUTextureType[E];if(v){var x=[];for(x.push("layout(set = ".concat(y,", binding = ").concat(b,") uniform ").concat(m).concat(h," ").concat(f,";")),e="\n",u=0;u0?"\n":"","#define ").concat(s).concat(u," ").concat(m).concat(T,"(").concat(s,"Texture").concat(u,", ").concat(f,")")}e=x.join("\n")+e,this._textureArrayProcessing.push(s)}else l=1,e="layout(set = ".concat(y,", binding = ").concat(b,") uniform ").concat(h," ").concat(f,";\n layout(set = ").concat(c.textures[0].groupIndex,", binding = ").concat(c.textures[0].bindingIndex,") uniform ").concat(m).concat(E," ").concat(s,"Texture;\n #define ").concat(s," ").concat(m).concat(T,"(").concat(s,"Texture, ").concat(f,")");for(this._webgpuProcessingContext.availableTextures[s]=c,this._webgpuProcessingContext.availableSamplers[f]=_,this._addSamplerBindingDescription(f,_,!t),u=0;u=0,s=a?"vec4 glFragCoord_;\n":"",l=-1!==e.search(/layout *\(location *= *0\) *out/g);if(e=(e=(e=(e=(e=(e=(e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/gl_FragCoord/g,"glFragCoord_"),this._fragmentIsGLES3){var c=/^\s*out\s+\S+\s+\S+\s*;/gm.exec(e);null!==c&&(e=e.substring(0,c.index)+"layout(location = 0) "+e.substring(c.index))}else e=e.replace(/void\s+?main\s*\(/g,(o||l?"":"layout(location = 0) out vec4 glFragColor;\n")+"void main(");e=(e=e.replace(/dFdy/g,"(-yFactor_)*dFdy")).replace("##INJECTCODE##",s),a&&(e=this._injectStartingAndEndingCode(e,"void main","\n glFragCoord_ = gl_FragCoord;\n if (yFactor_ == 1.) {\n glFragCoord_.y = textureOutputHeight_ - glFragCoord_.y;\n }\n "))}else if(e=(e=e.replace(/gl_InstanceID/g,"gl_InstanceIndex")).replace(/gl_VertexID/g,"gl_VertexIndex"),-1!==t.indexOf("#define MULTIVIEW"))return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e;if(!i){var u=e.lastIndexOf("}");e=e.substring(0,u),e+="gl_Position.y *= yFactor_;\n",e+="}"}return e},t.prototype._applyTextureArrayProcessing=function(e,t){for(var i=new RegExp(t+"\\s*\\[(.+)?\\]","gm"),r=i.exec(e);null!==r;){var n=r[1],o=+n;this._preProcessors&&isNaN(o)&&(o=+this._preProcessors[n.trim()]),e=e.replace(r[0],t+o),r=i.exec(e)}return e},t.prototype._generateLeftOverUBOCode=function(e,t){for(var i="layout(set = ".concat(t.binding.groupIndex,", binding = ").concat(t.binding.bindingIndex,") uniform ").concat(e," {\n "),r=0,n=this._webgpuProcessingContext.leftOverUniforms;r0?i+=" ".concat(o.type," ").concat(o.name,"[").concat(o.length,"];\n"):i+=" ".concat(o.type," ").concat(o.name,";\n")}return i+"};\n\n"},t.prototype.finalizeShaders=function(e,t){for(var i=0;i0&&(t=n+"\n"+t)}var o=this._buildLeftOverUBO();return e=o+e,t=o+t,this._collectBindingNames(),this._preCreateBindGroupEntries(),this._preProcessors=null,this.vertexBufferKindToNumberOfComponents={},{vertexCode:e,fragmentCode:t}},t}(n_);li.IncludesShadersStoreWGSL.bonesDeclaration="#if NUM_BONE_INFLUENCERS>0\nattribute matricesIndices : vec4;attribute matricesWeights : vec4;\n#if NUM_BONE_INFLUENCERS>4\nattribute matricesIndicesExtra : vec4;attribute matricesWeightsExtra : vec4;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nvar boneSampler : texture_2d;uniform boneTextureWidth : f32;\n#else\nuniform mBones : array;\n#ifdef BONES_VELOCITY_ENABLED\nuniform mPreviousBones : array;\n#endif\n#endif\n#ifdef BONETEXTURE\nfn readMatrixFromRawSampler(smp : texture_2d,index : f32)->mat4x4\n{let offset=i32(index) *4; \nlet m0=textureLoad(smp,vec2(offset+0,0),0);let m1=textureLoad(smp,vec2(offset+1,0),0);let m2=textureLoad(smp,vec2(offset+2,0),0);let m3=textureLoad(smp,vec2(offset+3,0),0);return mat4x4(m0,m1,m2,m3);}\n#endif\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.bonesVertex="#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nvar influence : mat4x4;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[0])*vertexInputs.matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[1])*vertexInputs.matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[2])*vertexInputs.matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[3])*vertexInputs.matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[0])*vertexInputs.matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[1])*vertexInputs.matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[2])*vertexInputs.matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[3])*vertexInputs.matricesWeightsExtra[3];\n#endif \n#else \ninfluence=uniforms.mBones[int(vertexInputs.matricesIndices[0])]*vertexInputs.matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[1])]*vertexInputs.matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[2])]*vertexInputs.matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[3])]*vertexInputs.matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[0])]*vertexInputs.matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[1])]*vertexInputs.matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[2])]*vertexInputs.matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[3])]*vertexInputs.matricesWeightsExtra[3];\n#endif \n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.bakedVertexAnimationDeclaration="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform bakedVertexAnimationTime: f32;uniform bakedVertexAnimationTextureSizeInverted: vec2;uniform bakedVertexAnimationSettings: vec4;var bakedVertexAnimationTexture : texture_2d;\n#ifdef INSTANCES\nattribute bakedVertexAnimationSettingsInstanced : vec4;\n#endif\nfn readMatrixFromRawSamplerVAT(smp : texture_2d,index : f32,frame : f32)->mat4x4\n{let offset=i32(index)*4;let frameUV=i32(frame);let m0=textureLoad(smp,vec2(offset+0,frameUV),0);let m1=textureLoad(smp,vec2(offset+1,frameUV),0);let m2=textureLoad(smp,vec2(offset+2,frameUV),0);let m3=textureLoad(smp,vec2(offset+3,frameUV),0);return mat4x4(m0,m1,m2,m3);}\n#endif\n";li.IncludesShadersStoreWGSL.bakedVertexAnimation="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\nlet VATStartFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.x;let VATEndFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.y;let VATOffsetFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.z;let VATSpeed: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.w;\n#else\nlet VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;let VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;let VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;let VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;\n#endif\nlet totalFrames: f32=VATEndFrame-VATStartFrame+1.0;let time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;let frameCorrection: f32=select(1.0,0.0,time<1.0);let numOfFrames: f32=totalFrames-frameCorrection;var VATFrameNum: f32=fract(time)*numOfFrames;VATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;VATFrameNum=floor(VATFrameNum);VATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;var VATInfluence : mat4x4;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[0],VATFrameNum)*vertexInputs.matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[1],VATFrameNum)*vertexInputs.matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[2],VATFrameNum)*vertexInputs.matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[3],VATFrameNum)*vertexInputs.matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[0],VATFrameNum)*vertexInputs.matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[1],VATFrameNum)*vertexInputs.matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[2],VATFrameNum)*vertexInputs.matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[3],VATFrameNum)*vertexInputs.matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;}\n#endif\n";li.IncludesShadersStoreWGSL.clipPlaneFragment="#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelse if (fragmentInputs.fClipDistance>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE2\nelse if (fragmentInputs.fClipDistance2>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE3\nelse if (fragmentInputs.fClipDistance3>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE4\nelse if (fragmentInputs.fClipDistance4>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE5\nelse if (fragmentInputs.fClipDistance5>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE6\nelse if (fragmentInputs.fClipDistance6>0.0)\n{discard;}\n#endif\n";li.IncludesShadersStoreWGSL.clipPlaneFragmentDeclaration="#ifdef CLIPPLANE\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nvarying fClipDistance6: f32;\n#endif\n";li.IncludesShadersStoreWGSL.clipPlaneVertex="#ifdef CLIPPLANE\nvertexOutputs.fClipDistance=dot(worldPos,uniforms.vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nvertexOutputs.fClipDistance2=dot(worldPos,uniforms.vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nvertexOutputs.fClipDistance3=dot(worldPos,uniforms.vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nvertexOutputs.fClipDistance4=dot(worldPos,uniforms.vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nvertexOutputs.fClipDistance5=dot(worldPos,uniforms.vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nvertexOutputs.fClipDistance6=dot(worldPos,uniforms.vClipPlane6);\n#endif\n";li.IncludesShadersStoreWGSL.clipPlaneVertexDeclaration="#ifdef CLIPPLANE\nuniform vClipPlane: vec4;varying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nuniform vClipPlane2: vec4;varying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nuniform vClipPlane3: vec4;varying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nuniform vClipPlane4: vec4;varying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nuniform vClipPlane5: vec4;varying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nuniform vClipPlane6: vec4;varying fClipDistance6: f32;\n#endif\n";li.IncludesShadersStoreWGSL.instancesDeclaration="#ifdef INSTANCES\nattribute world0 : vec4;attribute world1 : vec4;attribute world2 : vec4;attribute world3 : vec4;\n#ifdef INSTANCESCOLOR\nattribute instanceColor : vec4;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform world : mat4x4;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nattribute previousWorld0 : vec4;attribute previousWorld1 : vec4;attribute previousWorld2 : vec4;attribute previousWorld3 : vec4;\n#ifdef THIN_INSTANCES\nuniform previousWorld : mat4x4;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform world : mat4x4;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nuniform previousWorld : mat4x4;\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.instancesVertex="#ifdef INSTANCES\nvar finalWorld=mat4x4(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=mat4x4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\n#if !defined(WORLD_UBO)\nfinalWorld=uniforms.world*finalWorld;\n#else\nfinalWorld=mesh.world*finalWorld;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nvar finalWorld=uniforms.world;\n#else\nvar finalWorld=mesh.world;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=previousWorld;\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.helperFunctions="const PI: f32=3.1415926535897932384626433832795;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const HALF_MIN: f32=5.96046448e-08; \nconst LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3=vec3 (0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\nfn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3=inMatrix[0];let i1: vec3=inMatrix[1];let i2: vec3=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);return outMatrix;}\nfn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01: f32=inMatrix[0][1];let a02: f32=inMatrix[0][2];let a10: f32=inMatrix[1][0];let a11: f32=inMatrix[1][1];let a12: f32=inMatrix[1][2];let a20: f32=inMatrix[2][0];let a21: f32=inMatrix[2][1];let a22: f32=inMatrix[2][2];let b01: f32=a22*a11-a12*a21;let b11: f32=-a22*a10+a12*a20;let b21: f32=a21*a10-a11*a20;let det: f32=a00*b01+a01*b11+a02*b21;return mat3x3f(b01/det,(-a22*a01+a02*a21)/det,(a12*a01-a02*a11)/det,\nb11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,\nb21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}\n#if USE_EXACT_SRGB_CONVERSIONS\nfn toLinearSpaceExact(color: vec3)->vec3\n{let nearZeroSection: vec3=0.0773993808*color;let remainingSection: vec3=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));}\nfn toGammaSpaceExact(color: vec3)->vec3\n{let nearZeroSection: vec3=12.92*color;let remainingSection: vec3=1.055*pow(color,vec3(0.41666))-vec3(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));}\n#endif\nfn toLinearSpace(color: vec4)->vec4\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toLinearSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n#endif\n}\nfn toLinearSpaceVec3(color: vec3)->vec3\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\n#else\nreturn pow(color,vec3(LinearEncodePowerApprox));\n#endif\n}\nfn toGammaSpace(color: vec4)->vec4\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toGammaSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n#endif\n}\nfn toGammaSpaceVec3(color: vec3)->vec3\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\n#else\nreturn pow(color,vec3(GammaEncodePowerApprox));\n#endif\n}\nfn square(value: vec3)->vec3\n{return value*value;}\nfn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}\nfn getLuminance(color: vec3)->f32\n{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}\nfn getRand(seed: vec2)->f32 {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);}\nfn dither(seed: vec2,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;}\nconst rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3)->vec4 {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3 =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4(clamp(rgb,vec3(0.,0.,0.),vec3(1.,1.,1.)),D); }\nfn fromRGBD(rgbd: vec4)->vec3 {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}\nfn parallaxCorrectNormal(vertexPos: vec3,origVec: vec3,cubeSize: vec3,cubePos: vec3)->vec3 {let invOrigVec: vec3=vec3(1.0,1.0,1.0)/origVec;let halfSize: vec3=cubeSize*0.5;let intersecAtMaxPlane: vec3=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}\n";li.IncludesShadersStoreWGSL.fresnelFunction="#ifdef FRESNEL\nfn computeFresnelTerm(viewDirection: vec3f,worldNormal: vec3f,bias: f32,power: f32)->f32\n{let fresnelTerm: f32=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}\n#endif\n";li.IncludesShadersStoreWGSL.meshUboDeclaration="struct Mesh {world : mat4x4,\nvisibility : f32,};var mesh : Mesh;\n#define WORLD_UBO\n";li.IncludesShadersStoreWGSL.morphTargetsVertex="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\n#if {X}==0\nfor (var i=0; i<$NUM_MORPH_INFLUENCERS$; i=i+1) {if (i>=uniforms.morphTargetCount) {break;}\nvertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x;positionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID) -vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n}\n#endif\n#else\npositionUpdated=positionUpdated+(position{X}-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(uv_{X}-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.morphTargetsVertexDeclaration="#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute position{X} : vec3;\n#ifdef MORPHTARGETS_NORMAL\nattribute normal{X} : vec3;\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute tangent{X} : vec3;\n#endif\n#ifdef MORPHTARGETS_UV\nattribute uv_{X} : vec2;\n#endif\n#elif {X}==0\nuniform morphTargetCount: i32;\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.morphTargetsVertexGlobal="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvar vertexID : f32;\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.morphTargetsVertexGlobalDeclaration="#ifdef MORPHTARGETS\nuniform morphTargetInfluences : array;\n#ifdef MORPHTARGETS_TEXTURE \nuniform morphTargetTextureIndices : array;uniform morphTargetTextureInfo : vec3;var morphTargets : texture_2d_array;var morphTargetsSampler : sampler;fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3\n{ \nlet y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;let textureUV=vec2((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);return textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;}\n#endif\n#endif\n";li.IncludesShadersStoreWGSL.sceneUboDeclaration="struct Scene {viewProjection : mat4x4,\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4,\n#endif \nview : mat4x4,\nprojection : mat4x4,\nvEyePosition : vec4,};var scene : Scene;\n";var c_,u_,h_={texture_1d:xf.E1d,texture_2d:xf.E2d,texture_2d_array:xf.E2dArray,texture_3d:xf.E3d,texture_cube:xf.Cube,texture_cube_array:xf.CubeArray,texture_multisampled_2d:xf.E2d,texture_depth_2d:xf.E2d,texture_depth_2d_array:xf.E2dArray,texture_depth_cube:xf.Cube,texture_depth_cube_array:xf.CubeArray,texture_depth_multisampled_2d:xf.E2d,texture_storage_1d:xf.E1d,texture_storage_2d:xf.E2d,texture_storage_2d_array:xf.E2dArray,texture_storage_3d:xf.E3d,texture_external:null},d_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.shaderLanguage=pt.WGSL,t.uniformRegexp=/uniform\s+(\w+)\s*:\s*(.+)\s*;/,t.textureRegexp=/var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,t.noPrecision=!0,t}return m(t,e),t.prototype._getArraySize=function(e,t,i){var r=0,n=t.lastIndexOf(">");if(t.indexOf("array")>=0&&n>0){for(var o=n;o>0&&" "!==t.charAt(o)&&","!==t.charAt(o);)o--;var a=t.substring(o+1,n);for(r=+a,isNaN(r)&&(r=+i[a.trim()]);o>0&&(" "===t.charAt(o)||","===t.charAt(o));)o--;t=t.substring(t.indexOf("<")+1,o+1)}return[e,t,r]},t.prototype.initializeShaders=function(e){this._webgpuProcessingContext=e,this._attributesInputWGSL=[],this._attributesWGSL=[],this._attributesConversionCodeWGSL=[],this._hasNonFloatAttribute=!1,this._varyingsWGSL=[],this._varyingNamesWGSL=[],this._stridedUniformArrays=[]},t.prototype.preProcessShaderCode=function(e){var t="struct ".concat(n_.InternalsUBOName," {\n yFactor_: f32,\n textureOutputHeight_: f32,\n};\nvar ").concat("internals"," : ").concat(n_.InternalsUBOName,";\n");return-1!==e.indexOf(t)?e:t+$p(e)},t.prototype.varyingCheck=function(e,t){return/(flat|linear|perspective)?\s*(center|centroid|sample)?\s*\bvarying\b/.test(e)},t.prototype.varyingProcessor=function(e,t,i){var r,n,o=/\s*(flat|linear|perspective)?\s*(center|centroid|sample)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(null!==o){var a,s=null!==(r=o[1])&&void 0!==r?r:"perspective",l=null!==(n=o[2])&&void 0!==n?n:"center",c=o[4],u=o[3],h="flat"===s?"@interpolate(".concat(s,")"):"@interpolate(".concat(s,", ").concat(l,")");t?void 0===(a=this._webgpuProcessingContext.availableVaryings[u])&&ae.Warn('Invalid fragment shader: The varying named "'.concat(u,'" is not declared in the vertex shader! This declaration will be ignored.')):(a=this._webgpuProcessingContext.getVaryingNextLocation(c,this._getArraySize(u,c,i)[2]),this._webgpuProcessingContext.availableVaryings[u]=a,this._varyingsWGSL.push(" @location(".concat(a,") ").concat(h," ").concat(u," : ").concat(c,",")),this._varyingNamesWGSL.push(u)),e=""}return e},t.prototype.attributeProcessor=function(e,t){var i=/\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(null!==i){var r=i[2],n=i[1],o=this._webgpuProcessingContext.getAttributeNextLocation(r,this._getArraySize(n,r,t)[2]);this._webgpuProcessingContext.availableAttributes[n]=o,this._webgpuProcessingContext.orderedAttributes[o]=n;var a=this.vertexBufferKindToNumberOfComponents[n];if(void 0!==a){var s=a<0?-1===a?"i32":"vec"+-a+"":1===a?"u32":"vec"+a+"",l="_int_".concat(n,"_");this._attributesInputWGSL.push("@location(".concat(o,") ").concat(l," : ").concat(s,",")),this._attributesWGSL.push("".concat(n," : ").concat(r,",")),this._attributesConversionCodeWGSL.push("vertexInputs.".concat(n," = ").concat(r,"(vertexInputs_.").concat(l,");")),this._hasNonFloatAttribute=!0}else this._attributesInputWGSL.push("@location(".concat(o,") ").concat(n," : ").concat(r,",")),this._attributesWGSL.push("".concat(n," : ").concat(r,",")),this._attributesConversionCodeWGSL.push("vertexInputs.".concat(n," = vertexInputs_.").concat(n,";"));e=""}return e},t.prototype.uniformProcessor=function(e,t,i){var r=this.uniformRegexp.exec(e);if(null!==r){var n=r[2],o=r[1];this._addUniformToLeftOverUBO(o,n,i),e=""}return e},t.prototype.textureProcessor=function(e,t,i){var r=this.textureRegexp.exec(e);if(null!==r){var n=r[1],o=r[2],a=!!r[3],s=r[4],l=s.indexOf("storage")>0,c=r[6],u=l?c.substring(0,c.indexOf(",")).trim():null,h=a?this._getArraySize(n,o,i)[2]:0,d=this._webgpuProcessingContext.availableTextures[n];if(d)h=d.textures.length;else{d={isTextureArray:h>0,isStorageTexture:l,textures:[],sampleType:Ff.Float},h=h||1;for(var p=0;p0,_=h_[s],m=f?Ff.Depth:"u32"===c?Ff.Uint:"i32"===c?Ff.Sint:Ff.Float;if(d.sampleType=m,void 0===_)throw"Can't get the texture dimension corresponding to the texture function \"".concat(s,'"!');for(p=0;p2?o[2]:""}return e.replace(/\$(\w+)\$/g,(function(e,t){var r;return null!==(r=i[t])&&void 0!==r?r:t}))},t.prototype.finalizeShaders=function(e,t){var i=t.indexOf("fragmentInputs.position")>=0?"\n if (internals.yFactor_ == 1.) {\n fragmentInputs.position.y = internals.textureOutputHeight_ - fragmentInputs.position.y;\n }\n ":"";e=this._processSamplers(e,!0),t=this._processSamplers(t,!1),e=this._processCustomBuffers(e,!0),t=this._processCustomBuffers(t,!1);var r=this._buildLeftOverUBO();t=r+t,e=(e=r+e).replace(/#define /g,"//#define "),e=this._processStridedUniformArrays(e);var n="struct VertexInputs {\n @builtin(vertex_index) vertexIndex : u32,\n @builtin(instance_index) instanceIndex : u32,\n";this._attributesInputWGSL.length>0&&(n+=this._attributesInputWGSL.join("\n")),n+="\n};\nvar vertexInputs"+(this._hasNonFloatAttribute?"_":"")+" : VertexInputs;\n",this._hasNonFloatAttribute&&(n+="struct VertexInputs_ {\n vertexIndex : u32, instanceIndex : u32,\n",n+=this._attributesWGSL.join("\n"),n+="\n};\nvar vertexInputs : VertexInputs_;\n");var o="struct FragmentInputs {\n @builtin(position) position : vec4,\n";this._varyingsWGSL.length>0&&(o+=this._varyingsWGSL.join("\n")),e=n+(o+="\n};\nvar vertexOutputs : FragmentInputs;\n")+e;var a="\n vertexInputs".concat(this._hasNonFloatAttribute?"_":""," = input;\n");this._hasNonFloatAttribute&&(a+="vertexInputs.vertexIndex = vertexInputs_.vertexIndex;\nvertexInputs.instanceIndex = vertexInputs_.instanceIndex;\n",a+=this._attributesConversionCodeWGSL.join("\n"),a+="\n"),e=this._injectStartingAndEndingCode(e,"fn main",a," vertexOutputs.position.y = vertexOutputs.position.y * internals.yFactor_;\n return vertexOutputs;"),t=t.replace(/#define /g,"//#define "),t=(t=this._processStridedUniformArrays(t)).replace(/dpdy/g,"(-internals.yFactor_)*dpdy");var s="struct FragmentInputs {\n @builtin(position) position : vec4,\n @builtin(front_facing) frontFacing : bool,\n";this._varyingsWGSL.length>0&&(s+=this._varyingsWGSL.join("\n")),s+="\n};\nvar fragmentInputs : FragmentInputs;\n";for(var l="struct FragmentOutputs {\n @location(0) color : vec4,\n",c=!1,u=0;!(c||(u=t.indexOf("fragmentOutputs.fragDepth",u))<0);){var h=u;for(c=!0;u>1&&"\n"!==t.charAt(u);){if("/"===t.charAt(u)&&"/"===t.charAt(u-1)){c=!1;break}u--}u=h+25}c&&(l+=" @builtin(frag_depth) fragDepth: f32,\n"),t=s+(l+="};\nvar fragmentOutputs : FragmentOutputs;\n")+t;var d=" fragmentInputs = input;\n "+i;return t=this._injectStartingAndEndingCode(t,"fn main",d," return fragmentOutputs;"),this._collectBindingNames(),this._preCreateBindGroupEntries(),this.vertexBufferKindToNumberOfComponents={},{vertexCode:e,fragmentCode:t}},t.prototype._generateLeftOverUBOCode=function(e,t){for(var i="",r="struct ".concat(e," {\n"),n=0,o=this._webgpuProcessingContext.leftOverUniforms;n)?$/,"$1"),l=n_.UniformSizes[s];if(a.length>0)if(l<=2){var c="".concat(e,"_").concat(this._stridedUniformArrays.length,"_strided_arr");i+="struct ".concat(c," {\n @size(16)\n el: ").concat(s,",\n }"),this._stridedUniformArrays.push(a.name),r+=" @align(16) ".concat(a.name," : array<").concat(c,", ").concat(a.length,">,\n")}else r+=" ".concat(a.name," : array<").concat(a.type,", ").concat(a.length,">,\n");else r+=" ".concat(a.name," : ").concat(a.type,",\n")}return r+="};\n",(r="".concat(i,"\n").concat(r))+"@group(".concat(t.binding.groupIndex,") @binding(").concat(t.binding.bindingIndex,") var ").concat("uniforms"," : ").concat(e,";\n")},t.prototype._processSamplers=function(e,t){for(var i=/var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm;;){var r=i.exec(e);if(null===r)break;var n=r[1],o=r[2],a=n.indexOf(n_.AutoSamplerSuffix)===n.length-n_.AutoSamplerSuffix.length?n.substring(0,n.indexOf(n_.AutoSamplerSuffix)):null,s="sampler_comparison"===o?Nf.Comparison:Nf.Filtering;if(a){var l=this._webgpuProcessingContext.availableTextures[a];l&&(l.autoBindSampler=!0)}var c=this._webgpuProcessingContext.availableSamplers[n];c||(c={binding:this._webgpuProcessingContext.getNextFreeUBOBinding(),type:s},this._webgpuProcessingContext.availableSamplers[n]=c),this._addSamplerBindingDescription(n,c,t);var u=e.substring(0,r.index),h="@group(".concat(c.binding.groupIndex,") @binding(").concat(c.binding.bindingIndex,") "),d=e.substring(r.index);e=u+h+d,i.lastIndex+=h.length}return e},t.prototype._processCustomBuffers=function(e,t){for(var i,r=/var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm;;){var n=r.exec(e);if(null===n)break;var o=n[1],a=n[3],s=n[4],l=n[5],c=this._webgpuProcessingContext.availableBuffers[s];if(!c){var u="uniform"===o?s_.KnownUBOs[l]:null,h=void 0;u?(s=l,-1===(h=u.binding).groupIndex&&((h=null===(i=this._webgpuProcessingContext.availableBuffers[s])||void 0===i?void 0:i.binding)||(h=this._webgpuProcessingContext.getNextFreeUBOBinding()))):h=this._webgpuProcessingContext.getNextFreeUBOBinding(),c={binding:h},this._webgpuProcessingContext.availableBuffers[s]=c}this._addBufferBindingDescription(s,this._webgpuProcessingContext.availableBuffers[s],"read_write"===a?Df.Storage:"storage"===o?Df.ReadOnlyStorage:Df.Uniform,t);var d=c.binding.groupIndex,p=c.binding.bindingIndex,f=e.substring(0,n.index),_="@group(".concat(d,") @binding(").concat(p,") "),m=e.substring(n.index);e=f+_+m,r.lastIndex+=_.length}return e},t.prototype._processStridedUniformArrays=function(e){for(var t=0,i=this._stridedUniformArrays;t1?4:1},e}(),f_=function(){function e(e){void 0===e&&(e=null),this._originalFormatIsRGB=!1,this.format=Cf.RGBA8Unorm,this.textureUsages=0,this.textureAdditionalUsages=0,this._webgpuTexture=e,this._webgpuMSAATexture=null,this.view=null,this.viewForWriting=null}return Object.defineProperty(e.prototype,"underlyingResource",{get:function(){return this._webgpuTexture},enumerable:!1,configurable:!0}),e.prototype.getMSAATexture=function(e){var t,i;return void 0===e&&(e=0),null!==(i=null===(t=this._webgpuMSAATexture)||void 0===t?void 0:t[e])&&void 0!==i?i:null},e.prototype.setMSAATexture=function(e,t){void 0===t&&(t=-1),this._webgpuMSAATexture||(this._webgpuMSAATexture=[]),-1===t&&(t=this._webgpuMSAATexture.length),this._webgpuMSAATexture[t]=e},e.prototype.releaseMSAATexture=function(){if(this._webgpuMSAATexture){for(var e=0,t=this._webgpuMSAATexture;e= ofstX + width) {\n discard;\n }\n if (gl_FragCoord.y < ofstY || gl_FragCoord.y >= ofstY + height) {\n discard;\n }\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, ofstY + height - (gl_FragCoord.y - ofstY)), 0);\n #else\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color.rgb *= color.a;\n #endif\n outColor = color;\n }\n "}],b_={"":0,r8unorm:1,r8uint:2,r8sint:3,r16uint:4,r16sint:5,r16float:6,rg8unorm:7,rg8uint:8,rg8sint:9,r32uint:10,r32sint:11,r32float:12,rg16uint:13,rg16sint:14,rg16float:15,rgba8unorm:16,"rgba8unorm-srgb":17,rgba8uint:18,rgba8sint:19,bgra8unorm:20,"bgra8unorm-srgb":21,rgb10a2uint:22,rgb10a2unorm:23,rg32uint:24,rg32sint:25,rg32float:26,rgba16uint:27,rgba16sint:28,rgba16float:29,rgba32uint:30,rgba32sint:31,rgba32float:32,stencil8:33,depth16unorm:34,depth24plus:35,"depth24plus-stencil8":36,depth32float:37,"depth32float-stencil8":38},T_=function(){function e(e,t,i,r,n,o){if(this._pipelines={},this._compiledShaders=[],this._videoPipelines={},this._videoCompiledShaders=[],this._deferredReleaseTextures=[],this._engine=e,this._device=t,this._glslang=i,this._tintWASM=r,this._bufferManager=n,-1!==o.indexOf(vf.RG11B10UFloatRenderable)){var a=Object.keys(b_);b_[Cf.RG11B10UFloat]=b_[a[a.length-1]]+1}this._mipmapSampler=t.createSampler({minFilter:Pf.Linear}),this._videoSampler=t.createSampler({minFilter:Pf.Linear}),this._ubCopyWithOfst=this._bufferManager.createBuffer(16,bf.Uniform|bf.CopyDst,"UBCopyWithOffset").underlyingResource,this._getPipeline(Cf.RGBA8Unorm),this._getVideoPipeline(Cf.RGBA8Unorm)}return e.prototype._getPipeline=function(e,t,i){void 0===t&&(t=c_.MipMap);var r=t===c_.MipMap?1:t===c_.InvertYPremultiplyAlpha?((i.invertY?1:0)<<1)+((i.premultiplyAlpha?1:0)<<2):t===c_.Clear?8:t===c_.InvertYPremultiplyAlphaWithOfst?((i.invertY?1:0)<<4)+((i.premultiplyAlpha?1:0)<<5):0;this._pipelines[e]||(this._pipelines[e]=[]);var n=this._pipelines[e][r];if(!n){var o="#version 450\n";t!==c_.InvertYPremultiplyAlpha&&t!==c_.InvertYPremultiplyAlphaWithOfst||(i.invertY&&(o+="#define INVERTY\n"),i.premultiplyAlpha&&(o+="#define PREMULTIPLYALPHA\n"));var a=this._compiledShaders[r];if(!a){var s=this._glslang.compileGLSL(o+y_[t].vertex,"vertex"),l=this._glslang.compileGLSL(o+y_[t].fragment,"fragment");this._tintWASM&&(s=this._tintWASM.convertSpirV2WGSL(s),l=this._tintWASM.convertSpirV2WGSL(l));var c=this._device.createShaderModule({code:s}),u=this._device.createShaderModule({code:l});a=this._compiledShaders[r]=[c,u]}var h=this._device.createRenderPipeline({layout:Uf.Auto,vertex:{module:a[0],entryPoint:"main"},fragment:{module:a[1],entryPoint:"main",targets:[{format:e}]},primitive:{topology:Vf.TriangleStrip,stripIndexFormat:jf.Uint16}});n=this._pipelines[e][r]=[h,h.getBindGroupLayout(0)]}return n},e.prototype._getVideoPipeline=function(e,t){void 0===t&&(t=u_.DontInvertY);var i=t===u_.InvertY?1:0;this._videoPipelines[e]||(this._videoPipelines[e]=[]);var r=this._videoPipelines[e][i];if(!r){var n=this._videoCompiledShaders[i];if(!n){var o=this._device.createShaderModule({code:"\n struct VertexOutput {\n @builtin(position) Position : vec4,\n @location(0) fragUV : vec2\n }\n\n @vertex\n fn main(\n @builtin(vertex_index) VertexIndex : u32\n ) -> VertexOutput {\n var pos = array, 4>(\n vec2(-1.0, 1.0),\n vec2( 1.0, 1.0),\n vec2(-1.0, -1.0),\n vec2( 1.0, -1.0)\n );\n var tex = array, 4>(\n vec2(0.0, 0.0),\n vec2(1.0, 0.0),\n vec2(0.0, 1.0),\n vec2(1.0, 1.0)\n );\n\n var output: VertexOutput;\n\n output.Position = vec4(pos[VertexIndex], 0.0, 1.0);\n output.fragUV = tex[VertexIndex];\n\n return output;\n }\n "}),a=this._device.createShaderModule({code:0===i?"\n @group(0) @binding(0) var videoSampler: sampler;\n @group(0) @binding(1) var videoTexture: texture_external;\n\n @fragment\n fn main(\n @location(0) fragUV: vec2\n ) -> @location(0) vec4 {\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, fragUV);\n }\n ":"\n @group(0) @binding(0) var videoSampler: sampler;\n @group(0) @binding(1) var videoTexture: texture_external;\n\n @fragment\n fn main(\n @location(0) fragUV: vec2\n ) -> @location(0) vec4 {\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2(fragUV.x, 1.0 - fragUV.y));\n }\n "});n=this._videoCompiledShaders[i]=[o,a]}var s=this._device.createRenderPipeline({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_CopyVideoToTexture_").concat(e,"_").concat(0===i?"DontInvertY":"InvertY"),layout:Uf.Auto,vertex:{module:n[0],entryPoint:"main"},fragment:{module:n[1],entryPoint:"main",targets:[{format:e}]},primitive:{topology:Vf.TriangleStrip,stripIndexFormat:jf.Uint16}});r=this._videoPipelines[e][i]=[s,s.getBindGroupLayout(0)]}return r},e.prototype.setCommandEncoder=function(e){this._commandEncoderForCreation=e},e.prototype.copyVideoToTexture=function(e,t,i,r,n){var o,a,s,l;void 0===r&&(r=!1);var c=void 0===n,u=this._getVideoPipeline(i,r?u_.InvertY:u_.DontInvertY),h=u[0],d=u[1];c&&(n=this._device.createCommandEncoder({})),null===(a=(o=n).pushDebugGroup)||void 0===a||a.call(o,"copy video to texture - invertY=".concat(r));var p=t._hardwareTexture,f={label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_copyVideoToTexture_").concat(i,"_").concat(r?"InvertY":"DontInvertY").concat(t.label?"_"+t.label:""),colorAttachments:[{view:p.underlyingResource.createView({format:i,dimension:xf.E2d,mipLevelCount:1,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:1,aspect:Af.All}),loadOp:Zf.Load,storeOp:Jf.Store}]},_=n.beginRenderPass(f),m={layout:d,entries:[{binding:0,resource:this._videoSampler},{binding:1,resource:this._device.importExternalTexture({source:e.underlyingResource})}]},g=this._device.createBindGroup(m);_.setPipeline(h),_.setBindGroup(0,g),_.draw(4,1,0,0),_.end(),null===(l=(s=n).popDebugGroup)||void 0===l||l.call(s),c&&(this._device.queue.submit([n.finish()]),n=null)},e.prototype.invertYPreMultiplyAlpha=function(e,t,i,r,n,o,a,s,l,c,u,h,d,p,f){var _,m,g,v,y,b;void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===a&&(a=0),void 0===s&&(s=0),void 0===l&&(l=1),void 0===c&&(c=0),void 0===u&&(u=0),void 0===h&&(h=0),void 0===d&&(d=0);var T,E=0!==h,S=void 0===p,x=this._getPipeline(r,E?c_.InvertYPremultiplyAlphaWithOfst:c_.InvertYPremultiplyAlpha,{invertY:n,premultiplyAlpha:o}),A=x[0],C=x[1];if(a=Math.max(a,0),S&&(p=this._device.createCommandEncoder({})),null===(m=(_=p).pushDebugGroup)||void 0===m||m.call(_,"internal process texture - invertY=".concat(n," premultiplyAlpha=").concat(o)),p_.IsHardwareTexture(e)?(T=e.underlyingResource,n&&!o&&1===l&&0===a||(e=void 0)):(T=e,e=void 0),T){E&&this._bufferManager.setRawData(this._ubCopyWithOfst,0,new Float32Array([c,u,h,d]),0,16);var R=e,P=null!==(g=null==R?void 0:R._copyInvertYTempTexture)&&void 0!==g?g:this.createTexture({width:t,height:i,layers:1},!1,!1,!1,!1,!1,r,1,p,Sf.CopySrc|Sf.RenderAttachment|Sf.TextureBinding,void 0,"TempTextureForCopyWithInvertY"),I=null!==(v=null==R?void 0:R._copyInvertYRenderPassDescr)&&void 0!==v?v:{label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_invertYPreMultiplyAlpha_").concat(r,"_").concat(n?"InvertY":"DontInvertY","_").concat(o?"PremultiplyAlpha":"DontPremultiplyAlpha"),colorAttachments:[{view:P.createView({format:r,dimension:xf.E2d,baseMipLevel:0,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:0}),loadOp:Zf.Load,storeOp:Jf.Store}]},M=p.beginRenderPass(I),O=E?null==R?void 0:R._copyInvertYBindGroupWithOfst:null==R?void 0:R._copyInvertYBindGroup;if(!O){var D={layout:C,entries:[{binding:0,resource:T.createView({format:r,dimension:xf.E2d,baseMipLevel:s,mipLevelCount:1,arrayLayerCount:l,baseArrayLayer:a})}]};E&&D.entries.push({binding:1,resource:{buffer:this._ubCopyWithOfst}}),O=this._device.createBindGroup(D)}M.setPipeline(A),M.setBindGroup(0,O),M.draw(4,1,0,0),M.end(),p.copyTextureToTexture({texture:P},{texture:T,mipLevel:s,origin:{x:0,y:0,z:a}},{width:t,height:i,depthOrArrayLayers:1}),R?(R._copyInvertYTempTexture=P,R._copyInvertYRenderPassDescr=I,E?R._copyInvertYBindGroupWithOfst=O:R._copyInvertYBindGroup=O):this._deferredReleaseTextures.push([P,null]),null===(b=(y=p).popDebugGroup)||void 0===b||b.call(y),S&&(this._device.queue.submit([p.finish()]),p=null)}},e.prototype.copyWithInvertY=function(e,t,i,r){var n,o,a,s,l=void 0===r,c=this._getPipeline(t,c_.InvertYPremultiplyAlpha,{invertY:!0,premultiplyAlpha:!1}),u=c[0],h=c[1];l&&(r=this._device.createCommandEncoder({})),null===(o=(n=r).pushDebugGroup)||void 0===o||o.call(n,"internal copy texture with invertY");var d=r.beginRenderPass(i),p=this._device.createBindGroup({layout:h,entries:[{binding:0,resource:e}]});d.setPipeline(u),d.setBindGroup(0,p),d.draw(4,1,0,0),d.end(),null===(s=(a=r).popDebugGroup)||void 0===s||s.call(a),l&&(this._device.queue.submit([r.finish()]),r=null)},e.prototype.createTexture=function(e,t,i,r,n,o,a,s,l,c,u,h){void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===a&&(a=Cf.RGBA8Unorm),void 0===s&&(s=1),void 0===c&&(c=-1),void 0===u&&(u=0),s=p_.GetSample(s);var d=e.layers||1,p={width:e.width,height:e.height,depthOrArrayLayers:d},f=b_[a]?Sf.RenderAttachment:0,_=p_.IsCompressedFormat(a),m=t?p_.ComputeNumMipmapLevels(e.width,e.height):1,g=c>=0?c:Sf.CopySrc|Sf.CopyDst|Sf.TextureBinding;u|=t&&!_?Sf.CopySrc|f:0,_||o||(u|=f|Sf.CopyDst);var v=this._device.createTexture({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_Texture").concat(o?"3D":"2D","_").concat(h?h+"_":"").concat(p.width,"x").concat(p.height,"x").concat(p.depthOrArrayLayers,"_").concat(t?"wmips":"womips","_").concat(a,"_samples").concat(s),size:p,dimension:o?Ef.E3d:Ef.E2d,format:a,usage:g|u,sampleCount:s,mipLevelCount:m});return p_.IsImageBitmap(e)&&(this.updateTexture(e,v,e.width,e.height,d,a,0,0,r,n,0,0),t&&i&&this.generateMipmaps(v,a,m,0,o,l)),v},e.prototype.createCubeTexture=function(e,t,i,r,n,o,a,s,l,c,u){void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=Cf.RGBA8Unorm),void 0===a&&(a=1),void 0===l&&(l=-1),void 0===c&&(c=0),a=p_.GetSample(a);var h=p_.IsImageBitmapArray(e)?e[0].width:e.width,d=p_.IsImageBitmapArray(e)?e[0].height:e.height,p=b_[o]?Sf.RenderAttachment:0,f=p_.IsCompressedFormat(o),_=t?p_.ComputeNumMipmapLevels(h,d):1,m=l>=0?l:Sf.CopySrc|Sf.CopyDst|Sf.TextureBinding;c|=t&&!f?Sf.CopySrc|p:0,f||(c|=p|Sf.CopyDst);var g=this._device.createTexture({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_TextureCube_").concat(u?u+"_":"").concat(h,"x").concat(d,"x6_").concat(t?"wmips":"womips","_").concat(o,"_samples").concat(a),size:{width:h,height:d,depthOrArrayLayers:6},dimension:Ef.E2d,format:o,usage:m|c,sampleCount:a,mipLevelCount:_});return p_.IsImageBitmapArray(e)&&(this.updateCubeTextures(e,g,h,d,o,r,n,0,0),t&&i&&this.generateCubeMipmaps(g,o,_,s)),g},e.prototype.generateCubeMipmaps=function(e,t,i,r){var n,o,a,s,l=void 0===r;l&&(r=this._device.createCommandEncoder({})),null===(o=(n=r).pushDebugGroup)||void 0===o||o.call(n,"create cube mipmaps - ".concat(i," levels"));for(var c=0;c<6;++c)this.generateMipmaps(e,t,i,c,!1,r);null===(s=(a=r).popDebugGroup)||void 0===s||s.call(a),l&&(this._device.queue.submit([r.finish()]),r=null)},e.prototype.generateMipmaps=function(e,t,i,r,n,o){var a,s,l,c,u,h,d,p;void 0===r&&(r=0),void 0===n&&(n=!1);var f,_=void 0===o,m=this._getPipeline(t),g=m[0],v=m[1];if(r=Math.max(r,0),_&&(o=this._device.createCommandEncoder({})),null===(s=(a=o).pushDebugGroup)||void 0===s||s.call(a,"create mipmaps for face #".concat(r," - ").concat(i," levels")),p_.IsHardwareTexture(e)?(f=e.underlyingResource,e._mipmapGenRenderPassDescr=e._mipmapGenRenderPassDescr||[],e._mipmapGenBindGroup=e._mipmapGenBindGroup||[]):(f=e,e=void 0),f){for(var y=e,b=1;bu;)this._device.queue.writeBuffer(o,t+h,i.buffer,a+h,u),h+=u;this._device.queue.writeBuffer(o,t+h,i.buffer,a+h,n-h)},e.prototype._getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,i){i||(i=new Float32Array(e));for(var r=new Uint16Array(t);e--;)i[e]=Ip(r[e]);return i},e.prototype.readDataFromBuffer=function(e,t,i,r,n,o,a,s,l,c,h){var d=this;void 0===a&&(a=u.TEXTURETYPE_UNSIGNED_BYTE),void 0===s&&(s=0),void 0===l&&(l=null),void 0===c&&(c=!0),void 0===h&&(h=!1);var p=a===u.TEXTURETYPE_FLOAT?2:a===u.TEXTURETYPE_HALF_FLOAT?1:0,f=this._engine.uniqueId;return new Promise((function(i,u){e.mapAsync(Tf.Read,s,t).then((function(){var u=e.getMappedRange(s,t),f=l;if(h)f=null===f?To(a,t,!0,u):To(a,f.buffer,void 0,u);else if(null===f)switch(p){case 0:(f=new Uint8Array(t)).set(new Uint8Array(u));break;case 1:f=d._getHalfFloatAsFloatRGBAArrayBuffer(t/2,u);break;case 2:(f=new Float32Array(t/4)).set(new Float32Array(u))}else switch(p){case 0:(f=new Uint8Array(f.buffer)).set(new Uint8Array(u));break;case 1:f=d._getHalfFloatAsFloatRGBAArrayBuffer(t/2,u,l);break;case 2:(f=new Float32Array(f.buffer)).set(new Float32Array(u))}if(n!==o){1!==p||h||(n*=2,o*=2);for(var _=new Uint8Array(f.buffer),m=n,g=0,v=1;v1?4:1;return x_[e.samplingMode]+A_[(e._comparisonFunction||514)-512+1]+C_[e.samplingMode]+((null!==(t=e._cachedWrapU)&&void 0!==t?t:1)<<8)+((null!==(i=e._cachedWrapV)&&void 0!==i?i:1)<<10)+((null!==(r=e._cachedWrapR)&&void 0!==r?r:1)<<12)+((e.useMipMaps?1:0)<<14)+(n<<15)},e._GetSamplerFilterDescriptor=function(e,t){var i,r,n,o,a,s=e.useMipMaps;switch(e.samplingMode){case u.TEXTURE_LINEAR_LINEAR_MIPNEAREST:i=Pf.Linear,r=Pf.Linear,n=Pf.Nearest,s||(o=a=0);break;case u.TEXTURE_LINEAR_LINEAR_MIPLINEAR:case u.TEXTURE_TRILINEAR_SAMPLINGMODE:i=Pf.Linear,r=Pf.Linear,s?n=Pf.Linear:(n=Pf.Nearest,o=a=0);break;case u.TEXTURE_NEAREST_NEAREST_MIPLINEAR:i=Pf.Nearest,r=Pf.Nearest,s?n=Pf.Linear:(n=Pf.Nearest,o=a=0);break;case u.TEXTURE_NEAREST_NEAREST_MIPNEAREST:i=Pf.Nearest,r=Pf.Nearest,n=Pf.Nearest,s||(o=a=0);break;case u.TEXTURE_NEAREST_LINEAR_MIPNEAREST:i=Pf.Nearest,r=Pf.Linear,n=Pf.Nearest,s||(o=a=0);break;case u.TEXTURE_NEAREST_LINEAR_MIPLINEAR:i=Pf.Nearest,r=Pf.Linear,s?n=Pf.Linear:(n=Pf.Nearest,o=a=0);break;case u.TEXTURE_NEAREST_LINEAR:i=Pf.Nearest,r=Pf.Linear,n=Pf.Nearest,o=a=0;break;case u.TEXTURE_NEAREST_NEAREST:case u.TEXTURE_NEAREST_SAMPLINGMODE:i=Pf.Nearest,r=Pf.Nearest,n=Pf.Nearest,o=a=0;break;case u.TEXTURE_LINEAR_NEAREST_MIPNEAREST:i=Pf.Linear,r=Pf.Nearest,n=Pf.Nearest,s||(o=a=0);break;case u.TEXTURE_LINEAR_NEAREST_MIPLINEAR:i=Pf.Linear,r=Pf.Nearest,s?n=Pf.Linear:(n=Pf.Nearest,o=a=0);break;case u.TEXTURE_LINEAR_LINEAR:case u.TEXTURE_BILINEAR_SAMPLINGMODE:i=Pf.Linear,r=Pf.Linear,n=Pf.Nearest,o=a=0;break;case u.TEXTURE_LINEAR_NEAREST:i=Pf.Linear,r=Pf.Nearest,n=Pf.Nearest,o=a=0;break;default:i=Pf.Nearest,r=Pf.Nearest,n=Pf.Nearest,o=a=0}return t>1&&(0!==o||0!==a)&&n!==Pf.Nearest?{magFilter:Pf.Linear,minFilter:Pf.Linear,mipmapFilter:Pf.Linear,anisotropyEnabled:!0}:{magFilter:i,minFilter:r,mipmapFilter:n,lodMinClamp:o,lodMaxClamp:a}},e._GetWrappingMode=function(e){switch(e){case u.TEXTURE_WRAP_ADDRESSMODE:return Rf.Repeat;case u.TEXTURE_CLAMP_ADDRESSMODE:return Rf.ClampToEdge;case u.TEXTURE_MIRROR_ADDRESSMODE:return Rf.MirrorRepeat}return Rf.Repeat},e._GetSamplerWrappingDescriptor=function(e){return{addressModeU:this._GetWrappingMode(e._cachedWrapU),addressModeV:this._GetWrappingMode(e._cachedWrapV),addressModeW:this._GetWrappingMode(e._cachedWrapR)}},e._GetSamplerDescriptor=function(t,i){var r=t.useMipMaps&&t._cachedAnisotropicFilteringLevel&&t._cachedAnisotropicFilteringLevel>1?4:1,n=this._GetSamplerFilterDescriptor(t,r);return g(g(g({label:i},n),this._GetSamplerWrappingDescriptor(t)),{compare:t._comparisonFunction?e.GetCompareFunction(t._comparisonFunction):void 0,maxAnisotropy:n.anisotropyEnabled?r:1})},e.GetCompareFunction=function(e){switch(e){case u.ALWAYS:return Mf.Always;case u.EQUAL:return Mf.Equal;case u.GREATER:return Mf.Greater;case u.GEQUAL:return Mf.GreaterEqual;case u.LESS:return Mf.Less;case u.LEQUAL:return Mf.LessEqual;case u.NEVER:return Mf.Never;case u.NOTEQUAL:return Mf.NotEqual;default:return Mf.Less}},e.prototype.getSampler=function(t,i,r,n){if(void 0===i&&(i=!1),void 0===r&&(r=0),this.disabled)return this._device.createSampler(e._GetSamplerDescriptor(t,n));i?r=0:0===r&&(r=e.GetSamplerHashCode(t));var o=i?void 0:this._samplers[r];return o||(o=this._device.createSampler(e._GetSamplerDescriptor(t,n)),i||(this._samplers[r]=o)),o},e}();!function(e){e[e.StencilReadMask=0]="StencilReadMask",e[e.StencilWriteMask=1]="StencilWriteMask",e[e.DepthBias=2]="DepthBias",e[e.DepthBiasSlopeScale=3]="DepthBiasSlopeScale",e[e.DepthStencilState=4]="DepthStencilState",e[e.MRTAttachments1=5]="MRTAttachments1",e[e.MRTAttachments2=6]="MRTAttachments2",e[e.RasterizationState=7]="RasterizationState",e[e.ColorStates=8]="ColorStates",e[e.ShaderStage=9]="ShaderStage",e[e.TextureStage=10]="TextureStage",e[e.VertexState=11]="VertexState",e[e.NumStates=12]="NumStates"}(v_||(v_={}));var P_={0:1,1:2,768:3,769:4,770:5,771:6,772:7,773:8,774:9,775:10,776:11,32769:12,32770:13,32771:12,32772:13},I_={0:0,7680:1,7681:2,7682:3,7683:4,5386:5,34055:6,34056:7},M_=((g_={})[Nr.PositionKind]=!0,g_[Nr.NormalKind]=!0,g_[Nr.TangentKind]=!0,g_[Nr.UVKind]=!0,g_[Nr.UV2Kind]=!0,g_[Nr.UV3Kind]=!0,g_[Nr.UV4Kind]=!0,g_[Nr.UV5Kind]=!0,g_[Nr.UV6Kind]=!0,g_[Nr.ColorKind]=!0,g_[Nr.ColorInstanceKind]=!0,g_[Nr.MatricesIndicesKind]=!0,g_[Nr.MatricesWeightsKind]=!0,g_[Nr.MatricesIndicesExtraKind]=!0,g_[Nr.MatricesWeightsExtraKind]=!0,g_),O_=function(){function e(e,t){this.mrtTextureCount=0,this._device=e,this._useTextureStage=!0,this._states=new Array(30),this._statesLength=0,this._stateDirtyLowestIndex=0,this._emptyVertexBuffer=t,this._mrtFormats=[],this._parameter={token:void 0,pipeline:null},this.disabled=!1,this.vertexBuffers=[],this._kMaxVertexBufferStride=e.limits.maxVertexBufferArrayStride||2048,this.reset()}return e._IsSignedType=function(e){switch(e){case Nr.BYTE:case Nr.SHORT:case Nr.INT:case Nr.FLOAT:return!0;case Nr.UNSIGNED_BYTE:case Nr.UNSIGNED_SHORT:case Nr.UNSIGNED_INT:return!1;default:throw new Error("Invalid type '".concat(e,"'"))}},e.prototype.reset=function(){this._isDirty=!0,this.vertexBuffers.length=0,this.setAlphaToCoverage(!1),this.resetDepthCullingState(),this.setClampDepth(!1),this.setDepthBias(0),this._webgpuColorFormat=[Cf.BGRA8Unorm],this.setColorFormat(Cf.BGRA8Unorm),this.setMRT([]),this.setAlphaBlendEnabled(!1),this.setAlphaBlendFactors([null,null,null,null],[null,null]),this.setWriteMask(15),this.setDepthStencilFormat(Cf.Depth24PlusStencil8),this.setStencilEnabled(!1),this.resetStencilState(),this.setBuffers(null,null,null),this._setTextureState(0)},Object.defineProperty(e.prototype,"colorFormats",{get:function(){return this._mrtAttachments1>0?this._mrtFormats:this._webgpuColorFormat},enumerable:!1,configurable:!0}),e.prototype.getRenderPipeline=function(t,i,r,n){if(void 0===n&&(n=0),r=p_.GetSample(r),this.disabled){var o=e._GetTopology(t);return this._setVertexState(i),this._setTextureState(n),this._parameter.pipeline=this._createRenderPipeline(i,o,r),e.NumCacheMiss++,e._NumPipelineCreationCurrentFrame++,this._parameter.pipeline}if(this._setShaderStage(i.uniqueId),this._setRasterizationState(t,r),this._setColorStates(),this._setDepthStencilState(),this._setVertexState(i),this._setTextureState(n),this.lastStateDirtyLowestIndex=this._stateDirtyLowestIndex,!this._isDirty&&this._parameter.pipeline)return this._stateDirtyLowestIndex=this._statesLength,e.NumCacheHitWithoutHash++,this._parameter.pipeline;if(this._getRenderPipeline(this._parameter),this._isDirty=!1,this._stateDirtyLowestIndex=this._statesLength,this._parameter.pipeline)return e.NumCacheHitWithHash++,this._parameter.pipeline;var a=e._GetTopology(t);return this._parameter.pipeline=this._createRenderPipeline(i,a,r),this._setRenderPipeline(this._parameter),e.NumCacheMiss++,e._NumPipelineCreationCurrentFrame++,this._parameter.pipeline},e.prototype.endFrame=function(){e.NumPipelineCreationLastFrame=e._NumPipelineCreationCurrentFrame,e._NumPipelineCreationCurrentFrame=0},e.prototype.setAlphaToCoverage=function(e){this._alphaToCoverageEnabled=e},e.prototype.setFrontFace=function(e){this._frontFace=e},e.prototype.setCullEnabled=function(e){this._cullEnabled=e},e.prototype.setCullFace=function(e){this._cullFace=e},e.prototype.setClampDepth=function(e){this._clampDepth=e},e.prototype.resetDepthCullingState=function(){this.setDepthCullingState(!1,2,1,0,0,!0,!0,u.ALWAYS)},e.prototype.setDepthCullingState=function(e,t,i,r,n,o,a,s){this._depthWriteEnabled=a,this._depthTestEnabled=o,this._depthCompare=(null!=s?s:u.ALWAYS)-512,this._cullFace=i,this._cullEnabled=e,this._frontFace=t,this.setDepthBiasSlopeScale(r),this.setDepthBias(n)},e.prototype.setDepthBias=function(e){this._depthBias!==e&&(this._depthBias=e,this._states[v_.DepthBias]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.DepthBias))},e.prototype.setDepthBiasSlopeScale=function(e){this._depthBiasSlopeScale!==e&&(this._depthBiasSlopeScale=e,this._states[v_.DepthBiasSlopeScale]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.DepthBiasSlopeScale))},e.prototype.setColorFormat=function(e){this._webgpuColorFormat[0]=e,this._colorFormat=b_[null!=e?e:""]},e.prototype.setMRTAttachments=function(e){this.mrtAttachments=e;for(var t=0,i=0;i10)throw"Can't handle more than 10 attachments for a MRT in cache render pipeline!";this.mrtTextureArray=e,this.mrtTextureCount=t,this._mrtEnabledMask=65535;for(var n=[0,0],o=0,a=0,s=0,l=0;l=32&&(a=0,o++)}this._mrtFormats.length=s,this._mrtAttachments1===n[0]&&this._mrtAttachments2===n[1]||(this._mrtAttachments1=n[0],this._mrtAttachments2=n[1],this._states[v_.MRTAttachments1]=n[0],this._states[v_.MRTAttachments2]=n[1],this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.MRTAttachments1))},e.prototype.setAlphaBlendEnabled=function(e){this._alphaBlendEnabled=e},e.prototype.setAlphaBlendFactors=function(e,t){this._alphaBlendFuncParams=e,this._alphaBlendEqParams=t},e.prototype.setWriteMask=function(e){this._writeMask=e},e.prototype.setDepthStencilFormat=function(e){this._webgpuDepthStencilFormat=e,this._depthStencilFormat=void 0===e?0:b_[e]},e.prototype.setDepthTestEnabled=function(e){this._depthTestEnabled=e},e.prototype.setDepthWriteEnabled=function(e){this._depthWriteEnabled=e},e.prototype.setDepthCompare=function(e){this._depthCompare=(null!=e?e:u.ALWAYS)-512},e.prototype.setStencilEnabled=function(e){this._stencilEnabled=e},e.prototype.setStencilCompare=function(e){this._stencilFrontCompare=(null!=e?e:u.ALWAYS)-512},e.prototype.setStencilDepthFailOp=function(e){this._stencilFrontDepthFailOp=null===e?1:I_[e]},e.prototype.setStencilPassOp=function(e){this._stencilFrontPassOp=null===e?2:I_[e]},e.prototype.setStencilFailOp=function(e){this._stencilFrontFailOp=null===e?1:I_[e]},e.prototype.setStencilReadMask=function(e){this._stencilReadMask!==e&&(this._stencilReadMask=e,this._states[v_.StencilReadMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.StencilReadMask))},e.prototype.setStencilWriteMask=function(e){this._stencilWriteMask!==e&&(this._stencilWriteMask=e,this._states[v_.StencilWriteMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.StencilWriteMask))},e.prototype.resetStencilState=function(){this.setStencilState(!1,u.ALWAYS,u.KEEP,u.REPLACE,u.KEEP,255,255)},e.prototype.setStencilState=function(e,t,i,r,n,o,a){this._stencilEnabled=e,this._stencilFrontCompare=(null!=t?t:u.ALWAYS)-512,this._stencilFrontDepthFailOp=null===i?1:I_[i],this._stencilFrontPassOp=null===r?2:I_[r],this._stencilFrontFailOp=null===n?1:I_[n],this.setStencilReadMask(o),this.setStencilWriteMask(a)},e.prototype.setBuffers=function(e,t,i){this._vertexBuffers=e,this._overrideVertexBuffers=i,this._indexBuffer=t},e._GetTopology=function(e){switch(e){case u.MATERIAL_TriangleFillMode:return Vf.TriangleList;case u.MATERIAL_PointFillMode:return Vf.PointList;case u.MATERIAL_WireFrameFillMode:return Vf.LineList;case u.MATERIAL_PointListDrawMode:return Vf.PointList;case u.MATERIAL_LineListDrawMode:return Vf.LineList;case u.MATERIAL_LineLoopDrawMode:throw"LineLoop is an unsupported fillmode in WebGPU";case u.MATERIAL_LineStripDrawMode:return Vf.LineStrip;case u.MATERIAL_TriangleStripDrawMode:return Vf.TriangleStrip;case u.MATERIAL_TriangleFanDrawMode:throw"TriangleFan is an unsupported fillmode in WebGPU";default:return Vf.TriangleList}},e._GetAphaBlendOperation=function(e){switch(e){case u.GL_ALPHA_EQUATION_ADD:return Hf.Add;case u.GL_ALPHA_EQUATION_SUBTRACT:return Hf.Subtract;case u.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:return Hf.ReverseSubtract;case u.GL_ALPHA_EQUATION_MIN:return Hf.Min;case u.GL_ALPHA_EQUATION_MAX:return Hf.Max;default:return Hf.Add}},e._GetAphaBlendFactor=function(e){switch(e){case 0:return Wf.Zero;case 1:return Wf.One;case u.GL_ALPHA_FUNCTION_SRC:return Wf.Src;case u.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:return Wf.OneMinusSrc;case u.GL_ALPHA_FUNCTION_SRC_ALPHA:return Wf.SrcAlpha;case u.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:return Wf.OneMinusSrcAlpha;case u.GL_ALPHA_FUNCTION_DST_ALPHA:return Wf.DstAlpha;case u.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:return Wf.OneMinusDstAlpha;case u.GL_ALPHA_FUNCTION_DST_COLOR:return Wf.Dst;case u.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:return Wf.OneMinusDst;case u.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:return Wf.SrcAlphaSaturated;case u.GL_ALPHA_FUNCTION_CONSTANT_COLOR:return Wf.Constant;case u.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:return Wf.OneMinusConstant;case u.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:return Wf.Constant;case u.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:return Wf.OneMinusConstant;default:return Wf.One}},e._GetCompareFunction=function(e){switch(e){case 0:return Mf.Never;case 1:return Mf.Less;case 2:return Mf.Equal;case 3:return Mf.LessEqual;case 4:return Mf.Greater;case 5:return Mf.NotEqual;case 6:return Mf.GreaterEqual;case 7:return Mf.Always}return Mf.Never},e._GetStencilOpFunction=function(e){switch(e){case 0:return Xf.Zero;case 1:return Xf.Keep;case 2:return Xf.Replace;case 3:return Xf.IncrementClamp;case 4:return Xf.DecrementClamp;case 5:return Xf.Invert;case 6:return Xf.IncrementWrap;case 7:return Xf.DecrementWrap}return Xf.Keep},e._GetVertexInputDescriptorFormat=function(e){var t=e.type,i=e.normalized,r=e.getSize();switch(t){case Nr.BYTE:switch(r){case 1:case 2:return i?Yf.Snorm8x2:Yf.Sint8x2;case 3:case 4:return i?Yf.Snorm8x4:Yf.Sint8x4}break;case Nr.UNSIGNED_BYTE:switch(r){case 1:case 2:return i?Yf.Unorm8x2:Yf.Uint8x2;case 3:case 4:return i?Yf.Unorm8x4:Yf.Uint8x4}break;case Nr.SHORT:switch(r){case 1:case 2:return i?Yf.Snorm16x2:Yf.Sint16x2;case 3:case 4:return i?Yf.Snorm16x4:Yf.Sint16x4}break;case Nr.UNSIGNED_SHORT:switch(r){case 1:case 2:return i?Yf.Unorm16x2:Yf.Uint16x2;case 3:case 4:return i?Yf.Unorm16x4:Yf.Uint16x4}break;case Nr.INT:switch(r){case 1:return Yf.Sint32;case 2:return Yf.Sint32x2;case 3:return Yf.Sint32x3;case 4:return Yf.Sint32x4}break;case Nr.UNSIGNED_INT:switch(r){case 1:return Yf.Uint32;case 2:return Yf.Uint32x2;case 3:return Yf.Uint32x3;case 4:return Yf.Uint32x4}break;case Nr.FLOAT:switch(r){case 1:return Yf.Float32;case 2:return Yf.Float32x2;case 3:return Yf.Float32x3;case 4:return Yf.Float32x4}}throw new Error("Invalid Format '".concat(e.getKind(),"' - type=").concat(t,", normalized=").concat(i,", size=").concat(r))},e.prototype._getAphaBlendState=function(){return this._alphaBlendEnabled?{srcFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),dstFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),operation:e._GetAphaBlendOperation(this._alphaBlendEqParams[1])}:null},e.prototype._getColorBlendState=function(){return this._alphaBlendEnabled?{srcFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),dstFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),operation:e._GetAphaBlendOperation(this._alphaBlendEqParams[0])}:null},e.prototype._setShaderStage=function(e){this._shaderId!==e&&(this._shaderId=e,this._states[v_.ShaderStage]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.ShaderStage))},e.prototype._setRasterizationState=function(e,t){var i=this._frontFace-1+((this._cullEnabled?this._cullFace:0)<<1)+((this._clampDepth?1:0)<<3)+((this._alphaToCoverageEnabled?1:0)<<4)+(e<<5)+(t<<8);this._rasterizationState!==i&&(this._rasterizationState=i,this._states[v_.RasterizationState]=this._rasterizationState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.RasterizationState))},e.prototype._setColorStates=function(){var e=((this._writeMask?1:0)<<22)+(this._colorFormat<<23)+((this._depthWriteEnabled?1:0)<<29);this._alphaBlendEnabled&&(e+=(0|(null===this._alphaBlendFuncParams[0]?2:P_[this._alphaBlendFuncParams[0]]))+((null===this._alphaBlendFuncParams[1]?2:P_[this._alphaBlendFuncParams[1]])<<4)+((null===this._alphaBlendFuncParams[2]?2:P_[this._alphaBlendFuncParams[2]])<<8)+((null===this._alphaBlendFuncParams[3]?2:P_[this._alphaBlendFuncParams[3]])<<12)+((null===this._alphaBlendEqParams[0]?1:this._alphaBlendEqParams[0]-32773)<<16)+((null===this._alphaBlendEqParams[1]?1:this._alphaBlendEqParams[1]-32773)<<19)),e!==this._colorStates&&(this._colorStates=e,this._states[v_.ColorStates]=this._colorStates,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.ColorStates))},e.prototype._setDepthStencilState=function(){var e=this._stencilEnabled?this._stencilFrontCompare+(this._stencilFrontDepthFailOp<<3)+(this._stencilFrontPassOp<<6)+(this._stencilFrontFailOp<<9):591,t=this._depthStencilFormat+((this._depthTestEnabled?this._depthCompare:7)<<6)+(e<<10);this._depthStencilState!==t&&(this._depthStencilState=t,this._states[v_.DepthStencilState]=this._depthStencilState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,v_.DepthStencilState))},e.prototype._setVertexState=function(e){for(var t,i,r,n=this._statesLength,o=v_.VertexState,a=e._pipelineContext,s=a.shaderProcessingContext.attributeNamesFromEffect,l=a.shaderProcessingContext.attributeLocationsFromEffect,c=0,u=0;u0)for(var p=0;p=this._video.HAVE_CURRENT_DATA},e.prototype.dispose=function(){},e}(),B_=function(){function e(){this.uniqueId=e._Counter++,this.updateId=0,this.textureState=0,this.reset()}return Object.defineProperty(e.prototype,"forceBindGroupCreation",{get:function(){return this._numExternalTextures>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasFloatOrDepthTextures",{get:function(){return this._numFloatOrDepthTextures>0},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this.samplers={},this.textures={},this.isDirty=!0,this._numFloatOrDepthTextures=0,this._numExternalTextures=0},e.prototype.setSampler=function(e,t){var i=this.samplers[e],r=-1;i?r=i.hashCode:this.samplers[e]=i={sampler:t,hashCode:0},i.sampler=t,i.hashCode=t?R_.GetSamplerHashCode(t):0;var n=r!==i.hashCode;n&&this.updateId++,this.isDirty||(this.isDirty=n)},e.prototype.setTexture=function(e,t){var i,r,n,o=this.textures[e],a=-1;o?a=null!==(r=null===(i=o.texture)||void 0===i?void 0:i.uniqueId)&&void 0!==r?r:-1:this.textures[e]=o={texture:t,isFloatOrDepthTexture:!1,isExternalTexture:!1},o.isExternalTexture&&this._numExternalTextures--,o.isFloatOrDepthTexture&&this._numFloatOrDepthTextures--,t?(o.isFloatOrDepthTexture=t.type===u.TEXTURETYPE_FLOAT||t.format>=u.TEXTUREFORMAT_DEPTH24_STENCIL8&&t.format<=u.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8,o.isExternalTexture=w_.IsExternalTexture(t),o.isFloatOrDepthTexture&&this._numFloatOrDepthTextures++,o.isExternalTexture&&this._numExternalTextures++):(o.isFloatOrDepthTexture=!1,o.isExternalTexture=!1),o.texture=t;var s=a!==(null!==(n=null==t?void 0:t.uniqueId)&&void 0!==n?n:-1);s&&this.updateId++,this.isDirty||(this.isDirty=s)},e._Counter=0,e}(),U_=function(){function e(t){this._bufferManager=t,this.uniqueId=e._Counter++,this._useInstancing=!1,this._currentInstanceCount=0,this.reset()}return e.prototype.isDirty=function(e){return this._isDirty||this._materialContextUpdateId!==e},e.prototype.resetIsDirty=function(e){this._isDirty=!1,this._materialContextUpdateId=e},Object.defineProperty(e.prototype,"useInstancing",{get:function(){return this._useInstancing},set:function(e){this._useInstancing!==e&&(e?(this.indirectDrawBuffer=this._bufferManager.createRawBuffer(20,bf.CopyDst|bf.Indirect|bf.Storage,void 0,"IndirectDrawBuffer"),this._indirectDrawData=new Uint32Array(5),this._indirectDrawData[3]=0,this._indirectDrawData[4]=0):(this.indirectDrawBuffer&&this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this._useInstancing=e,this._currentInstanceCount=-1)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this.buffers={},this._isDirty=!0,this._materialContextUpdateId=0,this.fastBundle=void 0,this.bindGroups=void 0},e.prototype.setBuffer=function(e,t){var i;this._isDirty||(this._isDirty=(null==t?void 0:t.uniqueId)!==(null===(i=this.buffers[e])||void 0===i?void 0:i.uniqueId)),this.buffers[e]=t},e.prototype.setIndirectData=function(e,t,i){t!==this._currentInstanceCount&&this.indirectDrawBuffer&&this._indirectDrawData&&(this._currentInstanceCount=t,this._indirectDrawData[0]=e,this._indirectDrawData[1]=t,this._indirectDrawData[2]=i,this._bufferManager.setRawData(this.indirectDrawBuffer,0,this._indirectDrawData,0,20))},e.prototype.dispose=function(){this.indirectDrawBuffer&&(this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this.fastBundle=void 0,this.bindGroups=void 0,this.buffers=void 0},e._Counter=0,e}(),V_=function(){this.values={}},k_=function(){function e(e,t,i){this.disabled=!1,this._device=e,this._cacheSampler=t,this._engine=i}return Object.defineProperty(e,"Statistics",{get:function(){return{totalCreated:e.NumBindGroupsCreatedTotal,lastFrameCreated:e.NumBindGroupsCreatedLastFrame,lookupLastFrame:e.NumBindGroupsLookupLastFrame,noLookupLastFrame:e.NumBindGroupsNoLookupLastFrame}},enumerable:!1,configurable:!0}),e.ResetCache=function(){e._Cache=new V_,e.NumBindGroupsCreatedTotal=0,e.NumBindGroupsCreatedLastFrame=0,e.NumBindGroupsLookupLastFrame=0,e.NumBindGroupsNoLookupLastFrame=0,e._NumBindGroupsCreatedCurrentFrame=0,e._NumBindGroupsLookupCurrentFrame=0,e._NumBindGroupsNoLookupCurrentFrame=0},e.prototype.endFrame=function(){e.NumBindGroupsCreatedLastFrame=e._NumBindGroupsCreatedCurrentFrame,e.NumBindGroupsLookupLastFrame=e._NumBindGroupsLookupCurrentFrame,e.NumBindGroupsNoLookupLastFrame=e._NumBindGroupsNoLookupCurrentFrame,e._NumBindGroupsCreatedCurrentFrame=0,e._NumBindGroupsLookupCurrentFrame=0,e._NumBindGroupsNoLookupCurrentFrame=0},e.prototype.getBindGroups=function(t,i,r){var n,o,a,s,l,c,u,h,d,p,f=void 0,_=e._Cache,m=this.disabled||r.forceBindGroupCreation;if(!m){if(!i.isDirty(r.updateId)&&!r.isDirty)return e._NumBindGroupsNoLookupCurrentFrame++,i.bindGroups;for(var g=0,v=t.shaderProcessingContext.bufferNames;g":t})),", materialContext.uniqueId=").concat(r.uniqueId),50);continue}N[F].resource=this._cacheSampler.getSampler(U,!1,k.hashCode,U.label)}else ae.Error('Sampler "'.concat(B,'" could not be bound. entry=').concat(JSON.stringify(L),", materialContext=").concat(JSON.stringify(r,(function(e,t){return"texture"===e||"sampler"===e?"":t}))),50);else if(L.texture||L.storageTexture)if(k=r.textures[B]){if(this._engine.dbgSanityChecks&&null===k.texture){ae.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(L),", bindingInfo=").concat(JSON.stringify(k,(function(e,t){return"texture"===e?"":t})),", materialContext.uniqueId=").concat(r.uniqueId),50);continue}var V=k.texture._hardwareTexture;if(this._engine.dbgSanityChecks&&(!V||L.texture&&!V.view||L.storageTexture&&!V.viewForWriting)){ae.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(L),", name=").concat(B,", bindingInfo=").concat(JSON.stringify(k,(function(e,t){return"texture"===e?"":t})),", isReady=").concat(null===(d=k.texture)||void 0===d?void 0:d.isReady,", materialContext.uniqueId=").concat(r.uniqueId),50);continue}N[F].resource=L.storageTexture?V.viewForWriting:V.view}else ae.Error('Texture "'.concat(B,'" could not be bound. entry=').concat(JSON.stringify(L),", materialContext=").concat(JSON.stringify(r,(function(e,t){return"texture"===e||"sampler"===e?"":t}))),50);else if(L.externalTexture){var k;if(k=r.textures[B]){if(this._engine.dbgSanityChecks&&null===k.texture){ae.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(L),", name=").concat(B,", bindingInfo=").concat(JSON.stringify(k,(function(e,t){return"texture"===e?"":t})),", materialContext.uniqueId=").concat(r.uniqueId),50);continue}var G=k.texture.underlyingResource;if(this._engine.dbgSanityChecks&&!G){ae.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(L),", name=").concat(B,", bindingInfo=").concat(JSON.stringify(k,(function(e,t){return"texture"===e?"":t})),", isReady=").concat(null===(p=k.texture)||void 0===p?void 0:p.isReady,", materialContext.uniqueId=").concat(r.uniqueId),50);continue}N[F].resource=this._device.importExternalTexture({source:G})}else ae.Error('Texture "'.concat(B,'" could not be bound. entry=').concat(JSON.stringify(L),", materialContext=").concat(JSON.stringify(r,(function(e,t){return"texture"===e||"sampler"===e?"":t}))),50)}else if(L.buffer){var z=i.buffers[B];if(z){var W=z.underlyingResource;N[F].resource.buffer=W,N[F].resource.size=z.capacity}else ae.Error("Can't find buffer \"".concat(B,'". entry=').concat(JSON.stringify(L),", buffers=").concat(JSON.stringify(i.buffers),", drawContext.uniqueId=").concat(i.uniqueId),50)}}var H=M[O];f[O]=this._device.createBindGroup({layout:H,entries:N})}return f},e.NumBindGroupsCreatedTotal=0,e.NumBindGroupsCreatedLastFrame=0,e.NumBindGroupsLookupLastFrame=0,e.NumBindGroupsNoLookupLastFrame=0,e._Cache=new V_,e._NumBindGroupsCreatedCurrentFrame=0,e._NumBindGroupsLookupCurrentFrame=0,e._NumBindGroupsNoLookupCurrentFrame=0,e}();li.ShadersStoreWGSL.clearQuadVertexShader="uniform depthValue: f32;const pos=array(\nvec2f(-1.0,1.0),\nvec2f(1.0,1.0),\nvec2f(-1.0,-1.0),\nvec2f(1.0,-1.0)\n);\n#define CUSTOM_VERTEX_DEFINITIONS\n@vertex\nfn main(input : VertexInputs)->FragmentInputs {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvertexOutputs.position=vec4f(pos[input.vertexIndex],uniforms.depthValue,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n";li.ShadersStoreWGSL.clearQuadPixelShader="uniform color: vec4f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=uniforms.color;}\n";var G_=function(){function e(e,t,i){this._bindGroups={},this._bundleCache={},this._keyTemp=[],this._device=e,this._engine=t,this._cacheRenderPipeline=new N_(this._device,i),this._cacheRenderPipeline.setDepthTestEnabled(!1),this._cacheRenderPipeline.setStencilReadMask(255),this._effect=t.createEffect("clearQuad",[],["color","depthValue"],void 0,void 0,void 0,void 0,void 0,void 0,pt.WGSL)}return e.prototype.setDepthStencilFormat=function(e){this._depthTextureFormat=e,this._cacheRenderPipeline.setDepthStencilFormat(e)},e.prototype.setColorFormat=function(e){this._cacheRenderPipeline.setColorFormat(e)},e.prototype.setMRTAttachments=function(e,t,i){this._cacheRenderPipeline.setMRT(t,i),this._cacheRenderPipeline.setMRTAttachments(e)},e.prototype.clear=function(e,t,i,r,n){var o,a,s;void 0===n&&(n=1);var l,c=null,h=!!this._engine._currentRenderTarget;if(e)s=e;else{var d=0;this._keyTemp.length=0;for(var p=0;p1?Math.pow(2,36):0)+f*Math.pow(2,37),l=this._keyTemp.join("_"),c=this._bundleCache[l])return c;s=this._device.createRenderBundleEncoder({label:"clearQuadRenderBundle",colorFormats:this._cacheRenderPipeline.colorFormats,depthStencilFormat:this._depthTextureFormat,sampleCount:p_.GetSample(n)})}this._cacheRenderPipeline.setDepthWriteEnabled(!!i),this._cacheRenderPipeline.setStencilEnabled(!!r&&!!this._depthTextureFormat&&p_.HasStencilAspect(this._depthTextureFormat)),this._cacheRenderPipeline.setStencilWriteMask(r?255:0),this._cacheRenderPipeline.setStencilCompare(r?u.ALWAYS:u.NEVER),this._cacheRenderPipeline.setStencilPassOp(r?u.REPLACE:u.KEEP),this._cacheRenderPipeline.setWriteMask(t?15:0);var _=this._cacheRenderPipeline.getRenderPipeline(u.MATERIAL_TriangleStripDrawMode,this._effect,n),m=this._effect._pipelineContext;t&&this._effect.setDirectColor4("color",t),this._effect.setFloat("depthValue",this._engine.useReverseDepthBuffer?this._engine._clearReverseDepthValue:this._engine._clearDepthValue),m.uniformBuffer.update();var g=h?this._engine._ubInvertY:this._engine._ubDontInvertY,v=m.uniformBuffer.getBuffer(),y=v.uniqueId+"-"+g.uniqueId,b=this._bindGroups[y];if(!b){var T=m.bindGroupLayouts[0];(b=this._bindGroups[y]=[]).push(this._device.createBindGroup({label:"clearQuadBindGroup0-".concat(y),layout:T[0],entries:[]})),s_._SimplifiedKnownBindings||b.push(this._device.createBindGroup({label:"clearQuadBindGroup1-".concat(y),layout:T[1],entries:[]})),b.push(this._device.createBindGroup({label:"clearQuadBindGroup".concat(s_._SimplifiedKnownBindings?1:2,"-").concat(y),layout:T[s_._SimplifiedKnownBindings?1:2],entries:[{binding:0,resource:{buffer:g.underlyingResource,size:g.capacity}},{binding:1,resource:{buffer:v.underlyingResource,size:v.capacity}}]}))}for(s.setPipeline(_),p=0;p=0&&(t._gpuFrameTimeCounter.fetchNewFrame(),t._gpuFrameTimeCounter.addCount(e,!0)),t._measureDurationState=0})))},e.prototype.startPass=function(e,t){this._enabled?this._measureDuration.startPass(e,t):e.timestampWrites=void 0},e.prototype.endPass=function(e,t){if(this._enabled&&t){var i=this._engine.frameId;this._measureDuration.stopPass(e).then((function(e){t._addDuration(i,null!==e&&e>0?e:0)}))}},e.prototype.dispose=function(){var e;null===(e=this._measureDuration)||void 0===e||e.dispose()},e}(),J_=function(){function e(e,t,i,r,n){void 0===r&&(r=2),this._count=r,this._querySet=new q_(e,r,$f.Timestamp,t,i,!0,n)}return e.prototype.start=function(e){var t;null===(t=e.writeTimestamp)||void 0===t||t.call(e,this._querySet.querySet,0)},e.prototype.stop=function(e){var t;return y(this,void 0,void 0,(function(){return b(this,(function(i){return null===(t=e.writeTimestamp)||void 0===t||t.call(e,this._querySet.querySet,1),[2,e.writeTimestamp?this._querySet.readTwoValuesAndSubtract(0):0]}))}))},e.prototype.startPass=function(e,t){if(t+3>this._count)throw new Error("WebGPUDurationMeasure: index out of range ("+t+")");e.timestampWrites={querySet:this._querySet.querySet,beginningOfPassWriteIndex:t+2,endOfPassWriteIndex:t+3}},e.prototype.stopPass=function(e){return y(this,void 0,void 0,(function(){return b(this,(function(t){return[2,this._querySet.readTwoValuesAndSubtract(e+2)]}))}))},e.prototype.dispose=function(){this._querySet.dispose()},e}(),$_=function(){function e(e,t,i,r,n){void 0===r&&(r=50),void 0===n&&(n=100),this._availableIndices=[],this._frameQuerySetIsDirty=-1,this._queryFrameId=[],this._engine=e,this._device=t,this._bufferManager=i,this._frameLastBuffer=-1,this._currentTotalIndices=0,this._countIncrement=n,this._allocateNewIndices(r)}return Object.defineProperty(e.prototype,"querySet",{get:function(){return this._querySet.querySet},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasQueries",{get:function(){return this._currentTotalIndices!==this._availableIndices.length},enumerable:!1,configurable:!0}),e.prototype.canBeginQuery=function(e){if(this._frameQuerySetIsDirty===this._engine.frameId||this._queryFrameId[e]===this._engine.frameId)return!1;var t=void 0!==this._engine._getCurrentRenderPassWrapper().renderPassDescriptor.occlusionQuerySet;return t&&(this._queryFrameId[e]=this._engine.frameId),t},e.prototype.createQuery=function(){0===this._availableIndices.length&&this._allocateNewIndices();var e=this._availableIndices[this._availableIndices.length-1];return this._availableIndices.length--,e},e.prototype.deleteQuery=function(e){this._availableIndices[this._availableIndices.length]=e},e.prototype.isQueryResultAvailable=function(e){return this._retrieveQueryBuffer(),!!this._lastBuffer&&e=this._allBundleLists.length)throw new Error("Invalid playBundleListIndex! Your snapshot is no longer valid for the current frame, you should recreate a new one. playBundleListIndex=".concat(this._playBundleListIndex,", allBundleLists.length=").concat(this._allBundleLists.length,"}"));t=this._allBundleLists[this._playBundleListIndex++]}return t.run(e),this._mode===u.SNAPSHOTRENDERING_FAST&&this._engine._reportDrawCall(t.numDrawCalls),!0},e.prototype.endFrame=function(){this._record&&(this._record=!1,this._play=!0,this._mode=this._modeSaved),this._playBundleListIndex=0},e.prototype.reset=function(){this.enabled=!1,this.enabled=!0},e}();li.ShadersStoreWGSL.postprocessVertexShader="attribute position: vec2;uniform scale: vec2;varying vUV: vec2;const madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\n@vertex\nfn main(input : VertexInputs)->FragmentInputs {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;vertexOutputs.position=vec4(vertexInputs.position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var im=function(e){function t(t){return e.call(this,t)||this}return m(t,e),t}(w_),rm={label:"TextureView_SwapChain_ResolveTarget",dimension:Ef.E2d,format:void 0,mipLevelCount:1,arrayLayerCount:1},nm={label:"TextureView_SwapChain",dimension:Ef.E2d,format:void 0,mipLevelCount:1,arrayLayerCount:1},om="/* disable_uniformity_analysis */",am=new J,sm=function(e){function t(t,i){void 0===i&&(i={});var r,n,o=this;return(o=e.call(this,null===(r=i.antialias)||void 0===r||r,i)||this).uniqueId=-1,o._uploadEncoderDescriptor={label:"upload"},o._renderEncoderDescriptor={label:"render"},o._clearDepthValue=1,o._clearReverseDepthValue=0,o._clearStencilValue=0,o._defaultSampleCount=4,o._glslang=null,o._tintWASM=null,o._adapterInfo={vendor:"",architecture:"",device:"",description:""},o._timestampIndex=0,o._compiledComputeEffects={},o._counters={numEnableEffects:0,numEnableDrawWrapper:0,numBundleCreationNonCompatMode:0,numBundleReuseNonCompatMode:0},o.countersLastFrame={numEnableEffects:0,numEnableDrawWrapper:0,numBundleCreationNonCompatMode:0,numBundleReuseNonCompatMode:0},o.numMaxUncapturedErrors=20,o.scenes=[],o._virtualScenes=new Array,o._commandBuffers=[null,null],o._currentRenderPass=null,o._mainRenderPassWrapper={renderPassDescriptor:null,colorAttachmentViewDescriptor:null,depthAttachmentViewDescriptor:null,colorAttachmentGPUTextures:[],depthTextureFormat:void 0},o._rttRenderPassWrapper={renderPassDescriptor:null,colorAttachmentViewDescriptor:null,depthAttachmentViewDescriptor:null,colorAttachmentGPUTextures:[],depthTextureFormat:void 0},o._pendingDebugCommands=[],o._currentOverrideVertexBuffers=null,o._currentIndexBuffer=null,o._colorWriteLocal=!0,o._forceEnableEffect=!1,o.dbgShowShaderCode=!1,o.dbgSanityChecks=!0,o.dbgVerboseLogsForFirstFrames=!1,o.dbgVerboseLogsNumFrames=10,o.dbgLogIfNotDrawWrapper=!0,o.dbgShowEmptyEnableEffectCalls=!0,o._snapshotRenderingMode=u.SNAPSHOTRENDERING_STANDARD,o.isNDCHalfZRange=!0,o.hasOriginBottomLeft=!1,o._viewportsCurrent={x:0,y:0,w:0,h:0},o._scissorsCurrent={x:0,y:0,w:0,h:0},o._scissorCached={x:0,y:0,z:0,w:0},o._stencilRefsCurrent=-1,o._blendColorsCurrent=[null,null,null,null],o._performanceMonitor=new yo,o._name="WebGPU",o._drawCalls=new an,i.deviceDescriptor=i.deviceDescriptor||{},i.enableGPUDebugMarkers=null!==(n=i.enableGPUDebugMarkers)&&void 0!==n&&n,ae.Log("Babylon.js v".concat(Do.Version," - ").concat(o.description," engine")),navigator.gpu?(i.swapChainFormat=i.swapChainFormat||navigator.gpu.getPreferredCanvasFormat(),o._isWebGPU=!0,o._shaderPlatformName="WEBGPU",o._renderingCanvas=t,o._options=i,o._mainPassSampleCount=i.antialias?o._defaultSampleCount:1,navigator&&navigator.userAgent&&o._setupMobileChecks(),o._sharedInit(o._renderingCanvas),o._shaderProcessor=new l_,o._shaderProcessorWGSL=new d_,o):(ae.Error("WebGPU is not supported by your browser."),o)}return m(t,e),Object.defineProperty(t.prototype,"snapshotRenderingMode",{get:function(){return this._snapshotRendering.mode},set:function(e){this._snapshotRendering.mode=e},enumerable:!1,configurable:!0}),t.prototype.snapshotRenderingReset=function(){this._snapshotRendering.reset()},Object.defineProperty(t.prototype,"snapshotRendering",{get:function(){return this._snapshotRendering.enabled},set:function(e){this._snapshotRendering.enabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableCacheSamplers",{get:function(){return!!this._cacheSampler&&this._cacheSampler.disabled},set:function(e){this._cacheSampler&&(this._cacheSampler.disabled=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableCacheRenderPipelines",{get:function(){return!!this._cacheRenderPipeline&&this._cacheRenderPipeline.disabled},set:function(e){this._cacheRenderPipeline&&(this._cacheRenderPipeline.disabled=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableCacheBindGroups",{get:function(){return!!this._cacheBindGroups&&this._cacheBindGroups.disabled},set:function(e){this._cacheBindGroups&&(this._cacheBindGroups.disabled=e)},enumerable:!1,configurable:!0}),t.prototype.areAllEffectsReady=function(){return!0},t.prototype.getFontOffset=function(e){return xo(e)},Object.defineProperty(t,"IsSupportedAsync",{get:function(){return navigator.gpu?navigator.gpu.requestAdapter().then((function(e){return!!e}),(function(){return!1})).catch((function(){return!1})):Promise.resolve(!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){return ae.Warn("You must call IsSupportedAsync for WebGPU!"),!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportsUniformBuffers",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportedExtensions",{get:function(){return this._adapterSupportedExtensions},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enabledExtensions",{get:function(){return this._deviceEnabledExtensions},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportedLimits",{get:function(){return this._adapterSupportedLimits},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentLimits",{get:function(){return this._deviceLimits},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"description",{get:function(){return this.name+this.version},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return 1},enumerable:!1,configurable:!0}),t.prototype.getInfo=function(){return{vendor:this._adapterInfo.vendor||"unknown vendor",renderer:this._adapterInfo.architecture||"unknown renderer",version:this._adapterInfo.description||"unknown version"}},Object.defineProperty(t.prototype,"compatibilityMode",{get:function(){return this._compatibilityMode},set:function(e){this._compatibilityMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableGPUTimingMeasurements",{get:function(){return this._timestampQuery.enable},set:function(e){this._timestampQuery.enable!==e&&(this.gpuTimeInFrameForMainPass=e?new vh:void 0,this._timestampQuery.enable=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentSampleCount",{get:function(){return this._currentRenderTarget?this._currentRenderTarget.samples:this._mainPassSampleCount},enumerable:!1,configurable:!0}),t.CreateAsync=function(e,i){void 0===i&&(i={});var r=new t(e,i);return new Promise((function(e){r.initAsync(i.glslangOptions,i.twgslOptions).then((function(){return e(r)}))}))},t.prototype.initAsync=function(e,i){var r,n=this;return this.uniqueId=t._InstanceId++,this._glslangOptions=e,this._twgslOptions=i,this._initGlslang(null!=e?e:null===(r=this._options)||void 0===r?void 0:r.glslangOptions).then((function(e){var r;return n._glslang=e,n._tintWASM=t.UseTWGSL?new em:null,n._tintWASM?n._tintWASM.initTwgsl(null!=i?i:null===(r=n._options)||void 0===r?void 0:r.twgslOptions).then((function(){return navigator.gpu.requestAdapter(n._options)})):navigator.gpu.requestAdapter(n._options)})).then((function(e){var t,i,r;if(e){n._adapter=e,n._adapterSupportedExtensions=[],null===(t=n._adapter.features)||void 0===t||t.forEach((function(e){return n._adapterSupportedExtensions.push(e)})),n._adapterSupportedLimits=n._adapter.limits,n._adapter.requestAdapterInfo().then((function(e){n._adapterInfo=e}));var o=null!==(i=n._options.deviceDescriptor)&&void 0!==i?i:{},a=null!==(r=null==o?void 0:o.requiredFeatures)&&void 0!==r?r:n._options.enableAllFeatures?n._adapterSupportedExtensions:void 0;if(a){for(var s=[],l=0,c=a;l=0||void 0,s3tc:this._deviceEnabledExtensions.indexOf(vf.TextureCompressionBC)>=0||void 0,pvrtc:null,etc1:null,etc2:this._deviceEnabledExtensions.indexOf(vf.TextureCompressionETC2)>=0||void 0,bptc:this._deviceEnabledExtensions.indexOf(vf.TextureCompressionBC)>=0||void 0,maxAnisotropy:16,uintIndices:!0,fragmentDepthSupported:!0,highPrecisionShaderSupported:!0,colorBufferFloat:!0,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:this._deviceEnabledExtensions.indexOf(vf.RG11B10UFloatRenderable)>=0,textureFloat:!0,textureFloatLinearFiltering:this._deviceEnabledExtensions.indexOf(vf.Float32Filterable)>=0,textureFloatRender:!0,textureHalfFloat:!0,textureHalfFloatLinearFiltering:!0,textureHalfFloatRender:!0,textureLOD:!0,texelFetch:!0,drawBuffersExtension:!0,depthTextureExtension:!0,vertexArrayObject:!1,instancedArrays:!0,timerQuery:"undefined"!=typeof BigUint64Array&&-1!==this._deviceEnabledExtensions.indexOf(vf.TimestampQuery)||void 0,supportOcclusionQuery:"undefined"!=typeof BigUint64Array,canUseTimestampForTimerQuery:!0,multiview:!1,oculusMultiview:!1,parallelShaderCompile:void 0,blendMinMax:!0,maxMSAASamples:4,canUseGLInstanceID:!0,canUseGLVertexID:!0,supportComputeShaders:!0,supportSRGBBuffers:!0,supportTransformFeedbacks:!1,textureMaxLevel:!0,texture2DArrayMaxLayerCount:this._deviceLimits.maxTextureArrayLayers,disableMorphTargetTexture:!1},this._features={forceBitmapOverHTMLImageElement:!0,supportRenderAndCopyToLodForFloatTextures:!0,supportDepthStencilTexture:!0,supportShadowSamplers:!0,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:!0,trackUbosInFrame:!0,checkUbosContentBeforeUpload:!0,supportCSM:!0,basisNeedsPOT:!1,support3DTextures:!0,needTypeSuffixInShaderConstants:!0,supportMSAA:!0,supportSSAO2:!0,supportExtendedTextureFormats:!0,supportSwitchCaseInShader:!0,supportSyncTextureRead:!1,needsInvertingBitmap:!1,useUBOBindingCache:!1,needShaderCodeInlining:!0,needToAlwaysBindUniformBuffers:!0,supportRenderPasses:!0,supportSpriteInstancing:!0,forceVertexBufferStrideAndOffsetMultiple4Bytes:!0,_collectUbosUpdatedInFrame:!1}},t.prototype._initializeContextAndSwapChain=function(){if(!this._renderingCanvas)throw"The rendering canvas has not been set!";this._context=this._renderingCanvas.getContext("webgpu"),this._configureContext(),this._colorFormat=this._options.swapChainFormat,this._mainRenderPassWrapper.colorAttachmentGPUTextures=[new f_],this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format=this._colorFormat,this._setColorFormat(this._mainRenderPassWrapper)},t.prototype._initializeMainAttachments=function(){if(this._bufferManager){this.flushFramebuffer(),this._mainTextureExtends={width:this.getRenderWidth(!0),height:this.getRenderHeight(!0),depthOrArrayLayers:1};var e,t=new Float32Array([this.getRenderHeight(!0)]);if(this._bufferManager.setSubData(this._ubInvertY,4,t),this._bufferManager.setSubData(this._ubDontInvertY,4,t),this._options.antialias){var i={label:"Texture_MainColor_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height,"_antialiasing"),size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:Ef.E2d,format:this._options.swapChainFormat,usage:Sf.RenderAttachment};this._mainTexture&&this._textureHelper.releaseTexture(this._mainTexture),this._mainTexture=this._device.createTexture(i),e=[{view:this._mainTexture.createView({label:"TextureView_MainColor_antialiasing",dimension:Ef.E2d,format:this._options.swapChainFormat,mipLevelCount:1,arrayLayerCount:1}),clearValue:new J(0,0,0,1),loadOp:Zf.Clear,storeOp:Jf.Store}]}else e=[{view:void 0,clearValue:new J(0,0,0,1),loadOp:Zf.Clear,storeOp:Jf.Store}];this._mainRenderPassWrapper.depthTextureFormat=this.isStencilEnable?Cf.Depth24PlusStencil8:Cf.Depth32Float,this._setDepthTextureFormat(this._mainRenderPassWrapper),this._setColorFormat(this._mainRenderPassWrapper);var r={label:"Texture_MainDepthStencil_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height),size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:Ef.E2d,format:this._mainRenderPassWrapper.depthTextureFormat,usage:Sf.RenderAttachment};this._depthTexture&&this._textureHelper.releaseTexture(this._depthTexture),this._depthTexture=this._device.createTexture(r);var n={view:this._depthTexture.createView({label:"TextureView_MainDepthStencil_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height),dimension:Ef.E2d,format:this._depthTexture.format,mipLevelCount:1,arrayLayerCount:1}),depthClearValue:this._clearDepthValue,depthLoadOp:Zf.Clear,depthStoreOp:Jf.Store,stencilClearValue:this._clearStencilValue,stencilLoadOp:this.isStencilEnable?Zf.Clear:void 0,stencilStoreOp:this.isStencilEnable?Jf.Store:void 0};this._mainRenderPassWrapper.renderPassDescriptor={label:"MainRenderPass",colorAttachments:e,depthStencilAttachment:n}}},t.prototype._sharedInit=function(t){e.prototype._sharedInit.call(this,t),Eo(this,t,this._creationOptions)},t.prototype._configureContext=function(){this._context.configure({device:this._device,format:this._options.swapChainFormat,usage:Sf.RenderAttachment|Sf.CopySrc,alphaMode:this.premultipliedAlpha?e_.Premultiplied:e_.Opaque})},t.prototype.resizeImageBitmap=function(e,t,i){return Co(this,e,t,i)},t.prototype._createImageBitmapFromSource=function(e,t){return Ao(this,e,t)},t.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},t.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&Ro(this._renderingCanvas))},t.prototype.exitFullscreen=function(){this.isFullscreen&&Po()},t.prototype.enterPointerlock=function(){this._renderingCanvas&&Io(this._renderingCanvas)},t.prototype.exitPointerlock=function(){Mo()},t.prototype._rebuildBuffers=function(){e.prototype._rebuildBuffers.call(this);for(var t=0,i=this._storageBuffers;t=0,n=t.indexOf(om)>=0,o=i===pt.GLSL?this._compileRawShaderToSpirV(e,"vertex"):e,a=i===pt.GLSL?this._compileRawShaderToSpirV(t,"fragment"):t;return this._createPipelineStageDescriptor(o,a,i,r,n)},t.prototype._compilePipelineStageDescriptor=function(e,t,i,r){this.onBeforeShaderCompilationObservable.notifyObservers(this);var n=e.indexOf(om)>=0,o=t.indexOf(om)>=0,a="#version 450\n",s=r===pt.GLSL?this._compileShaderToSpirV(e,"vertex",i,a):this._getWGSLShader(e,"vertex",i),l=r===pt.GLSL?this._compileShaderToSpirV(t,"fragment",i,a):this._getWGSLShader(t,"fragment",i),c=this._createPipelineStageDescriptor(s,l,r,n,o);return this.onAfterShaderCompilationObservable.notifyObservers(this),c},t.prototype.createRawShaderProgram=function(){throw"Not available on WebGPU"},t.prototype.createShaderProgram=function(){throw"Not available on WebGPU"},t.prototype.inlineShaderCode=function(e){var t=new tf(e);return t.debug=!1,t.processCode(),t.code},t.prototype.createPipelineContext=function(e){return new o_(e,this)},t.prototype.createMaterialContext=function(){return new B_},t.prototype.createDrawContext=function(){return new U_(this._bufferManager)},t.prototype._preparePipelineContext=function(e,t,i,r,n,o,a,s){var l=e,c=l.shaderProcessingContext.shaderLanguage;this.dbgShowShaderCode&&(ae.Log(["defines",s]),ae.Log(t),ae.Log(i),ae.Log("***********************************************")),l.sources={fragment:i,vertex:t,rawVertex:n,rawFragment:o},l.stages=r?this._compileRawPipelineStageDescriptor(t,i,c):this._compilePipelineStageDescriptor(t,i,s,c)},t.prototype.getAttributes=function(e,t){for(var i=new Array(t.length),r=e,n=0;n0,l.is3D=d>0,l._cachedWrapU=u.TEXTURE_CLAMP_ADDRESSMODE,l._cachedWrapV=u.TEXTURE_CLAMP_ADDRESSMODE,l._useSRGBBuffer=s.useSRGBBuffer,l.label=s.label,this._internalTexturesCache.push(l),i||this._textureHelper.createGPUTextureForInternalTexture(l,c,h,p||1,s.creationFlags),l},t.prototype.createTexture=function(e,t,i,r,n,o,a,s,l,c,h,d,p,f,_){var m=this;return void 0===n&&(n=u.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=null),this._createTextureBase(e,t,i,r,n,o,a,(function(e,t,i,r,n,o,a,s){var l,h=r;if(e.baseWidth=h.width,e.baseHeight=h.height,e.width=h.width,e.height=h.height,e.format=-1!==e.format?e.format:null!=c?c:u.TEXTUREFORMAT_RGBA,e.type=-1!==e.type?e.type:u.TEXTURETYPE_UNSIGNED_BYTE,e._creationFlags=null!=f?f:0,s(e.width,e.height,h,t,e,(function(){})),null===(l=e._hardwareTexture)||void 0===l?void 0:l.underlyingResource)o||a||m._generateMipmaps(e,m._uploadEncoder);else{var d=m._textureHelper.createGPUTextureForInternalTexture(e,h.width,h.height,void 0,f);p_.IsImageBitmap(h)&&(m._textureHelper.updateTexture(h,e,h.width,h.height,e.depth,d.format,0,0,n,!1,0,0),o||a||m._generateMipmaps(e,m._uploadEncoder))}i&&i.removePendingData(e),e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}),(function(){return!1}),s,l,c,h,d,p,_)},t.prototype.wrapWebGPUTexture=function(e){var t=new f_(e),i=new Pi(this,Ti.Unknown,!0);return i._hardwareTexture=t,i.isReady=!0,i},t.prototype.wrapWebGLTexture=function(){throw new Error("wrapWebGLTexture is not supported, use wrapWebGPUTexture instead.")},t.prototype.generateMipMapsForCubemap=function(e){var t;e.generateMipMaps&&((null===(t=e._hardwareTexture)||void 0===t?void 0:t.underlyingResource)||this._textureHelper.createGPUTextureForInternalTexture(e),this._generateMipmaps(e))},t.prototype._getUseSRGBBuffer=function(e,t){return e&&this._caps.supportSRGBBuffers},t.prototype._unpackFlipY=function(e){},t.prototype.updateTextureSamplingMode=function(e,t,i){void 0===i&&(i=!1),i&&(t.generateMipMaps=!0,this._generateMipmaps(t)),t.samplingMode=e},t.prototype.updateTextureWrappingMode=function(e,t,i,r){void 0===i&&(i=null),void 0===r&&(r=null),null!==t&&(e._cachedWrapU=t),null!==i&&(e._cachedWrapV=i),(e.is2DArray||e.is3D)&&null!==r&&(e._cachedWrapR=r)},t.prototype.updateTextureDimensions=function(e,t,i,r){if(void 0===r&&(r=1),e._hardwareTexture&&(e.width!==t||e.height!==i||e.depth!==r)){var n=e._hardwareTexture.textureAdditionalUsages;e._hardwareTexture.release(),this._textureHelper.createGPUTextureForInternalTexture(e,t,i,r,n)}},t.prototype._setInternalTexture=function(e,t,i){if(i=null!=i?i:e,this._currentEffect){var r=this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[i];if(this._currentMaterialContext.setTexture(e,t),r&&r.autoBindSampler){var n=i+n_.AutoSamplerSuffix;this._currentMaterialContext.setSampler(n,t)}}},t.prototype.createPrefilteredCubeTexture=function(e,t,i,r,n,o,a,s,l){return void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!0),this.createCubeTexture(e,t,null,!1,(function(e){if(e){var t=e.texture;l?e.info.sphericalPolynomial&&(t._sphericalPolynomial=e.info.sphericalPolynomial):t._sphericalPolynomial=new Sp,t._source=Ti.CubePrefiltered,n&&n(t)}else n&&n(null)}),o,a,s,l,i,r)},t.prototype.setTexture=function(e,t,i,r){this._setTexture(e,i,!1,!1,r,r)},t.prototype.setTextureArray=function(e,t,i,r){for(var n=0;n0;for(var n in e){var o=e[n],a=i[n],s=a.group,l=a.binding,c=o.type,u=o.object,h=o.indexInGroupEntries;switch((y=this._bindGroupEntries[s])||(y=this._bindGroupEntries[s]=[]),c){case mh.Sampler:var d=u;void 0!==h&&r?y[h].resource=this._cacheSampler.getSampler(d):(o.indexInGroupEntries=y.length,y.push({binding:l,resource:this._cacheSampler.getSampler(d)}));break;case mh.Texture:case mh.TextureWithoutSampler:var p=(f=u)._texture._hardwareTexture;void 0!==h&&r?(c===mh.Texture&&(y[h++].resource=this._cacheSampler.getSampler(f._texture)),y[h].resource=p.view):(o.indexInGroupEntries=y.length,c===mh.Texture&&y.push({binding:l-1,resource:this._cacheSampler.getSampler(f._texture)}),y.push({binding:l,resource:p.view}));break;case mh.StorageTexture:(p=(f=u)._texture._hardwareTexture).textureAdditionalUsages&Sf.StorageBinding||ae.Error("computeDispatch: The texture (name=".concat(f.name,", uniqueId=").concat(f.uniqueId,") is not a storage texture!"),50),void 0!==h&&r?y[h].resource=p.viewForWriting:(o.indexInGroupEntries=y.length,y.push({binding:l,resource:p.viewForWriting}));break;case mh.ExternalTexture:var f,_=(f=u).underlyingResource;void 0!==h&&r?y[h].resource=this._device.importExternalTexture({source:_}):(o.indexInGroupEntries=y.length,y.push({binding:l,resource:this._device.importExternalTexture({source:_})}));break;case mh.UniformBuffer:case mh.StorageBuffer:case mh.DataBuffer:var m=c===mh.DataBuffer?u:(mh.UniformBuffer,u.getBuffer()),g=m.underlyingResource;void 0!==h&&r?(y[h].resource.buffer=g,y[h].resource.size=m.capacity):(o.indexInGroupEntries=y.length,y.push({binding:l,resource:{buffer:g,offset:0,size:m.capacity}}))}}for(var v=0;v0&&d.dispatchWorkgroups(r,n,o),d.end(),c&&(this._timestampQuery.endPass(this._timestampIndex,c),this._timestampIndex+=2)},sm.prototype.releaseComputeEffects=function(){for(var e in this._compiledComputeEffects){var t=this._compiledComputeEffects[e].getPipelineContext();this._deleteComputePipelineContext(t)}this._compiledComputeEffects={}},sm.prototype._prepareComputePipelineContext=function(e,t,i,r,n){var o=e;this.dbgShowShaderCode&&(ae.Log(r),ae.Log(t)),o.sources={compute:t,rawCompute:i},o.stage=this._createComputePipelineStageDescriptor(t,r,n)},sm.prototype._releaseComputeEffect=function(e){this._compiledComputeEffects[e._key]&&(delete this._compiledComputeEffects[e._key],this._deleteComputePipelineContext(e.getPipelineContext()))},sm.prototype._rebuildComputeEffects=function(){for(var e in this._compiledComputeEffects){var t=this._compiledComputeEffects[e];t._pipelineContext=null,t._wasPreviouslyReady=!1,t._prepareEffect()}},sm.prototype._executeWhenComputeStateIsCompiled=function(e,t){e.stage.module.getCompilationInfo().then((function(e){for(var i={numErrors:0,messages:[]},r=0,n=e.messages;r>g,y=[],b=0;b<6;b++){var T=h[g][m[b]];c&&(T=hm(T,v,v,n)),y.push(new Uint8Array(T.buffer,T.byteOffset,T.byteLength))}p._textureHelper.updateCubeTextures(y,_.underlyingResource,v,v,_.format,d,!1,0,0)}else p.updateRawCubeTexture(f,o,r,n,d);f.isReady=!0,null==t||t.removePendingData(f),l&&l()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t.removePendingData(f),c&&e&&c(e.status+" "+e.statusText,i)})),f},sm.prototype.createRawTexture3D=function(e,t,i,r,n,o,a,s,l,c,h){void 0===l&&(l=null),void 0===c&&(c=u.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=0);var d=Ti.Raw3D,p=new Pi(this,d);return p.baseWidth=t,p.baseHeight=i,p.baseDepth=r,p.width=t,p.height=i,p.depth=r,p.format=n,p.type=c,p.generateMipMaps=o,p.samplingMode=s,p.is3D=!0,p._creationFlags=h,this._doNotHandleContextLost||(p._bufferView=e),this._textureHelper.createGPUTextureForInternalTexture(p,t,i,void 0,h),this.updateRawTexture3D(p,e,n,a,l,c),this._internalTexturesCache.push(p),p},sm.prototype.updateRawTexture3D=function(e,t,i,r,n,o){if(void 0===n&&(n=null),void 0===o&&(o=u.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n),t){var a=e._hardwareTexture;i===u.TEXTUREFORMAT_RGB&&(t=hm(t,e.width,e.height,o));var s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(s,e,e.width,e.height,e.depth,a.format,0,0,r,!1,0,0),e.generateMipMaps&&this._generateMipmaps(e,this._uploadEncoder)}e.isReady=!0},sm.prototype.createRawTexture2DArray=function(e,t,i,r,n,o,a,s,l,c,h){void 0===l&&(l=null),void 0===c&&(c=u.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=0);var d=Ti.Raw2DArray,p=new Pi(this,d);return p.baseWidth=t,p.baseHeight=i,p.baseDepth=r,p.width=t,p.height=i,p.depth=r,p.format=n,p.type=c,p.generateMipMaps=o,p.samplingMode=s,p.is2DArray=!0,p._creationFlags=h,this._doNotHandleContextLost||(p._bufferView=e),this._textureHelper.createGPUTextureForInternalTexture(p,t,i,r,h),this.updateRawTexture2DArray(p,e,n,a,l,c),this._internalTexturesCache.push(p),p},sm.prototype.updateRawTexture2DArray=function(e,t,i,r,n,o){if(void 0===n&&(n=null),void 0===o&&(o=u.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n),t){var a=e._hardwareTexture;i===u.TEXTUREFORMAT_RGB&&(t=hm(t,e.width,e.height,o));var s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(s,e,e.width,e.height,e.depth,a.format,0,0,r,!1,0,0),e.generateMipMaps&&this._generateMipmaps(e,this._uploadEncoder)}e.isReady=!0},sm.prototype._readTexturePixels=function(e,t,i,r,n,o,a,s,l,c){void 0===r&&(r=-1),void 0===n&&(n=0),void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===l&&(l=0),void 0===c&&(c=0);var u=e._hardwareTexture;return a&&this.flushFramebuffer(),this._textureHelper.readPixels(u.underlyingResource,l,c,t,i,u.format,r,n,o,s)},sm.prototype._readTexturePixelsSync=function(){throw"_readTexturePixelsSync is unsupported in WebGPU!"};var dm=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,r,n,o)||this;return n.enableGPUTimingMeasurements&&(a.gpuTimeInFrame=new vh),a}return m(t,e),t}(cl);sm.prototype._createHardwareRenderTargetWrapper=function(e,t,i){var r=new dm(e,t,i,this);return this._renderTargetWrapperCache.push(r),r},sm.prototype.createRenderTargetTexture=function(e,t){var i,r,n,o=this._createHardwareRenderTargetWrapper(!1,!1,e),a={};void 0!==t&&"object"==typeof t?(a.generateMipMaps=t.generateMipMaps,a.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,a.generateStencilBuffer=a.generateDepthBuffer&&t.generateStencilBuffer,a.samplingMode=void 0===t.samplingMode?u.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,a.creationFlags=null!==(i=t.creationFlags)&&void 0!==i?i:0,a.noColorAttachment=!!t.noColorAttachment,a.samples=t.samples,a.label=t.label):(a.generateMipMaps=t,a.generateDepthBuffer=!0,a.generateStencilBuffer=!1,a.samplingMode=u.TEXTURE_TRILINEAR_SAMPLINGMODE,a.creationFlags=0,a.noColorAttachment=!1);var s=a.noColorAttachment?null:this._createInternalTexture(e,t,!0,Ti.RenderTarget);return o.label=null!==(r=a.label)&&void 0!==r?r:"RenderTargetWrapper",o._samples=null!==(n=a.samples)&&void 0!==n?n:1,o._generateDepthBuffer=a.generateDepthBuffer,o._generateStencilBuffer=!!a.generateStencilBuffer,o.setTextures(s),(o._generateDepthBuffer||o._generateStencilBuffer)&&o.createDepthStencilTexture(0,!1,o._generateStencilBuffer,o.samples,a.generateStencilBuffer?u.TEXTUREFORMAT_DEPTH24_STENCIL8:u.TEXTUREFORMAT_DEPTH32_FLOAT,a.label?a.label+"-DepthStencil":void 0),s&&(void 0!==t&&"object"==typeof t&&t.createMipMaps&&!a.generateMipMaps&&(s.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(s,void 0,void 0,void 0,a.creationFlags),void 0!==t&&"object"==typeof t&&t.createMipMaps&&!a.generateMipMaps&&(s.generateMipMaps=!1)),o},sm.prototype._createDepthStencilTexture=function(e,t){var i=new Pi(this,t.generateStencil?Ti.DepthStencil:Ti.Depth);i.label=t.label;var r=g({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,samples:1,depthTextureFormat:t.generateStencil?u.TEXTUREFORMAT_DEPTH24_STENCIL8:u.TEXTUREFORMAT_DEPTH32_FLOAT},t);i.format=r.depthTextureFormat,this._setupDepthStencilTexture(i,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction,r.samples),this._textureHelper.createGPUTextureForInternalTexture(i);var n=i._hardwareTexture;return i.type=p_.GetTextureTypeFromFormat(n.format),this._internalTexturesCache.push(i),i},sm.prototype._setupDepthStencilTexture=function(e,t,i,r,n,o){void 0===o&&(o=1);var a=t.width||t,s=t.height||t,l=t.layers||0,c=t.depth||0;e.baseWidth=a,e.baseHeight=s,e.width=a,e.height=s,e.is2DArray=l>0,e.is3D=c>0,e.depth=l||c,e.isReady=!0,e.samples=o,e.generateMipMaps=!1,e.samplingMode=r?u.TEXTURE_BILINEAR_SAMPLINGMODE:u.TEXTURE_NEAREST_SAMPLINGMODE,e.type=u.TEXTURETYPE_FLOAT,e._comparisonFunction=n,e._cachedWrapU=u.TEXTURE_CLAMP_ADDRESSMODE,e._cachedWrapV=u.TEXTURE_CLAMP_ADDRESSMODE},sm.prototype.updateRenderTargetTextureSampleCount=function(e,t){return e&&e.texture&&e.samples!==t?(t=Math.min(t,this.getCaps().maxMSAASamples),this._textureHelper.createMSAATexture(e.texture,t),e._depthStencilTexture&&(this._textureHelper.createMSAATexture(e._depthStencilTexture,t),e._depthStencilTexture.samples=t),e._samples=t,e.texture.samples=t,t):t},sm.prototype.createRenderTargetCubeTexture=function(e,t){var i,r=this._createHardwareRenderTargetWrapper(!1,!0,e),n=g({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:u.TEXTURETYPE_UNSIGNED_INT,samplingMode:u.TEXTURE_TRILINEAR_SAMPLINGMODE,format:u.TEXTUREFORMAT_RGBA,samples:1},t);n.generateStencilBuffer=n.generateDepthBuffer&&n.generateStencilBuffer,r.label=null!==(i=n.label)&&void 0!==i?i:"RenderTargetWrapper",r._generateDepthBuffer=n.generateDepthBuffer,r._generateStencilBuffer=n.generateStencilBuffer;var o=new Pi(this,Ti.RenderTarget);return o.width=e,o.height=e,o.depth=0,o.isReady=!0,o.isCube=!0,o.samples=n.samples,o.generateMipMaps=n.generateMipMaps,o.samplingMode=n.samplingMode,o.type=n.type,o.format=n.format,this._internalTexturesCache.push(o),r.setTextures(o),(r._generateDepthBuffer||r._generateStencilBuffer)&&r.createDepthStencilTexture(0,void 0===n.samplingMode||n.samplingMode===u.TEXTURE_BILINEAR_SAMPLINGMODE||n.samplingMode===u.TEXTURE_LINEAR_LINEAR||n.samplingMode===u.TEXTURE_TRILINEAR_SAMPLINGMODE||n.samplingMode===u.TEXTURE_LINEAR_LINEAR_MIPLINEAR||n.samplingMode===u.TEXTURE_NEAREST_LINEAR_MIPNEAREST||n.samplingMode===u.TEXTURE_NEAREST_LINEAR_MIPLINEAR||n.samplingMode===u.TEXTURE_NEAREST_LINEAR||n.samplingMode===u.TEXTURE_LINEAR_LINEAR_MIPNEAREST,r._generateStencilBuffer,r.samples),t&&t.createMipMaps&&!n.generateMipMaps&&(o.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(o),t&&t.createMipMaps&&!n.generateMipMaps&&(o.generateMipMaps=!1),r},sm.prototype.updateVideoTexture=function(e,t,i){var r,n=this;if(e&&!e._isDisabled){void 0===this._videoTextureSupported&&(this._videoTextureSupported=!0);var o=e._hardwareTexture;(null===(r=e._hardwareTexture)||void 0===r?void 0:r.underlyingResource)||(o=this._textureHelper.createGPUTextureForInternalTexture(e)),function(e){return!(!e||void 0===e.underlyingResource)}(t)?(this._textureHelper.copyVideoToTexture(t,e,o.format,!i),e.generateMipMaps&&this._generateMipmaps(e),e.isReady=!0):t&&this.createImageBitmap(t).then((function(t){n._textureHelper.updateTexture(t,e,e.width,e.height,e.depth,o.format,0,0,!i,!1,0,0),e.generateMipMaps&&n._generateMipmaps(e),e.isReady=!0})).catch((function(){e.isReady=!0}))}};var pm=function(){function e(){}return e.CreateAsync=function(e,t){return y(this,void 0,void 0,(function(){return b(this,(function(i){switch(i.label){case 0:return[4,sm.IsSupportedAsync];case 1:return i.sent()?[2,sm.CreateAsync(e,t)]:Do.IsSupported?[2,new Do(e,void 0,t)]:[2,new cp(t)]}}))}))},e}(),fm=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),_m=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return fm.COPY;case 86:return fm.PASTE;case 88:return fm.CUT;default:return-1}},e}(),mm=function(e){function t(i,r,n,o,a,s,l){var c;void 0===r&&(r=Z.Gray()),void 0===n&&(n=Ih.DefaultUtilityLayer),void 0===o&&(o=null),void 0===a&&(a=1),void 0===s&&(s=Z.Yellow()),void 0===l&&(l=Z.Gray());var u,h,d,p,_,m,g,v=this;(v=e.call(this,n)||this)._pointerObserver=null,v.snapDistance=0,v.onSnapObservable=new f,v.uniformScaling=!1,v.sensitivity=1,v.dragScale=1,v.incrementalSnap=!1,v._isEnabled=!0,v._parent=null,v._dragging=!1,v._tmpVector=new V(0,0,0),v._incrementalStartupValue=V.Zero(),v._parent=o,v._coloredMaterial=new Uu("",n.utilityLayerScene),v._coloredMaterial.diffuseColor=r,v._coloredMaterial.specularColor=r.subtract(new Z(.1,.1,.1)),v._hoverMaterial=new Uu("",n.utilityLayerScene),v._hoverMaterial.diffuseColor=s,v._disableMaterial=new Uu("",n.utilityLayerScene),v._disableMaterial.diffuseColor=l,v._disableMaterial.alpha=.4,v._gizmoMesh=new Fa("axis",n.utilityLayerScene);var y=(c=v._createGizmoMesh(v._gizmoMesh,a)).arrowMesh,b=c.arrowTail,T=v._createGizmoMesh(v._gizmoMesh,a+4,!0);v._gizmoMesh.lookAt(v._rootMesh.position.add(i)),v._rootMesh.addChild(v._gizmoMesh,Oh.PreserveScaling),v._gizmoMesh.scaling.scaleInPlace(1/3);var E=y.position.clone(),S=b.position.clone(),x=b.scaling.clone(),A=function(e){var t=e*(3/v._rootMesh.scaling.length())*6;y.position.z+=t/3.5,b.scaling.y+=t,v.dragScale=b.scaling.y,b.position.z=y.position.z/2},C=function(){y.position.set(E.x,E.y,E.z),b.position.set(S.x,S.y,S.z),b.scaling.set(x.x,x.y,x.z),v.dragScale=b.scaling.y,v._dragging=!1};v.dragBehavior=new gs({dragAxis:i}),v.dragBehavior.moveAttached=!1,v.dragBehavior.updateDragPlane=!1,v._rootMesh.addBehavior(v.dragBehavior);var R=0,P=0,I={snapDistance:0};v.dragBehavior.onDragObservable.add((function(e){if(v.attachedNode){var r=v.sensitivity*e.dragDistance*(3*v.scaleRatio/v._rootMesh.scaling.length()),n=v._tmpVector,o=!1,a=0;if(v.uniformScaling?n.setAll(.57735):n.copyFrom(i),0==v.snapDistance)n.scaleToRef(r,n);else{R+=r,P+=r;var s=v.incrementalSnap?P:R;Math.abs(s)>v.snapDistance?(a=Math.floor(Math.abs(s)/v.snapDistance),s<0&&(a*=-1),R%=v.snapDistance,n.scaleToRef(v.snapDistance*a,n),o=!0):n.scaleInPlace(0)}n.addInPlaceFromFloats(1,1,1),n.x=Math.abs(n.x)0&&v.incrementalSnap?(v.attachedNode.getWorldMatrix().decompose(void 0,H.Quaternion[0],H.Vector3[2],Oh.PreserveScaling?l:void 0),n.addInPlace(v._incrementalStartupValue),n.addInPlaceFromFloats(-1,-1,-1),n.x=Math.abs(n.x)*(v._incrementalStartupValue.x>0?1:-1),n.y=Math.abs(n.y)*(v._incrementalStartupValue.y>0?1:-1),n.z=Math.abs(n.z)*(v._incrementalStartupValue.z>0?1:-1),z.ComposeToRef(n,H.Quaternion[0],H.Vector3[2],H.Matrix[1])):(z.ScalingToRef(n.x,n.y,n.z,H.Matrix[2]),H.Matrix[2].multiplyToRef(v.attachedNode.getWorldMatrix(),H.Matrix[1])),H.Matrix[1].decompose(H.Vector3[1],void 0,void 0,Oh.PreserveScaling?l:void 0);var c=1e5;Math.abs(H.Vector3[1].x)0){var h=Math.floor(Math.abs(s)/r.rotationSnapDistance)*(s<0?-1:1),d=r.rotationSnapDistance*h;u=d-l,l=d}e>=8?G.RotationYawPitchRollToRef(0,0,u,r._tmpQuaternion):e>=4?G.RotationYawPitchRollToRef(u,0,0,r._tmpQuaternion):G.RotationYawPitchRollToRef(0,u,0,r._tmpQuaternion),r.attachedMesh.isUsingPivotMatrix()&&r._anchorMesh.position.copyFrom(r.attachedMesh.position),r._anchorMesh.addChild(r.attachedMesh),r._anchorMesh.getScene().useRightHandedSystem&&r._tmpQuaternion.conjugateInPlace(),r._tmpQuaternion.normalize(),r._anchorMesh.rotationQuaternion.multiplyToRef(r._tmpQuaternion,r._anchorMesh.rotationQuaternion),r._anchorMesh.rotationQuaternion.normalize(),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(i)}r.updateBoundingBox(),ds._RestorePivotPoint(r.attachedMesh)}r._updateDummy()})),n.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({}),r._dragging=!0,r._selectNode(t)})),n.onDragEndObservable.add((function(e){r.onRotationSphereDragEndObservable.notifyObservers({}),r._dragging=!1,r._selectNode(null),r._updateDummy(),r._unhoverMeshOnTouchUp(e.pointerInfo,t)})),a._rotateSpheresDragBehaviors.push(n),a._rotateSpheresParent.addChild(t)},a=this,s=0;s<12;s++)o(s);for(r._rootMesh.addChild(r._rotateSpheresParent),r._scaleBoxesParent=new Uo("",i.utilityLayerScene),r._scaleBoxesParent.rotationQuaternion=new G,s=0;s<3;s++)for(var l=0;l<3;l++)for(var c=function(e){var t=(1===s?1:0)+(1===l?1:0)+(1===e?1:0);if(1===t||3===t)return"continue";var n=Uh("",{size:1},i.utilityLayerScene);n.material=u._coloredMaterial,n._internalMetadata=2===t,n.isNearGrabbable=!0;var o=new V(s-1,l-1,e-1).normalize(),a=new gs({dragAxis:o});a.updateDragPlane=!1,a.moveAttached=!1;var c=0,h=0;n.addBehavior(a),a.onDragObservable.add((function(e){if(r.onScaleBoxDragObservable.notifyObservers({}),r.attachedMesh){var i=r.attachedMesh.parent;if(i&&i.scaling&&i.scaling.isNonUniformWithinEpsilon(.001))return void ae.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");ds._RemoveAndStorePivotPoint(r.attachedMesh);var a=e.dragDistance/r._boundingDimensions.length()*r._anchorMesh.scaling.length();if(c+=a,r.scalingSnapDistance>0){var s=Math.floor(Math.abs(c)/r.scalingSnapDistance)*(c<0?-1:1),l=r.scalingSnapDistance*s;a=l-h,h=l}var u=new V(a,a,a),d=new V(h,h,h);2===t&&(u.x*=Math.abs(o.x),u.y*=Math.abs(o.y),u.z*=Math.abs(o.z)),u.scaleInPlace(r._scaleDragSpeed),u.multiplyInPlace(r._axisFactor),d.scaleInPlace(r._scaleDragSpeed),d.multiplyInPlace(r._axisFactor),d.addInPlace(r._incrementalStartupValue),r.updateBoundingBox(),r.scalePivot?(r.attachedMesh.getWorldMatrix().getRotationMatrixToRef(r._tmpRotationMatrix),r._boundingDimensions.scaleToRef(.5,r._tmpVector),V.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector),r._boundingDimensions.multiplyToRef(r.scalePivot,r._tmpVector),V.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.addInPlace(r._tmpVector)):(n.absolutePosition.subtractToRef(r._anchorMesh.position,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector),r.attachedMesh.isUsingPivotMatrix()&&r._anchorMesh.position.subtractInPlace(r.attachedMesh.getPivotPoint())),r._anchorMesh.addChild(r.attachedMesh),r.incrementalSnap?(d.x/=Math.abs(r._incrementalStartupValue.x)A)}i++}}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleDragSpeed",{get:function(){return this._scaleDragSpeed},set:function(e){this._scaleDragSpeed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverColoredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerDragBehavior",{get:function(){return this._pointerDragBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this._dragging||this._pointerDragBehavior.dragging},enumerable:!1,configurable:!0}),t.prototype.setColor=function(e){this._coloredMaterial.emissiveColor=e,this._hoverColoredMaterial.emissiveColor=e.clone().add(new Z(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach((function(t){t.color&&(t.color=e)}))},t.prototype._attachedNodeChanged=function(e){var t=this;if(e){this._anchorMesh.scaling.setAll(1),ds._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),ds._RestorePivotPoint(e),this.updateBoundingBox(),e.getChildMeshes(!1).forEach((function(e){e.markAsDirty("scaling")})),this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce((function(){t._updateDummy()}))}},t.prototype._selectNode=function(e){this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach((function(t){t.isVisible=!e||t==e}))},t.prototype._unhoverMeshOnTouchUp=function(e,t){(null==e?void 0:e.event)instanceof PointerEvent&&"touch"===(null==e?void 0:e.event.pointerType)&&(t.material=this._coloredMaterial)},t.prototype.getScaleBoxes=function(){return this._scaleBoxesParent.getChildMeshes()},t.prototype.updateBoundingBox=function(){if(this.attachedMesh){ds._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=G.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=G.RotationYawPitchRoll(this._anchorMesh.rotation.y,this._anchorMesh.rotation.x,this._anchorMesh.rotation.z)),this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var t=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);t.max.subtractToRef(t.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((t.max.x+t.min.x)/2,(t.max.y+t.min.y)/2,(t.max.z+t.min.z)/2),this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),this.attachedMesh.setParent(e)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),ds._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.getChildMeshes(),t=0;t<3;t++)for(var i=0;i<2;i++)for(var r=0;r<2;r++){var n=4*t+2*i+r;if(0==t&&(e[n].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*i,this._boundingDimensions.z*r),e[n].position.addInPlace(new V(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(V.Cross(e[n].position.normalizeToNew(),V.Right()).normalizeToNew().add(e[n].position))),1==t&&(e[n].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y/2,this._boundingDimensions.z*r),e[n].position.addInPlace(new V(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(V.Cross(e[n].position.normalizeToNew(),V.Up()).normalizeToNew().add(e[n].position))),2==t&&(e[n].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y*r,this._boundingDimensions.z/2),e[n].position.addInPlace(new V(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(V.Cross(e[n].position.normalizeToNew(),V.Forward()).normalizeToNew().add(e[n].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[n].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[n].scaling.set(o,o,o)}else this.fixedDragMeshBoundsSize?e[n].scaling.set(this.rotationSphereSize*this._boundingDimensions.x,this.rotationSphereSize*this._boundingDimensions.y,this.rotationSphereSize*this._boundingDimensions.z):e[n].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0,i=0;i<3;i++)for(var r=0;r<3;r++)for(var n=0;n<3;n++){var o=(1===i?1:0)+(1===r?1:0)+(1===n?1:0);if(1!==o&&3!==o){if(e[t])if(e[t].position.set(this._boundingDimensions.x*(i/2),this._boundingDimensions.y*(r/2),this._boundingDimensions.z*(n/2)),e[t].position.addInPlace(new V(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[t].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition,this._tmpVector);var a=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[t].scaling.set(a,a,a)}else this.fixedDragMeshBoundsSize?e[t].scaling.set(this.scaleBoxSize*this._boundingDimensions.x,this.scaleBoxSize*this._boundingDimensions.y,this.scaleBoxSize*this._boundingDimensions.z):e[t].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize);t++}}},t.prototype.setEnabledRotationAxis=function(e){this._rotateSpheresParent.getChildMeshes().forEach((function(t,i){i<4?t.setEnabled(-1!=e.indexOf("x")):i<8?t.setEnabled(-1!=e.indexOf("y")):t.setEnabled(-1!=e.indexOf("z"))}))},t.prototype.setEnabledScaling=function(e,t){void 0===t&&(t=!1),this._scaleBoxesParent.getChildMeshes().forEach((function(i){var r=e;t&&!0===i._internalMetadata&&(r=!1),i.setEnabled(r)}))},t.prototype._updateDummy=function(){this._dragMesh&&(this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))},t.prototype.enableDragBehavior=function(){this._dragMesh=Uh("dummy",{size:1},this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new G,this._pointerDragBehavior.useObjectOrientationForDragging=!1,this._dragMesh.addBehavior(this._pointerDragBehavior)},t.prototype.releaseDrag=function(){this._scaleBoxesDragBehaviors.forEach((function(e){e.releaseDrag()})),this._rotateSpheresDragBehaviors.forEach((function(e){e.releaseDrag()})),this._pointerDragBehavior.releaseDrag()},t.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateSpheresParent.dispose(),this._scaleBoxesParent.dispose(),this._dragMesh&&this._dragMesh.dispose(),this._scaleBoxesDragBehaviors.length=0,this._rotateSpheresDragBehaviors.length=0,e.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e),e.rotationQuaternion||(e.rotationQuaternion=G.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var i=e.position.clone(),r=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var n=Uh("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,n.scaling),0===n.scaling.y&&(n.scaling.y=A),0===n.scaling.x&&(n.scaling.x=A),0===n.scaling.z&&(n.scaling.z=A),n.position.set((o.max.x+o.min.x)/2,(o.max.y+o.min.y)/2,(o.max.z+o.min.z)/2),e.addChild(n),e.rotationQuaternion.copyFrom(r),e.position.copyFrom(i),e.removeChild(n),n.addChild(e),n.visibility=0,n},t.prototype.setCustomMesh=function(){ae.Error("Custom meshes are not supported on this gizmo")},t}(Oh),vm=function(e){function t(i,r,n,o,a,s,l,c,u){var h;void 0===r&&(r=Z.Gray()),void 0===n&&(n=Ih.DefaultUtilityLayer),void 0===o&&(o=32),void 0===a&&(a=null),void 0===s&&(s=!1),void 0===l&&(l=1),void 0===c&&(c=Z.Yellow()),void 0===u&&(u=Z.Gray());var d,p=this;(p=e.call(this,n)||this)._pointerObserver=null,p.snapDistance=0,p.onSnapObservable=new f,p.angle=0,p.sensitivity=1,p._isEnabled=!0,p._parent=null,p._dragging=!1,p._angles=new V,p._parent=a,p._coloredMaterial=new Uu("",n.utilityLayerScene),p._coloredMaterial.diffuseColor=r,p._coloredMaterial.specularColor=r.subtract(new Z(.1,.1,.1)),p._hoverMaterial=new Uu("",n.utilityLayerScene),p._hoverMaterial.diffuseColor=c,p._hoverMaterial.specularColor=c,p._disableMaterial=new Uu("",n.utilityLayerScene),p._disableMaterial.diffuseColor=u,p._disableMaterial.alpha=.4,p._gizmoMesh=new Fa("",n.utilityLayerScene);var _=(h=p._createGizmoMesh(p._gizmoMesh,l,o)).rotationMesh,m=h.collider;p._rotationDisplayPlane=fs("rotationDisplay",{size:.6,updatable:!1},p.gizmoLayer.utilityLayerScene),p._rotationDisplayPlane.rotation.z=.5*Math.PI,p._rotationDisplayPlane.parent=p._gizmoMesh,p._rotationDisplayPlane.setEnabled(!1),Ei.ShadersStore.rotationGizmoVertexShader=t._RotationGizmoVertexShader,Ei.ShadersStore.rotationGizmoFragmentShader=t._RotationGizmoFragmentShader,p._rotationShaderMaterial=new ld("shader",p.gizmoLayer.utilityLayerScene,{vertex:"rotationGizmo",fragment:"rotationGizmo"},{attributes:["position","uv"],uniforms:["worldViewProjection","angles","rotationColor"]}),p._rotationShaderMaterial.backFaceCulling=!1,p.rotationColor=c,p._rotationDisplayPlane.material=p._rotationShaderMaterial,p._rotationDisplayPlane.visibility=.999,p._gizmoMesh.lookAt(p._rootMesh.position.add(i)),p._rootMesh.addChild(p._gizmoMesh,Oh.PreserveScaling),p._gizmoMesh.scaling.scaleInPlace(1/3),p.dragBehavior=new gs({dragPlaneNormal:i}),p.dragBehavior.moveAttached=!1,p.dragBehavior.maxDragAngle=t.MaxDragAngle,p.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,p._rootMesh.addBehavior(p.dragBehavior);var g=new V,v=new z,y=new V,b=new V;p.dragBehavior.onDragStartObservable.add((function(e){p.attachedNode&&(g.copyFrom(e.dragPlanePoint),p._rotationDisplayPlane.setEnabled(!0),p._rotationDisplayPlane.getWorldMatrix().invertToRef(v),V.TransformCoordinatesToRef(e.dragPlanePoint,v,g),p._angles.x=Math.atan2(g.y,g.x)+Math.PI,p._angles.y=0,p._angles.z=p.updateGizmoRotationToMatchAttachedMesh?1:0,p._dragging=!0,g.copyFrom(e.dragPlanePoint),p._rotationShaderMaterial.setVector3("angles",p._angles),p.angle=0)})),p.dragBehavior.onDragEndObservable.add((function(){p._dragging=!1,p._rotationDisplayPlane.setEnabled(!1)}));var T={snapDistance:0},E=0,S=new z,x=new G;p.dragBehavior.onDragObservable.add((function(e){if(p.attachedNode){var t=new V(1,1,1),r=new G(0,0,0,1),o=new V(0,0,0);if(p.attachedNode.getWorldMatrix().decompose(t,r,o),!(Math.abs(Math.abs(t.x)-Math.abs(t.y))<=A&&Math.abs(Math.abs(t.x)-Math.abs(t.z))<=A)&&p.updateGizmoRotationToMatchAttachedMesh)return void ae.Warn("Unable to use a rotation gizmo matching mesh rotation with non uniform scaling. Use uniform scaling or set updateGizmoRotationToMatchAttachedMesh to false.");r.normalize();var a=p.updateGizmoPositionToMatchAttachedMesh?o:p._rootMesh.absolutePosition,s=e.dragPlanePoint.subtract(a).normalize(),l=g.subtract(a).normalize(),c=V.Cross(s,l),u=V.Dot(s,l),h=Math.atan2(c.length(),u)*p.sensitivity;y.copyFrom(i),b.copyFrom(i),p.updateGizmoRotationToMatchAttachedMesh&&(r.toRotationMatrix(v),b=V.TransformCoordinates(y,v));var d=!1;if(n.utilityLayerScene.activeCamera){var f=n.utilityLayerScene.activeCamera.position.subtract(a).normalize();V.Dot(f,b)>0&&(y.scaleInPlace(-1),b.scaleInPlace(-1),d=!0)}V.Dot(b,c)>0&&(h=-h),H.Vector3[0].set(h,0,0),p.dragBehavior.validateDrag(H.Vector3[0])||(h=0);var _=!1;if(0!=p.snapDistance)if(E+=h,Math.abs(E)>p.snapDistance){var m=Math.floor(Math.abs(E)/p.snapDistance);E<0&&(m*=-1),E%=p.snapDistance,h=p.snapDistance*m,_=!0}else h=0;var C=Math.sin(h/2);if(x.set(y.x*C,y.y*C,y.z*C,Math.cos(h/2)),S.determinant()>0){var R=new V;x.toEulerAnglesToRef(R),G.RotationYawPitchRollToRef(R.y,-R.x,-R.z,x)}if(p.updateGizmoRotationToMatchAttachedMesh)r.multiplyToRef(x,r),r.normalize(),z.ComposeToRef(t,r,o,p.attachedNode.getWorldMatrix());else{x.toRotationMatrix(H.Matrix[0]);var P=p.attachedNode.getWorldMatrix().getTranslation();p.attachedNode.getWorldMatrix().multiplyToRef(H.Matrix[0],p.attachedNode.getWorldMatrix()),p.attachedNode.getWorldMatrix().setTranslation(P)}g.copyFrom(e.dragPlanePoint),_&&(T.snapDistance=h,p.onSnapObservable.notifyObservers(T)),p._angles.y+=h,p.angle+=d?-h:h,p._rotationShaderMaterial.setVector3("angles",p._angles),p._matrixChanged()}}));var C=n._getSharedGizmoLight();C.includedOnlyMeshes=C.includedOnlyMeshes.concat(p._rootMesh.getChildMeshes(!1));var R={colliderMeshes:[m],gizmoMeshes:[_],material:p._coloredMaterial,hoverMaterial:p._hoverMaterial,disableMaterial:p._disableMaterial,active:!1,dragBehavior:p.dragBehavior};return null===(d=p._parent)||void 0===d||d.addToAxisCache(p._gizmoMesh,R),p._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var i;if(!p._customMeshSet&&(p.dragBehavior.maxDragAngle=t.MaxDragAngle,p._isHovered=!(-1==R.colliderMeshes.indexOf(null===(i=null==e?void 0:e.pickInfo)||void 0===i?void 0:i.pickedMesh)),!p._parent)){var r=R.dragBehavior.enabled?p._isHovered||p._dragging?p._hoverMaterial:p._coloredMaterial:p._disableMaterial;p._setGizmoMeshMaterial(R.gizmoMeshes,r)}})),p.dragBehavior.onEnabledObservable.add((function(e){p._setGizmoMeshMaterial(R.gizmoMeshes,e?p._coloredMaterial:p._disableMaterial)})),p}return m(t,e),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationColor",{set:function(e){this._rotationShaderMaterial.setColor3("rotationColor",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),t.prototype._createGizmoMesh=function(e,t,i){var r=sh("ignore",{diameter:.6,thickness:.03*t,tessellation:i},this.gizmoLayer.utilityLayerScene);r.visibility=0;var n=sh("",{diameter:.6,thickness:.005*t,tessellation:i},this.gizmoLayer.utilityLayerScene);return n.material=this._coloredMaterial,n.rotation.x=Math.PI/2,r.rotation.x=Math.PI/2,e.addChild(n,Oh.PreserveScaling),e.addChild(r,Oh.PreserveScaling),{rotationMesh:n,collider:r}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh):this.attachedMesh=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),this._rotationDisplayPlane&&this._rotationDisplayPlane.dispose(),this._rotationShaderMaterial&&this._rotationShaderMaterial.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t.MaxDragAngle=9*Math.PI/20,t._RotationGizmoVertexShader="\n precision highp float;\n attribute vec3 position;\n attribute vec2 uv;\n uniform mat4 worldViewProjection;\n varying vec3 vPosition;\n varying vec2 vUV;\n\n void main(void) {\n gl_Position = worldViewProjection * vec4(position, 1.0);\n vUV = uv;\n }",t._RotationGizmoFragmentShader="\n precision highp float;\n varying vec2 vUV;\n varying vec3 vPosition;\n uniform vec3 angles;\n uniform vec3 rotationColor;\n\n #define twopi 6.283185307\n\n void main(void) {\n vec2 uv = vUV - vec2(0.5);\n float angle = atan(uv.y, uv.x) + 3.141592;\n float delta = gl_FrontFacing ? angles.y : -angles.y;\n float begin = angles.x - delta * angles.z;\n float start = (begin < (begin + delta)) ? begin : (begin + delta);\n float end = (begin > (begin + delta)) ? begin : (begin + delta);\n float len = sqrt(dot(uv,uv));\n float opacity = 1. - step(0.5, len);\n\n float base = abs(floor(start / twopi)) * twopi;\n start += base;\n end += base;\n\n float intensity = 0.;\n for (int i = 0; i < 5; i++)\n {\n intensity += max(step(start, angle) - step(end, angle), 0.);\n angle += twopi;\n }\n gl_FragColor = vec4(rotationColor, min(intensity * 0.25, 0.8)) * opacity;\n }\n ",t}(Oh),ym=function(e){function t(t,i,r,n,o,a){void 0===t&&(t=Ih.DefaultUtilityLayer),void 0===i&&(i=32),void 0===r&&(r=!1),void 0===n&&(n=1);var s=e.call(this,t)||this;s.onDragStartObservable=new f,s.onDragObservable=new f,s.onDragEndObservable=new f,s._observables=[],s._sensitivity=1,s._gizmoAxisCache=new Map;var l=a&&a.xOptions&&a.xOptions.color?a.xOptions.color:Z.Red().scale(.5),c=a&&a.yOptions&&a.yOptions.color?a.yOptions.color:Z.Green().scale(.5),u=a&&a.zOptions&&a.zOptions.color?a.zOptions.color:Z.Blue().scale(.5);return s.xGizmo=new vm(new V(1,0,0),l,t,i,s,r,n),s.yGizmo=new vm(new V(0,1,0),c,t,i,s,r,n),s.zGizmo=new vm(new V(0,0,1),u,t,i,s,r,n),s.additionalTransformNode=null==a?void 0:a.additionalTransformNode,[s.xGizmo,s.yGizmo,s.zGizmo].forEach((function(e){a&&null!=a.updateScale&&(e.updateScale=a.updateScale),e.dragBehavior.onDragStartObservable.add((function(){s.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragObservable.add((function(){s.onDragObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){s.onDragEndObservable.notifyObservers({})}))})),s.attachedMesh=null,s.attachedNode=null,o?o.addToAxisCache(s._gizmoAxisCache):Oh.GizmoAxisPointerObserver(t,s._gizmoAxisCache),s}return m(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),t.prototype._checkBillboardTransform=function(){this._nodeAttached&&this._nodeAttached.billboardMode&&ae.Log("Rotation Gizmo will not work with transforms in billboard mode.")},Object.defineProperty(t.prototype,"sensitivity",{get:function(){return this._sensitivity},set:function(e){this._sensitivity=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t&&(t.sensitivity=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){return this.xGizmo.isHovered||this.yGizmo.isHovered||this.zGizmo.isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this.xGizmo.dragBehavior.dragging||this.yGizmo.dragBehavior.dragging||this.zGizmo.dragBehavior.dragging},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.additionalTransformNode=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoPositionToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoPositionToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoPositionToMatchAttachedMesh=e,this.yGizmo.updateGizmoPositionToMatchAttachedMesh=e,this.zGizmo.updateGizmoPositionToMatchAttachedMesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(e){this._anchorPoint=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.anchorPoint=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.coordinatesMode=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateScale",{get:function(){return this.xGizmo.updateScale},set:function(e){this.xGizmo&&(this.xGizmo.updateScale=e,this.yGizmo.updateScale=e,this.zGizmo.updateScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(e){this._customRotationQuaternion=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t&&(t.customRotationQuaternion=e)}))},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.releaseDrag=function(){this.xGizmo.dragBehavior.releaseDrag(),this.yGizmo.dragBehavior.releaseDrag(),this.zGizmo.dragBehavior.releaseDrag()},t.prototype.dispose=function(){var e=this;this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragObservable.clear(),this.onDragEndObservable.clear(),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)}))},t.prototype.setCustomMesh=function(){ae.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},t}(Oh),bm=function(e){function t(i,r,n,o,a,s){void 0===r&&(r=Z.Gray()),void 0===n&&(n=Ih.DefaultUtilityLayer),void 0===o&&(o=null),void 0===a&&(a=Z.Yellow()),void 0===s&&(s=Z.Gray());var l,c=this;(c=e.call(this,n)||this)._pointerObserver=null,c.snapDistance=0,c.onSnapObservable=new f,c._isEnabled=!1,c._parent=null,c._dragging=!1,c._parent=o,c._coloredMaterial=new Uu("",n.utilityLayerScene),c._coloredMaterial.diffuseColor=r,c._coloredMaterial.specularColor=r.subtract(new Z(.1,.1,.1)),c._hoverMaterial=new Uu("",n.utilityLayerScene),c._hoverMaterial.diffuseColor=a,c._disableMaterial=new Uu("",n.utilityLayerScene),c._disableMaterial.diffuseColor=s,c._disableMaterial.alpha=.4,c._gizmoMesh=t._CreatePlane(n.utilityLayerScene,c._coloredMaterial),c._gizmoMesh.lookAt(c._rootMesh.position.add(i)),c._gizmoMesh.scaling.scaleInPlace(1/3),c._gizmoMesh.parent=c._rootMesh;var u=0,h=new V,d={snapDistance:0};c.dragBehavior=new gs({dragPlaneNormal:i}),c.dragBehavior.moveAttached=!1,c._rootMesh.addBehavior(c.dragBehavior),c.dragBehavior.onDragObservable.add((function(e){if(c.attachedNode){if(0==c.snapDistance)c.attachedNode.getWorldMatrix().getTranslationToRef(H.Vector3[0]),H.Vector3[0].addToRef(e.delta,H.Vector3[0]),c.dragBehavior.validateDrag(H.Vector3[0])&&c.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z);else if(u+=e.dragDistance,Math.abs(u)>c.snapDistance){var t=Math.floor(Math.abs(u)/c.snapDistance);u%=c.snapDistance,e.delta.normalizeToRef(h),h.scaleInPlace(c.snapDistance*t),c.attachedNode.getWorldMatrix().getTranslationToRef(H.Vector3[0]),H.Vector3[0].addToRef(h,H.Vector3[0]),c.dragBehavior.validateDrag(H.Vector3[0])&&(c.attachedNode.getWorldMatrix().addTranslationFromFloats(h.x,h.y,h.z),d.snapDistance=c.snapDistance*t,c.onSnapObservable.notifyObservers(d))}c._matrixChanged()}})),c.dragBehavior.onDragStartObservable.add((function(){c._dragging=!0})),c.dragBehavior.onDragEndObservable.add((function(){c._dragging=!1}));var p=n._getSharedGizmoLight();p.includedOnlyMeshes=p.includedOnlyMeshes.concat(c._rootMesh.getChildMeshes(!1));var _={gizmoMeshes:c._gizmoMesh.getChildMeshes(),colliderMeshes:c._gizmoMesh.getChildMeshes(),material:c._coloredMaterial,hoverMaterial:c._hoverMaterial,disableMaterial:c._disableMaterial,active:!1,dragBehavior:c.dragBehavior};return null===(l=c._parent)||void 0===l||l.addToAxisCache(c._gizmoMesh,_),c._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!c._customMeshSet&&(c._isHovered=!(-1==_.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!c._parent)){var i=_.dragBehavior.enabled?c._isHovered||c._dragging?c._hoverMaterial:c._coloredMaterial:c._disableMaterial;c._setGizmoMeshMaterial(_.gizmoMeshes,i)}})),c.dragBehavior.onEnabledObservable.add((function(e){c._setGizmoMeshMaterial(_.gizmoMeshes,e?c._coloredMaterial:c._disableMaterial)})),c}return m(t,e),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),t._CreatePlane=function(e,t){var i=new Fo("plane",e),r=fs("dragPlane",{width:.1375,height:.1375,sideOrientation:2},e);return r.material=t,r.parent=i,i},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedNode=this._parent.attachedNode):this.attachedNode=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()}))},t}(Oh),Tm=function(e){function t(t,i,r,n){void 0===t&&(t=Ih.DefaultUtilityLayer),void 0===i&&(i=1);var o=e.call(this,t)||this;return o._meshAttached=null,o._nodeAttached=null,o._observables=[],o._gizmoAxisCache=new Map,o.onDragStartObservable=new f,o.onDragObservable=new f,o.onDragEndObservable=new f,o._planarGizmoEnabled=!1,o.xGizmo=new Dh(new V(1,0,0),Z.Red().scale(.5),t,o,i),o.yGizmo=new Dh(new V(0,1,0),Z.Green().scale(.5),t,o,i),o.zGizmo=new Dh(new V(0,0,1),Z.Blue().scale(.5),t,o,i),o.xPlaneGizmo=new bm(new V(1,0,0),Z.Red().scale(.5),o.gizmoLayer,o),o.yPlaneGizmo=new bm(new V(0,1,0),Z.Green().scale(.5),o.gizmoLayer,o),o.zPlaneGizmo=new bm(new V(0,0,1),Z.Blue().scale(.5),o.gizmoLayer,o),o.additionalTransformNode=null==n?void 0:n.additionalTransformNode,[o.xGizmo,o.yGizmo,o.zGizmo,o.xPlaneGizmo,o.yPlaneGizmo,o.zPlaneGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){o.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragObservable.add((function(){o.onDragObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){o.onDragEndObservable.notifyObservers({})}))})),o.attachedMesh=null,r?r.addToAxisCache(o._gizmoAxisCache):Oh.GizmoAxisPointerObserver(t,o._gizmoAxisCache),o}return m(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){return this.xGizmo.isHovered||this.yGizmo.isHovered||this.zGizmo.isHovered||this.xPlaneGizmo.isHovered||this.yPlaneGizmo.isHovered||this.zPlaneGizmo.isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this.xGizmo.dragBehavior.dragging||this.yGizmo.dragBehavior.dragging||this.zGizmo.dragBehavior.dragging||this.xPlaneGizmo.dragBehavior.dragging||this.yPlaneGizmo.dragBehavior.dragging||this.zPlaneGizmo.dragBehavior.dragging},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.additionalTransformNode=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"planarGizmoEnabled",{get:function(){return this._planarGizmoEnabled},set:function(e){var t=this;this._planarGizmoEnabled=e,[this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(i){i&&(i.isEnabled=e,e&&(i.attachedMesh?i.attachedMesh=t.attachedMesh:i.attachedNode=t.attachedNode))}),this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(e){this._customRotationQuaternion=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.customRotationQuaternion=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.updateGizmoRotationToMatchAttachedMesh=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoPositionToMatchAttachedMesh",{get:function(){return this._updateGizmoPositionToMatchAttachedMesh},set:function(e){this._updateGizmoPositionToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.updateGizmoPositionToMatchAttachedMesh=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(e){this._anchorPoint=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.anchorPoint=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.coordinatesMode=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateScale",{get:function(){return this.xGizmo.updateScale},set:function(e){this.xGizmo&&(this.xGizmo.updateScale=e,this.yGizmo.updateScale=e,this.zGizmo.updateScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.snapDistance=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.scaleRatio=e)}))},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.releaseDrag=function(){this.xGizmo.dragBehavior.releaseDrag(),this.yGizmo.dragBehavior.releaseDrag(),this.zGizmo.dragBehavior.releaseDrag(),this.xPlaneGizmo.dragBehavior.releaseDrag(),this.yPlaneGizmo.dragBehavior.releaseDrag(),this.zPlaneGizmo.dragBehavior.releaseDrag()},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(e){e&&e.dispose()})),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)})),this.onDragStartObservable.clear(),this.onDragObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(){ae.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)")},t}(Oh),Em=function(e){function t(t,i,r,n){void 0===t&&(t=Ih.DefaultUtilityLayer),void 0===i&&(i=1);var o=e.call(this,t)||this;return o._meshAttached=null,o._nodeAttached=null,o._incrementalSnap=!1,o._sensitivity=1,o._observables=[],o._gizmoAxisCache=new Map,o.onDragStartObservable=new f,o.onDragObservable=new f,o.onDragEndObservable=new f,o.uniformScaleGizmo=o._createUniformScaleMesh(),o.xGizmo=new mm(new V(1,0,0),Z.Red().scale(.5),t,o,i),o.yGizmo=new mm(new V(0,1,0),Z.Green().scale(.5),t,o,i),o.zGizmo=new mm(new V(0,0,1),Z.Blue().scale(.5),t,o,i),o.additionalTransformNode=null==n?void 0:n.additionalTransformNode,[o.xGizmo,o.yGizmo,o.zGizmo,o.uniformScaleGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){o.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragObservable.add((function(){o.onDragObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){o.onDragEndObservable.notifyObservers({})}))})),o.attachedMesh=null,o.attachedNode=null,r?r.addToAxisCache(o._gizmoAxisCache):Oh.GizmoAxisPointerObserver(t,o._gizmoAxisCache),o}return m(t,e),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateScale",{get:function(){return this.xGizmo.updateScale},set:function(e){this.xGizmo&&(this.xGizmo.updateScale=e,this.yGizmo.updateScale=e,this.zGizmo.updateScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){return this.xGizmo.isHovered||this.yGizmo.isHovered||this.zGizmo.isHovered||this.uniformScaleGizmo.isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this.xGizmo.dragBehavior.dragging||this.yGizmo.dragBehavior.dragging||this.zGizmo.dragBehavior.dragging||this.uniformScaleGizmo.dragBehavior.dragging},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t.additionalTransformNode=e}))},enumerable:!1,configurable:!0}),t.prototype._createUniformScaleMesh=function(){this._coloredMaterial=new Uu("",this.gizmoLayer.utilityLayerScene),this._coloredMaterial.diffuseColor=Z.Gray(),this._hoverMaterial=new Uu("",this.gizmoLayer.utilityLayerScene),this._hoverMaterial.diffuseColor=Z.Yellow(),this._disableMaterial=new Uu("",this.gizmoLayer.utilityLayerScene),this._disableMaterial.diffuseColor=Z.Gray(),this._disableMaterial.alpha=.4;var e=new mm(new V(0,1,0),Z.Gray().scale(.5),this.gizmoLayer,this);e.updateGizmoRotationToMatchAttachedMesh=!1,e.uniformScaling=!0,this._uniformScalingMesh=Fd("uniform",{type:1},e.gizmoLayer.utilityLayerScene),this._uniformScalingMesh.scaling.scaleInPlace(.01),this._uniformScalingMesh.visibility=0,this._octahedron=Fd("",{type:1},e.gizmoLayer.utilityLayerScene),this._octahedron.scaling.scaleInPlace(.007),this._uniformScalingMesh.addChild(this._octahedron),e.setCustomMesh(this._uniformScalingMesh,!0);var t=this.gizmoLayer._getSharedGizmoLight();t.includedOnlyMeshes=t.includedOnlyMeshes.concat(this._octahedron);var i={gizmoMeshes:[this._octahedron,this._uniformScalingMesh],colliderMeshes:[this._octahedron,this._uniformScalingMesh],material:this._coloredMaterial,hoverMaterial:this._hoverMaterial,disableMaterial:this._disableMaterial,active:!1,dragBehavior:e.dragBehavior};return this.addToAxisCache(e._rootMesh,i),e},Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){e?(this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.updateGizmoRotationToMatchAttachedMesh=e)}))):ae.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(e){this._anchorPoint=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.anchorPoint=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(e){this._customRotationQuaternion=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.customRotationQuaternion=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{set:function(e){e==Ph.World&&ae.Warn("Setting coordinates Mode to world on scaling gizmo is not supported."),[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(e){e.coordinatesMode=Ph.Local}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.snapDistance=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"incrementalSnap",{get:function(){return this._incrementalSnap},set:function(e){this._incrementalSnap=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.incrementalSnap=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.scaleRatio=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sensitivity",{get:function(){return this._sensitivity},set:function(e){this._sensitivity=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.sensitivity=e)}))},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.getAxisCache=function(e){return this._gizmoAxisCache.get(e)},t.prototype.releaseDrag=function(){this.xGizmo.dragBehavior.releaseDrag(),this.yGizmo.dragBehavior.releaseDrag(),this.zGizmo.dragBehavior.releaseDrag(),this.uniformScaleGizmo.dragBehavior.releaseDrag()},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(e){e&&e.dispose()})),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)})),this.onDragStartObservable.clear(),this.onDragObservable.clear(),this.onDragEndObservable.clear(),[this._uniformScalingMesh,this._octahedron].forEach((function(e){e&&e.dispose()})),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()}))},t}(Oh),Sm=function(){function e(e,t,i,r){void 0===t&&(t=1),void 0===i&&(i=Ih.DefaultUtilityLayer),void 0===r&&(r=Ih.DefaultKeepDepthUtilityLayer),this._scene=e,this.clearGizmoOnEmptyPointerEvent=!1,this.enableAutoPicking=!0,this.onAttachedToMeshObservable=new f,this.onAttachedToNodeObservable=new f,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObservers=[],this._attachedMesh=null,this._attachedNode=null,this._boundingBoxColor=Z.FromHexString("#0984e3"),this._thickness=1,this._scaleRatio=1,this._coordinatesMode=Ph.Local,this._gizmoAxisCache=new Map,this.boundingBoxDragBehavior=new bs,this.attachableMeshes=null,this.attachableNodes=null,this.usePointerToAttachGizmos=!0,this._defaultUtilityLayer=i,this._defaultKeepDepthUtilityLayer=r,this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,this._thickness=t,this.gizmos={positionGizmo:null,rotationGizmo:null,scaleGizmo:null,boundingBoxGizmo:null};var n=this._attachToMeshPointerObserver(e),o=Oh.GizmoAxisPointerObserver(this._defaultUtilityLayer,this._gizmoAxisCache);this._pointerObservers=[n,o]}return Object.defineProperty(e.prototype,"keepDepthUtilityLayer",{get:function(){return this._defaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"utilityLayer",{get:function(){return this._defaultUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHovered",{get:function(){var e=!1;for(var t in this.gizmos){var i=this.gizmos[t];if(i&&i.isHovered){e=!0;break}}return e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDragging",{get:function(){var e=!1;return[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo,this.gizmos.boundingBoxGizmo].forEach((function(t){t&&t.isDragging&&(e=!0)})),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo].forEach((function(t){t&&(t.scaleRatio=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(e){this._coordinatesMode=e,[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo].forEach((function(t){t&&(t.coordinatesMode=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attachedNode",{get:function(){return this._attachedNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){this._additionalTransformNode=e,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),e.prototype._attachToMeshPointerObserver=function(e){var t=this;return e.onPointerObservable.add((function(e){if(t.usePointerToAttachGizmos&&e.type==Gr.POINTERDOWN)if(e.pickInfo&&e.pickInfo.pickedMesh){if(t.enableAutoPicking){var i=e.pickInfo.pickedMesh;if(null==t.attachableMeshes)for(;i&&null!=i.parent;)i=i.parent;else{var r=!1;t.attachableMeshes.forEach((function(e){i&&(i==e||i.isDescendantOf(e))&&(i=e,r=!0)})),r||(i=null)}i instanceof Uo?t._attachedMesh!=i&&t.attachToMesh(i):t.clearGizmoOnEmptyPointerEvent&&t.attachToMesh(null)}}else t.clearGizmoOnEmptyPointerEvent&&t.attachToMesh(null)}))},e.prototype.attachToMesh=function(e){for(var t in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=e,this._attachedNode=null,this.gizmos){var i=this.gizmos[t];i&&this._gizmosEnabled[t]&&(i.attachedMesh=e)}this.boundingBoxGizmoEnabled&&this._attachedMesh&&this._attachedMesh.addBehavior(this.boundingBoxDragBehavior),this.onAttachedToMeshObservable.notifyObservers(e)},e.prototype.attachToNode=function(e){for(var t in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=null,this._attachedNode=e,this.gizmos){var i=this.gizmos[t];i&&this._gizmosEnabled[t]&&(i.attachedNode=e)}this.boundingBoxGizmoEnabled&&this._attachedNode&&this._attachedNode.addBehavior(this.boundingBoxDragBehavior),this.onAttachedToNodeObservable.notifyObservers(e)},Object.defineProperty(e.prototype,"positionGizmoEnabled",{get:function(){return this._gizmosEnabled.positionGizmo},set:function(e){e?(this.gizmos.positionGizmo||(this.gizmos.positionGizmo=new Tm(this._defaultUtilityLayer,this._thickness,this)),this._attachedNode?this.gizmos.positionGizmo.attachedNode=this._attachedNode:this.gizmos.positionGizmo.attachedMesh=this._attachedMesh):this.gizmos.positionGizmo&&(this.gizmos.positionGizmo.attachedNode=null),this._gizmosEnabled.positionGizmo=e,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotationGizmoEnabled",{get:function(){return this._gizmosEnabled.rotationGizmo},set:function(e){e?(this.gizmos.rotationGizmo||(this.gizmos.rotationGizmo=new ym(this._defaultUtilityLayer,32,!1,this._thickness,this)),this._attachedNode?this.gizmos.rotationGizmo.attachedNode=this._attachedNode:this.gizmos.rotationGizmo.attachedMesh=this._attachedMesh):this.gizmos.rotationGizmo&&(this.gizmos.rotationGizmo.attachedNode=null),this._gizmosEnabled.rotationGizmo=e,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleGizmoEnabled",{get:function(){return this._gizmosEnabled.scaleGizmo},set:function(e){e?(this.gizmos.scaleGizmo=this.gizmos.scaleGizmo||new Em(this._defaultUtilityLayer,this._thickness,this),this._attachedNode?this.gizmos.scaleGizmo.attachedNode=this._attachedNode:this.gizmos.scaleGizmo.attachedMesh=this._attachedMesh):this.gizmos.scaleGizmo&&(this.gizmos.scaleGizmo.attachedNode=null),this._gizmosEnabled.scaleGizmo=e,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"boundingBoxGizmoEnabled",{get:function(){return this._gizmosEnabled.boundingBoxGizmo},set:function(e){e?(this.gizmos.boundingBoxGizmo=this.gizmos.boundingBoxGizmo||new gm(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),this._attachedMesh?this.gizmos.boundingBoxGizmo.attachedMesh=this._attachedMesh:this.gizmos.boundingBoxGizmo.attachedNode=this._attachedNode,this._attachedMesh?(this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)):this._attachedNode&&(this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode.addBehavior(this.boundingBoxDragBehavior))):this.gizmos.boundingBoxGizmo&&(this._attachedMesh?this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior):this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this.gizmos.boundingBoxGizmo.attachedNode=null),this._gizmosEnabled.boundingBoxGizmo=e,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),e.prototype._setAdditionalTransformNode=function(){for(var e in this.gizmos){var t=this.gizmos[e];t&&this._gizmosEnabled[e]&&(t.additionalTransformNode=this._additionalTransformNode)}},e.prototype.addToAxisCache=function(e){var t=this;e.size>0&&e.forEach((function(e,i){t._gizmoAxisCache.set(i,e)}))},e.prototype.releaseDrag=function(){[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo,this.gizmos.boundingBoxGizmo].forEach((function(e){null==e||e.releaseDrag()}))},e.prototype.dispose=function(){var e,t,i=this;for(var r in this._pointerObservers.forEach((function(e){i._scene.onPointerObservable.remove(e)})),this.gizmos){var n=this.gizmos[r];n&&n.dispose()}this._defaultKeepDepthUtilityLayer!==Ih._DefaultKeepDepthUtilityLayer&&(null===(e=this._defaultKeepDepthUtilityLayer)||void 0===e||e.dispose()),this._defaultUtilityLayer!==Ih._DefaultUtilityLayer&&(null===(t=this._defaultUtilityLayer)||void 0===t||t.dispose()),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},e}(),xm=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._needProjectionMatrixCompute=!0,t._viewMatrix=z.Identity(),t._projectionMatrix=z.Identity(),t}return m(t,e),t.prototype._setPosition=function(e){this._position=e},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!1,configurable:!0}),t.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix||(this.transformedPosition||(this.transformedPosition=V.Zero()),V.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=V.Zero()),V.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),0))},t.prototype.getDepthScale=function(){return 50},t.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},t.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},t.prototype.setDirectionToTarget=function(e){return this.direction=V.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=V.Cross(this.direction,_n.Y),t=V.Cross(e,this.direction);return V.RotationFromAxis(e,t,this.direction)},t.prototype.needCube=function(){return!1},t.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},t.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=V.Zero()},t.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},t.prototype.computeWorldMatrix=function(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=z.Identity()),z.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)},t.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},t.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},t.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},t.prototype._syncParentEnabledState=function(){e.prototype._syncParentEnabledState.call(this),this.parent&&this.parent.getWorldMatrix||(this.transformedPosition=null,this.transformedDirection=null)},t.prototype.getViewMatrix=function(e){var t=H.Vector3[0],i=this.position;this.computeTransformedInformation()&&(i=this.transformedPosition),V.NormalizeToRef(this.getShadowDirection(e),t),1===Math.abs(V.Dot(t,V.Up()))&&(t.z=1e-13);var r=H.Vector3[1];return i.addToRef(t,r),z.LookAtLHToRef(i,r,V.Up(),this._viewMatrix),this._viewMatrix},t.prototype.getProjectionMatrix=function(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,null!=e?e:this._viewMatrix,null!=t?t:[]),this._projectionMatrix},v([Fe()],t.prototype,"position",null),v([Fe()],t.prototype,"direction",null),v([Ie()],t.prototype,"shadowMinZ",null),v([Ie()],t.prototype,"shadowMaxZ",null),t}(wa);qe.AddNodeConstructor("Light_Type_1",(function(e,t){return function(){return new Am(e,V.Zero(),t)}}));var Am=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.1,n.autoUpdateExtends=!0,n.autoCalcShadowZBounds=!1,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return m(t,e),Object.defineProperty(t.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoLeft",{get:function(){return this._orthoLeft},set:function(e){this._orthoLeft=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoRight",{get:function(){return this._orthoRight},set:function(e){this._orthoRight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoTop",{get:function(){return this._orthoTop},set:function(e){this._orthoTop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoBottom",{get:function(){return this._orthoBottom},set:function(e){this._orthoBottom=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DirectionalLight"},t.prototype.getTypeID=function(){return wa.LIGHTTYPEID_DIRECTIONALLIGHT},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var t=this.getScene().activeCamera;t&&z.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e,this.getScene().getEngine().isNDCHalfZRange)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;if(r){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var n=V.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var o=Number.MAX_VALUE,a=-Number.MAX_VALUE,s=0;sthis._orthoRight&&(this._orthoRight=n.x),n.y>this._orthoTop&&(this._orthoTop=n.y),this.autoCalcShadowZBounds&&(n.za&&(a=n.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=o,this._shadowMaxZ=a)}var h=this._orthoRight-this._orthoLeft,d=this._orthoTop-this._orthoBottom,p=void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,f=void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,_=this.getScene().getEngine().useReverseDepthBuffer;z.OrthoOffCenterLHToRef(this._orthoLeft-h*this.shadowOrthoScale,this._orthoRight+h*this.shadowOrthoScale,this._orthoBottom-d*this.shadowOrthoScale,this._orthoTop+d*this.shadowOrthoScale,_?f:p,_?p:f,e,this.getScene().getEngine().isNDCHalfZRange)}},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},t.prototype.transferToNodeMaterialEffect=function(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)},t.prototype.getDepthMinZ=function(e){var t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1},t.prototype.getDepthMaxZ=function(e){var t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1},t.prototype.prepareLightSpecificDefines=function(e,t){e["DIRLIGHT"+t]=!0},v([Ie()],t.prototype,"shadowFrustumSize",null),v([Ie()],t.prototype,"shadowOrthoScale",null),v([Ie()],t.prototype,"autoUpdateExtends",void 0),v([Ie()],t.prototype,"autoCalcShadowZBounds",void 0),v([Ie("orthoLeft")],t.prototype,"_orthoLeft",void 0),v([Ie("orthoRight")],t.prototype,"_orthoRight",void 0),v([Ie("orthoTop")],t.prototype,"_orthoTop",void 0),v([Ie("orthoBottom")],t.prototype,"_orthoBottom",void 0),t}(xm);function Cm(e,t,i){void 0===t&&(t={}),t.diameter||(t.diameter=1),t.segments||(t.segments=16);var r=Gh("",{slice:.5,diameter:t.diameter,segments:t.segments},i),n=qh("",{radius:t.diameter/2,tessellation:3*t.segments+(4-t.segments)},i);n.rotation.x=-Math.PI/2,n.parent=r;var o=Fa.MergeMeshes([n,r],!0);return o.name=e,o}a("BABYLON.DirectionalLight",Am);var Rm={CreateHemisphere:Cm};Fa.CreateHemisphere=function(e,t,i,r){return Cm(e,{segments:t,diameter:i},r)},qe.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new Pm(e,V.Zero(),V.Zero(),0,0,t)}}));var Pm=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,a)||this;return s._innerAngle=0,s._projectionTextureMatrix=z.Zero(),s._projectionTextureLightNear=1e-6,s._projectionTextureLightFar=1e3,s._projectionTextureUpDirection=V.Up(),s._projectionTextureViewLightDirty=!0,s._projectionTextureProjectionLightDirty=!0,s._projectionTextureDirty=!0,s._projectionTextureViewTargetVector=V.Zero(),s._projectionTextureViewLightMatrix=z.Zero(),s._projectionTextureProjectionLightMatrix=z.Zero(),s._projectionTextureScalingMatrix=z.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),s.position=i,s.direction=r,s.angle=n,s.exponent=o,s}return m(t,e),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){var i=this;this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady()&&(t._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled((function(){i._markMeshesAsLightDirty()})):t._IsTexture(this._projectionTexture)&&this._projectionTexture.onLoadObservable.addOnce((function(){i._markMeshesAsLightDirty()}))))},enumerable:!1,configurable:!0}),t._IsProceduralTexture=function(e){return void 0!==e.onGeneratedObservable},t._IsTexture=function(e){return void 0!==e.onLoadObservable},Object.defineProperty(t.prototype,"projectionTextureProjectionLightMatrix",{get:function(){return this._projectionTextureProjectionLightMatrix},set:function(e){this._projectionTextureProjectionLightMatrix=e,this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return wa.LIGHTTYPEID_SPOTLIGHT},t.prototype._setDirection=function(t){e.prototype._setDirection.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setPosition=function(t){e.prototype._setPosition.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;if(r){this._shadowAngleScale=this._shadowAngleScale||1;var n=this._shadowAngleScale*this._angle,o=void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,a=void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,s=this.getScene().getEngine().useReverseDepthBuffer;z.PerspectiveFovLHToRef(n,1,s?a:o,s?o:a,e,!0,this._scene.getEngine().isNDCHalfZRange,void 0,s)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.getAbsolutePosition().addToRef(this.getShadowDirection(),this._projectionTextureViewTargetVector),z.LookAtLHToRef(this.getAbsolutePosition(),this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},t.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,i=e/(e-t),r=-i*t,n=1/Math.tan(this._angle/2);z.FromValuesToRef(n/1,0,0,0,0,n,0,0,0,0,i,1,0,0,r,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof Ja){var e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;z.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,.5,0,.5,.5,.5,1,this._projectionTextureScalingMatrix)}this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype._computeAngleValues=function(){this._lightAngleScale=1/Math.max(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},t.prototype.transferTexturesToEffect=function(e,t){return this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightSampler"+t,this.projectionTexture)),this},t.prototype.transferToEffect=function(e,t){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),i=V.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),i=V.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this},t.prototype.transferToNodeMaterialEffect=function(e,t){var i;return i=this.computeTransformedInformation()?V.Normalize(this.transformedDirection):V.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-i.x,-i.y,-i.z):e.setFloat3(t,i.x,i.y,i.z),this},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},t.prototype.getDepthMinZ=function(e){var t=this._scene.getEngine(),i=void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ;return t.useReverseDepthBuffer&&t.isNDCHalfZRange?i:this._scene.getEngine().isNDCHalfZRange?0:i},t.prototype.getDepthMaxZ=function(e){var t=this._scene.getEngine(),i=void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ;return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:i},t.prototype.prepareLightSpecificDefines=function(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!(!this.projectionTexture||!this.projectionTexture.isReady())},v([Ie()],t.prototype,"angle",null),v([Ie()],t.prototype,"innerAngle",null),v([Ie()],t.prototype,"shadowAngleScale",null),v([Ie()],t.prototype,"exponent",void 0),v([Ie()],t.prototype,"projectionTextureLightNear",null),v([Ie()],t.prototype,"projectionTextureLightFar",null),v([Ie()],t.prototype,"projectionTextureUpDirection",null),v([Me("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(xm);a("BABYLON.SpotLight",Pm);var Im=function(e){function t(t){void 0===t&&(t=Ih.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._cachedPosition=new V,i._cachedForward=new V(0,0,1),i._pointerObserver=null,i.onClickedObservable=new f,i._light=null,i.attachedMesh=new Uo("",i.gizmoLayer.utilityLayerScene),i._attachedMeshParent=new Fo("parent",i.gizmoLayer.utilityLayerScene),i.attachedMesh.parent=i._attachedMeshParent,i._material=new Uu("light",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new Z(.5,.5,.5),i._material.specularColor=new Z(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._light&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._light))}),Gr.POINTERDOWN),i}return m(t,e),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this.attachedMesh},set:function(e){ae.Warn("Nodes cannot be attached to LightGizmo. Attach to a mesh instead.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"light",{get:function(){return this._light},set:function(e){var i=this;if(this._light=e,e){this._lightMesh&&this._lightMesh.dispose(),this._lightMesh=e instanceof Ch?t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Am?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Pm?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._lightMesh.parent=this._rootMesh;var r=this.gizmoLayer._getSharedGizmoLight();if(r.includedOnlyMeshes=r.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new G,this.attachedMesh.reservedDataStore||(this.attachedMesh.reservedDataStore={}),this.attachedMesh.reservedDataStore.lightGizmo=this,e.parent&&this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()),e.position&&(this.attachedMesh.position.copyFrom(e.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)),e.direction){this.attachedMesh.setDirection(e.direction),this.attachedMesh.computeWorldMatrix(!0);var n=this._getMeshForward();this._cachedForward.copyFrom(n)}this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._getMeshForward=function(){var e=this.attachedMesh.forward;return this.attachedMesh.getScene().useRightHandedSystem&&(e.negateToRef(H.Vector3[0]),e=H.Vector3[0]),e},t.prototype._update=function(){if(e.prototype._update.call(this),this._light){if(this._light.parent&&this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()),this._light.position)if(this.attachedMesh.position.equals(this._cachedPosition))this.attachedMesh.position.copyFrom(this._light.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position);else{var t=this.attachedMesh.position;this._light.position=new V(t.x,t.y,t.z),this._cachedPosition.copyFrom(this.attachedMesh.position)}if(this._light.direction){var i=this._getMeshForward();if(V.DistanceSquared(i,this._cachedForward)>1e-4){var r=i;this._light.direction=new V(r.x,r.y,r.z),this._cachedForward.copyFrom(i)}else V.DistanceSquared(i,this._light.direction)>1e-4&&(this.attachedMesh.setDirection(this._light.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(i))}}},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._material.dispose(),e.prototype.dispose.call(this),this._attachedMeshParent.dispose()},t._CreateHemisphericLightMesh=function(e){var i=new Fa("hemisphereLight",e),r=Cm(i.name,{segments:10,diameter:1},e);return r.position.z=-.15,r.rotation.x=Math.PI/2,r.parent=i,this._CreateLightLines(3,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreatePointLightMesh=function(e){var i=new Fa("pointLight",e),r=Gh(i.name,{segments:10,diameter:1},e);return r.rotation.x=Math.PI/2,r.parent=i,this._CreateLightLines(5,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateSpotLightMesh=function(e){var i=new Fa("spotLight",e);Gh(i.name,{segments:10,diameter:1},e).parent=i;var r=Cm(i.name,{segments:10,diameter:2},e);return r.parent=i,r.rotation.x=-Math.PI/2,this._CreateLightLines(2,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateDirectionalLightMesh=function(e){var i=new Fa("directionalLight",e),r=new Fa(i.name,e);r.parent=i,Gh(i.name,{diameter:1.2,segments:10},e).parent=r;var n=xh(i.name,{updatable:!1,height:6,diameterTop:.3,diameterBottom:.3,tessellation:6,subdivisions:1},e);n.parent=r;var o=n.clone(i.name);o.scaling.y=.5,o.position.x+=1.25;var a=n.clone(i.name);a.scaling.y=.5,a.position.x+=-1.25;var s=xh(i.name,{updatable:!1,height:1,diameterTop:0,diameterBottom:.6,tessellation:6,subdivisions:1},e);return s.position.y+=3,s.parent=r,(o=s.clone(i.name)).position.y=1.5,o.position.x+=1.25,(a=s.clone(i.name)).position.y=1.5,a.position.x+=-1.25,r.scaling.scaleInPlace(t._Scale),r.rotation.z=Math.PI/2,r.rotation.y=Math.PI/2,i},t._Scale=.007,t._CreateLightLines=function(e,t){var i=new Fa("root",t);i.rotation.x=Math.PI/2;var r=new Fa("linePivot",t);r.parent=i;var n=xh("line",{updatable:!1,height:2,diameterTop:.2,diameterBottom:.3,tessellation:6,subdivisions:1},t);if(n.position.y=n.scaling.y/2+1.2,n.parent=r,e<2)return r;for(var o=0;o<4;o++){var a=r.clone("lineParentClone");a.rotation.z=Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}if(e<3)return i;for(o=0;o<4;o++){var s=r.clone("linePivotClone");s.rotation.z=Math.PI/2,s.rotation.y=Math.PI/2*o}if(e<4)return i;for(o=0;o<4;o++){var l=r.clone("linePivotClone");l.rotation.z=Math.PI+Math.PI/4,l.rotation.y=Math.PI/2+Math.PI/2*o,l.getChildMeshes()[0].scaling.y=.5,l.getChildMeshes()[0].scaling.x=l.getChildMeshes()[0].scaling.z=.8,l.getChildMeshes()[0].position.y=l.getChildMeshes()[0].scaling.y/2+1.2}return e<5||(r.clone("linePivotClone").rotation.z=Math.PI),i},t}(Oh),Mm=function(e){function t(t,i,r){void 0===t&&(t=Ih.DefaultUtilityLayer);var n=e.call(this,t)||this;return n._pointerObserver=null,n.onClickedObservable=new f,n._camera=null,n._invProjection=new z,n._material=new Uu("cameraGizmoMaterial",n.gizmoLayer.utilityLayerScene),n._frustumLinesColor=r,n._material.diffuseColor=null!=i?i:new Z(.5,.5,.5),n._material.specularColor=new Z(.1,.1,.1),n._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){n._camera&&(n._isHovered=!(!e.pickInfo||-1==n._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),n._isHovered&&0===e.event.button&&n.onClickedObservable.notifyObservers(n._camera))}),Gr.POINTERDOWN),n}return m(t,e),Object.defineProperty(t.prototype,"displayFrustum",{get:function(){return this._cameraLinesMesh.isEnabled()},set:function(e){this._cameraLinesMesh.setEnabled(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(e){var i,r,n=this;if(this._camera=e,this.attachedNode=e,e){this._customMeshSet||(this._cameraMesh&&this._cameraMesh.dispose(),this._cameraMesh=t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),this._cameraMesh.getChildMeshes(!1).forEach((function(e){e.material=n._material})),this._cameraMesh.parent=this._rootMesh),this._cameraLinesMesh&&this._cameraLinesMesh.dispose();var o=null!==(r=null===(i=this._frustumLinesColor)||void 0===i?void 0:i.toColor4(1))&&void 0!==r?r:new J(1,1,1,1);this._cameraLinesMesh=t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene,o),this._cameraLinesMesh.parent=this._rootMesh,this.gizmoLayer.utilityLayerScene.activeCamera&&this.gizmoLayer.utilityLayerScene.activeCamera.maxZ<1.5*e.maxZ&&(this.gizmoLayer.utilityLayerScene.activeCamera.maxZ=1.5*e.maxZ),this.attachedNode.reservedDataStore||(this.attachedNode.reservedDataStore={}),this.attachedNode.reservedDataStore.cameraGizmo=this;var a=this.gizmoLayer._getSharedGizmoLight();a.includedOnlyMeshes=a.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){e.prototype._update.call(this),this._camera&&(this._camera.getProjectionMatrix().invertToRef(this._invProjection),this._cameraLinesMesh.setPivotMatrix(this._invProjection,!1),this._cameraLinesMesh.scaling.x=1/this._rootMesh.scaling.x,this._cameraLinesMesh.scaling.y=1/this._rootMesh.scaling.y,this._cameraLinesMesh.scaling.z=1/this._rootMesh.scaling.z,this._cameraMesh.parent=null,this._cameraMesh.rotation.y=.5*Math.PI*(this._camera.getScene().useRightHandedSystem?1:-1),this._cameraMesh.parent=this._rootMesh)},t.prototype.setCustomMesh=function(e){if(e.getScene()!=this.gizmoLayer.utilityLayerScene)throw"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";this._cameraMesh&&this._cameraMesh.dispose(),this._cameraMesh=e,this._cameraMesh.parent=this._rootMesh,this._customMeshSet=!0},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._material.dispose(),e.prototype.dispose.call(this)},t._CreateCameraMesh=function(e){var i=new Fa("rootCameraGizmo",e),r=new Fa(i.name,e);r.parent=i,Uh(i.name,{width:1,height:.8,depth:.5},e).parent=r;var n=xh(i.name,{height:.5,diameterTop:.8,diameterBottom:.8},e);n.parent=r,n.position.y=.3,n.position.x=-.6,n.rotation.x=.5*Math.PI;var o=xh(i.name,{height:.5,diameterTop:.6,diameterBottom:.6},e);o.parent=r,o.position.y=.5,o.position.x=.4,o.rotation.x=.5*Math.PI;var a=xh(i.name,{height:.5,diameterTop:.5,diameterBottom:.5},e);return a.parent=r,a.position.y=0,a.position.x=.6,a.rotation.z=.5*Math.PI,i.scaling.scaleInPlace(t._Scale),r.position.x=-.9,i},t._CreateCameraFrustum=function(e,t){var i=new Fa("rootCameraGizmo",e),r=new Fa(i.name,e);r.parent=i;for(var n=0;n<4;n+=2)for(var o=0;o<4;o+=2){var a=fd("lines",{points:[new V(-1+o,-1+n,-1),new V(-1+o,-1+n,1)],colors:[t,t]},e);a.parent=r,a.alwaysSelectAsActiveMesh=!0,a.isPickable=!1,(a=fd("lines",{points:[new V(-1,-1+o,-1+n),new V(1,-1+o,-1+n)],colors:[t,t]},e)).parent=r,a.alwaysSelectAsActiveMesh=!0,a.isPickable=!1,(a=fd("lines",{points:[new V(-1+o,-1,-1+n),new V(-1+o,1,-1+n)],colors:[t,t]},e)).parent=r,a.alwaysSelectAsActiveMesh=!0,a.isPickable=!1}return i},t._Scale=.05,t}(Oh);li.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";li.IncludesShadersStore.packingFunctions="vec4 pack(float depth)\n{const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\nfloat unpack(vec4 color)\n{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}";li.IncludesShadersStore.kernelBlurFragment="#ifdef DOF\nfactor=sampleCoC(sampleCoord{X}); \ncomputedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif\n";li.IncludesShadersStore.kernelBlurFragment2="#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif\n";li.ShadersStore.kernelBlurPixelShader="uniform sampler2D textureSampler;uniform vec2 delta;varying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;float sampleCoC(in vec2 offset) {float coc=texture2D(circleOfConfusionSampler,offset).r;return coc; }\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \nfloat factor=0.0;\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include[0..varyingCount]\n#include[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";li.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";li.ShadersStore.kernelBlurVertexShader="attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";var Om=function(e){function t(t,i,r,n,o,a,s,l,c,h,d,p){void 0===a&&(a=Ja.BILINEAR_SAMPLINGMODE),void 0===c&&(c=u.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=""),void 0===d&&(d=!1),void 0===p&&(p=u.TEXTUREFORMAT_RGBA);var f=e.call(this,t,"kernelBlur",["delta","direction"],["circleOfConfusionSampler"],n,o,a,s,l,null,c,"kernelBlur",{varyingCount:0,depCount:0},!0,p)||this;return f._blockCompilation=d,f._packedFloat=!1,f._staticDefines="",f._staticDefines=h,f.direction=i,f.onApplyObservable.add((function(e){f._outputTexture?e.setFloat2("delta",1/f._outputTexture.width*f.direction.x,1/f._outputTexture.height*f.direction.y):e.setFloat2("delta",1/f.width*f.direction.x,1/f.height*f.direction.y)})),f.kernel=r,f}return m(t,e),Object.defineProperty(t.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this._blockCompilation||this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this._blockCompilation||this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"BlurPostProcess"},t.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._updateParameters(n,o)},t.prototype._updateParameters=function(t,i){for(var r=this._kernel,n=(r-1)/2,o=[],a=[],s=0,l=0;l0)return Math.max(n,3)}return Math.max(t,3)},t.prototype._gaussianWeight=function(e){var t=1/3,i=-e*e/(2*t*t);return 1/(Math.sqrt(2*Math.PI)*t)*Math.exp(i)},t.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},t._Parse=function(e,i,r,n){return Ke.Parse((function(){return new t(e.name,e.direction,e.kernel,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.reusable,e.textureType,void 0,!1)}),e,r,n)},v([Ie("kernel")],t.prototype,"_kernel",void 0),v([Ie("packedFloat")],t.prototype,"_packedFloat",void 0),v([Ne()],t.prototype,"direction",void 0),t}(hl);a("BABYLON.BlurPostProcess",Om);var Dm=function(e){function t(t,i,r,n,o,a,s){void 0===o&&(o=u.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=Ja.BILINEAR_SAMPLINGMODE),void 0===s&&(s=!0);var l=e.call(this,t,i,r,n,!0,o,!1,a,s)||this;if(l.mirrorPlane=new sn(0,1,0,1),l._transformMatrix=z.Zero(),l._mirrorMatrix=z.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,!(r=l.getScene()))return l;l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=r.imageProcessingConfiguration.onUpdateParameters.add((function(){l._updateGammaSpace()}));var c,h=r.getEngine();return h.supportsUniformBuffers&&(l._sceneUBO=r.createSceneUniformBuffer('Scene for Mirror Texture (name "'.concat(t,'")'))),l.onBeforeBindObservable.add((function(){var e;null===(e=h._debugPushGroup)||void 0===e||e.call(h,"mirror generation for ".concat(t),1)})),l.onAfterUnbindObservable.add((function(){var e;null===(e=h._debugPopGroup)||void 0===e||e.call(h,1)})),l.onBeforeRenderObservable.add((function(){l._sceneUBO&&(l._currentSceneUBO=r.getSceneUniformBuffer(),r.setSceneUniformBuffer(l._sceneUBO),r.getSceneUniformBuffer().unbindEffect()),z.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._mirrorMatrix.multiplyToRef(r.getViewMatrix(),l._transformMatrix),r.setTransformMatrix(l._transformMatrix,r.getProjectionMatrix()),c=r.clipPlane,r.clipPlane=l.mirrorPlane,r._mirroredCameraPosition=V.TransformCoordinates(r.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){l._sceneUBO&&r.setSceneUniformBuffer(l._currentSceneUBO),r.updateTransformMatrix(),r._mirroredCameraPosition=null,r.clipPlane=c})),l}return m(t,e),Object.defineProperty(t.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i},t.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},t.prototype._updateGammaSpace=function(){var e=this.getScene();e&&(this.gammaSpace=!e.imageProcessingConfiguration.isEnabled||!e.imageProcessingConfiguration.applyByPostProcess)},t.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var e=this.getScene().getEngine(),t=e.getCaps().textureFloatRender&&e.getCaps().textureFloatLinearFiltering?u.TEXTURETYPE_FLOAT:u.TEXTURETYPE_HALF_FLOAT;this._blurX=new Om("horizontal blur",new U(1,0),this._blurKernelX,this._blurRatio,null,Ja.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._renderTarget:this._blurX.alwaysForcePOT=!0,this._blurY=new Om("vertical blur",new U(0,1),this._blurKernelY,this._blurRatio,null,Ja.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}else this._blurY&&(this.removePostProcess(this._blurY),this._blurY.dispose(),this._blurY=null),this._blurX&&(this.removePostProcess(this._blurX),this._blurX.dispose(),this._blurX=null)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),r=new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r},t.prototype.serialize=function(){if(!this.name)return null;var t=e.prototype.serialize.call(this);return t.mirrorPlane=this.mirrorPlane.asArray(),t},t.prototype.dispose=function(){var t;e.prototype.dispose.call(this);var i=this.getScene();i&&i.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),null===(t=this._sceneUBO)||void 0===t||t.dispose()},t}(Pl);Ja._CreateMirror=function(e,t,i,r){return new Dm(e,t,i,r)};var Nm=function(e){function t(t,i,r,n,o,a,s,l,c,h,d,p,_,m,g){void 0===r&&(r=null),void 0===n&&(n=!1),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=u.TEXTUREFORMAT_RGBA),void 0===c&&(c=!1),void 0===h&&(h=null),void 0===d&&(d=!1),void 0===p&&(p=.8),void 0===_&&(_=0);var v,y=this;return(y=e.call(this,i)||this)._lodScale=.8,y._lodOffset=0,y.onLoadObservable=new f,y.boundingBoxPosition=V.Zero(),y._rotationY=0,y._files=null,y._forcedExtension=null,y._extensions=null,y._textureMatrixRefraction=new z,y.name=t,y.url=t,y._noMipmap=n,y.hasAlpha=!1,y._format=l,y.isCube=!0,y._textureMatrix=z.Identity(),y._createPolynomials=d,y.coordinatesMode=Ja.CUBIC_MODE,y._extensions=r,y._files=o,y._forcedExtension=h,y._loaderOptions=m,y._useSRGBBuffer=g,y._lodScale=p,y._lodOffset=_,t||o?(y.updateURL(t,h,a,c,s,r,null===(v=y.getScene())||void 0===v?void 0:v.useDelayedTextureLoading,o),y):y}return m(t,e),Object.defineProperty(t.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var t=this.getScene();t&&t.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(z.RotationY(this._rotationY))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forcedExtension",{get:function(){return this._forcedExtension},enumerable:!1,configurable:!0}),t.CreateFromImages=function(e,i,r){var n="";return e.forEach((function(e){return n+=e})),new t(n,i,null,r,e)},t.CreateFromPrefilteredData=function(e,i,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=i.useDelayedTextureLoading;i.useDelayedTextureLoading=!1;var a=new t(e,i,null,!1,null,null,null,void 0,!0,r,n);return i.useDelayedTextureLoading=o,a},t.prototype.getClassName=function(){return"CubeTexture"},t.prototype.updateURL=function(e,t,i,r,n,o,a,s){void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=null),void 0===o&&(o=null),void 0===a&&(a=!1),void 0===s&&(s=null),this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,t&&(this._forcedExtension=t);var l=e.lastIndexOf("."),c=t||(l>-1?e.substring(l).toLowerCase():""),h=0===c.indexOf(".dds"),d=0===c.indexOf(".env"),p=0===c.indexOf(".basis");if(d?(this.gammaSpace=!1,this._prefiltered=!1,this.anisotropicFilteringLevel=1):(this._prefiltered=r,r&&(this.gammaSpace=!1,this.anisotropicFilteringLevel=1)),s)this._files=s;else if(p||d||h||o||(o=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),this._files=this._files||[],this._files.length=0,o){for(var f=0;f0,o.LODINREFLECTIONALPHA=s.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,s.coordinatesMode===Ja.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=s.isCube,o.REFLECTIONMAP_OPPOSITEZ=o.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,s.coordinatesMode){case Ja.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Ja.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Ja.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Ja.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0;break;case Ja.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Ja.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ja.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ja.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ja.CUBIC_MODE:case Ja.INVCUBIC_MODE:default:o.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(o.REFLECTIONFRESNEL=!0,o.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1)}else o.REFLECTION=!1,o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1,o.REFLECTIONBLUR=!1,o.REFLECTIONMAP_3D=!1,o.REFLECTIONMAP_SPHERICAL=!1,o.REFLECTIONMAP_PLANAR=!1,o.REFLECTIONMAP_CUBIC=!1,o.REFLECTIONMAP_PROJECTION=!1,o.REFLECTIONMAP_SKYBOX=!1,o.REFLECTIONMAP_EXPLICIT=!1,o.REFLECTIONMAP_EQUIRECTANGULAR=!1,o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,o.INVERTCUBICMAP=!1,o.REFLECTIONMAP_OPPOSITEZ=!1,o.LODINREFLECTIONALPHA=!1,o.GAMMAREFLECTION=!1,o.RGBDREFLECTION=!1}o.PREMULTIPLYALPHA=this.alphaMode===u.ALPHA_PREMULTIPLIED||this.alphaMode===u.ALPHA_PREMULTIPLIED_PORTERDUFF,o.USERGBCOLOR=this._useRGBColor,o.NOISE=this._enableNoise}if(o._areLightsDirty&&(o.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel),o.BACKMAT_SHADOWONLY=this._shadowOnly),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(o._areMiscDirty&&(o.REFLECTIONMAP_3D&&this._enableGroundProjection?(o.PROJECTED_GROUND=!0,o.REFLECTIONMAP_SKYBOX=!0):o.PROJECTED_GROUND=!1),da(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),_a(n,a,this,o,i,null,t.getRenderingMesh().hasThinInstances),ya(e,o,!1,!0,!1)&&e&&(n.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(Nr.NormalKind)||(e.createNormals(!0),ae.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),n.resetCachedMaterial();var l=new ll;o.FOG&&l.addFallback(0,"FOG"),o.POINTSIZE&&l.addFallback(1,"POINTSIZE"),o.MULTIVIEW&&l.addFallback(0,"MULTIVIEW"),ua(o,l,this._maxSimultaneousLights);var c=[Nr.PositionKind];o.NORMAL&&c.push(Nr.NormalKind),o.UV1&&c.push(Nr.UVKind),o.UV2&&c.push(Nr.UV2Kind),la(c,e,o,l),ca(c,o);var h=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix","projectedGroundInfos","logarithmicDepthConstant"];Go(h);var d=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],p=["Material","Scene"];pr&&(pr.PrepareUniforms(h,o),pr.PrepareSamplers(d,o)),Aa({uniformsNames:h,uniformBuffersNames:p,samplers:d,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var f=o.toString(),_=n.getEngine().createEffect("background",{attributes:c,uniformsNames:h,uniformBuffersNames:p,samplers:d,defines:f,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a);t.setEffect(_,o,this._materialContext),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady()||(o._renderId=n.getRenderId(),r._wasPreviouslyReady=!0,r._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),0))},t.prototype._computePrimaryColorFromPerceptualColor=function(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor,this.getScene().getEngine().useExactSrgbConversions),this._imageProcessingConfiguration&&this._primaryColor.scaleToRef(1/this._imageProcessingConfiguration.exposure,this._primaryColor),this._computePrimaryColors())},t.prototype._computePrimaryColors=function(){0===this._primaryColorShadowLevel&&0===this._primaryColorHighlightLevel||(this._primaryColor.scaleToRef(this._primaryColorShadowLevel,this._primaryShadowColor),this._primaryColor.subtractToRef(this._primaryShadowColor,this._primaryShadowColor),this._white.subtractToRef(this._primaryColor,this._primaryHighlightColor),this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel,this._primaryHighlightColor),this._primaryColor.addToRef(this._primaryHighlightColor,this._primaryHighlightColor))},t.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vPrimaryColorShadow",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("fFovMultiplier",1),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroundCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.addUniform("projectedGroundInfos",2),this._uniformBuffer.create()},t.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),e.prototype.unbind.call(this)},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindForSubMesh=function(e,t,i){var r=this.getScene(),n=i.materialDefines;if(n){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),na(t,this._activeEffect);var a=this._mustRebind(r,o,i,t.visibility);if(a){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o);var s=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync&&!i._drawWrapper._forceRebindOnNextCall||(r.texturesEnabled&&(this._diffuseTexture&&xu.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),ia(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&xu.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",s.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),n.USEHIGHLIGHTANDSHADOWCOLORS?(this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryHighlightColor,1),this._uniformBuffer.updateColor4("vPrimaryColorShadow",this._primaryShadowColor,1)):this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,1)),this._uniformBuffer.updateFloat("fFovMultiplier",this._fovMultiplier),r.texturesEnabled&&(this._diffuseTexture&&xu.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&xu.ReflectionTextureEnabled&&(n.REFLECTIONBLUR&&n.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",s):n.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",s._lodTextureMid||s),this._uniformBuffer.setTexture("reflectionSamplerLow",s._lodTextureLow||s),this._uniformBuffer.setTexture("reflectionSamplerHigh",s._lodTextureHigh||s)):this._uniformBuffer.setTexture("reflectionSampler",s),n.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w))),n.PROJECTED_GROUND&&this._uniformBuffer.updateFloat2("projectedGroundInfos",this.projectedGroundRadius,this.projectedGroundHeight)),Ho(this._activeEffect,this,r),r.bindEyePosition(o)}else r.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._uniformBuffer.bindToEffect(o,"Material"),this._needToBindSceneUbo=!0);!a&&this.isFrozen||(r.lightsEnabled&&sa(r,t,this._activeEffect,n,this._maxSimultaneousLights),this.bindView(o),Qo(r,t,this._activeEffect,!0),this._useLogarithmicDepth&&Ko(n,o,r),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,i),this._uniformBuffer.update()}}},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this._reflectionTexture===t||this._diffuseTexture===t},t.prototype.dispose=function(t,i){void 0===t&&(t=!1),void 0===i&&(i=!1),i&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return Ke.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.customType="BABYLON.BackgroundMaterial",t},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,i,r){return Ke.Parse((function(){return new t(e.name,i)}),e,i,r)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,v([Oe()],t.prototype,"_primaryColor",void 0),v([Pe("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),v([Oe()],t.prototype,"__perceptualColor",void 0),v([Ie()],t.prototype,"_primaryColorShadowLevel",void 0),v([Ie()],t.prototype,"_primaryColorHighlightLevel",void 0),v([Pe("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),v([Me()],t.prototype,"_reflectionTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),v([Ie()],t.prototype,"_reflectionBlur",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),v([Me()],t.prototype,"_diffuseTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),v([Ie()],t.prototype,"_shadowLevel",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),v([Fe()],t.prototype,"_sceneCenter",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),v([Ie()],t.prototype,"_opacityFresnel",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),v([Ie()],t.prototype,"_reflectionFresnel",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),v([Ie()],t.prototype,"_reflectionFalloffDistance",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),v([Ie()],t.prototype,"_reflectionAmount",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),v([Ie()],t.prototype,"_reflectionReflectance0",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),v([Ie()],t.prototype,"_reflectionReflectance90",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),v([Ie()],t.prototype,"_useRGBColor",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),v([Ie()],t.prototype,"_enableNoise",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),v([Ie()],t.prototype,"_maxSimultaneousLights",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),v([Ie()],t.prototype,"_shadowOnly",void 0),v([Pe("_markAllSubMeshesAsLightsDirty")],t.prototype,"shadowOnly",void 0),v([Ue()],t.prototype,"_imageProcessingConfiguration",void 0),v([Ie(),Pe("_markAllSubMeshesAsMiscDirty")],t.prototype,"enableGroundProjection",void 0),v([Ie()],t.prototype,"projectedGroundRadius",void 0),v([Ie()],t.prototype,"projectedGroundHeight",void 0),t}(ws);a("BABYLON.BackgroundMaterial",Lm);var wm=function(){function e(t,i){var r=this;this._errorHandler=function(e,t){r.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=g(g({},e._GetDefaultOptions(i)),t),this._scene=i,this.onErrorObservable=new f,this._setupBackground(),this._setupImageProcessing()}return e._GetDefaultOptions=function(e){return{createGround:!0,groundSize:15,groundTexture:this._GroundTextureCDNUrl,groundColor:new Z(.2,.2,.3).toLinearSpace(e.getEngine().useExactSrgbConversions).scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:u.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._SkyboxTextureCDNUrl,skyboxColor:new Z(.2,.2,.3).toLinearSpace(e.getEngine().useExactSrgbConversions).scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:V.Zero(),setupImageProcessing:!0,environmentTexture:this._EnvironmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skybox",{get:function(){return this._skybox},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ground",{get:function(){return this._ground},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!1,configurable:!0}),e.prototype.updateOptions=function(e){var t=g(g({},this._options),e);this._ground&&!t.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!t.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=t.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!t.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!t.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=t.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!t.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=t.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=t,this._setupBackground(),this._setupImageProcessing()},e.prototype.setMainColor=function(e){this.groundMaterial&&(this.groundMaterial.primaryColor=e),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=e),this.groundMirror&&(this.groundMirror.clearColor=new J(e.r,e.g,e.b,1))},e.prototype._setupImageProcessing=function(){this._options.setupImageProcessing&&(this._scene.imageProcessingConfiguration.contrast=this._options.cameraContrast,this._scene.imageProcessingConfiguration.exposure=this._options.cameraExposure,this._scene.imageProcessingConfiguration.toneMappingEnabled=this._options.toneMappingEnabled,this._setupEnvironmentTexture())},e.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof Ya)this._scene.environmentTexture=this._options.environmentTexture;else{var e=Nm.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new Fa("BackgroundHelper",this._scene)),this._rootMesh.rotation.y=this._options.backgroundYRotation;var e=this._getSceneSize();this._options.createGround&&(this._setupGround(e),this._setupGroundMaterial(),this._setupGroundDiffuseTexture(),this._options.enableGroundMirror&&this._setupGroundMirrorTexture(e),this._setupMirrorInGroundMaterial()),this._options.createSkybox&&(this._setupSkybox(e),this._setupSkyboxMaterial(),this._setupSkyboxReflectionTexture()),this._rootMesh.position.x=e.rootPosition.x,this._rootMesh.position.z=e.rootPosition.z,this._rootMesh.position.y=e.rootPosition.y},e.prototype._getSceneSize=function(){var e=this,t=this._options.groundSize,i=this._options.skyboxSize,r=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:i,rootPosition:r};var n=this._scene.getWorldExtends((function(t){return t!==e._ground&&t!==e._rootMesh&&t!==e._skybox})),o=n.max.subtract(n.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Nc&&this._scene.activeCamera.upperRadiusLimit&&(i=t=2*this._scene.activeCamera.upperRadiusLimit);var a=o.length();a>t&&(i=t=2*a),t*=1.1,i*=1.5,(r=n.min.add(o.scale(.5))).y=n.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:i,rootPosition:r}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=fs("BackgroundPlane",{size:e.groundSize},this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add((function(){t._ground=null}))),this._ground.receiveShadows=this._options.enableGroundShadow},e.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new Lm("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=u.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},e.prototype._setupGroundDiffuseTexture=function(){this._groundMaterial&&(this._groundTexture||(this._options.groundTexture instanceof Ya?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new Ja(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._groundTexture.gammaSpace=!1,this._groundTexture.hasAlpha=!0,this._groundMaterial.diffuseTexture=this._groundTexture)))},e.prototype._setupGroundMirrorTexture=function(e){var t=Ja.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new Dm("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Ja.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new sn(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.renderList))for(var i=0;i0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)},t.prototype.dispose=function(e){var t,i,r,n;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose(),null===(r=this._bumpTexture)||void 0===r||r.dispose(),null===(n=this._tintTexture)||void 0===n||n.dispose())},t.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},t.prototype.addFallbacks=function(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(i++,"CLEARCOAT"),i},t.prototype.getSamplers=function(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vClearCoatParams",size:2,type:"vec2"},{name:"vClearCoatRefractionParams",size:4,type:"vec4"},{name:"vClearCoatInfos",size:4,type:"vec4"},{name:"clearCoatMatrix",size:16,type:"mat4"},{name:"clearCoatRoughnessMatrix",size:16,type:"mat4"},{name:"vClearCoatBumpInfos",size:2,type:"vec2"},{name:"vClearCoatTangentSpaceParams",size:2,type:"vec2"},{name:"clearCoatBumpMatrix",size:16,type:"mat4"},{name:"vClearCoatTintParams",size:4,type:"vec4"},{name:"clearCoatColorAtDistance",size:1,type:"float"},{name:"vClearCoatTintInfos",size:2,type:"vec2"},{name:"clearCoatTintMatrix",size:16,type:"mat4"}]}},t._DefaultIndexOfRefraction=1.5,v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),v([Ie()],t.prototype,"intensity",void 0),v([Ie()],t.prototype,"roughness",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"remapF0OnInterfaceChange",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTintEnabled",void 0),v([Oe()],t.prototype,"tintColor",void 0),v([Ie()],t.prototype,"tintColorAtDistance",void 0),v([Ie()],t.prototype,"tintThickness",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"tintTexture",void 0),t}(Nu),jm=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.IRIDESCENCE=!1,t.IRIDESCENCE_TEXTURE=!1,t.IRIDESCENCE_TEXTUREDIRECTUV=0,t.IRIDESCENCE_THICKNESS_TEXTURE=!1,t.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0,t}return m(t,e),t}(Gs),Ym=function(e){function t(i,r){void 0===r&&(r=!0);var n=e.call(this,i,"PBRIridescence",110,new jm,r)||this;return n._isEnabled=!1,n.isEnabled=!1,n.intensity=1,n.minimumThickness=t._DefaultMinimumThickness,n.maximumThickness=t._DefaultMaximumThickness,n.indexOfRefraction=t._DefaultIndexOfRefraction,n._texture=null,n.texture=null,n._thicknessTexture=null,n.thicknessTexture=null,n._internalMarkAllSubMeshesAsTexturesDirty=i._dirtyCallbacks[u.MATERIAL_TextureDirtyFlag],n}return m(t,e),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isReadyForSubMesh=function(e,t){if(!this._isEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&xu.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._thicknessTexture&&xu.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefinesBeforeAttributes=function(e,t){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&xu.IridescenceTextureEnabled?ta(this._texture,e,"IRIDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&xu.IridescenceTextureEnabled?ta(this._thicknessTexture,e,"IRIDESCENCE_THICKNESS_TEXTURE"):e.IRIDESCENCE_THICKNESS_TEXTURE=!1)):(e.IRIDESCENCE=!1,e.IRIDESCENCE_TEXTURE=!1,e.IRIDESCENCE_THICKNESS_TEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0)},t.prototype.bindForSubMesh=function(e,t){var i,r,n,o,a,s,l,c;if(this._isEnabled){var u=this._material.isFrozen;e.useUbo&&u&&e.isSync||((this._texture||this._thicknessTexture)&&xu.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",null!==(r=null===(i=this._texture)||void 0===i?void 0:i.coordinatesIndex)&&void 0!==r?r:0,null!==(o=null===(n=this._texture)||void 0===n?void 0:n.level)&&void 0!==o?o:0,null!==(s=null===(a=this._thicknessTexture)||void 0===a?void 0:a.coordinatesIndex)&&void 0!==s?s:0,null!==(c=null===(l=this._thicknessTexture)||void 0===l?void 0:l.level)&&void 0!==c?c:0),this._texture&&ia(this._texture,e,"iridescence"),this._thicknessTexture&&ia(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),t.texturesEnabled&&(this._texture&&xu.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&xu.IridescenceTextureEnabled&&e.setTexture("iridescenceThicknessSampler",this._thicknessTexture))}},t.prototype.hasTexture=function(e){return this._texture===e||this._thicknessTexture===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._thicknessTexture&&e.push(this._thicknessTexture)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture)},t.prototype.dispose=function(e){var t,i;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._thicknessTexture)||void 0===i||i.dispose())},t.prototype.getClassName=function(){return"PBRIridescenceConfiguration"},t.prototype.addFallbacks=function(e,t,i){return e.IRIDESCENCE&&t.addFallback(i++,"IRIDESCENCE"),i},t.prototype.getSamplers=function(e){e.push("iridescenceSampler","iridescenceThicknessSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vIridescenceParams",size:4,type:"vec4"},{name:"vIridescenceInfos",size:4,type:"vec4"},{name:"iridescenceMatrix",size:16,type:"mat4"},{name:"iridescenceThicknessMatrix",size:16,type:"mat4"}]}},t._DefaultMinimumThickness=100,t._DefaultMaximumThickness=400,t._DefaultIndexOfRefraction=1.3,v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),v([Ie()],t.prototype,"intensity",void 0),v([Ie()],t.prototype,"minimumThickness",void 0),v([Ie()],t.prototype,"maximumThickness",void 0),v([Ie()],t.prototype,"indexOfRefraction",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"thicknessTexture",void 0),t}(Nu),Km=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.ANISOTROPIC=!1,t.ANISOTROPIC_TEXTURE=!1,t.ANISOTROPIC_TEXTUREDIRECTUV=0,t.ANISOTROPIC_LEGACY=!1,t.MAINUV1=!1,t}return m(t,e),t}(Gs),Qm=function(e){function t(t,i){void 0===i&&(i=!0);var r=e.call(this,t,"PBRAnisotropic",110,new Km,i)||this;return r._isEnabled=!1,r.isEnabled=!1,r.intensity=1,r.direction=new U(1,0),r._texture=null,r.texture=null,r._legacy=!1,r.legacy=!1,r._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[u.MATERIAL_TextureDirtyFlag],r._internalMarkAllSubMeshesAsMiscDirty=t._dirtyCallbacks[u.MATERIAL_MiscDirtyFlag],r}return m(t,e),Object.defineProperty(t.prototype,"angle",{get:function(){return Math.atan2(this.direction.y,this.direction.x)},set:function(e){this.direction.x=Math.cos(e),this.direction.y=Math.sin(e)},enumerable:!1,configurable:!0}),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype._markAllSubMeshesAsMiscDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsMiscDirty()},t.prototype.isReadyForSubMesh=function(e,t){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&xu.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},t.prototype.prepareDefinesBeforeAttributes=function(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(Nr.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&xu.AnisotropicTextureEnabled?ta(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1),e._areMiscDirty&&(e.ANISOTROPIC_LEGACY=this._legacy)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.ANISOTROPIC_LEGACY=!1)},t.prototype.bindForSubMesh=function(e,t){if(this._isEnabled){var i=this._material.isFrozen;e.useUbo&&i&&e.isSync||(this._texture&&xu.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),ia(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&xu.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)}},t.prototype.hasTexture=function(e){return this._texture===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},t.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},t.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},t.prototype.addFallbacks=function(e,t,i){return e.ANISOTROPIC&&t.addFallback(i++,"ANISOTROPIC"),i},t.prototype.getSamplers=function(e){e.push("anisotropySampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vAnisotropy",size:3,type:"vec3"},{name:"vAnisotropyInfos",size:2,type:"vec2"},{name:"anisotropyMatrix",size:16,type:"mat4"}]}},t.prototype.parse=function(t,i,r){e.prototype.parse.call(this,t,i,r),void 0===t.legacy&&(this.legacy=!0)},v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),v([Ie()],t.prototype,"intensity",void 0),v([Ne()],t.prototype,"direction",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),v([Ie(),Pe("_markAllSubMeshesAsMiscDirty")],t.prototype,"legacy",void 0),t}(Nu),qm=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.SHEEN=!1,t.SHEEN_TEXTURE=!1,t.SHEEN_GAMMATEXTURE=!1,t.SHEEN_TEXTURE_ROUGHNESS=!1,t.SHEEN_TEXTUREDIRECTUV=0,t.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,t.SHEEN_LINKWITHALBEDO=!1,t.SHEEN_ROUGHNESS=!1,t.SHEEN_ALBEDOSCALING=!1,t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t}return m(t,e),t}(Gs),Zm=function(e){function t(t,i){void 0===i&&(i=!0);var r=e.call(this,t,"Sheen",120,new qm,i)||this;return r._isEnabled=!1,r.isEnabled=!1,r._linkSheenWithAlbedo=!1,r.linkSheenWithAlbedo=!1,r.intensity=1,r.color=Z.White(),r._texture=null,r.texture=null,r._useRoughnessFromMainTexture=!0,r.useRoughnessFromMainTexture=!0,r._roughness=null,r.roughness=null,r._textureRoughness=null,r.textureRoughness=null,r._albedoScaling=!1,r.albedoScaling=!1,r._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[u.MATERIAL_TextureDirtyFlag],r}return m(t,e),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isReadyForSubMesh=function(e,t){if(!this._isEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&xu.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&xu.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefinesBeforeAttributes=function(e,t){this._isEnabled?(e.SHEEN=!0,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=null!==this._roughness,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&xu.SheenTextureEnabled?(ta(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&xu.SheenTextureEnabled?ta(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_GAMMATEXTURE=!1,e.SHEEN_TEXTUREDIRECTUV=0,e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0)},t.prototype.bindForSubMesh=function(e,t,i,r){var n,o,a,s,l,c,u,h;if(this._isEnabled){var d=r.materialDefines,p=this._material.isFrozen;e.useUbo&&p&&e.isSync||((this._texture||this._textureRoughness)&&xu.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",null!==(o=null===(n=this._texture)||void 0===n?void 0:n.coordinatesIndex)&&void 0!==o?o:0,null!==(s=null===(a=this._texture)||void 0===a?void 0:a.level)&&void 0!==s?s:0,null!==(c=null===(l=this._textureRoughness)||void 0===l?void 0:l.coordinatesIndex)&&void 0!==c?c:0,null!==(h=null===(u=this._textureRoughness)||void 0===u?void 0:u.level)&&void 0!==h?h:0),this._texture&&ia(this._texture,e,"sheen"),this._textureRoughness&&!d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&ia(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),null!==this._roughness&&e.updateFloat("vSheenRoughness",this._roughness)),t.texturesEnabled&&(this._texture&&xu.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&xu.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))}},t.prototype.hasTexture=function(e){return this._texture===e||this._textureRoughness===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)},t.prototype.dispose=function(e){var t,i;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose())},t.prototype.getClassName=function(){return"PBRSheenConfiguration"},t.prototype.addFallbacks=function(e,t,i){return e.SHEEN&&t.addFallback(i++,"SHEEN"),i},t.prototype.getSamplers=function(e){e.push("sheenSampler","sheenRoughnessSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vSheenColor",size:4,type:"vec4"},{name:"vSheenRoughness",size:1,type:"float"},{name:"vSheenInfos",size:4,type:"vec4"},{name:"sheenMatrix",size:16,type:"mat4"},{name:"sheenRoughnessMatrix",size:16,type:"mat4"}]}},v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkSheenWithAlbedo",void 0),v([Ie()],t.prototype,"intensity",void 0),v([Oe()],t.prototype,"color",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoScaling",void 0),t}(Nu),Jm=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.SUBSURFACE=!1,t.SS_REFRACTION=!1,t.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,t.SS_TRANSLUCENCY=!1,t.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,t.SS_SCATTERING=!1,t.SS_DISPERSION=!1,t.SS_THICKNESSANDMASK_TEXTURE=!1,t.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,t.SS_HAS_THICKNESS=!1,t.SS_REFRACTIONINTENSITY_TEXTURE=!1,t.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,t.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,t.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,t.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,t.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,t.SS_REFRACTIONMAP_3D=!1,t.SS_REFRACTIONMAP_OPPOSITEZ=!1,t.SS_LODINREFRACTIONALPHA=!1,t.SS_GAMMAREFRACTION=!1,t.SS_RGBDREFRACTION=!1,t.SS_LINEARSPECULARREFRACTION=!1,t.SS_LINKREFRACTIONTOTRANSPARENCY=!1,t.SS_ALBEDOFORREFRACTIONTINT=!1,t.SS_ALBEDOFORTRANSLUCENCYTINT=!1,t.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,t.SS_USE_THICKNESS_AS_DEPTH=!1,t.SS_USE_GLTF_TEXTURES=!1,t}return m(t,e),t}(Gs),$m=function(e){function t(t,i){void 0===i&&(i=!0);var r=e.call(this,t,"PBRSubSurface",130,new Jm,i)||this;return r._isRefractionEnabled=!1,r.isRefractionEnabled=!1,r._isTranslucencyEnabled=!1,r.isTranslucencyEnabled=!1,r._isDispersionEnabled=!1,r.isDispersionEnabled=!1,r._isScatteringEnabled=!1,r.isScatteringEnabled=!1,r._scatteringDiffusionProfileIndex=0,r.refractionIntensity=1,r.translucencyIntensity=1,r.useAlbedoToTintRefraction=!1,r.useAlbedoToTintTranslucency=!1,r._thicknessTexture=null,r.thicknessTexture=null,r._refractionTexture=null,r.refractionTexture=null,r._indexOfRefraction=1.5,r.indexOfRefraction=1.5,r._volumeIndexOfRefraction=-1,r._invertRefractionY=!1,r.invertRefractionY=!1,r._linkRefractionWithTransparency=!1,r.linkRefractionWithTransparency=!1,r.minimumThickness=0,r.maximumThickness=1,r.useThicknessAsDepth=!1,r.tintColor=Z.White(),r.tintColorAtDistance=1,r.dispersion=0,r.diffusionDistance=Z.White(),r._useMaskFromThicknessTexture=!1,r.useMaskFromThicknessTexture=!1,r._refractionIntensityTexture=null,r.refractionIntensityTexture=null,r._translucencyIntensityTexture=null,r.translucencyIntensityTexture=null,r.translucencyColor=null,r._translucencyColorTexture=null,r.translucencyColorTexture=null,r._useGltfStyleTextures=!0,r.useGltfStyleTextures=!0,r._scene=t.getScene(),r.registerForExtraEvents=!0,r._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[u.MATERIAL_TextureDirtyFlag],r._internalMarkScenePrePassDirty=t._dirtyCallbacks[u.MATERIAL_PrePassDirtyFlag],r}return m(t,e),Object.defineProperty(t.prototype,"scatteringDiffusionProfile",{get:function(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null},set:function(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"volumeIndexOfRefraction",{get:function(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction},set:function(e){this._volumeIndexOfRefraction=e>=1?e:-1},enumerable:!1,configurable:!0}),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype._markScenePrePassDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()},t.prototype.isReadyForSubMesh=function(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&xu.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;if(this._translucencyColorTexture&&xu.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking())return!1;var i=this._getRefractionTexture(t);if(i&&xu.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefinesBeforeAttributes=function(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return e.SUBSURFACE=!1,e.SS_DISPERSION=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,e.SS_HAS_THICKNESS=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,e.SS_REFRACTIONMAP_3D=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,void(e.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0);if(e._areTexturesDirty){if(e.SUBSURFACE=!0,e.SS_DISPERSION=this._isDispersionEnabled,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_HAS_THICKNESS=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e._areTexturesDirty&&t.texturesEnabled&&(this._thicknessTexture&&xu.ThicknessTextureEnabled&&ta(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&xu.RefractionIntensityTextureEnabled&&ta(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&xu.TranslucencyIntensityTextureEnabled&&ta(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&xu.TranslucencyColorTextureEnabled&&ta(this._translucencyColorTexture,e,"SS_TRANSLUCENCYCOLOR_TEXTURE")),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!=0,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._refractionIntensityTexture,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._translucencyIntensityTexture,this._isRefractionEnabled&&t.texturesEnabled){var i=this._getRefractionTexture(t);i&&xu.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=this._scene.useRightHandedSystem&&i.isCube?!i.invertZ:i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=i.isCube&&i.boundingBoxSize,e.SS_USE_THICKNESS_AS_DEPTH=this.useThicknessAsDepth)}this._isTranslucencyEnabled&&(e.SS_ALBEDOFORTRANSLUCENCYTINT=this.useAlbedoToTintTranslucency)}},t.prototype.hardBindForSubMesh=function(e,t,i,r){if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled){r.getRenderingMesh().getWorldMatrix().decompose(H.Vector3[0]);var n=Math.max(Math.abs(H.Vector3[0].x),Math.abs(H.Vector3[0].y),Math.abs(H.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*n,(this.maximumThickness-this.minimumThickness)*n)}},t.prototype.bindForSubMesh=function(e,t,i,r){var n;if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled){var o=r.materialDefines,a=this._material.isFrozen,s=this._material.realTimeFiltering,l=o.LODBASEDMICROSFURACE,c=this._getRefractionTexture(t);if(!e.useUbo||!a||!e.isSync){if(this._thicknessTexture&&xu.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),ia(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&xu.RefractionIntensityTextureEnabled&&o.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),ia(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&xu.TranslucencyColorTextureEnabled&&o.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),ia(this._translucencyColorTexture,e,"translucencyColor")),c&&xu.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",c.getRefractionTextureMatrix());var u=1;c.isCube||c.depth&&(u=c.depth);var h=c.getSize().width,d=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",c.level,1/d,u,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",h,c.lodGenerationScale,c.lodGenerationOffset,1/this.indexOfRefraction),s&&e.updateFloat2("vRefractionFilteringInfo",h,j.Log2(h)),c.boundingBoxSize){var p=c;e.updateVector3("vRefractionPosition",p.boundingBoxPosition),e.updateVector3("vRefractionSize",p.boundingBoxSize)}}this._isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintColorAtDistance)),e.updateColor4("vTranslucencyColor",null!==(n=this.translucencyColor)&&void 0!==n?n:this.tintColor,0),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0),e.updateFloat("dispersion",this.dispersion)}t.texturesEnabled&&(this._thicknessTexture&&xu.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&xu.RefractionIntensityTextureEnabled&&o.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&xu.TranslucencyIntensityTextureEnabled&&o.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&xu.TranslucencyColorTextureEnabled&&o.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),c&&xu.RefractionTextureEnabled&&(l?e.setTexture("refractionSampler",c):(e.setTexture("refractionSampler",c._lodTextureMid||c),e.setTexture("refractionSamplerLow",c._lodTextureLow||c),e.setTexture("refractionSamplerHigh",c._lodTextureHigh||c))))}},t.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(t.prototype,"disableAlphaBlending",{get:function(){return this._isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!1,configurable:!0}),t.prototype.fillRenderTargetTextures=function(e){xu.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},t.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e||this._refractionIntensityTexture===e||this._translucencyIntensityTexture===e||this._translucencyColorTexture===e},t.prototype.hasRenderTargetTextures=function(){return!!(xu.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},t.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture),this._translucencyColorTexture&&e.push(this._translucencyColorTexture)},t.prototype.getAnimatables=function(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this._translucencyColorTexture&&this._translucencyColorTexture.animations&&this._translucencyColorTexture.animations.length>0&&e.push(this._translucencyColorTexture)},t.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._translucencyColorTexture&&this._translucencyColorTexture.dispose())},t.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},t.prototype.addFallbacks=function(e,t,i){return e.SS_SCATTERING&&t.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(i++,"SS_TRANSLUCENCY"),i},t.prototype.getSamplers=function(e){e.push("thicknessSampler","refractionIntensitySampler","translucencyIntensitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","translucencyColorSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vRefractionMicrosurfaceInfos",size:4,type:"vec4"},{name:"vRefractionFilteringInfo",size:2,type:"vec2"},{name:"vTranslucencyIntensityInfos",size:2,type:"vec2"},{name:"vRefractionInfos",size:4,type:"vec4"},{name:"refractionMatrix",size:16,type:"mat4"},{name:"vThicknessInfos",size:2,type:"vec2"},{name:"vRefractionIntensityInfos",size:2,type:"vec2"},{name:"thicknessMatrix",size:16,type:"mat4"},{name:"refractionIntensityMatrix",size:16,type:"mat4"},{name:"translucencyIntensityMatrix",size:16,type:"mat4"},{name:"vThicknessParam",size:2,type:"vec2"},{name:"vDiffusionDistance",size:3,type:"vec3"},{name:"vTintColor",size:4,type:"vec4"},{name:"vSubSurfaceIntensity",size:3,type:"vec3"},{name:"vRefractionPosition",size:3,type:"vec3"},{name:"vRefractionSize",size:3,type:"vec3"},{name:"scatteringDiffusionProfile",size:1,type:"float"},{name:"dispersion",size:1,type:"float"},{name:"vTranslucencyColor",size:4,type:"vec4"},{name:"vTranslucencyColorInfos",size:2,type:"vec2"},{name:"translucencyColorMatrix",size:16,type:"mat4"}]}},v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isRefractionEnabled",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTranslucencyEnabled",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isDispersionEnabled",void 0),v([Ie(),Pe("_markScenePrePassDirty")],t.prototype,"isScatteringEnabled",void 0),v([Ie()],t.prototype,"_scatteringDiffusionProfileIndex",void 0),v([Ie()],t.prototype,"refractionIntensity",void 0),v([Ie()],t.prototype,"translucencyIntensity",void 0),v([Ie()],t.prototype,"useAlbedoToTintRefraction",void 0),v([Ie()],t.prototype,"useAlbedoToTintTranslucency",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"thicknessTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),v([Ie()],t.prototype,"_volumeIndexOfRefraction",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"volumeIndexOfRefraction",null),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),v([Ie()],t.prototype,"minimumThickness",void 0),v([Ie()],t.prototype,"maximumThickness",void 0),v([Ie()],t.prototype,"useThicknessAsDepth",void 0),v([Oe()],t.prototype,"tintColor",void 0),v([Ie()],t.prototype,"tintColorAtDistance",void 0),v([Ie()],t.prototype,"dispersion",void 0),v([Oe()],t.prototype,"diffusionDistance",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMaskFromThicknessTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionIntensityTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"translucencyIntensityTexture",void 0),v([Oe()],t.prototype,"translucencyColor",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"translucencyColorTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGltfStyleTextures",void 0),t}(Nu),eg={effect:null,subMesh:null},tg=function(e){function t(t){var i=e.call(this,t)||this;return i.PBR=!0,i.NUM_SAMPLES="0",i.REALTIME_FILTERING=!1,i.MAINUV1=!1,i.MAINUV2=!1,i.MAINUV3=!1,i.MAINUV4=!1,i.MAINUV5=!1,i.MAINUV6=!1,i.UV1=!1,i.UV2=!1,i.UV3=!1,i.UV4=!1,i.UV5=!1,i.UV6=!1,i.ALBEDO=!1,i.GAMMAALBEDO=!1,i.ALBEDODIRECTUV=0,i.VERTEXCOLOR=!1,i.BAKED_VERTEX_ANIMATION_TEXTURE=!1,i.AMBIENT=!1,i.AMBIENTDIRECTUV=0,i.AMBIENTINGRAYSCALE=!1,i.OPACITY=!1,i.VERTEXALPHA=!1,i.OPACITYDIRECTUV=0,i.OPACITYRGB=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.ALPHABLEND=!1,i.ALPHAFROMALBEDO=!1,i.ALPHATESTVALUE="0.5",i.SPECULAROVERALPHA=!1,i.RADIANCEOVERALPHA=!1,i.ALPHAFRESNEL=!1,i.LINEARALPHAFRESNEL=!1,i.PREMULTIPLYALPHA=!1,i.EMISSIVE=!1,i.EMISSIVEDIRECTUV=0,i.GAMMAEMISSIVE=!1,i.REFLECTIVITY=!1,i.REFLECTIVITY_GAMMA=!1,i.REFLECTIVITYDIRECTUV=0,i.SPECULARTERM=!1,i.MICROSURFACEFROMREFLECTIVITYMAP=!1,i.MICROSURFACEAUTOMATIC=!1,i.LODBASEDMICROSFURACE=!1,i.MICROSURFACEMAP=!1,i.MICROSURFACEMAPDIRECTUV=0,i.METALLICWORKFLOW=!1,i.ROUGHNESSSTOREINMETALMAPALPHA=!1,i.ROUGHNESSSTOREINMETALMAPGREEN=!1,i.METALLNESSSTOREINMETALMAPBLUE=!1,i.AOSTOREINMETALMAPRED=!1,i.METALLIC_REFLECTANCE=!1,i.METALLIC_REFLECTANCE_GAMMA=!1,i.METALLIC_REFLECTANCEDIRECTUV=0,i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=!1,i.REFLECTANCE=!1,i.REFLECTANCE_GAMMA=!1,i.REFLECTANCEDIRECTUV=0,i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1,i.NORMAL=!1,i.TANGENT=!1,i.BUMP=!1,i.BUMPDIRECTUV=0,i.OBJECTSPACE_NORMALMAP=!1,i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.NORMALXYSCALE=!0,i.LIGHTMAP=!1,i.LIGHTMAPDIRECTUV=0,i.USELIGHTMAPASSHADOWMAP=!1,i.GAMMALIGHTMAP=!1,i.RGBDLIGHTMAP=!1,i.REFLECTION=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.USEIRRADIANCEMAP=!1,i.USESPHERICALINVERTEX=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.LODINREFLECTIONALPHA=!1,i.GAMMAREFLECTION=!1,i.RGBDREFLECTION=!1,i.LINEARSPECULARREFLECTION=!1,i.RADIANCEOCCLUSION=!1,i.HORIZONOCCLUSION=!1,i.INSTANCES=!1,i.THIN_INSTANCES=!1,i.INSTANCESCOLOR=!1,i.PREPASS=!1,i.PREPASS_IRRADIANCE=!1,i.PREPASS_IRRADIANCE_INDEX=-1,i.PREPASS_ALBEDO_SQRT=!1,i.PREPASS_ALBEDO_SQRT_INDEX=-1,i.PREPASS_DEPTH=!1,i.PREPASS_DEPTH_INDEX=-1,i.PREPASS_NORMAL=!1,i.PREPASS_NORMAL_INDEX=-1,i.PREPASS_NORMAL_WORLDSPACE=!1,i.PREPASS_POSITION=!1,i.PREPASS_POSITION_INDEX=-1,i.PREPASS_VELOCITY=!1,i.PREPASS_VELOCITY_INDEX=-1,i.PREPASS_REFLECTIVITY=!1,i.PREPASS_REFLECTIVITY_INDEX=-1,i.SCENE_MRT_COUNT=0,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.BONETEXTURE=!1,i.BONES_VELOCITY_ENABLED=!1,i.NONUNIFORMSCALING=!1,i.MORPHTARGETS=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_UV=!1,i.NUM_MORPH_INFLUENCERS=0,i.MORPHTARGETS_TEXTURE=!1,i.IMAGEPROCESSING=!1,i.VIGNETTE=!1,i.VIGNETTEBLENDMODEMULTIPLY=!1,i.VIGNETTEBLENDMODEOPAQUE=!1,i.TONEMAPPING=0,i.CONTRAST=!1,i.COLORCURVES=!1,i.COLORGRADING=!1,i.COLORGRADING3D=!1,i.SAMPLER3DGREENDEPTH=!1,i.SAMPLER3DBGRMAP=!1,i.DITHER=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.EXPOSURE=!1,i.MULTIVIEW=!1,i.ORDER_INDEPENDENT_TRANSPARENCY=!1,i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1,i.TWOSIDEDLIGHTING=!1,i.SHADOWFLOAT=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.POINTSIZE=!1,i.FOG=!1,i.LOGARITHMICDEPTH=!1,i.CAMERA_ORTHOGRAPHIC=!1,i.CAMERA_PERSPECTIVE=!1,i.FORCENORMALFORWARD=!1,i.SPECULARAA=!1,i.UNLIT=!1,i.DECAL_AFTER_DETAIL=!1,i.DEBUGMODE=0,i.rebuild(),i}return m(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0},t}(Gs),ig=function(e){function t(i,r){var n=e.call(this,i,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new k(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._albedoTexture=null,n._ambientTexture=null,n._ambientTextureStrength=1,n._ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,n._opacityTexture=null,n._reflectionTexture=null,n._emissiveTexture=null,n._reflectivityTexture=null,n._metallicTexture=null,n._metallic=null,n._roughness=null,n._metallicF0Factor=1,n._metallicReflectanceColor=Z.White(),n._useOnlyMetallicFromMetallicReflectanceTexture=!1,n._metallicReflectanceTexture=null,n._reflectanceTexture=null,n._microSurfaceTexture=null,n._bumpTexture=null,n._lightmapTexture=null,n._ambientColor=new Z(0,0,0),n._albedoColor=new Z(1,1,1),n._reflectivityColor=new Z(1,1,1),n._reflectionColor=new Z(1,1,1),n._emissiveColor=new Z(0,0,0),n._microSurface=.9,n._useLightmapAsShadowmap=!1,n._useHorizonOcclusion=!0,n._useRadianceOcclusion=!0,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._lightFalloff=t.LIGHTFALLOFF_PHYSICAL,n._useRadianceOverAlpha=!0,n._useObjectSpaceNormalMap=!1,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._useAlphaFresnel=!1,n._useLinearAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._realTimeFiltering=!1,n._realTimeFilteringQuality=u.TEXTURE_FILTERING_QUALITY_LOW,n._forceNormalForward=!1,n._enableSpecularAntiAliasing=!1,n._imageProcessingObserver=null,n._renderTargets=new ar(16),n._globalAmbientColor=new Z(0,0,0),n._unlit=!1,n._applyDecalMapAfterDetailMap=!1,n._debugMode=0,n.debugMode=0,n.debugLimit=-1,n.debugFactor=1,n._cacheHasRenderTargetTextures=!1,n.brdf=new Wm(n),n.clearCoat=new Xm(n),n.iridescence=new Ym(n),n.anisotropy=new Qm(n),n.sheen=new Zm(n),n.subSurface=new $m(n),n.detailMap=new Lu(n),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),xu.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),n._eventInfo.renderTargets=n._renderTargets,n._callbackPluginEventFillRenderTargetTextures(n._eventInfo),n._renderTargets},n._environmentBRDFTexture=km(n.getScene()),n.prePassConfiguration=new Su,n}return m(t,e),Object.defineProperty(t.prototype,"realTimeFiltering",{get:function(){return this._realTimeFiltering},set:function(e){this._realTimeFiltering=e,this.markAsDirty(u.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"realTimeFilteringQuality",{get:function(){return this._realTimeFilteringQuality},set:function(e){this._realTimeFilteringQuality=e,this.markAsDirty(u.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canRenderToMRT",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!!(xu.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||this._cacheHasRenderTargetTextures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPrePassCapable",{get:function(){return!this.disableDepthWrite},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(t.prototype,"_disableAlphaBlending",{get:function(){var e;return this._transparencyMode===t.PBRMATERIAL_OPAQUE||this._transparencyMode===t.PBRMATERIAL_ALPHATEST||(null===(e=this.subSurface)||void 0===e?void 0:e.disableAlphaBlending)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},t.prototype.needAlphaTesting=function(){var e;return!!this._forceAlphaTest||!(null===(e=this.subSurface)||void 0===e?void 0:e.disableAlphaBlending)&&this._hasAlphaChannel()&&(null==this._transparencyMode||this._transparencyMode===t.PBRMATERIAL_ALPHATEST)},t.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==t.PBRMATERIAL_OPAQUE},t.prototype._hasAlphaChannel=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha||null!=this._opacityTexture},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,t,i){var r;this._uniformBufferLayoutBuilt||this.buildUniformLayout();var n=t._drawWrapper;if(n.effect&&this.isFrozen&&n._wasPreviouslyReady&&n._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(Vo.GetDefineNames,this._eventInfo),t.materialDefines=new tg(this._eventInfo.defineNames));var o=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;var a=this.getScene(),s=a.getEngine();if(o._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a.texturesEnabled)){if(this._albedoTexture&&xu.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&xu.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&xu.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var l=this._getReflectionTexture();if(l&&xu.ReflectionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;if(l.irradianceTexture){if(!l.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!l.sphericalPolynomial&&(null===(r=l.getInternalTexture())||void 0===r?void 0:r._sphericalPolynomialPromise))return!1}if(this._lightmapTexture&&xu.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&xu.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(xu.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking())return!1;if(this._reflectanceTexture&&!this._reflectanceTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(s.getCaps().standardDerivatives&&this._bumpTexture&&xu.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&xu.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=o,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(o._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;s.getCaps().standardDerivatives||e.isVerticesDataPresent(Nr.NormalKind)||(e.createNormals(!0),ae.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var c=t.effect,u=o._areLightsDisposed,h=this._prepareEffect(e,o,this.onCompiled,this.onError,i,null,t.getRenderingMesh().hasThinInstances),d=!1;if(h)if(this._onEffectCreatedObservable&&(eg.effect=h,eg.subMesh=t,this._onEffectCreatedObservable.notifyObservers(eg)),this.allowShaderHotSwapping&&c&&!h.isReady()){if(h=c,o.markAsUnprocessed(),d=this.isFrozen,u)return o._areLightsDisposed=!0,!1}else a.resetCachedMaterial(),t.setEffect(h,o,this._materialContext);return!(!t.effect||!t.effect.isReady()||(o._renderId=a.getRenderId(),n._wasPreviouslyReady=!d,n._wasPreviouslyUsingInstances=!!i,this._checkScenePerformancePriority(),0))},t.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,t,i,r,n,o,a){if(void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),this._prepareDefines(e,t,n,o,a),!t.isDirty)return null;t.markAsProcessed();var s=this.getScene().getEngine(),l=new ll,c=0;t.USESPHERICALINVERTEX&&l.addFallback(c++,"USESPHERICALINVERTEX"),t.FOG&&l.addFallback(c,"FOG"),t.SPECULARAA&&l.addFallback(c,"SPECULARAA"),t.POINTSIZE&&l.addFallback(c,"POINTSIZE"),t.LOGARITHMICDEPTH&&l.addFallback(c,"LOGARITHMICDEPTH"),t.PARALLAX&&l.addFallback(c,"PARALLAX"),t.PARALLAX_RHS&&l.addFallback(c,"PARALLAX_RHS"),t.PARALLAXOCCLUSION&&l.addFallback(c++,"PARALLAXOCCLUSION"),t.ENVIRONMENTBRDF&&l.addFallback(c++,"ENVIRONMENTBRDF"),t.TANGENT&&l.addFallback(c++,"TANGENT"),t.BUMP&&l.addFallback(c++,"BUMP"),c=ua(t,l,this._maxSimultaneousLights,c++),t.SPECULARTERM&&l.addFallback(c++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&l.addFallback(c++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&l.addFallback(c++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&l.addFallback(c++,"LIGHTMAP"),t.NORMAL&&l.addFallback(c++,"NORMAL"),t.AMBIENT&&l.addFallback(c++,"AMBIENT"),t.EMISSIVE&&l.addFallback(c++,"EMISSIVE"),t.VERTEXCOLOR&&l.addFallback(c++,"VERTEXCOLOR"),t.MORPHTARGETS&&l.addFallback(c++,"MORPHTARGETS"),t.MULTIVIEW&&l.addFallback(0,"MULTIVIEW");var h=[Nr.PositionKind];t.NORMAL&&h.push(Nr.NormalKind),t.TANGENT&&h.push(Nr.TangentKind);for(var d=1;d<=u.MAX_SUPPORTED_UV_SETS;++d)t["UV"+d]&&h.push("uv".concat(1===d?"":d));t.VERTEXCOLOR&&h.push(Nr.ColorKind),la(h,e,t,l),ca(h,t),Zo(h,e,t),ra(h,0,t);var p="pbr",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vMetallicReflectanceFactors","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vReflectionFilteringInfo","vMetallicReflectanceInfos","vReflectanceInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","reflectanceMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX_ZZ","vSphericalYY_ZZ","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vSphericalL00","vSphericalL1_1","vSphericalL10","vSphericalL11","vSphericalL2_2","vSphericalL2_1","vSphericalL20","vSphericalL21","vSphericalL22","vReflectionMicrosurfaceInfos","vTangentSpaceParams","boneTextureWidth","vDebugMode","morphTargetTextureInfo","morphTargetTextureIndices"],_=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler","reflectanceSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],m=["Material","Scene","Mesh"],g={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=l,this._eventInfo.fallbackRank=c,this._eventInfo.defines=t,this._eventInfo.uniforms=f,this._eventInfo.attributes=h,this._eventInfo.samplers=_,this._eventInfo.uniformBuffersNames=m,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=g,this._callbackPluginEventGeneric(Vo.PrepareEffect,this._eventInfo),Su.AddUniforms(f),Su.AddSamplers(_),Go(f),pr&&(pr.PrepareUniforms(f,t),pr.PrepareSamplers(_,t)),Aa({uniformsNames:f,uniformBuffersNames:m,samplers:_,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});var v={};this.customShaderNameResolve&&(p=this.customShaderNameResolve(p,f,m,_,t,h,v));var y=t.toString(),b=s.createEffect(p,{attributes:h,uniformsNames:f,uniformBuffersNames:m,samplers:_,defines:y,fallbacks:l,onCompiled:i,onError:r,indexParameters:g,processFinalCode:v.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:t.PREPASS},s);return this._eventInfo.customCode=void 0,b},t.prototype._prepareDefines=function(e,i,r,n,o){void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=!1);var a=this.getScene(),s=a.getEngine();pa(a,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,ba(a,i);var l=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Ea(a,i,this.canRenderToMRT&&!l),Ta(a,i,l),i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){i._needUVs=!1;for(var c=1;c<=u.MAX_SUPPORTED_UV_SETS;++c)i["MAINUV"+c]=!1;if(a.texturesEnabled){i.ALBEDODIRECTUV=0,i.AMBIENTDIRECTUV=0,i.OPACITYDIRECTUV=0,i.EMISSIVEDIRECTUV=0,i.REFLECTIVITYDIRECTUV=0,i.MICROSURFACEMAPDIRECTUV=0,i.METALLIC_REFLECTANCEDIRECTUV=0,i.REFLECTANCEDIRECTUV=0,i.BUMPDIRECTUV=0,i.LIGHTMAPDIRECTUV=0,s.getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&xu.DiffuseTextureEnabled?(ta(this._albedoTexture,i,"ALBEDO"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._ambientTexture&&xu.AmbientTextureEnabled?(ta(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&xu.OpacityTextureEnabled?(ta(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;var h=this._getReflectionTexture();if(h&&xu.ReflectionTextureEnabled){switch(i.REFLECTION=!0,i.GAMMAREFLECTION=h.gammaSpace,i.RGBDREFLECTION=h.isRGBD,i.LODINREFLECTIONALPHA=h.lodLevelInAlpha,i.LINEARSPECULARREFLECTION=h.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(i.NUM_SAMPLES=""+this.realTimeFilteringQuality,s._features.needTypeSuffixInShaderConstants&&(i.NUM_SAMPLES=i.NUM_SAMPLES+"u"),i.REALTIME_FILTERING=!0):i.REALTIME_FILTERING=!1,i.INVERTCUBICMAP=h.coordinatesMode===Ja.INVCUBIC_MODE,i.REFLECTIONMAP_3D=h.isCube,i.REFLECTIONMAP_OPPOSITEZ=i.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!h.invertZ:h.invertZ,i.REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,h.coordinatesMode){case Ja.EXPLICIT_MODE:i.REFLECTIONMAP_EXPLICIT=!0;break;case Ja.PLANAR_MODE:i.REFLECTIONMAP_PLANAR=!0;break;case Ja.PROJECTION_MODE:i.REFLECTIONMAP_PROJECTION=!0;break;case Ja.SKYBOX_MODE:i.REFLECTIONMAP_SKYBOX=!0;break;case Ja.SPHERICAL_MODE:i.REFLECTIONMAP_SPHERICAL=!0;break;case Ja.EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ja.FIXED_EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ja.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ja.CUBIC_MODE:case Ja.INVCUBIC_MODE:default:i.REFLECTIONMAP_CUBIC=!0,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!!h.boundingBoxSize}h.coordinatesMode!==Ja.SKYBOX_MODE&&(h.irradianceTexture?(i.USEIRRADIANCEMAP=!0,i.USESPHERICALFROMREFLECTIONMAP=!1):h.isCube&&(i.USESPHERICALFROMREFLECTIONMAP=!0,i.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||s.getCaps().maxVaryingVectors<=8?i.USESPHERICALINVERTEX=!1:i.USESPHERICALINVERTEX=!0))}else i.REFLECTION=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.USEIRRADIANCEMAP=!1,i.USESPHERICALINVERTEX=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.LODINREFLECTIONALPHA=!1,i.GAMMAREFLECTION=!1,i.RGBDREFLECTION=!1,i.LINEARSPECULARREFLECTION=!1;this._lightmapTexture&&xu.LightmapTextureEnabled?(ta(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&xu.EmissiveTextureEnabled?(ta(this._emissiveTexture,i,"EMISSIVE"),i.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):i.EMISSIVE=!1,xu.SpecularTextureEnabled?(this._metallicTexture?(ta(this._metallicTexture,i,"REFLECTIVITY"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,i.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?(ta(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,i.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):i.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture?(i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture,this._metallicReflectanceTexture?(ta(this._metallicReflectanceTexture,i,"METALLIC_REFLECTANCE"),i.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):i.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(ta(this._reflectanceTexture,i,"REFLECTANCE"),i.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):i.REFLECTANCE=!1):(i.METALLIC_REFLECTANCE=!1,i.REFLECTANCE=!1),this._microSurfaceTexture?ta(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),s.getCaps().standardDerivatives&&this._bumpTexture&&xu.BumpTextureEnabled&&!this._disableBumpMap?(ta(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&xu.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAX_RHS=a.useRightHandedSystem,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(i.BUMP=!1,i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&xu.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===t.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===t.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.SPECULARAA=s.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE="".concat(this._alphaCutOff).concat(this._alphaCutOff%1==0?".":""),i.PREMULTIPLYALPHA=this.alphaMode===u.ALPHA_PREMULTIPLIED||this.alphaMode===u.ALPHA_PREMULTIPLIED_PORTERDUFF,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(da(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,i,this._applyDecalMapAfterDetailMap),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(Nr.NormalKind),i.DEBUGMODE=this._debugMode),_a(a,s,this,i,!!r,n,o),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),ya(e,i,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)},t.prototype.forceCompilation=function(e,t,i){var r=this,n=g({clipPlane:!1,useInstances:!1},i);this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(Vo.GetDefineNames,this._eventInfo);var o=new tg(this._eventInfo.defineNames),a=this._prepareEffect(e,o,void 0,void 0,n.useInstances,n.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(eg.effect=a,eg.subMesh=null,this._onEffectCreatedObservable.notifyObservers(eg)),a.isReady()?t&&t(this):a.onCompileObservable.add((function(){t&&t(r)}))},t.prototype.buildUniformLayout=function(){var t=this._uniformBuffer;t.addUniform("vAlbedoInfos",2),t.addUniform("vAmbientInfos",4),t.addUniform("vOpacityInfos",2),t.addUniform("vEmissiveInfos",2),t.addUniform("vLightmapInfos",2),t.addUniform("vReflectivityInfos",3),t.addUniform("vMicroSurfaceSamplerInfos",2),t.addUniform("vReflectionInfos",2),t.addUniform("vReflectionFilteringInfo",2),t.addUniform("vReflectionPosition",3),t.addUniform("vReflectionSize",3),t.addUniform("vBumpInfos",3),t.addUniform("albedoMatrix",16),t.addUniform("ambientMatrix",16),t.addUniform("opacityMatrix",16),t.addUniform("emissiveMatrix",16),t.addUniform("lightmapMatrix",16),t.addUniform("reflectivityMatrix",16),t.addUniform("microSurfaceSamplerMatrix",16),t.addUniform("bumpMatrix",16),t.addUniform("vTangentSpaceParams",2),t.addUniform("reflectionMatrix",16),t.addUniform("vReflectionColor",3),t.addUniform("vAlbedoColor",4),t.addUniform("vLightingIntensity",4),t.addUniform("vReflectionMicrosurfaceInfos",3),t.addUniform("pointSize",1),t.addUniform("vReflectivityColor",4),t.addUniform("vEmissiveColor",3),t.addUniform("vAmbientColor",3),t.addUniform("vDebugMode",2),t.addUniform("vMetallicReflectanceFactors",4),t.addUniform("vMetallicReflectanceInfos",2),t.addUniform("metallicReflectanceMatrix",16),t.addUniform("vReflectanceInfos",2),t.addUniform("reflectanceMatrix",16),t.addUniform("vSphericalL00",3),t.addUniform("vSphericalL1_1",3),t.addUniform("vSphericalL10",3),t.addUniform("vSphericalL11",3),t.addUniform("vSphericalL2_2",3),t.addUniform("vSphericalL2_1",3),t.addUniform("vSphericalL20",3),t.addUniform("vSphericalL21",3),t.addUniform("vSphericalL22",3),t.addUniform("vSphericalX",3),t.addUniform("vSphericalY",3),t.addUniform("vSphericalZ",3),t.addUniform("vSphericalXX_ZZ",3),t.addUniform("vSphericalYY_ZZ",3),t.addUniform("vSphericalZZ",3),t.addUniform("vSphericalXY",3),t.addUniform("vSphericalYZ",3),t.addUniform("vSphericalZX",3),e.prototype.buildUniformLayout.call(this)},t.prototype.bindForSubMesh=function(e,t,i){var r,n,o,a,s=this.getScene(),l=i.materialDefines;if(l){var c=i.effect;if(c){this._activeEffect=c,t.getMeshUniformBuffer().bindToEffect(c,"Mesh"),t.transferToEffect(e);var u=s.getEngine();this._uniformBuffer.bindToEffect(c,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,s,t,e,this.isFrozen),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),l.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var h=this._mustRebind(s,c,i,t.visibility);na(t,this._activeEffect,this.prePassConfiguration);var d=null,p=this._uniformBuffer;if(h){if(this.bindViewProjection(c),d=this._getReflectionTexture(),!p.useUbo||!this.isFrozen||!p.isSync||i._drawWrapper._forceRebindOnNextCall){if(s.texturesEnabled){if(this._albedoTexture&&xu.DiffuseTextureEnabled&&(p.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),ia(this._albedoTexture,p,"albedo")),this._ambientTexture&&xu.AmbientTextureEnabled&&(p.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),ia(this._ambientTexture,p,"ambient")),this._opacityTexture&&xu.OpacityTextureEnabled&&(p.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ia(this._opacityTexture,p,"opacity")),d&&xu.ReflectionTextureEnabled){if(p.updateMatrix("reflectionMatrix",d.getReflectionTextureMatrix()),p.updateFloat2("vReflectionInfos",d.level,0),d.boundingBoxSize){var f=d;p.updateVector3("vReflectionPosition",f.boundingBoxPosition),p.updateVector3("vReflectionSize",f.boundingBoxSize)}if(this.realTimeFiltering){var _=d.getSize().width;p.updateFloat2("vReflectionFilteringInfo",_,j.Log2(_))}if(!l.USEIRRADIANCEMAP){var m=d.sphericalPolynomial;if(l.USESPHERICALFROMREFLECTIONMAP&&m)if(l.SPHERICAL_HARMONICS){var g=m.preScaledHarmonics;p.updateVector3("vSphericalL00",g.l00),p.updateVector3("vSphericalL1_1",g.l1_1),p.updateVector3("vSphericalL10",g.l10),p.updateVector3("vSphericalL11",g.l11),p.updateVector3("vSphericalL2_2",g.l2_2),p.updateVector3("vSphericalL2_1",g.l2_1),p.updateVector3("vSphericalL20",g.l20),p.updateVector3("vSphericalL21",g.l21),p.updateVector3("vSphericalL22",g.l22)}else p.updateFloat3("vSphericalX",m.x.x,m.x.y,m.x.z),p.updateFloat3("vSphericalY",m.y.x,m.y.y,m.y.z),p.updateFloat3("vSphericalZ",m.z.x,m.z.y,m.z.z),p.updateFloat3("vSphericalXX_ZZ",m.xx.x-m.zz.x,m.xx.y-m.zz.y,m.xx.z-m.zz.z),p.updateFloat3("vSphericalYY_ZZ",m.yy.x-m.zz.x,m.yy.y-m.zz.y,m.yy.z-m.zz.z),p.updateFloat3("vSphericalZZ",m.zz.x,m.zz.y,m.zz.z),p.updateFloat3("vSphericalXY",m.xy.x,m.xy.y,m.xy.z),p.updateFloat3("vSphericalYZ",m.yz.x,m.yz.y,m.yz.z),p.updateFloat3("vSphericalZX",m.zx.x,m.zx.y,m.zx.z)}p.updateFloat3("vReflectionMicrosurfaceInfos",d.getSize().width,d.lodGenerationScale,d.lodGenerationOffset)}this._emissiveTexture&&xu.EmissiveTextureEnabled&&(p.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ia(this._emissiveTexture,p,"emissive")),this._lightmapTexture&&xu.LightmapTextureEnabled&&(p.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ia(this._lightmapTexture,p,"lightmap")),xu.SpecularTextureEnabled&&(this._metallicTexture?(p.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),ia(this._metallicTexture,p,"reflectivity")):this._reflectivityTexture&&(p.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),ia(this._reflectivityTexture,p,"reflectivity")),this._metallicReflectanceTexture&&(p.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),ia(this._metallicReflectanceTexture,p,"metallicReflectance")),this._reflectanceTexture&&l.REFLECTANCE&&(p.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),ia(this._reflectanceTexture,p,"reflectance")),this._microSurfaceTexture&&(p.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),ia(this._microSurfaceTexture,p,"microSurfaceSampler"))),this._bumpTexture&&u.getCaps().standardDerivatives&&xu.BumpTextureEnabled&&!this._disableBumpMap&&(p.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),ia(this._bumpTexture,p,"bump"),s._mirroredCameraPosition?p.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):p.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&p.updateFloat("pointSize",this.pointSize),l.METALLICWORKFLOW){$.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,$.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,p.updateColor4("vReflectivityColor",$.Color3[0],1);var v=null!==(n=null===(r=this.subSurface)||void 0===r?void 0:r._indexOfRefraction)&&void 0!==n?n:1.5,y=Math.pow((v-1)/(v+1),2);this._metallicReflectanceColor.scaleToRef(y*this._metallicF0Factor,$.Color3[0]);var b=this._metallicF0Factor;p.updateColor4("vMetallicReflectanceFactors",$.Color3[0],b)}else p.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);p.updateColor3("vEmissiveColor",xu.EmissiveTextureEnabled?this._emissiveColor:Z.BlackReadOnly),p.updateColor3("vReflectionColor",this._reflectionColor),!l.SS_REFRACTION&&(null===(o=this.subSurface)||void 0===o?void 0:o._linkRefractionWithTransparency)?p.updateColor4("vAlbedoColor",this._albedoColor,1):p.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*s.environmentIntensity,this._lightingInfos.w=this._specularIntensity,p.updateVector4("vLightingIntensity",this._lightingInfos),s.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),p.updateColor3("vAmbientColor",this._globalAmbientColor),p.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}s.texturesEnabled&&(this._albedoTexture&&xu.DiffuseTextureEnabled&&p.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&xu.AmbientTextureEnabled&&p.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&xu.OpacityTextureEnabled&&p.setTexture("opacitySampler",this._opacityTexture),d&&xu.ReflectionTextureEnabled&&(l.LODBASEDMICROSFURACE?p.setTexture("reflectionSampler",d):(p.setTexture("reflectionSampler",d._lodTextureMid||d),p.setTexture("reflectionSamplerLow",d._lodTextureLow||d),p.setTexture("reflectionSamplerHigh",d._lodTextureHigh||d)),l.USEIRRADIANCEMAP&&p.setTexture("irradianceSampler",d.irradianceTexture)),l.ENVIRONMENTBRDF&&p.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&xu.EmissiveTextureEnabled&&p.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&xu.LightmapTextureEnabled&&p.setTexture("lightmapSampler",this._lightmapTexture),xu.SpecularTextureEnabled&&(this._metallicTexture?p.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&p.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&p.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&l.REFLECTANCE&&p.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&p.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&u.getCaps().standardDerivatives&&xu.BumpTextureEnabled&&!this._disableBumpMap&&p.setTexture("bumpSampler",this._bumpTexture)),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(c),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Ho(this._activeEffect,this,s),this.bindEyePosition(c)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!h&&this.isFrozen||(s.lightsEnabled&&!this._disableLighting&&sa(s,t,this._activeEffect,l,this._maxSimultaneousLights),(s.fogEnabled&&t.applyFog&&s.fogMode!==pn.FOGMODE_NONE||d||this.subSurface.refractionTexture||t.receiveShadows||l.PREPASS)&&this.bindView(c),Qo(s,t,this._activeEffect,!0),l.NUM_MORPH_INFLUENCERS&&$o(t,this._activeEffect),l.BAKED_VERTEX_ANIMATION_TEXTURE&&(null===(a=t.bakedVertexAnimationManager)||void 0===a||a.bind(c,l.INSTANCES)),this._imageProcessingConfiguration.bind(this._activeEffect),Ko(l,this._activeEffect,s)),this._afterBind(t,this._activeEffect,i),p.update()}}},t.prototype.getAnimatables=function(){var t=e.prototype.getAnimatables.call(this);return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&t.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&t.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&t.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&t.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&t.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?t.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&t.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&t.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&t.push(this._lightmapTexture),this._metallicReflectanceTexture&&this._metallicReflectanceTexture.animations&&this._metallicReflectanceTexture.animations.length>0&&t.push(this._metallicReflectanceTexture),this._reflectanceTexture&&this._reflectanceTexture.animations&&this._reflectanceTexture.animations.length>0&&t.push(this._reflectanceTexture),this._microSurfaceTexture&&this._microSurfaceTexture.animations&&this._microSurfaceTexture.animations.length>0&&t.push(this._microSurfaceTexture),t},t.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._albedoTexture&&t.push(this._albedoTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._reflectivityTexture&&t.push(this._reflectivityTexture),this._metallicTexture&&t.push(this._metallicTexture),this._metallicReflectanceTexture&&t.push(this._metallicReflectanceTexture),this._reflectanceTexture&&t.push(this._reflectanceTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this._albedoTexture===t||this._ambientTexture===t||this._opacityTexture===t||this._reflectionTexture===t||this._emissiveTexture===t||this._reflectivityTexture===t||this._metallicTexture===t||this._metallicReflectanceTexture===t||this._reflectanceTexture===t||this._microSurfaceTexture===t||this._bumpTexture===t||this._lightmapTexture===t},t.prototype.setPrePassRenderer=function(){var e;if(!(null===(e=this.subSurface)||void 0===e?void 0:e.isScatteringEnabled))return!1;var t=this.getScene().enableSubSurfaceForPrePass();return t&&(t.enabled=!0),!0},t.prototype.dispose=function(t,i){var r,n,o,a,s,l,c,u,h,d,p,f;i&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),null===(r=this._albedoTexture)||void 0===r||r.dispose(),null===(n=this._ambientTexture)||void 0===n||n.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(l=this._metallicTexture)||void 0===l||l.dispose(),null===(c=this._reflectivityTexture)||void 0===c||c.dispose(),null===(u=this._bumpTexture)||void 0===u||u.dispose(),null===(h=this._lightmapTexture)||void 0===h||h.dispose(),null===(d=this._metallicReflectanceTexture)||void 0===d||d.dispose(),null===(p=this._reflectanceTexture)||void 0===p||p.dispose(),null===(f=this._microSurfaceTexture)||void 0===f||f.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.PBRMATERIAL_OPAQUE=Ca.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=Ca.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=Ca.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=Ca.MATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,v([Ue()],t.prototype,"_imageProcessingConfiguration",void 0),v([Pe("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),t}(ws),rg=function(e){function t(i,r){var n=e.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,n.metallicF0Factor=1,n.metallicReflectanceColor=Z.White(),n.useOnlyMetallicFromMetallicReflectanceTexture=!1,n.ambientColor=new Z(0,0,0),n.albedoColor=new Z(1,1,1),n.reflectivityColor=new Z(1,1,1),n.reflectionColor=new Z(1,1,1),n.emissiveColor=new Z(0,0,0),n.microSurface=1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.useRadianceOverAlpha=!0,n.useObjectSpaceNormalMap=!1,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.useAlphaFresnel=!1,n.useLinearAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n.enableSpecularAntiAliasing=!1,n.useHorizonOcclusion=!0,n.useRadianceOcclusion=!0,n.unlit=!1,n.applyDecalMapAfterDetailMap=!1,n._environmentBRDFTexture=km(n.getScene()),n}return m(t,e),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this.subSurface.refractionTexture},set:function(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"invertRefractionY",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkRefractionWithTransparency",{get:function(){return this.subSurface.linkRefractionWithTransparency},set:function(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===ig.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?ig.LIGHTFALLOFF_PHYSICAL:ig.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===ig.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?ig.LIGHTFALLOFF_GLTF:ig.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.clone=function(e,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r="");var o=Ke.Clone((function(){return new t(e,n.getScene())}),this,{cloneTexturesOnlyOnce:i});return o.id=e,o.name=e,this.stencil.copyTo(o.stencil),this._clonePlugins(o,r),o},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.customType="BABYLON.PBRMaterial",t},t.Parse=function(e,i,r){var n=Ke.Parse((function(){return new t(e.name,i)}),e,i,r);return e.stencil&&n.stencil.parse(e.stencil,i,r),Ca._ParsePlugins(e,n,i,r),e.clearCoat&&n.clearCoat.parse(e.clearCoat,i,r),e.anisotropy&&n.anisotropy.parse(e.anisotropy,i,r),e.brdf&&n.brdf.parse(e.brdf,i,r),e.sheen&&n.sheen.parse(e.sheen,i,r),e.subSurface&&n.subSurface.parse(e.subSurface,i,r),e.iridescence&&n.iridescence.parse(e.iridescence,i,r),n},t.PBRMATERIAL_OPAQUE=ig.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=ig.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=ig.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=ig.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=ig.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),v([Oe(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceColor",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectanceTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),v([Me(),Pe("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),v([Oe("ambient"),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),v([Oe("albedo"),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),v([Oe("reflectivity"),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),v([Oe("reflection"),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),v([Oe("emissive"),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),v([Ie()],t.prototype,"usePhysicalLightFalloff",null),v([Ie()],t.prototype,"useGLTFLightFalloff",null),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),v([Ie(),Pe("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),v([Ie(),Pe("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),v([Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),v([Ie(),Pe("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),v([Ie(),Pe("_markAllSubMeshesAsMiscDirty")],t.prototype,"applyDecalMapAfterDetailMap",void 0),t}(ig);a("BABYLON.PBRMaterial",rg);var ng=131072,og=131072;function ag(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var sg=ag("DXT1"),lg=ag("DXT3"),cg=ag("DXT5"),ug=ag("DX10"),hg=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e.buffer,e.byteOffset,31),i=new Int32Array(e.buffer,e.byteOffset,35),r=1;t[2]&ng&&(r=Math.max(1,t[7]));var n=t[21],o=n===ug?i[32]:0,a=u.TEXTURETYPE_UNSIGNED_INT;switch(n){case 113:a=u.TEXTURETYPE_HALF_FLOAT;break;case 116:a=u.TEXTURETYPE_FLOAT;break;case ug:if(10===o){a=u.TEXTURETYPE_HALF_FLOAT;break}if(2===o){a=u.TEXTURETYPE_FLOAT;break}}return{width:t[4],height:t[3],mipmapCount:r,isFourCC:!(4&~t[20]),isRGB:!(64&~t[20]),isLuminance:(t[20]&og)===og,isCube:!(512&~t[28]),isCompressed:n===sg||n===lg||n===cg,dxgiFormat:o,textureType:a}},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,i,r,n,o,a){for(var s=new Float32Array(n),l=new Uint16Array(o,r),c=0,u=0;u>8)},e._GetRGBArrayBuffer=function(e,t,i,r,n,o,a,s){for(var l=new Uint8Array(r),c=new Uint8Array(n,i),u=0,h=0;h>8&255,A>>16&255,A>>24&255))])}var P=e._ExtractLongWordOrder(b[23]),I=e._ExtractLongWordOrder(b[24]),M=e._ExtractLongWordOrder(b[25]),O=e._ExtractLongWordOrder(b[26]);C&&(E=t._getRGBABufferInternalSizedFormat(n.textureType)),v=1,b[2]&ng&&!1!==o&&(v=Math.max(1,b[7]));for(var D=l||0,N=t.getCaps(),F=D;F0?n.sphericalPolynomial=Lp.ConvertCubeMapToSphericalPolynomial({size:b[4],right:h[0],left:h[1],up:h[2],down:h[3],front:h[4],back:h[5],format:u.TEXTUREFORMAT_RGBA,type:u.TEXTURETYPE_FLOAT,gammaSpace:!1}):n.sphericalPolynomial=void 0}else ae.Error("Compressed textures are not supported on this platform.");else ae.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else ae.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();Er.prototype.createPrefilteredCubeTexture=function(e,t,i,r,n,o,a,s,l){var c=this;return void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!0),this.createCubeTexture(e,t,null,!1,(function(e){if(e){var o=e.texture;if(l?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new Sp,o._source=Ti.CubePrefiltered,c.getCaps().textureLOD)n&&n(o);else{var a=c._gl,s=e.width;if(s){for(var h=[],d=0;d<3;d++){var p=1-d/2,f=r,_=j.Log2(s)*i+r,m=f+(_-f)*p,g=Math.round(Math.min(Math.max(m,0),_)),v=new Pi(c,Ti.Temp);if(v.type=o.type,v.format=o.format,v.width=Math.pow(2,Math.max(j.Log2(s)-g,0)),v.height=v.width,v.isCube=!0,v._cachedWrapU=u.TEXTURE_CLAMP_ADDRESSMODE,v._cachedWrapV=u.TEXTURE_CLAMP_ADDRESSMODE,c._bindTextureDirectly(a.TEXTURE_CUBE_MAP,v,!0),v.samplingMode=u.TEXTURE_LINEAR_LINEAR,a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),e.isDDS){var y=e.info,b=e.data;c._unpackFlipY(y.isCompressed),hg.UploadDDSLevels(c,v,b,y,!0,6,g)}else ae.Warn("DDS is the only prefiltered cube map supported so far.");c._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var T=new Ya(t);T._isCube=!0,T._texture=v,v.isReady=!0,h.push(T)}o._lodTextureHigh=h[2],o._lodTextureMid=h[1],o._lodTextureLow=h[0],n&&n(o)}}}else n&&n(null)}),o,a,s,l,i,r)};var dg=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e){return e.endsWith(".dds")},e.prototype.loadCubeData=function(e,t,i,r){var n,o=t.getEngine(),a=!1,s=1e3;if(Array.isArray(e))for(var l=0;l1)&&t.generateMipMaps,o._unpackFlipY(n.isCompressed),hg.UploadDDSLevels(o,t,c,n,a,6,-1,l),n.isFourCC||1!==n.mipmapCount?s=n.mipmapCount-1:o.generateMipMapsForCubemap(t)}else c=e,n=hg.GetDDSInfo(c),t.width=n.width,t.height=n.height,i&&(n.sphericalPolynomial=new Sp),a=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps,o._unpackFlipY(n.isCompressed),hg.UploadDDSLevels(o,t,c,n,a,6),n.isFourCC||1!==n.mipmapCount?s=n.mipmapCount-1:o.generateMipMapsForCubemap(t,!1);o._setCubeMapTextureParams(t,a,s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r({isDDS:!0,width:t.width,info:n,data:e,texture:t})},e.prototype.loadData=function(e,t,i){var r=hg.GetDDSInfo(e),n=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&t.generateMipMaps&&r.width>>r.mipmapCount-1==1;i(r.width,r.height,n,r.isFourCC,(function(){hg.UploadDDSLevels(t.getEngine(),t,e,r,n,1)}))},e}();Do._TextureLoaders.push(new dg);var pg=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return e.endsWith(".env")},e.prototype.loadCubeData=function(e,t,i,r,n){if(!Array.isArray(e)){var o=Vp(e);if(o){t.width=o.width,t.height=o.width;try{Yp(t,o),Hp(t,e,o).then((function(){t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}),(function(e){null==n||n("Can not upload environment levels",e)}))}catch(e){null==n||n("Can not upload environment file",e)}}else n&&n("Can not parse the environment file",null)}},e.prototype.loadData=function(){throw".env not supported in 2d."},e}();Do._TextureLoaders.push(new pg);var fg,_g,mg,gg=function(){function e(t,i){if(this.data=t,this.isInvalid=!1,!e.IsValid(t))return this.isInvalid=!0,void ae.Error("texture missing KTX identifier");var r=Uint32Array.BYTES_PER_ELEMENT,n=new DataView(this.data.buffer,this.data.byteOffset+12,13*r),o=67305985===n.getUint32(0,!0);return this.glType=n.getUint32(1*r,o),this.glTypeSize=n.getUint32(2*r,o),this.glFormat=n.getUint32(3*r,o),this.glInternalFormat=n.getUint32(4*r,o),this.glBaseInternalFormat=n.getUint32(5*r,o),this.pixelWidth=n.getUint32(6*r,o),this.pixelHeight=n.getUint32(7*r,o),this.pixelDepth=n.getUint32(8*r,o),this.numberOfArrayElements=n.getUint32(9*r,o),this.numberOfFaces=n.getUint32(10*r,o),this.numberOfMipmapLevels=n.getUint32(11*r,o),this.bytesOfKeyValueData=n.getUint32(12*r,o),0!==this.glType?(ae.Error("only compressed formats currently supported"),void(this.isInvalid=!0)):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?(ae.Error("only 2D textures currently supported"),void(this.isInvalid=!0)):0!==this.numberOfArrayElements?(ae.Error("texture arrays not currently supported"),void(this.isInvalid=!0)):this.numberOfFaces!==i?(ae.Error("number of faces expected"+i+", but found "+this.numberOfFaces),void(this.isInvalid=!0)):void(this.loadType=e.COMPRESSED_2D))}return e.prototype.uploadLevels=function(t,i){switch(this.loadType){case e.COMPRESSED_2D:this._upload2DCompressedLevels(t,i);case e.TEX_2D:case e.COMPRESSED_3D:case e.TEX_3D:}},e.prototype._upload2DCompressedLevels=function(t,i){for(var r=e.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,a=i?this.numberOfMipmapLevels:1,s=0;s=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.HEADER_LEN=64,e.COMPRESSED_2D=0,e.COMPRESSED_3D=1,e.TEX_2D=2,e.TEX_3D=3,e}(),vg=function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{workerPromise:Promise.resolve(e),idle:!0}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;e1,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(var n=0;n=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&50===t[5]&&48===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.URLConfig={jsDecoderModule:"https://cdn.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,wasmUASTCToR8_UNORM:null,wasmUASTCToRG8_UNORM:null,jsMSCTranscoder:null,wasmMSCTranscoder:null,wasmZSTDDecoder:null},e.DefaultNumWorkers=e.GetDefaultNumWorkers(),e.DefaultDecoderOptions=new Eg,e}(),xg=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t){return e.endsWith(".ktx")||e.endsWith(".ktx2")||"image/ktx"===t||"image/ktx2"===t},e.prototype.loadCubeData=function(e,t,i,r){if(!Array.isArray(e)){t._invertVScale=!t.invertY;var n=t.getEngine(),o=new gg(e,6),a=o.numberOfMipmapLevels>1&&t.generateMipMaps;n._unpackFlipY(!0),o.uploadLevels(t,t.generateMipMaps),t.width=o.pixelWidth,t.height=o.pixelHeight,n._setCubeMapTextureParams(t,a,o.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}},e.prototype.loadData=function(e,t,i,r){if(gg.IsValid(e)){t._invertVScale=!t.invertY;var n=new gg(e,1),o=function(e){switch(e){case u.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT:return u.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;case u.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:return u.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;case u.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:return u.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;case u.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2:return u.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2;case u.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return u.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;case u.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return u.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case u.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:return u.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;case u.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:return u.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM}return null}(n.glInternalFormat);o?(t.format=o,t._useSRGBBuffer=t.getEngine()._getUseSRGBBuffer(!0,t.generateMipMaps),t._gammaSpace=!0):t.format=n.glInternalFormat,i(n.pixelWidth,n.pixelHeight,t.generateMipMaps,!0,(function(){n.uploadLevels(t,t.generateMipMaps)}),n.isInvalid)}else Sg.IsValid(e)?new Sg(t.getEngine())._uploadAsync(e,t,r).then((function(){i(t.width,t.height,t.generateMipMaps,!0,(function(){}),!1)}),(function(e){ae.Warn("Failed to load KTX2 texture data: ".concat(e.message)),i(0,0,!1,!1,(function(){}),!0)})):(ae.Error("texture missing KTX identifier"),i(0,0,!1,!1,(function(){}),!0))},e}();Do._TextureLoaders.push(new xg);var Ag=function(e){function t(t,i,r){var n=e.call(this,t,V.Zero(),i)||this;return n._xrSessionManager=r,n._firstFrame=!1,n._referenceQuaternion=G.Identity(),n._referencedPosition=new V,n._trackingState=ku.NOT_TRACKING,n.onXRCameraInitializedObservable=new f,n.onBeforeCameraTeleport=new f,n.onAfterCameraTeleport=new f,n.onTrackingStateChanged=new f,n.compensateOnFirstFrame=!0,n._rotate180=new G(0,1,0,0),n.minZ=.1,n.rotationQuaternion=new G,n.cameraRigMode=$n.RIG_MODE_CUSTOM,n.updateUpVectorFromRotation=!0,n._updateNumberOfRigCameras(1),n.freezeProjectionMatrix(),n._deferOnly=!0,n._xrSessionManager.onXRSessionInit.add((function(){n._referencedPosition.copyFromFloats(0,0,0),n._referenceQuaternion.copyFromFloats(0,0,0,1),n._firstFrame=n.compensateOnFirstFrame,n._xrSessionManager.onWorldScaleFactorChangedObservable.add((function(){n._xrSessionManager.currentFrame&&n._updateDepthNearFar()}))})),n._xrSessionManager.onXRFrameObservable.add((function(){n._firstFrame&&n._updateFromXRSession(),n.onXRCameraInitializedObservable.hasObservers()&&(n.onXRCameraInitializedObservable.notifyObservers(n),n.onXRCameraInitializedObservable.clear()),n._deferredUpdated&&(n.position.copyFrom(n._deferredPositionUpdate),n.rotationQuaternion.copyFrom(n._deferredRotationQuaternionUpdate)),n._updateReferenceSpace(),n._updateFromXRSession()}),void 0,!0),n}return m(t,e),Object.defineProperty(t.prototype,"trackingState",{get:function(){return this._trackingState},enumerable:!1,configurable:!0}),t.prototype._setTrackingState=function(e){this._trackingState!==e&&(this._trackingState=e,this.onTrackingStateChanged.notifyObservers(e))},Object.defineProperty(t.prototype,"realWorldHeight",{get:function(){var e=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);return e&&e.transform?e.transform.position.y*this._xrSessionManager.worldScalingFactor:0},enumerable:!1,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new Jn(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Jn(.5,0,.5,1),this.rigCameras[1].outputRenderTarget=null},t.prototype.setTransformationFromNonVRCamera=function(e,t){void 0===e&&(e=this.getScene().activeCamera),void 0===t&&(t=!0),e&&e!==this&&(e.computeWorldMatrix().decompose(void 0,this.rotationQuaternion,this.position),this.position.y=0,G.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,t&&this._xrSessionManager.resetReferenceSpace())},t.prototype.getClassName=function(){return"WebXRCamera"},t.prototype.setTarget=function(e){var t=H.Vector3[1];e.subtractToRef(this.position,t),t.y=0,t.normalize();var i=Math.atan2(t.x,t.z);this.rotationQuaternion.toEulerAnglesToRef(t),G.FromEulerAnglesToRef(t.x,i,t.z,this.rotationQuaternion)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._lastXRViewerPose=void 0},t.prototype._updateDepthNearFar=function(){var e=(this.maxZ||1e4)*this._xrSessionManager.worldScalingFactor,t={depthFar:e,depthNear:this.minZ};this._xrSessionManager.updateRenderState(t),this._cache.minZ=this.minZ,this._cache.maxZ=e},t.prototype._updateFromXRSession=function(){var e=this,t=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);if(this._lastXRViewerPose=t||void 0,t){var i=t.emulatedPosition?ku.TRACKING_LOST:ku.TRACKING;if(this._setTrackingState(i),this.minZ===this._cache.minZ&&this.maxZ===this._cache.maxZ||this._updateDepthNearFar(),t.transform){var r=t.transform.orientation;if(void 0===t.transform.orientation.x)return;var n=t.transform.position;this._referencedPosition.set(n.x,n.y,n.z).scaleInPlace(this._xrSessionManager.worldScalingFactor),this._referenceQuaternion.set(r.x,r.y,r.z,r.w),this._scene.useRightHandedSystem||(this._referencedPosition.z*=-1,this._referenceQuaternion.z*=-1,this._referenceQuaternion.w*=-1),this._firstFrame?(this._firstFrame=!1,this.position.y+=this._referencedPosition.y,this._referenceQuaternion.copyFromFloats(0,0,0,1)):(this.rotationQuaternion.copyFrom(this._referenceQuaternion),this.position.copyFrom(this._referencedPosition))}this.rigCameras.length!==t.views.length&&this._updateNumberOfRigCameras(t.views.length),t.views.forEach((function(t,i){var r,n=e.rigCameras[i];n.isLeftCamera||n.isRightCamera||("right"===t.eye?n._isRightCamera=!0:"left"===t.eye&&(n._isLeftCamera=!0));for(var o=e.getScene().customRenderTargets,a=0;ae;){var i=this.rigCameras.pop();i&&i.dispose()}},t.prototype._updateReferenceSpace=function(){if(!this.position.equals(this._referencedPosition)||!this.rotationQuaternion.equals(this._referenceQuaternion)){var e=H.Matrix[0],i=H.Matrix[1],r=H.Matrix[2];z.ComposeToRef(t._ScaleReadOnly,this._referenceQuaternion,this._referencedPosition,e),z.ComposeToRef(t._ScaleReadOnly,this.rotationQuaternion,this.position,i),e.invert().multiplyToRef(i,r),r.invert(),this._scene.useRightHandedSystem||r.toggleModelMatrixHandInPlace(),r.decompose(void 0,this._referenceQuaternion,this._referencedPosition);var n=new XRRigidTransform({x:this._referencedPosition.x/this._xrSessionManager.worldScalingFactor,y:this._referencedPosition.y/this._xrSessionManager.worldScalingFactor,z:this._referencedPosition.z/this._xrSessionManager.worldScalingFactor},{x:this._referenceQuaternion.x,y:this._referenceQuaternion.y,z:this._referenceQuaternion.z,w:this._referenceQuaternion.w});this._xrSessionManager.referenceSpace=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(n)}},t._ScaleReadOnly=V.One(),t}(Oc),Cg=function(){function e(e){var t=this;this._scene=e,this._nonVRCamera=null,this._attachedToElement=!1,this._spectatorCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this._spectatorMode=!1,this._lastTimestamp=0,this.onInitialXRPoseSetObservable=new f,this.onStateChangedObservable=new f,this.state=Vu.NOT_IN_XR,this.sessionManager=new Zu(e),this.camera=new Ag("webxr",e,this.sessionManager),this.featuresManager=new xs(this.sessionManager),e.onDisposeObservable.addOnce((function(){t.dispose()}))}return e.CreateAsync=function(t){var i=new e(t);return i.sessionManager.initializeAsync().then((function(){return i._supported=!0,i})).catch((function(e){throw i._setState(Vu.NOT_IN_XR),i.dispose(),e}))},e.prototype.dispose=function(){var e;this.exitXRAsync(),this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),null===(e=this._spectatorCamera)||void 0===e||e.dispose(),this._nonVRCamera&&(this._scene.activeCamera=this._nonVRCamera)},e.prototype.enterXRAsync=function(e,t,i,r){var n,o,a;return void 0===i&&(i=this.sessionManager.getWebXRRenderTarget()),void 0===r&&(r={}),y(this,void 0,void 0,(function(){var s,l,c,u=this;return b(this,(function(h){switch(h.label){case 0:if(!this._supported)throw"WebXR not supported in this browser or environment";return this._setState(Vu.ENTERING_XR),"viewer"!==t&&"local"!==t&&(r.optionalFeatures=r.optionalFeatures||[],r.optionalFeatures.push(t)),[4,this.featuresManager._extendXRSessionInitObject(r)];case 1:r=h.sent(),"immersive-ar"===e&&"unbounded"!==t&&ae.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),h.label=2;case 2:return h.trys.push([2,7,,8]),[4,this.sessionManager.initializeSessionAsync(e,r)];case 3:return h.sent(),[4,this.sessionManager.setReferenceSpaceTypeAsync(t)];case 4:return h.sent(),s={depthFar:this.camera.maxZ||1e4,depthNear:this.camera.minZ},this.featuresManager.getEnabledFeature(Ss.LAYERS)?[3,6]:[4,i.initializeXRLayerAsync(this.sessionManager.session)];case 5:l=h.sent(),s.baseLayer=l,h.label=6;case 6:return this.sessionManager.updateRenderState(s),this.sessionManager.runXRRenderLoop(),this._originalSceneAutoClear=this._scene.autoClear,this._nonVRCamera=this._scene.activeCamera,this._attachedToElement=!!(null===(o=null===(n=this._nonVRCamera)||void 0===n?void 0:n.inputs)||void 0===o?void 0:o.attachedToElement),null===(a=this._nonVRCamera)||void 0===a||a.detachControl(),this._scene.activeCamera=this.camera,"immersive-ar"!==e?this._nonXRToXRCamera():(this._scene.autoClear=!1,this.camera.compensateOnFirstFrame=!1,this.camera.position.set(0,0,0),this.camera.rotationQuaternion.set(0,0,0,1),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)),this.sessionManager.onXRSessionEnded.addOnce((function(){u.state!==Vu.EXITING_XR&&u._setState(Vu.EXITING_XR),u.camera.rigCameras.forEach((function(e){e.outputRenderTarget=null})),u._scene.autoClear=u._originalSceneAutoClear,u._scene.activeCamera=u._nonVRCamera,u._attachedToElement&&u._nonVRCamera&&u._nonVRCamera.attachControl(!!u._nonVRCamera.inputs.noPreventDefault),"immersive-ar"!==e&&u.camera.compensateOnFirstFrame&&(u._nonVRCamera.setPosition?u._nonVRCamera.setPosition(u.camera.position):u._nonVRCamera.position.copyFrom(u.camera.position)),u._setState(Vu.NOT_IN_XR)})),this.sessionManager.onXRFrameObservable.addOnce((function(){u._setState(Vu.IN_XR)})),[2,this.sessionManager];case 7:throw c=h.sent(),ae.Log(c),ae.Log(c.message),this._setState(Vu.NOT_IN_XR),c;case 8:return[2]}}))}))},e.prototype.exitXRAsync=function(){return this.state!==Vu.IN_XR?Promise.resolve():(this._setState(Vu.EXITING_XR),this.sessionManager.exitXRAsync())},e.prototype.enableSpectatorMode=function(e){this._spectatorMode||(this._spectatorMode=!0,this._switchSpectatorMode(e))},e.prototype.disableSpecatatorMode=function(){this._spectatorMode&&(this._spectatorMode=!1,this._switchSpectatorMode())},e.prototype._switchSpectatorMode=function(e){var t=this,i=1/((null==e?void 0:e.fps)?e.fps:1e3)*1e3,r=(null==e?void 0:e.preferredCameraIndex)?null==e?void 0:e.preferredCameraIndex:0,n=function(){t._spectatorCamera&&t.sessionManager.currentTimestamp-t._lastTimestamp>=i&&(t._lastTimestamp=t.sessionManager.currentTimestamp,t._spectatorCamera.position.copyFrom(t.camera.rigCameras[r].globalPosition),t._spectatorCamera.rotationQuaternion.copyFrom(t.camera.rigCameras[r].absoluteRotation))};if(this._spectatorMode){if(r>=this.camera.rigCameras.length)throw new Error("the preferred camera index is beyond the length of rig camera array.");var o=function(){t.state===Vu.IN_XR?(t._spectatorCamera=new Kc("webxr-spectator",V.Zero(),t._scene),t._spectatorCamera.rotationQuaternion=new G,t._scene.activeCameras=[t.camera,t._spectatorCamera],t.sessionManager.onXRFrameObservable.add(n),t._scene.onAfterRenderCameraObservable.add((function(e){e===t.camera&&(t._scene.getEngine().framebufferDimensionsObject=null)}))):t.state===Vu.EXITING_XR&&(t.sessionManager.onXRFrameObservable.removeCallback(n),t._scene.activeCameras=null)};this.onStateChangedObservable.add(o),o()}else this.sessionManager.onXRFrameObservable.removeCallback(n),this._scene.activeCameras=[this.camera]},e.prototype._nonXRToXRCamera=function(){this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)},e.prototype._setState=function(e){this.state!==e&&(this.state=e,this.onStateChangedObservable.notifyObservers(this.state))},e}(),Rg=function(){function e(e,t,i,r){void 0===i&&(i=-1),void 0===r&&(r=[]),this.id=e,this.type=t,this._buttonIndex=i,this._axesIndices=r,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new f,this.onButtonStateChangedObservable=new f}return Object.defineProperty(e.prototype,"axes",{get:function(){return this._axes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"changes",{get:function(){return this._changes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChanges",{get:function(){return this._hasChanges},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pressed",{get:function(){return this._pressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touched",{get:function(){return this._touched},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()},e.prototype.isAxes=function(){return 0!==this._axesIndices.length},e.prototype.isButton=function(){return-1!==this._buttonIndex},e.prototype.update=function(e){var t=!1,i=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var r=e.buttons[this._buttonIndex];if(!r)return;this._currentValue!==r.value&&(this.changes.value={current:r.value,previous:this._currentValue},t=!0,this._currentValue=r.value),this._touched!==r.touched&&(this.changes.touched={current:r.touched,previous:this._touched},t=!0,this._touched=r.touched),this._pressed!==r.pressed&&(this.changes.pressed={current:r.pressed,previous:this._pressed},t=!0,this._pressed=r.pressed)}this.isAxes()&&(this._axes.x!==e.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:e.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=e.axes[this._axesIndices[0]],i=!0),this._axes.y!==e.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=e.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:e.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=e.axes[this._axesIndices[1]],i=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),i&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))},e.BUTTON_TYPE="button",e.SQUEEZE_TYPE="squeeze",e.THUMBSTICK_TYPE="thumbstick",e.TOUCHPAD_TYPE="touchpad",e.TRIGGER_TYPE="trigger",e}(),Pg=function(){function e(e,t,i,r,n,o){void 0===n&&(n=!1);var a=this;this.scene=e,this.layout=t,this.gamepadObject=i,this.handedness=r,this._doNotLoadControllerMesh=n,this._controllerCache=o,this._initComponent=function(e){if(e){var t=a.layout.components[e],i=t.type,r=t.gamepadIndices.button,n=[];void 0!==t.gamepadIndices.xAxis&&void 0!==t.gamepadIndices.yAxis&&n.push(t.gamepadIndices.xAxis,t.gamepadIndices.yAxis),a.components[e]=new Rg(e,i,r,n)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new f,t.components&&Object.keys(t.components).forEach(this._initComponent)}return e.prototype.dispose=function(){var e=this;this.getComponentIds().forEach((function(t){return e.getComponent(t).dispose()})),this.rootMesh&&(this.rootMesh.getChildren(void 0,!0).forEach((function(e){e.setEnabled(!1)})),this.rootMesh.dispose(!!this._controllerCache,!this._controllerCache))},e.prototype.getAllComponentsOfType=function(e){var t=this;return this.getComponentIds().map((function(e){return t.components[e]})).filter((function(t){return t.type===e}))},e.prototype.getComponent=function(e){return this.components[e]},e.prototype.getComponentIds=function(){return Object.keys(this.components)},e.prototype.getComponentOfType=function(e){return this.getAllComponentsOfType(e)[0]||null},e.prototype.getMainComponent=function(){return this.getComponent(this.layout.selectComponentId)},e.prototype.loadModel=function(){return y(this,void 0,void 0,(function(){var e,t,i=this;return b(this,(function(r){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?ae.Warn("Falling back to generic models"):t=this._getFilenameAndPath(),[2,new Promise((function(r,n){var o=function(t){e?i._getGenericParentMesh(t):i._setRootMesh(t),i._processLoadedModel(t),i._modelReady=!0,i.onModelLoadedObservable.notifyObservers(i),r(!0)};if(i._controllerCache){var a=i._controllerCache.filter((function(e){return e.filename===t.filename&&e.path===t.path}));if(a[0])return a[0].meshes.forEach((function(e){return e.setEnabled(!0)})),void o(a[0].meshes)}Ls.ImportMesh("",t.path,t.filename,i.scene,(function(e){i._controllerCache&&i._controllerCache.push(g(g({},t),{meshes:e})),o(e)}),null,(function(e,r){ae.Log(r),ae.Warn("Failed to retrieve controller model of type ".concat(i.profileId," from the remote server: ").concat(t.path).concat(t.filename)),n(r)}))}))]}))}))},e.prototype.updateFromXRFrame=function(e){var t=this;this.getComponentIds().forEach((function(e){return t.getComponent(e).update(t.gamepadObject)})),this.updateModel(e)},Object.defineProperty(e.prototype,"handness",{get:function(){return this.handedness},enumerable:!1,configurable:!0}),e.prototype.pulse=function(e,t,i){return void 0===i&&(i=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[i]?this.gamepadObject.hapticActuators[i].pulse(e,t):Promise.resolve(!1)},e.prototype._getChildByName=function(e,t){return e.getChildren((function(e){return e.name===t}),!1)[0]},e.prototype._getImmediateChildByName=function(e,t){return e.getChildren((function(e){return e.name==t}),!0)[0]},e.prototype._lerpTransform=function(e,t,i){if(e.minMesh&&e.maxMesh&&e.valueMesh&&e.minMesh.rotationQuaternion&&e.maxMesh.rotationQuaternion&&e.valueMesh.rotationQuaternion){var r=i?.5*t+.5:t;G.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,r,e.valueMesh.rotationQuaternion),V.LerpToRef(e.minMesh.position,e.maxMesh.position,r,e.valueMesh.position)}},e.prototype.updateModel=function(e){this._modelReady&&this._updateModel(e)},e.prototype._getGenericFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},e.prototype._getGenericParentMesh=function(e){var t=this;this.rootMesh=new Fa(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.parent||(e.isPickable=!1,e.setParent(t.rootMesh))})),this.rootMesh.rotationQuaternion=G.FromEulerAngles(0,Math.PI,0)},e}(),Ig=function(e){function t(i,r,n){var o=e.call(this,i,Mg[n],r,n)||this;return o.profileId=t.ProfileId,o}return m(t,e),t.prototype._getFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){},t.prototype._setRootMesh=function(e){var t=this;this.rootMesh=new Fa(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.isPickable=!1,e.parent||e.setParent(t.rootMesh)})),this.rootMesh.rotationQuaternion=G.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(Pg),Mg={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-right",assetPath:"right.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-none",assetPath:"none.glb"}},Og=function(e){function t(t,i,r,n,o){var a=e.call(this,t,r.layouts[i.handedness||"none"],i.gamepad,i.handedness,void 0,o)||this;return a._repositoryUrl=n,a.controllerCache=o,a._buttonMeshMapping={},a._touchDots={},a.profileId=r.profileId,a}return m(t,e),t.prototype.dispose=function(){var t=this;e.prototype.dispose.call(this),this.controllerCache||Object.keys(this._touchDots).forEach((function(e){t._touchDots[e].dispose()}))},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:"".concat(this._repositoryUrl,"/profiles/").concat(this.profileId,"/")}},t.prototype._getModelLoadingConstraints=function(){var e=Ls.IsPluginForExtensionAvailable(".glb");return e||ae.Warn("glTF / glb loader was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var t=this;this.getComponentIds().forEach((function(e){var i=t.layout.components[e];t._buttonMeshMapping[e]={mainMesh:t._getChildByName(t.rootMesh,i.rootNodeName),states:{}},Object.keys(i.visualResponses).forEach((function(r){var n=i.visualResponses[r];if("transform"===n.valueNodeProperty)t._buttonMeshMapping[e].states[r]={valueMesh:t._getChildByName(t.rootMesh,n.valueNodeName),minMesh:t._getChildByName(t.rootMesh,n.minNodeName),maxMesh:t._getChildByName(t.rootMesh,n.maxNodeName)};else{var o=i.type===Rg.TOUCHPAD_TYPE&&i.touchPointNodeName?i.touchPointNodeName:n.valueNodeName;if(t._buttonMeshMapping[e].states[r]={valueMesh:t._getChildByName(t.rootMesh,o)},i.type===Rg.TOUCHPAD_TYPE&&!t._touchDots[r]){var a=Gh(r+"dot",{diameter:.0015,segments:8},t.scene);a.material=new Uu(r+"mat",t.scene),a.material.diffuseColor=Z.Red(),a.parent=t._buttonMeshMapping[e].states[r].valueMesh||null,a.isVisible=!1,t._touchDots[r]=a}}}))}))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new Fa(this.profileId+"-"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;ir/10&&(a.isVisible=!0),(s+=t._scene.getEngine().getDeltaTime())>=r)t._scene.simulatePointerDown(i.pick,c),l=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,c),a.isVisible=!1;else{var e=1-s/r;a.scaling.set(e,e,e)}else l=!1,s=0;t._scene.simulatePointerMove(i.pick,c),o=i.pick}})),void 0!==this._options.renderingGroupId&&(a.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce((function(){i.pick&&!t._options.disablePointerUpOnTouchOut&&l&&(t._scene.simulatePointerUp(i.pick,c),i.finalPointerUpTriggered=!0),a.dispose()}))},t.prototype._attachScreenRayMode=function(e){var t=this,i=this._controllers[e.uniqueId],r=!1,n={pointerId:i.id,pointerType:"xr"};i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){t._augmentPointerInit(n,i.id,i.screenCoordinates),!i.pick||t._options.disablePointerUpOnTouchOut&&r||(r?t._scene.simulatePointerMove(i.pick,n):(t._scene.simulatePointerDown(i.pick,n),i.pointerDownTriggered=!0,r=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,n)))})),e.onDisposeObservable.addOnce((function(){t._augmentPointerInit(n,i.id,i.screenCoordinates),t._xrSessionManager.runInXRFrame((function(){i.pick&&!i.finalPointerUpTriggered&&r&&!t._options.disablePointerUpOnTouchOut&&(t._scene.simulatePointerUp(i.pick,n),i.finalPointerUpTriggered=!0)}))}))},t.prototype._attachTrackedPointerRayMode=function(e){var t=this,i=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);var r={pointerId:i.id,pointerType:"xr"};if(i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){i.laserPointer.material.disableLighting=t.disablePointerLighting,i.selectionMesh.material.disableLighting=t.disableSelectionMeshLighting,i.pick&&(t._augmentPointerInit(r,i.id,i.screenCoordinates),t._scene.simulatePointerMove(i.pick,r))})),e.inputSource.gamepad){var n=function(n){t._options.overrideButtonId&&(i.selectionComponent=n.getComponent(t._options.overrideButtonId)),i.selectionComponent||(i.selectionComponent=n.getMainComponent()),i.onButtonChangedObserver=i.selectionComponent.onButtonStateChangedObservable.add((function(n){if(n.changes.pressed){var o=n.changes.pressed.current;if(i.pick)(t._options.enablePointerSelectionOnAllControllers||e.uniqueId===t._attachedController)&&(t._augmentPointerInit(r,i.id,i.screenCoordinates),o?(t._scene.simulatePointerDown(i.pick,r),i.pointerDownTriggered=!0,i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor):(t._scene.simulatePointerUp(i.pick,r),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor));else if(o&&!t._options.enablePointerSelectionOnAllControllers&&!t._options.disableSwitchOnClick){var a=t._controllers[t._attachedController];a&&a.pointerDownTriggered&&!a.finalPointerUpTriggered&&(t._augmentPointerInit(r,a.id,a.screenCoordinates),t._scene.simulatePointerUp(new Fr,{pointerId:a.id,pointerType:"xr"}),a.finalPointerUpTriggered=!0),t._attachedController=e.uniqueId}}}))};e.motionController?n(e.motionController):e.onMotionControllerInitObservable.add(n)}else{var o=function(e){t._xrSessionManager.onXRFrameObservable.addOnce((function(){t._augmentPointerInit(r,i.id,i.screenCoordinates),i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerDown(i.pick,r),i.pointerDownTriggered=!0,i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor)}))},a=function(e){t._xrSessionManager.onXRFrameObservable.addOnce((function(){t._augmentPointerInit(r,i.id,i.screenCoordinates),i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerUp(i.pick,r),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)}))};i.eventListeners={selectend:a,selectstart:o},this._xrSessionManager.session.addEventListener("selectstart",o),this._xrSessionManager.session.addEventListener("selectend",a)}},t.prototype._convertNormalToDirectionOfRay=function(e,t){return e&&Math.acos(V.Dot(e,t.direction))r},t.prototype._updatePointerDistance=function(e,t){void 0===t&&(t=100),e.scaling.y=t,this._scene.useRightHandedSystem&&(t*=-1),e.position.z=t/2+.05},t.prototype._augmentPointerInit=function(e,t,i){e.pointerId=t,e.pointerType="xr",i&&(e.screenX=i.x,e.screenY=i.y)},Object.defineProperty(t.prototype,"lasterPointerDefaultColor",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._IdCounter=200,t.Name=Ss.POINTER_SELECTION,t.Version=1,t}(As);xs.AddWebXRFeature(Vg.Name,(function(e,t){return function(){return new Vg(e,t)}}),Vg.Version,!0),po.prototype._projectOnTrianglesToRef=function(e,t,i,r,n,o){for(var a=H.Vector3[0],s=H.Vector3[1],l=1/0,c=this.indexStart;ce.currentAnimationState)switch(e.currentAnimationState){case Fg.DEHYDRATED:if(e.hydrateCollisionMeshFunction(!0),t===Fg.HOVER)break;case Fg.HOVER:if(e.touchCollisionMeshFunction(!0),t===Fg.TOUCH)break}else switch(e.currentAnimationState){case Fg.TOUCH:if(e.touchCollisionMeshFunction(!1),t===Fg.HOVER)break;case Fg.HOVER:if(e.hydrateCollisionMeshFunction(!1),t===Fg.DEHYDRATED)break}e.currentAnimationState=t}},t.prototype._processTouchPoint=function(e,t,i){var r,n=this._controllers[e];n.grabRay.origin.copyFrom(t),i.toEulerAnglesToRef(H.Vector3[0]),n.grabRay.direction.copyFrom(H.Vector3[0]),this._options.nearInteractionControllerMode!==Lg.CENTERED_IN_FRONT||(null===(r=n.xrController)||void 0===r?void 0:r.inputSource.hand)||(n.xrController.getWorldPointerRayToRef(this._tmpRay),n.grabRay.origin.addInPlace(this._tmpRay.direction.scale(.05))),n.grabRay.length=this._nearGrabLengthScale*this._hoverRadius*this._xrSessionManager.worldScalingFactor,n.touchCollisionMesh.position.copyFrom(n.grabRay.origin).scaleInPlace(this._xrSessionManager.worldScalingFactor)},t.prototype._onXRFrame=function(e){var t=this;Object.keys(this._controllers).forEach((function(i){var r,n=t._controllers[i],o=null===(r=n.xrController)||void 0===r?void 0:r.inputSource.hand;if((t._options.enableNearInteractionOnAllControllers||i===t._attachedController)&&n.xrController&&(o||t._options.nearInteractionControllerMode&&n.xrController.inputSource.gamepad)){if(n.hoverInteraction=!1,n.nearInteraction=!1,n.xrController){if(o){var a=o.get("index-finger-tip");if(a){var s=e.getJointPose(a,t._xrSessionManager.referenceSpace);if(s&&s.transform){var l=t._scene.useRightHandedSystem?1:-1;H.Vector3[0].set(s.transform.position.x,s.transform.position.y,s.transform.position.z*l),H.Quaternion[0].set(s.transform.orientation.x,s.transform.orientation.y,s.transform.orientation.z*l,s.transform.orientation.w*l),t._processTouchPoint(i,H.Vector3[0],H.Quaternion[0])}}}else if(n.xrController.inputSource.gamepad&&t._options.nearInteractionControllerMode!==Lg.DISABLED){var c=n.xrController.pointer;n.xrController.grip&&t._options.nearInteractionControllerMode===Lg.CENTERED_ON_CONTROLLER&&(c=n.xrController.grip),t._processTouchPoint(i,c.position,c.rotationQuaternion)}var u=function(e,t){return t&&t.hit?e&&e.hit?t.distances&&(a=0,h.copyFrom(t.center)),-1!==a&&a=e.timeout&&(e.contextObservable.remove(n),e.onEnded&&e.onEnded(a))}),e.observableParameters.mask,e.observableParameters.insertFirst,e.observableParameters.scope);return n}!function(e){e[e.INIT=0]="INIT",e[e.STARTED=1]="STARTED",e[e.ENDED=2]="ENDED"}(Gg||(Gg={}));var jg=function(){function e(e){var t,i,r=this;this.onEachCountObservable=new f,this.onTimerAbortedObservable=new f,this.onTimerEndedObservable=new f,this.onStateChangedObservable=new f,this._observer=null,this._breakOnNextTick=!1,this._tick=function(e){var t=Date.now();r._timer=t-r._startTime;var i={startTime:r._startTime,currentTime:t,deltaTime:r._timer,completeRate:r._timer/r._timeToEnd,payload:e},n=r._breakOnNextTick||r._breakCondition(i);n||r._timer>=r._timeToEnd?r._stop(i,n):r.onEachCountObservable.notifyObservers(i)},this._setState(Gg.INIT),this._contextObservable=e.contextObservable,this._observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{},this._breakCondition=null!==(i=e.breakCondition)&&void 0!==i?i:function(){return!1},this._timeToEnd=e.timeout,e.onEnded&&this.onTimerEndedObservable.add(e.onEnded),e.onTick&&this.onEachCountObservable.add(e.onTick),e.onAborted&&this.onTimerAbortedObservable.add(e.onAborted)}return Object.defineProperty(e.prototype,"breakCondition",{set:function(e){this._breakCondition=e},enumerable:!1,configurable:!0}),e.prototype.clearObservables=function(){this.onEachCountObservable.clear(),this.onTimerAbortedObservable.clear(),this.onTimerEndedObservable.clear(),this.onStateChangedObservable.clear()},e.prototype.start=function(e){if(void 0===e&&(e=this._timeToEnd),this._state===Gg.STARTED)throw new Error("Timer already started. Please stop it before starting again");this._timeToEnd=e,this._startTime=Date.now(),this._timer=0,this._observer=this._contextObservable.add(this._tick,this._observableParameters.mask,this._observableParameters.insertFirst,this._observableParameters.scope),this._setState(Gg.STARTED)},e.prototype.stop=function(){this._state===Gg.STARTED&&(this._breakOnNextTick=!0)},e.prototype.dispose=function(){this._observer&&this._contextObservable.remove(this._observer),this.clearObservables()},e.prototype._setState=function(e){this._state=e,this.onStateChangedObservable.notifyObservers(this._state)},e.prototype._stop=function(e,t){void 0===t&&(t=!1),this._contextObservable.remove(this._observer),this._setState(Gg.ENDED),t?this.onTimerAbortedObservable.notifyObservers(e):this.onTimerEndedObservable.notifyObservers(e)},e}(),Yg=function(e){function t(t,i){var r=e.call(this,t)||this;return r._options=i,r._controllers={},r._snappedToPoint=!1,r._cachedColor4White=new J(1,1,1,1),r._tmpRay=new hs(new V,new V),r._tmpVector=new V,r._tmpQuaternion=new G,r._worldScaleObserver=null,r.skipNextTeleportation=!1,r.backwardsMovementEnabled=!0,r.backwardsTeleportationDistance=.7,r.parabolicCheckRadius=5,r.parabolicRayEnabled=!0,r.straightRayEnabled=!0,r.rotationAngle=Math.PI/8,r.onTargetMeshPositionUpdatedObservable=new f,r.teleportationEnabled=!0,r._rotationEnabled=!0,r.onBeforeCameraTeleportRotation=new f,r.onAfterCameraTeleportRotation=new f,r._attachController=function(e){if(!(r._controllers[e.uniqueId]||r._options.forceHandedness&&e.inputSource.handedness!==r._options.forceHandedness)){r._controllers[e.uniqueId]={xrController:e,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0,blocked:!1,initialHit:!1,mainComponentUsed:!1}};var t=r._controllers[e.uniqueId];if("tracked-pointer"===t.xrController.inputSource.targetRayMode&&t.xrController.inputSource.gamepad){var i=function(){if(e.motionController){var i=e.motionController.getComponentOfType(Rg.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(Rg.TOUCHPAD_TYPE);if(!i||r._options.useMainComponentOnly){var n=e.motionController.getMainComponent();if(!n)return;t.teleportationState.mainComponentUsed=!0,t.teleportationComponent=n,t.onButtonChangedObserver=n.onButtonStateChangedObservable.add((function(){if(r.teleportationEnabled){var i=function(){t.teleportationState.forward=!0,t.teleportationState.initialHit=!1,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Xg({timeout:r._options.timeToTeleport||3e3,contextObservable:r._xrSessionManager.onXRFrameObservable,breakCondition:function(){return!n.pressed},onEnded:function(){r._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&r._teleportForward(e.uniqueId)}})};n.changes.pressed&&(n.changes.pressed.current?r._options.timeToTeleportStart?Xg({timeout:r._options.timeToTeleportStart,contextObservable:r._xrSessionManager.onXRFrameObservable,onEnded:function(){n.pressed&&i()}}):i():(t.teleportationState.forward=!1,r._currentTeleportationControllerId=""))}}))}else t.teleportationComponent=i,t.onAxisChangedObserver=i.onAxisValueChangedObservable.add((function(i){if(i.y<=.7&&t.teleportationState.backwards&&(t.teleportationState.backwards=!1),i.y>.7&&!t.teleportationState.forward&&r.backwardsMovementEnabled&&!r.snapPointsOnly&&!t.teleportationState.backwards){t.teleportationState.backwards=!0,r._tmpQuaternion.copyFrom(r._options.xrInput.xrCamera.rotationQuaternion),r._tmpQuaternion.toEulerAnglesToRef(r._tmpVector),r._tmpVector.x=0,r._tmpVector.z=0,G.FromEulerVectorToRef(r._tmpVector,r._tmpQuaternion),r._tmpVector.set(0,0,r.backwardsTeleportationDistance*(r._xrSessionManager.scene.useRightHandedSystem?1:-1)),r._tmpVector.rotateByQuaternionToRef(r._tmpQuaternion,r._tmpVector),r._tmpVector.addInPlace(r._options.xrInput.xrCamera.position),r._tmpRay.origin.copyFrom(r._tmpVector),r._tmpRay.length=r._options.xrInput.xrCamera.realWorldHeight+.1,r._tmpRay.direction.set(0,-1,0);var n=r._xrSessionManager.scene.pickWithRay(r._tmpRay,(function(e){return-1!==r._floorMeshes.indexOf(e)}));n&&n.pickedPoint&&(r._options.xrInput.xrCamera.position.x=n.pickedPoint.x,r._options.xrInput.xrCamera.position.z=n.pickedPoint.z)}if(i.y<-.7&&!r._currentTeleportationControllerId&&!t.teleportationState.rotating&&r.teleportationEnabled&&(t.teleportationState.forward=!0,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),i.x){if(t.teleportationState.forward)r._currentTeleportationControllerId===t.xrController.uniqueId&&(r.rotationEnabled?setTimeout((function(){t.teleportationState.currentRotation=Math.atan2(i.x,i.y*(r._xrSessionManager.scene.useRightHandedSystem?1:-1))})):t.teleportationState.currentRotation=0);else if(!t.teleportationState.rotating&&Math.abs(i.x)>.7){t.teleportationState.rotating=!0;var o=r.rotationAngle*(i.x>0?1:-1)*(r._xrSessionManager.scene.useRightHandedSystem?-1:1);r.onBeforeCameraTeleportRotation.notifyObservers(o),G.FromEulerAngles(0,o,0).multiplyToRef(r._options.xrInput.xrCamera.rotationQuaternion,r._options.xrInput.xrCamera.rotationQuaternion),r.onAfterCameraTeleportRotation.notifyObservers(r._options.xrInput.xrCamera.rotationQuaternion)}}else t.teleportationState.rotating=!1;0===i.x&&0===i.y&&(t.teleportationState.blocked&&(t.teleportationState.blocked=!1,r._setTargetMeshVisibility(!1)),t.teleportationState.forward&&r._teleportForward(e.uniqueId))}))}};e.motionController?i():e.onMotionControllerInitObservable.addOnce((function(){i()}))}else{t.teleportationState.mainComponentUsed=!0;var n=!1,o=function(){r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.forward=!0,t.teleportationState.initialHit=!1,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Xg({timeout:r._options.timeToTeleport||3e3,contextObservable:r._xrSessionManager.onXRFrameObservable,onEnded:function(){r._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&r._teleportForward(e.uniqueId)}})};r._xrSessionManager.scene.onPointerObservable.add((function(e){e.type===Gr.POINTERDOWN?(n=!1,r._options.timeToTeleportStart?Xg({timeout:r._options.timeToTeleportStart,contextObservable:r._xrSessionManager.onXRFrameObservable,onEnded:function(){r._currentTeleportationControllerId===t.xrController.uniqueId&&o()},breakCondition:function(){return!!n&&(n=!1,!0)}}):o()):e.type===Gr.POINTERUP&&(n=!0,t.teleportationState.forward=!1,r._currentTeleportationControllerId="")}))}}},r._colorArray=Array(24).fill(r._cachedColor4White),r._options.teleportationTargetMesh||r._createDefaultTargetMesh(),r._floorMeshes=r._options.floorMeshes||[],r._snapToPositions=r._options.snapPositions||[],r._blockedRayColor=r._options.blockedRayColor||new J(1,0,0,.75),r._setTargetMeshVisibility(!1),r.onBeforeCameraTeleport=i.xrInput.xrCamera.onBeforeCameraTeleport,r.onAfterCameraTeleport=i.xrInput.xrCamera.onAfterCameraTeleport,r.parabolicCheckRadius*=r._xrSessionManager.worldScalingFactor,r._worldScaleObserver=t.onWorldScaleFactorChangedObservable.add((function(e){var t;r.parabolicCheckRadius=r.parabolicCheckRadius/e.previousScaleFactor*e.newScaleFactor,null===(t=r._options.teleportationTargetMesh)||void 0===t||t.scaling.scaleInPlace(e.newScaleFactor/e.previousScaleFactor)})),r}return m(t,e),Object.defineProperty(t.prototype,"rotationEnabled",{get:function(){return this._rotationEnabled},set:function(e){if(this._rotationEnabled=e,this._options.teleportationTargetMesh){var t=this._options.teleportationTargetMesh.getChildMeshes(!1,(function(e){return"rotationCone"===e.name}));t[0]&&t[0].setEnabled(e)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"teleportationTargetMesh",{get:function(){return this._options.teleportationTargetMesh||null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapPointsOnly",{get:function(){return!!this._options.snapPointsOnly},set:function(e){this._options.snapPointsOnly=e},enumerable:!1,configurable:!0}),t.prototype.addFloorMesh=function(e){this._floorMeshes.push(e)},t.prototype.addBlockerMesh=function(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[],this._options.pickBlockerMeshes.push(e)},t.prototype.addSnapPoint=function(e){this._snapToPositions.push(e)},t.prototype.attach=function(){var t=this;return!!e.prototype.attach.call(this)&&(this._currentTeleportationControllerId="",this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(e){t._detachController(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach((function(e){t._detachController(e)})),this._setTargetMeshVisibility(!1),this._currentTeleportationControllerId="",this._controllers={},!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.dispose(!1,!0),this._worldScaleObserver&&this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(this._worldScaleObserver)},t.prototype.removeFloorMesh=function(e){var t=this._floorMeshes.indexOf(e);-1!==t&&this._floorMeshes.splice(t,1)},t.prototype.removeBlockerMesh=function(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[];var t=this._options.pickBlockerMeshes.indexOf(e);-1!==t&&this._options.pickBlockerMeshes.splice(t,1)},t.prototype.removeFloorMeshByName=function(e){var t=this._xrSessionManager.scene.getMeshByName(e);t&&this.removeFloorMesh(t)},t.prototype.removeSnapPoint=function(e){var t=this._snapToPositions.indexOf(e);if(-1===t)for(var i=0;i=h.video.HAVE_CURRENT_DATA;return!h._settings.poster||h._settings.autoPlay&&f?f&&h._createInternalTexture():(h._texture=h._getEngine().createTexture(h._settings.poster,!1,!h.invertY,r),h._displayingPosterTexture=!0),h}return m(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new f),this._onUserActionRequestedObservable},enumerable:!1,configurable:!0}),t.prototype._processError=function(e){this._errorFound=!0,this._onError?this._onError(null==e?void 0:e.message):ae.Error(null==e?void 0:e.message)},t.prototype._handlePlay=function(){var e=this;this._errorFound=!1,this.video.play().catch((function(t){if("NotAllowedError"===(null==t?void 0:t.name)){if(e._onUserActionRequestedObservable&&e._onUserActionRequestedObservable.hasObservers())return void e._onUserActionRequestedObservable.notifyObservers(e);if(!e.video.muted)return ae.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),e.video.muted=!0,e._errorFound=!1,void e.video.play().catch((function(t){e._processError(t)}))}e._processError(t)}))},t.prototype.getClassName=function(){return"VideoTexture"},t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},t.prototype._getVideo=function(e){if(e.isNative)return e;if(e instanceof HTMLVideoElement)return rr.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(rr.SetCorsBehavior(e,t),t.src=e):(rr.SetCorsBehavior(e[0],t),e.forEach((function(e){var i=document.createElement("source");i.src=e,t.appendChild(i)}))),this.onDisposeObservable.addOnce((function(){Zg(t)})),t},t.prototype._rebuild=function(){this.update()},t.prototype.update=function(){this.autoUpdateTexture&&this.updateTexture(!0)},t.prototype.updateTexture=function(e){e&&(this.video.paused&&this._stillImageCaptured||(this._stillImageCaptured=!0,this._updateInternalTexture()))},Object.defineProperty(t.prototype,"externalTexture",{get:function(){return this._externalTexture},enumerable:!1,configurable:!0}),t.prototype.updateURL=function(e){this.video.src=e,this._currentSrc=e},t.prototype.clone=function(){return new t(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)},t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),this._currentSrc=null,this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener(this._createInternalTextureOnEvent,this._createInternalTexture),this._settings.independentVideoSource||(this.video.removeEventListener("paused",this._updateInternalTexture),this.video.removeEventListener("seeked",this._updateInternalTexture),this.video.removeEventListener("loadeddata",this._updateInternalTexture),this.video.removeEventListener("emptied",this._reset),this.video.removeEventListener("resize",this._resizeInternalTexture),this.video.pause()),null===(t=this._externalTexture)||void 0===t||t.dispose()},t.CreateFromStreamAsync=function(e,i,r,n){void 0===n&&(n=!0);var o=e.getEngine().createVideoElement(r);return e.getEngine()._badOS&&(document.body.appendChild(o),o.style.transform="scale(0.0001, 0.0001)",o.style.opacity="0",o.style.position="fixed",o.style.bottom="0px",o.style.right="0px"),o.setAttribute("autoplay",""),o.setAttribute("muted","true"),o.setAttribute("playsinline",""),o.muted=!0,o.isNative||(void 0!==o.mozSrcObject?o.mozSrcObject=i:"object"==typeof o.srcObject?o.srcObject=i:o.src=window.URL&&window.URL.createObjectURL(i)),new Promise((function(i){var r=function(){var a=new t("video",o,e,!0,n,void 0,void 0,void 0,u.TEXTUREFORMAT_RGB);e.getEngine()._badOS&&a.onDisposeObservable.addOnce((function(){o.remove()})),a.onDisposeObservable.addOnce((function(){Zg(o)})),i(a),o.removeEventListener("playing",r)};o.addEventListener("playing",r),o.play()}))},t.CreateFromWebCamAsync=function(e,t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!0),y(this,void 0,void 0,(function(){var n,o;return b(this,(function(a){switch(a.label){case 0:return navigator.mediaDevices?[4,navigator.mediaDevices.getUserMedia({video:t,audio:i})]:[3,3];case 1:return n=a.sent(),[4,this.CreateFromStreamAsync(e,n,t,r)];case 2:return(o=a.sent()).onDisposeObservable.addOnce((function(){n.getTracks().forEach((function(e){e.stop()}))})),[2,o];case 3:return[2,Promise.reject("No support for userMedia on this device")]}}))}))},t.CreateFromWebCam=function(e,t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=!0),this.CreateFromWebCamAsync(e,i,r,n).then((function(e){t&&t(e)})).catch((function(e){ae.Error(e.name)}))},v([Ie("settings")],t.prototype,"_settings",void 0),v([Ie("src")],t.prototype,"_currentSrc",void 0),v([Ie()],t.prototype,"isVideo",void 0),t}(Ja);Ja._CreateVideoTexture=function(e,t,i,r,n,o,a,s,l){return void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=Ja.TRILINEAR_SAMPLINGMODE),void 0===a&&(a={}),void 0===l&&(l=u.TEXTUREFORMAT_RGBA),new Jg(e,t,i,r,n,o,a,s,l)},a("BABYLON.VideoTexture",Jg);var $g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"videoMode",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,t,i){var r=this,n={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},o=new Jg((this.name||"videoDome")+"_texture",e,t,i.generateMipMaps,this._useDirectMapping,Ja.TRILINEAR_SAMPLINGMODE,n);return i.clickToPlay&&(this._pointerObserver=t.onPointerObservable.add((function(e){var t;(null===(t=e.pickInfo)||void 0===t?void 0:t.pickedMesh)===r.mesh&&r._texture.video.play()}),Gr.POINTERDOWN)),this._textureObserver=o.onLoadObservable.add((function(){r.onLoadObservable.notifyObservers()})),o},t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._texture.onLoadObservable.remove(this._textureObserver),this._scene.onPointerObservable.remove(this._pointerObserver),e.prototype.dispose.call(this,t,i)},t.MODE_MONOSCOPIC=Bm.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=Bm.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=Bm.MODE_SIDEBYSIDE,t}(Bm),ev=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new an,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this.engine.getGPUFrameTimeCounter()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,this.engine.captureGPUFrameTime(e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add((function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()})),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add((function(){t._shaderCompilationTime.endMonitoring()}))):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null,this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null,this.engine=null},e}(),tv=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new an,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new an,this._captureFrameTime=!1,this._frameTime=new an,this._captureRenderTime=!1,this._renderTime=new an,this._captureInterFrameTime=!1,this._interFrameTime=new an,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new an,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new an,this._capturePhysicsTime=!1,this._physicsTime=new an,this._captureAnimationsTime=!1,this._animationsTime=new an,this._captureCameraRenderTime=!1,this._cameraRenderTime=new an,this._onBeforeActiveMeshesEvaluationObserver=null,this._onAfterActiveMeshesEvaluationObserver=null,this._onBeforeRenderTargetsRenderObserver=null,this._onAfterRenderTargetsRenderObserver=null,this._onAfterRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterDrawPhaseObserver=null,this._onBeforeAnimationsObserver=null,this._onBeforeParticlesRenderingObserver=null,this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver=null,this._onAfterSpritesRenderingObserver=null,this._onBeforePhysicsObserver=null,this._onAfterPhysicsObserver=null,this._onAfterAnimationsObserver=null,this._onBeforeCameraRenderObserver=null,this._onAfterCameraRenderObserver=null,this._onBeforeAnimationsObserver=e.onBeforeAnimationsObservable.add((function(){t._captureActiveMeshesEvaluationTime&&t._activeMeshesEvaluationTime.fetchNewFrame(),t._captureRenderTargetsRenderTime&&t._renderTargetsRenderTime.fetchNewFrame(),t._captureFrameTime&&(rr.StartPerformanceCounter("Scene rendering"),t._frameTime.beginMonitoring()),t._captureInterFrameTime&&t._interFrameTime.endMonitoring(),t._captureParticlesRenderTime&&t._particlesRenderTime.fetchNewFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.fetchNewFrame(),t._captureAnimationsTime&&t._animationsTime.beginMonitoring(),t._captureRenderTime&&t._renderTime.fetchNewFrame(),t._captureCameraRenderTime&&t._cameraRenderTime.fetchNewFrame(),t.scene.getEngine()._drawCalls.fetchNewFrame()})),this._onAfterRenderObserver=e.onAfterRenderObservable.add((function(){t._captureFrameTime&&(rr.EndPerformanceCounter("Scene rendering"),t._frameTime.endMonitoring()),t._captureRenderTime&&t._renderTime.endMonitoring(!1),t._captureInterFrameTime&&t._interFrameTime.beginMonitoring(),t._captureActiveMeshesEvaluationTime&&t._activeMeshesEvaluationTime.endFrame(),t._captureRenderTargetsRenderTime&&t._renderTargetsRenderTime.endFrame(),t._captureParticlesRenderTime&&t._particlesRenderTime.endFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.endFrame(),t._captureRenderTime&&t._renderTime.endFrame(),t._captureCameraRenderTime&&t._cameraRenderTime.endFrame()}))}return Object.defineProperty(e.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(e){var t=this;e!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=e,e?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add((function(){rr.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){rr.EndPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.endMonitoring(!1)}))):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(e){var t=this;e!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=e,e?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add((function(){rr.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){rr.EndPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(e){var t=this;e!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=e,e?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add((function(){rr.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){rr.EndPerformanceCounter("Particles"),t._particlesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(e){var t=this;e!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=e,this.scene.spriteManagers&&(e?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add((function(){rr.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){rr.EndPerformanceCounter("Sprites"),t._spritesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(e){var t=this;e!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=e,e?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add((function(){rr.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){rr.EndPerformanceCounter("Physics"),t._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add((function(){t._animationsTime.endMonitoring()})):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(e){var t=this;e!==this._captureRenderTime&&(this._captureRenderTime=e,e?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add((function(){t._renderTime.beginMonitoring(),rr.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),rr.EndPerformanceCounter("Main render")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureCameraRenderTime",{get:function(){return this._captureCameraRenderTime},set:function(e){var t=this;e!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=e,e?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add((function(e){t._cameraRenderTime.beginMonitoring(),rr.StartPerformanceCounter("Rendering camera ".concat(e.name))})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),rr.EndPerformanceCounter("Rendering camera ".concat(e.name))}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=null,this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null,this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null,this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver&&(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null),this._onAfterSpritesRenderingObserver&&(this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null),this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null,this._onBeforePhysicsObserver&&(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null),this._onAfterPhysicsObserver&&(this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null),this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null,this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null,this.scene=null},e}();li.ShadersStore.glowMapGenerationPixelShader="#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)\n#include\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;uniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;uniform sampler2D opacitySampler;uniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;uniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;uniform float glowIntensity;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\nvec4 finalColor=glowColor;\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\n#ifdef DIFFUSE_ISLINEAR\nalbedoTexture=toGammaSpace(albedoTexture);\n#endif\n#ifdef GLOW\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef HIGHLIGHT\nfinalColor.a=albedoTexture.a;\n#endif\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nuniform mat4 viewProjection;varying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;uniform mat4 diffuseMatrix;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;uniform mat4 opacityMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;uniform mat4 emissiveMatrix;\n#endif\n#ifdef VERTEXALPHA\nattribute vec4 color;varying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef CUBEMAP\nvPosition=worldPos;gl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*worldPos;gl_Position=vPosition;\n#endif\n#ifdef DIFFUSE\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef OPACITY\n#ifdef OPACITYUV1\nvUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef OPACITYUV2\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef VERTEXALPHA\nvColor=color;\n#endif\n#include\n}";var iv=function(){function e(t,i){this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new J},this._effectIntensity={},this.neutralColor=new J,this.isEnabled=!0,this.disableBoundingBoxesFromEffectLayer=!1,this.onDisposeObservable=new f,this.onBeforeRenderMainTextureObservable=new f,this.onBeforeComposeObservable=new f,this.onBeforeRenderMeshToEffect=new f,this.onAfterRenderMeshToEffect=new f,this.onAfterComposeObservable=new f,this.onSizeChangedObservable=new f,this._materialForRendering={},this.name=t,this._scene=i||M.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),this._mergeDrawWrapper=[],this._generateIndexBuffer(),this._generateVertexBuffer()}return Object.defineProperty(e.prototype,"camera",{get:function(){return this._effectLayerOptions.camera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._effectLayerOptions.renderingGroupId},set:function(e){this._effectLayerOptions.renderingGroupId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mainTexture",{get:function(){return this._mainTexture},enumerable:!1,configurable:!0}),e.prototype.setMaterialForRendering=function(e,t){if(this._mainTexture.setMaterialForRendering(e,t),Array.isArray(e))for(var i=0;i4&&(c.push(Nr.MatricesIndicesExtraKind),c.push(Nr.MatricesWeightsExtraKind)),l.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers);var g=o.skeleton;g&&g.isUsingTextureForMatrices?l.push("#define BONETEXTURE"):l.push("#define BonesPerMesh "+(g?g.bones.length+1:0)),o.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,o)}else l.push("#define NUM_BONE_INFLUENCERS 0");var v=o.morphTargetManager,y=0;v&&(y=v.numMaxInfluencers||v.numInfluencers)>0&&(l.push("#define MORPHTARGETS"),l.push("#define NUM_MORPH_INFLUENCERS "+y),v.isUsingTextureForTargets&&l.push("#define MORPHTARGETS_TEXTURE"),qo(c,o,y)),t&&(l.push("#define INSTANCES"),Jo(c),e.getRenderingMesh().hasThinInstances&&l.push("#define THIN_INSTANCES")),zo(s,this._scene,l),this._addCustomEffectDefines(l);var b=e._getDrawWrapper(void 0,!0),T=b.defines,E=l.join("\n");if(T!==E){var S=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","glowIntensity"];Go(S),b.setEffect(this._engine.createEffect("glowMapGeneration",c,S,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets"],E,m,void 0,void 0,{maxSimultaneousMorphTargets:y}),E)}return b.effect.isReady()},e.prototype.render=function(){for(var e=0;e-1&&this._scene.effectLayers.splice(r,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},e.prototype.getClassName=function(){return"EffectLayer"},e.Parse=function(e,t,i){return rr.Instantiate(e.customType).Parse(e,t,i)},e._SceneComponentInitialization=function(e){throw He("EffectLayerSceneComponent")},v([Ie()],e.prototype,"name",void 0),v([Be()],e.prototype,"neutralColor",void 0),v([Ie()],e.prototype,"isEnabled",void 0),v([Ge()],e.prototype,"camera",null),v([Ie()],e.prototype,"renderingGroupId",null),v([Ie()],e.prototype,"disableBoundingBoxesFromEffectLayer",void 0),e}();c.AddParser(Vr.NAME_EFFECTLAYER,(function(e,t,i,r){if(e.effectLayers){i.effectLayers||(i.effectLayers=[]);for(var n=0;n0){this._previousStencilState=this._engine.getStencilBuffer();for(var r=0,n=i;r-1)){this._renderEffects=!0,this._needStencil=this._needStencil||o.needStencil();var a=o._mainTexture;a._shouldRender()&&(this.scene.incrementRenderId(),a.render(!1,!1),t=!0)}}this.scene.incrementRenderId()}return t},e.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},e.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},e.prototype._draw=function(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var t=this.scene.effectLayers,i=0;i-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){var t=this;e.resetDrawCache(this._mainTexture.renderPassId),this._meshesUsingTheirOwnMaterials.push(e.uniqueId),e.onDisposeObservable.add((function(){t._disposeMesh(e)}))},t.prototype.unReferenceMeshFromUsingItsOwnMaterial=function(e){for(var t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);t>=0;)this._meshesUsingTheirOwnMaterials.splice(t,1),t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);e.resetDrawCache(this._mainTexture.renderPassId)},t.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},t.prototype.getClassName=function(){return"GlowLayer"},t.prototype.serialize=function(){var e,t=Ke.Serialize(this);if(t.customType="BABYLON.GlowLayer",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e0&&e.isBackground===t&&e.applyPostProcess===i&&e.renderTargetTextures.indexOf(n)>-1&&!!(e.layerMask&r)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!0,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForegroundWithPostProcessing=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!1,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForegroundWithoutPostProcessing=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!1,!1,t.scene.activeCamera.layerMask,e)}))},e.prototype.addFromContainer=function(e){var t=this;e.layers&&e.layers.forEach((function(e){t.scene.layers.push(e)}))},e.prototype.removeFromContainer=function(e,t){var i=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var r=i.scene.layers.indexOf(e);-1!==r&&i.scene.layers.splice(r,1),t&&e.dispose()}))},e}();li.ShadersStore.layerPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec4 color;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef LINEAR\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";li.ShadersStore.layerVertexShader="attribute vec2 position;uniform vec2 scale;uniform vec2 offset;uniform mat4 textureMatrix;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec2 shiftedPosition=position*scale+offset;vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));gl_Position=vec4(shiftedPosition,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";var lv=function(){function e(e,t,i,r,n){this.name=e,this._applyPostProcess=!0,this.scale=new U(1,1),this.offset=new U(0,0),this.alphaBlendingMode=u.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this.isEnabled=!0,this._vertexBuffers={},this.onDisposeObservable=new f,this.onBeforeRenderObservable=new f,this.onAfterRenderObservable=new f,this.texture=t?new Ja(t,i,!0):null,this.isBackground=void 0===r||r,this.color=void 0===n?new J(1,1,1,1):n,this._scene=i||M.LastCreatedScene;var o=this._scene._getComponent(Vr.NAME_LAYER);o||(o=new sv(this._scene),this._scene._addComponent(o)),this._scene.layers.push(this);var a=this._scene.getEngine();this._drawWrapper=new ho(a);var s=[];s.push(1,1),s.push(-1,1),s.push(-1,-1),s.push(1,-1);var l=new Nr(a,s,Nr.PositionKind,!1,!1,2);this._vertexBuffers[Nr.PositionKind]=l,this._createIndexBuffer()}return Object.defineProperty(e.prototype,"applyPostProcess",{get:function(){return this.isBackground||this._applyPostProcess},set:function(e){this._applyPostProcess=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},e.prototype._rebuild=function(){var e=this._vertexBuffers[Nr.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.isReady=function(){var e,t=this._scene.getEngine(),i="";this.alphaTest&&(i="#define ALPHATEST"),this.texture&&!this.texture.gammaSpace&&(i+="\n#define LINEAR"),this._previousDefines!==i&&(this._previousDefines=i,this._drawWrapper.effect=t.createEffect("layer",[Nr.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],i));var r=this._drawWrapper.effect;return(null==r?void 0:r.isReady())&&(null===(e=this.texture)||void 0===e?void 0:e.isReady())},e.prototype.render=function(){if(this.isEnabled){var e=this._scene.getEngine();if(this.isReady()){var t=this._drawWrapper.effect;this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(this._drawWrapper),e.setState(!1),t.setTexture("textureSampler",this.texture),t.setMatrix("textureMatrix",this.texture.getTextureMatrix()),t.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),t.setVector2("offset",this.offset),t.setVector2("scale",this.scale),e.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this.alphaTest?e.drawElementsType(Ca.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(Ca.TriangleFillMode,0,6),e.setAlphaMode(u.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}}},e.prototype.dispose=function(){var e=this._vertexBuffers[Nr.PositionKind];e&&(e.dispose(),this._vertexBuffers[Nr.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var t=this._scene.layers.indexOf(this);this._scene.layers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},e}(),cv=function(){function e(e,t,i,r,n){this.size=e,this.position=t,this.alphaMode=u.ALPHA_ONEONE,this.color=i||new Z(1,1,1),this.texture=r?new Ja(r,n.getScene(),!0):null,this._system=n;var o=n.scene.getEngine();this._drawWrapper=new ho(o),this._drawWrapper.effect=o.createEffect("lensFlare",[Nr.PositionKind],["color","viewportMatrix"],["textureSampler"],""),n.lensFlares.push(this)}return e.AddFlare=function(t,i,r,n,o){return new e(t,i,r,n,o)},e.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},e}();li.ShadersStore.lensFlarePixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);gl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";li.ShadersStore.lensFlareVertexShader="attribute vec2 position;uniform mat4 viewportMatrix;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;gl_Position=viewportMatrix*vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";var uv=function(){function e(t,i,r){this.name=t,this.lensFlares=[],this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=r||M.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=i,this.id=t,r.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return r.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&!!(e.layerMask&r.activeCamera.layerMask)};var n=r.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[Nr.PositionKind]=new Nr(n,o,Nr.PositionKind,!1,!1,2),this._createIndexBuffer()}return Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEmitter=function(){return this._emitter},e.prototype.setEmitter=function(e){this._emitter=e},e.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},e.prototype.computeEffectivePosition=function(e){var t=this.getEmitterPosition();t=V.Project(t,z.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=V.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),this.viewportBorder>0&&(e.x-=this.viewportBorder,e.y-=this.viewportBorder,e.width+=2*this.viewportBorder,e.height+=2*this.viewportBorder,t.x+=this.viewportBorder,t.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder);var i=this._scene.useRightHandedSystem;return!!(t.z>0&&!i||t.z<0&&i)&&(this._positionX>e.x&&this._positionXe.y&&(this._positionY,e.y,e.height),!0)},e.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var e=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),t=e.length();e.normalize();var i=new hs(this._scene.activeCamera.globalPosition,e),r=this._scene.pickWithRay(i,this.meshesSelectionPredicate,!0);return!r||!r.hit||r.distance>t},e.prototype.render=function(){if(!this._scene.activeCamera)return!1;var e,t,i=this._scene.getEngine(),r=this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0),i.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n=(e=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0)>(t=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0)?e:t;(n-=this.viewportBorder)>this.borderLimit&&(n=this.borderLimit);var o=1-j.Clamp(n/this.borderLimit,0,1);if(o<0)return!1;o>1&&(o=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var a=r.x+r.width/2,s=r.y+r.height/2,l=a-this._positionX,c=s-this._positionY;i.setState(!1),i.setDepthBuffer(!1);for(var h=0;h0);for(var i=0,r=t;i0)}},e}();uv._SceneComponentInitialization=function(e){var t=e._getComponent(Vr.NAME_LENSFLARESYSTEM);t||(t=new hv(e),e._addComponent(t))};li.IncludesShadersStore.bayerDitherFunctions="float bayerDither2(vec2 _P) {return mod(2.0*_P.y+_P.x+1.0,4.0);}\nfloat bayerDither4(vec2 _P) {vec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5*mod(_P,4.0)); \nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);}\nfloat bayerDither8(vec2 _P) {vec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5 *mod(_P,4.0)); \nvec2 P4=floor(0.25*mod(_P,8.0)); \nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);}\n";li.IncludesShadersStore.shadowMapFragmentExtraDeclaration="#if SM_FLOAT==0\n#include\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#include\nuniform float softTransparentShadowSM;\n#endif\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nuniform vec3 lightDataSM;varying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n";li.IncludesShadersStore.shadowMapFragment="float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\n#if SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\ndepthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\ndepthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_FragDepth=clamp(1.0-depthSM,0.0,1.0);\n#else\ngl_FragDepth=clamp(depthSM,0.0,1.0); \n#endif\n#elif SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#if SM_ESM==1\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\n#endif\n#if SM_FLOAT==1\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depthSM);\n#endif\nreturn;";li.ShadersStore.shadowMapPixelShader="#include\n#ifdef ALPHATEXTURE\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\n#ifdef ALPHATEXTURE\nfloat alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;\n#ifdef ALPHATESTVALUE\nif (alphaFromAlphaTexture=softTransparentShadowSM*alphaFromAlphaTexture) discard;\n#else\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;\n#endif\n#endif\n#include\n}";li.IncludesShadersStore.sceneVertexDeclaration="uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;\n";li.IncludesShadersStore.meshVertexDeclaration="uniform mat4 world;uniform float visibility;\n";li.IncludesShadersStore.shadowMapVertexDeclaration="#include\n#include\n";li.IncludesShadersStore.shadowMapUboDeclaration="layout(std140,column_major) uniform;\n#include\n#include\n";li.IncludesShadersStore.shadowMapVertexExtraDeclaration="#if SM_NORMALBIAS==1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;varying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nvarying vec3 vPositionWSM;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n";li.IncludesShadersStore.shadowMapVertexNormalBias="#if SM_NORMALBIAS==1\n#if SM_DIRECTIONINLIGHTDATA==1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;vec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);float sinNLSM=sqrt(1.0-ndlSM*ndlSM);float normalBiasSM=biasAndScaleSM.y*sinNLSM;worldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";li.IncludesShadersStore.shadowMapVertexMetric="#if SM_USEDISTANCE==1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE==1\n#ifdef IS_NDC_HALF_ZRANGE\n#define BIASFACTOR 0.5\n#else\n#define BIASFACTOR 1.0\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#else\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#endif\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nzSM=gl_Position.z;gl_Position.z=0.0;\n#elif SM_USEDISTANCE==0\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\nvDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n";li.ShadersStore.shadowMapVertexShader="attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef INSTANCES\nattribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;\n#endif\n#include\n#include<__decl__shadowMapVertex>\n#ifdef ALPHATEXTURE\nvarying vec2 vUV;uniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normWorldSM=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\n#endif\n#endif\n#include\ngl_Position=viewProjection*worldPos;\n#include\n#ifdef ALPHATEXTURE\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}";li.ShadersStore.depthBoxBlurPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 colorDepth=vec4(0.0);for (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));}";li.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow="#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";var dv=function(){function e(t,i,r,n,o){this.onBeforeShadowMapRenderObservable=new f,this.onAfterShadowMapRenderObservable=new f,this.onBeforeShadowMapRenderMeshObservable=new f,this.onAfterShadowMapRenderMeshObservable=new f,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=e.FILTER_NONE,this._filteringQuality=e.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.useOpacityTextureForTransparentShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=V.Zero(),this._viewMatrix=z.Zero(),this._projectionMatrix=z.Zero(),this._transformMatrix=z.Zero(),this._cachedPosition=new V(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new V(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=z.Identity(),this._mapSize=t,this._light=i,this._scene=i.getScene(),this._camera=null!=n?n:null,this._useRedTextureType=!!o;var a=i._shadowGenerators;a||(a=i._shadowGenerators=new Map),a.set(this._camera,this),this.id=i.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "'.concat(this._light.name,'")')))),e._SceneComponentInitialization(this._scene);var s=this._scene.getEngine().getCaps();r?s.textureFloatRender&&s.textureFloatLinearFiltering?this._textureType=u.TEXTURETYPE_FLOAT:s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?this._textureType=u.TEXTURETYPE_HALF_FLOAT:this._textureType=u.TEXTURETYPE_UNSIGNED_INT:s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?this._textureType=u.TEXTURETYPE_HALF_FLOAT:s.textureFloatRender&&s.textureFloatLinearFiltering?this._textureType=u.TEXTURETYPE_FLOAT:this._textureType=u.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(e.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!1,configurable:!0}),e.prototype._validateFilter=function(e){return e},Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){if(t=this._validateFilter(t),this._light.needCube()){if(t===e.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(t===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(t===e.FILTER_PCF||t===e.FILTER_PCSS)return void(this.usePoissonSampling=!0)}t!==e.FILTER_PCF&&t!==e.FILTER_PCSS||this._scene.getEngine()._features.supportShadowSamplers?this._filter!==t&&(this._filter=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"usePoissonSampling",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){var i=this._validateFilter(e.FILTER_POISSONSAMPLING);(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){var i=this._validateFilter(e.FILTER_PCF);(t||this.filter===e.FILTER_PCF)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useContactHardeningShadow",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){var i=this._validateFilter(e.FILTER_PCSS);(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"darkness",{get:function(){return this._darkness},set:function(e){this.setDarkness(e)},enumerable:!1,configurable:!0}),e.prototype.getDarkness=function(){return this._darkness},e.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},Object.defineProperty(e.prototype,"transparencyShadow",{get:function(){return this._transparencyShadow},set:function(e){this.setTransparencyShadow(e)},enumerable:!1,configurable:!0}),e.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},e.prototype.getShadowMap=function(){return this._shadowMap},e.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},e.prototype.getClassName=function(){return e.CLASSNAME},e.prototype.addShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),-1===this._shadowMap.renderList.indexOf(e)&&this._shadowMap.renderList.push(e),t)for(var i=0,r=e.getChildMeshes();i=a.length)return void(e&&e(i));setTimeout(h,16)}};h()}else e&&e(this)}else e&&e(this)}else e&&e(this)},e.prototype.forceCompilationAsync=function(e){var t=this;return new Promise((function(i){t.forceCompilation((function(){i()}),e)}))},e.prototype._isReadyCustomDefines=function(e,t,i){},e.prototype._prepareShadowDefines=function(e,t,i,r){i.push("#define SM_LIGHTTYPE_"+this._light.getClassName().toUpperCase()),i.push("#define SM_FLOAT "+(this._textureType!==u.TEXTURETYPE_UNSIGNED_INT?"1":"0")),i.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),i.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));var n=e.getMesh();return i.push("#define SM_NORMALBIAS "+(this.normalBias&&n.isVerticesDataPresent(Nr.NormalKind)?"1":"0")),i.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===wa.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),i.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),i.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&r?"1":"0")),this._isReadyCustomDefines(i,e,t),i},e.prototype.isReady=function(t,i,r){var n,o=t.getMaterial(),a=null==o?void 0:o.shadowDepthWrapper;if(this._opacityTexture=null,!o)return!1;var s=[];if(this._prepareShadowDefines(t,i,s,r),a){if(!a.isReadyForSubMesh(t,s,this,i,this._scene.getEngine().currentRenderPassId))return!1}else{var l=t._getDrawWrapper(void 0,!0),c=l.effect,u=l.defines,h=[Nr.PositionKind],d=t.getMesh();this.normalBias&&d.isVerticesDataPresent(Nr.NormalKind)&&(h.push(Nr.NormalKind),s.push("#define NORMAL"),d.nonUniformScaling&&s.push("#define NONUNIFORMSCALING"));var p=o.needAlphaTesting();if((p||o.needAlphaBlending())&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=o.opacityTexture:this._opacityTexture=o.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;var f=null!==(n=o.alphaCutOff)&&void 0!==n?n:e.DEFAULT_ALPHA_CUTOFF;s.push("#define ALPHATEXTURE"),p&&s.push("#define ALPHATESTVALUE ".concat(f).concat(f%1==0?".":"")),d.isVerticesDataPresent(Nr.UVKind)&&(h.push(Nr.UVKind),s.push("#define UV1")),d.isVerticesDataPresent(Nr.UV2Kind)&&1===this._opacityTexture.coordinatesIndex&&(h.push(Nr.UV2Kind),s.push("#define UV2"))}var _=new ll;if(d.useBones&&d.computeBonesUsingShaders&&d.skeleton){h.push(Nr.MatricesIndicesKind),h.push(Nr.MatricesWeightsKind),d.numBoneInfluencers>4&&(h.push(Nr.MatricesIndicesExtraKind),h.push(Nr.MatricesWeightsExtraKind));var m=d.skeleton;s.push("#define NUM_BONE_INFLUENCERS "+d.numBoneInfluencers),d.numBoneInfluencers>0&&_.addCPUSkinningFallback(0,d),m.isUsingTextureForMatrices?s.push("#define BONETEXTURE"):s.push("#define BonesPerMesh "+(m.bones.length+1))}else s.push("#define NUM_BONE_INFLUENCERS 0");var g=d.morphTargetManager,v=0;if(g&&(v=g.numMaxInfluencers||g.numInfluencers)>0&&(s.push("#define MORPHTARGETS"),s.push("#define NUM_MORPH_INFLUENCERS "+v),g.isUsingTextureForTargets&&s.push("#define MORPHTARGETS_TEXTURE"),qo(h,d,v)),zo(o,this._scene,s),i&&(s.push("#define INSTANCES"),Jo(h),t.getRenderingMesh().hasThinInstances&&s.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(var y=0,b=this.customShaderOptions.defines;y4&&(c.push(Nr.MatricesIndicesExtraKind),c.push(Nr.MatricesWeightsExtraKind)),l.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),l.push("#define BonesPerMesh "+(n.skeleton?n.skeleton.bones.length+1:0));var u=e.getRenderingMesh().skeleton;(null==u?void 0:u.isUsingTextureForMatrices)&&l.push("#define BONETEXTURE")}else l.push("#define NUM_BONE_INFLUENCERS 0");var h=n.morphTargetManager,d=0;h&&(d=h.numMaxInfluencers||h.numInfluencers)>0&&(l.push("#define MORPHTARGETS"),l.push("#define NUM_MORPH_INFLUENCERS "+d),h.isUsingTextureForTargets&&l.push("#define MORPHTARGETS_TEXTURE"),qo(c,n,d)),s.pointsCloud&&l.push("#define POINTSIZE"),t&&(l.push("#define INSTANCES"),Jo(c),e.getRenderingMesh().hasThinInstances&&l.push("#define THIN_INSTANCES")),this._storeNonLinearDepth&&l.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&l.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&l.push("#define PACKED"),zo(s,o,l);var p=e._getDrawWrapper(void 0,!0),f=p.defines,_=l.join("\n");if(f!==_){var m=["world","mBones","boneTextureWidth","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices"];Go(m),p.setEffect(r.createEffect("depth",c,m,["diffuseSampler","morphTargets","boneSampler"],_,void 0,void 0,void 0,{maxSimultaneousMorphTargets:d}),_)}return p.effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){var e=[];for(var t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(var i=0,r=e;i1||l>1;){s=Math.max(Math.round(s/2),1),l=Math.max(Math.round(l/2),1);var h=new hl("Reduction phase "+c,"minmaxRedux",["texSize"],null,{width:s,height:l},null,u.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define "+(1==s&&1==l?"LAST":1==s||1==l?"ONEBEFORELAST":"MAIN"),i,void 0,void 0,void 0,u.TEXTUREFORMAT_RG);h.autoClear=!1,h.forceFullscreenViewport=r,h.onApply=function(e,t){return function(i){1==e||1==t?i.setInt2("texSize",e,t):i.setFloat2("texSize",e,t)}}(s,l),this._reductionSteps.push(h),c++,1==s&&1==l&&h.onAfterRenderObservable.add(function(e,t,i){var r=new Float32Array(4*e*t),a={min:0,max:0};return function(){o.getEngine()._readTexturePixels(i.inputTexture.texture,e,t,-1,0,r,!1),a.min=r[0],a.max=r[1],n.onAfterReductionPerformed.notifyObservers(a)}}(s,l,h))}}},Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._sourceTexture?this._sourceTexture.refreshRate:-1},set:function(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activated",{get:function(){return this._activated},enumerable:!1,configurable:!0}),e.prototype.activate=function(){var e=this;!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add((function(){var t,i,r=e._camera.getScene().getEngine();null===(t=r._debugPushGroup)||void 0===t||t.call(r,"min max reduction",1),e._reductionSteps[0].activate(e._camera),e._postProcessManager.directRender(e._reductionSteps,e._reductionSteps[0].inputTexture,e._forceFullscreenViewport),r.unBindFramebuffer(e._reductionSteps[0].inputTexture,!1),null===(i=r._debugPopGroup)||void 0===i||i.call(r,1)})),this._activated=!0)},e.prototype.deactivate=function(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)},e.prototype.dispose=function(e){if(void 0===e&&(e=!0),e&&(this.onAfterReductionPerformed.clear(),this._onContextRestoredObserver&&(this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)),this.deactivate(),this._reductionSteps){for(var t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,"minDistance",{get:function(){return this._minDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e=0&&et.maxZ&&0!==t.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthClamp",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cascadeBlendPercentage",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lambda",{get:function(){return this._lambda},set:function(e){var t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)},enumerable:!1,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e=0&&e=0&&e=r&&(i=0,r=1),i==t._minDistance&&r==t._maxDistance||t.setMinMaxDistance(i,r)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,t,i;return null!==(i=null===(t=null===(e=this._depthReducer)||void 0===e?void 0:e.depthRenderer)||void 0===t?void 0:t.getDepthMap().refreshRate)&&void 0!==i?i:-1},set:function(e){var t;(null===(t=this._depthReducer)||void 0===t?void 0:t.depthRenderer)&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!1,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._getCamera();if(e){for(var t=e.minZ,i=e.maxZ||this._shadowMaxZ,r=i-t,n=this._minDistance,o=t+n*r,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance)*r,s=a-o,l=a/o,c=0;cMath.PI;)n-=2*Math.PI;var a=n/Math.PI,s=o/Math.PI;a=.5*a+.5;var l=Math.round(a*i);l<0?l=0:l>=i&&(l=i-1);var c=Math.round(s*r);c<0?c=0:c>=r&&(c=r-1);var u=r-c-1;return{r:t[u*i*3+3*l+0],g:t[u*i*3+3*l+1],b:t[u*i*3+3*l+2]}},e.FACE_LEFT=[new V(-1,-1,-1),new V(1,-1,-1),new V(-1,1,-1),new V(1,1,-1)],e.FACE_RIGHT=[new V(1,-1,1),new V(-1,-1,1),new V(1,1,1),new V(-1,1,1)],e.FACE_FRONT=[new V(1,-1,-1),new V(1,-1,1),new V(1,1,-1),new V(1,1,1)],e.FACE_BACK=[new V(-1,-1,1),new V(-1,-1,-1),new V(-1,1,1),new V(-1,1,-1)],e.FACE_DOWN=[new V(1,1,-1),new V(1,1,1),new V(-1,1,-1),new V(-1,1,1)],e.FACE_UP=[new V(-1,-1,-1),new V(-1,-1,1),new V(1,-1,-1),new V(1,-1,1)],e}(),Cv=function(){function e(){}return e._Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},e._Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this._Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e._ReadStringLine=function(e,t){for(var i="",r="",n=t;n32767)throw"HDR Bad header format, unsupported size";return{height:t,width:i,dataPosition:a+=r.length+1}},e.GetCubeMapTextureData=function(e,t,i){void 0===i&&(i=!1);var r=new Uint8Array(e),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels(r,n);return Av.ConvertPanoramaToCubemap(o,n.width,n.height,t,i)},e.RGBE_ReadPixels=function(e,t){return this._RGBEReadPixelsRLE(e,t)},e._RGBEReadPixelsRLE=function(e,t){for(var i,r,n,o,a,s=t.height,l=t.width,c=t.dataPosition,u=0,h=0,d=0,p=new ArrayBuffer(4*l),f=new Uint8Array(p),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);s>0;){if(i=e[c++],r=e[c++],n=e[c++],o=e[c++],2!=i||2!=r||128&n||t.width<8||t.width>32767)return this._RGBEReadPixelsNOTRLE(e,t);if((n<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(u=0,d=0;d<4;d++)for(h=(d+1)*l;u128){if(0==(a=i-128)||a>h-u)throw"HDR Bad Format, bad scanline data (run)";for(;a-- >0;)f[u++]=r}else{if(0==(a=i)||a>h-u)throw"HDR Bad Format, bad scanline data (non-run)";if(f[u++]=r,--a>0)for(var g=0;g0;){for(a=0;a255){var g=255/m;p*=g,f*=g,_*=g}s[3*d+0]=p,s[3*d+1]=f,s[3*d+2]=_}l?a.push(l):s?a.push(s):a.push(h)}return a}),null,this._onLoad,this._onError)},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e},t.prototype.delayLoad=function(){this.delayLoadState===u.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=u.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this._loadTexture())},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var t,i=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&(null===(t=this.getScene())||void 0===t||t.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(i)})))},t.prototype.dispose=function(){this.onLoadObservable.clear(),e.prototype.dispose.call(this)},t.Parse=function(e,i,r){var n=null;return e.name&&!e.isRenderTarget&&((n=new t(r+e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,n.hasAlpha=e.hasAlpha,n.level=e.level,n.coordinatesMode=e.coordinatesMode,n.isBlocking=e.isBlocking),n&&(e.boundingBoxPosition&&(n.boundingBoxPosition=V.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(n.boundingBoxSize=V.FromArray(e.boundingBoxSize)),e.rotationY&&(n.rotationY=e.rotationY)),n},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this.gammaSpace,e.generateHarmonics=this._generateHarmonics,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e.rotationY=this._rotationY,e},t._FacesMapping=["right","left","up","down","front","back"],t}(Ya);a("BABYLON.HDRCubeTexture",Pv);var Iv=function(){function e(e,t,i){void 0===t&&(t=0),void 0===i&&(i=null),this.name=e,this.animations=[],this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new f,this._onDataLayoutChanged=new f,this._animationPropertiesOverride=null,this._scene=i||M.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(e.prototype,"influence",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasUVs",{get:function(){return!!this._uvs},enumerable:!1,configurable:!0}),e.prototype.setPositions=function(e){var t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getPositions=function(){return this._positions},e.prototype.setNormals=function(e){var t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getNormals=function(){return this._normals},e.prototype.setTangents=function(e){var t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getTangents=function(){return this._tangents},e.prototype.setUVs=function(e){var t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getUVs=function(){return this._uvs},e.prototype.clone=function(){var t=this,i=Ke.Clone((function(){return new e(t.name,t.influence,t._scene)}),this);return i._positions=this._positions,i._normals=this._normals,i._tangents=this._tangents,i._uvs=this._uvs,i},e.prototype.serialize=function(){var e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),null!=this.id&&(e.id=this.id),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),Ke.AppendSerializedAnimations(this,e),e},e.prototype.getClassName=function(){return"MorphTarget"},e.Parse=function(t,i){var r=new e(t.name,t.influence);if(r.setPositions(t.positions),null!=t.id&&(r.id=t.id),t.normals&&r.setNormals(t.normals),t.tangents&&r.setTangents(t.tangents),t.uvs&&r.setUVs(t.uvs),t.animations){for(var n=0;n0&&t.texture2DArrayMaxLayerCount>1}}return Object.defineProperty(e.prototype,"areUpdatesFrozen",{get:function(){return this._blockCounter>0},set:function(e){e?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(!0)))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numMaxInfluencers",{get:function(){return this._numMaxInfluencers},set:function(e){this._numMaxInfluencers!==e&&(this._numMaxInfluencers=e,this._syncActiveTargets(!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertexCount",{get:function(){return this._vertexCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsNormals",{get:function(){return this._supportsNormals&&this.enableNormalMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsTangents",{get:function(){return this._supportsTangents&&this.enableTangentMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsUVs",{get:function(){return this._supportsUVs&&this.enableUVMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numTargets",{get:function(){return this._targets.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numInfluencers",{get:function(){return this._activeTargets.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"influences",{get:function(){return this._influences},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useTextureToStoreTargets",{get:function(){return this._useTextureToStoreTargets},set:function(e){this._useTextureToStoreTargets=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForTargets",{get:function(){var t;return e.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets&&!(null===(t=this._scene)||void 0===t?void 0:t.getEngine().getCaps().disableMorphTargetTexture)},enumerable:!1,configurable:!0}),e.prototype.getActiveTarget=function(e){return this._activeTargets.data[e]},e.prototype.getTarget=function(e){return this._targets[e]},e.prototype.addTarget=function(e){var t=this;this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add((function(e){t._syncActiveTargets(e)}))),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add((function(){t._syncActiveTargets(!0)}))),this._syncActiveTargets(!0)},e.prototype.removeTarget=function(e){var t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0)),this._scene&&this._scene.stopAnimation(e)},e.prototype._bind=function(e){e.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),e.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),e.setTexture("morphTargets",this._targetStoreTexture),e.setInt("morphTargetCount",this.numInfluencers)},e.prototype.clone=function(){for(var t=new e(this._scene),i=0,r=this._targets;ithis._scene.getEngine().getCaps().texture2DArrayMaxLayerCount&&(this.useTextureToStoreTargets=!1),this._morphTargetTextureIndices&&this._morphTargetTextureIndices.length===this._targets.length||(this._morphTargetTextureIndices=new Float32Array(this._targets.length));for(var r=-1,n=0,o=this._targets;n=e.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(a),this._morphTargetTextureIndices[i]=r,this._tempInfluences[i++]=a.influence,this._supportsNormals=this._supportsNormals&&a.hasNormals,this._supportsTangents=this._supportsTangents&&a.hasTangents,this._supportsUVs=this._supportsUVs&&a.hasUVs;var s=a.getPositions();if(s){var l=s.length/3;if(0===this._vertexCount)this._vertexCount=l;else if(this._vertexCount!==l)return void ae.Error("Incompatible target. Targets must all have the same vertices count.")}}}this._morphTargetTextureIndices.length!==i&&(this._morphTargetTextureIndices=this._morphTargetTextureIndices.slice(0,i)),this._influences&&this._influences.length===i||(this._influences=new Float32Array(i));for(var c=0;c0)){this._textureVertexStride=1,this._supportsNormals&&this._textureVertexStride++,this._supportsTangents&&this._textureVertexStride++,this._supportsUVs&&this._textureVertexStride++,this._textureWidth=this._vertexCount*this._textureVertexStride||1,this._textureHeight=1;var e=this._scene.getEngine().getCaps().maxTextureSize;this._textureWidth>e&&(this._textureHeight=Math.ceil(this._textureWidth/e),this._textureWidth=e);var t=!0;if(this._targetStoreTexture){var i=this._targetStoreTexture.getSize();i.width===this._textureWidth&&i.height===this._textureHeight&&this._targetStoreTexture.depth===this._targets.length&&(t=!1)}if(t){this._targetStoreTexture&&this._targetStoreTexture.dispose();for(var r=this._targets.length,n=new Float32Array(r*this._textureWidth*this._textureHeight*4),o=0,a=0;a-1&&this._parentContainer.morphTargetManagers.splice(e,1),this._parentContainer=null}for(var t=0,i=this._targets;t-1&&this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e)},e.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},e.prototype.removeJoint=function(e,t,i){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},e.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},e.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},e.prototype.getImpostors=function(){return this._impostors},e.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t0&&(this._physicsBodiesToRemoveAfterStep.forEach((function(t){"function"==typeof e.world.removeBody?e.world.removeBody(t):e.world.remove(t)})),this._physicsBodiesToRemoveAfterStep.length=0)},e.prototype.applyImpulse=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},e.prototype.applyForce=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(n,r)},e.prototype.generatePhysicsBody=function(e){if(this._removeMarkedPhysicsBodiesFromWorld(),e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var t=this._createShape(e);if(!t)return void ae.Warn("It was not possible to create a physics body for this object.");var i=e.physicsBody;i&&this.removePhysicsBody(e);var r=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),n={mass:e.getParam("mass"),material:r},o=e.getParam("nativeOptions");for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(n[a]=o[a]);e.physicsBody=new this.BJSCANNON.Body(n),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),"function"==typeof this.world.addBody?this.world.addBody(e.physicsBody):this.world.add(e.physicsBody),i&&["force","torque","velocity","angularVelocity"].forEach((function(t){var r=i[t];e.physicsBody[t].set(r.x,r.y,r.z)})),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,i=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],r=e.object.rotationQuaternion;if(r?r.conjugateToRef(this._tmpQuaternion):this._tmpQuaternion.set(0,0,0,1),i.length){var n=function(i){if(i.rotationQuaternion){var r=i.getPhysicsImpostor();if(r&&r.parent!==e&&i.parent){var o=i.getAbsolutePosition().subtract(i.parent.getAbsolutePosition()),a=i.rotationQuaternion.multiply(t._tmpQuaternion);r.physicsBody&&(t.removePhysicsBody(r),r.physicsBody=null),r.parent=e,r.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(r),new t.BJSCANNON.Vec3(o.x,o.y,o.z),new t.BJSCANNON.Quaternion(a.x,a.y,a.z,a.w)),e.physicsBody.mass+=r.getParam("mass")}i.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(n)}};i.filter((function(e){return!!e.physicsImpostor})).forEach(n)}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),-1===this._physicsBodiesToRemoveAfterStep.indexOf(e.physicsBody)&&this._physicsBodiesToRemoveAfterStep.push(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var r,n=e.joint.jointData,o={pivotA:n.mainPivot?(new this.BJSCANNON.Vec3).set(n.mainPivot.x,n.mainPivot.y,n.mainPivot.z):null,pivotB:n.connectedPivot?(new this.BJSCANNON.Vec3).set(n.connectedPivot.x,n.connectedPivot.y,n.connectedPivot.z):null,axisA:n.mainAxis?(new this.BJSCANNON.Vec3).set(n.mainAxis.x,n.mainAxis.y,n.mainAxis.z):null,axisB:n.connectedAxis?(new this.BJSCANNON.Vec3).set(n.connectedAxis.x,n.connectedAxis.y,n.connectedAxis.z):null,maxForce:n.nativeParams.maxForce,collideConnected:!!n.collision};switch(e.joint.type){case Cs.HingeJoint:case Cs.Hinge2Joint:r=new this.BJSCANNON.HingeConstraint(t,i,o);break;case Cs.DistanceJoint:r=new this.BJSCANNON.DistanceConstraint(t,i,n.maxDistance||2);break;case Cs.SpringJoint:var a=n;r=new this.BJSCANNON.Spring(t,i,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case Cs.LockJoint:r=new this.BJSCANNON.LockConstraint(t,i,o);break;case Cs.PointToPointJoint:case Cs.BallAndSocketJoint:default:r=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)}r.collideConnected=!!n.collision,e.joint.physicsJoint=r,e.joint.type!==Cs.SpringJoint?this.world.addConstraint(r):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){r.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==Cs.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,i){var r,n;for(r=0;r1e3*i));s++);this.time+=r;for(var l=this.time%i/i,c=e,u=this.bodies,h=0;h!==u.length;h++){var d=u[h];d.type!==t.Body.STATIC&&d.sleepState!==t.Body.SLEEPING?(d.position.vsub(d.previousPosition,c),c.scale(l,c),d.position.vadd(c,d.interpolatedPosition)):(d.interpolatedPosition.set(d.position.x,d.position.y,d.position.z),d.interpolatedQuaternion.set(d.quaternion.x,d.quaternion.y,d.quaternion.z,d.quaternion.w))}}}},e.prototype.raycast=function(e,t){return this._raycastResult.reset(e,t),this.raycastToRef(e,t,this._raycastResult),this._raycastResult},e.prototype.raycastToRef=function(e,t,i){this._cannonRaycastResult.reset(),this.world.raycastClosest(e,t,{},this._cannonRaycastResult),i.reset(e,t),this._cannonRaycastResult.hasHit&&(i.setHitData({x:this._cannonRaycastResult.hitNormalWorld.x,y:this._cannonRaycastResult.hitNormalWorld.y,z:this._cannonRaycastResult.hitNormalWorld.z},{x:this._cannonRaycastResult.hitPointWorld.x,y:this._cannonRaycastResult.hitPointWorld.y,z:this._cannonRaycastResult.hitPointWorld.z}),i.setHitDistance(this._cannonRaycastResult.distance))},e}();Fv.DefaultPluginFactory=function(){return new Lv};var wv=function(){function e(e,t,i){void 0===e&&(e=!0),void 0===i&&(i=OIMO),this._useDeltaForWorldStep=e,this.name="OimoJSPlugin",this._fixedTimeStep=1/60,this._tmpImpostorsArray=[],this._tmpPositionVector=V.Zero(),this.BJSOIMO=i,this.world=new this.BJSOIMO.World({iterations:t}),this.world.clear(),this._raycastResult=new Nv}return e.prototype.getPluginVersion=function(){return 1},e.prototype.setGravity=function(e){this.world.gravity.set(e.x,e.y,e.z)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var i=this;t.forEach((function(e){e.beforeStep()})),this.world.timeStep=this._useDeltaForWorldStep?e:this._fixedTimeStep,this.world.step(),t.forEach((function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e}));for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var n=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];n&&o?(n.onCollide({body:o.physicsBody,point:null,distance:0,impulse:0,normal:null}),o.onCollide({body:n.physicsBody,point:null,distance:0,impulse:0,normal:null}),r=r.next):r=r.next}else r=r.next},e.prototype.applyImpulse=function(e,t,i){var r=e.physicsBody.mass;e.physicsBody.applyImpulse(i.scale(this.world.invScale),t.scale(this.world.invScale*r))},e.prototype.applyForce=function(e,t,i){ae.Warn("Oimo doesn't support applying force. Using impulse instead."),this.applyImpulse(e,t,i)},e.prototype.generatePhysicsBody=function(e){var t=this;if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var i={name:e.uniqueId,config:[e.getParam("mass")||.001,e.getParam("friction"),e.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==e.getParam("mass"),density:e.getParam("mass"),friction:e.getParam("friction"),restitution:e.getParam("restitution"),world:this.world},r=[e];(a=e.object).getChildMeshes&&a.getChildMeshes().forEach((function(e){e.physicsImpostor&&r.push(e.physicsImpostor)}));var n=function(e){return Math.max(e,A)},o=new G;r.forEach((function(r){if(r.object.rotationQuaternion){var a=r.object.rotationQuaternion;o.copyFrom(a),r.object.rotationQuaternion.set(0,0,0,1),r.object.computeWorldMatrix(!0);var s=o.toEulerAngles(),l=r.getObjectExtents(),c=57.29577951308232;if(r===e){var u=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(u,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),i.pos.push(u.x),i.pos.push(u.y),i.pos.push(u.z),i.posShape.push(0,0,0),i.rotShape.push(0,0,0)}else{var h=r.object.position.clone();i.posShape.push(h.x),i.posShape.push(h.y),i.posShape.push(h.z),i.rotShape.push(s.x*c,s.y*c,s.z*c)}switch(r.object.rotationQuaternion.copyFrom(o),r.type){case Ds.ParticleImpostor:ae.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case Ds.SphereImpostor:var d=l.x,p=l.y,f=l.z,_=Math.max(n(d),n(p),n(f))/2;i.type.push("sphere"),i.size.push(_),i.size.push(_),i.size.push(_);break;case Ds.CylinderImpostor:var m=n(l.x)/2,g=n(l.y);i.type.push("cylinder"),i.size.push(m),i.size.push(g),i.size.push(g);break;case Ds.PlaneImpostor:case Ds.BoxImpostor:default:m=n(l.x),g=n(l.y);var v=n(l.z);i.type.push("box"),i.size.push(m),i.size.push(g),i.size.push(v)}r.object.rotationQuaternion=a}})),e.physicsBody=this.world.add(i),e.physicsBody.resetQuaternion(o),e.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var a;e.setDeltaPosition(this._tmpPositionVector)}},e.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var r,n=e.joint.jointData,o=n.nativeParams||{},a={body1:t,body2:i,axe1:o.axe1||(n.mainAxis?n.mainAxis.asArray():null),axe2:o.axe2||(n.connectedAxis?n.connectedAxis.asArray():null),pos1:o.pos1||(n.mainPivot?n.mainPivot.asArray():null),pos2:o.pos2||(n.connectedPivot?n.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||n.collision,spring:o.spring,world:this.world};switch(e.joint.type){case Cs.BallAndSocketJoint:r="jointBall";break;case Cs.SpringJoint:ae.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var s=n;a.min=s.length||a.min,a.max=Math.max(a.min,a.max);case Cs.DistanceJoint:r="jointDistance",a.max=n.maxDistance;break;case Cs.PrismaticJoint:r="jointPrisme";break;case Cs.SliderJoint:r="jointSlide";break;case Cs.WheelJoint:r="jointWheel";break;case Cs.HingeJoint:default:r="jointHinge"}a.type=r,e.joint.physicsJoint=this.world.add(a)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){ae.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){for(var t=e.physicsBody.shapes;t.next;)t=t.next;e.object.position.set(t.position.x,t.position.y,t.position.z)}else{var i=e.physicsBody.getPosition();e.object.position.set(i.x,i.y,i.z)}if(e.object.rotationQuaternion){var r=e.physicsBody.getQuaternion();e.object.rotationQuaternion.set(r.x,r.y,r.z,r.w)}}},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody;e.physicsBody.shapes.next||(r.position.set(t.x,t.y,t.z),r.orientation.set(i.x,i.y,i.z,i.w),r.syncShapes(),r.awake())},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.set(t.x,t.y,t.z)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.set(t.x,t.y,t.z)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new V(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new V(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},e.prototype.getBodyMass=function(e){return e.physicsBody.shapes.density},e.prototype.getBodyFriction=function(e){return e.physicsBody.shapes.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.shapes.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.shapes.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.shapes.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.awake()},e.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotor.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotor.lowerLimit=i)},e.prototype.setMotor=function(e,t,i,r){void 0!==i?ae.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter"):i=1e6,t*=-1;var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setMotor(t,i)},e.prototype.setLimit=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setLimit(t,void 0===i?-t:i)},e.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.orientation.x,e.rotationQuaternion.y=i.orientation.y,e.rotationQuaternion.z=i.orientation.z,e.rotationQuaternion.w=i.orientation.w)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes;t.x=2*i.halfWidth,t.y=2*i.halfHeight,t.z=2*i.halfDepth},e.prototype.dispose=function(){this.world.clear()},e.prototype.raycast=function(e,t){return ae.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(e,t),this._raycastResult},e.prototype.raycastToRef=function(e,t,i){ae.Warn("raycast is not currently supported by the Oimo physics plugin"),i.reset(e,t)},e}(),Bv=function(){function e(e,t,i){void 0===e&&(e=!0),void 0===t&&(t=Ammo),void 0===i&&(i=null);var r=this;this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new G,this._tmpContactCallbackResult=!1,this._tmpContactPoint=new V,this._tmpContactNormal=new V,this._tmpVec3=new V,this._tmpMatrix=new z,"function"!=typeof t?(this.bjsAMMO=t,this.isSupported()?(this._collisionConfiguration=new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,this._dispatcher=new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),this._overlappingPairCache=i||new this.bjsAMMO.btDbvtBroadphase,this._solver=new this.bjsAMMO.btSequentialImpulseConstraintSolver,this._softBodySolver=new this.bjsAMMO.btDefaultSoftBodySolver,this.world=new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration,this._softBodySolver),this._tmpAmmoConcreteContactResultCallback=new this.bjsAMMO.ConcreteContactResultCallback,this._tmpAmmoConcreteContactResultCallback.addSingleResult=function(e){var t=(e=r.bjsAMMO.wrapPointer(e,r.bjsAMMO.btManifoldPoint)).getPositionWorldOnA(),i=e.m_normalWorldOnB;r._tmpContactPoint.x=t.x(),r._tmpContactPoint.y=t.y(),r._tmpContactPoint.z=t.z(),r._tmpContactNormal.x=i.x(),r._tmpContactNormal.y=i.y(),r._tmpContactNormal.z=i.z(),r._tmpContactImpulse=e.getAppliedImpulse(),r._tmpContactDistance=e.getDistance(),r._tmpContactCallbackResult=!0},this._raycastResult=new Nv,this._tmpAmmoTransform=new this.bjsAMMO.btTransform,this._tmpAmmoTransform.setIdentity(),this._tmpAmmoQuaternion=new this.bjsAMMO.btQuaternion(0,0,0,1),this._tmpAmmoVectorA=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorB=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorC=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorD=new this.bjsAMMO.btVector3(0,0,0)):ae.Error("AmmoJS is not available. Please make sure you included the js file.")):ae.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.")}return e.prototype.getPluginVersion=function(){return 1},e.prototype.setGravity=function(e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),this.world.setGravity(this._tmpAmmoVectorA),this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)},e.prototype.setTimeStep=function(e){this._timeStep=e},e.prototype.setFixedTimeStep=function(e){this._fixedTimeStep=e},e.prototype.setMaxSteps=function(e){this._maxSteps=e},e.prototype.getTimeStep=function(){return this._timeStep},e.prototype._isImpostorInContact=function(e){return this._tmpContactCallbackResult=!1,this.world.contactTest(e.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._isImpostorPairInContact=function(e,t){return this._tmpContactCallbackResult=!1,this.world.contactPairTest(e.physicsBody,t.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._stepSimulation=function(e,t,i){if(void 0===e&&(e=1/60),void 0===t&&(t=10),void 0===i&&(i=1/60),0==t)this.world.stepSimulation(e,0);else for(;t>0&&e>0;)e-i0&&this._isImpostorInContact(s))for(var l=0,c=s._onPhysicsCollideCallbacks;l3?3:s;var l=(new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,i-1,s);return l.get_m_cfg().set_collisions(17),l},e.prototype._createCustom=function(e){var t=null;return this.onCreateCustomShape&&(t=this.onCreateCustomShape(e)),null==t&&(t=new this.bjsAMMO.btCompoundShape),t},e.prototype._addHullVerts=function(e,t,i){var r=this,n=0;if(i&&i.getIndices&&i.getWorldMatrix&&i.getChildMeshes){var o=i.getIndices();o||(o=[]);var a=i.getVerticesData(Nr.PositionKind);a||(a=[]),i.computeWorldMatrix(!1);for(var s=o.length/3,l=0;l0){if(e.type!=Ds.NoImpostor){var l=this._createShape(e,!0);l&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),r.addChildShape(this._tmpAmmoTransform,l))}return r}this.bjsAMMO.destroy(r),r=null}switch(e.type){case Ds.SphereImpostor:if(j.WithinEpsilon(o.x,o.y,1e-4)&&j.WithinEpsilon(o.x,o.z,1e-4))r=new this.bjsAMMO.btSphereShape(o.x/2);else{this._tmpAmmoVectorA.setValue(0,0,0);var c=[this._tmpAmmoVectorA];r=new this.bjsAMMO.btMultiSphereShape(c,[1],1),this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r.setLocalScaling(this._tmpAmmoVectorA)}break;case Ds.CapsuleImpostor:var u=o.x/2;r=new this.bjsAMMO.btCapsuleShape(u,o.y-2*u);break;case Ds.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case Ds.PlaneImpostor:case Ds.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case Ds.MeshImpostor:if(0==e.getParam("mass")){if(this.onCreateCustomMeshImpostor)r=this.onCreateCustomMeshImpostor(e);else{var h=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(h);var d=this._addMeshVerts(h,n,n);r=0==d?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(h)}break}case Ds.ConvexHullImpostor:if(this.onCreateCustomConvexHullImpostor)r=this.onCreateCustomConvexHullImpostor(e);else{var p=new this.bjsAMMO.btConvexHullShape;0==(d=this._addHullVerts(p,n,n))?(e._pluginData.toDispose.push(p),r=new this.bjsAMMO.btCompoundShape):r=p}break;case Ds.NoImpostor:r=new this.bjsAMMO.btSphereShape(o.x/2);break;case Ds.CustomImpostor:r=this._createCustom(e);break;case Ds.SoftbodyImpostor:r=this._createSoftbody(e);break;case Ds.ClothImpostor:r=this._createCloth(e);break;case Ds.RopeImpostor:r=this._createRope(e);break;default:ae.Warn("The impostor type is not currently supported by the ammo plugin.")}return r},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.object.position.set(this._tmpAmmoTransform.getOrigin().x(),this._tmpAmmoTransform.getOrigin().y(),this._tmpAmmoTransform.getOrigin().z()),e.object.rotationQuaternion?e.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()):e.object.rotation&&(this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()),this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody.getWorldTransform();if(Math.abs(r.getOrigin().x()-t.x)>A||Math.abs(r.getOrigin().y()-t.y)>A||Math.abs(r.getOrigin().z()-t.z)>A||Math.abs(r.getRotation().x()-i.x)>A||Math.abs(r.getRotation().y()-i.y)>A||Math.abs(r.getRotation().z()-i.z)>A||Math.abs(r.getRotation().w()-i.w)>A)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),r.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(i.x,i.y,i.z,i.w),r.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(r),0==e.mass){var n=e.physicsBody.getMotionState();n&&n.setWorldTransform(r)}else e.physicsBody.activate()},e.prototype.isSupported=function(){return void 0!==this.bjsAMMO},e.prototype.setLinearVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.linearVelocity(this._tmpAmmoVectorA):e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)},e.prototype.setAngularVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.angularVelocity(this._tmpAmmoVectorA):e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)},e.prototype.getLinearVelocity=function(e){var t;if(!(t=e.soft?e.physicsBody.linearVelocity():e.physicsBody.getLinearVelocity()))return null;var i=new V(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},e.prototype.getAngularVelocity=function(e){var t;if(!(t=e.soft?e.physicsBody.angularVelocity():e.physicsBody.getAngularVelocity()))return null;var i=new V(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},e.prototype.setBodyMass=function(e,t){e.soft?e.physicsBody.setTotalMass(t,!1):e.physicsBody.setMassProps(t),e._pluginData.mass=t},e.prototype.getBodyMass=function(e){return e._pluginData.mass||0},e.prototype.getBodyFriction=function(e){return e._pluginData.friction||0},e.prototype.setBodyFriction=function(e,t){e.soft?e.physicsBody.get_m_cfg().set_kDF(t):e.physicsBody.setFriction(t),e._pluginData.friction=t},e.prototype.getBodyRestitution=function(e){return e._pluginData.restitution||0},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.setRestitution(t),e._pluginData.restitution=t},e.prototype.getBodyPressure=function(e){return e.soft?e._pluginData.pressure||0:(ae.Warn("Pressure is not a property of a rigid body"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===Ds.SoftbodyImpostor?(e.physicsBody.get_m_cfg().set_kPR(t),e._pluginData.pressure=t):(e.physicsBody.get_m_cfg().set_kPR(0),e._pluginData.pressure=0):ae.Warn("Pressure can only be applied to a softbody")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:(ae.Warn("Stiffness is not a property of a rigid body"),0)},e.prototype.setBodyStiffness=function(e,t){e.soft?(t=(t=t<0?0:t)>1?1:t,e.physicsBody.get_m_materials().at(0).set_m_kLST(t),e._pluginData.stiffness=t):ae.Warn("Stiffness cannot be applied to a rigid body")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:(ae.Warn("Velocity iterations is not a property of a rigid body"),0)},e.prototype.setBodyVelocityIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_viterations(t),e._pluginData.velocityIterations=t):ae.Warn("Velocity iterations cannot be applied to a rigid body")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:(ae.Warn("Position iterations is not a property of a rigid body"),0)},e.prototype.setBodyPositionIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_piterations(t),e._pluginData.positionIterations=t):ae.Warn("Position iterations cannot be applied to a rigid body")},e.prototype.appendAnchor=function(e,t,i,r,n,o){void 0===n&&(n=1),void 0===o&&(o=!1);var a=e.segments,s=Math.round((a-1)*i)+a*(a-1-Math.round((a-1)*r));e.physicsBody.appendAnchor(s,t.physicsBody,o,n)},e.prototype.appendHook=function(e,t,i,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);var o=Math.round(e.segments*i);e.physicsBody.appendAnchor(o,t.physicsBody,n,r)},e.prototype.sleepBody=function(e){e.physicsBody.forceActivationState(0)},e.prototype.wakeUpBody=function(e){e.physicsBody.activate()},e.prototype.updateDistanceJoint=function(){ae.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},e.prototype.setMotor=function(e,t,i){e.physicsJoint.enableAngularMotor(!0,t,i)},e.prototype.setLimit=function(){ae.Warn("setLimit is not currently supported by the Ammo physics plugin")},e.prototype.syncMeshWithImpostor=function(e,t){t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.position.x=this._tmpAmmoTransform.getOrigin().x(),e.position.y=this._tmpAmmoTransform.getOrigin().y(),e.position.z=this._tmpAmmoTransform.getOrigin().z(),e.rotationQuaternion&&(e.rotationQuaternion.x=this._tmpAmmoTransform.getRotation().x(),e.rotationQuaternion.y=this._tmpAmmoTransform.getRotation().y(),e.rotationQuaternion.z=this._tmpAmmoTransform.getRotation().z(),e.rotationQuaternion.w=this._tmpAmmoTransform.getRotation().w())},e.prototype.getRadius=function(e){return e.getObjectExtents().x/2},e.prototype.getBoxSizeToRef=function(e,t){var i=e.getObjectExtents();t.x=i.x,t.y=i.y,t.z=i.z},e.prototype.dispose=function(){this.bjsAMMO.destroy(this.world),this.bjsAMMO.destroy(this._softBodySolver),this.bjsAMMO.destroy(this._solver),this.bjsAMMO.destroy(this._overlappingPairCache),this.bjsAMMO.destroy(this._dispatcher),this.bjsAMMO.destroy(this._collisionConfiguration),this.bjsAMMO.destroy(this._tmpAmmoVectorA),this.bjsAMMO.destroy(this._tmpAmmoVectorB),this.bjsAMMO.destroy(this._tmpAmmoVectorC),this.bjsAMMO.destroy(this._tmpAmmoVectorD),this.bjsAMMO.destroy(this._tmpAmmoTransform),this.bjsAMMO.destroy(this._tmpAmmoQuaternion),this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),this.world=null},e.prototype.raycast=function(e,t){return this.raycastToRef(e,t,this._raycastResult),this._raycastResult},e.prototype.raycastToRef=function(e,t,i){this._tmpAmmoVectorRCA=new this.bjsAMMO.btVector3(e.x,e.y,e.z),this._tmpAmmoVectorRCB=new this.bjsAMMO.btVector3(t.x,t.y,t.z);var r=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,r),i.reset(e,t),r.hasHit()&&(i.setHitData({x:r.get_m_hitNormalWorld().x(),y:r.get_m_hitNormalWorld().y(),z:r.get_m_hitNormalWorld().z()},{x:r.get_m_hitPointWorld().x(),y:r.get_m_hitPointWorld().y(),z:r.get_m_hitPointWorld().z()}),i.calculateHitDistance()),this.bjsAMMO.destroy(r),this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),this.bjsAMMO.destroy(this._tmpAmmoVectorRCB)},e._DISABLE_COLLISION_FLAG=4,e._KINEMATIC_FLAG=2,e._DISABLE_DEACTIVATION_FLAG=4,e}();c.prototype.removeReflectionProbe=function(e){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(e);return-1!==t&&this.reflectionProbes.splice(t,1),t},c.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var Uv=function(){function e(e,t,i,r,n,o){void 0===r&&(r=!0),void 0===n&&(n=!1),void 0===o&&(o=!1);var a=this;if(this.name=e,this._viewMatrix=z.Identity(),this._target=V.Zero(),this._add=V.Zero(),this._invertYAxis=!1,this.position=V.Zero(),this.metadata=null,this._parentContainer=null,this._scene=i,i.getEngine().supportsUniformBuffers){this._sceneUBOs=[];for(var s=0;s<6;++s)this._sceneUBOs.push(i.createSceneUniformBuffer('Scene for Reflection Probe (name "'.concat(e,'") face #').concat(s)))}this._scene.reflectionProbes||(this._scene.reflectionProbes=[]),this._scene.reflectionProbes.push(this);var l=u.TEXTURETYPE_UNSIGNED_BYTE;if(n){var c=this._scene.getEngine().getCaps();c.textureHalfFloatRender?l=u.TEXTURETYPE_HALF_FLOAT:c.textureFloatRender&&(l=u.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new Pl(e,t,i,r,!0,l,!0),this._renderTargetTexture.gammaSpace=!o,this._renderTargetTexture.invertZ=i.useRightHandedSystem;var h,d=i.getEngine().useReverseDepthBuffer;this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(a._sceneUBOs&&(i.setSceneUniformBuffer(a._sceneUBOs[e]),i.getSceneUniformBuffer().unbindEffect()),e){case 0:a._add.copyFromFloats(1,0,0);break;case 1:a._add.copyFromFloats(-1,0,0);break;case 2:a._add.copyFromFloats(0,a._invertYAxis?1:-1,0);break;case 3:a._add.copyFromFloats(0,a._invertYAxis?-1:1,0);break;case 4:a._add.copyFromFloats(0,0,i.useRightHandedSystem?-1:1);break;case 5:a._add.copyFromFloats(0,0,i.useRightHandedSystem?1:-1)}a._attachedMesh&&a.position.copyFrom(a._attachedMesh.getAbsolutePosition()),a.position.addToRef(a._add,a._target);var t=i.useRightHandedSystem?z.LookAtRHToRef:z.LookAtLHToRef,r=i.useRightHandedSystem?z.PerspectiveFovRH:z.PerspectiveFovLH;t(a.position,a._target,V.Up(),a._viewMatrix),i.activeCamera&&(a._projectionMatrix=r(Math.PI/2,1,d?i.activeCamera.maxZ:i.activeCamera.minZ,d?i.activeCamera.minZ:i.activeCamera.maxZ,a._scene.getEngine().isNDCHalfZRange),i.setTransformMatrix(a._viewMatrix,a._projectionMatrix),i.activeCamera.isRigCamera&&!a._renderTargetTexture.activeCamera&&(a._renderTargetTexture.activeCamera=i.activeCamera.rigParent||null)),i._forcedViewPosition=a.position})),this._renderTargetTexture.onBeforeBindObservable.add((function(){var t,r;a._currentSceneUBO=i.getSceneUniformBuffer(),null===(r=(t=i.getEngine())._debugPushGroup)||void 0===r||r.call(t,"reflection probe generation for ".concat(e),1),h=a._scene.imageProcessingConfiguration.applyByPostProcess,o&&(i.imageProcessingConfiguration.applyByPostProcess=!0)})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){var e,t;i.imageProcessingConfiguration.applyByPostProcess=h,i._forcedViewPosition=null,a._sceneUBOs&&i.setSceneUniformBuffer(a._currentSceneUBO),i.updateTransformMatrix(!0),null===(t=(e=i.getEngine())._debugPopGroup)||void 0===t||t.call(e,1)}))}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},set:function(e){this._renderTargetTexture.renderList=e},enumerable:!1,configurable:!0}),e.prototype.attachToMesh=function(e){this._attachedMesh=e},e.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)},e.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);if(-1!==e&&this._scene.reflectionProbes.splice(e,1),this._parentContainer){var t=this._parentContainer.reflectionProbes.indexOf(this);t>-1&&this._parentContainer.reflectionProbes.splice(t,1),this._parentContainer=null}if(this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null),this._sceneUBOs){for(var i=0,r=this._sceneUBOs;ithis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},e}());pn.prototype._internalPickSprites=function(e,t,i,r){if(!Fr)return null;var n=null;if(!r){if(!this.activeCamera)return null;r=this.activeCamera}if(this.spriteManagers&&this.spriteManagers.length>0)for(var o=0;o=n.distance))&&(n=s,i))break}}return n||new Fr},pn.prototype._internalMultiPickSprites=function(e,t,i){if(!Fr)return null;var r=[];if(!i){if(!this.activeCamera)return null;i=this.activeCamera}if(this.spriteManagers&&this.spriteManagers.length>0)for(var n=0;n0&&(i=n.pickSprite(e,t,this._spritePredicate,!1,n.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite&&i.pickedSprite.actionManager){switch(n._pickedDownSprite=i.pickedSprite,r.button){case 0:i.pickedSprite.actionManager.processTrigger(u.ACTION_OnLeftPickTrigger,te.CreateNewFromSprite(i.pickedSprite,n,r));break;case 1:i.pickedSprite.actionManager.processTrigger(u.ACTION_OnCenterPickTrigger,te.CreateNewFromSprite(i.pickedSprite,n,r));break;case 2:i.pickedSprite.actionManager.processTrigger(u.ACTION_OnRightPickTrigger,te.CreateNewFromSprite(i.pickedSprite,n,r))}i.pickedSprite.actionManager&&i.pickedSprite.actionManager.processTrigger(u.ACTION_OnPickDownTrigger,te.CreateNewFromSprite(i.pickedSprite,n,r))}return i},e.prototype._pointerUp=function(e,t,i,r,n){var o=this.scene;if(o.spriteManagers&&o.spriteManagers.length>0){var a=o.pickSprite(e,t,this._spritePredicate,!1,o.cameraToUseForPointers||void 0);a&&(a.hit&&a.pickedSprite&&a.pickedSprite.actionManager&&(a.pickedSprite.actionManager.processTrigger(u.ACTION_OnPickUpTrigger,te.CreateNewFromSprite(a.pickedSprite,o,r)),a.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||a.pickedSprite.actionManager.processTrigger(u.ACTION_OnPickTrigger,te.CreateNewFromSprite(a.pickedSprite,o,r)),n&&a.pickedSprite.actionManager.processTrigger(u.ACTION_OnDoublePickTrigger,te.CreateNewFromSprite(a.pickedSprite,o,r)))),o._pickedDownSprite&&o._pickedDownSprite.actionManager&&o._pickedDownSprite!==a.pickedSprite&&o._pickedDownSprite.actionManager.processTrigger(u.ACTION_OnPickOutTrigger,te.CreateNewFromSprite(o._pickedDownSprite,o,r)))}return i},e}();li.IncludesShadersStore.imageProcessingCompatibility="#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif\n";li.ShadersStore.spritesPixelShader="#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform bool alphaTest;varying vec4 vColor;varying vec2 vUV;uniform sampler2D diffuseSampler;\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#ifdef PIXEL_PERFECT\nvec2 uvPixelPerfect(vec2 uv) {vec2 res=vec2(textureSize(diffuseSampler,0));uv=uv*res;vec2 seam=floor(uv+0.5);uv=seam+clamp((uv-seam)/fwidth(uv),-0.5,0.5);return uv/res;}\n#endif\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#ifdef PIXEL_PERFECT\nvec2 uv=uvPixelPerfect(vUV);\n#else\nvec2 uv=vUV;\n#endif\nvec4 color=texture2D(diffuseSampler,uv);float fAlphaTest=float(alphaTest);if (fAlphaTest != 0.)\n{if (color.a<0.95)\ndiscard;}\ncolor*=vColor;\n#include\n#include\ngl_FragColor=color;\n#include\n#define CUSTOM_FRAGMENT_MAIN_END\n}";li.ShadersStore.spritesVertexShader="attribute vec4 position;attribute vec2 options;attribute vec2 offsets;attribute vec2 inverts;attribute vec4 cellInfo;attribute vec4 color;uniform mat4 view;uniform mat4 projection;varying vec2 vUV;varying vec4 vColor;\n#include\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;float angle=position.w;vec2 size=vec2(options.x,options.y);vec2 offset=offsets.xy;cornerPos=vec2(offset.x-0.5,offset.y -0.5)*size;vec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;viewPos+=rotatedCorner;gl_Position=projection*vec4(viewPos,1.0); \nvColor=color;vec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));vec2 uvPlace=cellInfo.xy;vec2 uvSize=cellInfo.zw;vUV.x=uvPlace.x+uvSize.x*uvOffset.x;vUV.y=uvPlace.y+uvSize.y*uvOffset.y;\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n#include\n#define CUSTOM_VERTEX_MAIN_END\n}";var Gv=function(){function e(e,t,i,r){void 0===i&&(i=.01),void 0===r&&(r=null),this.blendMode=u.ALPHA_COMBINE,this.autoResetAlpha=!0,this.disableDepthWrite=!1,this._fogEnabled=!0,this._pixelPerfect=!1,this._useVAO=!1,this._useInstancing=!1,this._vertexBuffers={},this._capacity=t,this._epsilon=i,this._engine=e,this._useInstancing=e.getCaps().instancedArrays&&e._features.supportSpriteInstancing,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects,this._scene=r,this._useInstancing||this._buildIndexBuffer(),this._vertexBufferSize=this._useInstancing?16:18,this._vertexData=new Float32Array(t*this._vertexBufferSize*(this._useInstancing?1:4)),this._buffer=new Dr(e,this._vertexData,!0,this._vertexBufferSize);var n,o=this._buffer.createVertexBuffer(Nr.PositionKind,0,4,this._vertexBufferSize,this._useInstancing),a=this._buffer.createVertexBuffer("options",4,2,this._vertexBufferSize,this._useInstancing),s=6;if(this._useInstancing){var l=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new Dr(e,l,!1,2),n=this._spriteBuffer.createVertexBuffer("offsets",0,2)}else n=this._buffer.createVertexBuffer("offsets",s,2,this._vertexBufferSize,this._useInstancing),s+=2;var c=this._buffer.createVertexBuffer("inverts",s,2,this._vertexBufferSize,this._useInstancing),h=this._buffer.createVertexBuffer("cellInfo",s+2,4,this._vertexBufferSize,this._useInstancing),d=this._buffer.createVertexBuffer(Nr.ColorKind,s+6,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Nr.PositionKind]=o,this._vertexBuffers.options=a,this._vertexBuffers.offsets=n,this._vertexBuffers.inverts=c,this._vertexBuffers.cellInfo=h,this._vertexBuffers[Nr.ColorKind]=d,this._createEffects()}return Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this._createEffects())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){var t,i=!!(null===(t=this._scene)||void 0===t?void 0:t.getEngine().getCaps().fragmentDepthSupported);e&&!i&&ae.Warn("Logarithmic depth has been requested for a sprite renderer on a device that doesn't support it."),this._useLogarithmicDepth=e&&i,this._createEffects()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capacity",{get:function(){return this._capacity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pixelPerfect",{get:function(){return this._pixelPerfect},set:function(e){this._pixelPerfect!==e&&(this._pixelPerfect=e,this._createEffects())},enumerable:!1,configurable:!0}),e.prototype._createEffects=function(){var e,t;null===(e=this._drawWrapperBase)||void 0===e||e.dispose(),null===(t=this._drawWrapperDepth)||void 0===t||t.dispose(),this._drawWrapperBase=new ho(this._engine),this._drawWrapperDepth=new ho(this._engine,!1),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=this._useInstancing),this._drawWrapperDepth.drawContext&&(this._drawWrapperDepth.drawContext.useInstancing=this._useInstancing);var i="";this._pixelPerfect&&(i+="#define PIXEL_PERFECT\n"),this._scene&&this._scene.fogEnabled&&0!==this._scene.fogMode&&this._fogEnabled&&(i+="#define FOG\n"),this._useLogarithmicDepth&&(i+="#define LOGARITHMICDEPTH\n"),this._drawWrapperBase.effect=this._engine.createEffect("sprites",[Nr.PositionKind,"options","offsets","inverts","cellInfo",Nr.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor","logarithmicDepthConstant"],["diffuseSampler"],i),this._drawWrapperDepth.effect=this._drawWrapperBase.effect,this._drawWrapperDepth.materialContext=this._drawWrapperBase.materialContext},e.prototype.render=function(e,t,i,r,n){if(void 0===n&&(n=null),this.texture&&this.texture.isReady()&&e.length){var o=this._drawWrapperBase,a=this._drawWrapperDepth,s=this.fogEnabled&&this._scene&&this._scene.fogEnabled&&0!==this._scene.fogMode,l=o.effect;if(l.isReady()){for(var c=this._engine,h=!(!this._scene||!this._scene.useRightHandedSystem),d=this.texture.getBaseSize(),p=Math.min(this._capacity,e.length),f=0,_=!0,m=0;m0);var u=e.substring(0,c-1)+".json";rr.LoadFile(u,(function(e){try{var t=JSON.parse(e),r=Reflect.ownKeys(t.frames);i._spriteMap=r,i._packedAndReady=!0,i._cellData=t.frames}catch(e){throw i._fromPacked=!1,i._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}}),void 0,void 0,!1,(function(){ae.Error("JSON ERROR: Unable to load JSON file."),i._fromPacked=!1,i._packedAndReady=!1}))}},e.prototype._checkTextureAlpha=function(e,t,i,r,n){if(!e.useAlphaForPicking||!this.texture)return!0;var o=this.texture.getSize();this._textureContent||(this._textureContent=new Uint8Array(o.width*o.height*4),this.texture.readPixels(0,0,this._textureContent));var a=H.Vector3[0];a.copyFrom(t.direction),a.normalize(),a.scaleInPlace(i),a.addInPlace(t.origin);var s=(a.x-r.x)/(n.x-r.x),l=1-(a.y-r.y)/(n.y-r.y),c=e._xOffset*o.width+s*e._xSize|0,u=e._yOffset*o.height+l*e._ySize|0;return this._textureContent[4*(c+u*o.width)+3]>.5},e.prototype.intersects=function(e,t,i,r){for(var n=Math.min(this.capacity,this.sprites.length),o=V.Zero(),a=V.Zero(),s=Number.MAX_VALUE,l=null,c=H.Vector3[0],u=H.Vector3[1],h=t.getViewMatrix(),d=e,p=e,f=0;fm){if(!this._checkTextureAlpha(_,d,m,o,a))continue;if(p=d,s=m,l=_,r)break}}}}if(l){var g=new Fr;h.invertToRef(H.Matrix[0]),g.hit=!0,g.pickedSprite=l,g.distance=s;var v=H.Vector3[2];return v.copyFrom(p.direction),v.normalize(),v.scaleInPlace(s),p.origin.addToRef(v,c),g.pickedPoint=V.TransformCoordinates(c,H.Matrix[0]),g}return null},e.prototype.multiIntersects=function(e,t,i){for(var r,n=Math.min(this.capacity,this.sprites.length),o=V.Zero(),a=V.Zero(),s=[],l=H.Vector3[0].copyFromFloats(0,0,0),c=H.Vector3[1].copyFromFloats(0,0,0),u=t.getViewMatrix(),h=0;h0){var r=t._waitingData.lods.ids,n=i.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=r.length){var a=o.length>r.length?o[o.length-1]:0;i.setEnabled(!1);for(var s=0;s0&&i.addLODLevel(a,null),!0===n&&i.setEnabled(!0)}else rr.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},qv=function(e,t,i){if("number"!=typeof e){var r=i.getLastEntryById(e);return r&&null!=t?r.instances[parseInt(t)]:r}var n=Xv[e];return n&&null!=t?n.instances[parseInt(t)]:n},Zv=function(e,t){return"number"!=typeof e?t.getLastMaterialById(e,!0):jv[e]},Jv=function(e,t,i,r,n){void 0===n&&(n=!1);var o=new Va(e),a="importScene has failed JSON parse";try{var l=JSON.parse(t);a="";var u=Ls.loggingLevel===Ls.DETAILED_LOGGING,h=void 0,d=void 0;if(void 0!==l.environmentTexture&&null!==l.environmentTexture){var p=void 0===l.isPBR||l.isPBR;if(l.environmentTextureType&&"BABYLON.HDRCubeTexture"===l.environmentTextureType){var f=l.environmentTextureSize?l.environmentTextureSize:128,_=new Pv((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,f,!0,!p,void 0,l.environmentTexturePrefilterOnLoad);l.environmentTextureRotationY&&(_.rotationY=l.environmentTextureRotationY),e.environmentTexture=_}else if("object"==typeof l.environmentTexture){var m=Nm.Parse(l.environmentTexture,e,i);e.environmentTexture=m}else if(l.environmentTexture.endsWith(".env")){var g=new Nm((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,l.environmentTextureForcedExtension);l.environmentTextureRotationY&&(g.rotationY=l.environmentTextureRotationY),e.environmentTexture=g}else{var v=Nm.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,l.environmentTextureForcedExtension);l.environmentTextureRotationY&&(v.rotationY=l.environmentTextureRotationY),e.environmentTexture=v}if(!0===l.createDefaultSkybox){var y=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,b=l.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,p,y,b)}o.environmentTexture=e.environmentTexture}if(void 0!==l.environmentIntensity&&null!==l.environmentIntensity&&(e.environmentIntensity=l.environmentIntensity),void 0!==l.lights&&null!==l.lights)for(h=0,d=l.lights.length;h0){for(var se=0;se0){for(var ce=0;ce-1))for(var C=0,R=h.skeletons.length;C-1&&void 0!==h.morphTargetManagers&&null!==h.morphTargetManagers&&!(S.indexOf(s.morphTargetManagerId)>-1))for(var M=0,O=h.morphTargetManagers.length;M-1&&_.splice(I,1)}R._waitingParentId=null}R._waitingData.lods&&Qv(t,R)}for(var M=0,O=_;M0&&(_+1)%4==0)a[_]=255;else{var T=s[_];a[_]=T/f*255}e.is3D?(e.updateSize(c,c,c),r.updateRawTexture3D(e,a,u.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(c*c,c),r.updateRawTexture(e,a,u.TEXTUREFORMAT_RGBA,!1)),e.isReady=!0,i._triggerOnLoad()}},o=this.getScene();return o?o._loadFile(this.url,n):r._loadFile(this.url,n),this._texture},t.prototype._loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this._load3dlTexture()},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine());return e.level=this.level,e},t.prototype.delayLoad=function(){this.delayLoadState===u.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=u.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this._loadTexture())},t.Parse=function(e,i){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(e.name,i)).name=e.name,r.level=e.level),r},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},t._NoneEmptyLineRegex=/\S+/,t}(Ya);a("BABYLON.ColorGradingTexture",oy);var ay=function(e){function t(t,i,r,n,o,a,s,l){void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=!1);var c=e.call(this,i)||this;if(c._onLoad=null,c._onError=null,!t)throw new Error("Image url is not set");return c._coordinatesMode=Ja.CUBIC_MODE,c.name=t,c.url=t,c._size=r,c._supersample=l,c._noMipmap=n,c.gammaSpace=o,c._onLoad=a,c._onError=s,c.hasAlpha=!1,c.isCube=!0,c._texture=c._getFromCache(t,c._noMipmap,void 0,void 0,void 0,c.isCube),c._texture?a&&(c._texture.isReady?rr.SetImmediate((function(){return a()})):c._texture.onLoadedObservable.add(a)):i.useDelayedTextureLoading?c.delayLoadState=u.DELAYLOADSTATE_NOTLOADED:c._loadImage((function(){return c._loadTexture()}),c._onError),c}return m(t,e),t.prototype._loadImage=function(e,t){var i=this,r=this.getScene();if(r){var n=r.getEngine().createRawCubeTexture(null,this._size,u.TEXTUREFORMAT_RGB,r.getEngine().getCaps().textureFloat?u.TEXTURETYPE_FLOAT:u.TEXTURETYPE_UNSIGNED_INTEGER,!this._noMipmap,!1,u.TEXTURE_TRILINEAR_SAMPLINGMODE);n.generateMipMaps=!this._noMipmap,r.addPendingData(n),n.url=this.url,n.isReady=!1,r.getEngine()._internalTexturesCache.push(n),this._texture=n;var o=document.createElement("canvas");Bi(this.url,(function(t){i._width=t.width,i._height=t.height,o.width=i._width,o.height=i._height;var r=o.getContext("2d");r.drawImage(t,0,0);var n=r.getImageData(0,0,t.width,t.height);i._buffer=n.data.buffer,o.remove(),e()}),(function(e,o){r.removePendingData(n),t&&t("".concat(i.getClassName()," could not be loaded"),o)}),r?r.offlineProvider:null)}},t.prototype._loadTexture=function(){var e=this,i=this.getScene();if(i){var r=function(){for(var i=e._getFloat32ArrayFromArrayBuffer(e._buffer),r=Av.ConvertPanoramaToCubemap(i,e._width,e._height,e._size,e._supersample),n=[],o=0;o<6;o++){var a=r[t._FacesMapping[o]];n.push(a)}return n}(),n=this._texture;i.getEngine().updateRawCubeTexture(n,r,n.format,n.type,n.invertY),n.isReady=!0,i.removePendingData(n),n.onLoadedObservable.notifyObservers(n),n.onLoadedObservable.clear(),this._onLoad&&this._onLoad()}},t.prototype._getFloat32ArrayFromArrayBuffer=function(e){for(var t=new DataView(e),i=new Float32Array(3*e.byteLength/4),r=0,n=0;nt.length)ae.Error("Unable to load TGA file - Not enough data");else{i+=r.id_length;var n,o=!1,a=!1,s=!1;switch(r.image_type){case hy:o=!0;case ly:a=!0;break;case dy:o=!0;case cy:break;case py:o=!0;case uy:s=!0}var l,c,u,h,d,p,f,_=r.pixel_size>>3,m=r.width*r.height*_;if(a&&(l=t.subarray(i,i+=r.colormap_length*(r.colormap_size>>3))),o){n=new Uint8Array(m);for(var g=void 0,v=void 0,y=void 0,b=0,T=new Uint8Array(_);i>_y){default:case vy:c=0,h=1,f=r.width,u=0,d=1,p=r.height;break;case my:c=0,h=1,f=r.width,u=r.height-1,d=-1,p=-1;break;case yy:c=r.width-1,h=-1,f=-1,u=0,d=1,p=r.height;break;case gy:c=r.width-1,h=-1,f=-1,u=r.height-1,d=-1,p=-1}var E="_getImageData"+(s?"Grey":"")+r.pixel_size+"bits",S=Ey[E](r,l,n,u,d,p,c,h,f);e.getEngine()._uploadDataToTextureDirectly(e,S)}}}var Ey={GetTGAHeader:by,UploadContent:Ty,_getImageData8bits:function(e,t,i,r,n,o,a,s,l){var c,u,h,d=i,p=t,f=e.width,_=e.height,m=0,g=new Uint8Array(f*_*4);for(h=r;h!==o;h+=n)for(u=a;u!==l;u+=s,m++)c=d[m],g[4*(u+f*h)+3]=255,g[4*(u+f*h)+2]=p[3*c+0],g[4*(u+f*h)+1]=p[3*c+1],g[4*(u+f*h)+0]=p[3*c+2];return g},_getImageData16bits:function(e,t,i,r,n,o,a,s,l){var c,u,h,d=i,p=e.width,f=e.height,_=0,m=new Uint8Array(p*f*4);for(h=r;h!==o;h+=n)for(u=a;u!==l;u+=s,_+=2){var g=255*((31744&(c=d[_+0]+(d[_+1]<<8)))>>10)/31|0,v=255*((992&c)>>5)/31|0,y=255*(31&c)/31|0;m[4*(u+p*h)+0]=g,m[4*(u+p*h)+1]=v,m[4*(u+p*h)+2]=y,m[4*(u+p*h)+3]=32768&c?0:255}return m},_getImageData24bits:function(e,t,i,r,n,o,a,s,l){var c,u,h=i,d=e.width,p=e.height,f=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=a;c!==l;c+=s,f+=3)_[4*(c+d*u)+3]=255,_[4*(c+d*u)+2]=h[f+0],_[4*(c+d*u)+1]=h[f+1],_[4*(c+d*u)+0]=h[f+2];return _},_getImageData32bits:function(e,t,i,r,n,o,a,s,l){var c,u,h=i,d=e.width,p=e.height,f=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=a;c!==l;c+=s,f+=4)_[4*(c+d*u)+2]=h[f+0],_[4*(c+d*u)+1]=h[f+1],_[4*(c+d*u)+0]=h[f+2],_[4*(c+d*u)+3]=h[f+3];return _},_getImageDataGrey8bits:function(e,t,i,r,n,o,a,s,l){var c,u,h,d=i,p=e.width,f=e.height,_=0,m=new Uint8Array(p*f*4);for(h=r;h!==o;h+=n)for(u=a;u!==l;u+=s,_++)c=d[_],m[4*(u+p*h)+0]=c,m[4*(u+p*h)+1]=c,m[4*(u+p*h)+2]=c,m[4*(u+p*h)+3]=255;return m},_getImageDataGrey16bits:function(e,t,i,r,n,o,a,s,l){var c,u,h=i,d=e.width,p=e.height,f=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=a;c!==l;c+=s,f+=2)_[4*(c+d*u)+0]=h[f+0],_[4*(c+d*u)+1]=h[f+0],_[4*(c+d*u)+2]=h[f+0],_[4*(c+d*u)+3]=h[f+1];return _}},Sy=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return e.endsWith(".tga")},e.prototype.loadCubeData=function(){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,i){var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=by(r);i(n.width,n.height,t.generateMipMaps,!1,(function(){Ty(t,r)}))},e}();Do._TextureLoaders.push(new Sy);var xy=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return e.endsWith(".hdr")},e.prototype.loadCubeData=function(){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,i){for(var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=Cv.RGBE_ReadHeader(r),o=Cv.RGBE_ReadPixels(r,n),a=n.width*n.height,s=new Float32Array(4*a),l=0;l>2&3],o[p++]=n[d>>4&3],o[p++]=n[d>>6&3]}}return o}(a,0,e.getImageWidth(t,i)+3&-4,e.getImageHeight(t,i)+3&-4)),a):null}onmessage=function(i){if("init"===i.data.action){if(i.data.url)try{importScripts(i.data.url)}catch(e){postMessage({action:"error",error:e})}e||(e=BASIS({wasmBinary:i.data.wasmBinary})),null!==e&&e.then((function(e){BASIS=e,e.initializeBasis(),postMessage({action:"init"})}))}else if("transcode"===i.data.action){var r=i.data.config,n=i.data.imageData,o=new BASIS.BasisFile(n),a=function(e){for(var t=e.getHasAlpha(),i=e.getNumImages(),r=[],n=0;n1;var a=Uy.GetInternalFormatFromBasisFormat(t.format,i);e.format=a,wy(e,i),t.fileInfo.images[r].levels.forEach((function(t,n){i._uploadCompressedDataToTextureDirectly(e,a,t.width,t.height,t.transcodedPixels,r,n)})),!i._features.basisNeedsPOT||j.Log2(e.width)%1==0&&j.Log2(e.height)%1==0||(rr.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."),e._cachedWrapU=Ja.CLAMP_ADDRESSMODE,e._cachedWrapV=Ja.CLAMP_ADDRESSMODE)}},n=0;n1&&t.generateMipMaps;By(t,e),t.getEngine()._setCubeMapTextureParams(t,i),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()})).catch((function(e){rr.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0,n&&n(e)}))}},e.prototype.loadData=function(e,t,i){var r=t.getEngine().getCaps(),n={supportedCompressionFormats:{etc1:!!r.etc1,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,astc:!!r.astc,bc7:!!r.bptc}};Ly(e,n).then((function(e){var r=e.fileInfo.images[0].levels[0],n=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;i(r.width,r.height,n,-1!==e.format,(function(){By(t,e)}))})).catch((function(e){rr.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),rr.Warn("Failed to transcode Basis file: ".concat(e)),i(0,0,!1,!1,(function(){}),!0)}))},e}();Mi._TextureLoaders.push(new Vy);var ky=function(e){function t(t,i,r,n,o,a){var s=this,l=!(!o||!o.generateMipMaps)&&o.generateMipMaps,c=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,h=o&&o.depthTextureFormat?o.depthTextureFormat:u.TEXTUREFORMAT_DEPTH16,d=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio,p=!(!o||!o.drawOnlyOnFirstAttachmentByDefault)&&o.drawOnlyOnFirstAttachmentByDefault;if(!(s=e.call(this,t,i,n,l,d,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0)||this).isSupported)return s.dispose(),s;s._textureNames=a;var f=[],_=[],m=[],g=[],v=[],y=[],b=[],T=[];s._initTypes(r,f,_,m,g,v,y,b,T,o);var E=!o||void 0===o.generateDepthBuffer||o.generateDepthBuffer,S=!(!o||void 0===o.generateStencilBuffer)&&o.generateStencilBuffer;return s._multiRenderTargetOptions={samplingModes:_,generateMipMaps:l,generateDepthBuffer:E,generateStencilBuffer:S,generateDepthTexture:c,depthTextureFormat:h,types:f,textureCount:r,useSRGBBuffers:m,formats:g,targetTypes:v,faceIndex:y,layerIndex:b,layerCounts:T,labels:a,label:t},s._count=r,s._drawOnlyOnFirstAttachmentByDefault=p,r>0&&(s._createInternalTextures(),s._createTextures(a)),s}return m(t,e),Object.defineProperty(t.prototype,"isSupported",{get:function(){var e,t;return null!==(t=null===(e=this._engine)||void 0===e?void 0:e.getCaps().drawBuffersExtension)&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t=0;r--)this._textures[r]._texture=null;null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null}},t}(Pl),Gy=function(e,t,i){this.id=e,this.scale=t,this.offset=i},zy=function(){function e(t,i,r,n){var o,a,s,l,c,u,h,d,p,f,_,m,g;return this.name=t,this.meshes=i,this.scene=n,this.options=r,this.options.map=null!==(o=this.options.map)&&void 0!==o?o:["ambientTexture","bumpTexture","diffuseTexture","emissiveTexture","lightmapTexture","opacityTexture","reflectionTexture","refractionTexture","specularTexture"],this.options.uvsIn=null!==(a=this.options.uvsIn)&&void 0!==a?a:Nr.UVKind,this.options.uvsOut=null!==(s=this.options.uvsOut)&&void 0!==s?s:Nr.UVKind,this.options.layout=null!==(l=this.options.layout)&&void 0!==l?l:e.LAYOUT_STRIP,this.options.layout===e.LAYOUT_COLNUM&&(this.options.colnum=null!==(c=this.options.colnum)&&void 0!==c?c:8),this.options.updateInputMeshes=null===(u=this.options.updateInputMeshes)||void 0===u||u,this.options.disposeSources=null===(h=this.options.disposeSources)||void 0===h||h,this._expecting=0,this.options.fillBlanks=null===(d=this.options.fillBlanks)||void 0===d||d,!0===this.options.fillBlanks&&(this.options.customFillColor=null!==(p=this.options.customFillColor)&&void 0!==p?p:"black"),this.options.frameSize=null!==(f=this.options.frameSize)&&void 0!==f?f:256,this.options.paddingRatio=null!==(_=this.options.paddingRatio)&&void 0!==_?_:.0115,this._paddingValue=Math.ceil(this.options.frameSize*this.options.paddingRatio),this._paddingValue%2!=0&&this._paddingValue++,this.options.paddingMode=null!==(m=this.options.paddingMode)&&void 0!==m?m:e.SUBUV_WRAP,this.options.paddingMode===e.SUBUV_COLOR&&(this.options.paddingColor=null!==(g=this.options.paddingColor)&&void 0!==g?g:new J(0,0,0,1)),this.sets={},this.frames=[],this}return e.prototype._createFrames=function(e){for(var t=this,i=this._calculateSize(),r=new U(1,1).divide(i),n=0,o=this._expecting,a=this.meshes.length,s=Object.keys(this.sets),l=0;l0)try{t._config=JSON.parse(n.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+"/custom"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){i()}else i()}),!1),n.addEventListener("error",(function(){i()}),!1);try{n.send()}catch(e){ae.Error("CustomProceduralTexture: Error on XHR send request.")}},t.prototype.isReady=function(){if(!e.prototype.isReady.call(this))return!1;for(var t in this._textures)if(!this._textures[t].isReady())return!1;return!0},t.prototype.render=function(t){var i=this.getScene();this._animate&&i&&(this._time+=.03*i.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,t)},t.prototype.updateTextures=function(){for(var e=0;e0&&($o(i,e),i.morphTargetManager.isUsingTextureForTargets&&i.morphTargetManager._bind(e))},t.prototype.replaceRepeatableContent=function(e,t,i,r){var n=this.position,o=this.normal,a=this.tangent,s=this.uv,l=this.positionOutput,c=this.normalOutput,u=this.tangentOutput,h=this.uvOutput,d=e,p=r.NUM_MORPH_INFLUENCERS,f=i.morphTargetManager,_=f&&f.supportsNormals&&r.NORMAL,m=f&&f.supportsTangents&&r.TANGENT,g=f&&f.supportsUVs&&r.UV1,v="";if((null==f?void 0:f.isUsingTextureForTargets)&&p>0&&(v+="float vertexID;\n"),v+="#ifdef MORPHTARGETS\n",null==f?void 0:f.isUsingTextureForTargets)v+="for (int i = 0; i < NUM_MORPH_INFLUENCERS; i++) {\n",v+="if (i >= morphTargetCount) break;\n",v+="vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\n",v+="".concat(l.associatedVariableName," += (readVector3FromRawSampler(i, vertexID) - ").concat(n.associatedVariableName,") * morphTargetInfluences[i];\n"),v+="vertexID += 1.0;\n",_&&(v+="#ifdef MORPHTARGETS_NORMAL\n",v+="".concat(c.associatedVariableName," += (readVector3FromRawSampler(i, vertexID) - ").concat(o.associatedVariableName,") * morphTargetInfluences[i];\n"),v+="vertexID += 1.0;\n",v+="#endif\n"),g&&(v+="#ifdef MORPHTARGETS_UV\n",v+="".concat(h.associatedVariableName," += (readVector3FromRawSampler(i, vertexID).xy - ").concat(s.associatedVariableName,") * morphTargetInfluences[i];\n"),v+="vertexID += 1.0;\n",v+="#endif\n"),m&&(v+="#ifdef MORPHTARGETS_TANGENT\n",v+="".concat(u.associatedVariableName,".xyz += (readVector3FromRawSampler(i, vertexID) - ").concat(a.associatedVariableName,".xyz) * morphTargetInfluences[i];\n"),a.type===Ns.Vector4?v+="".concat(u.associatedVariableName,".w = ").concat(a.associatedVariableName,".w;\n"):v+="".concat(u.associatedVariableName,".w = 1.;\n"),v+="#endif\n"),v+="}\n";else for(var y=0;y0)for(y=0;y\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g,replace:""},{search:/uniform sampler2D bumpSampler;/g,replace:""},{search:/vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g,replace:"#define inline\nvec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)"},{search:/vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g,replace:"vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)"},{search:/texture2D\(bumpSampler,vBumpUV\)\.w/g,replace:"height_"}]});var p=l&&s?"texture2D(".concat(s,", ").concat(r.associatedVariableName," + uvOffset).xyz"):this.normalMapColor.associatedVariableName;return t.compilationString+=t._declareOutput(this.output)+" = vec4(0.);\n",t.compilationString+=t._emitCodeFromInclude("bumpFragment",i,{replaceStrings:[{search:/texture2D\(bumpSampler,vBumpUV\)/g,replace:"".concat(p)},{search:/#define CUSTOM_FRAGMENT_BUMP_FRAGMENT/g,replace:"mat4 normalMatrix = toNormalMatrix(".concat(this.world.isConnected?this.world.associatedVariableName:this._worldMatrixName,");")},{search:/perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,replace:"perturbNormal(TBN, ".concat(p,", vBumpInfos.y)")},{search:/parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,replace:"parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, ".concat(l&&this.useParallaxOcclusion?s:"bumpSampler",")")},{search:/parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,replace:"parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, ".concat(l?this.parallaxHeight.associatedVariableName:"0.",")")},{search:/vTangentSpaceParams/g,replace:this._tangentSpaceParameterName},{search:/vBumpInfos.y/g,replace:u},{search:/vBumpInfos.z/g,replace:c},{search:/vBumpUV/g,replace:r.associatedVariableName},{search:/vPositionW/g,replace:n.associatedVariableName+".xyz"},{search:/normalW=/g,replace:this.output.associatedVariableName+".xyz = "},{search:/mat3\(normalMatrix\)\*normalW/g,replace:"mat3(normalMatrix) * "+this.output.associatedVariableName+".xyz"},{search:/normalW/g,replace:o.associatedVariableName+".xyz"},{search:/viewDirectionW/g,replace:l?this.viewDirection.associatedVariableName:"vec3(0.)"},h]}),this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".invertX = ").concat(this.invertX,";\n");return t+="".concat(this._codeVariableName,".invertY = ").concat(this.invertY,";\n"),(t+="".concat(this._codeVariableName,".useParallaxOcclusion = ").concat(this.useParallaxOcclusion,";\n"))+"".concat(this._codeVariableName,".useObjectSpaceNormalMap = ").concat(this.useObjectSpaceNormalMap,";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.invertX=this.invertX,t.invertY=this.invertY,t.useParallaxOcclusion=this.useParallaxOcclusion,t.useObjectSpaceNormalMap=this.useObjectSpaceNormalMap,t},t.prototype._deserialize=function(t,i,r){e.prototype._deserialize.call(this,t,i,r),this.invertX=t.invertX,this.invertY=t.invertY,this.useParallaxOcclusion=!!t.useParallaxOcclusion,this.useObjectSpaceNormalMap=!!t.useObjectSpaceNormalMap},v([Ys("Invert X axis",Xs.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertX",void 0),v([Ys("Invert Y axis",Xs.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertY",void 0),v([Ys("Use parallax occlusion",Xs.Boolean)],t.prototype,"useParallaxOcclusion",void 0),v([Ys("Object Space Mode",Xs.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"useObjectSpaceNormalMap",void 0),t}(Ws);a("BABYLON.PerturbNormalBlock",ib);var rb=function(e){function t(t){var i=e.call(this,t,Fs.Fragment,!0)||this;return i.registerInput("value",Ns.Float,!0),i.registerInput("cutoff",Ns.Float,!0),i}return m(t,e),t.prototype.getClassName=function(){return"DiscardBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cutoff",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.sharedData.hints.needAlphaTesting=!0,this.cutoff.isConnected&&this.value.isConnected)return t.compilationString+="if (".concat(this.value.associatedVariableName," < ").concat(this.cutoff.associatedVariableName,") discard;\n"),this},t}(Ws);a("BABYLON.DiscardBlock",rb);var nb=function(e){function t(t){var i=e.call(this,t,Fs.Fragment)||this;return i.registerOutput("output",Ns.Float,Fs.Fragment),i}return m(t,e),t.prototype.getClassName=function(){return"FrontFacingBlock"},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===Fs.Vertex)throw"FrontFacingBlock must only be used in a fragment shader";var i=this._outputs[0];return t.compilationString+=t._declareOutput(i)+" = gl_FrontFacing ? 1.0 : 0.0;\n",this},t}(Ws);a("BABYLON.FrontFacingBlock",nb);var ob=function(e){function t(t){var i=e.call(this,t,Fs.Fragment)||this;return i.registerInput("input",Ns.AutoDetect,!1),i.registerOutput("dx",Ns.BasedOnInput),i.registerOutput("dy",Ns.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._outputs[1]._typeConnectionSource=i._inputs[0],i}return m(t,e),t.prototype.getClassName=function(){return"DerivativeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dx",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dy",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],r=this._outputs[1];t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var n="dFdx",o="dFdy";return t.shaderLanguage===pt.WGSL&&(n="dpdx",o="dpdy"),i.hasEndpoints&&(t.compilationString+=t._declareOutput(i)+" = ".concat(n,"(").concat(this.input.associatedVariableName,");\n")),r.hasEndpoints&&(t.compilationString+=t._declareOutput(r)+" = ".concat(o,"(").concat(this.input.associatedVariableName,");\n")),this},t}(Ws);a("BABYLON.DerivativeBlock",ob);var ab=function(e){function t(t){var i=e.call(this,t,Fs.Fragment)||this;return i.registerOutput("xy",Ns.Vector2,Fs.Fragment),i.registerOutput("xyz",Ns.Vector3,Fs.Fragment),i.registerOutput("xyzw",Ns.Vector4,Fs.Fragment),i.registerOutput("x",Ns.Float,Fs.Fragment),i.registerOutput("y",Ns.Float,Fs.Fragment),i.registerOutput("z",Ns.Float,Fs.Fragment),i.registerOutput("w",Ns.Float,Fs.Fragment),i}return m(t,e),t.prototype.getClassName=function(){return"FragCoordBlock"},Object.defineProperty(t.prototype,"xy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),t.prototype.writeOutputs=function(e){for(var t="",i=0,r=this._outputs;i=0;xa(n,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+n],r,o)}},t.prototype.bind=function(e,t,i){if(i){var r=i.getScene();this.light?aa(this.light,this._lightId,r,e,!0):sa(r,i,e,!0,t.maxSimultaneousLights)}},t.prototype._injectVertexCode=function(e){var t=this.worldPosition,i="//".concat(this.name);this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var r="v_"+t.associatedVariableName;e._emitVaryingFromString(r,Ns.Vector4)&&(e.compilationString+="".concat(r," = ").concat(t.associatedVariableName,";\n")),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:t.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = ".concat(t.associatedVariableName,";\n"),this.view.isConnected&&(e.compilationString+="mat4 view = ".concat(this.view.associatedVariableName,";\n")),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{repeatKey:"maxSimultaneousLights"}))},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===Fs.Fragment){this.generateOnlyFragmentCode&&t.sharedData.dynamicUniformBlocks.push(this),t.sharedData.forcedBindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var i="//".concat(this.name),r=this.worldPosition,n=r.associatedVariableName;this.generateOnlyFragmentCode?(n=t._getFreeVariableName("globalWorldPos"),t._emitFunction("light_globalworldpos","vec3 ".concat(n,";\n"),i),t.compilationString+="".concat(n," = ").concat(r.associatedVariableName,".xyz;\n"),t.compilationString+=t._emitCodeFromInclude("shadowsVertex",i,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"worldPos,".concat(r.associatedVariableName):void 0})):n="v_"+n+".xyz",t._emitFunctionFromInclude("helperFunctions",i),t._emitFunctionFromInclude("lightsFragmentFunctions",i,{replaceStrings:[{search:/vPositionW/g,replace:n}]}),t._emitFunctionFromInclude("shadowsFragmentFunctions",i,{replaceStrings:[{search:/vPositionW/g,replace:n}]}),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"varying,":void 0}),0===this._lightId&&(t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName," - ").concat(n,");\n")),t.compilationString+="lightingInfo info;\n",t.compilationString+="float shadow = 1.;\n",t.compilationString+="float aggShadow = 0.;\n",t.compilationString+="float numLights = 0.;\n",t.compilationString+="float glossiness = ".concat(this.glossiness.isConnected?this.glossiness.associatedVariableName:"1.0"," * ").concat(this.glossPower.isConnected?this.glossPower.associatedVariableName:"1024.0",";\n"),t.compilationString+="vec3 diffuseBase = vec3(0., 0., 0.);\n",t.compilationString+="vec3 specularBase = vec3(0., 0., 0.);\n",t.compilationString+="vec3 normalW = ".concat(this.worldNormal.associatedVariableName,".xyz;\n")),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/vPositionW/g,replace:n+".xyz"}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",i,{repeatKey:"maxSimultaneousLights",substitutionVars:"vPositionW,".concat(n,".xyz")}),0===this._lightId&&(t.compilationString+="aggShadow = aggShadow / numLights;\n");var o=this.diffuseOutput,a=this.specularOutput;return t.compilationString+=t._declareOutput(o)+" = diffuseBase".concat(this.diffuseColor.isConnected?" * "+this.diffuseColor.associatedVariableName:"",";\n"),a.hasEndpoints&&(t.compilationString+=t._declareOutput(a)+" = specularBase".concat(this.specularColor.isConnected?" * "+this.specularColor.associatedVariableName:"",";\n")),this.shadow.hasEndpoints&&(t.compilationString+=t._declareOutput(this.shadow)+" = aggShadow;\n"),this}this._injectVertexCode(t)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.generateOnlyFragmentCode=this.generateOnlyFragmentCode,this.light&&(t.lightId=this.light.id),t},t.prototype._deserialize=function(t,i,r){e.prototype._deserialize.call(this,t,i,r),t.lightId&&(this.light=i.getLightById(t.lightId)),this.generateOnlyFragmentCode=t.generateOnlyFragmentCode,this._setTarget()},v([Ys("Generate only fragment code",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0,update:!0,onValidation:t._OnGenerateOnlyFragmentCodeChanged}})],t.prototype,"generateOnlyFragmentCode",void 0),t}(Ws);a("BABYLON.LightBlock",_b);var mb=function(e){function t(i){var r=e.call(this,i,Fs.VertexAndFragment)||this;return r.registerOutput("source",Ns.Object,Fs.VertexAndFragment,new Qy("source",r,Us.Output,t,"ImageSourceBlock")),r}return m(t,e),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){var t,i=this;if(this._texture!==e){var r=null!==(t=null==e?void 0:e.getScene())&&void 0!==t?t:M.LastCreatedScene;!e&&r&&r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i._texture)})),this._texture=e,e&&r&&r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(t){return t.hasTexture(e)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerName",{get:function(){return this._samplerName},enumerable:!1,configurable:!0}),t.prototype.bind=function(e){this.texture&&e.setTexture(this._samplerName,this.texture)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.getClassName=function(){return"ImageSourceBlock"},Object.defineProperty(t.prototype,"source",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){return e.prototype._buildBlock.call(this,t),t.target===Fs.Vertex&&(this._samplerName=t._getFreeVariableName(this.name+"Sampler"),t.sharedData.blockingBlocks.push(this),t.sharedData.textureBlocks.push(this),t.sharedData.bindableBlocks.push(this)),t._emit2DSampler(this._samplerName),this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return this.texture?(t+="".concat(this._codeVariableName,'.texture = new BABYLON.Texture("').concat(this.texture.name,'", null, ').concat(this.texture.noMipmap,", ").concat(this.texture.invertY,", ").concat(this.texture.samplingMode,");\n"),t+="".concat(this._codeVariableName,".texture.wrapU = ").concat(this.texture.wrapU,";\n"),t+="".concat(this._codeVariableName,".texture.wrapV = ").concat(this.texture.wrapV,";\n"),t+="".concat(this._codeVariableName,".texture.uAng = ").concat(this.texture.uAng,";\n"),t+="".concat(this._codeVariableName,".texture.vAng = ").concat(this.texture.vAng,";\n"),t+="".concat(this._codeVariableName,".texture.wAng = ").concat(this.texture.wAng,";\n"),t+="".concat(this._codeVariableName,".texture.uOffset = ").concat(this.texture.uOffset,";\n"),t+="".concat(this._codeVariableName,".texture.vOffset = ").concat(this.texture.vOffset,";\n"),t+="".concat(this._codeVariableName,".texture.uScale = ").concat(this.texture.uScale,";\n"),t+="".concat(this._codeVariableName,".texture.vScale = ").concat(this.texture.vScale,";\n"),t+="".concat(this._codeVariableName,".texture.coordinatesMode = ").concat(this.texture.coordinatesMode,";\n")):t},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.texture&&!this.texture.isRenderTarget&&"VideoTexture"!==this.texture.getClassName()&&(t.texture=this.texture.serialize()),t},t.prototype._deserialize=function(t,i,r,n){e.prototype._deserialize.call(this,t,i,r,n),t.texture&&!Ll.IgnoreTexturesAtLoadTime&&void 0!==t.texture.url&&(0===t.texture.url.indexOf("data:")?r="":n&&(t.texture.url=n(t.texture.url),t.texture.name=t.texture.url),this.texture=Ja.Parse(t.texture,i,r))},t}(Ws);a("BABYLON.ImageSourceBlock",mb);var gb=function(e){function t(t,i){void 0===i&&(i=!1);var r=e.call(this,t,i?Fs.Fragment:Fs.VertexAndFragment)||this;return r._convertToGammaSpace=!1,r._convertToLinearSpace=!1,r.disableLevelMultiplication=!1,r._fragmentOnly=i,r.registerInput("uv",Ns.AutoDetect,!1,Fs.VertexAndFragment),r.registerInput("source",Ns.Object,!0,Fs.VertexAndFragment,new Qy("source",r,Us.Input,mb,"ImageSourceBlock")),r.registerInput("layer",Ns.Float,!0),r.registerInput("lod",Ns.Float,!0),r.registerOutput("rgba",Ns.Color4,Fs.Neutral),r.registerOutput("rgb",Ns.Color3,Fs.Neutral),r.registerOutput("r",Ns.Float,Fs.Neutral),r.registerOutput("g",Ns.Float,Fs.Neutral),r.registerOutput("b",Ns.Float,Fs.Neutral),r.registerOutput("a",Ns.Float,Fs.Neutral),r.registerOutput("level",Ns.Float,Fs.Neutral),r._inputs[0].addExcludedConnectionPointFromAllowedTypes(Ns.Vector2|Ns.Vector3|Ns.Vector4),r._inputs[0]._prioritizeVertex=!i,r}return m(t,e),Object.defineProperty(t.prototype,"texture",{get:function(){var e;return this.source.isConnected?(null===(e=this.source.connectedPoint)||void 0===e?void 0:e.ownerBlock).texture:this._texture},set:function(e){var t,i=this;if(this._texture!==e){var r=null!==(t=null==e?void 0:e.getScene())&&void 0!==t?t:M.LastCreatedScene;!e&&r&&r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i._texture)})),this._texture=e,e&&r&&r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(t){return t.hasTexture(e)}))}},enumerable:!1,configurable:!0}),t._IsPrePassTextureBlock=function(e){return"PrePassTextureBlock"===(null==e?void 0:e.getClassName())},Object.defineProperty(t.prototype,"_isSourcePrePass",{get:function(){return t._IsPrePassTextureBlock(this._imageSource)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerName",{get:function(){if(this._imageSource){if(!t._IsPrePassTextureBlock(this._imageSource))return this._imageSource.samplerName;if(this.source.connectedPoint)return this._imageSource.getSamplerName(this.source.connectedPoint)}return this._samplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasImageSource",{get:function(){return this.source.isConnected},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToGammaSpace",{get:function(){return this._convertToGammaSpace},set:function(e){var t,i=this;if(e!==this._convertToGammaSpace&&(this._convertToGammaSpace=e,this.texture)){var r=null!==(t=this.texture.getScene())&&void 0!==t?t:M.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i.texture)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToLinearSpace",{get:function(){return this._convertToLinearSpace},set:function(e){var t,i=this;if(e!==this._convertToLinearSpace&&(this._convertToLinearSpace=e,this.texture)){var r=null!==(t=this.texture.getScene())&&void 0!==t?t:M.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i.texture)}))}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TextureBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layer",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lod",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){if(this._fragmentOnly)return Fs.Fragment;if(!this.uv.isConnected)return Fs.VertexAndFragment;if(this.uv.sourceBlock.isInput)return Fs.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===Fs.Fragment)return Fs.Fragment;if(e.target===Fs.Vertex)return Fs.VertexAndFragment;if(e.target===Fs.Neutral||e.target===Fs.VertexAndFragment){var t=e.ownerBlock;if(t.target===Fs.Fragment)return Fs.Fragment;e=null;for(var i=0,r=t.inputs;i "+this.name},t.prototype.detachFromEndpoint=function(e){var t=this._endpoints.indexOf(e);-1!==t&&(this._endpoints.splice(t,1),e._outputs[0]._typeConnectionSource=null,e._entryPoint=null)},t.prototype.dispose=function(){e.prototype.dispose.call(this);for(var t=0,i=this._endpoints;t0&&(t.compilationString+=", "),i._inputSamplers&&-1!==i._inputSamplers.indexOf(e.name)?t.compilationString+=null!==(s=null===(a=null===(n=e.connectedPoint)||void 0===n?void 0:n.ownerBlock)||void 0===a?void 0:a.samplerName)&&void 0!==s?s:e.associatedVariableName:t.compilationString+=e.associatedVariableName,o=!0})),this._outputs.forEach((function(e,i){(i>0||o)&&(t.compilationString+=", "),t.compilationString+=e.associatedVariableName})),t.compilationString+=");\n",this},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".options = ").concat(JSON.stringify(this._options),";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.options=this._options,t},t.prototype._deserialize=function(t,i,r){this._deserializeOptions(t.options),e.prototype._deserialize.call(this,t,i,r)},t.prototype._deserializeOptions=function(e){var t,i,r,n=this;this._options=e,this._code=e.code.join("\n")+"\n",this.name=this.name||e.name,this.target=Fs[e.target],null===(t=e.inParameters)||void 0===t||t.forEach((function(e,t){var i=Ns[e.type];"sampler2D"===e.type||"samplerCube"===e.type?(n._inputSamplers=n._inputSamplers||[],n._inputSamplers.push(e.name),n.registerInput(e.name,Ns.Object,!0,Fs.VertexAndFragment,new Qy(e.name,n,Us.Input,mb,"ImageSourceBlock"))):n.registerInput(e.name,i),Object.defineProperty(n,e.name,{get:function(){return this._inputs[t]},enumerable:!0,configurable:!0})})),null===(i=e.outParameters)||void 0===i||i.forEach((function(e,t){n.registerOutput(e.name,Ns[e.type]),Object.defineProperty(n,e.name,{get:function(){return this._outputs[t]},enumerable:!0,configurable:!0}),"BasedOnInput"===e.type&&(n._outputs[t]._typeConnectionSource=n._findInputByName(e.typeFromInput)[0])})),null===(r=e.inLinkedConnectionTypes)||void 0===r||r.forEach((function(e){n._linkConnectionTypes(n._findInputByName(e.input1)[1],n._findInputByName(e.input2)[1])}))},t.prototype._findInputByName=function(e){if(!e)return null;for(var t=0;t=0;xa(n,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+n],r,o)}},t.prototype.isReady=function(e,t,i){return!(this._environmentBRDFTexture&&!this._environmentBRDFTexture.isReady()||i._areImageProcessingDirty&&t.imageProcessingConfiguration&&!t.imageProcessingConfiguration.isReady())},t.prototype.bind=function(e,t,i){var r,n;if(i){var o=i.getScene();this.light?aa(this.light,this._lightId,o,e,!0):sa(o,i,e,!0,t.maxSimultaneousLights),e.setTexture(this._environmentBrdfSamplerName,this._environmentBRDFTexture),e.setFloat2("vDebugMode",this.debugLimit,this.debugFactor);var a=this._scene.ambientColor;a&&e.setColor3("ambientFromScene",a);var s=o.useRightHandedSystem===(null!=o._mirroredCameraPosition);e.setFloat(this._invertNormalName,s?-1:1),e.setFloat4("vLightingIntensity",this.directIntensity,1,this.environmentIntensity*this._scene.environmentIntensity,this.specularIntensity);var l=null!==(n=null===(r=this.indexOfRefraction.connectInputBlock)||void 0===r?void 0:r.value)&&void 0!==n?n:1.5,c=Math.pow((l-1)/(l+1),2);this._metallicReflectanceColor.scaleToRef(c*this._metallicF0Factor,$.Color3[0]);var u=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,$.Color3[0],u),t.imageProcessingConfiguration&&t.imageProcessingConfiguration.bind(e)}},t.prototype._injectVertexCode=function(e){var t,i,r=this.worldPosition,n="//".concat(this.name);this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",n,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var o="v_"+r.associatedVariableName;e._emitVaryingFromString(o,Ns.Vector4)&&(e.compilationString+="".concat(o," = ").concat(r.associatedVariableName,";\n"));var a=this.reflection.isConnected?null===(t=this.reflection.connectedPoint)||void 0===t?void 0:t.ownerBlock:null;a&&(a.viewConnectionPoint=this.view),e.compilationString+=null!==(i=null==a?void 0:a.handleVertexSide(e))&&void 0!==i?i:"",e._emitVaryingFromString("vClipSpacePosition",Ns.Vector4,"defined(IGNORE) || DEBUGMODE > 0")&&(e._injectAtEnd+="#if DEBUGMODE > 0\n",e._injectAtEnd+="vClipSpacePosition = gl_Position;\n",e._injectAtEnd+="#endif\n"),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:r.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = ".concat(r.associatedVariableName,";\n"),this.view.isConnected&&(e.compilationString+="mat4 view = ".concat(this.view.associatedVariableName,";\n")),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",n,{repeatKey:"maxSimultaneousLights"}))},t.prototype._getAlbedoOpacityCode=function(){var e="albedoOpacityOutParams albedoOpacityOut;\n",t=this.baseColor.isConnected?this.baseColor.associatedVariableName:"vec3(1.)",i=this.opacity.isConnected?this.opacity.associatedVariableName:"1.";return e+"albedoOpacityBlock(\n vec4(".concat(t,", 1.),\n #ifdef ALBEDO\n vec4(1.),\n vec2(1., 1.),\n #endif\n #ifdef OPACITY\n vec4(").concat(i,"),\n vec2(1., 1.),\n #endif\n albedoOpacityOut\n );\n\n vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;\n float alpha = albedoOpacityOut.alpha;\n")},t.prototype._getAmbientOcclusionCode=function(){var e="ambientOcclusionOutParams aoOut;\n",t=this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:"1.";return e+"ambientOcclusionBlock(\n #ifdef AMBIENT\n vec3(".concat(t,"),\n vec4(0., 1.0, 1.0, 0.),\n #endif\n aoOut\n );\n")},t.prototype._getReflectivityCode=function(e){var t="reflectivityOutParams reflectivityOut;\n";return this._vMetallicReflectanceFactorsName=e._getFreeVariableName("vMetallicReflectanceFactors"),e._emitUniformFromString(this._vMetallicReflectanceFactorsName,Ns.Vector4),t+"vec3 baseColor = surfaceAlbedo;\n\n reflectivityBlock(\n vec4(".concat(this.metallic.associatedVariableName,", ").concat(this.roughness.associatedVariableName,", 0., 0.),\n #ifdef METALLICWORKFLOW\n surfaceAlbedo,\n ").concat(this._vMetallicReflectanceFactorsName,",\n #endif\n #ifdef REFLECTIVITY\n vec3(0., 0., ").concat("1.","),\n vec4(1.),\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor,\n #endif\n #ifdef MICROSURFACEMAP\n microSurfaceTexel, <== not handled!\n #endif\n reflectivityOut\n );\n\n float microSurface = reflectivityOut.microSurface;\n float roughness = reflectivityOut.roughness;\n\n #ifdef METALLICWORKFLOW\n surfaceAlbedo = reflectivityOut.surfaceAlbedo;\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;\n #endif\n")},t.prototype._buildBlock=function(t){var i,r,n,o,a,s,l,c,u,h,d,p,f,_,m,g,v,y,b,T,E,S,x,A,C,R,P,I,M,O,D,N,F,L,w,B,U,V,k,G,z;e.prototype._buildBlock.call(this,t),this._scene=t.sharedData.scene,this._environmentBRDFTexture||(this._environmentBRDFTexture=km(this._scene));var W=this.reflection.isConnected?null===(i=this.reflection.connectedPoint)||void 0===i?void 0:i.ownerBlock:null;if(W&&(W.worldPositionConnectionPoint=this.worldPosition,W.cameraPositionConnectionPoint=this.cameraPosition,W.worldNormalConnectionPoint=this.worldNormal,W.viewConnectionPoint=this.view),t.target!==Fs.Fragment)return this._injectVertexCode(t),this;t.sharedData.forcedBindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this),t.sharedData.blockingBlocks.push(this),this.generateOnlyFragmentCode&&t.sharedData.dynamicUniformBlocks.push(this);var H="//".concat(this.name),X=this.perturbedNormal,j=this.worldPosition.associatedVariableName;this.generateOnlyFragmentCode?(j=t._getFreeVariableName("globalWorldPos"),t._emitFunction("pbr_globalworldpos","vec3 ".concat(j,";\n"),H),t.compilationString+="".concat(j," = ").concat(this.worldPosition.associatedVariableName,".xyz;\n"),t.compilationString+=t._emitCodeFromInclude("shadowsVertex",H,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"worldPos,".concat(this.worldPosition.associatedVariableName):void 0}),t.compilationString+="#if DEBUGMODE > 0\n",t.compilationString+="vec4 vClipSpacePosition = vec4((vec2(gl_FragCoord.xy) / vec2(1.0)) * 2.0 - 1.0, 0.0, 1.0);\n",t.compilationString+="#endif\n"):j="v_"+j,this._environmentBrdfSamplerName=t._getFreeVariableName("environmentBrdfSampler"),t._emit2DSampler(this._environmentBrdfSamplerName),t.sharedData.hints.needAlphaBlending=t.sharedData.hints.needAlphaBlending||this.useAlphaBlending,t.sharedData.hints.needAlphaTesting=t.sharedData.hints.needAlphaTesting||this.useAlphaTest,t._emitExtension("lod","#extension GL_EXT_shader_texture_lod : enable","defined(LODBASEDMICROSFURACE)"),t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),t._emitUniformFromString("vDebugMode",Ns.Vector2,"defined(IGNORE) || DEBUGMODE > 0"),t._emitUniformFromString("ambientFromScene",Ns.Vector3),t.uniforms.push("exposureLinear"),t.uniforms.push("contrast"),t.uniforms.push("vInverseScreenSize"),t.uniforms.push("vignetteSettings1"),t.uniforms.push("vignetteSettings2"),t.uniforms.push("vCameraColorCurveNegative"),t.uniforms.push("vCameraColorCurveNeutral"),t.uniforms.push("vCameraColorCurvePositive"),t.uniforms.push("txColorTransform"),t.uniforms.push("colorTransformSettings"),t.uniforms.push("ditherIntensity"),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",H,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",H,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"varying,":void 0}),t._emitFunctionFromInclude("helperFunctions",H),t._emitFunctionFromInclude("importanceSampling",H),t._emitFunctionFromInclude("pbrHelperFunctions",H),t._emitFunctionFromInclude("imageProcessingDeclaration",H),t._emitFunctionFromInclude("imageProcessingFunctions",H),t._emitFunctionFromInclude("shadowsFragmentFunctions",H),t._emitFunctionFromInclude("pbrDirectLightingSetupFunctions",H,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions",H),t._emitFunctionFromInclude("pbrBRDFFunctions",H,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(r=null==W?void 0:W._defineSkyboxName)&&void 0!==r?r:"REFLECTIONMAP_SKYBOX"}]}),t._emitFunctionFromInclude("hdrFilteringFunctions",H),t._emitFunctionFromInclude("pbrDirectLightingFunctions",H,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrIBLFunctions",H),t._emitFunctionFromInclude("pbrBlockAlbedoOpacity",H),t._emitFunctionFromInclude("pbrBlockReflectivity",H),t._emitFunctionFromInclude("pbrBlockAmbientOcclusion",H),t._emitFunctionFromInclude("pbrBlockAlphaFresnel",H),t._emitFunctionFromInclude("pbrBlockAnisotropic",H),t._emitUniformFromString("vLightingIntensity",Ns.Vector4),(null==W?void 0:W.generateOnlyFragmentCode)&&(t.compilationString+=W.handleVertexSide(t)),this._vNormalWName=t._getFreeVariableName("vNormalW"),t.compilationString+="vec4 ".concat(this._vNormalWName," = normalize(").concat(this.worldNormal.associatedVariableName,");\n"),t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName," - ").concat(j,".xyz);\n")),t.compilationString+="vec3 geometricNormalW = ".concat(this._vNormalWName,".xyz;\n"),t.compilationString+="vec3 normalW = ".concat(X.isConnected?"normalize("+X.associatedVariableName+".xyz)":"geometricNormalW",";\n"),this._invertNormalName=t._getFreeVariableName("invertNormal"),t._emitUniformFromString(this._invertNormalName,Ns.Float),t.compilationString+=t._emitCodeFromInclude("pbrBlockNormalFinal",H,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),t.compilationString+=this._getAlbedoOpacityCode(),t.compilationString+=t._emitCodeFromInclude("depthPrePass",H),t.compilationString+=this._getAmbientOcclusionCode(),t.compilationString+=t._emitCodeFromInclude("pbrBlockLightmapInit",H),t.compilationString+="#ifdef UNLIT\n vec3 diffuseBase = vec3(1., 1., 1.);\n #else\n",t.compilationString+=this._getReflectivityCode(t),t.compilationString+=t._emitCodeFromInclude("pbrBlockGeometryInfo",H,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(n=null==W?void 0:W._defineSkyboxName)&&void 0!==n?n:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:null!==(o=null==W?void 0:W._define3DName)&&void 0!==o?o:"REFLECTIONMAP_3D"}]});var Y=this.anisotropy.isConnected?null===(a=this.anisotropy.connectedPoint)||void 0===a?void 0:a.ownerBlock:null;Y&&(Y.worldPositionConnectionPoint=this.worldPosition,Y.worldNormalConnectionPoint=this.worldNormal,t.compilationString+=Y.getCode(t,!this.perturbedNormal.isConnected)),W&&W.hasTexture&&(t.compilationString+=W.getCode(t,Y?"anisotropicOut.anisotropicNormal":"normalW")),t._emitFunctionFromInclude("pbrBlockReflection",H,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:null!==(s=null==W?void 0:W._define3DName)&&void 0!==s?s:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(l=null==W?void 0:W._defineOppositeZ)&&void 0!==l?l:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(c=null==W?void 0:W._defineProjectionName)&&void 0!==c?c:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(u=null==W?void 0:W._defineSkyboxName)&&void 0!==u?u:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(h=null==W?void 0:W._defineLODReflectionAlpha)&&void 0!==h?h:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(d=null==W?void 0:W._defineLinearSpecularReflection)&&void 0!==d?d:"LINEARSPECULARREFLECTION"},{search:/vReflectionFilteringInfo/g,replace:null!==(p=null==W?void 0:W._vReflectionFilteringInfoName)&&void 0!==p?p:"vReflectionFilteringInfo"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance0",H,{replaceStrings:[{search:/metallicReflectanceFactors/g,replace:this._vMetallicReflectanceFactorsName}]});var K=this.sheen.isConnected?null===(f=this.sheen.connectedPoint)||void 0===f?void 0:f.ownerBlock:null;K&&(t.compilationString+=K.getCode(W)),t._emitFunctionFromInclude("pbrBlockSheen",H,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(_=null==W?void 0:W._define3DName)&&void 0!==_?_:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(m=null==W?void 0:W._defineSkyboxName)&&void 0!==m?m:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(g=null==W?void 0:W._defineLODReflectionAlpha)&&void 0!==g?g:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(v=null==W?void 0:W._defineLinearSpecularReflection)&&void 0!==v?v:"LINEARSPECULARREFLECTION"}]});var Q=this.iridescence.isConnected?null===(y=this.iridescence.connectedPoint)||void 0===y?void 0:y.ownerBlock:null;t.compilationString+=_T.GetCode(Q),t._emitFunctionFromInclude("pbrBlockIridescence",H,{replaceStrings:[]});var q=this.clearcoat.isConnected?null===(b=this.clearcoat.connectedPoint)||void 0===b?void 0:b.ownerBlock:null,Z=!this.perturbedNormal.isConnected&&!this.anisotropy.isConnected,J=this.perturbedNormal.isConnected&&(null===(E=(null===(T=this.perturbedNormal.connectedPoint)||void 0===T?void 0:T.ownerBlock).worldTangent)||void 0===E?void 0:E.isConnected),$=this.anisotropy.isConnected&&(null===(S=this.anisotropy.connectedPoint)||void 0===S?void 0:S.ownerBlock).worldTangent.isConnected,ee=J||!this.perturbedNormal.isConnected&&$;t.compilationString+=fT.GetCode(t,q,W,j,Z,ee,this.worldNormal.associatedVariableName),Z&&(ee=null!==(x=null==q?void 0:q.worldTangent.isConnected)&&void 0!==x&&x),t._emitFunctionFromInclude("pbrBlockClearcoat",H,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:null!==(A=null==W?void 0:W._define3DName)&&void 0!==A?A:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(C=null==W?void 0:W._defineOppositeZ)&&void 0!==C?C:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(R=null==W?void 0:W._defineProjectionName)&&void 0!==R?R:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(P=null==W?void 0:W._defineSkyboxName)&&void 0!==P?P:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(I=null==W?void 0:W._defineLODReflectionAlpha)&&void 0!==I?I:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(M=null==W?void 0:W._defineLinearSpecularReflection)&&void 0!==M?M:"LINEARSPECULARREFLECTION"},{search:/defined\(TANGENT\)/g,replace:ee?"defined(TANGENT)":"defined(IGNORE)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance",H,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(O=null==W?void 0:W._defineSkyboxName)&&void 0!==O?O:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:null!==(D=null==W?void 0:W._define3DName)&&void 0!==D?D:"REFLECTIONMAP_3D"}]});var te=this.subsurface.isConnected?null===(N=this.subsurface.connectedPoint)||void 0===N?void 0:N.ownerBlock:null,ie=this.subsurface.isConnected?null===(L=(null===(F=this.subsurface.connectedPoint)||void 0===F?void 0:F.ownerBlock).refraction.connectedPoint)||void 0===L?void 0:L.ownerBlock:null;ie&&(ie.viewConnectionPoint=this.view,ie.indexOfRefractionConnectionPoint=this.indexOfRefraction),t.compilationString+=gT.GetCode(t,te,W,j),t._emitFunctionFromInclude("pbrBlockSubSurface",H,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(w=null==W?void 0:W._define3DName)&&void 0!==w?w:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(B=null==W?void 0:W._defineOppositeZ)&&void 0!==B?B:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(U=null==W?void 0:W._defineProjectionName)&&void 0!==U?U:"REFLECTIONMAP_PROJECTION"},{search:/SS_REFRACTIONMAP_3D/g,replace:null!==(V=null==ie?void 0:ie._define3DName)&&void 0!==V?V:"SS_REFRACTIONMAP_3D"},{search:/SS_LODINREFRACTIONALPHA/g,replace:null!==(k=null==ie?void 0:ie._defineLODRefractionAlpha)&&void 0!==k?k:"SS_LODINREFRACTIONALPHA"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:null!==(G=null==ie?void 0:ie._defineLinearSpecularRefraction)&&void 0!==G?G:"SS_LINEARSPECULARREFRACTION"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:null!==(z=null==ie?void 0:ie._defineOppositeZ)&&void 0!==z?z:"SS_REFRACTIONMAP_OPPOSITEZ"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockDirectLighting",H),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",H,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/vPositionW/g,replace:j+".xyz"}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",H,{repeatKey:"maxSimultaneousLights",substitutionVars:"vPositionW,".concat(j,".xyz")}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalLitComponents",H),t.compilationString+="#endif\n";var re=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:"vec3(0., 0., 0.)",ne=ig.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();-1===ne.indexOf(".")&&(ne+="."),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalUnlitComponents",H,{replaceStrings:[{search:/vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,replace:""},{search:/vAmbientColor/g,replace:re+" * ambientFromScene"},{search:/vAmbientInfos\.w/g,replace:ne}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalColorComposition",H,{replaceStrings:[{search:/finalEmissive/g,replace:"vec3(0.)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockImageProcessing",H,{replaceStrings:[{search:/visibility/g,replace:"1."}]}),t.compilationString+=t._emitCodeFromInclude("pbrDebug",H,{replaceStrings:[{search:/vNormalW/g,replace:this._vNormalWName},{search:/vPositionW/g,replace:j},{search:/albedoTexture\.rgb;/g,replace:"vec3(1.);\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\n"}]});for(var oe=0,se=this._outputs;oe ").concat(this.b.associatedVariableName)),";\n");break;case TT.GreaterOrEqual:t.compilationString+=t._declareOutput(i)+" = ".concat(t._generateTertiary(r,n,"".concat(this.a.associatedVariableName," >= ").concat(this.b.associatedVariableName)),";\n");break;case TT.Xor:t.compilationString+=t._declareOutput(i)+" = ".concat(t._generateTertiary(r,n,"(((".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,") % 2.0) > 0.0)")),";\n");break;case TT.Or:t.compilationString+=t._declareOutput(i)+" = ".concat(t._generateTertiary(r,n,"(min(".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,", 1.0) > 0.0)")),";\n");break;case TT.And:t.compilationString+=t._declareOutput(i)+" = ".concat(t._generateTertiary(r,n,"(".concat(this.a.associatedVariableName," * ").concat(this.b.associatedVariableName," > 0.0)")),";\n")}return this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.condition=this.condition,t},t.prototype._deserialize=function(t,i,r){e.prototype._deserialize.call(this,t,i,r),this.condition=t.condition},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".condition = BABYLON.ConditionalBlockConditions.").concat(TT[this.condition],";\n")},t}(Ws);a("BABYLON.ConditionalBlock",ST);var xT=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.octaves=6,i.registerInput("seed",Ns.AutoDetect),i.registerInput("chaos",Ns.AutoDetect,!0),i.registerInput("offsetX",Ns.Float,!0),i.registerInput("offsetY",Ns.Float,!0),i.registerInput("offsetZ",Ns.Float,!0),i.registerOutput("output",Ns.Float),i._inputs[0].acceptedConnectionPointTypes.push(Ns.Vector2),i._inputs[0].acceptedConnectionPointTypes.push(Ns.Vector3),i._linkConnectionTypes(0,1),i}return m(t,e),t.prototype.getClassName=function(){return"CloudBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chaos",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetX",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetY",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetZ",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){var i,r;if(e.prototype._buildBlock.call(this,t),this.seed.isConnected&&this._outputs[0].hasEndpoints){var n="fbm".concat(this.octaves);t._emitFunction("CloudBlockCode","\n\n float cloudRandom(in float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }\n\n // Based on Morgan McGuire @morgan3d\n // https://www.shadertoy.com/view/4dS3Wd\n float cloudNoise(in vec2 x, in vec2 chaos) {\n vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);\n\n vec2 i = floor(x);\n vec2 f = fract(x);\n\n float n = dot(i, step);\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),\n mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),\n u.y\n );\n }\n\n float cloudNoise(in vec3 x, in vec3 chaos) {\n vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);\n\n vec3 i = floor(x);\n vec3 f = fract(x);\n\n float n = dot(i, step);\n\n vec3 u = f * f * (3.0 - 2.0 * f);\n return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\n mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\n }","// CloudBlockCode"),t._emitFunction("CloudBlockCodeFBM"+this.octaves,"\n float fbm(in vec2 st, in vec2 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = .5;\n float frequency = 0.;\n\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitude * cloudNoise(st, chaos);\n st *= 2.0;\n amplitude *= 0.5;\n }\n return value;\n }\n\n float fbm(in vec3 x, in vec3 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < OCTAVES; ++i) {\n value += amplitude * cloudNoise(x, chaos);\n x = x * 2.0;\n amplitude *= 0.5;\n }\n return value;\n }".replace(/fbm/gi,n).replace(/OCTAVES/gi,(0|this.octaves).toString()),"// CloudBlockCode FBM");var o=t._getFreeVariableName("st"),a=(null===(i=this.seed.connectedPoint)||void 0===i?void 0:i.type)===Ns.Vector2?"vec2":"vec3";t.compilationString+="".concat(a," ").concat(o," = ").concat(this.seed.associatedVariableName,";\n"),this.offsetX.isConnected&&(t.compilationString+="".concat(o,".x += 0.1 * ").concat(this.offsetX.associatedVariableName,";\n")),this.offsetY.isConnected&&(t.compilationString+="".concat(o,".y += 0.1 * ").concat(this.offsetY.associatedVariableName,";\n")),this.offsetZ.isConnected&&"vec3"===a&&(t.compilationString+="".concat(o,".z += 0.1 * ").concat(this.offsetZ.associatedVariableName,";\n"));var s;return s=this.chaos.isConnected?this.chaos.associatedVariableName:(null===(r=this.seed.connectedPoint)||void 0===r?void 0:r.type)===Ns.Vector2?"vec2(0., 0.)":"vec3(0., 0., 0.)",t.compilationString+=t._declareOutput(this._outputs[0])+" = ".concat(n,"(").concat(o,", ").concat(s,");\n"),this}},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".octaves = ").concat(this.octaves,";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.octaves=this.octaves,t},t.prototype._deserialize=function(t,i,r){e.prototype._deserialize.call(this,t,i,r),this.octaves=t.octaves},v([Ys("Octaves",Xs.Int)],t.prototype,"octaves",void 0),t}(Ws);a("BABYLON.CloudBlock",xT);var AT=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.registerInput("seed",Ns.Vector2),i.registerInput("offset",Ns.Float),i.registerInput("density",Ns.Float),i.registerOutput("output",Ns.Float),i.registerOutput("cells",Ns.Float),i}return m(t,e),t.prototype.getClassName=function(){return"VoronoiNoiseBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offset",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"density",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cells",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),this.seed.isConnected){var i="vec2 voronoiRandom(vec2 seed, float offset){\n mat2 m = mat2(15.27, 47.63, 99.41, 89.98);\n vec2 uv = fract(sin(m * seed) * 46839.32);\n return vec2(sin(uv.y * offset) * 0.5 + 0.5, cos(uv.x * offset) * 0.5 + 0.5);\n }\n ";t.shaderLanguage===pt.WGSL&&(i=t._babylonSLtoWGSL(i)),t._emitFunction("voronoiRandom",i,"// Voronoi random generator"),i="void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){\n vec2 g = floor(seed * density);\n vec2 f = fract(seed * density);\n float t = 8.0;\n vec3 res = vec3(8.0, 0.0, 0.0);\n\n for(int y=-1; y<=1; y++)\n {\n for(int x=-1; x<=1; x++)\n {\n vec2 lattice = vec2(float(x),float(y));\n vec2 randomOffset = voronoiRandom(lattice + g, offset);\n float d = distance(lattice + randomOffset, f);\n if(d < res.x)\n {\n res = vec3(d, randomOffset.x, randomOffset.y);\n [*]outValue = res.x;\n [*]cells = res.y;\n }\n }\n }\n }\n ",i=t.shaderLanguage===pt.WGSL?t._babylonSLtoWGSL(i):t._babylonSLtoGLSL(i),t._emitFunction("voronoi",i,"// Voronoi");var r=t._getFreeVariableName("tempOutput"),n=t._getFreeVariableName("tempCells"),o=t.shaderLanguage===pt.WGSL?"&":"";return t.compilationString+="".concat(t._declareLocalVar(r,Ns.Float)," = 0.0;\n"),t.compilationString+="".concat(t._declareLocalVar(n,Ns.Float)," = 0.0;\n"),t.compilationString+="voronoi(".concat(this.seed.associatedVariableName,", ").concat(this.offset.associatedVariableName,", ").concat(this.density.associatedVariableName,", ").concat(o).concat(r,", ").concat(o).concat(n,");\n"),this.output.hasEndpoints&&(t.compilationString+=t._declareOutput(this.output)+" = ".concat(r,";\n")),this.cells.hasEndpoints&&(t.compilationString+=t._declareOutput(this.cells)+" = ".concat(n,";\n")),this}},t}(Ws);a("BABYLON.VoronoiNoiseBlock",AT);var CT=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.registerInput("input",Ns.AutoDetect),i.registerOutput("output",Ns.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return m(t,e),t.prototype.getClassName=function(){return"ElbowBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e=this._inputs[0];if(e.isConnected){var t=e.connectedPoint.ownerBlock;if(t.target!==Fs.VertexAndFragment)return t.target;if(e.connectedPoint.target!==Fs.VertexAndFragment)return e.connectedPoint.target}return this._target},set:function(e){this._target&e||(this._target=e)},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],r=this._inputs[0];return t.compilationString+=t._declareOutput(i)+" = ".concat(r.associatedVariableName,";\n"),this},t}(Ws);a("BABYLON.ElbowBlock",CT);var RT=function(e){function t(t,i){void 0===i&&(i=!1);var r=e.call(this,t,Fs.Neutral)||this;return r.projectAsCube=!1,r._convertToGammaSpace=!1,r._convertToLinearSpace=!1,r.disableLevelMultiplication=!1,r.registerInput("position",Ns.AutoDetect,!1),r.registerInput("normal",Ns.AutoDetect,!1),r.registerInput("sharpness",Ns.Float,!0),r.registerInput("source",Ns.Object,!0,Fs.VertexAndFragment,new Qy("source",r,Us.Input,mb,"ImageSourceBlock")),r.registerInput("sourceY",Ns.Object,!0,Fs.VertexAndFragment,new Qy("sourceY",r,Us.Input,mb,"ImageSourceBlock")),i||r.registerInput("sourceZ",Ns.Object,!0,Fs.VertexAndFragment,new Qy("sourceZ",r,Us.Input,mb,"ImageSourceBlock")),r.registerOutput("rgba",Ns.Color4,Fs.Neutral),r.registerOutput("rgb",Ns.Color3,Fs.Neutral),r.registerOutput("r",Ns.Float,Fs.Neutral),r.registerOutput("g",Ns.Float,Fs.Neutral),r.registerOutput("b",Ns.Float,Fs.Neutral),r.registerOutput("a",Ns.Float,Fs.Neutral),r.registerOutput("level",Ns.Float,Fs.Neutral),r._inputs[0].addExcludedConnectionPointFromAllowedTypes(Ns.Color3|Ns.Vector3|Ns.Vector4),r._inputs[1].addExcludedConnectionPointFromAllowedTypes(Ns.Color3|Ns.Vector3|Ns.Vector4),r}return m(t,e),Object.defineProperty(t.prototype,"texture",{get:function(){var e;return this.source.isConnected?(null===(e=this.source.connectedPoint)||void 0===e?void 0:e.ownerBlock).texture:this._texture},set:function(e){var t,i=this;if(this._texture!==e){var r=null!==(t=null==e?void 0:e.getScene())&&void 0!==t?t:M.LastCreatedScene;!e&&r&&r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i._texture)})),this._texture=e,e&&r&&r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(t){return t.hasTexture(e)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureY",{get:function(){var e;return this.sourceY.isConnected?(null===(e=this.sourceY.connectedPoint)||void 0===e?void 0:e.ownerBlock).texture:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureZ",{get:function(){var e,t;return(null===(e=this.sourceZ)||void 0===e?void 0:e.isConnected)?(null===(t=this.sourceY.connectedPoint)||void 0===t?void 0:t.ownerBlock).texture:null},enumerable:!1,configurable:!0}),t.prototype._getImageSourceBlock=function(e){return(null==e?void 0:e.isConnected)?e.connectedPoint.ownerBlock:null},Object.defineProperty(t.prototype,"samplerName",{get:function(){var e=this._getImageSourceBlock(this.source);return e?e.samplerName:this._samplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerYName",{get:function(){var e,t;return null!==(t=null===(e=this._getImageSourceBlock(this.sourceY))||void 0===e?void 0:e.samplerName)&&void 0!==t?t:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerZName",{get:function(){var e,t;return null!==(t=null===(e=this._getImageSourceBlock(this.sourceZ))||void 0===e?void 0:e.samplerName)&&void 0!==t?t:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasImageSource",{get:function(){return this.source.isConnected},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToGammaSpace",{get:function(){return this._convertToGammaSpace},set:function(e){var t,i=this;if(e!==this._convertToGammaSpace&&(this._convertToGammaSpace=e,this.texture)){var r=null!==(t=this.texture.getScene())&&void 0!==t?t:M.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i.texture)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToLinearSpace",{get:function(){return this._convertToLinearSpace},set:function(e){var t,i=this;if(e!==this._convertToLinearSpace&&(this._convertToLinearSpace=e,this.texture)){var r=null!==(t=this.texture.getScene())&&void 0!==t?t:M.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(u.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i.texture)}))}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TriPlanarBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sharpness",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceY",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceZ",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,t,i){if(i._areTexturesDirty){var r=this.convertToGammaSpace&&this.texture&&!this.texture.gammaSpace,n=this.convertToLinearSpace&&this.texture&&this.texture.gammaSpace;i.setValue(this._linearDefineName,r,!0),i.setValue(this._gammaDefineName,n,!0)}},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.bind=function(e){this.texture&&(e.setFloat(this._textureInfoName,this.texture.level),this._imageSource||e.setTexture(this._samplerName,this.texture))},t.prototype._generateTextureLookup=function(e){var t,i,r=this.samplerName,n=null!==(t=this.samplerYName)&&void 0!==t?t:r,o=null!==(i=this.samplerZName)&&void 0!==i?i:r,a=this.sharpness.isConnected?this.sharpness.associatedVariableName:"1.0",s=e._getFreeVariableName("x"),l=e._getFreeVariableName("y"),c=e._getFreeVariableName("z"),u=e._getFreeVariableName("w"),h=e._getFreeVariableName("n"),d=e._getFreeVariableName("uvx"),p=e._getFreeVariableName("uvy"),f=e._getFreeVariableName("uvz");e.compilationString+="\n vec3 ".concat(h," = ").concat(this.normal.associatedVariableName,".xyz;\n\n vec2 ").concat(d," = ").concat(this.position.associatedVariableName,".yz;\n vec2 ").concat(p," = ").concat(this.position.associatedVariableName,".zx;\n vec2 ").concat(f," = ").concat(this.position.associatedVariableName,".xy;\n "),this.projectAsCube&&(e.compilationString+="\n ".concat(d,".xy = ").concat(d,".yx;\n\n if (").concat(h,".x >= 0.0) {\n ").concat(d,".x = -").concat(d,".x;\n }\n if (").concat(h,".y < 0.0) {\n ").concat(p,".y = -").concat(p,".y;\n }\n if (").concat(h,".z < 0.0) {\n ").concat(f,".x = -").concat(f,".x;\n }\n ")),e.compilationString+="\n vec4 ".concat(s," = texture2D(").concat(r,", ").concat(d,");\n vec4 ").concat(l," = texture2D(").concat(n,", ").concat(p,");\n vec4 ").concat(c," = texture2D(").concat(o,", ").concat(f,");\n \n // blend weights\n vec3 ").concat(u," = pow(abs(").concat(h,"), vec3(").concat(a,"));\n\n // blend and return\n vec4 ").concat(this._tempTextureRead," = (").concat(s,"*").concat(u,".x + ").concat(l,"*").concat(u,".y + ").concat(c,"*").concat(u,".z) / (").concat(u,".x + ").concat(u,".y + ").concat(u,".z); \n ")},t.prototype._generateConversionCode=function(e,t,i){"a"!==i&&(this.texture&&this.texture.gammaSpace||(e.compilationString+="#ifdef ".concat(this._linearDefineName,"\n ").concat(t.associatedVariableName," = toGammaSpace(").concat(t.associatedVariableName,");\n #endif\n ")),e.compilationString+="#ifdef ".concat(this._gammaDefineName,"\n ").concat(t.associatedVariableName," = toLinearSpace(").concat(t.associatedVariableName,");\n #endif\n "))},t.prototype._writeOutput=function(e,t,i){var r="";this.disableLevelMultiplication||(r=" * ".concat(this._textureInfoName)),e.compilationString+="".concat(e._declareOutput(t)," = ").concat(this._tempTextureRead,".").concat(i).concat(r,";\n"),this._generateConversionCode(e,t,i)},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),this.source.isConnected?this._imageSource=this.source.connectedPoint.ownerBlock:this._imageSource=null,this._textureInfoName=t._getFreeVariableName("textureInfoName"),this.level.associatedVariableName=this._textureInfoName,this._tempTextureRead=t._getFreeVariableName("tempTextureRead"),this._linearDefineName=t._getFreeDefineName("ISLINEAR"),this._gammaDefineName=t._getFreeDefineName("ISGAMMA"),this._imageSource||(this._samplerName=t._getFreeVariableName(this.name+"Sampler"),t._emit2DSampler(this._samplerName)),t.sharedData.blockingBlocks.push(this),t.sharedData.textureBlocks.push(this),t.sharedData.blocksWithDefines.push(this),t.sharedData.bindableBlocks.push(this);var i="//".concat(this.name);t._emitFunctionFromInclude("helperFunctions",i),t._emitUniformFromString(this._textureInfoName,Ns.Float),this._generateTextureLookup(t);for(var r=0,n=this._outputs;r").concat(s,".y && ").concat(s,".x>").concat(s,".z) ? ivec3(0,1,2) :\n (").concat(s,".y>").concat(s,".z) ? ivec3(1,2,0) :\n ivec3(2,0,1) ;\n // determine minor axis (in x; yz are following axis)\n ivec3 ").concat(c," = (").concat(s,".x<").concat(s,".y && ").concat(s,".x<").concat(s,".z) ? ivec3(0,1,2) :\n (").concat(s,".y<").concat(s,".z) ? ivec3(1,2,0) :\n ivec3(2,0,1) ;\n // determine median axis (in x; yz are following axis)\n ivec3 ").concat(u," = ivec3(3) - ").concat(c," - ").concat(l,";\n \n // project+fetch\n vec4 ").concat(h," = textureGrad( ").concat(i,", vec2( ").concat(this.position.associatedVariableName,"[").concat(l,".y], ").concat(this.position.associatedVariableName,"[").concat(l,".z]), \n vec2(").concat(o,"[").concat(l,".y],").concat(o,"[").concat(l,".z]), \n vec2(").concat(a,"[").concat(l,".y],").concat(a,"[").concat(l,".z]) );\n vec4 ").concat(d," = textureGrad( ").concat(r,", vec2( ").concat(this.position.associatedVariableName,"[").concat(u,".y], ").concat(this.position.associatedVariableName,"[").concat(u,".z]), \n vec2(").concat(o,"[").concat(u,".y],").concat(o,"[").concat(u,".z]),\n vec2(").concat(a,"[").concat(u,".y],").concat(a,"[").concat(u,".z]) );\n \n // blend factors\n vec2 ").concat(p," = vec2(").concat(s,"[").concat(l,".x],").concat(s,"[").concat(u,".x]);\n // make local support\n ").concat(p," = clamp( (").concat(p,"-0.5773)/(1.0-0.5773), 0.0, 1.0 );\n // shape transition\n ").concat(p," = pow( ").concat(p,", vec2(").concat(n,"/8.0) );\n // blend and return\n vec4 ").concat(this._tempTextureRead," = (").concat(h,"*").concat(p,".x + ").concat(d,"*").concat(p,".y) / (").concat(p,".x + ").concat(p,".y);\n ")},t}(RT);a("BABYLON.BiPlanarBlock",PT);var IT=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.registerInput("input",Ns.Matrix),i.registerOutput("output",Ns.Float),i}return m(t,e),t.prototype.getClassName=function(){return"MatrixDeterminantBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.output,r=this.input;return t.compilationString+=t._declareOutput(i)+" = determinant(".concat(r.associatedVariableName,");\n"),this},t}(Ws);a("BABYLON.MatrixDeterminantBlock",IT);var MT,OT=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.registerInput("input",Ns.Matrix),i.registerOutput("output",Ns.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"MatrixTransposeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.output,r=this.input;return t.compilationString+=t._declareOutput(i)+"".concat(i.associatedVariableName," = transpose(").concat(r.associatedVariableName,");\n"),this},t}(Ws);a("BABYLON.MatrixTransposeBlock",OT),function(e){e[e.None=0]="None",e[e.Normal=1]="Normal",e[e.Tangent=2]="Tangent",e[e.VertexColor=3]="VertexColor",e[e.UV1=4]="UV1",e[e.UV2=5]="UV2",e[e.UV3=6]="UV3",e[e.UV4=7]="UV4",e[e.UV5=8]="UV5",e[e.UV6=9]="UV6"}(MT||(MT={}));var DT,NT=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.attributeType=MT.None,i.registerInput("input",Ns.AutoDetect),i.registerInput("fallback",Ns.AutoDetect),i.registerOutput("output",Ns.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._inputs[0].onConnectionObservable.add((function(e){var t;if(!i.attributeType){var r=e.ownerBlock;if(r instanceof rl&&r.isAttribute)switch(r.name){case"color":i.attributeType=MT.VertexColor;break;case"normal":i.attributeType=MT.Normal;break;case"tangent":i.attributeType=MT.Tangent;break;case"uv":i.attributeType=MT.UV1;break;case"uv2":i.attributeType=MT.UV2;break;case"uv3":i.attributeType=MT.UV3;break;case"uv4":i.attributeType=MT.UV4;break;case"uv5":i.attributeType=MT.UV5;break;case"uv6":i.attributeType=MT.UV6}else if(r instanceof Jy)switch(null===(t=i.input.connectedPoint)||void 0===t?void 0:t.name){case"normalOutput":i.attributeType=MT.Normal;break;case"tangentOutput":i.attributeType=MT.Tangent;break;case"uvOutput":i.attributeType=MT.UV1}}})),i}return m(t,e),t.prototype.getClassName=function(){return"MeshAttributeExistsBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fallback",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=null;switch(this.attributeType){case MT.VertexColor:i="VERTEXCOLOR_NME";break;case MT.Normal:i="NORMAL";break;case MT.Tangent:i="TANGENT";break;case MT.UV1:i="UV1";break;case MT.UV2:i="UV2";break;case MT.UV3:i="UV3";break;case MT.UV4:i="UV4";break;case MT.UV5:i="UV5";break;case MT.UV6:i="UV6"}var r=t._declareOutput(this.output);return i&&(t.compilationString+="#ifdef ".concat(i,"\n")),t.compilationString+="".concat(r," = ").concat(this.input.associatedVariableName,";\n"),i&&(t.compilationString+="#else\n",t.compilationString+="".concat(r," = ").concat(this.fallback.associatedVariableName,";\n"),t.compilationString+="#endif\n"),this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.attributeType=this.attributeType,t},t.prototype._deserialize=function(t,i,r){var n;e.prototype._deserialize.call(this,t,i,r),this.attributeType=null!==(n=t.attributeType)&&void 0!==n?n:MT.None},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".attributeType = ").concat(this.attributeType,";\n")},v([Ys("Attribute lookup",Xs.List,void 0,{notifiers:{update:!0},options:[{label:"(None)",value:MT.None},{label:"Normal",value:MT.Normal},{label:"Tangent",value:MT.Tangent},{label:"Vertex Color",value:MT.VertexColor},{label:"UV1",value:MT.UV1},{label:"UV2",value:MT.UV2},{label:"UV3",value:MT.UV3},{label:"UV4",value:MT.UV4},{label:"UV5",value:MT.UV5},{label:"UV6",value:MT.UV6}]})],t.prototype,"attributeType",void 0),t}(Ws);a("BABYLON.MeshAttributeExistsBlock",NT),function(e){e[e.EaseInSine=0]="EaseInSine",e[e.EaseOutSine=1]="EaseOutSine",e[e.EaseInOutSine=2]="EaseInOutSine",e[e.EaseInQuad=3]="EaseInQuad",e[e.EaseOutQuad=4]="EaseOutQuad",e[e.EaseInOutQuad=5]="EaseInOutQuad",e[e.EaseInCubic=6]="EaseInCubic",e[e.EaseOutCubic=7]="EaseOutCubic",e[e.EaseInOutCubic=8]="EaseInOutCubic",e[e.EaseInQuart=9]="EaseInQuart",e[e.EaseOutQuart=10]="EaseOutQuart",e[e.EaseInOutQuart=11]="EaseInOutQuart",e[e.EaseInQuint=12]="EaseInQuint",e[e.EaseOutQuint=13]="EaseOutQuint",e[e.EaseInOutQuint=14]="EaseInOutQuint",e[e.EaseInExpo=15]="EaseInExpo",e[e.EaseOutExpo=16]="EaseOutExpo",e[e.EaseInOutExpo=17]="EaseInOutExpo",e[e.EaseInCirc=18]="EaseInCirc",e[e.EaseOutCirc=19]="EaseOutCirc",e[e.EaseInOutCirc=20]="EaseInOutCirc",e[e.EaseInBack=21]="EaseInBack",e[e.EaseOutBack=22]="EaseOutBack",e[e.EaseInOutBack=23]="EaseInOutBack",e[e.EaseInElastic=24]="EaseInElastic",e[e.EaseOutElastic=25]="EaseOutElastic",e[e.EaseInOutElastic=26]="EaseInOutElastic"}(DT||(DT={}));var FT=function(e){function t(t){var i=e.call(this,t,Fs.Neutral)||this;return i.type=DT.EaseInOutSine,i.registerInput("input",Ns.AutoDetect),i.registerOutput("output",Ns.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(Ns.Matrix),i._inputs[0].excludedConnectionPointTypes.push(Ns.Object),i._inputs[0].excludedConnectionPointTypes.push(Ns.Int),i}return m(t,e),t.prototype.getClassName=function(){return"CurveBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._duplicateEntry=function(e,t){return"ret.".concat(t," = ").concat(e.replace(/VAL/g,"v."+t))},t.prototype._duplicateEntryDirect=function(e){return"return ".concat(e.replace(/VAL/g,"v"))},t.prototype._duplicateVector=function(e,t,i){if("float"===t||"f32"===t)return this._duplicateEntryDirect(e);for(var r=parseInt(t.replace("vec","")),n=i?"\n var ret: vec".concat(r,"f = vec").concat(r,"f(0.0);\n "):"\n vec".concat(r," ret = vec").concat(r,"(0.0);\n "),o=1;o<=r;o++)n+=this._duplicateEntry(e,1===o?"x":2===o?"y":3===o?"z":"w")+";\n";return n+"return ret;\n"},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i,r=this._outputs[0],n="",o=t._getShaderType(this.input.type),a=t.shaderLanguage===pt.WGSL;switch(i=DT[this.type]+"_"+o.replace("<","").replace(">",""),this.type){case DT.EaseInSine:n="return 1.0 - cos((v * 3.1415) / 2.0)";break;case DT.EaseOutSine:n="return sin((v * 3.1415) / 2.0)";break;case DT.EaseInOutSine:n="return -(cos(v * 3.1415) - 1.0) / 2.0";break;case DT.EaseInQuad:n="return v * v";break;case DT.EaseOutQuad:n="return (1.0 - v) * (1.0 - v)";break;case DT.EaseInOutQuad:var s=t._generateTertiary("2.0 * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 2.0) / 2.0","VAL < 0.5");n=this._duplicateVector(s,o,a);break;case DT.EaseInCubic:n="return v * v * v";break;case DT.EaseOutCubic:s="1.0 - pow(1.0 - VAL, 3.0)",n=this._duplicateVector(s,o,a);break;case DT.EaseInOutCubic:s=t._generateTertiary("4.0 * VAL * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 3.0) / 2.0","VAL < 0.5"),n=this._duplicateVector(s,o,a);break;case DT.EaseInQuart:n="return v * v * v * v";break;case DT.EaseOutQuart:s="1.0 - pow(1.0 - VAL, 4.0)",n=this._duplicateVector(s,o,a);break;case DT.EaseInOutQuart:s=t._generateTertiary("8.0 * VAL * VAL * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 4.0) / 2.0","VAL < 0.5"),n=this._duplicateVector(s,o,a);break;case DT.EaseInQuint:n="return v * v * v * v * v";break;case DT.EaseOutQuint:s="1.0 - pow(1.0 - VAL, 5.0)",n=this._duplicateVector(s,o,a);break;case DT.EaseInOutQuint:s=t._generateTertiary("16.0 * VAL * VAL * VAL * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 5.0) / 2.0","VAL < 0.5"),n=this._duplicateVector(s,o,a);break;case DT.EaseInExpo:s=t._generateTertiary("0.0","pow(2.0, 10.0 * VAL - 10.0)","VAL == 0.0"),n=this._duplicateVector(s,o,a);break;case DT.EaseOutExpo:s=t._generateTertiary("1.0","1.0 - pow(2.0, -10.0 * VAL)","VAL == 1.0"),n=this._duplicateVector(s,o,a);break;case DT.EaseInOutExpo:s=t._generateTertiary("0.0",t._generateTertiary("1.0",t._generateTertiary("pow(2.0, 20.0 * VAL - 10.0) / 2.0","(2.0 - pow(2.0, -20.0 * VAL + 10.0)) / 2.0","VAL < 0.5"),"VAL == 1.0"),"VAL == 0.0"),n=this._duplicateVector(s,o,a);break;case DT.EaseInCirc:s="1.0 - sqrt(1.0 - pow(VAL, 2.0))",n=this._duplicateVector(s,o,a);break;case DT.EaseOutCirc:s="sqrt(1.0 - pow(VAL - 1.0, 2.0))",n=this._duplicateVector(s,o,a);break;case DT.EaseInOutCirc:s=t._generateTertiary("(1.0 - sqrt(1.0 - pow(2.0 * VAL, 2.0))) / 2.0","(sqrt(1.0 - pow(-2.0 * VAL + 2.0, 2.0)) + 1.0) / 2.0","VAL < 0.5"),n=this._duplicateVector(s,o,a);break;case DT.EaseInBack:n="return 2.70158 * v * v * v - 1.70158 * v * v";break;case DT.EaseOutBack:s="2.70158 * pow(VAL - 1.0, 3.0) + 1.70158 * pow(VAL - 1.0, 2.0)",n=this._duplicateVector(s,o,a);break;case DT.EaseInOutBack:s=t._generateTertiary("(pow(2.0 * VAL, 2.0) * ((3.5949095) * 2.0 * VAL - 2.5949095)) / 2.0","(pow(2.0 * VAL - 2.0, 2.0) * (3.5949095 * (VAL * 2.0 - 2.0) + 3.5949095) + 2.0) / 2.0","VAL < 0.5"),n=this._duplicateVector(s,o,a);break;case DT.EaseInElastic:s=t._generateTertiary("0.0",t._generateTertiary("1.0","-pow(2.0, 10.0 * VAL - 10.0) * sin((VAL * 10.0 - 10.75) * ((2.0 * 3.1415) / 3.0))","VAL == 1.0"),"VAL == 0.0"),n=this._duplicateVector(s,o,a);break;case DT.EaseOutElastic:s=t._generateTertiary("0.0",t._generateTertiary("1.0","pow(2.0, -10.0 * VAL) * sin((VAL * 10.0 - 0.75) * ((2.0 * 3.1415) / 3.0)) + 1.0","VAL == 1.0"),"VAL == 0.0"),n=this._duplicateVector(s,o,a);break;case DT.EaseInOutElastic:s=t._generateTertiary("0.0",t._generateTertiary("1.0",t._generateTertiary("-(pow(2.0, 20.0 * VAL - 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0","(pow(2.0, -20.0 * VAL + 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 + 1.0","VAL < 0.5"),"VAL == 1.0"),"VAL == 0.0"),n=this._duplicateVector(s,o,a)}return a?t._emitFunction(i,"fn ".concat(i,"(v: ").concat(o,") -> ").concat(o," {").concat(n,";}\n"),""):t._emitFunction(i,"".concat(o," ").concat(i,"(").concat(o," v) {").concat(n,";}\n"),""),t.compilationString+=t._declareOutput(r)+" = ".concat(i,"(").concat(this.input.associatedVariableName,");\n"),this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.curveType=this.type,t},t.prototype._deserialize=function(t,i,r){e.prototype._deserialize.call(this,t,i,r),this.type=t.curveType},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".type = BABYLON.CurveBlockTypes.").concat(DT[this.type],";\n")},t}(Ws);a("BABYLON.CurveBlock",FT);var LT,wT,BT,UT=function(){function e(){}return e.prototype.optimize=function(e,t){},e}(),VT=function(){function e(){this.mm=new Map}return e.prototype.get=function(e,t){var i=this.mm.get(e);if(void 0!==i)return i.get(t)},e.prototype.set=function(e,t,i){var r=this.mm.get(e);void 0===r&&this.mm.set(e,r=new Map),r.set(t,i)},e}(),kT=function(){function e(e,t,i){var r=this;this._baseMaterial=e,this._scene=null!=t?t:M.LastCreatedScene,this._options=i,this._subMeshToEffect=new Map,this._subMeshToDepthWrapper=new VT,this._meshes=new Map,this._onEffectCreatedObserver=this._baseMaterial.onEffectCreatedObservable.add((function(e){var t,i,n=null===(t=e.subMesh)||void 0===t?void 0:t.getMesh();n&&!r._meshes.has(n)&&r._meshes.set(n,n.onDisposeObservable.add((function(e){for(var t=r._subMeshToEffect.keys(),i=t.next();!0!==i.done;i=t.next()){var n=i.value;(null==n?void 0:n.getMesh())===e&&(r._subMeshToEffect.delete(n),r._deleteDepthWrapperEffect(n))}}))),(null===(i=r._subMeshToEffect.get(e.subMesh))||void 0===i?void 0:i[0])!==e.effect&&(r._subMeshToEffect.set(e.subMesh,[e.effect,r._scene.getEngine().currentRenderPassId]),r._deleteDepthWrapperEffect(e.subMesh))}))}return Object.defineProperty(e.prototype,"standalone",{get:function(){var e,t;return null!==(t=null===(e=this._options)||void 0===e?void 0:e.standalone)&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMaterial",{get:function(){return this._baseMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doNotInjectCode",{get:function(){var e,t;return null!==(t=null===(e=this._options)||void 0===e?void 0:e.doNotInjectCode)&&void 0!==t&&t},enumerable:!1,configurable:!0}),e.prototype._deleteDepthWrapperEffect=function(e){var t=this._subMeshToDepthWrapper.mm.get(e);t&&(t.forEach((function(e){var t;null===(t=e.mainDrawWrapper.effect)||void 0===t||t.dispose()})),this._subMeshToDepthWrapper.mm.delete(e))},e.prototype.getEffect=function(e,t,i){var r,n=null===(r=this._subMeshToDepthWrapper.mm.get(e))||void 0===r?void 0:r.get(t);if(!n)return null;var o=n.drawWrapper[i];return o||(o=n.drawWrapper[i]=new ho(this._scene.getEngine())).setEffect(n.mainDrawWrapper.effect,n.mainDrawWrapper.defines),o},e.prototype.isReadyForSubMesh=function(e,t,i,r,n){var o,a;return!(this.standalone&&!this._baseMaterial.isReadyForSubMesh(e.getMesh(),e,r))&&null!==(a=null===(o=this._makeEffect(e,t,i,n))||void 0===o?void 0:o.isReady())&&void 0!==a&&a},e.prototype.dispose=function(){this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver),this._onEffectCreatedObserver=null;for(var e=this._meshes.entries(),t=e.next();!0!==t.done;t=e.next()){var i=t.value,r=i[0],n=i[1];r.onDisposeObservable.remove(n)}},e.prototype._makeEffect=function(e,t,i,r){var n,o,a,s=this._scene.getEngine(),l=this._subMeshToEffect.get(e);if(!l)return null;var c=l[0],u=l[1],h=this._subMeshToDepthWrapper.get(e,i);if(!h){var d=new ho(s);d.defines=null!==(o=null===(n=e._getDrawWrapper(u))||void 0===n?void 0:n.defines)&&void 0!==o?o:null,(h={drawWrapper:[],mainDrawWrapper:d,depthDefines:"",token:Qi()}).drawWrapper[r]=d,this._subMeshToDepthWrapper.set(e,i,h)}var p=t.join("\n");if(h.mainDrawWrapper.effect&&p===h.depthDefines)return h.mainDrawWrapper.effect;h.depthDefines=p;var f=c.getUniformNames().slice(),_=c.vertexSourceCodeBeforeMigration,m=c.fragmentSourceCodeBeforeMigration;if(!this.doNotInjectCode){var g=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):"#include",v=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):"#include",y=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):"#include",b="#include",T="#include";_=(_=-1!==(_=(_=c.shaderLanguage===pt.GLSL?_.replace(/void\s+?main/g,"\n".concat(T,"\nvoid main")):_.replace(/@vertex/g,"\n".concat(T,"\n@vertex"))).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,g)).indexOf("#define SHADOWDEPTH_METRIC")?_.replace(/#define SHADOWDEPTH_METRIC/g,v):_.replace(/}\s*$/g,v+"\n}")).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var E=m.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||m.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,S=-1!==m.indexOf("#define SHADOWDEPTH_FRAGMENT"),x="";E?m=m.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,y):x=y+"\n",m=m.replace(/void\s+?main/g,Ei.IncludesShadersStore.shadowMapFragmentExtraDeclaration+"\nvoid main"),S?m=m.replace(/#define SHADOWDEPTH_FRAGMENT/g,b):x+=b+"\n",x&&(m=m.replace(/}\s*$/g,x+"}")),f.push("biasAndScaleSM","depthValuesSM","lightDataSM","softTransparentShadowSM")}h.mainDrawWrapper.effect=s.createEffect({vertexSource:_,fragmentSource:m,vertexToken:h.token,fragmentToken:h.token},{attributes:c.getAttributesNames(),uniformsNames:f,uniformBuffersNames:c.getUniformBuffersNames(),samplers:c.getSamplers(),defines:p+"\n"+c.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:c.getIndexParameters(),shaderLanguage:c.shaderLanguage},s);for(var A=0;A0&&Array.isArray(e[0])&&e[0].length>0&&e[0][0]instanceof V){var n=[];return e.forEach((function(e){n.push(e.flatMap((function(e){return[e.x,e.y,e.z]})))})),n}if(e instanceof Float32Array)return[Array.from(e)];if(e.length&&e[0]instanceof Float32Array){var o=[];return e.forEach((function(e){o.push(Array.from(e))})),o}return[]},e.OmitZeroLengthPredicate=function(e,t,i){var r=[];return t.subtract(e).lengthSquared()>0&&r.push([e,t]),i.subtract(t).lengthSquared()>0&&r.push([t,i]),e.subtract(i).lengthSquared()>0&&r.push([i,e]),0===r.length?null:r},e.OmitDuplicatesPredicate=function(t,i,r,n){var o=[];return e._SearchInPoints(t,i,n)||o.push([t,i]),e._SearchInPoints(i,r,n)||o.push([i,r]),e._SearchInPoints(r,t,n)||o.push([r,t]),0===o.length?null:o},e._SearchInPoints=function(e,t,i){for(var r,n,o,a=0,s=i;ai?e.SegmentizeSegmentByCount(t.point1,t.point2,Math.ceil(t.length/i)).forEach((function(e){n.push(e)})):(n.push(t.point1),n.push(t.point2))})),n},e.SegmentizeLineBySegmentCount=function(t,i){var r="number"==typeof t[0]?e.ToVector3Array(t):t,n=e.GetLineLength(r)/i;return e.SegmentizeLineBySegmentLength(r,n)},e.GetLineSegments=function(e){for(var t=[],i=0;ia?a:i.length,l=Math.ceil(i.length/a);l>1&&(i=T(T([],i,!0),Array(s*l-i.length).fill(i[0]),!0));var c=e.Color3toRGBAUint8(i),u=new is(c,s,l,Do.TEXTUREFORMAT_RGBA,n,!1,!0,r);return u.name=t,u},e.PrepareEmptyColorsTexture=function(e){if(!qT.EmptyColorsTexture){var t=new Uint8Array(4);qT.EmptyColorsTexture=new is(t,1,1,Do.TEXTUREFORMAT_RGBA,e,!1,!1,is.NEAREST_NEAREST),qT.EmptyColorsTexture.name="grlEmptyColorsTexture"}return qT.EmptyColorsTexture},e.DisposeEmptyColorsTexture=function(){var e;null===(e=qT.EmptyColorsTexture)||void 0===e||e.dispose(),qT.EmptyColorsTexture=null},e.BooleanToNumber=function(e){return e?1:0},e}(),JT=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.GREASED_LINE_HAS_COLOR=!1,t.GREASED_LINE_SIZE_ATTENUATION=!1,t.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE=!1,t.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM=!1,t.GREASED_LINE_CAMERA_FACING=!0,t}return m(t,e),t}(Gs),$T=function(e){function t(i,r,n){var o,a,s,l,c,u,h,d,p,f,_,m,g,v,y,b,T,E=this;n=n||{color:qT.DEFAULT_COLOR};var S=new JT;return S.GREASED_LINE_HAS_COLOR=!!n.color&&!n.useColors,S.GREASED_LINE_SIZE_ATTENUATION=null!==(o=n.sizeAttenuation)&&void 0!==o&&o,S.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE=n.colorDistributionType===BT.COLOR_DISTRIBUTION_TYPE_LINE,S.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM=(null!=r?r:i.getScene()).useRightHandedSystem,S.GREASED_LINE_CAMERA_FACING=null===(a=n.cameraFacing)||void 0===a||a,(E=e.call(this,i,t.GREASED_LINE_MATERIAL_NAME,200,S)||this).colorsTexture=null,E._scene=null!=r?r:i.getScene(),E._engine=E._scene.getEngine(),E._cameraFacing=null===(s=n.cameraFacing)||void 0===s||s,E.visibility=null!==(l=n.visibility)&&void 0!==l?l:1,E.useDash=null!==(c=n.useDash)&&void 0!==c&&c,E.dashRatio=null!==(u=n.dashRatio)&&void 0!==u?u:.5,E.dashOffset=null!==(h=n.dashOffset)&&void 0!==h?h:0,E.width=n.width?n.width:n.sizeAttenuation?qT.DEFAULT_WIDTH_ATTENUATED:qT.DEFAULT_WIDTH,E._sizeAttenuation=null!==(d=n.sizeAttenuation)&&void 0!==d&&d,E.colorMode=null!==(p=n.colorMode)&&void 0!==p?p:wT.COLOR_MODE_SET,E._color=null!==(f=n.color)&&void 0!==f?f:null,E.useColors=null!==(_=n.useColors)&&void 0!==_&&_,E._colorsDistributionType=null!==(m=n.colorDistributionType)&&void 0!==m?m:BT.COLOR_DISTRIBUTION_TYPE_SEGMENT,E.colorsSampling=null!==(g=n.colorsSampling)&&void 0!==g?g:is.NEAREST_NEAREST,E._colors=null!==(v=n.colors)&&void 0!==v?v:null,E.dashCount=null!==(y=n.dashCount)&&void 0!==y?y:1,E.resolution=null!==(b=n.resolution)&&void 0!==b?b:new U(E._engine.getRenderWidth(),E._engine.getRenderHeight()),n.colorsTexture?E.colorsTexture=n.colorsTexture:E._colors?E.colorsTexture=ZT.CreateColorsTexture("".concat(i.name,"-colors-texture"),E._colors,E.colorsSampling,E._scene):(E._color=null!==(T=E._color)&&void 0!==T?T:qT.DEFAULT_COLOR,ZT.PrepareEmptyColorsTexture(E._scene)),E._engine.onDisposeObservable.add((function(){ZT.DisposeEmptyColorsTexture()})),E._enable(!0),E}return m(t,e),t.prototype.getAttributes=function(e){e.push("grl_offsets"),e.push("grl_widths"),e.push("grl_colorPointers"),e.push("grl_counters"),this._cameraFacing?(e.push("grl_previousAndSide"),e.push("grl_nextAndCounters")):e.push("grl_slopes")},t.prototype.getSamplers=function(e){e.push("grl_colors")},t.prototype.getActiveTextures=function(e){this.colorsTexture&&e.push(this.colorsTexture)},t.prototype.getUniforms=function(){var e=[{name:"grl_singleColor",size:3,type:"vec3"},{name:"grl_textureSize",size:2,type:"vec2"},{name:"grl_dashOptions",size:4,type:"vec4"},{name:"grl_colorMode_visibility_colorsWidth_useColors",size:4,type:"vec4"}];return this._cameraFacing&&e.push({name:"grl_projection",size:16,type:"mat4"},{name:"grl_aspect_resolution_lineWidth",size:4,type:"vec4"}),{ubo:e,vertex:this._cameraFacing?"\n uniform vec4 grl_aspect_resolution_lineWidth;\n uniform mat4 grl_projection;\n ":"",fragment:"\n uniform vec4 grl_dashOptions;\n uniform vec2 grl_textureSize;\n uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;\n uniform vec3 grl_singleColor;\n "}},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.bindForSubMesh=function(e){var t,i,r;if(this._cameraFacing){var n=this._scene.activeCamera;if(!n)throw Error("GreasedLinePluginMaterial requires an active camera.");var o=n.getProjectionMatrix();e.updateMatrix("grl_projection",o);var a=H.Vector4[0];a.x=this._aspect,a.y=this._resolution.x,a.z=this._resolution.y,a.w=this.width,e.updateVector4("grl_aspect_resolution_lineWidth",a)}var s=H.Vector4[0];s.x=ZT.BooleanToNumber(this.useDash),s.y=this._dashArray,s.z=this.dashOffset,s.w=this.dashRatio,e.updateVector4("grl_dashOptions",s);var l=H.Vector4[1];l.x=this.colorMode,l.y=this.visibility,l.z=this.colorsTexture?this.colorsTexture.getSize().width:0,l.w=ZT.BooleanToNumber(this.useColors),e.updateVector4("grl_colorMode_visibility_colorsWidth_useColors",l),this._color&&e.updateColor3("grl_singleColor",this._color);var c=null!==(t=this.colorsTexture)&&void 0!==t?t:qT.EmptyColorsTexture;e.setTexture("grl_colors",c),e.updateFloat2("grl_textureSize",null!==(i=null==c?void 0:c.getSize().width)&&void 0!==i?i:1,null!==(r=null==c?void 0:c.getSize().height)&&void 0!==r?r:1)},t.prototype.prepareDefines=function(e,t,i){e.GREASED_LINE_HAS_COLOR=!!this.color&&!this.useColors,e.GREASED_LINE_SIZE_ATTENUATION=this._sizeAttenuation,e.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE=this._colorsDistributionType===BT.COLOR_DISTRIBUTION_TYPE_LINE,e.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM=t.useRightHandedSystem,e.GREASED_LINE_CAMERA_FACING=this._cameraFacing},t.prototype.getClassName=function(){return t.GREASED_LINE_MATERIAL_NAME},t.prototype.getCustomCode=function(e){if("vertex"===e){var t={CUSTOM_VERTEX_DEFINITIONS:"\n attribute float grl_widths;\n attribute vec3 grl_offsets;\n attribute float grl_colorPointers;\n varying float grlCounters;\n varying float grlColorPointer;\n\n #ifdef GREASED_LINE_CAMERA_FACING\n attribute vec4 grl_previousAndSide;\n attribute vec4 grl_nextAndCounters;\n\n vec2 grlFix( vec4 i, float aspect ) {\n vec2 res = i.xy / i.w;\n res.x *= aspect;\n return res;\n }\n #else\n attribute vec3 grl_slopes;\n attribute float grl_counters;\n #endif\n ",CUSTOM_VERTEX_UPDATE_POSITION:"\n #ifdef GREASED_LINE_CAMERA_FACING\n vec3 grlPositionOffset = grl_offsets;\n positionUpdated += grlPositionOffset;\n #else\n positionUpdated = (positionUpdated + grl_offsets) + (grl_slopes * grl_widths);\n #endif\n ",CUSTOM_VERTEX_MAIN_END:"\n grlColorPointer = grl_colorPointers;\n\n #ifdef GREASED_LINE_CAMERA_FACING\n\n float grlAspect = grl_aspect_resolution_lineWidth.x;\n float grlBaseWidth = grl_aspect_resolution_lineWidth.w;\n\n\n vec3 grlPrevious = grl_previousAndSide.xyz;\n float grlSide = grl_previousAndSide.w;\n\n vec3 grlNext = grl_nextAndCounters.xyz;\n grlCounters = grl_nextAndCounters.w;\n\n mat4 grlMatrix = viewProjection * finalWorld;\n vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );\n vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );\n vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );\n\n vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );\n vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );\n vec2 grlNextP = grlFix( grlNextPos, grlAspect );\n\n float grlWidth = grlBaseWidth * grl_widths;\n\n vec2 grlDir;\n if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );\n else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );\n else {\n vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );\n vec2 grlDir2 = normalize( grlNextP - grlCurrentP );\n grlDir = normalize( grlDir1 + grlDir2 );\n }\n vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );\n #ifdef GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM\n grlNormal.xy *= -.5 * grlWidth;\n #else\n grlNormal.xy *= .5 * grlWidth;\n #endif\n\n grlNormal *= grl_projection;\n\n #ifdef GREASED_LINE_SIZE_ATTENUATION\n grlNormal.xy *= grlFinalPosition.w;\n grlNormal.xy /= ( vec4( grl_aspect_resolution_lineWidth.yz, 0., 1. ) * grl_projection ).xy;\n #endif\n\n grlFinalPosition.xy += grlNormal.xy * grlSide;\n gl_Position = grlFinalPosition;\n\n vPositionW = vec3(grlFinalPosition);\n #else\n grlCounters = grl_counters;\n #endif\n "};return this._cameraFacing&&(t["!gl_Position\\=viewProjection\\*worldPos;"]="//"),t}return"fragment"===e?{CUSTOM_FRAGMENT_DEFINITIONS:"\n varying float grlCounters;\n varying float grlColorPointer;\n uniform sampler2D grl_colors;\n ",CUSTOM_FRAGMENT_MAIN_END:"\n float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;\n float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;\n float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;\n float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;\n\n float grlUseDash = grl_dashOptions.x;\n float grlDashArray = grl_dashOptions.y;\n float grlDashOffset = grl_dashOptions.z;\n float grlDashRatio = grl_dashOptions.w;\n\n gl_FragColor.a *= step(grlCounters, grlVisibility);\n if( gl_FragColor.a == 0. ) discard;\n\n if(grlUseDash == 1.){\n gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));\n if (gl_FragColor.a == 0.) discard;\n }\n\n #ifdef GREASED_LINE_HAS_COLOR\n if (grlColorMode == ".concat(wT.COLOR_MODE_SET,".) {\n gl_FragColor.rgb = grl_singleColor;\n } else if (grlColorMode == ").concat(wT.COLOR_MODE_ADD,".) {\n gl_FragColor.rgb += grl_singleColor;\n } else if (grlColorMode == ").concat(wT.COLOR_MODE_MULTIPLY,".) {\n gl_FragColor.rgb *= grl_singleColor;\n }\n #else\n if (grlUseColors == 1.) {\n #ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE\n vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);\n #else\n vec2 lookup = vec2(fract(grlColorPointer / grl_textureSize.x), 1.0 - floor(grlColorPointer / grl_textureSize.x) / max(grl_textureSize.y - 1.0, 1.0));\n vec4 grlColor = texture2D(grl_colors, lookup, 0.0);\n #endif\n if (grlColorMode == ").concat(wT.COLOR_MODE_SET,".) {\n gl_FragColor = grlColor;\n } else if (grlColorMode == ").concat(wT.COLOR_MODE_ADD,".) {\n gl_FragColor += grlColor;\n } else if (grlColorMode == ").concat(wT.COLOR_MODE_MULTIPLY,".) {\n gl_FragColor *= grlColor;\n }\n }\n #endif\n\n ")}:null},t.prototype.dispose=function(){var t;null===(t=this.colorsTexture)||void 0===t||t.dispose(),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"colors",{get:function(){return this._colors},set:function(e){this.setColors(e)},enumerable:!1,configurable:!0}),t.prototype.setColors=function(e,t,i){var r,n,o,a;void 0===t&&(t=!1),void 0===i&&(i=!1);var s=null!==(n=null===(r=this._colors)||void 0===r?void 0:r.length)&&void 0!==n?n:0;if(this._colors=e,null!==e&&0!==e.length){if(!t||i)if(this.colorsTexture&&s===e.length&&!i){var l=ZT.Color3toRGBAUint8(e);this.colorsTexture.update(l)}else null===(a=this.colorsTexture)||void 0===a||a.dispose(),this.colorsTexture=ZT.CreateColorsTexture("".concat(this._material.name,"-colors-texture"),e,this.colorsSampling,this._scene)}else null===(o=this.colorsTexture)||void 0===o||o.dispose()},t.prototype.updateLazy=function(){this._colors&&this.setColors(this._colors,!1,!0)},Object.defineProperty(t.prototype,"dashCount",{get:function(){return this._dashCount},set:function(e){this._dashCount=e,this._dashArray=1/e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeAttenuation",{get:function(){return this._sizeAttenuation},set:function(e){this._sizeAttenuation=e,this.markAllDefinesAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._color},set:function(e){this.setColor(e)},enumerable:!1,configurable:!0}),t.prototype.setColor=function(e,t){void 0===t&&(t=!1),null===this._color&&null!==e||null!==this._color&&null===e?(this._color=e,!t&&this.markAllDefinesAsDirty()):this._color=e},Object.defineProperty(t.prototype,"colorsDistributionType",{get:function(){return this._colorsDistributionType},set:function(e){this._colorsDistributionType=e,this.markAllDefinesAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._aspect=e.x/e.y,this._resolution=e},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var t=e.prototype.serialize.call(this),i={colorDistributionType:this._colorsDistributionType,colorsSampling:this.colorsSampling,colorMode:this.colorMode,dashCount:this._dashCount,dashOffset:this.dashOffset,dashRatio:this.dashRatio,resolution:this._resolution,sizeAttenuation:this._sizeAttenuation,useColors:this.useColors,useDash:this.useDash,visibility:this.visibility,width:this.width};return this._colors&&(i.colors=this._colors),this._color&&(i.color=this._color),t.greasedLineMaterialOptions=i,t},t.prototype.parse=function(t,i,r){var n;e.prototype.parse.call(this,t,i,r);var o=t.greasedLineMaterialOptions;null===(n=this.colorsTexture)||void 0===n||n.dispose(),o.color&&this.setColor(o.color,!0),o.colorDistributionType&&(this.colorsDistributionType=o.colorDistributionType),o.colors&&(this.colors=o.colors),o.colorsSampling&&(this.colorsSampling=o.colorsSampling),o.colorMode&&(this.colorMode=o.colorMode),o.useColors&&(this.useColors=o.useColors),o.visibility&&(this.visibility=o.visibility),o.useDash&&(this.useDash=o.useDash),o.dashCount&&(this.dashCount=o.dashCount),o.dashRatio&&(this.dashRatio=o.dashRatio),o.dashOffset&&(this.dashOffset=o.dashOffset),o.width&&(this.width=o.width),o.sizeAttenuation&&(this.sizeAttenuation=o.sizeAttenuation),o.resolution&&(this.resolution=o.resolution),this.colors?this.colorsTexture=ZT.CreateColorsTexture("".concat(this._material.name,"-colors-texture"),this.colors,this.colorsSampling,i):ZT.PrepareEmptyColorsTexture(i),this.markAllDefinesAsDirty()},t.prototype.copyTo=function(e){var t,i=e;null===(t=i.colorsTexture)||void 0===t||t.dispose(),this._colors&&(i.colorsTexture=ZT.CreateColorsTexture("".concat(i._material.name,"-colors-texture"),this._colors,i.colorsSampling,this._scene)),i.setColor(this.color,!0),i.colorsDistributionType=this.colorsDistributionType,i.colorsSampling=this.colorsSampling,i.colorMode=this.colorMode,i.useColors=this.useColors,i.visibility=this.visibility,i.useDash=this.useDash,i.dashCount=this.dashCount,i.dashRatio=this.dashRatio,i.dashOffset=this.dashOffset,i.width=this.width,i.sizeAttenuation=this.sizeAttenuation,i.resolution=this.resolution,i.markAllDefinesAsDirty()},t.GREASED_LINE_MATERIAL_NAME="GreasedLinePluginMaterial",t}(Nu);a("BABYLON.".concat($T.GREASED_LINE_MATERIAL_NAME),$T);li.ShadersStore.greasedLinePixelShader="precision highp float;uniform sampler2D grlColors;uniform float grlUseColors;uniform float grlUseDash;uniform float grlDashArray;uniform float grlDashOffset;uniform float grlDashRatio;uniform float grlVisibility;uniform float grlColorsWidth;uniform vec2 grl_colorModeAndColorDistributionType;uniform vec3 grlColor;varying float grlCounters;varying float grlColorPointer;void main() {float grlColorMode=grl_colorModeAndColorDistributionType.x;float grlColorDistributionType=grl_colorModeAndColorDistributionType.y;gl_FragColor=vec4(grlColor,1.);gl_FragColor.a=step(grlCounters,grlVisibility);if (gl_FragColor.a==0.) discard;if( grlUseDash==1. ){gl_FragColor.a=ceil(mod(grlCounters+grlDashOffset,grlDashArray)-(grlDashArray*grlDashRatio));if (gl_FragColor.a==0.) discard;}\nif (grlUseColors==1.) {vec4 textureColor;if (grlColorDistributionType==COLOR_DISTRIBUTION_TYPE_LINE) { \ntextureColor=texture2D(grlColors,vec2(grlCounters,0.),0.);} else {textureColor=texture2D(grlColors,vec2(grlColorPointer/grlColorsWidth,0.),0.);}\nif (grlColorMode==COLOR_MODE_SET) {gl_FragColor=textureColor;} else if (grlColorMode==COLOR_MODE_ADD) {gl_FragColor+=textureColor;} else if (grlColorMode==COLOR_MODE_MULTIPLY) {gl_FragColor*=textureColor;}}}\n";li.ShadersStore.greasedLineVertexShader="precision highp float;\n#include\nattribute float grl_widths;attribute vec3 grl_offsets;attribute float grl_colorPointers;attribute vec3 position;uniform mat4 viewProjection;uniform mat4 projection;varying float grlCounters;varying float grlColorPointer;\n#ifdef GREASED_LINE_CAMERA_FACING\nattribute vec4 grl_nextAndCounters;attribute vec4 grl_previousAndSide;uniform vec2 grlResolution;uniform float grlAspect;uniform float grlWidth;uniform float grlSizeAttenuation;vec2 grlFix( vec4 i,float aspect ) {vec2 res=i.xy/i.w;res.x*=aspect;return res;}\n#else\nattribute vec3 grl_slopes;attribute float grl_counters;\n#endif\nvoid main() {\n#include\ngrlColorPointer=grl_colorPointers;mat4 grlMatrix=viewProjection*finalWorld ;\n#ifdef GREASED_LINE_CAMERA_FACING\nfloat grlBaseWidth=grlWidth;vec3 grlPrevious=grl_previousAndSide.xyz;float grlSide=grl_previousAndSide.w;vec3 grlNext=grl_nextAndCounters.xyz;grlCounters=grl_nextAndCounters.w;vec3 grlPositionOffset=grl_offsets;vec4 grlFinalPosition=grlMatrix*vec4( position+grlPositionOffset ,1.0 );vec4 grlPrevPos=grlMatrix*vec4( grlPrevious+grlPositionOffset,1.0 );vec4 grlNextPos=grlMatrix*vec4( grlNext+grlPositionOffset,1.0 );vec2 grlCurrentP=grlFix( grlFinalPosition,grlAspect );vec2 grlPrevP=grlFix( grlPrevPos,grlAspect );vec2 grlNextP=grlFix( grlNextPos,grlAspect );float grlWidth=grlBaseWidth*grl_widths;vec2 grlDir;if( grlNextP==grlCurrentP ) grlDir=normalize( grlCurrentP-grlPrevP );else if( grlPrevP==grlCurrentP ) grlDir=normalize( grlNextP-grlCurrentP );else {vec2 grlDir1=normalize( grlCurrentP-grlPrevP );vec2 grlDir2=normalize( grlNextP-grlCurrentP );grlDir=normalize( grlDir1+grlDir2 );}\nvec4 grlNormal=vec4( -grlDir.y,grlDir.x,0.,1. );\n#ifdef GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM\ngrlNormal.xy*=-.5*grlWidth;\n#else\ngrlNormal.xy*=.5*grlWidth;\n#endif\ngrlNormal*=projection;if (grlSizeAttenuation==1.) {grlNormal.xy*=grlFinalPosition.w;grlNormal.xy/=( vec4( grlResolution,0.,1. )*projection ).xy;}\ngrlFinalPosition.xy+=grlNormal.xy*grlSide;gl_Position=grlFinalPosition;\n#else\ngrlCounters=grl_counters;vec4 grlFinalPosition=grlMatrix*vec4( (position+grl_offsets)+grl_slopes*grl_widths ,1.0 ) ;gl_Position=grlFinalPosition;\n#endif\n}\n";var eE,tE=function(e){function t(t,i,r){var n,o,a,s,l,c,u,h,d,p,f,_,m,g,v=this,y=["COLOR_DISTRIBUTION_TYPE_LINE ".concat(BT.COLOR_DISTRIBUTION_TYPE_LINE,"."),"COLOR_DISTRIBUTION_TYPE_SEGMENT ".concat(BT.COLOR_DISTRIBUTION_TYPE_SEGMENT,"."),"COLOR_MODE_SET ".concat(wT.COLOR_MODE_SET,"."),"COLOR_MODE_ADD ".concat(wT.COLOR_MODE_ADD,"."),"COLOR_MODE_MULTIPLY ".concat(wT.COLOR_MODE_MULTIPLY,".")],b=["position","grl_widths","grl_offsets","grl_colorPointers"];i.useRightHandedSystem&&y.push("GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM"),r.cameraFacing?(y.push("GREASED_LINE_CAMERA_FACING"),b.push("grl_previousAndSide","grl_nextAndCounters")):(b.push("grl_slopes"),b.push("grl_counters")),(v=e.call(this,t,i,{vertex:"greasedLine",fragment:"greasedLine"},{attributes:b,uniforms:["world","viewProjection","view","projection","grlColorsWidth","grlUseColors","grlWidth","grlColor","grl_colorModeAndColorDistributionType","grlResolution","grlAspect","grlAizeAttenuation","grlDashArray","grlDashOffset","grlDashRatio","grlUseDash","grlVisibility"],samplers:["grlColors"],defines:y})||this)._color=Z.White(),v._colorsDistributionType=BT.COLOR_DISTRIBUTION_TYPE_SEGMENT,v._colorsTexture=null,r=r||{color:qT.DEFAULT_COLOR};var T=i.getEngine();return v.visibility=null!==(n=r.visibility)&&void 0!==n?n:1,v.useDash=null!==(o=r.useDash)&&void 0!==o&&o,v.dashRatio=null!==(a=r.dashRatio)&&void 0!==a?a:.5,v.dashOffset=null!==(s=r.dashOffset)&&void 0!==s?s:0,v.dashCount=null!==(l=r.dashCount)&&void 0!==l?l:1,v.width=r.width?r.width:r.sizeAttenuation&&r.cameraFacing?qT.DEFAULT_WIDTH_ATTENUATED:qT.DEFAULT_WIDTH,v.sizeAttenuation=null!==(c=r.sizeAttenuation)&&void 0!==c&&c,v.color=null!==(u=r.color)&&void 0!==u?u:Z.White(),v.useColors=null!==(h=r.useColors)&&void 0!==h&&h,v.colorsDistributionType=null!==(d=r.colorDistributionType)&&void 0!==d?d:BT.COLOR_DISTRIBUTION_TYPE_SEGMENT,v.colorsSampling=null!==(p=r.colorsSampling)&&void 0!==p?p:is.NEAREST_NEAREST,v.colorMode=null!==(f=r.colorMode)&&void 0!==f?f:wT.COLOR_MODE_SET,v._colors=null!==(_=r.colors)&&void 0!==_?_:null,v._cameraFacing=null===(m=r.cameraFacing)||void 0===m||m,v.resolution=null!==(g=r.resolution)&&void 0!==g?g:new U(T.getRenderWidth(),T.getRenderHeight()),r.colorsTexture?v.colorsTexture=r.colorsTexture:v.colorsTexture=ZT.PrepareEmptyColorsTexture(i),v._colors&&v.setColors(v._colors),T.onDisposeObservable.add((function(){ZT.DisposeEmptyColorsTexture()})),v}return m(t,e),t.prototype.dispose=function(){var t;null===(t=this._colorsTexture)||void 0===t||t.dispose(),e.prototype.dispose.call(this)},t.prototype._setColorModeAndColorDistributionType=function(){this.setVector2("grl_colorModeAndColorDistributionType",new U(this._colorMode,this._colorsDistributionType))},t.prototype.updateLazy=function(){this._colors&&this.setColors(this._colors,!1,!0)},Object.defineProperty(t.prototype,"colors",{get:function(){return this._colors},set:function(e){this.setColors(e)},enumerable:!1,configurable:!0}),t.prototype.setColors=function(e,t,i){var r,n,o,a;void 0===t&&(t=!1),void 0===i&&(i=!1);var s=null!==(n=null===(r=this._colors)||void 0===r?void 0:r.length)&&void 0!==n?n:0;if(this._colors=e,null!==e&&0!==e.length){if(!t||i)if(this._colorsTexture&&s===e.length&&!i){var l=ZT.Color3toRGBAUint8(e);this._colorsTexture.update(l)}else null===(a=this._colorsTexture)||void 0===a||a.dispose(),this.colorsTexture=ZT.CreateColorsTexture("".concat(this.name,"-colors-texture"),e,this.colorsSampling,this.getScene())}else null===(o=this._colorsTexture)||void 0===o||o.dispose()},Object.defineProperty(t.prototype,"colorsTexture",{get:function(){var e;return null!==(e=this._colorsTexture)&&void 0!==e?e:null},set:function(e){this._colorsTexture=e,this.setFloat("grlColorsWidth",this._colorsTexture.getSize().width),this.setTexture("grlColors",this._colorsTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e,this.setFloat("grlWidth",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useColors",{get:function(){return this._useColors},set:function(e){this._useColors=e,this.setFloat("grlUseColors",ZT.BooleanToNumber(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorsSampling",{get:function(){return this._colorsSampling},set:function(e){this._colorsSampling=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._visibility},set:function(e){this._visibility=e,this.setFloat("grlVisibility",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useDash",{get:function(){return this._useDash},set:function(e){this._useDash=e,this.setFloat("grlUseDash",ZT.BooleanToNumber(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dashOffset",{get:function(){return this._dashOffset},set:function(e){this._dashOffset=e,this.setFloat("grlDashOffset",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dashRatio",{get:function(){return this._dashRatio},set:function(e){this._dashRatio=e,this.setFloat("grlDashRatio",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dashCount",{get:function(){return this._dashCount},set:function(e){this._dashCount=e,this._dashArray=1/e,this.setFloat("grlDashArray",this._dashArray)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeAttenuation",{get:function(){return this._sizeAttenuation},set:function(e){this._sizeAttenuation=e,this.setFloat("grlSizeAttenuation",ZT.BooleanToNumber(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this.color},set:function(e){this.setColor(e)},enumerable:!1,configurable:!0}),t.prototype.setColor=function(e){e=null!=e?e:qT.DEFAULT_COLOR,this._color=e,this.setColor3("grlColor",e)},Object.defineProperty(t.prototype,"colorsDistributionType",{get:function(){return this._colorsDistributionType},set:function(e){this._colorsDistributionType=e,this._setColorModeAndColorDistributionType()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorMode",{get:function(){return this._colorMode},set:function(e){this._colorMode=e,this._setColorModeAndColorDistributionType()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._resolution=e,this.setVector2("grlResolution",e),this.setFloat("grlAspect",e.x/e.y)},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var t=e.prototype.serialize.call(this),i={colorDistributionType:this._colorsDistributionType,colorsSampling:this._colorsSampling,colorMode:this._colorMode,color:this._color,dashCount:this._dashCount,dashOffset:this._dashOffset,dashRatio:this._dashRatio,resolution:this._resolution,sizeAttenuation:this._sizeAttenuation,useColors:this._useColors,useDash:this._useDash,visibility:this._visibility,width:this._width,cameraFacing:this._cameraFacing};return this._colors&&(i.colors=this._colors),t.greasedLineMaterialOptions=i,t},t.prototype.parse=function(e,t,i){var r,n,o=e.greasedLineMaterialOptions;null===(r=this._colorsTexture)||void 0===r||r.dispose(),o.color&&(this.color=o.color),o.colorDistributionType&&(this.colorsDistributionType=o.colorDistributionType),o.colorsSampling&&(this.colorsSampling=o.colorsSampling),o.colorMode&&(this.colorMode=o.colorMode),o.useColors&&(this.useColors=o.useColors),o.visibility&&(this.visibility=o.visibility),o.useDash&&(this.useDash=o.useDash),o.dashCount&&(this.dashCount=o.dashCount),o.dashRatio&&(this.dashRatio=o.dashRatio),o.dashOffset&&(this.dashOffset=o.dashOffset),o.width&&(this.width=o.width),o.sizeAttenuation&&(this.sizeAttenuation=o.sizeAttenuation),o.resolution&&(this.resolution=o.resolution),o.colors?this.colorsTexture=ZT.CreateColorsTexture("".concat(this.name,"-colors-texture"),o.colors,this.colorsSampling,this.getScene()):this.colorsTexture=ZT.PrepareEmptyColorsTexture(t),this._cameraFacing=null===(n=o.cameraFacing)||void 0===n||n,this.setDefine("GREASED_LINE_CAMERA_FACING",this._cameraFacing)},t}(ld),iE=[new Z(.98,.26,.38),new Z(.47,.75,.3),new Z(0,.26,.77),new Z(.97,.6,.76),new Z(.19,.63,.78),new Z(.98,.8,.6),new Z(.65,.43,.15),new Z(.15,.47,.22),new Z(.67,.71,.86),new Z(.09,.46,.56),new Z(.8,.98,.02),new Z(.39,.29,.13),new Z(.53,.63,.06),new Z(.95,.96,.41),new Z(1,.72,.94),new Z(.63,.08,.31),new Z(.66,.96,.95),new Z(.22,.14,.19),new Z(.14,.65,.59),new Z(.93,1,.68),new Z(.93,.14,.44),new Z(.47,.86,.67),new Z(.85,.07,.78),new Z(.53,.64,.98),new Z(.43,.37,.56),new Z(.71,.65,.25),new Z(.66,.19,.01),new Z(.94,.53,.12),new Z(.41,.44,.44),new Z(.24,.71,.96),new Z(.57,.28,.56),new Z(.44,.98,.42)];!function(e){e[e.NONE=0]="NONE",e[e.TRIANGLES=1]="TRIANGLES",e[e.VERTICES=2]="VERTICES",e[e.TRIANGLES_VERTICES=3]="TRIANGLES_VERTICES",e[e.UV0=4]="UV0",e[e.UV1=5]="UV1",e[e.VERTEXCOLORS=6]="VERTEXCOLORS",e[e.MATERIALIDS=7]="MATERIALIDS"}(eE||(eE={}));var rE=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.DBG_MODE=eE.NONE,t.DBG_MULTIPLY=!0,t.DBG_ENABLED=!0,t}return m(t,e),t}(Gs),nE=function(e){function t(i,r){void 0===r&&(r={});var n,o,a,s,l,c,u,h,d,p,f,_,m,g=this,v=new rE;return v.DBG_MODE=null!==(n=r.mode)&&void 0!==n?n:v.DBG_MODE,v.DBG_MULTIPLY=null!==(o=r.multiply)&&void 0!==o?o:v.DBG_MULTIPLY,(g=e.call(this,i,"MeshDebug",200,v,!0,!0)||this)._mode=v.DBG_MODE,g._multiply=v.DBG_MULTIPLY,g.shadedDiffuseColor=null!==(a=r.shadedDiffuseColor)&&void 0!==a?a:new Z(1,1,1),g.shadedSpecularColor=null!==(s=r.shadedSpecularColor)&&void 0!==s?s:new Z(.8,.8,.8),g.shadedSpecularPower=null!==(l=r.shadedSpecularPower)&&void 0!==l?l:10,g.wireframeThickness=null!==(c=r.wireframeThickness)&&void 0!==c?c:.7,g.wireframeTrianglesColor=null!==(u=r.wireframeTrianglesColor)&&void 0!==u?u:new Z(0,0,0),g.wireframeVerticesColor=null!==(h=r.wireframeVerticesColor)&&void 0!==h?h:new Z(.8,.8,.8),g.vertexColor=null!==(d=r.vertexColor)&&void 0!==d?d:new Z(0,0,0),g.vertexRadius=null!==(p=r.vertexRadius)&&void 0!==p?p:1.2,g.uvScale=null!==(f=r.uvScale)&&void 0!==f?f:20,g.uvPrimaryColor=null!==(_=r.uvPrimaryColor)&&void 0!==_?_:new Z(1,1,1),g.uvSecondaryColor=null!==(m=r.uvSecondaryColor)&&void 0!==m?m:new Z(.5,.5,.5),g._materialColor=t.MaterialColors[t._PluginCount++%t.MaterialColors.length],g.isEnabled=!0,g}return m(t,e),t.prototype._markAllDefinesAsDirty=function(){this._enable(this._isEnabled),this.markAllDefinesAsDirty()},t.prototype.getClassName=function(){return"MeshDebugPluginMaterial"},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){if(this._isEnabled!==e){if(!this._material.getScene().getEngine().isWebGPU&&1==this._material.getScene().getEngine().version)return ae.Error("MeshDebugPluginMaterial is not supported on WebGL 1.0."),void(this._isEnabled=!1);this._isEnabled=e,this._markAllDefinesAsDirty()}},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,t,i){this._mode!=eE.VERTICES&&this._mode!=eE.TRIANGLES&&this._mode!=eE.TRIANGLES_VERTICES||i.isVerticesDataPresent("dbg_initialPass")||ae.Warn("For best results with TRIANGLES, TRIANGLES_VERTICES, or VERTICES modes, please use MeshDebugPluginMaterial.PrepareMeshForTrianglesAndVerticesMode() on mesh.",1),e.DBG_MODE=this._mode,e.DBG_MULTIPLY=this._multiply,e.DBG_ENABLED=this._isEnabled},t.prototype.getAttributes=function(e){e.push("dbg_initialPass")},t.prototype.getUniforms=function(){return{ubo:[{name:"dbg_shadedDiffuseColor",size:3,type:"vec3"},{name:"dbg_shadedSpecularColorPower",size:4,type:"vec4"},{name:"dbg_thicknessRadiusScale",size:3,type:"vec3"},{name:"dbg_wireframeTrianglesColor",size:3,type:"vec3"},{name:"dbg_wireframeVerticesColor",size:3,type:"vec3"},{name:"dbg_vertexColor",size:3,type:"vec3"},{name:"dbg_uvPrimaryColor",size:3,type:"vec3"},{name:"dbg_uvSecondaryColor",size:3,type:"vec3"},{name:"dbg_materialColor",size:3,type:"vec3"}],fragment:"#if defined(DBG_ENABLED)\nuniform vec3 dbg_shadedDiffuseColor;\nuniform vec4 dbg_shadedSpecularColorPower;\nuniform vec3 dbg_thicknessRadiusScale;\n\n#if DBG_MODE == 2 || DBG_MODE == 3\n uniform vec3 dbg_vertexColor;\n#endif\n\n#if DBG_MODE == 1\n uniform vec3 dbg_wireframeTrianglesColor;\n#elif DBG_MODE == 3\n uniform vec3 dbg_wireframeVerticesColor;\n#elif DBG_MODE == 4 || DBG_MODE == 5\n uniform vec3 dbg_uvPrimaryColor;\n uniform vec3 dbg_uvSecondaryColor;\n#elif DBG_MODE == 7\n uniform vec3 dbg_materialColor;\n#endif\n#endif"}},t.prototype.bindForSubMesh=function(e){this._isEnabled&&(e.updateFloat3("dbg_shadedDiffuseColor",this.shadedDiffuseColor.r,this.shadedDiffuseColor.g,this.shadedDiffuseColor.b),e.updateFloat4("dbg_shadedSpecularColorPower",this.shadedSpecularColor.r,this.shadedSpecularColor.g,this.shadedSpecularColor.b,this.shadedSpecularPower),e.updateFloat3("dbg_thicknessRadiusScale",this.wireframeThickness,this.vertexRadius,this.uvScale),e.updateColor3("dbg_wireframeTrianglesColor",this.wireframeTrianglesColor),e.updateColor3("dbg_wireframeVerticesColor",this.wireframeVerticesColor),e.updateColor3("dbg_vertexColor",this.vertexColor),e.updateColor3("dbg_uvPrimaryColor",this.uvPrimaryColor),e.updateColor3("dbg_uvSecondaryColor",this.uvSecondaryColor),e.updateColor3("dbg_materialColor",this._materialColor))},t.prototype.getCustomCode=function(e){return"vertex"===e?{CUSTOM_VERTEX_DEFINITIONS:"#if defined(DBG_ENABLED)\nattribute float dbg_initialPass;\nvarying vec3 dbg_vBarycentric;\nflat varying vec3 dbg_vVertexWorldPos;\nflat varying float dbg_vPass;\n#endif",CUSTOM_VERTEX_MAIN_END:"#if defined(DBG_ENABLED)\nfloat dbg_vertexIndex = mod(float(gl_VertexID), 3.);\nif (dbg_vertexIndex == 0.0) { \n dbg_vBarycentric = vec3(1.,0.,0.); \n}\nelse if (dbg_vertexIndex == 1.0) { \n dbg_vBarycentric = vec3(0.,1.,0.); \n}\nelse { \n dbg_vBarycentric = vec3(0.,0.,1.); \n}\n\ndbg_vVertexWorldPos = vPositionW;\ndbg_vPass = dbg_initialPass;\n#endif"}:{CUSTOM_FRAGMENT_DEFINITIONS:"#if defined(DBG_ENABLED)\nvarying vec3 dbg_vBarycentric;\nflat varying vec3 dbg_vVertexWorldPos;\nflat varying float dbg_vPass;\n\n#if !defined(DBG_MULTIPLY)\n vec3 dbg_applyShading(vec3 color) {\n vec3 N = vNormalW.xyz;\n vec3 L = normalize(vEyePosition.xyz - vPositionW.xyz);\n vec3 H = normalize(L + L);\n float LdotN = clamp(dot(L,N), 0., 1.);\n float HdotN = clamp(dot(H,N), 0., 1.);\n float specTerm = pow(HdotN, dbg_shadedSpecularColorPower.w);\n color *= (LdotN / PI);\n color += dbg_shadedSpecularColorPower.rgb * (specTerm / PI);\n return color;\n }\n#endif\n\n#if DBG_MODE == 1 || DBG_MODE == 3\n float dbg_edgeFactor() {\n vec3 d = fwidth(dbg_vBarycentric);\n vec3 a3 = smoothstep(vec3(0.), d * dbg_thicknessRadiusScale.x, dbg_vBarycentric);\n return min(min(a3.x, a3.y), a3.z);\n }\n#endif\n\n#if DBG_MODE == 2 || DBG_MODE == 3\n float dbg_cornerFactor() {\n vec3 worldPos = vPositionW;\n float dist = length(worldPos - dbg_vVertexWorldPos);\n float camDist = length(worldPos - vEyePosition.xyz);\n float d = sqrt(camDist) * .001;\n return smoothstep((dbg_thicknessRadiusScale.y * d), ((dbg_thicknessRadiusScale.y * 1.01) * d), dist);\n }\n#endif\n\n#if (DBG_MODE == 4 && defined(UV1)) || (DBG_MODE == 5 && defined(UV2))\n float dbg_checkerboardFactor(vec2 uv) {\n vec2 f = fract(uv * dbg_thicknessRadiusScale.z);\n f -= .5;\n return (f.x * f.y) > 0. ? 1. : 0.;\n }\n#endif\n#endif",CUSTOM_FRAGMENT_MAIN_END:"#if defined(DBG_ENABLED)\nvec3 dbg_color = vec3(1.);\n#if DBG_MODE == 1\n dbg_color = mix(dbg_wireframeTrianglesColor, vec3(1.), dbg_edgeFactor());\n#elif DBG_MODE == 2 || DBG_MODE == 3\n float dbg_cornerFactor = dbg_cornerFactor();\n if (dbg_vPass == 0. && dbg_cornerFactor == 1.) discard;\n dbg_color = mix(dbg_vertexColor, vec3(1.), dbg_cornerFactor);\n #if DBG_MODE == 3\n dbg_color *= mix(dbg_wireframeVerticesColor, vec3(1.), dbg_edgeFactor());\n #endif\n#elif DBG_MODE == 4 && defined(MAINUV1)\n dbg_color = mix(dbg_uvPrimaryColor, dbg_uvSecondaryColor, dbg_checkerboardFactor(vMainUV1));\n#elif DBG_MODE == 5 && defined(MAINUV2)\n dbg_color = mix(dbg_uvPrimaryColor, dbg_uvSecondaryColor, dbg_checkerboardFactor(vMainUV2));\n#elif DBG_MODE == 6 && defined(VERTEXCOLOR)\n dbg_color = vColor.rgb;\n#elif DBG_MODE == 7\n dbg_color = dbg_materialColor;\n#endif\n\n#if defined(DBG_MULTIPLY)\n gl_FragColor *= vec4(dbg_color, 1.);\n#else\n #if DBG_MODE != 6\n gl_FragColor = vec4(dbg_applyShading(dbg_shadedDiffuseColor) * dbg_color, 1.);\n #else\n gl_FragColor = vec4(dbg_color, 1.);\n #endif\n#endif\n#endif"}},t.Reset=function(){this._PluginCount=0,this.MaterialColors=iE},t.PrepareMeshForTrianglesAndVerticesMode=function(e,t){void 0===t&&(t=!1);var i=function(){};if(0==e.getTotalIndices())return i;if(t){for(var r=e.getVerticesDataKinds(),n=e.getIndices(),o={},a=0,s=r;a=2*this._numSamples&&(this._curIndex=0)},e.prototype._generateSequence=function(e){this._sequence=[],this._curIndex=0,this._numSamples=e;for(var t=1;t<=e;++t)this._sequence.push(this._halton(t,this._baseX)-.5,this._halton(t,this._baseY)-.5)},e.prototype._halton=function(e,t){for(var i=1,r=0;e>0;)r+=(i/=t)*(e%t),e=~~(e/t);return r},e}();function uE(e,t){return"{X: ".concat(e.x.toFixed(t)," Y: ").concat(e.y.toFixed(t),"}")}function hE(e,t){return"{X: ".concat(e._x.toFixed(t)," Y: ").concat(e._y.toFixed(t)," Z: ").concat(e._z.toFixed(t),"}")}function dE(e,t){return"{X: ".concat(e.x.toFixed(t)," Y: ").concat(e.y.toFixed(t)," Z: ").concat(e.z.toFixed(t)," W: ").concat(e.w.toFixed(t),"}")}function pE(e,t,i,r,n){var o=null,a=null,s=null;try{var l;o=new e.Decoder,(a=new e.DecoderBuffer).Init(t,t.byteLength);var c=o.GetEncodedGeometryType(a);switch(c){case e.TRIANGULAR_MESH:var u=new e.Mesh;if(!(l=o.DecodeBufferToMesh(a,u)).ok()||0===u.ptr)throw new Error(l.error_msg());var h=3*u.num_faces(),d=4*h,p=e._malloc(d);try{o.GetTrianglesUInt32Array(u,d,p);var f=new Uint32Array(h);f.set(new Uint32Array(e.HEAPF32.buffer,p,h)),r(f)}finally{e._free(p)}s=u;break;case e.POINT_CLOUD:var _=new e.PointCloud;if(!(l=o.DecodeBufferToPointCloud(a,_)).ok()||!_.ptr)throw new Error(l.error_msg());s=_;break;default:throw new Error("Invalid geometry type ".concat(c))}var m=s.num_points(),g=function(t,i,r,o){var a,s=o.data_type(),l=o.num_components(),c=o.normalized(),u=o.byte_stride(),h=o.byte_offset(),d=((a={})[e.DT_FLOAT32]={typedArrayConstructor:Float32Array,heap:e.HEAPF32},a[e.DT_INT8]={typedArrayConstructor:Int8Array,heap:e.HEAP8},a[e.DT_INT16]={typedArrayConstructor:Int16Array,heap:e.HEAP16},a[e.DT_INT32]={typedArrayConstructor:Int32Array,heap:e.HEAP32},a[e.DT_UINT8]={typedArrayConstructor:Uint8Array,heap:e.HEAPU8},a[e.DT_UINT16]={typedArrayConstructor:Uint16Array,heap:e.HEAPU16},a[e.DT_UINT32]={typedArrayConstructor:Uint32Array,heap:e.HEAPU32},a)[s];if(!d)throw new Error("Invalid data type ".concat(s));var p=m*l,f=p*d.typedArrayConstructor.BYTES_PER_ELEMENT,_=e._malloc(f);try{t.GetAttributeDataArrayForAllPoints(i,o,s,f,_);var g=new d.typedArrayConstructor(d.heap.buffer,_,p);n(r,g.slice(),l,h,u,c)}finally{e._free(_)}};if(i)for(var v in i){var y=i[v],b=o.GetAttributeByUniqueId(s,y);g(o,s,v,b)}else{var T={position:e.POSITION,normal:e.NORMAL,color:e.COLOR,uv:e.TEX_COORD};for(var v in T)-1!==(y=o.GetAttributeId(s,T[v]))&&(b=o.GetAttribute(s,y),g(o,s,v,b))}return m}finally{s&&e.destroy(s),a&&e.destroy(a),o&&e.destroy(o)}}function fE(){var e;onmessage=function(t){var i=t.data;switch(i.id){case"init":var r=i.decoder;r.url&&importScripts(r.url);var n=r.wasmBinary?{wasmBinary:r.wasmBinary}:{};e=DracoDecoderModule(n),postMessage({id:"initDone"});break;case"decodeMesh":if(!e)throw new Error("Draco decoder module is not available");e.then((function(e){var t=pE(e,i.dataView,i.attributes,(function(e){postMessage({id:"indices",data:e},[e.buffer])}),(function(e,t,i,r,n,o){postMessage({id:"attribute",kind:e,data:t,size:i,byteOffset:r,byteStride:n,normalized:o},[t.buffer])}));postMessage({id:"decodeMeshDone",totalVertices:t})}))}}}var _E=function(){function e(t){void 0===t&&(t=e.DefaultNumWorkers);var i=this,r=e.Configuration.decoder;if(r.workerPool||"object"==typeof t&&t.workerPool)this._workerPoolPromise=Promise.resolve(r.workerPool||t.workerPool);else{var n=r.wasmBinary||"object"==typeof t&&t.wasmBinary,o="number"==typeof t?t:t.numWorkers,a=o&&"function"==typeof Worker&&"function"==typeof URL,s=a||!a&&!r.jsModule,l=r.wasmUrl&&r.wasmBinaryUrl&&"object"==typeof WebAssembly?{url:s?rr.GetBabylonScriptURL(r.wasmUrl,!0):"",wasmBinaryPromise:n?Promise.resolve(n):rr.LoadFileAsync(rr.GetBabylonScriptURL(r.wasmBinaryUrl,!0))}:{url:s?rr.GetBabylonScriptURL(r.fallbackUrl):"",wasmBinaryPromise:Promise.resolve(void 0)};a?this._workerPoolPromise=l.wasmBinaryPromise.then((function(e){var t="".concat(pE,"(").concat(fE,")()"),i=URL.createObjectURL(new Blob([t],{type:"application/javascript"}));return new yg(o,(function(){return function(e,t,i){return new Promise((function(r,n){var o=function(t){e.removeEventListener("error",o),e.removeEventListener("message",a),n(t)},a=function(t){"initDone"===t.data.id&&(e.removeEventListener("error",o),e.removeEventListener("message",a),r(e))};if(e.addEventListener("error",o),e.addEventListener("message",a),t){var s=t.slice(0);e.postMessage({id:"init",decoder:{url:i,wasmBinary:s}},[s])}else e.postMessage({id:"init",decoder:{url:i}})}))}(new Worker(i),e,l.url)}))})):this._decoderModulePromise=l.wasmBinaryPromise.then((function(e){return y(i,void 0,void 0,(function(){return b(this,(function(t){switch(t.label){case 0:if("undefined"!=typeof DracoDecoderModule)return[3,2];if(r.jsModule)return[3,2];if(!l.url)throw new Error("Draco decoder module is not available");return[4,rr.LoadBabylonScriptAsync(l.url)];case 1:t.sent(),t.label=2;case 2:return[4,(i=e,n=r.jsModule,new Promise((function(e){(n||DracoDecoderModule)({wasmBinary:i}).then((function(t){e({module:t})}))})))];case 3:return[2,t.sent()]}var i,n}))}))}))}}return Object.defineProperty(e,"DecoderAvailable",{get:function(){var t=e.Configuration.decoder;return!!(t.wasmUrl&&t.wasmBinaryUrl&&"object"==typeof WebAssembly||t.fallbackUrl)},enumerable:!1,configurable:!0}),e.GetDefaultNumWorkers=function(){return"object"==typeof navigator&&navigator.hardwareConcurrency?Math.min(Math.floor(.5*navigator.hardwareConcurrency),4):1},Object.defineProperty(e,"Default",{get:function(){return e._Default||(e._Default=new e),e._Default},enumerable:!1,configurable:!0}),e.ResetDefault=function(t){e._Default&&(t||e._Default.dispose(),e._Default=null)},e.prototype.dispose=function(){this._workerPoolPromise&&this._workerPoolPromise.then((function(e){e.dispose()})),delete this._workerPoolPromise,delete this._decoderModulePromise},e.prototype.whenReadyAsync=function(){return y(this,void 0,void 0,(function(){return b(this,(function(e){switch(e.label){case 0:return this._workerPoolPromise?[4,this._workerPoolPromise]:[3,2];case 1:case 3:return e.sent(),[2];case 2:return this._decoderModulePromise?[4,this._decoderModulePromise]:[3,4];case 4:return[2]}}))}))},e.prototype.decodeMeshToMeshDataAsync=function(e,t,i){var r=e instanceof ArrayBuffer?new Int8Array(e):new Int8Array(e.buffer,e.byteOffset,e.byteLength);if(this._workerPoolPromise)return this._workerPoolPromise.then((function(e){return new Promise((function(n,o){e.push((function(e,a){var s=null,l=[],c=function(t){e.removeEventListener("error",c),e.removeEventListener("message",u),o(t),a()},u=function(t){var r,o,h=t.data;switch(h.id){case"decodeMeshDone":e.removeEventListener("error",c),e.removeEventListener("message",u),n({indices:s,attributes:l,totalVertices:h.totalVertices}),a();break;case"indices":s=h.data;break;case"attribute":l.push({kind:h.kind,data:h.data,size:h.size,byteOffset:h.byteOffset,byteStride:h.byteStride,normalized:(r=h.kind,o=h.normalized,i&&void 0!==i[r]?(o!==i[r]&&ae.Warn("Normalized flag from Draco data (".concat(o,") does not match normalized flag from glTF accessor (").concat(i[r],"). Using flag from glTF accessor.")),i[r]):o)})}};e.addEventListener("error",c),e.addEventListener("message",u);var h=r.slice();e.postMessage({id:"decodeMesh",dataView:h,attributes:t},[h.buffer])}))}))}));if(this._decoderModulePromise)return this._decoderModulePromise.then((function(e){var i=null,n=[],o=pE(e.module,r,t,(function(e){i=e}),(function(e,t,i,r,o,a){n.push({kind:e,data:t,size:i,byteOffset:r,byteStride:o,normalized:a})}));return{indices:i,attributes:n,totalVertices:o}}));throw new Error("Draco decoder module is not available")},e.prototype.decodeMeshToGeometryAsync=function(e,t,i,r){return y(this,void 0,void 0,(function(){var n,o,a,s,l;return b(this,(function(c){switch(c.label){case 0:return[4,this.decodeMeshToMeshDataAsync(i,r)];case 1:for(n=c.sent(),o=new vo(e,t),n.indices&&o.setIndices(n.indices),a=0,s=n.attributes;ae.EPSILON?1:0;l|=u,c.push(u)}switch(l){case 0:(V.Dot(this.normal,t.plane.normal)>0?i:r).push(t);break;case 1:n.push(t);break;case 2:o.push(t);break;case 3:var h=[],d=[];for(a=0;a=3&&(y=new bE(h,t.shared)).plane&&n.push(y),d.length>=3&&(y=new bE(d,t.shared)).plane&&o.push(y)}},e.EPSILON=1e-5,e}(),bE=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=yE.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e}(),TE=function(){function e(e){this._plane=null,this._front=null,this._back=null,this._polygons=new Array,e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t._plane=this._plane&&this._plane.clone(),t._front=this._front&&this._front.clone(),t._back=this._back&&this._back.clone(),t._polygons=this._polygons.map((function(e){return e.clone()})),t},e.prototype.invert=function(){for(var e=0;e\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\nvoid main(void) {vec3 positionUpdated=position;vec3 normalUpdated=normal;\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);mat3 normWorldSM=mat3(finalWorld);vec3 vNormalW;\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvNormalW=normalize(normWorldSM*normalUpdated);\n#endif\nvec3 normalView=normalize((projMatrix*vec4(vNormalW,0.0)).xyz);vec3 decalTC=(projMatrix*worldPos).xyz;vDecalTC=decalTC.xy;gl_Position=vec4(uv*2.0-1.0,normalView.z>0.0 ? 2. : decalTC.z,1.0);}";li.ShadersStore.meshUVSpaceRendererPixelShader="precision highp float;varying vec2 vDecalTC;uniform sampler2D textureSampler;void main(void) {if (vDecalTC.x<0. || vDecalTC.x>1. || vDecalTC.y<0. || vDecalTC.y>1.) {discard;}\ngl_FragColor=texture2D(textureSampler,vDecalTC);}\n";li.ShadersStore.meshUVSpaceRendererMaskerVertexShader="attribute vec2 uv;varying vec2 vUV;void main(void) {gl_Position=vec4(vec2(uv.x,uv.y)*2.0-1.0,0.,1.0);vUV=uv;}";li.ShadersStore.meshUVSpaceRendererMaskerPixelShader="varying vec2 vUV;void main(void) {gl_FragColor=vec4(1.0,1.0,1.0,1.0);}\n";li.ShadersStore.meshUVSpaceRendererFinaliserPixelShader="precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D maskTextureSampler;uniform vec2 textureSize;void main() {vec4 mask=texture2D(maskTextureSampler,vUV).rgba;if (mask.r>0.5) {gl_FragColor=texture2D(textureSampler,vUV);} else {vec2 texelSize=4.0/textureSize;vec2 uv_p01=vUV+vec2(-1.0,0.0)*texelSize;vec2 uv_p21=vUV+vec2(1.0,0.0)*texelSize;vec2 uv_p10=vUV+vec2(0.0,-1.0)*texelSize;vec2 uv_p12=vUV+vec2(0.0,1.0)*texelSize;float mask_p01=texture2D(maskTextureSampler,uv_p01).r;float mask_p21=texture2D(maskTextureSampler,uv_p21).r;float mask_p10=texture2D(maskTextureSampler,uv_p10).r;float mask_p12=texture2D(maskTextureSampler,uv_p12).r;vec4 col=vec4(0.0,0.0,0.0,0.0);float total_weight=0.0;if (mask_p01>0.5) {col+=texture2D(textureSampler,uv_p01);total_weight+=1.0;}\nif (mask_p21>0.5) {col+=texture2D(textureSampler,uv_p21);total_weight+=1.0;}\nif (mask_p10>0.5) {col+=texture2D(textureSampler,uv_p10);total_weight+=1.0;}\nif (mask_p12>0.5) {col+=texture2D(textureSampler,uv_p12);total_weight+=1.0;}\nif (total_weight>0.0) {gl_FragColor=col/total_weight;} else {gl_FragColor=col;}}}\n";li.ShadersStore.meshUVSpaceRendererFinaliserVertexShader="precision highp float;attribute vec3 position;attribute vec2 uv;uniform mat4 worldViewProjection;varying vec2 vUV;void main() {gl_Position=worldViewProjection*vec4(position,1.0);vUV=uv;}\n";var SE=function(){function e(e,t,i){this._textureCreatedInternally=!1,this._configureUserCreatedTexture=!0,this._maskTexture=null,this._finalPostProcess=null,this.clearColor=new J(0,0,0,0),this._mesh=e,this._scene=t,this._options=g({width:1024,height:1024,textureType:u.TEXTURETYPE_UNSIGNED_BYTE,generateMipMaps:!0,optimizeUVAllocation:!0,uvEdgeBlending:!1},i)}return e._GetShader=function(e){if(!e._meshUVSpaceRendererShader){var t=new ld("meshUVSpaceRendererShader",e,{vertex:"meshUVSpaceRenderer",fragment:"meshUVSpaceRenderer"},{attributes:["position","normal","uv"],uniforms:["world","projMatrix"],samplers:["textureSampler"],needAlphaBlending:!0});t.backFaceCulling=!1,t.alphaMode=u.ALPHA_COMBINE,e.onDisposeObservable.add((function(){var t;null===(t=e._meshUVSpaceRendererShader)||void 0===t||t.dispose(),e._meshUVSpaceRendererShader=null})),e._meshUVSpaceRendererShader=t}return e._meshUVSpaceRendererShader},e._GetMaskShader=function(e){if(!e._meshUVSpaceRendererMaskShader){var t=new ld("meshUVSpaceRendererMaskShader",e,{vertex:"meshUVSpaceRendererMasker",fragment:"meshUVSpaceRendererMasker"},{attributes:["position","uv"],uniforms:["worldViewProjection"]});t.backFaceCulling=!1,t.alphaMode=u.ALPHA_COMBINE,e.onDisposeObservable.add((function(){var t;null===(t=e._meshUVSpaceRendererMaskShader)||void 0===t||t.dispose(),e._meshUVSpaceRendererMaskShader=null})),e._meshUVSpaceRendererMaskShader=t}return e._meshUVSpaceRendererMaskShader},e._IsRenderTargetTexture=function(e){return void 0!==e.renderList},e.prototype.isReady=function(){var t,i,r,n;this.texture||this._createDiffuseRTT();var o=e._IsRenderTargetTexture(this.texture)?this.texture.isReadyForRendering():this.texture.isReady(),a=null===(i=null===(t=this._maskTexture)||void 0===t?void 0:t.isReadyForRendering())||void 0===i||i,s=null===(n=null===(r=this._finalPostProcess)||void 0===r?void 0:r.isReady())||void 0===n||n;return o&&a&&s},e.prototype.renderTexture=function(t,i,r,n,o){if(void 0===o&&(o=0),this.texture?this._configureUserCreatedTexture&&this._configureUserCreatedRTT():this._createDiffuseRTT(),e._IsRenderTargetTexture(this.texture)){var a=this._createProjectionMatrix(i,r,n,o),s=e._GetShader(this._scene);s.setTexture("textureSampler",t),s.setMatrix("projMatrix",a),this.texture.render()}},e.prototype.clear=function(){var t,i,r,n;e._IsRenderTargetTexture(this.texture)&&this.texture.renderTarget&&((n=this._scene.getEngine()).bindFramebuffer(this.texture.renderTarget),n.clear(this.clearColor,!0,!0,!0),n.unBindFramebuffer(this.texture.renderTarget)),(null===(t=this._finalPostProcess)||void 0===t?void 0:t.inputTexture)&&((n=this._scene.getEngine()).bindFramebuffer(null===(i=this._finalPostProcess)||void 0===i?void 0:i.inputTexture),n.clear(this.clearColor,!0,!0,!0),n.unBindFramebuffer(null===(r=this._finalPostProcess)||void 0===r?void 0:r.inputTexture))},e.prototype.dispose=function(){var e,t;this._textureCreatedInternally&&(this.texture.dispose(),this._textureCreatedInternally=!1),this._configureUserCreatedTexture=!0,null===(e=this._maskTexture)||void 0===e||e.dispose(),this._maskTexture=null,null===(t=this._finalPostProcess)||void 0===t||t.dispose(),this._finalPostProcess=null},e.prototype._configureUserCreatedRTT=function(){this._configureUserCreatedTexture=!1,e._IsRenderTargetTexture(this.texture)&&(this.texture.setMaterialForRendering(this._mesh,e._GetShader(this._scene)),this.texture.onClearObservable.add((function(){})),this.texture.renderList=[this._mesh],this._options.uvEdgeBlending&&(this._createMaskTexture(),this._createPostProcess(),this.texture.addPostProcess(this._finalPostProcess)))},e.prototype._createDiffuseRTT=function(){this._textureCreatedInternally=!0;var t=this._createRenderTargetTexture(this._options.width,this._options.height);t.setMaterialForRendering(this._mesh,e._GetShader(this._scene)),this.texture=t,this._configureUserCreatedTexture=!1,this._options.uvEdgeBlending&&(this._createMaskTexture(),this._createPostProcess(),t.addPostProcess(this._finalPostProcess))},e.prototype._createMaskTexture=function(){this._maskTexture||(this._maskTexture=new Pl(this._mesh.name+"_maskTexture",{width:this._options.width,height:this._options.height},this._scene,!1,!0,u.TEXTURETYPE_UNSIGNED_BYTE,!1,u.TEXTURE_BILINEAR_SAMPLINGMODE,void 0,void 0,void 0,u.TEXTUREFORMAT_R),this._maskTexture.clearColor=new J(0,0,0,0),this._maskTexture.renderList.push(this._mesh),this._maskTexture.setMaterialForRendering(this._mesh,e._GetMaskShader(this._scene)),this._maskTexture.refreshRate=Pl.REFRESHRATE_RENDER_ONCE,this._scene.customRenderTargets.push(this._maskTexture))},e.prototype._createPostProcess=function(){var e=this;this._finalPostProcess||(this._finalPostProcess=new hl(this._mesh.name+"_fixSeamsPostProcess","meshUVSpaceRendererFinaliser",["textureSize"],["textureSampler","maskTextureSampler"],1,null,u.TEXTURE_NEAREST_SAMPLINGMODE,this._scene.getEngine(),!1,null,this._options.textureType),this._finalPostProcess.onApplyObservable.add((function(t){t.setTexture("maskTextureSampler",e._maskTexture),t.setFloat2("textureSize",e._options.width,e._options.height)})))},e.prototype._createRenderTargetTexture=function(e,t){var i=this,r=new Pl(this._mesh.name+"_uvspaceTexture",{width:e,height:t},this._scene,this._options.generateMipMaps,!0,this._options.textureType,!1,this._options.generateMipMaps?u.TEXTURE_TRILINEAR_SAMPLINGMODE:u.TEXTURE_BILINEAR_SAMPLINGMODE,!1,!1,!1,u.TEXTUREFORMAT_RGBA);return r.renderParticles=!1,r.optimizeUVAllocation=!!this._options.optimizeUVAllocation,r.onClearObservable.addOnce((function(){i._scene.getEngine().clear(i.clearColor,!0,!0,!0),r.onClearObservable.add((function(){}))})),r.renderList=[this._mesh],r},e.prototype._createProjectionMatrix=function(e,t,i,r){void 0===r&&(r=0);var n=-Math.atan2(t.z,t.x)-Math.PI/2,o=Math.sqrt(t.x*t.x+t.z*t.z),a=Math.atan2(t.y,o),s=e.add(t.scale(.5*i.z)),l=z.RotationYawPitchRoll(n,a,r).multiply(z.Translation(s.x,s.y,s.z)),c=z.Invert(l),u=z.FromArray([2/i.x,0,0,0,0,2/i.y,0,0,0,0,1/i.z,0,0,0,0,1]),h=z.FromArray([.5,0,0,0,0,.5,0,0,0,0,1,0,.5,.5,0,1]);return c.multiply(u).multiply(h)},e}();Fa._TrailMeshParser=function(e,t){return AE.Parse(e,t)};var xE,AE=function(e){function t(t,i,r,n,o,a){void 0===n&&(n=1),void 0===o&&(o=60),void 0===a&&(a=!0);var s=e.call(this,t,r)||this;s._sectionPolygonPointsCount=4,s._running=!1,s._autoStart=a,s._generator=i,s.diameter=n,s._length=o,s._sectionVectors=[],s._sectionNormalVectors=[];for(var l=0;l<=s._sectionPolygonPointsCount;l++)s._sectionVectors[l]=V.Zero(),s._sectionNormalVectors[l]=V.Zero();return s._createMesh(),s}return m(t,e),t.prototype.getClassName=function(){return"TrailMesh"},t.prototype._createMesh=function(){var e=new _o,t=[],i=[],r=[],n=[],o=V.Zero();o=this._generator instanceof Uo&&this._generator.hasBoundingInfo?this._generator.getBoundingInfo().boundingBox.centerWorld:this._generator.absolutePosition;for(var a=2*Math.PI/this._sectionPolygonPointsCount,s=0;s<=this._sectionPolygonPointsCount;s++){var l=s!==this._sectionPolygonPointsCount?s*a:0;t.push(o.x+Math.cos(l)*this.diameter,o.y+Math.sin(l)*this.diameter,o.z),n.push(s/this._sectionPolygonPointsCount,0)}for(s=1;s<=this._length;s++){for(var c=0;c<=this._sectionPolygonPointsCount;c++)l=c!==this._sectionPolygonPointsCount?c*a:0,t.push(o.x+Math.cos(l)*this.diameter,o.y+Math.sin(l)*this.diameter,o.z),n.push(c/this._sectionPolygonPointsCount,s/this._length);var u=t.length/3-2*(this._sectionPolygonPointsCount+1);for(c=0;c<=this._sectionPolygonPointsCount;c++)r.push(u+c,u+c+this._sectionPolygonPointsCount,u+c+this._sectionPolygonPointsCount+1),r.push(u+c,u+c+this._sectionPolygonPointsCount+1,u+c+1)}_o.ComputeNormals(t,r,i),e.positions=t,e.normals=i,e.indices=r,e.uvs=n,e.applyToMesh(this,!0),this._autoStart&&this.start()},t.prototype.start=function(){var e=this;this._running||(this._running=!0,this._beforeRenderObserver=this.getScene().onBeforeRenderObservable.add((function(){e.update()})))},t.prototype.stop=function(){this._beforeRenderObserver&&this._running&&(this._running=!1,this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver))},t.prototype.update=function(){var e=this.getVerticesData(Nr.PositionKind),t=this.getVerticesData(Nr.NormalKind),i=this._generator.getWorldMatrix();if(e&&t){for(var r=3*(this._sectionPolygonPointsCount+1);rs||i.deleted||i.isDirty))for(var n=function(e){if(i.error[e]0&&this._reconstructedMesh.setVerticesData(Nr.NormalKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(Nr.UVKind,s),l.length>0&&this._reconstructedMesh.setVerticesData(Nr.ColorKind,l);var b=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],g.forEach((function(e){po.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),po.AddToMesh(b.materialIndex,m,d,_,3*n.length,this._reconstructedMesh))},e.prototype._initDecimatedMesh=function(){this._reconstructedMesh=new Fa(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},e.prototype._isFlipped=function(e,t,i,r,n){for(var o=0;o.999)return!0;var d=V.Cross(u,h).normalize();if(r[o]=!1,V.Dot(d,a.normal)<.2)return!0}else r[o]=!0,n.push(a)}}return!1},e.prototype._updateTriangles=function(e,t,i,r){for(var n=r,o=0;o65535?new Uint32Array(o):new Uint16Array(o),u=new Float32Array(a),h=new Float32Array(s),d=new Float32Array(s),p=0,f=0,_=0,m=0,g=0;e.forEach((function(e){for(var n=ZT.GetLineLengthArray(e),o=n[n.length-1],a=0,s=0;s>1]/o;if(i._options.uvs)for(R=0;R2)for(c=0;c0&&(d[0]+=1,d[1]+=1),s.push(d[1]+(u%2!=0?o:0),d[0],d[2]),p&&s.push(d[0],d[1]+(u%2!=0?o:0),d[2]);else for(c=0;cf.y&&f.x>f.z?r?t._RightHandedForwardReadOnlyQuaternion:t._LeftHandedForwardReadOnlyQuaternion:t._LeftReadOnlyQuaternion),c=f.normalize()}u=c.multiplyByFloats(s,s,s),o.push(d.add(u)),a.push(d.subtract(u))}n||(o.push(l[l.length-1].add(u)),a.push(l[l.length-1].subtract(u)))}return[o,a]},t._GetDirectionFromPoints=function(e,i,r){return e.x!==i.x||r&&1!==(null==r?void 0:r.x)?e.y===i.y?t.DIRECTION_XZ:e.z===i.z?t.DIRECTION_XY:t.DIRECTION_XZ:t.DIRECTION_YZ},t.prototype.clone=function(e,i){void 0===e&&(e="".concat(this.name,"-cloned"));var r=this._createLineOptions(),n={},o=[];ye.DeepCopy(this._pathsOptions,o,void 0,void 0,!0),ye.DeepCopy(r,n,["instance"],void 0,!0);var a=new t(e,this._scene,n,o);return i&&(a.parent=i),a.material=this.material,a},t.prototype.serialize=function(t){e.prototype.serialize.call(this,t),t.type=this.getClassName(),t.lineOptions=this._createLineOptions(),t.pathsOptions=this._pathsOptions},t.Parse=function(e,i){var r=e.lineOptions;return new t(e.name,i,r,e.pathOptions)},t.prototype._initGreasedLine=function(){e.prototype._initGreasedLine.call(this),this._paths=[],this._counters=[],this._slopes=[],this._ribbonWidths=[]},t.prototype._calculateSegmentLengths=function(e){var t=e.length;this._vSegmentLengths=new Array(t),this._vTotalLengths=new Array(t);for(var i=0,r=0;r0){if(t.length%2!=0&&t.push(r),i===kE.WIDTH_DISTRIBUTION_START_END){for(var s=Math.floor(t.length/2),l=0,c=0;l0){if(i===VE.COLOR_DISTRIBUTION_START_END){for(var a=Math.floor(t.length/2),s=0;s=this._thinInstanceDataStorage.instancesCount)return!1;var r=this._thinInstanceDataStorage.matrixData;return t.copyToArray(r,16*e),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[e]=t),i&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},Fa.prototype.thinInstanceSetAttributeAt=function(e,t,i,r){return void 0===r&&(r=!0),e===Nr.ColorKind&&(e=Nr.ColorInstanceKind),!(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[e]||t>=this._thinInstanceDataStorage.instancesCount||(this._thinInstanceUpdateBufferSize(e,0),this._userThinInstanceBuffersStorage.data[e].set(i,t*this._userThinInstanceBuffersStorage.strides[e]),r&&this.thinInstanceBufferUpdated(e),0))},Object.defineProperty(Fa.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(e){var t,i,r=null!==(t=this._thinInstanceDataStorage.matrixData)&&void 0!==t?t:null===(i=this.source)||void 0===i?void 0:i._thinInstanceDataStorage.matrixData;e<=(r?r.length/16:0)&&(this._thinInstanceDataStorage.instancesCount=e)},enumerable:!0,configurable:!0}),Fa.prototype._thinInstanceCreateMatrixBuffer=function(e,t,i){void 0===i&&(i=!0);for(var r=new Dr(this.getEngine(),t,!i,16,!1,!0),n=0;n<4;n++)this.setVerticesBuffer(r.createVertexBuffer(e+n,4*n,4));return r},Fa.prototype.thinInstanceSetBuffer=function(e,t,i,r){var n,o,a;void 0===i&&(i=0),void 0===r&&(r=!0),i=i||16,"matrix"===e?(null===(n=this._thinInstanceDataStorage.matrixBuffer)||void 0===n||n.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=t?t.length:32*i,this._thinInstanceDataStorage.matrixData=t,this._thinInstanceDataStorage.worldMatrices=null,null!==t?(this._thinInstanceDataStorage.instancesCount=t.length/i,this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",t,r),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)):(this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo())):"previousMatrix"===e?(null===(o=this._thinInstanceDataStorage.previousMatrixBuffer)||void 0===o||o.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=null,this._thinInstanceDataStorage.previousMatrixData=t,null!==t&&(this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",t,r))):(e===Nr.ColorKind&&(e=Nr.ColorInstanceKind),null===t?(null===(a=this._userThinInstanceBuffersStorage)||void 0===a?void 0:a.data[e])&&(this.removeVerticesData(e),delete this._userThinInstanceBuffersStorage.data[e],delete this._userThinInstanceBuffersStorage.strides[e],delete this._userThinInstanceBuffersStorage.sizes[e],delete this._userThinInstanceBuffersStorage.vertexBuffers[e]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[e]=t,this._userThinInstanceBuffersStorage.strides[e]=i,this._userThinInstanceBuffersStorage.sizes[e]=t.length,this._userThinInstanceBuffersStorage.vertexBuffers[e]=new Nr(this.getEngine(),t,e,!r,!1,i,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])))},Fa.prototype.thinInstanceBufferUpdated=function(e){var t,i,r;"matrix"===e?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.matrixBuffer&&!this._thinInstanceDataStorage.matrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(e),null===(t=this._thinInstanceDataStorage.matrixBuffer)||void 0===t||t.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount)):"previousMatrix"===e?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.previousMatrixBuffer&&!this._thinInstanceDataStorage.previousMatrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(e),null===(i=this._thinInstanceDataStorage.previousMatrixBuffer)||void 0===i||i.updateDirectly(this._thinInstanceDataStorage.previousMatrixData,0,this._thinInstanceDataStorage.instancesCount)):(e===Nr.ColorKind&&(e=Nr.ColorInstanceKind),(null===(r=this._userThinInstanceBuffersStorage)||void 0===r?void 0:r.vertexBuffers[e])&&(this.thinInstanceAllowAutomaticStaticBufferRecreation&&!this._userThinInstanceBuffersStorage.vertexBuffers[e].isUpdatable()&&this._thinInstanceRecreateBuffer(e),this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e],0)))},Fa.prototype.thinInstancePartialBufferUpdate=function(e,t,i){var r;"matrix"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,i):(e===Nr.ColorKind&&(e=Nr.ColorInstanceKind),(null===(r=this._userThinInstanceBuffersStorage)||void 0===r?void 0:r.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t,i))},Fa.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];var e=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=[];for(var t=0;t0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"innerType",{get:function(){return this._linkedConnectionSource&&this._linkedConnectionSource.isConnected?this.type:this._type},enumerable:!1,configurable:!0}),e.prototype._resetCounters=function(){this._callCount=0,this._executionCount=0},Object.defineProperty(e.prototype,"callCount",{get:function(){return this._callCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"executionCount",{get:function(){return this._executionCount},enumerable:!1,configurable:!0}),e.prototype.getConnectedValue=function(e){var t;return this.isConnected?(null===(t=this._connectedPoint)||void 0===t?void 0:t._storedFunction)?(this._connectedPoint._callCount++,this._connectedPoint._executionCount++,this._connectedPoint._storedFunction(e)):(this._connectedPoint._callCount++,this._connectedPoint._executionCount=1,this._connectedPoint._storedValue):(this._callCount++,this._executionCount=1,this.value)},e.prototype.getClassName=function(){return"NodeGeometryConnectionPoint"},e.prototype.canConnectTo=function(e){return this.checkCompatibilityState(e)===zE.Compatible},e.prototype.checkCompatibilityState=function(e){var t=this._ownerBlock,i=e.ownerBlock;if(this.type!==e.type&&e.innerType!==GE.AutoDetect)return e.acceptedConnectionPointTypes&&-1!==e.acceptedConnectionPointTypes.indexOf(this.type)?zE.Compatible:zE.TypeIncompatible;if(e.excludedConnectionPointTypes&&-1!==e.excludedConnectionPointTypes.indexOf(this.type))return zE.TypeIncompatible;var r=i,n=t;return this.direction===WE.Input&&(r=t,n=i),r.isAnAncestorOf(n)?zE.HierarchyIssue:zE.Compatible},e.prototype.connectTo=function(e,t){if(void 0===t&&(t=!1),!t&&!this.canConnectTo(e))throw"Cannot connect these two connectors.";return this._endpoints.push(e),e._connectedPoint=this,this.onConnectionObservable.notifyObservers(e),e.onConnectionObservable.notifyObservers(this),this},e.prototype.disconnectFrom=function(e){var t=this._endpoints.indexOf(e);return-1===t||(this._endpoints.splice(t,1),e._connectedPoint=null,this.onDisconnectionObservable.notifyObservers(e),e.onDisconnectionObservable.notifyObservers(this)),this},e.prototype.addExcludedConnectionPointFromAllowedTypes=function(e){for(var t=1;t=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t},e.prototype.dispose=function(){this.onConnectionObservable.clear(),this.onDisconnectionObservable.clear()},e}(),JE=function(){function e(e){this._name="",this._isInput=!1,this._isTeleportOut=!1,this._isTeleportIn=!1,this._isDebug=!1,this._isUnique=!1,this._buildExecutionTime=0,this.onBuildObservable=new f,this._inputs=new Array,this._outputs=new Array,this._codeVariableName="",this.visibleOnFrame=!1,this._name=e,this.uniqueId=cn.UniqueId}return Object.defineProperty(e.prototype,"buildExecutionTime",{get:function(){return this._buildExecutionTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputs",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outputs",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTeleportOut",{get:function(){return this._isTeleportOut},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTeleportIn",{get:function(){return this._isTeleportIn},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDebug",{get:function(){return this._isDebug},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnique",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"NodeGeometryBlock"},e.prototype._inputRename=function(e){return e},e.prototype._outputRename=function(e){return e},e.prototype.isAnAncestorOf=function(e){for(var t=0,i=this._outputs;t0){if(!this._outputs.some((function(e){return e.hasEndpoints}))&&!this.isDebug)return!1;this.outputs.forEach((function(e){return e._resetCounters()}))}this._buildId=e.buildId;for(var t=0,i=this._inputs;t0?this._geometryContextStack[this._geometryContextStack.length-1]:null},e.prototype.restoreExecutionContext=function(){this._executionContextStack.pop(),this._executionContext=this._executionContextStack.length>0?this._executionContextStack[this._executionContextStack.length-1]:null},e.prototype.restoreInstancingContext=function(){this._instancingContextStack.pop(),this._instancingContext=this._instancingContextStack.length>0?this._instancingContextStack[this._instancingContextStack.length-1]:null},e.prototype.getContextualValue=function(e,t){if(void 0===t&&(t=!1),!this.executionContext)return t||this.noContextualData.push(e),null;var i=this.executionContext.getExecutionIndex();switch(e){case qE.Positions:return this.executionContext.getOverridePositionsContextualValue?this.executionContext.getOverridePositionsContextualValue():this.geometryContext&&this.geometryContext.positions?V.FromArray(this.geometryContext.positions,3*i):V.Zero();case qE.Normals:return this.executionContext.getOverrideNormalsContextualValue?this.executionContext.getOverrideNormalsContextualValue():this.geometryContext&&this.geometryContext.normals?V.FromArray(this.geometryContext.normals,3*i):V.Zero();case qE.Colors:return this.geometryContext&&this.geometryContext.colors?k.FromArray(this.geometryContext.colors,4*i):k.Zero();case qE.Tangents:return this.geometryContext&&this.geometryContext.tangents?k.FromArray(this.geometryContext.tangents,4*i):k.Zero();case qE.UV:return this.executionContext.getOverrideUVs1ContextualValue?this.executionContext.getOverrideUVs1ContextualValue():this.geometryContext&&this.geometryContext.uvs?U.FromArray(this.geometryContext.uvs,2*i):U.Zero();case qE.UV2:return this.geometryContext&&this.geometryContext.uvs2?U.FromArray(this.geometryContext.uvs2,2*i):U.Zero();case qE.UV3:return this.geometryContext&&this.geometryContext.uvs3?U.FromArray(this.geometryContext.uvs3,2*i):U.Zero();case qE.UV4:return this.geometryContext&&this.geometryContext.uvs4?U.FromArray(this.geometryContext.uvs4,2*i):U.Zero();case qE.UV5:return this.geometryContext&&this.geometryContext.uvs5?U.FromArray(this.geometryContext.uvs5,2*i):U.Zero();case qE.UV6:return this.geometryContext&&this.geometryContext.uvs6?U.FromArray(this.geometryContext.uvs6,2*i):U.Zero();case qE.VertexID:return i;case qE.FaceID:return this.executionContext.getExecutionFaceIndex();case qE.LoopID:return this.executionContext.getExecutionLoopIndex();case qE.InstanceID:return this.instancingContext?this.instancingContext.getInstanceIndex():0;case qE.GeometryID:return this.geometryContext?this.geometryContext.uniqueId:0;case qE.CollectionID:return this.geometryContext&&this.geometryContext.metadata&&this.geometryContext.metadata.collectionId||0}return null},e.prototype.adapt=function(e,t){var i=e.getConnectedValue(this)||0;if(e.type===t)return i;switch(t){case GE.Vector2:return new U(i,i);case GE.Vector3:return new V(i,i,i);case GE.Vector4:return new k(i,i,i,i)}return null},e.prototype.adaptInput=function(e,t,i){var r;if(!e.isConnected)return e.value||i;var n=e.getConnectedValue(this);if((null===(r=e._connectedPoint)||void 0===r?void 0:r.type)===t)return n;switch(t){case GE.Vector2:return new U(n,n);case GE.Vector3:return new V(n,n,n);case GE.Vector4:return new k(n,n,n,n)}return null},e.prototype.emitErrors=function(){for(var e="",t=0,i=this.notConnectedNonOptionalInputs;t-1&&this.attachedBlocks.splice(t,1),e===this.outputBlock&&(this.outputBlock=null)},e.prototype.parseSerializedObject=function(e,t){void 0===t&&(t=!1),t||this.clear();for(var i={},r=0,n=e.blocks;rr;break;case ES.LessOrEqual:n=i<=r;break;case ES.GreaterOrEqual:n=i>=r;break;case ES.Xor:n=!!i&&!r||!i&&!!r;break;case ES.Or:n=!!i||!!r;break;case ES.And:n=!!i&&!!r}return n}(t)?e.ifTrue.getConnectedValue(t):e.ifFalse.getConnectedValue(t)}},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".test = BABYLON.ConditionBlockTests.").concat(ES[this.test],";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.test=this.test,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.test=t.test},v([Ys("Test",Xs.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Equal",value:ES.Equal},{label:"NotEqual",value:ES.NotEqual},{label:"LessThan",value:ES.LessThan},{label:"GreaterThan",value:ES.GreaterThan},{label:"LessOrEqual",value:ES.LessOrEqual},{label:"GreaterOrEqual",value:ES.GreaterOrEqual},{label:"Xor",value:ES.Xor},{label:"Or",value:ES.Or},{label:"And",value:ES.And}]})],t.prototype,"test",void 0),t}(JE);a("BABYLON.ConditionBlock",AS),function(e){e[e.None=0]="None",e[e.LoopID=1]="LoopID",e[e.InstanceID=2]="InstanceID"}(xS||(xS={}));var CS=function(e){function t(t){var i=e.call(this,t)||this;return i._currentLockId=-1,i.lockMode=xS.None,i.registerInput("min",GE.AutoDetect),i.registerInput("max",GE.AutoDetect),i.registerOutput("output",GE.BasedOnInput),i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i._inputs[1].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[1].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[1].excludedConnectionPointTypes.push(GE.Texture),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return m(t,e),t.prototype.getClassName=function(){return"RandomBlock"},Object.defineProperty(t.prototype,"min",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"max",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.min.isConnected){var e=new tS("Min");e.value=0,e.output.connectTo(this.min)}if(!this.max.isConnected){var t=new tS("Max");t.value=1,t.output.connectTo(this.max)}},t.prototype._buildBlock=function(){var e=this,t=null;switch(this._currentLockId=-1,this.min.type){case GE.Int:case GE.Float:t=function(t){var i=e.min.getConnectedValue(t)||0,r=e.max.getConnectedValue(t)||0;return i+Math.random()*(r-i)};break;case GE.Vector2:t=function(t){var i=e.min.getConnectedValue(t)||U.Zero(),r=e.max.getConnectedValue(t)||U.Zero();return new U(i.x+Math.random()*(r.x-i.x),i.y+Math.random()*(r.y-i.y))};break;case GE.Vector3:t=function(t){var i=e.min.getConnectedValue(t)||V.Zero(),r=e.max.getConnectedValue(t)||V.Zero();return new V(i.x+Math.random()*(r.x-i.x),i.y+Math.random()*(r.y-i.y),i.z+Math.random()*(r.z-i.z))};break;case GE.Vector4:t=function(t){var i=e.min.getConnectedValue(t)||k.Zero(),r=e.max.getConnectedValue(t)||k.Zero();return new k(i.x+Math.random()*(r.x-i.x),i.y+Math.random()*(r.y-i.y),i.z+Math.random()*(r.z-i.z),i.w+Math.random()*(r.w-i.w))}}this.lockMode!==xS.None&&t?this.output._storedFunction=function(i){var r=0;switch(e.lockMode){case xS.InstanceID:r=i.getContextualValue(qE.InstanceID,!0)||0;break;case xS.LoopID:r=i.getContextualValue(qE.LoopID,!0)||0}return e._currentLockId===r&&e.lockMode!==xS.None||(e._currentLockId=r,e.output._storedValue=t(i)),e.output._storedValue}:this.output._storedFunction=t},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".lockMode = BABYLON.RandomBlockLocks.").concat(xS[this.lockMode],";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.lockMode=this.lockMode,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.lockMode=t.lockMode},v([Ys("LockMode",Xs.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"None",value:xS.None},{label:"LoopID",value:xS.LoopID},{label:"InstanceID",value:xS.InstanceID}]})],t.prototype,"lockMode",void 0),t}(JE);a("BABYLON.RandomBlock",CS);var RS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("offset",GE.Vector3,!0,V.Zero()),i.registerInput("scale",GE.Float,!0,1),i.registerInput("octaves",GE.Float,!0,2,0,16),i.registerInput("roughness",GE.Float,!0,.5,0,1),i.registerOutput("output",GE.Float),i}return m(t,e),t.prototype.getClassName=function(){return"NoiseBlock"},Object.defineProperty(t.prototype,"offset",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"octaves",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._negateIf=function(e,t){return 0!==t?-e:e},t.prototype._noiseGrad=function(e,t,i,r){var n=15&e,o=n<8?t:i,a=n<4?i:12===n||14==n?t:r;return this._negateIf(o,n&o)+this._negateIf(a,2&n)},t.prototype._fade=function(e){return e*e*e*(e*(6*e-15)+10)},t.prototype._hashBitRotate=function(e,t){return e<>32-t},t.prototype._hash=function(e,t,i){var r,n,o;return r=n=o=3735928584,o+=i,r+=e,o^=n+=t,r^=o-=this._hashBitRotate(n,14),n^=r-=this._hashBitRotate(o,11),o^=n-=this._hashBitRotate(r,25),r^=o-=this._hashBitRotate(n,16),n^=r-=this._hashBitRotate(o,4),(o^=n-=this._hashBitRotate(r,14))-this._hashBitRotate(n,24)},t.prototype._mix=function(e,t,i,r,n,o,a,s,l,c,u){var h=1-l,d=1-c;return(1-u)*(d*(e*h+t*l)+c*(i*h+r*l))+u*(d*(n*h+o*l)+c*(a*h+s*l))},t.prototype._perlinNoise=function(e){var t=(0|e.x)-(e.x<0?1:0),i=(0|e.y)-(e.y<0?1:0),r=(0|e.z)-(e.z<0?1:0),n=e.x-t,o=e.y-i,a=e.z-r,s=this._fade(n),l=this._fade(o),c=this._fade(a);return this._mix(this._noiseGrad(this._hash(t,i,r),n,o,a),this._noiseGrad(this._hash(t+1,i,r),n-1,o,a),this._noiseGrad(this._hash(t,i+1,r),n,o-1,a),this._noiseGrad(this._hash(t+1,i+1,r),n-1,o-1,a),this._noiseGrad(this._hash(t,i,r+1),n,o,a-1),this._noiseGrad(this._hash(t+1,i,r+1),n-1,o,a-1),this._noiseGrad(this._hash(t,i+1,r+1),n,o-1,a-1),this._noiseGrad(this._hash(t+1,i+1,r+1),n-1,o-1,a-1),s,l,c)},t.prototype._perlinSigned=function(e){return.982*this._perlinNoise(e)},t.prototype._perlin=function(e){return this._perlinSigned(e)/2+.5},t.prototype.noise=function(e,t,i,r,n){for(var o=new V(i.x*n+r.x,i.y*n+r.y,i.z*n+r.z),a=1,s=1,l=0,c=0,u=0|(e=j.Clamp(e,0,15)),h=0;h<=u;h++)c+=this._perlin(o.scale(a))*s,l+=s,s*=j.Clamp(t,0,1),a*=2;var d=e-Math.floor(e);if(0==d)return c/l;var p=c+this._perlin(o.scale(a))*s;return(1-d)*(c/=l)+d*(p/(l+s))},t.prototype._buildBlock=function(){var e=this;this.output._storedFunction=function(t){var i=t.getContextualValue(qE.Positions),r=e.octaves.getConnectedValue(t),n=e.roughness.getConnectedValue(t),o=e.offset.getConnectedValue(t),a=e.scale.getConnectedValue(t);return e.noise(r,n,i,o,a)}},t}(JE);a("BABYLON.NoiseBlock",RS);var PS=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!1,i.registerInput("geometry0",GE.Geometry),i.registerInput("geometry1",GE.Geometry,!0),i.registerInput("geometry2",GE.Geometry,!0),i.registerInput("geometry3",GE.Geometry,!0),i.registerInput("geometry4",GE.Geometry,!0),i.registerOutput("output",GE.Geometry),i}return m(t,e),t.prototype.getClassName=function(){return"MergeGeometryBlock"},Object.defineProperty(t.prototype,"geometry0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry2",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry3",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry4",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this,i=function(e){var i,r=t.geometry0.getConnectedValue(e),n=[];return r?(r=r.clone(),t.geometry1.isConnected&&(i=t.geometry1.getConnectedValue(e))&&n.push(i),t.geometry2.isConnected&&(i=t.geometry2.getConnectedValue(e))&&n.push(i),t.geometry3.isConnected&&(i=t.geometry3.getConnectedValue(e))&&n.push(i),t.geometry4.isConnected&&(i=t.geometry4.getConnectedValue(e))&&n.push(i),n.length&&r&&(r=r.merge(n,!0,!1,!0,!0)),r):null};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.evaluateContext=t.evaluateContext},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(JE);a("BABYLON.MergeGeometryBlock",PS);var IS=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!0,i.registerInput("geometry0",GE.Geometry,!0),i.registerInput("geometry1",GE.Geometry,!0),i.registerInput("geometry2",GE.Geometry,!0),i.registerInput("geometry3",GE.Geometry,!0),i.registerInput("geometry4",GE.Geometry,!0),i.registerInput("geometry5",GE.Geometry,!0),i.registerInput("geometry6",GE.Geometry,!0),i.registerInput("geometry7",GE.Geometry,!0),i.registerInput("geometry8",GE.Geometry,!0),i.registerInput("geometry9",GE.Geometry,!0),i.registerOutput("output",GE.Geometry),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return m(t,e),t.prototype.getClassName=function(){return"GeometryCollectionBlock"},Object.defineProperty(t.prototype,"geometry0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry2",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry3",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry4",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry5",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry6",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry7",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry8",{get:function(){return this._inputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry9",{get:function(){return this._inputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._storeGeometry=function(e,t,i,r){if(e.isConnected){var n=e.getConnectedValue(t);if(!n)return;n.metadata=n.metadata||{},n.metadata.collectionId=i,r.push(n)}},t.prototype._buildBlock=function(e){var t=this,i=function(e){var i=[];return t._storeGeometry(t.geometry0,e,0,i),t._storeGeometry(t.geometry1,e,1,i),t._storeGeometry(t.geometry2,e,2,i),t._storeGeometry(t.geometry3,e,3,i),t._storeGeometry(t.geometry4,e,4,i),t._storeGeometry(t.geometry5,e,5,i),t._storeGeometry(t.geometry6,e,6,i),t._storeGeometry(t.geometry7,e,7,i),t._storeGeometry(t.geometry8,e,8,i),t._storeGeometry(t.geometry9,e,9,i),i.length?i[Math.round(Math.random()*(i.length-1))]:null};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.evaluateContext=t.evaluateContext},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(JE);a("BABYLON.GeometryCollectionBlock",IS);var MS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("input",GE.AutoDetect),i.registerOutput("output",GE.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return m(t,e),Object.defineProperty(t.prototype,"buildExecutionTime",{get:function(){return 0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"GeometryElbowBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],r=this._inputs[0];i._storedFunction=function(e){return r.getConnectedValue(e)}},t}(JE);a("BABYLON.GeometryElbowBlock",MS);var OS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("geometry",GE.Geometry),i.registerOutput("output",GE.Geometry),i}return m(t,e),t.prototype.getClassName=function(){return"ComputeNormalsBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;this.output._storedFunction=function(t){if(!e.geometry.isConnected)return null;var i=e.geometry.getConnectedValue(t);return i.normals||(i.normals=[]),_o.ComputeNormals(i.positions,i.indices,i.normals),i}},t}(JE);a("BABYLON.ComputeNormalsBlock",OS);var DS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("xyzw ",GE.Vector4,!0),i.registerInput("xyz ",GE.Vector3,!0),i.registerInput("xy ",GE.Vector2,!0),i.registerInput("zw ",GE.Vector2,!0),i.registerInput("x ",GE.Float,!0),i.registerInput("y ",GE.Float,!0),i.registerInput("z ",GE.Float,!0),i.registerInput("w ",GE.Float,!0),i.registerOutput("xyzw",GE.Vector4),i.registerOutput("xyz",GE.Vector3),i.registerOutput("xy",GE.Vector2),i.registerOutput("zw",GE.Vector2),i.registerOutput("x",GE.Float),i.registerOutput("y",GE.Float),i.registerOutput("z",GE.Float),i.registerOutput("w",GE.Float),i}return m(t,e),t.prototype.getClassName=function(){return"VectorConverterBlock"},Object.defineProperty(t.prototype,"xyzwIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwIn",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xIn",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yIn",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zIn",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wIn",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzwOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwOut",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xOut",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yOut",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zOut",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wOut",{get:function(){return this._outputs[7]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return"xyzw "===e?"xyzwIn":"xyz "===e?"xyzIn":"xy "===e?"xyIn":"zw "===e?"zwIn":"x "===e?"xIn":"y "===e?"yIn":"z "===e?"zIn":"w "===e?"wIn":e},t.prototype._outputRename=function(e){switch(e){case"x":return"xOut";case"y":return"yOut";case"z":return"zOut";case"w":return"wOut";case"xy":return"xyOut";case"zw":return"zwOut";case"xyz":return"xyzOut";case"xyzw":return"xyzwOut";default:return e}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.xIn,r=this.yIn,n=this.zIn,o=this.wIn,a=this.xyIn,s=this.zwIn,l=this.xyzIn,c=this.xyzwIn,u=this.xyzwOut,h=this.xyzOut,d=this.xyOut,p=this.zwOut,f=this.xOut,_=this.yOut,m=this.zOut,g=this.wOut,v=function(e){if(c.isConnected)return c.getConnectedValue(e);var t,u=0,h=0,d=0,p=0;return i.isConnected&&(u=i.getConnectedValue(e)),r.isConnected&&(h=r.getConnectedValue(e)),n.isConnected&&(d=n.getConnectedValue(e)),o.isConnected&&(p=o.getConnectedValue(e)),a.isConnected&&(t=a.getConnectedValue(e))&&(u=t.x,h=t.y),s.isConnected&&(t=s.getConnectedValue(e))&&(d=t.x,p=t.y),l.isConnected&&(t=l.getConnectedValue(e))&&(u=t.x,h=t.y,d=t.z),new k(u,h,d,p)};u._storedFunction=function(e){return v(e)},h._storedFunction=function(e){var t=v(e);return new V(t.x,t.y,t.z)},d._storedFunction=function(e){var t=v(e);return new U(t.x,t.y)},p._storedFunction=function(e){var t=v(e);return new U(t.z,t.w)},f._storedFunction=function(e){return v(e).x},_._storedFunction=function(e){return v(e).y},m._storedFunction=function(e){return v(e).z},g._storedFunction=function(e){return v(e).w}},t}(JE);a("BABYLON.VectorConverterBlock",DS);var NS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("input",GE.AutoDetect),i.registerOutput("output",GE.BasedOnInput),i._inputs[0].excludedConnectionPointTypes.push(GE.Float),i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return m(t,e),t.prototype.getClassName=function(){return"NormalizeVectorBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t),this.output._storedFunction=null,this.input.isConnected?this.output._storedFunction=function(e){return i.input.getConnectedValue(e).normalize()}:this.output._storedValue=null},t}(JE);a("BABYLON.NormalizeVectorBlock",NS);var FS,LS=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!0,i.registerInput("geometry",GE.Geometry),i.registerInput("id",GE.Int,!0,0),i.registerOutput("output",GE.Geometry),i.id.acceptedConnectionPointTypes.push(GE.Float),i}return m(t,e),t.prototype.getClassName=function(){return"SetMaterialIDBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this;if(!this.geometry.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var i=function(e){var i=t.geometry.getConnectedValue(e);if(!i||!i.indices||!i.positions)return i;var r=new fo;return r.materialIndex=0|t.id.getConnectedValue(e),r.indexStart=0,r.indexCount=i.indices.length,r.verticesStart=0,r.verticesCount=i.positions.length/3,i.materialInfos=[r],i};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),void 0!==t.evaluateContext&&(this.evaluateContext=t.evaluateContext)},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(JE);a("BABYLON.SetMaterialIDBlock",LS),function(e){e[e.Cos=0]="Cos",e[e.Sin=1]="Sin",e[e.Abs=2]="Abs",e[e.Exp=3]="Exp",e[e.Round=4]="Round",e[e.Floor=5]="Floor",e[e.Ceiling=6]="Ceiling",e[e.Sqrt=7]="Sqrt",e[e.Log=8]="Log",e[e.Tan=9]="Tan",e[e.ArcTan=10]="ArcTan",e[e.ArcCos=11]="ArcCos",e[e.ArcSin=12]="ArcSin",e[e.Sign=13]="Sign",e[e.Negate=14]="Negate",e[e.OneMinus=15]="OneMinus",e[e.Reciprocal=16]="Reciprocal",e[e.ToDegrees=17]="ToDegrees",e[e.ToRadians=18]="ToRadians",e[e.Fract=19]="Fract",e[e.Exp2=20]="Exp2"}(FS||(FS={}));var wS=function(e){function t(t){var i=e.call(this,t)||this;return i.operation=FS.Cos,i.registerInput("input",GE.AutoDetect),i.registerOutput("output",GE.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i}return m(t,e),t.prototype.getClassName=function(){return"GeometryTrigonometryBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t);var r=null;switch(this.operation){case FS.Cos:r=function(e){return Math.cos(e)};break;case FS.Sin:r=function(e){return Math.sin(e)};break;case FS.Abs:r=function(e){return Math.abs(e)};break;case FS.Exp:r=function(e){return Math.exp(e)};break;case FS.Exp2:r=function(e){return Math.pow(2,e)};break;case FS.Round:r=function(e){return Math.round(e)};break;case FS.Floor:r=function(e){return Math.floor(e)};break;case FS.Ceiling:r=function(e){return Math.ceil(e)};break;case FS.Sqrt:r=function(e){return Math.sqrt(e)};break;case FS.Log:r=function(e){return Math.log(e)};break;case FS.Tan:r=function(e){return Math.tan(e)};break;case FS.ArcTan:r=function(e){return Math.atan(e)};break;case FS.ArcCos:r=function(e){return Math.acos(e)};break;case FS.ArcSin:r=function(e){return Math.asin(e)};break;case FS.Sign:r=function(e){return Math.sign(e)};break;case FS.Negate:r=function(e){return-e};break;case FS.OneMinus:r=function(e){return 1-e};break;case FS.Reciprocal:r=function(e){return 1/e};break;case FS.ToRadians:r=function(e){return e*Math.PI/180};break;case FS.ToDegrees:r=function(e){return 180*e/Math.PI};break;case FS.Fract:r=function(e){return e>=0?e-Math.floor(e):e-Math.ceil(e)}}if(!r)return this.output._storedFunction=null,void(this.output._storedValue=null);switch(this.input.type){case GE.Int:case GE.Float:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return r(t)};break;case GE.Vector2:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return new U(r(t.x),r(t.y))};break;case GE.Vector3:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return new V(r(t.x),r(t.y),r(t.z))};break;case GE.Vector4:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return new k(r(t.x),r(t.y),r(t.z),r(t.w))}}return this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.operation=this.operation,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.operation=t.operation},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".operation = BABYLON.GeometryTrigonometryBlockOperations.").concat(FS[this.operation],";\n")},v([Ys("Operation",Xs.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Cos",value:FS.Cos},{label:"Sin",value:FS.Sin},{label:"Abs",value:FS.Abs},{label:"Exp",value:FS.Exp},{label:"Exp2",value:FS.Exp2},{label:"Round",value:FS.Round},{label:"Floor",value:FS.Floor},{label:"Ceiling",value:FS.Ceiling},{label:"Sqrt",value:FS.Sqrt},{label:"Log",value:FS.Log},{label:"Tan",value:FS.Tan},{label:"ArcTan",value:FS.ArcTan},{label:"ArcCos",value:FS.ArcCos},{label:"ArcSin",value:FS.ArcSin},{label:"Sign",value:FS.Sign},{label:"Negate",value:FS.Negate},{label:"OneMinus",value:FS.OneMinus},{label:"Reciprocal",value:FS.Reciprocal},{label:"ToDegrees",value:FS.ToDegrees},{label:"ToRadians",value:FS.ToRadians},{label:"Fract",value:FS.Fract}]})],t.prototype,"operation",void 0),t}(JE);a("BABYLON.GeometryTrigonometryBlock",wS);var BS=function(e){function t(t){var i=e.call(this,t)||this;return i._rotationMatrix=new z,i._scalingMatrix=new z,i._translationMatrix=new z,i._scalingRotationMatrix=new z,i._transformMatrix=new z,i.evaluateContext=!0,i.registerInput("value",GE.AutoDetect),i.registerInput("matrix",GE.Matrix,!0),i.registerInput("translation",GE.Vector3,!0,V.Zero()),i.registerInput("rotation",GE.Vector3,!0,V.Zero()),i.registerInput("scaling",GE.Vector3,!0,V.One()),i.registerOutput("output",GE.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(GE.Float),i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i}return m(t,e),t.prototype.getClassName=function(){return"GeometryTransformBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translation",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this;if(!this.value.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var i=function(e){var i,r=t.value.getConnectedValue(e);if(!r)return null;if(t.matrix.isConnected)i=t.matrix.getConnectedValue(e);else{var n=t.scaling.getConnectedValue(e),o=t.rotation.getConnectedValue(e),a=t.translation.getConnectedValue(e);z.ScalingToRef(n.x,n.y,n.z,t._scalingMatrix),z.RotationYawPitchRollToRef(o.y,o.x,o.z,t._rotationMatrix),z.TranslationToRef(a.x,a.y,a.z,t._translationMatrix),t._scalingMatrix.multiplyToRef(t._rotationMatrix,t._scalingRotationMatrix),t._scalingRotationMatrix.multiplyToRef(t._translationMatrix,t._transformMatrix),i=t._transformMatrix}switch(t.value.type){case GE.Geometry:var s=r.clone();return s.transform(i),s;case GE.Vector2:return U.Transform(r,i);case GE.Vector3:return V.TransformCoordinates(r,i);case GE.Vector4:return k.TransformCoordinates(r,i)}return null};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),void 0!==t.evaluateContext&&(this.evaluateContext=t.evaluateContext)},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(JE);a("BABYLON.GeometryTransformBlock",BS);var US=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("angle",GE.Float,!1,0),i.registerOutput("matrix",GE.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"RotationXBlock"},Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.angle.isConnected){var e=new tS("Angle");e.value=0,e.output.connectTo(this.angle)}},t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t),this.matrix._storedFunction=function(e){return z.RotationX(i.angle.getConnectedValue(e))}},t}(JE);a("BABYLON.RotationXBlock",US);var VS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("angle",GE.Float,!1,0),i.registerOutput("matrix",GE.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"RotationYBlock"},Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.angle.isConnected){var e=new tS("Angle");e.value=0,e.output.connectTo(this.angle)}},t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t),this.matrix._storedFunction=function(e){return z.RotationY(i.angle.getConnectedValue(e))}},t}(JE);a("BABYLON.RotationYBlock",VS);var kS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("angle",GE.Float,!1,0),i.registerOutput("matrix",GE.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"RotationZBlock"},Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.angle.isConnected){var e=new tS("Angle");e.value=0,e.output.connectTo(this.angle)}},t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t),this.matrix._storedFunction=function(e){return z.RotationZ(i.angle.getConnectedValue(e))}},t}(JE);a("BABYLON.RotationZBlock",kS);var GS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("scale",GE.Vector3,!1,V.One()),i.registerOutput("matrix",GE.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"ScalingBlock"},Object.defineProperty(t.prototype,"scale",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.scale.isConnected){var e=new tS("Scale");e.value=new V(1,1,1),e.output.connectTo(this.scale)}},t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t),this.matrix._storedFunction=function(e){var t=i.scale.getConnectedValue(e);return z.Scaling(t.x,t.y,t.z)}},t}(JE);a("BABYLON.ScalingBlock",GS);var zS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("source",GE.Vector3,!0,V.Up()),i.registerInput("target",GE.Vector3,!0,V.Left()),i.registerOutput("matrix",GE.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"AlignBlock"},Object.defineProperty(t.prototype,"source",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t),this.matrix._storedFunction=function(e){var t=i.source.getConnectedValue(e).clone(),r=i.target.getConnectedValue(e).clone(),n=new z;return t.normalize(),r.normalize(),z.RotationAlignToRef(t,r,n,!0),n}},t}(JE);a("BABYLON.AlignBlock",zS);var WS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("translation",GE.Vector3,!1,V.Zero()),i.registerOutput("matrix",GE.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"TranslationBlock"},Object.defineProperty(t.prototype,"translation",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.translation.isConnected){var e=new tS("Translation");e.value=new V(0,0,0),e.output.connectTo(this.translation)}},t.prototype._buildBlock=function(t){var i=this;e.prototype._buildBlock.call(this,t),this.matrix._storedFunction=function(e){var t=i.translation.getConnectedValue(e);return z.Translation(t.x,t.y,t.z)}},t}(JE);a("BABYLON.TranslationBlock",WS);var HS=function(e){function t(t){var i=e.call(this,t)||this;return i._indexTranslation=null,i.evaluateContext=!0,i.removeDuplicatedPositions=!0,i.registerInput("geometry",GE.Geometry),i.registerInput("instance",GE.Geometry,!0),i.registerInput("density",GE.Float,!0,1,0,1),i.registerInput("matrix",GE.Matrix,!0),i.registerInput("rotation",GE.Vector3,!0,V.Zero()),i.registerInput("scaling",GE.Vector3,!0,V.One()),i.scaling.acceptedConnectionPointTypes.push(GE.Float),i.registerOutput("output",GE.Geometry),i}return m(t,e),t.prototype.getInstanceIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionIndex=function(){return this._indexTranslation?this._indexTranslation[this._currentIndex]:this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"InstantiateOnVerticesBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"density",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this,i=function(e){if(e.pushExecutionContext(t),e.pushInstancingContext(t),t._vertexData=t.geometry.getConnectedValue(e),e.pushGeometryContext(t._vertexData),!t._vertexData||!t._vertexData.positions||!t.instance.isConnected)return e.restoreExecutionContext(),e.restoreInstancingContext(),e.restoreGeometryContext(),void(t.output._storedValue=null);var i=t._vertexData.positions.length/3,r=[],n=new V,o=[],a=t._vertexData.positions;if(t._currentLoopIndex=0,t.removeDuplicatedPositions){for(t._indexTranslation={},t._currentIndex=0;t._currentIndexp)){n.fromArray(a,3*t._currentIndex);var f=d.clone();if(t.matrix.isConnected){var _=t.matrix.getConnectedValue(e);e._instantiateWithPositionAndMatrix(f,n,_,r)}else{var m=e.adaptInput(t.scaling,GE.Vector3,V.OneReadOnly),g=t.rotation.getConnectedValue(e)||V.ZeroReadOnly;e._instantiate(f,n,g,m,r)}t._currentLoopIndex++}}}if(e.restoreGeometryContext(),e.restoreExecutionContext(),e.restoreInstancingContext(),!r.length)return null;if(1===r.length)t._vertexData=r[0];else{var v=r.splice(0,1)[0];t._vertexData=v.merge(r,!0,!1,!0,!0)}return t._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".removeDuplicatedPositions = ").concat(this.removeDuplicatedPositions?"true":"false",";\n")+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.removeDuplicatedPositions=this.removeDuplicatedPositions,t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.removeDuplicatedPositions=t.removeDuplicatedPositions,void 0!==t.evaluateContext&&(this.evaluateContext=t.evaluateContext)},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),v([Ys("Remove duplicated positions",Xs.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"removeDuplicatedPositions",void 0),t}(JE);a("BABYLON.InstantiateOnVerticesBlock",HS);var XS=function(e){function t(t){var i=e.call(this,t)||this;return i._currentPosition=new V,i._currentUV=new U,i._vertex0=new V,i._vertex1=new V,i._vertex2=new V,i._tempVector0=new V,i._tempVector1=new V,i._uv0=new U,i._uv1=new U,i._uv2=new U,i.evaluateContext=!0,i.registerInput("geometry",GE.Geometry),i.registerInput("instance",GE.Geometry,!0),i.registerInput("count",GE.Int,!0,256),i.registerInput("matrix",GE.Matrix,!0),i.registerInput("rotation",GE.Vector3,!0,V.Zero()),i.registerInput("scaling",GE.Vector3,!0,V.One()),i.scaling.acceptedConnectionPointTypes.push(GE.Float),i.registerOutput("output",GE.Geometry),i}return m(t,e),t.prototype.getInstanceIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionIndex=function(){return 0},t.prototype.getExecutionFaceIndex=function(){return this._currentFaceIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentLoopIndex},t.prototype.getOverridePositionsContextualValue=function(){return this._currentPosition},t.prototype.getOverrideNormalsContextualValue=function(){return this._vertex1.subtractToRef(this._vertex0,this._tempVector0),this._vertex2.subtractToRef(this._vertex1,this._tempVector1),this._tempVector0.normalize(),this._tempVector1.normalize(),V.Cross(this._tempVector1,this._tempVector0)},t.prototype.getOverrideUVs1ContextualValue=function(){return this._currentUV},t.prototype.getClassName=function(){return"InstantiateOnFacesBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this,i=function(e){if(e.pushExecutionContext(t),e.pushInstancingContext(t),t._vertexData=t.geometry.getConnectedValue(e),e.pushGeometryContext(t._vertexData),!(t._vertexData&&t._vertexData.positions&&t._vertexData.indices&&t.instance.isConnected))return e.restoreExecutionContext(),e.restoreInstancingContext(),e.restoreGeometryContext(),void(t.output._storedValue=null);var i=null,r=t.count.getConnectedValue(e),n=t._vertexData.indices.length/3,o=r/n,a=0,s=[],l=0;for(t._currentLoopIndex=0,t._currentFaceIndex=0;t._currentFaceIndex=r);p++){var f=Math.random(),_=Math.random();if(f>_){var m=f;f=_,_=m}var g=f,v=_-f,y=1-g-v;if(t._currentPosition.set(g*t._vertex0.x+v*t._vertex1.x+y*t._vertex2.x,g*t._vertex0.y+v*t._vertex1.y+y*t._vertex2.y,g*t._vertex0.z+v*t._vertex1.z+y*t._vertex2.z),t._vertexData.uvs&&t._currentUV.set(g*t._uv0.x+v*t._uv1.x+y*t._uv2.x,g*t._uv0.y+v*t._uv1.y+y*t._uv2.y),(i=t.instance.getConnectedValue(e))&&i.positions&&0!==i.positions.length){var b=i.clone();if(t.matrix.isConnected){var T=t.matrix.getConnectedValue(e);e._instantiateWithPositionAndMatrix(b,t._currentPosition,T,s)}else{var E=e.adaptInput(t.scaling,GE.Vector3,V.OneReadOnly),S=t.rotation.getConnectedValue(e)||V.ZeroReadOnly;e._instantiate(b,t._currentPosition,S,E,s)}l++,t._currentLoopIndex++}else a-=o}}}if(s.length)if(1===s.length)t._vertexData=s[0];else{var x=s.splice(0,1)[0];t._vertexData=x.merge(s,!0,!1,!0,!0)}return e.restoreExecutionContext(),e.restoreInstancingContext(),e.restoreGeometryContext(),t._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),void 0!==t.evaluateContext&&(this.evaluateContext=t.evaluateContext)},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(JE);a("BABYLON.InstantiateOnFacesBlock",XS);var jS=function(e){function t(t){var i=e.call(this,t)||this;return i._currentPosition=new V,i._vertex0=new V,i._vertex1=new V,i._vertex2=new V,i.evaluateContext=!0,i.registerInput("geometry",GE.Geometry),i.registerInput("instance",GE.Geometry,!0),i.registerInput("count",GE.Int,!0,256),i.registerInput("matrix",GE.Matrix,!0),i.registerInput("rotation",GE.Vector3,!0,V.Zero()),i.registerInput("scaling",GE.Vector3,!0,V.One()),i.scaling.acceptedConnectionPointTypes.push(GE.Float),i.registerOutput("output",GE.Geometry),i}return m(t,e),t.prototype.getInstanceIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionIndex=function(){return 0},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getExecutionLoopIndex=function(){return this._currentLoopIndex},t.prototype.getOverridePositionsContextualValue=function(){return this._currentPosition},t.prototype.getClassName=function(){return"InstantiateOnVolumeBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this,i=function(e){if(e.pushExecutionContext(t),e.pushInstancingContext(t),t._vertexData=t.geometry.getConnectedValue(e),e.pushGeometryContext(t._vertexData),!(t._vertexData&&t._vertexData.positions&&t._vertexData.indices&&t.instance.isConnected))return e.restoreExecutionContext(),e.restoreInstancingContext(),e.restoreGeometryContext(),void(t.output._storedValue=null);var i=null,r=t.count.getConnectedValue(e),n=[],o=uo(t._vertexData.positions,0,t._vertexData.positions.length/3),a=o.minimum,s=o.maximum,l=new V(1,0,0),c=t._vertexData.indices.length/3;t._currentLoopIndex=0;for(var u=0;u0&&d++}if(d%2!=0){if((i=t.instance.getConnectedValue(e))&&i.positions&&0!==i.positions.length){var _=i.clone();if(t.matrix.isConnected){var m=t.matrix.getConnectedValue(e);e._instantiateWithPositionAndMatrix(_,t._currentPosition,m,n)}else{var g=e.adaptInput(t.scaling,GE.Vector3,V.OneReadOnly),v=t.rotation.getConnectedValue(e)||V.ZeroReadOnly;e._instantiate(_,t._currentPosition,v,g,n)}t._currentLoopIndex++}}else u--}if(n.length)if(1===n.length)t._vertexData=n[0];else{var y=n.splice(0,1)[0];t._vertexData=y.merge(n,!0,!1,!0,!0)}return e.restoreGeometryContext(),e.restoreExecutionContext(),e.restoreInstancingContext(),t._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),void 0!==t.evaluateContext&&(this.evaluateContext=t.evaluateContext)},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(JE);a("BABYLON.InstantiateOnVolumeBlock",jS);var YS=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!0,i.registerInput("instance",GE.Geometry,!0),i.registerInput("count",GE.Int,!0,1),i.registerOutput("output",GE.Geometry),i}return m(t,e),t.prototype.getInstanceIndex=function(){return this._currentIndex},t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"InstantiateBaseBlock"},Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),void 0!==t.evaluateContext&&(this.evaluateContext=t.evaluateContext)},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(JE),KS=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("matrix",GE.Matrix,!0),i.registerInput("position",GE.Vector3,!0,V.Zero()),i.registerInput("rotation",GE.Vector3,!0,V.Zero()),i.registerInput("scaling",GE.Vector3,!0,V.One()),i.scaling.acceptedConnectionPointTypes.push(GE.Float),i}return m(t,e),t.prototype.getInstanceIndex=function(){return this._currentIndex},t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"InstantiateBlock"},Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this,i=function(e){e.pushExecutionContext(t),e.pushInstancingContext(t);var i=t.count.getConnectedValue(e),r=[];for(t._currentIndex=0;t._currentIndex0&&(a.x=Math.acos(t.y/s)/Math.PI,0===t.x&&0===t.z||(a.y=Math.atan2(t.x,t.z)/(2*Math.PI)));break;case $S.Cylindrical:var s;r.subtractToRef(o,t),(s=t.length())>0&&(a.x=Math.atan2(t.x/s,t.z/s)/(2*Math.PI),a.y=(t.y+1)/2);break;case $S.Cubic:var l=Math.abs(n.x),c=Math.abs(n.y),u=Math.abs(n.z),h=Math.max(Math.abs(r.x),Math.abs(r.y),Math.abs(r.z)),d=0,p=0;l>=c&&l>=u?(d=r.y/h-o.y,p=r.z/h-o.z):c>=l&&c>=u?(d=r.x/h-o.x,p=r.z/h-o.z):(d=r.x/h-o.x,p=r.y/h-o.y),a.x=(d+1)/2,a.y=(p+1)/2}return a}(i)}},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".mapping = BABYLON.MappingTypes.").concat($S[this.mapping],";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.mapping=this.mapping,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.mapping=t.mapping},v([Ys("Mapping",Xs.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Spherical",value:$S.Spherical},{label:"Cylindrical",value:$S.Cylindrical},{label:"Cubic",value:$S.Cubic}]})],t.prototype,"mapping",void 0),t}(JE);a("BABYLON.MappingBlock",tx);var ix=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("matrix0",GE.Matrix),i.registerInput("matrix1",GE.Matrix),i.registerOutput("output",GE.Matrix),i}return m(t,e),t.prototype.getClassName=function(){return"MatrixComposeBlock"},Object.defineProperty(t.prototype,"matrix0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;this.output._storedFunction=function(t){if(!e.matrix0.isConnected||!e.matrix1.isConnected)return null;var i=e.matrix0.getConnectedValue(t),r=e.matrix1.getConnectedValue(t);return i&&r?i.multiply(r):null}},t}(JE);a("BABYLON.MatrixComposeBlock",ix);var rx=function(e){function t(t){var i=e.call(this,t)||this;return i._endpoints=[],i._isTeleportIn=!0,i.registerInput("input",GE.AutoDetect),i}return m(t,e),Object.defineProperty(t.prototype,"endpoints",{get:function(){return this._endpoints},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TeleportInBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),t.prototype._dumpCode=function(t,i){for(var r=e.prototype._dumpCode.call(this,t,i),n=0,o=this.endpoints;n "+this.name},t.prototype.detachFromEndpoint=function(e){var t=this._endpoints.indexOf(e);-1!==t&&(this._endpoints.splice(t,1),e._outputs[0]._typeConnectionSource=null,e._entryPoint=null)},t.prototype._buildBlock=function(){for(var e=this,t=0,i=this._endpoints;t=0?e%1:1-Math.abs(e)%1},t.prototype._buildBlock=function(){var e=this,t=function(t){var i=e.texture.getConnectedValue(t);if(!i||!i.data)return null;var r=e.coordinates.getConnectedValue(t);if(!r)return null;var n=e.clampCoordinates?Math.max(0,Math.min(r.x,1)):e._repeatClamp(r.x),o=e.clampCoordinates?Math.max(0,Math.min(r.y,1)):e._repeatClamp(r.y),a=Math.floor(n*(i.width-1)),s=Math.floor(o*(i.height-1)),l=a+i.width*s;return k.FromArray(i.data,4*l)};this.rgba._storedFunction=function(e){return t(e)},this.rgb._storedFunction=function(e){var i=t(e);return i?i.toVector3():null},this.r._storedFunction=function(e){var i=t(e);return i?i.x:null},this.g._storedFunction=function(e){var i=t(e);return i?i.y:null},this.b._storedFunction=function(e){var i=t(e);return i?i.z:null},this.a._storedFunction=function(e){var i=t(e);return i?i.w:null}},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".clampCoordinates = ").concat(this.clampCoordinates,";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.clampCoordinates=this.clampCoordinates,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.clampCoordinates=t.clampCoordinates},v([Ys("Clamp Coordinates",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"clampCoordinates",void 0),t}(JE);a("BABYLON.GeometryTextureFetchBlock",ax);var sx,lx=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("geometry",GE.Geometry),i.registerOutput("min",GE.Vector3),i.registerOutput("max",GE.Vector3),i}return m(t,e),t.prototype.getClassName=function(){return"BoundingBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"min",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"max",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;this.min._storedFunction=function(t){var i=e.geometry.getConnectedValue(t);return i?uo(i.positions,0,i.positions.length/3).minimum:null},this.max._storedFunction=function(t){var i=e.geometry.getConnectedValue(t);return i?uo(i.positions,0,i.positions.length/3).maximum:null}},t}(JE);a("BABYLON.BoundingBlock",lx),function(e){e[e.Intersect=0]="Intersect",e[e.Subtract=1]="Subtract",e[e.Union=2]="Union"}(sx||(sx={}));var cx=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!1,i.operation=sx.Intersect,i.registerInput("geometry0",GE.Geometry),i.registerInput("geometry1",GE.Geometry),i.registerOutput("output",GE.Geometry),i}return m(t,e),t.prototype.getClassName=function(){return"BooleanGeometryBlock"},Object.defineProperty(t.prototype,"geometry0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var t=this,i=function(e){var i=t.geometry0.getConnectedValue(e),r=t.geometry1.getConnectedValue(e);if(!i||!r)return null;var n=i.positions.length/3;!i.normals&&r.normals&&(i.normals=new Array(i.positions.length)),!r.normals&&i.normals&&(r.normals=new Array(r.positions.length)),!i.uvs&&r.uvs&&(i.uvs=new Array(2*n)),!r.uvs&&i.uvs&&(r.uvs=new Array(2*n)),!i.colors&&r.colors&&(i.colors=new Array(4*n)),!r.colors&&i.colors&&(r.colors=new Array(4*n));var o,a=EE.FromVertexData(i),s=EE.FromVertexData(r);switch(t.operation){case sx.Intersect:o=a.intersect(s);break;case sx.Subtract:o=a.subtract(s);break;case sx.Union:o=a.union(s)}return o.toVertexData()};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",";\n")+"".concat(this._codeVariableName,".operation = BABYLON.BooleanGeometryOperations.").concat(sx[this.operation],";\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.evaluateContext=this.evaluateContext,t.operation=this.operation,t},t.prototype._deserialize=function(t){e.prototype._deserialize.call(this,t),this.evaluateContext=t.evaluateContext,t.operation&&(this.operation=t.operation)},v([Ys("Evaluate context",Xs.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),v([Ys("Operation",Xs.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Intersect",value:sx.Intersect},{label:"Subtract",value:sx.Subtract},{label:"Union",value:sx.Union}]})],t.prototype,"operation",void 0),t}(JE);a("BABYLON.BooleanGeometryBlock",cx);var ux=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("x",GE.AutoDetect),i.registerInput("y",GE.AutoDetect),i.registerOutput("output",GE.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i}return m(t,e),t.prototype.getClassName=function(){return"GeometryArcTan2Block"},Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.x.isConnected||!this.y.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var t=function(e,t){return Math.atan2(e,t)};this.output._storedFunction=function(i){var r=e.x.getConnectedValue(i),n=e.y.getConnectedValue(i);switch(e.x.type){case GE.Int:case GE.Float:return t(r,n);case GE.Vector2:return new U(t(r.x,n.x),t(r.y,n.y));case GE.Vector3:return new V(t(r.x,n.x),t(r.y,n.y),t(r.z,n.z));case GE.Vector4:return new k(t(r.x,n.x),t(r.y,n.y),t(r.z,n.z),t(r.w,n.w))}return 0}},t}(JE);a("BABYLON.GeometryArcTan2Block",ux);var hx=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("left",GE.AutoDetect),i.registerInput("right",GE.AutoDetect),i.registerInput("gradient",GE.Float),i.registerOutput("output",GE.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i}return m(t,e),t.prototype.getClassName=function(){return"GeometryLerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.left.isConnected||!this.right.isConnected||!this.gradient.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var t=function(e,t,i){return(1-e)*t+e*i};return this.output._storedFunction=function(i){var r=e.left.getConnectedValue(i),n=e.right.getConnectedValue(i),o=e.gradient.getConnectedValue(i);switch(e.left.type){case GE.Int:case GE.Float:return t(o,r,n);case GE.Vector2:return new U(t(o,r.x,n.x),t(o,r.y,n.y));case GE.Vector3:return new V(t(o,r.x,n.x),t(o,r.y,n.y),t(o,r.z,n.z));case GE.Vector4:return new k(t(o,r.x,n.x),t(o,r.y,n.y),t(o,r.z,n.z),t(o,r.w,n.w))}return 0},this},t}(JE);a("BABYLON.GeometryLerpBlock",hx);var dx=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("left",GE.AutoDetect),i.registerInput("right",GE.AutoDetect),i.registerInput("gradient",GE.Float),i.registerOutput("output",GE.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i}return m(t,e),t.prototype.getClassName=function(){return"GeometryNLerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.left.isConnected||!this.right.isConnected||!this.gradient.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var t=function(e,t,i){return(1-e)*t+e*i};return this.output._storedFunction=function(i){var r=e.left.getConnectedValue(i),n=e.right.getConnectedValue(i),o=e.gradient.getConnectedValue(i);switch(e.left.type){case GE.Int:case GE.Float:return t(o,r,n);case GE.Vector2:return(a=new U(t(o,r.x,n.x),t(o,r.y,n.y))).normalize(),a;case GE.Vector3:return(a=new V(t(o,r.x,n.x),t(o,r.y,n.y),t(o,r.z,n.z))).normalize(),a;case GE.Vector4:var a;return(a=new k(t(o,r.x,n.x),t(o,r.y,n.y),t(o,r.z,n.z),t(o,r.w,n.w))).normalize(),a}return 0},this},t}(JE);a("BABYLON.GeometryNLerpBlock",dx);var px=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("value",GE.AutoDetect),i.registerInput("edge",GE.Float),i.registerOutput("output",GE.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(GE.Matrix),i._inputs[0].excludedConnectionPointTypes.push(GE.Geometry),i._inputs[0].excludedConnectionPointTypes.push(GE.Texture),i}return m(t,e),t.prototype.getClassName=function(){return"GeometryStepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.value.isConnected||!this.edge.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var t=function(e,t){return e=.01&&(this._frameIdLastUpdate=n,this._canPostToWorker=!1,this._lastProj=this._modelViewMatrix.m.slice(0),this._worker.postMessage({view:this._modelViewMatrix.m,depthMix:this._depthMix},[this._depthMix.buffer]))}return e.prototype.render.call(this,t,i,r)},t.ConvertPLYToSplat=function(e){var t,i=new Uint8Array(e),r=(new TextDecoder).decode(i.slice(0,10240)),n=r.indexOf("end_header\n");if(n<0||!r)return e;for(var o=parseInt(/element vertex (\d+)\n/.exec(r)[1]),a=0,s={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1},l=[],c=0,u=r.slice(0,n).split("\n").filter((function(e){return e.startsWith("property ")}));ci&&(ae.Error("GaussianSplatting texture size: ("+i+", "+r+"), maxTextureSize: "+i),r=i),new U(i,r)},t._CreateWorker=function(e){var t,i,r,n,o=0;e.onmessage=function(a){if(a.data.positions)t=a.data.positions,o=a.data.vertexCount;else{var s=a.data.view;if(!t||!s)throw new Error("positions or view is not defined!");i=a.data.depthMix,r=new Uint32Array(i.buffer),n=new Float32Array(i.buffer);for(var l=0;l-1&&(this._agentDestinationArmed[i]=!0,this._agentDestination[i].set(t.x,t.y,t.z))},e.prototype.agentTeleport=function(e,t){this.recastCrowd.agentTeleport(e,new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z))},e.prototype.updateAgentParameters=function(e,t){var i=this.recastCrowd.getAgentParameters(e);void 0!==t.radius&&(i.radius=t.radius),void 0!==t.height&&(i.height=t.height),void 0!==t.maxAcceleration&&(i.maxAcceleration=t.maxAcceleration),void 0!==t.maxSpeed&&(i.maxSpeed=t.maxSpeed),void 0!==t.collisionQueryRange&&(i.collisionQueryRange=t.collisionQueryRange),void 0!==t.pathOptimizationRange&&(i.pathOptimizationRange=t.pathOptimizationRange),void 0!==t.separationWeight&&(i.separationWeight=t.separationWeight),this.recastCrowd.setAgentParameters(e,i)},e.prototype.removeAgent=function(e){this.recastCrowd.removeAgent(e);var t=this.agents.indexOf(e);t>-1&&(this.agents.splice(t,1),this.transforms.splice(t,1),this.reachRadii.splice(t,1),this._agentDestinationArmed.splice(t,1),this._agentDestination.splice(t,1))},e.prototype.getAgents=function(){return this.agents},e.prototype.update=function(e){if(this.bjsRECASTPlugin.navMesh.update(),!(e<=A)){var t=this.bjsRECASTPlugin.getTimeStep(),i=this.bjsRECASTPlugin.getMaximumSubStepCount();if(t<=A)this.recastCrowd.update(e);else{var r=Math.floor(e/t);i&&r>i&&(r=i),r<1&&(r=1);for(var n=e/r,o=0;od&&l.y=400&&o?o(c):i()}),!1),c.addEventListener("error",(function(){ae.Error("error on XHR request."),o&&o()}),!1),c.send()}else ae.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),o&&o()},e._ValidateXHRData=function(e,t){void 0===t&&(t=7);try{if(1&t){if(e.responseText&&e.responseText.length>0)return!0;if(1===t)return!1}if(2&t){var i=by(e.response);if(i.width&&i.height&&i.width>0&&i.height>0)return!0;if(2===t)return!1}if(4&t){var r=new Uint8Array(e.response,0,3);return 68===r[0]&&68===r[1]&&83===r[2]}}catch(e){}return!1},e._IsUASupportingBlobStorage=!0,e.IDBStorageEnabled=!1,e._ParseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},e._ReturnFullUrlLocation=function(t){return-1===t.indexOf("http:/")&&-1===t.indexOf("https:/")&&"undefined"!=typeof window?e._ParseURL(window.location.href)+t:t},e}(),Dx=function(){function e(){this.direction1=new V(0,1,0),this.direction2=new V(0,1,0),this.minEmitBox=new V(-.5,-.5,-.5),this.maxEmitBox=new V(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=D(this.direction1.x,this.direction2.x),o=D(this.direction1.y,this.direction2.y),a=D(this.direction1.z,this.direction2.z);if(r)return t.x=n,t.y=o,void(t.z=a);V.TransformNormalFromFloatsToRef(n,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=D(this.minEmitBox.x,this.maxEmitBox.x),o=D(this.minEmitBox.y,this.maxEmitBox.y),a=D(this.minEmitBox.z,this.maxEmitBox.z);if(r)return t.x=n,t.y=o,void(t.z=a);V.TransformCoordinatesFromFloatsToRef(n,o,a,e,t)},e.prototype.clone=function(){var t=new e;return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2),e.setVector3("minEmitBox",this.minEmitBox),e.setVector3("maxEmitBox",this.maxEmitBox)},e.prototype.buildUniformLayout=function(e){e.addUniform("direction1",3),e.addUniform("direction2",3),e.addUniform("minEmitBox",3),e.addUniform("maxEmitBox",3)},e.prototype.getEffectDefines=function(){return"#define BOXEMITTER"},e.prototype.getClassName=function(){return"BoxParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.minEmitBox=this.minEmitBox.asArray(),e.maxEmitBox=this.maxEmitBox.asArray(),e},e.prototype.parse=function(e){V.FromArrayToRef(e.direction1,0,this.direction1),V.FromArrayToRef(e.direction2,0,this.direction2),V.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),V.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),Nx=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===i&&(i=0),this.directionRandomizer=i,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!1,configurable:!0}),e.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},e.prototype.startDirectionFunction=function(e,t,i,r){r?H.Vector3[0].copyFrom(i._localPosition).normalize():i.position.subtractToRef(e.getTranslation(),H.Vector3[0]).normalize();var n=j.RandomRange(0,this.directionRandomizer),o=j.RandomRange(0,this.directionRandomizer),a=j.RandomRange(0,this.directionRandomizer);t.x=H.Vector3[0].x+n,t.y=H.Vector3[0].y+o,t.z=H.Vector3[0].z+a,t.normalize()},e.prototype.startPositionFunction=function(e,t,i,r){var n,o=j.RandomRange(0,2*Math.PI);n=this.emitFromSpawnPointOnly?1e-4:1-(n=j.RandomRange(0,this.heightRange))*n;var a=this._radius-j.RandomRange(0,this._radius*this.radiusRange),s=(a*=n)*Math.sin(o),l=a*Math.cos(o),c=n*this._height;if(r)return t.x=s,t.y=c,void(t.z=l);V.TransformCoordinatesFromFloatsToRef(s,c,l,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat2("radius",this._radius,this.radiusRange),e.setFloat("coneAngle",this._angle),e.setFloat2("height",this._height,this.heightRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform("radius",2),e.addUniform("coneAngle",1),e.addUniform("height",2),e.addUniform("directionRandomizer",1)},e.prototype.getEffectDefines=function(){var e="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(e+="\n#define CONEEMITTERSPAWNPOINT"),e},e.prototype.getClassName=function(){return"ConeParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e.radiusRange=this.radiusRange,e.heightRange=this.heightRange,e.emitFromSpawnPointOnly=this.emitFromSpawnPointOnly,e},e.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer,this.radiusRange=void 0!==e.radiusRange?e.radiusRange:1,this.heightRange=void 0!==e.radiusRange?e.heightRange:1,this.emitFromSpawnPointOnly=void 0!==e.emitFromSpawnPointOnly&&e.emitFromSpawnPointOnly},e}(),Fx=function(){function e(e,t,i,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0),this.radius=e,this.height=t,this.radiusRange=i,this.directionRandomizer=r,this._tempVector=V.Zero()}return e.prototype.startDirectionFunction=function(e,t,i,r,n){i.position.subtractToRef(e.getTranslation(),this._tempVector),this._tempVector.normalize(),V.TransformNormalToRef(this._tempVector,n,this._tempVector);var o=j.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),a=Math.atan2(this._tempVector.x,this._tempVector.z);a+=j.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,this._tempVector.y=o,this._tempVector.x=Math.sin(a),this._tempVector.z=Math.cos(a),this._tempVector.normalize(),r?t.copyFrom(this._tempVector):V.TransformNormalFromFloatsToRef(this._tempVector.x,this._tempVector.y,this._tempVector.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=j.RandomRange(-this.height/2,this.height/2),o=j.RandomRange(0,2*Math.PI),a=j.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),s=Math.sqrt(a)*this.radius,l=s*Math.cos(o),c=s*Math.sin(o);r?t.copyFromFloats(l,n,c):V.TransformCoordinatesFromFloatsToRef(l,n,c,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("height",1),e.addUniform("radiusRange",1),e.addUniform("directionRandomizer",1)},e.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},e.prototype.getClassName=function(){return"CylinderParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.height=this.height,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Lx=function(e){function t(t,i,r,n,o){void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=1),void 0===n&&(n=new V(0,1,0)),void 0===o&&(o=new V(0,1,0));var a=e.call(this,t,i,r)||this;return a.direction1=n,a.direction2=o,a}return m(t,e),t.prototype.startDirectionFunction=function(e,t,i,r){var n=j.RandomRange(this.direction1.x,this.direction2.x),o=j.RandomRange(this.direction1.y,this.direction2.y),a=j.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(n,o,a):V.TransformNormalFromFloatsToRef(n,o,a,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return ye.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("height",1),e.addUniform("radiusRange",1),e.addUniform("direction1",3),e.addUniform("direction2",3)},t.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER"},t.prototype.getClassName=function(){return"CylinderDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),V.FromArrayToRef(t.direction1,0,this.direction1),V.FromArrayToRef(t.direction2,0,this.direction2)},t}(Fx),wx=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=i.position.subtract(e.getTranslation()).normalize(),o=j.RandomRange(0,this.directionRandomizer),a=j.RandomRange(0,this.directionRandomizer),s=j.RandomRange(0,this.directionRandomizer);n.x+=o,n.y+=a,n.z+=s,n.normalize(),r?t.copyFrom(n):V.TransformNormalFromFloatsToRef(n.x,n.y,n.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=this.radius-j.RandomRange(0,this.radius*this.radiusRange),o=j.RandomRange(0,1),a=j.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=n*Math.cos(a)*Math.sin(s),c=n*Math.cos(s),u=n*Math.sin(a)*Math.sin(s);r?t.copyFromFloats(l,Math.abs(c),u):V.TransformCoordinatesFromFloatsToRef(l,Math.abs(c),u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("radiusRange",1),e.addUniform("directionRandomizer",1)},e.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},e.prototype.getClassName=function(){return"HemisphericParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Bx=function(){function e(){this.direction1=new V(0,1,0),this.direction2=new V(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=j.RandomRange(this.direction1.x,this.direction2.x),o=j.RandomRange(this.direction1.y,this.direction2.y),a=j.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(n,o,a):V.TransformNormalFromFloatsToRef(n,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){r?t.copyFromFloats(0,0,0):V.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.buildUniformLayout=function(e){e.addUniform("direction1",3),e.addUniform("direction2",3)},e.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},e.prototype.getClassName=function(){return"PointParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},e.prototype.parse=function(e){V.FromArrayToRef(e.direction1,0,this.direction1),V.FromArrayToRef(e.direction2,0,this.direction2)},e}(),Ux=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=i.position.subtract(e.getTranslation()).normalize(),o=j.RandomRange(0,this.directionRandomizer),a=j.RandomRange(0,this.directionRandomizer),s=j.RandomRange(0,this.directionRandomizer);n.x+=o,n.y+=a,n.z+=s,n.normalize(),r?t.copyFrom(n):V.TransformNormalFromFloatsToRef(n.x,n.y,n.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=this.radius-j.RandomRange(0,this.radius*this.radiusRange),o=j.RandomRange(0,1),a=j.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=n*Math.cos(a)*Math.sin(s),c=n*Math.cos(s),u=n*Math.sin(a)*Math.sin(s);r?t.copyFromFloats(l,c,u):V.TransformCoordinatesFromFloatsToRef(l,c,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("radiusRange",1),e.addUniform("directionRandomizer",1)},e.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},e.prototype.getClassName=function(){return"SphereParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Vx=function(e){function t(t,i,r){void 0===t&&(t=1),void 0===i&&(i=new V(0,1,0)),void 0===r&&(r=new V(0,1,0));var n=e.call(this,t)||this;return n.direction1=i,n.direction2=r,n}return m(t,e),t.prototype.startDirectionFunction=function(e,t){var i=j.RandomRange(this.direction1.x,this.direction2.x),r=j.RandomRange(this.direction1.y,this.direction2.y),n=j.RandomRange(this.direction1.z,this.direction2.z);V.TransformNormalFromFloatsToRef(i,r,n,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return ye.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("radiusRange",1),e.addUniform("direction1",3),e.addUniform("direction2",3)},t.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER"},t.prototype.getClassName=function(){return"SphereDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(Ux),kx=function(){function e(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=H.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,i,n);var o=H.Vector3[1];n.subtractToRef(i.position,o),o.scaleToRef(1/i.lifeTime,n)}else n.set(0,0,0);r?t.copyFrom(n):V.TransformNormalToRef(n,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=H.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,i,n):n.set(0,0,0),r?t.copyFrom(n):V.TransformCoordinatesToRef(n,e,t)},e.prototype.clone=function(){var t=new e;return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){},e.prototype.buildUniformLayout=function(e){},e.prototype.getEffectDefines=function(){return"#define CUSTOMEMITTER"},e.prototype.getClassName=function(){return"CustomParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.particlePositionGenerator=this.particlePositionGenerator,e.particleDestinationGenerator=this.particleDestinationGenerator,e},e.prototype.parse=function(e){e.particlePositionGenerator&&(this.particlePositionGenerator=e.particlePositionGenerator),e.particleDestinationGenerator&&(this.particleDestinationGenerator=e.particleDestinationGenerator)},e}(),Gx=function(){function e(e){void 0===e&&(e=null),this._indices=null,this._positions=null,this._normals=null,this._storedNormal=V.Zero(),this._mesh=null,this.direction1=new V(0,1,0),this.direction2=new V(0,1,0),this.useMeshNormalsForDirection=!0,this.mesh=e}return Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this._mesh!==e&&(this._mesh=e,e?(this._indices=e.getIndices(),this._positions=e.getVerticesData(Nr.PositionKind),this._normals=e.getVerticesData(Nr.NormalKind)):(this._indices=null,this._positions=null,this._normals=null))},enumerable:!1,configurable:!0}),e.prototype.startDirectionFunction=function(e,t,i,r){if(this.useMeshNormalsForDirection&&this._normals)V.TransformNormalToRef(this._storedNormal,e,t);else{var n=j.RandomRange(this.direction1.x,this.direction2.x),o=j.RandomRange(this.direction1.y,this.direction2.y),a=j.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(n,o,a):V.TransformNormalFromFloatsToRef(n,o,a,e,t)}},e.prototype.startPositionFunction=function(e,t,i,r){if(this._indices&&this._positions){var n=3*Math.random()*(this._indices.length/3)|0,o=Math.random(),a=Math.random()*(1-o),s=1-o-a,l=this._indices[n],c=this._indices[n+1],u=this._indices[n+2],h=H.Vector3[0],d=H.Vector3[1],p=H.Vector3[2],f=H.Vector3[3];V.FromArrayToRef(this._positions,3*l,h),V.FromArrayToRef(this._positions,3*c,d),V.FromArrayToRef(this._positions,3*u,p),f.x=o*h.x+a*d.x+s*p.x,f.y=o*h.y+a*d.y+s*p.y,f.z=o*h.z+a*d.z+s*p.z,r?t.copyFromFloats(f.x,f.y,f.z):V.TransformCoordinatesFromFloatsToRef(f.x,f.y,f.z,e,t),this.useMeshNormalsForDirection&&this._normals&&(V.FromArrayToRef(this._normals,3*l,h),V.FromArrayToRef(this._normals,3*c,d),V.FromArrayToRef(this._normals,3*u,p),this._storedNormal.x=o*h.x+a*d.x+s*p.x,this._storedNormal.y=o*h.y+a*d.y+s*p.y,this._storedNormal.z=o*h.z+a*d.z+s*p.z)}},e.prototype.clone=function(){var t=new e(this.mesh);return ye.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.buildUniformLayout=function(e){e.addUniform("direction1",3),e.addUniform("direction2",3)},e.prototype.getEffectDefines=function(){return""},e.prototype.getClassName=function(){return"MeshParticleEmitter"},e.prototype.serialize=function(){var e,t={};return t.type=this.getClassName(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.meshId=null===(e=this.mesh)||void 0===e?void 0:e.id,t.useMeshNormalsForDirection=this.useMeshNormalsForDirection,t},e.prototype.parse=function(e,t){V.FromArrayToRef(e.direction1,0,this.direction1),V.FromArrayToRef(e.direction2,0,this.direction2),e.meshId&&t&&(this.mesh=t.getLastMeshById(e.meshId)),this.useMeshNormalsForDirection=e.useMeshNormalsForDirection},e}(),zx=function(){function e(e){this._isUbo(e)?(this.setMatrix3x3=e.updateMatrix3x3.bind(e),this.setMatrix2x2=e.updateMatrix2x2.bind(e),this.setFloat=e.updateFloat.bind(e),this.setFloat2=e.updateFloat2.bind(e),this.setFloat3=e.updateFloat3.bind(e),this.setFloat4=e.updateFloat4.bind(e),this.setFloatArray=e.updateFloatArray.bind(e),this.setArray=e.updateArray.bind(e),this.setIntArray=e.updateIntArray.bind(e),this.setMatrix=e.updateMatrix.bind(e),this.setMatrices=e.updateMatrices.bind(e),this.setVector3=e.updateVector3.bind(e),this.setVector4=e.updateVector4.bind(e),this.setColor3=e.updateColor3.bind(e),this.setColor4=e.updateColor4.bind(e),this.setDirectColor4=e.updateDirectColor4.bind(e),this.setInt=e.updateInt.bind(e),this.setInt2=e.updateInt2.bind(e),this.setInt3=e.updateInt3.bind(e),this.setInt4=e.updateInt4.bind(e)):(this.setMatrix3x3=e.setMatrix3x3.bind(e),this.setMatrix2x2=e.setMatrix2x2.bind(e),this.setFloat=e.setFloat.bind(e),this.setFloat2=e.setFloat2.bind(e),this.setFloat3=e.setFloat3.bind(e),this.setFloat4=e.setFloat4.bind(e),this.setFloatArray=e.setFloatArray.bind(e),this.setArray=e.setArray.bind(e),this.setIntArray=e.setIntArray.bind(e),this.setMatrix=e.setMatrix.bind(e),this.setMatrices=e.setMatrices.bind(e),this.setVector3=e.setVector3.bind(e),this.setVector4=e.setVector4.bind(e),this.setColor3=e.setColor3.bind(e),this.setColor4=e.setColor4.bind(e),this.setDirectColor4=e.setDirectColor4.bind(e),this.setInt=e.setInt.bind(e),this.setInt2=e.setInt2.bind(e),this.setInt3=e.setInt3.bind(e),this.setInt4=e.setInt4.bind(e))}return e.prototype._isUbo=function(e){return void 0!==e.addUniform},e}();li.ShadersStore.gpuUpdateParticlesPixelShader="#version 300 es\nvoid main() {discard;}\n";li.ShadersStore.gpuUpdateParticlesVertexShader="#version 300 es\n#define PI 3.14159\nuniform float currentCount;uniform float timeDelta;uniform float stopFactor;\n#ifndef LOCAL\nuniform mat4 emitterWM;\n#endif\nuniform vec2 lifeTime;uniform vec2 emitPower;uniform vec2 sizeRange;uniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;uniform vec4 color2;\n#endif\nuniform vec3 gravity;uniform sampler2D randomSampler;uniform sampler2D randomSampler2;uniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;uniform vec3 direction2;uniform vec3 minEmitBox;uniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;uniform float radiusRange;uniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;uniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;uniform float height;uniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;uniform float coneAngle;uniform vec2 height;uniform float directionRandomizer;\n#endif\nin vec3 position;\n#ifdef CUSTOMEMITTER\nin vec3 initialPosition;\n#endif\nin float age;in float life;in vec4 seed;in vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;in vec3 noiseCoordinates2;\n#endif\nout vec3 outPosition;\n#ifdef CUSTOMEMITTER\nout vec3 outInitialPosition;\n#endif\nout float outAge;out float outLife;out vec4 outSeed;out vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;out vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif \n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;uniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;uniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec4 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;}\nvec4 getRandomVec4(float offset) {return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));}\nvoid main() {float newAge=age+timeDelta; \nif (newAge>=life && stopFactor != 0.) {vec3 newPosition;vec3 newDirection;vec4 randoms=getRandomVec4(seed.x);outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;outAge=newAge-life;outSeed=seed;\n#ifdef SIZEGRADIENTS \noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; \n#ifndef COLORGRADIENTS\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif \n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=vec3(0,0,0);newDirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;newDirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);newDirection=newPosition+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=normalize(direction1+(direction2-direction1)*randoms3);\n#else\nnewDirection=normalize(newPosition+directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float yPos=(randoms2.x-0.5)*height;float angle=randoms2.y*PI*2.;float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));float xPos=positionRadius*cos(angle);float zPos=positionRadius*sin(angle);newPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nangle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;newDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));newDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);float s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.0001;\n#else\nfloat h=randoms2.y*height.y;h=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;lRadius=lRadius*h;float randX=lRadius*sin(s);float randZ=lRadius*cos(s);float randY=h *height.x;newPosition=vec3(randX,randY,randZ); \nif (abs(cos(coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {vec3 randoms3=getRandomVec3(seed.z);newDirection=normalize(newPosition+directionRandomizer*randoms3); }\n#elif defined(CUSTOMEMITTER)\nnewPosition=initialPosition;outInitialPosition=initialPosition;\n#else \nnewPosition=vec3(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\n#ifdef LOCAL\noutPosition=newPosition;\n#else\noutPosition=(emitterWM*vec4(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#ifndef BILLBOARD \noutInitialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nvec3 initial=newDirection;\n#else \nvec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;\n#endif\noutDirection=initial*power;\n#ifndef BILLBOARD \noutInitialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {float directionScale=timeDelta;outAge=newAge;float ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#if defined(CUSTOMEMITTER)\noutPosition=position+(direction-position)*ageGradient; \noutInitialPosition=initialPosition;\n#else\noutPosition=position+direction*directionScale;\n#endif\noutLife=life;outSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;outSize.yz=size.yz;\n#else\noutSize=size;\n#endif \n#ifndef BILLBOARD \noutInitialDirection=initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#else\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;float currentVelocity=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*limitVelocityDamping;}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;outDirection=outDirection+force*timeDelta;outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;outAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;float dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;offsetAge+=cellStartOffset;\n#else\nfloat cellStartOffset=0.;\n#endif \nfloat ratio=0.;if (cellInfos.w==1.0) {ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);}\nelse {ratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);}\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}}";var Wx=function(){function e(e,t){this._renderVAO=[],this._updateVAO=[],this.alignDataInBuffer=!1,this._parent=e,this._engine=t,this._updateEffectOptions={attributes:["position","initialPosition","age","life","seed","size","color","direction","initialDirection","angle","cellIndex","cellStartOffset","noiseCoordinates1","noiseCoordinates2"],uniformsNames:["currentCount","timeDelta","emitterWM","lifeTime","color1","color2","sizeRange","scaleRange","gravity","emitPower","direction1","direction2","minEmitBox","maxEmitBox","radius","directionRandomizer","height","coneAngle","stopFactor","angleRange","radiusRange","cellInfos","noiseStrength","limitVelocityDamping"],uniformBuffersNames:[],samplers:["randomSampler","randomSampler2","sizeGradientSampler","angularSpeedGradientSampler","velocityGradientSampler","limitVelocityGradientSampler","noiseSampler","dragGradientSampler"],defines:"",fallbacks:null,onCompiled:null,onError:null,indexParameters:null,maxSimultaneousLights:0,transformFeedbackVaryings:[]}}return e.prototype.contextLost=function(){this._updateEffect=void 0,this._renderVAO.length=0,this._updateVAO.length=0},e.prototype.isUpdateBufferCreated=function(){return!!this._updateEffect},e.prototype.isUpdateBufferReady=function(){var e,t;return null!==(t=null===(e=this._updateEffect)||void 0===e?void 0:e.isReady())&&void 0!==t&&t},e.prototype.createUpdateBuffer=function(e){return this._updateEffectOptions.transformFeedbackVaryings=["outPosition"],this._updateEffectOptions.transformFeedbackVaryings.push("outAge"),this._updateEffectOptions.transformFeedbackVaryings.push("outSize"),this._updateEffectOptions.transformFeedbackVaryings.push("outLife"),this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"),this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),this._parent.particleEmitterType instanceof kx&&this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"),this._parent._colorGradientsTexture||this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),this._parent._isBillboardBased||this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),this._parent.noiseTexture&&(this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),this._parent.isAnimationSheetEnabled&&(this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),this._parent.spriteRandomStartCell&&this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),this._updateEffectOptions.defines=e,this._updateEffect=new Ei("gpuUpdateParticles",this._updateEffectOptions,this._engine),new zx(this._updateEffect)},e.prototype.createVertexBuffers=function(e,t){this._updateVAO.push(this._createUpdateVAO(e)),this._renderVAO.push(this._engine.recordVertexArrayObject(t,null,this._parent._getWrapper(this._parent.blendMode).effect)),this._engine.bindArrayBuffer(null),this._renderVertexBuffers=t},e.prototype.createParticleBuffer=function(e){return e},e.prototype.bindDrawBuffers=function(e,t,i){i?this._engine.bindBuffers(this._renderVertexBuffers,i,t):this._engine.bindVertexArrayObject(this._renderVAO[e],null)},e.prototype.preUpdateParticleBuffer=function(){var e=this._engine;if(this._engine.enableEffect(this._updateEffect),!e.setState)throw new Error("GPU particles cannot work without a full Engine. ThinEngine is not supported")},e.prototype.updateParticleBuffer=function(e,t,i){this._updateEffect.setTexture("randomSampler",this._parent._randomTexture),this._updateEffect.setTexture("randomSampler2",this._parent._randomTexture2),this._parent._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._parent._sizeGradientsTexture),this._parent._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._parent._angularSpeedGradientsTexture),this._parent._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._parent._velocityGradientsTexture),this._parent._limitVelocityGradientsTexture&&this._updateEffect.setTexture("limitVelocityGradientSampler",this._parent._limitVelocityGradientsTexture),this._parent._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._parent._dragGradientsTexture),this._parent.noiseTexture&&this._updateEffect.setTexture("noiseSampler",this._parent.noiseTexture),this._engine.bindVertexArrayObject(this._updateVAO[e],null);var r=this._engine;r.bindTransformFeedbackBuffer(t.getBuffer()),r.setRasterizerState(!1),r.beginTransformFeedback(!0),r.drawArraysType(u.MATERIAL_PointListDrawMode,0,i),r.endTransformFeedback(),r.setRasterizerState(!0),r.bindTransformFeedbackBuffer(null)},e.prototype.releaseBuffers=function(){},e.prototype.releaseVertexBuffers=function(){for(var e=0;ee)i(t[0],t[0],1);else{for(var r=0;r=n.gradient&&e<=o.gradient)return void i(n,o,(e-n.gradient)/(o.gradient-n.gradient))}var a=t.length-1;i(t[a],t[a],1)}},e}(),Qx=function(){function e(t){this.particleSystem=t,this.position=V.Zero(),this.direction=V.Zero(),this.color=new J(0,0,0,0),this.colorStep=new J(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new U(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new J(0,0,0,0),this._currentColor2=new J(0,0,0,0),this._currentSize1=0,this._currentSize2=0,this._currentAngularSpeed1=0,this._currentAngularSpeed2=0,this._currentVelocity1=0,this._currentVelocity2=0,this._currentLimitVelocity1=0,this._currentLimitVelocity2=0,this._currentDrag1=0,this._currentDrag2=0,this.id=e._Count++,this.particleSystem.isAnimationSheetEnabled&&this._updateCellInfoFromSystem()}return e.prototype._updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},e.prototype.updateCellIndex=function(){var e=this.age,t=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(void 0===this._randomCellOffset&&(this._randomCellOffset=Math.random()*this.lifeTime),0===t?(t=1,e=this._randomCellOffset):e+=this._randomCellOffset);var i,r=this._initialEndSpriteCellID-this._initialStartSpriteCellID+1;i=this._initialSpriteCellLoop?F(e*t%this.lifeTime/this.lifeTime):F(e*t/this.lifeTime),this.cellIndex=this._initialStartSpriteCellID+i*r|0},e.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;if(t.position.copyFrom(this.position),e.inheritDirection){var i=H.Vector3[0];this.direction.normalizeToRef(i),t.setDirection(i,0,Math.PI/2)}}else e.particleSystem.emitter.copyFrom(this.position);this.direction.scaleToRef(e.inheritedVelocityAmount/2,H.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(H.Vector3[0])},e.prototype._inheritParticleInfoToSubEmitters=function(){var e=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>0&&this._attachedSubEmitters.forEach((function(t){e._inheritParticleInfoToSubEmitter(t)}))},e.prototype._reset=function(){this.age=0,this.id=e._Count++,this._currentColorGradient=null,this._currentSizeGradient=null,this._currentAngularSpeedGradient=null,this._currentVelocityGradient=null,this._currentLimitVelocityGradient=null,this._currentDragGradient=null,this.cellIndex=this.particleSystem.startSpriteCellID,this._randomCellOffset=void 0},e.prototype.copyTo=function(e){e.position.copyFrom(this.position),this._initialDirection?e._initialDirection?e._initialDirection.copyFrom(this._initialDirection):e._initialDirection=this._initialDirection.clone():e._initialDirection=null,e.direction.copyFrom(this.direction),this._localPosition&&(e._localPosition?e._localPosition.copyFrom(this._localPosition):e._localPosition=this._localPosition.clone()),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e._randomCellOffset=this._randomCellOffset,e.size=this.size,e.scale.copyFrom(this.scale),e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex,e.id=this.id,e._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(e._currentColorGradient=this._currentColorGradient,e._currentColor1.copyFrom(this._currentColor1),e._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(e._currentSizeGradient=this._currentSizeGradient,e._currentSize1=this._currentSize1,e._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(e._currentAngularSpeedGradient=this._currentAngularSpeedGradient,e._currentAngularSpeed1=this._currentAngularSpeed1,e._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(e._currentVelocityGradient=this._currentVelocityGradient,e._currentVelocity1=this._currentVelocity1,e._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(e._currentLimitVelocityGradient=this._currentLimitVelocityGradient,e._currentLimitVelocity1=this._currentLimitVelocity1,e._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(e._currentDragGradient=this._currentDragGradient,e._currentDrag1=this._currentDrag1,e._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(e._initialStartSpriteCellID=this._initialStartSpriteCellID,e._initialEndSpriteCellID=this._initialEndSpriteCellID,e._initialSpriteCellLoop=this._initialSpriteCellLoop),this.particleSystem.useRampGradients&&(e.remapData&&this.remapData?e.remapData.copyFrom(this.remapData):e.remapData=new k(0,0,0,0)),this._randomNoiseCoordinates1&&(e._randomNoiseCoordinates1?(e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(e._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),e._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},e._Count=0,e}();li.ShadersStore.particlesPixelShader="#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nvarying vec2 vUV;varying vec4 vColor;uniform vec4 textureMask;uniform sampler2D diffuseSampler;\n#include\n#include\n#include\n#include\n#include\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;uniform sampler2D rampSampler;\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\nvec4 textureColor=texture2D(diffuseSampler,vUV);vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));baseColor.rgb*=rampColor.rgb;float finalAlpha=baseColor.a;baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n#include\n#include(color,baseColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);baseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";li.ShadersStore.particlesVertexShader="attribute vec3 position;attribute vec4 color;attribute float angle;attribute vec2 size;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos; \n#endif\nvarying vec2 vUV;varying vec4 vColor;varying vec3 vPositionW;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\n#endif\n#include\n#include\n#include\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));vec3 zaxis=normalize(cross(yaxis,xaxis));vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;return position+alignedCorner;}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {vec3 normalizedToCamera=normalize(toCamera);vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\n#ifdef BILLBOARDSTRETCHED_LOCAL\nvec3 row1=direction;\n#else\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\n#endif\nmat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;return position+alignedCorner;}\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec2 cornerPos;cornerPos=(vec2(offset.x-0.5,offset.y -0.5)-translationPivot)*size;\n#ifdef BILLBOARD\nvec3 rotatedCorner;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=position-eyePosition;yaxis.y=0.;vPositionW=rotate(normalize(yaxis),rotatedCorner);vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 toCamera=position-eyePosition;vPositionW=rotateAlign(toCamera,rotatedCorner);vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;vPositionW=(invView*vec4(viewPos,1)).xyz;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\ngl_Position=projection*vec4(viewPos,1.0);\n#else\nvec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=normalize(direction);vPositionW=rotate(yaxis,rotatedCorner);gl_Position=projection*view*vec4(vPositionW,1.0);\n#endif\nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex*particlesInfos.z);float columnOffset=cellIndex-rowOffset/particlesInfos.z;vec2 uvScale=particlesInfos.xy;vec2 uvOffset=vec2(offset.x ,1.0-offset.y);vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) || defined(FOG)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include\n#include\n#include\n#define CUSTOM_VERTEX_MAIN_END\n}";var qx,Zx=function(e){function t(t,i,r,n,o,a){void 0===n&&(n=null),void 0===o&&(o=!1),void 0===a&&(a=.01);var s=e.call(this,t)||this;s._emitterInverseWorldMatrix=z.Identity(),s._inheritedVelocityOffset=new V,s.onDisposeObservable=new f,s.onStoppedObservable=new f,s._particles=new Array,s._stockParticles=new Array,s._newPartsExcess=0,s._vertexBuffers={},s._scaledColorStep=new J(0,0,0,0),s._colorDiff=new J(0,0,0,0),s._scaledDirection=V.Zero(),s._scaledGravity=V.Zero(),s._currentRenderId=-1,s._useInstancing=!1,s._started=!1,s._stopped=!1,s._actualFrame=0,s._currentEmitRate1=0,s._currentEmitRate2=0,s._currentStartSize1=0,s._currentStartSize2=0,s.updateInAnimate=!0,s._rawTextureWidth=256,s._useRampGradients=!1,s.isLocal=!1,s.isGPU=!1,s._onBeforeDrawParticlesObservable=null,s._emitFromParticle=function(e){},s.recycleParticle=function(e){var t=s._particles.pop();t!==e&&t.copyTo(e),s._stockParticles.push(t)},s._createParticle=function(){var e;return 0!==s._stockParticles.length?(e=s._stockParticles.pop())._reset():e=new Qx(s),s._prepareParticle(e),e},s._capacity=i,s._epsilon=a,s._isAnimationSheetEnabled=o,r&&"Scene"!==r.getClassName()?(s._engine=r,s.defaultProjectionMatrix=z.PerspectiveFovLH(.8,1,.1,100,s._engine.isNDCHalfZRange)):(s._scene=r||M.LastCreatedScene,s._engine=s._scene.getEngine(),s.uniqueId=s._scene.getUniqueId(),s._scene.particleSystems.push(s)),s._engine.getCaps().vertexArrayObject&&(s._vertexArrayObject=null),s._attachImageProcessingConfiguration(null),s._customWrappers={0:new ho(s._engine)},s._customWrappers[0].effect=n,s._drawWrappers=[],s._useInstancing=s._engine.getCaps().instancedArrays,s._createIndexBuffer(),s._createVertexBuffers(),s.particleEmitterType=new Dx;var l=null;return s.updateFunction=function(e){var t,i=null;s.noiseTexture&&(i=s.noiseTexture.getSize(),null===(t=s.noiseTexture.getContent())||void 0===t||t.then((function(e){l=e})));for(var r,n=e===s._particles,o=function(t){var o=e[t],a=s._scaledUpdateSpeed,c=o.age;if(o.age+=a,o.age>o.lifeTime){var u=o.age-c;a=(o.lifeTime-c)*a/u,o.age=o.lifeTime}var h=o.age/o.lifeTime;s._colorGradients&&s._colorGradients.length>0?Kx.GetCurrentGradient(h,s._colorGradients,(function(e,t,i){e!==o._currentColorGradient&&(o._currentColor1.copyFrom(o._currentColor2),t.getColorToRef(o._currentColor2),o._currentColorGradient=e),J.LerpToRef(o._currentColor1,o._currentColor2,i,o.color)})):(o.colorStep.scaleToRef(a,s._scaledColorStep),o.color.addInPlace(s._scaledColorStep),o.color.a<0&&(o.color.a=0)),s._angularSpeedGradients&&s._angularSpeedGradients.length>0&&Kx.GetCurrentGradient(h,s._angularSpeedGradients,(function(e,t,i){e!==o._currentAngularSpeedGradient&&(o._currentAngularSpeed1=o._currentAngularSpeed2,o._currentAngularSpeed2=t.getFactor(),o._currentAngularSpeedGradient=e),o.angularSpeed=N(o._currentAngularSpeed1,o._currentAngularSpeed2,i)})),o.angle+=o.angularSpeed*a;var d=a;if(s._velocityGradients&&s._velocityGradients.length>0&&Kx.GetCurrentGradient(h,s._velocityGradients,(function(e,t,i){e!==o._currentVelocityGradient&&(o._currentVelocity1=o._currentVelocity2,o._currentVelocity2=t.getFactor(),o._currentVelocityGradient=e),d*=N(o._currentVelocity1,o._currentVelocity2,i)})),o.direction.scaleToRef(d,s._scaledDirection),s._limitVelocityGradients&&s._limitVelocityGradients.length>0&&Kx.GetCurrentGradient(h,s._limitVelocityGradients,(function(e,t,i){e!==o._currentLimitVelocityGradient&&(o._currentLimitVelocity1=o._currentLimitVelocity2,o._currentLimitVelocity2=t.getFactor(),o._currentLimitVelocityGradient=e);var r=N(o._currentLimitVelocity1,o._currentLimitVelocity2,i);o.direction.length()>r&&o.direction.scaleInPlace(s.limitVelocityDamping)})),s._dragGradients&&s._dragGradients.length>0&&Kx.GetCurrentGradient(h,s._dragGradients,(function(e,t,i){e!==o._currentDragGradient&&(o._currentDrag1=o._currentDrag2,o._currentDrag2=t.getFactor(),o._currentDragGradient=e);var r=N(o._currentDrag1,o._currentDrag2,i);s._scaledDirection.scaleInPlace(1-r)})),s.isLocal&&o._localPosition?(o._localPosition.addInPlace(s._scaledDirection),V.TransformCoordinatesToRef(o._localPosition,s._emitterWorldMatrix,o.position)):o.position.addInPlace(s._scaledDirection),l&&i&&o._randomNoiseCoordinates1){var p=s._fetchR(o._randomNoiseCoordinates1.x,o._randomNoiseCoordinates1.y,i.width,i.height,l),f=s._fetchR(o._randomNoiseCoordinates1.z,o._randomNoiseCoordinates2.x,i.width,i.height,l),_=s._fetchR(o._randomNoiseCoordinates2.y,o._randomNoiseCoordinates2.z,i.width,i.height,l),m=H.Vector3[0],g=H.Vector3[1];m.copyFromFloats((2*p-1)*s.noiseStrength.x,(2*f-1)*s.noiseStrength.y,(2*_-1)*s.noiseStrength.z),m.scaleToRef(a,g),o.direction.addInPlace(g)}if(s.gravity.scaleToRef(a,s._scaledGravity),o.direction.addInPlace(s._scaledGravity),s._sizeGradients&&s._sizeGradients.length>0&&Kx.GetCurrentGradient(h,s._sizeGradients,(function(e,t,i){e!==o._currentSizeGradient&&(o._currentSize1=o._currentSize2,o._currentSize2=t.getFactor(),o._currentSizeGradient=e),o.size=N(o._currentSize1,o._currentSize2,i)})),s._useRampGradients&&(s._colorRemapGradients&&s._colorRemapGradients.length>0&&Kx.GetCurrentGradient(h,s._colorRemapGradients,(function(e,t,i){var r=N(e.factor1,t.factor1,i),n=N(e.factor2,t.factor2,i);o.remapData.x=r,o.remapData.y=n-r})),s._alphaRemapGradients&&s._alphaRemapGradients.length>0&&Kx.GetCurrentGradient(h,s._alphaRemapGradients,(function(e,t,i){var r=N(e.factor1,t.factor1,i),n=N(e.factor2,t.factor2,i);o.remapData.z=r,o.remapData.w=n-r}))),s._isAnimationSheetEnabled&&o.updateCellIndex(),o._inheritParticleInfoToSubEmitters(),o.age>=o.lifeTime)return s._emitFromParticle(o),o._attachedSubEmitters&&(o._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),o._attachedSubEmitters=null),s.recycleParticle(o),n&&t--,r=t,"continue";r=t},a=0;at.gradient?1:0}))},t.prototype._removeFactorGradient=function(e,t){if(e)for(var i=0,r=0,n=e;rt.gradient?1:0})),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture())},t.prototype.addRampGradient=function(e,t){this._rampGradients||(this._rampGradients=[]);var i=new jx(e,t);return this._rampGradients.push(i),this._syncRampGradientTexture(),this},t.prototype.removeRampGradient=function(e){return this._removeGradientAndTexture(e,this._rampGradients,this._rampGradientsTexture),this._rampGradientsTexture=null,this._rampGradients&&this._rampGradients.length>0&&this._createRampGradientTexture(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var r=new Xx(e,t,i);return this._colorGradients.push(r),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,i=0,r=this._colorGradients;i0&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),this._emitRateGradients.length>1&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(this._startSizeGradients.length>0&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),this._startSizeGradients.length>1&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){-1!==(null===(t=this.emitter)||void 0===t?void 0:t.getClassName().indexOf("Mesh"))&&this.emitter.computeWorldMatrix(!0);var r=this.noiseTexture;if(r&&r.onGeneratedObservable)r.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0,this._postStop(e))},t.prototype._postStop=function(e){},t.prototype.reset=function(){this._stockParticles.length=0,this._particles.length=0},t.prototype._appendParticleVertex=function(e,t,i,r){var n=e*this._vertexBufferSize;if(this._vertexData[n++]=t.position.x+this.worldOffset.x,this._vertexData[n++]=t.position.y+this.worldOffset.y,this._vertexData[n++]=t.position.z+this.worldOffset.z,this._vertexData[n++]=t.color.r,this._vertexData[n++]=t.color.g,this._vertexData[n++]=t.color.b,this._vertexData[n++]=t.color.a,this._vertexData[n++]=t.angle,this._vertexData[n++]=t.scale.x*t.size,this._vertexData[n++]=t.scale.y*t.size,this._isAnimationSheetEnabled&&(this._vertexData[n++]=t.cellIndex),this._isBillboardBased)this.billboardMode!==u.PARTICLES_BILLBOARDMODE_STRETCHED&&this.billboardMode!==u.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL||(this._vertexData[n++]=t.direction.x,this._vertexData[n++]=t.direction.y,this._vertexData[n++]=t.direction.z);else if(t._initialDirection){var o=t._initialDirection;this.isLocal&&(V.TransformNormalToRef(o,this._emitterWorldMatrix,H.Vector3[0]),o=H.Vector3[0]),0===o.x&&0===o.z&&(o.x=.001),this._vertexData[n++]=o.x,this._vertexData[n++]=o.y,this._vertexData[n++]=o.z}else{var a=t.direction;this.isLocal&&(V.TransformNormalToRef(a,this._emitterWorldMatrix,H.Vector3[0]),a=H.Vector3[0]),0===a.x&&0===a.z&&(a.x=.001),this._vertexData[n++]=a.x,this._vertexData[n++]=a.y,this._vertexData[n++]=a.z}this._useRampGradients&&t.remapData&&(this._vertexData[n++]=t.remapData.x,this._vertexData[n++]=t.remapData.y,this._vertexData[n++]=t.remapData.z,this._vertexData[n++]=t.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon)),this._vertexData[n++]=i,this._vertexData[n++]=r)},t.prototype._prepareParticle=function(e){},t.prototype._update=function(e){var t,i=this;if(this._alive=this._particles.length>0,this.emitter.position){var r=this.emitter;this._emitterWorldMatrix=r.getWorldMatrix()}else{var n=this.emitter;this._emitterWorldMatrix=z.Translation(n.x,n.y,n.z)}this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),this.updateFunction(this._particles);for(var o=function(e){if(a._particles.length===a._capacity)return"break";if(t=a._createParticle(),a._particles.push(t),a.targetStopDuration&&a._lifeTimeGradients&&a._lifeTimeGradients.length>0){var r=F(a._actualFrame/a.targetStopDuration);Kx.GetCurrentGradient(r,a._lifeTimeGradients,(function(e,i){var n=e,o=i,a=n.getFactor(),s=o.getFactor(),l=(r-n.gradient)/(o.gradient-n.gradient);t.lifeTime=N(a,s,l)}))}else t.lifeTime=D(a.minLifeTime,a.maxLifeTime);var n=D(a.minEmitPower,a.maxEmitPower);if(a.startPositionFunction?a.startPositionFunction(a._emitterWorldMatrix,t.position,t,a.isLocal):a.particleEmitterType.startPositionFunction(a._emitterWorldMatrix,t.position,t,a.isLocal),a.isLocal&&(t._localPosition?t._localPosition.copyFrom(t.position):t._localPosition=t.position.clone(),V.TransformCoordinatesToRef(t._localPosition,a._emitterWorldMatrix,t.position)),a.startDirectionFunction?a.startDirectionFunction(a._emitterWorldMatrix,t.direction,t,a.isLocal):a.particleEmitterType.startDirectionFunction(a._emitterWorldMatrix,t.direction,t,a.isLocal,a._emitterInverseWorldMatrix),0===n?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(n),a._sizeGradients&&0!==a._sizeGradients.length?(t._currentSizeGradient=a._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,a._sizeGradients.length>1?t._currentSize2=a._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=D(a.minSize,a.maxSize),t.scale.copyFromFloats(D(a.minScaleX,a.maxScaleX),D(a.minScaleY,a.maxScaleY)),a._startSizeGradients&&a._startSizeGradients[0]&&a.targetStopDuration){var o=a._actualFrame/a.targetStopDuration;Kx.GetCurrentGradient(o,a._startSizeGradients,(function(e,r,n){e!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=r.getFactor(),i._currentStartSizeGradient=e);var o=N(i._currentStartSize1,i._currentStartSize2,n);t.scale.scaleInPlace(o)}))}if(a._angularSpeedGradients&&0!==a._angularSpeedGradients.length?(t._currentAngularSpeedGradient=a._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,a._angularSpeedGradients.length>1?t._currentAngularSpeed2=a._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=D(a.minAngularSpeed,a.maxAngularSpeed),t.angle=D(a.minInitialRotation,a.maxInitialRotation),a._velocityGradients&&a._velocityGradients.length>0&&(t._currentVelocityGradient=a._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),a._velocityGradients.length>1?t._currentVelocity2=a._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),a._limitVelocityGradients&&a._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=a._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),a._limitVelocityGradients.length>1?t._currentLimitVelocity2=a._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),a._dragGradients&&a._dragGradients.length>0&&(t._currentDragGradient=a._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),a._dragGradients.length>1?t._currentDrag2=a._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),a._colorGradients&&0!==a._colorGradients.length)t._currentColorGradient=a._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),a._colorGradients.length>1?a._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color);else{var s=D(0,1);J.LerpToRef(a.color1,a.color2,s,t.color),a.colorDead.subtractToRef(t.color,a._colorDiff),a._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)}a._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=a.startSpriteCellID,t._initialEndSpriteCellID=a.endSpriteCellID,t._initialSpriteCellLoop=a.spriteCellLoop),t.direction.addInPlace(a._inheritedVelocityOffset),a._useRampGradients&&(t.remapData=new k(0,1,0,1)),a.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new V(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new V(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},a=this,s=0;s-1)r=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var n=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var o=this._actualFrame/this.targetStopDuration;Kx.GetCurrentGradient(o,this._emitRateGradients,(function(e,t,r){e!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=t.getFactor(),i._currentEmitRateGradient=e),n=N(i._currentEmitRate1,i._currentEmitRate2,r)}))}r=n*this._scaledUpdateSpeed|0,this._newPartsExcess+=n*this._scaledUpdateSpeed-r}if(this._newPartsExcess>1&&(r+=0|this._newPartsExcess,this._newPartsExcess-=0|this._newPartsExcess),this._alive=!1,this._stopped?r=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(r),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene&&this._scene._toBeDisposed.push(this))),!e){for(var a=0,s=0;s=0&&(p.invertToRef(H.Matrix[0]),h.setMatrix("invView",H.Matrix[0])),void 0!==this._vertexArrayObject?(null===(r=this._scene)||void 0===r?void 0:r.forceWireframe)?d.bindBuffers(this._vertexBuffers,this._linesIndexBufferUseInstancing,h):(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,null,h)),this._engine.bindVertexArrayObject(this._vertexArrayObject,(null===(n=this._scene)||void 0===n?void 0:n.forceWireframe)?this._linesIndexBufferUseInstancing:this._indexBuffer)):this._indexBuffer?d.bindBuffers(this._vertexBuffers,(null===(a=this._scene)||void 0===a?void 0:a.forceWireframe)?this._linesIndexBuffer:this._indexBuffer,h):d.bindBuffers(this._vertexBuffers,(null===(o=this._scene)||void 0===o?void 0:o.forceWireframe)?this._linesIndexBufferUseInstancing:null,h),this.useLogarithmicDepth&&this._scene&&Ko(m,h,this._scene),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(h),e){case vl.BLENDMODE_ADD:d.setAlphaMode(u.ALPHA_ADD);break;case vl.BLENDMODE_ONEONE:d.setAlphaMode(u.ALPHA_ONEONE);break;case vl.BLENDMODE_STANDARD:d.setAlphaMode(u.ALPHA_COMBINE);break;case vl.BLENDMODE_MULTIPLY:d.setAlphaMode(u.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(h),this._useInstancing?(null===(s=this._scene)||void 0===s?void 0:s.forceWireframe)?d.drawElementsType(u.MATERIAL_LineStripDrawMode,0,10,this._particles.length):d.drawArraysType(u.MATERIAL_TriangleStripDrawMode,0,4,this._particles.length):(null===(l=this._scene)||void 0===l?void 0:l.forceWireframe)?d.drawElementsType(u.MATERIAL_WireFrameFillMode,0,10*this._particles.length):d.drawElementsType(u.MATERIAL_TriangleFillMode,0,6*this._particles.length),this._particles.length},t.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var e=this._engine;e.setState&&(e.setState(!1),this.forceDepthWrite&&e.setDepthWrite(!0));var t;return t=this.blendMode===vl.BLENDMODE_MULTIPLYADD?this._render(vl.BLENDMODE_MULTIPLY)+this._render(vl.BLENDMODE_ADD):this._render(this.blendMode),this._engine.unbindInstanceAttributes(),this._engine.setAlphaMode(u.ALPHA_DISABLE),t},t.prototype._onDispose=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1)},t.prototype.dispose=function(e,t,i){if(void 0===e&&(e=!0),void 0===t&&(t=!1),void 0===i&&(i=!1),this.resetDrawCache(),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._linesIndexBuffer&&(this._engine._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null),this._linesIndexBufferUseInstancing&&(this._engine._releaseBuffer(this._linesIndexBufferUseInstancing),this._linesIndexBufferUseInstancing=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._onDispose(t,i),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.clear(),this._scene){var r=this._scene.particleSystems.indexOf(this);r>-1&&this._scene.particleSystems.splice(r,1),this._scene._activeParticleSystems.dispose()}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onStoppedObservable.clear(),this.reset()},t}(vl);!function(e){e[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END"}(qx||(qx={}));var Jx=function(){function e(e){if(this.particleSystem=e,this.type=qx.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!e.emitter||!e.emitter.dispose){var t=s("BABYLON.AbstractMesh");e.emitter=new t("SubemitterSystemEmitter",e.getScene()),e._disposeEmitterOnDispose=!0}}return e.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof V?t=t.clone():-1!==t.getClassName().indexOf("Mesh")&&((t=new(s("BABYLON.Mesh"))("",t.getScene())).isVisible=!1):t=new V;var i=new e(this.particleSystem.clone(this.particleSystem.name,t));return i.particleSystem.name+="Clone",i.type=this.type,i.inheritDirection=this.inheritDirection,i.inheritedVelocityAmount=this.inheritedVelocityAmount,i.particleSystem._disposeEmitterOnDispose=!0,i.particleSystem.disposeOnStop=!0,i},e.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};return t.type=this.type,t.inheritDirection=this.inheritDirection,t.inheritedVelocityAmount=this.inheritedVelocityAmount,t.particleSystem=this.particleSystem.serialize(e),t},e._ParseParticleSystem=function(e,t,i,r){throw void 0===r&&(r=!1),He("ParseParticle")},e.Parse=function(t,i,r){var n=t.particleSystem,o=new e(e._ParseParticleSystem(n,i,r,!0));return o.type=t.type,o.inheritDirection=t.inheritDirection,o.inheritedVelocityAmount=t.inheritedVelocityAmount,o.particleSystem._isSubEmitter=!0,o},e.prototype.dispose=function(){this.particleSystem.dispose()},e}();function $x(e,t){var i=new Bx;return i.direction1=e,i.direction2=t,i}function eA(e,t){return void 0===e&&(e=1),void 0===t&&(t=1),new wx(e,t)}function tA(e,t){return void 0===e&&(e=1),void 0===t&&(t=1),new Ux(e,t)}function iA(e,t,i){return void 0===e&&(e=1),void 0===t&&(t=new V(0,1,0)),void 0===i&&(i=new V(0,1,0)),new Vx(e,t,i)}function rA(e,t,i,r){return void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0),new Fx(e,t,i,r)}function nA(e,t,i,r,n){return void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=new V(0,1,0)),void 0===n&&(n=new V(0,1,0)),new Lx(e,t,i,r,n)}function oA(e,t){return void 0===e&&(e=1),void 0===t&&(t=Math.PI/4),new Nx(e,t)}var aA=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._disposeEmitterOnDispose=!1,t._emitFromParticle=function(e){if(t._subEmitters&&0!==t._subEmitters.length){var i=Math.floor(Math.random()*t._subEmitters.length);t._subEmitters[i].forEach((function(i){if(i.type===qx.END){var r=i.clone();e._inheritParticleInfoToSubEmitter(r),r.particleSystem._rootParticleSystem=t,t.activeSubSystems.push(r.particleSystem),r.particleSystem.start()}}))}},t}return m(t,e),t.prototype.createPointEmitter=function(e,t){var i=$x(e,t);return this.particleEmitterType=i,i},t.prototype.createHemisphericEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=1);var i=eA(e,t);return this.particleEmitterType=i,i},t.prototype.createSphereEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=1);var i=tA(e,t);return this.particleEmitterType=i,i},t.prototype.createDirectedSphereEmitter=function(e,t,i){void 0===e&&(e=1),void 0===t&&(t=new V(0,1,0)),void 0===i&&(i=new V(0,1,0));var r=iA(e,t,i);return this.particleEmitterType=r,r},t.prototype.createCylinderEmitter=function(e,t,i,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0);var n=rA(e,t,i,r);return this.particleEmitterType=n,n},t.prototype.createDirectedCylinderEmitter=function(e,t,i,r,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=new V(0,1,0)),void 0===n&&(n=new V(0,1,0));var o=nA(e,t,i,r,n);return this.particleEmitterType=o,o},t.prototype.createConeEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=Math.PI/4);var i=oA(e,t);return this.particleEmitterType=i,i},t.prototype.createBoxEmitter=function(e,t,i,r){var n=new Dx;return this.particleEmitterType=n,this.direction1=e,this.direction2=t,this.minEmitBox=i,this.maxEmitBox=r,n},t.prototype._prepareSubEmitterInternalArray=function(){var e=this;this._subEmitters=new Array,this.subEmitters&&this.subEmitters.forEach((function(i){i instanceof t?e._subEmitters.push([new Jx(i)]):i instanceof Jx?e._subEmitters.push([i]):i instanceof Array&&e._subEmitters.push(i)}))},t.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach((function(e){e.stop(!0)})),this.activeSubSystems=[])},t.prototype._removeFromRoot=function(){if(this._rootParticleSystem){var e=this._rootParticleSystem.activeSubSystems.indexOf(this);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},t.prototype._preStart=function(){this._prepareSubEmitterInternalArray(),this._subEmitters&&0!=this._subEmitters.length&&(this.activeSubSystems=[])},t.prototype._postStop=function(e){e&&this._stopSubEmitters()},t.prototype._prepareParticle=function(e){if(this._subEmitters&&this._subEmitters.length>0){var t=this._subEmitters[Math.floor(Math.random()*this._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===qx.ATTACHED){var i=t.clone();e._attachedSubEmitters.push(i),i.particleSystem.start()}}))}},t.prototype._onDispose=function(e,t){var i;if(void 0===e&&(e=!1),void 0===t&&(t=!1),this._removeFromRoot(),this.subEmitters&&!this._subEmitters&&this._prepareSubEmitterInternalArray(),e&&(null===(i=this.particles)||void 0===i||i.forEach((function(e){if(e._attachedSubEmitters)for(var t=e._attachedSubEmitters.length-1;t>=0;t-=1)e._attachedSubEmitters[t].dispose()}))),t&&this.activeSubSystems)for(var r=this.activeSubSystems.length-1;r>=0;r-=1)this.activeSubSystems[r].dispose();if(this._subEmitters&&this._subEmitters.length){for(var n=0;n0?c.shaderOptions.defines.join("\n"):"";l=a.createEffectForParticles(c.shaderPath.fragmentElement,c.shaderOptions.uniforms,c.shaderOptions.samplers,u)}var h=new t(s,o||e.capacity,i,l,e.isAnimationSheetEnabled);if(h.customShader=c,h._rootUrl=r,e.id&&(h.id=e.id),e.subEmitters){h.subEmitters=[];for(var d=0,p=e.subEmitters;d0?o.shaderOptions.defines.join("\n"):"",l=a.createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s);n[0]?n[0].effect=l:this.setCustomEffect(l,0)}var c=this.serialize(r),u=t.Parse(c,this._scene||this._engine,this._rootUrl);return u.name=e,u.customShader=o,u._customWrappers=n,void 0===i&&(i=this.emitter),this.noiseTexture&&(u.noiseTexture=this.noiseTexture.clone()),u.emitter=i,this.preventAutoStart||u.start(),u},t.BILLBOARDMODE_Y=u.PARTICLES_BILLBOARDMODE_Y,t.BILLBOARDMODE_ALL=u.PARTICLES_BILLBOARDMODE_ALL,t.BILLBOARDMODE_STRETCHED=u.PARTICLES_BILLBOARDMODE_STRETCHED,t.BILLBOARDMODE_STRETCHED_LOCAL=u.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL,t}(Zx);Jx._ParseParticleSystem=aA.Parse;li.IncludesShadersStore.clipPlaneFragmentDeclaration2="#ifdef CLIPPLANE\nin float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nin float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nin float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nin float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nin float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nin float fClipDistance6;\n#endif\n";li.ShadersStore.gpuRenderParticlesPixelShader="precision highp float;\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform sampler2D diffuseSampler;varying vec2 vUV;varying vec4 vColor;\n#include \n#include\n#include\n#include\n#include\n#include\nvoid main() {\n#include \nvec4 textureColor=texture2D(diffuseSampler,vUV);gl_FragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;gl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);\n#endif \n#include\n#include(color,gl_FragColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);gl_FragColor=applyImageProcessing(gl_FragColor);\n#endif\n#endif\n}\n";li.IncludesShadersStore.clipPlaneVertexDeclaration2="#ifdef CLIPPLANE\nuniform vec4 vClipPlane;out float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;out float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;out float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;out float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;out float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;out float fClipDistance6;\n#endif\n";li.ShadersStore.gpuRenderParticlesVertexShader="precision highp float;uniform mat4 view;uniform mat4 projection;uniform vec2 translationPivot;uniform vec3 worldOffset;\n#ifdef LOCAL\nuniform mat4 emitterWM;\n#endif\nattribute vec3 position;attribute float age;attribute float life;attribute vec3 size;\n#ifndef BILLBOARD\nattribute vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\nattribute float angle;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\nattribute vec2 offset;attribute vec2 uv;varying vec2 vUV;varying vec4 vColor;varying vec3 vPositionW;\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\n#endif\n#include\n#include\n#include\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;attribute vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));vec3 zaxis=normalize(cross(yaxis,xaxis));vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {vec3 normalizedToCamera=normalize(toCamera);vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);float columnOffset=cellIndex-rowOffset*sheetInfos.z;vec2 uvScale=sheetInfos.xy;vec2 uvOffset=vec2(uv.x ,1.0-uv.y);vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture2D(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x;\n#ifdef BILLBOARD\nvec4 rotatedCorner;rotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=(position+worldOffset)-eyePosition;yaxis.y=0.;vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 toCamera=(position+worldOffset)-eyePosition;vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;\n#ifdef LOCAL\nvec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;\n#else\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\nvPositionW=(invView*viewPosition).xyz;\n#endif\n#else\nvec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=0.;rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.xz+=translationPivot;vec3 yaxis=normalize(initialDirection);vPositionW=rotate(yaxis,rotatedCorner);vec4 viewPosition=view*vec4(vPositionW,1.0);\n#endif\ngl_Position=projection*viewPosition;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) || defined(FOG)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include\n#include\n#include\n}";var sA=function(e){function t(t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=!1);var a=e.call(this,t)||this;if(a.layerMask=268435455,a._accumulatedCount=0,a._renderVertexBuffers=[],a._targetIndex=0,a._currentRenderId=-1,a._currentRenderingCameraUniqueId=-1,a._started=!1,a._stopped=!1,a._timeDelta=0,a.updateInAnimate=!1,a._actualFrame=0,a._rawTextureWidth=256,a._rebuildingAfterContextLost=!1,a.onDisposeObservable=new f,a.onStoppedObservable=new f,a.forceDepthWrite=!1,a._preWarmDone=!1,a.isLocal=!1,a.isGPU=!0,a._onBeforeDrawParticlesObservable=null,r&&"Scene"!==r.getClassName()?(a._engine=r,a.defaultProjectionMatrix=z.PerspectiveFovLH(.8,1,.1,100,a._engine.isNDCHalfZRange)):(a._scene=r||M.LastCreatedScene,a._engine=a._scene.getEngine(),a.uniqueId=a._scene.getUniqueId(),a._scene.particleSystems.push(a)),a._engine.getCaps().supportComputeShaders){if(!s("BABYLON.ComputeShaderParticleSystem"))throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");a._platform=new(s("BABYLON.ComputeShaderParticleSystem"))(a,a._engine)}else{if(!s("BABYLON.WebGL2ParticleSystem"))throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");a._platform=new(s("BABYLON.WebGL2ParticleSystem"))(a,a._engine)}a._customWrappers={0:new ho(a._engine)},a._customWrappers[0].effect=n,a._drawWrappers={0:new ho(a._engine)},a._drawWrappers[0].drawContext&&(a._drawWrappers[0].drawContext.useInstancing=!0),a._createIndexBuffer(),a._attachImageProcessingConfiguration(null),(i=null!=i?i:{}).randomTextureSize||delete i.randomTextureSize;var l=g({capacity:5e4,randomTextureSize:a._engine.getCaps().maxTextureSize},i),c=i;isFinite(c)&&(l.capacity=c),a._capacity=l.capacity,a._maxActiveParticleCount=l.capacity,a._currentActiveCount=0,a._isAnimationSheetEnabled=o,a.particleEmitterType=new Dx;for(var h=Math.min(a._engine.getCaps().maxTextureSize,l.randomTextureSize),d=[],p=0;p0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped||(this._stopped=!0)},t.prototype.reset=function(){this._releaseBuffers(),this._platform.releaseVertexBuffers(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype.getCustomEffect=function(e){var t,i;return void 0===e&&(e=0),null!==(i=null===(t=this._customWrappers[e])||void 0===t?void 0:t.effect)&&void 0!==i?i:this._customWrappers[0].effect},t.prototype._getCustomDrawWrapper=function(e){var t;return void 0===e&&(e=0),null!==(t=this._customWrappers[e])&&void 0!==t?t:this._customWrappers[0]},t.prototype.setCustomEffect=function(e,t){void 0===t&&(t=0),this._customWrappers[t]=new ho(this._engine),this._customWrappers[t].effect=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new f),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"gpuRenderParticles"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexBuffers",{get:function(){return this._renderVertexBuffers[1^this._targetIndex]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexBuffer",{get:function(){return null},enumerable:!1,configurable:!0}),t.prototype._removeGradientAndTexture=function(t,i,r){return e.prototype._removeGradientAndTexture.call(this,t,i,r),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t){this._colorGradients||(this._colorGradients=[]);var i=new Xx(e,t);return this._colorGradients.push(i),this._refreshColorGradient(!0),this._releaseBuffers(),this},t.prototype._refreshColorGradient=function(e){void 0===e&&(e=!1),this._colorGradients&&(e&&this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null))},t.prototype.forceRefreshGradients=function(){this._refreshColorGradient(),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture"),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture"),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture"),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture"),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture"),this.reset()},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype.resetDrawCache=function(){var e;for(var t in this._drawWrappers)null===(e=this._drawWrappers[t].drawContext)||void 0===e||e.reset()},t.prototype._addFactorGradient=function(e,t,i){var r=new Yx(t,i);e.push(r),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype._refreshFactorGradient=function(e,t,i){if(void 0===i&&(i=!1),e){i&&e.sort((function(e,t){return e.gradientt.gradient?1:0}));var r=this;r[t]&&(r[t].dispose(),r[t]=null)}},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},t.prototype.addVelocityGradient=function(e,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},t.prototype.addLimitVelocityGradient=function(e,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},t.prototype.addDragGradient=function(e,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},t.prototype.addEmitRateGradient=function(){return this},t.prototype.removeEmitRateGradient=function(){return this},t.prototype.addStartSizeGradient=function(){return this},t.prototype.removeStartSizeGradient=function(){return this},t.prototype.addColorRemapGradient=function(){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(){return this},t.prototype.removeAlphaRemapGradient=function(){return this},t.prototype.addRampGradient=function(){return this},t.prototype.removeRampGradient=function(){return this},t.prototype.getRampGradients=function(){return null},Object.defineProperty(t.prototype,"useRampGradients",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.addLifeTimeGradient=function(){return this},t.prototype.removeLifeTimeGradient=function(){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createVertexBuffers=function(e,t,i){var r={};r.position=t.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var n=3;r.age=t.createVertexBuffer("age",n,1,this._attributesStrideSize,!0),n+=1,r.size=t.createVertexBuffer("size",n,3,this._attributesStrideSize,!0),n+=3,r.life=t.createVertexBuffer("life",n,1,this._attributesStrideSize,!0),n+=1,n+=4,this.billboardMode===aA.BILLBOARDMODE_STRETCHED&&(r.direction=t.createVertexBuffer("direction",n,3,this._attributesStrideSize,!0)),n+=3,this._platform.alignDataInBuffer&&(n+=1),this.particleEmitterType instanceof kx&&(n+=3,this._platform.alignDataInBuffer&&(n+=1)),this._colorGradientsTexture||(r.color=t.createVertexBuffer("color",n,4,this._attributesStrideSize,!0),n+=4),this._isBillboardBased||(r.initialDirection=t.createVertexBuffer("initialDirection",n,3,this._attributesStrideSize,!0),n+=3,this._platform.alignDataInBuffer&&(n+=1)),this.noiseTexture&&(r.noiseCoordinates1=t.createVertexBuffer("noiseCoordinates1",n,3,this._attributesStrideSize,!0),n+=3,this._platform.alignDataInBuffer&&(n+=1),r.noiseCoordinates2=t.createVertexBuffer("noiseCoordinates2",n,3,this._attributesStrideSize,!0),n+=3,this._platform.alignDataInBuffer&&(n+=1)),r.angle=t.createVertexBuffer("angle",n,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?n++:n+=2,this._isAnimationSheetEnabled&&(r.cellIndex=t.createVertexBuffer("cellIndex",n,1,this._attributesStrideSize,!0),n+=1,this.spriteRandomStartCell&&(r.cellStartOffset=t.createVertexBuffer("cellStartOffset",n,1,this._attributesStrideSize,!0),n+=1)),r.offset=i.createVertexBuffer("offset",0,2),r.uv=i.createVertexBuffer("uv",2,2),this._renderVertexBuffers.push(r),this._platform.createVertexBuffers(e,r),this.resetDrawCache()},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._engine,i=[];this._attributesStrideSize=21,this._targetIndex=0,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1),this.particleEmitterType instanceof kx&&(this._attributesStrideSize+=3,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1)),this.isBillboardBased||(this._attributesStrideSize+=3,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1)),this._colorGradientsTexture&&(this._attributesStrideSize-=4),this._angularSpeedGradientsTexture&&(this._attributesStrideSize-=1),this._isAnimationSheetEnabled&&(this._attributesStrideSize+=1,this.spriteRandomStartCell&&(this._attributesStrideSize+=1)),this.noiseTexture&&(this._attributesStrideSize+=6,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=2)),this._platform.alignDataInBuffer&&(this._attributesStrideSize+=3-(this._attributesStrideSize+3&3));for(var r=this.particleEmitterType instanceof kx,n=H.Vector3[0],o=0,a=0;a0;)i.push(0)}var l=new Float32Array([.5,.5,1,1,-.5,.5,0,1,.5,-.5,1,0,-.5,-.5,0,0]),c=this._platform.createParticleBuffer(i),u=this._platform.createParticleBuffer(i);this._buffer0=new Dr(t,c,!1,this._attributesStrideSize),this._buffer1=new Dr(t,u,!1,this._attributesStrideSize),this._spriteBuffer=new Dr(t,l,!1,4),this._renderVertexBuffers=[],this._createVertexBuffers(this._buffer0,this._buffer1,this._spriteBuffer),this._createVertexBuffers(this._buffer1,this._buffer0,this._spriteBuffer),this._sourceBuffer=this._buffer0,this._targetBuffer=this._buffer1}},t.prototype._recreateUpdateEffect=function(){this._createColorGradientTexture(),this._createSizeGradientTexture(),this._createAngularSpeedGradientTexture(),this._createVelocityGradientTexture(),this._createLimitVelocityGradientTexture(),this._createDragGradientTexture();var e=this.particleEmitterType?this.particleEmitterType.getEffectDefines():"";return this._isBillboardBased&&(e+="\n#define BILLBOARD"),this._colorGradientsTexture&&(e+="\n#define COLORGRADIENTS"),this._sizeGradientsTexture&&(e+="\n#define SIZEGRADIENTS"),this._angularSpeedGradientsTexture&&(e+="\n#define ANGULARSPEEDGRADIENTS"),this._velocityGradientsTexture&&(e+="\n#define VELOCITYGRADIENTS"),this._limitVelocityGradientsTexture&&(e+="\n#define LIMITVELOCITYGRADIENTS"),this._dragGradientsTexture&&(e+="\n#define DRAGGRADIENTS"),this.isAnimationSheetEnabled&&(e+="\n#define ANIMATESHEET",this.spriteRandomStartCell&&(e+="\n#define ANIMATESHEETRANDOMSTART")),this.noiseTexture&&(e+="\n#define NOISE"),this.isLocal&&(e+="\n#define LOCAL"),this._platform.isUpdateBufferCreated()&&this._cachedUpdateDefines===e||(this._cachedUpdateDefines=e,this._updateBuffer=this._platform.createUpdateBuffer(e)),this._platform.isUpdateBufferReady()},t.prototype._getWrapper=function(e){var t=this._getCustomDrawWrapper(e);if(null==t?void 0:t.effect)return t;var i=[];this.fillDefines(i,e);var r=this._drawWrappers[e];r||((r=new ho(this._engine)).drawContext&&(r.drawContext.useInstancing=!0),this._drawWrappers[e]=r);var n=i.join("\n");if(r.defines!==n){var o=[],a=[],s=[];this.fillUniformsAttributesAndSamplerNames(a,o,s),r.setEffect(this._engine.createEffect("gpuRenderParticles",o,a,s,n),n)}return r},t._GetAttributeNamesOrOptions=function(e,t,i,r){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1);var n=[Nr.PositionKind,"age","life","size","angle"];return e||n.push(Nr.ColorKind),t&&n.push("cellIndex"),i||n.push("initialDirection"),r&&n.push("direction"),n.push("offset",Nr.UVKind),n},t._GetEffectCreationOptions=function(e,t,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1);var r=["emitterWM","worldOffset","view","projection","colorDead","invView","translationPivot","eyePosition"];return Go(r),e&&r.push("sheetInfos"),t&&r.push("logarithmicDepthConstant"),i&&(r.push("vFogInfos"),r.push("vFogColor")),r},t.prototype.fillDefines=function(e,t){if(void 0===t&&(t=0),this._scene&&(zo(this,this._scene,e),this.applyFog&&this._scene.fogEnabled&&this._scene.fogMode!==pn.FOGMODE_NONE&&e.push("#define FOG")),t===aA.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this.isLocal&&e.push("#define LOCAL"),this.useLogarithmicDepth&&e.push("#define LOGARITHMICDEPTH"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case aA.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case aA.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case aA.BILLBOARDMODE_ALL:e.push("#define BILLBOARDMODE_ALL")}this._colorGradientsTexture&&e.push("#define COLORGRADIENTS"),this.isAnimationSheetEnabled&&e.push("#define ANIMATESHEET"),this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e.push(""+this._imageProcessingConfigurationDefines.toString()))},t.prototype.fillUniformsAttributesAndSamplerNames=function(e,i,r){i.push.apply(i,t._GetAttributeNamesOrOptions(!!this._colorGradientsTexture,this._isAnimationSheetEnabled,this._isBillboardBased,this._isBillboardBased&&this.billboardMode===aA.BILLBOARDMODE_STRETCHED)),e.push.apply(e,t._GetEffectCreationOptions(this._isAnimationSheetEnabled,this.useLogarithmicDepth,this.applyFog)),r.push("diffuseSampler","colorGradientSampler"),this._imageProcessingConfiguration&&(pr.PrepareUniforms(e,this._imageProcessingConfigurationDefines),pr.PrepareSamplers(r,this._imageProcessingConfigurationDefines))},t.prototype.animate=function(e){var t;void 0===e&&(e=!1),this._timeDelta=this.updateSpeed*(e?this.preWarmStepOffset:(null===(t=this._scene)||void 0===t?void 0:t.getAnimationRatio())||1),this._actualFrame+=this._timeDelta,this._stopped||this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop(),this.updateInAnimate&&this._update()},t.prototype._createFactorGradientTexture=function(e,t){var i=this[t];if(e&&e.length&&!i){for(var r=new Float32Array(this._rawTextureWidth),n=function(t){var i=t/o._rawTextureWidth;Kx.GetCurrentGradient(i,e,(function(e,i,n){r[t]=j.Lerp(e.factor1,i.factor1,n)}))},o=this,a=0;a=0){var f=c.clone();f.invert(),l.setMatrix("invView",f)}switch(this.useLogarithmicDepth&&this._scene&&Ko(p,l,this._scene),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(l),e){case aA.BLENDMODE_ADD:this._engine.setAlphaMode(u.ALPHA_ADD);break;case aA.BLENDMODE_ONEONE:this._engine.setAlphaMode(u.ALPHA_ONEONE);break;case aA.BLENDMODE_STANDARD:this._engine.setAlphaMode(u.ALPHA_COMBINE);break;case aA.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(u.ALPHA_MULTIPLY)}return this._platform.bindDrawBuffers(this._targetIndex,l,(null===(n=this._scene)||void 0===n?void 0:n.forceWireframe)?this._linesIndexBufferUseInstancing:null),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(l),(null===(o=this._scene)||void 0===o?void 0:o.forceWireframe)?this._engine.drawElementsType(u.MATERIAL_LineStripDrawMode,0,10,this._currentActiveCount):this._engine.drawArraysType(u.MATERIAL_TriangleStripDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(u.ALPHA_DISABLE),(null===(a=this._scene)||void 0===a?void 0:a.forceWireframe)&&this._engine.unbindInstanceAttributes(),this._currentActiveCount},t.prototype._update=function(e){if(this.emitter&&this._targetBuffer&&this._recreateUpdateEffect()&&!this._rebuildingAfterContextLost){if(!e)if(this.emitter.position)e=this.emitter.getWorldMatrix();else{var t=this.emitter;e=H.Matrix[0],z.TranslationToRef(t.x,t.y,t.z,e)}this._platform.preUpdateParticleBuffer(),this._updateBuffer.setFloat("currentCount",this._currentActiveCount),this._updateBuffer.setFloat("timeDelta",this._timeDelta),this._updateBuffer.setFloat("stopFactor",this._stopped?0:1),this._updateBuffer.setInt("randomTextureSize",this._randomTextureSize),this._updateBuffer.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateBuffer.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateBuffer.setDirectColor4("color1",this.color1),this._updateBuffer.setDirectColor4("color2",this.color2)),this._updateBuffer.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateBuffer.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateBuffer.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateBuffer.setVector3("gravity",this.gravity),this._limitVelocityGradientsTexture&&this._updateBuffer.setFloat("limitVelocityDamping",this.limitVelocityDamping),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateBuffer),this._isAnimationSheetEnabled&&this._updateBuffer.setFloat4("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed,this.spriteCellLoop?1:0),this.noiseTexture&&this._updateBuffer.setVector3("noiseStrength",this.noiseStrength),this.isLocal||this._updateBuffer.setMatrix("emitterWM",e),this._platform.updateParticleBuffer(this._targetIndex,this._targetBuffer,this._currentActiveCount),this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var i=this._sourceBuffer;this._sourceBuffer=this._targetBuffer,this._targetBuffer=i}},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),!this._started)return 0;if(!this.isReady())return 0;if(!e&&this._scene){if(!this._preWarmDone&&this.preWarmCycles){for(var i=0;i1){var r=0|this._accumulatedCount;this._accumulatedCount-=r,this._currentActiveCount+=r}if(this._currentActiveCount=Math.min(this._maxActiveParticleCount,this._currentActiveCount),!this._currentActiveCount)return 0;var n;if(this.emitter.position)n=this.emitter.getWorldMatrix();else{var o=this.emitter;n=H.Matrix[0],z.TranslationToRef(o.x,o.y,o.z,n)}var a=this._engine;this.updateInAnimate||this._update(n);var s=0;return e||t||(a.setState(!1),this.forceDepthWrite&&a.setDepthWrite(!0),s=this.blendMode===aA.BLENDMODE_MULTIPLYADD?this._render(aA.BLENDMODE_MULTIPLY,n)+this._render(aA.BLENDMODE_ADD,n):this._render(this.blendMode,n),this._engine.setAlphaMode(u.ALPHA_DISABLE)),s},t.prototype.rebuild=function(){var e=this,t=function(){e._recreateUpdateEffect()&&e._platform.isUpdateBufferReady()?(e._initialize(!0),e._rebuildingAfterContextLost=!1):setTimeout(t,10)};this._createIndexBuffer(),this._cachedUpdateDefines="",this._platform.contextLost(),this._rebuildingAfterContextLost=!0,t()},t.prototype._releaseBuffers=function(){this._buffer0&&(this._buffer0.dispose(),this._buffer0=null),this._buffer1&&(this._buffer1.dispose(),this._buffer1=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._platform.releaseBuffers()},t.prototype.dispose=function(e){for(var t in void 0===e&&(e=!0),this._drawWrappers)this._drawWrappers[t].dispose();if(this._drawWrappers={},this._scene){var i=this._scene.particleSystems.indexOf(this);i>-1&&this._scene.particleSystems.splice(i,1)}this._releaseBuffers(),this._platform.releaseVertexBuffers();for(var r=0;r0?o.shaderOptions.defines.join("\n"):"";n[0]=a.createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s,void 0,void 0,void 0,this)}var l=this.serialize(r),c=t.Parse(l,this._scene||this._engine,this._rootUrl);return c.name=e,c.customShader=o,c._customWrappers=n,void 0===i&&(i=this.emitter),this.noiseTexture&&(c.noiseTexture=this.noiseTexture.clone()),c.emitter=i,c},t.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};return aA._Serialize(t,this,e),t.activeParticleCount=this.activeParticleCount,t.randomTextureSize=this._randomTextureSize,t.customShader=this.customShader,t},t.Parse=function(e,i,r,n,o){void 0===n&&(n=!1);var a,s=e.name;a=i instanceof Mi?i:i.getEngine();var l=new t(s,{capacity:o||e.capacity,randomTextureSize:e.randomTextureSize},i,null,e.isAnimationSheetEnabled);if(l._rootUrl=r,e.customShader&&a.createEffectForParticles){var c=e.customShader,u=c.shaderOptions.defines.length>0?c.shaderOptions.defines.join("\n"):"",h=a.createEffectForParticles(c.shaderPath.fragmentElement,c.shaderOptions.uniforms,c.shaderOptions.samplers,u,void 0,void 0,void 0,l);l.setCustomEffect(h,0),l.customShader=c}return e.id&&(l.id=e.id),e.activeParticleCount&&(l.activeParticleCount=e.activeParticleCount),aA._Parse(e,l,i,r),e.preventAutoStart&&(l.preventAutoStart=e.preventAutoStart),n||l.preventAutoStart||l.start(),l},t}(vl),lA=function(){function e(){this._emitterNodeIsOwned=!0,this.systems=[]}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},set:function(e){this._emitterNodeIsOwned&&this._emitterNode&&(this._emitterNode.dispose&&this._emitterNode.dispose(),this._emitterNodeIsOwned=!1);for(var t=0,i=this.systems;t0&&i.set(this._uvs32,Nr.UVKind),this._colors32.length>0&&i.set(this._colors32,Nr.ColorKind),i.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable)for(var r=0,n=0;np?p:n,r=Math.round(p/n),o=0):r=r>p?p:r;for(var f=[],_=[],m=[],g=[],v=[],y=V.Zero(),b=r;dp-(r=b+Math.floor((1+o)*Math.random()))&&(r=p-d),f.length=0,_.length=0,m.length=0,g.length=0,v.length=0;for(var T=0,E=3*d;E<3*(d+r);E++){m.push(T);var S=s[E],x=3*S;if(f.push(a[x],a[x+1],a[x+2]),_.push(u[x],u[x+1],u[x+2]),l){var A=2*S;g.push(l[A],l[A+1])}if(c){var C=4*S;v.push(c[C],c[C+1],c[C+2],c[C+3])}T++}var R=this.nbParticles,P=this._posToShape(f),I=this._uvsToShapeUV(g),M=m.slice(),O=v.slice(),D=_.slice();y.copyFromFloats(0,0,0);var N=void 0;for(N=0;N65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var B=null!==b.materialIndex?b.materialIndex:0;this.depthSortedParticles.push(new pA(d,t,n.length,B))}return b},e.prototype._posToShape=function(e){for(var t=[],i=0;i=this.nbParticles||!this._updatable)return[];var r=this.particles,n=this.nbParticles;if(t=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var F=this.mesh.getBoundingInfo();F&&(v.copyFrom(F.minimum),y.copyFrom(F.maximum))}var L=(P=this.particles[e]._pos)/3|0;M=4*L,D=2*L;for(var w=e;w<=t;w++){var B=this.particles[w];this.updateParticle(B);var U=B._model._shape,k=B._model._shapeUV,G=B._rotationMatrix,W=B.position,X=B.rotation,j=B.scaling,Y=B._globalPosition;if(p){var K=this.depthSortedParticles[w];K.idx=B.idx,K.ind=B._ind,K.indicesLength=B._model._indicesLength,K.sqDistance=V.DistanceSquared(B.position,b)}if(B.alive&&(!B._stillInvisible||B.isVisible||this._recomputeInvisibles)){if(B.isVisible){B._stillInvisible=!1;var Q=f[12];if(B.pivot.multiplyToRef(j,Q),this.billboard&&(X.x=0,X.y=0),(this._computeParticleRotation||this.billboard)&&B.getRotationMatrix(r),null!==B.parentId){var q=this.getParticleById(B.parentId);if(q){var Z=q._rotationMatrix,J=q._globalPosition,$=W.x*Z[1]+W.y*Z[4]+W.z*Z[7],ee=W.x*Z[0]+W.y*Z[3]+W.z*Z[6],te=W.x*Z[2]+W.y*Z[5]+W.z*Z[8];if(Y.x=J.x+ee,Y.y=J.y+$,Y.z=J.z+te,this._computeParticleRotation||this.billboard){var ie=r.m;G[0]=ie[0]*Z[0]+ie[1]*Z[3]+ie[2]*Z[6],G[1]=ie[0]*Z[1]+ie[1]*Z[4]+ie[2]*Z[7],G[2]=ie[0]*Z[2]+ie[1]*Z[5]+ie[2]*Z[8],G[3]=ie[4]*Z[0]+ie[5]*Z[3]+ie[6]*Z[6],G[4]=ie[4]*Z[1]+ie[5]*Z[4]+ie[6]*Z[7],G[5]=ie[4]*Z[2]+ie[5]*Z[5]+ie[6]*Z[8],G[6]=ie[8]*Z[0]+ie[9]*Z[3]+ie[10]*Z[6],G[7]=ie[8]*Z[1]+ie[9]*Z[4]+ie[10]*Z[7],G[8]=ie[8]*Z[2]+ie[9]*Z[5]+ie[10]*Z[8]}}else B.parentId=null}else Y.x=W.x,Y.y=W.y,Y.z=W.z,(this._computeParticleRotation||this.billboard)&&(ie=r.m,G[0]=ie[0],G[1]=ie[1],G[2]=ie[2],G[3]=ie[4],G[4]=ie[5],G[5]=ie[6],G[6]=ie[8],G[7]=ie[9],G[8]=ie[10]);var re=f[11];for(B.translateFromPivot?re.setAll(0):re.copyFrom(Q),N=0;N0)for(var t=0;t0&&t.set(this._uvs32,Nr.UVKind);var i=0;this._colors32.length>0&&(i=1,t.set(this._colors32,Nr.ColorKind));var r=new Fa(this.name,this._scene);t.applyToMesh(r,this._updatable),this.mesh=r,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var n=e;return n||((n=new Uu("point cloud material",this._scene)).emissiveColor=new Z(i,i,i),n.disableLighting=!0,n.pointsCloud=!0,n.pointSize=this._size),r.material=n,new Promise((function(e){return e(r)}))},e.prototype._addParticle=function(e,t,i,r){var n=new mA(e,t,i,r,this);return this.particles.push(n),n},e.prototype._randomUnitVector=function(e){e.position=new V(Math.random(),Math.random(),Math.random()),e.color=new J(1,1,1,1)},e.prototype._getColorIndicesForCoord=function(e,t,i,r){var n=e._groupImageData,o=i*(4*r)+4*t,a=[o,o+1,o+2,o+3],s=a[1],l=a[2],c=a[3],u=n[a[0]],h=n[s],d=n[l],p=n[c];return new J(u/255,h/255,d/255,p)},e.prototype._setPointsColorOrUV=function(e,t,i,r,n,o,a,s){s=null!=s?s:0,i&&e.updateFacetData();var l=2*e.getBoundingInfo().boundingSphere.radius,c=e.getVerticesData(Nr.PositionKind),u=e.getIndices(),h=e.getVerticesData(Nr.UVKind+(s?s+1:"")),d=e.getVerticesData(Nr.ColorKind),p=V.Zero();e.computeWorldMatrix();var f=e.getWorldMatrix();if(!f.isIdentity()){c=c.slice(0);for(var _=0;_1&&(Le=1),(we=Be.b+Ne)<0&&(we=0),we>1&&(we=1),Z.HSVtoRGBToRef(Fe,Le,we,Ve),ye.set(Ve.r,Ve.g,Ve.b,1)):ye=he.set(Math.random(),Math.random(),Math.random(),1),Ge.color=new J(ye.x,ye.y,ye.z,ye.w),this._colors.push(ye.x,ye.y,ye.z,ye.w))}},e.prototype._colorFromTexture=function(e,t,i){var r=this;if(null===e.material)return ae.Warn(e.name+"has no material."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var n=e.material.getActiveTextures();if(0===n.length)return ae.Warn(e.name+"has no usable texture."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var o=e.clone();o.setEnabled(!1),this._promises.push(new Promise((function(e){Ya.WhenAllReady(n,(function(){var a=t._textureNb;a<0&&(a=0),a>n.length-1&&(a=n.length-1);var s=function(){t._groupImgWidth=n[a].getSize().width,t._groupImgHeight=n[a].getSize().height,r._setPointsColorOrUV(o,t,i,!0,!0,void 0,void 0,n[a].coordinatesIndex),o.dispose(),e()};t._groupImageData=null;var l=n[a].readPixels();l?l.then((function(e){t._groupImageData=e,s()})):s()}))})))},e.prototype._calculateDensity=function(e,t,i){for(var r,n,o,a,s,l,c,u,h,d,p,f,_=V.Zero(),m=V.Zero(),g=V.Zero(),v=V.Zero(),y=V.Zero(),b=V.Zero(),T=[],E=0,S=i.length/3,x=0;x0;x--){var R=T[x];if(0===R)A[x]=0;else{var P=(R-T[x-1])/R*C,I=Math.floor(P),M=P-I,O=I+Number(Math.random()3)&&(o=uA.Random);var a=e.getVerticesData(Nr.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new gA(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===uA.Color?l._textureNb=r||0:r=r||new J(1,1,1,1),o){case uA.Color:this._colorFromTexture(e,l,!1);break;case uA.UV:this._setPointsColorOrUV(e,l,!1,!1,!1);break;case uA.Random:this._setPointsColorOrUV(e,l,!1);break;case uA.Stated:this._setPointsColorOrUV(e,l,!1,void 0,void 0,r,n)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.addVolumePoints=function(e,t,i,r,n){var o=i||uA.Random;(isNaN(o)||o<0||o>3)&&(o=uA.Random);var a=e.getVerticesData(Nr.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new gA(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===uA.Color?l._textureNb=r||0:r=r||new J(1,1,1,1),o){case uA.Color:this._colorFromTexture(e,l,!0);break;case uA.UV:this._setPointsColorOrUV(e,l,!0,!1,!1);break;case uA.Random:this._setPointsColorOrUV(e,l,!0);break;case uA.Stated:this._setPointsColorOrUV(e,l,!0,void 0,void 0,r,n)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.setParticles=function(e,t,i){var r,n;if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===i&&(i=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(e,t,i);var o=H.Matrix[0],a=this.mesh,s=this._colors32,l=this._positions32,c=this._uvs32,u=H.Vector3,h=u[5].copyFromFloats(1,0,0),d=u[6].copyFromFloats(0,1,0),p=u[7].copyFromFloats(0,0,1),f=u[8].setAll(Number.MAX_VALUE),_=u[9].setAll(-Number.MAX_VALUE);z.IdentityToRef(o);var m=0;if((null===(r=this.mesh)||void 0===r?void 0:r.isFacetDataEnabled)&&(this._computeBoundingBox=!0),t=t>=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var g=null===(n=this.mesh)||void 0===n?void 0:n.getBoundingInfo();g&&(f.copyFrom(g.minimum),_.copyFrom(g.maximum))}m=0;for(var v=0,y=0,b=0,T=e;T<=t;T++){var E=this.particles[T];v=3*(m=E.idx),y=4*m,b=2*m,this.updateParticle(E);var S=E._rotationMatrix,x=E.position,A=E._globalPosition;if(this._computeParticleRotation&&E.getRotationMatrix(o),null!==E.parentId){var C=this.particles[E.parentId],R=C._rotationMatrix,P=C._globalPosition,I=x.x*R[1]+x.y*R[4]+x.z*R[7],M=x.x*R[0]+x.y*R[3]+x.z*R[6],O=x.x*R[2]+x.y*R[5]+x.z*R[8];if(A.x=P.x+M,A.y=P.y+I,A.z=P.z+O,this._computeParticleRotation){var D=o.m;S[0]=D[0]*R[0]+D[1]*R[3]+D[2]*R[6],S[1]=D[0]*R[1]+D[1]*R[4]+D[2]*R[7],S[2]=D[0]*R[2]+D[1]*R[5]+D[2]*R[8],S[3]=D[4]*R[0]+D[5]*R[3]+D[6]*R[6],S[4]=D[4]*R[1]+D[5]*R[4]+D[6]*R[7],S[5]=D[4]*R[2]+D[5]*R[5]+D[6]*R[8],S[6]=D[8]*R[0]+D[9]*R[3]+D[10]*R[6],S[7]=D[8]*R[1]+D[9]*R[4]+D[10]*R[7],S[8]=D[8]*R[2]+D[9]*R[5]+D[10]*R[8]}}else A.x=0,A.y=0,A.z=0,this._computeParticleRotation&&(D=o.m,S[0]=D[0],S[1]=D[1],S[2]=D[2],S[3]=D[4],S[4]=D[5],S[5]=D[6],S[6]=D[8],S[7]=D[9],S[8]=D[10]);var N=u[11];E.translateFromPivot?N.setAll(0):N.copyFrom(E.pivot);var F=u[0];F.copyFrom(E.position);var L=F.x-E.pivot.x,w=F.y-E.pivot.y,B=F.z-E.pivot.z,U=L*S[0]+w*S[3]+B*S[6],V=L*S[1]+w*S[4]+B*S[7],k=L*S[2]+w*S[5]+B*S[8];U+=N.x,V+=N.y,k+=N.z;var G=l[v]=A.x+h.x*U+d.x*V+p.x*k,W=l[v+1]=A.y+h.y*U+d.y*V+p.y*k,X=l[v+2]=A.z+h.z*U+d.z*V+p.z*k;if(this._computeBoundingBox&&(f.minimizeInPlaceFromFloats(G,W,X),_.maximizeInPlaceFromFloats(G,W,X)),this._computeParticleColor&&E.color){var j=E.color,Y=this._colors32;Y[y]=j.r,Y[y+1]=j.g,Y[y+2]=j.b,Y[y+3]=j.a}if(this._computeParticleTexture&&E.uv){var K=E.uv,Q=this._uvs32;Q[b]=K.x,Q[b+1]=K.y}}return a&&(i&&(this._computeParticleColor&&a.updateVerticesData(Nr.ColorKind,s,!1,!1),this._computeParticleTexture&&a.updateVerticesData(Nr.UVKind,c,!1,!1),a.updateVerticesData(Nr.PositionKind,l,!1,!1)),this._computeBoundingBox&&(a.hasBoundingInfo?a.getBoundingInfo().reConstruct(f,_,a._worldMatrix):a.buildBoundingInfo(f,_,a._worldMatrix))),this.afterUpdateParticles(e,t,i),this},e.prototype.dispose=function(){var e;null===(e=this.mesh)||void 0===e||e.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._uvs32=null,this._colors32=null},e.prototype.refreshVisibleSize=function(){var e;return this._isVisibilityBoxLocked||null===(e=this.mesh)||void 0===e||e.refreshBoundingInfo(),this},e.prototype.setVisibilityBox=function(e){if(this.mesh){var t=e/2;this.mesh.buildBoundingInfo(new V(-t,-t,-t),new V(t,t,t))}},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this.mesh&&(this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{set:function(e){this._computeParticleRotation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!1,configurable:!0}),e.prototype.initParticles=function(){},e.prototype.recycleParticle=function(e){return e},e.prototype.updateParticle=function(e){return e},e.prototype.beforeUpdateParticles=function(e,t,i){},e.prototype.afterUpdateParticles=function(e,t,i){},e}();Object.defineProperty(Uo.prototype,"physicsImpostor",{get:function(){return this._physicsImpostor},set:function(e){var t=this;this._physicsImpostor!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsImpostor=e,e&&(this._disposePhysicsObserver=this.onDisposeObservable.add((function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)}))))},enumerable:!0,configurable:!0}),Uo.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},Uo.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},Uo.prototype.setPhysicsLinkWith=function(e,t,i,r){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,Cs.HingeJoint,{mainPivot:t,connectedPivot:i,nativeParams:r}),this):this};var yA,bA,TA,EA,SA,xA,AA,CA,RA=function(){function e(t,i){void 0===i&&(i=e.DefaultPluginFactory()),this._physicsPlugin=i,this._physicsBodies=[],this._subTimeStep=0,t=t||new V(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return e.prototype.getPluginVersion=function(){return this._physicsPlugin.getPluginVersion()},e.DefaultPluginFactory=function(){throw He("")},e.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},e.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},e.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},e.prototype.setSubTimeStep=function(e){void 0===e&&(e=0),this._subTimeStep=e},e.prototype.getSubTimeStep=function(){return this._subTimeStep},e.prototype.dispose=function(){this._physicsPlugin.dispose()},e.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},e.prototype._step=function(e){e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._physicsBodies)},e.prototype.addBody=function(e){this._physicsBodies.push(e)},e.prototype.removeBody=function(e){var t=this._physicsBodies.indexOf(e);t>-1&&this._physicsBodies.splice(t,1)},e.prototype.getBodies=function(){return this._physicsBodies},e.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},e.prototype.raycastToRef=function(e,t,i,r){this._physicsPlugin.raycast(e,t,i,r)},e.prototype.raycast=function(e,t,i){var r=new Nv;return this._physicsPlugin.raycast(e,t,r,i),r},e}();!function(e){e[e.FREE=0]="FREE",e[e.LIMITED=1]="LIMITED",e[e.LOCKED=2]="LOCKED"}(yA||(yA={})),function(e){e[e.LINEAR_X=0]="LINEAR_X",e[e.LINEAR_Y=1]="LINEAR_Y",e[e.LINEAR_Z=2]="LINEAR_Z",e[e.ANGULAR_X=3]="ANGULAR_X",e[e.ANGULAR_Y=4]="ANGULAR_Y",e[e.ANGULAR_Z=5]="ANGULAR_Z",e[e.LINEAR_DISTANCE=6]="LINEAR_DISTANCE"}(bA||(bA={})),function(e){e[e.BALL_AND_SOCKET=1]="BALL_AND_SOCKET",e[e.DISTANCE=2]="DISTANCE",e[e.HINGE=3]="HINGE",e[e.SLIDER=4]="SLIDER",e[e.LOCK=5]="LOCK",e[e.PRISMATIC=6]="PRISMATIC",e[e.SIX_DOF=7]="SIX_DOF"}(TA||(TA={})),function(e){e[e.SPHERE=0]="SPHERE",e[e.CAPSULE=1]="CAPSULE",e[e.CYLINDER=2]="CYLINDER",e[e.BOX=3]="BOX",e[e.CONVEX_HULL=4]="CONVEX_HULL",e[e.CONTAINER=5]="CONTAINER",e[e.MESH=6]="MESH",e[e.HEIGHTFIELD=7]="HEIGHTFIELD"}(EA||(EA={})),function(e){e[e.NONE=0]="NONE",e[e.VELOCITY=1]="VELOCITY",e[e.POSITION=2]="POSITION"}(SA||(SA={})),function(e){e.COLLISION_STARTED="COLLISION_STARTED",e.COLLISION_CONTINUED="COLLISION_CONTINUED",e.COLLISION_FINISHED="COLLISION_FINISHED",e.TRIGGER_ENTERED="TRIGGER_ENTERED",e.TRIGGER_EXITED="TRIGGER_EXITED"}(xA||(xA={})),function(e){e[e.STATIC=0]="STATIC",e[e.ANIMATED=1]="ANIMATED",e[e.DYNAMIC=2]="DYNAMIC"}(AA||(AA={})),function(e){e[e.SIMULATION_CONTROLLED=0]="SIMULATION_CONTROLLED",e[e.ALWAYS_ACTIVE=1]="ALWAYS_ACTIVE",e[e.ALWAYS_INACTIVE=2]="ALWAYS_INACTIVE"}(CA||(CA={}));var PA,IA=function(){function e(e,t,i,r){var n=this;if(this._pluginData=void 0,this._pluginDataInstances=[],this._collisionCBEnabled=!1,this._collisionEndedCBEnabled=!1,this.disablePreStep=!0,this.disableSync=!1,this._isDisposed=!1,this._shape=null,r){var o=r.getPhysicsEngine();if(!o)throw new Error("No Physics Engine available.");if(this._physicsEngine=o,2!=o.getPluginVersion())throw new Error("Plugin version is incorrect. Expected version 2.");var a=o.getPhysicsPlugin();if(!a)throw new Error("No Physics Plugin available.");this._physicsPlugin=a,e.rotationQuaternion||(e.rotationQuaternion=G.FromEulerAngles(e.rotation.x,e.rotation.y,e.rotation.z)),this.startAsleep=i,this._motionType=t,this.disableSync=t==AA.STATIC;var s=e;s.hasThinInstances?this._physicsPlugin.initBodyInstances(this,t,s):(e.parent&&e.computeWorldMatrix(!0),this._physicsPlugin.initBody(this,t,e.absolutePosition,e.absoluteRotationQuaternion)),this.transformNode=e,e.physicsBody=this,o.addBody(this),this._nodeDisposeObserver=e.onDisposeObservable.add((function(){n.dispose()}))}}return e.prototype.getClassName=function(){return"PhysicsBody"},e.prototype.clone=function(t){var i=new e(t,this.getMotionType(),this.startAsleep,this.transformNode.getScene());return i.shape=this.shape,i.setMassProperties(this.getMassProperties()),i.setLinearDamping(this.getLinearDamping()),i.setAngularDamping(this.getAngularDamping()),i},e.prototype.updateBodyInstances=function(){var e=this.transformNode;e.hasThinInstances&&this._physicsPlugin.updateBodyInstances(this,e)},Object.defineProperty(e.prototype,"numInstances",{get:function(){return this._pluginDataInstances.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"motionType",{get:function(){return this._motionType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){return this._shape},set:function(e){this._shape=e,e&&this._physicsPlugin.setShape(this,e)},enumerable:!1,configurable:!0}),e.prototype.setEventMask=function(e,t){this._physicsPlugin.setEventMask(this,e,t)},e.prototype.getEventMask=function(e){return this._physicsPlugin.getEventMask(this,e)},e.prototype.setMotionType=function(e,t){this.disableSync=e==AA.STATIC,this._physicsPlugin.setMotionType(this,e,t)},e.prototype.getMotionType=function(e){return this._physicsPlugin.getMotionType(this,e)},e.prototype.computeMassProperties=function(e){return this._physicsPlugin.computeMassProperties(this,e)},e.prototype.setMassProperties=function(e,t){this._physicsPlugin.setMassProperties(this,e,t)},e.prototype.getMassProperties=function(e){return this._physicsPlugin.getMassProperties(this,e)},e.prototype.setLinearDamping=function(e,t){this._physicsPlugin.setLinearDamping(this,e,t)},e.prototype.getLinearDamping=function(e){return this._physicsPlugin.getLinearDamping(this,e)},e.prototype.setAngularDamping=function(e,t){this._physicsPlugin.setAngularDamping(this,e,t)},e.prototype.getAngularDamping=function(e){return this._physicsPlugin.getAngularDamping(this,e)},e.prototype.setLinearVelocity=function(e,t){this._physicsPlugin.setLinearVelocity(this,e,t)},e.prototype.getLinearVelocityToRef=function(e,t){this._physicsPlugin.getLinearVelocityToRef(this,e,t)},e.prototype.getLinearVelocity=function(e){var t=new V;return this.getLinearVelocityToRef(t,e),t},e.prototype.setAngularVelocity=function(e,t){this._physicsPlugin.setAngularVelocity(this,e,t)},e.prototype.getAngularVelocityToRef=function(e,t){this._physicsPlugin.getAngularVelocityToRef(this,e,t)},e.prototype.getAngularVelocity=function(e){var t=new V;return this.getAngularVelocityToRef(t,e),t},e.prototype.applyImpulse=function(e,t,i){this._physicsPlugin.applyImpulse(this,e,t,i)},e.prototype.applyAngularImpulse=function(e,t){this._physicsPlugin.applyAngularImpulse(this,e,t)},e.prototype.applyForce=function(e,t,i){this._physicsPlugin.applyForce(this,e,t,i)},e.prototype.getGeometry=function(){return this._physicsPlugin.getBodyGeometry(this)},e.prototype.getCollisionObservable=function(){return this._physicsPlugin.getCollisionObservable(this)},e.prototype.getCollisionEndedObservable=function(){return this._physicsPlugin.getCollisionEndedObservable(this)},e.prototype.setCollisionCallbackEnabled=function(e){this._collisionCBEnabled=e,this._physicsPlugin.setCollisionCallbackEnabled(this,e)},e.prototype.setCollisionEndedCallbackEnabled=function(e){this._collisionEndedCBEnabled=e,this._physicsPlugin.setCollisionEndedCallbackEnabled(this,e)},e.prototype.getObjectCenterWorld=function(e){var t=new V;return this.getObjectCenterWorldToRef(t,e)},e.prototype.getObjectCenterWorldToRef=function(e,t){var i;if((null===(i=this._pluginDataInstances)||void 0===i?void 0:i.length)>0){var r=t||0,n=this.transformNode._thinInstanceDataStorage.matrixData;n&&e.set(n[16*r+12],n[16*r+13],n[16*r+14])}else e.copyFrom(this.transformNode.position);return e},e.prototype.addConstraint=function(e,t,i,r){this._physicsPlugin.addConstraint(this,e,t,i,r)},e.prototype.syncWithBone=function(e,t,i,r,n,o){var a=this.transformNode;if(a.rotationQuaternion)if(n){var s=H.Quaternion[0];e.getRotationQuaternionToRef(dn.WORLD,t,s),s.multiplyToRef(n,a.rotationQuaternion)}else e.getRotationQuaternionToRef(dn.WORLD,t,a.rotationQuaternion);var l=H.Vector3[0],c=H.Vector3[1];o||((o=H.Vector3[2]).x=0,o.y=1,o.z=0),e.getDirectionToRef(o,t,c),e.getAbsolutePositionToRef(t,l),null==r&&i&&(r=i.length()),null!=r&&(l.x+=c.x*r,l.y+=c.y*r,l.z+=c.z*r),a.setAbsolutePosition(l)},e.prototype.iterateOverAllInstances=function(e){var t;if((null===(t=this._pluginDataInstances)||void 0===t?void 0:t.length)>0)for(var i=0;i0},e.prototype._addSizeOptions=function(){var e,t,i,r,n,o,a,s;this.transformNode.computeWorldMatrix(!0);var l=this._getObjectBoundingBox(),c=H.Vector3[0];c.copyFrom(l.extendSize),c.scaleInPlace(2),c.multiplyInPlace(this.transformNode.scaling),c.x=Math.abs(c.x),c.y=Math.abs(c.y),c.z=Math.abs(c.z);var u=H.Vector3[1];if(u.copyFrom(l.minimum),u.multiplyInPlace(this.transformNode.scaling),!this._options.center){var h=new V;h.copyFrom(l.center),h.multiplyInPlace(this.transformNode.scaling),this._options.center=h}switch(this.type){case EA.SPHERE:!this._options.radius&&j.WithinEpsilon(c.x,c.y,1e-4)&&j.WithinEpsilon(c.x,c.z,1e-4)?this._options.radius=c.x/2:this._options.radius||(ae.Warn("Non uniform scaling is unsupported for sphere shapes. Setting the radius to the biggest bounding box extent."),this._options.radius=Math.max(c.x,c.y,c.z)/2);break;case EA.CAPSULE:var d=c.x/2;this._options.radius=null!==(e=this._options.radius)&&void 0!==e?e:d,this._options.pointA=null!==(t=this._options.pointA)&&void 0!==t?t:new V(0,u.y+d,0),this._options.pointB=null!==(i=this._options.pointB)&&void 0!==i?i:new V(0,u.y+c.y-d,0);break;case EA.CYLINDER:d=c.x/2,this._options.radius=null!==(r=this._options.radius)&&void 0!==r?r:d,this._options.pointA=null!==(n=this._options.pointA)&&void 0!==n?n:new V(0,u.y,0),this._options.pointB=null!==(o=this._options.pointB)&&void 0!==o?o:new V(0,u.y+c.y,0);break;case EA.MESH:case EA.CONVEX_HULL:if(!this._options.mesh&&this._hasVertices(this.transformNode))this._options.mesh=this.transformNode;else if(!this._options.mesh||!this._hasVertices(this._options.mesh))throw new Error("No valid mesh was provided for mesh or convex hull shape parameter. Please provide a mesh with valid geometry (number of vertices greater than 0).");break;case EA.BOX:this._options.extents=null!==(a=this._options.extents)&&void 0!==a?a:new V(c.x,c.y,c.z),this._options.rotation=null!==(s=this._options.rotation)&&void 0!==s?s:G.Identity()}},e.prototype.dispose=function(){this._nodeDisposeObserver&&(this.body.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver),this._nodeDisposeObserver=null),this.body.dispose(),this._disposeShapeWhenDisposed&&this.shape.dispose()},e}(),QA=function(){},qA=function(){function e(e,t,i){this._boxConfigs=new Array,this._joints=new Array,this._bones=new Array,this._initialRotation=new Array,this._initialRotation2=new Array,this._boneNames=[],this._transforms=new Array,this._aggregates=new Array,this._ragdollMode=!1,this._rootBoneName="",this._rootBoneIndex=-1,this._mass=10,this._restitution=0,this.pauseSync=!1,this._defaultJoint=TA.HINGE,this._defaultJointMin=-90,this._defaultJointMax=90,this._skeleton=e,this._scene=e.getScene(),this._rootTransformNode=t,this._config=i,this._boxConfigs=[],this._putBoxesInBoneCenter=!1,this._defaultJoint=TA.HINGE,this._init()}return e.prototype.getAggregate=function(e){return e<0||e>=this._aggregates.length?this._aggregates[this._rootBoneIndex]:this._aggregates[e]},e.prototype._createColliders=function(){var e,t,i;this._rootTransformNode.computeWorldMatrix(),this._skeleton.computeAbsoluteMatrices(!0),this._skeleton.prepare(!0);for(var r=this._config,n=0;n0)for(var t=0,i=e._pluginDataInstances;ts){this._createOrUpdateBodyInstances(e,l,a,s,o,!1);var c=this._hknp.HP_Body_GetShape(e._pluginDataInstances[0].hpBodyId)[1];c[0]||(c[0]=null===(n=e.shape)||void 0===n?void 0:n._pluginData[0]);for(var u=s;u0&&void 0===i)for(var n=0;n0){var r=i._thinInstanceDataStorage.matrixData;if(!r)return;var n=e.numInstances;this._createOrUpdateBodyInstances(e,e.getMotionType(),r,0,n,!0)}else this._hknp.HP_Body_SetQTransform(e._pluginData.hpBodyId,this._getTransformInfos(t))},e.prototype.setTargetTransform=function(e,t,i,r){var n=this;this._applyToBodyOrInstances(e,(function(e){n._hknp.HP_Body_SetTargetQTransform(e.hpBodyId,[n._bVecToV3(t),n._bQuatToV4(i)])}),r)},e.prototype.setGravityFactor=function(e,t,i){var r=this;this._applyToBodyOrInstances(e,(function(e){r._hknp.HP_Body_SetGravityFactor(e.hpBodyId,t)}),i)},e.prototype.getGravityFactor=function(e,t){var i=this._getPluginReference(e,t);return this._hknp.HP_Body_GetGravityFactor(i.hpBodyId)[1]},e.prototype.disposeBody=function(e){if(e._pluginDataInstances&&e._pluginDataInstances.length>0)for(var t=0,i=e._pluginDataInstances;t0?e._pluginDataInstances[0]:e._pluginData,r=this._hknp.HP_Body_GetShape(i.hpBodyId)[1],n=this._hknp.HP_Shape_CreateDebugDisplayGeometry(r);if(n[0]!=this._hknp.Result.RESULT_OK)return{positions:[],indices:[]};var o=this._hknp.HP_DebugGeometry_GetInfo(n[1])[1],a=new Float32Array(this._hknp.HEAPU8.buffer,o[0],3*o[1]),s=new Uint32Array(this._hknp.HEAPU8.buffer,o[2],3*o[3]),l=a.slice(0),c=s.slice(0);return this._hknp.HP_DebugGeometry_Release(n[1]),{positions:l,indices:c}},e.prototype.disposeShape=function(e){this._hknp.HP_Shape_Release(e._pluginData),e._pluginData=void 0},e.prototype.initConstraint=function(e,t,i,r,n){var o,a,s,l,c,u=e.type,h=e.options;if(u&&h)if(t._pluginDataInstances.length>0&&void 0===r||i._pluginDataInstances.length>0&&void 0===n)ae.Warn("Body is instanced but no instance index was specified. Constraint will not be applied.");else{e._pluginData=null!==(o=e._pluginData)&&void 0!==o?o:[];var d=this._hknp.HP_Constraint_Create()[1];e._pluginData.push(d);var p=this._getPluginReference(t,r).hpBodyId,f=this._getPluginReference(i,n).hpBodyId;this._hknp.HP_Constraint_SetParentBody(d,p),this._hknp.HP_Constraint_SetChildBody(d,f),this._constraintToBodyIdPair.set(d[0],[p[0],f[0]]);var _=h.pivotA?this._bVecToV3(h.pivotA):this._bVecToV3(V.Zero()),m=null!==(a=h.axisA)&&void 0!==a?a:new V(1,0,0),g=this._tmpVec3[0];h.perpAxisA?g.copyFrom(h.perpAxisA):m.getNormalToRef(g),this._hknp.HP_Constraint_SetAnchorInParent(d,_,this._bVecToV3(m),this._bVecToV3(g));var v=h.pivotB?this._bVecToV3(h.pivotB):this._bVecToV3(V.Zero()),y=null!==(s=h.axisB)&&void 0!==s?s:new V(1,0,0),b=this._tmpVec3[0];if(h.perpAxisB?b.copyFrom(h.perpAxisB):y.getNormalToRef(b),this._hknp.HP_Constraint_SetAnchorInChild(d,v,this._bVecToV3(y),this._bVecToV3(b)),e._initOptions||(e._initOptions={axisA:m.clone(),axisB:y.clone(),perpAxisA:g.clone(),perpAxisB:b.clone(),pivotA:new V(_[0],_[1],_[2]),pivotB:new V(v[0],v[1],v[2])}),u==TA.LOCK)this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(u==TA.DISTANCE){var T=h.maxDistance||0,E=this._hknp.ConstraintAxis.LINEAR_DISTANCE;this._hknp.HP_Constraint_SetAxisMode(d,E,this._hknp.ConstraintAxisLimitMode.LIMITED),this._hknp.HP_Constraint_SetAxisMinLimit(d,E,T),this._hknp.HP_Constraint_SetAxisMaxLimit(d,E,T)}else if(u==TA.HINGE)this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(u==TA.PRISMATIC)this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(u==TA.SLIDER)this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(u==TA.BALL_AND_SOCKET)this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(d,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else{if(u!=TA.SIX_DOF)throw new Error("Unsupported Constraint Type.");for(var S=0,x=e.limits;S0){var u=this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector,0)[1][1];this._populateHitData(u,i),i.calculateHitDistance()}},e.prototype.pointProximity=function(e,t){var i,r,n,o,a=null!==(r=null===(i=null==e?void 0:e.collisionFilter)||void 0===i?void 0:i.membership)&&void 0!==r?r:-1,s=null!==(o=null===(n=null==e?void 0:e.collisionFilter)||void 0===n?void 0:n.collideWith)&&void 0!==o?o:-1;t.reset();var l=e.ignoreBody?[BigInt(e.ignoreBody._pluginData.hpBodyId[0])]:[BigInt(0)],c=[this._bVecToV3(e.position),e.maxDistance,[a,s],e.shouldHitTriggers,l];if(this._hknp.HP_World_PointProximityWithCollector(this.world,this._queryCollector,c),this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1]>0){var u=this._hknp.HP_QueryCollector_GetPointProximityResult(this._queryCollector,0)[1],h=u[0],d=u[1];this._populateHitData(d,t),t.setHitDistance(h)}},e.prototype.shapeProximity=function(e,t,i){t.reset(),i.reset();var r=e.shape._pluginData,n=e.ignoreBody?[BigInt(e.ignoreBody._pluginData.hpBodyId[0])]:[BigInt(0)],o=[r,this._bVecToV3(e.position),this._bQuatToV4(e.rotation),e.maxDistance,e.shouldHitTriggers,n];if(this._hknp.HP_World_ShapeProximityWithCollector(this.world,this._queryCollector,o),this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1]>0){var a=this._hknp.HP_QueryCollector_GetShapeProximityResult(this._queryCollector,0)[1],s=a[0],l=a[1],c=a[2];this._populateHitData(l,t),this._populateHitData(c,i),t.setHitDistance(s),i.setHitDistance(s)}},e.prototype.shapeCast=function(e,t,i){t.reset(),i.reset();var r=e.shape._pluginData,n=e.ignoreBody?[BigInt(e.ignoreBody._pluginData.hpBodyId[0])]:[BigInt(0)],o=[r,this._bQuatToV4(e.rotation),this._bVecToV3(e.startPosition),this._bVecToV3(e.endPosition),e.shouldHitTriggers,n];if(this._hknp.HP_World_ShapeCastWithCollector(this.world,this._queryCollector,o),this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1]>0){var a=this._hknp.HP_QueryCollector_GetShapeCastResult(this._queryCollector,0)[1],s=a[0],l=a[1],c=a[2];this._populateHitData(l,t),this._populateHitData(c,i),t.setHitFraction(s),i.setHitFraction(s)}},e.prototype.getCollisionObservable=function(e){var t=e._pluginData.hpBodyId[0],i=this._bodyCollisionObservable.get(t);return i||(i=new f,this._bodyCollisionObservable.set(t,i)),i},e.prototype.getCollisionEndedObservable=function(e){var t=e._pluginData.hpBodyId[0],i=this._bodyCollisionEndedObservable.get(t);return i||(i=new f,this._bodyCollisionEndedObservable.set(t,i)),i},e.prototype.setCollisionCallbackEnabled=function(e,t){var i=this,r=this._hknp.EventType.COLLISION_STARTED.value|this._hknp.EventType.COLLISION_CONTINUED.value|this._hknp.EventType.COLLISION_FINISHED.value;e._pluginDataInstances&&e._pluginDataInstances.length?e._pluginDataInstances.forEach((function(e){i._hknp.HP_Body_SetEventMask(e.hpBodyId,t?r:0)})):e._pluginData&&this._hknp.HP_Body_SetEventMask(e._pluginData.hpBodyId,t?r:0)},e.prototype.setCollisionEndedCallbackEnabled=function(e,t){var i=this,r=this._getPluginReference(e),n=this._hknp.HP_Body_GetEventMask(r.hpBodyId)[1];n=t?n|this._hknp.EventType.COLLISION_FINISHED.value:n&~this._hknp.EventType.COLLISION_FINISHED.value,e._pluginDataInstances&&e._pluginDataInstances.length?e._pluginDataInstances.forEach((function(e){i._hknp.HP_Body_SetEventMask(e.hpBodyId,n)})):e._pluginData&&this._hknp.HP_Body_SetEventMask(e._pluginData.hpBodyId,n)},e.prototype._notifyTriggers=function(){for(var e=this._hknp.HP_World_GetTriggerEvents(this.world)[1],t=new tC;e;){tC.readToRef(this._hknp.HEAPU8.buffer,e,t);var i=this._bodies.get(t.bodyIdA),r=this._bodies.get(t.bodyIdB);if(i&&r){var n={collider:i.body,colliderIndex:i.index,collidedAgainst:r.body,collidedAgainstIndex:r.index,type:this._nativeTriggerCollisionValueToCollisionType(t.type)};this.onTriggerCollisionObservable.notifyObservers(n)}e=this._hknp.HP_World_GetNextTriggerEvent(this.world,e)}},e.prototype._notifyCollisions=function(){for(var e=this._hknp.HP_World_GetCollisionEvents(this.world)[1],t=new eC,i=Number(this.world);e;){eC.readToRef(this._hknp.HEAPU8.buffer,e,t);var r=this._bodies.get(t.contactOnA.bodyId),n=this._bodies.get(t.contactOnB.bodyId);if(r&&n){var o={collider:r.body,colliderIndex:r.index,collidedAgainst:n.body,collidedAgainstIndex:n.index,type:this._nativeCollisionValueToCollisionType(t.type)};if(o.type===xA.COLLISION_FINISHED)this.onCollisionEndedObservable.notifyObservers(o);else{t.contactOnB.position.subtractToRef(t.contactOnA.position,this._tmpVec3[0]);var a=V.Dot(this._tmpVec3[0],t.contactOnA.normal);o.point=t.contactOnA.position,o.distance=a,o.impulse=t.impulseApplied,o.normal=t.contactOnA.normal,this.onCollisionObservable.notifyObservers(o)}if(this._bodyCollisionObservable.size&&o.type!==xA.COLLISION_FINISHED){var s=this._bodyCollisionObservable.get(t.contactOnA.bodyId),l=this._bodyCollisionObservable.get(t.contactOnB.bodyId);s?s.notifyObservers(o):l&&(o.collider=n.body,o.colliderIndex=n.index,o.collidedAgainst=r.body,o.collidedAgainstIndex=r.index,o.normal=t.contactOnB.normal,l.notifyObservers(o))}else this._bodyCollisionEndedObservable.size&&(s=this._bodyCollisionEndedObservable.get(t.contactOnA.bodyId),l=this._bodyCollisionEndedObservable.get(t.contactOnB.bodyId),s?s.notifyObservers(o):l&&(o.collider=n.body,o.colliderIndex=n.index,o.collidedAgainst=r.body,o.collidedAgainstIndex=r.index,o.normal=t.contactOnB.normal,l.notifyObservers(o)))}e=this._hknp.HP_World_GetNextCollisionEvent(i,e)}},Object.defineProperty(e.prototype,"numBodies",{get:function(){return this._hknp.HP_World_GetNumBodies(this.world)[1]},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._hknp.HP_QueryCollector_Release(this._queryCollector),this._queryCollector=BigInt(0),this._hknp.HP_World_Release(this.world),this.world=void 0},e.prototype._v3ToBvecRef=function(e,t){t.set(e[0],e[1],e[2])},e.prototype._bVecToV3=function(e){return[e._x,e._y,e._z]},e.prototype._bQuatToV4=function(e){return[e._x,e._y,e._z,e._w]},e.prototype._constraintMotorTypeToNative=function(e){switch(e){case SA.POSITION:return this._hknp.ConstraintMotorType.POSITION;case SA.VELOCITY:return this._hknp.ConstraintMotorType.VELOCITY}return this._hknp.ConstraintMotorType.NONE},e.prototype._nativeToMotorType=function(e){switch(e){case this._hknp.ConstraintMotorType.POSITION:return SA.POSITION;case this._hknp.ConstraintMotorType.VELOCITY:return SA.VELOCITY}return SA.NONE},e.prototype._materialCombineToNative=function(e){switch(e){case PA.GEOMETRIC_MEAN:return this._hknp.MaterialCombine.GEOMETRIC_MEAN;case PA.MINIMUM:return this._hknp.MaterialCombine.MINIMUM;case PA.MAXIMUM:return this._hknp.MaterialCombine.MAXIMUM;case PA.ARITHMETIC_MEAN:return this._hknp.MaterialCombine.ARITHMETIC_MEAN;case PA.MULTIPLY:return this._hknp.MaterialCombine.MULTIPLY}},e.prototype._nativeToMaterialCombine=function(e){switch(e){case this._hknp.MaterialCombine.GEOMETRIC_MEAN:return PA.GEOMETRIC_MEAN;case this._hknp.MaterialCombine.MINIMUM:return PA.MINIMUM;case this._hknp.MaterialCombine.MAXIMUM:return PA.MAXIMUM;case this._hknp.MaterialCombine.ARITHMETIC_MEAN:return PA.ARITHMETIC_MEAN;case this._hknp.MaterialCombine.MULTIPLY:return PA.MULTIPLY;default:return}},e.prototype._constraintAxisToNative=function(e){switch(e){case bA.LINEAR_X:return this._hknp.ConstraintAxis.LINEAR_X;case bA.LINEAR_Y:return this._hknp.ConstraintAxis.LINEAR_Y;case bA.LINEAR_Z:return this._hknp.ConstraintAxis.LINEAR_Z;case bA.ANGULAR_X:return this._hknp.ConstraintAxis.ANGULAR_X;case bA.ANGULAR_Y:return this._hknp.ConstraintAxis.ANGULAR_Y;case bA.ANGULAR_Z:return this._hknp.ConstraintAxis.ANGULAR_Z;case bA.LINEAR_DISTANCE:return this._hknp.ConstraintAxis.LINEAR_DISTANCE}},e.prototype._nativeToLimitMode=function(e){switch(e){case this._hknp.ConstraintAxisLimitMode.FREE:return yA.FREE;case this._hknp.ConstraintAxisLimitMode.LIMITED:return yA.LIMITED;case this._hknp.ConstraintAxisLimitMode.LOCKED:return yA.LOCKED}return yA.FREE},e.prototype._limitModeToNative=function(e){switch(e){case yA.FREE:return this._hknp.ConstraintAxisLimitMode.FREE;case yA.LIMITED:return this._hknp.ConstraintAxisLimitMode.LIMITED;case yA.LOCKED:return this._hknp.ConstraintAxisLimitMode.LOCKED}},e.prototype._nativeCollisionValueToCollisionType=function(e){switch(e){case this._hknp.EventType.COLLISION_STARTED.value:return xA.COLLISION_STARTED;case this._hknp.EventType.COLLISION_FINISHED.value:return xA.COLLISION_FINISHED;case this._hknp.EventType.COLLISION_CONTINUED.value:return xA.COLLISION_CONTINUED}return xA.COLLISION_STARTED},e.prototype._nativeTriggerCollisionValueToCollisionType=function(e){switch(e){case 8:return xA.TRIGGER_ENTERED;case 16:return xA.TRIGGER_EXITED}return xA.TRIGGER_ENTERED},e}();pn.prototype.getPhysicsEngine=function(){return this._physicsEngine},pn.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var i=this._getComponent(Vr.NAME_PHYSICSENGINE);i||(i=new rC(this),this._addComponent(i));try{if(t&&1!==(null==t?void 0:t.getPluginVersion())){if(2!==(null==t?void 0:t.getPluginVersion()))throw new Error("Unsupported Physics plugin version.");this._physicsEngine=new RA(e,t)}else this._physicsEngine=new Fv(e,t);return this._physicsTimeAccumulator=0,!0}catch(e){return ae.Error(e.message),!1}},pn.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},pn.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},pn.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},pn.prototype._advancePhysicsEngineStep=function(e){if(this._physicsEngine){var t=this._physicsEngine.getSubTimeStep();if(t>0)for(this._physicsTimeAccumulator+=e;this._physicsTimeAccumulator>t;)this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(t/1e3),this.onAfterPhysicsObservable.notifyObservers(this),this._physicsTimeAccumulator-=t;else this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this)}};var rC=function(){function e(e){var t=this;this.name=Vr.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new f,this.scene.onAfterPhysicsObservable=new f,this.scene.getDeterministicFrameTime=function(){return t.scene._physicsEngine?1e3*t.scene._physicsEngine.getTimeStep():1e3/60}}return e.prototype.register=function(){},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},e}();Object.defineProperty(Fo.prototype,"physicsBody",{get:function(){return this._physicsBody},set:function(e){var t=this;this._physicsBody!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsBody=e,e&&(this._disposePhysicsObserver=this.onDisposeObservable.add((function(){t.physicsBody&&(t.physicsBody.dispose(),t.physicsBody=null)}))))},enumerable:!0,configurable:!0}),Fo.prototype.getPhysicsBody=function(){return this.physicsBody},Fo.prototype.applyImpulse=function(e,t){if(!this.physicsBody)throw new Error("No Physics Body for TransformNode");return this.physicsBody.applyImpulse(e,t),this},Fo.prototype.applyAngularImpulse=function(e){if(!this.physicsBody)throw new Error("No Physics Body for TransformNode");return this.physicsBody.applyAngularImpulse(e),this};var nC,oC,aC=function(){function e(){}return e.GetContactPointToRef=function(e,t,i,r,n){var o=e.getScene().getPhysicsEngine(),a=null==o?void 0:o.getPluginVersion();if(1===a){var s=new hs(t,i).intersectsMesh(e);if(s.hit&&s.pickedPoint)return r.copyFrom(s.pickedPoint),!0}else if(2===a)return e.physicsBody.getObjectCenterWorldToRef(r,n),!0;return!1},e.HasAppliedForces=function(e,t){var i,r,n;return e.getMotionType(t)===AA.STATIC||0===(null!==(r=null===(i=e.getMassProperties(t))||void 0===i?void 0:i.mass)&&void 0!==r?r:0)||0===(null===(n=e.transformNode)||void 0===n?void 0:n.getTotalVertices())},e.IsInsideCylinder=function(e,t,i,r){var n=H.Vector3[0];return e.subtractToRef(t,n),Math.abs(n.x)<=i&&Math.abs(n.z)<=i&&n.y>=0&&n.y<=r},e}(),sC=function(){function e(e){this._hitData={force:new V,contactPoint:new V,distanceFromOrigin:0},this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||ae.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return e.prototype.applyRadialExplosionImpulse=function(e,t,i,r){var n=this;if(!this._physicsEngine)return ae.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;if(1===this._physicsEngine.getPluginVersion()&&0===this._physicsEngine.getImpostors().length)return null;if(2===this._physicsEngine.getPluginVersion()&&0===this._physicsEngine.getBodies().length)return null;var o=!1;if("number"==typeof t){var a=t;(t=new dC).radius=a,t.strength=null!=i?i:t.strength,t.falloff=null!=r?r:t.falloff}else o=!(!t.affectedImpostorsCallback&&!t.affectedBodiesCallback);var s=new lC(this._scene,t),l=this._hitData;if(1===this._physicsEngine.getPluginVersion()){var c=Array();this._physicsEngine.getImpostors().forEach((function(t){s.getImpostorHitData(t,e,l)&&(t.applyImpulse(l.force,l.contactPoint),o&&c.push({impostor:t,hitData:n._copyPhysicsHitData(l)}))})),s.triggerAffectedImpostorsCallback(c)}else this._applicationForBodies(s,e,l,o,(function(e,t){e.applyImpulse(t.force,t.contactPoint,t.instanceIndex)}));return s.dispose(!1),s},e.prototype.applyRadialExplosionForce=function(e,t,i,r){var n=this;if(!this._physicsEngine)return ae.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(1===this._physicsEngine.getPluginVersion()&&0===this._physicsEngine.getImpostors().length)return null;if(2===this._physicsEngine.getPluginVersion()&&0===this._physicsEngine.getBodies().length)return null;var o=!1;if("number"==typeof t){var a=t;(t=new dC).radius=a,t.strength=null!=i?i:t.strength,t.falloff=null!=r?r:t.falloff}else o=!(!t.affectedImpostorsCallback&&!t.affectedBodiesCallback);var s=new lC(this._scene,t),l=this._hitData;if(1===this._physicsEngine.getPluginVersion()){var c=Array();this._physicsEngine.getImpostors().forEach((function(t){s.getImpostorHitData(t,e,l)&&(t.applyForce(l.force,l.contactPoint),o&&c.push({impostor:t,hitData:n._copyPhysicsHitData(l)}))})),s.triggerAffectedImpostorsCallback(c)}else this._applicationForBodies(s,e,l,o,(function(e,t){e.applyForce(t.force,t.contactPoint,t.instanceIndex)}));return s.dispose(!1),s},e.prototype._applicationForBodies=function(e,t,i,r,n){for(var o=this,a=Array(),s=0,l=this._physicsEngine.getBodies();sthis._options.radius)return!1;var s=this._options.falloff===nC.Constant?this._options.strength:this._options.strength*(1-a/this._options.radius);return n.scaleInPlace(s),r.force.copyFrom(n),r.contactPoint.copyFrom(o),r.distanceFromOrigin=a,!0},e.prototype.getBodyHitData=function(e,t,i,r){if(aC.HasAppliedForces(e,r))return!1;var n=e.transformNode,o=e.getObjectCenterWorld(r);return i.instanceIndex=r,this._getHitData(n,o,t,i)},e.prototype.getImpostorHitData=function(e,t,i){if(0===e.mass)return!1;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return!1;var r=e.object;if(!this._intersectsWithSphere(r,t,this._options.radius))return!1;var n=e.getObjectCenter();return this._getHitData(r,n,t,i),!0},e.prototype.triggerAffectedImpostorsCallback=function(e){this._options.affectedImpostorsCallback&&this._options.affectedImpostorsCallback(e)},e.prototype.triggerAffectedBodiesCallback=function(e){this._options.affectedBodiesCallback&&this._options.affectedBodiesCallback(e)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._sphere&&(e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0))},e.prototype._prepareSphere=function(){this._sphere||(this._sphere=Gh("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,i){return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling.setAll(2*i),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(e,!0)},e}(),cC=function(){function e(e,t,i,r){var n=this;this._physicsHelper=e,this._scene=t,this._origin=i,this._options=r,this._dataFetched=!1,this._options=g(g({},new dC),this._options),this._tickCallback=function(){return n._tick()},this._options.strength=-1*this._options.strength}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._sphere&&(e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0))},e.prototype._tick=function(){var e;if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);else{var t=this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);t&&(this._sphere=null===(e=t.getData().sphere)||void 0===e?void 0:e.clone("radialExplosionEventSphereClone"))}},e}(),uC=function(){function e(e,t,i){var r=this;this._scene=e,this._origin=t,this._options=i,this._originTop=V.Zero(),this._originDirection=V.Zero(),this._cylinderPosition=V.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=g(g({},new pC),this._options),this._origin.addToRef(new V(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new V(0,this._options.height,0),this._originTop),this._options.updraftMode===oC.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=function(){return r._tick()},1===this._physicsEngine.getPluginVersion()&&this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._cylinder&&(e?(this._cylinder.dispose(),this._cylinder=void 0):setTimeout((function(){!t._dataFetched&&t._cylinder&&(t._cylinder.dispose(),t._cylinder=void 0)}),0))},e.prototype._getHitData=function(e,t){var i;i=this._options.updraftMode===oC.Perpendicular?this._originDirection:e.subtract(this._originTop);var r=V.Distance(this._origin,e),n=-1*this._options.strength,o=i.multiplyByFloats(n,n,n);t.force.copyFrom(o),t.contactPoint.copyFrom(e),t.distanceFromOrigin=r},e.prototype._getBodyHitData=function(e,t,i){if(aC.HasAppliedForces(e))return!1;var r=e.getObjectCenterWorld(i);return!!aC.IsInsideCylinder(r,this._origin,this._options.radius,this._options.height)&&(t.instanceIndex=i,this._getHitData(r,t),!0)},e.prototype._getImpostorHitData=function(e,t){if(0===e.mass)return!1;var i=e.object;if(!this._intersectsWithCylinder(i))return!1;var r=e.getObjectCenter();return this._getHitData(r,t),!0},e.prototype._tick=function(){var t=this,i=e._HitData;1===this._physicsEngine.getPluginVersion()?this._physicsEngine.getImpostors().forEach((function(e){t._getImpostorHitData(e,i)&&e.applyForce(i.force,i.contactPoint)})):this._physicsEngine.getBodies().forEach((function(e){e.iterateOverAllInstances((function(e,r){t._getBodyHitData(e,i,r)&&e.applyForce(i.force,i.contactPoint,i.instanceIndex)}))}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=xh("updraftEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){return!!this._cylinder&&(this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(e,!0))},e._HitData={force:new V,contactPoint:new V,distanceFromOrigin:0},e}(),hC=function(){function e(e,t,i){var r=this;this._scene=e,this._origin=t,this._options=i,this._originTop=V.Zero(),this._cylinderPosition=V.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=g(g({},new fC),this._options),this._origin.addToRef(new V(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new V(0,this._options.height,0),this._originTop),this._tickCallback=function(){return r._tick()},1===this._physicsEngine.getPluginVersion()&&this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._cylinder&&(e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0))},e.prototype._getHitData=function(t,i,r){var n=e._OriginOnPlane;n.set(this._origin.x,i.y,this._origin.z);var o=H.Vector3[0];i.subtractToRef(n,o);var a=H.Vector3[1];if(!aC.GetContactPointToRef(t,n,o,a,r.instanceIndex))return!1;var s,l,c,u=V.Distance(a,n)/this._options.radius,h=H.Vector3[2];if(a.normalizeToRef(h),u>this._options.centripetalForceThreshold&&h.negateInPlace(),u>this._options.centripetalForceThreshold)s=h.x*this._options.centripetalForceMultiplier,l=h.y*this._options.updraftForceMultiplier,c=h.z*this._options.centripetalForceMultiplier;else{var d=V.Cross(n,i).normalize();s=(d.x+h.x)*this._options.centrifugalForceMultiplier,l=this._originTop.y*this._options.updraftForceMultiplier,c=(d.z+h.z)*this._options.centrifugalForceMultiplier}var p=H.Vector3[3];return p.set(s,l,c),p.scaleInPlace(this._options.strength),r.force.copyFrom(p),r.contactPoint.copyFrom(i),r.distanceFromOrigin=u,!0},e.prototype._getBodyHitData=function(e,t,i){if(aC.HasAppliedForces(e,i))return!1;var r=e.transformNode,n=e.getObjectCenterWorld(i);return!!aC.IsInsideCylinder(n,this._origin,this._options.radius,this._options.height)&&(t.instanceIndex=i,this._getHitData(r,n,t))},e.prototype._getImpostorHitData=function(e,t){if(0===e.mass)return!1;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return!1;var i=e.object;if(!this._intersectsWithCylinder(i))return!1;var r=e.getObjectCenter();return this._getHitData(i,r,t),!0},e.prototype._tick=function(){var t=this,i=e._HitData;1===this._physicsEngine.getPluginVersion()?this._physicsEngine.getImpostors().forEach((function(e){t._getImpostorHitData(e,i)&&e.applyForce(i.force,i.contactPoint)})):this._physicsEngine.getBodies().forEach((function(e){e.iterateOverAllInstances((function(e,r){t._getBodyHitData(e,i,r)&&e.applyForce(i.force,i.contactPoint,i.instanceIndex)}))}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=xh("vortexEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(e,!0)},e._OriginOnPlane=V.Zero(),e._HitData={force:new V,contactPoint:new V,distanceFromOrigin:0},e}(),dC=function(){this.radius=5,this.strength=10,this.falloff=nC.Constant,this.sphere={segments:32,diameter:1}},pC=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=oC.Center},fC=function(){this.radius=5,this.strength=10,this.height=10,this.centripetalForceThreshold=.7,this.centripetalForceMultiplier=5,this.centrifugalForceMultiplier=.5,this.updraftForceMultiplier=.02};!function(e){e[e.Constant=0]="Constant",e[e.Linear=1]="Linear"}(nC||(nC={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(oC||(oC={}));var _C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._hitDistance=0,t}return m(t,e),Object.defineProperty(t.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),t.prototype.setHitDistance=function(e){this._hitDistance=e},t.prototype.reset=function(){e.prototype.reset.call(this),this._hitDistance=0},t}(Dv),mC=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._hitFraction=0,t}return m(t,e),Object.defineProperty(t.prototype,"hitFraction",{get:function(){return this._hitFraction},enumerable:!1,configurable:!0}),t.prototype.setHitFraction=function(e){this._hitFraction=e},t}(Dv);li.ShadersStore.blackAndWhitePixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform float degree;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{vec3 color=texture2D(textureSampler,vUV).rgb;float luminance=dot(color,vec3(0.3,0.59,0.11)); \nvec3 blackAndWhite=vec3(luminance,luminance,luminance);gl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);}";var gC=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,"blackAndWhite",["degree"],null,i,r,n,o,a)||this;return s.degree=1,s.onApplyObservable.add((function(e){e.setFloat("degree",s.degree)})),s}return m(t,e),t.prototype.getClassName=function(){return"BlackAndWhitePostProcess"},t._Parse=function(e,i,r,n){return Ke.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.reusable)}),e,r,n)},v([Ie()],t.prototype,"degree",void 0),t}(hl);a("BABYLON.BlackAndWhitePostProcess",gC);var vC=function(){function e(e,t,i,r){this._name=t,this._singleInstance=r||!0,this._getPostProcesses=i,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(e.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(Object.prototype.hasOwnProperty.call(this._postProcesses,e))for(var t=this._postProcesses[e],i=0;i1?u.TEXTUREFORMAT_RED:u.TEXTUREFORMAT_RGBA;a._circleOfConfusion=new SC("circleOfConfusion",i,1,null,Ja.BILINEAR_SAMPLINGMODE,s,!1,n,o),a._depthOfFieldBlurY=[],a._depthOfFieldBlurX=[];var c=1,h=15;switch(r){case RC.High:c=3,h=51;break;case RC.Medium:c=2,h=31;break;default:h=15,c=1}for(var d=h/Math.pow(2,c-1),p=1,f=0;f-1?"#define MALI 1\n":null},t._Parse=function(e,i,r,n){return Ke.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.reusable)}),e,r,n)},t}(hl);a("BABYLON.FxaaPostProcess",DC);li.ShadersStore.grainPixelShader="#include\nuniform sampler2D textureSampler; \nuniform float intensity;uniform float animatedSeed;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(textureSampler,vUV);vec2 seed=vUV*(animatedSeed);float grain=dither(seed,intensity);float lum=getLuminance(gl_FragColor.rgb);float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;gl_FragColor.rgb+=grain*grainAmount;gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);}";var NC=function(e){function t(t,i,r,n,o,a,s,l){void 0===s&&(s=u.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1);var c=e.call(this,t,"grain",["intensity","animatedSeed"],[],i,r,n,o,a,null,s,void 0,null,l)||this;return c.intensity=30,c.animated=!1,c.onApplyObservable.add((function(e){e.setFloat("intensity",c.intensity),e.setFloat("animatedSeed",c.animated?Math.random()+1:1)})),c}return m(t,e),t.prototype.getClassName=function(){return"GrainPostProcess"},t._Parse=function(e,i,r,n){return Ke.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.reusable)}),e,r,n)},v([Ie()],t.prototype,"intensity",void 0),v([Ie()],t.prototype,"animated",void 0),t}(hl);a("BABYLON.GrainPostProcess",NC);li.ShadersStore.highlightsPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;const vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{vec4 tex=texture2D(textureSampler,vUV);vec3 c=tex.rgb;float luma=dot(c.rgb,RGBLuminanceCoefficients);gl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); }";var FC=function(e){function t(t,i,r,n,o,a,s){return void 0===s&&(s=u.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,"highlights",null,null,i,r,n,o,a,null,s)||this}return m(t,e),t.prototype.getClassName=function(){return"HighlightsPostProcess"},t}(hl);li.ShadersStore.imageProcessingPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;}";var LC=function(e){function t(t,i,r,n,o,a,s,l){void 0===r&&(r=null),void 0===s&&(s=u.TEXTURETYPE_UNSIGNED_INT);var c=e.call(this,t,"imageProcessing",[],[],i,r,n,o,a,null,s,"postprocess",null,!0)||this;return c._fromLinearSpace=!0,c._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:0,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,DITHER:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1,SKIPFINALCOLORCLAMP:!1},l?(l.applyByPostProcess=!0,c._attachImageProcessingConfiguration(l,!0),c._updateParameters()):(c._attachImageProcessingConfiguration(null,!0),c.imageProcessingConfiguration.applyByPostProcess=!0),c.onApply=function(e){c.imageProcessingConfiguration.bind(e,c.aspectRatio)},c}return m(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,t){var i=this;if(void 0===t&&(t=!1),e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{var r=null,n=this.getEngine(),o=this.getCamera();if(o)r=o.getScene();else if(n&&n.scenes){var a=n.scenes;r=a[a.length-1]}else r=M.LastCreatedScene;this._imageProcessingConfiguration=r?r.imageProcessingConfiguration:new pr}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){i._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(t.prototype,"isSupported",{get:function(){var e=this.getEffect();return!e||e.isSupported},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingType",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCenterX},set:function(e){this.imageProcessingConfiguration.vignetteCenterX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCenterY},set:function(e){this.imageProcessingConfiguration.vignetteCenterY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCenterY",{get:function(){return this.imageProcessingConfiguration.vignetteCenterY},set:function(e){this.imageProcessingConfiguration.vignetteCenterY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCenterX",{get:function(){return this.imageProcessingConfiguration.vignetteCenterX},set:function(e){this.imageProcessingConfiguration.vignetteCenterX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ditheringIntensity",{get:function(){return this.imageProcessingConfiguration.ditheringIntensity},set:function(e){this.imageProcessingConfiguration.ditheringIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ditheringEnabled",{get:function(){return this.imageProcessingConfiguration.ditheringEnabled},set:function(e){this.imageProcessingConfiguration.ditheringEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"ImageProcessingPostProcess"},t.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var e="";for(var t in this._defines){var i=this._defines[t];switch(typeof i){case"number":case"string":e+="#define ".concat(t," ").concat(i,";\n");break;default:i&&(e+="#define ".concat(t,";\n"))}}var r=["textureSampler"],n=["scale"];pr&&(pr.PrepareSamplers(r,this._defines),pr.PrepareUniforms(n,this._defines)),this.updateEffect(e,n,r)},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},v([Ie()],t.prototype,"_fromLinearSpace",void 0),t}(hl);li.IncludesShadersStore.mrtFragmentDeclaration="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";li.ShadersStore.geometryPixelShader="#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#ifdef BUMP\nvarying mat4 vWorldView;varying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIVITY)\n#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nuniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;\n#endif\n#ifdef ALBEDOTEXTURE\nvarying vec2 vAlbedoUV;uniform sampler2D albedoSampler;\n#endif\n#ifdef REFLECTIVITYCOLOR\nuniform vec3 reflectivityColor;\n#endif\n#ifdef ALBEDOCOLOR\nuniform vec3 albedoColor;\n#endif\n#ifdef METALLIC\nuniform float metallic;\n#endif\n#if defined(ROUGHNESS) || defined(GLOSSINESS)\nuniform float glossiness;\n#endif\n#endif\n#if defined(ALPHATEST) && defined(NEED_UV)\nuniform sampler2D diffuseSampler;\n#endif\n#include\n#include[RENDER_TARGET_COUNT]\n#include\n#include\n#include\nvoid main() {\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include\n#ifdef NORMAL_WORLDSPACE\nnormalOutput=normalW;\n#else\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#endif\n#else\nnormalOutput=normalize(vNormalV);\n#endif\n#ifdef ENCODE_NORMAL\nnormalOutput=normalOutput*0.5+0.5;\n#endif\n#ifdef PREPASS\n#ifdef PREPASS_DEPTH\ngl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);\n#endif\n#else\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);gl_FragData[1]=vec4(normalOutput,1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#ifdef METALLICWORKFLOW\nfloat metal=1.0;float roughness=1.0;\n#ifdef ORMTEXTURE\nmetal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;\n#endif\n#ifdef METALLIC\nmetal*=metallic;\n#endif\n#ifdef ROUGHNESS\nroughness*=(1.0-glossiness); \n#endif\nreflectivity.a-=roughness;vec3 color=vec3(1.0);\n#ifdef ALBEDOTEXTURE\ncolor=texture2D(albedoSampler,vAlbedoUV).rgb;\n#ifdef GAMMAALBEDO\ncolor=toLinearSpace(color);\n#endif\n#endif\n#ifdef ALBEDOCOLOR\ncolor*=albedoColor.xyz;\n#endif\nreflectivity.rgb=mix(vec3(0.04),color,metal);\n#else\n#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nreflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#ifdef GAMMAREFLECTIVITYTEXTURE\nreflectivity.rgb=toLinearSpace(reflectivity.rgb);\n#endif\n#else \n#ifdef REFLECTIVITYCOLOR\nreflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;\n#endif\n#endif\n#ifdef GLOSSINESSS\nreflectivity.a*=glossiness; \n#endif\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}\n";li.IncludesShadersStore.geometryVertexDeclaration="uniform mat4 viewProjection;uniform mat4 view;";li.IncludesShadersStore.geometryUboDeclaration="#include\n";li.ShadersStore.geometryVertexShader="precision highp float;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include<__decl__geometryVertex>\n#include\nattribute vec3 position;attribute vec3 normal;\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;varying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;uniform mat4 albedoMatrix;varying vec2 vReflectivityUV;varying vec2 vAlbedoUV;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;vec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include\n#include\nvec4 worldPos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;vNormalW=normalUpdated;\n#else\n#ifdef NORMAL_WORLDSPACE\nvNormalV=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\n#endif\nvViewPos=view*worldPos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP)\nvPositionW=worldPos.xyz/worldPos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#include\n#ifdef NEED_UV\n#ifdef UV1\n#if defined(ALPHATEST) && defined(ALPHATEST_UV1)\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uv;\n#endif\n#ifdef BUMP_UV1\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV1\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef ALBEDO_UV1\nvAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#if defined(ALPHATEST) && defined(ALPHATEST_UV2)\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#else\nvUV=uv2;\n#endif\n#ifdef BUMP_UV2\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV2\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef ALBEDO_UV2\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#endif\n#include\n}\n";var wC=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","boneTextureWidth"];Go(wC);var BC=function(){function e(t,i,r,n){void 0===i&&(i=1),void 0===r&&(r=u.TEXTUREFORMAT_DEPTH16),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this.generateNormalsInWorldSpace=!1,this._normalsAreUnsigned=!1,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._clearColor=new J(0,0,0,0),this._clearDepthColor=new J(1e8,0,0,1),this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthIndex=-1,this._normalIndex=-1,this._linkedWithPrePass=!1,this.useSpecificClearForDepthTexture=!1,this._scene=t,this._ratioOrDimensions=i,this._useUbo=t.getEngine().supportsUniformBuffers,this._depthFormat=r,this._textureTypesAndFormats=n||{},e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return Object.defineProperty(e.prototype,"normalsAreUnsigned",{get:function(){return this._normalsAreUnsigned},enumerable:!1,configurable:!0}),e.prototype._linkPrePassRenderer=function(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add((function(){})))},e.prototype._unlinkPrePassRenderer=function(){this._linkedWithPrePass=!1,this._createRenderTargets()},e.prototype._resetLayout=function(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachmentsFromPrePass=[]},e.prototype._forceTextureType=function(t,i){t===e.POSITION_TEXTURE_TYPE?(this._positionIndex=i,this._enablePosition=!0):t===e.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=i,this._enableVelocity=!0):t===e.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=i,this._enableReflectivity=!0):t===e.DEPTH_TEXTURE_TYPE?this._depthIndex=i:t===e.NORMAL_TEXTURE_TYPE&&(this._normalIndex=i)},e.prototype._setAttachments=function(e){this._attachmentsFromPrePass=e},e.prototype._linkInternalTexture=function(e){this._multiRenderTarget.setInternalTexture(e,0,!1)},Object.defineProperty(e.prototype,"renderList",{get:function(){return this._multiRenderTarget.renderList},set:function(e){this._multiRenderTarget.renderList=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!1,configurable:!0}),e.prototype.getTextureIndex=function(t){switch(t){case e.POSITION_TEXTURE_TYPE:return this._positionIndex;case e.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case e.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;case e.DEPTH_TEXTURE_TYPE:return this._linkedWithPrePass?this._depthIndex:0;case e.NORMAL_TEXTURE_TYPE:return this._linkedWithPrePass?this._normalIndex:1;default:return-1}},Object.defineProperty(e.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets()),this._scene.needsPreviousWorldMatrices=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableReflectivity",{get:function(){return this._enableReflectivity},set:function(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return"object"==typeof this._ratioOrDimensions?1:this._ratioOrDimensions},enumerable:!1,configurable:!0}),e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;var r=[],n=[Nr.PositionKind,Nr.NormalKind],o=e.getMesh();if(i){var a=!1;if(i.needAlphaTesting()&&i.getAlphaTestTexture()&&(r.push("#define ALPHATEST"),r.push("#define ALPHATEST_UV".concat(i.getAlphaTestTexture().coordinatesIndex+1)),a=!0),i.bumpTexture&&xu.BumpTextureEnabled&&(r.push("#define BUMP"),r.push("#define BUMP_UV".concat(i.bumpTexture.coordinatesIndex+1)),a=!0),this._enableReflectivity){var s=!1;"PBRMetallicRoughnessMaterial"===i.getClassName()?(i.metallicRoughnessTexture&&(r.push("#define ORMTEXTURE"),r.push("#define REFLECTIVITY_UV".concat(i.metallicRoughnessTexture.coordinatesIndex+1)),r.push("#define METALLICWORKFLOW"),a=!0,s=!0),null!=i.metallic&&(r.push("#define METALLIC"),r.push("#define METALLICWORKFLOW"),s=!0),null!=i.roughness&&(r.push("#define ROUGHNESS"),r.push("#define METALLICWORKFLOW"),s=!0),s&&(i.baseTexture&&(r.push("#define ALBEDOTEXTURE"),r.push("#define ALBEDO_UV".concat(i.baseTexture.coordinatesIndex+1)),i.baseTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),a=!0),i.baseColor&&r.push("#define ALBEDOCOLOR"))):"PBRSpecularGlossinessMaterial"===i.getClassName()?(i.specularGlossinessTexture?(r.push("#define SPECULARGLOSSINESSTEXTURE"),r.push("#define REFLECTIVITY_UV".concat(i.specularGlossinessTexture.coordinatesIndex+1)),a=!0,i.specularGlossinessTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE")):i.specularColor&&r.push("#define REFLECTIVITYCOLOR"),null!=i.glossiness&&r.push("#define GLOSSINESS")):"PBRMaterial"===i.getClassName()?(i.metallicTexture&&(r.push("#define ORMTEXTURE"),r.push("#define REFLECTIVITY_UV".concat(i.metallicTexture.coordinatesIndex+1)),r.push("#define METALLICWORKFLOW"),a=!0,s=!0),null!=i.metallic&&(r.push("#define METALLIC"),r.push("#define METALLICWORKFLOW"),s=!0),null!=i.roughness&&(r.push("#define ROUGHNESS"),r.push("#define METALLICWORKFLOW"),s=!0),s?(i.albedoTexture&&(r.push("#define ALBEDOTEXTURE"),r.push("#define ALBEDO_UV".concat(i.albedoTexture.coordinatesIndex+1)),i.albedoTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),a=!0),i.albedoColor&&r.push("#define ALBEDOCOLOR")):(i.reflectivityTexture?(r.push("#define SPECULARGLOSSINESSTEXTURE"),r.push("#define REFLECTIVITY_UV".concat(i.reflectivityTexture.coordinatesIndex+1)),i.reflectivityTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE"),a=!0):i.reflectivityColor&&r.push("#define REFLECTIVITYCOLOR"),null!=i.microSurface&&r.push("#define GLOSSINESS"))):"StandardMaterial"===i.getClassName()&&(i.specularTexture&&(r.push("#define REFLECTIVITYTEXTURE"),r.push("#define REFLECTIVITY_UV".concat(i.specularTexture.coordinatesIndex+1)),i.specularTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE"),a=!0),i.specularColor&&r.push("#define REFLECTIVITYCOLOR"))}a&&(r.push("#define NEED_UV"),o.isVerticesDataPresent(Nr.UVKind)&&(n.push(Nr.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(Nr.UV2Kind)&&(n.push(Nr.UV2Kind),r.push("#define UV2")))}this._linkedWithPrePass&&(r.push("#define PREPASS"),-1!==this._depthIndex&&(r.push("#define DEPTH_INDEX "+this._depthIndex),r.push("#define PREPASS_DEPTH")),-1!==this._normalIndex&&(r.push("#define NORMAL_INDEX "+this._normalIndex),r.push("#define PREPASS_NORMAL"))),this._enablePosition&&(r.push("#define POSITION"),r.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(r.push("#define VELOCITY"),r.push("#define VELOCITY_INDEX "+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(o)&&r.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(r.push("#define REFLECTIVITY"),r.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),this.generateNormalsInWorldSpace&&r.push("#define NORMAL_WORLDSPACE"),this._normalsAreUnsigned&&r.push("#define ENCODE_NORMAL"),o.useBones&&o.computeBonesUsingShaders&&o.skeleton?(n.push(Nr.MatricesIndicesKind),n.push(Nr.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(Nr.MatricesIndicesExtraKind),n.push(Nr.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BONETEXTURE "+o.skeleton.isUsingTextureForMatrices),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):(r.push("#define NUM_BONE_INFLUENCERS 0"),r.push("#define BONETEXTURE false"),r.push("#define BonesPerMesh 0"));var l=o.morphTargetManager,c=0;l&&(c=l.numMaxInfluencers||l.numInfluencers)>0&&(r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+c),l.isUsingTextureForTargets&&r.push("#define MORPHTARGETS_TEXTURE"),qo(n,o,c)),t&&(r.push("#define INSTANCES"),Jo(n,this._enableVelocity),e.getRenderingMesh().hasThinInstances&&r.push("#define THIN_INSTANCES")),this._linkedWithPrePass?r.push("#define RENDER_TARGET_COUNT "+this._attachmentsFromPrePass.length):r.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length),zo(i,this._scene,r);var u=this._scene.getEngine(),h=e._getDrawWrapper(void 0,!0),d=h.defines,p=r.join("\n");return d!==p&&h.setEffect(u.createEffect("geometry",{attributes:n,uniformsNames:wC,samplers:["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets","boneSampler"],defines:p,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:c}},u),p),h.effect.isReady()},e.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(e.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.getGBuffer().dispose()},e.prototype._assignRenderTargetIndices=function(){var t=[],i=[],r=2;return t.push("gBuffer_Depth","gBuffer_Normal"),i.push(this._textureTypesAndFormats[e.DEPTH_TEXTURE_TYPE]),i.push(this._textureTypesAndFormats[e.NORMAL_TEXTURE_TYPE]),this._enablePosition&&(this._positionIndex=r,r++,t.push("gBuffer_Position"),i.push(this._textureTypesAndFormats[e.POSITION_TEXTURE_TYPE])),this._enableVelocity&&(this._velocityIndex=r,r++,t.push("gBuffer_Velocity"),i.push(this._textureTypesAndFormats[e.VELOCITY_TEXTURE_TYPE])),this._enableReflectivity&&(this._reflectivityIndex=r,r++,t.push("gBuffer_Reflectivity"),i.push(this._textureTypesAndFormats[e.REFLECTIVITY_TEXTURE_TYPE])),[r,t,i]},e.prototype._createRenderTargets=function(){var t,i=this,r=this._scene.getEngine(),n=(t=this._assignRenderTargetIndices())[0],o=t[1],a=t[2],s=u.TEXTURETYPE_UNSIGNED_BYTE;r._caps.textureFloat&&r._caps.textureFloatLinearFiltering?s=u.TEXTURETYPE_FLOAT:r._caps.textureHalfFloat&&r._caps.textureHalfFloatLinearFiltering&&(s=u.TEXTURETYPE_HALF_FLOAT);for(var l=void 0!==this._ratioOrDimensions.width?this._ratioOrDimensions:{width:r.getRenderWidth()*this._ratioOrDimensions,height:r.getRenderHeight()*this._ratioOrDimensions},c=[],h=[],d=0,p=a;d-1){var v=g.getTransformMatrixTexture(t);d.setTexture("boneSampler",v),d.setFloat("boneTextureWidth",4*(g.bones.length+1))}else d.setMatrices("mBones",t.skeleton.getTransformMatrices(t));i._enableVelocity&&d.setMatrices("mPreviousBones",i._previousBonesTransformationMatrices[t.uniqueId])}$o(t,d),t.morphTargetManager&&t.morphTargetManager.isUsingTextureForTargets&&t.morphTargetManager._bind(d),i._enableVelocity&&(d.setMatrix("previousWorld",i._previousTransformationMatrices[r.uniqueId].world),d.setMatrix("previousViewProjection",i._previousTransformationMatrices[r.uniqueId].viewProjection)),c&&t.hasThinInstances&&d.setMatrix("world",u),t._processRendering(r,e,d,a.fillMode,l,c,(function(e,t){e||d.setMatrix("world",t)}))}i._enableVelocity&&(i._previousTransformationMatrices[r.uniqueId].world=u.clone(),i._previousTransformationMatrices[r.uniqueId].viewProjection=i._scene.getTransformMatrix().clone(),t.skeleton&&i._copyBonesTransformationMatrices(t.skeleton.getTransformMatrices(t),i._previousBonesTransformationMatrices[r.uniqueId]))}}};this._multiRenderTarget.customIsReadyFunction=function(e,t,n){if((n||0===t)&&e.subMeshes)for(var o=0;o0){var i=this._renderEffects[t[0]].getPostProcesses();i&&(i[0].samples=e)}return!0},e.prototype._adaptPostProcessesToViewPort=function(){for(var e=0,t=Object.keys(this._renderEffects);e1){for(var i=0,r=this._cameras;i-1&&(e.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())}))}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var o=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=o.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new LC("imageProcessing",1,null,Ja.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),this._hdr?(this.addEffect(new vC(t,this.ImageProcessingPostProcessId,(function(){return e.imageProcessing}),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this._cameras&&0!==this._cameras.length||(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new DC("fxaa",1,null,Ja.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new vC(t,this.FxaaPostProcessId,(function(){return e.fxaa}),!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),(this._scene.activeCameras&&this._scene.activeCameras.length>1||this._scene.activeCamera&&-1===this._cameras.indexOf(this._scene.activeCamera))&&(this._scene.autoClear=!0),this._activeCameraChangedObserver||(this._activeCameraChangedObserver=this._scene.onActiveCameraChanged.add((function(){e._scene.activeCamera&&-1===e._cameras.indexOf(e._scene.activeCamera)&&(e._scene.autoClear=!0)}))),this._activeCamerasChangedObserver||(this._activeCamerasChangedObserver=this._scene.onActiveCamerasChanged.add((function(){e._scene.activeCameras&&e._scene.activeCameras.length>1&&(e._scene.autoClear=!0)}))),this._adaptPostProcessesToViewPort(),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&ae.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}},t.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);vec3 tangent=normalize(rvec-normal*dot(rvec,normal));vec3 bitangent=cross(normal,tangent);mat3 tbn=mat3(tangent,bitangent,normal);float difference;for (int i=0; i1.0 || offset.y>1.0) {continue;}\nfloat sampleDepth=abs(textureLod(depthSampler,offset.xy,0.0).r);difference=depthSign*samplePosition.z-sampleDepth;float rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);occlusion+=step(EPSILON,difference)*rangeCheck;}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));float ao=1.0-totalStrength*occlusion*samplesFactor;float result=clamp(ao+base,0.0,1.0);gl_FragColor=vec4(vec3(result),1.0);}\n#endif\n#ifdef BLUR\nuniform float outSize;uniform float soften;uniform float tolerance;uniform int samples;\n#ifndef BLUR_BYPASS\nuniform sampler2D depthSampler;\n#ifdef BLUR_LEGACY\n#define inline\nfloat blur13Bilateral(sampler2D image,vec2 uv,vec2 step) {float result=0.0;vec2 off1=vec2(1.411764705882353)*step;vec2 off2=vec2(3.2941176470588234)*step;vec2 off3=vec2(5.176470588235294)*step;float compareDepth=abs(textureLod(depthSampler,uv,0.0).r);float sampleDepth;float weight;float weightSum=30.0;result+=textureLod(image,uv,0.0).r*30.0;sampleDepth=abs(textureLod(depthSampler,uv+off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureLod(image,uv+off1,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureLod(image,uv-off1,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv+off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv+off2,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv-off2,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv+off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv+off3,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv-off3,0.0).r*weight;return result/weightSum;}\n#endif\n#endif\nvoid main()\n{float result=0.0;\n#ifdef BLUR_BYPASS\nresult=textureLod(textureSampler,vUV,0.0).r;\n#else\n#ifdef BLUR_H\nvec2 step=vec2(1.0/outSize,0.0);\n#else\nvec2 step=vec2(0.0,1.0/outSize);\n#endif\n#ifdef BLUR_LEGACY\nresult=blur13Bilateral(textureSampler,vUV,step);\n#else\nfloat compareDepth=abs(textureLod(depthSampler,vUV,0.0).r);float weightSum=0.0;for (int i=-samples; i0?t:i),e.setInt("samples",a.bilateralSamples),e.setFloat("soften",a.bilateralSoften),e.setFloat("tolerance",a.bilateralTolerance),a._geometryBufferRenderer?e.setTexture("depthSampler",a._geometryBufferRenderer.getGBuffer().textures[0]):a._prePassRenderer&&e.setTexture("depthSampler",a._prePassRenderer.getRenderTarget().textures[a._prePassRenderer.getIndex(u.PREPASS_DEPTH_TEXTURE_TYPE)])}},s.samples=this.textureSamples,s.autoClear=!1,s},t.prototype._radicalInverse_VdC=function(e){return this._bits[0]=e,this._bits[0]=(this._bits[0]<<16|this._bits[0]>>16)>>>0,this._bits[0]=(1431655765&this._bits[0])<<1|(2863311530&this._bits[0])>>>1>>>0,this._bits[0]=(858993459&this._bits[0])<<2|(3435973836&this._bits[0])>>>2>>>0,this._bits[0]=(252645135&this._bits[0])<<4|(4042322160&this._bits[0])>>>4>>>0,this._bits[0]=(16711935&this._bits[0])<<8|(4278255360&this._bits[0])>>>8>>>0,2.3283064365386963e-10*this._bits[0]},t.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},t.prototype._hemisphereSample_uniform=function(e,t){var i=2*t*Math.PI,r=1-.85*e,n=Math.sqrt(1-r*r);return new V(Math.cos(i)*n,Math.sin(i)*n,r)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,i=[],r=0;r0.0)\nhitCoord-=dir;else\nhitCoord+=dir;info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;}\nprojectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);info.coords=vec4(projectedCoord.xy,sampledDepth,1.0);info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;info.color/=float(SMOOTH_STEPS+1);return info;}\n/**\n* Tests the given world position (hitCoord) according to the given reflection vector (dir)\n* until it finds a collision (means that depth is enough close to say \"it's the pixel to sample!\").\n*/\nReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)\n{ReflectionInfo info;vec4 projectedCoord;float sampledDepth;dir*=stepSize;for(int i=0; i1&&ae.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},t.prototype._createDownSampleX4PostProcess=function(e,t){var i=this,r=new Array(32);this.downSampleX4PostProcess=new hl("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,n=i.downSampleX4PostProcess.width,o=i.downSampleX4PostProcess.height,a=-2;a<2;a++)for(var s=-2;s<2;s++)r[t]=(a+.5)*(1/n),r[t+1]=(s+.5)*(1/o),t+=2;e.setArray2("dsOffsets",r)},this.addEffect(new vC(e.getEngine(),"HDRDownSampleX4",(function(){return i.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var i=this,r=new Array(8);this.brightPassPostProcess=new hl("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(e){var t=1/i.brightPassPostProcess.width,n=1/i.brightPassPostProcess.height;r[0]=-.5*t,r[1]=.5*n,r[2]=.5*t,r[3]=.5*n,r[4]=-.5*t,r[5]=-.5*n,r[6]=.5*t,r[7]=-.5*n,e.setArray2("dsOffsets",r),e.setFloat("brightThreshold",i.brightThreshold)},this.addEffect(new vC(e.getEngine(),"HDRBrightPass",(function(){return i.brightPassPostProcess}),!0))},t.prototype._createBlurPostProcesses=function(e,t,i,r){var n=this;void 0===r&&(r="blurWidth");var o=e.getEngine(),a=new Om("HDRBlurH_"+i,new U(1,0),this[r],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),s=new Om("HDRBlurV_"+i,new U(0,1),this[r],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);a.onActivateObservable.add((function(){var e=a.width/o.getRenderWidth();a.kernel=n[r]*e})),s.onActivateObservable.add((function(){var e=s.height/o.getRenderHeight();s.kernel=n.horizontalBlur?64*e:n[r]*e})),this.addEffect(new vC(e.getEngine(),"HDRBlurH"+i,(function(){return a}),!0)),this.addEffect(new vC(e.getEngine(),"HDRBlurV"+i,(function(){return s}),!0)),this.blurHPostProcesses.push(a),this.blurVPostProcesses.push(s)},t.prototype._createTextureAdderPostProcess=function(e,t){var i=this;this.textureAdderPostProcess=new hl("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._vlsEnabled?i._currentDepthOfFieldSource:i.originalPostProcess),e.setTexture("lensSampler",i.lensTexture),e.setFloat("exposure",i._currentExposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new vC(e.getEngine(),"HDRTextureAdder",(function(){return i.textureAdderPostProcess}),!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var i=this,r=e.enableGeometryBufferRenderer();r.enablePosition=!0;var n=r.getGBuffer();this.volumetricLightPostProcess=new hl("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var o=U.Zero();this.volumetricLightPostProcess.onApply=function(e){if(i.sourceLight&&i.sourceLight.getShadowGenerator()&&i._scene.activeCamera){var t=i.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",n.textures[2]),e.setColor3("sunColor",i.sourceLight.diffuse),e.setVector3("sunDirection",i.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",i._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",i.volumetricLightCoefficient),e.setFloat("scatteringPower",i.volumetricLightPower),o.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),o.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),e.setVector2("depthValues",o)}},this.addEffect(new vC(e.getEngine(),"HDRVLS",(function(){return i.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new hl("HDRVLSMerge","standard",[],["originalSampler"],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",i._bloomEnabled?i.textureAdderFinalPostProcess:i.originalPostProcess),i._currentDepthOfFieldSource=i.volumetricLightFinalPostProcess},this.addEffect(new vC(e.getEngine(),"HDRVLSMerge",(function(){return i.volumetricLightMergePostProces}),!0))},t.prototype._createLuminancePostProcesses=function(e,i){var r=this,n=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new hl("HDRLuminance","standard",["lumOffsets"],[],{width:n,height:n},null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",i);var o=[];this.luminancePostProcess.onApply=function(e){var t=1/r.luminancePostProcess.width,i=1/r.luminancePostProcess.height;o[0]=-.5*t,o[1]=.5*i,o[2]=.5*t,o[3]=.5*i,o[4]=-.5*t,o[5]=-.5*i,o[6]=.5*t,o[7]=-.5*i,e.setArray2("lumOffsets",o)},this.addEffect(new vC(e.getEngine(),"HDRLuminance",(function(){return r.luminancePostProcess}),!0));for(var a=t.LuminanceSteps-1;a>=0;a--){n=Math.pow(3,a);var s="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(s+="#define FINAL_DOWN_SAMPLER");var l=new hl("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:n,height:n},null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,s,i);this.luminanceDownSamplePostProcesses.push(l)}var c=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,i){var n=new Array(18);t.onApply=function(e){if(c){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)n[o]=a/c.width,n[o+1]=s/c.height,o+=2;e.setArray2("dsOffsets",n),e.setFloat("halfDestPixelSize",.5/c.width),c=i===r.luminanceDownSamplePostProcesses.length-1?r.luminancePostProcess:t}},i===r.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),i=new k(1/16581375,1/65025,1/255,1);t.then((function(e){var t=new Uint8Array(e.buffer);r._hdrCurrentLuminance=(t[0]*i.x+t[1]*i.y+t[2]*i.z+t[3]*i.w)/100}))}),r.addEffect(new vC(e.getEngine(),"HDRLuminanceDownSample"+i,(function(){return t}),!0))}))},t.prototype._createHdrPostProcess=function(e,t){var i=this,r=["#define HDR"];this._hdrAutoExposure&&r.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new hl("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r.join("\n"),u.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,a=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",i._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),n<0)n=i._hdrCurrentLuminance;else{var r=(a-o)/1e3;i._hdrCurrentLuminancen-i.hdrIncreaseRate*r?n-=i.hdrIncreaseRate*r:n=i._hdrCurrentLuminance}i.hdrAutoExposure?i._currentExposure=i._fixedExposure/n:(n=j.Clamp(n,i.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",n)),a=o,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new vC(e.getEngine(),"HDR",(function(){return i.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var i=this;this.lensFlarePostProcess=new hl("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",u.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new vC(e.getEngine(),"HDRLensFlare",(function(){return i.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new hl("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",u.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new vC(e.getEngine(),"HDRLensFlareCompose",(function(){return i.lensFlareComposePostProcess}),!0));var r=new U(0,0);this.lensFlarePostProcess.externalTextureSamplerBinding=!0,this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",i._bloomEnabled?i.blurHPostProcesses[0]:i.originalPostProcess),e.setTexture("lensColorSampler",i.lensColorTexture),e.setFloat("strength",i.lensFlareStrength),e.setFloat("ghostDispersal",i.lensFlareGhostDispersal),e.setFloat("haloWidth",i.lensFlareHaloWidth),r.x=i.lensFlarePostProcess.width,r.y=i.lensFlarePostProcess.height,e.setVector2("resolution",r),e.setFloat("distortionStrength",i.lensFlareDistortionStrength)};var n=z.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),o=z.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(i._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",i.lensFlarePostProcess),e.setTexture("lensDirtSampler",i.lensFlareDirtTexture),e.setTexture("lensStarSampler",i.lensStarTexture);var t=i._scene.activeCamera.getViewMatrix().getRow(0),r=i._scene.activeCamera.getViewMatrix().getRow(2),a=V.Dot(t.toVector3(),new V(1,0,0))+V.Dot(r.toVector3(),new V(0,0,1));a*=4;var s=z.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),l=o.multiply(s).multiply(n);e.setMatrix("lensStarMatrix",l),i._currentDepthOfFieldSource=i.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var i=this;this.depthOfFieldPostProcess=new hl("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",u.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._currentDepthOfFieldSource),e.setTexture("depthSampler",i._getDepthTexture()),e.setFloat("distance",i.depthOfFieldDistance)},this.addEffect(new vC(e.getEngine(),"HDRDepthOfField",(function(){return i.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var i=this;if(this._isObjectBasedMotionBlur){var r=new kC("HDRMotionBlur",e,t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,u.TEXTURETYPE_UNSIGNED_INT);r.motionStrength=this.motionStrength,r.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=r}else{this.motionBlurPostProcess=new hl("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Ja.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),u.TEXTURETYPE_UNSIGNED_INT);var n=0,o=z.Identity(),a=z.Identity(),s=z.Identity(),l=U.Zero();this.motionBlurPostProcess.onApply=function(t){(s=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(a),t.setMatrix("inverseViewProjection",a),t.setMatrix("prevViewProjection",o),o=s,l.x=i.motionBlurPostProcess.width,l.y=i.motionBlurPostProcess.height,t.setVector2("screenSize",l),n=e.getEngine().getFps()/60,t.setFloat("motionScale",n),t.setFloat("motionStrength",i.motionStrength),t.setTexture("depthSampler",i._getDepthTexture())}}this.addEffect(new vC(e.getEngine(),"HDRMotionBlur",(function(){return i.motionBlurPostProcess}),!0))},t.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},t.prototype._disposePostProcesses=function(){for(var e=0;e0.01 and project within the valid screen rectangle\nparam csDirection Unit length camera-space ray direction\nparam projectToPixelMatrix A projection matrix that maps to **pixel** coordinates \n(**not** [-1,+1] normalized device coordinates).\nparam csZBuffer The camera-space Z buffer\nparam csZBufferSize Dimensions of csZBuffer\nparam csZThickness Camera space csZThickness to ascribe to each pixel in the depth buffer\nparam nearPlaneZ Positive number. Doesn't have to be THE actual near plane,just a reasonable value\nfor clipping rays headed towards the camera\nparam stride Step in horizontal or vertical pixels between samples. This is a float\nbecause integer math is slow on GPUs,but should be set to an integer>=1\nparam jitterFraction Number between 0 and 1 for how far to bump the ray in stride units\nto conceal banding artifacts,plus the stride ray offset.\nparam maxSteps Maximum number of iterations. Higher gives better images but may be slow\nparam maxRayTraceDistance Maximum camera-space distance to trace before returning a miss\nparam selfCollisionNumSkip Number of steps to skip at start when raytracing to avoid self collisions.\n1 is a reasonable value,depending on the scene you may need to set this value to 2\nparam hitPixel Pixel coordinates of the first intersection with the scene\nparam numIterations number of iterations performed\nparam csHitPoint Camera space location of the ray hit\n*/\n#define inline\nbool traceScreenSpaceRay1(\nvec3 csOrigin,\nvec3 csDirection,\nmat4 projectToPixelMatrix,\nsampler2D csZBuffer,\nvec2 csZBufferSize,\n#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER\nsampler2D csZBackBuffer,\nfloat csZBackSizeFactor,\n#endif\nfloat csZThickness,\nfloat nearPlaneZ,\nfloat stride,\nfloat jitterFraction,\nfloat maxSteps,\nfloat maxRayTraceDistance,\nfloat selfCollisionNumSkip,\nout vec2 startPixel,\nout vec2 hitPixel,\nout vec3 csHitPoint,\nout float numIterations\n#ifdef SSRAYTRACE_DEBUG\n,out vec3 debugColor\n#endif\n)\n{\n#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE\nfloat rayLength=(csOrigin.z+csDirection.z*maxRayTraceDistance)>-nearPlaneZ ? (-nearPlaneZ-csOrigin.z)/csDirection.z : maxRayTraceDistance;\n#else\nfloat rayLength=(csOrigin.z+csDirection.z*maxRayTraceDistance)yMax) || (P1.yyMax) ? yMax : yMin))/(P1.y-P0.y);}\nif ((P1.x>xMax) || (P1.xxMax) ? xMax : xMin))/(P1.x-P0.x));}\nP1=mix(P1,P0,alpha); k1=mix(k1,k0,alpha); Q1=mix(Q1,Q0,alpha);\n#endif\nP1+=vec2((distanceSquared(P0,P1)<0.0001) ? 0.01 : 0.0);vec2 delta=P1-P0;bool permute=false;if (abs(delta.x)rayZMax) { \nfloat t=rayZMin; rayZMin=rayZMax; rayZMax=t;}\nsceneZMax=texelFetch(csZBuffer,ivec2(hitPixel),0).r;\n#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE\n#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER\nfloat sceneBackZ=texelFetch(csZBackBuffer,ivec2(hitPixel/csZBackSizeFactor),0).r;hit=(rayZMax>=sceneBackZ-csZThickness) && (rayZMin<=sceneZMax);\n#else\nhit=(rayZMax>=sceneZMax-csZThickness) && (rayZMin<=sceneZMax);\n#endif\n#else\n#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER\nfloat sceneBackZ=texelFetch(csZBackBuffer,ivec2(hitPixel/csZBackSizeFactor),0).r;hit=(rayZMin<=sceneBackZ+csZThickness) && (rayZMax>=sceneZMax) && (sceneZMax != 0.0);\n#else\nhit=(rayZMin<=sceneZMax+csZThickness) && (rayZMax>=sceneZMax);\n#endif\n#endif\n}\npqk-=dPQK;stepCount-=1.0;if (((pqk.x+dPQK.x)*stepDirection)>end || (stepCount+1.0)>=maxSteps || sceneZMax==0.0) {hit=false;}\n#ifdef SSRAYTRACE_ENABLE_REFINEMENT\nif (stride>1.0 && hit) {pqk-=dPQK;stepCount-=1.0;float invStride=1.0/stride;dPQK*=invStride;float refinementStepCount=0.0;prevZMaxEstimate=pqk.z/pqk.w;rayZMax=prevZMaxEstimate;sceneZMax=rayZMax+1e7;for (;refinementStepCount<=1.0 ||\n(refinementStepCount<=stride*1.4) &&\n(rayZMaxend) {debugColor=vec3(0,0,1);} else if ((stepCount+1.0)>=maxSteps) {debugColor=vec3(1,0,0);} else if (sceneZMax==0.0) {debugColor=vec3(1,1,0);} else {debugColor=vec3(0,stepCount/maxSteps,0);}\n#endif\nreturn hit;}\n/**\ntexCoord: in the [0,1] range\ndepth: depth in view space (range [znear,zfar]])\n*/\nvec3 computeViewPosFromUVDepth(vec2 texCoord,float depth,mat4 projection,mat4 invProjectionMatrix) {vec4 ndc;ndc.xy=texCoord*2.0-1.0;\n#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE\n#ifdef ORTHOGRAPHIC_CAMERA\nndc.z=-projection[2].z*depth+projection[3].z;\n#else\nndc.z=-projection[2].z-projection[3].z/depth;\n#endif\n#else\n#ifdef ORTHOGRAPHIC_CAMERA\nndc.z=projection[2].z*depth+projection[3].z;\n#else\nndc.z=projection[2].z+projection[3].z/depth;\n#endif\n#endif\nndc.w=1.0;vec4 eyePos=invProjectionMatrix*ndc;eyePos.xyz/=eyePos.w;return eyePos.xyz;}\n";li.ShadersStore.screenSpaceReflection2PixelShader="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)\n#define TEXTURECUBEFUNC(s,c,lod) textureLod(s,c,lod)\n#else\n#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)\n#define TEXTURECUBEFUNC(s,c,bias) textureCube(s,c,bias)\n#endif\nuniform sampler2D textureSampler;varying vec2 vUV;\n#ifdef SSR_SUPPORTED\nuniform sampler2D reflectivitySampler;uniform sampler2D normalSampler;uniform sampler2D depthSampler;\n#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER\nuniform sampler2D backDepthSampler;uniform float backSizeFactor;\n#endif\n#ifdef SSR_USE_ENVIRONMENT_CUBE\nuniform samplerCube envCubeSampler;\n#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC\nuniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;\n#endif\n#endif\nuniform mat4 view;uniform mat4 invView;uniform mat4 projection;uniform mat4 invProjectionMatrix;uniform mat4 projectionPixel;uniform float nearPlaneZ;uniform float stepSize;uniform float maxSteps;uniform float strength;uniform float thickness;uniform float roughnessFactor;uniform float reflectionSpecularFalloffExponent;uniform float maxDistance;uniform float selfCollisionNumSkip;uniform float reflectivityThreshold;\n#include\n#include\n#include\nvec3 hash(vec3 a)\n{a=fract(a*0.8);a+=dot(a,a.yxz+19.19);return fract((a.xxy+a.yxx)*a.zyx);}\nfloat computeAttenuationForIntersection(ivec2 hitPixel,vec2 hitUV,vec3 vsRayOrigin,vec3 vsHitPoint,vec3 reflectionVector,float maxRayDistance,float numIterations) {float attenuation=1.0;\n#ifdef SSR_ATTENUATE_SCREEN_BORDERS\nvec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-hitUV.xy));attenuation*=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);\n#endif\n#ifdef SSR_ATTENUATE_INTERSECTION_DISTANCE\nattenuation*=1.0-clamp(distance(vsRayOrigin,vsHitPoint)/maxRayDistance,0.0,1.0);\n#endif\n#ifdef SSR_ATTENUATE_INTERSECTION_NUMITERATIONS\nattenuation*=1.0-(numIterations/maxSteps);\n#endif\n#ifdef SSR_ATTENUATE_BACKFACE_REFLECTION\nvec3 reflectionNormal=texelFetch(normalSampler,hitPixel,0).xyz;float directionBasedAttenuation=smoothstep(-0.17,0.0,dot(reflectionNormal,-reflectionVector));attenuation*=directionBasedAttenuation;\n#endif\nreturn attenuation;}\n#endif\nvoid main()\n{\n#ifdef SSR_SUPPORTED\nvec4 colorFull=TEXTUREFUNC(textureSampler,vUV,0.0);vec3 color=colorFull.rgb;vec4 reflectivity=TEXTUREFUNC(reflectivitySampler,vUV,0.0);\n#ifndef SSR_DISABLE_REFLECTIVITY_TEST\nif (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=reflectivityThreshold) {\n#ifdef SSR_USE_BLUR\ngl_FragColor=vec4(0.);\n#else\ngl_FragColor=colorFull;\n#endif\nreturn;}\n#endif\n#ifdef SSR_INPUT_IS_GAMMA_SPACE\ncolor=toLinearSpace(color);\n#endif\nvec2 texSize=vec2(textureSize(depthSampler,0));vec3 csNormal=texelFetch(normalSampler,ivec2(vUV*texSize),0).xyz; \n#ifdef SSR_DECODE_NORMAL\ncsNormal=csNormal*2.0-1.0;\n#endif\n#ifdef SSR_NORMAL_IS_IN_WORLDSPACE\ncsNormal=(view*vec4(csNormal,0.0)).xyz;\n#endif\nfloat depth=texelFetch(depthSampler,ivec2(vUV*texSize),0).r;vec3 csPosition=computeViewPosFromUVDepth(vUV,depth,projection,invProjectionMatrix);\n#ifdef ORTHOGRAPHIC_CAMERA\nvec3 csViewDirection=vec3(0.,0.,1.);\n#else\nvec3 csViewDirection=normalize(csPosition);\n#endif\nvec3 csReflectedVector=reflect(csViewDirection,csNormal);\n#ifdef SSR_USE_ENVIRONMENT_CUBE\nvec3 wReflectedVector=vec3(invView*vec4(csReflectedVector,0.0));\n#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC\nvec4 worldPos=invView*vec4(csPosition,1.0);wReflectedVector=parallaxCorrectNormal(worldPos.xyz,normalize(wReflectedVector),vReflectionSize,vReflectionPosition);\n#endif\n#ifdef SSR_INVERTCUBICMAP\nwReflectedVector.y*=-1.0;\n#endif\n#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE\nwReflectedVector.z*=-1.0;\n#endif\nvec3 envColor=TEXTURECUBEFUNC(envCubeSampler,wReflectedVector,0.0).xyz;\n#ifdef SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE\nenvColor=toLinearSpace(envColor);\n#endif\n#else\nvec3 envColor=color;\n#endif\nfloat reflectionAttenuation=1.0;bool rayHasHit=false;vec2 startPixel;vec2 hitPixel;vec3 hitPoint;float numIterations;\n#ifdef SSRAYTRACE_DEBUG\nvec3 debugColor;\n#endif\n#ifdef SSR_ATTENUATE_FACING_CAMERA\nreflectionAttenuation*=1.0-smoothstep(0.25,0.5,dot(-csViewDirection,csReflectedVector));\n#endif\nif (reflectionAttenuation>0.0) {\n#ifdef SSR_USE_BLUR\nvec3 jitt=vec3(0.);\n#else\nfloat roughness=1.0-reflectivity.a;vec3 jitt=mix(vec3(0.0),hash(csPosition)-vec3(0.5),roughness)*roughnessFactor; \n#endif\nvec2 uv2=vUV*texSize;float c=(uv2.x+uv2.y)*0.25;float jitter=mod(c,1.0); \nrayHasHit=traceScreenSpaceRay1(\ncsPosition,\nnormalize(csReflectedVector+jitt),\nprojectionPixel,\ndepthSampler,\ntexSize,\n#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER\nbackDepthSampler,\nbackSizeFactor,\n#endif\nthickness,\nnearPlaneZ,\nstepSize,\njitter,\nmaxSteps,\nmaxDistance,\nselfCollisionNumSkip,\nstartPixel,\nhitPixel,\nhitPoint,\nnumIterations\n#ifdef SSRAYTRACE_DEBUG\n,debugColor\n#endif\n);}\n#ifdef SSRAYTRACE_DEBUG\ngl_FragColor=vec4(debugColor,1.);return;\n#endif\nvec3 F0=reflectivity.rgb;vec3 fresnel=fresnelSchlickGGX(max(dot(csNormal,-csViewDirection),0.0),F0,vec3(1.));vec3 SSR=envColor;if (rayHasHit) {vec3 reflectedColor=texelFetch(textureSampler,ivec2(hitPixel),0).rgb;\n#ifdef SSR_INPUT_IS_GAMMA_SPACE\nreflectedColor=toLinearSpace(reflectedColor);\n#endif\nreflectionAttenuation*=computeAttenuationForIntersection(ivec2(hitPixel),hitPixel/texSize,csPosition,hitPoint,csReflectedVector,maxDistance,numIterations);SSR=reflectedColor*reflectionAttenuation+(1.0-reflectionAttenuation)*envColor;}\n#ifndef SSR_BLEND_WITH_FRESNEL\nSSR*=fresnel;\n#endif\n#ifdef SSR_USE_BLUR\nfloat blur_radius=0.0;float roughness=1.0-reflectivity.a*(1.0-roughnessFactor);if (roughness>0.001) {float cone_angle=min(roughness,0.999)*3.14159265*0.5;float cone_len=distance(startPixel,hitPixel);float op_len=2.0*tan(cone_angle)*cone_len; \nfloat a=op_len;float h=cone_len;float a2=a*a;float fh2=4.0f*h*h;blur_radius=(a*(sqrt(a2+fh2)-a))/(4.0f*h);}\ngl_FragColor=vec4(SSR,blur_radius/255.0); \n#else\n#ifdef SSR_BLEND_WITH_FRESNEL\nvec3 reflectionMultiplier=clamp(pow(fresnel*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);\n#else\nvec3 reflectionMultiplier=clamp(pow(reflectivity.rgb*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);\n#endif\nvec3 colorMultiplier=1.0-reflectionMultiplier;vec3 finalColor=(color*colorMultiplier)+(SSR*reflectionMultiplier);\n#ifdef SSR_OUTPUT_IS_GAMMA_SPACE\nfinalColor=toGammaSpace(finalColor);\n#endif\ngl_FragColor=vec4(finalColor,colorFull.a);\n#endif\n#else\ngl_FragColor=TEXTUREFUNC(textureSampler,vUV,0.0);\n#endif\n}\n";li.ShadersStore.screenSpaceReflection2BlurPixelShader="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)\n#else\n#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)\n#endif\nuniform sampler2D textureSampler;varying vec2 vUV;uniform vec2 texelOffsetScale;const float weights[8]=float[8] (0.071303,0.131514,0.189879,0.321392,0.452906, 0.584419,0.715932,0.847445);void processSample(vec2 uv,float i,vec2 stepSize,inout vec4 accumulator,inout float denominator)\n{vec2 offsetUV=stepSize*i+uv;float coefficient=weights[int(2.0-abs(i))];accumulator+=TEXTUREFUNC(textureSampler,offsetUV,0.0)*coefficient;denominator+=coefficient;}\nvoid main()\n{vec4 colorFull=TEXTUREFUNC(textureSampler,vUV,0.0);if (dot(colorFull,vec4(1.0))==0.0) {gl_FragColor=colorFull;return;}\nfloat blurRadius=colorFull.a*255.0; \nvec2 stepSize=texelOffsetScale.xy*blurRadius;vec4 accumulator=TEXTUREFUNC(textureSampler,vUV,0.0)*0.214607;float denominator=0.214607;processSample(vUV,1.0,stepSize,accumulator,denominator);processSample(vUV,1.0*0.2,stepSize,accumulator,denominator);processSample(vUV,1.0*0.4,stepSize,accumulator,denominator);processSample(vUV,1.0*0.6,stepSize,accumulator,denominator);processSample(vUV,1.0*0.8,stepSize,accumulator,denominator);processSample(vUV,1.0*1.2,stepSize,accumulator,denominator);processSample(vUV,1.0*1.4,stepSize,accumulator,denominator);processSample(vUV,1.0*1.6,stepSize,accumulator,denominator);processSample(vUV,1.0*1.8,stepSize,accumulator,denominator);processSample(vUV,1.0*2.0,stepSize,accumulator,denominator);processSample(vUV,-1.0,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.2,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.4,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.6,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.8,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.2,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.4,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.6,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.8,stepSize,accumulator,denominator);processSample(vUV,-1.0*2.0,stepSize,accumulator,denominator);gl_FragColor=vec4(accumulator.rgb/denominator,colorFull.a);}\n";li.ShadersStore.screenSpaceReflection2BlurCombinerPixelShader="uniform sampler2D textureSampler; \nuniform sampler2D mainSampler;uniform sampler2D reflectivitySampler;uniform float strength;uniform float reflectionSpecularFalloffExponent;uniform float reflectivityThreshold;varying vec2 vUV;\n#include\n#ifdef SSR_BLEND_WITH_FRESNEL\n#include\n#include\nuniform mat4 projection;uniform mat4 invProjectionMatrix;uniform sampler2D normalSampler;uniform sampler2D depthSampler;\n#endif\nvoid main()\n{\n#ifdef SSRAYTRACE_DEBUG\ngl_FragColor=texture2D(textureSampler,vUV);\n#else\nvec3 SSR=texture2D(textureSampler,vUV).rgb;vec4 color=texture2D(mainSampler,vUV);vec4 reflectivity=texture2D(reflectivitySampler,vUV);\n#ifndef SSR_DISABLE_REFLECTIVITY_TEST\nif (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=reflectivityThreshold) {gl_FragColor=color;return;}\n#endif\n#ifdef SSR_INPUT_IS_GAMMA_SPACE\ncolor=toLinearSpace(color);\n#endif\n#ifdef SSR_BLEND_WITH_FRESNEL\nvec2 texSize=vec2(textureSize(depthSampler,0));vec3 csNormal=texelFetch(normalSampler,ivec2(vUV*texSize),0).xyz;float depth=texelFetch(depthSampler,ivec2(vUV*texSize),0).r;vec3 csPosition=computeViewPosFromUVDepth(vUV,depth,projection,invProjectionMatrix);vec3 csViewDirection=normalize(csPosition);vec3 F0=reflectivity.rgb;vec3 fresnel=fresnelSchlickGGX(max(dot(csNormal,-csViewDirection),0.0),F0,vec3(1.));vec3 reflectionMultiplier=clamp(pow(fresnel*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);\n#else\nvec3 reflectionMultiplier=clamp(pow(reflectivity.rgb*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);\n#endif\nvec3 colorMultiplier=1.0-reflectionMultiplier;vec3 finalColor=(color.rgb*colorMultiplier)+(SSR*reflectionMultiplier);\n#ifdef SSR_OUTPUT_IS_GAMMA_SPACE\nfinalColor=toGammaSpace(finalColor);\n#endif\ngl_FragColor=vec4(finalColor,color.a);\n#endif\n}\n";var tR=z.Compose(new V(.5,.5,.5),G.Identity(),new V(.5,.5,.5)),iR=z.Compose(new V(.5,.5,1),G.Identity(),new V(.5,.5,0)),rR=function(e){function t(t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=u.TEXTURETYPE_UNSIGNED_BYTE);var a=e.call(this,i.getEngine(),t)||this;if(a.SSRRenderEffect="SSRRenderEffect",a.SSRBlurRenderEffect="SSRBlurRenderEffect",a.SSRCombineRenderEffect="SSRCombineRenderEffect",a._samples=1,a.maxDistance=1e3,a.step=1,a.thickness=.5,a.strength=1,a.reflectionSpecularFalloffExponent=1,a.maxSteps=1e3,a.roughnessFactor=.2,a.selfCollisionNumSkip=1,a._reflectivityThreshold=.04,a._ssrDownsample=0,a._blurDispersionStrength=.03,a._blurDownsample=0,a._enableSmoothReflections=!1,a._environmentTextureIsProbe=!1,a._attenuateScreenBorders=!0,a._attenuateIntersectionDistance=!0,a._attenuateIntersectionIterations=!0,a._attenuateFacingCamera=!1,a._attenuateBackfaceReflection=!1,a._clipToFrustum=!0,a._useFresnel=!1,a._enableAutomaticThicknessComputation=!1,a._backfaceDepthTextureDownsample=0,a._backfaceForceDepthWriteTransparentMeshes=!0,a._isEnabled=!0,a._inputTextureColorIsInGammaSpace=!0,a._generateOutputInGammaSpace=!0,a._debug=!1,a._forceGeometryBuffer=!1,a._isDirty=!1,a._camerasToBeAttached=[],a._cameras=r||i.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=i,a._textureType=o,a._forceGeometryBuffer=n,a.isSupported){if(i.postProcessRenderPipelineManager.addPipeline(a),a._forceGeometryBuffer){var s=i.enableGeometryBufferRenderer();s&&(s.enableReflectivity=!0,s.useSpecificClearForDepthTexture=!0)}else{var l=i.enablePrePassRenderer();l&&(l.useSpecificClearForDepthTexture=!0,l.markAsDirty())}a._buildPipeline()}return a}return m(t,e),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectivityThreshold",{get:function(){return this._reflectivityThreshold},set:function(e){e!==this._reflectivityThreshold&&(0===e&&0!==this._reflectivityThreshold||0!==e&&0===this._reflectivityThreshold?(this._reflectivityThreshold=e,this._buildPipeline()):this._reflectivityThreshold=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ssrDownsample",{get:function(){return this._ssrDownsample},set:function(e){e!==this._ssrDownsample&&(this._ssrDownsample=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurDispersionStrength",{get:function(){return this._blurDispersionStrength},set:function(e){if(e!==this._blurDispersionStrength){var t=0===e&&0!==this._blurDispersionStrength||0!==e&&0===this._blurDispersionStrength;this._blurDispersionStrength=e,t&&this._buildPipeline()}},enumerable:!1,configurable:!0}),t.prototype._useBlur=function(){return this._blurDispersionStrength>0},Object.defineProperty(t.prototype,"blurDownsample",{get:function(){return this._blurDownsample},set:function(e){e!==this._blurDownsample&&(this._blurDownsample=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableSmoothReflections",{get:function(){return this._enableSmoothReflections},set:function(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture=e,this._updateEffectDefines()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"environmentTextureIsProbe",{get:function(){return this._environmentTextureIsProbe},set:function(e){this._environmentTextureIsProbe=e,this._updateEffectDefines()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateScreenBorders",{get:function(){return this._attenuateScreenBorders},set:function(e){this._attenuateScreenBorders!==e&&(this._attenuateScreenBorders=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateIntersectionDistance",{get:function(){return this._attenuateIntersectionDistance},set:function(e){this._attenuateIntersectionDistance!==e&&(this._attenuateIntersectionDistance=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateIntersectionIterations",{get:function(){return this._attenuateIntersectionIterations},set:function(e){this._attenuateIntersectionIterations!==e&&(this._attenuateIntersectionIterations=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateFacingCamera",{get:function(){return this._attenuateFacingCamera},set:function(e){this._attenuateFacingCamera!==e&&(this._attenuateFacingCamera=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateBackfaceReflection",{get:function(){return this._attenuateBackfaceReflection},set:function(e){this._attenuateBackfaceReflection!==e&&(this._attenuateBackfaceReflection=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clipToFrustum",{get:function(){return this._clipToFrustum},set:function(e){this._clipToFrustum!==e&&(this._clipToFrustum=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useFresnel",{get:function(){return this._useFresnel},set:function(e){this._useFresnel!==e&&(this._useFresnel=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableAutomaticThicknessComputation",{get:function(){return this._enableAutomaticThicknessComputation},set:function(e){this._enableAutomaticThicknessComputation!==e&&(this._enableAutomaticThicknessComputation=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backfaceDepthRenderer",{get:function(){return this._depthRenderer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backfaceDepthTextureDownsample",{get:function(){return this._backfaceDepthTextureDownsample},set:function(e){this._backfaceDepthTextureDownsample!==e&&(this._backfaceDepthTextureDownsample=e,this._resizeDepthRenderer())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backfaceForceDepthWriteTransparentMeshes",{get:function(){return this._backfaceForceDepthWriteTransparentMeshes},set:function(e){this._backfaceForceDepthWriteTransparentMeshes!==e&&(this._backfaceForceDepthWriteTransparentMeshes=e,this._depthRenderer&&(this._depthRenderer.forceDepthWriteTransparentMeshes=e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,e?e&&(this._isDirty?this._buildPipeline():null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)):null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputTextureColorIsInGammaSpace",{get:function(){return this._inputTextureColorIsInGammaSpace},set:function(e){this._inputTextureColorIsInGammaSpace!==e&&(this._inputTextureColorIsInGammaSpace=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generateOutputInGammaSpace",{get:function(){return this._generateOutputInGammaSpace},set:function(e){this._generateOutputInGammaSpace!==e&&(this._generateOutputInGammaSpace=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug!==e&&(this._debug=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype.getScene=function(){return this._scene},Object.defineProperty(t.prototype,"_geometryBufferRenderer",{get:function(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_prePassRenderer",{get:function(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSupported",{get:function(){var e=this._scene.getEngine().getCaps();return e.drawBuffersExtension&&e.texelFetch},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSRRenderingPipeline"},t.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},t.prototype.removeCamera=function(e){var t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()},t.prototype.dispose=function(t){void 0===t&&(t=!1),this._disposeDepthRenderer(),this._disposePostProcesses(),t&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),e.prototype.dispose.call(this)},t.prototype._getTextureSize=function(){var e,t,i=this._scene.getEngine(),r=this._prePassRenderer,n={width:i.getRenderWidth(),height:i.getRenderHeight()};if(r&&(null===(e=this._scene.activeCamera)||void 0===e?void 0:e._getFirstPostProcess())===this._ssrPostProcess){var o=r.getRenderTarget();o&&o.textures&&(n=o.textures[r.getIndex(u.PREPASS_COLOR_TEXTURE_TYPE)].getSize())}else(null===(t=this._ssrPostProcess)||void 0===t?void 0:t.inputTexture)&&(n.width=this._ssrPostProcess.inputTexture.width,n.height=this._ssrPostProcess.inputTexture.height);return n},t.prototype._updateEffectDefines=function(){var e,t,i,r,n,o,a=[];(this._geometryBufferRenderer||this._prePassRenderer)&&a.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&a.push("#define SSRAYTRACE_ENABLE_REFINEMENT"),this._scene.useRightHandedSystem&&a.push("#define SSRAYTRACE_RIGHT_HANDED_SCENE"),this._environmentTexture&&(a.push("#define SSR_USE_ENVIRONMENT_CUBE"),this._environmentTexture.boundingBoxSize&&a.push("#define SSR_USE_LOCAL_REFLECTIONMAP_CUBIC"),this._environmentTexture.gammaSpace&&a.push("#define SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE")),this._environmentTextureIsProbe&&a.push("#define SSR_INVERTCUBICMAP"),this._enableAutomaticThicknessComputation&&a.push("#define SSRAYTRACE_USE_BACK_DEPTHBUFFER"),this._attenuateScreenBorders&&a.push("#define SSR_ATTENUATE_SCREEN_BORDERS"),this._attenuateIntersectionDistance&&a.push("#define SSR_ATTENUATE_INTERSECTION_DISTANCE"),this._attenuateIntersectionIterations&&a.push("#define SSR_ATTENUATE_INTERSECTION_NUMITERATIONS"),this._attenuateFacingCamera&&a.push("#define SSR_ATTENUATE_FACING_CAMERA"),this._attenuateBackfaceReflection&&a.push("#define SSR_ATTENUATE_BACKFACE_REFLECTION"),this._clipToFrustum&&a.push("#define SSRAYTRACE_CLIP_TO_FRUSTUM"),this._useBlur()&&a.push("#define SSR_USE_BLUR"),this._debug&&a.push("#define SSRAYTRACE_DEBUG"),this._inputTextureColorIsInGammaSpace&&a.push("#define SSR_INPUT_IS_GAMMA_SPACE"),this._generateOutputInGammaSpace&&a.push("#define SSR_OUTPUT_IS_GAMMA_SPACE"),this._useFresnel&&a.push("#define SSR_BLEND_WITH_FRESNEL"),0===this._reflectivityThreshold&&a.push("#define SSR_DISABLE_REFLECTIVITY_TEST"),(null!==(t=null===(e=this._geometryBufferRenderer)||void 0===e?void 0:e.generateNormalsInWorldSpace)&&void 0!==t?t:null===(i=this._prePassRenderer)||void 0===i?void 0:i.generateNormalsInWorldSpace)&&a.push("#define SSR_NORMAL_IS_IN_WORLDSPACE"),(null===(r=this._geometryBufferRenderer)||void 0===r?void 0:r.normalsAreUnsigned)&&a.push("#define SSR_DECODE_NORMAL");var s=null===(n=this._cameras)||void 0===n?void 0:n[0];s&&s.mode===u.ORTHOGRAPHIC_CAMERA&&a.push("#define ORTHOGRAPHIC_CAMERA"),null===(o=this._ssrPostProcess)||void 0===o||o.updateEffect(a.join("\n"))},t.prototype._buildPipeline=function(){var e,t=this;if(this.isSupported)if(this._isEnabled){this._isDirty=!1;var i=this._scene.getEngine();if(this._disposeDepthRenderer(),this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._enableAutomaticThicknessComputation){var r=null===(e=this._cameras)||void 0===e?void 0:e[0];r&&(this._depthRendererCamera=r,this._depthRenderer=new pv(this._scene,void 0,void 0,void 0,u.TEXTURE_NEAREST_SAMPLINGMODE,!0,"SSRBackDepth"),this._depthRenderer.clearColor.r=1e8,this._depthRenderer.reverseCulling=!0,this._depthRenderer.forceDepthWriteTransparentMeshes=this._backfaceForceDepthWriteTransparentMeshes,this._resizeDepthRenderer(),r.customRenderTargets.push(this._depthRenderer.getDepthMap()))}this._createSSRPostProcess(),this.addEffect(new vC(i,this.SSRRenderEffect,(function(){return t._ssrPostProcess}),!0)),this._useBlur()&&(this._createBlurAndCombinerPostProcesses(),this.addEffect(new vC(i,this.SSRBlurRenderEffect,(function(){return[t._blurPostProcessX,t._blurPostProcessY]}),!0)),this.addEffect(new vC(i,this.SSRCombineRenderEffect,(function(){return t._blurCombinerPostProcess}),!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)}else this._isDirty=!0},t.prototype._resizeDepthRenderer=function(){if(this._depthRenderer){var e=this._getTextureSize(),t=this._depthRenderer.getDepthMap().getSize(),i=Math.floor(e.width/(this._backfaceDepthTextureDownsample+1)),r=Math.floor(e.height/(this._backfaceDepthTextureDownsample+1));t.width===i&&t.height===r||this._depthRenderer.getDepthMap().resize({width:i,height:r})}},t.prototype._disposeDepthRenderer=function(){var e;if(this._depthRenderer){if(this._depthRendererCamera){var t=null!==(e=this._depthRendererCamera.customRenderTargets.indexOf(this._depthRenderer.getDepthMap()))&&void 0!==e?e:-1;-1!==t&&this._depthRendererCamera.customRenderTargets.splice(t,1)}this._depthRendererCamera=null,this._depthRenderer.getDepthMap().dispose()}this._depthRenderer=null},t.prototype._disposePostProcesses=function(){for(var e,t,i,r,n=0;n0&&-1===this.includedMeshes.indexOf(e)||this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)},t.prototype._createPass=function(e,t){var i=this,r=e.getEngine();this._volumetricLightScatteringRTT=new Pl("volumetricLightScatteringMap",{width:r.getRenderWidth()*t,height:r.getRenderHeight()*t},e,!1,!0,u.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Ja.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Ja.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var n=this.getCamera();n?n.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,a=function(e){var t,r=e.getRenderingMesh(),n=e.getEffectiveMesh();if(!i._meshExcluded(r)){n._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var o=e.getMaterial();if(o){var a=r.getScene(),s=a.getEngine();s.setState(o.backFaceCulling,void 0,void 0,void 0,o.cullBackFaces);var l=r._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!l.mustReturn){var c=s.getCaps().instancedArrays&&(null!==l.visibleInstances[e._id]||r.hasThinInstances);if(i._isReady(e,c)){var u=null===(t=n._internalAbstractMeshDataInfo._materialForRenderPass)||void 0===t?void 0:t[s.currentRenderPassId],h=e._getDrawWrapper();if(r!==i.mesh||h||(h=o._getDrawWrapper()),!h)return;var d=h.effect;if(s.enableEffect(h),c||r._bind(e,d,o.fillMode),r===i.mesh)o.bind(n.getWorldMatrix(),r);else if(u)u.bindForSubMesh(n.getWorldMatrix(),n,e);else{if(d.setMatrix("viewProjection",a.getTransformMatrix()),o&&o.needAlphaTesting()){var p=o.getAlphaTestTexture();d.setTexture("diffuseSampler",p),p&&d.setMatrix("diffuseMatrix",p.getTextureMatrix())}r.useBones&&r.computeBonesUsingShaders&&r.skeleton&&d.setMatrices("mBones",r.skeleton.getTransformMatrices(r))}c&&r.hasThinInstances&&d.setMatrix("world",n.getWorldMatrix()),r._processRendering(n,e,d,Ca.TriangleFillMode,l,c,(function(e,t){e||d.setMatrix("world",t)}))}}}}},s=new J(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=e.clearColor,e.clearColor=s})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){e.clearColor=o})),this._volumetricLightScatteringRTT.customIsReadyFunction=function(e,t,n){if((n||0===t)&&e.subMeshes)for(var o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),s.setAlphaMode(u.ALPHA_COMBINE),o=0;o\nuniform vec4 color;\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#include\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";li.ShadersStore.lineVertexShader="#include\n#include\nattribute vec3 position;attribute vec4 normal;uniform mat4 viewProjection;uniform float width;uniform float aspectRatio;\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include\nmat4 worldViewProjection=viewProjection*finalWorld;vec4 viewPosition=worldViewProjection*vec4(position,1.0);vec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);vec2 currentScreen=viewPosition.xy/viewPosition.w;vec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;currentScreen.x*=aspectRatio;nextScreen.x*=aspectRatio;vec2 dir=normalize(nextScreen-currentScreen);vec2 normalDir=vec2(-dir.y,dir.x);normalDir*=width/2.0;normalDir.x/=aspectRatio;vec4 offset=vec4(normalDir*normal.w,0.0,0.0);gl_Position=viewPosition+offset;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include\n#endif\n#include\n#define CUSTOM_VERTEX_MAIN_END\n}",Uo.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},Uo.prototype.enableEdgesRendering=function(e,t,i){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new _R(this,e,t,!0,i),this},Object.defineProperty(Uo.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),cd.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new mR(this,e,t),this},ud.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),cd.prototype.enableEdgesRendering.apply(this,arguments),this};var fR=function(){this.edges=[],this.edgesConnectedCount=0},_R=function(){function e(e,t,i,r,n){void 0===t&&(t=.95),void 0===i&&(i=!1),void 0===r&&(r=!0);var o,a=this;this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._buffersForInstances={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this.customInstances=new ar(32),this._source=e,this._checkVerticesInsteadOfIndices=i,this._options=null!=n?n:null,this._epsilon=t,this._source.getScene().getEngine().isWebGPU&&(this._drawWrapper=new ho(e.getEngine())),this._prepareRessources(),r&&(null===(o=null==n?void 0:n.useAlternateEdgeFinder)||void 0===o||o?this._generateEdgesLinesAlternate():this._generateEdgesLines()),this._meshRebuildObserver=this._source.onRebuildObservable.add((function(){a._rebuild()})),this._meshDisposeObserver=this._source.onDisposeObservable.add((function(){a.dispose()}))}return Object.defineProperty(e.prototype,"linesPositions",{get:function(){return this._linesPositions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesNormals",{get:function(){return this._linesNormals},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesIndices",{get:function(){return this._linesIndices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineShader",{get:function(){return this._lineShader},set:function(e){this._lineShader=e},enumerable:!1,configurable:!0}),e._GetShader=function(e){if(!e._edgeRenderLineShader){var t=new ld("lineShader",e,"line",{attributes:["position","normal"],uniforms:["world","viewProjection","color","width","aspectRatio"]},!1);t.disableDepthWrite=!0,t.backFaceCulling=!1,t.checkReadyOnEveryCall=e.getEngine().isWebGPU,e._edgeRenderLineShader=t}return e._edgeRenderLineShader},e.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=e._GetShader(this._source.getScene()))},e.prototype._rebuild=function(){var e=this._buffers[Nr.PositionKind];e&&e._rebuild(),(e=this._buffers[Nr.NormalKind])&&e._rebuild();var t=this._source.getScene().getEngine();this._ib=t.createIndexBuffer(this._linesIndices)},e.prototype.dispose=function(){var e;this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var t=this._buffers[Nr.PositionKind];t&&(t.dispose(),this._buffers[Nr.PositionKind]=null),(t=this._buffers[Nr.NormalKind])&&(t.dispose(),this._buffers[Nr.NormalKind]=null),this._ib&&this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose(),null===(e=this._drawWrapper)||void 0===e||e.dispose()},e.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},e.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){var o=1e-10;return e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(r,o)||e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(i,o)?0:e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(n,o)||e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(r,o)?1:e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(i,o)||e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(n,o)?2:-1},e.prototype._checkEdge=function(e,t,i,r,n){(void 0===t||V.Dot(i[e],i[t])=0&&t.push(i);for(var r=0;r=e[0].length&&e[1].length>=e[2].length?o=1:e[2].length>=e[0].length&&e[2].length>=e[1].length&&(o=2);for(var a=0;a<3;++a)a===o?e[a].sort((function(e,t){return e[1]t[1]?1:0})):e[a].sort((function(e,t){return e[1]>t[1]?-1:e[1]=o+1;--u)n(e[u%3],l,u!==o+2?r[i[t+(u+1)%3]]:-1);var h=l.length;i.push(r[i[t+o]],s[0],l[0]),i.push(r[i[t+(o+1)%3]],l[h-1],s[c-1]);for(var d=c<=h,p=d?c:h,f=d?h:c,_=d?c-1:h-1,m=d?0:1,g=c+h-2,v=0,y=0,b=d?s:l,T=d?l:s,E=0;g-- >0;){m?i.push(b[v],T[y]):i.push(T[y],b[v]);var S=void 0;(E+=p)>=f&&v<_?(S=b[++v],E-=f):S=T[++y],i.push(S)}i[t+0]=i[i.length-3],i[t+1]=i[i.length-2],i[t+2]=i[i.length-1],i.length=i.length-3},e.prototype._generateEdgesLinesAlternate=function(){var e,t,i,r,n,o,a,s,l,c,u=this._source.getVerticesData(Nr.PositionKind),h=this._source.getIndices();if(h&&u){Array.isArray(h)||(h=Array.from(h));var d=null===(t=null===(e=this._options)||void 0===e?void 0:e.useFastVertexMerger)||void 0===t||t,p=d?Math.round(-Math.log(null!==(r=null===(i=this._options)||void 0===i?void 0:i.epsilonVertexMerge)&&void 0!==r?r:1e-6)/Math.log(10)):null!==(o=null===(n=this._options)||void 0===n?void 0:n.epsilonVertexMerge)&&void 0!==o?o:1e-6,f=[],_=[];if(d)for(var m={},g=0;gN){var te=D;D=N,N=te}(re=$[ie=D+"_"+N])?re.done||(V.Dot(ee,re.normal)0||this._source.hasThinInstances)},e.prototype.render=function(){var e=this._source.getScene(),t=this._lineShader._getDrawWrapper();if(this._drawWrapper&&this._lineShader._setDrawWrapper(this._drawWrapper),this.isReady()&&e.activeCamera){var i=this._source.hasInstances&&this.customInstances.length>0,r=i||this._source.hasThinInstances,n=0;if(r)if(this._buffersForInstances.world0=this._source.getVertexBuffer("world0"),this._buffersForInstances.world1=this._source.getVertexBuffer("world1"),this._buffersForInstances.world2=this._source.getVertexBuffer("world2"),this._buffersForInstances.world3=this._source.getVertexBuffer("world3"),i){var o=this._source._instanceDataStorage;if(n=this.customInstances.length,!o.instancesData)return void(this._source.getScene()._activeMeshesFrozen||this.customInstances.reset());if(!o.isFrozen){for(var a=0,s=0;s0&&(this._useSpecificClearForDepthTexture&&this._mrtLayout[n]===u.PREPASS_DEPTH_TEXTURE_TYPE?(t.push(!1),i.push(!0)):(t.push(!0),i.push(!1)),r.push(!1));this._multiRenderAttachments=this._engine.buildTextureLayout(e),this._clearAttachments=this._engine.buildTextureLayout(t),this._clearDepthAttachments=this._engine.buildTextureLayout(i),this._defaultAttachments=this._engine.buildTextureLayout(r)},e.prototype._resetLayout=function(){for(var t=0;t=0;e--)this.renderTargets[e].dispose();for(e=0;e=5)return ae.Error("You already reached the maximum number of diffusion profiles."),0;for(var t=0;t4&&(n.push(Nr.MatricesIndicesExtraKind),n.push(Nr.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0");var l=o.morphTargetManager,c=0;l&&(c=l.numMaxInfluencers||l.numInfluencers)>0&&(r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+c),l.isUsingTextureForTargets&&r.push("#define MORPHTARGETS_TEXTURE"),qo(n,o,c)),t&&(r.push("#define INSTANCES"),Jo(n),e.getRenderingMesh().hasThinInstances&&r.push("#define THIN_INSTANCES"));var u=e._getDrawWrapper(i,!0),h=u.defines,d=r.join("\n");if(h!==d){var p=["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices"];Go(p),u.setEffect(this.scene.getEngine().createEffect("outline",n,p,["diffuseSampler","morphTargets"],d,void 0,void 0,void 0,{maxSimultaneousMorphTargets:c}),d)}return u.effect.isReady()},e.prototype._beforeRenderingMesh=function(t,i,r){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var n=i.getMaterial();n&&n.needAlphaBlendingForMesh(t)&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(u.REPLACE),this._engine.setStencilFunction(u.ALWAYS),this._engine.setStencilMask(e._StencilReference),this._engine.setStencilFunctionReference(e._StencilReference),this._engine.stencilStateComposer.useStencilGlobalOnly=!0,this.render(i,r,!0,this._passIdForDrawWrapper[1]),this._engine.setColorWrite(!0),this._engine.setStencilFunction(u.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(i,r,!1,this._passIdForDrawWrapper[0]),this._engine.setDepthWrite(this._savedDepthWrite),n&&n.needAlphaBlendingForMesh(t)&&(this._engine.stencilStateComposer.useStencilGlobalOnly=!1,this._engine.restoreStencilState())}},e.prototype._afterRenderingMesh=function(e,t,i){if(e.renderOverlay){var r=this._engine.getAlphaMode(),n=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(u.ALPHA_COMBINE),this.render(t,i,!0,this._passIdForDrawWrapper[3]),this._engine.setAlphaMode(r),this._engine.setDepthWrite(this._savedDepthWrite),this._engine.alphaState.alphaBlend=n}e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,i,!1,this._passIdForDrawWrapper[2]),this._engine.setColorWrite(!0))},e._StencilReference=4,e}(),AR=function(){function e(e){this.priority=0,this._particleSize=.1,this.onParticleSizeChanged=new f,this.particleThicknessAlpha=.05,this._useVelocity=!1,this._scene=e,this._engine=e.getEngine(),this._effectsAreDirty=!0,this._depthEffectWrapper=null,this._thicknessEffectWrapper=null}return Object.defineProperty(e.prototype,"particleSize",{get:function(){return this._particleSize},set:function(e){e!==this._particleSize&&(this._particleSize=e,this.onParticleSizeChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useInstancing",{get:function(){return!this.indexBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useVelocity",{get:function(){return this._useVelocity},set:function(e){this._useVelocity!==e&&this._hasVelocity()&&(this._useVelocity=e,this._effectsAreDirty=!0)},enumerable:!1,configurable:!0}),e.prototype._hasVelocity=function(){var e;return!!(null===(e=this.vertexBuffers)||void 0===e?void 0:e.velocity)},Object.defineProperty(e.prototype,"indexBuffer",{get:function(){return null},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"FluidRenderingObject"},e.prototype._createEffects=function(){var e=["view","projection","particleRadius","size"],t=["position","offset"],i=[];this._effectsAreDirty=!1,this.useVelocity&&(t.push("velocity"),i.push("#define FLUIDRENDERING_VELOCITY")),this._scene.useRightHandedSystem&&i.push("#define FLUIDRENDERING_RHS"),this._depthEffectWrapper=new El({engine:this._engine,useShaderStore:!0,vertexShader:"fluidRenderingParticleDepth",fragmentShader:"fluidRenderingParticleDepth",attributeNames:t,uniformNames:e,samplerNames:[],defines:i}),e.push("particleAlpha"),this._thicknessEffectWrapper=new El({engine:this._engine,useShaderStore:!0,vertexShader:"fluidRenderingParticleThickness",fragmentShader:"fluidRenderingParticleThickness",attributeNames:["position","offset"],uniformNames:e,samplerNames:[]})},e.prototype.isReady=function(){if(this._effectsAreDirty&&this._createEffects(),!this._depthEffectWrapper||!this._thicknessEffectWrapper)return!1;var e=this._depthEffectWrapper._drawWrapper.effect,t=this._thicknessEffectWrapper._drawWrapper.effect;return e.isReady()&&t.isReady()},e.prototype.renderDepthTexture=function(){var e=this.numParticles;if(this._depthEffectWrapper&&0!==e){var t=this._depthEffectWrapper._drawWrapper,i=t.effect;this._engine.enableEffect(t),this._engine.bindBuffers(this.vertexBuffers,this.indexBuffer,i),i.setMatrix("view",this._scene.getViewMatrix()),i.setMatrix("projection",this._scene.getProjectionMatrix()),i.setFloat2("size",this._particleSize,this._particleSize),i.setFloat("particleRadius",this._particleSize/2),this.useInstancing?this._engine.drawArraysType(u.MATERIAL_TriangleStripDrawMode,0,4,e):this._engine.drawElementsType(u.MATERIAL_TriangleFillMode,0,e)}},e.prototype.renderThicknessTexture=function(){var e=this.numParticles;if(this._thicknessEffectWrapper&&0!==e){var t=this._thicknessEffectWrapper._drawWrapper,i=t.effect;this._engine.setAlphaMode(u.ALPHA_ONEONE),this._engine.setDepthWrite(!1),this._engine.enableEffect(t),this._engine.bindBuffers(this.vertexBuffers,this.indexBuffer,i),i.setMatrix("view",this._scene.getViewMatrix()),i.setMatrix("projection",this._scene.getProjectionMatrix()),i.setFloat("particleAlpha",this.particleThicknessAlpha),i.setFloat2("size",this._particleSize,this._particleSize),this.useInstancing?this._engine.drawArraysType(u.MATERIAL_TriangleStripDrawMode,0,4,e):this._engine.drawElementsType(u.MATERIAL_TriangleFillMode,0,e),this._engine.setDepthWrite(!0),this._engine.setAlphaMode(u.ALPHA_DISABLE)}},e.prototype.renderDiffuseTexture=function(){},e.prototype.dispose=function(){var e,t;null===(e=this._depthEffectWrapper)||void 0===e||e.dispose(),null===(t=this._thicknessEffectWrapper)||void 0===t||t.dispose()},e}(),CR=function(e){function t(t,i){var r=e.call(this,t)||this;return r._useTrueRenderingForDiffuseTexture=!0,r._particleSystem=i,r._originalRender=i.render.bind(i),r._blendMode=i.blendMode,r._onBeforeDrawParticleObserver=null,r._updateInAnimate=r._particleSystem.updateInAnimate,r._particleSystem.updateInAnimate=!0,r._particleSystem.render=function(){return 0},r.particleSize=(i.minSize+i.maxSize)/2,r.useTrueRenderingForDiffuseTexture=!1,r}return m(t,e),Object.defineProperty(t.prototype,"particleSystem",{get:function(){return this._particleSystem},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"FluidRenderingObjectParticleSystem"},Object.defineProperty(t.prototype,"useTrueRenderingForDiffuseTexture",{get:function(){return this._useTrueRenderingForDiffuseTexture},set:function(e){var t=this;this._useTrueRenderingForDiffuseTexture!==e&&(this._useTrueRenderingForDiffuseTexture=e,e?(this._particleSystem.blendMode=this._blendMode,this._particleSystem.onBeforeDrawParticlesObservable.remove(this._onBeforeDrawParticleObserver),this._onBeforeDrawParticleObserver=null):(this._particleSystem.blendMode=-1,this._onBeforeDrawParticleObserver=this._particleSystem.onBeforeDrawParticlesObservable.add((function(){t._engine.setAlphaMode(u.ALPHA_COMBINE)}))))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexBuffers",{get:function(){return this._particleSystem.vertexBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexBuffer",{get:function(){return this._particleSystem.indexBuffer},enumerable:!1,configurable:!0}),t.prototype.isReady=function(){return e.prototype.isReady.call(this)&&this._particleSystem.isReady()},Object.defineProperty(t.prototype,"numParticles",{get:function(){return this._particleSystem.getActiveCount()},enumerable:!1,configurable:!0}),t.prototype.renderDiffuseTexture=function(){this._originalRender()},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._particleSystem.onBeforeDrawParticlesObservable.remove(this._onBeforeDrawParticleObserver),this._onBeforeDrawParticleObserver=null,this._particleSystem.render=this._originalRender,this._particleSystem.blendMode=this._blendMode,this._particleSystem.updateInAnimate=this._updateInAnimate},t}(AR),RR=function(){function e(e,t,i,r,n,o,a,s,l,c,h,d,p,_){void 0===a&&(a=u.TEXTURETYPE_FLOAT),void 0===s&&(s=u.TEXTUREFORMAT_R),void 0===l&&(l=u.TEXTURETYPE_FLOAT),void 0===c&&(c=u.TEXTUREFORMAT_R),void 0===h&&(h=!1),void 0===d&&(d=null),void 0===p&&(p=!0),void 0===_&&(_=1),this.enableBlur=!0,this.blurSizeDivisor=1,this.blurFilterSize=7,this._blurNumIterations=3,this.blurMaxFilterSize=100,this.blurDepthScale=10,this.particleSize=.02,this.onDisposeObservable=new f,this._name=e,this._scene=t,this._camera=d,this._engine=t.getEngine(),this._width=i,this._height=r,this._blurTextureSizeX=n,this._blurTextureSizeY=o,this._textureType=a,this._textureFormat=s,this._blurTextureType=l,this._blurTextureFormat=c,this._useStandardBlur=h,this._generateDepthBuffer=p,this._samples=_,this._postProcessRunningIndex=0,this.enableBlur=0!==n&&0!==o,this._rt=null,this._texture=null,this._rtBlur=null,this._textureBlurred=null,this._blurPostProcesses=null}return Object.defineProperty(e.prototype,"blurNumIterations",{get:function(){return this._blurNumIterations},set:function(e){if(this._blurNumIterations!==e&&(this._blurNumIterations=e,null!==this._blurPostProcesses)){var t=this._blurPostProcesses[0],i=this._blurPostProcesses[1];this._blurPostProcesses=[];for(var r=0;r<2*this._blurNumIterations;++r)this._blurPostProcesses[r]=1&r?i:t}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTarget",{get:function(){return this._rt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetBlur",{get:function(){return this._rtBlur},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textureBlur",{get:function(){return this._textureBlurred},enumerable:!1,configurable:!0}),e.prototype.initialize=function(){if(this.dispose(),this._createRenderTarget(),this.enableBlur&&this._texture){var e=this._createBlurPostProcesses(this._texture,this._blurTextureType,this._blurTextureFormat,this.blurSizeDivisor,this._name,this._useStandardBlur),t=e[0],i=e[1],r=e[2];this._rtBlur=t,this._textureBlurred=i,this._blurPostProcesses=r}},e.prototype.applyBlurPostProcesses=function(){this.enableBlur&&this._blurPostProcesses&&(this._postProcessRunningIndex=0,this._scene.postProcessManager.directRender(this._blurPostProcesses,this._rtBlur,!0),this._engine.unBindFramebuffer(this._rtBlur))},e.prototype._createRenderTarget=function(){this._rt=this._engine.createRenderTargetTexture({width:this._width,height:this._height},{generateMipMaps:!1,type:this._textureType,format:this._textureFormat,samplingMode:u.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:!1,samples:this._samples,label:"FluidRenderingRTT-".concat(this._name)});var e=this._rt.texture;e.incrementReferences(),this._texture=new Ja(null,this._scene),this._texture.name="rtt"+this._name,this._texture._texture=e,this._texture.wrapU=Ja.CLAMP_ADDRESSMODE,this._texture.wrapV=Ja.CLAMP_ADDRESSMODE,this._texture.anisotropicFilteringLevel=1},e.prototype._createBlurPostProcesses=function(e,t,i,r,n,o){var a=this;void 0===o&&(o=!1);var s=this._scene.getEngine(),l=new U(Math.floor(this._blurTextureSizeX/r),Math.floor(this._blurTextureSizeY/r)),c=t===u.TEXTURETYPE_FLOAT&&s.getCaps().textureFloatLinearFiltering||t===u.TEXTURETYPE_HALF_FLOAT&&s.getCaps().textureHalfFloatLinearFiltering,h=this._engine.createRenderTargetTexture({width:l.x,height:l.y},{generateMipMaps:!1,type:t,format:i,samplingMode:c?u.TEXTURE_BILINEAR_SAMPLINGMODE:u.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1,samples:this._samples,label:"FluidRenderingRTTBlur-".concat(n)}),d=h.texture;d.incrementReferences();var p=new Ja(null,this._scene);if(p.name="rttBlurred"+n,p._texture=d,p.wrapU=Ja.CLAMP_ADDRESSMODE,p.wrapV=Ja.CLAMP_ADDRESSMODE,p.anisotropicFilteringLevel=1,o){var f=new hl("BilateralBlurX","fluidRenderingStandardBlur",["filterSize","blurDir"],null,1,null,u.TEXTURE_NEAREST_SAMPLINGMODE,s,!0,null,t,void 0,void 0,void 0,i);f.samples=this._samples,f.externalTextureSamplerBinding=!0,f.onApplyObservable.add((function(t){0===a._postProcessRunningIndex?t.setTexture("textureSampler",e):t._bindTexture("textureSampler",f.inputTexture.texture),t.setInt("filterSize",a.blurFilterSize),t.setFloat2("blurDir",1/a._blurTextureSizeX,0),a._postProcessRunningIndex++})),f.onSizeChangedObservable.add((function(){f._textures.forEach((function(e){e.texture.wrapU=Ja.CLAMP_ADDRESSMODE,e.texture.wrapV=Ja.CLAMP_ADDRESSMODE}))})),this._fixReusablePostProcess(f);var _=new hl("BilateralBlurY","fluidRenderingStandardBlur",["filterSize","blurDir"],null,1,null,u.TEXTURE_NEAREST_SAMPLINGMODE,s,!0,null,t,void 0,void 0,void 0,i);_.samples=this._samples,_.onApplyObservable.add((function(e){e.setInt("filterSize",a.blurFilterSize),e.setFloat2("blurDir",0,1/a._blurTextureSizeY),a._postProcessRunningIndex++})),_.onSizeChangedObservable.add((function(){_._textures.forEach((function(e){e.texture.wrapU=Ja.CLAMP_ADDRESSMODE,e.texture.wrapV=Ja.CLAMP_ADDRESSMODE}))})),this._fixReusablePostProcess(_),f.autoClear=!1,_.autoClear=!1;for(var m=[],g=0;g<2*this._blurNumIterations;++g)m[g]=1&g?_:f;return[h,p,m]}var v=["maxFilterSize","blurDir","projectedParticleConstant","depthThreshold"],y=new hl("BilateralBlurX","fluidRenderingBilateralBlur",v,null,1,null,u.TEXTURE_NEAREST_SAMPLINGMODE,s,!0,null,t,void 0,void 0,void 0,i);y.samples=this._samples,y.externalTextureSamplerBinding=!0,y.onApplyObservable.add((function(t){0===a._postProcessRunningIndex?t.setTexture("textureSampler",e):t._bindTexture("textureSampler",y.inputTexture.texture),t.setInt("maxFilterSize",a.blurMaxFilterSize),t.setFloat2("blurDir",1/a._blurTextureSizeX,0),t.setFloat("projectedParticleConstant",a._getProjectedParticleConstant()),t.setFloat("depthThreshold",a._getDepthThreshold()),a._postProcessRunningIndex++})),y.onSizeChangedObservable.add((function(){y._textures.forEach((function(e){e.texture.wrapU=Ja.CLAMP_ADDRESSMODE,e.texture.wrapV=Ja.CLAMP_ADDRESSMODE}))})),this._fixReusablePostProcess(y);var b=new hl("BilateralBlurY","fluidRenderingBilateralBlur",v,null,1,null,u.TEXTURE_NEAREST_SAMPLINGMODE,s,!0,null,t,void 0,void 0,void 0,i);for(b.samples=this._samples,b.onApplyObservable.add((function(e){e.setInt("maxFilterSize",a.blurMaxFilterSize),e.setFloat2("blurDir",0,1/a._blurTextureSizeY),e.setFloat("projectedParticleConstant",a._getProjectedParticleConstant()),e.setFloat("depthThreshold",a._getDepthThreshold()),a._postProcessRunningIndex++})),b.onSizeChangedObservable.add((function(){b._textures.forEach((function(e){e.texture.wrapU=Ja.CLAMP_ADDRESSMODE,e.texture.wrapV=Ja.CLAMP_ADDRESSMODE}))})),this._fixReusablePostProcess(b),y.autoClear=!1,b.autoClear=!1,m=[],g=0;g<2*this._blurNumIterations;++g)m[g]=1&g?b:y;return[h,p,m]},e.prototype._fixReusablePostProcess=function(e){e.isReusable()&&(e.onActivateObservable.add((function(){e._currentRenderTextureInd=(e._currentRenderTextureInd+1)%2})),e.onApplyObservable.add((function(){e._currentRenderTextureInd=(e._currentRenderTextureInd+1)%2})))},e.prototype._getProjectedParticleConstant=function(){var e,t;return this.blurFilterSize*this.particleSize*.05*(this._height/2)/Math.tan((null!==(t=null===(e=this._camera)||void 0===e?void 0:e.fov)&&void 0!==t?t:45*Math.PI/180)/2)},e.prototype._getDepthThreshold=function(){return this.particleSize/2*this.blurDepthScale},e.prototype.dispose=function(){var e,t,i,r;this.onDisposeObservable.hasObservers()&&this.onDisposeObservable.notifyObservers(this),null===(e=this._rt)||void 0===e||e.dispose(),this._rt=null,null===(t=this._texture)||void 0===t||t.dispose(),this._texture=null,null===(i=this._rtBlur)||void 0===i||i.dispose(),this._rtBlur=null,null===(r=this._textureBlurred)||void 0===r||r.dispose(),this._textureBlurred=null,this._blurPostProcesses&&(this._blurPostProcesses[0].dispose(),this._blurPostProcesses[1].dispose()),this._blurPostProcesses=null},e}();!function(e){e[e.DepthTexture=0]="DepthTexture",e[e.DepthBlurredTexture=1]="DepthBlurredTexture",e[e.ThicknessTexture=2]="ThicknessTexture",e[e.ThicknessBlurredTexture=3]="ThicknessBlurredTexture",e[e.DiffuseTexture=4]="DiffuseTexture",e[e.Normals=5]="Normals",e[e.DiffuseRendering=6]="DiffuseRendering"}(SR||(SR={}));var PR,IR=function(){function e(e,t){this._generateDiffuseTexture=!1,this.fluidColor=new Z(.085,.6375,.765),this.density=2,this.refractionStrength=.1,this.fresnelClamp=1,this.specularPower=250,this.minimumThickness=0,this.dirLight=new V(-2,-1,1).normalize(),this._debugFeature=SR.DepthBlurredTexture,this._debug=!1,this._enableBlurDepth=!0,this._blurDepthSizeDivisor=1,this._blurDepthFilterSize=7,this._blurDepthNumIterations=3,this._blurDepthMaxFilterSize=100,this._blurDepthDepthScale=10,this._enableBlurThickness=!0,this._blurThicknessSizeDivisor=1,this._blurThicknessFilterSize=5,this._blurThicknessNumIterations=1,this._useFixedThickness=!1,this._onUseVelocityChanged=new f,this._useVelocity=!1,this._depthMapSize=null,this._thicknessMapSize=null,this._diffuseMapSize=null,this._samples=1,this._compositeMode=!1,this._scene=e,this._engine=e.getEngine(),this._camera=null!=t?t:e.activeCamera,this._needInitialization=!0,this._bgDepthTexture=null,this._invProjectionMatrix=new z,this._depthClearColor=new J(1e6,1e6,1e6,1),this._thicknessClearColor=new J(0,0,0,1),this._depthRenderTarget=null,this._diffuseRenderTarget=null,this._thicknessRenderTarget=null,this._renderPostProcess=null}return Object.defineProperty(e.prototype,"needInitialization",{get:function(){return this._needInitialization},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"generateDiffuseTexture",{get:function(){return this._generateDiffuseTexture},set:function(e){this._generateDiffuseTexture!==e&&(this._generateDiffuseTexture=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugFeature",{get:function(){return this._debugFeature},set:function(e){this._debugFeature!==e&&(this._needInitialization=!0,this._debugFeature=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug!==e&&(this._debug=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"environmentMap",{get:function(){return this._environmentMap},set:function(e){this._environmentMap!==e&&(this._needInitialization=!0,this._environmentMap=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableBlurDepth",{get:function(){return this._enableBlurDepth},set:function(e){this._enableBlurDepth!==e&&(this._enableBlurDepth=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurDepthSizeDivisor",{get:function(){return this._blurDepthSizeDivisor},set:function(e){this._blurDepthSizeDivisor!==e&&(this._blurDepthSizeDivisor=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurDepthFilterSize",{get:function(){return this._blurDepthFilterSize},set:function(e){this._blurDepthFilterSize!==e&&(this._blurDepthFilterSize=e,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurDepthNumIterations",{get:function(){return this._blurDepthNumIterations},set:function(e){this._blurDepthNumIterations!==e&&(this._blurDepthNumIterations=e,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurDepthMaxFilterSize",{get:function(){return this._blurDepthMaxFilterSize},set:function(e){this._blurDepthMaxFilterSize!==e&&(this._blurDepthMaxFilterSize=e,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurDepthDepthScale",{get:function(){return this._blurDepthDepthScale},set:function(e){this._blurDepthDepthScale!==e&&(this._blurDepthDepthScale=e,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableBlurThickness",{get:function(){return this._enableBlurThickness},set:function(e){this._enableBlurThickness!==e&&(this._enableBlurThickness=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurThicknessSizeDivisor",{get:function(){return this._blurThicknessSizeDivisor},set:function(e){this._blurThicknessSizeDivisor!==e&&(this._blurThicknessSizeDivisor=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurThicknessFilterSize",{get:function(){return this._blurThicknessFilterSize},set:function(e){this._blurThicknessFilterSize!==e&&(this._blurThicknessFilterSize=e,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurThicknessNumIterations",{get:function(){return this._blurThicknessNumIterations},set:function(e){this._blurThicknessNumIterations!==e&&(this._blurThicknessNumIterations=e,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useFixedThickness",{get:function(){return this._useFixedThickness},set:function(e){this._useFixedThickness!==e&&(this._useFixedThickness=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useVelocity",{get:function(){return this._useVelocity},set:function(e){this._useVelocity!==e&&(this._useVelocity=e,this._needInitialization=!0,this._onUseVelocityChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthMapSize",{get:function(){return this._depthMapSize},set:function(e){this._depthMapSize!==e&&(this._depthMapSize=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thicknessMapSize",{get:function(){return this._thicknessMapSize},set:function(e){this._thicknessMapSize!==e&&(this._thicknessMapSize=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseMapSize",{get:function(){return this._diffuseMapSize},set:function(e){this._diffuseMapSize!==e&&(this._diffuseMapSize=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"compositeMode",{get:function(){return this._compositeMode},set:function(e){this._compositeMode!==e&&(this._compositeMode=e,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},enumerable:!1,configurable:!0}),e.prototype._initialize=function(){var e,t,i;this.dispose(),this._needInitialization=!1;var r=null!==(e=this._depthMapSize)&&void 0!==e?e:this._engine.getRenderWidth(),n=null!==this._depthMapSize?Math.round(this._depthMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();if(this._depthRenderTarget=new RR("Depth",this._scene,r,n,r,n,u.TEXTURETYPE_FLOAT,u.TEXTUREFORMAT_RG,u.TEXTURETYPE_FLOAT,u.TEXTUREFORMAT_RG,!1,this._camera,!0,this._samples),this._initializeRenderTarget(this._depthRenderTarget),this.generateDiffuseTexture){var o=null!==(t=this._diffuseMapSize)&&void 0!==t?t:this._engine.getRenderWidth(),a=null!==this._diffuseMapSize?Math.round(this._diffuseMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();this._diffuseRenderTarget=new RR("Diffuse",this._scene,o,a,0,0,u.TEXTURETYPE_UNSIGNED_BYTE,u.TEXTUREFORMAT_RGBA,u.TEXTURETYPE_UNSIGNED_BYTE,u.TEXTUREFORMAT_RGBA,!0,this._camera,!0,this._samples),this._initializeRenderTarget(this._diffuseRenderTarget)}var s=null!==(i=this._thicknessMapSize)&&void 0!==i?i:this._engine.getRenderWidth(),l=null!==this._thicknessMapSize?Math.round(this._thicknessMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();this._useFixedThickness||(this._thicknessRenderTarget=new RR("Thickness",this._scene,s,l,s,l,u.TEXTURETYPE_HALF_FLOAT,u.TEXTUREFORMAT_R,u.TEXTURETYPE_HALF_FLOAT,u.TEXTUREFORMAT_R,!0,this._camera,!1,this._samples),this._initializeRenderTarget(this._thicknessRenderTarget)),this._createLiquidRenderingPostProcess()},e.prototype._setBlurParameters=function(e){void 0===e&&(e=null),null!==e&&e!==this._depthRenderTarget||this._setBlurDepthParameters(),null!==e&&e!==this._thicknessRenderTarget||this._setBlurThicknessParameters()},e.prototype._setBlurDepthParameters=function(){this._depthRenderTarget&&(this._depthRenderTarget.blurFilterSize=this.blurDepthFilterSize,this._depthRenderTarget.blurMaxFilterSize=this.blurDepthMaxFilterSize,this._depthRenderTarget.blurNumIterations=this.blurDepthNumIterations,this._depthRenderTarget.blurDepthScale=this.blurDepthDepthScale)},e.prototype._setBlurThicknessParameters=function(){this._thicknessRenderTarget&&(this._thicknessRenderTarget.blurFilterSize=this.blurThicknessFilterSize,this._thicknessRenderTarget.blurNumIterations=this.blurThicknessNumIterations)},e.prototype._initializeRenderTarget=function(e){e!==this._diffuseRenderTarget&&(e.enableBlur=e===this._depthRenderTarget?this.enableBlurDepth:this.enableBlurThickness,e.blurSizeDivisor=e===this._depthRenderTarget?this.blurDepthSizeDivisor:this.blurThicknessSizeDivisor),this._setBlurParameters(e),e.initialize()},e.prototype._createLiquidRenderingPostProcess=function(){var e,t=this,i=this._scene.getEngine(),r=["viewMatrix","projectionMatrix","invProjectionMatrix","texelSize","dirLight","cameraFar","density","refractionStrength","fresnelClamp","specularPower"],n=["depthSampler"],o=[];if(this.dispose(!0),this._camera){var a=this._depthRenderTarget.enableBlur?this._depthRenderTarget.textureBlur:this._depthRenderTarget.texture,s=new U(1/a.getSize().width,1/a.getSize().height);this._scene.useRightHandedSystem&&o.push("#define FLUIDRENDERING_RHS"),null!==this._environmentMap&&(null!==(e=this._environmentMap)&&void 0!==e?e:this._scene.environmentTexture)&&(n.push("reflectionSampler"),o.push("#define FLUIDRENDERING_ENVIRONMENT")),this._diffuseRenderTarget?(n.push("diffuseSampler"),o.push("#define FLUIDRENDERING_DIFFUSETEXTURE")):r.push("diffuseColor"),this._useVelocity&&(n.push("velocitySampler"),o.push("#define FLUIDRENDERING_VELOCITY")),this._useFixedThickness?(r.push("thickness"),n.push("bgDepthSampler"),o.push("#define FLUIDRENDERING_FIXED_THICKNESS")):(r.push("minimumThickness"),n.push("thicknessSampler")),this._compositeMode&&o.push("#define FLUIDRENDERING_COMPOSITE_MODE"),this._debug&&(o.push("#define FLUIDRENDERING_DEBUG"),this._debugFeature===SR.Normals?o.push("#define FLUIDRENDERING_DEBUG_SHOWNORMAL"):this._debugFeature===SR.DiffuseRendering?o.push("#define FLUIDRENDERING_DEBUG_DIFFUSERENDERING"):(o.push("#define FLUIDRENDERING_DEBUG_TEXTURE"),n.push("debugSampler"),this._debugFeature!==SR.DepthTexture&&this._debugFeature!==SR.DepthBlurredTexture||o.push("#define FLUIDRENDERING_DEBUG_DEPTH"))),this._renderPostProcess=new hl("FluidRendering","fluidRenderingRender",r,n,1,null,u.TEXTURE_BILINEAR_SAMPLINGMODE,i,!1,null,u.TEXTURETYPE_UNSIGNED_BYTE,void 0,void 0,!0,void 0),this._renderPostProcess.updateEffect(o.join("\n")),this._renderPostProcess.samples=this._samples;var l=i,c=l.setTextureSampler;this._renderPostProcess.onApplyObservable.add((function(e){var i,r,n,o,a,u,h,d,p,f,_,m,g,v,y,b,T,E,S,x,A,C,R;if(t._invProjectionMatrix.copyFrom(t._scene.getProjectionMatrix()),t._invProjectionMatrix.invert(),c&&c.call(l,"textureSamplerSampler",t._renderPostProcess.inputTexture.texture),t._depthRenderTarget.enableBlur?(e.setTexture("depthSampler",t._depthRenderTarget.textureBlur),c&&c.call(l,"depthSamplerSampler",null!==(o=null===(n=t._depthRenderTarget.textureBlur)||void 0===n?void 0:n.getInternalTexture())&&void 0!==o?o:null)):(e.setTexture("depthSampler",t._depthRenderTarget.texture),c&&c.call(l,"depthSamplerSampler",null!==(r=null===(i=t._depthRenderTarget.texture)||void 0===i?void 0:i.getInternalTexture())&&void 0!==r?r:null)),t._diffuseRenderTarget?t._diffuseRenderTarget.enableBlur?(e.setTexture("diffuseSampler",t._diffuseRenderTarget.textureBlur),c&&c.call(l,"diffuseSamplerSampler",null!==(d=null===(h=t._diffuseRenderTarget.textureBlur)||void 0===h?void 0:h.getInternalTexture())&&void 0!==d?d:null)):(e.setTexture("diffuseSampler",t._diffuseRenderTarget.texture),c&&c.call(l,"diffuseSamplerSampler",null!==(u=null===(a=t._diffuseRenderTarget.texture)||void 0===a?void 0:a.getInternalTexture())&&void 0!==u?u:null)):e.setColor3("diffuseColor",t.fluidColor),t._useFixedThickness?(e.setFloat("thickness",t.minimumThickness),e._bindTexture("bgDepthSampler",t._bgDepthTexture),c&&c.call(l,"bgDepthSamplerSampler",null!==(p=t._bgDepthTexture)&&void 0!==p?p:null)):(t._thicknessRenderTarget.enableBlur?(e.setTexture("thicknessSampler",t._thicknessRenderTarget.textureBlur),c&&c.call(l,"thicknessSamplerSampler",null!==(g=null===(m=t._thicknessRenderTarget.textureBlur)||void 0===m?void 0:m.getInternalTexture())&&void 0!==g?g:null)):(e.setTexture("thicknessSampler",t._thicknessRenderTarget.texture),c&&c.call(l,"thicknessSamplerSampler",null!==(_=null===(f=t._thicknessRenderTarget.texture)||void 0===f?void 0:f.getInternalTexture())&&void 0!==_?_:null)),e.setFloat("minimumThickness",t.minimumThickness)),null!==t._environmentMap){var P=null!==(v=t._environmentMap)&&void 0!==v?v:t._scene.environmentTexture;P&&(e.setTexture("reflectionSampler",P),c&&c.call(l,"reflectionSamplerSampler",null!==(y=null==P?void 0:P.getInternalTexture())&&void 0!==y?y:null))}if(e.setMatrix("viewMatrix",t._scene.getViewMatrix()),e.setMatrix("invProjectionMatrix",t._invProjectionMatrix),e.setMatrix("projectionMatrix",t._scene.getProjectionMatrix()),e.setVector2("texelSize",s),e.setFloat("density",t.density),e.setFloat("refractionStrength",t.refractionStrength),e.setFloat("fresnelClamp",t.fresnelClamp),e.setFloat("specularPower",t.specularPower),e.setVector3("dirLight",t.dirLight),e.setFloat("cameraFar",t._camera.maxZ),t._debug){var I=null;switch(t._debugFeature){case SR.DepthTexture:I=t._depthRenderTarget.texture;break;case SR.DepthBlurredTexture:I=t._depthRenderTarget.enableBlur?t._depthRenderTarget.textureBlur:t._depthRenderTarget.texture;break;case SR.ThicknessTexture:I=null!==(T=null===(b=t._thicknessRenderTarget)||void 0===b?void 0:b.texture)&&void 0!==T?T:null;break;case SR.ThicknessBlurredTexture:I=(null===(E=t._thicknessRenderTarget)||void 0===E?void 0:E.enableBlur)?null!==(x=null===(S=t._thicknessRenderTarget)||void 0===S?void 0:S.textureBlur)&&void 0!==x?x:null:null!==(C=null===(A=t._thicknessRenderTarget)||void 0===A?void 0:A.texture)&&void 0!==C?C:null;break;case SR.DiffuseTexture:t._diffuseRenderTarget&&(I=t._diffuseRenderTarget.texture)}t._debugFeature!==SR.Normals&&(e.setTexture("debugSampler",I),c&&c.call(l,"debugSamplerSampler",null!==(R=null==I?void 0:I.getInternalTexture())&&void 0!==R?R:null))}}))}},e.prototype._clearTargets=function(){var e,t,i;(null===(e=this._depthRenderTarget)||void 0===e?void 0:e.renderTarget)&&(this._engine.bindFramebuffer(this._depthRenderTarget.renderTarget),this._engine.clear(this._depthClearColor,!0,!0,!1),this._engine.unBindFramebuffer(this._depthRenderTarget.renderTarget)),(null===(t=this._diffuseRenderTarget)||void 0===t?void 0:t.renderTarget)&&(this._engine.bindFramebuffer(this._diffuseRenderTarget.renderTarget),this._engine.clear(this._thicknessClearColor,!0,!0,!1),this._engine.unBindFramebuffer(this._diffuseRenderTarget.renderTarget)),(null===(i=this._thicknessRenderTarget)||void 0===i?void 0:i.renderTarget)&&(this._engine.bindFramebuffer(this._thicknessRenderTarget.renderTarget),this._engine.clear(this._thicknessClearColor,!0,!1,!1),this._engine.unBindFramebuffer(this._thicknessRenderTarget.renderTarget))},e.prototype._render=function(e){var t,i,r,n,o,a;if(!this._needInitialization&&e.isReady()){var s=this._engine._currentRenderTarget;this._engine.setState(!1,void 0,void 0,void 0,!0),this._engine.setDepthBuffer(!0),this._engine.setDepthWrite(!0),this._engine.setAlphaMode(u.ALPHA_DISABLE),(null===(t=this._depthRenderTarget)||void 0===t?void 0:t.renderTarget)&&(this._engine.bindFramebuffer(this._depthRenderTarget.renderTarget),e.renderDepthTexture(),this._engine.unbindInstanceAttributes(),this._engine.unBindFramebuffer(this._depthRenderTarget.renderTarget)),(null===(i=this._diffuseRenderTarget)||void 0===i?void 0:i.renderTarget)&&(this._engine.bindFramebuffer(this._diffuseRenderTarget.renderTarget),e.renderDiffuseTexture(),this._engine.unbindInstanceAttributes(),this._engine.unBindFramebuffer(this._diffuseRenderTarget.renderTarget)),(null===(r=this._thicknessRenderTarget)||void 0===r?void 0:r.renderTarget)&&(this._engine.bindFramebuffer(this._thicknessRenderTarget.renderTarget),e.renderThicknessTexture(),this._engine.unbindInstanceAttributes(),this._engine.unBindFramebuffer(this._thicknessRenderTarget.renderTarget)),null===(n=this._depthRenderTarget)||void 0===n||n.applyBlurPostProcesses(),null===(o=this._diffuseRenderTarget)||void 0===o||o.applyBlurPostProcesses(),null===(a=this._thicknessRenderTarget)||void 0===a||a.applyBlurPostProcesses(),s&&this._engine.bindFramebuffer(s)}},e.prototype.dispose=function(e){var t,i,r,n;void 0===e&&(e=!1),e||(null===(t=this._depthRenderTarget)||void 0===t||t.dispose(),this._depthRenderTarget=null,null===(i=this._diffuseRenderTarget)||void 0===i||i.dispose(),this._diffuseRenderTarget=null,null===(r=this._thicknessRenderTarget)||void 0===r||r.dispose(),this._thicknessRenderTarget=null),this._renderPostProcess&&this._camera&&this._camera.detachPostProcess(this._renderPostProcess),null===(n=this._renderPostProcess)||void 0===n||n.dispose(),this._renderPostProcess=null,this._needInitialization=!1},e}(),MR=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n._numParticles=r,n._diffuseEffectWrapper=null,n._vertexBuffers={},n.addBuffers(i),n}return m(t,e),t.prototype.getClassName=function(){return"FluidRenderingObjectCustomParticles"},Object.defineProperty(t.prototype,"vertexBuffers",{get:function(){return this._vertexBuffers},enumerable:!1,configurable:!0}),t.prototype.addBuffers=function(e){for(var t in e){var i=void 0,r=!0;switch(t){case"velocity":i=3;break;case"offset":r=!1}this._vertexBuffers[t]=new Nr(this._engine,e[t],t,!0,!1,i,r)}},t.prototype._createEffects=function(){e.prototype._createEffects.call(this),this._diffuseEffectWrapper=new El({engine:this._engine,useShaderStore:!0,vertexShader:"fluidRenderingParticleDiffuse",fragmentShader:"fluidRenderingParticleDiffuse",attributeNames:["position","offset","color"],uniformNames:["view","projection","size"],samplerNames:[]})},t.prototype.isReady=function(){var t,i;return this._vertexBuffers.offset||(this._vertexBuffers.offset=new Nr(this._engine,[0,0,1,0,0,1,1,1],"offset",!1,!1,2)),e.prototype.isReady.call(this)&&null!==(i=null===(t=this._diffuseEffectWrapper)||void 0===t?void 0:t.effect.isReady())&&void 0!==i&&i},Object.defineProperty(t.prototype,"numParticles",{get:function(){return this._numParticles},enumerable:!1,configurable:!0}),t.prototype.setNumParticles=function(e){this._numParticles=e},t.prototype.renderDiffuseTexture=function(){var e=this.numParticles;if(this._diffuseEffectWrapper&&0!==e){var t=this._diffuseEffectWrapper._drawWrapper,i=t.effect;this._engine.enableEffect(t),this._engine.bindBuffers(this.vertexBuffers,this.indexBuffer,i),i.setMatrix("view",this._scene.getViewMatrix()),i.setMatrix("projection",this._scene.getProjectionMatrix()),null!==this._particleSize&&i.setFloat2("size",this._particleSize,this._particleSize),this.useInstancing?this._engine.drawArraysType(u.MATERIAL_TriangleStripDrawMode,0,4,e):this._engine.drawElementsType(u.MATERIAL_TriangleFillMode,0,e)}},t.prototype.dispose=function(){var t;for(var i in e.prototype.dispose.call(this),null===(t=this._diffuseEffectWrapper)||void 0===t||t.dispose(),this._vertexBuffers)this._vertexBuffers[i].dispose();this._vertexBuffers={}},t}(AR);li.ShadersStore.copyTextureToTexturePixelShader="uniform float conversion;uniform sampler2D textureSampler;varying vec2 vUV;\n#include\nvoid main(void) \n{vec4 color=texture2D(textureSampler,vUV);\n#ifdef DEPTH_TEXTURE\ngl_FragDepth=color.r;\n#else\nif (conversion==1.) {color=toLinearSpace(color);} else if (conversion==2.) {color=toGammaSpace(color);}\ngl_FragColor=color;\n#endif\n}\n",function(e){e[e.None=0]="None",e[e.ToLinearSpace=1]="ToLinearSpace",e[e.ToGammaSpace=2]="ToGammaSpace"}(PR||(PR={}));var OR=function(){function e(e,t){void 0===t&&(t=!1);var i=this;this._engine=e,this._isDepthTexture=t,this._renderer=new Tl(e),this._effectWrapper=new El({engine:e,name:"CopyTextureToTexture",fragmentShader:"copyTextureToTexture",useShaderStore:!0,uniformNames:["conversion"],samplerNames:["textureSampler"],defines:t?["#define DEPTH_TEXTURE"]:[]}),this._effectWrapper.onApplyObservable.add((function(){t&&(e.setState(!1),e.setDepthBuffer(!0),e.depthCullingState.depthMask=!0,e.depthCullingState.depthFunc=u.ALWAYS),i._textureIsInternal(i._source)?i._effectWrapper.effect._bindTexture("textureSampler",i._source):i._effectWrapper.effect.setTexture("textureSampler",i._source),i._effectWrapper.effect.setFloat("conversion",i._conversion)}))}return e.prototype._textureIsInternal=function(e){return void 0===e.getInternalTexture},e.prototype.isReady=function(){return this._effectWrapper.effect.isReady()},e.prototype.copy=function(e,t,i){if(void 0===i&&(i=PR.None),!this.isReady())return!1;this._source=e,this._conversion=i;var r=this._engine.depthCullingState.depthFunc;return this._renderer.render(this._effectWrapper,t),this._isDepthTexture&&r&&(this._engine.depthCullingState.depthFunc=r),!0},e.prototype.dispose=function(){this._effectWrapper.dispose(),this._renderer.dispose()},e}(),DR=function(){function e(e,t,i,r){void 0===r&&(r=1),this._engine=e,this._copyTextureToTexture=new OR(e,!0),this._depthRTWrapper=this._engine.createRenderTargetTexture({width:t,height:i},{generateMipMaps:!1,type:u.TEXTURETYPE_UNSIGNED_BYTE,format:u.TEXTUREFORMAT_R,samplingMode:u.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:!0,generateStencilBuffer:!1,samples:r,noColorAttachment:!0,label:"FluidRenderingDepthTextureCopyRTT"}),this._depthRTWrapper.createDepthStencilTexture(0,!1,!1,1,void 0,"FluidRenderingDepthTextureCopyRTTDepthStencil").label="FluidDepthTextureCopy".concat(t,"x").concat(i,"x").concat(r)}return Object.defineProperty(e.prototype,"depthRTWrapper",{get:function(){return this._depthRTWrapper},enumerable:!1,configurable:!0}),e.prototype.copy=function(e){return this._copyTextureToTexture.copy(e,this._depthRTWrapper)},e.prototype.dispose=function(){this._depthRTWrapper.dispose(),this._copyTextureToTexture.dispose()},e}();li.ShadersStore.fluidRenderingParticleDepthVertexShader="attribute vec3 position;attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;varying vec3 viewPos;varying float sphereRadius;\n#ifdef FLUIDRENDERING_VELOCITY\nattribute vec3 velocity;varying float velocityNorm;\n#endif\nvoid main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;viewPos=(view*vec4(position,1.0)).xyz;gl_Position=projection*vec4(viewPos+cornerPos,1.0);uv=offset;sphereRadius=size.x/2.0;\n#ifdef FLUIDRENDERING_VELOCITY\nvelocityNorm=length(velocity);\n#endif\n}\n";li.ShadersStore.fluidRenderingParticleDepthPixelShader="uniform mat4 projection;varying vec2 uv;varying vec3 viewPos;varying float sphereRadius;\n#ifdef FLUIDRENDERING_VELOCITY\nvarying float velocityNorm;\n#endif\nvoid main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;normal.z=sqrt(1.0-r2);\n#ifndef FLUIDRENDERING_RHS\nnormal.z=-normal.z;\n#endif\nvec4 realViewPos=vec4(viewPos+normal*sphereRadius,1.0);vec4 clipSpacePos=projection*realViewPos;\n#ifdef WEBGPU\ngl_FragDepth=clipSpacePos.z/clipSpacePos.w;\n#else\ngl_FragDepth=(clipSpacePos.z/clipSpacePos.w)*0.5+0.5;\n#endif\n#ifdef FLUIDRENDERING_RHS\nrealViewPos.z=-realViewPos.z;\n#endif\n#ifdef FLUIDRENDERING_VELOCITY\nglFragColor=vec4(realViewPos.z,velocityNorm,0.,1.);\n#else\nglFragColor=vec4(realViewPos.z,0.,0.,1.);\n#endif\n}\n";li.ShadersStore.fluidRenderingParticleThicknessVertexShader="attribute vec3 position;attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;vec3 viewPos=(view*vec4(position,1.0)).xyz+cornerPos;gl_Position=projection*vec4(viewPos,1.0);uv=offset;}\n";li.ShadersStore.fluidRenderingParticleThicknessPixelShader="uniform float particleAlpha;varying vec2 uv;void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;float thickness=sqrt(1.0-r2);glFragColor=vec4(vec3(particleAlpha*thickness),1.0);}\n";li.ShadersStore.fluidRenderingParticleDiffuseVertexShader="attribute vec3 position;attribute vec2 offset;attribute vec4 color;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;varying vec3 diffuseColor;void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;vec3 viewPos=(view*vec4(position,1.0)).xyz+cornerPos;gl_Position=projection*vec4(viewPos,1.0);uv=offset;diffuseColor=color.rgb;}\n";li.ShadersStore.fluidRenderingParticleDiffusePixelShader="uniform float particleAlpha;varying vec2 uv;varying vec3 diffuseColor;void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;glFragColor=vec4(diffuseColor,1.0);}\n";li.ShadersStore.fluidRenderingBilateralBlurPixelShader="uniform sampler2D textureSampler;uniform int maxFilterSize;uniform vec2 blurDir;uniform float projectedParticleConstant;uniform float depthThreshold;varying vec2 vUV;void main(void) {float depth=textureLod(textureSampler,vUV,0.).x;if (depth>=1e6 || depth<=0.) {glFragColor=vec4(vec3(depth),1.);return;}\nint filterSize=min(maxFilterSize,int(ceil(projectedParticleConstant/depth)));float sigma=float(filterSize)/3.0;float two_sigma2=2.0*sigma*sigma;float sigmaDepth=depthThreshold/3.0;float two_sigmaDepth2=2.0*sigmaDepth*sigmaDepth;float sum=0.;float wsum=0.;float sumVel=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec2 sampleDepthVel=textureLod(textureSampler,vUV+coords*blurDir,0.).rg;float r=dot(coords,coords);float w=exp(-r/two_sigma2);float rDepth=sampleDepthVel.r-depth;float wd=exp(-rDepth*rDepth/two_sigmaDepth2);sum+=sampleDepthVel.r*w*wd;sumVel+=sampleDepthVel.g*w*wd;wsum+=w*wd;}\nglFragColor=vec4(sum/wsum,sumVel/wsum,0.,1.);}\n";li.ShadersStore.fluidRenderingStandardBlurPixelShader="uniform sampler2D textureSampler;uniform int filterSize;uniform vec2 blurDir;varying vec2 vUV;void main(void) {vec4 s=textureLod(textureSampler,vUV,0.);if (s.r==0.) {glFragColor=vec4(0.,0.,0.,1.);return;}\nfloat sigma=float(filterSize)/3.0;float twoSigma2=2.0*sigma*sigma;vec4 sum=vec4(0.);float wsum=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec4 sampl=textureLod(textureSampler,vUV+coords*blurDir,0.);float w=exp(-coords.x*coords.x/twoSigma2);sum+=sampl*w;wsum+=w;}\nsum/=wsum;glFragColor=vec4(sum.rgb,1.);}\n";function NR(e){return!!e.particleSystem}function FR(e){return!!e.addBuffers}li.ShadersStore.fluidRenderingRenderPixelShader="/* disable_uniformity_analysis */\n#define IOR 1.333\n#define ETA 1.0/IOR\n#define F0 0.02\nuniform sampler2D textureSampler;uniform sampler2D depthSampler;\n#ifdef FLUIDRENDERING_DIFFUSETEXTURE\nuniform sampler2D diffuseSampler;\n#else\nuniform vec3 diffuseColor;\n#endif\n#ifdef FLUIDRENDERING_FIXED_THICKNESS\nuniform float thickness;uniform sampler2D bgDepthSampler;\n#else\nuniform float minimumThickness;uniform sampler2D thicknessSampler;\n#endif\n#ifdef FLUIDRENDERING_ENVIRONMENT\nuniform samplerCube reflectionSampler;\n#endif\n#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)\nuniform sampler2D debugSampler;\n#endif\nuniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform mat4 invProjectionMatrix;uniform vec2 texelSize;uniform vec3 dirLight;uniform float cameraFar;uniform float density;uniform float refractionStrength;uniform float fresnelClamp;uniform float specularPower;varying vec2 vUV;vec3 computeViewPosFromUVDepth(vec2 texCoord,float depth) {vec4 ndc;ndc.xy=texCoord*2.0-1.0;\n#ifdef FLUIDRENDERING_RHS\nndc.z=-projectionMatrix[2].z+projectionMatrix[3].z/depth;\n#else\nndc.z=projectionMatrix[2].z+projectionMatrix[3].z/depth;\n#endif\nndc.w=1.0;vec4 eyePos=invProjectionMatrix*ndc;eyePos.xyz/=eyePos.w;return eyePos.xyz;}\nvec3 getViewPosFromTexCoord(vec2 texCoord) {float depth=textureLod(depthSampler,texCoord,0.).x;return computeViewPosFromUVDepth(texCoord,depth);}\nvoid main(void) {vec2 texCoord=vUV;\n#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)\nvec4 color=texture2D(debugSampler,texCoord);\n#ifdef FLUIDRENDERING_DEBUG_DEPTH\nglFragColor=vec4(color.rgb/vec3(2.0),1.);if (color.r>0.999 && color.g>0.999) {glFragColor=texture2D(textureSampler,texCoord);}\n#else\nglFragColor=vec4(color.rgb,1.);if (color.r<0.001 && color.g<0.001 && color.b<0.001) {glFragColor=texture2D(textureSampler,texCoord);}\n#endif\nreturn;\n#endif\nvec2 depthVel=textureLod(depthSampler,texCoord,0.).rg;float depth=depthVel.r;\n#ifndef FLUIDRENDERING_FIXED_THICKNESS\nfloat thickness=texture2D(thicknessSampler,texCoord).x;\n#else\nfloat bgDepth=texture2D(bgDepthSampler,texCoord).x;float depthNonLinear=projectionMatrix[2].z+projectionMatrix[3].z/depth;depthNonLinear=depthNonLinear*0.5+0.5;\n#endif\nvec4 backColor=texture2D(textureSampler,texCoord);\n#ifndef FLUIDRENDERING_FIXED_THICKNESS\nif (depth>=cameraFar || depth<=0. || thickness<=minimumThickness) {\n#else\nif (depth>=cameraFar || depth<=0. || bgDepth<=depthNonLinear) {\n#endif\n#ifdef FLUIDRENDERING_COMPOSITE_MODE\nglFragColor.rgb=backColor.rgb*backColor.a;glFragColor.a=backColor.a;\n#else\nglFragColor=backColor;\n#endif\nreturn;}\nvec3 viewPos=computeViewPosFromUVDepth(texCoord,depth);vec3 ddx=getViewPosFromTexCoord(texCoord+vec2(texelSize.x,0.))-viewPos;vec3 ddy=getViewPosFromTexCoord(texCoord+vec2(0.,texelSize.y))-viewPos;vec3 ddx2=viewPos-getViewPosFromTexCoord(texCoord+vec2(-texelSize.x,0.));if (abs(ddx.z)>abs(ddx2.z)) {ddx=ddx2;}\nvec3 ddy2=viewPos-getViewPosFromTexCoord(texCoord+vec2(0.,-texelSize.y));if (abs(ddy.z)>abs(ddy2.z)) {ddy=ddy2;}\nvec3 normal=normalize(cross(ddy,ddx));\n#ifdef FLUIDRENDERING_RHS\nnormal=-normal;\n#endif\n#ifndef WEBGPU\nif(isnan(normal.x) || isnan(normal.y) || isnan(normal.z) || isinf(normal.x) || isinf(normal.y) || isinf(normal.z)) {normal=vec3(0.,0.,-1.);}\n#endif\n#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_SHOWNORMAL)\nglFragColor=vec4(normal*0.5+0.5,1.0);return;\n#endif\nvec3 rayDir=normalize(viewPos); \n#ifdef FLUIDRENDERING_DIFFUSETEXTURE\nvec3 diffuseColor=textureLod(diffuseSampler,texCoord,0.0).rgb;\n#endif\nvec3 lightDir=normalize(vec3(viewMatrix*vec4(-dirLight,0.)));vec3 H =normalize(lightDir-rayDir);float specular=pow(max(0.0,dot(H,normal)),specularPower);\n#ifdef FLUIDRENDERING_DEBUG_DIFFUSERENDERING\nfloat diffuse =max(0.0,dot(lightDir,normal))*1.0;glFragColor=vec4(vec3(0.1) /*ambient*/+vec3(0.42,0.50,1.00)*diffuse+vec3(0,0,0.2)+specular,1.);return;\n#endif\nvec3 refractionDir=refract(rayDir,normal,ETA);vec4 transmitted=textureLod(textureSampler,vec2(texCoord+refractionDir.xy*thickness*refractionStrength),0.0);\n#ifdef FLUIDRENDERING_COMPOSITE_MODE\nif (transmitted.a==0.) transmitted.a=thickness;\n#endif\nvec3 transmittance=exp(-density*thickness*(1.0-diffuseColor)); \nvec3 refractionColor=transmitted.rgb*transmittance;\n#ifdef FLUIDRENDERING_ENVIRONMENT\nvec3 reflectionDir=reflect(rayDir,normal);vec3 reflectionColor=(textureCube(reflectionSampler,reflectionDir).rgb);float fresnel=clamp(F0+(1.0-F0)*pow(1.0-dot(normal,-rayDir),5.0),0.,fresnelClamp);vec3 finalColor=mix(refractionColor,reflectionColor,fresnel)+specular;\n#else\nvec3 finalColor=refractionColor+specular;\n#endif\n#ifdef FLUIDRENDERING_VELOCITY\nfloat velocity=depthVel.g;finalColor=mix(finalColor,vec3(1.0),smoothstep(0.3,1.0,velocity/6.0));\n#endif\nglFragColor=vec4(finalColor,transmitted.a);}\n",Object.defineProperty(pn.prototype,"fluidRenderer",{get:function(){return this._fluidRenderer},set:function(e){this._fluidRenderer=e},enumerable:!0,configurable:!0}),pn.prototype.enableFluidRenderer=function(){return this._fluidRenderer||(this._fluidRenderer=new wR(this)),this._fluidRenderer},pn.prototype.disableFluidRenderer=function(){var e;null===(e=this._fluidRenderer)||void 0===e||e.dispose(),this._fluidRenderer=null};var LR=function(){function e(e){this.name=Vr.NAME_FLUIDRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherActiveCameraRenderTargetsStage.registerStep(Vr.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER,this,this._gatherActiveCameraRenderTargets),this.scene._afterCameraDrawStage.registerStep(Vr.STEP_AFTERCAMERADRAW_FLUIDRENDERER,this,this._afterCameraDraw)},e.prototype._gatherActiveCameraRenderTargets=function(e){var t;null===(t=this.scene.fluidRenderer)||void 0===t||t._prepareRendering()},e.prototype._afterCameraDraw=function(e){var t;null===(t=this.scene.fluidRenderer)||void 0===t||t._render(e)},e.prototype.rebuild=function(){var e=this.scene.fluidRenderer;if(e){for(var t=new Set,i=0;it.object.priority?1:0}))},e.prototype._removeUnusedTargetRenderers=function(){for(var e,t={},i=0;i=1e6 || depth<=0.) {glFragColor=vec4(color,1.);return;}\nvec3 normal=textureLod(normalSampler,vUV,0.).rgb;\n#ifdef DECODE_NORMAL\nnormal=normal*2.0-1.0;\n#endif\nfloat sigma=float(filterSize);float two_sigma2=2.0*sigma*sigma;float sigmaDepth=depthThreshold;float two_sigmaDepth2=2.0*sigmaDepth*sigmaDepth;float sigmaNormal=normalThreshold;float two_sigmaNormal2=2.0*sigmaNormal*sigmaNormal;vec3 sum=vec3(0.);float wsum=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec3 sampleColor=textureLod(textureSampler,vUV+coords*blurDir,0.).rgb;float sampleDepth=textureLod(depthSampler,vUV+coords*blurDir,0.).r;vec3 sampleNormal=textureLod(normalSampler,vUV+coords*blurDir,0.).rgb;\n#ifdef DECODE_NORMAL\nsampleNormal=sampleNormal*2.0-1.0;\n#endif\nfloat r=dot(coords,coords);float w=exp(-r/two_sigma2);float depthDelta=abs(sampleDepth-depth);float wd=step(depthDelta,depthThreshold);vec3 normalDelta=abs(sampleNormal-normal);float wn=step(normalDelta.x+normalDelta.y+normalDelta.z,normalThreshold);sum+=sampleColor*w*wd*wn;wsum+=w*wd*wn;}\nglFragColor=vec4(sum/wsum,1.);}\n";li.ShadersStore.bilateralBlurQualityPixelShader="uniform sampler2D textureSampler;uniform sampler2D depthSampler;uniform sampler2D normalSampler;uniform int filterSize;uniform vec2 blurDir;uniform float depthThreshold;uniform float normalThreshold;varying vec2 vUV;void main(void) {vec3 color=textureLod(textureSampler,vUV,0.).rgb;float depth=textureLod(depthSampler,vUV,0.).x;if (depth>=1e6 || depth<=0.) {glFragColor=vec4(color,1.);return;}\nvec3 normal=textureLod(normalSampler,vUV,0.).rgb;\n#ifdef DECODE_NORMAL\nnormal=normal*2.0-1.0;\n#endif\nfloat sigma=float(filterSize);float two_sigma2=2.0*sigma*sigma;float sigmaDepth=depthThreshold;float two_sigmaDepth2=2.0*sigmaDepth*sigmaDepth;float sigmaNormal=normalThreshold;float two_sigmaNormal2=2.0*sigmaNormal*sigmaNormal;vec3 sum=vec3(0.);float wsum=0.;for (int x=-filterSize; x<=filterSize; ++x) {for (int y=-filterSize; y<=filterSize; ++y) {vec2 coords=vec2(x,y)*blurDir;vec3 sampleColor=textureLod(textureSampler,vUV+coords,0.).rgb;float sampleDepth=textureLod(depthSampler,vUV+coords,0.).r;vec3 sampleNormal=textureLod(normalSampler,vUV+coords,0.).rgb;\n#ifdef DECODE_NORMAL\nsampleNormal=sampleNormal*2.0-1.0;\n#endif\nfloat r=dot(coords,coords);float w=exp(-r/two_sigma2);float rDepth=sampleDepth-depth;float wd=exp(-rDepth*rDepth/two_sigmaDepth2);float rNormal=abs(sampleNormal.x-normal.x)+abs(sampleNormal.y-normal.y)+abs(sampleNormal.z-normal.z);float wn=exp(-rNormal*rNormal/two_sigmaNormal2);sum+=sampleColor*w*wd*wn;wsum+=w*wd*wn;}}\nglFragColor=vec4(sum/wsum,1.);}\n";li.ShadersStore.rsmGlobalIlluminationPixelShader="/**\n* The implementation is an application of the formula found in http:\n* For better results,it also adds a random (noise) rotation to the RSM samples (the noise artifacts are easier to remove than the banding artifacts).\n*/\nprecision highp float;varying vec2 vUV;uniform mat4 rsmLightMatrix;uniform vec4 rsmInfo;uniform vec4 rsmInfo2;uniform sampler2D textureSampler;uniform sampler2D normalSampler;uniform sampler2D rsmPositionW;uniform sampler2D rsmNormalW;uniform sampler2D rsmFlux;uniform sampler2D rsmSamples;\n#ifdef TRANSFORM_NORMAL\nuniform mat4 invView;\n#endif\nfloat mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}\nvec4 perm(vec4 x){return mod289(((x*34.0)+1.0)*x);}\nfloat noise(vec3 p){vec3 a=floor(p);vec3 d=p-a;d=d*d*(3.0-2.0*d);vec4 b=a.xxyy+vec4(0.0,1.0,0.0,1.0);vec4 k1=perm(b.xyxy);vec4 k2=perm(k1.xyxy+b.zzww);vec4 c=k2+a.zzzz;vec4 k3=perm(c);vec4 k4=perm(c+1.0);vec4 o1=fract(k3*(1.0/41.0));vec4 o2=fract(k4*(1.0/41.0));vec4 o3=o2*d.z+o1*(1.0-d.z);vec2 o4=o3.yw*d.x+o3.xz*(1.0-d.x);return o4.y*d.y+o4.x*(1.0-d.y);}\nvec3 computeIndirect(vec3 p,vec3 n) {vec3 indirectDiffuse=vec3(0.);int numSamples=int(rsmInfo.x);float radius=rsmInfo.y;float intensity=rsmInfo.z;float edgeArtifactCorrection=rsmInfo.w;vec4 texRSM=rsmLightMatrix*vec4(p,1.);texRSM.xy/=texRSM.w;texRSM.xy=texRSM.xy*0.5+0.5;float angle=noise(p*rsmInfo2.x);float c=cos(angle);float s=sin(angle);for (int i=0; i1. || uv.y<0. || uv.y>1.) continue;vec3 vplPositionW=textureLod(rsmPositionW,uv,0.).xyz;vec3 vplNormalW=textureLod(rsmNormalW,uv,0.).xyz*2.0-1.0;vec3 vplFlux=textureLod(rsmFlux,uv,0.).rgb;vplPositionW-=vplNormalW*edgeArtifactCorrection; \nfloat dist2=dot(vplPositionW-p,vplPositionW-p);indirectDiffuse+=vplFlux*weightSquare*max(0.,dot(n,vplPositionW-p))*max(0.,dot(vplNormalW,p-vplPositionW))/(dist2*dist2);}\nreturn clamp(indirectDiffuse*intensity,0.0,1.0);}\nvoid main(void) \n{vec3 positionW=texture2D(textureSampler,vUV).xyz;vec3 normalW=texture2D(normalSampler,vUV).xyz;\n#ifdef DECODE_NORMAL\nnormalW=normalW*2.0-1.0;\n#endif\n#ifdef TRANSFORM_NORMAL\nnormalW=(invView*vec4(normalW,0.)).xyz;\n#endif\ngl_FragColor.rgb=computeIndirect(positionW,normalW);gl_FragColor.a=1.0;}\n";li.ShadersStore.rsmFullGlobalIlluminationPixelShader="/**\n* The implementation is a direct application of the formula found in http:\n*/\nprecision highp float;varying vec2 vUV;uniform mat4 rsmLightMatrix;uniform vec4 rsmInfo;uniform sampler2D textureSampler;uniform sampler2D normalSampler;uniform sampler2D rsmPositionW;uniform sampler2D rsmNormalW;uniform sampler2D rsmFlux;\n#ifdef TRANSFORM_NORMAL\nuniform mat4 invView;\n#endif\nvec3 computeIndirect(vec3 p,vec3 n) {vec3 indirectDiffuse=vec3(0.);float intensity=rsmInfo.z;float edgeArtifactCorrection=rsmInfo.w;vec4 texRSM=rsmLightMatrix*vec4(p,1.);texRSM.xy/=texRSM.w;texRSM.xy=texRSM.xy*0.5+0.5;int width=int(rsmInfo.x);int height=int(rsmInfo.y);for (int j=0; j0&&e.isEnabled()&&e.material&&t._addGISupportToMaterial(e.material)}))},Object.defineProperty(e.prototype,"countersGPU",{get:function(){return this._counters},enumerable:!1,configurable:!0}),e.prototype.recreateResources=function(e){void 0===e&&(e=!1),this._disposePostProcesses(e),this._createPostProcesses(),this._setPluginParameters()},e.prototype.generateSampleTexture=function(e){var t;null===(t=this._sampleTexture)||void 0===t||t.dispose(),this._maxSamples=e;for(var i=new Float32Array(4*this._maxSamples),r=0;r=this._outputDimensions.width&&this._giTextureDimensions.height>=this._outputDimensions.height||this._forceFullSizeBlur)y.push(this._blurRTT.renderTarget);else{var b=[];this._counters.push({name:"GI upsampling",value:0}),this._countersRTW.push(b),this._upsamplingXPostprocess=new hl(this._useQualityUpsampling?"BilateralUpsampling":"BilateralUpsamplingX",this._useQualityUpsampling?"bilateralBlurQuality":"bilateralBlur",{uniforms:["filterSize","blurDir","depthThreshold","normalThreshold"],samplers:["depthSampler","normalSampler"],defines:s?"#define DECODE_NORMAL":void 0,size:v,samplingMode:u.TEXTURE_BILINEAR_SAMPLINGMODE,engine:this._engine,textureType:this._giTextureType,textureFormat:o}),this._upsamplingXPostprocess.autoClear=!1,this._upsamplingXPostprocess.onApplyObservable.add((function(e){e.setTexture("depthSampler",a.getGBuffer().textures[a.getTextureIndex(BC.DEPTH_TEXTURE_TYPE)]),e.setTexture("normalSampler",a.getGBuffer().textures[a.getTextureIndex(BC.NORMAL_TEXTURE_TYPE)]),e.setInt("filterSize",n.upsamplerKernel),e.setFloat2("blurDir",1/n._outputDimensions.width,n._useQualityUpsampling?1/n._outputDimensions.height:0),e.setFloat("depthThreshold",n.blurDepthThreshold),e.setFloat("normalThreshold",n.blurNormalThreshold)})),this._upsamplingXPostprocess.resize(v.width,v.height),y.push(this._upsamplingXPostprocess.inputTexture),this.useQualityUpsampling||(this._upsamplingYPostprocess=new hl("BilateralUpsamplingY","bilateralBlur",{uniforms:["filterSize","blurDir","depthThreshold","normalThreshold"],samplers:["depthSampler","normalSampler"],defines:s?"#define DECODE_NORMAL":void 0,size:this._outputDimensions,samplingMode:u.TEXTURE_BILINEAR_SAMPLINGMODE,engine:this._engine,textureType:this._giTextureType,textureFormat:o}),this._upsamplingYPostprocess.autoClear=!1,this._upsamplingYPostprocess.onApplyObservable.add((function(e){e.setTexture("depthSampler",a.getGBuffer().textures[a.getTextureIndex(BC.DEPTH_TEXTURE_TYPE)]),e.setTexture("normalSampler",a.getGBuffer().textures[a.getTextureIndex(BC.NORMAL_TEXTURE_TYPE)]),e.setInt("filterSize",n.upsamplerKernel),e.setFloat2("blurDir",0,1/n._outputDimensions.height),e.setFloat("depthThreshold",n.blurDepthThreshold),e.setFloat("normalThreshold",n.blurNormalThreshold)})),this._upsamplingYPostprocess.resize(this._outputDimensions.width,this._outputDimensions.height),b.push(this._upsamplingYPostprocess.inputTexture)),b.push(this._blurRTT.renderTarget),this._blurPostProcesses.push(this._upsamplingXPostprocess),this._upsamplingYPostprocess&&this._blurPostProcesses.push(this._upsamplingYPostprocess)}}null===(r=this._debugLayer.texture)||void 0===r||r.dispose(),this._debugLayer.texture=new Ya(this._scene,this._enableBlur?this._blurRTT.renderTarget.texture:this._ppGlobalIllumination[0].inputTexture.texture)}},e.prototype._addGISupportToMaterial=function(e){var t;if(!(null===(t=e.pluginManager)||void 0===t?void 0:t.getPlugin(WR.Name))){var i=new WR(e);this._enable&&this._ppGlobalIllumination.length>0&&(i.textureGIContrib=this._ppGlobalIllumination[0].inputTexture.texture,i.outputTextureWidth=this._outputDimensions.width,i.outputTextureHeight=this._outputDimensions.height),i.isEnabled=this._enable,this._materialsWithRenderPlugin.push(e)}},e.GeometryBufferTextureTypesAndFormats={0:{textureType:u.TEXTURETYPE_HALF_FLOAT,textureFormat:u.TEXTUREFORMAT_R},1:{textureType:u.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,textureFormat:u.TEXTUREFORMAT_RGBA},2:{textureType:u.TEXTURETYPE_HALF_FLOAT,textureFormat:u.TEXTUREFORMAT_RGBA}},e}(),zR=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.RENDER_WITH_GIRSM=!1,t.RSMCREATE_PROJTEXTURE=!1,t}return m(t,e),t}(Gs),WR=function(e){function t(i){var r=e.call(this,i,t.Name,310,new zR)||this;return r._isEnabled=!1,r.isEnabled=!1,r._internalMarkAllSubMeshesAsTexturesDirty=i._dirtyCallbacks[u.MATERIAL_TextureDirtyFlag],r._isPBR=i instanceof ig,r}return m(t,e),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.prepareDefines=function(e){e.RENDER_WITH_GIRSM=this._isEnabled},t.prototype.getClassName=function(){return"GIRSMRenderPluginMaterial"},t.prototype.getUniforms=function(){return{ubo:[{name:"girsmTextureOutputSize",size:2,type:"vec2"}],fragment:"#ifdef RENDER_WITH_GIRSM\n uniform vec2 girsmTextureOutputSize;\n #endif"}},t.prototype.getSamplers=function(e){e.push("girsmTextureGIContrib")},t.prototype.bindForSubMesh=function(e){this._isEnabled&&(e.bindTexture("girsmTextureGIContrib",this.textureGIContrib),e.updateFloat2("girsmTextureOutputSize",this.outputTextureWidth,this.outputTextureHeight))},t.prototype.getCustomCode=function(e){var t={CUSTOM_FRAGMENT_DEFINITIONS:"\n #ifdef RENDER_WITH_GIRSM\n uniform sampler2D girsmTextureGIContrib;\n\n vec3 computeIndirect() {\n vec2 uv = gl_FragCoord.xy / girsmTextureOutputSize;\n return texture2D(girsmTextureGIContrib, uv).rgb;\n }\n #endif\n ",CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION:"\n #ifdef RENDER_WITH_GIRSM\n finalDiffuse += computeIndirect() * surfaceAlbedo.rgb;\n #endif\n "};return this._isPBR||(t.CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR="\n #ifdef RENDER_WITH_GIRSM\n color.rgb += computeIndirect() * baseColor.rgb;\n #endif\n "),"vertex"===e?null:t},t.Name="GIRSMRender",v([Ie()],t.prototype,"textureGIContrib",void 0),v([Ie()],t.prototype,"outputTextureWidth",void 0),v([Ie()],t.prototype,"outputTextureHeight",void 0),v([Ie(),Pe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),t}(Nu);a("BABYLON.GIRSMRenderPluginMaterial",WR);li.ShadersStore.spriteMapPixelShader="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\nprecision highp float;varying vec3 vPosition;varying vec2 vUV;varying vec2 tUV;uniform float time;uniform float spriteCount;uniform sampler2D spriteSheet;uniform vec2 spriteMapSize;uniform vec2 outputSize;uniform vec2 stageSize;uniform sampler2D frameMap;uniform sampler2D tileMaps[LAYERS];uniform sampler2D animationMap;uniform vec3 colorMul;float mt;const float fdStep=1./4.;const float aFrameSteps=1./MAX_ANIMATION_FRAMES;mat4 getFrameData(float frameID){float fX=frameID/spriteCount;return mat4(\ntexture2D(frameMap,vec2(fX,0.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*1.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*2.),0.),\nvec4(0.)\n);}\nvoid main(){vec4 color=vec4(0.);vec2 tileUV=fract(tUV);\n#ifdef FLIPU\ntileUV.y=1.0-tileUV.y;\n#endif\nvec2 tileID=floor(tUV);vec2 sheetUnits=1./spriteMapSize;float spriteUnits=1./spriteCount;vec2 stageUnits=1./stageSize;for(int i=0; i0.) {mt=mod(time*animationData.z,1.0);for(float f=0.; fmt){frameID=animationData.x;break;}\nanimationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);}}\nmat4 frameData=getFrameData(frameID+0.5);vec2 frameSize=(frameData[0].zw)/spriteMapSize;vec2 offset=frameData[0].xy*sheetUnits;vec2 ratio=frameData[2].xy/frameData[0].zw;if (frameData[2].z==1.){tileUV.xy=tileUV.yx;}\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);if (i==0){color=nc;} else {float alpha=min(color.a+nc.a,1.0);vec3 mixed=mix(color.xyz,nc.xyz,nc.a);color=vec4(mixed,alpha);}}\ncolor.xyz*=colorMul;gl_FragColor=color;}";li.ShadersStore.spriteMapVertexShader="precision highp float;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;varying vec3 vPosition;varying vec2 vUV;varying vec2 tUV;varying vec2 stageUnits;varying vec2 levelUnits;varying vec2 tileID;uniform float time;uniform mat4 worldViewProjection;uniform vec2 outputSize;uniform vec2 stageSize;uniform vec2 spriteMapSize;uniform float stageScale;void main() {vec4 p=vec4( position,1. );vPosition=p.xyz;vUV=uv;tUV=uv*stageSize; \ngl_Position=worldViewProjection*p;}";var HR,XR=function(){function e(e,t,i,r,n){var o=this;this.name=e,this.sprites=[],this.atlasJSON=t,this.sprites=this.atlasJSON.frames,this.spriteSheet=i,this.options=r,r.stageSize=r.stageSize||new U(1,1),r.outputSize=r.outputSize||r.stageSize,r.outputPosition=r.outputPosition||V.Zero(),r.outputRotation=r.outputRotation||V.Zero(),r.layerCount=r.layerCount||1,r.maxAnimationFrames=r.maxAnimationFrames||0,r.baseTile=r.baseTile||0,r.flipU=r.flipU||!1,r.colorMultiply=r.colorMultiply||new V(1,1,1),this._scene=n,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var a=0;a0&&(e+="\n\r"),e+=this._tileMaps[t]._texture._bufferView.toString();var i=document.createElement("a");i.href="data:octet/stream;charset=utf-8,"+encodeURI(e),i.target="_blank",i.download=this.name+".tilemaps",i.click(),i.remove()},e.prototype.loadTileMaps=function(e){var t=this,i=new XMLHttpRequest;i.open("GET",e);var r=this.options.layerCount||0;i.onload=function(){for(var e=i.response.split("\n\r"),n=0;n-1&&this._tasks.splice(t,1)},e.prototype._decreaseWaitingTasksCount=function(e){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,e),this.onProgressObservable.notifyObservers(new KR(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){ae.Error("Error running progress callbacks."),ae.Log(e)}if(0===this._waitingTasksCount){try{var t=this._tasks.slice();this.onFinish&&this.onFinish(t);for(var i=0,r=t;i-1&&this._tasks.splice(o,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){ae.Error("Error running tasks-done callbacks."),ae.Log(e)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(e){var t=this,i=function(i,r){e._setErrorObject(i,r),t.onTaskError?t.onTaskError(e):e.onError||ae.Error(t._formatTaskErrorMessage(e)),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,(function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){i("Error executing task success callbacks",e)}}),i)},e.prototype._formatTaskErrorMessage=function(e){var t="Unable to complete task "+e.name;return e.errorObject.message&&(t+=": ".concat(e.errorObject.message)),e.errorObject.exception&&(t+=": ".concat(e.errorObject.exception)),t},e.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},e.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,0===this._waitingTasksCount)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e=0&&this._meshes.splice(i,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var r=0;r0&&this._textureLoadingCallback(e)}this._currentScene.render()}},e.prototype._drag=function(e){e.stopPropagation(),e.preventDefault()},e.prototype._drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},e.prototype._traverseFolder=function(e,t,i,r){var n=this,o=e.createReader(),a=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries((function(e){i.count+=e.length;for(var o=0,s=e;o0)){for(var i=[],r=[],n=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&ae.ClearLogCache(),this._engine.stopRenderLoop()),Ls.ShowLoadingScreen=!1,this.displayLoadingUI&&this._engine.displayLoadingUI(),this.loadAsync(this._sceneFileToLoad,this._progressCallback).then((function(t){e.useAppend?e.displayLoadingUI&&e._engine.hideLoadingUI():(e._currentScene&&e._currentScene.dispose(),e._currentScene=t,e._currentScene.executeWhenReady((function(){e.displayLoadingUI&&e._engine.hideLoadingUI(),e._engine.runRenderLoop((function(){e._renderFunction()}))}))),e._sceneLoadedCallback&&e._currentScene&&e._sceneLoadedCallback(e._sceneFileToLoad,e._currentScene)})).catch((function(t){e.displayLoadingUI&&e._engine.hideLoadingUI(),e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)}))):ae.Error("Please provide a valid .babylon file.")},e}(),cP=function(){function e(){}return e.prototype.dispose=function(){if(this._observers&&this._observables)for(var e=0;ethis.maximumSize&&(n.scale(this.step),i=!1)}}return i},t}(uP),dP=function(e){function t(t,i,r){void 0===t&&(t=0),void 0===i&&(i=2),void 0===r&&(r=.25);var n=e.call(this,t)||this;return n.priority=t,n.maximumScale=i,n.step=r,n._currentScale=-1,n._directionOffset=1,n}return m(t,e),t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,t){return-1===this._currentScale&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),1===this._directionOffset?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(uP),pP=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(uP),fP=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0},t}(uP),_P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0},t}(uP),mP=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,t){return!this.onApply||this.onApply(e,t)},t}(uP),gP=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(uP),vP=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(uP),yP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof Fa))return!1;var t=e;return!(t.isDisposed()||!t.isVisible||!t.isEnabled()||t.instances.length>0||t.skeleton||t.hasLODLevels||0===t.getTotalVertices())},t}return m(t,e),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,i,r){for(var n=e.meshes.slice(0),o=n.length,a=0;a=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var r=!0,n=!0,o=0;o0){a.animationGroups=[];for(var p=0;p0)for(a.reflectionProbes=[],r=0;r0&&setTimeout((function(){i.stopRecording()}),1e3*t),this._fileName=e,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise((function(e,t){i._resolve=e,i._reject=t}))},e.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},e.prototype._handleDataAvailable=function(e){e.data.size>0&&this._recordedChunks.push(e.data)},e.prototype._handleError=function(e){if(this.stopRecording(),!this._reject)throw new e.error;this._reject(e.error)},e.prototype._handleStop=function(){this.stopRecording();var e=new Blob(this._recordedChunks);this._resolve&&this._resolve(e),window.URL.createObjectURL(e),this._fileName&&rr.Download(e,this._fileName)},e._DefaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},e}(),RP=null;function PP(e,t,i,r,n,o,a){void 0===n&&(n="image/png"),void 0===o&&(o=!1);var s=NP(e,t,i),l=s.height,c=s.width;if(l&&c){RP||(RP=document.createElement("canvas")),RP.width=c,RP.height=l;var u=RP.getContext("2d"),h=e.getRenderWidth()/e.getRenderHeight(),d=c,p=d/h;p>l&&(d=(p=l)*h);var f=Math.max(0,c-d)/2,_=Math.max(0,l-p)/2;t.getScene().activeCamera!==t?OP(e,t,i,(function(e){if(o){var t=new Blob([e]);rr.DownloadBlob(t),r&&r("")}else r&&r(e)}),n,1,e.getCreationOptions().antialias,void 0,void 0,void 0,void 0,a):e.onEndFrameObservable.addOnce((function(){var t=e.getRenderingCanvas();u&&t&&u.drawImage(t,f,_,d,p),RP&&(o?(rr.EncodeScreenshotCanvasData(RP,void 0,n,void 0,a),r&&r("")):rr.EncodeScreenshotCanvasData(RP,r,n,void 0,a))}))}else ae.Error("Invalid 'size' parameter !")}function IP(e,t,i,r,n){return void 0===r&&(r="image/png"),new Promise((function(o,a){PP(e,t,i,(function(e){void 0!==e?o(e):a(new Error("Data is undefined"))}),r,void 0,n)}))}function MP(e,t,i,r,n,o){return void 0===n&&(n="image/png"),new Promise((function(a){PP(e,t,{width:i,height:r},(function(){a()}),n,!0,o)}))}function OP(e,t,i,r,n,o,a,s,l,c,h,d,p){void 0===n&&(n="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===l&&(l=!1),void 0===c&&(c=!1),void 0===h&&(h=!0);var f=NP(e,t,i),_=f.height,m=f.width,g=f.finalWidth,v=f.finalHeight,y={width:m,height:_};if(_&&m){var b={width:e.getRenderWidth(),height:e.getRenderHeight()};e.setSize(m,_);var T=t.getScene(),E=new Pl("screenShot",y,T,!1,!1,u.TEXTURETYPE_UNSIGNED_INT,!1,Ja.BILINEAR_SAMPLINGMODE,void 0,c,void 0,void 0,void 0,o);E.renderList=T.meshes.slice(),E.samples=o,E.renderSprites=l,E.activeCamera=t,E.forceLayerMaskCheck=h,null==p||p(E);var S=function(){E.isReadyForRendering()&&t.isReady(!0)?(e.onEndFrameObservable.addOnce((function(){g===m&&v===_?E.readPixels(void 0,void 0,void 0,!1).then((function(e){Rl.DumpData(m,_,e,r,n,s,!0,void 0,d),E.dispose()})):Rp("pass",E.getInternalTexture(),T,void 0,void 0,void 0,g,v).then((function(t){e._readTexturePixels(t,g,v,-1,0,null,!0,!1,0,0).then((function(e){Rl.DumpData(g,v,e,r,n,s,!0,void 0,d),t.dispose()}))}))})),E.render(!0),T.incrementRenderId(),T.resetCachedMaterial(),e.setSize(b.width,b.height),t.getProjectionMatrix(!0),T.render()):setTimeout(S,16)},x=function(){T.incrementRenderId(),T.resetCachedMaterial(),S()};if(a){var A=new DC("antialiasing",1,T.activeCamera);E.addPostProcess(A),A.getEffect().isReady()?x():A.getEffect().onCompiled=function(){x()}}else x()}else ae.Error("Invalid 'size' parameter !")}function DP(e,t,i,r,n,o,a,s,l,c,u){return void 0===r&&(r="image/png"),void 0===n&&(n=1),void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===l&&(l=!1),void 0===c&&(c=!0),new Promise((function(h,d){OP(e,t,i,(function(e){void 0!==e?h(e):d(new Error("Data is undefined"))}),r,n,o,a,s,l,c,u)}))}function NP(e,t,i){var r=0,n=0,o=0,a=0;if("object"==typeof i){var s=i.precision?Math.abs(i.precision):1;i.width&&i.height?(r=i.height*s,n=i.width*s):i.width&&!i.height?(n=i.width*s,r=Math.round(n/e.getAspectRatio(t))):i.height&&!i.width?(r=i.height*s,n=Math.round(r*e.getAspectRatio(t))):(n=Math.round(e.getRenderWidth()*s),r=Math.round(n/e.getAspectRatio(t))),i.finalWidth&&i.finalHeight?(a=i.finalHeight,o=i.finalWidth):i.finalWidth&&!i.finalHeight?(o=i.finalWidth,a=Math.round(o/e.getAspectRatio(t))):i.finalHeight&&!i.finalWidth?(a=i.finalHeight,o=Math.round(a*e.getAspectRatio(t))):(o=n,a=r)}else isNaN(i)||(r=i,n=i,o=i,a=i);return n&&(n=Math.floor(n)),r&&(r=Math.floor(r)),o&&(o=Math.floor(o)),a&&(a=Math.floor(a)),{height:0|r,width:0|n,finalWidth:0|o,finalHeight:0|a}}var FP,LP={CreateScreenshot:PP,CreateScreenshotAsync:IP,CreateScreenshotWithResizeAsync:MP,CreateScreenshotUsingRenderTarget:OP,CreateScreenshotUsingRenderTargetAsync:DP};rr.CreateScreenshot=PP,rr.CreateScreenshotAsync=IP,rr.CreateScreenshotUsingRenderTarget=OP,rr.CreateScreenshotUsingRenderTargetAsync=DP,function(e){e[e.Checkbox=0]="Checkbox",e[e.Slider=1]="Slider",e[e.Vector3=2]="Vector3",e[e.Quaternion=3]="Quaternion",e[e.Color3=4]="Color3",e[e.String=5]="String",e[e.Button=6]="Button",e[e.Options=7]="Options",e[e.Tab=8]="Tab",e[e.FileButton=9]="FileButton",e[e.Vector2=10]="Vector2"}(FP||(FP={}));var wP,BP=function(){function e(e){this.byteOffset=0,this.buffer=e}return e.prototype.loadAsync=function(e){var t=this;return this.buffer.readAsync(this.byteOffset,e).then((function(e){t._dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),t._dataByteOffset=0}))},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,e},e.prototype.readUint8Array=function(e){var t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,e);return this._dataByteOffset+=e,this.byteOffset+=e,t},e.prototype.readString=function(e){return St(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),UP=function(){function e(){}return e._GetStorage=function(){try{return localStorage.setItem("test",""),localStorage.removeItem("test"),localStorage}catch(t){var e={};return{getItem:function(t){var i=e[t];return void 0===i?null:i},setItem:function(t,i){e[t]=i}}}},e.ReadString=function(e,t){var i=this._Storage.getItem(e);return null!==i?i:t},e.WriteString=function(e,t){this._Storage.setItem(e,t)},e.ReadBoolean=function(e,t){var i=this._Storage.getItem(e);return null!==i?"true"===i:t},e.WriteBoolean=function(e,t){this._Storage.setItem(e,t?"true":"false")},e.ReadNumber=function(e,t){var i=this._Storage.getItem(e);return null!==i?parseFloat(i):t},e.WriteNumber=function(e,t){this._Storage.setItem(e,t.toString())},e._Storage=e._GetStorage(),e}(),VP=function(){function e(){this._trackedScene=null}return e.prototype.track=function(e){this._trackedScene=e,Ke.AllowLoadingUniqueId=!0,this._savedJSON=AP.Serialize(e),Ke.AllowLoadingUniqueId=!1},e.prototype.getDelta=function(){if(!this._trackedScene)return null;var e=Ja.ForceSerializeBuffers;Ja.ForceSerializeBuffers=!1,Ke.AllowLoadingUniqueId=!0;var t=AP.Serialize(this._trackedScene);Ke.AllowLoadingUniqueId=!1;var i={};for(var r in t)this._compareCollections(r,this._savedJSON[r],t[r],i);return Ja.ForceSerializeBuffers=e,i},e.prototype._compareArray=function(e,t,i,r){if(0===t.length&&0===i.length)return!0;if(t.length&&!isNaN(t[0])||i.length&&!isNaN(i[0])){if(t.length!==i.length)return!1;if(0===t.length)return!0;for(var n=0;ne._MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+e._MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=i,this._characters=t.map((function(e){return r._alphabet.getCharacterIdx(e)}))}return e.prototype.serialize=function(){return JSON.stringify(this._characters)},e.Deserialize=function(t,i){var r=new e([],i);return r._characters=JSON.parse(t),r},e.prototype.distance=function(t){return e._Distance(this,t)},e._Distance=function(t,i){var r=t._alphabet;if(r!==i._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var n=t._characters,o=i._characters,a=n.length,s=o.length,l=e._CostMatrix;l[0][0]=0;for(var c=0;c.98||(V.CrossToRef(e._ForwardDir,e._InverseFromVec,e._UpDir),e._UpDir.normalize(),z.LookAtLHToRef(t,i,e._UpDir,e._LookMatrix),r.subtractToRef(i,e._FromToVec),e._FromToVec.normalize(),V.TransformNormalToRef(e._FromToVec,e._LookMatrix,n),0))},e._TokenizeSegment=function(t,i){e._BestMatch=0,e._Score=V.Dot(t,i[0]),e._BestScore=e._Score;for(var r=1;re._BestScore&&(e._BestMatch=r,e._BestScore=e._Score);return e._BestMatch},e._ForwardDir=new V,e._InverseFromVec=new V,e._UpDir=new V,e._FromToVec=new V,e._LookMatrix=new z,e}(),GP=function(){function e(e){this.chars=new Array(e)}return e.Generate=function(t,i,r,n,o){void 0===t&&(t=64),void 0===i&&(i=256),void 0===r&&(r=.1),void 0===n&&(n=.001),void 0===o&&(o=[]);for(var a,s,l=new e(t),c=0;c1e-6&&d.scaleAndAddToRef(1/(d.lengthSquared()*s),h)})),h.scaleInPlace(a),l.chars[e].addInPlace(h),l.chars[e].normalize()};for(c=o.length;c4;o=Math.floor(o/2))n.push(t.resampleAtTargetResolution(o).tokenize(i.chars));return n},e.prototype.distance=function(e){for(var t=0,i=0;i0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,e._MIN_AVERAGE_DISTANCE))},e._MIN_AVERAGE_DISTANCE=1,e}(),HP=function(){function e(){this._maximumAllowableMatchCost=4,this._nameToDescribedTrajectory=new Map}return e.prototype.serialize=function(){var e={};return e.maximumAllowableMatchCost=this._maximumAllowableMatchCost,e.vector3Alphabet=this._vector3Alphabet.serialize(),e.levenshteinAlphabet=this._levenshteinAlphabet.serialize(),e.nameToDescribedTrajectory=[],this._nameToDescribedTrajectory.forEach((function(t,i){e.nameToDescribedTrajectory.push(i),e.nameToDescribedTrajectory.push(t.serialize())})),JSON.stringify(e)},e.Deserialize=function(t){var i=JSON.parse(t),r=new e;r._maximumAllowableMatchCost=i.maximumAllowableMatchCost,r._vector3Alphabet=GP.Deserialize(i.vector3Alphabet),r._levenshteinAlphabet=wP.Alphabet.Deserialize(i.levenshteinAlphabet);for(var n=0;n=this._itemLength?NaN:this._view[e]},e.prototype.subarray=function(e,t){return e>=t||e<0?new Float32Array(0):(t>this._itemLength&&(t=this._itemLength),this._view.subarray(e,t))},e.prototype.push=function(e){this._view[this._itemLength]=e,this._itemLength++,this._itemLength>=this._view.length&&this._growArray()},e.prototype._growArray=function(){var e=Math.floor(1.5*this._view.length),t=new Float32Array(e);t.set(this._view),this._view=t},e}(),KP=1800,QP="timestamp",qP="numPoints",ZP=/\r/g,JP=function(){function e(t,i){var r=this;this._scene=t,this._collectDataAtFrame=function(){var t=_t.Now-r._startingTimestamp,i=r.datasets.ids.length,n=r.datasets.startingIndices.itemLength,o=0;if(n>0){var a=r.datasets.startingIndices.at(n-1);o=a+r.datasets.data.at(a+e.NumberOfPointsOffset)+e.SliceDataOffset}if(r.datasets.startingIndices.push(o),r.datasets.data.push(t),r.datasets.data.push(i),r.datasets.ids.forEach((function(e){var t=r._strategies.get(e);t&&r.datasets.data.push(t.getData())})),r.datasetObservable.hasObservers()){for(var s=[t,i],l=0;l>i&255).toString(16)).substr(-2);return r},e.prototype.getCurrentSlice=function(){var e=this,t=[_t.Now-this._startingTimestamp,this.datasets.ids.length];this.datasets.ids.forEach((function(i){var r=e._strategies.get(i);r&&e.datasetObservable.hasObservers()&&t.push(r.getData())})),this.datasetObservable.hasObservers()&&this.datasetObservable.notifyObservers(t)},e.prototype.updateMetadata=function(e,t,i){var r=this._datasetMeta.get(e);r&&(r[t]=i,this.metadataObservable.notifyObservers(this._datasetMeta))},e.prototype.clear=function(e){this.datasets.data=new YP(KP),this.datasets.ids.length=0,this.datasets.startingIndices=new YP(KP),this._datasetMeta.clear(),this._strategies.forEach((function(e){return e.dispose()})),this._strategies.clear(),e||this._eventRestoreSet.clear(),this._hasLoadedData=!1},Object.defineProperty(e.prototype,"hasLoadedData",{get:function(){return this._hasLoadedData},enumerable:!1,configurable:!0}),e.prototype.loadFromFileData=function(t,i){var r=t.replace(ZP,"").split("\n").map((function(e){return e.split(",").filter((function(e){return e.length>0}))})).filter((function(e){return e.length>0})),n=e.NumberOfPointsOffset;if(r.length<2)return!1;var o={ids:[],data:new YP(KP),startingIndices:new YP(KP)},a=r[0],s=r.slice(1);if(a.length<2||a[0]!==QP||a[n]!==qP)return!1;for(var l=new Map,c=e.SliceDataOffset;c0&&this.onFeaturePointsAddedObservable.notifyObservers(n),r.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(r)}}},t.prototype._init=function(){this._xrSessionManager.session.trySetFeaturePointCloudEnabled&&this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)&&(this._enabled=!0)},t.Name=Ss.FEATURE_POINTS,t.Version=1,t}(As);xs.AddWebXRFeature(hI.Name,(function(e){return function(){return new hI(e)}}),hI.Version);var dI,pI=0,fI=function(e){function t(t,i){void 0===i&&(i={});var r=e.call(this,t)||this;return r._options=i,r._detectedMeshes=new Map,r.onMeshAddedObservable=new f,r.onMeshRemovedObservable=new f,r.onMeshUpdatedObservable=new f,r.xrNativeFeatureName="mesh-detection",r._options.generateMeshes&&(r._options.convertCoordinateSystems=!0),r._xrSessionManager.session?r._init():r._xrSessionManager.onXRSessionInit.addOnce((function(){r._init()})),r}return m(t,e),t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(this._xrSessionManager.isNative&&this._xrSessionManager.session.trySetMeshDetectorEnabled&&this._xrSessionManager.session.trySetMeshDetectorEnabled(!1),this._options.doNotRemoveMeshesOnSessionEnded||(this._detectedMeshes.forEach((function(e){t.onMeshRemovedObservable.notifyObservers(e)})),this._detectedMeshes.clear()),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onMeshUpdatedObservable.clear()},t.prototype._onXRFrame=function(e){var t,i=this;try{if(!this.attached||!e)return;var r=e.detectedMeshes||(null===(t=e.worldInformation)||void 0===t?void 0:t.detectedMeshes);if(r){var n=new Set;this._detectedMeshes.forEach((function(e,t){r.has(t)||n.add(t)})),n.forEach((function(e){var t=i._detectedMeshes.get(e);t&&(i.onMeshRemovedObservable.notifyObservers(t),i._detectedMeshes.delete(e))})),r.forEach((function(t){if(i._detectedMeshes.has(t))t.lastChangedTime===i._xrSessionManager.currentTimestamp&&(n=i._detectedMeshes.get(t))&&(i._updateVertexDataWithXRMesh(t,n,e),i.onMeshUpdatedObservable.notifyObservers(n));else{var r={id:pI++,xrMesh:t},n=i._updateVertexDataWithXRMesh(t,r,e);i._detectedMeshes.set(t,n),i.onMeshAddedObservable.notifyObservers(n)}}))}}catch(e){ae.Log(e.stack)}},t.prototype._init=function(){this._xrSessionManager.isNative&&(this._xrSessionManager.session.trySetMeshDetectorEnabled&&this._xrSessionManager.session.trySetMeshDetectorEnabled(!0),this._options.preferredDetectorOptions&&this._xrSessionManager.session.trySetPreferredMeshDetectorOptions&&this._xrSessionManager.session.trySetPreferredMeshDetectorOptions(this._options.preferredDetectorOptions))},t.prototype._updateVertexDataWithXRMesh=function(e,t,i){var r;t.xrMesh=e,t.worldParentNode=this._options.worldParentNode;var n=e.vertices||e.positions;if(this._options.convertCoordinateSystems){if(this._xrSessionManager.scene.useRightHandedSystem)t.positions=n,t.normals=e.normals;else{t.positions=new Float32Array(n.length);for(var o=0;o0?dI.Received:dI.NotReceived,[2]}}))}))},t.Name=Ss.IMAGE_TRACKING,t.Version=1,t}(As);xs.AddWebXRFeature(_I.Name,(function(e,t){return function(){return new _I(e,t)}}),_I.Version,!1);var mI=function(e){function t(t,i){var r=e.call(this,t)||this;return r.options=i,r._domOverlayType=null,r._beforeXRSelectListener=null,r._element=null,r.xrNativeFeatureName="dom-overlay",rr.Warn("dom-overlay is an experimental and unstable feature."),r}return m(t,e),t.prototype.attach=function(){return!(!e.prototype.attach.call(this)||!this._xrSessionManager.session.domOverlayState||null===this._xrSessionManager.session.domOverlayState.type||(this._domOverlayType=this._xrSessionManager.session.domOverlayState.type,null!==this._element&&!0===this.options.supressXRSelectEvents&&(this._beforeXRSelectListener=function(e){e.preventDefault()},this._element.addEventListener("beforexrselect",this._beforeXRSelectListener)),0))},Object.defineProperty(t.prototype,"domOverlayType",{get:function(){return this._domOverlayType},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),null!==this._element&&this._beforeXRSelectListener&&this._element.removeEventListener("beforexrselect",this._beforeXRSelectListener)},t.prototype._onXRFrame=function(e){},t.prototype.getXRSessionInitExtension=function(){return y(this,void 0,void 0,(function(){var e;return b(this,(function(t){if(void 0===this.options.element)return rr.Warn('"element" option must be provided to attach xr-dom-overlay feature.'),[2,{}];if("string"==typeof this.options.element){if(null===(e=document.querySelector(this.options.element)))return rr.Warn("element not found '".concat(this.options.element,"' (not requesting xr-dom-overlay)")),[2,{}];this._element=e}else this._element=this.options.element;return[2,{domOverlay:{root:this._element}}]}))}))},t.Name=Ss.DOM_OVERLAY,t.Version=1,t}(As);xs.AddWebXRFeature(mI.Name,(function(e,t){return function(){return new mI(e,t)}}),mI.Version,!1);var gI=function(e){function t(i,r){var n,o,a,s,l,c,u=this;return(u=e.call(this,i)||this)._controllers={},u._currentRegistrationConfigurations=[],u._movementDirection=new G,u._tmpRotationMatrix=z.Identity(),u._tmpTranslationDirection=new V,u._tmpMovementTranslation=new V,u._tempCacheQuaternion=new G,u._attachController=function(e){if(!u._controllers[e.uniqueId]){u._controllers[e.uniqueId]={xrController:e,registeredComponents:[]};var t=u._controllers[e.uniqueId];if("tracked-pointer"===t.xrController.inputSource.targetRayMode&&t.xrController.inputSource.gamepad){var i=function(){if(e.motionController)for(var i=function(i){var r=null;if(i.allowedComponentTypes)for(var n=0,o=i.allowedComponentTypes;ni.rotationThreshold?e.x:0,t.rotateY=Math.abs(e.y)>i.rotationThreshold?e.y:0}},{allowedComponentTypes:[Rg.THUMBSTICK_TYPE,Rg.TOUCHPAD_TYPE],forceHandedness:"right",axisChangedHandler:function(e,t,i){t.moveX=Math.abs(e.x)>i.movementThreshold?e.x:0,t.moveY=Math.abs(e.y)>i.movementThreshold?e.y:0}}]},t.Version=1,t}(As);xs.AddWebXRFeature(gI.Name,(function(e,t){return function(){return new gI(e,t)}}),gI.Version,!0);var vI=function(e){function t(t,i){var r=e.call(this,t)||this;return r.options=i,r._canvasContext=null,r._reflectionCubeMap=null,r._xrLightEstimate=null,r._xrLightProbe=null,r._xrWebGLBinding=null,r._lightDirection=V.Up().negateInPlace(),r._lightColor=Z.White(),r._intensity=1,r._sphericalHarmonics=new Ep,r._cubeMapPollTime=Date.now(),r._lightEstimationPollTime=Date.now(),r._reflectionCubeMapTextureSize=16,r.directionalLight=null,r.onReflectionCubeMapUpdatedObservable=new f,r._updateReflectionCubeMap=function(){var e;if(r._xrLightProbe){if(r.options.cubeMapPollInterval){var t=Date.now();if(t-r._cubeMapPollTime=this._samples.length)throw new Error("Index out of bounds");return this._samples[(this._idx+e)%this._samples.length]},e}(),TI=function(){function e(){this._samples=new bI(20),this._entropy=0,this.onFirstStepDetected=new f}return e.prototype.update=function(e,t,i,r){this._samples.push(e,t);var n=this._samples.at(0);if(this._entropy*=this._entropyDecayFactor,this._entropy+=U.Distance(n,this._samples.at(1)),!(this._entropy>this._entropyThreshold)){var o;for(o=this._samePointCheckStartIdx;oa&&(s=c,a=l);if(!(ao*this._squaredProjectionDistanceThreshold)){var _=H.Vector3[0];_.set(i,r,0);var m=H.Vector3[1];m.set(h.x,h.y,0);var g=V.Cross(_,m).z>0,v=n.clone(),y=n.clone();u.subtractToRef(n,h),g?(h.scaleAndAddToRef(this._axisToApexShrinkFactor,v),h.scaleAndAddToRef(this._axisToApexExtendFactor,y)):(h.scaleAndAddToRef(this._axisToApexExtendFactor,v),h.scaleAndAddToRef(this._axisToApexShrinkFactor,y)),this.onFirstStepDetected.notifyObservers({leftApex:v,rightApex:y,currentPosition:n,currentStepDirection:g?"right":"left"})}}}}},e.prototype.reset=function(){for(var e=0;ethis._maxT&&(this._maxT=this._t,this._maxTPosition.copyFromFloats(e,t)),!(this._vitalityi&&(this.onMovement.notifyObservers({deltaT:this._t-i}),i<.5&&this._t>=.5&&this.onFootfall.notifyObservers({foot:this._steppingLeft?"left":"right"})),this._t<.95*this._maxT&&(this._currentPosition.copyFromFloats(e,t),this._steppingLeft?this._leftApex.copyFrom(this._maxTPosition):this._rightApex.copyFrom(this._maxTPosition),this._reset(this._leftApex,this._rightApex,this._currentPosition,!this._steppingLeft)),this._axisLength<.03))},Object.defineProperty(e.prototype,"_vitalityThreshold",{get:function(){return.1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"forward",{get:function(){return this._forward},enumerable:!1,configurable:!0}),e}(),SI=function(){function e(t){var i=this;this._detector=new TI,this._walker=null,this._movement=new U,this._millisecondsSinceLastUpdate=e._MillisecondsPerUpdate,this.movementThisFrame=V.Zero(),this._engine=t,this._detector.onFirstStepDetected.add((function(e){i._walker||(i._walker=new EI(e.leftApex,e.rightApex,e.currentPosition,e.currentStepDirection),i._walker.onFootfall.add((function(){ae.Log("Footfall!")})),i._walker.onMovement.add((function(e){i._walker.forward.scaleAndAddToRef(.024*e.deltaT,i._movement)})))}))}return Object.defineProperty(e,"_MillisecondsPerUpdate",{get:function(){return 1e3/15},enumerable:!1,configurable:!0}),e.prototype.update=function(t,i){i.y=0,i.normalize(),this._millisecondsSinceLastUpdate+=this._engine.getDeltaTime(),this._millisecondsSinceLastUpdate>=e._MillisecondsPerUpdate&&(this._millisecondsSinceLastUpdate-=e._MillisecondsPerUpdate,this._detector.update(t.x,t.z,i.x,i.z),this._walker&&(this._walker.update(t.x,t.z)||(this._walker=null)),this._movement.scaleInPlace(.85)),this.movementThisFrame.set(this._movement.x,0,this._movement.y)},e}(),xI=function(e){function t(t,i){var r=e.call(this,t)||this;return r._up=new V,r._forward=new V,r._position=new V,r._movement=new V,r._sessionManager=t,r.locomotionTarget=i.locomotionTarget,r._isLocomotionTargetWebXRCamera&&ae.Warn("Using walking locomotion directly on a WebXRCamera may have unintended interactions with other XR techniques. Using an XR space parent is highly recommended"),r}return m(t,e),Object.defineProperty(t,"Name",{get:function(){return Ss.WALKING_LOCOMOTION},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Version",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"locomotionTarget",{get:function(){return this._locomotionTarget},set:function(e){this._locomotionTarget=e,this._isLocomotionTargetWebXRCamera="WebXRCamera"===this._locomotionTarget.getClassName()},enumerable:!1,configurable:!0}),t.prototype.isCompatible=function(){return void 0===this._sessionManager.sessionMode||"immersive-vr"===this._sessionManager.sessionMode},t.prototype.attach=function(){return!(!this.isCompatible||!e.prototype.attach.call(this)||(this._walker=new SI(this._sessionManager.scene.getEngine()),0))},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._walker=null,!0)},t.prototype._onXRFrame=function(e){var t=e.getViewerPose(this._sessionManager.baseReferenceSpace);if(t){var i=this.locomotionTarget.getScene().useRightHandedSystem?1:-1,r=t.transform.matrix;this._up.copyFromFloats(r[4],r[5],i*r[6]),this._forward.copyFromFloats(r[8],r[9],i*r[10]),this._position.copyFromFloats(r[12],r[13],i*r[14]),this._forward.scaleAndAddToRef(.05,this._position),this._up.scaleAndAddToRef(-.05,this._position),this._walker.update(this._position,this._forward),this._movement.copyFrom(this._walker.movementThisFrame),this._isLocomotionTargetWebXRCamera||V.TransformNormalToRef(this._movement,this.locomotionTarget.getWorldMatrix(),this._movement),this.locomotionTarget.position.addInPlace(this._movement)}},t}(As);xs.AddWebXRFeature(xI.Name,(function(e,t){return function(){return new xI(e,t)}}),xI.Version,!1);var AI=function(e){function t(t,i,r,n,o,a,s){void 0===s&&(s=null);var l=e.call(this,t,i,r,n,a)||this;return l.getWidth=t,l.getHeight=i,l.layer=r,l.layerType=n,l.isMultiview=o,l.createRTTProvider=a,l._originalInternalTexture=s,l}return m(t,e),t}(zu),CI=function(e){function t(t,i,r){var n=e.call(this,t.scene,r)||this;return n._xrSessionManager=t,n._xrWebGLBinding=i,n.layerWrapper=r,n._lastSubImages=new Map,n.onRenderTargetTextureCreatedObservable=new f,n._compositionLayer=r.layer,n}return m(t,e),t.prototype._getRenderTargetForSubImage=function(e,t){var i,r,n,o;void 0===t&&(t="none");var a=this._lastSubImages.get(t),s="right"==t?1:0,l=null!==(i=e.colorTextureWidth)&&void 0!==i?i:e.textureWidth,c=null!==(r=e.colorTextureHeight)&&void 0!==r?r:e.textureHeight;if(!this._renderTargetTextures[s]||(null==a?void 0:a.textureWidth)!==l||(null==a?void 0:a.textureHeight)!==c){var u=void 0,h=null!==(n=e.depthStencilTextureWidth)&&void 0!==n?n:l,d=null!==(o=e.depthStencilTextureHeight)&&void 0!==o?o:c;l!==h&&c!==d||(u=e.depthStencilTexture),this._renderTargetTextures[s]=this._createRenderTargetTexture(l,c,null,e.colorTexture,u,this.layerWrapper.isMultiview),this._framebufferDimensions={framebufferWidth:l,framebufferHeight:c},this.onRenderTargetTextureCreatedObservable.notifyObservers({texture:this._renderTargetTextures[s],eye:t})}return this._lastSubImages.set(t,e),this._renderTargetTextures[s]},t.prototype._getSubImageForEye=function(e){var t=this._xrSessionManager.currentFrame;return t?this._xrWebGLBinding.getSubImage(this._compositionLayer,t,e):null},t.prototype.getRenderTargetTextureForEye=function(e){var t=this._getSubImageForEye(e);return t?this._getRenderTargetForSubImage(t,e):null},t.prototype.getRenderTargetTextureForView=function(e){return this.getRenderTargetTextureForEye(null==e?void 0:e.eye)},t.prototype._setViewportForSubImage=function(e,t){var i,r,n=null!==(i=t.colorTextureWidth)&&void 0!==i?i:t.textureWidth,o=null!==(r=t.colorTextureHeight)&&void 0!==r?r:t.textureHeight,a=t.viewport;e.x=a.x/n,e.y=a.y/o,e.width=a.width/n,e.height=a.height/o},t.prototype.trySetViewportForView=function(e,t){var i=this._lastSubImages.get(t.eye)||this._getSubImageForEye(t.eye);return!!i&&(this._setViewportForSubImage(e,i),!0)},t}(Wu),RI=function(e){function t(t,i,r){var n=e.call(this,(function(){return t.textureWidth}),(function(){return t.textureHeight}),t,"XRProjectionLayer",i,(function(e){return new PI(e,r,n)}))||this;return n.layer=t,n}return m(t,e),t}(AI),PI=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.layerWrapper=r,n._projectionLayer=r.layer,n}return m(t,e),t.prototype._getSubImageForView=function(e){return this._xrWebGLBinding.getViewSubImage(this._projectionLayer,e)},t.prototype.getRenderTargetTextureForView=function(e){return this._getRenderTargetForSubImage(this._getSubImageForView(e),e.eye)},t.prototype.getRenderTargetTextureForEye=function(e){var t=this._lastSubImages.get(e);return t?this._getRenderTargetForSubImage(t,e):null},t.prototype.trySetViewportForView=function(e,t){var i=this._lastSubImages.get(t.eye)||this._getSubImageForView(t);return!!i&&(this._setViewportForSubImage(e,i),!0)},t}(CI),II={textureType:"texture",colorFormat:6408,depthFormat:35056,scaleFactor:1,clearOnAccess:!1},MI={},OI=function(e){function t(t,i){void 0===i&&(i={});var r=e.call(this,t)||this;return r._options=i,r._existingLayers=[],r._isMultiviewEnabled=!1,r._projectionLayerInitialized=!1,r._compositionLayerTextureMapping=new WeakMap,r._layerToRTTProviderMapping=new WeakMap,r.xrNativeFeatureName="layers",r}return m(t,e),t.prototype.attach=function(){if(!e.prototype.attach.call(this))return!1;var t=this._xrSessionManager.scene.getEngine();this._glContext=t._gl,this._xrWebGLBinding=new XRWebGLBinding(this._xrSessionManager.session,this._glContext),this._existingLayers.length=0;var i=g(g({},II),this._options.projectionLayerInit);return this._isMultiviewEnabled=this._options.preferMultiviewOnInit&&t.getCaps().multiview,this.createProjectionLayer(i),this._projectionLayerInitialized=!0,!0},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._existingLayers.forEach((function(e){e.dispose()})),this._existingLayers.length=0,this._projectionLayerInitialized=!1,!0)},t.prototype.createXRWebGLLayer=function(e){void 0===e&&(e=MI);var t=new XRWebGLLayer(this._xrSessionManager.session,this._glContext,e);return new Hu(t)},t.prototype._validateLayerInit=function(e,t){if(void 0===t&&(t=this._isMultiviewEnabled),!this._xrSessionManager.inXRSession)throw new Error("Cannot create a layer outside of a WebXR session. Make sure the session has started before creating layers.");if(t&&"texture-array"!==e.textureType)throw new Error("Projection layers can only be made multiview if they use texture arrays. Set the textureType parameter to 'texture-array'.");if(!t&&"texture-array"===e.textureType)throw new Error("We currently only support multiview rendering when the textureType parameter is set to 'texture-array'.")},t.prototype._extendXRLayerInit=function(e,t){return void 0===t&&(t=this._isMultiviewEnabled),t&&(e.textureType="texture-array"),e},t.prototype.createProjectionLayer=function(e,t){void 0===e&&(e=II),void 0===t&&(t=this._isMultiviewEnabled),this._extendXRLayerInit(e,t),this._validateLayerInit(e,t);var i=this._xrWebGLBinding.createProjectionLayer(e),r=new RI(i,t,this._xrWebGLBinding);return this.addXRSessionLayer(r),r},t.prototype._createQuadLayer=function(e,t){var i=this;void 0===e&&(e={params:{}}),this._extendXRLayerInit(e.params,!1);var r=this._existingLayers[0].layer.textureWidth,n=this._existingLayers[0].layer.textureHeight,o=g({space:this._xrSessionManager.referenceSpace,viewPixelWidth:r,viewPixelHeight:n,clearOnAccess:!0},e.params);this._validateLayerInit(o,!1);var a=this._xrWebGLBinding.createQuadLayer(o);a.width=this._isMultiviewEnabled?1:2,a.height=1;var s=new AI((function(){return a.width}),(function(){return a.height}),a,"XRQuadLayer",!1,(function(e){return new CI(e,i._xrWebGLBinding,s)}));t&&this._compositionLayerTextureMapping.set(a,t);var l=s.createRenderTargetTextureProvider(this._xrSessionManager);return this._layerToRTTProviderMapping.set(a,l),this.addXRSessionLayer(s),s},t.prototype.addFullscreenAdvancedDynamicTexture=function(e,t){var i=this;void 0===t&&(t={distanceFromHeadset:1.5});var r=this._createQuadLayer({params:{space:this._xrSessionManager.viewerReferenceSpace,textureType:"texture",layout:"mono"}},e),n=r.layer,o={x:0,y:0,z:-Math.max(.1,t.distanceFromHeadset)};n.transform=new XRRigidTransform(o,{x:0,y:0,z:0,w:1});var a=this._layerToRTTProviderMapping.get(n);if(!a)throw new Error("Could not find the RTT provider for the layer");var s=this._xrSessionManager.scene.layers.find((function(t){return t.texture===e}));if(!s)throw new Error("Could not find the babylon layer for the texture");return a.onRenderTargetTextureCreatedObservable.add((function(e){e.eye&&"right"===e.eye||(e.texture.clearColor=new J(0,0,0,0),s.renderTargetTextures.push(e.texture),s.renderOnlyInRenderTargetTextures=!0,i._xrSessionManager.scene.onBeforeRenderObservable.add((function(){e.texture.render()})),s.renderTargetTextures.push(e.texture),s.renderOnlyInRenderTargetTextures=!0,i._xrSessionManager.onXRSessionEnded.addOnce((function(){s.renderTargetTextures.splice(s.renderTargetTextures.indexOf(e.texture),1),s.renderOnlyInRenderTargetTextures=!1})))})),r},t.prototype._addLensFlareSystem=function(e){var t=this,i=this._createQuadLayer({params:{space:this._xrSessionManager.viewerReferenceSpace,textureType:"texture",layout:"mono"}}),r=i.layer;r.width=2,r.height=1;r.transform=new XRRigidTransform({x:0,y:0,z:-10},{x:0,y:0,z:0,w:1});var n=this._layerToRTTProviderMapping.get(r);if(!n)throw new Error("Could not find the RTT provider for the layer");return n.onRenderTargetTextureCreatedObservable.add((function(t){t.texture.clearColor=new J(0,0,0,0),t.texture.customRenderFunction=function(){e.render()}})),this._xrSessionManager.onXRSessionInit.add((function(){t._xrSessionManager.scene.lensFlareSystems.splice(t._xrSessionManager.scene.lensFlareSystems.indexOf(e),1)})),this._xrSessionManager.onXRSessionEnded.add((function(){t._xrSessionManager.scene.lensFlareSystems.push(e)})),i},t.prototype.addXRSessionLayer=function(e){this._existingLayers.push(e),this.setXRSessionLayers(this._existingLayers)},t.prototype.setXRSessionLayers=function(e){void 0===e&&(e=this._existingLayers);var t=g({},this._xrSessionManager.session.renderState);t.baseLayer=void 0,t.layers=e.map((function(e){return e.layer})),this._xrSessionManager.updateRenderState(t),this._projectionLayerInitialized||this._xrSessionManager._setBaseLayerWrapper(e.length>0?e.at(0):null)},t.prototype.isCompatible=function(){return!this._xrSessionManager.isNative&&"undefined"!=typeof XRWebGLBinding&&!!XRWebGLBinding.prototype.createProjectionLayer},t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype._onXRFrame=function(e){for(var t=this._existingLayers,i=0;i0},e.prototype.connectTo=function(e){if(this._connectionType===e._connectionType)throw new Error("Cannot connect two points of type ".concat(this.connectionType));if(this._isSingularConnection()&&this._connectedPoint.length>0||e._isSingularConnection()&&e._connectedPoint.length>0)throw new Error("Max number of connections for point reached");this._connectedPoint.push(e),e._connectedPoint.push(this)},e.prototype.serialize=function(e){void 0===e&&(e={}),e.uniqueId=this.uniqueId,e.name=this.name,e._connectionType=this._connectionType,e.connectedPointIds=[],e.className=this.getClassName();for(var t=0,i=this._connectedPoint;t0;){e(o=t.pop());for(var a=0,s=o.dataInputs;ar)this.timeRemaining.setValue(0,e),this.out._activateSignal(e),e._setExecutionVariable(this,"lastExecutedTime",n);else{var o=r-(n-i);this.timeRemaining.setValue(o,e)}},t.prototype.getClassName=function(){return"FGThrottleBlock"},t}(CM);a("FGThrottleBlock",wM);var BM=function(e){function t(t){var i=e.call(this,t)||this;return i.timeout=i.registerDataInput("timeout",JI),i}return m(t,e),t.prototype._preparePendingTasks=function(e){var t=this,i=this.timeout.getValue(e);if(void 0!==i&&i>=0){var r=e._getExecutionVariable(this,"runningTimers")||[],n=e.configuration.scene,o=new jg({timeout:i,contextObservable:n.onBeforeRenderObservable,onEnded:function(){return t._onEnded(o,e)}});o.start(),r.push(o),e._setExecutionVariable(this,"runningTimers",r)}},t.prototype._execute=function(e){this._startPendingTasks(e),this.out._activateSignal(e)},t.prototype._onEnded=function(e,t){var i=t._getExecutionVariable(this,"runningTimers")||[],r=i.indexOf(e);-1!==r?i.splice(r,1):rr.Warn("FlowGraphTimerBlock: Timer ended but was not found in the running timers list"),t._removePendingBlock(this),this.done._activateSignal(t)},t.prototype._cancelPendingTasks=function(e){for(var t=0,i=e._getExecutionVariable(this,"runningTimers")||[];t=this.config.numberOutputFlows&&this.config.loop)o=0;else if(o>=this.config.numberOutputFlows&&!this.config.loop)return;if(n=n.filter((function(e){return e!==o})),0===n.length)for(var a=0;a=0&&(i[n+1]=!0)}if(e._setExecutionVariable(this,"activationState",i.slice()),i.every((function(e){return e})))for(this.out._activateSignal(e),r=0;r=i&&(this.out._activateSignal(e),e._setExecutionVariable(this,"debounceCount",0))}else e._setExecutionVariable(this,"debounceCount",0)},t.prototype.getClassName=function(){return"FGDebounceBlock"},t}(CM);a("FGDebounceBlock",WM);var HM=function(e){function t(t){var i=e.call(this,t)||this;return i.onOn=i._registerSignalOutput("onOn"),i.onOff=i._registerSignalOutput("onOff"),i.isOn=i.registerDataOutput("isOn",$I),i}return m(t,e),t.prototype._execute=function(e,t){var i=e._getExecutionVariable(this,"value",!1);i=!i,e._setExecutionVariable(this,"value",i),this.isOn.setValue(i,e),i?this.onOn._activateSignal(e):this.onOff._activateSignal(e)},t.prototype.getClassName=function(){return"FGFlipFlopBlock"},t}(mM);a("FGFlipFlopBlock",HM);var XM=function(e){function t(t){var i=e.call(this,t)||this;i.config=t,i.outFlows=[];for(var r=0;rt}))},t.ClassName="FGGreaterThanBlock",t}(rO);a(qO.ClassName,qO);var ZO=function(e){function t(i){var r=e.call(this,qI,qI,$I,(function(e,t){return r._polymorphicGreaterThanOrEqual(e,t)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicGreaterThanOrEqual=function(e,t){return YO(e,t,(function(e,t){return e>=t}))},t.ClassName="FGGreaterThanOrEqualBlock",t}(rO);a(ZO.ClassName,ZO);var JO=function(e){function t(i){var r=e.call(this,qI,$I,(function(e){return r._polymorphicIsNan(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicIsNan=function(e){var t=fO(e);if(""===t)return isNaN(e);if("FlowGraphInteger"===t)return isNaN(e.value);throw new Error("Cannot get NaN of ".concat(e))},t.ClassName="FGIsNanBlock",t}(nO);a(JO.ClassName,JO);var $O=function(e){function t(i){var r=e.call(this,qI,$I,(function(e){return r._polymorphicIsInf(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicIsInf=function(e){var t=fO(e);if(""===t)return!isFinite(e);if("FlowGraphInteger"===t)return!isFinite(e.value);throw new Error("Cannot get isInf of ".concat(e))},t.ClassName="FGIsInfBlock",t}(nO),eD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicDegToRad(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._degToRad=function(e){return e*Math.PI/180},t.prototype._polymorphicDegToRad=function(e){return PO(e,this._degToRad)},t.ClassName="FGDegToRadBlock",t}(nO);a(eD.ClassName,eD);var tD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicRadToDeg(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._radToDeg=function(e){return 180*e/Math.PI},t.prototype._polymorphicRadToDeg=function(e){return PO(e,this._radToDeg)},t.ClassName="FGRadToDegBlock",t}(nO);a(tD.ClassName,tD);var iD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicSin(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicSin=function(e){return PO(e,Math.sin)},t.ClassName="FGSinBlock",t}(nO);a(iD.ClassName,iD);var rD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicCos(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicCos=function(e){return PO(e,Math.cos)},t.ClassName="FGCosBlock",t}(nO);a(rD.ClassName,rD);var nD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicTan(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicTan=function(e){return PO(e,Math.tan)},t.ClassName="FGTanBlock",t}(nO);a(nD.ClassName,nD);var oD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicAsin(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicAsin=function(e){return PO(e,Math.asin)},t.ClassName="FGAsinBlock",t}(nO);a(oD.ClassName,oD);var aD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicAcos(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicAcos=function(e){return PO(e,Math.acos)},t.ClassName="FGAcosBlock",t}(nO);a(aD.ClassName,aD);var sD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicAtan(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicAtan=function(e){return PO(e,Math.atan)},t.ClassName="FGAtanBlock",t}(nO);a(sD.ClassName,sD);var lD=function(e){function t(i){var r=e.call(this,qI,qI,qI,(function(e,t){return r._polymorphicAtan2(e,t)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicAtan2=function(e,t){return wO(e,t,Math.atan2)},t.ClassName="FGAtan2Block",t}(rO);a(lD.ClassName,lD);var cD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicSinh(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicSinh=function(e){return PO(e,Math.sinh)},t.ClassName="FGSinhBlock",t}(nO);a(cD.ClassName,cD);var uD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicCosh(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicCosh=function(e){return PO(e,Math.cosh)},t.ClassName="FGCoshBlock",t}(nO);a(uD.ClassName,uD);var hD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicTanh(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicTanh=function(e){return PO(e,Math.tanh)},t.ClassName="FGTanhBlock",t}(nO);a(hD.ClassName,hD);var dD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicAsinh(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicAsinh=function(e){return PO(e,Math.asinh)},t.ClassName="FGAsinhBlock",t}(nO);a(dD.ClassName,dD);var pD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicAcosh(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicAcosh=function(e){return PO(e,Math.acosh)},t.ClassName="FGAcoshBlock",t}(nO);a(pD.ClassName,pD);var fD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicAtanh(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicAtanh=function(e){return PO(e,Math.atanh)},t.ClassName="FGAtanhBlock",t}(nO);a(fD.ClassName,fD);var _D=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicExp(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicExp=function(e){return PO(e,Math.exp)},t.ClassName="FGExpBlock",t}(nO);a(_D.ClassName,_D);var mD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicLog(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicLog=function(e){return PO(e,Math.log)},t.ClassName="FGLogBlock",t}(nO);a(mD.ClassName,mD);var gD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicLog2(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicLog2=function(e){return PO(e,Math.log2)},t.ClassName="FGLog2Block",t}(nO);a(gD.ClassName,gD);var vD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicLog10(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicLog10=function(e){return PO(e,Math.log10)},t.ClassName="FGLog10Block",t}(nO);a(vD.ClassName,vD);var yD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicSqrt(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicSqrt=function(e){return PO(e,Math.sqrt)},t.ClassName="FGSqrtBlock",t}(nO);a(yD.ClassName,yD);var bD=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicCubeRoot(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicCubeRoot=function(e){return PO(e,Math.cbrt)},t.ClassName="FGCubeRootBlock",t}(nO);a(bD.ClassName,bD);var TD=function(e){function t(i){var r=e.call(this,qI,JI,JI,(function(e,t){return r._polymorphicPow(e,t)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicPow=function(e,t){return wO(e,t,Math.pow)},t.ClassName="FGPowBlock",t}(rO);a(TD.ClassName,TD);var ED=function(e){function t(i){var r=e.call(this,qI,JI,(function(e){return r._polymorphicLength(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicLength=function(e){switch(fO(e)){case"Vector2":case"Vector3":case"Vector4":return e.length();default:throw new Error("Cannot compute length of value ".concat(e))}},t.ClassName="FGLengthBlock",t}(nO);a(ED.ClassName,ED);var SD=function(e){function t(i){var r=e.call(this,qI,qI,(function(e){return r._polymorphicNormalize(e)}),t.ClassName,i)||this;return r}return m(t,e),t.prototype._polymorphicNormalize=function(e){switch(fO(e)){case"Vector2":case"Vector3":case"Vector4":return e.normalize();default:throw new Error("Cannot normalize value ".concat(e))}},t.ClassName="FGNormalizeBlock",t}(nO);a(SD.ClassName,SD);var xD=function(e){function t(i){return e.call(this,tM,tM,tM,(function(e,t){return V.Cross(e,t)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGCrossBlock",t}(rO);a(xD.ClassName,xD);var AD=function(e){function t(i){return e.call(this,eM,JI,eM,(function(e,t){return U.Transform(e,z.RotationZ(t))}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGRotate2DBlock",t}(rO);a(AD.ClassName,AD);var CD=function(e){function t(i){return e.call(this,tM,tM,JI,tM,(function(e,t,i){return V.TransformCoordinates(e,z.RotationAxis(t,i))}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGRotate3DBlock",t}(pO);a(CD.ClassName,CD);var RD=function(e){function t(i){return e.call(this,rM,rM,(function(e){return z.Transpose(e)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGTransposeBlock",t}(nO);a(RD.ClassName,RD);var PD=function(e){function t(i){return e.call(this,rM,JI,(function(e){return e.determinant()}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGDeterminantBlock",t}(nO);a(PD.ClassName,PD);var ID=function(e){function t(i){return e.call(this,rM,rM,(function(e){return z.Invert(e)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGInvertMatrixBlock",t}(nO);a(ID.ClassName,ID);var MD=function(e){function t(i){return e.call(this,rM,rM,rM,(function(e,t){return t.multiply(e)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGMatMulBlock",t}(rO);a(MD.ClassName,MD);var OD=function(e){function t(i){return e.call(this,sM,sM,(function(e){return new KI(~e.value)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGBitwiseNotBlock",t}(nO);a(OD.ClassName,OD);var DD=function(e){function t(i){return e.call(this,sM,sM,sM,(function(e,t){return new KI(e.value&t.value)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGBitwiseAndBlock",t}(rO);a(DD.ClassName,DD);var ND=function(e){function t(i){return e.call(this,sM,sM,sM,(function(e,t){return new KI(e.value|t.value)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGBitwiseOrBlock",t}(rO);a(ND.ClassName,ND);var FD=function(e){function t(i){return e.call(this,sM,sM,sM,(function(e,t){return new KI(e.value^t.value)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGBitwiseXorBlock",t}(rO);a(FD.ClassName,FD);var LD=function(e){function t(i){return e.call(this,sM,sM,sM,(function(e,t){return new KI(e.value<>t.value)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGBitwiseRightShiftBlock",t}(rO);a(wD.ClassName,wD);var BD=function(e){function t(i){return e.call(this,sM,sM,(function(e){return new KI(Math.clz32(e.value))}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGCountLeadingZerosBlock",t}(nO);a(BD.ClassName,BD);var UD=function(e){function t(i){return e.call(this,sM,sM,(function(e){return new KI(e.value?31-Math.clz32(e.value&-e.value):32)}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGCountTrailingZerosBlock",t}(nO);a(UD.ClassName,UD);var VD=function(e){function t(i){return e.call(this,sM,sM,(function(e){return new KI(function(e){for(var t=0;e;)t+=1&e,e>>=1;return t}(e.value))}),t.ClassName,i)||this}return m(t,e),t.ClassName="FGCountOneBitsBlock",t}(nO);a(VD.ClassName,VD);var kD=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype._preparePendingTasks=function(e){var t=this;if(!e._getExecutionVariable(this,"sceneReadyObserver")){var i=e.configuration.scene.onReadyObservable.add((function(){t._execute(e)}));e._setExecutionVariable(this,"sceneReadyObserver",i)}},t.prototype._cancelPendingTasks=function(e){var t=e._getExecutionVariable(this,"sceneReadyObserver");e.configuration.scene.onReadyObservable.remove(t),e._deleteExecutionVariable(this,"sceneReadyObserver")},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGSceneReadyEventBlock",t}(vM);a("FGSceneReadyEventBlock",kD);var GD=function(e){function t(t){var i=e.call(this,t)||this;i.config=t;for(var r=0;r