!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:()=>JO});var i={};e.r(i),e.d(i,{AxesViewer:()=>cu,BoneAxesViewer:()=>uu,DebugLayer:()=>hu,DebugLayerTab:()=>au,DirectionalLightFrustumViewer:()=>Bh,PhysicsViewer:()=>Fh,RayHelper:()=>Lh,SkeletonViewer:()=>wh});var r={};e.r(r),e.d(r,{AbstractActionManager:()=>s,AbstractAssetTask:()=>fA,AbstractMesh:()=>Vn,AbstractScene:()=>o,AcquireNativeObjectAsync:()=>Gd,Action:()=>k,ActionEvent:()=>G,ActionManager:()=>de,AddBlock:()=>jv,AddressMode:()=>ip,AdvancedTimer:()=>Tm,AlignBlock:()=>iE,AlphaState:()=>Ht,AmmoJSPlugin:()=>hg,AnaglyphArcRotateCamera:()=>Ol,AnaglyphFreeCamera:()=>Dl,AnaglyphGamepadCamera:()=>Nl,AnaglyphPostProcess:()=>Il,AnaglyphUniversalCamera:()=>Fl,Analyser:()=>lo,AndOrNotEvaluator:()=>_e,Angle:()=>Fr,Animatable:()=>Ir,AnimatedInputBlockTypes:()=>ya,Animation:()=>Ke,AnimationAssetTask:()=>vA,AnimationEvent:()=>Jr,AnimationGroup:()=>en,AnimationGroupMask:()=>rn,AnimationGroupMaskMode:()=>Dr,AnimationKeyInterpolation:()=>Ue,AnimationPropertiesOverride:()=>Or,AnimationRange:()=>Ge,AnisotropyBlock:()=>Ny,ApplyPostProcess:()=>rd,Arc2:()=>Lr,ArcFollowCamera:()=>vl,ArcRotateCamera:()=>ul,ArcRotateCameraGamepadInput:()=>Vs,ArcRotateCameraInputsManager:()=>Ws,ArcRotateCameraKeyboardMoveInput:()=>ks,ArcRotateCameraMouseWheelInput:()=>Gs,ArcRotateCameraPointersInput:()=>zs,ArcRotateCameraVRDeviceOrientationInput:()=>Hs,ArcTan2Block:()=>_y,AssetContainer:()=>so,AssetTaskState:()=>hA,AssetsManager:()=>RA,AssetsProgressEvent:()=>_A,AsyncLoop:()=>Pi,AttachToBoxBehavior:()=>Do,AudioEngine:()=>co,AudioSceneComponent:()=>po,AutoLayoutMode:()=>pp,AutoReleaseWorkerPool:()=>K_,AutoRotationBehavior:()=>Po,AxesViewer:()=>cu,Axis:()=>Cr,AxisDragGizmo:()=>lu,AxisScaleGizmo:()=>Xf,BRDFTextureTools:()=>m_,BabylonFileLoaderConfiguration:()=>fg,BackEase:()=>Gr,BackgroundMaterial:()=>u_,BakedVertexAnimationManager:()=>_o,BallAndSocketConstraint:()=>gS,BaseCameraMouseWheelInput:()=>Ds,BaseCameraPointersInput:()=>Ns,BaseError:()=>ht,BaseParticleSystem:()=>Ka,BaseSixDofDragBehavior:()=>zo,BaseTexture:()=>go,BasisTools:()=>nv,BasisToolsOptions:()=>qg,BasisTranscodeConfiguration:()=>Qg,BezierCurve:()=>Nr,BezierCurveEase:()=>Zr,BiPlanarBlock:()=>Qy,BinaryFileAssetTask:()=>bA,BlackAndWhitePostProcess:()=>WS,BlendFactor:()=>vp,BlendOperation:()=>yp,BloomEffect:()=>YS,BloomMergePostProcess:()=>jS,BlurPostProcess:()=>a_,Bone:()=>Pr,BoneAxesViewer:()=>uu,BoneIKController:()=>Cs,BoneLookController:()=>Ps,BonesBlock:()=>gv,BooleanGeometryBlock:()=>SE,BooleanGeometryOperations:()=>TE,BounceEase:()=>zr,BouncingBehavior:()=>Io,BoundingBlock:()=>EE,BoundingBox:()=>fn,BoundingBoxGizmo:()=>jf,BoundingBoxRenderer:()=>Fx,BoundingInfo:()=>bn,BoundingSphere:()=>_n,BoxBlock:()=>mT,BoxBuilder:()=>_u,BoxParticleEmitter:()=>Ua,Buffer:()=>Xi,BufferBindingType:()=>sp,BufferMapState:()=>Kd,BufferUsage:()=>Qd,CSG:()=>Bb,Camera:()=>dn,CameraGizmo:()=>o_,CameraInputTypes:()=>Fs,CameraInputsManager:()=>Ls,CannonJSPlugin:()=>cg,CanvasAlphaMode:()=>Ip,CapsuleBlock:()=>RT,CapsuleBuilder:()=>Tu,CascadedShadowGenerator:()=>qm,ChromaticAberrationPostProcess:()=>KS,CircleEase:()=>kr,CircleOfConfusionPostProcess:()=>QS,ClampBlock:()=>Kv,ClearCoatBlock:()=>Ly,ClipPlanesBlock:()=>zv,ClipboardEventTypes:()=>Wf,ClipboardInfo:()=>Hf,CloudBlock:()=>Xy,CloudPoint:()=>YE,Collider:()=>Xc,Color3:()=>B,Color3Gradient:()=>DE,Color4:()=>U,ColorCorrectionPostProcess:()=>qS,ColorCurves:()=>Ni,ColorGradient:()=>OE,ColorGradingTexture:()=>Pg,ColorMergerBlock:()=>$v,ColorSplitterBlock:()=>Qa,ColorWrite:()=>gp,CombineAction:()=>se,CompareFunction:()=>op,CompatibilityOptions:()=>Pn,CompilationMessageType:()=>hp,CompleteGreasedLineColorTable:()=>cT,CompleteGreasedLineWidthTable:()=>lT,ComputeBindingType:()=>Yc,ComputeEffect:()=>Kc,ComputeNormalsBlock:()=>XT,ComputePassTimestampLocation:()=>xp,ComputeShader:()=>Qc,ComputeShaderParticleSystem:()=>IE,Condition:()=>Q,ConditionBlock:()=>VT,ConditionBlockTests:()=>wT,ConditionalBlock:()=>Hy,ConditionalBlockConditions:()=>zy,ConeParticleEmitter:()=>Va,Constants:()=>a,ContainerAssetTask:()=>mA,ConversionMode:()=>$x,ConvolutionPostProcess:()=>ZS,Coordinate:()=>Rr,CopyTextureToTexture:()=>iA,CopyTools:()=>To,CreateBox:()=>fu,CreateBoxVertexData:()=>du,CreateCapsule:()=>bu,CreateCapsuleVertexData:()=>yu,CreateCylinder:()=>eu,CreateCylinderVertexData:()=>$c,CreateDashedLines:()=>Xu,CreateDashedLinesVertexData:()=>zu,CreateDecal:()=>yh,CreateDisc:()=>Ru,CreateDiscVertexData:()=>Au,CreateEnvTextureAsync:()=>gd,CreateGeodesic:()=>Ah,CreateGoldberg:()=>Ph,CreateGoldbergVertexData:()=>Ch,CreateGreasedLine:()=>sT,CreateGreasedLineMaterial:()=>aT,CreateGround:()=>Nc,CreateGroundFromHeightMap:()=>Lc,CreateGroundFromHeightMapVertexData:()=>Dc,CreateGroundVertexData:()=>Mc,CreateHemisphere:()=>t_,CreateIcoSphere:()=>ps,CreateIcoSphereVertexData:()=>ds,CreateImageDataArrayBufferViews:()=>yd,CreateLathe:()=>oh,CreateLineSystem:()=>Wu,CreateLineSystemVertexData:()=>Gu,CreateLines:()=>Hu,CreatePlane:()=>Bo,CreatePlaneVertexData:()=>wo,CreatePolygon:()=>Ju,CreatePolygonVertexData:()=>Zu,CreatePolyhedron:()=>uh,CreatePolyhedronVertexData:()=>ch,CreateResizedCopy:()=>id,CreateRibbon:()=>Su,CreateRibbonVertexData:()=>Eu,CreateScreenshot:()=>QA,CreateScreenshotAsync:()=>qA,CreateScreenshotUsingRenderTarget:()=>JA,CreateScreenshotUsingRenderTargetAsync:()=>$A,CreateScreenshotWithResizeAsync:()=>ZA,CreateSegmentedBoxVertexData:()=>pu,CreateSphere:()=>gu,CreateSphereVertexData:()=>mu,CreateText:()=>Dh,CreateTextShapePaths:()=>Oh,CreateTiledBox:()=>Du,CreateTiledBoxVertexData:()=>Ou,CreateTiledGround:()=>Fc,CreateTiledGroundVertexData:()=>Oc,CreateTiledPlane:()=>Iu,CreateTiledPlaneVertexData:()=>Pu,CreateTorus:()=>Uc,CreateTorusKnot:()=>Lu,CreateTorusKnotVertexData:()=>Fu,CreateTorusVertexData:()=>Bc,CreateTube:()=>sh,CrossBlock:()=>Qv,CubeMapToSphericalPolynomialTools:()=>hd,CubeTexture:()=>l_,CubeTextureAssetTask:()=>SA,CubicEase:()=>Wr,CullMode:()=>mp,CurrentScreenBlock:()=>Ra,Curve3:()=>Ur,CurveBlock:()=>tb,CurveBlockTypes:()=>$y,CustomBlock:()=>qv,CustomOptimization:()=>BA,CustomParticleEmitter:()=>ja,CustomProceduralTexture:()=>uv,CylinderBlock:()=>AT,CylinderBuilder:()=>tu,CylinderDirectedParticleEmitter:()=>Ga,CylinderParticleEmitter:()=>ka,DDSTools:()=>k_,DataBuffer:()=>qt,DataReader:()=>nR,DataStorage:()=>oR,Database:()=>RE,DebugBlock:()=>dE,DebugLayer:()=>hu,DebugLayerTab:()=>au,DecalBuilder:()=>bh,DecalMapConfiguration:()=>cb,DecalMapDefines:()=>lb,Decode:()=>mt,DecodeBase64ToBinary:()=>yt,DecodeBase64ToString:()=>vt,DecodeBase64UrlToBinary:()=>yi,DecodeBase64UrlToString:()=>Ti,DeepCopier:()=>he,DefaultCollisionCoordinator:()=>jc,DefaultKTX2DecoderOptions:()=>q_,DefaultLoadingScreen:()=>$m,DefaultRenderingPipeline:()=>vx,Deferred:()=>CA,DepthCullingState:()=>zt,DepthOfFieldBlurPostProcess:()=>JS,DepthOfFieldEffect:()=>tx,DepthOfFieldEffectBlurLevel:()=>$S,DepthOfFieldMergePostProcess:()=>ex,DepthPeelingRenderer:()=>Bx,DepthPeelingSceneComponent:()=>Ux,DepthReducer:()=>Hm,DepthRenderer:()=>zm,DepthRendererSceneComponent:()=>Lx,DepthSortedParticle:()=>HE,DerivativeBlock:()=>Rv,DesaturateBlock:()=>Oy,DetailMapConfiguration:()=>dc,DeviceInputEventType:()=>Wi,DeviceLostReason:()=>Mp,DeviceOrientationCamera:()=>hl,DeviceSource:()=>pr,DeviceSourceManager:()=>_r,DeviceType:()=>wi,DirectionalLight:()=>e_,DirectionalLightFrustumViewer:()=>Bh,DiscBlock:()=>CT,DiscBuilder:()=>Cu,DiscardBlock:()=>xv,DisplayPassPostProcess:()=>ix,DistanceBlock:()=>uy,DistanceConstraint:()=>vS,DistanceJoint:()=>qo,DivideBlock:()=>iy,DoNothingAction:()=>ae,DomManagement:()=>st,DotBlock:()=>Zv,DracoCompression:()=>Mb,DrawWrapper:()=>ei,DualSenseInput:()=>ki,DualShockButton:()=>yl,DualShockDpad:()=>bl,DualShockInput:()=>Vi,DualShockPad:()=>El,DumpTools:()=>rs,DynamicFloat32Array:()=>fR,DynamicTexture:()=>vc,EasingFunction:()=>Vr,EdgesRenderer:()=>kx,Effect:()=>Gt,EffectFallbacks:()=>Ma,EffectLayer:()=>Om,EffectLayerSceneComponent:()=>Dm,EffectRenderer:()=>Za,EffectWrapper:()=>Ja,ElasticEase:()=>Hr,ElbowBlock:()=>Yy,EncodeArrayBufferToBase64:()=>gt,EndsWith:()=>ft,Engine:()=>Nn,EngineFactory:()=>zf,EngineFormat:()=>X_,EngineInstrumentation:()=>Im,EngineStore:()=>S,EngineView:()=>Wh,EnvironmentHelper:()=>h_,EnvironmentTextureTools:()=>Ad,Epsilon:()=>_,EquiRectangularCubeTexture:()=>Ig,EquiRectangularCubeTextureAssetTask:()=>AA,ErrorCodes:()=>dt,ErrorFilter:()=>Op,EventConstants:()=>lr,EventState:()=>l,ExecuteCodeAction:()=>le,ExponentialEase:()=>Xr,ExternalTexture:()=>df,ExtractHighlightsPostProcess:()=>XS,ExtrudePolygon:()=>$u,ExtrudeShape:()=>th,ExtrudeShapeCustom:()=>ih,FactorGradient:()=>NE,FadeInOutBehavior:()=>No,FeatureName:()=>Yd,FileTools:()=>bi,FileToolsOptions:()=>ci,FilesInput:()=>IA,FilesInputStore:()=>ct,FilterMode:()=>rp,FilterPostProcess:()=>rx,FlowGraph:()=>VC,FlowGraphACosNumberBlock:()=>UI,FlowGraphASinNumberBlock:()=>wI,FlowGraphATan2NumberBlock:()=>jI,FlowGraphATanNumberBlock:()=>kI,FlowGraphAbsNumberBlock:()=>uI,FlowGraphAddMatrixAndNumberBlock:()=>TO,FlowGraphAddMatrixBlock:()=>yO,FlowGraphAddNumberBlock:()=>jP,FlowGraphAddVector2Block:()=>dM,FlowGraphAddVector3Block:()=>IM,FlowGraphAddVector4Block:()=>tO,FlowGraphBitwiseAndBlock:()=>IP,FlowGraphBitwiseLeftShiftBlock:()=>NP,FlowGraphBitwiseNotBlock:()=>DP,FlowGraphBitwiseOrBlock:()=>MP,FlowGraphBitwiseRightShiftBlock:()=>FP,FlowGraphBitwiseXorBlock:()=>OP,FlowGraphBlock:()=>PC,FlowGraphBranchBlock:()=>KC,FlowGraphCeilNumberBlock:()=>mI,FlowGraphClampMatrixBlock:()=>LO,FlowGraphComposeMatrixBlock:()=>VO,FlowGraphConditionalDataBlock:()=>hP,FlowGraphConstantBlock:()=>fP,FlowGraphContext:()=>BC,FlowGraphCoordinateTransformBlock:()=>pP,FlowGraphCoordinator:()=>zC,FlowGraphCosNumberBlock:()=>DI,FlowGraphCountLeadingZerosBlock:()=>LP,FlowGraphCountTrailingZerosBlock:()=>wP,FlowGraphCounterBlock:()=>iP,FlowGraphCreateVector2Block:()=>AM,FlowGraphCreateVector3Block:()=>YM,FlowGraphCreateVector4Block:()=>_O,FlowGraphCrossVector3Block:()=>XM,FlowGraphDebounceBlock:()=>nP,FlowGraphDecomposeMatrixBlock:()=>BO,FlowGraphDivideMatrixAndNumberBlock:()=>OO,FlowGraphDivideMatrixBlock:()=>IO,FlowGraphDivideNumberBlock:()=>JP,FlowGraphDivideVector2Block:()=>vM,FlowGraphDivideVector3Block:()=>LM,FlowGraphDivideVector4Block:()=>sO,FlowGraphDoNBlock:()=>QC,FlowGraphDotVector3Block:()=>WM,FlowGraphENumberBlock:()=>zI,FlowGraphEqualsNumberBlock:()=>eM,FlowGraphEventBlock:()=>DC,FlowGraphEventCoordinator:()=>kC,FlowGraphExecutionBlock:()=>MC,FlowGraphExpNumberBlock:()=>EI,FlowGraphFlipFlopBlock:()=>oP,FlowGraphFloorNumberBlock:()=>fI,FlowGraphForLoopBlock:()=>qC,FlowGraphGetTransformationMatrixBlock:()=>WO,FlowGraphGetVariableBlock:()=>dP,FlowGraphGreaterThanNumberBlock:()=>iM,FlowGraphGreaterThanOrEqualsNumberBlock:()=>nM,FlowGraphIsInfinityNumberBlock:()=>aI,FlowGraphIsNaNNumberBlock:()=>nI,FlowGraphLengthVector2Block:()=>EM,FlowGraphLengthVector3Block:()=>VM,FlowGraphLengthVector4Block:()=>hO,FlowGraphLessThanNumberBlock:()=>aM,FlowGraphLessThanOrEqualsNumberBlock:()=>lM,FlowGraphLnNumberBlock:()=>PI,FlowGraphLog10NumberBlock:()=>xI,FlowGraphLogBlock:()=>HC,FlowGraphLogNumberBlock:()=>RI,FlowGraphLogicAndBlock:()=>GP,FlowGraphLogicNotBlock:()=>WP,FlowGraphLogicOrBlock:()=>zP,FlowGraphMaxNumberBlock:()=>JI,FlowGraphMeshPickEventBlock:()=>HO,FlowGraphMinNumberBlock:()=>qI,FlowGraphMixNumberBlock:()=>uM,FlowGraphModNumberBlock:()=>eI,FlowGraphMultiGateBlock:()=>$C,FlowGraphMultiplyMatrixBlock:()=>CO,FlowGraphMultiplyNumberBlock:()=>qP,FlowGraphMultiplyVector2Block:()=>mM,FlowGraphMultiplyVector3Block:()=>NM,FlowGraphMultiplyVector4Block:()=>oO,FlowGraphNegateNumberBlock:()=>dI,FlowGraphNormalizeVector2Block:()=>xM,FlowGraphNormalizeVector3Block:()=>GM,FlowGraphNormalizeVector4Block:()=>pO,FlowGraphPauseAnimationBlock:()=>lP,FlowGraphPiNumberBlock:()=>HI,FlowGraphPlayAnimationBlock:()=>aP,FlowGraphPlayAudioBlock:()=>cP,FlowGraphPowNumberBlock:()=>iI,FlowGraphQuaternionToRotationMatrixBlock:()=>GO,FlowGraphRandomNumberBlock:()=>KI,FlowGraphReceiveCustomEventBlock:()=>jO,FlowGraphRotate2dVector2Block:()=>CM,FlowGraphRotate3dVector3Block:()=>ZM,FlowGraphRoundNumberBlock:()=>vI,FlowGraphScaleMatrixBlock:()=>NO,FlowGraphScaleVector2Block:()=>bM,FlowGraphScaleVector3Block:()=>BM,FlowGraphScaleVector4Block:()=>cO,FlowGraphSceneReadyEventBlock:()=>XO,FlowGraphSceneTickEventBlock:()=>YO,FlowGraphSendCustomEventBlock:()=>YC,FlowGraphSetPropertyBlock:()=>jC,FlowGraphSetVariableBlock:()=>XC,FlowGraphSignalConnection:()=>IC,FlowGraphSinNumberBlock:()=>MI,FlowGraphSplitVector2Block:()=>RM,FlowGraphSplitVector3Block:()=>QM,FlowGraphSplitVector4Block:()=>gO,FlowGraphSqrtNumberBlock:()=>lI,FlowGraphState:()=>wC,FlowGraphStopAnimationBlock:()=>sP,FlowGraphStopAudioBlock:()=>uP,FlowGraphSubtractMatrixAndNumberBlock:()=>AO,FlowGraphSubtractMatrixBlock:()=>SO,FlowGraphSubtractNumberBlock:()=>KP,FlowGraphSubtractVector2Block:()=>fM,FlowGraphSubtractVector3Block:()=>OM,FlowGraphSubtractVector4Block:()=>rO,FlowGraphSwitchBlock:()=>eP,FlowGraphTanNumberBlock:()=>FI,FlowGraphThrottleBlock:()=>ZC,FlowGraphTimerBlock:()=>JC,FlowGraphTransformVector3Block:()=>$M,FlowGraphTruncNumberBlock:()=>bI,FlowGraphWaitAllBlock:()=>tP,FlowGraphWhileLoopBlock:()=>rP,FluidRenderer:()=>aA,FluidRendererSceneComponent:()=>oA,FluidRenderingDebug:()=>Kx,FluidRenderingObject:()=>qx,FluidRenderingObjectCustomParticles:()=>tA,FluidRenderingObjectParticleSystem:()=>Zx,FluidRenderingTargetRenderer:()=>eA,FlyCamera:()=>pl,FlyCameraInputsManager:()=>dl,FlyCameraKeyboardInput:()=>Xs,FlyCameraMouseInput:()=>js,FogBlock:()=>Lv,FollowBehavior:()=>Xo,FollowCamera:()=>gl,FollowCameraInputsManager:()=>fl,FollowCameraKeyboardMoveInput:()=>Ys,FollowCameraMouseWheelInput:()=>Ks,FollowCameraPointersInput:()=>Qs,FragCoordBlock:()=>Cv,FragDepthBlock:()=>Dv,FragmentOutputBlock:()=>va,FramingBehavior:()=>Mo,FreeCamera:()=>ll,FreeCameraDeviceOrientationInput:()=>il,FreeCameraGamepadInput:()=>nl,FreeCameraInputsManager:()=>tl,FreeCameraKeyboardMoveInput:()=>qs,FreeCameraMouseInput:()=>Js,FreeCameraMouseWheelInput:()=>$s,FreeCameraTouchInput:()=>el,FreeCameraVirtualJoystickInput:()=>al,FresnelBlock:()=>sy,FresnelParameters:()=>Sg,FromHalfFloat:()=>od,FrontFace:()=>_p,FrontFacingBlock:()=>Av,Frustum:()=>br,FxaaPostProcess:()=>nx,GPUParticleSystem:()=>UE,GUID:()=>Ai,Gamepad:()=>Bs,GamepadCamera:()=>Rl,GamepadManager:()=>Sl,GamepadSystemSceneComponent:()=>xl,GenerateBase64StringFromPixelData:()=>vo,GenerateBase64StringFromTexture:()=>yo,GenerateBase64StringFromTextureAsync:()=>bo,GenericPad:()=>Us,GeodesicData:()=>xh,Geometry:()=>In,GeometryBufferRenderer:()=>cx,GeometryBufferRendererSceneComponent:()=>hx,GeometryCollectionBlock:()=>WT,GeometryElbowBlock:()=>HT,GeometryInfoBlock:()=>fE,GeometryInputBlock:()=>_T,GeometryOptimizeBlock:()=>vT,GeometryOutputBlock:()=>pT,GeometryTextureBlock:()=>yE,GeometryTextureFetchBlock:()=>bE,GeometryTransformBlock:()=>ZT,GeometryTrigonometryBlock:()=>qT,GeometryTrigonometryBlockOperations:()=>KT,GetClass:()=>T,GetDOMTextContent:()=>ot,GetEnvInfo:()=>_d,GetEnvironmentBRDFTexture:()=>__,GetInternalFormatFromBasisFormat:()=>Zg,GetTGAHeader:()=>Wg,GetTextureDataAsync:()=>sd,Gizmo:()=>su,GizmoAnchorPoint:()=>iu,GizmoCoordinatesMode:()=>ru,GizmoManager:()=>Jf,GlowLayer:()=>Nm,GoldbergMesh:()=>Rh,GradientBlock:()=>Sy,GradientBlockColorStep:()=>Ey,GradientHelper:()=>FE,GrainPostProcess:()=>ox,GreasedLineBaseMesh:()=>Jb,GreasedLineMaterialDefaults:()=>gb,GreasedLineMesh:()=>$b,GreasedLineMeshColorDistribution:()=>eT,GreasedLineMeshColorDistributionType:()=>nb,GreasedLineMeshColorMode:()=>rb,GreasedLineMeshMaterialType:()=>ib,GreasedLineMeshWidthDistribution:()=>tT,GreasedLinePluginMaterial:()=>bb,GreasedLineRibbonAutoDirectionMode:()=>qb,GreasedLineRibbonFacesMode:()=>Qb,GreasedLineRibbonMesh:()=>oT,GreasedLineRibbonPointsMode:()=>Kb,GreasedLineSimpleMaterial:()=>Eb,GreasedLineTools:()=>vb,GridBlock:()=>ST,GroundBuilder:()=>wc,GroundMesh:()=>Ic,HDRCubeTexture:()=>rg,HDRCubeTextureAssetTask:()=>xA,HDRFiltering:()=>ig,HDRTools:()=>tg,HandConstraintBehavior:()=>Rs,HandConstraintOrientation:()=>ys,HandConstraintVisibility:()=>bs,HandConstraintZone:()=>vs,HandPart:()=>_s,HardwareScalingOptimization:()=>NA,HavokPlugin:()=>MS,HeightToNormalBlock:()=>Ov,HemisphereBuilder:()=>i_,HemisphericLight:()=>nu,HemisphericParticleEmitter:()=>za,HighlightLayer:()=>Lm,HighlightsPostProcess:()=>ax,Hinge2Joint:()=>$o,HingeConstraint:()=>yS,HingeJoint:()=>Jo,HtmlElementTexture:()=>Mg,IFlowGraphCoordinatorConfiguration:()=>GC,IWebXRControllerPhysicsOptions:()=>IR,IcoSphereBlock:()=>TT,IcoSphereBuilder:()=>gs,ImageAssetTask:()=>TA,ImageProcessingBlock:()=>Tv,ImageProcessingConfiguration:()=>Li,ImageProcessingConfigurationDefines:()=>Fi,ImageProcessingPostProcess:()=>sx,ImageSourceBlock:()=>Bv,IncrementValueAction:()=>re,IndexFormat:()=>Tp,InputBlock:()=>Aa,InspectableType:()=>tR,InstancedLinesMesh:()=>ku,InstancedMesh:()=>ro,InstancesBlock:()=>vv,InstantiateBlock:()=>lE,InstantiateLinearBlock:()=>cE,InstantiateOnFacesBlock:()=>oE,InstantiateOnVerticesBlock:()=>nE,InstantiateOnVolumeBlock:()=>aE,InstantiateRadialBlock:()=>uE,InstantiatedEntries:()=>ao,IntFloatConverterBlock:()=>hE,InternalTexture:()=>jt,InternalTextureSource:()=>Ot,InterpolateValueAction:()=>Qe,IntersectionInfo:()=>pn,IsBase64DataUrl:()=>gi,IsDocumentAvailable:()=>nt,IsFileURL:()=>mi,IsNavigatorAvailable:()=>rt,IsWindowObjectExist:()=>it,JoystickAxis:()=>rl,KeepAssets:()=>oo,KeyboardEventTypes:()=>nr,KeyboardInfo:()=>or,KeyboardInfoPre:()=>ar,KhronosTextureContainer:()=>j_,KhronosTextureContainer2:()=>Z_,LatheBuilder:()=>ah,Layer:()=>Bm,LayerSceneComponent:()=>wm,LengthBlock:()=>hy,LensFlare:()=>Um,LensFlareSystem:()=>Vm,LensFlareSystemSceneComponent:()=>km,LensFlaresOptimization:()=>wA,LensRenderingPipeline:()=>yx,LerpBlock:()=>ty,Light:()=>no,LightBlock:()=>wv,LightGizmo:()=>n_,LightInformationBlock:()=>bv,LineEdgesRenderer:()=>Gx,LinesBuilder:()=>ju,LinesMesh:()=>Vu,LoadFile:()=>fi,LoadFileError:()=>ai,LoadImage:()=>di,LoadOp:()=>Rp,LoadTextureFromTranscodeResult:()=>rv,LockConstraint:()=>TS,Logger:()=>$,MapMode:()=>qd,MapRangeBlock:()=>BT,MappingBlock:()=>_E,MappingTypes:()=>pE,Material:()=>Kn,MaterialAnisotropicDefines:()=>S_,MaterialClearCoatDefines:()=>y_,MaterialDefines:()=>Di,MaterialDetailMapDefines:()=>hc,MaterialFlags:()=>tc,MaterialGreasedLineDefines:()=>yb,MaterialHelper:()=>jn,MaterialIridescenceDefines:()=>T_,MaterialPluginBase:()=>uc,MaterialPluginEvent:()=>Xn,MaterialPluginManager:()=>rc,MaterialSheenDefines:()=>A_,MaterialSubSurfaceDefines:()=>C_,MathBlock:()=>LT,MathBlockOperations:()=>NT,Matrix:()=>I,MatrixBuilderBlock:()=>Wy,MatrixComposeBlock:()=>mE,MatrixDeterminantBlock:()=>qy,MatrixTransposeBlock:()=>Jy,MaxBlock:()=>ly,MergeGeometryBlock:()=>zT,MergeMeshesOptimization:()=>kA,Mesh:()=>io,MeshAssetTask:()=>gA,MeshAttributeExistsBlock:()=>eb,MeshAttributeExistsBlockTypes:()=>Zy,MeshBlock:()=>bT,MeshBuilder:()=>Nh,MeshDebugMode:()=>Tb,MeshDebugPluginMaterial:()=>Ab,MeshExploder:()=>PA,MeshLODLevel:()=>qn,MeshParticleEmitter:()=>Ya,MeshUVSpaceRenderer:()=>Ub,MeshoptCompression:()=>Ob,MinBlock:()=>cy,MinMaxReducer:()=>Wm,MipmapFilterMode:()=>np,MirrorTexture:()=>s_,ModBlock:()=>Gy,ModelShape:()=>WE,MorphTarget:()=>ng,MorphTargetManager:()=>ag,MorphTargetsBlock:()=>yv,MotionBlurPostProcess:()=>dx,MotorEnabledJoint:()=>Zo,MultiMaterial:()=>Qn,MultiObserver:()=>MA,MultiPointerScaleBehavior:()=>Go,MultiRenderTarget:()=>sv,MultiplyBlock:()=>Ba,NLerpBlock:()=>xy,NativeDataStream:()=>Qh,NativeEngine:()=>Xd,NativePointerInput:()=>Ui,NativeXRFrame:()=>dC,NativeXRLayerRenderTargetTextureProvider:()=>Rc,NativeXRLayerWrapper:()=>Ac,NativeXRRenderTarget:()=>Cc,NegateBlock:()=>dy,Node:()=>We,NodeGeometry:()=>gT,NodeGeometryBlock:()=>dT,NodeGeometryBlockConnectionPointTypes:()=>iT,NodeGeometryBuildState:()=>fT,NodeGeometryConnectionPoint:()=>hT,NodeGeometryConnectionPointCompatibilityStates:()=>rT,NodeGeometryConnectionPointDirection:()=>nT,NodeGeometryContextualSources:()=>uT,NodeMaterial:()=>hs,NodeMaterialBlock:()=>ha,NodeMaterialBlockConnectionPointMode:()=>ma,NodeMaterialBlockConnectionPointTypes:()=>ia,NodeMaterialBlockTargets:()=>ra,NodeMaterialConnectionPoint:()=>ua,NodeMaterialConnectionPointCompatibilityStates:()=>aa,NodeMaterialConnectionPointCustomObject:()=>mv,NodeMaterialConnectionPointDirection:()=>sa,NodeMaterialDefines:()=>us,NodeMaterialModes:()=>wa,NodeMaterialOptimizer:()=>ob,NodeMaterialSystemValues:()=>ga,NodeMaterialTeleportInBlock:()=>Hv,NodeMaterialTeleportOutBlock:()=>Xv,NoiseBlock:()=>GT,NoiseProceduralTexture:()=>hv,NormalBlendBlock:()=>Cy,NormalizeBlock:()=>Jv,NormalizeVectorBlock:()=>YT,NullBlock:()=>PT,NullEngine:()=>Vh,NullEngineOptions:()=>Uh,Observable:()=>u,Observer:()=>c,OcclusionMaterial:()=>xg,Octree:()=>Zc,OctreeBlock:()=>qc,OctreeSceneComponent:()=>Jc,OimoJSPlugin:()=>ug,OnAfterEnteringVRObservableEvent:()=>zc,OneMinusBlock:()=>oy,Orientation:()=>Mr,OutlineRenderer:()=>Qx,PBRAnisotropicConfiguration:()=>x_,PBRBaseMaterial:()=>O_,PBRBaseSimpleMaterial:()=>Ag,PBRClearCoatConfiguration:()=>b_,PBRIridescenceConfiguration:()=>E_,PBRMaterial:()=>D_,PBRMaterialDefines:()=>M_,PBRMetallicRoughnessBlock:()=>ky,PBRMetallicRoughnessMaterial:()=>Rg,PBRSheenConfiguration:()=>R_,PBRSpecularGlossinessMaterial:()=>Cg,PBRSubSurfaceConfiguration:()=>P_,PHI:()=>f,PadNumber:()=>bt,PanoramaToCubeMapTools:()=>eg,Particle:()=>LE,ParticleBlendMultiplyBlock:()=>Ia,ParticleHelper:()=>kE,ParticleRampGradientBlock:()=>Pa,ParticleSystem:()=>BE,ParticleSystemSet:()=>VE,ParticleTextureBlock:()=>Ca,ParticlesOptimization:()=>UA,PassCubePostProcess:()=>Pl,PassPostProcess:()=>Cl,Path2:()=>wr,Path3D:()=>Br,PathCursor:()=>tn,PerfCollectionStrategy:()=>TR,PerfCounter:()=>vr,PerformanceConfigurator:()=>E,PerformanceMonitor:()=>Mn,PerformanceViewerCollector:()=>yR,PerturbNormalBlock:()=>Sv,PhotoDome:()=>p_,Physics6DoFConstraint:()=>mS,Physics6DoFLimit:()=>_S,PhysicsAggregate:()=>xS,PhysicsBody:()=>nS,PhysicsConstraint:()=>fS,PhysicsConstraintAxis:()=>ZE,PhysicsConstraintAxisLimitMode:()=>qE,PhysicsConstraintMotorType:()=>eS,PhysicsConstraintType:()=>JE,PhysicsEngine:()=>lg,PhysicsEngineV2:()=>rS,PhysicsEventType:()=>tS,PhysicsHelper:()=>LS,PhysicsImpostor:()=>ta,PhysicsJoint:()=>Qo,PhysicsMaterialCombineMode:()=>oS,PhysicsMotionType:()=>iS,PhysicsRadialExplosionEventOptions:()=>kS,PhysicsRadialImpulseFalloff:()=>DS,PhysicsRaycastResult:()=>sg,PhysicsShape:()=>aS,PhysicsShapeBox:()=>uS,PhysicsShapeCapsule:()=>lS,PhysicsShapeContainer:()=>pS,PhysicsShapeConvexHull:()=>hS,PhysicsShapeCylinder:()=>cS,PhysicsShapeMesh:()=>dS,PhysicsShapeSphere:()=>sS,PhysicsShapeType:()=>$E,PhysicsUpdraftEventOptions:()=>GS,PhysicsUpdraftMode:()=>NS,PhysicsViewer:()=>Fh,PhysicsVortexEventOptions:()=>zS,PickingInfo:()=>Yi,PipelineErrorReason:()=>dp,PivotTools:()=>Lo,Plane:()=>yr,PlaneBlock:()=>yT,PlaneBuilder:()=>Uo,PlaneDragGizmo:()=>Qf,PlaneRotationGizmo:()=>Yf,PlayAnimationAction:()=>ne,PlaySoundAction:()=>pe,PointColor:()=>GE,PointLight:()=>Jm,PointParticleEmitter:()=>Wa,PointerDragBehavior:()=>ko,PointerEventTypes:()=>er,PointerInfo:()=>rr,PointerInfoBase:()=>tr,PointerInfoPre:()=>ir,PointerInput:()=>Bi,PointsCloudSystem:()=>QE,PointsGroup:()=>KE,Polar:()=>Rb,Polygon:()=>Qu,PolygonBuilder:()=>eh,PolygonMeshBuilder:()=>qu,PolyhedronBuilder:()=>hh,PolyhedronData:()=>Sh,PositionGizmo:()=>qf,PositionNormalTextureVertex:()=>Ta,PositionNormalVertex:()=>ba,PostProcess:()=>Na,PostProcessManager:()=>Ki,PostProcessRenderEffect:()=>HS,PostProcessRenderPipeline:()=>_x,PostProcessRenderPipelineManager:()=>mx,PostProcessRenderPipelineManagerSceneComponent:()=>gx,PostProcessesOptimization:()=>LA,PosterizeBlock:()=>by,PowBlock:()=>py,PowerEase:()=>jr,PowerPreference:()=>jd,PrePassOutputBlock:()=>Fv,PrePassRenderer:()=>Wx,PrePassRendererSceneComponent:()=>Hx,PrePassTextureBlock:()=>Wv,PrecisionDate:()=>lt,PredicateCondition:()=>Z,PressureObserverWrapper:()=>pR,PrimitiveTopology:()=>fp,PrismaticConstraint:()=>ES,ProceduralTexture:()=>ss,ProceduralTextureSceneComponent:()=>os,PropertyTypeForEdition:()=>pa,PushMaterial:()=>oa,QuadraticEase:()=>Yr,QuadraticErrorSimplification:()=>Yb,QuarticEase:()=>Kr,Quaternion:()=>P,QueryType:()=>Pp,QuinticEase:()=>Qr,RGBDTextureTools:()=>cd,RandomBlock:()=>kT,RandomBlockLocks:()=>UT,RandomGUID:()=>xi,RandomNumberBlock:()=>fy,RawCubeTexture:()=>dv,RawTexture:()=>Ro,RawTexture2DArray:()=>og,RawTexture3D:()=>pv,Ray:()=>Fo,RayHelper:()=>Lh,ReadFile:()=>pi,ReadFileError:()=>li,RecastJSCrowd:()=>AE,RecastJSPlugin:()=>xE,ReciprocalBlock:()=>gy,ReflectBlock:()=>Iy,ReflectionBlock:()=>Fy,ReflectionProbe:()=>dg,ReflectionTextureBlock:()=>kv,Reflector:()=>dR,RefractBlock:()=>My,RefractionBlock:()=>By,RefractionPostProcess:()=>px,RefractionTexture:()=>fv,RegisterClass:()=>b,RegisterMaterialPlugin:()=>sc,RegisterNativeTypeAsync:()=>zd,RemapBlock:()=>La,RenderPassTimestampLocation:()=>Ap,RenderTargetTexture:()=>ns,RenderTargetWrapper:()=>Oa,RenderTargetsOptimization:()=>VA,RenderingGroup:()=>Qi,RenderingGroupInfo:()=>qi,RenderingManager:()=>Zi,ReplaceColorBlock:()=>vy,RequestFile:()=>_i,RequestFileError:()=>si,RetryStrategy:()=>ut,RibbonBuilder:()=>xu,RichType:()=>fC,RichTypeAny:()=>_C,RichTypeBoolean:()=>vC,RichTypeColor3:()=>SC,RichTypeColor4:()=>xC,RichTypeMatrix:()=>EC,RichTypeNumber:()=>gC,RichTypeQuaternion:()=>AC,RichTypeString:()=>mC,RichTypeVector2:()=>yC,RichTypeVector3:()=>bC,RichTypeVector4:()=>TC,RollingAverage:()=>On,Rotate2dBlock:()=>Py,RotationGizmo:()=>Kf,RotationXBlock:()=>JT,RotationYBlock:()=>$T,RotationZBlock:()=>eE,RuntimeAnimation:()=>tt,RuntimeError:()=>pt,SSAO2RenderingPipeline:()=>Tx,SSAORenderingPipeline:()=>Ex,SSRRenderingPipeline:()=>Ix,SamplerBindingType:()=>lp,Scalar:()=>h,ScaleBlock:()=>Yv,ScaleGizmo:()=>Zf,ScalingBlock:()=>tE,Scene:()=>Ar,SceneComponentConstants:()=>Ji,SceneDepthBlock:()=>Gv,SceneInstrumentation:()=>Mm,SceneLoader:()=>na,SceneLoaderAnimationGroupLoadingMode:()=>ea,SceneLoaderFlags:()=>Cn,SceneOptimization:()=>OA,SceneOptimizer:()=>zA,SceneOptimizerOptions:()=>GA,ScenePerformancePriority:()=>sr,SceneRecorder:()=>aR,SceneSerializer:()=>jA,ScreenSizeBlock:()=>Pv,ScreenSpaceBlock:()=>Iv,ScreenSpaceCurvaturePostProcess:()=>Nx,ScreenSpaceReflectionPostProcess:()=>xx,ScreenshotTools:()=>iR,SerializationHelper:()=>Ve,SetColorsBlock:()=>DT,SetCorsBehavior:()=>hi,SetMaterialIDBlock:()=>QT,SetNormalsBlock:()=>MT,SetParentAction:()=>ce,SetPositionsBlock:()=>IT,SetStateAction:()=>te,SetTangentsBlock:()=>FT,SetUVsBlock:()=>OT,SetValueAction:()=>ie,ShaderCodeInliner:()=>Od,ShaderLanguage:()=>at,ShaderMaterial:()=>Uu,ShaderStage:()=>ap,ShaderStore:()=>kt,ShadowDepthWrapper:()=>sb,ShadowGenerator:()=>Gm,ShadowGeneratorSceneComponent:()=>Zm,ShadowLight:()=>$f,ShadowMapBlock:()=>Nv,ShadowsOptimization:()=>FA,ShapeBuilder:()=>nh,SharpenPostProcess:()=>fx,SheenBlock:()=>Dy,SimplexPerlin3DBlock:()=>Ry,SimplicationQueueSceneComponent:()=>Zb,SimplificationQueue:()=>zb,SimplificationSettings:()=>Gb,SimplificationType:()=>Vb,SineEase:()=>qr,SixDofDragBehavior:()=>Wo,Size:()=>He,Skeleton:()=>Is,SkeletonViewer:()=>wh,SliderConstraint:()=>bS,SmartArray:()=>Ii,SmartArrayNoDuplicate:()=>Mi,SmoothStepBlock:()=>my,SolidParticle:()=>zE,SolidParticleSystem:()=>jE,SolidParticleVertex:()=>XE,Sound:()=>uo,SoundTrack:()=>ho,SourceTextureFormat:()=>W_,Space:()=>xr,SphereBlock:()=>ET,SphereBuilder:()=>vu,SphereDirectedParticleEmitter:()=>Xa,SphereParticleEmitter:()=>Ha,Spherical:()=>Cb,SphericalHarmonics:()=>ed,SphericalPolynomial:()=>td,SpotLight:()=>r_,SpringConstraint:()=>SS,Sprite:()=>sA,SpriteManager:()=>uA,SpriteMap:()=>dA,SpritePackedManager:()=>pA,SpriteSceneComponent:()=>lA,Stage:()=>$i,StandardMaterial:()=>_c,StandardMaterialDefines:()=>fc,StandardRenderingPipeline:()=>Ax,StartsWith:()=>_t,StateCondition:()=>J,StencilOperation:()=>bp,StencilState:()=>Wt,StencilStateComposer:()=>ti,StepBlock:()=>ny,StereoscopicArcRotateCamera:()=>Ul,StereoscopicFreeCamera:()=>Vl,StereoscopicGamepadCamera:()=>kl,StereoscopicInterlacePostProcess:()=>wl,StereoscopicInterlacePostProcessI:()=>Ll,StereoscopicScreenUniversalCamera:()=>zl,StereoscopicUniversalCamera:()=>Gl,StickValues:()=>ws,StopAnimationAction:()=>oe,StopSoundAction:()=>fe,StorageBuffer:()=>Ms,StorageTextureAccess:()=>up,StoreOp:()=>Cp,StringDictionary:()=>Oi,StringTools:()=>Tt,SubEmitter:()=>wE,SubEmitterType:()=>ME,SubMesh:()=>xn,SubSurfaceBlock:()=>Uy,SubSurfaceSceneComponent:()=>Yx,SubtractBlock:()=>ry,SurfaceMagnetismBehavior:()=>Ho,SwitchBooleanAction:()=>ee,SwitchInput:()=>zi,TBNBlock:()=>Ev,TGATools:()=>Xg,Tags:()=>me,TargetCamera:()=>sl,TargetedAnimation:()=>$r,TeleportInBlock:()=>gE,TeleportOutBlock:()=>vE,TestBase64DataUrl:()=>vi,TextFileAssetTask:()=>yA,Texture:()=>Eo,TextureAspect:()=>ep,TextureAssetTask:()=>EA,TextureBlock:()=>Uv,TextureDimension:()=>Zd,TextureFormat:()=>tp,TextureOptimization:()=>DA,TexturePacker:()=>cv,TexturePackerFrame:()=>lv,TextureSampleType:()=>cp,TextureSampler:()=>Xt,TextureTools:()=>ld,TextureUsage:()=>Jd,TextureViewDimension:()=>$d,ThinEngine:()=>ri,ThinRenderTargetTexture:()=>_v,ThinTexture:()=>mo,TiledBoxBuilder:()=>Nu,TiledPlaneBuilder:()=>Mu,TimerState:()=>mm,TmpColors:()=>V,TmpVectors:()=>O,ToGammaSpace:()=>d,ToHalfFloat:()=>nd,ToLinearSpace:()=>p,TonemapPostProcess:()=>Ox,TonemappingOperator:()=>Mx,Tools:()=>Ri,TorusBlock:()=>xT,TorusBuilder:()=>Vc,TorusKnotBuilder:()=>wu,TouchCamera:()=>cl,TrailMesh:()=>kb,Trajectory:()=>sR,TrajectoryClassifier:()=>hR,TranscodeAsync:()=>tv,TranscodeTarget:()=>H_,TransformBlock:()=>da,TransformNode:()=>Ln,TranslationBlock:()=>rE,TriPlanarBlock:()=>Ky,TrigonometryBlock:()=>ls,TrigonometryBlockOperations:()=>as,TubeBuilder:()=>lh,TwirlBlock:()=>Mv,UniformBuffer:()=>Hi,UniversalCamera:()=>Al,UnregisterAllMaterialPlugins:()=>cc,UnregisterMaterialPlugin:()=>lc,UploadContent:()=>Hg,UploadEnvLevelsAsync:()=>bd,UploadEnvSpherical:()=>Sd,UploadLevelsAsync:()=>Ed,UtilityLayerRenderer:()=>ou,VRCameraMetrics:()=>Hl,VRDeviceOrientationArcRotateCamera:()=>Zl,VRDeviceOrientationFreeCamera:()=>Jl,VRDeviceOrientationGamepadCamera:()=>$l,VRDistortionCorrectionPostProcess:()=>Xl,VRExperienceHelper:()=>Wc,VRMultiviewToSingleviewPostProcess:()=>Ql,ValidatedNativeDataStream:()=>Dp,ValueCondition:()=>q,Vector2:()=>A,Vector3:()=>R,Vector4:()=>C,VectorConverterBlock:()=>jT,VectorMergerBlock:()=>Fa,VectorSplitterBlock:()=>ey,VertexAnimationBaker:()=>Co,VertexBuffer:()=>ji,VertexData:()=>Rn,VertexDataMaterialInfo:()=>An,VertexFormat:()=>Ep,VertexOutputBlock:()=>fa,VertexStepMode:()=>Sp,VideoDome:()=>Pm,VideoRecorder:()=>YA,VideoTexture:()=>Cm,ViewDirectionBlock:()=>ay,Viewport:()=>hn,VirtualJoystick:()=>ol,VirtualJoysticksCamera:()=>Wl,VolumetricLightScatteringPostProcess:()=>Dx,VoronoiNoiseBlock:()=>jy,WaveBlock:()=>Ty,WaveBlockKind:()=>yy,WebGL2ParticleSystem:()=>PE,WebGL2ShaderProcessor:()=>Qt,WebGLDataBuffer:()=>Zt,WebGLHardwareTexture:()=>$t,WebGLPipelineContext:()=>Jt,WebGPUCacheBindGroups:()=>mf,WebGPUCacheRenderPipeline:()=>sf,WebGPUCacheRenderPipelineTree:()=>cf,WebGPUCacheSampler:()=>rf,WebGPUDataBuffer:()=>qp,WebGPUDrawContext:()=>ff,WebGPUEngine:()=>wf,WebGPUTintWASM:()=>Mf,WebRequest:()=>Xe,WebXRAbstractFeature:()=>Ko,WebXRAbstractMotionController:()=>rm,WebXRAnchorSystem:()=>AR,WebXRBackgroundRemover:()=>PR,WebXRCamera:()=>em,WebXRCompositionLayerWrapper:()=>jR,WebXRControllerComponent:()=>im,WebXRControllerMovement:()=>UR,WebXRControllerPhysics:()=>MR,WebXRControllerPointerSelection:()=>fm,WebXRDefaultExperience:()=>xm,WebXRDefaultExperienceOptions:()=>Sm,WebXRDepthSensing:()=>$R,WebXRDomOverlay:()=>BR,WebXREnterExitUI:()=>ym,WebXREnterExitUIButton:()=>gm,WebXREnterExitUIOptions:()=>vm,WebXRExperienceHelper:()=>tm,WebXREyeTracking:()=>kR,WebXRFeatureName:()=>jo,WebXRFeaturePointSystem:()=>DR,WebXRFeaturesManager:()=>Yo,WebXRGenericHandController:()=>rC,WebXRGenericTriggerMotionController:()=>nm,WebXRHTCViveMotionController:()=>cC,WebXRHand:()=>Ss,WebXRHandJoint:()=>ms,WebXRHandTracking:()=>xs,WebXRHitTest:()=>OR,WebXRHitTestLegacy:()=>SR,WebXRImageTracking:()=>wR,WebXRInput:()=>pm,WebXRInputSource:()=>dm,WebXRLayers:()=>JR,WebXRLightEstimation:()=>VR,WebXRManagedOutputCanvas:()=>xc,WebXRManagedOutputCanvasOptions:()=>Sc,WebXRMeshDetector:()=>LR,WebXRMicrosoftMixedRealityController:()=>oC,WebXRMotionControllerManager:()=>lm,WebXRMotionControllerTeleportation:()=>Em,WebXRNearControllerMode:()=>um,WebXRNearInteraction:()=>_m,WebXROculusTouchMotionController:()=>sC,WebXRPlaneDetector:()=>CR,WebXRProfiledMotionController:()=>am,WebXRProjectionLayerWrapper:()=>KR,WebXRSessionManager:()=>Pc,WebXRSpaceWarp:()=>iC,WebXRSpaceWarpRenderTargetTextureProvider:()=>tC,WebXRState:()=>mc,WebXRTrackingState:()=>gc,WebXRWalkingLocomotion:()=>XR,WeightedSound:()=>fo,WorkerPool:()=>Y_,WorleyNoise3DBlock:()=>Ay,XRSpaceWarpRenderTarget:()=>eC,Xbox360Button:()=>_l,Xbox360Dpad:()=>ml,Xbox360Pad:()=>Tl,XboxInput:()=>Gi,_BabylonLoaderRegistered:()=>pg,_BasisTextureLoader:()=>av,_CreationDataStorage:()=>Zn,_DDSTextureLoader:()=>G_,_ENVTextureLoader:()=>z_,_HDRTextureLoader:()=>Yg,_IAnimationState:()=>je,_InstancesBatch:()=>$n,_KTXTextureLoader:()=>$_,_MeshCollisionData:()=>wn,_OcclusionDataStorage:()=>Gh,_PrimaryIsoTriangle:()=>Eh,_TGATextureLoader:()=>jg,_TimeToken:()=>kh,_UpdateRGBDAsync:()=>xd,_forceSceneHelpersToBundle:()=>Am,_forceTransformFeedbackToBundle:()=>zh,_injectLTSFileTools:()=>Ei,addClipPlaneUniforms:()=>kn,allocateAndCopyTypedBuffer:()=>Dn,bindClipPlane:()=>Wn,captureEquirectangularFromScene:()=>ER,className:()=>Ci,createDetailMapPlugin:()=>mb,createPBRAnisotropicPlugin:()=>ub,createPBRBRDFPlugin:()=>hb,createPBRClearCoatPlugin:()=>db,createPBRIridescencePlugin:()=>pb,createPBRSheenPlugin:()=>fb,createPBRSubSurfacePlugin:()=>_b,createYieldingScheduler:()=>on,editableInPropertyPage:()=>_a,expandToProperty:()=>xe,extractMinAndMax:()=>Sn,extractMinAndMaxIndexed:()=>En,getRichTypeFromValue:()=>RC,inlineScheduler:()=>nn,makeAsyncFunction:()=>un,makeSyncFunction:()=>cn,nativeOverride:()=>ke,normalizeEnvInfo:()=>md,prepareDefinesForClipPlanes:()=>zn,prepareStringDefinesForClipPlanes:()=>Gn,runCoroutine:()=>an,runCoroutineAsync:()=>ln,runCoroutineSync:()=>sn,serialize:()=>Ae,serializeAsCameraReference:()=>Be,serializeAsColor3:()=>Ce,serializeAsColor4:()=>Ne,serializeAsColorCurves:()=>De,serializeAsFresnelParameters:()=>Pe,serializeAsImageProcessingConfiguration:()=>Fe,serializeAsMatrix:()=>we,serializeAsMeshReference:()=>Oe,serializeAsQuaternion:()=>Le,serializeAsTexture:()=>Re,serializeAsVector2:()=>Ie,serializeAsVector3:()=>Me,setAndStartTimer:()=>bm,setStereoscopicAnaglyphRigMode:()=>Ml,setStereoscopicRigMode:()=>Bl,setVRRigMode:()=>ql});var n={};e.r(n),e.d(n,{AbstractActionManager:()=>s,AbstractAssetTask:()=>fA,AbstractMesh:()=>Vn,AbstractScene:()=>o,AcquireNativeObjectAsync:()=>Gd,Action:()=>k,ActionEvent:()=>G,ActionManager:()=>de,AddBlock:()=>jv,AddressMode:()=>ip,AdvancedTimer:()=>Tm,AlignBlock:()=>iE,AlphaState:()=>Ht,AmmoJSPlugin:()=>hg,AnaglyphArcRotateCamera:()=>Ol,AnaglyphFreeCamera:()=>Dl,AnaglyphGamepadCamera:()=>Nl,AnaglyphPostProcess:()=>Il,AnaglyphUniversalCamera:()=>Fl,Analyser:()=>lo,AndOrNotEvaluator:()=>_e,Angle:()=>Fr,Animatable:()=>Ir,AnimatedInputBlockTypes:()=>ya,Animation:()=>Ke,AnimationAssetTask:()=>vA,AnimationEvent:()=>Jr,AnimationGroup:()=>en,AnimationGroupMask:()=>rn,AnimationGroupMaskMode:()=>Dr,AnimationKeyInterpolation:()=>Ue,AnimationPropertiesOverride:()=>Or,AnimationRange:()=>Ge,AnisotropyBlock:()=>Ny,ApplyPostProcess:()=>rd,Arc2:()=>Lr,ArcFollowCamera:()=>vl,ArcRotateCamera:()=>ul,ArcRotateCameraGamepadInput:()=>Vs,ArcRotateCameraInputsManager:()=>Ws,ArcRotateCameraKeyboardMoveInput:()=>ks,ArcRotateCameraMouseWheelInput:()=>Gs,ArcRotateCameraPointersInput:()=>zs,ArcRotateCameraVRDeviceOrientationInput:()=>Hs,ArcTan2Block:()=>_y,AssetContainer:()=>so,AssetTaskState:()=>hA,AssetsManager:()=>RA,AssetsProgressEvent:()=>_A,AsyncLoop:()=>Pi,AttachToBoxBehavior:()=>Do,AudioEngine:()=>co,AudioSceneComponent:()=>po,AutoLayoutMode:()=>pp,AutoReleaseWorkerPool:()=>K_,AutoRotationBehavior:()=>Po,AxesViewer:()=>cu,Axis:()=>Cr,AxisDragGizmo:()=>lu,AxisScaleGizmo:()=>Xf,BRDFTextureTools:()=>m_,BabylonFileLoaderConfiguration:()=>fg,BackEase:()=>Gr,BackgroundMaterial:()=>u_,BakedVertexAnimationManager:()=>_o,BallAndSocketConstraint:()=>gS,BaseCameraMouseWheelInput:()=>Ds,BaseCameraPointersInput:()=>Ns,BaseError:()=>ht,BaseParticleSystem:()=>Ka,BaseSixDofDragBehavior:()=>zo,BaseTexture:()=>go,BasisTools:()=>nv,BasisToolsOptions:()=>qg,BasisTranscodeConfiguration:()=>Qg,BezierCurve:()=>Nr,BezierCurveEase:()=>Zr,BiPlanarBlock:()=>Qy,BinaryFileAssetTask:()=>bA,BlackAndWhitePostProcess:()=>WS,BlendFactor:()=>vp,BlendOperation:()=>yp,BloomEffect:()=>YS,BloomMergePostProcess:()=>jS,BlurPostProcess:()=>a_,Bone:()=>Pr,BoneAxesViewer:()=>uu,BoneIKController:()=>Cs,BoneLookController:()=>Ps,BonesBlock:()=>gv,BooleanGeometryBlock:()=>SE,BooleanGeometryOperations:()=>TE,BounceEase:()=>zr,BouncingBehavior:()=>Io,BoundingBlock:()=>EE,BoundingBox:()=>fn,BoundingBoxGizmo:()=>jf,BoundingBoxRenderer:()=>Fx,BoundingInfo:()=>bn,BoundingSphere:()=>_n,BoxBlock:()=>mT,BoxBuilder:()=>_u,BoxParticleEmitter:()=>Ua,Buffer:()=>Xi,BufferBindingType:()=>sp,BufferMapState:()=>Kd,BufferUsage:()=>Qd,CSG:()=>Bb,Camera:()=>dn,CameraGizmo:()=>o_,CameraInputTypes:()=>Fs,CameraInputsManager:()=>Ls,CannonJSPlugin:()=>cg,CanvasAlphaMode:()=>Ip,CapsuleBlock:()=>RT,CapsuleBuilder:()=>Tu,CascadedShadowGenerator:()=>qm,ChromaticAberrationPostProcess:()=>KS,CircleEase:()=>kr,CircleOfConfusionPostProcess:()=>QS,ClampBlock:()=>Kv,ClearCoatBlock:()=>Ly,ClipPlanesBlock:()=>zv,ClipboardEventTypes:()=>Wf,ClipboardInfo:()=>Hf,CloudBlock:()=>Xy,CloudPoint:()=>YE,Collider:()=>Xc,Color3:()=>B,Color3Gradient:()=>DE,Color4:()=>U,ColorCorrectionPostProcess:()=>qS,ColorCurves:()=>Ni,ColorGradient:()=>OE,ColorGradingTexture:()=>Pg,ColorMergerBlock:()=>$v,ColorSplitterBlock:()=>Qa,ColorWrite:()=>gp,CombineAction:()=>se,CompareFunction:()=>op,CompatibilityOptions:()=>Pn,CompilationMessageType:()=>hp,CompleteGreasedLineColorTable:()=>cT,CompleteGreasedLineWidthTable:()=>lT,ComputeBindingType:()=>Yc,ComputeEffect:()=>Kc,ComputeNormalsBlock:()=>XT,ComputePassTimestampLocation:()=>xp,ComputeShader:()=>Qc,ComputeShaderParticleSystem:()=>IE,Condition:()=>Q,ConditionBlock:()=>VT,ConditionBlockTests:()=>wT,ConditionalBlock:()=>Hy,ConditionalBlockConditions:()=>zy,ConeParticleEmitter:()=>Va,Constants:()=>a,ContainerAssetTask:()=>mA,ConversionMode:()=>$x,ConvolutionPostProcess:()=>ZS,Coordinate:()=>Rr,CopyTextureToTexture:()=>iA,CopyTools:()=>To,CreateBox:()=>fu,CreateBoxVertexData:()=>du,CreateCapsule:()=>bu,CreateCapsuleVertexData:()=>yu,CreateCylinder:()=>eu,CreateCylinderVertexData:()=>$c,CreateDashedLines:()=>Xu,CreateDashedLinesVertexData:()=>zu,CreateDecal:()=>yh,CreateDisc:()=>Ru,CreateDiscVertexData:()=>Au,CreateEnvTextureAsync:()=>gd,CreateGeodesic:()=>Ah,CreateGoldberg:()=>Ph,CreateGoldbergVertexData:()=>Ch,CreateGreasedLine:()=>sT,CreateGreasedLineMaterial:()=>aT,CreateGround:()=>Nc,CreateGroundFromHeightMap:()=>Lc,CreateGroundFromHeightMapVertexData:()=>Dc,CreateGroundVertexData:()=>Mc,CreateHemisphere:()=>t_,CreateIcoSphere:()=>ps,CreateIcoSphereVertexData:()=>ds,CreateImageDataArrayBufferViews:()=>yd,CreateLathe:()=>oh,CreateLineSystem:()=>Wu,CreateLineSystemVertexData:()=>Gu,CreateLines:()=>Hu,CreatePlane:()=>Bo,CreatePlaneVertexData:()=>wo,CreatePolygon:()=>Ju,CreatePolygonVertexData:()=>Zu,CreatePolyhedron:()=>uh,CreatePolyhedronVertexData:()=>ch,CreateResizedCopy:()=>id,CreateRibbon:()=>Su,CreateRibbonVertexData:()=>Eu,CreateScreenshot:()=>QA,CreateScreenshotAsync:()=>qA,CreateScreenshotUsingRenderTarget:()=>JA,CreateScreenshotUsingRenderTargetAsync:()=>$A,CreateScreenshotWithResizeAsync:()=>ZA,CreateSegmentedBoxVertexData:()=>pu,CreateSphere:()=>gu,CreateSphereVertexData:()=>mu,CreateText:()=>Dh,CreateTextShapePaths:()=>Oh,CreateTiledBox:()=>Du,CreateTiledBoxVertexData:()=>Ou,CreateTiledGround:()=>Fc,CreateTiledGroundVertexData:()=>Oc,CreateTiledPlane:()=>Iu,CreateTiledPlaneVertexData:()=>Pu,CreateTorus:()=>Uc,CreateTorusKnot:()=>Lu,CreateTorusKnotVertexData:()=>Fu,CreateTorusVertexData:()=>Bc,CreateTube:()=>sh,CrossBlock:()=>Qv,CubeMapToSphericalPolynomialTools:()=>hd,CubeTexture:()=>l_,CubeTextureAssetTask:()=>SA,CubicEase:()=>Wr,CullMode:()=>mp,CurrentScreenBlock:()=>Ra,Curve3:()=>Ur,CurveBlock:()=>tb,CurveBlockTypes:()=>$y,CustomBlock:()=>qv,CustomOptimization:()=>BA,CustomParticleEmitter:()=>ja,CustomProceduralTexture:()=>uv,CylinderBlock:()=>AT,CylinderBuilder:()=>tu,CylinderDirectedParticleEmitter:()=>Ga,CylinderParticleEmitter:()=>ka,DDSTools:()=>k_,DataBuffer:()=>qt,DataReader:()=>nR,DataStorage:()=>oR,Database:()=>RE,Debug:()=>ZO,DebugBlock:()=>dE,DebugLayer:()=>hu,DebugLayerTab:()=>au,DecalBuilder:()=>bh,DecalMapConfiguration:()=>cb,DecalMapDefines:()=>lb,Decode:()=>mt,DecodeBase64ToBinary:()=>yt,DecodeBase64ToString:()=>vt,DecodeBase64UrlToBinary:()=>yi,DecodeBase64UrlToString:()=>Ti,DeepCopier:()=>he,DefaultCollisionCoordinator:()=>jc,DefaultKTX2DecoderOptions:()=>q_,DefaultLoadingScreen:()=>$m,DefaultRenderingPipeline:()=>vx,Deferred:()=>CA,DepthCullingState:()=>zt,DepthOfFieldBlurPostProcess:()=>JS,DepthOfFieldEffect:()=>tx,DepthOfFieldEffectBlurLevel:()=>$S,DepthOfFieldMergePostProcess:()=>ex,DepthPeelingRenderer:()=>Bx,DepthPeelingSceneComponent:()=>Ux,DepthReducer:()=>Hm,DepthRenderer:()=>zm,DepthRendererSceneComponent:()=>Lx,DepthSortedParticle:()=>HE,DerivativeBlock:()=>Rv,DesaturateBlock:()=>Oy,DetailMapConfiguration:()=>dc,DeviceInputEventType:()=>Wi,DeviceLostReason:()=>Mp,DeviceOrientationCamera:()=>hl,DeviceSource:()=>pr,DeviceSourceManager:()=>_r,DeviceType:()=>wi,DirectionalLight:()=>e_,DirectionalLightFrustumViewer:()=>Bh,DiscBlock:()=>CT,DiscBuilder:()=>Cu,DiscardBlock:()=>xv,DisplayPassPostProcess:()=>ix,DistanceBlock:()=>uy,DistanceConstraint:()=>vS,DistanceJoint:()=>qo,DivideBlock:()=>iy,DoNothingAction:()=>ae,DomManagement:()=>st,DotBlock:()=>Zv,DracoCompression:()=>Mb,DrawWrapper:()=>ei,DualSenseInput:()=>ki,DualShockButton:()=>yl,DualShockDpad:()=>bl,DualShockInput:()=>Vi,DualShockPad:()=>El,DumpTools:()=>rs,DynamicFloat32Array:()=>fR,DynamicTexture:()=>vc,EasingFunction:()=>Vr,EdgesRenderer:()=>kx,Effect:()=>Gt,EffectFallbacks:()=>Ma,EffectLayer:()=>Om,EffectLayerSceneComponent:()=>Dm,EffectRenderer:()=>Za,EffectWrapper:()=>Ja,ElasticEase:()=>Hr,ElbowBlock:()=>Yy,EncodeArrayBufferToBase64:()=>gt,EndsWith:()=>ft,Engine:()=>Nn,EngineFactory:()=>zf,EngineFormat:()=>X_,EngineInstrumentation:()=>Im,EngineStore:()=>S,EngineView:()=>Wh,EnvironmentHelper:()=>h_,EnvironmentTextureTools:()=>Ad,Epsilon:()=>_,EquiRectangularCubeTexture:()=>Ig,EquiRectangularCubeTextureAssetTask:()=>AA,ErrorCodes:()=>dt,ErrorFilter:()=>Op,EventConstants:()=>lr,EventState:()=>l,ExecuteCodeAction:()=>le,ExponentialEase:()=>Xr,ExternalTexture:()=>df,ExtractHighlightsPostProcess:()=>XS,ExtrudePolygon:()=>$u,ExtrudeShape:()=>th,ExtrudeShapeCustom:()=>ih,FactorGradient:()=>NE,FadeInOutBehavior:()=>No,FeatureName:()=>Yd,FileTools:()=>bi,FileToolsOptions:()=>ci,FilesInput:()=>IA,FilesInputStore:()=>ct,FilterMode:()=>rp,FilterPostProcess:()=>rx,FlowGraph:()=>VC,FlowGraphACosNumberBlock:()=>UI,FlowGraphASinNumberBlock:()=>wI,FlowGraphATan2NumberBlock:()=>jI,FlowGraphATanNumberBlock:()=>kI,FlowGraphAbsNumberBlock:()=>uI,FlowGraphAddMatrixAndNumberBlock:()=>TO,FlowGraphAddMatrixBlock:()=>yO,FlowGraphAddNumberBlock:()=>jP,FlowGraphAddVector2Block:()=>dM,FlowGraphAddVector3Block:()=>IM,FlowGraphAddVector4Block:()=>tO,FlowGraphBitwiseAndBlock:()=>IP,FlowGraphBitwiseLeftShiftBlock:()=>NP,FlowGraphBitwiseNotBlock:()=>DP,FlowGraphBitwiseOrBlock:()=>MP,FlowGraphBitwiseRightShiftBlock:()=>FP,FlowGraphBitwiseXorBlock:()=>OP,FlowGraphBlock:()=>PC,FlowGraphBranchBlock:()=>KC,FlowGraphCeilNumberBlock:()=>mI,FlowGraphClampMatrixBlock:()=>LO,FlowGraphComposeMatrixBlock:()=>VO,FlowGraphConditionalDataBlock:()=>hP,FlowGraphConstantBlock:()=>fP,FlowGraphContext:()=>BC,FlowGraphCoordinateTransformBlock:()=>pP,FlowGraphCoordinator:()=>zC,FlowGraphCosNumberBlock:()=>DI,FlowGraphCountLeadingZerosBlock:()=>LP,FlowGraphCountTrailingZerosBlock:()=>wP,FlowGraphCounterBlock:()=>iP,FlowGraphCreateVector2Block:()=>AM,FlowGraphCreateVector3Block:()=>YM,FlowGraphCreateVector4Block:()=>_O,FlowGraphCrossVector3Block:()=>XM,FlowGraphDebounceBlock:()=>nP,FlowGraphDecomposeMatrixBlock:()=>BO,FlowGraphDivideMatrixAndNumberBlock:()=>OO,FlowGraphDivideMatrixBlock:()=>IO,FlowGraphDivideNumberBlock:()=>JP,FlowGraphDivideVector2Block:()=>vM,FlowGraphDivideVector3Block:()=>LM,FlowGraphDivideVector4Block:()=>sO,FlowGraphDoNBlock:()=>QC,FlowGraphDotVector3Block:()=>WM,FlowGraphENumberBlock:()=>zI,FlowGraphEqualsNumberBlock:()=>eM,FlowGraphEventBlock:()=>DC,FlowGraphEventCoordinator:()=>kC,FlowGraphExecutionBlock:()=>MC,FlowGraphExpNumberBlock:()=>EI,FlowGraphFlipFlopBlock:()=>oP,FlowGraphFloorNumberBlock:()=>fI,FlowGraphForLoopBlock:()=>qC,FlowGraphGetTransformationMatrixBlock:()=>WO,FlowGraphGetVariableBlock:()=>dP,FlowGraphGreaterThanNumberBlock:()=>iM,FlowGraphGreaterThanOrEqualsNumberBlock:()=>nM,FlowGraphIsInfinityNumberBlock:()=>aI,FlowGraphIsNaNNumberBlock:()=>nI,FlowGraphLengthVector2Block:()=>EM,FlowGraphLengthVector3Block:()=>VM,FlowGraphLengthVector4Block:()=>hO,FlowGraphLessThanNumberBlock:()=>aM,FlowGraphLessThanOrEqualsNumberBlock:()=>lM,FlowGraphLnNumberBlock:()=>PI,FlowGraphLog10NumberBlock:()=>xI,FlowGraphLogBlock:()=>HC,FlowGraphLogNumberBlock:()=>RI,FlowGraphLogicAndBlock:()=>GP,FlowGraphLogicNotBlock:()=>WP,FlowGraphLogicOrBlock:()=>zP,FlowGraphMaxNumberBlock:()=>JI,FlowGraphMeshPickEventBlock:()=>HO,FlowGraphMinNumberBlock:()=>qI,FlowGraphMixNumberBlock:()=>uM,FlowGraphModNumberBlock:()=>eI,FlowGraphMultiGateBlock:()=>$C,FlowGraphMultiplyMatrixBlock:()=>CO,FlowGraphMultiplyNumberBlock:()=>qP,FlowGraphMultiplyVector2Block:()=>mM,FlowGraphMultiplyVector3Block:()=>NM,FlowGraphMultiplyVector4Block:()=>oO,FlowGraphNegateNumberBlock:()=>dI,FlowGraphNormalizeVector2Block:()=>xM,FlowGraphNormalizeVector3Block:()=>GM,FlowGraphNormalizeVector4Block:()=>pO,FlowGraphPauseAnimationBlock:()=>lP,FlowGraphPiNumberBlock:()=>HI,FlowGraphPlayAnimationBlock:()=>aP,FlowGraphPlayAudioBlock:()=>cP,FlowGraphPowNumberBlock:()=>iI,FlowGraphQuaternionToRotationMatrixBlock:()=>GO,FlowGraphRandomNumberBlock:()=>KI,FlowGraphReceiveCustomEventBlock:()=>jO,FlowGraphRotate2dVector2Block:()=>CM,FlowGraphRotate3dVector3Block:()=>ZM,FlowGraphRoundNumberBlock:()=>vI,FlowGraphScaleMatrixBlock:()=>NO,FlowGraphScaleVector2Block:()=>bM,FlowGraphScaleVector3Block:()=>BM,FlowGraphScaleVector4Block:()=>cO,FlowGraphSceneReadyEventBlock:()=>XO,FlowGraphSceneTickEventBlock:()=>YO,FlowGraphSendCustomEventBlock:()=>YC,FlowGraphSetPropertyBlock:()=>jC,FlowGraphSetVariableBlock:()=>XC,FlowGraphSignalConnection:()=>IC,FlowGraphSinNumberBlock:()=>MI,FlowGraphSplitVector2Block:()=>RM,FlowGraphSplitVector3Block:()=>QM,FlowGraphSplitVector4Block:()=>gO,FlowGraphSqrtNumberBlock:()=>lI,FlowGraphState:()=>wC,FlowGraphStopAnimationBlock:()=>sP,FlowGraphStopAudioBlock:()=>uP,FlowGraphSubtractMatrixAndNumberBlock:()=>AO,FlowGraphSubtractMatrixBlock:()=>SO,FlowGraphSubtractNumberBlock:()=>KP,FlowGraphSubtractVector2Block:()=>fM,FlowGraphSubtractVector3Block:()=>OM,FlowGraphSubtractVector4Block:()=>rO,FlowGraphSwitchBlock:()=>eP,FlowGraphTanNumberBlock:()=>FI,FlowGraphThrottleBlock:()=>ZC,FlowGraphTimerBlock:()=>JC,FlowGraphTransformVector3Block:()=>$M,FlowGraphTruncNumberBlock:()=>bI,FlowGraphWaitAllBlock:()=>tP,FlowGraphWhileLoopBlock:()=>rP,FluidRenderer:()=>aA,FluidRendererSceneComponent:()=>oA,FluidRenderingDebug:()=>Kx,FluidRenderingObject:()=>qx,FluidRenderingObjectCustomParticles:()=>tA,FluidRenderingObjectParticleSystem:()=>Zx,FluidRenderingTargetRenderer:()=>eA,FlyCamera:()=>pl,FlyCameraInputsManager:()=>dl,FlyCameraKeyboardInput:()=>Xs,FlyCameraMouseInput:()=>js,FogBlock:()=>Lv,FollowBehavior:()=>Xo,FollowCamera:()=>gl,FollowCameraInputsManager:()=>fl,FollowCameraKeyboardMoveInput:()=>Ys,FollowCameraMouseWheelInput:()=>Ks,FollowCameraPointersInput:()=>Qs,FragCoordBlock:()=>Cv,FragDepthBlock:()=>Dv,FragmentOutputBlock:()=>va,FramingBehavior:()=>Mo,FreeCamera:()=>ll,FreeCameraDeviceOrientationInput:()=>il,FreeCameraGamepadInput:()=>nl,FreeCameraInputsManager:()=>tl,FreeCameraKeyboardMoveInput:()=>qs,FreeCameraMouseInput:()=>Js,FreeCameraMouseWheelInput:()=>$s,FreeCameraTouchInput:()=>el,FreeCameraVirtualJoystickInput:()=>al,FresnelBlock:()=>sy,FresnelParameters:()=>Sg,FromHalfFloat:()=>od,FrontFace:()=>_p,FrontFacingBlock:()=>Av,Frustum:()=>br,FxaaPostProcess:()=>nx,GPUParticleSystem:()=>UE,GUID:()=>Ai,Gamepad:()=>Bs,GamepadCamera:()=>Rl,GamepadManager:()=>Sl,GamepadSystemSceneComponent:()=>xl,GenerateBase64StringFromPixelData:()=>vo,GenerateBase64StringFromTexture:()=>yo,GenerateBase64StringFromTextureAsync:()=>bo,GenericPad:()=>Us,GeodesicData:()=>xh,Geometry:()=>In,GeometryBufferRenderer:()=>cx,GeometryBufferRendererSceneComponent:()=>hx,GeometryCollectionBlock:()=>WT,GeometryElbowBlock:()=>HT,GeometryInfoBlock:()=>fE,GeometryInputBlock:()=>_T,GeometryOptimizeBlock:()=>vT,GeometryOutputBlock:()=>pT,GeometryTextureBlock:()=>yE,GeometryTextureFetchBlock:()=>bE,GeometryTransformBlock:()=>ZT,GeometryTrigonometryBlock:()=>qT,GeometryTrigonometryBlockOperations:()=>KT,GetClass:()=>T,GetDOMTextContent:()=>ot,GetEnvInfo:()=>_d,GetEnvironmentBRDFTexture:()=>__,GetInternalFormatFromBasisFormat:()=>Zg,GetTGAHeader:()=>Wg,GetTextureDataAsync:()=>sd,Gizmo:()=>su,GizmoAnchorPoint:()=>iu,GizmoCoordinatesMode:()=>ru,GizmoManager:()=>Jf,GlowLayer:()=>Nm,GoldbergMesh:()=>Rh,GradientBlock:()=>Sy,GradientBlockColorStep:()=>Ey,GradientHelper:()=>FE,GrainPostProcess:()=>ox,GreasedLineBaseMesh:()=>Jb,GreasedLineMaterialDefaults:()=>gb,GreasedLineMesh:()=>$b,GreasedLineMeshColorDistribution:()=>eT,GreasedLineMeshColorDistributionType:()=>nb,GreasedLineMeshColorMode:()=>rb,GreasedLineMeshMaterialType:()=>ib,GreasedLineMeshWidthDistribution:()=>tT,GreasedLinePluginMaterial:()=>bb,GreasedLineRibbonAutoDirectionMode:()=>qb,GreasedLineRibbonFacesMode:()=>Qb,GreasedLineRibbonMesh:()=>oT,GreasedLineRibbonPointsMode:()=>Kb,GreasedLineSimpleMaterial:()=>Eb,GreasedLineTools:()=>vb,GridBlock:()=>ST,GroundBuilder:()=>wc,GroundMesh:()=>Ic,HDRCubeTexture:()=>rg,HDRCubeTextureAssetTask:()=>xA,HDRFiltering:()=>ig,HDRTools:()=>tg,HandConstraintBehavior:()=>Rs,HandConstraintOrientation:()=>ys,HandConstraintVisibility:()=>bs,HandConstraintZone:()=>vs,HandPart:()=>_s,HardwareScalingOptimization:()=>NA,HavokPlugin:()=>MS,HeightToNormalBlock:()=>Ov,HemisphereBuilder:()=>i_,HemisphericLight:()=>nu,HemisphericParticleEmitter:()=>za,HighlightLayer:()=>Lm,HighlightsPostProcess:()=>ax,Hinge2Joint:()=>$o,HingeConstraint:()=>yS,HingeJoint:()=>Jo,HtmlElementTexture:()=>Mg,IFlowGraphCoordinatorConfiguration:()=>GC,IWebXRControllerPhysicsOptions:()=>IR,IcoSphereBlock:()=>TT,IcoSphereBuilder:()=>gs,ImageAssetTask:()=>TA,ImageProcessingBlock:()=>Tv,ImageProcessingConfiguration:()=>Li,ImageProcessingConfigurationDefines:()=>Fi,ImageProcessingPostProcess:()=>sx,ImageSourceBlock:()=>Bv,IncrementValueAction:()=>re,IndexFormat:()=>Tp,InputBlock:()=>Aa,InspectableType:()=>tR,InstancedLinesMesh:()=>ku,InstancedMesh:()=>ro,InstancesBlock:()=>vv,InstantiateBlock:()=>lE,InstantiateLinearBlock:()=>cE,InstantiateOnFacesBlock:()=>oE,InstantiateOnVerticesBlock:()=>nE,InstantiateOnVolumeBlock:()=>aE,InstantiateRadialBlock:()=>uE,InstantiatedEntries:()=>ao,IntFloatConverterBlock:()=>hE,InternalTexture:()=>jt,InternalTextureSource:()=>Ot,InterpolateValueAction:()=>Qe,IntersectionInfo:()=>pn,IsBase64DataUrl:()=>gi,IsDocumentAvailable:()=>nt,IsFileURL:()=>mi,IsNavigatorAvailable:()=>rt,IsWindowObjectExist:()=>it,JoystickAxis:()=>rl,KeepAssets:()=>oo,KeyboardEventTypes:()=>nr,KeyboardInfo:()=>or,KeyboardInfoPre:()=>ar,KhronosTextureContainer:()=>j_,KhronosTextureContainer2:()=>Z_,LatheBuilder:()=>ah,Layer:()=>Bm,LayerSceneComponent:()=>wm,LengthBlock:()=>hy,LensFlare:()=>Um,LensFlareSystem:()=>Vm,LensFlareSystemSceneComponent:()=>km,LensFlaresOptimization:()=>wA,LensRenderingPipeline:()=>yx,LerpBlock:()=>ty,Light:()=>no,LightBlock:()=>wv,LightGizmo:()=>n_,LightInformationBlock:()=>bv,LineEdgesRenderer:()=>Gx,LinesBuilder:()=>ju,LinesMesh:()=>Vu,LoadFile:()=>fi,LoadFileError:()=>ai,LoadImage:()=>di,LoadOp:()=>Rp,LoadTextureFromTranscodeResult:()=>rv,LockConstraint:()=>TS,Logger:()=>$,MapMode:()=>qd,MapRangeBlock:()=>BT,MappingBlock:()=>_E,MappingTypes:()=>pE,Material:()=>Kn,MaterialAnisotropicDefines:()=>S_,MaterialClearCoatDefines:()=>y_,MaterialDefines:()=>Di,MaterialDetailMapDefines:()=>hc,MaterialFlags:()=>tc,MaterialGreasedLineDefines:()=>yb,MaterialHelper:()=>jn,MaterialIridescenceDefines:()=>T_,MaterialPluginBase:()=>uc,MaterialPluginEvent:()=>Xn,MaterialPluginManager:()=>rc,MaterialSheenDefines:()=>A_,MaterialSubSurfaceDefines:()=>C_,MathBlock:()=>LT,MathBlockOperations:()=>NT,Matrix:()=>I,MatrixBuilderBlock:()=>Wy,MatrixComposeBlock:()=>mE,MatrixDeterminantBlock:()=>qy,MatrixTransposeBlock:()=>Jy,MaxBlock:()=>ly,MergeGeometryBlock:()=>zT,MergeMeshesOptimization:()=>kA,Mesh:()=>io,MeshAssetTask:()=>gA,MeshAttributeExistsBlock:()=>eb,MeshAttributeExistsBlockTypes:()=>Zy,MeshBlock:()=>bT,MeshBuilder:()=>Nh,MeshDebugMode:()=>Tb,MeshDebugPluginMaterial:()=>Ab,MeshExploder:()=>PA,MeshLODLevel:()=>qn,MeshParticleEmitter:()=>Ya,MeshUVSpaceRenderer:()=>Ub,MeshoptCompression:()=>Ob,MinBlock:()=>cy,MinMaxReducer:()=>Wm,MipmapFilterMode:()=>np,MirrorTexture:()=>s_,ModBlock:()=>Gy,ModelShape:()=>WE,MorphTarget:()=>ng,MorphTargetManager:()=>ag,MorphTargetsBlock:()=>yv,MotionBlurPostProcess:()=>dx,MotorEnabledJoint:()=>Zo,MultiMaterial:()=>Qn,MultiObserver:()=>MA,MultiPointerScaleBehavior:()=>Go,MultiRenderTarget:()=>sv,MultiplyBlock:()=>Ba,NLerpBlock:()=>xy,NativeDataStream:()=>Qh,NativeEngine:()=>Xd,NativePointerInput:()=>Ui,NativeXRFrame:()=>dC,NativeXRLayerRenderTargetTextureProvider:()=>Rc,NativeXRLayerWrapper:()=>Ac,NativeXRRenderTarget:()=>Cc,NegateBlock:()=>dy,Node:()=>We,NodeGeometry:()=>gT,NodeGeometryBlock:()=>dT,NodeGeometryBlockConnectionPointTypes:()=>iT,NodeGeometryBuildState:()=>fT,NodeGeometryConnectionPoint:()=>hT,NodeGeometryConnectionPointCompatibilityStates:()=>rT,NodeGeometryConnectionPointDirection:()=>nT,NodeGeometryContextualSources:()=>uT,NodeMaterial:()=>hs,NodeMaterialBlock:()=>ha,NodeMaterialBlockConnectionPointMode:()=>ma,NodeMaterialBlockConnectionPointTypes:()=>ia,NodeMaterialBlockTargets:()=>ra,NodeMaterialConnectionPoint:()=>ua,NodeMaterialConnectionPointCompatibilityStates:()=>aa,NodeMaterialConnectionPointCustomObject:()=>mv,NodeMaterialConnectionPointDirection:()=>sa,NodeMaterialDefines:()=>us,NodeMaterialModes:()=>wa,NodeMaterialOptimizer:()=>ob,NodeMaterialSystemValues:()=>ga,NodeMaterialTeleportInBlock:()=>Hv,NodeMaterialTeleportOutBlock:()=>Xv,NoiseBlock:()=>GT,NoiseProceduralTexture:()=>hv,NormalBlendBlock:()=>Cy,NormalizeBlock:()=>Jv,NormalizeVectorBlock:()=>YT,NullBlock:()=>PT,NullEngine:()=>Vh,NullEngineOptions:()=>Uh,Observable:()=>u,Observer:()=>c,OcclusionMaterial:()=>xg,Octree:()=>Zc,OctreeBlock:()=>qc,OctreeSceneComponent:()=>Jc,OimoJSPlugin:()=>ug,OnAfterEnteringVRObservableEvent:()=>zc,OneMinusBlock:()=>oy,Orientation:()=>Mr,OutlineRenderer:()=>Qx,PBRAnisotropicConfiguration:()=>x_,PBRBaseMaterial:()=>O_,PBRBaseSimpleMaterial:()=>Ag,PBRClearCoatConfiguration:()=>b_,PBRIridescenceConfiguration:()=>E_,PBRMaterial:()=>D_,PBRMaterialDefines:()=>M_,PBRMetallicRoughnessBlock:()=>ky,PBRMetallicRoughnessMaterial:()=>Rg,PBRSheenConfiguration:()=>R_,PBRSpecularGlossinessMaterial:()=>Cg,PBRSubSurfaceConfiguration:()=>P_,PHI:()=>f,PadNumber:()=>bt,PanoramaToCubeMapTools:()=>eg,Particle:()=>LE,ParticleBlendMultiplyBlock:()=>Ia,ParticleHelper:()=>kE,ParticleRampGradientBlock:()=>Pa,ParticleSystem:()=>BE,ParticleSystemSet:()=>VE,ParticleTextureBlock:()=>Ca,ParticlesOptimization:()=>UA,PassCubePostProcess:()=>Pl,PassPostProcess:()=>Cl,Path2:()=>wr,Path3D:()=>Br,PathCursor:()=>tn,PerfCollectionStrategy:()=>TR,PerfCounter:()=>vr,PerformanceConfigurator:()=>E,PerformanceMonitor:()=>Mn,PerformanceViewerCollector:()=>yR,PerturbNormalBlock:()=>Sv,PhotoDome:()=>p_,Physics6DoFConstraint:()=>mS,Physics6DoFLimit:()=>_S,PhysicsAggregate:()=>xS,PhysicsBody:()=>nS,PhysicsConstraint:()=>fS,PhysicsConstraintAxis:()=>ZE,PhysicsConstraintAxisLimitMode:()=>qE,PhysicsConstraintMotorType:()=>eS,PhysicsConstraintType:()=>JE,PhysicsEngine:()=>lg,PhysicsEngineV2:()=>rS,PhysicsEventType:()=>tS,PhysicsHelper:()=>LS,PhysicsImpostor:()=>ta,PhysicsJoint:()=>Qo,PhysicsMaterialCombineMode:()=>oS,PhysicsMotionType:()=>iS,PhysicsRadialExplosionEventOptions:()=>kS,PhysicsRadialImpulseFalloff:()=>DS,PhysicsRaycastResult:()=>sg,PhysicsShape:()=>aS,PhysicsShapeBox:()=>uS,PhysicsShapeCapsule:()=>lS,PhysicsShapeContainer:()=>pS,PhysicsShapeConvexHull:()=>hS,PhysicsShapeCylinder:()=>cS,PhysicsShapeMesh:()=>dS,PhysicsShapeSphere:()=>sS,PhysicsShapeType:()=>$E,PhysicsUpdraftEventOptions:()=>GS,PhysicsUpdraftMode:()=>NS,PhysicsViewer:()=>Fh,PhysicsVortexEventOptions:()=>zS,PickingInfo:()=>Yi,PipelineErrorReason:()=>dp,PivotTools:()=>Lo,Plane:()=>yr,PlaneBlock:()=>yT,PlaneBuilder:()=>Uo,PlaneDragGizmo:()=>Qf,PlaneRotationGizmo:()=>Yf,PlayAnimationAction:()=>ne,PlaySoundAction:()=>pe,PointColor:()=>GE,PointLight:()=>Jm,PointParticleEmitter:()=>Wa,PointerDragBehavior:()=>ko,PointerEventTypes:()=>er,PointerInfo:()=>rr,PointerInfoBase:()=>tr,PointerInfoPre:()=>ir,PointerInput:()=>Bi,PointsCloudSystem:()=>QE,PointsGroup:()=>KE,Polar:()=>Rb,Polygon:()=>Qu,PolygonBuilder:()=>eh,PolygonMeshBuilder:()=>qu,PolyhedronBuilder:()=>hh,PolyhedronData:()=>Sh,PositionGizmo:()=>qf,PositionNormalTextureVertex:()=>Ta,PositionNormalVertex:()=>ba,PostProcess:()=>Na,PostProcessManager:()=>Ki,PostProcessRenderEffect:()=>HS,PostProcessRenderPipeline:()=>_x,PostProcessRenderPipelineManager:()=>mx,PostProcessRenderPipelineManagerSceneComponent:()=>gx,PostProcessesOptimization:()=>LA,PosterizeBlock:()=>by,PowBlock:()=>py,PowerEase:()=>jr,PowerPreference:()=>jd,PrePassOutputBlock:()=>Fv,PrePassRenderer:()=>Wx,PrePassRendererSceneComponent:()=>Hx,PrePassTextureBlock:()=>Wv,PrecisionDate:()=>lt,PredicateCondition:()=>Z,PressureObserverWrapper:()=>pR,PrimitiveTopology:()=>fp,PrismaticConstraint:()=>ES,ProceduralTexture:()=>ss,ProceduralTextureSceneComponent:()=>os,PropertyTypeForEdition:()=>pa,PushMaterial:()=>oa,QuadraticEase:()=>Yr,QuadraticErrorSimplification:()=>Yb,QuarticEase:()=>Kr,Quaternion:()=>P,QueryType:()=>Pp,QuinticEase:()=>Qr,RGBDTextureTools:()=>cd,RandomBlock:()=>kT,RandomBlockLocks:()=>UT,RandomGUID:()=>xi,RandomNumberBlock:()=>fy,RawCubeTexture:()=>dv,RawTexture:()=>Ro,RawTexture2DArray:()=>og,RawTexture3D:()=>pv,Ray:()=>Fo,RayHelper:()=>Lh,ReadFile:()=>pi,ReadFileError:()=>li,RecastJSCrowd:()=>AE,RecastJSPlugin:()=>xE,ReciprocalBlock:()=>gy,ReflectBlock:()=>Iy,ReflectionBlock:()=>Fy,ReflectionProbe:()=>dg,ReflectionTextureBlock:()=>kv,Reflector:()=>dR,RefractBlock:()=>My,RefractionBlock:()=>By,RefractionPostProcess:()=>px,RefractionTexture:()=>fv,RegisterClass:()=>b,RegisterMaterialPlugin:()=>sc,RegisterNativeTypeAsync:()=>zd,RemapBlock:()=>La,RenderPassTimestampLocation:()=>Ap,RenderTargetTexture:()=>ns,RenderTargetWrapper:()=>Oa,RenderTargetsOptimization:()=>VA,RenderingGroup:()=>Qi,RenderingGroupInfo:()=>qi,RenderingManager:()=>Zi,ReplaceColorBlock:()=>vy,RequestFile:()=>_i,RequestFileError:()=>si,RetryStrategy:()=>ut,RibbonBuilder:()=>xu,RichType:()=>fC,RichTypeAny:()=>_C,RichTypeBoolean:()=>vC,RichTypeColor3:()=>SC,RichTypeColor4:()=>xC,RichTypeMatrix:()=>EC,RichTypeNumber:()=>gC,RichTypeQuaternion:()=>AC,RichTypeString:()=>mC,RichTypeVector2:()=>yC,RichTypeVector3:()=>bC,RichTypeVector4:()=>TC,RollingAverage:()=>On,Rotate2dBlock:()=>Py,RotationGizmo:()=>Kf,RotationXBlock:()=>JT,RotationYBlock:()=>$T,RotationZBlock:()=>eE,RuntimeAnimation:()=>tt,RuntimeError:()=>pt,SSAO2RenderingPipeline:()=>Tx,SSAORenderingPipeline:()=>Ex,SSRRenderingPipeline:()=>Ix,SamplerBindingType:()=>lp,Scalar:()=>h,ScaleBlock:()=>Yv,ScaleGizmo:()=>Zf,ScalingBlock:()=>tE,Scene:()=>Ar,SceneComponentConstants:()=>Ji,SceneDepthBlock:()=>Gv,SceneInstrumentation:()=>Mm,SceneLoader:()=>na,SceneLoaderAnimationGroupLoadingMode:()=>ea,SceneLoaderFlags:()=>Cn,SceneOptimization:()=>OA,SceneOptimizer:()=>zA,SceneOptimizerOptions:()=>GA,ScenePerformancePriority:()=>sr,SceneRecorder:()=>aR,SceneSerializer:()=>jA,ScreenSizeBlock:()=>Pv,ScreenSpaceBlock:()=>Iv,ScreenSpaceCurvaturePostProcess:()=>Nx,ScreenSpaceReflectionPostProcess:()=>xx,ScreenshotTools:()=>iR,SerializationHelper:()=>Ve,SetColorsBlock:()=>DT,SetCorsBehavior:()=>hi,SetMaterialIDBlock:()=>QT,SetNormalsBlock:()=>MT,SetParentAction:()=>ce,SetPositionsBlock:()=>IT,SetStateAction:()=>te,SetTangentsBlock:()=>FT,SetUVsBlock:()=>OT,SetValueAction:()=>ie,ShaderCodeInliner:()=>Od,ShaderLanguage:()=>at,ShaderMaterial:()=>Uu,ShaderStage:()=>ap,ShaderStore:()=>kt,ShadowDepthWrapper:()=>sb,ShadowGenerator:()=>Gm,ShadowGeneratorSceneComponent:()=>Zm,ShadowLight:()=>$f,ShadowMapBlock:()=>Nv,ShadowsOptimization:()=>FA,ShapeBuilder:()=>nh,SharpenPostProcess:()=>fx,SheenBlock:()=>Dy,SimplexPerlin3DBlock:()=>Ry,SimplicationQueueSceneComponent:()=>Zb,SimplificationQueue:()=>zb,SimplificationSettings:()=>Gb,SimplificationType:()=>Vb,SineEase:()=>qr,SixDofDragBehavior:()=>Wo,Size:()=>He,Skeleton:()=>Is,SkeletonViewer:()=>wh,SliderConstraint:()=>bS,SmartArray:()=>Ii,SmartArrayNoDuplicate:()=>Mi,SmoothStepBlock:()=>my,SolidParticle:()=>zE,SolidParticleSystem:()=>jE,SolidParticleVertex:()=>XE,Sound:()=>uo,SoundTrack:()=>ho,SourceTextureFormat:()=>W_,Space:()=>xr,SphereBlock:()=>ET,SphereBuilder:()=>vu,SphereDirectedParticleEmitter:()=>Xa,SphereParticleEmitter:()=>Ha,Spherical:()=>Cb,SphericalHarmonics:()=>ed,SphericalPolynomial:()=>td,SpotLight:()=>r_,SpringConstraint:()=>SS,Sprite:()=>sA,SpriteManager:()=>uA,SpriteMap:()=>dA,SpritePackedManager:()=>pA,SpriteSceneComponent:()=>lA,Stage:()=>$i,StandardMaterial:()=>_c,StandardMaterialDefines:()=>fc,StandardRenderingPipeline:()=>Ax,StartsWith:()=>_t,StateCondition:()=>J,StencilOperation:()=>bp,StencilState:()=>Wt,StencilStateComposer:()=>ti,StepBlock:()=>ny,StereoscopicArcRotateCamera:()=>Ul,StereoscopicFreeCamera:()=>Vl,StereoscopicGamepadCamera:()=>kl,StereoscopicInterlacePostProcess:()=>wl,StereoscopicInterlacePostProcessI:()=>Ll,StereoscopicScreenUniversalCamera:()=>zl,StereoscopicUniversalCamera:()=>Gl,StickValues:()=>ws,StopAnimationAction:()=>oe,StopSoundAction:()=>fe,StorageBuffer:()=>Ms,StorageTextureAccess:()=>up,StoreOp:()=>Cp,StringDictionary:()=>Oi,StringTools:()=>Tt,SubEmitter:()=>wE,SubEmitterType:()=>ME,SubMesh:()=>xn,SubSurfaceBlock:()=>Uy,SubSurfaceSceneComponent:()=>Yx,SubtractBlock:()=>ry,SurfaceMagnetismBehavior:()=>Ho,SwitchBooleanAction:()=>ee,SwitchInput:()=>zi,TBNBlock:()=>Ev,TGATools:()=>Xg,Tags:()=>me,TargetCamera:()=>sl,TargetedAnimation:()=>$r,TeleportInBlock:()=>gE,TeleportOutBlock:()=>vE,TestBase64DataUrl:()=>vi,TextFileAssetTask:()=>yA,Texture:()=>Eo,TextureAspect:()=>ep,TextureAssetTask:()=>EA,TextureBlock:()=>Uv,TextureDimension:()=>Zd,TextureFormat:()=>tp,TextureOptimization:()=>DA,TexturePacker:()=>cv,TexturePackerFrame:()=>lv,TextureSampleType:()=>cp,TextureSampler:()=>Xt,TextureTools:()=>ld,TextureUsage:()=>Jd,TextureViewDimension:()=>$d,ThinEngine:()=>ri,ThinRenderTargetTexture:()=>_v,ThinTexture:()=>mo,TiledBoxBuilder:()=>Nu,TiledPlaneBuilder:()=>Mu,TimerState:()=>mm,TmpColors:()=>V,TmpVectors:()=>O,ToGammaSpace:()=>d,ToHalfFloat:()=>nd,ToLinearSpace:()=>p,TonemapPostProcess:()=>Ox,TonemappingOperator:()=>Mx,Tools:()=>Ri,TorusBlock:()=>xT,TorusBuilder:()=>Vc,TorusKnotBuilder:()=>wu,TouchCamera:()=>cl,TrailMesh:()=>kb,Trajectory:()=>sR,TrajectoryClassifier:()=>hR,TranscodeAsync:()=>tv,TranscodeTarget:()=>H_,TransformBlock:()=>da,TransformNode:()=>Ln,TranslationBlock:()=>rE,TriPlanarBlock:()=>Ky,TrigonometryBlock:()=>ls,TrigonometryBlockOperations:()=>as,TubeBuilder:()=>lh,TwirlBlock:()=>Mv,UniformBuffer:()=>Hi,UniversalCamera:()=>Al,UnregisterAllMaterialPlugins:()=>cc,UnregisterMaterialPlugin:()=>lc,UploadContent:()=>Hg,UploadEnvLevelsAsync:()=>bd,UploadEnvSpherical:()=>Sd,UploadLevelsAsync:()=>Ed,UtilityLayerRenderer:()=>ou,VRCameraMetrics:()=>Hl,VRDeviceOrientationArcRotateCamera:()=>Zl,VRDeviceOrientationFreeCamera:()=>Jl,VRDeviceOrientationGamepadCamera:()=>$l,VRDistortionCorrectionPostProcess:()=>Xl,VRExperienceHelper:()=>Wc,VRMultiviewToSingleviewPostProcess:()=>Ql,ValidatedNativeDataStream:()=>Dp,ValueCondition:()=>q,Vector2:()=>A,Vector3:()=>R,Vector4:()=>C,VectorConverterBlock:()=>jT,VectorMergerBlock:()=>Fa,VectorSplitterBlock:()=>ey,VertexAnimationBaker:()=>Co,VertexBuffer:()=>ji,VertexData:()=>Rn,VertexDataMaterialInfo:()=>An,VertexFormat:()=>Ep,VertexOutputBlock:()=>fa,VertexStepMode:()=>Sp,VideoDome:()=>Pm,VideoRecorder:()=>YA,VideoTexture:()=>Cm,ViewDirectionBlock:()=>ay,Viewport:()=>hn,VirtualJoystick:()=>ol,VirtualJoysticksCamera:()=>Wl,VolumetricLightScatteringPostProcess:()=>Dx,VoronoiNoiseBlock:()=>jy,WaveBlock:()=>Ty,WaveBlockKind:()=>yy,WebGL2ParticleSystem:()=>PE,WebGL2ShaderProcessor:()=>Qt,WebGLDataBuffer:()=>Zt,WebGLHardwareTexture:()=>$t,WebGLPipelineContext:()=>Jt,WebGPUCacheBindGroups:()=>mf,WebGPUCacheRenderPipeline:()=>sf,WebGPUCacheRenderPipelineTree:()=>cf,WebGPUCacheSampler:()=>rf,WebGPUDataBuffer:()=>qp,WebGPUDrawContext:()=>ff,WebGPUEngine:()=>wf,WebGPUTintWASM:()=>Mf,WebRequest:()=>Xe,WebXRAbstractFeature:()=>Ko,WebXRAbstractMotionController:()=>rm,WebXRAnchorSystem:()=>AR,WebXRBackgroundRemover:()=>PR,WebXRCamera:()=>em,WebXRCompositionLayerWrapper:()=>jR,WebXRControllerComponent:()=>im,WebXRControllerMovement:()=>UR,WebXRControllerPhysics:()=>MR,WebXRControllerPointerSelection:()=>fm,WebXRDefaultExperience:()=>xm,WebXRDefaultExperienceOptions:()=>Sm,WebXRDepthSensing:()=>$R,WebXRDomOverlay:()=>BR,WebXREnterExitUI:()=>ym,WebXREnterExitUIButton:()=>gm,WebXREnterExitUIOptions:()=>vm,WebXRExperienceHelper:()=>tm,WebXREyeTracking:()=>kR,WebXRFeatureName:()=>jo,WebXRFeaturePointSystem:()=>DR,WebXRFeaturesManager:()=>Yo,WebXRGenericHandController:()=>rC,WebXRGenericTriggerMotionController:()=>nm,WebXRHTCViveMotionController:()=>cC,WebXRHand:()=>Ss,WebXRHandJoint:()=>ms,WebXRHandTracking:()=>xs,WebXRHitTest:()=>OR,WebXRHitTestLegacy:()=>SR,WebXRImageTracking:()=>wR,WebXRInput:()=>pm,WebXRInputSource:()=>dm,WebXRLayers:()=>JR,WebXRLightEstimation:()=>VR,WebXRManagedOutputCanvas:()=>xc,WebXRManagedOutputCanvasOptions:()=>Sc,WebXRMeshDetector:()=>LR,WebXRMicrosoftMixedRealityController:()=>oC,WebXRMotionControllerManager:()=>lm,WebXRMotionControllerTeleportation:()=>Em,WebXRNearControllerMode:()=>um,WebXRNearInteraction:()=>_m,WebXROculusTouchMotionController:()=>sC,WebXRPlaneDetector:()=>CR,WebXRProfiledMotionController:()=>am,WebXRProjectionLayerWrapper:()=>KR,WebXRSessionManager:()=>Pc,WebXRSpaceWarp:()=>iC,WebXRSpaceWarpRenderTargetTextureProvider:()=>tC,WebXRState:()=>mc,WebXRTrackingState:()=>gc,WebXRWalkingLocomotion:()=>XR,WeightedSound:()=>fo,WorkerPool:()=>Y_,WorleyNoise3DBlock:()=>Ay,XRSpaceWarpRenderTarget:()=>eC,Xbox360Button:()=>_l,Xbox360Dpad:()=>ml,Xbox360Pad:()=>Tl,XboxInput:()=>Gi,_BabylonLoaderRegistered:()=>pg,_BasisTextureLoader:()=>av,_CreationDataStorage:()=>Zn,_DDSTextureLoader:()=>G_,_ENVTextureLoader:()=>z_,_HDRTextureLoader:()=>Yg,_IAnimationState:()=>je,_InstancesBatch:()=>$n,_KTXTextureLoader:()=>$_,_MeshCollisionData:()=>wn,_OcclusionDataStorage:()=>Gh,_PrimaryIsoTriangle:()=>Eh,_TGATextureLoader:()=>jg,_TimeToken:()=>kh,_UpdateRGBDAsync:()=>xd,_forceSceneHelpersToBundle:()=>Am,_forceTransformFeedbackToBundle:()=>zh,_injectLTSFileTools:()=>Ei,addClipPlaneUniforms:()=>kn,allocateAndCopyTypedBuffer:()=>Dn,bindClipPlane:()=>Wn,captureEquirectangularFromScene:()=>ER,className:()=>Ci,createDetailMapPlugin:()=>mb,createPBRAnisotropicPlugin:()=>ub,createPBRBRDFPlugin:()=>hb,createPBRClearCoatPlugin:()=>db,createPBRIridescencePlugin:()=>pb,createPBRSheenPlugin:()=>fb,createPBRSubSurfacePlugin:()=>_b,createYieldingScheduler:()=>on,editableInPropertyPage:()=>_a,expandToProperty:()=>xe,extractMinAndMax:()=>Sn,extractMinAndMaxIndexed:()=>En,getRichTypeFromValue:()=>RC,inlineScheduler:()=>nn,makeAsyncFunction:()=>un,makeSyncFunction:()=>cn,nativeOverride:()=>ke,normalizeEnvInfo:()=>md,prepareDefinesForClipPlanes:()=>zn,prepareStringDefinesForClipPlanes:()=>Gn,runCoroutine:()=>an,runCoroutineAsync:()=>ln,runCoroutineSync:()=>sn,serialize:()=>Ae,serializeAsCameraReference:()=>Be,serializeAsColor3:()=>Ce,serializeAsColor4:()=>Ne,serializeAsColorCurves:()=>De,serializeAsFresnelParameters:()=>Pe,serializeAsImageProcessingConfiguration:()=>Fe,serializeAsMatrix:()=>we,serializeAsMeshReference:()=>Oe,serializeAsQuaternion:()=>Le,serializeAsTexture:()=>Re,serializeAsVector2:()=>Ie,serializeAsVector3:()=>Me,setAndStartTimer:()=>bm,setStereoscopicAnaglyphRigMode:()=>Ml,setStereoscopicRigMode:()=>Bl,setVRRigMode:()=>ql});var o=function(){function e(){this.rootNodes=new Array,this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=[],this.animationGroups=new Array,this.multiMaterials=new Array,this.materials=new Array,this.morphTargetManagers=new Array,this.geometries=new Array,this.transformNodes=new Array,this.actionManagers=new Array,this.textures=new Array,this._environmentTexture=null,this.postProcesses=new Array}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=new Array;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=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_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.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}(),s=function(){function e(){this.hoverCursor="",this.actions=new Array,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>=a.ACTION_OnPickTrigger&&i<=a.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}(),l=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}(),c=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}(),u=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 l(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 c(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;t0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},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*e.Clamp(r)},e.InverseLerp=function(t,i,r){return t!=i?e.Clamp((r-t)/(i-t)):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.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.NormalizeRadians=function(t){return t-e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.HCF=function(t,i){var r=t%i;return 0===r?i:e.HCF(i,r)},e.TwoPi=2*Math.PI,e}(),d=1/2.2,p=2.2,f=(1+Math.sqrt(5))/2,_=.001,m=function(){function e(){}return e.BuildArray=function(e,t){for(var i=[],r=0;ri.x?i.x:r)i.y?i.y:n)t.x?e.x:t.x,r=e.y>t.y?e.y:t.y;return new e.constructor(i,r)},e.Transform=function(t,i){var r=new t.constructor;return e.TransformToRef(t,i,r),r},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){var r=new t.constructor;return e.CenterToRef(t,i,r)},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}(),R=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=x(this._x);return 397*(e=397*e^x(this._y))^x(this._z)},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},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 P.RotationYawPitchRoll(this._y,this._x,this._z)},e.prototype.addInPlace=function(e){return this.addInPlaceFromFloats(e._x,e._y,e._z)},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(e){return new this.constructor(this._x+e._x,this._y+e._y,this._z+e._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(e){return new this.constructor(this._x-e._x,this._y-e._y,this._z-e._z)},e.prototype.subtractToRef=function(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)},e.prototype.subtractFromFloats=function(e,t,i){return new this.constructor(this._x-e,this._y-t,this._z-i)},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 this.constructor(-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(e){return new this.constructor(this._x*e,this._y*e,this._z*e)},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(e){return this.applyRotationQuaternionToRef(e,new this.constructor)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this._x*e,this._y*e,this._z*e)},e.prototype.projectOnPlane=function(e,t){var i=new this.constructor;return this.projectOnPlaneToRef(e,t,i),i},e.prototype.projectOnPlaneToRef=function(t,i,r){var n=t.normal,o=t.d,a=M.Vector3[0];this.subtractToRef(i,a),a.normalize();var s=e.Dot(a,n);if(Math.abs(s)this._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(!h.WithinEpsilon(t,i,e))return!0;var r=Math.abs(this._z);return!h.WithinEpsilon(t,r,e)||!h.WithinEpsilon(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.floor=function(){return new this.constructor(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},e.prototype.fract=function(){return new this.constructor(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._x*this._x+this._y*this._y+this._z*this._z)},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){var t=this;return"xyz"===(e=e.toLowerCase())||(M.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(i,r){t[i]=M.Vector3[0][e[r]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,i){return t.toRotationMatrix(M.Matrix[0]),e.TransformCoordinatesToRef(this,M.Matrix[0],i),i},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,i){return this.subtractToRef(t,M.Vector3[0]),M.Vector3[0].rotateByQuaternionToRef(e,M.Vector3[0]),t.addToRef(M.Vector3[0],i),i},e.prototype.cross=function(t){var i=new this.constructor;return e.CrossToRef(this,t,i)},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){var e=new this.constructor(0,0,0);return this.normalizeToRef(e),e},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFromFloats(this._x,this._y,this._z):this.scaleToRef(1/t,e)},e.prototype.clone=function(){return new this.constructor(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)-n;return o/(o-(e.Dot(i,r)-n))},e.GetAngleBetweenVectors=function(t,i,r){var n=t.normalizeToRef(M.Vector3[1]),o=i.normalizeToRef(M.Vector3[2]),a=e.Dot(n,o);a=h.Clamp(a,-1,1);var s=Math.acos(a),l=M.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){M.Vector3[0].copyFrom(t);var n=M.Vector3[0];M.Vector3[1].copyFrom(i);var o=M.Vector3[1];M.Vector3[2].copyFrom(r);var a=M.Vector3[2],s=M.Vector3[3],l=M.Vector3[4];n.normalize(),o.normalize(),a.normalize(),e.CrossToRef(a,n,s),e.CrossToRef(s,a,l);var c=Math.atan2(e.Dot(o,s),e.Dot(o,l));return h.NormalizeRadians(c)},e.PitchYawRollToMoveBetweenPointsToRef=function(e,t,i){var r=O.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=h.Clamp(r,0,1);var o=M.Vector3[0],a=M.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,d=e.Dot(o,a);if(d<1-_){var p=Math.acos(d),f=1/Math.sin(p);c=Math.sin((1-r)*p)*f,u=Math.sin(r*p)*f}else c=1-r,u=r;return o.scaleInPlace(c),a.scaleInPlace(u),n.copyFrom(o).addInPlace(a),n.scaleInPlace(h.Lerp(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(h.RandomRange(t,i),h.RandomRange(t,i),h.RandomRange(t,i))},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(e,t,i,r,n){var o=n*n,a=n*o,s=.5*(2*t._x+(-e._x+i._x)*n+(2*e._x-5*t._x+4*i._x-r._x)*o+(-e._x+3*t._x-3*i._x+r._x)*a),l=.5*(2*t._y+(-e._y+i._y)*n+(2*e._y-5*t._y+4*i._y-r._y)*o+(-e._y+3*t._y-3*i._y+r._y)*a),c=.5*(2*t._z+(-e._z+i._z)*n+(2*e._z-5*t._z+4*i._z-r._z)*o+(-e._z+3*t._z-3*i._z+r._z)*a);return new e.constructor(s,l,c)},e.Clamp=function(t,i,r){var n=new t.constructor;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?(D.copyFrom(a),P=i,I=r):C>0&&O<0?(D.copyFrom(l),P=r,I=n):(D.copyFrom(s).scaleInPlace(-1),P=n,I=i);var N=M.Vector3[9],F=M.Vector3[4];if(P.subtractToRef(b,x),I.subtractToRef(b,N),e.CrossToRef(x,N,F),!(e.Dot(F,c)<0))return o.copyFrom(b),Math.abs(g*v);var L=M.Vector3[5];e.CrossToRef(D,F,L),L.normalize();var w=M.Vector3[9];w.copyFrom(P).subtractInPlace(b);var B=w.length();if(B<_)return o.copyFrom(P),e.Distance(t,P);w.normalizeFromLength(B);var U=e.Dot(L,w),V=M.Vector3[7];V.copyFrom(b).addInPlace(L.scaleInPlace(B*U)),x.copyFrom(V).subtractInPlace(P),g=D.length(),D.normalizeFromLength(g);var k=e.Dot(x,D)/Math.max(g,_);return k=h.Clamp(k,0,1),V.copyFrom(P).addInPlace(D.scaleInPlace(k*g)),o.copyFrom(V),e.Distance(t,V)},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.RotationFromAxis=function(t,i,r){var n=new t.constructor;return e.RotationFromAxisToRef(t,i,r,n),n},e.RotationFromAxisToRef=function(e,t,i,r){var n=M.Quaternion[0];return P.RotationQuaternionFromAxisToRef(e,t,i,n),n.toEulerAnglesToRef(r),r},e._UpReadOnly=e.Up(),e._DownReadOnly=e.Down(),e._LeftHandedForwardReadOnly=e.Forward(!1),e._RightHandedForwardReadOnly=e.Forward(!0),e._LeftHandedBackwardReadOnly=e.Backward(!1),e._RightHandedBackwardReadOnly=e.Backward(!0),e._RightReadOnly=e.Right(),e._LeftReadOnly=e.Left(),e._ZeroReadOnly=e.Zero(),e._OneReadOnly=e.One(),e}(),C=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=0),this.x=e,this.y=t,this.z=i,this.w=r}return 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"Vector4"},e.prototype.getHashCode=function(){var e=x(this.x);return 397*(e=397*(e=397*e^x(this.y))^x(this.z))^x(this.w)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},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),this},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.add=function(e){return new this.constructor(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},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},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},e.prototype.subtract=function(e){return new this.constructor(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},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},e.prototype.subtractFromFloats=function(e,t,i,r){return new this.constructor(this.x-e,this.y-t,this.z-i,this.w-r)},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},e.prototype.negate=function(){return new this.constructor(-this.x,-this.y,-this.z,-this.w)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y,-1*this.z,-1*this.w)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scale=function(e){return new this.constructor(this.x*e,this.y*e,this.z*e,this.w*e)},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},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},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=_),e&&h.WithinEpsilon(this.x,e.x,t)&&h.WithinEpsilon(this.y,e.y,t)&&h.WithinEpsilon(this.z,e.z,t)&&h.WithinEpsilon(this.w,e.w,t)},e.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},e.prototype.multiply=function(e){return new this.constructor(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},e.prototype.multiplyToRef=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},e.prototype.multiplyByFloats=function(e,t,i,r){return new this.constructor(this.x*e,this.y*t,this.z*i,this.w*r)},e.prototype.divide=function(e){return new this.constructor(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},e.prototype.divideToRef=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},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.minimizeInPlace=function(e){return e.xthis.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.floor=function(){return new this.constructor(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fract=function(){return new this.constructor(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(){var e=this.length();return 0===e?this:this.scaleInPlace(1/e)},e.prototype.toVector3=function(){return new R(this.x,this.y,this.z)},e.prototype.clone=function(){return new this.constructor(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.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(h.RandomRange(t,i),h.RandomRange(t,i),h.RandomRange(t,i),h.RandomRange(t,i))},Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!1,configurable:!0}),e.Normalize=function(t){var i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){return t.copyFrom(e),t.normalize(),t},e.Minimize=function(e,t){var i=new e.constructor;return i.copyFrom(e),i.minimizeInPlace(t),i},e.Maximize=function(e,t){var i=new e.constructor;return i.copyFrom(e),i.maximizeInPlace(t),i},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.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=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){var r=new t.constructor;return e.TransformNormalToRef(t,i,r),r},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._ZeroReadOnly=e.Zero(),e}(),P=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=x(this._x);return 397*(e=397*(e=397*e^x(this._y))^x(this._z))^x(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.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=_),e&&h.WithinEpsilon(this._x,e._x,t)&&h.WithinEpsilon(this._y,e._y,t)&&h.WithinEpsilon(this._z,e._z,t)&&h.WithinEpsilon(this._w,e._w,t)},e.prototype.clone=function(){return new this.constructor(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.add=function(e){return new this.constructor(this._x+e._x,this._y+e._y,this._z+e._z,this._w+e._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.subtract=function(e){return new this.constructor(this._x-e._x,this._y-e._y,this._z-e._z,this._w-e._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(e){return new this.constructor(this._x*e,this._y*e,this._z*e,this._w*e)},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(e){var t=new this.constructor(0,0,0,1);return this.multiplyToRef(e,t),t},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),this},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 this.constructor(-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(){var e=this.length();if(0===e)return this;var t=1/e;return this.scaleInPlace(t),this},e.prototype.normalizeToNew=function(){var e=this.length();if(0===e)return this.clone();var t=1/e;return this.scale(t)},e.prototype.toEulerAngles=function(){var e=R.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 I.FromQuaternionToRef(this,e),e},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},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=h.Clamp(a,0,1),e.SlerpToRef(t,i,a,o),o},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(e){return new e.constructor(-e._x,-e._y,-e._z,e._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.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=_);var n=R.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):(R.CrossToRef(e,t,O.Vector3[0]),i.set(O.Vector3[0].x,O.Vector3[0].y,O.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=M.Matrix[0];return I.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=M.Matrix[0];return I.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=M.Matrix[0];return I.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(e,t,i,r,n){var o=n*n,a=n*o,s=2*a-3*o+1,l=-2*a+3*o,c=a-2*o+n,u=a-o,h=e._x*s+i._x*l+t._x*c+r._x*u,d=e._y*s+i._y*l+t._y*c+r._y*u,p=e._z*s+i._z*l+t._z*c+r._z*u,f=e._w*s+i._w*l+t._w*c+r._w*u;return new e.constructor(h,d,p,f)},e.Hermite1stDerivative=function(e,t,i,r,n){var o=new e.constructor;return this.Hermite1stDerivativeToRef(e,t,i,r,n,o),o},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}(),I=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,E.MatrixTrackPrecisionChange&&E.MatrixTrackedMatrices.push(this),this._m=new E.MatrixCurrentType(16),this.markAsUpdated()}return Object.defineProperty(e,"Use64Bits",{get:function(){return E.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(){return this._m},e.prototype.asArray=function(){return this._m},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){return e.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},e.prototype.add=function(e){var t=new this.constructor;return this.addToRef(e,t),t},e.prototype.addToRef=function(e,t){for(var i=this._m,r=t._m,n=e.m,o=0;o<16;o++)r[o]=i[o]+n[o];return t.markAsUpdated(),t},e.prototype.addToSelf=function(e){for(var t=this._m,i=e.m,r=0;r<16;r++)t[r]+=i[r];return this.markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),t;var i=this._m,r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],l=i[5],c=i[6],u=i[7],h=i[8],d=i[9],p=i[10],f=i[11],_=i[12],m=i[13],g=i[14],v=i[15],y=p*v-g*f,b=d*v-m*f,T=d*g-m*p,E=h*v-_*f,S=h*g-p*_,x=h*m-_*d,A=+(l*y-c*b+u*T),R=-(s*y-c*E+u*S),C=+(s*b-l*E+u*x),P=-(s*T-l*S+c*x),I=r*A+n*R+o*C+a*P;if(0===I)return t.copyFrom(this),t;var M=1/I,O=c*v-g*u,D=l*v-m*u,N=l*g-m*c,F=s*v-_*u,L=s*g-_*c,w=s*m-_*l,B=c*f-p*u,U=l*f-d*u,V=l*p-d*c,k=s*f-h*u,G=s*p-h*c,z=s*d-h*l,W=-(n*y-o*b+a*T),H=+(r*y-o*E+a*S),X=-(r*b-n*E+a*x),j=+(r*T-n*S+o*x),Y=+(n*O-o*D+a*N),K=-(r*O-o*F+a*L),Q=+(r*D-n*F+a*w),q=-(r*N-n*L+o*w),Z=-(n*B-o*U+a*V),J=+(r*B-o*k+a*G),$=-(r*U-n*k+a*z),ee=+(r*V-n*G+o*z);return e.FromValuesToRef(A*M,W*M,Y*M,Z*M,R*M,H*M,K*M,J*M,C*M,X*M,Q*M,$*M,P*M,j*M,q*M,ee*M,t),t},e.prototype.addAtIndex=function(e,t){return this._m[e]+=t,this.markAsUpdated(),this},e.prototype.multiplyAtIndex=function(e,t){return this._m[e]*=t,this.markAsUpdated(),this},e.prototype.setTranslationFromFloats=function(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this.markAsUpdated(),this},e.prototype.addTranslationFromFloats=function(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this.markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e._x,e._y,e._z)},e.prototype.getTranslation=function(){return new R(this._m[12],this._m[13],this._m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],e},e.prototype.removeRotationAndScaling=function(){var t=this.m;return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t[12],t[13],t[14],t[15],this),this._updateIdentityStatus(0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]),this},e.prototype.multiply=function(e){var t=new this.constructor;return this.multiplyToRef(e,t),t},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);var i=this._m;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],this},e.prototype.multiplyToRef=function(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)},e.prototype.multiplyToArray=function(e,t,i){var r=this._m,n=e.m,o=r[0],a=r[1],s=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=r[9],_=r[10],m=r[11],g=r[12],v=r[13],y=r[14],b=r[15],T=n[0],E=n[1],S=n[2],x=n[3],A=n[4],R=n[5],C=n[6],P=n[7],I=n[8],M=n[9],O=n[10],D=n[11],N=n[12],F=n[13],L=n[14],w=n[15];return t[i]=o*T+a*A+s*I+l*N,t[i+1]=o*E+a*R+s*M+l*F,t[i+2]=o*S+a*C+s*O+l*L,t[i+3]=o*x+a*P+s*D+l*w,t[i+4]=c*T+u*A+h*I+d*N,t[i+5]=c*E+u*R+h*M+d*F,t[i+6]=c*S+u*C+h*O+d*L,t[i+7]=c*x+u*P+h*D+d*w,t[i+8]=p*T+f*A+_*I+m*N,t[i+9]=p*E+f*R+_*M+m*F,t[i+10]=p*S+f*C+_*O+m*L,t[i+11]=p*x+f*P+_*D+m*w,t[i+12]=g*T+v*A+y*I+b*N,t[i+13]=g*E+v*R+y*M+b*F,t[i+14]=g*S+v*C+y*O+b*L,t[i+15]=g*x+v*P+y*D+b*w,this},e.prototype.equals=function(e){var t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;var i=this.m,r=t.m;return i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]&&i[3]===r[3]&&i[4]===r[4]&&i[5]===r[5]&&i[6]===r[6]&&i[7]===r[7]&&i[8]===r[8]&&i[9]===r[9]&&i[10]===r[10]&&i[11]===r[11]&&i[12]===r[12]&&i[13]===r[13]&&i[14]===r[14]&&i[15]===r[15]},e.prototype.clone=function(){var e=new this.constructor;return e.copyFrom(this),e},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=x(this._m[0]),t=1;t<16;t++)e=397*e^x(this._m[t]);return e},e.prototype.decomposeToTransformNode=function(e){return e.rotationQuaternion=e.rotationQuaternion||new P,this.decompose(e.scaling,e.rotationQuaternion,e.position)},e.prototype.decompose=function(t,i,r,n){if(this._isIdentity)return r&&r.setAll(0),t&&t.setAll(1),i&&i.copyFromFloats(0,0,0,1),!0;var o=this._m;if(r&&r.copyFromFloats(o[12],o[13],o[14]),(t=t||M.Vector3[0]).x=Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2]),t.y=Math.sqrt(o[4]*o[4]+o[5]*o[5]+o[6]*o[6]),t.z=Math.sqrt(o[8]*o[8]+o[9]*o[9]+o[10]*o[10]),n){var a=n.absoluteScaling.x<0?-1:1,s=n.absoluteScaling.y<0?-1:1,l=n.absoluteScaling.z<0?-1:1;t.x*=a,t.y*=s,t.z*=l}else this.determinant()<=0&&(t.y*=-1);if(0===t._x||0===t._y||0===t._z)return i&&i.copyFromFloats(0,0,0,1),!1;if(i){var c=1/t._x,u=1/t._y,h=1/t._z;e.FromValuesToRef(o[0]*c,o[1]*c,o[2]*c,0,o[4]*u,o[5]*u,o[6]*u,0,o[8]*h,o[9]*h,o[10]*h,0,0,0,0,1,M.Matrix[0]),P.FromRotationMatrixToRef(M.Matrix[0],i)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new C(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 this.constructor;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(e){var t=new this.constructor;return this.scaleToRef(e,t),t},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.toNormalMatrix=function(t){var i=M.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 e=new this.constructor;return this.getRotationMatrixToRef(e),e},e.prototype.getRotationMatrixToRef=function(t){var i=M.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(e){var t=new e.constructor;return e.invertToRef(t),t},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=R.Dot(t,e),o=i._m;if(n<-1+_)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=R.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 P.RotationYawPitchRollToRef(e,t,i,M.Quaternion[0]),M.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 t.constructor;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 t.constructor;return e.DecomposeLerpToRef(t,i,r,n),n},e.DecomposeLerpToRef=function(t,i,r,n){var o=M.Vector3[0],a=M.Quaternion[0],s=M.Vector3[1];t.decompose(o,a,s);var l=M.Vector3[2],c=M.Quaternion[1],u=M.Vector3[3];i.decompose(l,c,u);var h=M.Vector3[4];R.LerpToRef(o,l,r,h);var d=M.Quaternion[2];P.SlerpToRef(a,c,r,d);var p=M.Vector3[5];return R.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=M.Vector3[0],a=M.Vector3[1],s=M.Vector3[2];i.subtractToRef(t,s),s.normalize(),R.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),R.CrossToRef(s,o,a),a.normalize();var c=-R.Dot(o,t),u=-R.Dot(a,t),h=-R.Dot(s,t);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)},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=M.Vector3[0],a=M.Vector3[1],s=M.Vector3[2];t.subtractToRef(i,s),s.normalize(),R.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),R.CrossToRef(s,o,a),a.normalize();var c=-R.Dot(o,t),u=-R.Dot(a,t),h=-R.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=M.Vector3[0];n.copyFrom(t),n.scaleInPlace(-1);var o=M.Vector3[1];return R.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=M.Vector3[2];return R.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(D,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(D,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,M.Matrix[1]),e.FromValuesToRef(1,0,0,0,0,1,0,0,d,p,1,0,0,0,0,1,M.Matrix[0]),M.Matrix[1].multiplyToRef(M.Matrix[0],M.Matrix[0]),e.TranslationToRef(0,0,c,M.Matrix[1]),M.Matrix[0].multiplyToRef(M.Matrix[1],M.Matrix[0]),e.OrthoOffCenterLHToRef(t,i,r,n,o,a,u,h),M.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,M.Matrix[1]),e.FromValuesToRef(1,0,0,0,0,1,0,0,d,p,1,0,0,0,0,1,M.Matrix[0]),M.Matrix[1].multiplyToRef(M.Matrix[0],M.Matrix[0]),e.TranslationToRef(0,0,-c,M.Matrix[1]),M.Matrix[0].multiplyToRef(M.Matrix[1],M.Matrix[0]),e.OrthoOffCenterRHToRef(t,i,r,n,o,a,u,h),M.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(D,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(D,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(D,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(D,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(D,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 i.constructor;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 E.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 E.MatrixUse64Bits?i:new Float32Array(i)},e.Transpose=function(t){var i=new t.constructor;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}(),M=function(){function e(){}return e.Vector3=m.BuildTuple(11,R.Zero),e.Matrix=m.BuildTuple(2,I.Identity),e.Quaternion=m.BuildTuple(3,P.Zero),e}(),O=function(){function e(){}return e.Vector2=m.BuildTuple(3,A.Zero),e.Vector3=m.BuildTuple(13,R.Zero),e.Vector4=m.BuildTuple(3,C.Zero),e.Quaternion=m.BuildTuple(2,P.Zero),e.Matrix=m.BuildTuple(8,I.Identity),e}();b("BABYLON.Vector2",A),b("BABYLON.Vector3",R),b("BABYLON.Vector4",C),b("BABYLON.Matrix",I);var D=I.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function N(e){return Math.pow(e,p)}function F(e){return e<=.04045?.0773993808*e:Math.pow(.947867299*(e+.055),2.4)}function L(e){return Math.pow(e,d)}function w(e){return e<=.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var B=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|0))^(255*this.b|0)},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 U(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,this},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.r===e&&this.g===t&&this.b===i},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,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=h.Clamp(this.r,e,t),i.g=h.Clamp(this.g,e,t),i.b=h.Clamp(this.b,e,t),this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},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,this},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,this},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.toHexString=function(){var e=Math.round(255*this.r),t=Math.round(255*this.g),i=Math.round(255*this.b);return"#"+h.ToHex(e)+h.ToHex(t)+h.ToHex(i)},e.prototype.toHSV=function(){var t=new e;return this.toHSVToRef(t),t},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;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;r.set(s+u,l+u,c+u)},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}(),U=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.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},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(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),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.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,this},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,this},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,this},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=h.Clamp(this.r,e,t),i.g=h.Clamp(this.g,e,t),i.b=h.Clamp(this.b,e,t),i.a=h.Clamp(this.a,e,t),this},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.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|0))^(255*this.b|0))^(255*this.a|0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},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.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"#"+h.ToHex(t)+h.ToHex(i)+h.ToHex(r);var n=Math.round(255*this.a);return"#"+h.ToHex(t)+h.ToHex(i)+h.ToHex(r)+h.ToHex(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=F(this.r),e.g=F(this.g),e.b=F(this.b)):(e.r=N(this.r),e.g=N(this.g),e.b=N(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=w(this.r),e.g=w(this.g),e.b=w(this.b)):(e.r=L(this.r),e.g=L(this.g),e.b=L(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){var n=new e(0,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,r.a=e.a+(t.a-e.a)*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,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;r=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 j(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 Y(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]this.value;case t.IsLesser:return this._effectiveTarget[this._property]").concat(n,"
");e._AddLogEntry(a),e._GenerateLimitMessage(i,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}(),ee=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 W(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:[k._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},t)},t}(k),te=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 W(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:[k._GetTargetProperty(this._target),{name:"value",value:this.value}]},t)},t}(k),ie=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 W(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:[k._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:k._SerializeValueAsString(this.value)}]},t)},t}(k),re=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 W(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]&&$.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:[k._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:k._SerializeValueAsString(this.value)}]},t)},t}(k),ne=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 W(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:[k._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:k._SerializeValueAsString(this.loop)||!1}]},t)},t}(k),oe=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._target=i,n}return W(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:[k._GetTargetProperty(this._target)]},t)},t}(k),ae=function(e){function t(t,i){return void 0===t&&(t=a.ACTION_NothingTrigger),e.call(this,t,i)||this}return W(t,e),t.prototype.execute=function(){},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},t)},t}(k),se=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 W(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?($.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?u.push(n):u.push(i),p){for(var f=new Array,_=0;_0){var u=c.properties[0].value,h=null===c.properties[0].targetType?u:r.getMeshByName(u);h._meshId&&(h.mesh=r.getMeshById(h._meshId)),l={trigger:t[c.name],parameter:h}}else l=t[c.name];for(var d=0;d1)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:O.Vector3[0],referenceQuaternion:O.Quaternion[0],referenceScaling:O.Vector3[1],keyPosition:O.Vector3[2],keyQuaternion:O.Quaternion[1],keyScaling:O.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):(Ye.key=0,y=c._interpolate(u,Ye),_.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),I.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 n=this._keys,o=n.length,a=i.key;a>=0&&t=n[a+1].frame;)++a;if(i.key=a,a<0)return r?void 0:this._getKeyValue(n[0].value);if(a+1>o-1)return r?void 0:this._getKeyValue(n[o-1].value);var s=n[a],l=n[a+1];if(!r||t!==s.frame&&t!==l.frame){var c=this._getKeyValue(s.value),u=this._getKeyValue(l.value);if(s.interpolation===Ue.STEP)return l.frame>t?c:u;var h=void 0!==s.outTangent&&void 0!==l.inTangent,d=l.frame-s.frame,p=(t-s.frame)/d,f=this.getEasingFunction();switch(null!==f&&(p=f.ease(p)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var _=h?this.floatInterpolateFunctionWithTangents(c,s.outTangent*d,u,l.inTangent*d,p):this.floatInterpolateFunction(c,u,p);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return _;case e.ANIMATIONLOOPMODE_RELATIVE:return i.offsetValue*i.repeatCount+_}break;case e.ANIMATIONTYPE_QUATERNION:var m=h?this.quaternionInterpolateFunctionWithTangents(c,s.outTangent.scale(d),u,l.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,u,p);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.addInPlace(i.offsetValue.scale(i.repeatCount))}return m;case e.ANIMATIONTYPE_VECTOR3:var g=h?this.vector3InterpolateFunctionWithTangents(c,s.outTangent.scale(d),u,l.inTangent.scale(d),p):this.vector3InterpolateFunction(c,u,p);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(i.offsetValue.scale(i.repeatCount))}break;case e.ANIMATIONTYPE_VECTOR2:var v=h?this.vector2InterpolateFunctionWithTangents(c,s.outTangent.scale(d),u,l.inTangent.scale(d),p):this.vector2InterpolateFunction(c,u,p);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return v;case e.ANIMATIONLOOPMODE_RELATIVE:return v.add(i.offsetValue.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(c,u,p);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,u,p).add(i.offsetValue.scale(i.repeatCount))}break;case e.ANIMATIONTYPE_COLOR3:var y=h?this.color3InterpolateFunctionWithTangents(c,s.outTangent.scale(d),u,l.inTangent.scale(d),p):this.color3InterpolateFunction(c,u,p);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return y;case e.ANIMATIONLOOPMODE_RELATIVE:return y.add(i.offsetValue.scale(i.repeatCount))}break;case e.ANIMATIONTYPE_COLOR4:var b=h?this.color4InterpolateFunctionWithTangents(c,s.outTangent.scale(d),u,l.inTangent.scale(d),p):this.color4InterpolateFunction(c,u,p);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:case e.ANIMATIONLOOPMODE_YOYO:return b;case e.ANIMATIONLOOPMODE_RELATIVE:return b.add(i.offsetValue.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(c,u,p,i.workValue):c;case e.ANIMATIONLOOPMODE_RELATIVE:return c}}return 0}},e.prototype.matrixInterpolateFunction=function(t,i,r,n){return e.AllowMatrixDecomposeForInterpolation?n?(I.DecomposeLerpToRef(t,i,r,n),n):I.DecomposeLerp(t,i,r):n?(I.LerpToRef(t,i,r,n),n):I.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){Ye.key=0;var t=this._interpolate(e,Ye,!0);if(!t)return Ye.key===e?Ye.key:Ye.key+1;var i={frame:e,value:t.clone?t.clone():t};return this._keys.splice(Ye.key+1,0,i),Ye.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=P.FromArray(s.values),s.values.length>=8){var h=P.FromArray(s.values.slice(4,8));h.equals(P.Zero())||(l=h)}if(s.values.length>=12){var d=P.FromArray(s.values.slice(8,12));d.equals(P.Zero())||(c=d)}s.values.length>=13&&(u=s.values[12]);break;case e.ANIMATIONTYPE_MATRIX:i=I.FromArray(s.values),s.values.length>=17&&(u=s.values[16]);break;case e.ANIMATIONTYPE_COLOR3:i=B.FromArray(s.values),s.values[3]&&(l=B.FromArray(s.values[3])),s.values[4]&&(c=B.FromArray(s.values[4])),s.values[5]&&(u=s.values[5]);break;case e.ANIMATIONTYPE_COLOR4:i=U.FromArray(s.values),s.values[4]&&(l=U.FromArray(s.values[4])),s.values[5]&&(c=U.FromArray(s.values[5])),s.values[6]&&(u=U.FromArray(s.values[6]));break;case e.ANIMATIONTYPE_VECTOR3:default:i=R.FromArray(s.values),s.values[3]&&(l=R.FromArray(s.values[3])),s.values[4]&&(c=R.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[i[0]],n=1;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;if(r&&this._animationState.loopMode===Ke.ANIMATIONLOOPMODE_YOYO){var f=(d-t)/h;d=Math.abs(Math.sin(f*Math.PI))*h+t}if(this._previousElapsedTime=e,this._previousAbsoluteFrame=d,!r&&i>=t&&d>=h)l=!1,p=a._getKeyValue(this._maxValue);else if(!r&&t>=i&&d<=h)l=!1,p=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==Ke.ANIMATIONLOOPMODE_CYCLE){var _=i.toString()+t.toString();if(!this._offsetsCache[_]){this._animationState.repeatCount=0,this._animationState.loopMode=Ke.ANIMATIONLOOPMODE_CYCLE;var m=a._interpolate(t,this._animationState),g=a._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case Ke.ANIMATIONTYPE_FLOAT:this._offsetsCache[_]=g-m;break;case Ke.ANIMATIONTYPE_QUATERNION:case Ke.ANIMATIONTYPE_VECTOR3:case Ke.ANIMATIONTYPE_VECTOR2:case Ke.ANIMATIONTYPE_SIZE:case Ke.ANIMATIONTYPE_COLOR3:this._offsetsCache[_]=g.subtract(m)}this._highLimitsCache[_]=g}p=this._highLimitsCache[_],c=this._offsetsCache[_]}if(void 0===c)switch(a.dataType){case Ke.ANIMATIONTYPE_FLOAT:c=0;break;case Ke.ANIMATIONTYPE_QUATERNION:c=qe;break;case Ke.ANIMATIONTYPE_VECTOR3:c=Ze;break;case Ke.ANIMATIONTYPE_VECTOR2:c=Je;break;case Ke.ANIMATIONTYPE_SIZE:c=$e;break;case Ke.ANIMATIONTYPE_COLOR3:c=et}if(this._host&&this._host.syncRoot){var v=this._host.syncRoot;u=t+h*((v.masterFrame-v.fromFrame)/(v.toFrame-v.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 T=a._interpolate(u,this._animationState);if(this.setValue(T,o),y.length)for(b=0;b0&&u>=y[b].frame&&y[b].frame>=t||h<0&&u<=y[b].frame&&y[b].frame<=t){var E=y[b];E.isDone||(E.onlyOnce&&(y.splice(b,1),b--),E.isDone=!0,E.action(u))}return l||(this._stopped=!0),l},e}();function it(){return"undefined"!=typeof window}function rt(){return"undefined"!=typeof navigator}function nt(){return"undefined"!=typeof document}function ot(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t}var at,st={IsWindowObjectExist:it,IsNavigatorAvailable:rt,IsDocumentAvailable:nt,GetDOMTextContent:ot},lt=function(){function e(){}return Object.defineProperty(e,"Now",{get:function(){return it()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),e}(),ct=function(){function e(){}return e.FilesToLoad={},e}(),ut=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}(),ht=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),dt={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002},pt=function(e){function t(i,r,n){var o=e.call(this,i)||this;return o.errorCode=r,o.innerError=n,o.name="RuntimeError",ht._setPrototypeOf(o,t.prototype),o}return W(t,e),t}(ht),ft=function(e,t){return e.endsWith(t)},_t=function(e,t){return!!e&&e.startsWith(t)},mt=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},vt=function(e){return atob(e)},yt=function(e){for(var t=vt(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}(Rt);!function(e){e[e.GLSL=0]="GLSL",e[e.WGSL=1]="WGSL"}(at||(at={}));var Ot,Dt=/defined\s*?\((.+?)\)/g,Nt=/defined\s*?\[(.+?)\]/g,Ft=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,Lt=/__decl__/,wt=/light\{X\}.(\w*)/g,Bt=/\{X\}/g,Ut=[],Vt=function(){function e(){}return e.Initialize=function(e){e.processor&&e.processor.initializeShaders&&e.processor.initializeShaders(e.processingContext)},e.Process=function(e,t,i,r){var n,o=this;(null===(n=t.processor)||void 0===n?void 0:n.preProcessShaderCode)&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),this._ProcessIncludes(e,t,(function(e){t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e));var n=o._ProcessShaderConversion(e,t,r);i(n,e)}))},e.PreProcess=function(e,t,i,r){var n,o=this;(null===(n=t.processor)||void 0===n?void 0:n.preProcessShaderCode)&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),this._ProcessIncludes(e,t,(function(e){t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e));var n=o._ApplyPreProcessing(e,t,r);i(n,e)}))},e.Finalize=function(e,t,i){return i.processor&&i.processor.finalizeShaders?i.processor.finalizeShaders(e,t,i.processingContext):{vertexCode:e,fragmentCode:t}},e._ProcessPrecision=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._ExtractOperation=function(e){var t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new Ct(t[1].trim(),"!"===e[0]);for(var i="",r=0,n=0,o=["==","!=",">=","<=","<",">"];n-1));n++);if(-1===r)return new Ct(e);var a=e.substring(0,r).trim(),s=e.substring(r+i.length).trim();return new Mt(a,i,s)},e._BuildSubExpression=function(e){e=e.replace(Dt,"defined[$1]");for(var t=[],i=0,r=Rt.infixToPostfix(e);i=2){var o=t[t.length-1],a=t[t.length-2];t.length-=2;var s="&&"==n?new It:new Pt;"string"==typeof o&&(o=o.replace(Nt,"defined($1)")),"string"==typeof a&&(a=a.replace(Nt,"defined($1)")),s.leftOperand="string"==typeof a?this._ExtractOperation(a):a,s.rightOperand="string"==typeof o?this._ExtractOperation(o):o,t.push(s)}}var l=t[t.length-1];return"string"==typeof l&&(l=l.replace(Nt,"defined($1)")),"string"==typeof l?this._ExtractOperation(l):l},e._BuildExpression=function(e,t){var i=new At,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 Ct(n):"#ifndef"===r?new Ct(n,!0):this._BuildSubExpression(n),i},e._MoveCursorWithinIf=function(e,t,i){for(var r=e.currentLine;this._MoveCursor(e,i);){var n=(r=e.currentLine).substring(0,5).toLowerCase();if("#else"===n){var o=new Et;return t.children.push(o),void this._MoveCursor(e,o)}if("#elif"===n){var a=this._BuildExpression(r,5);t.children.push(a),i=a}}},e._MoveCursor=function(t,i){for(;t.canRead;){t.lineIndex++;var r=t.currentLine;if(r.indexOf("#")>=0){var n=e._MoveCursorRegex.exec(r);if(n&&n.length){switch(n[0]){case"#ifdef":var o=new xt;i.children.push(o);var a=this._BuildExpression(r,6);o.children.push(a),this._MoveCursorWithinIf(t,o,a);break;case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":o=new xt,i.children.push(o),a=this._BuildExpression(r,7),o.children.push(a),this._MoveCursorWithinIf(t,o,a);break;case"#if":o=new xt,a=this._BuildExpression(r,3),i.children.push(o),o.children.push(a),this._MoveCursorWithinIf(t,o,a)}continue}}var s=new Et;if(s.line=r,i.children.push(s),"#"===r[0]&&"d"===r[1]){var l=r.replace(";","").split(" ");s.additionalDefineKey=l[1],3===l.length&&(s.additionalDefineValue=l[2])}}return!1},e._EvaluatePreProcessors=function(e,t,i){var r=new Et,n=new St;return n.lineIndex=-1,n.lines=e.split("\n"),this._MoveCursor(n,r),r.process(t,i)},e._PreparePreProcessors=function(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)===at.GLSL&&(r.GL_ES="true"),r.__VERSION__=e.version,r[e.platformName]="true",t._getGlobalDefines(r),r},e._ProcessShaderConversion=function(e,t,i){var r=this._ProcessPrecision(e,t);if(!t.processor)return r;if(t.processor.shaderLanguage===at.GLSL&&-1!==r.indexOf("#version 3")&&(r=r.replace("#version 300 es",""),!t.processor.parseGLES3))return r;var n=t.defines,o=this._PreparePreProcessors(t,i);return t.processor.preProcessor&&(r=t.processor.preProcessor(r,n,t.isFragment,t.processingContext)),r=this._EvaluatePreProcessors(r,o,t),t.processor.postProcessor&&(r=t.processor.postProcessor(r,n,t.isFragment,t.processingContext,i)),i._features.needShaderCodeInlining&&(r=i.inlineShaderCode(r)),r},e._ApplyPreProcessing=function(e,t,i){var r,n,o=e,a=t.defines,s=this._PreparePreProcessors(t,i);return(null===(r=t.processor)||void 0===r?void 0:r.preProcessor)&&(o=t.processor.preProcessor(o,a,t.isFragment,t.processingContext)),o=this._EvaluatePreProcessors(o,s,t),(null===(n=t.processor)||void 0===n?void 0:n.postProcessor)&&(o=t.processor.postProcessor(o,a,t.isFragment,t.processingContext,i)),i._features.needShaderCodeInlining&&(o=i.inlineShaderCode(o)),o},e._ProcessIncludes=function(t,i,r){var n,o=this;for(Ut.length=0;null!==(n=Ft.exec(t));)Ut.push(n);for(var a=String(t),s=[t],l=!1,c=function(t){var n=t[1];if(-1!==n.indexOf("__decl__")&&(n=n.replace(Lt,""),i.supportsUniformBuffers&&(n=n.replace("Vertex","Ubo").replace("Fragment","Ubo")),n+="Declaration"),!i.includesShadersStore[n]){var a=i.shadersRepository+"ShadersInclude/"+n+".fx";return e._FileToolsLoadFile(a,(function(e){i.includesShadersStore[n]=e,o._ProcessIncludes(s.join(""),i,r)})),{value:void 0}}var c=i.includesShadersStore[n];if(t[2])for(var u=t[3].split(","),h=0;h=0||c.indexOf("#include <")>=0},u=0,h=Ut;u-1?e:kt.GetShadersRepository(this._shaderLanguage)+e,this._engine._loadFile(n+"."+t.toLowerCase()+".fx",r))}else r(window.atob(e.substr(7)));else r(e.substr(7))},Object.defineProperty(e.prototype,"vertexSourceCode",{get:function(){var e,t;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:null!==(t=null===(e=this._pipelineContext)||void 0===e?void 0:e._getVertexShaderCode())&&void 0!==t?t:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fragmentSourceCode",{get:function(){var e,t;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:null!==(t=null===(e=this._pipelineContext)||void 0===e?void 0:e._getFragmentShaderCode())&&void 0!==t?t:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertexSourceCodeBeforeMigration",{get:function(){return this._vertexSourceCodeBeforeMigration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fragmentSourceCodeBeforeMigration",{get:function(){return this._fragmentSourceCodeBeforeMigration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawVertexSourceCode",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawFragmentSourceCode",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),e.prototype._rebuildProgram=function(e,t,i,r){var n=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){r&&r(t)},this.onCompiled=function(){var e=n.getEngine().scenes;if(e)for(var t=0;t=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($.Error("Unable to compile effect:"),$.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),$.Error("Attributes: "+c.map((function(e){return" "+e}))),$.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&&($.Error("Vertex code:"),$.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&&($.Error("Fragment code:"),$.Error(p))),h&&$.Error(h),d&&$.Error(d)}$.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,$.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;n0&&parseInt(O[O.length-1])>=M)continue}for(var D=0,N=P;D1?new Qt:new Yt,this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent);var w="Babylon.js v".concat(e.Version);console.log(w+" - ".concat(this.description)),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",w)}}return Object.defineProperty(e,"NpmPackage",{get:function(){return"babylonjs@6.28.1"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"Version",{get:function(){return"6.28.1"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"description",{get:function(){var e=this.name+this.webGLVersion;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e},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,"version",{get:function(){return this._webGLVersion},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShadersRepository",{get:function(){return Gt.ShadersRepository},set:function(e){Gt.ShadersRepository=e},enumerable:!1,configurable:!0}),e.prototype._getShaderProcessor=function(e){return this._shaderProcessor},Object.defineProperty(e.prototype,"useReverseDepthBuffer",{get:function(){return this._useReverseDepthBuffer},set:function(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,this._depthCullingState.depthFunc=e?a.GEQUAL:a.LEQUAL)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frameId",{get:function(){return this._frameId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),e.prototype.getCreationOptions=function(){return this._creationOptions},Object.defineProperty(e.prototype,"_shouldUseHighPrecisionShader",{get:function(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeRenderLoops",{get:function(){return this._activeRenderLoops},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framebufferDimensionsObject",{set:function(e){this._framebufferDimensionsObject=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,a.TEXTUREFORMAT_RGBA,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,a.TEXTUREFORMAT_RGBA,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture2DArray",{get:function(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,a.TEXTUREFORMAT_RGBA,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture2DArray},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,a.TEXTUREFORMAT_RGBA,a.TEXTURETYPE_UNSIGNED_INT,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWebGPU",{get:function(){return this._isWebGPU},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shaderPlatformName",{get:function(){return this._shaderPlatformName},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"snapshotRendering",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"snapshotRenderingMode",{get:function(){return this._snapshotRenderingMode},set:function(e){this._snapshotRenderingMode=e},enumerable:!1,configurable:!0}),e.prototype.snapshotRenderingReset=function(){this.snapshotRendering=!1},e._CreateCanvas=function(e,t){if("undefined"==typeof document)return new OffscreenCanvas(e,t);var i=document.createElement("canvas");return i.width=e,i.height=t,i},e.prototype.createCanvas=function(t,i){return e._CreateCanvas(t,i)},e.prototype.createCanvasImage=function(){return document.createElement("img")},e.prototype._setupMobileChecks=function(){var e=this;navigator&&navigator.userAgent&&(this._checkForMobile=function(){var t=navigator.userAgent;e.hostInformation.isMobile=-1!==t.indexOf("Mobile")||-1!==t.indexOf("Mac")&&nt()&&"ontouchend"in document},this._checkForMobile(),it()&&window.addEventListener("resize",this._checkForMobile))},e.prototype._restoreEngineAfterContextLost=function(e){var t=this;setTimeout((function(){return j(t,void 0,void 0,(function(){var t,i,r,n,o;return Y(this,(function(a){switch(a.label){case 0:return this._dummyFramebuffer=null,t=this._depthCullingState.depthTest,i=this._depthCullingState.depthFunc,r=this._depthCullingState.depthMask,n=this._stencilState.stencilTest,[4,e()];case 1:return a.sent(),this.wipeCaches(!0),this._rebuildEffects(),null===(o=this._rebuildComputeEffects)||void 0===o||o.call(this),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=r,this._stencilState.stencilTest=n,$.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1,[2]}}))}))}),0)},e.prototype._sharedInit=function(e){this._renderingCanvas=e},e.prototype._getShaderProcessingContext=function(e){return null},e.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e1?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")),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._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=0&&(this._activeRenderLoops.splice(t,1),0==this._activeRenderLoops.length&&this._cancelFrame())},e.prototype._cancelFrame=function(){if(this._renderingQueueLaunched&&this._frameHandler){if(this._renderingQueueLaunched=!1,it()){var e=(this.getHostWindow()||window).cancelAnimationFrame;if("function"==typeof e)return e(this._frameHandler)}else if("function"==typeof cancelAnimationFrame)return cancelAnimationFrame(this._frameHandler);return clearTimeout(this._frameHandler)}},e.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;if((this._isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e){this.beginFrame();for(var t=0;t0?this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},e.prototype.getRenderingCanvas=function(){return this._renderingCanvas},e.prototype.getAudioContext=function(){return this._audioContext},e.prototype.getAudioDestination=function(){return this._audioDestination},e.prototype.getHostWindow=function(){return it()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},e.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth},e.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight},e.prototype._queueNewFrame=function(t,i){return e.QueueNewFrame(t,i)},e.prototype.runRenderLoop=function(e){var t=this;-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._boundRenderFunction=function(){return t._renderLoop()},this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},e.prototype.clear=function(t,i,r,n){var o,s;void 0===n&&(n=!1);var l=this.stencilStateComposer.useStencilGlobalOnly;this.stencilStateComposer.useStencilGlobalOnly=!0,this.applyStates(),this.stencilStateComposer.useStencilGlobalOnly=l;var c=0;if(i&&t){var u=!0;if(this._currentRenderTarget){var h=null===(o=this._currentRenderTarget.texture)||void 0===o?void 0:o.format;if(h===a.TEXTUREFORMAT_RED_INTEGER||h===a.TEXTUREFORMAT_RG_INTEGER||h===a.TEXTUREFORMAT_RGB_INTEGER||h===a.TEXTUREFORMAT_RGBA_INTEGER){var d=null===(s=this._currentRenderTarget.texture)||void 0===s?void 0:s.type;d===a.TEXTURETYPE_UNSIGNED_INTEGER||d===a.TEXTURETYPE_UNSIGNED_SHORT?(e._TempClearColorUint32[0]=255*t.r,e._TempClearColorUint32[1]=255*t.g,e._TempClearColorUint32[2]=255*t.b,e._TempClearColorUint32[3]=255*t.a,this._gl.clearBufferuiv(this._gl.COLOR,0,e._TempClearColorUint32),u=!1):(e._TempClearColorInt32[0]=255*t.r,e._TempClearColorInt32[1]=255*t.g,e._TempClearColorInt32[2]=255*t.b,e._TempClearColorInt32[3]=255*t.a,this._gl.clearBufferiv(this._gl.COLOR,0,e._TempClearColorInt32),u=!1)}}u&&(this._gl.clearColor(t.r,t.g,t.b,void 0!==t.a?t.a:1),c|=this._gl.COLOR_BUFFER_BIT)}r&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GEQUAL,this._gl.clearDepth(0)):this._gl.clearDepth(1),c|=this._gl.DEPTH_BUFFER_BIT),n&&(this._gl.clearStencil(0),c|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(c)},e.prototype._viewport=function(e,t,i,r){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&r===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=r,this._gl.viewport(e,t,i,r))},e.prototype.setViewport=function(e,t,i){var r=t||this.getRenderWidth(),n=i||this.getRenderHeight(),o=e.x||0,a=e.y||0;this._cachedViewport=e,this._viewport(o*r,a*n,r*e.width,n*e.height)},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._frameId++},e.prototype.resize=function(e){var t,i;if(void 0===e&&(e=!1),this.adaptToDeviceRatio){var r=it()&&window.devicePixelRatio||1,n=this._lastDevicePixelRatio/r;this._lastDevicePixelRatio=r,this._hardwareScalingLevel*=n}if(it()&&nt())if(this._renderingCanvas){var o=this._renderingCanvas.getBoundingClientRect?this._renderingCanvas.getBoundingClientRect():{width:this._renderingCanvas.width*this._hardwareScalingLevel,height:this._renderingCanvas.height*this._hardwareScalingLevel};t=this._renderingCanvas.clientWidth||o.width||this._renderingCanvas.width||100,i=this._renderingCanvas.clientHeight||o.height||this._renderingCanvas.height||100}else t=window.innerWidth,i=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,i=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,i/this._hardwareScalingLevel,e)},e.prototype.setSize=function(e,t,i){return void 0===i&&(i=!1),!(!this._renderingCanvas||(e|=0,t|=0,!i&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t||(this._renderingCanvas.width=e,this._renderingCanvas.height=t,0)))},e.prototype.bindFramebuffer=function(e,t,i,r,n,o,a){var s,l,c,u,h,d;void 0===t&&(t=0),void 0===o&&(o=0),void 0===a&&(a=0);var p=e;this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(p._MSAAFramebuffer?p._MSAAFramebuffer:p._framebuffer);var f=this._gl;e.isMulti||(e.is2DArray?f.framebufferTextureLayer(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,null===(s=e.texture._hardwareTexture)||void 0===s?void 0:s.underlyingResource,o,a):e.isCube?f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+t,null===(l=e.texture._hardwareTexture)||void 0===l?void 0:l.underlyingResource,o):p._currentLOD!==o&&(f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,null===(c=e.texture._hardwareTexture)||void 0===c?void 0:c.underlyingResource,o),p._currentLOD=o));var _=e._depthStencilTexture;if(_){var m=e._depthStencilTextureWithStencil?f.DEPTH_STENCIL_ATTACHMENT:f.DEPTH_ATTACHMENT;e.is2DArray?f.framebufferTextureLayer(f.FRAMEBUFFER,m,null===(u=_._hardwareTexture)||void 0===u?void 0:u.underlyingResource,o,a):e.isCube?f.framebufferTexture2D(f.FRAMEBUFFER,m,f.TEXTURE_CUBE_MAP_POSITIVE_X+t,null===(h=_._hardwareTexture)||void 0===h?void 0:h.underlyingResource,o):f.framebufferTexture2D(f.FRAMEBUFFER,m,f.TEXTURE_2D,null===(d=_._hardwareTexture)||void 0===d?void 0:d.underlyingResource,o)}this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,r):(i||(i=e.width,o&&(i/=Math.pow(2,o))),r||(r=e.height,o&&(r/=Math.pow(2,o))),this._viewport(0,0,i,r)),this.wipeCaches()},e.prototype.setState=function(e,t,i,r,n,o,a){var s,l;void 0===t&&(t=0),void 0===r&&(r=!1),void 0===a&&(a=0),(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);var c=null===(l=null!==(s=this.cullBackFaces)&&void 0!==s?s:n)||void 0===l||l?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==c||i)&&(this._depthCullingState.cullFace=c),this.setZOffset(t),this.setZOffsetUnits(a);var u=r?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==u||i)&&(this._depthCullingState.frontFace=u),this._stencilStateComposer.stencilMaterial=o},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._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},e.prototype._currentFrameBufferIsDefaultFrameBuffer=function(){return null===this._currentFramebuffer},e.prototype.generateMipmaps=function(e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)},e.prototype.unBindFramebuffer=function(e,t,i){var r;void 0===t&&(t=!1);var n=e;this._currentRenderTarget=null;var o=this._gl;if(n._MSAAFramebuffer){if(e.isMulti)return void this.unBindMultiColorAttachmentFramebuffer(e,t,i);o.bindFramebuffer(o.READ_FRAMEBUFFER,n._MSAAFramebuffer),o.bindFramebuffer(o.DRAW_FRAMEBUFFER,n._framebuffer),o.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,o.COLOR_BUFFER_BIT,o.NEAREST)}!(null===(r=e.texture)||void 0===r?void 0:r.generateMipMaps)||t||e.isCube||this.generateMipmaps(e.texture),i&&(n._MSAAFramebuffer&&this._bindUnboundFramebuffer(n._framebuffer),i()),this._bindUnboundFramebuffer(null)},e.prototype.flushFramebuffer=function(){this._gl.flush()},e.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},e.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},e.prototype.createVertexBuffer=function(e,t,i){return this._createVertexBuffer(e,this._gl.STATIC_DRAW)},e.prototype._createVertexBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error("Unable to create vertex buffer");var r=new Zt(i);return this.bindArrayBuffer(r),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),t):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,t),this._resetVertexBufferBinding(),r.references=1,r},e.prototype.createDynamicVertexBuffer=function(e,t){return this._createVertexBuffer(e,this._gl.DYNAMIC_DRAW)},e.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},e.prototype.createIndexBuffer=function(e,t,i){var r=this._gl.createBuffer(),n=new Zt(r);if(!r)throw new Error("Unable to create index buffer");this.bindIndexBuffer(n);var o=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,o,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),n.references=1,n.is32Bits=4===o.BYTES_PER_ELEMENT,n},e.prototype._normalizeIndexData=function(e){if(2===e.BYTES_PER_ELEMENT)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(var t=0;t=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)},e.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ARRAY_BUFFER)},e.prototype.bindUniformBlock=function(e,t,i){var r=e.program,n=this._gl.getUniformBlockIndex(r,t);this._gl.uniformBlockBinding(r,n,i)},e.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},e.prototype._bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)},e.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},e.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))}},e.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},e.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))))}}},e.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},e.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)},e.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)},e.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},e.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)},e.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1?"#version 300 es\n#define WEBGL2 \n":"",s=this._compileShader(t,"vertex",r,a),l=this._compileShader(i,"fragment",r,a);return this._createShaderProgram(e,s,l,n,o)},e.prototype.inlineShaderCode=function(e){return e},e.prototype.createPipelineContext=function(e){var t=new Jt;return t.engine=this,this._caps.parallelShaderCompile&&(t.isParallelCompiled=!0),t},e.prototype.createMaterialContext=function(){},e.prototype.createDrawContext=function(){},e.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");return r.attachShader(o,t),r.attachShader(o,i),r.linkProgram(o),e.context=r,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},e.prototype._finalizePipelineContext=function(e){var t=e.context,i=e.vertexShader,r=e.fragmentShader,n=e.program;if(!t.getProgramParameter(n,t.LINK_STATUS)){var o,a;if(!this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS)&&(o=this._gl.getShaderInfoLog(i)))throw e.vertexCompilationError=o,new Error("VERTEX SHADER "+o);if(!this._gl.getShaderParameter(r,this._gl.COMPILE_STATUS)&&(o=this._gl.getShaderInfoLog(r)))throw e.fragmentCompilationError=o,new Error("FRAGMENT SHADER "+o);if(a=t.getProgramInfoLog(n))throw e.programLinkError=a,new Error(a)}if(this.validateShaderPrograms&&(t.validateProgram(n),!t.getProgramParameter(n,t.VALIDATE_STATUS)&&(a=t.getProgramInfoLog(n))))throw e.programValidationError=a,new Error(a);t.deleteShader(i),t.deleteShader(r),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)},e.prototype._preparePipelineContext=function(e,t,i,r,n,o,a,s,l,c){var u=e;u.program=r?this.createRawShaderProgram(u,t,i,void 0,l):this.createShaderProgram(u,t,i,s,void 0,l),u.program.__SPECTOR_rebuildProgram=a},e.prototype._isRenderingStateCompiled=function(e){var t=e;return!(this._isDisposed||t._isDisposed||!this._gl.getProgramParameter(t.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)||(this._finalizePipelineContext(t),0))},e.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var i=e;if(i.isParallelCompiled){var r=i.onCompiled;i.onCompiled=r?function(){r(),t()}:t}else t()},e.prototype.getUniforms=function(e,t){for(var i=new Array,r=e,n=0;n1||this.isWebGPU)),(l!==a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(l!==a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(c=a.TEXTURE_NEAREST_SAMPLINGMODE),l!==a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(l=a.TEXTURETYPE_UNSIGNED_INT,$.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));var p=this._gl,f=new jt(this,r),_=e.width||e,m=e.height||e,g=e.layers||0,v=this._getSamplingParameters(c,s),y=0!==g?p.TEXTURE_2D_ARRAY:p.TEXTURE_2D,b=this._getRGBABufferInternalSizedFormat(l,u,h),T=this._getInternalFormat(u),E=this._getWebGLTextureType(l);return this._bindTextureDirectly(y,f),0!==g?(f.is2DArray=!0,p.texImage3D(y,0,b,_,m,g,0,T,E,null)):p.texImage2D(y,0,b,_,m,0,T,E,null),p.texParameteri(y,p.TEXTURE_MAG_FILTER,v.mag),p.texParameteri(y,p.TEXTURE_MIN_FILTER,v.min),p.texParameteri(y,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(y,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),s&&this._gl.generateMipmap(y),this._bindTextureDirectly(y,null),f._useSRGBBuffer=h,f.baseWidth=_,f.baseHeight=m,f.width=_,f.height=m,f.depth=g,f.isReady=!0,f.samples=d,f.generateMipMaps=s,f.samplingMode=c,f.type=l,f.format=u,f.label=o,this._internalTexturesCache.push(f),f},e.prototype._getUseSRGBBuffer=function(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU||t)},e.prototype._createTextureBase=function(t,i,r,n,o,s,l,c,u,h,d,p,f,_,m,g){var v=this;void 0===o&&(o=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===l&&(l=null),void 0===h&&(h=null),void 0===d&&(d=null),void 0===p&&(p=null),void 0===f&&(f=null);var y="data:"===(t=t||"").substr(0,5),b="blob:"===t.substr(0,5),T=y&&-1!==t.indexOf(";base64,"),E=d||new jt(this,Ot.Url);E!==d&&(E.label=t.substring(0,60));var x=t;!this._transformTextureUrl||T||d||h||(t=this._transformTextureUrl(t)),x!==t&&(E._originalUrl=x);var A=t.lastIndexOf("."),R=f||(A>-1?t.substring(A).toLowerCase():""),C=null;R.indexOf("?")>-1&&(R=R.split("?")[0]);for(var P=0,I=e._TextureLoaders;Ph||i.height>h||!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 d=new jt(m,Ot.Temp);return m._bindTextureDirectly(s.TEXTURE_2D,d,!0),s.texImage2D(s.TEXTURE_2D,0,c.internalFormat,c.format,c.type,i),m._rescaleTexture(d,o,r,c.format,(function(){m._releaseTexture(d),m._bindTextureDirectly(s.TEXTURE_2D,o,!0),a()})),!0}),l,c,u,h,d,p,_)},e.prototype._getTexImageParametersForCreateTexture=function(e,t,i){var r,n;return null==e&&(e=".jpg"!==t||i?a.TEXTUREFORMAT_RGBA:a.TEXTUREFORMAT_RGB),1===this.webGLVersion?n=r=this._getInternalFormat(e,i):(r=this._getInternalFormat(e,!1),n=this._getRGBABufferInternalSizedFormat(a.TEXTURETYPE_UNSIGNED_BYTE,e,i)),{internalFormat:n,format:r,type:this._gl.UNSIGNED_BYTE}},e._FileToolsLoadImage=function(e,t,i,r,n,o){throw ve("FileTools")},e.prototype._rescaleTexture=function(e,t,i,r,n){},e.prototype.createRawTexture=function(e,t,i,r,n,o,s,l,c,u,h){throw void 0===l&&(l=null),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=0),void 0===h&&(h=!1),ve("Engine.RawTexture")},e.prototype.createRawCubeTexture=function(e,t,i,r,n,o,a,s){throw void 0===s&&(s=null),ve("Engine.RawTexture")},e.prototype.createRawTexture3D=function(e,t,i,r,n,o,s,l,c,u){throw void 0===c&&(c=null),void 0===u&&(u=a.TEXTURETYPE_UNSIGNED_INT),ve("Engine.RawTexture")},e.prototype.createRawTexture2DArray=function(e,t,i,r,n,o,s,l,c,u){throw void 0===c&&(c=null),void 0===u&&(u=a.TEXTURETYPE_UNSIGNED_INT),ve("Engine.RawTexture")},e.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},e.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},e.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},e.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},e.prototype.updateTextureDimensions=function(e,t,i,r){void 0===r&&(r=1)},e.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)},e.prototype._setupDepthStencilTexture=function(e,t,i,r,n,o){void 0===o&&(o=1);var s=t.width||t,l=t.height||t,c=t.layers||0;e.baseWidth=s,e.baseHeight=l,e.width=s,e.height=l,e.is2DArray=c>0,e.depth=c,e.isReady=!0,e.samples=o,e.generateMipMaps=!1,e.samplingMode=r?a.TEXTURE_BILINEAR_SAMPLINGMODE:a.TEXTURE_NEAREST_SAMPLINGMODE,e.type=a.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=n;var u=this._gl,h=this._getTextureTarget(e),d=this._getSamplingParameters(e.samplingMode,!1);u.texParameteri(h,u.TEXTURE_MAG_FILTER,d.mag),u.texParameteri(h,u.TEXTURE_MIN_FILTER,d.min),u.texParameteri(h,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(h,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),this.webGLVersion>1&&(0===n?(u.texParameteri(h,u.TEXTURE_COMPARE_FUNC,a.LEQUAL),u.texParameteri(h,u.TEXTURE_COMPARE_MODE,u.NONE)):(u.texParameteri(h,u.TEXTURE_COMPARE_FUNC,n),u.texParameteri(h,u.TEXTURE_COMPARE_MODE,u.COMPARE_REF_TO_TEXTURE)))},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0);var l=this._gl,c=l.TEXTURE_2D;if(e.isCube&&(c=l.TEXTURE_CUBE_MAP_POSITIVE_X+o),e._useSRGBBuffer)switch(t){case a.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:case a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:this._caps.etc2?t=l.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case a.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:this._caps.etc2?t=l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:t=l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1}this._gl.compressedTexImage2D(c,s,t,i,r,0,n)},e.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)},e.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)},e.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)},e.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()}},e.prototype._prepareWebGLTexture=function(t,i,r,n,o,s,l,c,u){var h=this;void 0===u&&(u=a.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,p=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(n.width,d):n.width),f=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(n.height,d):n.height),_=this._gl;_&&(t._hardwareTexture?(this._bindTextureDirectly(_.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=n.width,t.baseHeight=n.height,t.width=p,t.height=f,t.isReady=!0,t.type=-1!==t.type?t.type:a.TEXTURETYPE_UNSIGNED_BYTE,t.format=-1!==t.format?t.format:".jpg"!==i||t._useSRGBBuffer?a.TEXTUREFORMAT_RGBA:a.TEXTUREFORMAT_RGB,c(p,f,n,i,t,(function(){h._prepareWebGLTextureContinuation(t,r,s,l,u)}))||this._prepareWebGLTextureContinuation(t,r,s,l,u)):r&&r.removePendingData(t))},e.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},e.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)},e.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},e.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()},e.prototype._releaseRenderTargetWrapper=function(e){var t=this._renderTargetWrapperCache.indexOf(e);-1!==t&&this._renderTargetWrapperCache.splice(t,1)},e.prototype._deleteTexture=function(e){e&&this._gl.deleteTexture(e)},e.prototype._setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},e.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 console.error(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},e.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)}},e.prototype.unbindAllTextures=function(){for(var e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},e.prototype.setTexture=function(e,t,i,r){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},e.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i&&i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},e.prototype._getTextureWrapMode=function(e){switch(e){case a.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case a.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case a.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.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===a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var s;s=r?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!i&&s&&(s._associatedChannel=e);var l=!0;this._boundTexturesCache[e]===s&&(i||this._bindSamplerUniformToChannel(s._associatedChannel,e),l=!1),this._activeChannel=e;var c=this._getTextureTarget(s);if(l&&this._bindTextureDirectly(c,s,i),s&&!s.isMultiview){if(s.isCube&&s._cachedCoordinatesMode!==t.coordinatesMode){s._cachedCoordinatesMode=t.coordinatesMode;var u=t.coordinatesMode!==a.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==a.TEXTURE_SKYBOX_MODE?a.TEXTURE_WRAP_ADDRESSMODE:a.TEXTURE_CLAMP_ADDRESSMODE;t.wrapU=u,t.wrapV=u}s._cachedWrapU!==t.wrapU&&(s._cachedWrapU=t.wrapU,this._setTextureParameterInteger(c,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),s)),s._cachedWrapV!==t.wrapV&&(s._cachedWrapV=t.wrapV,this._setTextureParameterInteger(c,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),s)),s.is3D&&s._cachedWrapR!==t.wrapR&&(s._cachedWrapR=t.wrapR,this._setTextureParameterInteger(c,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),s)),this._setAnisotropicLevel(c,s,t.anisotropicFilteringLevel)}return!0},e.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)}},e.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}},e.prototype.dispose=function(){var e,t;this._isDisposed=!0,this.stopRenderLoop(),this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.releaseEffects(),null===(e=this.releaseComputeEffects)||void 0===e||e.call(this),this.unbindAllAttributes(),this._boundUniforms={},it()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored)),window.removeEventListener("resize",this._checkForMobile)),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._renderingCanvas=null,this._currentProgram=null,this._boundRenderFunction=null,Gt.ResetCache();for(var i=0,r=this._activeRequests;i1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(a.TEXTURETYPE_FLOAT)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(a.TEXTURETYPE_HALF_FLOAT)},e.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},e.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case a.TEXTURETYPE_BYTE:return this._gl.BYTE;case a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case a.TEXTURETYPE_SHORT:return this._gl.SHORT;case a.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case a.TEXTURETYPE_INT:return this._gl.INT;case a.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case a.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},e.prototype._getInternalFormat=function(e,t){void 0===t&&(t=!1);var i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case a.TEXTUREFORMAT_ALPHA:i=this._gl.ALPHA;break;case a.TEXTUREFORMAT_LUMINANCE:i=this._gl.LUMINANCE;break;case a.TEXTUREFORMAT_LUMINANCE_ALPHA:i=this._gl.LUMINANCE_ALPHA;break;case a.TEXTUREFORMAT_RED:i=this._gl.RED;break;case a.TEXTUREFORMAT_RG:i=this._gl.RG;break;case a.TEXTUREFORMAT_RGB:i=t?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case a.TEXTUREFORMAT_RGBA:i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA}if(this._webGLVersion>1)switch(e){case a.TEXTUREFORMAT_RED_INTEGER:i=this._gl.RED_INTEGER;break;case a.TEXTUREFORMAT_RG_INTEGER:i=this._gl.RG_INTEGER;break;case a.TEXTUREFORMAT_RGB_INTEGER:i=this._gl.RGB_INTEGER;break;case a.TEXTUREFORMAT_RGBA_INTEGER:i=this._gl.RGBA_INTEGER}return i},e.prototype._getRGBABufferInternalSizedFormat=function(e,t,i){if(void 0===i&&(i=!1),1===this._webGLVersion){if(void 0!==t)switch(t){case a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case a.TEXTUREFORMAT_RGB:return i?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case a.TEXTURETYPE_BYTE:switch(t){case a.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case a.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case a.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case a.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case a.TEXTUREFORMAT_RED:return this._gl.R8;case a.TEXTUREFORMAT_RG:return this._gl.RG8;case a.TEXTUREFORMAT_RGB:return i?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case a.TEXTUREFORMAT_RGBA:return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case a.TEXTURETYPE_SHORT:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case a.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case a.TEXTURETYPE_INT:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case a.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case a.TEXTURETYPE_FLOAT:switch(t){case a.TEXTUREFORMAT_RED:return this._gl.R32F;case a.TEXTUREFORMAT_RG:return this._gl.RG32F;case a.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case a.TEXTURETYPE_HALF_FLOAT:switch(t){case a.TEXTUREFORMAT_RED:return this._gl.R16F;case a.TEXTUREFORMAT_RG:return this._gl.RG16F;case a.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case a.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(e,t){switch(void 0===t&&(t=a.TEXTUREFORMAT_RGBA),e){case a.TEXTURETYPE_FLOAT:return t===a.TEXTUREFORMAT_R?this._gl.R32F:this._gl.RGBA32F;case a.TEXTURETYPE_HALF_FLOAT:return t===a.TEXTUREFORMAT_R?this._gl.R16F:this._gl.RGBA16F}return this._gl.RGBA8},e.prototype._loadFile=function(t,i,r,n,o,a){var s=this,l=e._FileToolsLoadFile(t,i,r,n,o,a);return this._activeRequests.push(l),l.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),l},e._FileToolsLoadFile=function(e,t,i,r,n,o){throw ve("FileTools")},e.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)},Object.defineProperty(e,"IsSupportedAsync",{get:function(){return Promise.resolve(this.isSupported())},enumerable:!1,configurable:!0}),Object.defineProperty(e,"IsSupported",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),e.isSupported=function(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{var e=this._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(e,"HasMajorPerformanceCaveat",{get:function(){if(null===this._HasMajorPerformanceCaveat)try{var e=this._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}),e.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},e.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},e.NearestPOT=function(t){var i=e.CeilingPOT(t),r=e.FloorPOT(t);return i-t>t-r?r:i},e.GetExponentOfTwo=function(t,i,r){var n;switch(void 0===r&&(r=a.SCALEMODE_NEAREST),r){case a.SCALEMODE_FLOOR:n=e.FloorPOT(t);break;case a.SCALEMODE_NEAREST:n=e.NearestPOT(t);break;case a.SCALEMODE_CEILING:default:n=e.CeilingPOT(t)}return Math.min(n,i)},e.QueueNewFrame=function(e,t){if(it()){var i=(t||window).requestAnimationFrame;if("function"==typeof i)return i(e)}else if("function"==typeof requestAnimationFrame)return requestAnimationFrame(e);return setTimeout(e,16)},e.prototype.getHostDocument=function(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:nt()?document:null},e._TempClearColorUint32=new Uint32Array(4),e._TempClearColorInt32=new Int32Array(4),e.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:".*AppleWebKit.*(15.4).*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]},{key:".*(15.4).*AppleWebKit.*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]}],e._TextureLoaders=[],e.CollisionsEpsilon=.001,e._IsSupported=null,e._HasMajorPerformanceCaveat=null,e}(),ni=function(){function e(){}return e.SetImmediate=function(e){it()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},e}(),oi=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i),ai=function(e){function t(i,r){var n=e.call(this,i,dt.LoadFileError)||this;return n.name="LoadFileError",ht._setPrototypeOf(n,t.prototype),r instanceof Xe?n.request=r:n.file=r,n}return W(t,e),t}(pt),si=function(e){function t(i,r){var n=e.call(this,i,dt.RequestFileError)||this;return n.request=r,n.name="RequestFileError",ht._setPrototypeOf(n,t.prototype),n}return W(t,e),t}(pt),li=function(e){function t(i,r){var n=e.call(this,i,dt.ReadFileError)||this;return n.file=r,n.name="ReadFileError",ht._setPrototypeOf(n,t.prototype),n}return W(t,e),t}(pt),ci={DefaultRetryStrategy:ut.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:function(e){return e},ScriptBaseUrl:"",ScriptPreprocessUrl:function(e){return e}},ui=function(e){return e.replace(/#/gm,"%23")},hi=function(e,t){if((!e||0!==e.indexOf("data:"))&&ci.CorsBehavior)if("string"==typeof ci.CorsBehavior||ci.CorsBehavior instanceof String)t.crossOrigin=ci.CorsBehavior;else{var i=ci.CorsBehavior(e);i&&(t.crossOrigin=i)}},di=function(e,t,i,r,n,o){var a,s;void 0===n&&(n="");var l=!1;e instanceof ArrayBuffer||ArrayBuffer.isView(e)?"undefined"!=typeof Blob&&"undefined"!=typeof URL?(s=URL.createObjectURL(new Blob([e],{type:n})),l=!0):s="data:".concat(n,";base64,")+gt(e):e instanceof Blob?(s=URL.createObjectURL(e),l=!0):(s=ui(e),s=ci.PreprocessUrl(e));var c=S.LastCreatedEngine,u=function(t){if(i){var r=s||e.toString();i("Error while trying to load image: ".concat(0===r.indexOf("http")||r.length<=128?r:r.slice(0,128)+"..."),t)}};if("undefined"==typeof Image||null!==(a=null==c?void 0:c._features.forceBitmapOverHTMLImageElement)&&void 0!==a&&a)return fi(s,(function(r){c.createImageBitmap(new Blob([r],{type:n}),H({premultiplyAlpha:"none"},o)).then((function(e){t(e),l&&URL.revokeObjectURL(s)})).catch((function(t){i&&i("Error while trying to load image: "+e,t)}))}),void 0,r||void 0,!0,(function(e,t){u(t)})),null;var h=new Image;hi(s,h);var d=[],p=function(){d.forEach((function(e){e.target.removeEventListener(e.name,e.handler)})),d.length=0};d.push({target:h,name:"load",handler:function(){p(),t(h),l&&h.src&&URL.revokeObjectURL(h.src)}}),d.push({target:h,name:"error",handler:function(e){p(),u(e),l&&h.src&&URL.revokeObjectURL(h.src)}}),d.push({target:document,name:"securitypolicyviolation",handler:function(e){if(e.blockedURI===h.src){p();var t=new Error("CSP violation of policy ".concat(e.effectiveDirective," ").concat(e.blockedURI,". Current policy is ").concat(e.originalPolicy));S.UseFallbackTexture=!1,u(t),l&&h.src&&URL.revokeObjectURL(h.src),h.src=""}}}),d.forEach((function(e){e.target.addEventListener(e.name,e.handler)}));var f="blob:"===s.substring(0,5),_="data:"===s.substring(0,5),m=function(){f||_||!Xe.IsCustomRequestAvailable?h.src=s:fi(s,(function(e,t,i){var r=new Blob([e],{type:!n&&i?i:n}),o=URL.createObjectURL(r);l=!0,h.src=o}),void 0,r||void 0,!0,(function(e,t){u(t)}))};if(!f&&!_&&r&&r.enableTexturesOffline)r.open((function(){r&&r.loadImage(s,h)}),m);else{if(-1!==s.indexOf("file:")){var g=decodeURIComponent(s.substring(5).toLowerCase());if(ct.FilesToLoad[g]&&"undefined"!=typeof URL){try{var v=void 0;try{v=URL.createObjectURL(ct.FilesToLoad[g])}catch(e){v=URL.createObjectURL(ct.FilesToLoad[g])}h.src=v,l=!0}catch(e){h.src=""}return h}}m()}return h},pi=function(e,t,i,r,n){var o=new FileReader,a={onCompleteObservable:new u,abort:function(){return o.abort()}};return o.onloadend=function(){return a.onCompleteObservable.notifyObservers(a)},n&&(o.onerror=function(){n(new li("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},fi=function(e,t,i,r,n,o,a){if(e.name)return pi(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=ct.FilesToLoad[l];if(c)return pi(c,t,i,n,o?function(e){return o(void 0,new ai(e.message,e.file))}:void 0)}var h=vi(s),d=h.match,p=h.type;if(d){var f={onCompleteObservable:new u,abort:function(){return function(){}}};try{var _=n?yi(s):Ti(s);t(_,void 0,p)}catch(e){o?o(void 0,e):$.Error(e.message||"Failed to parse the Data URL")}return ni.SetImmediate((function(){f.onCompleteObservable.notifyObservers(f)})),f}return _i(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 ai(e.message,e.request))}:void 0,a)},_i=function(e,t,i,r,n,o,a){e=ui(e),e=ci.PreprocessUrl(e);var s=ci.BaseUrl+e,l=!1,c={onCompleteObservable:new u,abort:function(){return l=!0}},h=function(){var e,r=new Xe,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 si(t,r)):$.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&&(!it()||mi())){try{t&&t(n?r.response:r.responseText,r)}catch(e){p(e)}return}var i=ci.DefaultRetryStrategy;if(i){var a=i(s,r,c);if(-1!==a)return h(),r=new Xe,void(u=setTimeout((function(){return f(c+1)}),a))}var d=new si("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 d=function(e){e&&e.status>400?o&&o(e):h()};r.open((function(){r&&r.loadFile(ci.BaseUrl+e,(function(e){!l&&t&&t(e),c.onCompleteObservable.notifyObservers(c)}),i?function(e){!l&&i&&i(e)}:void 0,d,n)}),d)}else h();return c},mi=function(){return"undefined"!=typeof location&&"file:"===location.protocol},gi=function(e){return oi.test(e)},vi=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 yi(e){return yt(e.split(",")[1])}var bi,Ti=function(e){return vt(e.split(",")[1])};ri._FileToolsLoadImage=di,ri._FileToolsLoadFile=fi,Vt._FileToolsLoadFile=fi;var Ei=function(e,t,i,r,n,o,a,s,l,c){bi={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(bi,"DefaultRetryStrategy",{get:function(){return i.DefaultRetryStrategy},set:function(e){i.DefaultRetryStrategy=e}}),Object.defineProperty(bi,"BaseUrl",{get:function(){return i.BaseUrl},set:function(e){i.BaseUrl=e}}),Object.defineProperty(bi,"PreprocessUrl",{get:function(){return i.PreprocessUrl},set:function(e){i.PreprocessUrl=e}}),Object.defineProperty(bi,"CorsBehavior",{get:function(){return i.CorsBehavior},set:function(e){i.CorsBehavior=e}})};Ei(yi,Ti,ci,gi,mi,fi,di,pi,_i,hi);var Si=function(){function e(){}return e.Instantiate=function(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];var t=T(e);if(t)return t;$.Warn(e+" not found, you may have missed an import.");for(var i=e.split("."),r=window||this,n=0,o=i.length;ne.indexOf("/"))&&(e.indexOf("://")=t)break;if(r(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),n)},e}();S.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 Ii=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}(),Mi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return W(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){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 $.Error("Cannot add an uniform after UBO has been created.");this.addUniform(e,i),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(o=0;o0&&i.negateInPlace()}return i.normalize(),i},e.prototype.getTextureCoordinates=function(e){if(void 0===e&&(e=ji.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=A.FromArray(i,2*t[3*this.faceId]),n=A.FromArray(i,2*t[3*this.faceId+1]),o=A.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 A(r.x+n.x+o.x,r.y+n.y+o.y)},e}(),Ki=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[ji.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[ji.PositionKind]=new ji(this._scene.getEngine(),e,ji.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[ji.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 s;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 l=this._scene.getEngine(),c=0;ci._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._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=Bi.LeftClick&&i<=Bi.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=lr.DOM_DELTA_PIXEL,a.deltaX=0,a.deltaY=0,a.deltaZ=0,i){case Bi.MouseWheelX:a.deltaX=r;break;case Bi.MouseWheelY:a.deltaY=r;break;case Bi.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,Bi.Horizontal),l=n.pollInput(e,t,Bi.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,Ui.DeltaHorizontal),a.movementY=n.pollInput(e,t,Ui.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=wi.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(wi.Keyboard),r=i&&1===t.pollInput(wi.Keyboard,0,a.INPUT_ALT_KEY),n=i&&1===t.pollInput(wi.Keyboard,0,a.INPUT_CTRL_KEY),o=i&&(1===t.pollInput(wi.Keyboard,0,a.INPUT_META_KEY1)||1===t.pollInput(wi.Keyboard,0,a.INPUT_META_KEY2)||1===t.pollInput(wi.Keyboard,0,a.INPUT_META_KEY3)),s=i&&1===t.pollInput(wi.Keyboard,0,a.INPUT_SHIFT_KEY);e.altKey=r,e.ctrlKey=n,e.metaKey=o,e.shiftKey=s},e._CreateEvent=function(e){var t={preventDefault:function(){}};return t.target=e,t},e}(),ur=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=cr.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===wi.Mouse||e===wi.Touch},e.prototype.dispose=function(){this._nativeInput.dispose()},e.prototype._createDummyNativeInput=function(){return{pollInput:function(){return 0},isDeviceAvailable:function(){return!1},dispose:function(){}}},e}(),hr=Object.keys(Bi).length/2,dr=function(){function e(e,t,i,r){var n=this;this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=Ri.IsSafari(),this._usingMacOS=rt()&&/(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=rt()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Firefox"),this._isUsingChromium=rt()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Chrome"),this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=function(e){},this._gamepadDisconnectedEvent=function(e){},this._eventPrefix=Ri.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(wi[e]);e>=wi.DualShock&&e<=wi.DualSense&&this._updateDevice(e,t,i);var n=r[i];if(void 0===n)throw"Unable to find input ".concat(i," for device ").concat(wi[e]," in slot ").concat(t);return i===Bi.Move&&Ri.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 Ri.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=Bi.Move,o[Bi.Horizontal]=t.clientX,o[Bi.Vertical]=t.clientY,i===wi.Touch&&0===o[Bi.LeftClick]&&(o[Bi.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===wi.Mouse?0:t.pointerId;if(i===wi.Touch){var n=e._activeTouchIds.indexOf(-1);if(!(n>=0))return void Ri.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===wi.Touch&&e._onDeviceConnected(i,r):e._addPointerDevice(i,r,t.clientX,t.clientY);var o=e._inputs[i][r];if(o){var a=o[Bi.Horizontal],s=o[Bi.Vertical];if(i===wi.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[Bi.Horizontal]=t.clientX,o[Bi.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=Bi.Move,e._onInputChanged(i,r,l))}},this._pointerUpEvent=function(t){var i,r,n,o,a,s=e._getPointerType(t),l=s===wi.Mouse?0:e._activeTouchIds.indexOf(t.pointerId);if(s===wi.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[Bi.Horizontal],h=c[Bi.Vertical];c[Bi.Horizontal]=t.clientX,c[Bi.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=Bi.Move,e._onInputChanged(s,l,d)),d.inputIndex=t.button+2,s===wi.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===wi.Touch&&e._onDeviceDisconnected(s,l)}},this._pointerCancelEvent=function(t){var i,r,n,o;if("mouse"===t.pointerType){var a=e._inputs[wi.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=Bi.LeftClick;s<=Bi.BrowserForward;s++)if(1===a[s]){a[s]=0;var l=cr.CreateDeviceEvent(wi.Mouse,0,s,0,e,e._elementToAttachTo);e._onInputChanged(wi.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[wi.Touch][c][Bi.LeftClick]=0,l=cr.CreateDeviceEvent(wi.Touch,c,Bi.LeftClick,0,e,e._elementToAttachTo,t.pointerId),e._onInputChanged(wi.Touch,c,l),e._activeTouchIds[c]=-1,e._onDeviceDisconnected(wi.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(wi.Mouse)){var a=e._inputs[wi.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=Bi.LeftClick;s<=Bi.BrowserForward;s++)if(1===a[s]){a[s]=0;var l=cr.CreateDeviceEvent(wi.Mouse,0,s,0,e,e._elementToAttachTo);e._onInputChanged(wi.Mouse,0,l)}}if(e.isDeviceAvailable(wi.Touch)){a=e._inputs[wi.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(wi.Mouse)){var t=e._inputs[wi.Mouse][0];t[Bi.MouseWheelX]=0,t[Bi.MouseWheelY]=0,t[Bi.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")?wi.DualSense:wi.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?wi.Xbox:-1!==e.indexOf("057e")?wi.Switch:wi.Generic},e.prototype._getPointerType=function(e){var t=wi.Mouse;return("touch"===e.pointerType||"pen"===e.pointerType||e.touches)&&(t=wi.Touch),t},e}(),pr=function(){function e(e,t,i){void 0===i&&(i=0),this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new u,this._deviceInputSystem=e}return e.prototype.getInput=function(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)},e}(),fr=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(wi).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=Bi.MouseWheelX&&t.inputIndex<=Bi.MouseWheelZ?er.POINTERWHEEL:er.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,u)),e?(c=new rr(u,t,e),this._setRayOnPointerInfo(e,t)):(c=new rr(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,I.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 ir(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(n.originalPickingInfo=e,n.ray=e.ray,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=Bi.Move,this._checkPrePointerObservable(e,i,er.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,er.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 s=t.pickedMesh._getActionManagerForTrigger();if(s){if(s.hasPickTriggers)switch(s.processTrigger(a.ACTION_OnPickDownTrigger,G.CreateNew(t.pickedMesh,i,t)),i.button){case 0:s.processTrigger(a.ACTION_OnLeftPickTrigger,G.CreateNew(t.pickedMesh,i,t));break;case 1:s.processTrigger(a.ACTION_OnCenterPickTrigger,G.CreateNew(t.pickedMesh,i,t));break;case 2:s.processTrigger(a.ACTION_OnRightPickTrigger,G.CreateNew(t.pickedMesh,i,t))}s.hasSpecificTrigger(a.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(a.ACTION_OnLongPressTrigger)&&e===n._pickedDownMesh}),!1,o.cameraToUseForPointers);(null==t?void 0:t.pickedMesh)&&s&&0!==n._totalPointersPressed&&Date.now()-n._startingPointerTime>e.LongPressDelay&&!n._isPointerSwiping()&&(n._startingPointerTime=0,s.processTrigger(a.ACTION_OnLongPressTrigger,G.CreateNew(t.pickedMesh,i)))}),e.LongPressDelay)}}else for(var l=0,c=o._pointerDownStage;lthis._cameraObserverCount)){var n=er.POINTERPICK,o=new rr(n,t,e);this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(o,n)}var s=e.pickedMesh._getActionManagerForTrigger();if(s&&!i.ignore){s.processTrigger(a.ACTION_OnPickUpTrigger,G.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&s.processTrigger(a.ACTION_OnPickTrigger,G.CreateNew(e.pickedMesh,t,e));var l=e.pickedMesh._getActionManagerForTrigger(a.ACTION_OnDoublePickTrigger);i.doubleClick&&l&&l.processTrigger(a.ACTION_OnDoublePickTrigger,G.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(var c=0,u=r._pointerUpStage;ce.DoubleClickDelay&&!o._doubleClickOccured||t!==o._previousButtonPressed)&&(o._doubleClickOccured=!1,i.singleClick=!0,i.ignore=!1,o._delayedClicks[t])){var n=o._delayedClicks[t].evt,a=er.POINTERTAP,s=new rr(a,n,o._currentPickResult);l.onPointerObservable.hasObservers()&&l.onPointerObservable.hasSpecificMask(a)&&l.onPointerObservable.notifyObservers(s,a),o._delayedClicks[t]=null}},this._initClickEvent=function(t,i,r,n){var l,c,u=new mr;o._currentPickResult=null;var h=null,d=t.hasSpecificMask(er.POINTERPICK)||i.hasSpecificMask(er.POINTERPICK)||t.hasSpecificMask(er.POINTERTAP)||i.hasSpecificMask(er.POINTERTAP)||t.hasSpecificMask(er.POINTERDOUBLETAP)||i.hasSpecificMask(er.POINTERDOUBLETAP);!d&&s&&(h=o._initActionManager(h,u))&&(d=h.hasPickTriggers);var p=!1;if(d){var f=r.button;if(u.hasSwiped=o._isPointerSwiping(),!u.hasSwiped){var _=!e.ExclusiveDoubleClickMode;if(_||(_=!t.hasSpecificMask(er.POINTERDOUBLETAP)&&!i.hasSpecificMask(er.POINTERDOUBLETAP))&&!s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger)&&(h=o._initActionManager(h,u))&&(_=!h.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),_)(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay||f!==o._previousButtonPressed)&&(u.singleClick=!0,n(u,o._currentPickResult),p=!0);else{var m={evt:r,clickInfo:u,timeoutId:window.setTimeout(o._delayedSimpleClick.bind(o,f,u,n),e.DoubleClickDelay)};o._delayedClicks[f]=m}var g=t.hasSpecificMask(er.POINTERDOUBLETAP)||i.hasSpecificMask(er.POINTERDOUBLETAP);!g&&s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger)&&(h=o._initActionManager(h,u))&&(g=h.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),g&&(f===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTimee.DragMovementThreshold||Math.abs(o._startingPointerPosition.y-o._pointerY)>e.DragMovementThreshold),c.isPointerLock&&c._verifyPointerLock(),!o._checkPrePointerObservable(null,t,t.inputIndex>=Bi.MouseWheelX&&t.inputIndex<=Bi.MouseWheelZ?er.POINTERWHEEL:er.POINTERMOVE)&&(l.cameraToUseForPointers||l.activeCamera))if(l.skipPointerMovePicking)o._processPointerMove(new Yi,t);else{l.pointerMovePredicate||(l.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||l.constantlyUpdateMeshUnderPointer||null!==e._getActionManagerForTrigger())&&(!l.cameraToUseForPointers||0!=(l.cameraToUseForPointers.layerMask&e.layerMask))});var i=l._registeredActions>0||l.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 a=0;a1&&(o._isMultiTouchGesture=!0)):t&&0===e.getInput(n.inputIndex)&&(o._onPointerUp(n),0===o._totalPointersPressed&&(o._isMultiTouchGesture=!1))),r&&n.inputIndex===Bi.Move&&o._onPointerMove(n)})):e.deviceType===wi.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(a.ACTION_OnPointerOutTrigger))&&n.processTrigger(a.ACTION_OnPointerOutTrigger,G.CreateNew(o,r,{pointerId:t})),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,(n=e._getActionManagerForTrigger(a.ACTION_OnPointerOverTrigger))&&n.processTrigger(a.ACTION_OnPointerOverTrigger,G.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}(),vr=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=lt.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=lt.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=lt.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}(),yr=function(){function e(e,t,i,r){this.normal=new R(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^(0|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 R.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return R.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 i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return R.Dot(i,t)+r},e._TmpMatrix=I.Identity(),e}(),br=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new yr(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}(),Tr=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}(),Er=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}(),Sr=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"}(sr||(sr={}));var xr,Ar=function(e){function t(i,r){var n=e.call(this)||this;n._inputManager=new gr(n),n.cameraToUseForPointers=null,n._isScene=!0,n._blockEntityCollection=!1,n.autoClear=!0,n.autoClearDepthAndStencil=!0,n.clearColor=new U(.2,.2,.3,1),n.ambientColor=new B(0,0,0),n.environmentIntensity=1,n._performancePriority=sr.BackwardCompatible,n.onScenePerformancePriorityChangedObservable=new u,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=new Array,n.onDisposeObservable=new u,n._onDisposeObserver=null,n.onBeforeRenderObservable=new u,n._onBeforeRenderObserver=null,n.onAfterRenderObservable=new u,n.onAfterRenderCameraObservable=new u,n._onAfterRenderObserver=null,n.onBeforeAnimationsObservable=new u,n.onAfterAnimationsObservable=new u,n.onBeforeDrawPhaseObservable=new u,n.onAfterDrawPhaseObservable=new u,n.onReadyObservable=new u,n.onBeforeCameraRenderObservable=new u,n._onBeforeCameraRenderObserver=null,n.onAfterCameraRenderObservable=new u,n._onAfterCameraRenderObserver=null,n.onBeforeActiveMeshesEvaluationObservable=new u,n.onAfterActiveMeshesEvaluationObservable=new u,n.onBeforeParticlesRenderingObservable=new u,n.onAfterParticlesRenderingObservable=new u,n.onDataLoadedObservable=new u,n.onNewCameraAddedObservable=new u,n.onCameraRemovedObservable=new u,n.onNewLightAddedObservable=new u,n.onLightRemovedObservable=new u,n.onNewGeometryAddedObservable=new u,n.onGeometryRemovedObservable=new u,n.onNewTransformNodeAddedObservable=new u,n.onTransformNodeRemovedObservable=new u,n.onNewMeshAddedObservable=new u,n.onMeshRemovedObservable=new u,n.onNewSkeletonAddedObservable=new u,n.onSkeletonRemovedObservable=new u,n.onNewMaterialAddedObservable=new u,n.onNewMultiMaterialAddedObservable=new u,n.onMaterialRemovedObservable=new u,n.onMultiMaterialRemovedObservable=new u,n.onNewTextureAddedObservable=new u,n.onTextureRemovedObservable=new u,n.onBeforeRenderTargetsRenderObservable=new u,n.onAfterRenderTargetsRenderObservable=new u,n.onBeforeStepObservable=new u,n.onAfterStepObservable=new u,n.onActiveCameraChanged=new u,n.onActiveCamerasChanged=new u,n.onBeforeRenderingGroupObservable=new u,n.onAfterRenderingGroupObservable=new u,n.onMeshImportedObservable=new u,n.onAnimationFileImportedObservable=new u,n._registeredForLateAnimationBindings=new Mi(256),n._pointerPickingConfiguration=new Sr,n.onPrePointerObservable=new u,n.onPointerObservable=new u,n.onPreKeyboardObservable=new u,n.onKeyboardObservable=new u,n._useRightHandedSystem=!1,n._timeAccumulator=0,n._currentStepId=0,n._currentInternalStep=0,n._fogEnabled=!0,n._fogMode=t.FOGMODE_NONE,n.fogColor=new B(.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 R(0,-9.807,0),n.postProcessesEnabled=!0,n.renderTargetsEnabled=!0,n.dumpNextRenderTargets=!1,n.customRenderTargets=new Array,n.importedMeshesFiles=new Array,n.probesEnabled=!0,n._meshesForIntersections=new Mi(256),n.proceduralTexturesEnabled=!0,n._totalVertices=new vr,n._activeIndices=new vr,n._activeParticles=new vr,n._activeBones=new vr,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 Ii(256),n._processedMaterials=new Ii(256),n._renderTargets=new Mi(256),n._materialsRenderTargets=new Mi(256),n._activeParticleSystems=new Ii(256),n._activeSkeletons=new Mi(32),n._softwareSkinnedMeshes=new Mi(32),n._activeAnimatables=new Array,n._transformMatrix=I.Zero(),n.requireLightSorting=!1,n._components=[],n._serializableComponents=[],n._transientComponents=[],n._beforeCameraUpdateStage=$i.Create(),n._beforeClearStage=$i.Create(),n._beforeRenderTargetClearStage=$i.Create(),n._gatherRenderTargetsStage=$i.Create(),n._gatherActiveCameraRenderTargetsStage=$i.Create(),n._isReadyForMeshStage=$i.Create(),n._beforeEvaluateActiveMeshStage=$i.Create(),n._evaluateSubMeshStage=$i.Create(),n._preActiveMeshStage=$i.Create(),n._cameraDrawRenderTargetStage=$i.Create(),n._beforeCameraDrawStage=$i.Create(),n._beforeRenderTargetDrawStage=$i.Create(),n._beforeRenderingGroupDrawStage=$i.Create(),n._beforeRenderingMeshStage=$i.Create(),n._afterRenderingMeshStage=$i.Create(),n._afterRenderingGroupDrawStage=$i.Create(),n._afterCameraDrawStage=$i.Create(),n._afterCameraPostProcessStage=$i.Create(),n._afterRenderTargetDrawStage=$i.Create(),n._afterRenderTargetPostProcessStage=$i.Create(),n._afterRenderStage=$i.Create(),n._pointerMoveStage=$i.Create(),n._pointerDownStage=$i.Create(),n._pointerUpStage=$i.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=new Array;var o=H({useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1},r);return i=n._engine=i||S.LastCreatedEngine,o.virtual?i._virtualScenes.push(n):(S._LastCreatedScene=n,i.scenes.push(n)),n._uid=null,n._renderingManager=new Zi(n),Ki&&(n.postProcessManager=new Ki(n)),it()&&n.attachControl(),n._createUbo(),Li&&(n._imageProcessingConfiguration=new Li),n.setDefaultCandidateProviders(),o.useGeometryUniqueIdsMap&&(n._geometriesByUniqueId={}),n.useMaterialMeshMap=o.useMaterialMeshMap,n.useClonedMeshMap=o.useClonedMeshMap,r&&r.virtual||i.onNewSceneAddedObservable.notifyObservers(n),n}return W(t,e),t.DefaultMaterialFactory=function(e){throw ve("StandardMaterial")},t.CollisionCoordinatorFactory=function(){throw ve("DefaultCollisionCoordinator")},Object.defineProperty(t.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(a.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 sr.BackwardCompatible:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case sr.Intermediate:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case sr.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(a.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(a.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 gr.DragMovementThreshold},set:function(e){gr.DragMovementThreshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LongPressDelay",{get:function(){return gr.LongPressDelay},set:function(e){gr.LongPressDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DoubleClickDelay",{get:function(){return gr.DoubleClickDelay},set:function(e){gr.DoubleClickDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ExclusiveDoubleClickMode",{get:function(){return gr.ExclusiveDoubleClickMode},set:function(e){gr.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 O.Vector4[0].set(r.x,r.y,r.z,n?-1:1),e&&(i?e.setFloat3(t,O.Vector4[0].x,O.Vector4[0].y,O.Vector4[0].z):e.setVector4(t,O.Vector4[0])),O.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(a.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(a.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(a.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(a.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(a.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=v(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(a.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(a.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&&(l=!1),null===(r=this.prePassRenderer)||void 0===r||r.update(),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=lt.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?br.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=br.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 Hi(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 Tr.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&&0!=(c.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||c.alwaysSelectAsActiveMesh||c.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(c),this.activeCamera._activeMeshes.push(c),u!==c&&u._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){Ri.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===a.ACTION_OnIntersectionExitTrigger&&i._executeCurrent(G.CreateNew(t,void 0,n)),t.actionManager.hasSpecificTrigger(a.ACTION_OnIntersectionExitTrigger,(function(e){var t=e.mesh?e.mesh:e;return n===t}))&&i.trigger!==a.ACTION_OnIntersectionExitTrigger||t._intersectionsInProgress.splice(s,1))}},r=0;t.actionManager&&r0&&n0)for(var l=0;l0),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:a.RENDERPASS_MAIN,this.activeCamera=d,this._activeCamera&&this._activeCamera.cameraRigMode!==a.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var _=0,m=this._beforeClearStage;_0)for(l=0;l0);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),S._LastCreatedScene===this&&(this._engine.scenes.length>0?S._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:S._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=e}this.deltaTime=this.useConstantAnimationDeltaTime?16:(e-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=e;var t=this._activeAnimatables;if(0!==t.length){this._animationTime+=this.deltaTime;for(var i=this._animationTime,r=0;ri&&n>0&&(n*=-1),s&&this.stopAnimation(e,void 0,l),a||(a=new Ir(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 Ir(this,e,i,r,n,o,a,t,s,l)},Ar.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(P.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&&(P.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 Mr,Or=function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=Ke.ANIMATIONLOOPMODE_CYCLE};!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(Mr||(Mr={}));var Dr,Nr=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}(),Fr=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.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}(),Lr=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 A((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=Fr.BetweenTwoPoints(this.centerPoint,this.startPoint);var s=this.startAngle.degrees(),l=Fr.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),c=Fr.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?Mr.CW:Mr.CCW,this.angle=Fr.FromDegrees(this.orientation===Mr.CW?s-c:c-s)},wr=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new A(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new A(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 A(e,t),s=new A(i,r),l=new Lr(o,a,s),c=l.angle.radians()/n;l.orientation===Mr.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 A.Zero();for(var t=e*this.length(),i=0,r=0;r=i&&t<=s){var l=a.normalize(),c=t-i;return new A(o.x+l.x*c,o.y+l.y*c)}i=s}return A.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}(),Br=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:R.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:I.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=h.WithinEpsilon(Math.abs(e.y)/r,1,_)?h.WithinEpsilon(Math.abs(e.x)/r,1,_)?h.WithinEpsilon(Math.abs(e.z)/r,1,_)?R.Zero():new R(0,0,1):new R(1,0,0):new R(0,-1,0),i=R.Cross(e,n)}else i=R.Cross(e,t),R.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=I.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=P.RotationQuaternionFromAxis(r,n,i),c=P.RotationQuaternionFromAxis(a,s,o);P.Slerp(l,c,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),Ur=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=new Array,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 R(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=new Array,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 R(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=new Array,s=1/o,l=0;l<=o;l++)a.push(R.Hermite(t,i,r,n,l*s));return new e(a)},e.CreateCatmullRomSpline=function(t,i,r){var n=new Array,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}(),kr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(Vr),Gr=function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return W(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}(Vr),zr=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 W(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}(Vr),Wr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(Vr),Hr=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 W(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}(Vr),Xr=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return W(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(Vr),jr=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return W(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(Vr),Yr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.easeInCore=function(e){return e*e},t}(Vr),Kr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(Vr),Qr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(Vr),qr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(Vr),Zr=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 W(t,e),t.prototype.easeInCore=function(e){return Nr.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(Vr),Jr=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}(),$r=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}(),en=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 u,this.onAnimationLoopObservable=new u,this.onAnimationGroupLoopObservable=new u,this.onAnimationGroupEndObservable=new u,this.onAnimationGroupPauseObservable=new u,this.onAnimationGroupPlayObservable=new u,this.metadata=null,this._animationLoopFlags=[],this._scene=t||S.LastCreatedScene,this._weight=i,this._playOrder=r,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}return e.prototype.syncWithMask=function(){if(this.mask){this._numActiveAnimatables=0;for(var e=0;e0)){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"}(Dr||(Dr={}));var rn=function(){function e(e,t){void 0===t&&(t=Dr.Include),this.mode=t,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(){nn(i,r,n)}),0)):nn(i,r,n)}}function an(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 sn(e,t){var i;return an(e,nn,(function(e){return i=e}),(function(e){throw e}),t),i}function ln(e,t,i){return new Promise((function(r,n){an(e,t,r,n,i)}))}function cn(e,t){return function(){for(var i=[],r=0;r-1?($.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 I.Identity()},t.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()||(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?I.PerspectiveFovRHToRef:I.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?I.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):I.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?I.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):I.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?R.Distance(this.position,this.target):this.position.length()))+e},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?br.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=br.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),ve("Ray")},t.prototype.getForwardRayToRef=function(e,t,i,r){throw void 0===t&&(t=100),ve("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=Ri.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 I.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=Ri.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 R.ClampToRef(r,t,i,o),R.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=m.BuildArray(3,R.Zero),e}(),_n=function(){function e(e,t,i){this.center=R.Zero(),this.centerWorld=R.Zero(),this.minimum=R.Zero(),this.maximum=R.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var r=R.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*r,this._update(i||I.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{R.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e._TmpVector3[0];R.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=R.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorldgn.max||gn.min>mn.max)},bn=function(){function e(e,t,i){this._isLocked=!1,this.boundingBox=new fn(e,t,i),this.boundingSphere=new _n(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=R.Minimize(this.minimum,e),i=R.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this},e.prototype.encapsulateBoundingInfo=function(e){var t=O.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);var i=O.Vector3[0];return R.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i),this.encapsulate(i),R.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=a.MESHES_CULLINGSTRATEGY_STANDARD),!(t!==a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&t!==a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(t!==a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&t!==a.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(!_n.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!fn.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,r=e.boundingBox;return!!(yn(i.directions[0],i,r)&&yn(i.directions[1],i,r)&&yn(i.directions[2],i,r)&&yn(r.directions[0],i,r)&&yn(r.directions[1],i,r)&&yn(r.directions[2],i,r)&&yn(R.Cross(i.directions[0],r.directions[0]),i,r)&&yn(R.Cross(i.directions[0],r.directions[1]),i,r)&&yn(R.Cross(i.directions[0],r.directions[2]),i,r)&&yn(R.Cross(i.directions[1],r.directions[0]),i,r)&&yn(R.Cross(i.directions[1],r.directions[1]),i,r)&&yn(R.Cross(i.directions[1],r.directions[2]),i,r)&&yn(R.Cross(i.directions[2],r.directions[0]),i,r)&&yn(R.Cross(i.directions[2],r.directions[1]),i,r)&&yn(R.Cross(i.directions[2],r.directions[2]),i,r))},e._TmpVector3=m.BuildArray(2,R.Zero),e}(),Tn=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}(),An=function(){},Rn=function(){function e(){this.uniqueId=0,this.metadata={},this._applyTo=cn(this._applyToCoroutine.bind(this)),this.uniqueId=e._UniqueIDGenerator,e._UniqueIDGenerator++}return e.prototype.set=function(e,t){switch(e.length||$.Warn("Setting vertex data kind '".concat(t,"' with an empty array")),t){case ji.PositionKind:this.positions=e;break;case ji.NormalKind:this.normals=e;break;case ji.TangentKind:this.tangents=e;break;case ji.UVKind:this.uvs=e;break;case ji.UV2Kind:this.uvs2=e;break;case ji.UV3Kind:this.uvs3=e;break;case ji.UV4Kind:this.uvs4=e;break;case ji.UV5Kind:this.uvs5=e;break;case ji.UV6Kind:this.uvs6=e;break;case ji.ColorKind:this.colors=e;break;case ji.MatricesIndicesKind:this.matricesIndices=e;break;case ji.MatricesWeightsKind:this.matricesWeights=e;break;case ji.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case ji.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),Y(this,(function(s){switch(s.label){case 0:return this.positions?(e.setVerticesData(ji.PositionKind,this.positions,t),i?[4]:[3,2]):[3,2];case 1:s.sent(),s.label=2;case 2:return this.normals?(e.setVerticesData(ji.NormalKind,this.normals,t),i?[4]:[3,4]):[3,4];case 3:s.sent(),s.label=4;case 4:return this.tangents?(e.setVerticesData(ji.TangentKind,this.tangents,t),i?[4]:[3,6]):[3,6];case 5:s.sent(),s.label=6;case 6:return this.uvs?(e.setVerticesData(ji.UVKind,this.uvs,t),i?[4]:[3,8]):[3,8];case 7:s.sent(),s.label=8;case 8:return this.uvs2?(e.setVerticesData(ji.UV2Kind,this.uvs2,t),i?[4]:[3,10]):[3,10];case 9:s.sent(),s.label=10;case 10:return this.uvs3?(e.setVerticesData(ji.UV3Kind,this.uvs3,t),i?[4]:[3,12]):[3,12];case 11:s.sent(),s.label=12;case 12:return this.uvs4?(e.setVerticesData(ji.UV4Kind,this.uvs4,t),i?[4]:[3,14]):[3,14];case 13:s.sent(),s.label=14;case 14:return this.uvs5?(e.setVerticesData(ji.UV5Kind,this.uvs5,t),i?[4]:[3,16]):[3,16];case 15:s.sent(),s.label=16;case 16:return this.uvs6?(e.setVerticesData(ji.UV6Kind,this.uvs6,t),i?[4]:[3,18]):[3,18];case 17:s.sent(),s.label=18;case 18:return this.colors?(e.setVerticesData(ji.ColorKind,this.colors,t),i?[4]:[3,20]):[3,20];case 19:s.sent(),s.label=20;case 20:return this.matricesIndices?(e.setVerticesData(ji.MatricesIndicesKind,this.matricesIndices,t),i?[4]:[3,22]):[3,22];case 21:s.sent(),s.label=22;case 22:return this.matricesWeights?(e.setVerticesData(ji.MatricesWeightsKind,this.matricesWeights,t),i?[4]:[3,24]):[3,24];case 23:s.sent(),s.label=24;case 24:return this.matricesIndicesExtra?(e.setVerticesData(ji.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i?[4]:[3,26]):[3,26];case 25:s.sent(),s.label=26;case 26:return this.matricesWeightsExtra?(e.setVerticesData(ji.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})),R=0,C=g;R0))return[3,4];L=null!==(K=null==F?void 0:F.length)&&void 0!==K?K:0,F||(F=new Array(D)),F.length!==D&&(Array.isArray(F)?F.length=D:((w=r||F instanceof Uint32Array?new Uint32Array(D):new Uint16Array(D)).set(F),F=w),t&&t.determinant()<0&&e._FlipFaces(F,0,L)),B=c.positions?c.positions.length/3:0,U=0,V=i,Y.label=1;case 1:if(!(U0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable)),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 Rn;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(ji.PositionKind,l,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var c=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);i.setVerticesData(ji.NormalKind,c,!1)}if(s.tangetsAttrDesc&&s.tangetsAttrDesc.count>0){var u=new Float32Array(t,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);i.setVerticesData(ji.TangentKind,u,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var h=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);if(Pn.UseOpenGLOrientationForUV)for(var d=1;d0){var p=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);if(Pn.UseOpenGLOrientationForUV)for(d=1;d0){var f=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);if(Pn.UseOpenGLOrientationForUV)for(d=1;d0){var _=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);if(Pn.UseOpenGLOrientationForUV)for(d=1;d<_.length;d+=2)_[d]=1-_[d];i.setVerticesData(ji.UV4Kind,_,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var m=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);if(Pn.UseOpenGLOrientationForUV)for(d=1;d0){var g=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);if(Pn.UseOpenGLOrientationForUV)for(d=1;d0){var v=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(ji.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(ji.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(ji.MatricesIndicesExtraKind,b,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var E=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(ji.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(ji.MatricesIndicesKind,b,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(ji.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(ji.MatricesIndicesExtraKind,b,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,i),i.setVerticesData(ji.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&i.setVerticesData(ji.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(ji.MatricesIndicesKind),a=t.getVerticesData(ji.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(ji.MatricesIndicesKind,o),e.matricesWeightsExtra&&t.setVerticesData(ji.MatricesIndicesExtraKind,a)}}}},e.Parse=function(t,i,r){var n=new e(t.id,i,void 0,t.updatable);return n._loadedUniqueId=t.uniqueId,me&&me.AddTagsTo(n,t.tags),t.delayLoadingFile?(n.delayLoadState=a.DELAYLOADSTATE_NOTLOADED,n.delayLoadingFile=r+t.delayLoadingFile,n._boundingInfo=new bn(R.FromArray(t.boundingBoxMinimum),R.FromArray(t.boundingBoxMaximum)),n._delayInfo=[],t.hasUVs&&n._delayInfo.push(ji.UVKind),t.hasUVs2&&n._delayInfo.push(ji.UV2Kind),t.hasUVs3&&n._delayInfo.push(ji.UV3Kind),t.hasUVs4&&n._delayInfo.push(ji.UV4Kind),t.hasUVs5&&n._delayInfo.push(ji.UV5Kind),t.hasUVs6&&n._delayInfo.push(ji.UV6Kind),t.hasColors&&n._delayInfo.push(ji.ColorKind),t.hasMatricesIndices&&n._delayInfo.push(ji.MatricesIndicesKind),t.hasMatricesWeights&&n._delayInfo.push(ji.MatricesWeightsKind),n._delayLoadingFunction=Rn.ImportVertexData):Rn.ImportVertexData(t,n),i.pushGeometry(n,!0),n},e}(),Mn=function(){function e(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new On(e)}return e.prototype.sampleFrame=function(e){if(void 0===e&&(e=lt.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}(),On=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 Dn(e,t,i,r){switch(void 0===i&&(i=!1),e){case a.TEXTURETYPE_BYTE:var n=(ArrayBuffer,new Int8Array(t));return r&&n.set(new Int8Array(r)),n;case a.TEXTURETYPE_UNSIGNED_BYTE:var o=(ArrayBuffer,new Uint8Array(t));return r&&o.set(new Uint8Array(r)),o;case a.TEXTURETYPE_SHORT:var s=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(i?t/2:t);return r&&s.set(new Int16Array(r)),s;case a.TEXTURETYPE_UNSIGNED_SHORT:case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:case a.TEXTURETYPE_HALF_FLOAT:var l=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(i?t/2:t);return r&&l.set(new Uint16Array(r)),l;case a.TEXTURETYPE_INT:var c=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(i?t/4:t);return r&&c.set(new Int32Array(r)),c;case a.TEXTURETYPE_UNSIGNED_INTEGER:case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:case a.TEXTURETYPE_UNSIGNED_INT_24_8:case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:case a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:var u=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(i?t/4:t);return r&&u.set(new Uint32Array(r)),u;case a.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}ri.prototype.setAlphaConstants=function(e,t,i,r){this._alphaState.setAlphaBlendConstants(e,t,i,r)},ri.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case a.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case a.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 a.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 a.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 a.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.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 a.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.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 a.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 a.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 a.ALPHA_ONEONE_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.ALPHA_ALPHATOCOLOR:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case a.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 a.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 a.ALPHA_ONEONE_ONEZERO:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case a.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 a.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===a.ALPHA_DISABLE),this._alphaMode=e}else if(!t){var i=e===a.ALPHA_DISABLE;this.depthCullingState.depthMask!==i&&(this.depthCullingState.depthMask=i)}},ri.prototype.getAlphaMode=function(){return this._alphaMode},ri.prototype.setAlphaEquation=function(e){if(this._alphaEquation!==e){switch(e){case a.ALPHA_EQUATION_ADD:this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_ADD,a.GL_ALPHA_EQUATION_ADD);break;case a.ALPHA_EQUATION_SUBSTRACT:this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_SUBTRACT,a.GL_ALPHA_EQUATION_SUBTRACT);break;case a.ALPHA_EQUATION_REVERSE_SUBTRACT:this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT,a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT);break;case a.ALPHA_EQUATION_MAX:this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MAX,a.GL_ALPHA_EQUATION_MAX);break;case a.ALPHA_EQUATION_MIN:this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MIN,a.GL_ALPHA_EQUATION_MIN);break;case a.ALPHA_EQUATION_DARKEN:this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MIN,a.GL_ALPHA_EQUATION_ADD)}this._alphaEquation=e}},ri.prototype.getAlphaEquation=function(){return this._alphaEquation},ri.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=Dn(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},ri.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))},ri.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()},ri.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()};var Nn=function(e){function t(i,r,n,o){void 0===o&&(o=!1);var s=e.call(this,i,r,n,o)||this;if(s.enableOfflineSupport=!1,s.disableManifestCheck=!1,s.disableContextMenu=!0,s.scenes=new Array,s._virtualScenes=new Array,s.onNewSceneAddedObservable=new u,s.postProcesses=new Array,s.isPointerLock=!1,s.onResizeObservable=new u,s.onCanvasBlurObservable=new u,s.onCanvasFocusObservable=new u,s.onCanvasPointerOutObservable=new u,s.onBeginFrameObservable=new u,s.customAnimationFrameRequester=null,s.onEndFrameObservable=new u,s.onBeforeShaderCompilationObservable=new u,s.onAfterShaderCompilationObservable=new u,s._deterministicLockstep=!1,s._lockstepMaxSteps=4,s._timeStep=1/60,s._fps=60,s._deltaTime=0,s._drawCalls=new vr,s.canvasTabIndex=1,s.disablePerformanceMonitorInBackground=!1,s._performanceMonitor=new Mn,s._compatibilityMode=!0,s.currentRenderPassId=a.RENDERPASS_MAIN,s._renderPassNames=["main"],t.Instances.push(s),!i)return s;if(s._features.supportRenderPasses=!0,n=s._creationOptions,i.getContext){var l=i;s._sharedInit(l)}return s}return W(t,e),Object.defineProperty(t,"NpmPackage",{get:function(){return ri.NpmPackage},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Version",{get:function(){return ri.Version},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Instances",{get:function(){return S.Instances},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedEngine",{get:function(){return S.LastCreatedEngine},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedScene",{get:function(){return S.LastCreatedScene},enumerable:!1,configurable:!0}),t.prototype._createImageBitmapFromSource=function(e,t){var i=this;return new Promise((function(r,n){var o=new Image;o.onload=function(){o.decode().then((function(){i.createImageBitmap(o,t).then((function(e){r(e)}))}))},o.onerror=function(){n("Error loading image ".concat(o.src))},o.src=e}))},t.prototype.createImageBitmap=function(e,t){return createImageBitmap(e,t)},t.prototype.resizeImageBitmap=function(e,t,i){var r=this.createCanvas(t,i).getContext("2d");if(!r)throw new Error("Unable to get 2d context for resizeImageBitmap");return r.drawImage(e,0,0),r.getImageData(0,0,t,i).data},t.MarkAllMaterialsAsDirty=function(e,i){for(var r=0;r0?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()):this._renderingQueueLaunched=!1},t.prototype._renderViews=function(){return!1},t.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},t.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&t._RequestFullscreen(this._renderingCanvas))},t.prototype.exitFullscreen=function(){this.isFullscreen&&t._ExitFullscreen()},t.prototype.enterPointerlock=function(){this._renderingCanvas&&t._RequestPointerlock(this._renderingCanvas)},t.prototype.exitPointerlock=function(){t._ExitPointerlock()},t.prototype.beginFrame=function(){this._measureFps(),this.onBeginFrameObservable.notifyObservers(this),e.prototype.beginFrame.call(this)},t.prototype.endFrame=function(){e.prototype.endFrame.call(this),this.onEndFrameObservable.notifyObservers(this)},t.prototype.setSize=function(t,i,r){if(void 0===r&&(r=!1),!this._renderingCanvas)return!1;if(!e.prototype.setSize.call(this,t,i,r))return!1;if(this.scenes){for(var n=0;n1&&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.getRenderPassNames=function(){return this._renderPassNames},t.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]},t.prototype.createRenderPassId=function(e){var i=++t._RenderPassIdCounter;return this._renderPassNames[i]=null!=e?e:"NONAME",i},t.prototype.releaseRenderPassId=function(e){this._renderPassNames[e]=void 0;for(var t=0;t=0&&S.Instances.splice(r,1),t.Instances.length||S.OnEnginesDisposedObservable.notifyObservers(this),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},t.prototype._disableTouchAction=function(){this._renderingCanvas&&this._renderingCanvas.setAttribute&&(this._renderingCanvas.setAttribute("touch-action","none"),this._renderingCanvas.style.touchAction="none",this._renderingCanvas.style.webkitTapHighlightColor="transparent")},t.prototype.displayLoadingUI=function(){if(it()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},t.prototype.hideLoadingUI=function(){if(it()){var e=this._loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(t.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=t.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!1,configurable:!0}),t.prototype.createVideoElement=function(e){return document.createElement("video")},t._RequestPointerlock=function(e){if(e.requestPointerLock){var t=e.requestPointerLock();t instanceof Promise?t.then((function(){e.focus()})).catch((function(){})):e.focus()}},t._ExitPointerlock=function(){document.exitPointerLock&&document.exitPointerLock()},t._RequestFullscreen=function(e){var t=e.requestFullscreen||e.webkitRequestFullscreen;t&&t.call(e)},t._ExitFullscreen=function(){var e=document;document.exitFullscreen?document.exitFullscreen():e.webkitCancelFullScreen&&e.webkitCancelFullScreen()},t.prototype.getFontOffset=function(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}},t.ALPHA_DISABLE=a.ALPHA_DISABLE,t.ALPHA_ADD=a.ALPHA_ADD,t.ALPHA_COMBINE=a.ALPHA_COMBINE,t.ALPHA_SUBTRACT=a.ALPHA_SUBTRACT,t.ALPHA_MULTIPLY=a.ALPHA_MULTIPLY,t.ALPHA_MAXIMIZED=a.ALPHA_MAXIMIZED,t.ALPHA_ONEONE=a.ALPHA_ONEONE,t.ALPHA_PREMULTIPLIED=a.ALPHA_PREMULTIPLIED,t.ALPHA_PREMULTIPLIED_PORTERDUFF=a.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHA_INTERPOLATE=a.ALPHA_INTERPOLATE,t.ALPHA_SCREENMODE=a.ALPHA_SCREENMODE,t.DELAYLOADSTATE_NONE=a.DELAYLOADSTATE_NONE,t.DELAYLOADSTATE_LOADED=a.DELAYLOADSTATE_LOADED,t.DELAYLOADSTATE_LOADING=a.DELAYLOADSTATE_LOADING,t.DELAYLOADSTATE_NOTLOADED=a.DELAYLOADSTATE_NOTLOADED,t.NEVER=a.NEVER,t.ALWAYS=a.ALWAYS,t.LESS=a.LESS,t.EQUAL=a.EQUAL,t.LEQUAL=a.LEQUAL,t.GREATER=a.GREATER,t.GEQUAL=a.GEQUAL,t.NOTEQUAL=a.NOTEQUAL,t.KEEP=a.KEEP,t.REPLACE=a.REPLACE,t.INCR=a.INCR,t.DECR=a.DECR,t.INVERT=a.INVERT,t.INCR_WRAP=a.INCR_WRAP,t.DECR_WRAP=a.DECR_WRAP,t.TEXTURE_CLAMP_ADDRESSMODE=a.TEXTURE_CLAMP_ADDRESSMODE,t.TEXTURE_WRAP_ADDRESSMODE=a.TEXTURE_WRAP_ADDRESSMODE,t.TEXTURE_MIRROR_ADDRESSMODE=a.TEXTURE_MIRROR_ADDRESSMODE,t.TEXTUREFORMAT_ALPHA=a.TEXTUREFORMAT_ALPHA,t.TEXTUREFORMAT_LUMINANCE=a.TEXTUREFORMAT_LUMINANCE,t.TEXTUREFORMAT_LUMINANCE_ALPHA=a.TEXTUREFORMAT_LUMINANCE_ALPHA,t.TEXTUREFORMAT_RGB=a.TEXTUREFORMAT_RGB,t.TEXTUREFORMAT_RGBA=a.TEXTUREFORMAT_RGBA,t.TEXTUREFORMAT_RED=a.TEXTUREFORMAT_RED,t.TEXTUREFORMAT_R=a.TEXTUREFORMAT_R,t.TEXTUREFORMAT_RG=a.TEXTUREFORMAT_RG,t.TEXTUREFORMAT_RED_INTEGER=a.TEXTUREFORMAT_RED_INTEGER,t.TEXTUREFORMAT_R_INTEGER=a.TEXTUREFORMAT_R_INTEGER,t.TEXTUREFORMAT_RG_INTEGER=a.TEXTUREFORMAT_RG_INTEGER,t.TEXTUREFORMAT_RGB_INTEGER=a.TEXTUREFORMAT_RGB_INTEGER,t.TEXTUREFORMAT_RGBA_INTEGER=a.TEXTUREFORMAT_RGBA_INTEGER,t.TEXTURETYPE_UNSIGNED_BYTE=a.TEXTURETYPE_UNSIGNED_BYTE,t.TEXTURETYPE_UNSIGNED_INT=a.TEXTURETYPE_UNSIGNED_INT,t.TEXTURETYPE_FLOAT=a.TEXTURETYPE_FLOAT,t.TEXTURETYPE_HALF_FLOAT=a.TEXTURETYPE_HALF_FLOAT,t.TEXTURETYPE_BYTE=a.TEXTURETYPE_BYTE,t.TEXTURETYPE_SHORT=a.TEXTURETYPE_SHORT,t.TEXTURETYPE_UNSIGNED_SHORT=a.TEXTURETYPE_UNSIGNED_SHORT,t.TEXTURETYPE_INT=a.TEXTURETYPE_INT,t.TEXTURETYPE_UNSIGNED_INTEGER=a.TEXTURETYPE_UNSIGNED_INTEGER,t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,t.TEXTURETYPE_UNSIGNED_INT_24_8=a.TEXTURETYPE_UNSIGNED_INT_24_8,t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,t.TEXTURE_NEAREST_SAMPLINGMODE=a.TEXTURE_NEAREST_SAMPLINGMODE,t.TEXTURE_BILINEAR_SAMPLINGMODE=a.TEXTURE_BILINEAR_SAMPLINGMODE,t.TEXTURE_TRILINEAR_SAMPLINGMODE=a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.TEXTURE_NEAREST_NEAREST_MIPLINEAR=a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR_MIPNEAREST=a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TEXTURE_LINEAR_LINEAR_MIPLINEAR=a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_NEAREST_MIPNEAREST=a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPNEAREST=a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPLINEAR=a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_LINEAR=a.TEXTURE_NEAREST_LINEAR,t.TEXTURE_NEAREST_NEAREST=a.TEXTURE_NEAREST_NEAREST,t.TEXTURE_LINEAR_NEAREST_MIPNEAREST=a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.TEXTURE_LINEAR_NEAREST_MIPLINEAR=a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR=a.TEXTURE_LINEAR_LINEAR,t.TEXTURE_LINEAR_NEAREST=a.TEXTURE_LINEAR_NEAREST,t.TEXTURE_EXPLICIT_MODE=a.TEXTURE_EXPLICIT_MODE,t.TEXTURE_SPHERICAL_MODE=a.TEXTURE_SPHERICAL_MODE,t.TEXTURE_PLANAR_MODE=a.TEXTURE_PLANAR_MODE,t.TEXTURE_CUBIC_MODE=a.TEXTURE_CUBIC_MODE,t.TEXTURE_PROJECTION_MODE=a.TEXTURE_PROJECTION_MODE,t.TEXTURE_SKYBOX_MODE=a.TEXTURE_SKYBOX_MODE,t.TEXTURE_INVCUBIC_MODE=a.TEXTURE_INVCUBIC_MODE,t.TEXTURE_EQUIRECTANGULAR_MODE=a.TEXTURE_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.SCALEMODE_FLOOR=a.SCALEMODE_FLOOR,t.SCALEMODE_NEAREST=a.SCALEMODE_NEAREST,t.SCALEMODE_CEILING=a.SCALEMODE_CEILING,t._RescalePostProcessFactory=null,t._RenderPassIdCounter=0,t}(ri),Fn=I.Compose(R.One(),P.FromEulerAngles(0,Math.PI,0),R.Zero()),Ln=function(e){function t(i,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=e.call(this,i,r)||this;return o._forward=new R(0,0,1),o._up=new R(0,1,0),o._right=new R(1,0,0),o._position=R.Zero(),o._rotation=R.Zero(),o._rotationQuaternion=null,o._scaling=R.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=I.Zero(),o._usePivotMatrix=!1,o._absolutePosition=R.Zero(),o._absoluteScaling=R.Zero(),o._absoluteRotationQuaternion=P.Identity(),o._pivotMatrix=I.Identity(),o._postMultiplyPivotMatrix=!1,o._isWorldMatrixFrozen=!1,o._indexInSceneTransformNodesArray=-1,o.onAfterWorldMatrixUpdateObservable=new u,o._nonUniformScaling=!1,n&&o.getScene().addTransformNode(o),o}return W(t,e),Object.defineProperty(t.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=0!=(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},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 R.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 R.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return R.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=I.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=I.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);nNn.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 Hi(n.getScene().getEngine(),void 0,void 0,i,!n.getScene().getEngine().isWebGPU),n._buildUniformLayout(),r.performancePriority){case sr.Aggressive:n.doNotSyncBoundingInfo=!0;case sr.Intermediate:n.alwaysSelectAsActiveMesh=!0,n.isPickable=!1}return n}return W(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return Ln.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return Ln.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return Ln.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return Ln.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return Ln.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return Ln.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!==Ln.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;t0){var u=l.getPositions();u&&(i[a]+=(u[a]-i[a])*c)}}if(n++,r===ji.PositionKind&&this._positions&&3===n){n=0;var h=3*o;this._positions[o++].copyFromFloats(i[h],i[h+1],i[h+2])}}if(i&&e&&this.skeleton){var d=this.getVerticesData(ji.MatricesIndicesKind),p=this.getVerticesData(ji.MatricesWeightsKind);if(p&&d){var f=this.numBoneInfluencers>4,_=f?this.getVerticesData(ji.MatricesIndicesExtraKind):null,m=f?this.getVerticesData(ji.MatricesWeightsExtraKind):null,g=this.skeleton.getTransformMatrices(this),v=O.Vector3[0],y=O.Matrix[0],b=O.Matrix[1],T=0;for(h=0;h0&&(I.FromFloat32ArrayToRefScaled(g,Math.floor(16*d[T+E]),S,b),y.addToSelf(b));if(f)for(E=0;E<4;E++)(S=m[T+E])>0&&(I.FromFloat32ArrayToRefScaled(g,Math.floor(16*_[T+E]),S,b),y.addToSelf(b));r===ji.NormalKind?R.TransformNormalFromFloatsToRef(i[h],i[h+1],i[h+2],y,v):R.TransformCoordinatesFromFloatsToRef(i[h],i[h+1],i[h+2],y,v),v.toArray(i,h),r===ji.PositionKind&&this._positions&&this._positions[h/3].copyFrom(v)}}}return i},t.prototype.getNormalsData=function(e,t){return void 0===e&&(e=!1),void 0===t&&(t=!1),this._getData(e,t,null,ji.NormalKind)},t.prototype.getPositionData=function(e,t,i){return void 0===e&&(e=!1),void 0===t&&(t=!1),this._getData(e,t,i,ji.PositionKind)},t.prototype._getPositionData=function(e,t){var i,r=this.getVerticesData(ji.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=O.Matrix[0],i=O.Matrix[1];return I.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 s=new Yi,l=this.getClassName(),c="InstancedLinesMesh"===l||"LinesMesh"===l||"GreasedLineMesh"===l?this.intersectionThreshold:0,u=this.getBoundingInfo();if(!this.subMeshes)return s;if(!(o||e.intersectsSphere(u.boundingSphere,c)&&e.intersectsBox(u.boundingBox,c)))return s;if(r)return s.hit=!o,s.pickedMesh=o?null:this,s.distance=o?0:R.Distance(e.origin,u.boundingSphere.center),s.subMeshId=0,s;if(!this._generatePointsArray())return s;for(var h=null,d=this._scene.getIntersectingSubMeshCandidates(this,e),p=d.length,f=!1,_=0;_1)||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:R.Zero()}e.depthSortedFacets=[];for(var l=0;l_?n.maximum.x-n.minimum.x:_,e.bbSize.y=n.maximum.y-n.minimum.y>_?n.maximum.y-n.minimum.y:_,e.bbSize.z=n.maximum.z-n.minimum.z>_?n.maximum.z-n.minimum.z:_;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),R.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,r&&Rn.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=O.Matrix[5];a.invertToRef(s);var l=O.Vector3[8];R.TransformCoordinatesFromFloatsToRef(e,t,i,s,l);var c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,r,n,o);return r&&R.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,t.NUM_MORPH_INFLUENCERS=i.numInfluencers,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)},e.PrepareDefinesForBakedVertexAnimation=function(e,t){var i=e.bakedVertexAnimationManager;t.BAKED_VERTEX_ANIMATION_TEXTURE=!(!i||!i.isEnabled)},e.PrepareDefinesForAttributes=function(e,t,i,r,n,o,s){if(void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===s&&(s=!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(ji.NormalKind),t._needNormals&&e.isVerticesDataPresent(ji.TangentKind)&&(t.TANGENT=!0);for(var l=1;l<=a.MAX_SUPPORTED_UV_SETS;++l)t["UV"+l]=!!t._needUVs&&e.isVerticesDataPresent("uv".concat(1===l?"":l));if(i){var c=e.useVertexColors&&e.isVerticesDataPresent(ji.ColorKind);t.VERTEXCOLOR=c,t.VERTEXALPHA=e.hasVertexAlpha&&c&&o}return e.isVerticesDataPresent(ji.ColorInstanceKind)&&(e.hasInstances||e.hasThinInstances)&&(t.INSTANCESCOLOR=!0),r&&this.PrepareDefinesForBones(e,t),n&&this.PrepareDefinesForMorphTargets(e,t),s&&this.PrepareDefinesForBakedVertexAnimation(e,t),!0},e.PrepareDefinesForMultiview=function(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()}},e.PrepareDefinesForOIT=function(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()},e.PrepareDefinesForPrePass=function(e,t,i){var r=t.PREPASS;if(t._arePrePassDirty){var n=[{type:a.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:a.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:a.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:a.PREPASS_DEPTH_TEXTURE_TYPE,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:a.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;o0&&(a.shadowEnabled=!0,l.prepareDefines(n,r))}}i.lightmapMode!=Er.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,n["LIGHTMAPEXCLUDED"+r]=!0,n["LIGHTMAPNOSPECULAR"+r]=i.lightmapMode==Er.LIGHTMAP_SHADOWSONLY):(n["LIGHTMAPEXCLUDED"+r]=!1,n["LIGHTMAPNOSPECULAR"+r]=!1)},e.PrepareDefinesForLights=function(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&&(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++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,i){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=i,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,i){var r=i.NUM_MORPH_INFLUENCERS;if(r>0&&S.LastCreatedEngine){var n=S.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&&$.Error("Cannot add more vertex attributes for mesh "+t.name)}},e.PrepareAttributesForBakedVertexAnimation=function(e,t,i){i.BAKED_VERTEX_ANIMATION_TEXTURE&&i.INSTANCES&&e.push("bakedVertexAnimationSettingsInstanced")},e.PrepareAttributesForBones=function(e,t,i,r){i.NUM_BONE_INFLUENCERS>0&&(r.addCPUSkinningFallback(0,t),e.push(ji.MatricesIndicesKind),e.push(ji.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(e.push(ji.MatricesIndicesExtraKind),e.push(ji.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&this.PushAttributesForInstances(e,!!t.PREPASS_VELOCITY),t.INSTANCESCOLOR&&e.push(ji.ColorInstanceKind)},e.PushAttributesForInstances=function(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"))},e.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},e.BindLight=function(e,t,i,r,n,o){void 0===o&&(o=!0),e._bindLight(t,i,r,n,o)},e.BindLights=function(e,t,i,r,n){void 0===n&&(n=4);for(var o=Math.min(t.lightSources.length,n),a=0;a-1){var o=n.getTransformMatrixTexture(t);i.setTexture("boneSampler",o),i.setFloat("boneTextureWidth",4*(n.bones.length+1))}else{var s=n.getTransformMatrices(t);s&&(i.setMatrices("mBones",s),r&&t.getScene().prePassRenderer&&t.getScene().prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(r.previousBones[t.uniqueId]||(r.previousBones[t.uniqueId]=s.slice()),i.setMatrices("mPreviousBones",r.previousBones[t.uniqueId]),e._CopyBonesTransformationMatrices(s,r.previousBones[t.uniqueId])))}}},e._CopyBonesTransformationMatrices=function(e,t){return t.set(e),t},e.BindMorphTargetParameters=function(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)},e.BindLogDepth=function(e,t,i){if(!e||e.LOGARITHMICDEPTH||e.indexOf&&e.indexOf("LOGARITHMICDEPTH")>=0){var r=i.activeCamera;r.mode===dn.ORTHOGRAPHIC_CAMERA&&$.Error("Logarithmic depth is not compatible with orthographic cameras!",20),t.setFloat("logarithmicDepthConstant",2/(Math.log(r.maxZ+1)/Math.LN2))}},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._TempFogColor=B.Black(),e}(),Yn=function(){function e(){this.reset()}return e.prototype.reset=function(){this.enabled=!1,this.mask=255,this.func=a.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=a.KEEP,this.opDepthFail=a.KEEP,this.opStencilDepthPass=a.REPLACE},Object.defineProperty(e.prototype,"func",{get:function(){return this._func},set:function(e){this._func=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"funcRef",{get:function(){return this._funcRef},set:function(e){this._funcRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"funcMask",{get:function(){return this._funcMask},set:function(e){this._funcMask=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"opStencilFail",{get:function(){return this._opStencilFail},set:function(e){this._opStencilFail=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"opDepthFail",{get:function(){return this._opDepthFail},set:function(e){this._opDepthFail=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"opStencilDepthPass",{get:function(){return this._opStencilDepthPass},set:function(e){this._opStencilDepthPass=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled=e},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"MaterialStencilState"},e.prototype.copyTo=function(e){Ve.Clone((function(){return e}),this)},e.prototype.serialize=function(){return Ve.Serialize(this)},e.prototype.parse=function(e,t,i){var r=this;Ve.Parse((function(){return r}),e,t,i)},X([Ae()],e.prototype,"func",null),X([Ae()],e.prototype,"funcRef",null),X([Ae()],e.prototype,"funcMask",null),X([Ae()],e.prototype,"opStencilFail",null),X([Ae()],e.prototype,"opDepthFail",null),X([Ae()],e.prototype,"opStencilDepthPass",null),X([Ae()],e.prototype,"mask",null),X([Ae()],e.prototype,"enabled",null),e}();!function(e){e[e.Created=1]="Created",e[e.Disposed=2]="Disposed",e[e.GetDefineNames=4]="GetDefineNames",e[e.PrepareUniformBuffer=8]="PrepareUniformBuffer",e[e.IsReadyForSubMesh=16]="IsReadyForSubMesh",e[e.PrepareDefines=32]="PrepareDefines",e[e.BindForSubMesh=64]="BindForSubMesh",e[e.PrepareEffect=128]="PrepareEffect",e[e.GetAnimatables=256]="GetAnimatables",e[e.GetActiveTextures=512]="GetActiveTextures",e[e.HasTexture=1024]="HasTexture",e[e.FillRenderTargetTextures=2048]="FillRenderTargetTextures",e[e.HasRenderTargetTextures=4096]="HasRenderTargetTextures",e[e.HardBindForSubMesh=8192]="HardBindForSubMesh"}(Xn||(Xn={}));var Kn=function(){function e(t,i,r){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new u,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=a.ALPHA_COMBINE,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this.zOffsetUnits=0,this.stencil=new Yn,this._useUBO=!1,this._fillMode=e.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=function(){},this._callbackPluginEventIsReadyForSubMesh=function(){},this._callbackPluginEventPrepareDefines=function(){},this._callbackPluginEventPrepareDefinesBeforeAttributes=function(){},this._callbackPluginEventHardBindForSubMesh=function(){},this._callbackPluginEventBindForSubMesh=function(){},this._callbackPluginEventHasRenderTargetTextures=function(){},this._callbackPluginEventFillRenderTargetTextures=function(){},this._forceAlphaTest=!1,this._transparencyMode=null,this.name=t;var n=i||S.LastCreatedScene;n&&(this._scene=n,this._dirtyCallbacks={},this._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[a.MATERIAL_LightDirtyFlag]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[a.MATERIAL_FresnelDirtyFlag]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[a.MATERIAL_AttributesDirtyFlag]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[a.MATERIAL_PrePassDirtyFlag]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[a.MATERIAL_AllDirtyFlag]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=t||Ri.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new ei(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._scene.useRightHandedSystem?this.sideOrientation=e.ClockWiseSideOrientation:this.sideOrientation=e.CounterClockWiseSideOrientation,this._uniformBuffer=new Hi(this._scene.getEngine(),void 0,void 0,t),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,r||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),e.OnEventObservable.notifyObservers(this,Xn.Created))}return Object.defineProperty(e.prototype,"canRenderToMRT",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){if(this._alpha!==t){var i=this._alpha;this._alpha=t,1!==i&&1!==t||this.markAsDirty(e.MiscDirtyFlag+e.PrePassDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(t){this._backFaceCulling!==t&&(this._backFaceCulling=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cullBackFaces",{get:function(){return this._cullBackFaces},set:function(t){this._cullBackFaces!==t&&(this._cullBackFaces=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blockDirtyMechanism",{get:function(){return this._blockDirtyMechanism},set:function(e){this._blockDirtyMechanism!==e&&(this._blockDirtyMechanism=e,e||this.markDirty())},enumerable:!1,configurable:!0}),e.prototype.atomicMaterialsUpdate=function(e){this.blockDirtyMechanism=!0;try{e(this)}finally{this.blockDirtyMechanism=!1}},Object.defineProperty(e.prototype,"hasRenderTargetTextures",{get:function(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures},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,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new u),this._onBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new u),this._onUnBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onEffectCreatedObservable",{get:function(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new u),this._onEffectCreatedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(t){this._alphaMode!==t&&(this._alphaMode=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPrePassCapable",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wireframe",{get:function(){switch(this._fillMode){case e.WireFrameFillMode:case e.LineListDrawMode:case e.LineLoopDrawMode:case e.LineStripDrawMode:return!0}return this._scene.forceWireframe},set:function(t){this.fillMode=t?e.WireFrameFillMode:e.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pointsCloud",{get:function(){switch(this._fillMode){case e.PointFillMode:case e.PointListDrawMode:return!0}return this._scene.forcePointsCloud},set:function(t){this.fillMode=t?e.PointFillMode:e.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fillMode",{get:function(){return this._fillMode},set:function(t){this._fillMode!==t&&(this._fillMode=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!1,configurable:!0}),e.prototype._getDrawWrapper=function(){return this._drawWrapper},e.prototype._setDrawWrapper=function(e){this._drawWrapper=e},e.prototype.toString=function(e){return"Name: "+this.name},e.prototype.getClassName=function(){return"Material"},Object.defineProperty(e.prototype,"_isMaterial",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!1,configurable:!0}),e.prototype.freeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!0},e.prototype.unfreeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!1},e.prototype.isReady=function(e,t){return!0},e.prototype.isReadyForSubMesh=function(e,t,i){var r=t.materialDefines;return!!r&&(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=r,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh)},e.prototype.getEffect=function(){return this._drawWrapper.effect},e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,this._forceAlphaTest=t===e.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_disableAlphaBlending",{get:function(){return this._transparencyMode===e.MATERIAL_OPAQUE||this._transparencyMode===e.MATERIAL_ALPHATEST},enumerable:!1,configurable:!0}),e.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&this.alpha<1},e.prototype.needAlphaBlendingForMesh=function(e){return e.visibility<1||!this._disableAlphaBlending&&(e.hasVertexAlpha||this.needAlphaBlending())},e.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest},e.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(t){void 0===t&&(t=!1);for(var i=0,r=this.getScene().meshes;i-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,me&&me.AddTagsTo(r,e.tags),e.materialsUniqueIds?r._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach((function(e){return r.subMaterials.push(i.getLastMaterialById(e))})),r},t}(Kn);b("BABYLON.MultiMaterial",Qn);var qn=function(e,t){this.distanceOrScreenCoverage=e,this.mesh=t},Zn=function(){},Jn=function(){this.visibleInstances={},this.batchCache=new $n,this.batchCacheReplacementModeInFrozenMode=new $n,this.instancesBufferSize=2048},$n=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array,this.hardwareInstancedRendering=new Array},eo=function(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null},to=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},io=function(e){function t(i,r,n,o,s,l){void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),void 0===l&&(l=!0);var c=e.call(this,i,r)||this;if(c._internalMeshDataInfo=new to,c.delayLoadState=a.DELAYLOADSTATE_NONE,c.instances=new Array,c._creationDataStorage=null,c._geometry=null,c._instanceDataStorage=new Jn,c._thinInstanceDataStorage=new eo,c._shouldGenerateFlatShading=!1,c._originalBuilderSideOrientation=t.DEFAULTSIDE,c.overrideMaterialSideOrientation=null,c.ignoreCameraMaxZ=!1,r=c.getScene(),c._onBeforeDraw=function(e,t,i){e&&i&&(c._uniformBuffer?c.transferToEffect(t):i.bindOnlyWorldMatrix(t))},o){if(o._geometry&&o._geometry.applyToMesh(c),he.DeepCopy(o,c,["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"]),c._internalMeshDataInfo._source=o,r.useClonedMeshMap&&(o._internalMeshDataInfo.meshMap||(o._internalMeshDataInfo.meshMap={}),o._internalMeshDataInfo.meshMap[c.uniqueId]=c),c._originalBuilderSideOrientation=o._originalBuilderSideOrientation,c._creationDataStorage=o._creationDataStorage,o._ranges){var h=o._ranges;for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&h[d]&&c.createAnimationRange(d,h[d].from,h[d].to)}if(o.metadata&&o.metadata.clone?c.metadata=o.metadata.clone():c.metadata=o.metadata,c._internalMetadata=o._internalMetadata,me&&me.HasTags(o)&&me.AddTagsTo(c,me.GetTags(o,!0)),c.setEnabled(o.isEnabled(!1)),c.parent=o.parent,c.setPivotMatrix(o.getPivotMatrix()),c.id=i+"."+o.id,c.material=o.material,!s)for(var p=o.getDescendants(!0),f=0;f0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasThinInstances",{get:function(){var e;return(null!==(e=this._thinInstanceDataStorage.instancesCount)&&void 0!==e?e: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 $.Warn("You cannot use a mesh as LOD level twice"),this;var i=new qn(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;is*o)return this.onLODLevelSelection&&this.onLODLevelSelection(o,this,this),this;for(var u=0;u0||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 xn(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++)xn.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 Rn;n.set(t,e);var o=this.getScene();new In(In.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=In.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(ji.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(ji.PositionKind,i,!1,!1),t){var r=this.getIndices(),n=this.getVerticesData(ji.NormalKind);if(!n)return this;Rn.ComputeNormals(i,r,n),this.updateVerticesData(ji.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(In.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},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 Rn;r.indices=e;var n=this.getScene();new In(In.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 Kn.PointFillMode:n=null;break;case Kn.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),o);break;default:case Kn.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==Kn.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==Kn.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&&l.activeCamera===l.activeCameras[0]||c<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;var u=this._getInstancesRenderList(e._id,!!i);if(u.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var h=l.getEngine(),d=0,p=null;this.ignoreCameraMaxZ&&l.activeCamera&&!l._isInIntermediateRendering()&&(d=l.activeCamera.maxZ,p=l.activeCamera,l.activeCamera.maxZ=0,l.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);var f,_=e.getRenderingMesh(),m=u.hardwareInstancedRendering[e._id]||_.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,g=this._instanceDataStorage,v=e.getMaterial();if(!v)return p&&(p.maxZ=d,l.updateTransformMatrix(!0)),this;if(g.isFrozen&&this._internalMeshDataInfo._effectiveMaterial&&this._internalMeshDataInfo._effectiveMaterial===v){if(v._storeEffectOnSubMeshes&&!(null===(o=e.effect)||void 0===o?void 0:o._wasPreviouslyReady)||!v._storeEffectOnSubMeshes&&!(null===(a=v.getEffect())||void 0===a?void 0:a._wasPreviouslyReady))return p&&(p.maxZ=d,l.updateTransformMatrix(!0)),this}else{if(v._storeEffectOnSubMeshes){if(!v.isReadyForSubMesh(this,e,m))return p&&(p.maxZ=d,l.updateTransformMatrix(!0)),this}else if(!v.isReady(this,m))return p&&(p.maxZ=d,l.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=v}t&&h.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);for(var y=null!==(s=null==(f=this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?e._drawWrapper:this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper())?void 0:f.effect)&&void 0!==s?s:null,b=0,T=l._beforeRenderingMeshStage;bu&&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(ji.MatricesIndicesKind),y=this.getVerticesData(ji.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===a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=a.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 Ri.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=a.DELAYLOADSTATE_LOADED,e.removePendingData(t)}),(function(){}),e.offlineProvider,i),this},t.prototype.isInFrustum=function(t){return this.delayLoadState!==a.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=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(ji.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,r=this.getVerticesData(ji.PositionKind),n=R.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(ji.MatricesIndicesExtraKind):null,h=c?this.getVerticesData(ji.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),p=R.Zero(),f=new I,_=new I,m=0,g=0;g0&&(I.FromFloat32ArrayToRefScaled(d,Math.floor(16*a[m+l]),v,_),f.addToSelf(_));if(c)for(l=0;l<4;l++)(v=h[m+l])>0&&(I.FromFloat32ArrayToRefScaled(d,Math.floor(16*u[m+l]),v,_),f.addToSelf(_));R.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g],i._sourcePositions[g+1],i._sourcePositions[g+2],f,p),p.toArray(n,g),t&&(R.TransformNormalFromFloatsToRef(i._sourceNormals[g],i._sourceNormals[g+1],i._sourceNormals[g+2],f,p),p.toArray(o,g)),f.reset()}return this.updateVerticesData(ji.PositionKind,n),t&&this.updateVerticesData(ji.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:R.Zero(),max:R.Zero()}},t.Center=function(e){var i=e instanceof Array?t.MinMax(e):e;return R.Center(i.min,i.max)},t.MergeMeshes=function(e,i,r,n,o,a){return void 0===i&&(i=!0),sn(t._MergeMeshesCoroutine(e,i,r,n,o,a,!1))},t.MergeMeshesAsync=function(e,i,r,n,o,a){return void 0===i&&(i=!0),ln(t._MergeMeshesCoroutine(e,i,r,n,o,a,!0),on())},t._MergeMeshesCoroutine=function(e,i,r,n,o,a,s){var l,c,u,h,d,p,f,_,m,g,v,y,b,T,E,S,x,A,R,C,P,I,M,O,D,N;return void 0===i&&(i=!0),Y(this,(function(F){switch(F.label){case 0:if(0===(e=e.filter(Boolean)).length)return[2,null];if(!r)for(c=0,l=0;l=65536)return $.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!==Ln.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new I);var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,O.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(O.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&&0==(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)}))),Ve.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e},t.GetConstructorFromName=function(e,t,i){return We.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=Ve.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&&(console.error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach((function(e){return console.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 io?(r.geometry&&-1===this.geometries.indexOf(r.geometry)&&this.geometries.push(r.geometry),this.meshes.push(r)):r instanceof Ln?this.transformNodes.push(r):r instanceof no?this.lights.push(r):r instanceof dn&&this.cameras.push(r),r instanceof Vn){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":f.push(i);case"Array":0===f.length&&(f=i);for(var m=function(e){var t=f[e];if(_=o&&o.skipCodecCheck||-1!==t.indexOf(".mp3",t.length-4)&&Nn.audioEngine.isMP3supported||-1!==t.indexOf(".ogg",t.length-4)&&Nn.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,Ri.SetCorsBehavior(t,g._htmlAudioElement),g._htmlAudioElement.preload="auto",g._htmlAudioElement.addEventListener("canplaythrough",(function(){d._isReadyToPlay=!0,d.autoplay&&d.play(0,d._offset,d._length),d._readyToPlayCallback&&d._readyToPlayCallback()})),document.body.appendChild(g._htmlAudioElement),g._htmlAudioElement.load()):g._scene._loadFile(t,(function(e){d._soundLoaded(e)}),void 0,!0,!0,(function(e){e&&$.Error("XHR "+e.status+" error on: "+t+"."),$.Error("Sound creation aborted."),d._scene.mainSoundTrack.removeSound(d)})),"break"},g=this,v=0;v0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if((null===(t=Nn.audioEngine)||void 0===t?void 0:t.audioContext)&&this._soundSource){var r=e?Nn.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=Nn.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+=Nn.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){var i;(null===(i=Nn.audioEngine)||void 0===i?void 0:i.canUseWebAudio)&&this._soundGain&&(t&&Nn.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(Nn.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,Nn.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,Nn.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=Nn.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=R.FromArray(t.position);s.setPosition(u)}if(t.isDirectional&&(s.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var h=R.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=Nn.audioEngine)||void 0===e||e.onAudioUnlockedObservable.remove(this._audioUnlockedObserver),this._audioUnlockedObserver=null)},e._SceneComponentInitialization=function(e){throw ve("AudioSceneComponent")},e}(),ho=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,(e=e||S.LastCreatedScene)&&(this._scene=e,this.soundCollection=new Array,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=Nn.audioEngine)||void 0===e?void 0:e.canUseWebAudio)&&Nn.audioEngine.audioContext&&(this._outputAudioNode=Nn.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Nn.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(Nn.audioEngine&&Nn.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=Nn.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=Nn.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){var e;if(null===(e=Nn.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),R.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=Ve.Serialize(this);return Ve.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 yo(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?vo(n,e.getSize(),r.invertY):null}function bo(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=0),j(this,void 0,void 0,(function(){var r,n;return Y(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,vo(n,e.getSize(),r.invertY)]:[2,null]}}))}))}var To={GenerateBase64StringFromPixelData:vo,GenerateBase64StringFromTexture:yo,GenerateBase64StringFromTextureAsync:bo},Eo=function(e){function t(i,r,n,o,s,l,c,h,d,p,f,_,m,g){void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=null),void 0===d&&(d=!1);var v,y,b,T,E,S,x,A,R,C,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._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 u,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:!Pn.UseOpenGLOrientationForUV,s=null!==(b=n.samplingMode)&&void 0!==b?b:t.TRILINEAR_SAMPLINGMODE,l=null!==(T=n.onLoad)&&void 0!==T?T:null,c=null!==(E=n.onError)&&void 0!==E?E:null,h=null!==(S=n.buffer)&&void 0!==S?S:null,d=null!==(x=n.deleteBuffer)&&void 0!==x&&x,p=n.format,f=n.mimeType,_=n.loaderOptions,m=n.creationFlags,M=null!==(A=n.useSRGBBuffer)&&void 0!==A&&A,O=null!==(R=n.internalTexture)&&void 0!==R?R:null,D=null!==(C=n.gammaSpace)&&void 0!==C?C:D):P=!!n,I._gammaSpace=D,I._noMipmap=P,I._invertY=void 0===o?!Pn.UseOpenGLOrientationForUV:o,I._initialSamplingMode=s,I._buffer=h,I._deleteBuffer=d,I._mimeType=f,I._loaderOptions=_,I._creationFlags=m,I._useSRGBBuffer=M,I._forcedExtension=g,p&&(I._format=p);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),l&&l(),!I.isBlocking&&N&&N.resetCachedMaterial()},w=function(e,i){I._loadingError=!0,I._errorObject={message:e,exception:i},c&&c(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,s,I._invertY,M,I.isCube),I._texture)if(I._texture.isReady)ni.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=a.DELAYLOADSTATE_NOTLOADED,I._delayedOnLoad=L,I._delayedOnError=w;else{try{I._texture=F.createTexture(I.url,P,I._invertY,N,s,L,w,I._buffer,void 0,I._format,I._forcedExtension,f,_,m,M)}catch(e){throw w("error loading",e),e}d&&(I._buffer=null)}return I}return W(t,e),t._CreateVideoTexture=function(e,i,r,n,o,s,l,c,u){throw void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l={}),void 0===u&&(u=a.TEXTUREFORMAT_RGBA),ve("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(a.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=a.DELAYLOADSTATE_NOTLOADED,i&&(this._delayedOnLoad=i),this.delayLoad()},t.prototype.delayLoad=function(){if(this.delayLoadState===a.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=a.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?ni.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,R.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.checkTransformsAreIdentical=function(e){return null!==e&&this.uOffset===e.uOffset&&this.vOffset===e.vOffset&&this.uScale===e.uScale&&this.vScale===e.vScale&&this.uAng===e.uAng&&this.vAng===e.vAng&&this.wAng===e.wAng},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=I.Zero(),this._rowGenerationMatrix=new I,this._t0=R.Zero(),this._t1=R.Zero(),this._t2=R.Zero()),I.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(I.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,O.Matrix[0]),I.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,O.Matrix[1]),I.ScalingToRef(this._cachedUScale,this._cachedVScale,0,O.Matrix[2]),I.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,O.Matrix[3]),O.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(O.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(O.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(O.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),I.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();return i?(this.optimizeUVAllocation&&i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(t)})),this._cachedTextureMatrix):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=I.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=I.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:I.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:I.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:I.IdentityToRef(this._cachedReflectionTextureMatrix)}return r&&i.markAllMaterialsAsDirty(a.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 Ve.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,"+gt(this._buffer):(t.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(o.base64String=!this._engine||this._engine._features.supportSyncTextureRead?yo(this):bo(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=Si.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 s=0,l=i.getEngine().getLoadedTexturesCache();s0||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(){u(l)},internalTexture:o};l=new t(m,i,g)}return l}),e,i);return h},t.CreateFromBase64String=function(e,i,r,n,o,s,l,c,u,h){return void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=a.TEXTUREFORMAT_RGBA),new t("data:"+i,r,n,o,s,l,c,e,!1,u,void 0,void 0,h)},t.LoadFromDataString=function(e,i,r,n,o,s,l,c,u,h,d){return void 0===n&&(n=!1),void 0===s&&(s=!0),void 0===l&&(l=t.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=a.TEXTUREFORMAT_RGBA),"data:"!==e.substr(0,5)&&(e="data:"+e),new t(e,r,o,s,l,c,u,i,n,h,void 0,void 0,d)},t.SerializeBuffers=!0,t.ForceSerializeBuffers=!1,t.OnTextureLoadErrorObservable=new u,t._SerializeInternalTextureUniqueId=!1,t._CubeTextureParser=function(e,t,i){throw ve("CubeTexture")},t._CreateMirror=function(e,t,i,r){throw ve("MirrorTexture")},t._CreateRenderTargetTexture=function(e,t,i,r,n){throw ve("RenderTargetTexture")},t.NEAREST_SAMPLINGMODE=a.TEXTURE_NEAREST_SAMPLINGMODE,t.NEAREST_NEAREST_MIPLINEAR=a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.BILINEAR_SAMPLINGMODE=a.TEXTURE_BILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPNEAREST=a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TRILINEAR_SAMPLINGMODE=a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPLINEAR=a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.NEAREST_NEAREST_MIPNEAREST=a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.NEAREST_LINEAR_MIPNEAREST=a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.NEAREST_LINEAR_MIPLINEAR=a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.NEAREST_LINEAR=a.TEXTURE_NEAREST_LINEAR,t.NEAREST_NEAREST=a.TEXTURE_NEAREST_NEAREST,t.LINEAR_NEAREST_MIPNEAREST=a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.LINEAR_NEAREST_MIPLINEAR=a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.LINEAR_LINEAR=a.TEXTURE_LINEAR_LINEAR,t.LINEAR_NEAREST=a.TEXTURE_LINEAR_NEAREST,t.EXPLICIT_MODE=a.TEXTURE_EXPLICIT_MODE,t.SPHERICAL_MODE=a.TEXTURE_SPHERICAL_MODE,t.PLANAR_MODE=a.TEXTURE_PLANAR_MODE,t.CUBIC_MODE=a.TEXTURE_CUBIC_MODE,t.PROJECTION_MODE=a.TEXTURE_PROJECTION_MODE,t.SKYBOX_MODE=a.TEXTURE_SKYBOX_MODE,t.INVCUBIC_MODE=a.TEXTURE_INVCUBIC_MODE,t.EQUIRECTANGULAR_MODE=a.TEXTURE_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MODE=a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.CLAMP_ADDRESSMODE=a.TEXTURE_CLAMP_ADDRESSMODE,t.WRAP_ADDRESSMODE=a.TEXTURE_WRAP_ADDRESSMODE,t.MIRROR_ADDRESSMODE=a.TEXTURE_MIRROR_ADDRESSMODE,t.UseSerializedUrlIfAny=!1,X([Ae()],t.prototype,"url",void 0),X([Ae()],t.prototype,"uOffset",void 0),X([Ae()],t.prototype,"vOffset",void 0),X([Ae()],t.prototype,"uScale",void 0),X([Ae()],t.prototype,"vScale",void 0),X([Ae()],t.prototype,"uAng",void 0),X([Ae()],t.prototype,"vAng",void 0),X([Ae()],t.prototype,"wAng",void 0),X([Ae()],t.prototype,"uRotationCenter",void 0),X([Ae()],t.prototype,"vRotationCenter",void 0),X([Ae()],t.prototype,"wRotationCenter",void 0),X([Ae()],t.prototype,"homogeneousRotationInUVTransform",void 0),X([Ae()],t.prototype,"isBlocking",null),t}(go);function So(e,t,i,r){var n,o=1;r===a.TEXTURETYPE_FLOAT?n=new Float32Array(t*i*4):r===a.TEXTURETYPE_HALF_FLOAT?(n=new Uint16Array(t*i*4),o=15360):n=r===a.TEXTURETYPE_UNSIGNED_INTEGER?new Uint32Array(t*i*4):new Uint8Array(t*i*4);for(var s=0;s>v,b=0;b<6;b++){var T=g[v][b];m&&(T=So(T,y,y,n)),f.texImage2D(b,v,h,y,y,0,u,a,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(),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t.removePendingData(_),u&&e&&u(e.status+" "+e.statusText,i)})),_},ri.prototype.createRawTexture2DArray=xo(!1),ri.prototype.createRawTexture3D=xo(!0),ri.prototype.updateRawTexture2DArray=Ao(!1),ri.prototype.updateRawTexture3D=Ao(!0);var Ro=function(e){function t(t,i,r,n,o,s,l,c,u,h,d){void 0===s&&(s=!0),void 0===l&&(l=!1),void 0===c&&(c=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===u&&(u=a.TEXTURETYPE_UNSIGNED_INT);var p=e.call(this,null,o,!s,l,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||u!==a.TEXTURETYPE_FLOAT||(c=a.TEXTURE_NEAREST_SAMPLINGMODE),p._engine._caps.textureHalfFloatLinearFiltering||u!==a.TEXTURETYPE_HALF_FLOAT||(c=a.TEXTURE_NEAREST_SAMPLINGMODE),p._texture=p._engine.createRawTexture(t,i,r,n,s,l,c,null,u,null!=h?h:0,null!=d&&d),p.wrapU=Eo.CLAMP_ADDRESSMODE,p.wrapV=Eo.CLAMP_ADDRESSMODE,p):p}return W(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,s,l){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,a.TEXTUREFORMAT_LUMINANCE,n,o,s,l)},t.CreateLuminanceAlphaTexture=function(e,i,r,n,o,s,l){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,a.TEXTUREFORMAT_LUMINANCE_ALPHA,n,o,s,l)},t.CreateAlphaTexture=function(e,i,r,n,o,s,l){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,a.TEXTUREFORMAT_ALPHA,n,o,s,l)},t.CreateRGBTexture=function(e,i,r,n,o,s,l,c,u,h){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=0),void 0===h&&(h=!1),new t(e,i,r,a.TEXTUREFORMAT_RGB,n,o,s,l,c,u,h)},t.CreateRGBATexture=function(e,i,r,n,o,s,l,c,u,h){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=0),void 0===h&&(h=!1),new t(e,i,r,a.TEXTUREFORMAT_RGBA,n,o,s,l,c,u,h)},t.CreateRGBAStorageTexture=function(e,i,r,n,o,s,l,c,u){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=!1),new t(e,i,r,a.TEXTUREFORMAT_RGBA,n,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE,u)},t.CreateRTexture=function(e,i,r,n,o,s,l,c){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=Eo.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_FLOAT),new t(e,i,r,a.TEXTUREFORMAT_R,n,o,s,l,c)},t.CreateRStorageTexture=function(e,i,r,n,o,s,l,c){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=Eo.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_FLOAT),new t(e,i,r,a.TEXTUREFORMAT_R,n,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)},t}(Eo),Co=function(){function e(e,t){this._scene=e,this._mesh=t}return e.prototype.bakeVertexData=function(e){return j(this,void 0,void 0,(function(){var t,i,r,n,o,a,s,l;return Y(this,(function(c){switch(c.label){case 0:if(!this._mesh.skeleton)throw new Error("No skeleton in this mesh.");if(t=this._mesh.skeleton.bones.length,i=e.reduce((function(e,t){return e+t.to-t.from+1}),0),isNaN(i))throw new Error("Invalid animation ranges.");r=0,n=new Float32Array(4*(t+1)*4*i),this._scene.stopAnimation(this._mesh),this._mesh.skeleton.returnToRest(),o=0,a=e,c.label=1;case 1:if(!(o0},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!==er.POINTERDOWN?e.type===er.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){if(!t._reachTargetAlpha()){var e=lt.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:lt.Now},e.prototype._reachTargetAlpha=function(){return!(!this._attachedCamera||!this.targetAlpha)&&Math.abs(this._attachedCamera.alpha-this.targetAlpha)<_},e.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},e.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},e.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=lt.Now)},e.prototype._userIsMoving=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)},e}(),Io=function(){function e(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(e.prototype,"name",{get:function(){return"Bouncing"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}})):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&this._attachedCamera.radius===e&&!this._radiusIsAnimating},e.prototype._applyBoundRadiusAnimation=function(t){var i=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=Ke.CreateAnimation("radius",Ke.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var r=Ke.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return i._clearAnimationLocks()}));r&&this._animatables.push(r)}},e.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.EasingFunction=new Gr(.3),e.EasingMode=Vr.EASINGMODE_EASEOUT,e}(),Mo=function(){function e(){this.onTargetFramingAnimationEndObservable=new u,this._mode=e.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"Framing"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._attachedCamera=t;var r=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=r.onPrePointerObservable.add((function(e){e.type!==er.POINTERDOWN?e.type===er.POINTERUP&&(i._isPointerDown=!1):i._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&i.zoomOnMesh(e,void 0,(function(){i.onTargetFramingAnimationEndObservable.notifyObservers()}))})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){i._applyUserInteraction(),i._maintainCameraAboveGround()}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},e.prototype.zoomOnMesh=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,i)},e.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,i)},e.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var r=new R(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new R(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;or.upperRadiusLimit?r.upperRadiusLimit:n),n},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var i=lt.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=Ke.CreateAnimation("beta",Ke.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=Ke.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=lt.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 Xr,e.EasingMode=Vr.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),Oo=function(e,t,i,r){void 0===t&&(t=new R),void 0===i&&(i=0),void 0===r&&(r=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=r},Do=function(){function e(e){this._ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Oo(R.Up()),new Oo(R.Down()),new Oo(R.Left()),new Oo(R.Right()),new Oo(R.Forward()),new Oo(R.Forward().scaleInPlace(-1))],this._tmpMatrix=new I,this._tmpVector=new R,this._zeroVector=R.Zero(),this._lookAtTmpMatrix=new I}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=P.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),R.TransformCoordinatesToRef(i.direction,t._tmpMatrix,i.rotatedDirection),i.diff=R.GetAngleBetweenVectors(i.rotatedDirection,e,R.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}(),Fo=function(){function e(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}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),R.CrossToRef(this.direction,o,a);var c=R.Dot(n,a);if(0===c)return null;var u=1/c;this.origin.subtractToRef(t,s);var h=R.Dot(s,a)*u;if(h<0||h>1)return null;R.CrossToRef(s,n,l);var d=R.Dot(this.direction,l)*u;if(d<0||h+d>1)return null;var p=R.Dot(o,l)*u;return p>this.length?null:new pn(1-h-d,h,p)},e.prototype.intersectsPlane=function(e){var t,i=R.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var r=R.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 R(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 R(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 R(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=O.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=O.Vector3[0],a=O.Vector3[1],s=O.Vector3[2],l=O.Vector3[3];i.subtractToRef(t,o),this.direction.scaleToRef(e._Rayl,s),n.addToRef(s,a),t.subtractToRef(n,l);var c,u,h=R.Dot(o,o),d=R.Dot(o,s),p=R.Dot(s,s),f=R.Dot(o,l),_=R.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},Ar.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 Ar(this._scene.getEngine(),{virtual:!0}),e._PlaneScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._PlaneScene.dispose(),e._PlaneScene=null})))),this._dragPlane=Bo("pointerDragPlane",{size:this._debugMode?1:1e4,updatable:!1,sideOrientation:io.DOUBLESIDE},e._PlaneScene),this.lastDragPosition=new R(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==er.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==er.POINTERUP)!r.startAndReleaseDragOnPointerEvents||r.currentDraggingPointerId!=t.event.pointerId||r._activeDragButton!==t.event.button&&-1!==r._activeDragButton||r.releaseDrag();else if(t.type==er.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 Fo(new R,new R)),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;Lo._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),Lo._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){Lo._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(),Lo._RestorePivotPoint(this.attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){Lo._RemoveAndStorePivotPoint(this.attachedNode),this.updateDragPlane&&this._updateDragPlanePosition(e,t);var i=0;this._options.dragAxis?(this.useObjectOrientationForDragging?R.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=R.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),Lo._RestorePivotPoint(this.attachedNode)}},e.prototype._pickWithRayOnDragPlane=function(t){var i=this;if(!t)return null;var r=Math.acos(R.Dot(this._dragPlane.forward,t.direction));if(r>Math.PI/2&&(r=Math.PI-r),this.maxDragAngle>0&&r>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(t.direction),this.attachedNode.absolutePosition.subtractToRef(t.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*R.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var n=R.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-n,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var o=e._PlaneScene.pickWithRay(t,(function(e){return e==i._dragPlane}));return o&&o.hit&&o.pickedMesh&&o.pickedPoint?o.pickedPoint:null},e.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrientationForDragging?R.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),e.origin.subtractToRef(this._pointA,this._pointC),this._pointC.normalize(),Math.abs(R.Dot(this._localAxis,this._pointC))>.999?Math.abs(R.Dot(R.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(R.Right()):this._lookAt.copyFrom(R.UpReadOnly):(R.CrossToRef(this._localAxis,this._pointC,this._lookAt),R.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?R.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}(),Go=function(){function e(){this._startDistance=0,this._initialScale=new R(0,0,0),this._targetScale=new R(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new ko({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new ko({}),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}(),zo=function(){function e(){this._attachedToElement=!1,this._virtualMeshesInfo={},this._tmpVector=new R,this._tmpQuaternion=new P,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 u,this.onDragObservable=new u,this.onDragEndObservable=new u,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 Vn("",e._virtualScene);t.rotationQuaternion=new P;var i=new Vn("",e._virtualScene);i.rotationQuaternion=new P;var r=new Vn("",e._virtualScene);return r.rotationQuaternion=new P,{dragging:!1,moving:!1,dragMesh:t,originMesh:i,pivotMesh:r,startingPivotPosition:new R,startingPivotOrientation:new P,startingPosition:new R,startingOrientation:new P,lastOriginPosition:new R,lastDragPosition:new R}},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 Ar(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;if(e.type==er.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&&i.currentDraggingPointerIds.length>0)return;!i._pointerCamera||i._pointerCamera.cameraRigMode!==dn.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._attachedToElement=!1),i._targetDragStart(a.pivotMesh.position,a.pivotMesh.rotationQuaternion,t),i.onDragStartObservable.notifyObservers({position:a.pivotMesh.position})}}else if(e.type==er.POINTERUP||e.type==er.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==er.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}(),Wo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._sceneRenderObserver=null,t._targetPosition=new R(0,0,0),t._targetOrientation=new P,t._targetScaling=new R(1,1,1),t._startingPosition=new R(0,0,0),t._startingOrientation=new P,t._startingScaling=new R(1,1,1),t.onPositionChangedObservable=new u,t.dragDeltaRatio=.2,t.rotateDraggedObject=!0,t.rotateAroundYOnly=!1,t.rotateWithMotionController=!0,t.disableMovement=!1,t.faceCameraOnDragStart=!1,t}return W(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,this._virtualTransformNode=new Ln("virtual_sixDof",zo._virtualScene),this._virtualTransformNode.rotationQuaternion=P.Identity(),this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(1===i.currentDraggingPointerIds.length&&i._moving&&!i.disableMovement){var e=t.parent;t.setParent(null),t.position.addInPlace(i._targetPosition.subtract(t.position).scale(i.dragDeltaRatio)),i.onPositionChangedObservable.notifyObservers({position:t.absolutePosition}),(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&P.SlerpToRef(t.rotationQuaternion,i._targetOrientation,i.dragDeltaRatio,t.rotationQuaternion),t.setParent(e)}}))},t.prototype._getPositionOffsetAround=function(e,t,i){var r=O.Matrix[0],n=O.Matrix[1],o=O.Matrix[2],a=O.Matrix[3],s=O.Matrix[4];return I.TranslationToRef(e.x,e.y,e.z,r),I.TranslationToRef(-e.x,-e.y,-e.z,n),I.FromQuaternionToRef(i,o),I.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){O.Vector3[0].setAll(0),this._dragging===this._dragType.DRAG?this.rotateDraggedObject&&(this.rotateAroundYOnly?P.RotationYawPitchRollToRef(t.toEulerAngles().y,0,0,O.Quaternion[0]):O.Quaternion[0].copyFrom(t),O.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=O.Vector3[0];e.addToRef(t,i),i.scaleInPlace(.5);var r=O.Vector3[1];t.subtractToRef(e,r);var n=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition,o=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition,a=O.Vector3[2];n.addToRef(o,a),a.scaleInPlace(.5);var s=O.Vector3[3];o.subtractToRef(n,s);var l=s.length()/r.length(),c=a.subtract(i),u=P.FromEulerAngles(0,R.GetAngleBetweenVectorsOnPlane(r.normalize(),s.normalize(),R.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,t=this._ownerNode.parent;this._ownerNode.rotationQuaternion||(this._ownerNode.rotationQuaternion=P.RotationYawPitchRoll(this._ownerNode.rotation.y,this._ownerNode.rotation.x,this._ownerNode.rotation.z));var i=this._ownerNode.getAbsolutePivotPoint();if(this._ownerNode.setParent(null),1===e){if(this._targetPosition.copyFrom(this._ownerNode.position),this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion),this._targetScaling.copyFrom(this._ownerNode.scaling),this.faceCameraOnDragStart&&this._scene.activeCamera){var r=O.Vector3[0];this._scene.activeCamera.position.subtractToRef(i,r),r.normalize();var n=O.Quaternion[0];this._scene.useRightHandedSystem?P.FromLookDirectionRHToRef(r,new R(0,1,0),n):P.FromLookDirectionLHToRef(r,new R(0,1,0),n),n.normalize(),P.RotationYawPitchRollToRef(n.toEulerAngles().y,0,0,O.Quaternion[0]),this._targetOrientation.copyFrom(O.Quaternion[0])}this._startingPosition.copyFrom(this._targetPosition),this._startingOrientation.copyFrom(this._targetOrientation),this._startingScaling.copyFrom(this._targetScaling)}else 2===e&&(this._virtualTransformNode.setPivotPoint(new R(0,0,0),xr.LOCAL),this._virtualTransformNode.position.copyFrom(this._ownerNode.position),this._virtualTransformNode.scaling.copyFrom(this._ownerNode.scaling),this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),this._virtualTransformNode.setPivotPoint(i,xr.WORLD),this._resetVirtualMeshesPosition());this._ownerNode.setParent(t)},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.isNearGrabbable=!1,this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)),this._virtualTransformNode&&this._virtualTransformNode.dispose()},t}(zo),Ho=function(){function e(){this._attachPointLocalOffset=new R,this._workingPosition=new R,this._workingQuaternion=new P,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=P.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=O.Vector3[0];return r.copyFrom(t),r.scaleInPlace(this.hitNormalOffset),r.addInPlace(i),this._attachedMesh.parent&&(O.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),R.TransformNormalToRef(r,O.Matrix[0],r)),{position:r,quaternion:P.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&&R.Distance(this._attachedMesh.position,i.position)c&&(P.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?(P.RotationAxisToRef(n,-u-h,a),t.rotateByQuaternionToRef(a,t),o=!0):u>h&&(P.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),R.CrossToRef(r,n,o);var a=o.length();a<_||(o.normalizeFromLength(a),R.CrossToRef(o,r,n),(null===(i=this.attachedNode)||void 0===i?void 0:i.getScene().useRightHandedSystem)?P.FromLookDirectionRHToRef(r,n,t):P.FromLookDirectionLHToRef(r,n,t))},e.prototype._passedOrientationDeadzone=function(e,t){var i=this._tmpVectors[5];return i.copyFrom(e),i.normalize(),180*Math.abs(R.GetAngleBetweenVectorsOnPlane(t,i,R.UpReadOnly))/Math.PI>this.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(),R.TransformCoordinatesToRef(o,i,r);var s=this._tmpPosition;s.copyFromFloats(0,0,0),R.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),R.TransformNormalToRef(c,a,c);var u=this._tmpNodeForward;if(u.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),R.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=P.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 R;i.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),R.SmoothToRef(i,this._workingPosition,e,this.lerpTime,i),i.addInPlace(this.followedCamera.globalPosition),this.attachedNode.position.copyFrom(i);var r=new P;r.copyFrom(this.attachedNode.rotationQuaternion),P.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}(),jo=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}(),Yo=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()},e.prototype.detachFeature=function(e){var t=this._features[e];t&&t.featureImplementation.attached&&t.featureImplementation.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 Ri.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 j(this,void 0,void 0,(function(){var t,i,r,n,o,a,s;return Y(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=P.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new P),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&&$.Warn("You must affect impostors to children before affecting impostor to parent.")):$.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):$.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 Vn?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):R.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):R.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):$.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):$.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):$.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):P.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 Qo(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 P),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,xr.WORLD,i)}else t.setRotationQuaternion(s.rotationQuaternion,xr.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(xr.WORLD,i,l),l.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(xr.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 R(1,1,1),e.IDENTITY_QUATERNION=P.Identity(),e._TmpVecs=m.BuildArray(3,R.Zero),e._TmpQuat=P.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"}(ea||(ea={}));var ia,ra,na=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return Cn.ForceFullSceneLoadingForIncremental},set:function(e){Cn.ForceFullSceneLoadingForIncremental=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return Cn.ShowLoadingScreen},set:function(e){Cn.ShowLoadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return Cn.loggingLevel},set:function(e){Cn.loggingLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return Cn.CleanBoneMatrixWeights},set:function(e){Cn.CleanBoneMatrixWeights=e},enumerable:!1,configurable:!0}),e.GetDefaultPlugin=function(){return e._RegisteredPlugins[".babylon"]},e._GetPluginForExtension=function(t){return e._RegisteredPlugins[t]||($.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)||!gi(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").concat(i.substitutionVars?"("+i.substitutionVars+")":"","[0..").concat(i.repeatKey,"]\n");var r=Gt.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]));if(this.functions[n]=Gt.IncludesShadersStore[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 o=0;o0},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()},e}(),ha=function(){function e(e,t,i){void 0===t&&(t=ra.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===ra.Neutral,this._isFinalMerger=i,this._isInput="InputBlock"===this.getClassName(),this._isTeleportOut="NodeMaterialTeleportOutBlock"===this.getClassName(),this._isTeleportIn="NodeMaterialTeleportInBlock"===this.getClassName(),this._name=e,this.uniqueId=Tr.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){0==(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===ra.Neutral},e.prototype.initialize=function(e){},e.prototype.bind=function(e,t,i,r){},e.prototype._declareOutput=function(e,t){return"".concat(t._getGLType(e.type)," ").concat(e.associatedVariableName)},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 ua(e,this,sa.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 ua(e,this,sa.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,"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,"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 s;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=a.TEXTUREFORMAT_DEPTH32_FLOAT),null===(s=this._depthStencilTexture)||void 0===s||s.dispose(),this._depthStencilTextureWithStencil=i,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._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,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,s,l,c=null;if(this._isMulti){var u=this.textures;if(u&&u.length>0){var h=!1,d=u.length,p=u[u.length-1]._source;p!==Ot.Depth&&p!==Ot.DepthStencil||(h=!0,d--);for(var f=[],_=[],m=[],g=[],v=[],y=[],b=[],T={},E=0;E1&&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}(),Da=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 W(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._shareDepth=function(t){e.prototype._shareDepth.call(this,t);var i=this._context,r=this._depthStencilBuffer,n=t._MSAAFramebuffer||t._framebuffer;t._depthStencilBuffer&&t._depthStencilBuffer!==r&&i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=r;var o=t._generateStencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;this._engine._bindUnboundFramebuffer(n),i.framebufferRenderbuffer(i.FRAMEBUFFER,o,i.RENDERBUFFER,r),this._engine._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._currentFramebuffer;if(this._engine._bindUnboundFramebuffer(l),this._engine.webGLVersion>1){var u=(h=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,h.framebufferTextureLayer(h.FRAMEBUFFER,u,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,h.framebufferTexture2D(h.FRAMEBUFFER,u,h.TEXTURE_CUBE_MAP_POSITIVE_X+i,e._hardwareTexture.underlyingResource,r)):h.framebufferTexture2D(h.FRAMEBUFFER,u,h.TEXTURE_2D,e._hardwareTexture.underlyingResource,r)}else{u=(h=this._context)["COLOR_ATTACHMENT"+t+"_WEBGL"];var h,d=void 0!==i?h.TEXTURE_CUBE_MAP_POSITIVE_X+i:h.TEXTURE_2D;h.framebufferTexture2D(h.FRAMEBUFFER,u,d,e._hardwareTexture.underlyingResource,r)}this._engine._bindUnboundFramebuffer(c)}},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&&(s.format===a.TEXTUREFORMAT_DEPTH16?d=r.DEPTH_COMPONENT16:s.format===a.TEXTUREFORMAT_DEPTH24?d=r.DEPTH_COMPONENT24:s.format===a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||s.format===a.TEXTUREFORMAT_DEPTH24_STENCIL8?d=r.DEPTH24_STENCIL8:s.format===a.TEXTUREFORMAT_DEPTH32_FLOAT?d=r.DEPTH_COMPONENT32F:s.format===a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8&&(d=r.DEPTH32F_STENCIL8)),s.is2DArray?r.texImage3D(o,0,d,s.width,s.height,n,0,h,u,null):r.texImage2D(o,0,d,s.width,s.height,0,h,u,null),this._bindTextureDirectly(o,null),this._internalTexturesCache.push(s);var p=i;if(p._depthStencilBuffer){var f=this._currentFramebuffer;this._bindUnboundFramebuffer(p._framebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,null),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,null),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.STENCIL_ATTACHMENT,r.RENDERBUFFER,null),this._bindUnboundFramebuffer(f),r.deleteRenderbuffer(p._depthStencilBuffer),p._depthStencilBuffer=null}return s},ri.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._getRGBAMultiSampleBufferFormat(e.texture.type),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 Na=function(){function e(e,t,i,r,n,o,s,l,c,h,d,p,f,_,m,g){void 0===s&&(s=a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===h&&(h=null),void 0===d&&(d=a.TEXTURETYPE_UNSIGNED_INT),void 0===p&&(p="postprocess"),void 0===_&&(_=!1),void 0===m&&(m=a.TEXTUREFORMAT_RGBA),void 0===g&&(g=at.GLSL),this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.alphaMode=a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new Ii(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new A(1,1),this._texelSize=A.Zero(),this.onActivateObservable=new u,this.onSizeChangedObservable=new u,this.onApplyObservable=new u,this.onBeforeRenderObservable=new u,this.onAfterRenderObservable=new u,this.name=e,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()):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=n,this.renderTargetSamplingMode=s||a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=c||!1,this._textureType=d,this._textureFormat=m,this._shaderLanguage=g,this._samplers=r||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=p,this._parameters=i||[],this._parameters.push("scale"),this._indexParameters=f,this._drawWrapper=new ei(this._engine),_||this.updateEffect(h)}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 Ii(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:[],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;for(var o=null,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=Ve.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=T(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 Ve.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={},X([Ae()],e.prototype,"uniqueId",void 0),X([Ae()],e.prototype,"name",void 0),X([Ae()],e.prototype,"width",void 0),X([Ae()],e.prototype,"height",void 0),X([Ae()],e.prototype,"renderTargetSamplingMode",void 0),X([Ne()],e.prototype,"clearColor",void 0),X([Ae()],e.prototype,"autoClear",void 0),X([Ae()],e.prototype,"forceAutoClearInAlphaMode",void 0),X([Ae()],e.prototype,"alphaMode",void 0),X([Ae()],e.prototype,"alphaConstants",void 0),X([Ae()],e.prototype,"enablePixelPerfectMode",void 0),X([Ae()],e.prototype,"forceFullscreenViewport",void 0),X([Ae()],e.prototype,"scaleMode",void 0),X([Ae()],e.prototype,"alwaysForcePOT",void 0),X([Ae("samples")],e.prototype,"_samples",void 0),X([Ae()],e.prototype,"adaptScaleToCurrentViewport",void 0),e}();b("BABYLON.PostProcess",Na);var Fa=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.xSwizzle="x",i.ySwizzle="y",i.zSwizzle="z",i.wSwizzle="w",i.registerInput("xyzw ",ia.Vector4,!0),i.registerInput("xyz ",ia.Vector3,!0),i.registerInput("xy ",ia.Vector2,!0),i.registerInput("zw ",ia.Vector2,!0),i.registerInput("x",ia.Float,!0),i.registerInput("y",ia.Float,!0),i.registerInput("z",ia.Float,!0),i.registerInput("w",ia.Float,!0),i.registerOutput("xyzw",ia.Vector4),i.registerOutput("xyz",ia.Vector3),i.registerOutput("xy",ia.Vector2),i.registerOutput("zw",ia.Vector2),i}return W(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];return c.isConnected?(u.hasEndpoints&&(t.compilationString+=this._declareOutput(u,t)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(4),";\n")),h.hasEndpoints&&(t.compilationString+=this._declareOutput(h,t)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(3),";\n")),d.hasEndpoints&&(t.compilationString+=this._declareOutput(d,t)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(2),";\n"))):l.isConnected?(u.hasEndpoints&&(t.compilationString+=this._declareOutput(u,t)+" = vec4(".concat(l.associatedVariableName,", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(4),";\n")),h.hasEndpoints&&(t.compilationString+=this._declareOutput(h,t)+" = ".concat(l.associatedVariableName).concat(this._buildSwizzle(3),";\n")),d.hasEndpoints&&(t.compilationString+=this._declareOutput(d,t)+" = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2),";\n"))):a.isConnected?(u.hasEndpoints&&(s.isConnected?t.compilationString+=this._declareOutput(u,t)+" = vec4(".concat(a.associatedVariableName,", ").concat(s.associatedVariableName,")").concat(this._buildSwizzle(4),";\n"):t.compilationString+=this._declareOutput(u,t)+" = vec4(".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+=this._declareOutput(h,t)+" = vec3(".concat(a.associatedVariableName,", ").concat(n.isConnected?this._writeVariable(n):"0.0",")").concat(this._buildSwizzle(3),";\n")),d.hasEndpoints&&(t.compilationString+=this._declareOutput(d,t)+" = ".concat(a.associatedVariableName).concat(this._buildSwizzle(2),";\n")),p.hasEndpoints&&(s.isConnected?t.compilationString+=this._declareOutput(p,t)+" = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2),";\n"):t.compilationString+=this._declareOutput(p,t)+" = vec2(".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+=this._declareOutput(u,t)+" = vec4(".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+=this._declareOutput(u,t)+" = vec4(".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+=this._declareOutput(h,t)+" = vec3(".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+=this._declareOutput(d,t)+" = vec2(".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+=this._declareOutput(p,t)+" = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2),";\n"):t.compilationString+=this._declareOutput(p,t)+" = vec2(".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}(ha);b("BABYLON.VectorMergerBlock",Fa);var La=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.sourceRange=new A(-1,1),i.targetRange=new A(0,1),i.registerInput("input",ia.AutoDetect),i.registerInput("sourceMin",ia.Float,!0),i.registerInput("sourceMax",ia.Float,!0),i.registerInput("targetMin",ia.Float,!0),i.registerInput("targetMax",ia.Float,!0),i.registerOutput("output",ia.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return W(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+=this._declareOutput(i,t)+" = ".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=A.FromArray(t.sourceRange),this.targetRange=A.FromArray(t.targetRange)},X([_a("From",pa.Vector2)],t.prototype,"sourceRange",void 0),X([_a("To",pa.Vector2)],t.prototype,"targetRange",void 0),t}(ha);b("BABYLON.RemapBlock",La);var wa,Ba=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.registerInput("left",ia.AutoDetect),i.registerInput("right",ia.AutoDetect),i.registerOutput("output",ia.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._inputs[0].acceptedConnectionPointTypes.push(ia.Float),i._inputs[1].acceptedConnectionPointTypes.push(ia.Float),i}return W(t,e),t.prototype.getClassName=function(){return"MultiplyBlock"},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._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = ".concat(this.left.associatedVariableName," * ").concat(this.right.associatedVariableName,";\n"),this},t}(ha);b("BABYLON.MultiplyBlock",Ba),function(e){e[e.Material=0]="Material",e[e.PostProcess=1]="PostProcess",e[e.Particle=2]="Particle",e[e.ProceduralTexture=3]="ProceduralTexture"}(wa||(wa={}));var Ua=function(){function e(){this.direction1=new R(0,1,0),this.direction2=new R(0,1,0),this.minEmitBox=new R(-.5,-.5,-.5),this.maxEmitBox=new R(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=h.RandomRange(this.direction1.x,this.direction2.x),o=h.RandomRange(this.direction1.y,this.direction2.y),a=h.RandomRange(this.direction1.z,this.direction2.z);if(r)return t.x=n,t.y=o,void(t.z=a);R.TransformNormalFromFloatsToRef(n,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=h.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),o=h.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),a=h.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);if(r)return t.x=n,t.y=o,void(t.z=a);R.TransformCoordinatesFromFloatsToRef(n,o,a,e,t)},e.prototype.clone=function(){var t=new e;return he.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){R.FromArrayToRef(e.direction1,0,this.direction1),R.FromArrayToRef(e.direction2,0,this.direction2),R.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),R.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),Va=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?O.Vector3[0].copyFrom(i._localPosition).normalize():i.position.subtractToRef(e.getTranslation(),O.Vector3[0]).normalize();var n=h.RandomRange(0,this.directionRandomizer),o=h.RandomRange(0,this.directionRandomizer),a=h.RandomRange(0,this.directionRandomizer);t.x=O.Vector3[0].x+n,t.y=O.Vector3[0].y+o,t.z=O.Vector3[0].z+a,t.normalize()},e.prototype.startPositionFunction=function(e,t,i,r){var n,o=h.RandomRange(0,2*Math.PI);n=this.emitFromSpawnPointOnly?1e-4:1-(n=h.RandomRange(0,this.heightRange))*n;var a=this._radius-h.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);R.TransformCoordinatesFromFloatsToRef(s,c,l,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return he.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}(),ka=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=R.Zero()}return e.prototype.startDirectionFunction=function(e,t,i,r,n){i.position.subtractToRef(e.getTranslation(),this._tempVector),this._tempVector.normalize(),R.TransformNormalToRef(this._tempVector,n,this._tempVector);var o=h.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),a=Math.atan2(this._tempVector.x,this._tempVector.z);a+=h.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):R.TransformNormalFromFloatsToRef(this._tempVector.x,this._tempVector.y,this._tempVector.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=h.RandomRange(-this.height/2,this.height/2),o=h.RandomRange(0,2*Math.PI),a=h.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):R.TransformCoordinatesFromFloatsToRef(l,n,c,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return he.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}(),Ga=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 R(0,1,0)),void 0===o&&(o=new R(0,1,0));var a=e.call(this,t,i,r)||this;return a.direction1=n,a.direction2=o,a}return W(t,e),t.prototype.startDirectionFunction=function(e,t){var i=h.RandomRange(this.direction1.x,this.direction2.x),r=h.RandomRange(this.direction1.y,this.direction2.y),n=h.RandomRange(this.direction1.z,this.direction2.z);R.TransformNormalFromFloatsToRef(i,r,n,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return he.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),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(ka),za=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=h.RandomRange(0,this.directionRandomizer),a=h.RandomRange(0,this.directionRandomizer),s=h.RandomRange(0,this.directionRandomizer);n.x+=o,n.y+=a,n.z+=s,n.normalize(),r?t.copyFrom(n):R.TransformNormalFromFloatsToRef(n.x,n.y,n.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=this.radius-h.RandomRange(0,this.radius*this.radiusRange),o=h.RandomRange(0,1),a=h.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):R.TransformCoordinatesFromFloatsToRef(l,Math.abs(c),u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return he.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}(),Wa=function(){function e(){this.direction1=new R(0,1,0),this.direction2=new R(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=h.RandomRange(this.direction1.x,this.direction2.x),o=h.RandomRange(this.direction1.y,this.direction2.y),a=h.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(n,o,a):R.TransformNormalFromFloatsToRef(n,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){r?t.copyFromFloats(0,0,0):R.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return he.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){R.FromArrayToRef(e.direction1,0,this.direction1),R.FromArrayToRef(e.direction2,0,this.direction2)},e}(),Ha=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=h.RandomRange(0,this.directionRandomizer),a=h.RandomRange(0,this.directionRandomizer),s=h.RandomRange(0,this.directionRandomizer);n.x+=o,n.y+=a,n.z+=s,n.normalize(),r?t.copyFrom(n):R.TransformNormalFromFloatsToRef(n.x,n.y,n.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=this.radius-h.RandomRange(0,this.radius*this.radiusRange),o=h.RandomRange(0,1),a=h.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):R.TransformCoordinatesFromFloatsToRef(l,c,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return he.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}(),Xa=function(e){function t(t,i,r){void 0===t&&(t=1),void 0===i&&(i=new R(0,1,0)),void 0===r&&(r=new R(0,1,0));var n=e.call(this,t)||this;return n.direction1=i,n.direction2=r,n}return W(t,e),t.prototype.startDirectionFunction=function(e,t){var i=h.RandomRange(this.direction1.x,this.direction2.x),r=h.RandomRange(this.direction1.y,this.direction2.y),n=h.RandomRange(this.direction1.z,this.direction2.z);R.TransformNormalFromFloatsToRef(i,r,n,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return he.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}(Ha),ja=function(){function e(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return e.prototype.startDirectionFunction=function(e,t,i,r){var n=O.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,i,n);var o=O.Vector3[1];n.subtractToRef(i.position,o),o.scaleToRef(1/i.lifeTime,n)}else n.set(0,0,0);r?t.copyFrom(n):R.TransformNormalToRef(n,e,t)},e.prototype.startPositionFunction=function(e,t,i,r){var n=O.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,i,n):n.set(0,0,0),r?t.copyFrom(n):R.TransformCoordinatesToRef(n,e,t)},e.prototype.clone=function(){var t=new e;return he.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},e.prototype.parse=function(e){},e}(),Ya=function(){function e(e){void 0===e&&(e=null),this._indices=null,this._positions=null,this._normals=null,this._storedNormal=R.Zero(),this._mesh=null,this.direction1=new R(0,1,0),this.direction2=new R(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(ji.PositionKind),this._normals=e.getVerticesData(ji.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)R.TransformNormalToRef(this._storedNormal,e,t);else{var n=h.RandomRange(this.direction1.x,this.direction2.x),o=h.RandomRange(this.direction1.y,this.direction2.y),a=h.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(n,o,a):R.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=O.Vector3[0],d=O.Vector3[1],p=O.Vector3[2],f=O.Vector3[3];R.FromArrayToRef(this._positions,3*l,h),R.FromArrayToRef(this._positions,3*c,d),R.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):R.TransformCoordinatesFromFloatsToRef(f.x,f.y,f.z,e,t),this.useMeshNormalsForDirection&&this._normals&&(R.FromArrayToRef(this._normals,3*l,h),R.FromArrayToRef(this._normals,3*c,d),R.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 he.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){R.FromArrayToRef(e.direction1,0,this.direction1),R.FromArrayToRef(e.direction2,0,this.direction2),e.meshId&&t&&(this.mesh=t.getLastMeshById(e.meshId)),this.useMeshNormalsForDirection=e.useMeshNormalsForDirection},e}(),Ka=function(){function e(t){this.animations=[],this.renderingGroupId=0,this.emitter=R.Zero(),this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this._wasDispatched=!1,this._rootUrl="",this.noiseStrength=new R(10,10,10),this.onAnimationEnd=null,this.blendMode=e.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteCellLoop=!0,this.spriteRandomStartCell=!1,this.translationPivot=new A(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new R(0,0,0),this._useLogarithmicDepth=!1,this.gravity=R.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new U(1,1,1,1),this.color2=new U(1,1,1,1),this.colorDead=new U(0,0,0,1),this.textureMask=new U(1,1,1,1),this._isSubEmitter=!1,this._billboardMode=a.PARTICLES_BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new Fi,this.id=t,this.name=t}return Object.defineProperty(e.prototype,"noiseTexture",{get:function(){return this._noiseTexture},set:function(e){this._noiseTexture!==e&&(this._noiseTexture=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||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:R.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:R.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:R.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:R.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=P.getScene())||void 0===i||i.meshes.forEach((function(e){e._markSubMeshesAsLightDirty()})))},P.renderParticles=!0,P.renderSprites=!1,P.forceLayerMaskCheck=!1,P.ignoreCameraViewport=!1,P.onBeforeBindObservable=new u,P.onAfterUnbindObservable=new u,P.onBeforeRenderObservable=new u,P.onAfterRenderObservable=new u,P.onClearObservable=new u,P.onResizeObservable=new u,P._cleared=!1,P.skipInitialClear=!1,P._currentRefreshId=-1,P._refreshRate=1,P._samples=1,P._canRescale=!0,P._renderTarget=null,P.boundingBoxPosition=R.Zero(),!(r=P.getScene()))return P;var N=P.getScene().getEngine();return P._gammaSpace=O,P._coordinatesMode=Eo.PROJECTION_MODE,P.renderList=new Array,P.name=t,P.isRenderTarget=!0,P._initialSizeParameter=i,P._renderPassIds=[],P._isCubeData=l,P._processSizeParameter(i),P.renderPassId=P._renderPassIds[0],P._resizeObserver=N.onResizeObservable.add((function(){})),P._generateMipMaps=!!n,P._doNotChangeAspectRatio=o,P._renderingManager=new Zi(r),P._renderingManager._useSceneAutoClearSetup=!0,p||(P._renderTargetOptions={generateMipMaps:n,type:s,format:null!==(C=P._format)&&void 0!==C?C:void 0,samplingMode:P.samplingMode,generateDepthBuffer:h,generateStencilBuffer:d,samples:m,creationFlags:g,noColorAttachment:v,useSRGBBuffer:y,colorAttachment:M,label:P.name},P.samplingMode===Eo.NEAREST_SAMPLINGMODE&&(P.wrapU=Eo.CLAMP_ADDRESSMODE,P.wrapV=Eo.CLAMP_ADDRESSMODE),_||(l?(P._renderTarget=r.getEngine().createRenderTargetCubeTexture(P.getRenderSize(),P._renderTargetOptions),P.coordinatesMode=Eo.INVCUBIC_MODE,P._textureMatrix=I.Identity()):P._renderTarget=r.getEngine().createRenderTargetTexture(P._size,P._renderTargetOptions),P._texture=P._renderTarget.texture,void 0!==m&&(P.samples=m))),P}return W(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=v(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(){return this._size.layers||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){this.renderList=[];for(var a=0;a1||this.activeCamera&&this.activeCamera!==n.activeCamera)&&n.setTransformMatrix(n.activeCamera.getViewMatrix(),n.activeCamera.getProjectionMatrix(!0)),o.setViewport(n.activeCamera.viewport)),n.resetCachedMaterial(),f},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var i=e*t,r=Nn.NearestPOT(i+16384/(128+i));return Math.min(Nn.FloorPOT(e),r)},t.prototype._prepareRenderingManager=function(e,t,i,r){var n=this.getScene();if(n){this._renderingManager.reset();for(var o=n.getRenderId(),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}(Eo);Eo._CreateRenderTargetTexture=function(e,t,i,r,n){return new ns(e,t,i,r)};var os=function(){function e(e){this.name=Ji.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(Ji.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){Ri.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var e=0;e0)}},e}();kt.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 as,ss=function(e){function t(t,i,r,n,o,s,l,c){void 0===o&&(o=null),void 0===s&&(s=!0),void 0===l&&(l=!1),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT);var h=e.call(this,null,n,!s)||this;h.isEnabled=!0,h.autoClear=!0,h.onGeneratedObservable=new u,h.onBeforeGenerationObservable=new u,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._matrices={},h._fallbackTextureUsed=!1,h._cachedDefines=null,h._contentUpdateId=-1,h._rtWrapper=null;var d=(n=h.getScene()||S.LastCreatedScene)._getComponent(Ji.NAME_PROCEDURALTEXTURE);d||(d=new os(n),n._addComponent(d)),n.proceduralTextures.push(h),h._fullEngine=n.getEngine(),h.name=t,h.isRenderTarget=!0,h._size=i,h._textureType=c,h._generateMipMaps=s,h._drawWrapper=new ei(h._fullEngine),h.setFragment(r),h._fallbackTexture=o;var p=h._createRtWrapper(l,i,s,c);h._texture=p.texture;var f=[];return f.push(1,1),f.push(-1,1),f.push(-1,-1),f.push(1,-1),h._vertexBuffers[ji.PositionKind]=new ji(h._fullEngine,f,ji.PositionKind,!1,!1,2),h._createIndexBuffer(),h}return W(t,e),t.prototype._createRtWrapper=function(e,t,i,r){return e?(this._rtWrapper=this._fullEngine.createRenderTargetCubeTexture(t,{generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:r}),this.setFloat("face",0)):this._rtWrapper=this._fullEngine.createRenderTargetTexture(t,{generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:r}),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[ji.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===ns.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=ns.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.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,[ji.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.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._matrices)this._drawWrapper.effect.setMatrix(f,this._matrices[f])}if(this._texture&&this._rtWrapper){null===(t=n._debugPushGroup)||void 0===t||t.call(n,"procedural texture generation for ".concat(this.name),1);var _=n.currentViewport;if(this.isCube)for(var m=0;m<6;m++)n.bindFramebuffer(this._rtWrapper,m,void 0,void 0,!0),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._drawWrapper.effect.setFloat("face",m),this.autoClear&&n.clear(r.clearColor,!0,!1,!1),n.drawElementsType(Kn.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(Kn.TriangleFillMode,0,6);n.unBindFramebuffer(this._rtWrapper,this.isCube),_&&n.setViewport(_),this.isCube&&n.generateMipMapsForCubemap(this._texture),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[ji.PositionKind];r&&(r.dispose(),this._vertexBuffers[ji.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),e.prototype.dispose.call(this)}},X([Ae()],t.prototype,"isEnabled",void 0),X([Ae()],t.prototype,"autoClear",void 0),X([Ae()],t.prototype,"_generateMipMaps",void 0),X([Ae()],t.prototype,"_size",void 0),X([Ae()],t.prototype,"refreshRate",null),t}(Eo);b("BABYLON.ProceduralTexture",ss),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"}(as||(as={}));var ls=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.operation=as.Cos,i.registerInput("input",ia.AutoDetect),i.registerOutput("output",ia.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return W(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 as.Cos:r="cos";break;case as.Sin:r="sin";break;case as.Abs:r="abs";break;case as.Exp:r="exp";break;case as.Exp2:r="exp2";break;case as.Round:r="round";break;case as.Floor:r="floor";break;case as.Ceiling:r="ceil";break;case as.Sqrt:r="sqrt";break;case as.Log:r="log";break;case as.Tan:r="tan";break;case as.ArcTan:r="atan";break;case as.ArcCos:r="acos";break;case as.ArcSin:r="asin";break;case as.Fract:r="fract";break;case as.Sign:r="sign";break;case as.Radians:r="radians";break;case as.Degrees:r="degrees"}return t.compilationString+=this._declareOutput(i,t)+" = ".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(as[this.operation],";\n")},t}(ha);b("BABYLON.TrigonometryBlock",ls);var cs={effect:null,subMesh:null},us=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=!1,t.TONEMAPPING_ACES=!1,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 W(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}(Di),hs=function(e){function t(i,r,n){void 0===n&&(n={});var o=e.call(this,i,r||S.LastCreatedScene)||this;return o._buildId=t._BuildIdGenerator++,o._buildWasSuccessful=!1,o._cachedWorldViewMatrix=new I,o._cachedWorldViewProjectionMatrix=new I,o._optimizers=new Array,o._animationFrame=-1,o.BJSNODEMATERIALEDITOR=o._getGlobalNodeMaterialEditor(),o.editorData=null,o.ignoreAlpha=!1,o.maxSimultaneousLights=4,o.onBuildObservable=new u,o._vertexOutputNodes=new Array,o._fragmentOutputNodes=new Array,o.attachedBlocks=new Array,o._mode=wa.Material,o.forceAlphaBlending=!1,o._options=H({emitComments:!1},n),o._attachImageProcessingConfiguration(null),o}return W(t,e),t._BlockIsTextureBlock=function(e){return"TextureBlock"===e.getClassName()||"ReflectionTextureBaseBlock"===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,"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 0!=(e.target&ra.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&ra.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&ra.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&ra.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=ra.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=ra.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===ra.VertexAndFragment||t.target===ra.Fragment&&e.target===ra.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===wa.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 la,this._vertexCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._vertexCompilationState.target=ra.Vertex,this._fragmentCompilationState=new la,this._fragmentCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._fragmentCompilationState.target=ra.Fragment,this._sharedData=new ca,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,s){return void 0===t&&(t=1),void 0===i&&(i=a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===o&&(o=a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=a.TEXTUREFORMAT_RGBA),this.mode!==wa.PostProcess?(console.log("Incompatible material mode"),null):this._createEffectForPostProcess(null,e,t,i,r,n,o,s)},t.prototype.createEffectForPostProcess=function(e){this._createEffectForPostProcess(e)},t.prototype._createEffectForPostProcess=function(e,t,i,r,n,o,s,l){var c=this;void 0===i&&(i=1),void 0===r&&(r=a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===s&&(s=a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=a.TEXTUREFORMAT_RGBA);var u=this.name+this._buildId,h=new us,d=new Vn(u+"PostProcess",this.getScene()),p=this._buildId;return this._processDefines(d,h),Gt.RegisterShader(u,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString),e?e.updateEffect(h.toString(),this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,{maxSimultaneousLights:this.maxSimultaneousLights},void 0,void 0,u,u):e=new Na(this.name+"PostProcess",u,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,t,r,n,o,h.toString(),s,u,{maxSimultaneousLights:this.maxSimultaneousLights},!1,l),e.nodeMaterialSource=this,e.onApplyObservable.add((function(t){p!==c._buildId&&(delete Gt.ShadersStore[u+"VertexShader"],delete Gt.ShadersStore[u+"PixelShader"],u=c.name+c._buildId,h.markAllAsDirty(),p=c._buildId),c._processDefines(d,h)&&(Gt.RegisterShader(u,c._fragmentCompilationState._builtCompilationString,c._vertexCompilationState._builtCompilationString),ni.SetImmediate((function(){return e.updateEffect(h.toString(),c._fragmentCompilationState.uniforms,c._fragmentCompilationState.samplers,{maxSimultaneousLights:c.maxSimultaneousLights},void 0,void 0,u,u)}))),c._checkInternals(t)})),e},t.prototype.createProceduralTexture=function(e,t){var i=this;if(this.mode!==wa.ProceduralTexture)return console.log("Incompatible material mode"),null;var r=this.name+this._buildId,n=new ss(r,e,null,t),o=new Vn(r+"Procedural",this.getScene());o.reservedDataStore={hidden:!0};var a=new us,s=this._processDefines(o,a);Gt.RegisterShader(r,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString);var l=this.getScene().getEngine().createEffect({vertexElement:r,fragmentElement:r},[ji.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 Gt.ShadersStore[r+"VertexShader"],delete Gt.ShadersStore[r+"PixelShader"],r=i.name+i._buildId,a.markAllAsDirty(),c=i._buildId);var e=i._processDefines(o,a);e&&(Gt.RegisterShader(r,i._fragmentCompilationState._builtCompilationString,i._vertexCompilationState._builtCompilationString),ni.SetImmediate((function(){l=i.getScene().getEngine().createEffect({vertexElement:r,fragmentElement:r},[ji.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 us),a||(a=this.getScene().getMeshByName(this.name+"Particle"))||((a=new Vn(this.name+"Particle",this.getScene())).reservedDataStore={hidden:!0});var u=this._buildId,h=[],d=s;if(!n){var p=this._processDefines(a,o);Gt.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 Gt.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 Gt.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(jo.EYE_TRACKING)}catch(e){}try{this._handTracking=t.getEnabledFeature(jo.HAND_TRACKING)}catch(e){Ri.Error("Hand tracking must be enabled for the Hand Menu to work")}}else Ri.Error("XR features manager must be available or provided directly for the Hand Menu to work")},e}(),Cs=function(){function e(e,t,i){this.targetPosition=R.Zero(),this.poleTargetPosition=R.Zero(),this.poleTargetLocalOffset=R.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=P.Identity(),this._bone1Mat=I.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=R.Right(),this._slerping=!1,this._adjustRoll=0,this._notEnoughInformation=!1,this._bone2=t;var r=t.getParent();if(!r)return this._notEnoughInformation=!0,void $.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 $.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=R.Distance(s,l),this._bone1Length=R.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=R.Distance(l,c);this._bone1.getRotationMatrixToRef(xr.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&&R.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(),R.CrossToRef(l,c,a),a.normalize(),R.CrossToRef(l,a,s),s.normalize(),I.FromXYZAxesToRef(s,l,a,r);var h=this._bone1Length,d=this._bone2Length,p=R.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)I.RotationYawPitchRollToRef(0,0,this._adjustRoll,n),n.multiplyToRef(r,r),I.RotationAxisToRef(this._bendAxis,g,n),n.multiplyToRef(r,r);else{var y=e._TmpVecs[5];y.copyFrom(this._bendAxis),y.x*=-1,I.RotationAxisToRef(y,-g,n),n.multiplyToRef(r,r)}this.poleAngle&&(I.RotationAxisToRef(l,this.poleAngle,n),r.multiplyToRef(n,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||P.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),P.FromRotationMatrixToRef(r,u),P.SlerpToRef(this._bone1Quat,u,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,xr.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,xr.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1),this._updateLinkedTransformRotation(this._bone1)),this._bone2.setAxisAngle(this._bendAxis,v,xr.LOCAL),this._updateLinkedTransformRotation(this._bone2),this._bone2Ang=v}},e.prototype._updateLinkedTransformRotation=function(e){e._linkedTransformNode&&(e._linkedTransformNode.rotationQuaternion||(e._linkedTransformNode.rotationQuaternion=new P),e.getRotationQuaternionToRef(xr.LOCAL,null,e._linkedTransformNode.rotationQuaternion))},e._TmpVecs=[R.Zero(),R.Zero(),R.Zero(),R.Zero(),R.Zero(),R.Zero()],e._TmpQuat=P.Identity(),e._TmpMats=[I.Identity(),I.Identity()],e}(),Ps=function(){function e(e,t,i,r){if(this.upAxis=R.Up(),this.upAxisSpace=xr.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=P.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=R.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=Cr.Y,o=Cr.X;null!=r.yawAxis&&(n=r.yawAxis.clone()).normalize(),null!=r.pitchAxis&&(o=r.pitchAxis.clone()).normalize();var a=R.Cross(o,n);this._transformYawPitch=I.Identity(),I.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!=xr.BONE||(this.upAxisSpace=xr.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==xr.BONE&&s?(this._transformYawPitch&&R.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),s.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==xr.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==xr.BONE&&1==l.y&&s)s.getRotationMatrixToRef(xr.WORLD,this.mesh,h);else if(this.upAxisSpace!=xr.LOCAL||1!=l.y||s){var p=e._TmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&R.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),s?s.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var f=R.Cross(l,p);f.normalize(),p=R.Cross(f,l),I.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),R.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(Cr.Z),this._transformYawPitch&&R.TransformCoordinatesToRef(E,this._transformYawPitchInv,E);var S=e._TmpMats[4];this._boneQuat.toRotationMatrix(S),this.mesh.getWorldMatrix().multiplyToRef(S,S),R.TransformCoordinatesToRef(E,S,E),R.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&&e0}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){return this.needInitialSkinMatrix?(e._bonesTransformMatrices||this.prepare(),e._bonesTransformMatrices):(this._transformMatrices&&!this._isDirty||this.prepare(),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=R.FromArray(t.dimensionsAtRest)),n.needInitialSkinMatrix=t.needInitialSkinMatrix,r=0;r-1&&(s=n.bones[o.parentBoneIndex]);var l=o.rest?I.FromArray(o.rest):null,c=new Pr(o.name,n,s,I.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(Ke.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=new Array,t=new Array(this.bones.length),i=0;i=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}(),Us=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.onButtonDownObservable=new u,n.onButtonUpObservable=new u,n.type=Bs.GENERIC,n._buttons=new Array(r.buttons.length),n}return W(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"},X([Ae()],e.prototype,"gamepadRotationSensibility",void 0),X([Ae()],e.prototype,"gamepadMoveSensibility",void 0),e}();Fs.ArcRotateCameraGamepadInput=Vs;var ks=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=Ri.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===nr.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=Ri.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i){if(i.type===er.POINTERWHEEL){var r=i.event,n=0,o=r.deltaMode===lr.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=h.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,er.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=yr.FromPositionAndNormal(e.target,t)},e.prototype._getPosition=function(){var e,t=this.camera,i=t.getScene(),r=i.createPickingRay(i.pointerX,i.pointerY,I.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=R.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=O.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)<_&&(e.x=0),Math.abs(e.y)<_&&(e.y=0),Math.abs(e.z)<_&&(e.z=0)},X([Ae()],e.prototype,"wheelPrecision",void 0),X([Ae()],e.prototype,"zoomToMouseLocation",void 0),X([Ae()],e.prototype,"wheelDeltaPercentage",void 0),e}();Fs.ArcRotateCameraMouseWheelInput=Gs;var zs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.useNaturalPinchZoom=!1,t.pinchZoom=!0,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return W(t,e),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype._computeMultiTouchPanning=function(e,t){if(0!==this.panningSensibility&&e&&t){var i=t.x-e.x,r=t.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=r/this.panningSensibility}},t.prototype._computePinchZoom=function(e,i){var r=this.camera.radius||t.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=r*Math.sqrt(e)/Math.sqrt(i):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(i-e)*r*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(i-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)},t.prototype.onTouch=function(e,t,i){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},t.prototype.onDoubleTap=function(){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,i,r,n,o){0===i&&null===n||0===r&&null===o||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,r),this._computeMultiTouchPanning(n,o)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(r)-Math.sqrt(i))>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,X([Ae()],t.prototype,"buttons",void 0),X([Ae()],t.prototype,"angularSensibilityX",void 0),X([Ae()],t.prototype,"angularSensibilityY",void 0),X([Ae()],t.prototype,"pinchPrecision",void 0),X([Ae()],t.prototype,"pinchDeltaPercentage",void 0),X([Ae()],t.prototype,"useNaturalPinchZoom",void 0),X([Ae()],t.prototype,"pinchZoom",void 0),X([Ae()],t.prototype,"panningSensibility",void 0),X([Ae()],t.prototype,"multiTouchPanning",void 0),X([Ae()],t.prototype,"multiTouchPanAndZoom",void 0),t}(Ns);Fs.ArcRotateCameraPointersInput=zs;var Ws=function(e){function t(t){return e.call(this,t)||this}return W(t,e),t.prototype.addMouseWheel=function(){return this.add(new Gs),this},t.prototype.addPointers=function(){return this.add(new zs),this},t.prototype.addKeyboard=function(){return this.add(new ks),this},t}(Ls);Ws.prototype.addVRDeviceOrientation=function(){return this.add(new Hs),this};var Hs=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=Ri.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):Ri.Warn("Permission not granted.")})).catch((function(e){Ri.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}();Fs.ArcRotateCameraVRDeviceOrientationInput=Hs;var Xs=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=Ri.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===nr.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},X([Ae()],e.prototype,"keysHeightOffsetIncr",void 0),X([Ae()],e.prototype,"keysHeightOffsetDecr",void 0),X([Ae()],e.prototype,"keysHeightOffsetModifierAlt",void 0),X([Ae()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),X([Ae()],e.prototype,"keysHeightOffsetModifierShift",void 0),X([Ae()],e.prototype,"keysRotationOffsetIncr",void 0),X([Ae()],e.prototype,"keysRotationOffsetDecr",void 0),X([Ae()],e.prototype,"keysRotationOffsetModifierAlt",void 0),X([Ae()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),X([Ae()],e.prototype,"keysRotationOffsetModifierShift",void 0),X([Ae()],e.prototype,"keysRadiusIncr",void 0),X([Ae()],e.prototype,"keysRadiusDecr",void 0),X([Ae()],e.prototype,"keysRadiusModifierAlt",void 0),X([Ae()],e.prototype,"keysRadiusModifierCtrl",void 0),X([Ae()],e.prototype,"keysRadiusModifierShift",void 0),X([Ae()],e.prototype,"heightSensibility",void 0),X([Ae()],e.prototype,"rotationSensibility",void 0),X([Ae()],e.prototype,"radiusSensibility",void 0),e}();Fs.FollowCameraKeyboardMoveInput=Ys;var Ks=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=Ri.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i){if(i.type===er.POINTERWHEEL){var r=i.event,n=0,o=Math.max(-1,Math.min(1,r.deltaY));t.wheelDeltaPercentage?(console.assert(t.axisControlRadius+t.axisControlHeight+t.axisControlRotation<=1,"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,er.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"},X([Ae()],e.prototype,"axisControlRadius",void 0),X([Ae()],e.prototype,"axisControlHeight",void 0),X([Ae()],e.prototype,"axisControlRotation",void 0),X([Ae()],e.prototype,"wheelPrecision",void 0),X([Ae()],e.prototype,"wheelDeltaPercentage",void 0),e}();Fs.FollowCameraMouseWheelInput=Ks;var Qs=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 W(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: ";console.assert(this.axisXControlRotation+this.axisXControlHeight+this.axisXControlRadius<=1,e+"axisXControlRotation: "+this.axisXControlRotation+", axisXControlHeight: "+this.axisXControlHeight+", axisXControlRadius: "+this.axisXControlRadius),console.assert(this.axisYControlRotation+this.axisYControlHeight+this.axisYControlRadius<=1,e+"axisYControlRotation: "+this.axisYControlRotation+", axisYControlHeight: "+this.axisYControlHeight+", axisYControlRadius: "+this.axisYControlRadius),console.assert(this.axisPinchControlRotation+this.axisPinchControlHeight+this.axisPinchControlRadius<=1,e+"axisPinchControlRotation: "+this.axisPinchControlRotation+", axisPinchControlHeight: "+this.axisPinchControlHeight+", axisPinchControlRadius: "+this.axisPinchControlRadius)}},X([Ae()],t.prototype,"angularSensibilityX",void 0),X([Ae()],t.prototype,"angularSensibilityY",void 0),X([Ae()],t.prototype,"pinchPrecision",void 0),X([Ae()],t.prototype,"pinchDeltaPercentage",void 0),X([Ae()],t.prototype,"axisXControlRadius",void 0),X([Ae()],t.prototype,"axisXControlHeight",void 0),X([Ae()],t.prototype,"axisXControlRotation",void 0),X([Ae()],t.prototype,"axisYControlRadius",void 0),X([Ae()],t.prototype,"axisYControlHeight",void 0),X([Ae()],t.prototype,"axisYControlRotation",void 0),X([Ae()],t.prototype,"axisPinchControlRadius",void 0),X([Ae()],t.prototype,"axisPinchControlHeight",void 0),X([Ae()],t.prototype,"axisPinchControlRotation",void 0),t}(Ns);Fs.FollowCameraPointersInput=Qs;var qs=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=Ri.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===nr.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 R(0,0,0!==this.touchMoveSensibility?i*this._offsetY/this.touchMoveSensibility:0);I.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(R.TransformCoordinates(r,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},X([Ae()],e.prototype,"touchAngularSensibility",void 0),X([Ae()],e.prototype,"touchMoveSensibility",void 0),e}();Fs.FreeCameraTouchInput=el;var tl=function(e){function t(t){var i=e.call(this,t)||this;return i._mouseInput=null,i._mouseWheelInput=null,i}return W(t,e),t.prototype.addKeyboard=function(){return this.add(new qs),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new Js(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 $s,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 el),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}(Ls);tl.prototype.addDeviceOrientation=function(e){return this._deviceOrientationInput||(this._deviceOrientationInput=new il,e&&(this._deviceOrientationInput.smoothFactor=e),this.add(this._deviceOrientationInput)),this};var il=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new P,this._alpha=0,this._beta=0,this._gamma=0,this.smoothFactor=0,this._onDeviceOrientationChangedObservable=new u,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=-Ri.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?Ri.SmoothAngleChange(e._alpha,t.alpha,e.smoothFactor):0,e._beta=null!==t.beta?Ri.SmoothAngleChange(e._beta,t.beta,e.smoothFactor):0,e._gamma=null!==t.gamma?Ri.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 P(-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):Ri.Warn("Permission not granted.")})).catch((function(e){Ri.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 P),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():Ri.Warn("Permission not granted.")})).catch((function(e){Ri.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&&(P.RotationYawPitchRollToRef(Ri.ToRadians(this._alpha),Ri.ToRadians(this._beta),-Ri.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}();Fs.FreeCameraDeviceOrientationInput=il;var rl,nl=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this.deadzoneDelta=.1,this._yAxisScale=1,this._cameraTransform=I.Identity(),this._deltaTransform=R.Zero(),this._vector3=R.Zero(),this._vector2=A.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!==Bs.POSE_ENABLED&&(e.gamepad&&t.type!==Bs.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(Bs.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):I.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),R.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"},X([Ae()],e.prototype,"gamepadAngularSensibility",void 0),X([Ae()],e.prototype,"gamepadMoveSensibility",void 0),e}();Fs.FreeCameraGamepadInput=nl,function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(rl||(rl={}));var ol=function(){function e(t,i){var r=this;this._released=!1;var n=H(H({},e._GetDefaultOptions()),i);if(this._leftJoystick=!!t,e._GlobalJoystickIndex++,this._axisTargetedByLeftAndRight=rl.X,this._axisTargetedByUpAndDown=rl.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new Oi,this.deltaPosition=R.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 A(0,0),this._joystickPreviousPointerPos=new A(0,0),this._joystickPointerStartPos=new A(0,0),this._deltaJoystickVector=new A(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 A(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&&P.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(O.Matrix[0]),R.TransformNormalToRef(this.cameraDirection,O.Matrix[0],O.Vector3[0]),this._deferredPositionUpdate.addInPlace(O.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()&&(P.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)Nn.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 tl(o),o.inputs.addKeyboard().addMouse(),o}return W(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=Ri.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new R(0,0,0),this.cameraRotation=new A(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?R.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=R.Zero(),this._transformedDirection=R.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"},X([Me()],t.prototype,"ellipsoid",void 0),X([Me()],t.prototype,"ellipsoidOffset",void 0),X([Ae()],t.prototype,"checkCollisions",void 0),X([Ae()],t.prototype,"applyGravity",void 0),t}(sl);We.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new cl(e,R.Zero(),t)}}));var cl=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return W(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}(ll);We.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new ul(e,0,0,1,R.Zero(),t)}}));var ul=function(e){function t(t,i,r,n,o,a,s){void 0===s&&(s=!0);var l=e.call(this,t,R.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=R.Zero(),l.panningInertia=.9,l.zoomOnFactor=1,l.targetScreenOffset=A.Zero(),l.allowUpsideDown=!0,l.useInputToRestoreState=!0,l._viewMatrix=new I,l.panningAxis=new R(1,1,0),l._transformedDirection=new R,l.mapPanning=!1,l.onMeshTargetChangedObservable=new u,l.checkCollisions=!1,l.collisionRadius=new R(.5,.5,.5),l._previousPosition=R.Zero(),l._collisionVelocity=R.Zero(),l._newPosition=R.Zero(),l._computationVector=R.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=R.Zero(),o&&l.setTarget(o),l.alpha=i,l.beta=r,l.radius=n,l.getViewMatrix(),l.inputs=new Ws(l),l.inputs.addKeyboard().addMouseWheel().addPointers(),l}return W(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 I,this._upToYMatrix=new I,this._upVector=R.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),t.prototype.setMatUp=function(){I.RotationAlignToRef(R.UpReadOnly,this._upVector,this._yToUpMatrix),I.RotationAlignToRef(this._upVector,R.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 Io,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 Mo,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 Po,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 R(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=A.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=Ri.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)<_&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<_&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)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||R.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.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():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||R.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=io.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=io.MinMax(n),r=R.Distance(i.min,i.max)}else i=e,r=e.distance;this._target=io.Center(i),t||(this.maxZ=2*r)},t.prototype.createRigCamera=function(e,i){var r=0;switch(this.cameraRigMode){case dn.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case dn.RIG_MODE_STEREOSCOPIC_OVERUNDER:case dn.RIG_MODE_STEREOSCOPIC_INTERLACED:case dn.RIG_MODE_VR:r=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case dn.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 dn.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case dn.RIG_MODE_STEREOSCOPIC_OVERUNDER:case dn.RIG_MODE_STEREOSCOPIC_INTERLACED:case dn.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case dn.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=R.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"},X([Ae()],t.prototype,"alpha",void 0),X([Ae()],t.prototype,"beta",void 0),X([Ae()],t.prototype,"radius",void 0),X([Ae()],t.prototype,"overrideCloneAlphaBetaRadius",void 0),X([Me("target")],t.prototype,"_target",void 0),X([Oe("targetHost")],t.prototype,"_targetHost",void 0),X([Ae()],t.prototype,"inertialAlphaOffset",void 0),X([Ae()],t.prototype,"inertialBetaOffset",void 0),X([Ae()],t.prototype,"inertialRadiusOffset",void 0),X([Ae()],t.prototype,"lowerAlphaLimit",void 0),X([Ae()],t.prototype,"upperAlphaLimit",void 0),X([Ae()],t.prototype,"lowerBetaLimit",void 0),X([Ae()],t.prototype,"upperBetaLimit",void 0),X([Ae()],t.prototype,"lowerRadiusLimit",void 0),X([Ae()],t.prototype,"upperRadiusLimit",void 0),X([Ae()],t.prototype,"inertialPanningX",void 0),X([Ae()],t.prototype,"inertialPanningY",void 0),X([Ae()],t.prototype,"pinchToPanMaxDistance",void 0),X([Ae()],t.prototype,"panningDistanceLimit",void 0),X([Me()],t.prototype,"panningOriginTarget",void 0),X([Ae()],t.prototype,"panningInertia",void 0),X([Ae()],t.prototype,"zoomToMouseLocation",null),X([Ae()],t.prototype,"zoomOnFactor",void 0),X([Ie()],t.prototype,"targetScreenOffset",void 0),X([Ae()],t.prototype,"allowUpsideDown",void 0),X([Ae()],t.prototype,"useInputToRestoreState",void 0),t}(sl);We.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new hl(e,R.Zero(),t)}}));var hl=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n._tmpDragQuaternion=new P,n._disablePointerInputWhenUsingDeviceOrientation=!0,n._dragFactor=0,n._quaternionCache=new P,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 P),P.FromEulerAnglesToRef(0,e.offsetX*n._dragFactor,0,n._tmpDragQuaternion),n._initialQuaternion.multiplyToRef(n._tmpDragQuaternion,n._initialQuaternion))})))})),n}return W(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=Cr.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new P),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}(ll),dl=function(e){function t(t){return e.call(this,t)||this}return W(t,e),t.prototype.addKeyboard=function(){return this.add(new Xs),this},t.prototype.addMouse=function(){return this.add(new js),this},t}(Ls),pl=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 R(1,1,1),o.ellipsoidOffset=new R(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o.cameraDirection=R.Zero(),o._trackRoll=0,o.rollCorrect=100,o.bankedTurn=!1,o.bankedTurnLimit=Math.PI/2,o.bankedTurnMultiplier=1,o._needMoveForGravity=!1,o._oldPosition=R.Zero(),o._diffPosition=R.Zero(),o._newPosition=R.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()>Nn.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new dl(o),o.inputs.addKeyboard().addMouse(),o}return W(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=Ri.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new R(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?R.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=R.Zero(),this._transformedDirection=R.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"},X([Me()],t.prototype,"ellipsoid",void 0),X([Me()],t.prototype,"ellipsoidOffset",void 0),X([Ae()],t.prototype,"checkCollisions",void 0),X([Ae()],t.prototype,"applyGravity",void 0),t}(sl),fl=function(e){function t(t){return e.call(this,t)||this}return W(t,e),t.prototype.addKeyboard=function(){return this.add(new Ys),this},t.prototype.addMouseWheel=function(){return this.add(new Ks),this},t.prototype.addPointers=function(){return this.add(new Qs),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(Ls);We.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new gl(e,R.Zero(),t)}})),We.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new vl(e,0,0,1,null,t)}}));var _l,ml,gl=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 fl(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return W(t,e),t.prototype._follow=function(e){if(e){var t=O.Matrix[0];e.absoluteRotationQuaternion.toRotationMatrix(t);var i=Math.atan2(t.m[8],t.m[10]),r=Ri.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 R(this.position.x+u,this.position.y+h,this.position.z+d),this.setTarget(n)}},t.prototype.attachControl=function(e,t){t=Ri.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"},X([Ae()],t.prototype,"radius",void 0),X([Ae()],t.prototype,"lowerRadiusLimit",void 0),X([Ae()],t.prototype,"upperRadiusLimit",void 0),X([Ae()],t.prototype,"rotationOffset",void 0),X([Ae()],t.prototype,"lowerRotationOffsetLimit",void 0),X([Ae()],t.prototype,"upperRotationOffsetLimit",void 0),X([Ae()],t.prototype,"heightOffset",void 0),X([Ae()],t.prototype,"lowerHeightOffsetLimit",void 0),X([Ae()],t.prototype,"upperHeightOffsetLimit",void 0),X([Ae()],t.prototype,"cameraAcceleration",void 0),X([Ae()],t.prototype,"maxCameraSpeed",void 0),X([Oe("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(sl),vl=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,R.Zero(),a)||this;return s.alpha=i,s.beta=r,s.radius=n,s._cartesianCoordinates=R.Zero(),s.setMeshTarget(o),s}return W(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}(sl);!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"}(_l||(_l={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(ml||(ml={}));var yl,bl,Tl=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 u,o.onButtonUpObservable=new u,o.onPadDownObservable=new u,o.onPadUpObservable=new u,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=Bs.XBOX,o._isXboxOnePad=n,o}return W(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,_l.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,_l.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,_l.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,_l.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,_l.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,_l.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,_l.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,_l.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,_l.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,_l.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,ml.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,ml.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,ml.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,ml.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}(Bs);!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"}(yl||(yl={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(bl||(bl={}));var El=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 u,n.onButtonUpObservable=new u,n.onPadDownObservable=new u,n.onPadUpObservable=new u,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=Bs.DUALSHOCK,n}return W(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,yl.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,yl.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,yl.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,yl.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,yl.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,yl.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,yl.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,yl.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,yl.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,yl.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,bl.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,bl.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,bl.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,bl.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}(Bs),Sl=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new u,it()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator&&navigator.getGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new u((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=Bs.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 Ve.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)}),e,r,n)},t}(Na);Nn._RescalePostProcessFactory=function(e){return new Cl("rescale",1,null,a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,a.TEXTURETYPE_UNSIGNED_INT)};kt.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 Il=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 W(t,e),t.prototype.getClassName=function(){return"AnaglyphPostProcess"},t}(Na);function Ml(e){e._rigCameras[0]._rigPostProcess=new Cl(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new Il(e.name+"_anaglyph",1,e._rigCameras)}b("BABYLON.AnaglyphPostProcess",Il),We.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,i){return function(){return new Ol(e,0,0,1,R.Zero(),i.interaxial_distance,t)}}));var Ol=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 Ml(l)},l.interaxialDistance=a,l.setCameraRigMode(dn.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),l}return W(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(ul);We.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,i){return function(){return new Dl(e,R.Zero(),i.interaxial_distance,t)}}));var Dl=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o._setRigMode=function(){return Ml(o)},o.interaxialDistance=r,o.setCameraRigMode(dn.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return W(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(ll);We.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,i){return function(){return new Nl(e,R.Zero(),i.interaxial_distance,t)}}));var Nl=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o._setRigMode=function(){return Ml(o)},o.interaxialDistance=r,o.setCameraRigMode(dn.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return W(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(Rl);We.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,i){return function(){return new Fl(e,R.Zero(),i.interaxial_distance,t)}}));var Fl=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o._setRigMode=function(){return Ml(o)},o.interaxialDistance=r,o.setCameraRigMode(dn.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return W(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(Al);kt.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 Ll=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 A(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new A(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 W(t,e),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcessI"},t}(Na),wl=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 A(1/s.width,1/s.height),s.onSizeChangedObservable.add((function(){s._stepSize=new A(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 W(t,e),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcess"},t}(Na);function Bl(e){var t=e.cameraRigMode===dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,i=e.cameraRigMode===dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e.cameraRigMode===dn.RIG_MODE_STEREOSCOPIC_INTERLACED?(e._rigCameras[0]._rigPostProcess=new Cl(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new Ll(e.name+"_stereoInterlace",e._rigCameras,!1,!0)):(e._rigCameras[i?1:0].viewport=new hn(0,0,t?.5:1,t?1:.5),e._rigCameras[i?0:1].viewport=new hn(t?.5:0,t?0:.5,t?.5:1,t?1:.5))}We.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,i){return function(){return new Ul(e,0,0,1,R.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ul=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 Bl(c)},c.interaxialDistance=a,c.isStereoscopicSideBySide=s,c.setCameraRigMode(s?dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:dn.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),c}return W(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(ul);We.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new Vl(e,R.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Vl=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,o)||this;return a._setRigMode=function(){return Bl(a)},a.interaxialDistance=r,a.isStereoscopicSideBySide=n,a.setCameraRigMode(n?dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:dn.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return W(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(ll);We.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,i){return function(){return new kl(e,R.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var kl=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,o)||this;return a._setRigMode=function(){return Bl(a)},a.interaxialDistance=r,a.isStereoscopicSideBySide=n,a.setCameraRigMode(n?dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:dn.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return W(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(Rl);We.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new Gl(e,R.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Gl=function(e){function t(t,i,r,n,o){var a=e.call(this,t,i,o)||this;return a._setRigMode=function(){return Bl(a)},a.interaxialDistance=r,a.isStereoscopicSideBySide=n,a.setCameraRigMode(n?dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:dn.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return W(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(Al),zl=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(dn.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,{stereoHalfAngle:0}),a._cameraRigParams.stereoHalfAngle=0,a._cameraRigParams.interaxialDistance=o,a}return W(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 sl(e,R.Zero(),this.getScene()),i=new Ln("tm_"+e,this.getScene());return t.parent=i,i.setPivotMatrix(I.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 Xl=function(e){function t(t,i,r,n){var o=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,n.postProcessScaleFactor,i,Eo.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 A(2,2/o.aspectRatio),o._scaleFactor=new A(1/o._postProcessScaleFactor*.5,1/o._postProcessScaleFactor*.5*o.aspectRatio),o._lensCenter=new A(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 W(t,e),t.prototype.getClassName=function(){return"VRDistortionCorrectionPostProcess"},t}(Na);kt.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 jl=function(e){function t(t,i){void 0===i&&(i=512);var r=e.call(this,"multiview rtt",i,t,!1,!0,a.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=a.TEXTUREFORMAT_RGBA,r.samples=r._getEngine().getCaps().maxSamples||r.samples,r._texture.samples=r._samples,r}return W(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}(ns);function Yl(e,t){var i=new Hi(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}Nn.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 jt(this,Ot.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},Nn.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))},Nn.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)},dn.prototype._useMultiviewToSingleView=!1,dn.prototype._multiviewTexture=null,dn.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new jl(this.getScene(),{width:e,height:t})):this._multiviewTexture=new jl(this.getScene(),{width:e,height:t})};var Kl=Ar.prototype.createSceneUniformBuffer;Ar.prototype._transformMatrixR=I.Zero(),Ar.prototype._multiviewSceneUbo=null,Ar.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=Yl(this.getEngine(),"scene_multiview")},Ar.prototype.createSceneUniformBuffer=function(e){return this._multiviewSceneUbo?Yl(this.getEngine(),e):Kl.bind(this)(e)},Ar.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,O.Matrix[0]),br.GetRightPlaneToRef(O.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))},Ar.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 Xn.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=at.GLSL;l={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:i._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:i._engine.supportsUniformBuffers,shadersRepository:kt.GetShadersRepository(o),includesShadersStore:kt.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,Vt._ProcessIncludes(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 _=ic.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:nc.push([e,t])}function lc(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"}]}},X([Re("detailTexture"),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),X([Ae()],t.prototype,"diffuseBlendLevel",void 0),X([Ae()],t.prototype,"roughnessBlendLevel",void 0),X([Ae()],t.prototype,"bumpLevel",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"normalBlendMethod",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),t}(uc),pc={effect:null,subMesh:null},fc=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=!1,i.TONEMAPPING_ACES=!1,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 W(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,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===Eo.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,o.REFLECTIONMAP_OPPOSITEZ=o.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!this._reflectionTexture.invertZ:this._reflectionTexture.invertZ,o.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case Eo.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case Eo.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case Eo.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case Eo.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case Eo.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case Eo.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case Eo.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case Eo.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case Eo.CUBIC_MODE:case Eo.INVCUBIC_MODE:default:o.setReflectionMode("REFLECTIONMAP_CUBIC")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1,o.REFLECTIONMAP_OPPOSITEZ=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;jn.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;jn.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,o.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;jn.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;jn.PrepareDefinesForMergedUV(this._bumpTexture,o,"BUMP"),o.PARALLAX=this._useParallax,o.PARALLAX_RHS=n.useRightHandedSystem,o.PARALLAXOCCLUSION=this._useParallaxOcclusion,o.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else o.BUMP=!1,o.PARALLAX=!1,o.PARALLAX_RHS=!1,o.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;o._needUVs=!0,o.REFRACTION=!0,o.REFRACTIONMAP_3D=this._refractionTexture.isCube,o.RGBDREFRACTION=this._refractionTexture.isRGBD,o.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize}else o.REFRACTION=!1;o.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else o.DIFFUSE=!1,o.AMBIENT=!1,o.OPACITY=!1,o.REFLECTION=!1,o.EMISSIVE=!1,o.LIGHTMAP=!1,o.BUMP=!1,o.REFRACTION=!1;o.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),o.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,o.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,o.SPECULAROVERALPHA=this._useSpecularOverAlpha,o.PREMULTIPLYALPHA=this.alphaMode===a.ALPHA_PREMULTIPLIED||this.alphaMode===a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,o.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=o,this._eventInfo.subMesh=i,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}o._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(o.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,o.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,o.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,o.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,o.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,o.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,o._needNormals=!0,o.FRESNEL=!0):o.FRESNEL=!1),jn.PrepareDefinesForMisc(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,o,this._applyDecalMapAfterDetailMap),jn.PrepareDefinesForFrameBoundValues(n,s,this,o,r,null,i.getRenderingMesh().hasThinInstances),this._eventInfo.defines=o,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),jn.PrepareDefinesForAttributes(e,o,!0,!0,!0),this._callbackPluginEventPrepareDefines(this._eventInfo);var u=!1;if(o.isDirty){var h=o._areLightsDisposed;o.markAsProcessed();var d=new Ma;o.REFLECTION&&d.addFallback(0,"REFLECTION"),o.SPECULAR&&d.addFallback(0,"SPECULAR"),o.BUMP&&d.addFallback(0,"BUMP"),o.PARALLAX&&d.addFallback(1,"PARALLAX"),o.PARALLAX_RHS&&d.addFallback(1,"PARALLAX_RHS"),o.PARALLAXOCCLUSION&&d.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&d.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&d.addFallback(1,"FOG"),o.POINTSIZE&&d.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&d.addFallback(0,"LOGARITHMICDEPTH"),jn.HandleFallbacksForShadows(o,d,this._maxSimultaneousLights),o.SPECULARTERM&&d.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&d.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&d.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&d.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&d.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&d.addFallback(4,"FRESNEL"),o.MULTIVIEW&&d.addFallback(0,"MULTIVIEW");var p=[ji.PositionKind];for(o.NORMAL&&p.push(ji.NormalKind),o.TANGENT&&p.push(ji.TangentKind),c=1;c<=a.MAX_SUPPORTED_UV_SETS;++c)o["UV"+c]&&p.push("uv".concat(1===c?"":c));o.VERTEXCOLOR&&p.push(ji.ColorKind),jn.PrepareAttributesForBones(p,e,o,d),jn.PrepareAttributesForInstances(p,o),jn.PrepareAttributesForMorphTargets(p,e,o),jn.PrepareAttributesForBakedVertexAnimation(p,e,o);var f="default",_=["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"],m=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],g=["Material","Scene","Mesh"],v={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=d,this._eventInfo.fallbackRank=0,this._eventInfo.defines=o,this._eventInfo.uniforms=_,this._eventInfo.attributes=p,this._eventInfo.samplers=m,this._eventInfo.uniformBuffersNames=g,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=v,this._callbackPluginEventGeneric(Xn.PrepareEffect,this._eventInfo),ec.AddUniforms(_),ec.AddSamplers(m),Li&&(Li.PrepareUniforms(_,o),Li.PrepareSamplers(m,o)),jn.PrepareUniformsAndSamplersList({uniformsNames:_,uniformBuffersNames:g,samplers:m,defines:o,maxSimultaneousLights:this._maxSimultaneousLights}),kn(_);var y={};this.customShaderNameResolve&&(f=this.customShaderNameResolve(f,_,g,m,o,p,y));var b=o.toString(),T=i.effect,E=n.getEngine().createEffect(f,{attributes:p,uniformsNames:_,uniformBuffersNames:g,samplers:m,defines:b,fallbacks:d,onCompiled:this.onCompiled,onError:this.onError,indexParameters:v,processFinalCode:y.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:o.PREPASS},s);if(this._eventInfo.customCode=void 0,E)if(this._onEffectCreatedObservable&&(pc.effect=E,pc.subMesh=i,this._onEffectCreatedObservable.notifyObservers(pc)),this.allowShaderHotSwapping&&T&&!E.isReady()){if(E=T,o.markAsUnprocessed(),u=this.isFrozen,h)return o._areLightsDisposed=!0,!1}else n.resetCachedMaterial(),i.setEffect(E,o,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(o._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!u,i.effect._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=s._forceRebindOnNextCall||this._mustRebind(o,s,i.visibility);jn.BindBonesParameters(i,s);var c=this._uniformBuffer;if(l){if(this.bindViewProjection(s),!c.useUbo||!this.isFrozen||!c.isSync||s._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 B(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),jn.BindTextureMatrix(this._diffuseTexture,c,"diffuse")),this._ambientTexture&&t.AmbientTextureEnabled&&(c.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),jn.BindTextureMatrix(this._ambientTexture,c,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(c.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),jn.BindTextureMatrix(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),jn.BindTextureMatrix(this._emissiveTexture,c,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(c.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),jn.BindTextureMatrix(this._lightmapTexture,c,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(c.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),jn.BindTextureMatrix(this._specularTexture,c,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(c.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),jn.BindTextureMatrix(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:B.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),Wn(s,this,o),this.bindEyePosition(s)}else o.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!l&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&jn.BindLights(o,i,s,a,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==Ar.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||i.receiveShadows||a.PREPASS)&&this.bindView(s),jn.BindFogParameters(o,i,s),a.NUM_MORPH_INFLUENCERS&&jn.BindMorphTargetParameters(i,s),a.BAKED_VERTEX_ANIMATION_TEXTURE&&(null===(n=i.bakedVertexAnimationManager)||void 0===n||n.bind(s,a.INSTANCES)),this.useLogarithmicDepth&&jn.BindLogDepth(a,s,o),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(i,this._activeEffect),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=Ve.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=Ve.Parse((function(){return new t(e.name,i)}),e,i,r);return e.stencil&&n.stencil.parse(e.stencil,i,r),Kn._parsePlugins(e,n,i,r),n},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return tc.DiffuseTextureEnabled},set:function(e){tc.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DetailTextureEnabled",{get:function(){return tc.DetailTextureEnabled},set:function(e){tc.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return tc.AmbientTextureEnabled},set:function(e){tc.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return tc.OpacityTextureEnabled},set:function(e){tc.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return tc.ReflectionTextureEnabled},set:function(e){tc.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return tc.EmissiveTextureEnabled},set:function(e){tc.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return tc.SpecularTextureEnabled},set:function(e){tc.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return tc.BumpTextureEnabled},set:function(e){tc.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return tc.LightmapTextureEnabled},set:function(e){tc.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return tc.RefractionTextureEnabled},set:function(e){tc.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return tc.ColorGradingTextureEnabled},set:function(e){tc.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return tc.FresnelEnabled},set:function(e){tc.FresnelEnabled=e},enumerable:!1,configurable:!0}),X([Re("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),X([xe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),X([Re("ambientTexture")],t.prototype,"_ambientTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),X([Re("opacityTexture")],t.prototype,"_opacityTexture",void 0),X([xe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),X([Re("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),X([Re("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),X([Re("specularTexture")],t.prototype,"_specularTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),X([Re("bumpTexture")],t.prototype,"_bumpTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),X([Re("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),X([Re("refractionTexture")],t.prototype,"_refractionTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),X([Ce("ambient")],t.prototype,"ambientColor",void 0),X([Ce("diffuse")],t.prototype,"diffuseColor",void 0),X([Ce("specular")],t.prototype,"specularColor",void 0),X([Ce("emissive")],t.prototype,"emissiveColor",void 0),X([Ae()],t.prototype,"specularPower",void 0),X([Ae("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),X([xe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),X([Ae("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),X([Ae("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),X([Ae("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),X([Ae("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),X([Ae("disableLighting")],t.prototype,"_disableLighting",void 0),X([xe("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),X([Ae("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),X([Ae("useParallax")],t.prototype,"_useParallax",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),X([Ae("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),X([Ae()],t.prototype,"parallaxScaleBias",void 0),X([Ae("roughness")],t.prototype,"_roughness",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),X([Ae()],t.prototype,"indexOfRefraction",void 0),X([Ae()],t.prototype,"invertRefractionY",void 0),X([Ae()],t.prototype,"alphaCutOff",void 0),X([Ae("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),X([Pe("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),X([xe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),X([Pe("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),X([xe("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),X([Pe("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),X([xe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),X([Pe("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),X([xe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),X([Pe("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),X([xe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),X([Ae("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),X([xe("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),X([Ae("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),X([Ae("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),X([xe("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),X([Ae("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),X([Ae("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),X([Ae("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),X([Ae("applyDecalMapAfterDetailMap")],t.prototype,"_applyDecalMapAfterDetailMap",void 0),X([xe("_markAllSubMeshesAsMiscDirty")],t.prototype,"applyDecalMapAfterDetailMap",void 0),X([Ae()],t.prototype,"useLogarithmicDepth",null),t}(oa);b("BABYLON.StandardMaterial",_c),Ar.DefaultMaterialFactory=function(e){return new _c("default material",e)},ri.prototype.createDynamicTexture=function(e,t,i,r){var n=new jt(this,Ot.Dynamic);return n.baseWidth=e,n.baseHeight=t,i&&(e=this.needPOTTextures?ri.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?ri.GetExponentOfTwo(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},ri.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),e.isReady=!0}};var mc,gc,vc=function(e){function t(t,i,r,n,o,s,l){void 0===r&&(r=null),void 0===n&&(n=!1),void 0===o&&(o=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===s&&(s=a.TEXTUREFORMAT_RGBA);var c=e.call(this,null,r,!n,l,o,void 0,void 0,void 0,void 0,s)||this;c.name=t,c.wrapU=Eo.CLAMP_ADDRESSMODE,c.wrapV=Eo.CLAMP_ADDRESSMODE,c._generateMipMaps=n;var u=c._getEngine();if(!u)return c;i.getContext?(c._canvas=i,c._texture=u.createDynamicTexture(i.width,i.height,n,o)):(c._canvas=u.createCanvas(1,1),i.width||0===i.width?c._texture=u.createDynamicTexture(i.width,i.height,n,o):c._texture=u.createDynamicTexture(i,i,n,o));var h=c.getSize();return c._canvas.width!==h.width&&(c._canvas.width=h.width),c._canvas.height!==h.height&&(c._canvas.height=h.height),c._context=c._canvas.getContext("2d"),c}return W(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(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.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.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()&&$.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}(Eo),yc=function(){function e(e,t,i,r,n){this.getWidth=e,this.getHeight=t,this.layer=i,this.layerType=r,this.createRenderTargetTextureProvider=n}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}(),bc=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 jt(this._engine,Ot.Unknown,!0);return i.width=e.width,i.height=e.height,i._hardwareTexture=new $t(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 jl(this._scene,a):new ns("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(),"undefined"!=typeof XRWebGLBinding&&(s.skipInitialClear=!0),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}(),Tc=function(e){function t(t){var i=e.call(this,(function(){return t.framebufferWidth}),(function(){return t.framebufferHeight}),t,"XRWebGLLayer",(function(e){return new Ec(e.scene,i)}))||this;return i.layer=t,i}return W(t,e),t}(yc),Ec=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 W(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}(bc),Sc=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}(),xc=function(){function e(e,t){void 0===t&&(t=Sc.GetDefaults());var i=this;if(this._options=t,this._canvas=null,this._engine=null,this.xrLayer=null,this._xrLayerWrapper=null,this.onXRLayerInitObservable=new u,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()}))}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype.initializeXRLayerAsync=function(e){return j(this,void 0,void 0,(function(){var t,i=this;return Y(this,(function(r){return t=function(){return i.xrLayer=new XRWebGLLayer(e,i.canvasContext,i._options.canvasOptions),i._xrLayerWrapper=new Tc(i.xrLayer),i.onXRLayerInitObservable.notifyObservers(i.xrLayer),i.xrLayer},this.canvasContext.makeXRCompatible?[2,this.canvasContext.makeXRCompatible().then((function(){}),(function(){Ri.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.")})).then((function(){return t()}))]:[2,Promise.resolve(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}(),Ac=function(e){function t(t){var i=e.call(this,(function(){return t.framebufferWidth}),(function(){return t.framebufferHeight}),t,"XRWebGLLayer",(function(e){return new Rc(e,i)}))||this;return i.layer=t,i}return W(t,e),t}(yc),Rc=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 W(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}(bc),Cc=function(){function e(e){this._nativeRenderTarget=navigator.xr.getWebXRRenderTarget(e.scene.getEngine())}return e.prototype.initializeXRLayerAsync=function(e){return j(this,void 0,void 0,(function(){return Y(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}(),Pc=function(){function e(e){var t=this;this.scene=e,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new u,this.onXRReferenceSpaceChanged=new u,this.onXRSessionEnded=new u,this.onXRSessionInit=new u,this.inXRFrameLoop=!1,this.inXRSession=!1,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,"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(),null===(e=this._engine)||void 0===e||e.onDisposeObservable.remove(this._onEngineDisposedObserver),this._engine=null},e.prototype.exitXRAsync=function(){return this.session&&this.inXRSession?(this.inXRSession=!1,this.session.end().catch((function(){$.Warn("Could not end XR session.")}))):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 Cc(this):((e=e||Sc.GetDefaults(t)).canvasElement=e.canvasElement||t.getRenderingCanvas()||void 0,new xc(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.onXRSessionInit.notifyObservers(t),i.inXRSession=!0,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;t.inXRSession&&t._engine&&(t.currentFrame=i,t.currentTimestamp=e,i&&(t.inXRFrameLoop=!0,t._engine.framebufferDimensionsObject=(null===(r=t._baseLayerRTTProvider)||void 0===r?void 0:r.getFramebufferDimensions())||null,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,"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 $.Error("XR.requestReferenceSpace failed for the following reason: "),$.Error(e),$.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 $.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.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 Ac(e.baseLayer):new Tc(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 $.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"}(mc||(mc={})),function(e){e[e.NOT_TRACKING=0]="NOT_TRACKING",e[e.TRACKING_LOST=1]="TRACKING_LOST",e[e.TRACKING=2]="TRACKING"}(gc||(gc={})),io._GroundMeshParser=function(e,t){return Ic.Parse(e,t)};var Ic=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.generateOctree=!1,r}return W(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=O.Matrix[5];i.invertToRef(r);var n=O.Vector3[8];if(R.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 R.TransformCoordinatesFromFloatsToRef(0,a,0,i,n),n.y},t.prototype.getNormalAtCoordinates=function(e,t){var i=new R(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var r=this.getWorldMatrix(),n=O.Matrix[5];r.invertToRef(n);var o=O.Vector3[8];if(R.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 R.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 R(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,m=e.buffer[d+2]/255,g=e.buffer[d+3]/255;c&&(p=1-p,f=1-f,m=1-m);var v=p*s.r+f*s.g+m*s.b;h.y=g>=l?e.minHeight+(e.maxHeight-e.minHeight)*v:e.minHeight-_,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,x=n[3*b+1]>=e.minHeight,A=n[3*T+1]>=e.minHeight;S&&x&&A&&(r.push(y),r.push(b),r.push(T)),n[3*E+1]>=e.minHeight&&S&&A&&(r.push(E),r.push(y),r.push(T))}Rn.ComputeNormals(n,r,o);var C=new Rn;return C.indices=r,C.positions=n,C.normals=o,C.uvs=a,C}function Nc(e,t,i){void 0===t&&(t={});var r=new Ic(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,Mc(t).applyToMesh(r,t.updatable),r._setReady(!0),r}function Fc(e,t,i){void 0===i&&(i=null);var r=new io(e,i);return Oc(t).applyToMesh(r,t.updatable),r}function Lc(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 B(.3,.59,.11),u=i.alphaFilter||0,h=i.updatable,d=i.onReady;r=r||S.LastCreatedScene;var p=new Ic(e,r);return p._subdivisionsX=a,p._subdivisionsY=a,p._width=n,p._height=o,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1),Ri.LoadImage(t,(function(e){var t=e.width,i=e.height;if(!r.isDisposed){var f=null==r?void 0:r.getEngine().resizeImageBitmap(e,t,i);Dc({width:n,height:o,subdivisions:a,minHeight:s,maxHeight:l,colorFilter:c,buffer:f,bufferWidth:t,bufferHeight:i,alphaFilter:u}).applyToMesh(p,h),d&&d(p),p._setReady(!0)}}),(function(){}),r.offlineProvider),p}var wc={CreateGround:Nc,CreateGroundFromHeightMap:Lc,CreateTiledGround:Fc};function Bc(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||Rn.DEFAULTSIDE,c=s+1,u=0;u<=s;u++)for(var h=u/s,d=u*Math.PI*2/s-Math.PI/2,p=I.Translation(o/2,0,0).multiply(I.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 R(g,v,0),b=y.scale(a/2),T=new A(h,_);b=R.TransformCoordinates(b,p),y=R.TransformNormal(y,p),i.push(b.x,b.y,b.z),r.push(y.x,y.y,y.z),n.push(T.x,Pn.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)}Rn._ComputeSides(l,i,t,r,n,e.frontUVs,e.backUVs);var x=new Rn;return x.indices=t,x.positions=i,x.normals=r,x.uvs=n,x}function Uc(e,t,i){void 0===t&&(t={});var r=new io(e,i);return t.sideOrientation=io._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,Bc(t).applyToMesh(r,t.updatable),r}Rn.CreateGround=Mc,Rn.CreateTiledGround=Oc,Rn.CreateGroundFromHeightMap=Dc,io.CreateGround=function(e,t,i,r,n,o){return Nc(e,{width:t,height:i,subdivisions:r,updatable:o},n)},io.CreateTiledGround=function(e,t,i,r,n,o,a,s,l){return Fc(e,{xmin:t,zmin:i,xmax:r,zmax:n,subdivisions:o,precision:a,updatable:l},s)},io.CreateGroundFromHeightMap=function(e,t,i,r,n,o,a,s,l,c,u){return Lc(e,t,{width:i,height:r,subdivisions:n,minHeight:o,maxHeight:a,updatable:l,onReady:c,alphaFilter:u},s)};var Vc={CreateTorus:Uc};Rn.CreateTorus=Bc,io.CreateTorus=function(e,t,i,r,n,o,a){return Uc(e,{diameter:t,thickness:i,tessellation:r,sideOrientation:a,updatable:o},n)};var kc,Gc=function(e){function t(t,i){var r=e.call(this,i)||this;return r._getCamera=t,r}return W(t,e),t.prototype._getForwardRay=function(e){var t=this._getCamera();return t?t.getForwardRay(e):new Fo(R.Zero(),R.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=Uc("gazeTracker",{diameter:.0035,thickness:.0025,tessellation:20,updatable:!1},t),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var r=new _c("targetMat",t);r.specularColor=B.Black(),r.emissiveColor=new B(.7,.7,.7),r.backFaceCulling=!1,this._gazeTracker.material=r}}return e.prototype._getForwardRay=function(e){return new Fo(R.Zero(),new R(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}()),zc=function(){},Wc=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 u,this.onAfterEnteringVRObservable=new u,this.onExitingVRObservable=new u,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 R(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new R(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._pickedLaserColor=new B(.2,.2,1),this._pickedGazeColor=new B(0,0,1),this.onNewMeshSelected=new u,this.onNewMeshPicked=new u,this.onBeforeCameraTeleport=new u,this.onAfterCameraTeleport=new u,this.onSelectedMeshUnselected=new u,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!==Bs.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===Bs.XBOX&&(e.onbuttondown((function(e){r._interactionsEnabled&&e===_l.A&&r._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){r._interactionsEnabled&&e===_l.A&&r._cameraGazer._selectionPointerUp()}))))},this._workingVector=R.Zero(),this._workingQuaternion=P.Identity(),this._workingMatrix=I.Identity(),$.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 R(0,this._defaultHeight,0),i.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new hl("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 sl&&this._scene.activeCamera.rotation)){var n=this._scene.activeCamera;n.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(n.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(P.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?Pc.IsSessionSupportedAsync("immersive-vr").then((function(e){e?($.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 Gc((function(){return r.xr.baseExperience.camera}),t),r.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case mc.ENTERING_XR:r.onEnteringVRObservable.notifyObservers(r),r._interactionsEnabled||r.xr.pointerSelection.detach(),r.xr.pointerSelection.displayLaserPointer=r._displayLaserPointer;break;case mc.EXITING_XR:r.onExitingVRObservable.notifyObservers(r),r._scene.getEngine().resize();break;case mc.IN_XR:r._hasEnteredVR=!0;break;case mc.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 Jl("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._cameraGazer=new Gc((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())}),er.POINTERDOUBLETAP,!1),e.onDisposeObservable.add((function(){i.dispose()})),this._updateButtonVisibility(),this._circleEase=new kr,this._circleEase.setEasingMode(Vr.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){i._interactionsEnabled&&e.activeCamera===i.vrDeviceOrientationCamera&&"mouse"===t.event.pointerType&&(t.type===er.POINTERDOWN?i._cameraGazer._selectionPointerDown():t.type===er.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===mc.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){$.Warn("Error in your custom logic onEnteringVR: "+e)}this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=P.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){$.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===mc.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 Li;o.vignetteColor=new U(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=P.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),r=this.currentVRCamera.position;i.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,P.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),R.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var n=new Fo(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=Nc("teleportationTarget",{width:2,height:2,subdivisions:2},this._scene),this._teleportationTarget.isPickable=!1;var e=new vc("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 _c("TextPlaneMaterial",this._scene);i.diffuseTexture=e,this._teleportationTarget.material=i;var r=Uc("torusTeleportation",{diameter:.75,thickness:.1,tessellation:25,updatable:!1},this._scene);r.isPickable=!1,r.parent=this._teleportationTarget;var n=new Ke("animationInnerCircle","position.y",30,Ke.ANIMATIONTYPE_FLOAT,Ke.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 qr;a.setEasingMode(Vr.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 ll){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var t=P.FromRotationMatrix(I.RotationY(Math.PI/4*this._rotationAngle)),i=new Ke("animationRotation","rotationQuaternion",90,Ke.ANIMATIONTYPE_QUATERNION,Ke.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 Ke("animationPP","vignetteWeight",90,Ke.ANIMATIONTYPE_FLOAT,Ke.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 Ke("animationPP2","vignetteStretch",90,Ke.ANIMATIONTYPE_FLOAT,Ke.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 ll){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=R.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 Ke("animationCameraTeleportation","position",90,Ke.ANIMATIONTYPE_VECTOR3,Ke.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 Ke("animationPP","vignetteWeight",90,Ke.ANIMATIONTYPE_FLOAT,Ke.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 Ke("animationPP2","vignetteStretch",90,Ke.ANIMATIONTYPE_FLOAT,Ke.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}(),Hc=(kc={root:0,found:!1},function(e,t,i,r){kc.root=0,kc.found=!1;var n=t*t-4*e*i;if(n<0)return kc;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=R.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 yr(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=R.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*R.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,b=Hc(g,v,y,m);b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(r)),this._basePoint.subtractToRef(n,this._tempVector),v=2*R.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=Hc(g,v,y,m)).found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(o,this._tempVector),v=2*R.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=Hc(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=R.Dot(this._edge,this._velocity),x=R.Dot(this._edge,this._baseToVertex);g=E*-this._velocitySquaredLength+S*S,v=2*(E*R.Dot(this._velocity,this._baseToVertex)-S*x),y=E*(1-this._baseToVertex.lengthSquared())+x*x,(b=Hc(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=R.Dot(this._edge,this._velocity),x=R.Dot(this._edge,this._baseToVertex),g=E*-this._velocitySquaredLength+S*S,v=2*(E*R.Dot(this._velocity,this._baseToVertex)-S*x),y=E*(1-this._baseToVertex.lengthSquared())+x*x,(b=Hc(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=R.Dot(this._edge,this._velocity),x=R.Dot(this._edge,this._baseToVertex),g=E*-this._velocitySquaredLength+S*S,v=2*(E*R.Dot(this._velocity,this._baseToVertex)-S*x),y=E*(1-this._baseToVertex.lengthSquared())+x*x,(b=Hc(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(){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._getShaderCodeAndErrorLine=function(e,t){var i=null;if(t&&e){var r=t.match(/COMPUTE SHADER ERROR: 0:(\d+?):/);if(r&&2===r.length){var n=parseInt(r[1]),o=e.split("\n",-1);o.length>=n&&(i="Offending line [".concat(n,"] in compute code: ").concat(o[n-1]))}}return[e,i]},e.prototype._processCompilationErrors=function(t,i){var r,n;if(void 0===i&&(i=null),this._compilationError=t.message,$.Error("Unable to compile compute effect:"),$.Error("Defines:\n"+this.defines),e.LogShaderCodeOnCompilationError){var o=null,a=null;(null===(n=this._pipelineContext)||void 0===n?void 0:n._getComputeShaderCode())&&(a=(r=this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(),this._compilationError))[0],o=r[1],a&&($.Error("Compute code:"),$.Error(a))),o&&$.Error(o)}$.Error("Error: "+this._compilationError),i&&(this._pipelineContext=i,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this))},e.prototype.dispose=function(){this._pipelineContext&&this._pipelineContext.dispose(),this._engine._releaseComputeEffect(this)},e.RegisterShader=function(e,t){kt.GetShadersStore(at.WGSL)["".concat(e,"ComputeShader")]=t},e._UniqueIdSeed=0,e.LogShaderCodeOnCompilationError=!0,e}();!function(e){e[e.Texture=0]="Texture",e[e.StorageTexture=1]="StorageTexture",e[e.UniformBuffer=2]="UniformBuffer",e[e.StorageBuffer=3]="StorageBuffer",e[e.TextureWithoutSampler=4]="TextureWithoutSampler",e[e.Sampler=5]="Sampler",e[e.ExternalTexture=6]="ExternalTexture"}(Yc||(Yc={})),ri.prototype.createComputeEffect=function(e,t){throw new Error("createComputeEffect: This engine does not support compute shaders!")},ri.prototype.createComputePipelineContext=function(){throw new Error("createComputePipelineContext: This engine does not support compute shaders!")},ri.prototype.createComputeContext=function(){},ri.prototype.computeDispatch=function(e,t,i,r,n,o,a){throw new Error("computeDispatch: This engine does not support compute shaders!")},ri.prototype.areAllComputeEffectsReady=function(){return!0},ri.prototype.releaseComputeEffects=function(){},ri.prototype._prepareComputePipelineContext=function(e,t,i,r,n){},ri.prototype._rebuildComputeEffects=function(){},ri.prototype._executeWhenComputeStateIsCompiled=function(e,t){t()},ri.prototype._releaseComputeEffect=function(e){},ri.prototype._deleteComputePipelineContext=function(e){};var Qc=function(){function e(e,t,i,r){void 0===r&&(r={}),this._bindings={},this._samplers={},this._contextIsDirty=!1,this.onCompiled=null,this.onError=null,this.name=e,this._engine=t,this.uniqueId=Tr.UniqueId,this._engine.getCaps().supportComputeShaders?r.bindingsMapping?(this._context=t.createComputeContext(),this._shaderPath=i,this._options=H({bindingsMapping:{},defines:[]},r)):$.Error("You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!"):$.Error("This engine does not support compute shaders!")}return Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shaderPath",{get:function(){return this._shaderPath},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"ComputeShader"},e.prototype.setTexture=function(e,t,i){void 0===i&&(i=!0);var r=this._bindings[e];this._bindings[e]={type:i?Yc.Texture:Yc.TextureWithoutSampler,object:t,indexInGroupEntries:null==r?void 0:r.indexInGroupEntries},this._contextIsDirty||(this._contextIsDirty=!r||r.object!==t||r.type!==this._bindings[e].type)},e.prototype.setStorageTexture=function(e,t){var i=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!i||i.object!==t),this._bindings[e]={type:Yc.StorageTexture,object:t,indexInGroupEntries:null==i?void 0:i.indexInGroupEntries}},e.prototype.setExternalTexture=function(e,t){var i=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!i||i.object!==t),this._bindings[e]={type:Yc.ExternalTexture,object:t,indexInGroupEntries:null==i?void 0:i.indexInGroupEntries}},e.prototype.setVideoTexture=function(e,t){return!!t.externalTexture&&(this.setExternalTexture(e,t.externalTexture),!0)},e.prototype.setUniformBuffer=function(e,t){var i=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!i||i.object!==t),this._bindings[e]={type:Yc.UniformBuffer,object:t,indexInGroupEntries:null==i?void 0:i.indexInGroupEntries}},e.prototype.setStorageBuffer=function(e,t){var i=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!i||i.object!==t),this._bindings[e]={type:Yc.StorageBuffer,object:t,indexInGroupEntries:null==i?void 0:i.indexInGroupEntries}},e.prototype.setTextureSampler=function(e,t){var i=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!i||!t.compareSampler(i.object)),this._bindings[e]={type:Yc.Sampler,object:t,indexInGroupEntries:null==i?void 0:i.indexInGroupEntries}},e.prototype.isReady=function(){var e=this._effect;for(var t in this._bindings){var i=this._bindings[t],r=i.type,n=i.object;switch(r){case Yc.Texture:case Yc.TextureWithoutSampler:case Yc.StorageTexture:case Yc.ExternalTexture:if(!n.isReady())return!1}}var o=[],a=this._shaderPath;if(this._options.defines)for(var s=0;sthis.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||Rn.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!==er.POINTERMOVE&&t.type!==er.POINTERUP||i._lastPointerEvents[s.pointerId]&&(i.onPointerOutObservable.notifyObservers(s.pointerId),delete i._lastPointerEvents[s.pointerId]),i._notifyObservers(t,o,s))),t.type===er.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 nu("shared gizmo light",new R(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=B.Gray()),this._sharedGizmoLight},Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer?e._CreateDefaultUtilityLayerFromScene(S.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(S.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 rr(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"}(iu||(iu={})),function(e){e[e.World=0]="World",e[e.Local=1]="Local"}(ru||(ru={}));var au,su=function(){function e(e){void 0===e&&(e=ou.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=iu.Origin,this._updateScale=!0,this._coordinatesMode=ru.Local,this._interactionsEnabled=!0,this._rightHandtoLeftHandMatrix=I.RotationY(Math.PI),this._rootMesh=new io("gizmoRootNode",e.utilityLayerScene),this._rootMesh.rotationQuaternion=P.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,"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==ru.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==iu.Pivot&&t.getAbsolutePivotPoint){var i=t.getAbsolutePivotPoint();this._rootMesh.position.copyFrom(i)}else{var r=t.getWorldMatrix().getRow(3);i=r?r.toVector3():new R(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,O.Vector3[0]);var s=this.scaleRatio;if(o.mode==dn.ORTHOGRAPHIC_CAMERA)o.orthoTop&&o.orthoBottom&&(s*=o.orthoTop-o.orthoBottom);else{var l=o.getScene().useRightHandedSystem?R.RightHandedForwardReadOnly:R.LeftHandedForwardReadOnly,c=o.getDirection(l);s*=R.Dot(O.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)}},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=O.Matrix[1];t.parent._worldMatrix.invertToRef(n),this._attachedNode._worldMatrix.multiplyToRef(n,O.Matrix[0]),i=O.Matrix[0]}else i=this._attachedNode._worldMatrix;if(t.getScene().useRightHandedSystem?(this._rightHandtoLeftHandMatrix.multiplyToRef(i,O.Matrix[1]),r=O.Matrix[1]):r=i,r.decompose(O.Vector3[1],O.Quaternion[0],O.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=O.Quaternion[0].toEulerAngles(),o.rotationQuaternion&&(o.rotationQuaternion.copyFrom(O.Quaternion[0]),o.rotationQuaternion.normalize())}t.position.copyFrom(O.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=O.Matrix[0];var s=O.Matrix[1];if(a.parent.getWorldMatrix().invertToRef(n),this._attachedNode.getWorldMatrix().multiplyToRef(n,s),s.decompose(O.Vector3[0],O.Quaternion[0],a.position),O.Quaternion[0].normalize(),a.isUsingPivotMatrix()){var l=O.Quaternion[1];P.RotationYawPitchRollToRef(a.rotation.y,a.rotation.x,a.rotation.z,l);var c=O.Matrix[2];I.ScalingToRef(a.scaling.x,a.scaling.y,a.scaling.z,c);var u=O.Matrix[2];l.toRotationMatrix(u);var h=a.getPivotMatrix(),d=O.Matrix[3];h.invertToRef(d),h.multiplyToRef(c,O.Matrix[4]),O.Matrix[4].multiplyToRef(u,O.Matrix[5]),O.Matrix[5].multiplyToRef(d,O.Matrix[6]),O.Matrix[6].getTranslationToRef(O.Vector3[1]),a.position.subtractInPlace(O.Vector3[1])}}else this._attachedNode._worldMatrix.decompose(O.Vector3[0],O.Quaternion[0],a.position,e.PreserveScaling?a:void 0);O.Vector3[0].scaleInPlace(1/a.scalingDeterminant),a.scaling.copyFrom(O.Vector3[0]),a.billboardMode||(a.rotationQuaternion?(a.rotationQuaternion.copyFrom(O.Quaternion[0]),a.rotationQuaternion.normalize()):a.rotation=O.Quaternion[0].toEulerAngles())}else if("Bone"===this._attachedNode.getClassName()){var p=this._attachedNode,f=p.getParent();if(f){var _=O.Matrix[0],m=O.Matrix[1];f.getFinalMatrix().invertToRef(_),p.getFinalMatrix().multiplyToRef(_,m),p.getLocalMatrix().copyFrom(m)}else p.getLocalMatrix().copyFrom(p.getFinalMatrix());p.markAsDirty()}else{var g=this._attachedNode;if(g.getTypeID){var v=g.getTypeID();if(v===no.LIGHTTYPEID_DIRECTIONALLIGHT||v===no.LIGHTTYPEID_SPOTLIGHT||v===no.LIGHTTYPEID_POINTLIGHT){var y=g.parent;if(y){_=O.Matrix[0];var b=O.Matrix[1];y.getWorldMatrix().invertToRef(_),g.getWorldMatrix().multiplyToRef(_,b),b.decompose(void 0,O.Quaternion[0],O.Vector3[0])}else this._attachedNode._worldMatrix.decompose(void 0,O.Quaternion[0],O.Vector3[0]);g.position=new R(O.Vector3[0].x,O.Vector3[0].y,O.Vector3[0].z),g.direction&&(g.direction=new R(g.direction.x,g.direction.y,g.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===er.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===er.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===er.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}(),lu=function(e){function t(i,r,n,o,a){void 0===r&&(r=B.Gray()),void 0===n&&(n=ou.DefaultUtilityLayer),void 0===o&&(o=null),void 0===a&&(a=1);var s,l=this;(l=e.call(this,n)||this)._pointerObserver=null,l.snapDistance=0,l.onSnapObservable=new u,l._isEnabled=!0,l._parent=null,l._dragging=!1,l._parent=o,l._coloredMaterial=new _c("",n.utilityLayerScene),l._coloredMaterial.diffuseColor=r,l._coloredMaterial.specularColor=r.subtract(new B(.1,.1,.1)),l._hoverMaterial=new _c("",n.utilityLayerScene),l._hoverMaterial.diffuseColor=B.Yellow(),l._disableMaterial=new _c("",n.utilityLayerScene),l._disableMaterial.diffuseColor=B.Gray(),l._disableMaterial.alpha=.4;var c=t._CreateArrow(n.utilityLayerScene,l._coloredMaterial,a),h=t._CreateArrow(n.utilityLayerScene,l._coloredMaterial,a+4,!0);l._gizmoMesh=new io("",n.utilityLayerScene),l._gizmoMesh.addChild(c),l._gizmoMesh.addChild(h),l._gizmoMesh.lookAt(l._rootMesh.position.add(i)),l._gizmoMesh.scaling.scaleInPlace(1/3),l._gizmoMesh.parent=l._rootMesh;var d=0,p={snapDistance:0};l.dragBehavior=new ko({dragAxis:i}),l.dragBehavior.moveAttached=!1,l.dragBehavior.updateDragPlane=!1,l._rootMesh.addBehavior(l.dragBehavior),l.dragBehavior.onDragObservable.add((function(e){if(l.attachedNode){var t=!1;if(0==l.snapDistance)l.attachedNode.getWorldMatrix().getTranslationToRef(O.Vector3[2]),O.Vector3[2].addInPlace(e.delta),l.dragBehavior.validateDrag(O.Vector3[2])&&(l.attachedNode.position&&l.attachedNode.position.addInPlaceFromFloats(e.delta.x,e.delta.y,e.delta.z),l.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z),l.attachedNode.updateCache(),t=!0);else if(d+=e.dragDistance,Math.abs(d)>l.snapDistance){var i=Math.floor(Math.abs(d)/l.snapDistance);d%=l.snapDistance,e.delta.normalizeToRef(O.Vector3[1]),O.Vector3[1].scaleInPlace(l.snapDistance*i),l.attachedNode.getWorldMatrix().getTranslationToRef(O.Vector3[2]),O.Vector3[2].addInPlace(O.Vector3[1]),l.dragBehavior.validateDrag(O.Vector3[2])&&(l.attachedNode.getWorldMatrix().addTranslationFromFloats(O.Vector3[1].x,O.Vector3[1].y,O.Vector3[1].z),l.attachedNode.updateCache(),p.snapDistance=l.snapDistance*i,l.onSnapObservable.notifyObservers(p),t=!0)}t&&l._matrixChanged()}})),l.dragBehavior.onDragStartObservable.add((function(){l._dragging=!0})),l.dragBehavior.onDragEndObservable.add((function(){l._dragging=!1}));var f=n._getSharedGizmoLight();f.includedOnlyMeshes=f.includedOnlyMeshes.concat(l._rootMesh.getChildMeshes(!1));var _={gizmoMeshes:c.getChildMeshes(),colliderMeshes:h.getChildMeshes(),material:l._coloredMaterial,hoverMaterial:l._hoverMaterial,disableMaterial:l._disableMaterial,active:!1,dragBehavior:l.dragBehavior};return null===(s=l._parent)||void 0===s||s.addToAxisCache(h,_),l._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!l._customMeshSet&&(l._isHovered=!(-1==_.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!l._parent)){var i=l.dragBehavior.enabled?l._isHovered||l._dragging?l._hoverMaterial:l._coloredMaterial:l._disableMaterial;l._setGizmoMeshMaterial(_.gizmoMeshes,i)}})),l.dragBehavior.onEnabledObservable.add((function(e){l._setGizmoMeshMaterial(_.gizmoMeshes,e?_.material:_.disableMaterial)})),l}return W(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 Ln("arrow",e),o=eu("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(i-1)/4),tessellation:96},e),a=eu("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 Ln("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||Rn.DEFAULTSIDE,b=e.faceUV||new Array(6),T=e.faceColors,E=[],S=0;S<6;S++)void 0===b[S]&&(b[S]=new C(0,0,1,1)),T&&void 0===T[S]&&(T[S]=new U(1,1,1,1));for(var x=0;x<6;x++)if(n.push(b[x].z,Pn.UseOpenGLOrientationForUV?1-b[x].w:b[x].w),n.push(b[x].x,Pn.UseOpenGLOrientationForUV?1-b[x].w:b[x].w),n.push(b[x].x,Pn.UseOpenGLOrientationForUV?1-b[x].y:b[x].y),n.push(b[x].z,Pn.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);Rn._ComputeSides(y,t,i,r,n,e.frontUVs,e.backUVs);var R=new Rn;if(R.indices=i,R.positions=t,R.normals=r,R.uvs=n,T){var P=y===Rn.DOUBLESIDE?E.concat(E):E;R.colors=P}return R}function pu(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 I,l=new I,c=new I,u=Mc({width:t,height:r,subdivisionsX:n,subdivisionsY:a});I.TranslationToRef(0,-i/2,0,l),I.RotationZToRef(Math.PI,s),s.multiplyToRef(l,c),u.transform(c);var h=Mc({width:t,height:r,subdivisionsX:n,subdivisionsY:a});I.TranslationToRef(0,i/2,0,c),h.transform(c);var d=Mc({width:i,height:r,subdivisionsX:o,subdivisionsY:a});I.TranslationToRef(-t/2,0,0,l),I.RotationZToRef(Math.PI/2,s),s.multiplyToRef(l,c),d.transform(c);var p=Mc({width:i,height:r,subdivisionsX:o,subdivisionsY:a});I.TranslationToRef(t/2,0,0,l),I.RotationZToRef(-Math.PI/2,s),s.multiplyToRef(l,c),p.transform(c);var f=Mc({width:t,height:i,subdivisionsX:n,subdivisionsY:o});I.TranslationToRef(0,0,-r/2,l),I.RotationXToRef(-Math.PI/2,s),s.multiplyToRef(l,c),f.transform(c);var _=Mc({width:t,height:i,subdivisionsX:n,subdivisionsY:o});return I.TranslationToRef(0,0,r/2,l),I.RotationXToRef(Math.PI/2,s),s.multiplyToRef(l,c),_.transform(c),u.merge([h,p,d,f,_],!0),u}function fu(e,t,i){void 0===t&&(t={}),void 0===i&&(i=null);var r=new io(e,i);return t.sideOrientation=io._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,du(t).applyToMesh(r,t.updatable),r}var _u={CreateBox:fu};function mu(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||Rn.DEFAULTSIDE,l=!!e.dedupTopBottomIndices,c=new R(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=I.RotationZ(-v),S=I.RotationY(T),x=R.TransformCoordinates(R.Up(),E),A=R.TransformCoordinates(x,S),C=A.multiply(c),P=A.divide(c).normalize();p.push(C.x,C.y,C.z),f.push(P.x,P.y,P.z),_.push(b,Pn.UseOpenGLOrientationForUV?1-g:g)}if(m>0)for(var M=p.length/3,O=M-2*(h+1);O+h+21&&(d.push(O),d.push(O+1),d.push(O+h+1)),(mo?o:Math.floor(a);var s,l,c,u,h=0===e.sideOrientation?0:e.sideOrientation||Rn.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=R[u].subtract(R[u-1]).length()+b[l],v[l].push(P),b[l]=P),u++;r&&(u--,f.push(R[0].x,R[0].y,R[0].z),P=R[u].subtract(R[0]).length()+b[l],v[l].push(P),b[l]=P),E[l]=C+D,S[l]=O,O+=C+D}var N,F,L=null,w=null;for(c=0;c1)?1:e.arc||1,l=0===e.sideOrientation?0:e.sideOrientation||Rn.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 io.CENTER:m-=l/=2,v+=l;break;case io.LEFT:v+=l,f=-l/2;break;case io.RIGHT:m-=l,f=l/2}switch(o){case io.CENTER:g-=h/=2,y+=h;break;case io.BOTTOM:y+=h,_=-h/2;break;case io.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!==io.ROTATE_TILE&&t!==io.ROTATE_ROW||(E[1]=[1,1,0,1,0,0,1,0]),t!==io.FLIP_TILE&&t!==io.FLIP_ROW||(E[1]=[1,0,0,0,0,1,1,1]),t!==io.FLIP_N_ROTATE_TILE&&t!==io.FLIP_N_ROTATE_ROW||(E[1]=[0,1,1,1,1,0,0,0]);for(var S=[],x=[],A=[],R=0,C=0;C0||h>0){var I=h>0&&(o===io.CENTER||o===io.TOP),M=h>0&&(o===io.CENTER||o===io.BOTTOM),O=l>0&&(n===io.CENTER||n===io.RIGHT),D=l>0&&(n===io.CENTER||n===io.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(R,R+1,R+3,R+1,R+2,R+3),R+=4,N=[F=1-l/i,L=1-h/r,w=1,L,w,B=1,F,B],t===io.ROTATE_ROW&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),t===io.FLIP_ROW&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),t===io.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(R,R+1,R+3,R+1,R+2,R+3),R+=4,N=[F=0,L=1-h/r,w=l/i,L,w,B=1,F,B],(t===io.ROTATE_ROW||t===io.ROTATE_TILE&&s%2==0)&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),(t===io.FLIP_ROW||t===io.FLIP_TILE&&s%2==0)&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),(t===io.FLIP_N_ROTATE_ROW||t===io.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(R,R+1,R+3,R+1,R+2,R+3),R+=4,N=[F=1-l/i,L=0,w=1,L,w,B=h/r,F,B],(t===io.ROTATE_ROW&&u%2==1||t===io.ROTATE_TILE&&u%1==0)&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),(t===io.FLIP_ROW&&u%2==1||t===io.FLIP_TILE&&u%2==0)&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),(t===io.FLIP_N_ROTATE_ROW&&u%2==1||t===io.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(R,R+1,R+3,R+1,R+2,R+3),R+=4,N=[F=0,L=0,w=l/i,L,w,B=h/r,F,B],(t===io.ROTATE_ROW&&u%2==1||t===io.ROTATE_TILE&&(u+s)%2==1)&&(N=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),(t===io.FLIP_ROW&&u%2==1||t===io.FLIP_TILE&&(u+s)%2==1)&&(N=[1-F,L,1-w,L,1-w,B,1-F,B]),(t===io.FLIP_N_ROTATE_ROW&&u%2==1||t===io.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!==io.ROTATE_TILE&&t!==io.ROTATE_ROW||(U[1]=[1-F,1-L,1-w,1-L,1-w,1-B,1-F,1-B]),t!==io.FLIP_TILE&&t!==io.FLIP_ROW||(U[1]=[1-F,L,1-w,L,1-w,B,1-F,B]),t!==io.FLIP_N_ROTATE_TILE&&t!==io.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)if(s){if(i.effect&&i.effect._wasPreviouslyReady)return!0}else{var l=this._drawWrapper.effect;if(l&&l._wasPreviouslyReady&&l._wasPreviouslyUsingInstances===t)return!0}var c=this.getScene(),u=c.getEngine(),h=[],d=[],p=new Ma,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!==this._options.uniforms.indexOf("viewProjection")&&-1===this._options.uniforms.indexOf("viewProjectionR")&&this._options.uniforms.push("viewProjectionR"));for(var v=0;v4&&(d.push(ji.MatricesIndicesExtraKind),d.push(ji.MatricesWeightsExtraKind));var b=e.skeleton;h.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),p.addCPUSkinningFallback(0,e),b.isUsingTextureForMatrices?(h.push("#define BONETEXTURE"),-1===this._options.uniforms.indexOf("boneTextureWidth")&&this._options.uniforms.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(h.push("#define BonesPerMesh "+(b.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.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.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===this._options.uniforms.indexOf("morphTargetTextureIndices")&&this._options.uniforms.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("morphTargetTextureInfo"),_.push("morphTargetTextureIndices"))}else h.push("#define NUM_MORPH_INFLUENCERS 0");if(e){var R=e.bakedVertexAnimationManager;R&&R.isEnabled&&(h.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),-1===this._options.uniforms.indexOf("bakedVertexAnimationSettings")&&this._options.uniforms.push("bakedVertexAnimationSettings"),-1===this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted")&&this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"),-1===this._options.uniforms.indexOf("bakedVertexAnimationTime")&&this._options.uniforms.push("bakedVertexAnimationTime"),-1===this._options.samplers.indexOf("bakedVertexAnimationTexture")&&this._options.samplers.push("bakedVertexAnimationTexture")),jn.PrepareAttributesForBakedVertexAnimation(d,e,h)}for(var C in this._textures)if(!this._textures[C].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&h.push("#define ALPHATEST"),!1!==this._options.useClipPlane&&(kn(_),Gn(this,c,h)),this.customShaderNameResolve&&(_=_.slice(),m=m.slice(),g=g.slice(),f=this.customShaderNameResolve(f,_,m,g,h,d));var P=s?i._getDrawWrapper():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&&(Bu.effect=D,Bu.subMesh=null!==(o=null!=i?i:null==e?void 0:e.subMeshes[0])&&void 0!==o?o:null,this._onEffectCreatedObservable.notifyObservers(Bu))),D._wasPreviouslyUsingInstances=!!t,null!==(a=!(null==D?void 0:D.isReady()))&&void 0!==a&&!a&&(I!==D&&c.resetCachedMaterial(),D._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)))},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){this._activeEffect=a,this.bindOnlyWorldMatrix(e,i);var s=this._options.uniformBuffers,l=!1;if(a&&s&&s.length>0&&this.getScene().getEngine().supportsUniformBuffers)for(var c=0;c0&&jn.BindMorphTargetParameters(t,a);var _=t.bakedVertexAnimationManager;_&&_.isEnabled&&(null===(n=t.bakedVertexAnimationManager)||void 0===n||n.bind(a,!!a._wasPreviouslyUsingInstances))}this._afterBind(t,a)}},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#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#define CUSTOM_FRAGMENT_MAIN_END\n}";kt.ShadersStore.colorVertexShader="attribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n#include\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#define CUSTOM_VERTEX_MAIN_END\n}",io._LinesMeshParser=function(e,t){return Vu.Parse(e,t)};var Vu=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 B(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:[ji.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(ji.ColorKind)):(u.uniforms.push("color"),c._color4=new U),l?c.material=l:(c.material=new Uu("colorShader",c.getScene(),"color",u,!1),c.material.doNotSerialize=!0),c}return W(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=Kn.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(Kn.LineListDrawMode,e.verticesStart,e.verticesCount,i):r.drawElementsType(Kn.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 ku(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=B.FromArray(e.color),r.alpha=e.alpha,r},t}(io),ku=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.intersectionThreshold=i.intersectionThreshold,r}return W(t,e),t.prototype.getClassName=function(){return"InstancedLinesMesh"},t}(ro);function Gu(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 h=new Rn;return h.indices=t,h.positions=i,n&&(h.colors=o),h}function zu(e){var t,i,r=e.dashSize||3,n=e.gapSize||1,o=e.dashNb||200,a=e.points,s=new Array,l=new Array,c=R.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}(),Qu=function(){function e(){}return e.Rectangle=function(e,t,i,r){return[new A(e,t),new A(i,t),new A(i,r),new A(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=new Array,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?S<_-1?new R(d.x,0,d.y).subtract(new R(p.x,0,p.y)).normalize():v.add(g).normalize():b;var x=R.Dot(y,g);E=x>l?x<_-1?new R(p.x,0,p.y).subtract(new R(d.x,0,d.y)).normalize():y.add(g).normalize():b,i.push(u/n.width,0),i.push(u/n.width,1),u+=g.length(),i.push(u/n.width,0),i.push(u/n.width,1),t.push(T.x,T.y,T.z),t.push(T.x,T.y,T.z),t.push(E.x,E.y,E.z),t.push(E.x,E.y,E.z),s?(r.push(c),r.push(c+2),r.push(c+1),r.push(c+1),r.push(c+2),r.push(c+3)):(r.push(c),r.push(c+1),r.push(c+2),r.push(c+1),r.push(c+3),r.push(c+2)),c+=4}},e}();function Zu(e,t,i,r,n,o,a){for(var s=i||new Array(3),l=r,c=[],u=a||!1,h=0;h<3;h++)void 0===s[h]&&(s[h]=new C(0,0,1,1)),l&&void 0===l[h]&&(l[h]=new U(1,1,1,1));var d=e.getVerticesData(ji.PositionKind),p=e.getVerticesData(ji.NormalKind),f=e.getVerticesData(ji.UVKind),_=e.getIndices(),m=d.length/9,g=0,v=0,y=0,b=0,T=[0];if(u)for(var E=m;E0){var m=h[_-1];R.Dot(m,h[_])<0&&h[_].scaleInPlace(-1),m=d[_-1],R.Dot(m,d[_])<0&&d[_].scaleInPlace(-1),m=p[_-1],R.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===io.NO_CAP||l===io.CAP_END?0:2,T=O.Matrix[0];for(_=0;_3?0:c;var x=Su(e,{pathArray:T=E(t,i,b=v?new Br(i,v):new Br(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}Rn.CreatePolygon=Zu,io.CreatePolygon=function(e,t,i,r,n,o,a){return void 0===a&&(a=earcut),Ju(e,{shape:t,holes:r,updatable:n,sideOrientation:o},i,a)},io.ExtrudePolygon=function(e,t,i,r,n,o,a,s){return void 0===s&&(s=earcut),$u(e,{shape:t,holes:n,depth:i,updatable:o,sideOrientation:a},r,s)};var nh={ExtrudeShape:th,ExtrudeShapeCustom:ih};function oh(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=io._GetDefaultSideOrientation(t.sideOrientation),p=t.cap||io.NO_CAP,f=2*Math.PI,_=new Array,m=t.invertUV||!1,g=0,v=0,y=f/c*o;for(g=0;g<=c-u;g++){for(n=[],p!=io.CAP_START&&p!=io.CAP_ALL||(n.push(new R(0,s[0].y,0)),n.push(new R(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=O.Matrix[0],v=a===io.NO_CAP||a===io.CAP_END?0:2,y=0;y3?0:l;var g=Su(e,{pathArray:p=f(r,d=new Br(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}io.CreateLathe=function(e,t,i,r,n,o,a){return oh(e,{shape:t,radius:i,tessellation:r,sideOrientation:a,updatable:o},n)};var lh={CreateTube:sh};function ch(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||Rn.DEFAULTSIDE,y=new Array,b=new Array,T=new Array,E=new Array,S=new Array,x=0,A=0,R=new Array,P=0,I=0;if(g)for(I=0;I0){var k=r(L,D[O+V],F,4);I[B]=D[O+V],M[B]=h.Lerp(N[O+V],k>=0?w[k]:0,P),B++}for(V=0;V<4&&B<4;++V){var G=L[F+V];-1===r(D,G,O,4)&&(I[B]=G,M[B]=h.Lerp(0,w[F+V],P),B++)}var z=M[0]+M[1]+M[2]+M[3];M[0]/=z,M[1]/=z,M[2]/=z,M[3]/=z}var W=e.localPositionOverride?e.localPositionOverride[0]:null!==(c=null==f?void 0:f[e.vertexIdx])&&void 0!==c?c:0,H=e.localPositionOverride?e.localPositionOverride[1]:null!==(u=null==f?void 0:f[e.vertexIdx+1])&&void 0!==u?u:0,X=e.localPositionOverride?e.localPositionOverride[2]:null!==(d=null==f?void 0:f[e.vertexIdx+2])&&void 0!==d?d:0,j=n.localPositionOverride?n.localPositionOverride[0]:null!==(p=null==f?void 0:f[n.vertexIdx])&&void 0!==p?p:0,Y=n.localPositionOverride?n.localPositionOverride[1]:null!==(m=null==f?void 0:f[n.vertexIdx+1])&&void 0!==m?m:0,K=n.localPositionOverride?n.localPositionOverride[2]:null!==(y=null==f?void 0:f[n.vertexIdx+2])&&void 0!==y?y:0,Q=e.localNormalOverride?e.localNormalOverride[0]:null!==(b=null==_?void 0:_[e.vertexIdx])&&void 0!==b?b:0,q=e.localNormalOverride?e.localNormalOverride[1]:null!==(T=null==_?void 0:_[e.vertexIdx+1])&&void 0!==T?T:0,Z=e.localNormalOverride?e.localNormalOverride[2]:null!==(E=null==_?void 0:_[e.vertexIdx+2])&&void 0!==E?E:0,J=Q+((n.localNormalOverride?n.localNormalOverride[0]:null!==(S=null==_?void 0:_[n.vertexIdx])&&void 0!==S?S:0)-Q)*P,$=q+((n.localNormalOverride?n.localNormalOverride[1]:null!==(x=null==_?void 0:_[n.vertexIdx+1])&&void 0!==x?x:0)-q)*P,ee=Z+((n.localNormalOverride?n.localNormalOverride[2]:null!==(C=null==_?void 0:_[n.vertexIdx+2])&&void 0!==C?C:0)-Z)*P,te=Math.sqrt(J*J+$*$+ee*ee);return new vh(R.Lerp(e.position,n.position,P),R.Lerp(e.normal,n.normal,P).normalize(),A.Lerp(e.uv,n.uv,P),-1,-1,f?[W+(j-W)*P,H+(Y-H)*P,X+(K-X)*P]:null,_?[J/te,$/te,ee/te]:null,I,M)},o=null;e.length>3&&(o=new Array);for(var a=0;a0,p=R.Dot(e[a+1].position,t)-i>0,m=R.Dot(e[a+2].position,t)-i>0;switch((d?1:0)+(p?1:0)+(m?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,d&&(s=e[a+1],l=e[a+2],c=n(e[a],s),u=n(e[a],l)),p){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}m&&(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,d||(l=n(s=e[a].clone(),e[a+1]),c=n(s,e[a+2]),o.push(s),o.push(l),o.push(c)),p||(l=n(s=e[a+1].clone(),e[a+2]),c=n(s,e[a]),o.push(s),o.push(l),o.push(c)),m||(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},k=t instanceof io?t:null,G=null==k?void 0:k._thinInstanceDataStorage.matrixData,z=(null==k?void 0:k.thinInstanceCount)||1,W=O.Matrix[0];W.copyFrom(I.IdentityReadOnly);for(var H=0;H2?S[l[p]]=[-x[i][0],x[i][1],l[p]]:S[l[p]]=[E[x[i][0]],x[i][1],l[p]]};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 R=0;R<20;R++){if(n=(E=this.IDATA.face[R])[2],o=E[1],a=E[0],_=m.x+"|"+m.y,(p=R+"|"+_)in l||(l[p]=n,S[n]=[E[x[_][0]],x[_][1]]),_=g.x+"|"+g.y,(p=R+"|"+_)in l||(l[p]=o,S[o]=[E[x[_][0]],x[_][1]]),_=v.x+"|"+v.y,(p=R+"|"+_)in l||(l[p]=a,S[a]=[E[x[_][0]],x[_][1]]),i=this.IDATA.edgematch[R][0],"B"===(r=this.IDATA.edgematch[R][1]))for(var C=1;C2?S[l[p]]=[-x[_][0],x[_][1],l[p]]:S[l[p]]=[E[x[_][0]],x[_][1],l[p]])}this.closestTo=S,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=h.HCF(e,t),c=e/l,u=t/l,d=1;d-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 Sh("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,$.Warn("n > m therefore m and n swapped")}var a=new Eh;return a.build(r,n),uh(e,{custom:xh.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)}io._GoldbergMeshParser=function(e,t){return Rh.Parse(e,t)};var Rh=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 W(t,e),t.prototype.relatedGoldbergFace=function(e,t){return void 0===t?(e>this.goldbergData.nbUnsharedFaces-1&&($.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&($.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&($.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,$.Warn("n > m therefore m and n swapped")}var u=new Eh;u.build(s,l);var h=xh.BuildGeodesicData(u),d=h.toGoldbergPolyhedronData(),p=new Rh(e,i);t.sideOrientation=io._GetDefaultSideOrientation(t.sideOrientation),p._originalBuilderSideOrientation=t.sideOrientation,Ch(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 Mh(e,t,i,r,n,o){var a=o.glyphs[e]||o.glyphs["?"];if(!a)return null;var s=new Ih(n);if(a.o)for(var l=a.o.split(" "),c=0,u=l.length;c_&&(e.x=1*Math.sign(e.x)),Math.abs(e.y-1)>_&&(e.y=1*Math.sign(e.y)),Math.abs(e.z-1)>_&&(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,O.Matrix[0],d),g=i._getTransformFromBodyToRef(f,O.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),P.FromRotationMatrixToRef(I.FromXYZAxesToRef(a,l,R.CrossToRef(a,l,O.Vector3[0]),O.Matrix[0]),v.rotationQuaternion),P.FromRotationMatrixToRef(I.FromXYZAxesToRef(s,c,R.CrossToRef(s,c,O.Vector3[1]),O.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 _c("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=B.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugInertiaMaterial=function(e){return this._debugInertiaMaterial||(this._debugInertiaMaterial=new _c("",e),this._debugInertiaMaterial.disableLighting=!0,this._debugInertiaMaterial.alpha=0),this._debugInertiaMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=fu("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=P.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=gu("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=P.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=bu("physicsBodyCapsuleViewMesh",{height:1},e),this._debugCapsuleMesh.rotationQuaternion=P.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=eu("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=P.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyCylinderViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var i=new io(e.name,t,null,e);return i.setParent(e),i.position=R.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 $.Warn("Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor."),null;switch(e.type){case ta.BoxImpostor:r=this._getDebugBoxMesh(n),e.getBoxSizeToRef(r.scaling);break;case ta.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 ta.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 ta.MeshImpostor:t&&(r=this._getDebugMeshMesh(t,n));break;case ta.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 ta.BoxImpostor:(r=i._getDebugBoxMesh(n)).position.copyFrom(o),r.position.addInPlace(a),r.position.scaleInPlace(.5);break;case ta.SphereImpostor:r=i._getDebugSphereMesh(n);break;case ta.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)}})):$.Warn("No target mesh parameter provided for NoImpostor. Skipping."),r=null;break;case ta.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 io("custom",t),r=new Rn,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)}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:P.Identity(),a=null!==(r=e.inertia)&&void 0!==r?r:R.Zero(),s=null!==(n=e.centerOfMass)&&void 0!==n?n:R.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=O.Vector3[0];f.set(p,c,h);var _=I.ScalingToRef(f.x,f.y,f.z,O.Matrix[0]),m=o.toRotationMatrix(O.Matrix[1]),g=I.TranslationToRef(s.x,s.y,s.z,O.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=Nh.CreateBox("custom",{size:1},t),r=I.Identity();if(e._pluginDataInstances.length){for(var n=new Float32Array(16*e._pluginDataInstances.length),o=0;o=0?I.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 io("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}(),Lh=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=Hu("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),Hu("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=R.Zero()),o.origin||(o.origin=R.Zero()),r&&(o.length=r),i||(i=R.Zero()),t||(t=new R(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),R.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),e.origin)))},e.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},e}(),wh=function(){function e(t,i,r,n,o,a){var s,l,c,u,h,d,p,f,_,m,g,v,y,b;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=B.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;var T=i.getVerticesData(ji.MatricesIndicesKind),E=i.getVerticesData(ji.MatricesWeightsKind);if(this._boneIndices=new Set,!a.useAllBones&&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:B.Black(),u=null!==(r=e.colorZero)&&void 0!==r?r:B.Blue(),h=null!==(n=e.colorQuarter)&&void 0!==n?n:B.Green(),d=null!==(o=e.colorHalf)&&void 0!==o?o:B.Yellow(),p=null!==(a=e.colorFull)&&void 0!==a?a:B.Red(),f=null!==(s=e.targetBoneIndex)&&void 0!==s?s:0;Gt.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 }",Gt.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 Uu("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=Kn.MATERIAL_OPAQUE,_},e.CreateSkeletonMapShader=function(t,i){var r,n=t.skeleton,o=null!==(r=t.colorMap)&&void 0!==r?r:[{color:new B(1,.38,.18),location:0},{color:new B(.59,.18,1),location:.2},{color:new B(.59,1,.18),location:.4},{color:new B(1,.87,.17),location:.6},{color:new B(1,.17,.42),location:.8},{color:new B(.17,.68,1),location:1}],a=n.bones.length+1,s=e._CreateBoneMapColorBuffer(a,o,i),l=new Uu("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=Kn.MATERIAL_OPAQUE,l},e._CreateBoneMapColorBuffer=function(e,t,i){var r=new vc("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=0;le.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=O.Matrix[0],s=t.getParent();if(a.copyFrom(t.getLocalMatrix()),0!==r||0!==n||0!==o){var l=O.Matrix[1];I.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){for(var i=e.length,r=this.mesh.position,n=0,o=0;o=0;o--){var a=e[o],s=a.getParent();if(s&&(this._boneIndices.has(a.getIndex())||this.options.useAllBones)){var l=this._debugLines[i];l||(l=[R.Zero(),R.Zero()],this._debugLines[i]=l),a.getAbsolutePositionToRef(r,l[0]),s.getAbsolutePositionToRef(r,l[1]),l[0].subtractInPlace(n),l[1].subtractInPlace(n),i++}}},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(I.Identity())},e.prototype._buildSpheresAndSpurs=function(e){var t,i,r;void 0===e&&(e=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var n=null===(i=this.utilityLayer)||void 0===i?void 0:i.utilityLayerScene,o=this.skeleton.bones,a=[],s=[],l=this.scene.animationsEnabled;try{this.options.pauseAnimations&&(this.scene.animationsEnabled=!1,n.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteMatrices();for(var c=Number.NEGATIVE_INFINITY,u=this.options.displayOptions||{},h=function(t){var i=o[t];if(-1===i._index||!d._boneIndices.has(i.getIndex())&&!d.options.useAllBones)return"continue";var r=new I;d._getAbsoluteBindPoseToRef(i,r);var l=new R;r.decompose(void 0,void 0,l),i.children.forEach((function(t){var o=new I;t.getLocalMatrix().multiplyToRef(r,o);var a=new R;o.decompose(void 0,void 0,a);var h=R.Distance(l,a);if(h>c&&(c=h),!e){for(var d=a.clone().subtract(l.clone()),p=d.length(),f=d.normalize().scale(p),_=u.midStep||.165,m=u.midStepFactor||.215,g=f.scale(_),v=ih("skeletonViewer",{shape:[new R(1,-1,0),new R(1,1,0),new R(-1,1,0),new R(-1,-1,0),new R(1,-1,0)],path:[R.Zero(),g,f],scaleFunction:function(e){switch(e){case 0:case 2:return 0;case 1:return p*m}return 0},sideOrientation:io.DEFAULTSIDE,updatable:!1},n),y=v.getTotalVertices(),b=[],T=[],E=0;E9?T.push(t.getIndex(),0,0,0):T.push(i.getIndex(),0,0,0);v.position=l.clone(),v.setVerticesData(ji.MatricesWeightsKind,b,!1),v.setVerticesData(ji.MatricesIndicesKind,T,!1),v.convertToFlatShadedMesh(),s.push(v)}}));for(var h=gu("skeletonViewer",{segments:6,diameter:u.sphereBaseSize||.2,updatable:!0},n),p=h.getTotalVertices(),f=[],_=[],m=0;m=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,O.Vector3[0].set(this._light.orthoLeft,this._light.orthoBottom,void 0!==this._light.shadowMinZ?this._light.shadowMinZ:this._camera.minZ),O.Vector3[1].set(this._light.orthoRight,this._light.orthoTop,void 0!==this._light.shadowMaxZ?this._light.shadowMaxZ:this._camera.maxZ);var a=this._getInvertViewMatrix();O.Vector3[2].copyFromFloats(O.Vector3[1].x,O.Vector3[1].y,O.Vector3[0].z),O.Vector3[3].copyFromFloats(O.Vector3[1].x,O.Vector3[0].y,O.Vector3[0].z),O.Vector3[4].copyFromFloats(O.Vector3[0].x,O.Vector3[0].y,O.Vector3[0].z),O.Vector3[5].copyFromFloats(O.Vector3[0].x,O.Vector3[1].y,O.Vector3[0].z),R.TransformCoordinatesToRef(O.Vector3[2],a,O.Vector3[2]),R.TransformCoordinatesToRef(O.Vector3[3],a,O.Vector3[3]),R.TransformCoordinatesToRef(O.Vector3[4],a,O.Vector3[4]),R.TransformCoordinatesToRef(O.Vector3[5],a,O.Vector3[5]),O.Vector3[6].copyFromFloats(O.Vector3[1].x,O.Vector3[1].y,O.Vector3[1].z),O.Vector3[7].copyFromFloats(O.Vector3[1].x,O.Vector3[0].y,O.Vector3[1].z),O.Vector3[8].copyFromFloats(O.Vector3[0].x,O.Vector3[0].y,O.Vector3[1].z),O.Vector3[9].copyFromFloats(O.Vector3[0].x,O.Vector3[1].y,O.Vector3[1].z),R.TransformCoordinatesToRef(O.Vector3[6],a,O.Vector3[6]),R.TransformCoordinatesToRef(O.Vector3[7],a,O.Vector3[7]),R.TransformCoordinatesToRef(O.Vector3[8],a,O.Vector3[8]),R.TransformCoordinatesToRef(O.Vector3[9],a,O.Vector3[9]),Hu("nearlines",{updatable:!0,points:this._nearLinesPoints,instance:this._lightHelperFrustumMeshes[0]},this._scene),Hu("farlines",{updatable:!0,points:this._farLinesPoints,instance:this._lightHelperFrustumMeshes[1]},this._scene),Hu("trlines",{updatable:!0,points:this._trLinesPoints,instance:this._lightHelperFrustumMeshes[2]},this._scene),Hu("brlines",{updatable:!0,points:this._brLinesPoints,instance:this._lightHelperFrustumMeshes[3]},this._scene),Hu("tllines",{updatable:!0,points:this._tlLinesPoints,instance:this._lightHelperFrustumMeshes[4]},this._scene),Hu("bllines",{updatable:!0,points:this._blLinesPoints,instance:this._lightHelperFrustumMeshes[5]},this._scene),O.Vector3[2].toArray(this._nearPlaneVertices,0),O.Vector3[3].toArray(this._nearPlaneVertices,3),O.Vector3[4].toArray(this._nearPlaneVertices,6),O.Vector3[5].toArray(this._nearPlaneVertices,9),null===(e=this._lightHelperFrustumMeshes[6].geometry)||void 0===e||e.updateVerticesDataDirectly("position",this._nearPlaneVertices,0),O.Vector3[6].toArray(this._farPlaneVertices,0),O.Vector3[7].toArray(this._farPlaneVertices,3),O.Vector3[8].toArray(this._farPlaneVertices,6),O.Vector3[9].toArray(this._farPlaneVertices,9),null===(t=this._lightHelperFrustumMeshes[7].geometry)||void 0===t||t.updateVerticesDataDirectly("position",this._farPlaneVertices,0),O.Vector3[2].toArray(this._rightPlaneVertices,0),O.Vector3[6].toArray(this._rightPlaneVertices,3),O.Vector3[7].toArray(this._rightPlaneVertices,6),O.Vector3[3].toArray(this._rightPlaneVertices,9),null===(i=this._lightHelperFrustumMeshes[8].geometry)||void 0===i||i.updateVerticesDataDirectly("position",this._rightPlaneVertices,0),O.Vector3[5].toArray(this._leftPlaneVertices,0),O.Vector3[9].toArray(this._leftPlaneVertices,3),O.Vector3[8].toArray(this._leftPlaneVertices,6),O.Vector3[4].toArray(this._leftPlaneVertices,9),null===(r=this._lightHelperFrustumMeshes[9].geometry)||void 0===r||r.updateVerticesDataDirectly("position",this._leftPlaneVertices,0),O.Vector3[2].toArray(this._topPlaneVertices,0),O.Vector3[6].toArray(this._topPlaneVertices,3),O.Vector3[9].toArray(this._topPlaneVertices,6),O.Vector3[5].toArray(this._topPlaneVertices,9),null===(n=this._lightHelperFrustumMeshes[10].geometry)||void 0===n||n.updateVerticesDataDirectly("position",this._topPlaneVertices,0),O.Vector3[3].toArray(this._bottomPlaneVertices,0),O.Vector3[7].toArray(this._bottomPlaneVertices,3),O.Vector3[8].toArray(this._bottomPlaneVertices,6),O.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 Ln("directionalLightHelperRoot_"+this._light.name,this._scene),this._rootNode.parent=this._light.parent,this._nearLinesPoints=[R.ZeroReadOnly,R.ZeroReadOnly,R.ZeroReadOnly,R.ZeroReadOnly,R.ZeroReadOnly];var t=Hu("nearlines",{updatable:!0,points:this._nearLinesPoints},this._scene);t.parent=this._rootNode,t.alwaysSelectAsActiveMesh=!0,this._farLinesPoints=[R.ZeroReadOnly,R.ZeroReadOnly,R.ZeroReadOnly,R.ZeroReadOnly,R.ZeroReadOnly];var i=Hu("farlines",{updatable:!0,points:this._farLinesPoints},this._scene);i.parent=this._rootNode,i.alwaysSelectAsActiveMesh=!0,this._trLinesPoints=[R.ZeroReadOnly,R.ZeroReadOnly];var r=Hu("trlines",{updatable:!0,points:this._trLinesPoints},this._scene);r.parent=this._rootNode,r.alwaysSelectAsActiveMesh=!0,this._brLinesPoints=[R.ZeroReadOnly,R.ZeroReadOnly];var n=Hu("brlines",{updatable:!0,points:this._brLinesPoints},this._scene);n.parent=this._rootNode,n.alwaysSelectAsActiveMesh=!0,this._tlLinesPoints=[R.ZeroReadOnly,R.ZeroReadOnly];var o=Hu("tllines",{updatable:!0,points:this._tlLinesPoints},this._scene);o.parent=this._rootNode,o.alwaysSelectAsActiveMesh=!0,this._blLinesPoints=[R.ZeroReadOnly,R.ZeroReadOnly];var a=Hu("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 io(t+"plane",e._scene),o=new _c(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 Rn;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 B(1,0,0),this._nearPlaneVertices),s("far",new B(.3,0,0),this._farPlaneVertices),s("right",new B(0,1,0),this._rightPlaneVertices),s("left",new B(0,.3,0),this._leftPlaneVertices),s("top",new B(0,0,1),this._topPlaneVertices),s("bottom",new B(0,0,.3),this._bottomPlaneVertices),this._nearLinesPoints[0]=O.Vector3[2],this._nearLinesPoints[1]=O.Vector3[3],this._nearLinesPoints[2]=O.Vector3[4],this._nearLinesPoints[3]=O.Vector3[5],this._nearLinesPoints[4]=O.Vector3[2],this._farLinesPoints[0]=O.Vector3[6],this._farLinesPoints[1]=O.Vector3[7],this._farLinesPoints[2]=O.Vector3[8],this._farLinesPoints[3]=O.Vector3[9],this._farLinesPoints[4]=O.Vector3[6],this._trLinesPoints[0]=O.Vector3[2],this._trLinesPoints[1]=O.Vector3[6],this._brLinesPoints[0]=O.Vector3[3],this._brLinesPoints[1]=O.Vector3[7],this._tlLinesPoints[0]=O.Vector3[4],this._tlLinesPoints[1]=O.Vector3[8],this._blLinesPoints[0]=O.Vector3[5],this._blLinesPoints[1]=O.Vector3[9]},e.prototype._getInvertViewMatrix=function(){return I.LookAtLHToRef(this._light.position,this._light.position.add(this._light.direction),R.UpReadOnly,this._inverseViewMatrix),this._inverseViewMatrix.invertToRef(this._inverseViewMatrix),this._inverseViewMatrix},e}(),Uh=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},Vh=function(t){function i(i){void 0===i&&(i=new Uh);var r=t.call(this,null)||this;Nn.Instances.push(r),void 0===i.deterministicLockstep&&(i.deterministicLockstep=!1),void 0===i.lockstepMaxSteps&&(i.lockstepMaxSteps=4),r._options=i,E.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,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,forceVertexBufferStrideMultiple4Bytes:!1,_collectUbosUpdatedInFrame:!1},$.Log("Babylon.js v".concat(Nn.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 W(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 qt;return t.references=1,t},i.prototype.createIndexBuffer=function(e){var t=new qt;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&&ei.IsWrapper(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!==a.ALPHA_DISABLE,t||this.setDepthWrite(e===a.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,s,l,c,u,h,d){void 0===n&&(n=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=null);var p=new jt(this,Ot.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,u&&(p.format=u),p.isReady=!0,o&&setTimeout((function(){o(p)})),this._internalTexturesCache.push(p),p},i.prototype._createHardwareRenderTargetWrapper=function(e,t,i){var r=new Oa(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?a.TEXTURETYPE_UNSIGNED_INT:t.type,r.samplingMode=void 0===t.samplingMode?a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode):(r.generateMipMaps=t,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.type=a.TEXTURETYPE_UNSIGNED_INT,r.samplingMode=a.TEXTURE_TRILINEAR_SAMPLINGMODE);var n=new jt(this,Ot.RenderTarget),o=e.width||e,s=e.height||e;return i._generateDepthBuffer=r.generateDepthBuffer,i._generateStencilBuffer=!!r.generateStencilBuffer,n.baseWidth=o,n.baseHeight=s,n.width=o,n.height=s,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=H({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:a.TEXTURETYPE_UNSIGNED_INT,samplingMode:a.TEXTURE_TRILINEAR_SAMPLINGMODE,format:a.TEXTUREFORMAT_RGBA},t);r.generateStencilBuffer=r.generateDepthBuffer&&r.generateStencilBuffer,(r.type!==a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(r.type!==a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(r.samplingMode=a.TEXTURE_NEAREST_SAMPLINGMODE),i._generateDepthBuffer=r.generateDepthBuffer,i._generateStencilBuffer=!!r.generateStencilBuffer;var n=new jt(this,Ot.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,s,l,c,u,h){void 0===l&&(l=null),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=0),void 0===h&&(h=!1);var d=new jt(this,Ot.Raw);return d.baseWidth=t,d.baseHeight=i,d.width=t,d.height=i,d.format=r,d.generateMipMaps=n,d.samplingMode=s,d.invertY=o,d._compression=l,d.type=c,d._useSRGBBuffer=h,this._doNotHandleContextLost||(d._bufferView=e),d},i.prototype.updateRawTexture=function(e,t,i,r,n,o,s){void 0===n&&(n=null),void 0===o&&(o=a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=!1),e&&(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n,e.type=o,e._useSRGBBuffer=s)},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 qt;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}(Nn);ri.prototype._debugPushGroup=function(e,t){},ri.prototype._debugPopGroup=function(e){},ri.prototype._debugInsertMarker=function(e,t){},ri.prototype._debugFlushPendingCommands=function(){};var kh=function(){this._timeElapsedQueryEnded=!1},Gh=function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=Vn.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=Vn.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,this.forceRenderingWhenOccluded=!1};Nn.prototype.createQuery=function(){var e=this._gl.createQuery();if(!e)throw new Error("Unable to create Occlusion Query");return e},Nn.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},Nn.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},Nn.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},Nn.prototype.beginOcclusionQuery=function(e,t){var i=this._getGlAlgorithmType(e);return this._gl.beginQuery(i,t),!0},Nn.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},Nn.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},Nn.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},Nn.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},Nn.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},Nn.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var i=new kh;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),e.canUseTimestampForTimerQuery)i._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(i._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;i._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,i._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,i._timeElapsedQuery),this._currentNonTimestampToken=i}return i},Nn.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(),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},Nn.prototype._captureGPUFrameTime=!1,Nn.prototype._gpuFrameTime=new vr,Nn.prototype.getGPUFrameTimeCounter=function(){return this._gpuFrameTime},Nn.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))},Nn.prototype._getGlAlgorithmType=function(e){return e===Vn.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(Vn.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},set:function(e){this._occlusionDataStorage.isOcclusionQueryInProgress=e},enumerable:!1,configurable:!0}),Object.defineProperty(Vn.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new Gh),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(Vn.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(Vn.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Vn.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Vn.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),Object.defineProperty(Vn.prototype,"forceRenderingWhenOccluded",{get:function(){return this._occlusionDataStorage.forceRenderingWhenOccluded},set:function(e){this._occlusionDataStorage.forceRenderingWhenOccluded=e},enumerable:!0,configurable:!0}),Vn.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===Vn.OCCLUSION_TYPE_NONE)return e.isOccluded=!1,!1;var t=this.getEngine();if(!t.getCaps().supportOcclusionQuery)return e.isOccluded=!1,!1;if(!t.isQueryResultAvailable)return e.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&null!==this._occlusionQuery&&void 0!==this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var i=t.getQueryResult(this._occlusionQuery);e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=!(i>0)}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return e.occlusionType!==Vn.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==Vn.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var r=this.getScene();if(r.getBoundingBoxRenderer){var n=r.getBoundingBoxRenderer();null===this._occlusionQuery&&(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery)&&(n.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0)}return e.isOccluded};var zh=!0;Nn.prototype.createTransformFeedback=function(){var e=this._gl.createTransformFeedback();if(!e)throw new Error("Unable to create Transform Feedback");return e},Nn.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},Nn.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},Nn.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},Nn.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},Nn.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},Nn.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)},ri.prototype.createExternalTexture=function(e){return null},ri.prototype.setExternalTexture=function(e,t){throw new Error("setExternalTexture: This engine does not support external textures!")},ri.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){var r=this._getInternalFormat(e.format),n=this._getRGBABufferInternalSizedFormat(a.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 s=e._workingCanvas.getContext("2d");if(!s)throw new Error("Unable to get 2d context");e._workingContext=s,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}}},ri.prototype.restoreSingleAttachment=function(){var e=this._gl;this.bindAttachments([e.BACK])},ri.prototype.restoreSingleAttachmentForRenderTarget=function(){var e=this._gl;this.bindAttachments([e.COLOR_ATTACHMENT0])},ri.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===a.TEXTUREFORMAT_DEPTH24_STENCIL8||t.depthTextureFormat===a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||t.depthTextureFormat===a.TEXTUREFORMAT_DEPTH24||t.depthTextureFormat===a.TEXTUREFORMAT_DEPTH32_FLOAT||t.depthTextureFormat===a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8)&&(c=t.depthTextureFormat));var x=this._gl,A=x.createFramebuffer();this._bindUnboundFramebuffer(A);var R=e.width||e,C=e.height||e,P=[],I=[],M=this.webGLVersion>1&&l&&(t.depthTextureFormat===a.TEXTUREFORMAT_DEPTH24_STENCIL8||t.depthTextureFormat===a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||t.depthTextureFormat===a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8),O=this._setupFramebufferDepthAttachments(!M&&s,!l&&o,R,C);S._framebuffer=A,S._depthStencilBuffer=O,S._generateDepthBuffer=!l&&o,S._generateStencilBuffer=!M&&s,S._attachments=I;for(var D=0;D1||this.isWebGPU);var k=this.webGLVersion>1,G=x[k?"COLOR_ATTACHMENT"+D:"COLOR_ATTACHMENT"+D+"_WEBGL"];if(I.push(G),-1!==B){var z=new jt(this,Ot.MultiRenderTarget);P[D]=z,x.activeTexture(x["TEXTURE"+D]),x.bindTexture(B,z._hardwareTexture.underlyingResource),x.texParameteri(B,x.TEXTURE_MAG_FILTER,V.mag),x.texParameteri(B,x.TEXTURE_MIN_FILTER,V.min),x.texParameteri(B,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(B,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE);var W=this._getRGBABufferInternalSizedFormat(F,w,L),H=this._getInternalFormat(w),X=this._getWebGLTextureType(F);if(!k||B!==a.TEXTURE_2D_ARRAY&&B!==a.TEXTURE_3D)if(B===a.TEXTURE_CUBE_MAP){for(var j=0;j<6;j++)x.texImage2D(x.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,W,R,C,0,H,X,null);z.isCube=!0}else x.texImage2D(x.TEXTURE_2D,0,W,R,C,0,H,X,null);else B===a.TEXTURE_2D_ARRAY?z.is2DArray=!0:z.is3D=!0,z.baseDepth=z.depth=U,x.texImage3D(B,0,W,R,C,U,0,H,X,null);n&&x.generateMipmap(B),this._bindTextureDirectly(B,null),z.baseWidth=R,z.baseHeight=C,z.width=R,z.height=C,z.isReady=!0,z.samples=1,z.generateMipMaps=n,z.samplingMode=N,z.type=F,z._useSRGBBuffer=L,z.format=w,this._internalTexturesCache.push(z)}}if(l&&this._caps.depthTextureExtension){var Y=new jt(this,Ot.Depth),K=a.TEXTURETYPE_UNSIGNED_SHORT,Q=x.DEPTH_COMPONENT16,q=x.DEPTH_COMPONENT,Z=x.UNSIGNED_SHORT,J=x.DEPTH_ATTACHMENT;this.webGLVersion<2?Q=x.DEPTH_COMPONENT:c===a.TEXTUREFORMAT_DEPTH32_FLOAT?(K=a.TEXTURETYPE_FLOAT,Z=x.FLOAT,Q=x.DEPTH_COMPONENT32F):c===a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8?(K=a.TEXTURETYPE_UNSIGNED_INT,Z=x.FLOAT_32_UNSIGNED_INT_24_8_REV,Q=x.DEPTH32F_STENCIL8,q=x.DEPTH_STENCIL,J=x.DEPTH_STENCIL_ATTACHMENT):c===a.TEXTUREFORMAT_DEPTH24?(K=a.TEXTURETYPE_UNSIGNED_INT,Z=x.UNSIGNED_INT,Q=x.DEPTH_COMPONENT24,J=x.DEPTH_ATTACHMENT):c!==a.TEXTUREFORMAT_DEPTH24_STENCIL8&&c!==a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||(K=a.TEXTURETYPE_UNSIGNED_INT_24_8,Z=x.UNSIGNED_INT_24_8,Q=x.DEPTH24_STENCIL8,q=x.DEPTH_STENCIL,J=x.DEPTH_STENCIL_ATTACHMENT),x.activeTexture(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,Y._hardwareTexture.underlyingResource),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,x.NEAREST),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,x.NEAREST),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE),x.texImage2D(x.TEXTURE_2D,0,Q,R,C,0,q,Z,null),x.framebufferTexture2D(x.FRAMEBUFFER,J,x.TEXTURE_2D,Y._hardwareTexture.underlyingResource,0),Y.baseWidth=R,Y.baseHeight=C,Y.width=R,Y.height=C,Y.isReady=!0,Y.samples=1,Y.generateMipMaps=n,Y.samplingMode=a.TEXTURE_NEAREST_SAMPLINGMODE,Y.format=c,Y.type=K,P[u]=Y,this._internalTexturesCache.push(Y)}return S.setTextures(P),i&&x.drawBuffers(I),this._bindUnboundFramebuffer(null),S.setLayerAndFaceIndices(T,b),this.resetTextureCache(),S},ri.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._getRGBAMultiSampleBufferFormat(c.type,c.format),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},ri.prototype._createDepthStencilCubeTexture=function(e,t,i){var r=new jt(this,Ot.DepthStencil);if(r.isCube=!0,1===this.webGLVersion)return $.Error("Depth cube texture is not supported by WebGL 1."),r;var n=H({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),o=this._gl;this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,r,!0),this._setupDepthStencilTexture(r,e,n.generateStencil,n.bilinearFiltering,n.comparisonFunction),i._depthStencilTexture=r,i._depthStencilTextureWithStencil=n.generateStencil;for(var a=0;a<6;a++)n.generateStencil?o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,o.DEPTH24_STENCIL8,e,e,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,o.DEPTH_COMPONENT24,e,e,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null);return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(r),r},ri.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)}))},ri.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)},ri.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)},ri.prototype._partialLoadImg=function(e,t,i,r,n,o,a,s){void 0===a&&(a=null);var l=xi();di(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)},ri.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?a.TEXTURE_TRILINEAR_SAMPLINGMODE:a.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)},ri.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 jt(this,Ot.Cube);m.isCube=!0,m.url=e,m.generateMipMaps=!r,m._lodGenerationScale=c,m._lodGenerationOffset=u,m._useSRGBBuffer=!!f&&this._caps.supportSRGBBuffers&&(this.webGLVersion>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=ri._TextureLoaders;E-1?e.substring(i,e.length):"";return(t>-1?e.substring(0,t):e)+this._textureFormatInUse+r}Object.defineProperty(Nn.prototype,"onBeforeViewRenderObservable",{get:function(){return Hh}}),Object.defineProperty(Nn.prototype,"onAfterViewRenderObservable",{get:function(){return Xh}}),Object.defineProperty(Nn.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))}}),Nn.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},Nn.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}(),qh=[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))],Zh=[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}],Jh=function(e,t){return qh[e]*Zh[e](t)},$h=[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],ed=function(){function e(){this.preScaled=!1,this.l00=R.Zero(),this.l1_1=R.Zero(),this.l10=R.Zero(),this.l11=R.Zero(),this.l2_2=R.Zero(),this.l2_1=R.Zero(),this.l20=R.Zero(),this.l21=R.Zero(),this.l22=R.Zero()}return e.prototype.addLight=function(e,t,i){O.Vector3[0].set(t.r,t.g,t.b);var r=O.Vector3[0],n=O.Vector3[1];r.scaleToRef(i,n),n.scaleToRef(Jh(0,e),O.Vector3[2]),this.l00.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(1,e),O.Vector3[2]),this.l1_1.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(2,e),O.Vector3[2]),this.l10.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(3,e),O.Vector3[2]),this.l11.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(4,e),O.Vector3[2]),this.l2_2.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(5,e),O.Vector3[2]),this.l2_1.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(6,e),O.Vector3[2]),this.l20.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(7,e),O.Vector3[2]),this.l21.addInPlace(O.Vector3[2]),n.scaleToRef(Jh(8,e),O.Vector3[2]),this.l22.addInPlace(O.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($h[0]),this.l1_1.scaleInPlace($h[1]),this.l10.scaleInPlace($h[2]),this.l11.scaleInPlace($h[3]),this.l2_2.scaleInPlace($h[4]),this.l2_1.scaleInPlace($h[5]),this.l20.scaleInPlace($h[6]),this.l21.scaleInPlace($h[7]),this.l22.scaleInPlace($h[8])},e.prototype.convertIrradianceToLambertianRadiance=function(){this.scaleInPlace(1/Math.PI)},e.prototype.preScaleForRendering=function(){this.preScaled=!0,this.l00.scaleInPlace(qh[0]),this.l1_1.scaleInPlace(qh[1]),this.l10.scaleInPlace(qh[2]),this.l11.scaleInPlace(qh[3]),this.l2_2.scaleInPlace(qh[4]),this.l2_1.scaleInPlace(qh[5]),this.l20.scaleInPlace(qh[6]),this.l21.scaleInPlace(qh[7]),this.l22.scaleInPlace(qh[8])},e.prototype.updateFromArray=function(e){return R.FromArrayToRef(e[0],0,this.l00),R.FromArrayToRef(e[1],0,this.l1_1),R.FromArrayToRef(e[2],0,this.l10),R.FromArrayToRef(e[3],0,this.l11),R.FromArrayToRef(e[4],0,this.l2_2),R.FromArrayToRef(e[5],0,this.l2_1),R.FromArrayToRef(e[6],0,this.l20),R.FromArrayToRef(e[7],0,this.l21),R.FromArrayToRef(e[8],0,this.l22),this},e.prototype.updateFromFloatsArray=function(e){return R.FromFloatsToRef(e[0],e[1],e[2],this.l00),R.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),R.FromFloatsToRef(e[6],e[7],e[8],this.l10),R.FromFloatsToRef(e[9],e[10],e[11],this.l11),R.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),R.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),R.FromFloatsToRef(e[18],e[19],e[20],this.l20),R.FromFloatsToRef(e[21],e[22],e[23],this.l21),R.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}(),td=function(){function e(){this.x=R.Zero(),this.y=R.Zero(),this.z=R.Zero(),this.xx=R.Zero(),this.yy=R.Zero(),this.zz=R.Zero(),this.xy=R.Zero(),this.yz=R.Zero(),this.zx=R.Zero()}return Object.defineProperty(e.prototype,"preScaledHarmonics",{get:function(){return this._harmonics||(this._harmonics=ed.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics},enumerable:!1,configurable:!0}),e.prototype.addAmbient=function(e){O.Vector3[0].copyFromFloats(e.r,e.g,e.b);var t=O.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),O.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),O.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(O.Vector3[0]).addInPlace(O.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(O.Vector3[0]).subtractInPlace(O.Vector3[1]),this.zz.copyFrom(e.l00),O.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(O.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 R.FromArrayToRef(t[0],0,i.x),R.FromArrayToRef(t[1],0,i.y),R.FromArrayToRef(t[2],0,i.z),R.FromArrayToRef(t[3],0,i.xx),R.FromArrayToRef(t[4],0,i.yy),R.FromArrayToRef(t[5],0,i.zz),R.FromArrayToRef(t[6],0,i.yz),R.FromArrayToRef(t[7],0,i.zx),R.FromArrayToRef(t[8],0,i.xy),i},e}();function id(e,t,i,r){void 0===r&&(r=!0);var n=e.getScene(),o=n.getEngine(),s=new ns("resized"+e.name,{width:t,height:i},n,!e.noMipmap,!0,e._texture.type,!1,e.samplingMode,!1);s.wrapU=e.wrapU,s.wrapV=e.wrapV,s.uOffset=e.uOffset,s.vOffset=e.vOffset,s.uScale=e.uScale,s.vScale=e.vScale,s.uAng=e.uAng,s.vAng=e.vAng,s.wAng=e.wAng,s.coordinatesIndex=e.coordinatesIndex,s.level=e.level,s.anisotropicFilteringLevel=e.anisotropicFilteringLevel,s._texture.isReady=!1,e.wrapU=Eo.CLAMP_ADDRESSMODE,e.wrapV=Eo.CLAMP_ADDRESSMODE;var l=new Cl("pass",1,null,r?Eo.BILINEAR_SAMPLINGMODE:Eo.NEAREST_SAMPLINGMODE,o,!1,a.TEXTURETYPE_UNSIGNED_INT);return l.externalTextureSamplerBinding=!0,l.getEffect().executeWhenCompiled((function(){l.onApply=function(t){t.setTexture("textureSampler",e)};var t=s.renderTarget;t&&(n.postProcessManager.directRender([l],t),o.unBindFramebuffer(t),s.disposeFramebufferObjects(),l.dispose(),s.getInternalTexture().isReady=!0)})),s}function rd(e,t,i,r,n,o,s,l){var c=t.getEngine();return t.isReady=!1,n=null!=n?n:t.samplingMode,r=null!=r?r:t.type,o=null!=o?o:t.format,s=null!=s?s:t.width,l=null!=l?l:t.height,-1===r&&(r=a.TEXTURETYPE_UNSIGNED_BYTE),new Promise((function(u){var h=new Na("postprocess",e,null,null,1,null,n,c,!1,void 0,r,void 0,null,!1,o);h.externalTextureSamplerBinding=!0;var d=c.createRenderTargetTexture({width:s,height:l},{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),c.restoreDefaultFramebuffer(),c._releaseTexture(t),h&&h.dispose(),d._swapAndDie(t),t.type=r,t.format=a.TEXTUREFORMAT_RGBA,t.isReady=!0,u(t)}))}))}function nd(e){Yh||(Yh=new Float32Array(1),Kh=new Int32Array(Yh.buffer)),Yh[0]=e;var t=Kh[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 od(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))}kt.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);}";var ad=function(e,t,i,r,n){return j(void 0,void 0,void 0,(function(){var o,a,s,l,c,u,h,d,p;return Y(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 Na("lodCube","lodCube",["lod","gamma"],null,1,null,Eo.NEAREST_NEAREST_MIPNEAREST,a,!1,l[r])):s=new Na("lod","lod",["lod","gamma"],null,1,null,Eo.NEAREST_NEAREST_MIPNEAREST,a),[4,new Promise((function(e){s.getEffect().executeWhenCompiled((function(){e(0)}))}))];case 1:f.sent(),c=new ns("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(Eo.NEAREST_NEAREST_MIPNEAREST):e.updateSamplingMode(Eo.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 sd(e,t,i,r,n){return void 0===r&&(r=0),void 0===n&&(n=0),j(this,void 0,void 0,(function(){return Y(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,ad(e,t,i,r,n)];case 3:return[2,o.sent()]}}))}))}var ld={CreateResizedCopy:id,ApplyPostProcess:rd,ToHalfFloat:nd,FromHalfFloat:od,GetTextureDataAsync:sd},cd=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=a.TEXTURETYPE_HALF_FLOAT):r.textureFloatRender&&r.textureFloatLinearFiltering&&(o=!0,t.type=a.TEXTURETYPE_FLOAT),o&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1);var s=function(){if(o){var r=new Na("rgbdDecode","rgbdDecode",null,null,1,null,a.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:a.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}))}};n?s():e.onLoadObservable.addOnce(s)}},e.EncodeTextureToRGBD=function(e,t,i){return void 0===i&&(i=a.TEXTURETYPE_UNSIGNED_BYTE),rd("rgbdEncode",e,t,i,a.TEXTURE_NEAREST_SAMPLINGMODE,a.TEXTUREFORMAT_RGBA)},e}(),ud=function(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r},hd=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,s=e.readPixels(0,void 0,void 0,!1),l=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 c=e.readPixels(4,void 0,void 0,!1),u=e.readPixels(5,void 0,void 0,!1),h=e.gammaSpace,d=a.TEXTUREFORMAT_RGBA,p=a.TEXTURETYPE_UNSIGNED_INT;return e.textureType!=a.TEXTURETYPE_FLOAT&&e.textureType!=a.TEXTURETYPE_HALF_FLOAT||(p=a.TEXTURETYPE_FLOAT),new Promise((function(e){Promise.all([l,s,r,n,c,u]).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 ed,i=0,r=2/e.size,n=r,o=.5*r,s=o-1,l=0;l<6;l++)for(var c=this._FileFaces[l],u=e[c.name],d=s,f=e.format===a.TEXTUREFORMAT_RGBA?4:3,_=0;_S){var A=S/x;b*=A,T*=A,E*=A}}else b=h.Clamp(b,0,S),T=h.Clamp(T,0,S),E=h.Clamp(E,0,S);var R=new B(b,T,E);t.addLight(v,R,y),i+=y,m+=r}d+=n}var C=4*Math.PI*6/6/i;return t.scaleInPlace(C),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),td.FromHarmonics(t)},e._FileFaces=[new ud("right",new R(1,0,0),new R(0,0,-1),new R(0,-1,0)),new ud("left",new R(-1,0,0),new R(0,0,1),new R(0,-1,0)),new ud("up",new R(0,1,0),new R(1,0,0),new R(0,0,1)),new ud("down",new R(0,-1,0),new R(1,0,0),new R(0,0,-1)),new ud("front",new R(0,0,1),new R(1,0,0),new R(0,-1,0)),new ud("back",new R(0,0,-1),new R(-1,0,0),new R(0,-1,0))],e.MAX_HDRI_VALUE=4096,e.PRESERVE_CLAMPED_COLORS=!1,e}();go.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)},Object.defineProperty(go.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=hd.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});kt.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 dd="image/png",pd=2,fd=[134,22,135,150,246,214,150,54];function _d(e){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0,r=0;rpd)throw new Error('Unsupported babylon environment map version "'.concat(e.version,'". Latest supported version is "').concat(pd,'".'));return 2===e.version?e:e=H(H({},e),{version:2,imageType:dd})}function gd(e,t){var i,r;return void 0===t&&(t={}),j(this,void 0,void 0,(function(){var n,o,s,l,c,u,d,p,f,_,m,g,v,y,b,T,E,S,x,A,R,C,P,I,M,O,D,N,F,L,w,B,U;return Y(this,(function(V){switch(V.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:dd,s=n.getEngine(),e.textureType!==a.TEXTURETYPE_HALF_FLOAT&&e.textureType!==a.TEXTURETYPE_FLOAT&&e.textureType!==a.TEXTURETYPE_UNSIGNED_BYTE&&e.textureType!==a.TEXTURETYPE_UNSIGNED_INT&&e.textureType!==a.TEXTURETYPE_UNSIGNED_INTEGER&&-1!==e.textureType)return[2,Promise.reject("The cube texture should allow HDR (Full Float or Half Float).")];if(l=a.TEXTURETYPE_FLOAT,!s.getCaps().textureFloatRender&&(l=a.TEXTURETYPE_HALF_FLOAT,!s.getCaps().textureHalfFloatRender))return[2,Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];e.sphericalPolynomial,c=null===(r=e.getInternalTexture())||void 0===r?void 0:r._sphericalPolynomialPromise,u=n.width,d=new Ar(s),p={},s.flushFramebuffer(),f=h.ILog2(n.width),w=0,V.label=1;case 1:if(!(w<=f))return[3,9];_=Math.pow(2,f-w),B=0,V.label=2;case 2:return B<6?[4,e.readPixels(B,w,void 0,!1)]:[3,8];case 3:if((m=V.sent())&&m.byteLength===m.length){for(g=new Float32Array(4*m.byteLength),v=0;v=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||95==t}function Id(e){for(var t=0,i="",r=!1,n=[];t=0&&e.charAt(t)!==i;)t--;return t}var Od=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&&console.log("Start inlining process (code size=".concat(this._sourceCode.length,")...")),this._collectFunctions(),this._processInlining(this._numMaxIterations),this.debug&&console.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(),Ud(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.nativeProgram,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(){return new Dd(this)},t.prototype.createMaterialContext=function(){},t.prototype.createDrawContext=function(){},t.prototype._preparePipelineContext=function(e,t,i,r,n,o,a,s){e.nativeProgram=r?this.createRawShaderProgram():this.createShaderProgram(e,t,i,s)},t.prototype.isAsync=function(e){return!(!e.isAsync||!this._engine.createProgramAsync)},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var i=e;if(this.isAsync(e)){var r=i.onCompiled;i.onCompiled=r?function(){r(),t()}: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;if(o.nativeProgram)throw new Error("Tried to create a second program in the same NativePipelineContext");this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=new Od(t);a.processCode(),t=a.code;var s=new Od(i);s.processCode(),i=s.code,t=ri._ConcatenateShader(t,r),i=ri._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(this.isAsync(e))return this._engine.createProgramAsync(t,i,l,(function(e){o.compilationError=e}));try{var c=o.nativeProgram=this._engine.createProgram(t,i);return l(),c}catch(e){var u=null==e?void 0:e.message;throw new Error("SHADER ERROR"+("string"==typeof u?"\n"+u:""))}},t.prototype.inlineShaderCode=function(e){var t=new Od(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.nativeProgram&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),this._commandBufferEncoder.encodeCommandArgAsNativeData(t.nativeProgram),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.getUniforms=function(e,t){var i=e;return this._engine.getUniforms(i.nativeProgram,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.nativeProgram);for(var i=e.getSamplers(),r=0;r-1?e.substring(T).toLowerCase():""),x=null,A=0,R=Nn._TextureLoaders;A-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){return function(e){var t=_d(e);m.width=t.width,m.height=t.width,Sd(m,t);var i=t.specular;if(!i)throw new Error("Nothing else parsed so far");m._lodGenerationScale=i.lodGenerationScale;var r=yd(e,t);m.format=a.TEXTUREFORMAT_RGBA,m.type=a.TEXTURETYPE_UNSIGNED_INT,m.generateMipMaps=!0,m.getEngine().updateTextureSamplingMode(Eo.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))}),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 Ri.LoadFileAsync(e).then((function(e){return new Uint8Array(e)}))}))).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 Fd(this._createTexture(),this._engine)},t.prototype._createHardwareRenderTargetWrapper=function(e,t,i){var r=new Nd(e,t,i,this);return this._renderTargetWrapperCache.push(r),r},t.prototype._createInternalTexture=function(e,t,i,r){var n,o,s;void 0===i&&(i=!0),void 0===r&&(r=Ot.Unknown);var l,c=!1,u=a.TEXTURETYPE_UNSIGNED_INT,h=a.TEXTURE_TRILINEAR_SAMPLINGMODE,d=a.TEXTUREFORMAT_RGBA,p=!1,f=1;void 0!==t&&"object"==typeof t?(c=!!t.generateMipMaps,u=void 0===t.type?a.TEXTURETYPE_UNSIGNED_INT:t.type,h=void 0===t.samplingMode?a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,d=void 0===t.format?a.TEXTUREFORMAT_RGBA:t.format,p=void 0!==t.useSRGBBuffer&&t.useSRGBBuffer,f=null!==(n=t.samples)&&void 0!==n?n:1,l=t.label):c=!!t,p=this._getUseSRGBBuffer(p,!c),(u!==a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(u!==a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(h=a.TEXTURE_NEAREST_SAMPLINGMODE),u!==a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(u=a.TEXTURETYPE_UNSIGNED_INT,$.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));var _=new jt(this,r),m=null!==(o=e.width)&&void 0!==o?o:e,g=null!==(s=e.height)&&void 0!==s?s:e,v=e.layers||0;if(0!==v)throw new Error("Texture layers are not supported in Babylon Native");var y=_._hardwareTexture.underlyingResource,b=Ld(d,u);return this._engine.initializeTexture(y,m,g,c,b,!0,p,f),this._setTextureSampling(y,wd(h)),_._useSRGBBuffer=p,_.baseWidth=m,_.baseHeight=g,_.width=m,_.height=g,_.depth=v,_.isReady=!0,_.samples=f,_.generateMipMaps=c,_.samplingMode=h,_.type=u,_.format=d,_.label=l,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,Ot.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 $.Warn("Updating render target sample count is not currently supported"),e.samples},t.prototype.updateTextureSamplingMode=function(e,t){if(t._hardwareTexture){var i=wd(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){var n=e,o=ArrayBuffer.isView(t)?t:new Float32Array(t);this._engine.updateDynamicVertexBuffer(n.nativeVertexBuffer,o.buffer,o.byteOffset+(null!=i?i:0),null!=r?r:o.byteLength)},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===a.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,Bd(t.wrapU),Bd(t.wrapV),Bd(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._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}(Nn);Xd._createNativeDataStream=function(){return _native.NativeDataStream.VALIDATION_ENABLED?new Dp:new Qh};var jd,Yd,Kd,Qd,qd,Zd,Jd,$d,ep,tp,ip,rp,np,op,ap,sp,lp,cp,up,hp,dp,pp,fp,_p,mp,gp,vp,yp,bp,Tp,Ep,Sp,xp,Ap,Rp,Cp,Pp,Ip,Mp,Op,Dp=function(e){function t(){return e.call(this)||this}return W(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}(Qh);!function(e){e.LowPower="low-power",e.HighPerformance="high-performance"}(jd||(jd={})),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"}(Yd||(Yd={})),function(e){e.Unmapped="unmapped",e.Pending="pending",e.Mapped="mapped"}(Kd||(Kd={})),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"}(Qd||(Qd={})),function(e){e[e.Read=1]="Read",e[e.Write=2]="Write"}(qd||(qd={})),function(e){e.E1d="1d",e.E2d="2d",e.E3d="3d"}(Zd||(Zd={})),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"}(Jd||(Jd={})),function(e){e.E1d="1d",e.E2d="2d",e.E2dArray="2d-array",e.Cube="cube",e.CubeArray="cube-array",e.E3d="3d"}($d||($d={})),function(e){e.All="all",e.StencilOnly="stencil-only",e.DepthOnly="depth-only"}(ep||(ep={})),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"}(tp||(tp={})),function(e){e.ClampToEdge="clamp-to-edge",e.Repeat="repeat",e.MirrorRepeat="mirror-repeat"}(ip||(ip={})),function(e){e.Nearest="nearest",e.Linear="linear"}(rp||(rp={})),function(e){e.Nearest="nearest",e.Linear="linear"}(np||(np={})),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"}(op||(op={})),function(e){e[e.Vertex=1]="Vertex",e[e.Fragment=2]="Fragment",e[e.Compute=4]="Compute"}(ap||(ap={})),function(e){e.Uniform="uniform",e.Storage="storage",e.ReadOnlyStorage="read-only-storage"}(sp||(sp={})),function(e){e.Filtering="filtering",e.NonFiltering="non-filtering",e.Comparison="comparison"}(lp||(lp={})),function(e){e.Float="float",e.UnfilterableFloat="unfilterable-float",e.Depth="depth",e.Sint="sint",e.Uint="uint"}(cp||(cp={})),function(e){e.WriteOnly="write-only"}(up||(up={})),function(e){e.Error="error",e.Warning="warning",e.Info="info"}(hp||(hp={})),function(e){e.Validation="validation",e.Internal="internal"}(dp||(dp={})),function(e){e.Auto="auto"}(pp||(pp={})),function(e){e.PointList="point-list",e.LineList="line-list",e.LineStrip="line-strip",e.TriangleList="triangle-list",e.TriangleStrip="triangle-strip"}(fp||(fp={})),function(e){e.CCW="ccw",e.CW="cw"}(_p||(_p={})),function(e){e.None="none",e.Front="front",e.Back="back"}(mp||(mp={})),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"}(gp||(gp={})),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"}(vp||(vp={})),function(e){e.Add="add",e.Subtract="subtract",e.ReverseSubtract="reverse-subtract",e.Min="min",e.Max="max"}(yp||(yp={})),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"}(bp||(bp={})),function(e){e.Uint16="uint16",e.Uint32="uint32"}(Tp||(Tp={})),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"}(Ep||(Ep={})),function(e){e.Vertex="vertex",e.Instance="instance"}(Sp||(Sp={})),function(e){e.Beginning="beginning",e.End="end"}(xp||(xp={})),function(e){e.Beginning="beginning",e.End="end"}(Ap||(Ap={})),function(e){e.Load="load",e.Clear="clear"}(Rp||(Rp={})),function(e){e.Store="store",e.Discard="discard"}(Cp||(Cp={})),function(e){e.Occlusion="occlusion",e.Timestamp="timestamp"}(Pp||(Pp={})),function(e){e.Opaque="opaque",e.Premultiplied="premultiplied"}(Ip||(Ip={})),function(e){e.Unknown="unknown",e.Destroyed="destroyed"}(Mp||(Mp={})),function(e){e.Validation="validation",e.OutOfMemory="out-of-memory",e.Internal="internal"}(Op||(Op={}));var Np=function(){function e(){this.shaderLanguage=at.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 Hi(this.engine,void 0,void 0,"leftOver-"+this._name);for(var e=0,t=this.shaderProcessingContext.leftOverUniforms;e)?$/,"$1"),n=Np.UniformSizes[r];this.uniformBuffer.addUniform(i.name,n,i.length),this._leftOverUniformsByName[i.name]=i.type}this.uniformBuffer.create()}},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}(),Lp={mat2:2,mat3:3,mat4:4,mat2x2:2,mat3x3:3,mat4x4:4},wp=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=Lp[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=Lp[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}(),Bp=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=at.GLSL,t.parseGLES3=!0,t}return W(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(Np.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&&$.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:cp.Float};for(var u=0;u<(l||1);++u)c.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())}var h=null!==(n=Np._SamplerTypeByWebGLSamplerType[a])&&void 0!==n?n:"sampler",d=!!Np._IsComparisonSamplerByWebGPUSamplerType[h],p=d?lp.Comparison:lp.Filtering,f=s+Np.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?cp.Depth:"u"===m?cp.Uint:"i"===m?cp.Sint:cp.Float;c.sampleType=g;var v=l>0,y=_.binding.groupIndex,b=_.binding.bindingIndex,T=Np._SamplerFunctionByWebGLSamplerType[a],E=Np._TextureTypeByWebGLSamplerType[a],S=Np._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",n.isNDCHalfZRange||(e+="gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;\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}(Np);kt.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";kt.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";kt.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";kt.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";kt.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";kt.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";kt.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";kt.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";kt.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";kt.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";kt.IncludesShadersStoreWGSL.meshUboDeclaration="struct Mesh {world : mat4x4,\nvisibility : f32,};var mesh : Mesh;\n#define WORLD_UBO\n";kt.IncludesShadersStoreWGSL.morphTargetsVertex="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE \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#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";kt.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#endif\n#endif\n";kt.IncludesShadersStoreWGSL.morphTargetsVertexGlobal="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvar vertexID : f32;\n#endif\n#endif\n";kt.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";kt.IncludesShadersStoreWGSL.sceneUboDeclaration="struct Scene {viewProjection : mat4x4,\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4,\n#endif \nview : mat4x4,\nprojection : mat4x4,\nvEyePosition : vec4,};var scene : Scene;\n";var Up,Vp,kp={texture_1d:$d.E1d,texture_2d:$d.E2d,texture_2d_array:$d.E2dArray,texture_3d:$d.E3d,texture_cube:$d.Cube,texture_cube_array:$d.CubeArray,texture_multisampled_2d:$d.E2d,texture_depth_2d:$d.E2d,texture_depth_2d_array:$d.E2dArray,texture_depth_cube:$d.Cube,texture_depth_cube_array:$d.CubeArray,texture_depth_multisampled_2d:$d.E2d,texture_storage_1d:$d.E1d,texture_storage_2d:$d.E2d,texture_storage_2d_array:$d.E2dArray,texture_storage_3d:$d.E3d,texture_external:null},Gp=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.shaderLanguage=at.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 W(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){return"struct ".concat(Np.InternalsUBOName," {\n yFactor_: f32,\n textureOutputHeight_: f32,\n};\nvar ").concat("internals"," : ").concat(Np.InternalsUBOName,";\n")+Id(e)},t.prototype.varyingProcessor=function(e,t,i){var r=/\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(null!==r){var n,o=r[2],a=r[1];t?void 0===(n=this._webgpuProcessingContext.availableVaryings[a])&&$.Warn('Invalid fragment shader: The varying named "'.concat(a,'" is not declared in the vertex shader! This declaration will be ignored.')):(n=this._webgpuProcessingContext.getVaryingNextLocation(o,this._getArraySize(a,o,i)[2]),this._webgpuProcessingContext.availableVaryings[a]=n,this._varyingsWGSL.push(" @location(".concat(n,") ").concat(a," : ").concat(o,",")),this._varyingNamesWGSL.push(a)),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:cp.Float},h=h||1;for(var p=0;p0,_=kp[s],m=f?cp.Depth:"u32"===c?cp.Uint:"i32"===c?cp.Sint:cp.Float;if(d.sampleType=m,void 0===_)throw"Can't get the texture dimension corresponding to the texture function \"".concat(s,'"!');for(p=0;p=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=Np.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(Np.AutoSamplerSuffix)===n.length-Np.AutoSamplerSuffix.length?n.substring(0,n.indexOf(Np.AutoSamplerSuffix)):null,s="sampler_comparison"===o?lp.Comparison:lp.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=/var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm;;){var r=i.exec(e);if(null===r)break;var n=r[1],o=r[3],a=r[4],s=r[5],l=this._webgpuProcessingContext.availableBuffers[a];if(!l){var c="uniform"===n?wp.KnownUBOs[s]:null,u=void 0;c?(a=s,-1===(u=c.binding).groupIndex&&(u=this._webgpuProcessingContext.getNextFreeUBOBinding())):u=this._webgpuProcessingContext.getNextFreeUBOBinding(),l={binding:u},this._webgpuProcessingContext.availableBuffers[a]=l}this._addBufferBindingDescription(a,this._webgpuProcessingContext.availableBuffers[a],"read_write"===o?sp.Storage:"storage"===n?sp.ReadOnlyStorage:sp.Uniform,t);var h=l.binding.groupIndex,d=l.binding.bindingIndex,p=e.substring(0,r.index),f="@group(".concat(h,") @binding(").concat(d,") "),_=e.substring(r.index);e=p+f+_,i.lastIndex+=f.length}return e},t.prototype._processStridedUniformArrays=function(e){for(var t=0,i=this._stridedUniformArrays;t= 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 "}],Kp={"":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},Qp=function(){function e(e,t,i,r,n){if(this._pipelines={},this._compiledShaders=[],this._videoPipelines={},this._videoCompiledShaders=[],this._deferredReleaseTextures=[],this._device=e,this._glslang=t,this._tintWASM=i,this._bufferManager=r,-1!==n.indexOf(Yd.RG11B10UFloatRenderable)){var o=Object.keys(Kp);Kp[tp.RG11B10UFloat]=Kp[o[o.length-1]]+1}this._mipmapSampler=e.createSampler({minFilter:rp.Linear}),this._videoSampler=e.createSampler({minFilter:rp.Linear}),this._ubCopyWithOfst=this._bufferManager.createBuffer(16,Qd.Uniform|Qd.CopyDst,"UBCopyWithOffset").underlyingResource,this._getPipeline(tp.RGBA8Unorm),this._getVideoPipeline(tp.RGBA8Unorm)}return e.ComputeNumMipmapLevels=function(e,t){return h.ILog2(Math.max(e,t))+1},e.prototype._getPipeline=function(e,t,i){void 0===t&&(t=Up.MipMap);var r=t===Up.MipMap?1:t===Up.InvertYPremultiplyAlpha?((i.invertY?1:0)<<1)+((i.premultiplyAlpha?1:0)<<2):t===Up.Clear?8:t===Up.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!==Up.InvertYPremultiplyAlpha&&t!==Up.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+Yp[t].vertex,"vertex"),l=this._glslang.compileGLSL(o+Yp[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:pp.Auto,vertex:{module:a[0],entryPoint:"main"},fragment:{module:a[1],entryPoint:"main",targets:[{format:e}]},primitive:{topology:fp.TriangleStrip,stripIndexFormat:Tp.Uint16}});n=this._pipelines[e][r]=[h,h.getBindGroupLayout(0)]}return n},e.prototype._getVideoPipeline=function(e,t){void 0===t&&(t=Vp.DontInvertY);var i=t===Vp.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:"CopyVideoToTexture_".concat(e,"_").concat(0===i?"DontInvertY":"InvertY"),layout:pp.Auto,vertex:{module:n[0],entryPoint:"main"},fragment:{module:n[1],entryPoint:"main",targets:[{format:e}]},primitive:{topology:fp.TriangleStrip,stripIndexFormat:Tp.Uint16}});r=this._videoPipelines[e][i]=[s,s.getBindGroupLayout(0)]}return r},e._GetTextureTypeFromFormat=function(e){switch(e){case tp.R8Unorm:case tp.R8Snorm:case tp.R8Uint:case tp.R8Sint:case tp.RG8Unorm:case tp.RG8Snorm:case tp.RG8Uint:case tp.RG8Sint:case tp.RGBA8Unorm:case tp.RGBA8UnormSRGB:case tp.RGBA8Snorm:case tp.RGBA8Uint:case tp.RGBA8Sint:case tp.BGRA8Unorm:case tp.BGRA8UnormSRGB:case tp.RGB10A2UINT:case tp.RGB10A2Unorm:case tp.RGB9E5UFloat:case tp.RG11B10UFloat:case tp.Depth32FloatStencil8:case tp.BC7RGBAUnorm:case tp.BC7RGBAUnormSRGB:case tp.BC6HRGBUFloat:case tp.BC6HRGBFloat:case tp.BC5RGUnorm:case tp.BC5RGSnorm:case tp.BC3RGBAUnorm:case tp.BC3RGBAUnormSRGB:case tp.BC2RGBAUnorm:case tp.BC2RGBAUnormSRGB:case tp.BC4RUnorm:case tp.BC4RSnorm:case tp.BC1RGBAUnorm:case tp.BC1RGBAUnormSRGB:case tp.ETC2RGB8Unorm:case tp.ETC2RGB8UnormSRGB:case tp.ETC2RGB8A1Unorm:case tp.ETC2RGB8A1UnormSRGB:case tp.ETC2RGBA8Unorm:case tp.ETC2RGBA8UnormSRGB:case tp.EACR11Unorm:case tp.EACR11Snorm:case tp.EACRG11Unorm:case tp.EACRG11Snorm:case tp.ASTC4x4Unorm:case tp.ASTC4x4UnormSRGB:case tp.ASTC5x4Unorm:case tp.ASTC5x4UnormSRGB:case tp.ASTC5x5Unorm:case tp.ASTC5x5UnormSRGB:case tp.ASTC6x5Unorm:case tp.ASTC6x5UnormSRGB:case tp.ASTC6x6Unorm:case tp.ASTC6x6UnormSRGB:case tp.ASTC8x5Unorm:case tp.ASTC8x5UnormSRGB:case tp.ASTC8x6Unorm:case tp.ASTC8x6UnormSRGB:case tp.ASTC8x8Unorm:case tp.ASTC8x8UnormSRGB:case tp.ASTC10x5Unorm:case tp.ASTC10x5UnormSRGB:case tp.ASTC10x6Unorm:case tp.ASTC10x6UnormSRGB:case tp.ASTC10x8Unorm:case tp.ASTC10x8UnormSRGB:case tp.ASTC10x10Unorm:case tp.ASTC10x10UnormSRGB:case tp.ASTC12x10Unorm:case tp.ASTC12x10UnormSRGB:case tp.ASTC12x12Unorm:case tp.ASTC12x12UnormSRGB:return a.TEXTURETYPE_UNSIGNED_BYTE;case tp.R16Uint:case tp.R16Sint:case tp.RG16Uint:case tp.RG16Sint:case tp.RGBA16Uint:case tp.RGBA16Sint:case tp.Depth16Unorm:return a.TEXTURETYPE_UNSIGNED_SHORT;case tp.R16Float:case tp.RG16Float:case tp.RGBA16Float:return a.TEXTURETYPE_HALF_FLOAT;case tp.R32Uint:case tp.R32Sint:case tp.RG32Uint:case tp.RG32Sint:case tp.RGBA32Uint:case tp.RGBA32Sint:return a.TEXTURETYPE_UNSIGNED_INTEGER;case tp.R32Float:case tp.RG32Float:case tp.RGBA32Float:case tp.Depth32Float:return a.TEXTURETYPE_FLOAT;case tp.Stencil8:throw"No fixed size for Stencil8 format!";case tp.Depth24Plus:throw"No fixed size for Depth24Plus format!";case tp.Depth24PlusStencil8:throw"No fixed size for Depth24PlusStencil8 format!"}return a.TEXTURETYPE_UNSIGNED_BYTE},e._GetBlockInformationFromFormat=function(e){switch(e){case tp.R8Unorm:case tp.R8Snorm:case tp.R8Uint:case tp.R8Sint:return{width:1,height:1,length:1};case tp.R16Uint:case tp.R16Sint:case tp.R16Float:case tp.RG8Unorm:case tp.RG8Snorm:case tp.RG8Uint:case tp.RG8Sint:return{width:1,height:1,length:2};case tp.R32Uint:case tp.R32Sint:case tp.R32Float:case tp.RG16Uint:case tp.RG16Sint:case tp.RG16Float:case tp.RGBA8Unorm:case tp.RGBA8UnormSRGB:case tp.RGBA8Snorm:case tp.RGBA8Uint:case tp.RGBA8Sint:case tp.BGRA8Unorm:case tp.BGRA8UnormSRGB:case tp.RGB9E5UFloat:case tp.RGB10A2UINT:case tp.RGB10A2Unorm:case tp.RG11B10UFloat:return{width:1,height:1,length:4};case tp.RG32Uint:case tp.RG32Sint:case tp.RG32Float:case tp.RGBA16Uint:case tp.RGBA16Sint:case tp.RGBA16Float:return{width:1,height:1,length:8};case tp.RGBA32Uint:case tp.RGBA32Sint:case tp.RGBA32Float:return{width:1,height:1,length:16};case tp.Stencil8:throw"No fixed size for Stencil8 format!";case tp.Depth16Unorm:return{width:1,height:1,length:2};case tp.Depth24Plus:throw"No fixed size for Depth24Plus format!";case tp.Depth24PlusStencil8:throw"No fixed size for Depth24PlusStencil8 format!";case tp.Depth32Float:return{width:1,height:1,length:4};case tp.Depth32FloatStencil8:return{width:1,height:1,length:5};case tp.BC7RGBAUnorm:case tp.BC7RGBAUnormSRGB:case tp.BC6HRGBUFloat:case tp.BC6HRGBFloat:case tp.BC5RGUnorm:case tp.BC5RGSnorm:case tp.BC3RGBAUnorm:case tp.BC3RGBAUnormSRGB:case tp.BC2RGBAUnorm:case tp.BC2RGBAUnormSRGB:return{width:4,height:4,length:16};case tp.BC4RUnorm:case tp.BC4RSnorm:case tp.BC1RGBAUnorm:case tp.BC1RGBAUnormSRGB:case tp.ETC2RGB8Unorm:case tp.ETC2RGB8UnormSRGB:case tp.ETC2RGB8A1Unorm:case tp.ETC2RGB8A1UnormSRGB:case tp.EACR11Unorm:case tp.EACR11Snorm:return{width:4,height:4,length:8};case tp.ETC2RGBA8Unorm:case tp.ETC2RGBA8UnormSRGB:case tp.EACRG11Unorm:case tp.EACRG11Snorm:case tp.ASTC4x4Unorm:case tp.ASTC4x4UnormSRGB:return{width:4,height:4,length:16};case tp.ASTC5x4Unorm:case tp.ASTC5x4UnormSRGB:return{width:5,height:4,length:16};case tp.ASTC5x5Unorm:case tp.ASTC5x5UnormSRGB:return{width:5,height:5,length:16};case tp.ASTC6x5Unorm:case tp.ASTC6x5UnormSRGB:return{width:6,height:5,length:16};case tp.ASTC6x6Unorm:case tp.ASTC6x6UnormSRGB:return{width:6,height:6,length:16};case tp.ASTC8x5Unorm:case tp.ASTC8x5UnormSRGB:return{width:8,height:5,length:16};case tp.ASTC8x6Unorm:case tp.ASTC8x6UnormSRGB:return{width:8,height:6,length:16};case tp.ASTC8x8Unorm:case tp.ASTC8x8UnormSRGB:return{width:8,height:8,length:16};case tp.ASTC10x5Unorm:case tp.ASTC10x5UnormSRGB:return{width:10,height:5,length:16};case tp.ASTC10x6Unorm:case tp.ASTC10x6UnormSRGB:return{width:10,height:6,length:16};case tp.ASTC10x8Unorm:case tp.ASTC10x8UnormSRGB:return{width:10,height:8,length:16};case tp.ASTC10x10Unorm:case tp.ASTC10x10UnormSRGB:return{width:10,height:10,length:16};case tp.ASTC12x10Unorm:case tp.ASTC12x10UnormSRGB:return{width:12,height:10,length:16};case tp.ASTC12x12Unorm:case tp.ASTC12x12UnormSRGB:return{width:12,height:12,length:16}}return{width:1,height:1,length:4}},e._IsHardwareTexture=function(e){return!!e.release},e._IsInternalTexture=function(e){return!!e.dispose},e.IsImageBitmap=function(e){return void 0!==e.close},e.IsImageBitmapArray=function(e){return Array.isArray(e)&&void 0!==e[0].close},e.prototype.setCommandEncoder=function(e){this._commandEncoderForCreation=e},e.IsCompressedFormat=function(e){switch(e){case tp.BC7RGBAUnormSRGB:case tp.BC7RGBAUnorm:case tp.BC6HRGBFloat:case tp.BC6HRGBUFloat:case tp.BC5RGSnorm:case tp.BC5RGUnorm:case tp.BC4RSnorm:case tp.BC4RUnorm:case tp.BC3RGBAUnormSRGB:case tp.BC3RGBAUnorm:case tp.BC2RGBAUnormSRGB:case tp.BC2RGBAUnorm:case tp.BC1RGBAUnormSRGB:case tp.BC1RGBAUnorm:case tp.ETC2RGB8Unorm:case tp.ETC2RGB8UnormSRGB:case tp.ETC2RGB8A1Unorm:case tp.ETC2RGB8A1UnormSRGB:case tp.ETC2RGBA8Unorm:case tp.ETC2RGBA8UnormSRGB:case tp.EACR11Unorm:case tp.EACR11Snorm:case tp.EACRG11Unorm:case tp.EACRG11Snorm:case tp.ASTC4x4Unorm:case tp.ASTC4x4UnormSRGB:case tp.ASTC5x4Unorm:case tp.ASTC5x4UnormSRGB:case tp.ASTC5x5Unorm:case tp.ASTC5x5UnormSRGB:case tp.ASTC6x5Unorm:case tp.ASTC6x5UnormSRGB:case tp.ASTC6x6Unorm:case tp.ASTC6x6UnormSRGB:case tp.ASTC8x5Unorm:case tp.ASTC8x5UnormSRGB:case tp.ASTC8x6Unorm:case tp.ASTC8x6UnormSRGB:case tp.ASTC8x8Unorm:case tp.ASTC8x8UnormSRGB:case tp.ASTC10x5Unorm:case tp.ASTC10x5UnormSRGB:case tp.ASTC10x6Unorm:case tp.ASTC10x6UnormSRGB:case tp.ASTC10x8Unorm:case tp.ASTC10x8UnormSRGB:case tp.ASTC10x10Unorm:case tp.ASTC10x10UnormSRGB:case tp.ASTC12x10Unorm:case tp.ASTC12x10UnormSRGB:case tp.ASTC12x12Unorm:case tp.ASTC12x12UnormSRGB:return!0}return!1},e.GetWebGPUTextureFormat=function(e,t,i){switch(void 0===i&&(i=!1),t){case a.TEXTUREFORMAT_DEPTH16:return tp.Depth16Unorm;case a.TEXTUREFORMAT_DEPTH24:return tp.Depth24Plus;case a.TEXTUREFORMAT_DEPTH24_STENCIL8:return tp.Depth24PlusStencil8;case a.TEXTUREFORMAT_DEPTH32_FLOAT:return tp.Depth32Float;case a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8:return tp.Depth32FloatStencil8;case a.TEXTUREFORMAT_STENCIL8:return tp.Stencil8;case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:return i?tp.BC7RGBAUnormSRGB:tp.BC7RGBAUnorm;case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:return tp.BC6HRGBUFloat;case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:return tp.BC6HRGBFloat;case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:return i?tp.BC3RGBAUnormSRGB:tp.BC3RGBAUnorm;case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:return i?tp.BC2RGBAUnormSRGB:tp.BC2RGBAUnorm;case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:return i?tp.BC1RGBAUnormSRGB:tp.BC1RGBAUnorm;case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:return i?tp.ASTC4x4UnormSRGB:tp.ASTC4x4Unorm;case a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:case a.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:return i?tp.ETC2RGB8UnormSRGB:tp.ETC2RGB8Unorm;case a.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:return i?tp.ETC2RGBA8UnormSRGB:tp.ETC2RGBA8Unorm}switch(e){case a.TEXTURETYPE_BYTE:switch(t){case a.TEXTUREFORMAT_RED:return tp.R8Snorm;case a.TEXTUREFORMAT_RG:return tp.RG8Snorm;case a.TEXTUREFORMAT_RGB:throw"RGB format not supported in WebGPU";case a.TEXTUREFORMAT_RED_INTEGER:return tp.R8Sint;case a.TEXTUREFORMAT_RG_INTEGER:return tp.RG8Sint;case a.TEXTUREFORMAT_RGB_INTEGER:throw"RGB_INTEGER format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA_INTEGER:return tp.RGBA8Sint;default:return tp.RGBA8Snorm}case a.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case a.TEXTUREFORMAT_RED:return tp.R8Unorm;case a.TEXTUREFORMAT_RG:return tp.RG8Unorm;case a.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA:return i?tp.RGBA8UnormSRGB:tp.RGBA8Unorm;case a.TEXTUREFORMAT_BGRA:return i?tp.BGRA8UnormSRGB:tp.BGRA8Unorm;case a.TEXTUREFORMAT_RED_INTEGER:return tp.R8Uint;case a.TEXTUREFORMAT_RG_INTEGER:return tp.RG8Uint;case a.TEXTUREFORMAT_RGB_INTEGER:throw"RGB_INTEGER format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA_INTEGER:return tp.RGBA8Uint;case a.TEXTUREFORMAT_ALPHA:throw"TEXTUREFORMAT_ALPHA format not supported in WebGPU";case a.TEXTUREFORMAT_LUMINANCE:throw"TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";case a.TEXTUREFORMAT_LUMINANCE_ALPHA:throw"TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";default:return tp.RGBA8Unorm}case a.TEXTURETYPE_SHORT:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return tp.R16Sint;case a.TEXTUREFORMAT_RG_INTEGER:return tp.RG16Sint;case a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA_INTEGER:default:return tp.RGBA16Sint}case a.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return tp.R16Uint;case a.TEXTUREFORMAT_RG_INTEGER:return tp.RG16Uint;case a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA_INTEGER:default:return tp.RGBA16Uint}case a.TEXTURETYPE_INT:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return tp.R32Sint;case a.TEXTUREFORMAT_RG_INTEGER:return tp.RG32Sint;case a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA_INTEGER:default:return tp.RGBA32Sint}case a.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case a.TEXTUREFORMAT_RED_INTEGER:return tp.R32Uint;case a.TEXTUREFORMAT_RG_INTEGER:return tp.RG32Uint;case a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA_INTEGER:default:return tp.RGBA32Uint}case a.TEXTURETYPE_FLOAT:switch(t){case a.TEXTUREFORMAT_RED:return tp.R32Float;case a.TEXTUREFORMAT_RG:return tp.RG32Float;case a.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA:default:return tp.RGBA32Float}case a.TEXTURETYPE_HALF_FLOAT:switch(t){case a.TEXTUREFORMAT_RED:return tp.R16Float;case a.TEXTUREFORMAT_RG:return tp.RG16Float;case a.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case a.TEXTUREFORMAT_RGBA:default:return tp.RGBA16Float}case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:throw"TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:switch(t){case a.TEXTUREFORMAT_RGBA:return tp.RG11B10UFloat;case a.TEXTUREFORMAT_RGBA_INTEGER:throw"TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV";default:return tp.RG11B10UFloat}case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:switch(t){case a.TEXTUREFORMAT_RGBA:return tp.RGB9E5UFloat;case a.TEXTUREFORMAT_RGBA_INTEGER:throw"TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV";default:return tp.RGB9E5UFloat}case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:throw"TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:throw"TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case a.TEXTUREFORMAT_RGBA:return tp.RGB10A2Unorm;case a.TEXTUREFORMAT_RGBA_INTEGER:return tp.RGB10A2UINT;default:return tp.RGB10A2Unorm}}return i?tp.RGBA8UnormSRGB:tp.RGBA8Unorm},e.GetNumChannelsFromWebGPUTextureFormat=function(e){switch(e){case tp.R8Unorm:case tp.R8Snorm:case tp.R8Uint:case tp.R8Sint:case tp.BC4RUnorm:case tp.BC4RSnorm:case tp.R16Uint:case tp.R16Sint:case tp.Depth16Unorm:case tp.R16Float:case tp.R32Uint:case tp.R32Sint:case tp.R32Float:case tp.Depth32Float:case tp.Stencil8:case tp.Depth24Plus:case tp.EACR11Unorm:case tp.EACR11Snorm:return 1;case tp.RG8Unorm:case tp.RG8Snorm:case tp.RG8Uint:case tp.RG8Sint:case tp.Depth32FloatStencil8:case tp.BC5RGUnorm:case tp.BC5RGSnorm:case tp.RG16Uint:case tp.RG16Sint:case tp.RG16Float:case tp.RG32Uint:case tp.RG32Sint:case tp.RG32Float:case tp.Depth24PlusStencil8:case tp.EACRG11Unorm:case tp.EACRG11Snorm:return 2;case tp.RGB9E5UFloat:case tp.RG11B10UFloat:case tp.BC6HRGBUFloat:case tp.BC6HRGBFloat:case tp.ETC2RGB8Unorm:case tp.ETC2RGB8UnormSRGB:return 3;case tp.RGBA8Unorm:case tp.RGBA8UnormSRGB:case tp.RGBA8Snorm:case tp.RGBA8Uint:case tp.RGBA8Sint:case tp.BGRA8Unorm:case tp.BGRA8UnormSRGB:case tp.RGB10A2UINT:case tp.RGB10A2Unorm:case tp.BC7RGBAUnorm:case tp.BC7RGBAUnormSRGB:case tp.BC3RGBAUnorm:case tp.BC3RGBAUnormSRGB:case tp.BC2RGBAUnorm:case tp.BC2RGBAUnormSRGB:case tp.BC1RGBAUnorm:case tp.BC1RGBAUnormSRGB:case tp.RGBA16Uint:case tp.RGBA16Sint:case tp.RGBA16Float:case tp.RGBA32Uint:case tp.RGBA32Sint:case tp.RGBA32Float:case tp.ETC2RGB8A1Unorm:case tp.ETC2RGB8A1UnormSRGB:case tp.ETC2RGBA8Unorm:case tp.ETC2RGBA8UnormSRGB:case tp.ASTC4x4Unorm:case tp.ASTC4x4UnormSRGB:case tp.ASTC5x4Unorm:case tp.ASTC5x4UnormSRGB:case tp.ASTC5x5Unorm:case tp.ASTC5x5UnormSRGB:case tp.ASTC6x5Unorm:case tp.ASTC6x5UnormSRGB:case tp.ASTC6x6Unorm:case tp.ASTC6x6UnormSRGB:case tp.ASTC8x5Unorm:case tp.ASTC8x5UnormSRGB:case tp.ASTC8x6Unorm:case tp.ASTC8x6UnormSRGB:case tp.ASTC8x8Unorm:case tp.ASTC8x8UnormSRGB:case tp.ASTC10x5Unorm:case tp.ASTC10x5UnormSRGB:case tp.ASTC10x6Unorm:case tp.ASTC10x6UnormSRGB:case tp.ASTC10x8Unorm:case tp.ASTC10x8UnormSRGB:case tp.ASTC10x10Unorm:case tp.ASTC10x10UnormSRGB:case tp.ASTC12x10Unorm:case tp.ASTC12x10UnormSRGB:case tp.ASTC12x12Unorm:case tp.ASTC12x12UnormSRGB:return 4}throw"Unknown format ".concat(e,"!")},e.HasStencilAspect=function(e){switch(e){case tp.Stencil8:case tp.Depth32FloatStencil8:case tp.Depth24PlusStencil8:return!0}return!1},e.HasDepthAndStencilAspects=function(e){switch(e){case tp.Depth32FloatStencil8:case tp.Depth24PlusStencil8:return!0}return!1},e.GetDepthFormatOnly=function(e){switch(e){case tp.Depth16Unorm:return tp.Depth16Unorm;case tp.Depth24Plus:case tp.Depth24PlusStencil8:return tp.Depth24Plus;case tp.Depth32Float:case tp.Depth32FloatStencil8:return tp.Depth32Float}return 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?Vp.InvertY:Vp.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={colorAttachments:[{view:t._hardwareTexture.underlyingResource.createView({format:i,dimension:$d.E2d,mipLevelCount:1,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:1,aspect:ep.All}),loadOp:Rp.Load,storeOp:Cp.Store}]},f=n.beginRenderPass(p),_={layout:d,entries:[{binding:0,resource:this._videoSampler},{binding:1,resource:this._device.importExternalTexture({source:e.underlyingResource})}]},m=this._device.createBindGroup(_);f.setPipeline(h),f.setBindGroup(0,m),f.draw(4,1,0,0),f.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(t,i,r,n,o,a,s,l,c,u,h,d,p,f,_){var m,g,v,y,b,T;void 0===o&&(o=!1),void 0===a&&(a=!1),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=1),void 0===u&&(u=0),void 0===h&&(h=0),void 0===d&&(d=0),void 0===p&&(p=0);var E,S=0!==d,x=void 0===f,A=this._getPipeline(n,S?Up.InvertYPremultiplyAlphaWithOfst:Up.InvertYPremultiplyAlpha,{invertY:o,premultiplyAlpha:a}),R=A[0],C=A[1];if(s=Math.max(s,0),x&&(f=this._device.createCommandEncoder({})),null===(g=(m=f).pushDebugGroup)||void 0===g||g.call(m,"internal process texture - invertY=".concat(o," premultiplyAlpha=").concat(a)),e._IsHardwareTexture(t)?(E=t.underlyingResource,o&&!a&&1===c&&0===s||(t=void 0)):(E=t,t=void 0),E){S&&this._bufferManager.setRawData(this._ubCopyWithOfst,0,new Float32Array([u,h,d,p]),0,16);var P=t,I=null!==(v=null==P?void 0:P._copyInvertYTempTexture)&&void 0!==v?v:this.createTexture({width:i,height:r,layers:1},!1,!1,!1,!1,!1,n,1,f,Jd.CopySrc|Jd.RenderAttachment|Jd.TextureBinding,void 0,"TempTextureForCopyWithInvertY"),M=null!==(y=null==P?void 0:P._copyInvertYRenderPassDescr)&&void 0!==y?y:{colorAttachments:[{view:I.createView({format:n,dimension:$d.E2d,baseMipLevel:0,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:0}),loadOp:Rp.Load,storeOp:Cp.Store}]},O=f.beginRenderPass(M),D=S?null==P?void 0:P._copyInvertYBindGroupWithOfst:null==P?void 0:P._copyInvertYBindGroup;if(!D){var N={layout:C,entries:[{binding:0,resource:E.createView({format:n,dimension:$d.E2d,baseMipLevel:l,mipLevelCount:1,arrayLayerCount:c,baseArrayLayer:s})}]};S&&N.entries.push({binding:1,resource:{buffer:this._ubCopyWithOfst}}),D=this._device.createBindGroup(N)}O.setPipeline(R),O.setBindGroup(0,D),O.draw(4,1,0,0),O.end(),f.copyTextureToTexture({texture:I},{texture:E,mipLevel:l,origin:{x:0,y:0,z:s}},{width:i,height:r,depthOrArrayLayers:1}),P?(P._copyInvertYTempTexture=I,P._copyInvertYRenderPassDescr=M,S?P._copyInvertYBindGroupWithOfst=D:P._copyInvertYBindGroup=D):this._deferredReleaseTextures.push([I,null]),null===(T=(b=f).popDebugGroup)||void 0===T||T.call(b),x&&(this._device.queue.submit([f.finish()]),f=null)}},e.prototype.copyWithInvertY=function(e,t,i,r){var n,o,a,s,l=void 0===r,c=this._getPipeline(t,Up.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(t,i,r,n,o,a,s,l,c,u,h,d){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),void 0===s&&(s=tp.RGBA8Unorm),void 0===l&&(l=1),void 0===u&&(u=-1),void 0===h&&(h=0),l>1&&(l=4);var p=t.layers||1,f={width:t.width,height:t.height,depthOrArrayLayers:p},_=Kp[s]?Jd.RenderAttachment:0,m=e.IsCompressedFormat(s),g=i?e.ComputeNumMipmapLevels(t.width,t.height):1,v=u>=0?u:Jd.CopySrc|Jd.CopyDst|Jd.TextureBinding;h|=i&&!m?Jd.CopySrc|_:0,m||a||(h|=_|Jd.CopyDst);var y=this._device.createTexture({label:"Texture".concat(a?"3D":"2D","_").concat(d?d+"_":"").concat(f.width,"x").concat(f.height,"x").concat(f.depthOrArrayLayers,"_").concat(i?"wmips":"womips","_").concat(s,"_samples").concat(l),size:f,dimension:a?Zd.E3d:Zd.E2d,format:s,usage:v|h,sampleCount:l,mipLevelCount:g});return e.IsImageBitmap(t)&&(this.updateTexture(t,y,t.width,t.height,p,s,0,0,n,o,0,0),i&&r&&this.generateMipmaps(y,s,g,0,c)),y},e.prototype.createCubeTexture=function(t,i,r,n,o,a,s,l,c,u,h){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===a&&(a=tp.RGBA8Unorm),void 0===s&&(s=1),void 0===c&&(c=-1),void 0===u&&(u=0),s>1&&(s=4);var d=e.IsImageBitmapArray(t)?t[0].width:t.width,p=e.IsImageBitmapArray(t)?t[0].height:t.height,f=Kp[a]?Jd.RenderAttachment:0,_=e.IsCompressedFormat(a),m=i?e.ComputeNumMipmapLevels(d,p):1,g=c>=0?c:Jd.CopySrc|Jd.CopyDst|Jd.TextureBinding;u|=i&&!_?Jd.CopySrc|f:0,_||(u|=f|Jd.CopyDst);var v=this._device.createTexture({label:"TextureCube_".concat(h?h+"_":"").concat(d,"x").concat(p,"x6_").concat(i?"wmips":"womips","_").concat(a,"_samples").concat(s),size:{width:d,height:p,depthOrArrayLayers:6},dimension:Zd.E2d,format:a,usage:g|u,sampleCount:s,mipLevelCount:m});return e.IsImageBitmapArray(t)&&(this.updateCubeTextures(t,v,d,p,a,n,o,0,0),i&&r&&this.generateCubeMipmaps(v,a,m,l)),v},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,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(t,i,r,n,o){var a,s,l,c,u,h,d,p;void 0===n&&(n=0);var f,_=void 0===o,m=this._getPipeline(i),g=m[0],v=m[1];if(n=Math.max(n,0),_&&(o=this._device.createCommandEncoder({})),null===(s=(a=o).pushDebugGroup)||void 0===s||s.call(a,"create mipmaps for face #".concat(n," - ").concat(r," levels")),e._IsHardwareTexture(t)?(f=t.underlyingResource,t._mipmapGenRenderPassDescr=t._mipmapGenRenderPassDescr||[],t._mipmapGenBindGroup=t._mipmapGenBindGroup||[]):(f=t,t=void 0),f){for(var y=t,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]=od(r[e]);return i},e.prototype.readDataFromBuffer=function(e,t,i,r,n,o,s,l,c,u,h){var d=this;void 0===s&&(s=a.TEXTURETYPE_UNSIGNED_BYTE),void 0===l&&(l=0),void 0===c&&(c=null),void 0===u&&(u=!0),void 0===h&&(h=!1);var p=s===a.TEXTURETYPE_FLOAT?2:s===a.TEXTURETYPE_HALF_FLOAT?1:0;return new Promise((function(i,a){e.mapAsync(qd.Read,l,t).then((function(){var a=e.getMappedRange(l,t),f=c;if(h)f=null===f?Dn(s,t,!0,a):Dn(s,f.buffer,void 0,a);else if(null===f)switch(p){case 0:(f=new Uint8Array(t)).set(new Uint8Array(a));break;case 1:f=d._getHalfFloatAsFloatRGBAArrayBuffer(t/2,a);break;case 2:(f=new Float32Array(t/4)).set(new Float32Array(a))}else switch(p){case 0:(f=new Uint8Array(f.buffer)).set(new Uint8Array(a));break;case 1:f=d._getHalfFloatAsFloatRGBAArrayBuffer(t/2,a,c);break;case 2:(f=new Float32Array(f.buffer)).set(new Float32Array(a))}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 $p[e.samplingMode]+ef[(e._comparisonFunction||514)-512+1]+tf[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,s,l=e.useMipMaps;switch(e.samplingMode){case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:i=rp.Linear,r=rp.Linear,n=rp.Nearest,l||(o=s=0);break;case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:case a.TEXTURE_TRILINEAR_SAMPLINGMODE:i=rp.Linear,r=rp.Linear,l?n=rp.Linear:(n=rp.Nearest,o=s=0);break;case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:i=rp.Nearest,r=rp.Nearest,l?n=rp.Linear:(n=rp.Nearest,o=s=0);break;case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:i=rp.Nearest,r=rp.Nearest,n=rp.Nearest,l||(o=s=0);break;case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:i=rp.Nearest,r=rp.Linear,n=rp.Nearest,l||(o=s=0);break;case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:i=rp.Nearest,r=rp.Linear,l?n=rp.Linear:(n=rp.Nearest,o=s=0);break;case a.TEXTURE_NEAREST_LINEAR:i=rp.Nearest,r=rp.Linear,n=rp.Nearest,o=s=0;break;case a.TEXTURE_NEAREST_NEAREST:case a.TEXTURE_NEAREST_SAMPLINGMODE:i=rp.Nearest,r=rp.Nearest,n=rp.Nearest,o=s=0;break;case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:i=rp.Linear,r=rp.Nearest,n=rp.Nearest,l||(o=s=0);break;case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:i=rp.Linear,r=rp.Nearest,l?n=rp.Linear:(n=rp.Nearest,o=s=0);break;case a.TEXTURE_LINEAR_LINEAR:case a.TEXTURE_BILINEAR_SAMPLINGMODE:i=rp.Linear,r=rp.Linear,n=rp.Nearest,o=s=0;break;case a.TEXTURE_LINEAR_NEAREST:i=rp.Linear,r=rp.Nearest,n=rp.Nearest,o=s=0;break;default:i=rp.Nearest,r=rp.Nearest,n=rp.Nearest,o=s=0}return t>1&&(0!==o||0!==s)&&n!==rp.Nearest?{magFilter:rp.Linear,minFilter:rp.Linear,mipmapFilter:rp.Linear,anisotropyEnabled:!0}:{magFilter:i,minFilter:r,mipmapFilter:n,lodMinClamp:o,lodMaxClamp:s}},e._GetWrappingMode=function(e){switch(e){case a.TEXTURE_WRAP_ADDRESSMODE:return ip.Repeat;case a.TEXTURE_CLAMP_ADDRESSMODE:return ip.ClampToEdge;case a.TEXTURE_MIRROR_ADDRESSMODE:return ip.MirrorRepeat}return ip.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){var i=t.useMipMaps&&t._cachedAnisotropicFilteringLevel&&t._cachedAnisotropicFilteringLevel>1?4:1,r=this._GetSamplerFilterDescriptor(t,i);return H(H(H({},r),this._GetSamplerWrappingDescriptor(t)),{compare:t._comparisonFunction?e.GetCompareFunction(t._comparisonFunction):void 0,maxAnisotropy:r.anisotropyEnabled?i:1})},e.GetCompareFunction=function(e){switch(e){case a.ALWAYS:return op.Always;case a.EQUAL:return op.Equal;case a.GREATER:return op.Greater;case a.GEQUAL:return op.GreaterEqual;case a.LESS:return op.Less;case a.LEQUAL:return op.LessEqual;case a.NEVER:return op.Never;case a.NOTEQUAL:return op.NotEqual;default:return op.Less}},e.prototype.getSampler=function(t,i,r){if(void 0===i&&(i=!1),void 0===r&&(r=0),this.disabled)return this._device.createSampler(e._GetSamplerDescriptor(t));i?r=0:0===r&&(r=e.GetSamplerHashCode(t));var n=i?void 0:this._samplers[r];return n||(n=this._device.createSampler(e._GetSamplerDescriptor(t)),i||(this._samplers[r]=n)),n},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"}(jp||(jp={}));var nf={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},of={0:0,7680:1,7681:2,7682:3,7683:4,5386:5,34055:6,34056:7},af=((Xp={})[ji.PositionKind]=!0,Xp[ji.NormalKind]=!0,Xp[ji.TangentKind]=!0,Xp[ji.UVKind]=!0,Xp[ji.UV2Kind]=!0,Xp[ji.UV3Kind]=!0,Xp[ji.UV4Kind]=!0,Xp[ji.UV5Kind]=!0,Xp[ji.UV6Kind]=!0,Xp[ji.ColorKind]=!0,Xp[ji.ColorInstanceKind]=!0,Xp[ji.MatricesIndicesKind]=!0,Xp[ji.MatricesWeightsKind]=!0,Xp[ji.MatricesIndicesExtraKind]=!0,Xp[ji.MatricesWeightsExtraKind]=!0,Xp),sf=function(){function e(e,t,i){this.mrtTextureCount=0,this._device=e,this._useTextureStage=i,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 ji.BYTE:case ji.SHORT:case ji.INT:case ji.FLOAT:return!0;case ji.UNSIGNED_BYTE:case ji.UNSIGNED_SHORT:case ji.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=[tp.BGRA8Unorm],this.setColorFormat(tp.BGRA8Unorm),this.setMRT([]),this.setAlphaBlendEnabled(!1),this.setAlphaBlendFactors([null,null,null,null],[null,null]),this.setWriteMask(15),this.setDepthStencilFormat(tp.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>1&&(r=4),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,a.ALWAYS)},e.prototype.setDepthCullingState=function(e,t,i,r,n,o,s,l){this._depthWriteEnabled=s,this._depthTestEnabled=o,this._depthCompare=(null!=l?l:a.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[jp.DepthBias]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.DepthBias))},e.prototype.setDepthBiasSlopeScale=function(e){this._depthBiasSlopeScale!==e&&(this._depthBiasSlopeScale=e,this._states[jp.DepthBiasSlopeScale]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.DepthBiasSlopeScale))},e.prototype.setColorFormat=function(e){this._webgpuColorFormat[0]=e,this._colorFormat=Kp[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[jp.MRTAttachments1]=n[0],this._states[jp.MRTAttachments2]=n[1],this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.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:Kp[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:a.ALWAYS)-512},e.prototype.setStencilEnabled=function(e){this._stencilEnabled=e},e.prototype.setStencilCompare=function(e){this._stencilFrontCompare=(null!=e?e:a.ALWAYS)-512},e.prototype.setStencilDepthFailOp=function(e){this._stencilFrontDepthFailOp=null===e?1:of[e]},e.prototype.setStencilPassOp=function(e){this._stencilFrontPassOp=null===e?2:of[e]},e.prototype.setStencilFailOp=function(e){this._stencilFrontFailOp=null===e?1:of[e]},e.prototype.setStencilReadMask=function(e){this._stencilReadMask!==e&&(this._stencilReadMask=e,this._states[jp.StencilReadMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.StencilReadMask))},e.prototype.setStencilWriteMask=function(e){this._stencilWriteMask!==e&&(this._stencilWriteMask=e,this._states[jp.StencilWriteMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.StencilWriteMask))},e.prototype.resetStencilState=function(){this.setStencilState(!1,a.ALWAYS,a.KEEP,a.REPLACE,a.KEEP,255,255)},e.prototype.setStencilState=function(e,t,i,r,n,o,s){this._stencilEnabled=e,this._stencilFrontCompare=(null!=t?t:a.ALWAYS)-512,this._stencilFrontDepthFailOp=null===i?1:of[i],this._stencilFrontPassOp=null===r?2:of[r],this._stencilFrontFailOp=null===n?1:of[n],this.setStencilReadMask(o),this.setStencilWriteMask(s)},e.prototype.setBuffers=function(e,t,i){this._vertexBuffers=e,this._overrideVertexBuffers=i,this._indexBuffer=t},e._GetTopology=function(e){switch(e){case a.MATERIAL_TriangleFillMode:return fp.TriangleList;case a.MATERIAL_PointFillMode:return fp.PointList;case a.MATERIAL_WireFrameFillMode:return fp.LineList;case a.MATERIAL_PointListDrawMode:return fp.PointList;case a.MATERIAL_LineListDrawMode:return fp.LineList;case a.MATERIAL_LineLoopDrawMode:throw"LineLoop is an unsupported fillmode in WebGPU";case a.MATERIAL_LineStripDrawMode:return fp.LineStrip;case a.MATERIAL_TriangleStripDrawMode:return fp.TriangleStrip;case a.MATERIAL_TriangleFanDrawMode:throw"TriangleFan is an unsupported fillmode in WebGPU";default:return fp.TriangleList}},e._GetAphaBlendOperation=function(e){switch(e){case a.GL_ALPHA_EQUATION_ADD:return yp.Add;case a.GL_ALPHA_EQUATION_SUBTRACT:return yp.Subtract;case a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:return yp.ReverseSubtract;case a.GL_ALPHA_EQUATION_MIN:return yp.Min;case a.GL_ALPHA_EQUATION_MAX:return yp.Max;default:return yp.Add}},e._GetAphaBlendFactor=function(e){switch(e){case 0:return vp.Zero;case 1:return vp.One;case a.GL_ALPHA_FUNCTION_SRC:return vp.Src;case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:return vp.OneMinusSrc;case a.GL_ALPHA_FUNCTION_SRC_ALPHA:return vp.SrcAlpha;case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:return vp.OneMinusSrcAlpha;case a.GL_ALPHA_FUNCTION_DST_ALPHA:return vp.DstAlpha;case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:return vp.OneMinusDstAlpha;case a.GL_ALPHA_FUNCTION_DST_COLOR:return vp.Dst;case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:return vp.OneMinusDst;case a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:return vp.SrcAlphaSaturated;case a.GL_ALPHA_FUNCTION_CONSTANT_COLOR:return vp.Constant;case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:return vp.OneMinusConstant;case a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:return vp.Constant;case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:return vp.OneMinusConstant;default:return vp.One}},e._GetCompareFunction=function(e){switch(e){case 0:return op.Never;case 1:return op.Less;case 2:return op.Equal;case 3:return op.LessEqual;case 4:return op.Greater;case 5:return op.NotEqual;case 6:return op.GreaterEqual;case 7:return op.Always}return op.Never},e._GetStencilOpFunction=function(e){switch(e){case 0:return bp.Zero;case 1:return bp.Keep;case 2:return bp.Replace;case 3:return bp.IncrementClamp;case 4:return bp.DecrementClamp;case 5:return bp.Invert;case 6:return bp.IncrementWrap;case 7:return bp.DecrementWrap}return bp.Keep},e._GetVertexInputDescriptorFormat=function(e){var t=e.type,i=e.normalized,r=e.getSize();switch(t){case ji.BYTE:switch(r){case 1:case 2:return i?Ep.Snorm8x2:Ep.Sint8x2;case 3:case 4:return i?Ep.Snorm8x4:Ep.Sint8x4}break;case ji.UNSIGNED_BYTE:switch(r){case 1:case 2:return i?Ep.Unorm8x2:Ep.Uint8x2;case 3:case 4:return i?Ep.Unorm8x4:Ep.Uint8x4}break;case ji.SHORT:switch(r){case 1:case 2:return i?Ep.Snorm16x2:Ep.Sint16x2;case 3:case 4:return i?Ep.Snorm16x4:Ep.Sint16x4}break;case ji.UNSIGNED_SHORT:switch(r){case 1:case 2:return i?Ep.Unorm16x2:Ep.Uint16x2;case 3:case 4:return i?Ep.Unorm16x4:Ep.Uint16x4}break;case ji.INT:switch(r){case 1:return Ep.Sint32;case 2:return Ep.Sint32x2;case 3:return Ep.Sint32x3;case 4:return Ep.Sint32x4}break;case ji.UNSIGNED_INT:switch(r){case 1:return Ep.Uint32;case 2:return Ep.Uint32x2;case 3:return Ep.Uint32x3;case 4:return Ep.Uint32x4}break;case ji.FLOAT:switch(r){case 1:return Ep.Float32;case 2:return Ep.Float32x2;case 3:return Ep.Float32x3;case 4:return Ep.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[jp.ShaderStage]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.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[jp.RasterizationState]=this._rasterizationState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.RasterizationState))},e.prototype._setColorStates=function(){var e=((this._writeMask?1:0)<<22)+(this._colorFormat<<23)+((this._depthWriteEnabled?1:0)<<29);this._alphaBlendEnabled&&(e+=((null===this._alphaBlendFuncParams[0]?2:nf[this._alphaBlendFuncParams[0]])<<0)+((null===this._alphaBlendFuncParams[1]?2:nf[this._alphaBlendFuncParams[1]])<<4)+((null===this._alphaBlendFuncParams[2]?2:nf[this._alphaBlendFuncParams[2]])<<8)+((null===this._alphaBlendFuncParams[3]?2:nf[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[jp.ColorStates]=this._colorStates,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.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[jp.DepthStencilState]=this._depthStencilState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,jp.DepthStencilState))},e.prototype._setVertexState=function(e){for(var t,i,r,n=this._statesLength,o=jp.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}(),pf=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,"hasFloatTextures",{get:function(){return this._numFloatTextures>0},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this.samplers={},this.textures={},this.isDirty=!0,this._numFloatTextures=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?rf.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],s=-1;o?s=null!==(r=null===(i=o.texture)||void 0===i?void 0:i.uniqueId)&&void 0!==r?r:-1:this.textures[e]=o={texture:t,isFloatTexture:!1,isExternalTexture:!1},o.isExternalTexture&&this._numExternalTextures--,o.isFloatTexture&&this._numFloatTextures--,t?(o.isFloatTexture=t.type===a.TEXTURETYPE_FLOAT,o.isExternalTexture=df.IsExternalTexture(t),o.isFloatTexture&&this._numFloatTextures++,o.isExternalTexture&&this._numExternalTextures++):(o.isFloatTexture=!1,o.isExternalTexture=!1),o.texture=t;var l=s!==(null!==(n=null==t?void 0:t.uniqueId)&&void 0!==n?n:-1);l&&this.updateId++,this.isDirty||(this.isDirty=l)},e._Counter=0,e}(),ff=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,Qd.CopyDst|Qd.Indirect|Qd.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}(),_f=function(){this.values={}},mf=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.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)}else $.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){$.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)){$.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 $.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){$.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){$.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 $.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 $.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 _f,e._NumBindGroupsCreatedCurrentFrame=0,e._NumBindGroupsLookupCurrentFrame=0,e._NumBindGroupsNoLookupCurrentFrame=0,e}();kt.ShadersStore.clearQuadVertexShader="uniform float depthValue;const vec2 pos[4]={vec2(-1.0,1.0),\nvec2(1.0,1.0),\nvec2(-1.0,-1.0),\nvec2(1.0,-1.0)};\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\ngl_Position=vec4(pos[gl_VertexID],depthValue,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n";kt.ShadersStore.clearQuadPixelShader="uniform vec4 color;void main() {gl_FragColor=color;}\n";var gf=function(){function e(e,t,i){this._bindGroups={},this._bundleCache={},this._keyTemp=[],this._device=e,this._engine=t,this._cacheRenderPipeline=new cf(this._device,i,!t._caps.textureFloatLinearFiltering),this._cacheRenderPipeline.setDepthTestEnabled(!1),this._cacheRenderPipeline.setStencilReadMask(255),this._effect=t.createEffect("clearQuad",[],["color","depthValue"])}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,s,l;void 0===n&&(n=1);var c,u=null,h=!!this._engine._currentRenderTarget;if(e)l=e;else{var d=0;this._keyTemp.length=0;for(var p=0;p1?Math.pow(2,36):0)+f*Math.pow(2,37),c=this._keyTemp.join("_"),u=this._bundleCache[c])return u;l=this._device.createRenderBundleEncoder({colorFormats:this._cacheRenderPipeline.colorFormats,depthStencilFormat:this._depthTextureFormat,sampleCount:n})}this._cacheRenderPipeline.setDepthWriteEnabled(!!i),this._cacheRenderPipeline.setStencilEnabled(!!r&&!!this._depthTextureFormat&&Qp.HasStencilAspect(this._depthTextureFormat)),this._cacheRenderPipeline.setStencilWriteMask(r?255:0),this._cacheRenderPipeline.setStencilCompare(r?a.ALWAYS:a.NEVER),this._cacheRenderPipeline.setStencilPassOp(r?a.REPLACE:a.KEEP),this._cacheRenderPipeline.setWriteMask(t?15:0);var _=this._cacheRenderPipeline.getRenderPipeline(a.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({layout:T[0],entries:[]})),wp._SimplifiedKnownBindings||b.push(this._device.createBindGroup({layout:T[1],entries:[]})),b.push(this._device.createBindGroup({layout:T[wp._SimplifiedKnownBindings?1:2],entries:[{binding:0,resource:{buffer:g.underlyingResource,size:g.capacity}},{binding:1,resource:{buffer:v.underlyingResource,size:v.capacity}}]}))}for(l.setPipeline(_),p=0;p=0&&(t._gpuFrameTimeCounter.fetchNewFrame(),t._gpuFrameTimeCounter.addCount(e,!0)),t._measureDurationState=0})))},e}(),Pf=function(){function e(e,t){this._querySet=new Rf(2,Pp.Timestamp,e,t)}return e.prototype.start=function(e){e.writeTimestamp(this._querySet.querySet,0)},e.prototype.stop=function(e){return j(this,void 0,void 0,(function(){return Y(this,(function(t){return e.writeTimestamp(this._querySet.querySet,1),[2,this._querySet.readTwoValuesAndSubtract(0)]}))}))},e.prototype.dispose=function(){this._querySet.dispose()},e}(),If=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=!1;switch(this._engine._getCurrentRenderPassIndex()){case 0:t=void 0!==this._engine._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet;break;case 1:t=void 0!==this._engine._rttRenderPassWrapper.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;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 Df={label:"TextureView_SwapChain_ResolveTarget",dimension:Zd.E2d,format:void 0,mipLevelCount:1,arrayLayerCount:1},Nf={label:"TextureView_SwapChain",dimension:Zd.E2d,format:void 0,mipLevelCount:1,arrayLayerCount:1},Ff="/* disable_uniformity_analysis */",Lf=new U,wf=function(e){function t(t,i){void 0===i&&(i={});var r,n,o=this;return(o=e.call(this,null,null===(r=i.antialias)||void 0===r||r,i)||this)._uploadEncoderDescriptor={label:"upload"},o._renderEncoderDescriptor={label:"render"},o._renderTargetEncoderDescriptor={label:"renderTarget"},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._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._commandBuffers=[null,null,null],o._currentRenderPass=null,o._mainRenderPassWrapper=new Jp,o._rttRenderPassWrapper=new Jp,o._pendingDebugCommands=[],o._onAfterUnbindFrameBufferObservable=new u,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.isNDCHalfZRange=!0,o.hasOriginBottomLeft=!1,o._viewportsCurrent=[{x:0,y:0,w:0,h:0},{x:0,y:0,w:0,h:0}],o._scissorsCurrent=[{x:0,y:0,w:0,h:0},{x:0,y:0,w:0,h:0}],o._scissorCached={x:0,y:0,z:0,w:0},o._stencilRefsCurrent=[-1,-1],o._blendColorsCurrent=[[null,null,null,null],[null,null,null,null]],o._name="WebGPU",i.deviceDescriptor=i.deviceDescriptor||{},i.enableGPUDebugMarkers=null!==(n=i.enableGPUDebugMarkers)&&void 0!==n&&n,$.Log("Babylon.js v".concat(Nn.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,o._setupMobileChecks(),o._sharedInit(t),o._shaderProcessor=new Bp,o._shaderProcessorWGSL=new Gp,o):($.Error("WebGPU is not supported by your browser."),o)}return W(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}),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 $.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,"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._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 Mf: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)}),(function(e){throw $.Error("Can not initialize twgsl!"),$.Error(e),Error("WebGPU initializations stopped.")})):navigator.gpu.requestAdapter(n._options)}),(function(e){throw $.Error("Can not initialize glslang!"),$.Error(e),Error("WebGPU initializations stopped.")})).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(Yd.TextureCompressionBC)>=0||void 0,pvrtc:null,etc1:null,etc2:this._deviceEnabledExtensions.indexOf(Yd.TextureCompressionETC2)>=0||void 0,bptc:this._deviceEnabledExtensions.indexOf(Yd.TextureCompressionBC)>=0||void 0,maxAnisotropy:16,uintIndices:!0,fragmentDepthSupported:!0,highPrecisionShaderSupported:!0,colorBufferFloat:!0,textureFloat:!0,textureFloatLinearFiltering:this._deviceEnabledExtensions.indexOf(Yd.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(Yd.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._caps.parallelShaderCompile=null,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,forceVertexBufferStrideMultiple4Bytes:!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 zp],this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format=this._colorFormat},t.prototype._initializeMainAttachments=function(){if(this._bufferManager){this.flushFramebuffer(!1),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:Zd.E2d,format:this._options.swapChainFormat,usage:Jd.RenderAttachment};this._mainTexture&&this._textureHelper.releaseTexture(this._mainTexture),this._mainTexture=this._device.createTexture(i),e=[{view:this._mainTexture.createView({label:"TextureView_MainColor_antialiasing",dimension:Zd.E2d,format:this._options.swapChainFormat,mipLevelCount:1,arrayLayerCount:1}),clearValue:new U(0,0,0,1),loadOp:Rp.Clear,storeOp:Cp.Store}]}else e=[{view:void 0,clearValue:new U(0,0,0,1),loadOp:Rp.Clear,storeOp:Cp.Store}];this._mainRenderPassWrapper.depthTextureFormat=this.isStencilEnable?tp.Depth24PlusStencil8:tp.Depth32Float,this._setDepthTextureFormat(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:Zd.E2d,format:this._mainRenderPassWrapper.depthTextureFormat,usage:Jd.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:Zd.E2d,format:this._depthTexture.format,mipLevelCount:1,arrayLayerCount:1}),depthClearValue:this._clearDepthValue,depthLoadOp:Rp.Clear,depthStoreOp:Cp.Store,stencilClearValue:this._clearStencilValue,stencilLoadOp:this.isStencilEnable?Rp.Clear:void 0,stencilStoreOp:this.isStencilEnable?Cp.Store:void 0};this._mainRenderPassWrapper.renderPassDescriptor={label:"MainRenderPass",colorAttachments:e,depthStencilAttachment:n}}},t.prototype._configureContext=function(){this._context.configure({device:this._device,format:this._options.swapChainFormat,usage:Jd.RenderAttachment|Jd.CopySrc,alphaMode:this.premultipliedAlpha?Ip.Premultiplied:Ip.Opaque})},t.prototype.setSize=function(t,i,r){return void 0===r&&(r=!1),!!e.prototype.setSize.call(this,t,i,r)&&(this.dbgVerboseLogsForFirstFrames&&(void 0===this._count&&(this._count=0),(!this._count||this._count=0,n=t.indexOf(Ff)>=0,o=i===at.GLSL?this._compileRawShaderToSpirV(e,"vertex"):e,a=i===at.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(Ff)>=0,o=t.indexOf(Ff)>=0,a="#version 450\n",s=r===at.GLSL?this._compileShaderToSpirV(e,"vertex",i,a):this._getWGSLShader(e,"vertex",i),l=r===at.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 Od(e);return t.debug=!1,t.processCode(),t.code},t.prototype.createPipelineContext=function(e){return new Fp(e,this)},t.prototype.createMaterialContext=function(){return new pf},t.prototype.createDrawContext=function(){return new ff(this._bufferManager)},t.prototype._preparePipelineContext=function(e,t,i,r,n,o,a,s){var l=e,c=l.shaderProcessingContext.shaderLanguage;this.dbgShowShaderCode&&(console.log(s),console.log(t),console.log(i),console.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,c._cachedWrapU=a.TEXTURE_CLAMP_ADDRESSMODE,c._cachedWrapV=a.TEXTURE_CLAMP_ADDRESSMODE,c._useSRGBBuffer=l.useSRGBBuffer,c.label=l.label,this._internalTexturesCache.push(c),i||this._textureHelper.createGPUTextureForInternalTexture(c,u,h,d||1,l.creationFlags),c},t.prototype.createTexture=function(e,t,i,r,n,o,s,l,c,u,h,d,p,f,_){var m=this;return void 0===n&&(n=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=null),this._createTextureBase(e,t,i,r,n,o,s,(function(e,t,i,r,n,o,s,l){var c,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!=u?u:a.TEXTUREFORMAT_RGBA,e.type=-1!==e.type?e.type:a.TEXTURETYPE_UNSIGNED_BYTE,l(e.width,e.height,h,t,e,(function(){})),null===(c=e._hardwareTexture)||void 0===c?void 0:c.underlyingResource)o||s||m._generateMipmaps(e,m._uploadEncoder);else{var d=m._textureHelper.createGPUTextureForInternalTexture(e,h.width,h.height,void 0,f);Qp.IsImageBitmap(h)&&(m._textureHelper.updateTexture(h,e,h.width,h.height,e.depth,d.format,0,0,n,!1,0,0),o||s||m._generateMipmaps(e,m._uploadEncoder))}i&&i.removePendingData(e),e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}),(function(){return!1}),l,c,u,h,d,p,_)},t.prototype.wrapWebGPUTexture=function(e){var t=new zp(e),i=new jt(this,Ot.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,e.source===Ot.RenderTarget||e.source===Ot.MultiRenderTarget?this._renderTargetEncoder:void 0))},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+Np.AutoSamplerSuffix;this._currentMaterialContext.setSampler(n,t)}}},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 Yc.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 Yc.Texture:case Yc.TextureWithoutSampler:var p=(f=u)._texture._hardwareTexture;void 0!==h&&r?(c===Yc.Texture&&(y[h++].resource=this._cacheSampler.getSampler(f._texture)),y[h].resource=p.view):(o.indexInGroupEntries=y.length,c===Yc.Texture&&y.push({binding:l-1,resource:this._cacheSampler.getSampler(f._texture)}),y.push({binding:l,resource:p.view}));break;case Yc.StorageTexture:0==((p=(f=u)._texture._hardwareTexture).textureAdditionalUsages&Jd.StorageBinding)&&$.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 Yc.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 Yc.UniformBuffer:case Yc.StorageBuffer:var m=(Yc.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;v>v,b=[],T=0;T<6;T++){var E=_[v][g[T]];h&&(E=kf(E,y,y,n)),b.push(new Uint8Array(E.buffer,E.byteOffset,E.byteLength))}p._textureHelper.updateCubeTextures(b,m.underlyingResource,y,y,m.format,d,!1,0,0)}else{for(b=[],T=0;T<6;T++)b.push(o[u[T]]);p.updateRawCubeTexture(f,b,r,n,d)}f.isReady=!0,null==t||t.removePendingData(f),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t.removePendingData(f),u&&e&&u(e.status+" "+e.statusText,i)})),f},wf.prototype.createRawTexture3D=function(e,t,i,r,n,o,s,l,c,u,h){void 0===c&&(c=null),void 0===u&&(u=a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=0);var d=Ot.Raw3D,p=new jt(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=u,p.generateMipMaps=o,p.samplingMode=l,p.is3D=!0,this._doNotHandleContextLost||(p._bufferView=e),this._textureHelper.createGPUTextureForInternalTexture(p,t,i,void 0,h),this.updateRawTexture3D(p,e,n,s,c,u),this._internalTexturesCache.push(p),p},wf.prototype.updateRawTexture3D=function(e,t,i,r,n,o){if(void 0===n&&(n=null),void 0===o&&(o=a.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n),t){var s=e._hardwareTexture;i===a.TEXTUREFORMAT_RGB&&(t=kf(t,e.width,e.height,o));var l=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(l,e,e.width,e.height,e.depth,s.format,0,0,r,!1,0,0),e.generateMipMaps&&this._generateMipmaps(e,this._uploadEncoder)}e.isReady=!0},wf.prototype.createRawTexture2DArray=function(e,t,i,r,n,o,s,l,c,u,h){void 0===c&&(c=null),void 0===u&&(u=a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=0);var d=Ot.Raw2DArray,p=new jt(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=u,p.generateMipMaps=o,p.samplingMode=l,p.is2DArray=!0,this._doNotHandleContextLost||(p._bufferView=e),this._textureHelper.createGPUTextureForInternalTexture(p,t,i,r,h),this.updateRawTexture2DArray(p,e,n,s,c,u),this._internalTexturesCache.push(p),p},wf.prototype.updateRawTexture2DArray=function(e,t,i,r,n,o){if(void 0===n&&(n=null),void 0===o&&(o=a.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n),t){var s=e._hardwareTexture;i===a.TEXTUREFORMAT_RGB&&(t=kf(t,e.width,e.height,o));var l=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(l,e,e.width,e.height,e.depth,s.format,0,0,r,!1,0,0),e.generateMipMaps&&this._generateMipmaps(e,this._uploadEncoder)}e.isReady=!0},wf.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)},wf.prototype._readTexturePixelsSync=function(){throw"_readTexturePixelsSync is unsupported in WebGPU!"};var Gf=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t}(Oa);wf.prototype._createHardwareRenderTargetWrapper=function(e,t,i){var r=new Gf(e,t,i,this);return this._renderTargetWrapperCache.push(r),r},wf.prototype.createRenderTargetTexture=function(e,t){var i,r,n,o=this._createHardwareRenderTargetWrapper(!1,!1,e),s={};void 0!==t&&"object"==typeof t?(s.generateMipMaps=t.generateMipMaps,s.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,s.generateStencilBuffer=s.generateDepthBuffer&&t.generateStencilBuffer,s.samplingMode=void 0===t.samplingMode?a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,s.creationFlags=null!==(i=t.creationFlags)&&void 0!==i?i:0,s.noColorAttachment=!!t.noColorAttachment,s.samples=t.samples,s.label=t.label):(s.generateMipMaps=t,s.generateDepthBuffer=!0,s.generateStencilBuffer=!1,s.samplingMode=a.TEXTURE_TRILINEAR_SAMPLINGMODE,s.creationFlags=0,s.noColorAttachment=!1);var l=s.noColorAttachment?null:this._createInternalTexture(e,t,!0,Ot.RenderTarget);return o.label=null!==(r=s.label)&&void 0!==r?r:"RenderTargetWrapper",o._samples=null!==(n=s.samples)&&void 0!==n?n:1,o._generateDepthBuffer=s.generateDepthBuffer,o._generateStencilBuffer=!!s.generateStencilBuffer,o.setTextures(l),(o._generateDepthBuffer||o._generateStencilBuffer)&&o.createDepthStencilTexture(0,this._caps.textureFloatLinearFiltering&&(void 0===s.samplingMode||s.samplingMode===a.TEXTURE_BILINEAR_SAMPLINGMODE||s.samplingMode===a.TEXTURE_LINEAR_LINEAR||s.samplingMode===a.TEXTURE_TRILINEAR_SAMPLINGMODE||s.samplingMode===a.TEXTURE_LINEAR_LINEAR_MIPLINEAR||s.samplingMode===a.TEXTURE_NEAREST_LINEAR_MIPNEAREST||s.samplingMode===a.TEXTURE_NEAREST_LINEAR_MIPLINEAR||s.samplingMode===a.TEXTURE_NEAREST_LINEAR||s.samplingMode===a.TEXTURE_LINEAR_LINEAR_MIPNEAREST),o._generateStencilBuffer,o.samples,s.generateStencilBuffer?a.TEXTUREFORMAT_DEPTH24_STENCIL8:a.TEXTUREFORMAT_DEPTH32_FLOAT,s.label?s.label+"-DepthStencil":void 0),l&&(void 0!==t&&"object"==typeof t&&t.createMipMaps&&!s.generateMipMaps&&(l.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(l,void 0,void 0,void 0,s.creationFlags),void 0!==t&&"object"==typeof t&&t.createMipMaps&&!s.generateMipMaps&&(l.generateMipMaps=!1)),o},wf.prototype._createDepthStencilTexture=function(e,t){var i=new jt(this,Ot.DepthStencil);i.label=t.label;var r=H({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,samples:1,depthTextureFormat:t.generateStencil?a.TEXTUREFORMAT_DEPTH24_STENCIL8:a.TEXTUREFORMAT_DEPTH32_FLOAT},t);return i.format=r.depthTextureFormat,this._setupDepthStencilTexture(i,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction,r.samples),this._textureHelper.createGPUTextureForInternalTexture(i),this._internalTexturesCache.push(i),i},wf.prototype._setupDepthStencilTexture=function(e,t,i,r,n,o){void 0===o&&(o=1);var s=t.width||t,l=t.height||t,c=t.layers||0;e.baseWidth=s,e.baseHeight=l,e.width=s,e.height=l,e.is2DArray=c>0,e.depth=c,e.isReady=!0,e.samples=o,e.generateMipMaps=!1,e.samplingMode=r?a.TEXTURE_BILINEAR_SAMPLINGMODE:a.TEXTURE_NEAREST_SAMPLINGMODE,e.type=a.TEXTURETYPE_FLOAT,e._comparisonFunction=n,e._cachedWrapU=a.TEXTURE_CLAMP_ADDRESSMODE,e._cachedWrapV=a.TEXTURE_CLAMP_ADDRESSMODE},wf.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},wf.prototype.createRenderTargetCubeTexture=function(e,t){var i,r=this._createHardwareRenderTargetWrapper(!1,!0,e),n=H({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:a.TEXTURETYPE_UNSIGNED_INT,samplingMode:a.TEXTURE_TRILINEAR_SAMPLINGMODE,format:a.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 jt(this,Ot.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===a.TEXTURE_BILINEAR_SAMPLINGMODE||n.samplingMode===a.TEXTURE_LINEAR_LINEAR||n.samplingMode===a.TEXTURE_TRILINEAR_SAMPLINGMODE||n.samplingMode===a.TEXTURE_LINEAR_LINEAR_MIPLINEAR||n.samplingMode===a.TEXTURE_NEAREST_LINEAR_MIPNEAREST||n.samplingMode===a.TEXTURE_NEAREST_LINEAR_MIPLINEAR||n.samplingMode===a.TEXTURE_NEAREST_LINEAR||n.samplingMode===a.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},Gt.prototype.setTextureSampler=function(e,t){this._engine.setTextureSampler(e,t)},wf.prototype.setTextureSampler=function(e,t){var i;null===(i=this._currentMaterialContext)||void 0===i||i.setSampler(e,t)},Gt.prototype.setStorageBuffer=function(e,t){this._engine.setStorageBuffer(e,t)},wf.prototype.createStorageBuffer=function(e,t,i){return this._createBuffer(e,t|a.BUFFER_CREATIONFLAG_STORAGE,i)},wf.prototype.updateStorageBuffer=function(e,t,i,r){var n,o=e;void 0===i&&(i=0),void 0===r?r=(n=t instanceof Array?new Float32Array(t):t instanceof ArrayBuffer?new Uint8Array(t):t).byteLength:n=t instanceof Array?new Float32Array(t):t instanceof ArrayBuffer?new Uint8Array(t):t,this._bufferManager.setSubData(o,i,n,0,r)},wf.prototype.readFromStorageBuffer=function(e,t,i,r){var n=this;i=i||e.capacity;var o=this._bufferManager.createRawBuffer(i,Qd.MapRead|Qd.CopyDst,void 0,"TempReadFromStorageBuffer");return this._renderTargetEncoder.copyBufferToBuffer(e.underlyingResource,null!=t?t:0,o,0,i),new Promise((function(e,t){n.onEndFrameObservable.addOnce((function(){o.mapAsync(qd.Read,0,i).then((function(){var t=o.getMappedRange(0,i),a=r;if(void 0===a)(a=new Uint8Array(i)).set(new Uint8Array(t));else{var s=a.constructor;(a=new s(a.buffer)).set(new s(t))}o.unmap(),n._bufferManager.releaseBuffer(o),e(a)}),(function(e){return t(e)}))}))}))},wf.prototype.setStorageBuffer=function(e,t){var i,r;null===(i=this._currentDrawContext)||void 0===i||i.setBuffer(e,null!==(r=null==t?void 0:t.getBuffer())&&void 0!==r?r:null)},wf.prototype.createUniformBuffer=function(e,t){var i;return i=e instanceof Array?new Float32Array(e):e,this._bufferManager.createBuffer(i,Qd.Uniform|Qd.CopyDst,t)},wf.prototype.createDynamicUniformBuffer=function(e,t){return this.createUniformBuffer(e,t)},wf.prototype.updateUniformBuffer=function(e,t,i,r){void 0===i&&(i=0);var n,o=e;void 0===r?r=(n=t instanceof Float32Array?t:new Float32Array(t)).byteLength:n=t instanceof Float32Array?t:new Float32Array(t),this._bufferManager.setSubData(o,i,n,0,r)},wf.prototype.bindUniformBufferBase=function(e,t,i){this._currentDrawContext.setBuffer(i,e)},wf.prototype.bindUniformBlock=function(){},wf.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,this._uploadEncoder),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,n._uploadEncoder),e.isReady=!0})).catch((function(){e.isReady=!0}))}};var zf=function(){function e(){}return e.CreateAsync=function(e,t){return j(this,void 0,void 0,(function(){return Y(this,(function(i){switch(i.label){case 0:return[4,wf.IsSupportedAsync];case 1:return i.sent()?[2,wf.CreateAsync(e,t)]:Nn.IsSupported?[2,new Nn(e,void 0,t)]:[2,new Vh(t)]}}))}))},e}(),Wf=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),Hf=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return Wf.COPY;case 86:return Wf.PASTE;case 88:return Wf.CUT;default:return-1}},e}(),Xf=function(e){function t(t,i,r,n,o){void 0===i&&(i=B.Gray()),void 0===r&&(r=ou.DefaultUtilityLayer),void 0===n&&(n=null),void 0===o&&(o=1);var a,s,l,c,h,d,p,f=this;(f=e.call(this,r)||this)._pointerObserver=null,f.snapDistance=0,f.onSnapObservable=new u,f.uniformScaling=!1,f.sensitivity=1,f.dragScale=1,f._isEnabled=!0,f._parent=null,f._dragging=!1,f._tmpVector=new R(0,0,0),f._parent=n,f._coloredMaterial=new _c("",r.utilityLayerScene),f._coloredMaterial.diffuseColor=i,f._coloredMaterial.specularColor=i.subtract(new B(.1,.1,.1)),f._hoverMaterial=new _c("",r.utilityLayerScene),f._hoverMaterial.diffuseColor=B.Yellow(),f._disableMaterial=new _c("",r.utilityLayerScene),f._disableMaterial.diffuseColor=B.Gray(),f._disableMaterial.alpha=.4,f._gizmoMesh=new io("axis",r.utilityLayerScene);var _=f._createGizmoMesh(f._gizmoMesh,o),m=_.arrowMesh,g=_.arrowTail,v=f._createGizmoMesh(f._gizmoMesh,o+4,!0);f._gizmoMesh.lookAt(f._rootMesh.position.add(t)),f._rootMesh.addChild(f._gizmoMesh,su.PreserveScaling),f._gizmoMesh.scaling.scaleInPlace(1/3);var y=m.position.clone(),b=g.position.clone(),T=g.scaling.clone(),E=function(e){var t=e*(3/f._rootMesh.scaling.length())*6;m.position.z+=t/3.5,g.scaling.y+=t,f.dragScale=g.scaling.y,g.position.z=m.position.z/2},S=function(){m.position.set(y.x,y.y,y.z),g.position.set(b.x,b.y,b.z),g.scaling.set(T.x,T.y,T.z),f.dragScale=g.scaling.y,f._dragging=!1};f.dragBehavior=new ko({dragAxis:t}),f.dragBehavior.moveAttached=!1,f.dragBehavior.updateDragPlane=!1,f._rootMesh.addBehavior(f.dragBehavior);var x=0,A={snapDistance:0};f.dragBehavior.onDragObservable.add((function(e){if(f.attachedNode){var i=f.sensitivity*e.dragDistance*(3*f.scaleRatio/f._rootMesh.scaling.length()),r=f._tmpVector,n=!1,o=0;f.uniformScaling?r.setAll(.57735):r.copyFrom(t),0==f.snapDistance?r.scaleToRef(i,r):(x+=i,Math.abs(x)>f.snapDistance?(o=Math.floor(Math.abs(x)/f.snapDistance),x<0&&(o*=-1),x%=f.snapDistance,r.scaleToRef(f.snapDistance*o,r),n=!0):r.scaleInPlace(0)),I.ScalingToRef(1+r.x,1+r.y,1+r.z,O.Matrix[2]),O.Matrix[2].multiplyToRef(f.attachedNode.getWorldMatrix(),O.Matrix[1]);var a=f.attachedNode._isMesh?f.attachedNode:void 0;O.Matrix[1].decompose(O.Vector3[1],void 0,void 0,su.PreserveScaling?a:void 0);var s=1e5;Math.abs(O.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?P.RotationYawPitchRollToRef(0,0,u,r._tmpQuaternion):e>=4?P.RotationYawPitchRollToRef(u,0,0,r._tmpQuaternion):P.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(),Lo._RestorePivotPoint(r.attachedMesh)}r._updateDummy()})),n.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(t)})),n.onDragEndObservable.add((function(e){r.onRotationSphereDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy(),r._unhoverMeshOnTouchUp(e.pointerInfo,t)})),a._rotateSpheresParent.addChild(t)},a=this,s=0;s<12;s++)o(s);for(r._rootMesh.addChild(r._rotateSpheresParent),r._scaleBoxesParent=new Vn("",i.utilityLayerScene),r._scaleBoxesParent.rotationQuaternion=new P,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=fu("",{size:1},i.utilityLayerScene);n.material=h._coloredMaterial,n._internalMetadata=2===t,n.isNearGrabbable=!0;var o=new R(s-1,l-1,e-1).normalize(),a=new ko({dragAxis:o});a.updateDragPlane=!1,a.moveAttached=!1;var c=0,u=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 $.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");Lo._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-u,u=l}var h=new R(a,a,a);2===t&&(h.x*=Math.abs(o.x),h.y*=Math.abs(o.y),h.z*=Math.abs(o.z)),h.scaleInPlace(r._scaleDragSpeed),h.multiplyInPlace(r._axisFactor),r.updateBoundingBox(),r.scalePivot?(r.attachedMesh.getWorldMatrix().getRotationMatrixToRef(r._tmpRotationMatrix),r._boundingDimensions.scaleToRef(.5,r._tmpVector),R.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector),r._boundingDimensions.multiplyToRef(r.scalePivot,r._tmpVector),R.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._anchorMesh.scaling.addInPlace(h),(r._anchorMesh.scaling.x<0||r._anchorMesh.scaling.y<0||r._anchorMesh.scaling.z<0)&&r._anchorMesh.scaling.subtractInPlace(h),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(i),Lo._RestorePivotPoint(r.attachedMesh)}r._updateDummy()})),a.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(n),c=0,u=0})),a.onDragEndObservable.add((function(e){r.onScaleBoxDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy(),r._unhoverMeshOnTouchUp(e.pointerInfo,n)})),h._scaleBoxesParent.addChild(n)},h=this,d=0;d<3;d++)c(d);r._rootMesh.addChild(r._scaleBoxesParent);var p=new Array;return r._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){p[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=p[e.event.pointerId]&&(p[e.event.pointerId].material=r._coloredMaterial,delete p[e.event.pointerId],r._isHovered=!1):r._rotateSpheresParent.getChildMeshes().concat(r._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(p[e.event.pointerId]=t,t.material=r._hoverColoredMaterial,r._isHovered=!0)}))})),r._renderObserver=r.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){r.attachedMesh&&!r._existingMeshScale.equals(r.attachedMesh.scaling)?r.updateBoundingBox():(r.fixedDragMeshScreenSize||r.fixedDragMeshBoundsSize)&&(r._updateRotationSpheres(),r._updateScaleBoxes()),r._dragMesh&&r.attachedMesh&&r._pointerDragBehavior.dragging&&(r._lineBoundingBox.position.rotateByQuaternionToRef(r._rootMesh.rotationQuaternion,r._tmpVector),r.attachedMesh.setAbsolutePosition(r._dragMesh.position.add(r._tmpVector.scale(-1))))})),r.updateBoundingBox(),r}return W(t,e),Object.defineProperty(t.prototype,"axisFactor",{get:function(){return this._axisFactor},set:function(e){this._axisFactor=e;for(var t=this._scaleBoxesParent.getChildMeshes(),i=0,r=0;r<3;r++)for(var n=0;n<3;n++)for(var o=0;o<3;o++){var a=(1===r?1:0)+(1===n?1:0)+(1===o?1:0);if(1!==a&&3!==a){if(t[i]){var s=new R(r-1,n-1,o-1);s.multiplyInPlace(this._axisFactor),t[i].setEnabled(s.lengthSquared()>_)}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}),t.prototype.setColor=function(e){this._coloredMaterial.emissiveColor=e,this._hoverColoredMaterial.emissiveColor=e.clone().add(new B(.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),Lo._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),Lo._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){Lo._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=P.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=P.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),Lo._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 R(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(R.Cross(e[n].position.normalizeToNew(),R.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 R(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(R.Cross(e[n].position.normalizeToNew(),R.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 R(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(R.Cross(e[n].position.normalizeToNew(),R.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 R(-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.position,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=fu("dummy",{size:1},this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new P,this._pointerDragBehavior.useObjectOrientationForDragging=!1,this._dragMesh.addBehavior(this._pointerDragBehavior)},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(),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=P.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=fu("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,n.scaling),0===n.scaling.y&&(n.scaling.y=_),0===n.scaling.x&&(n.scaling.x=_),0===n.scaling.z&&(n.scaling.z=_),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(){$.Error("Custom meshes are not supported on this gizmo")},t}(su),Yf=function(e){function t(i,r,n,o,a,s,l){var c;void 0===r&&(r=B.Gray()),void 0===n&&(n=ou.DefaultUtilityLayer),void 0===o&&(o=32),void 0===a&&(a=null),void 0===s&&(s=!1),void 0===l&&(l=1);var h,d=this;(d=e.call(this,n)||this)._pointerObserver=null,d.snapDistance=0,d.onSnapObservable=new u,d.angle=0,d.sensitivity=1,d._isEnabled=!0,d._parent=null,d._dragging=!1,d._angles=new R,d._parent=a,d._coloredMaterial=new _c("",n.utilityLayerScene),d._coloredMaterial.diffuseColor=r,d._coloredMaterial.specularColor=r.subtract(new B(.1,.1,.1)),d._hoverMaterial=new _c("",n.utilityLayerScene),d._hoverMaterial.diffuseColor=B.Yellow(),d._disableMaterial=new _c("",n.utilityLayerScene),d._disableMaterial.diffuseColor=B.Gray(),d._disableMaterial.alpha=.4,d._gizmoMesh=new io("",n.utilityLayerScene);var p=(c=d._createGizmoMesh(d._gizmoMesh,l,o)).rotationMesh,f=c.collider;d._rotationDisplayPlane=Bo("rotationDisplay",{size:.6,updatable:!1},d.gizmoLayer.utilityLayerScene),d._rotationDisplayPlane.rotation.z=.5*Math.PI,d._rotationDisplayPlane.parent=d._gizmoMesh,d._rotationDisplayPlane.setEnabled(!1),Gt.ShadersStore.rotationGizmoVertexShader=t._RotationGizmoVertexShader,Gt.ShadersStore.rotationGizmoFragmentShader=t._RotationGizmoFragmentShader,d._rotationShaderMaterial=new Uu("shader",d.gizmoLayer.utilityLayerScene,{vertex:"rotationGizmo",fragment:"rotationGizmo"},{attributes:["position","uv"],uniforms:["worldViewProjection","angles"]}),d._rotationShaderMaterial.backFaceCulling=!1,d._rotationDisplayPlane.material=d._rotationShaderMaterial,d._rotationDisplayPlane.visibility=.999,d._gizmoMesh.lookAt(d._rootMesh.position.add(i)),d._rootMesh.addChild(d._gizmoMesh,su.PreserveScaling),d._gizmoMesh.scaling.scaleInPlace(1/3),d.dragBehavior=new ko({dragPlaneNormal:i}),d.dragBehavior.moveAttached=!1,d.dragBehavior.maxDragAngle=t.MaxDragAngle,d.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,d._rootMesh.addBehavior(d.dragBehavior);var m=new R,g=new I,v=new R,y=new R;d.dragBehavior.onDragStartObservable.add((function(e){d.attachedNode&&(m.copyFrom(e.dragPlanePoint),d._rotationDisplayPlane.setEnabled(!0),d._rotationDisplayPlane.getWorldMatrix().invertToRef(g),R.TransformCoordinatesToRef(e.dragPlanePoint,g,m),d._angles.x=Math.atan2(m.y,m.x)+Math.PI,d._angles.y=0,d._angles.z=d.updateGizmoRotationToMatchAttachedMesh?1:0,d._dragging=!0,m.copyFrom(e.dragPlanePoint),d._rotationShaderMaterial.setVector3("angles",d._angles),d.angle=0)})),d.dragBehavior.onDragEndObservable.add((function(){d._dragging=!1,d._rotationDisplayPlane.setEnabled(!1)}));var b={snapDistance:0},T=0,E=new I,S=new P;d.dragBehavior.onDragObservable.add((function(e){if(d.attachedNode){var t=new R(1,1,1),r=new P(0,0,0,1),o=new R(0,0,0);if(d.attachedNode.getWorldMatrix().decompose(t,r,o),!(Math.abs(Math.abs(t.x)-Math.abs(t.y))<=_&&Math.abs(Math.abs(t.x)-Math.abs(t.z))<=_)&&d.updateGizmoRotationToMatchAttachedMesh)return void $.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=d.updateGizmoPositionToMatchAttachedMesh?o:d._rootMesh.absolutePosition,s=e.dragPlanePoint.subtract(a).normalize(),l=m.subtract(a).normalize(),c=R.Cross(s,l),u=R.Dot(s,l),h=Math.atan2(c.length(),u)*d.sensitivity;v.copyFrom(i),y.copyFrom(i),d.updateGizmoRotationToMatchAttachedMesh&&(r.toRotationMatrix(g),y=R.TransformCoordinates(v,g));var p=!1;if(n.utilityLayerScene.activeCamera){var f=n.utilityLayerScene.activeCamera.position.subtract(a).normalize();R.Dot(f,y)>0&&(v.scaleInPlace(-1),y.scaleInPlace(-1),p=!0)}R.Dot(y,c)>0&&(h=-h),O.Vector3[0].set(h,0,0),d.dragBehavior.validateDrag(O.Vector3[0])||(h=0);var x=!1;if(0!=d.snapDistance)if(T+=h,Math.abs(T)>d.snapDistance){var A=Math.floor(Math.abs(T)/d.snapDistance);T<0&&(A*=-1),T%=d.snapDistance,h=d.snapDistance*A,x=!0}else h=0;var C=Math.sin(h/2);if(S.set(v.x*C,v.y*C,v.z*C,Math.cos(h/2)),E.determinant()>0){var M=new R;S.toEulerAnglesToRef(M),P.RotationYawPitchRollToRef(M.y,-M.x,-M.z,S)}if(d.updateGizmoRotationToMatchAttachedMesh)r.multiplyToRef(S,r),r.normalize(),I.ComposeToRef(t,r,o,d.attachedNode.getWorldMatrix());else{S.toRotationMatrix(O.Matrix[0]);var D=d.attachedNode.getWorldMatrix().getTranslation();d.attachedNode.getWorldMatrix().multiplyToRef(O.Matrix[0],d.attachedNode.getWorldMatrix()),d.attachedNode.getWorldMatrix().setTranslation(D)}m.copyFrom(e.dragPlanePoint),x&&(b.snapDistance=h,d.onSnapObservable.notifyObservers(b)),d._angles.y+=h,d.angle+=p?-h:h,d._rotationShaderMaterial.setVector3("angles",d._angles),d._matrixChanged()}}));var x=n._getSharedGizmoLight();x.includedOnlyMeshes=x.includedOnlyMeshes.concat(d._rootMesh.getChildMeshes(!1));var A={colliderMeshes:[f],gizmoMeshes:[p],material:d._coloredMaterial,hoverMaterial:d._hoverMaterial,disableMaterial:d._disableMaterial,active:!1,dragBehavior:d.dragBehavior};return null===(h=d._parent)||void 0===h||h.addToAxisCache(d._gizmoMesh,A),d._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var i;if(!d._customMeshSet&&(d.dragBehavior.maxDragAngle=t.MaxDragAngle,d._isHovered=!(-1==A.colliderMeshes.indexOf(null===(i=null==e?void 0:e.pickInfo)||void 0===i?void 0:i.pickedMesh)),!d._parent)){var r=A.dragBehavior.enabled?d._isHovered||d._dragging?d._hoverMaterial:d._coloredMaterial:d._disableMaterial;d._setGizmoMeshMaterial(A.gizmoMeshes,r)}})),d.dragBehavior.onEnabledObservable.add((function(e){d._setGizmoMeshMaterial(A.gizmoMeshes,e?d._coloredMaterial:d._disableMaterial)})),d}return W(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.prototype._createGizmoMesh=function(e,t,i){var r=Uc("ignore",{diameter:.6,thickness:.03*t,tessellation:i},this.gizmoLayer.utilityLayerScene);r.visibility=0;var n=Uc("",{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,su.PreserveScaling),e.addChild(r,su.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 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 #define twopi 6.283185307\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(1.,1.,0., min(intensity * 0.25, 0.8)) * opacity;\n }",t}(su),Kf=function(e){function t(t,i,r,n,o,a){void 0===t&&(t=ou.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 u,s.onDragObservable=new u,s.onDragEndObservable=new u,s._observables=[],s._sensitivity=1,s._gizmoAxisCache=new Map;var l=a&&a.xOptions&&a.xOptions.color?a.xOptions.color:B.Red().scale(.5),c=a&&a.yOptions&&a.yOptions.color?a.yOptions.color:B.Green().scale(.5),h=a&&a.zOptions&&a.zOptions.color?a.zOptions.color:B.Blue().scale(.5);return s.xGizmo=new Yf(new R(1,0,0),l,t,i,s,r,n),s.yGizmo=new Yf(new R(0,1,0),c,t,i,s,r,n),s.zGizmo=new Yf(new R(0,0,1),h,t,i,s,r,n),[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):su.GizmoAxisPointerObserver(t,s._gizmoAxisCache),s}return W(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&&console.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(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){e=e||t.isHovered})),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}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},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(){$.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}(su),Qf=function(e){function t(i,r,n,o){void 0===r&&(r=B.Gray()),void 0===n&&(n=ou.DefaultUtilityLayer),void 0===o&&(o=null);var a,s=this;(s=e.call(this,n)||this)._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new u,s._isEnabled=!1,s._parent=null,s._dragging=!1,s._parent=o,s._coloredMaterial=new _c("",n.utilityLayerScene),s._coloredMaterial.diffuseColor=r,s._coloredMaterial.specularColor=r.subtract(new B(.1,.1,.1)),s._hoverMaterial=new _c("",n.utilityLayerScene),s._hoverMaterial.diffuseColor=B.Yellow(),s._disableMaterial=new _c("",n.utilityLayerScene),s._disableMaterial.diffuseColor=B.Gray(),s._disableMaterial.alpha=.4,s._gizmoMesh=t._CreatePlane(n.utilityLayerScene,s._coloredMaterial),s._gizmoMesh.lookAt(s._rootMesh.position.add(i)),s._gizmoMesh.scaling.scaleInPlace(1/3),s._gizmoMesh.parent=s._rootMesh;var l=0,c=new R,h={snapDistance:0};s.dragBehavior=new ko({dragPlaneNormal:i}),s.dragBehavior.moveAttached=!1,s._rootMesh.addBehavior(s.dragBehavior),s.dragBehavior.onDragObservable.add((function(e){if(s.attachedNode){if(0==s.snapDistance)s.attachedNode.getWorldMatrix().getTranslationToRef(O.Vector3[0]),O.Vector3[0].addToRef(e.delta,O.Vector3[0]),s.dragBehavior.validateDrag(O.Vector3[0])&&s.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z);else if(l+=e.dragDistance,Math.abs(l)>s.snapDistance){var t=Math.floor(Math.abs(l)/s.snapDistance);l%=s.snapDistance,e.delta.normalizeToRef(c),c.scaleInPlace(s.snapDistance*t),s.attachedNode.getWorldMatrix().getTranslationToRef(O.Vector3[0]),O.Vector3[0].addToRef(c,O.Vector3[0]),s.dragBehavior.validateDrag(O.Vector3[0])&&(s.attachedNode.getWorldMatrix().addTranslationFromFloats(c.x,c.y,c.z),h.snapDistance=s.snapDistance*t,s.onSnapObservable.notifyObservers(h))}s._matrixChanged()}})),s.dragBehavior.onDragStartObservable.add((function(){s._dragging=!0})),s.dragBehavior.onDragEndObservable.add((function(){s._dragging=!1}));var d=n._getSharedGizmoLight();d.includedOnlyMeshes=d.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1));var p={gizmoMeshes:s._gizmoMesh.getChildMeshes(),colliderMeshes:s._gizmoMesh.getChildMeshes(),material:s._coloredMaterial,hoverMaterial:s._hoverMaterial,disableMaterial:s._disableMaterial,active:!1,dragBehavior:s.dragBehavior};return null===(a=s._parent)||void 0===a||a.addToAxisCache(s._gizmoMesh,p),s._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!s._customMeshSet&&(s._isHovered=!(-1==p.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!s._parent)){var i=p.dragBehavior.enabled?s._isHovered||s._dragging?s._hoverMaterial:s._coloredMaterial:s._disableMaterial;s._setGizmoMeshMaterial(p.gizmoMeshes,i)}})),s.dragBehavior.onEnabledObservable.add((function(e){s._setGizmoMeshMaterial(p.gizmoMeshes,e?s._coloredMaterial:s._disableMaterial)})),s}return W(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 Ln("plane",e),r=Bo("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}(su),qf=function(e){function t(t,i,r){void 0===t&&(t=ou.DefaultUtilityLayer),void 0===i&&(i=1);var n=e.call(this,t)||this;return n._meshAttached=null,n._nodeAttached=null,n._observables=[],n._gizmoAxisCache=new Map,n.onDragStartObservable=new u,n.onDragObservable=new u,n.onDragEndObservable=new u,n._planarGizmoEnabled=!1,n.xGizmo=new lu(new R(1,0,0),B.Red().scale(.5),t,n,i),n.yGizmo=new lu(new R(0,1,0),B.Green().scale(.5),t,n,i),n.zGizmo=new lu(new R(0,0,1),B.Blue().scale(.5),t,n,i),n.xPlaneGizmo=new Qf(new R(1,0,0),B.Red().scale(.5),n.gizmoLayer,n),n.yPlaneGizmo=new Qf(new R(0,1,0),B.Green().scale(.5),n.gizmoLayer,n),n.zPlaneGizmo=new Qf(new R(0,0,1),B.Blue().scale(.5),n.gizmoLayer,n),[n.xGizmo,n.yGizmo,n.zGizmo,n.xPlaneGizmo,n.yPlaneGizmo,n.zPlaneGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragObservable.add((function(){n.onDragObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){n.onDragEndObservable.notifyObservers({})}))})),n.attachedMesh=null,r?r.addToAxisCache(n._gizmoAxisCache):su.GizmoAxisPointerObserver(t,n._gizmoAxisCache),n}return W(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(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){e=e||t.isHovered})),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,"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.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(){$.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}(su),Zf=function(e){function t(t,i,r){void 0===t&&(t=ou.DefaultUtilityLayer),void 0===i&&(i=1);var n=e.call(this,t)||this;return n._meshAttached=null,n._nodeAttached=null,n._sensitivity=1,n._observables=[],n._gizmoAxisCache=new Map,n.onDragStartObservable=new u,n.onDragObservable=new u,n.onDragEndObservable=new u,n.uniformScaleGizmo=n._createUniformScaleMesh(),n.xGizmo=new Xf(new R(1,0,0),B.Red().scale(.5),t,n,i),n.yGizmo=new Xf(new R(0,1,0),B.Green().scale(.5),t,n,i),n.zGizmo=new Xf(new R(0,0,1),B.Blue().scale(.5),t,n,i),[n.xGizmo,n.yGizmo,n.zGizmo,n.uniformScaleGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragObservable.add((function(){n.onDragObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){n.onDragEndObservable.notifyObservers({})}))})),n.attachedMesh=null,n.attachedNode=null,r?r.addToAxisCache(n._gizmoAxisCache):su.GizmoAxisPointerObserver(t,n._gizmoAxisCache),n}return W(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(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,configurable:!0}),t.prototype._createUniformScaleMesh=function(){this._coloredMaterial=new _c("",this.gizmoLayer.utilityLayerScene),this._coloredMaterial.diffuseColor=B.Gray(),this._hoverMaterial=new _c("",this.gizmoLayer.utilityLayerScene),this._hoverMaterial.diffuseColor=B.Yellow(),this._disableMaterial=new _c("",this.gizmoLayer.utilityLayerScene),this._disableMaterial.diffuseColor=B.Gray(),this._disableMaterial.alpha=.4;var e=new Xf(new R(0,1,0),B.Gray().scale(.5),this.gizmoLayer,this);e.updateGizmoRotationToMatchAttachedMesh=!1,e.uniformScaling=!0,this._uniformScalingMesh=uh("uniform",{type:1},e.gizmoLayer.utilityLayerScene),this._uniformScalingMesh.scaling.scaleInPlace(.01),this._uniformScalingMesh.visibility=0,this._octahedron=uh("",{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._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)}))):$.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,"coordinatesMode",{set:function(e){e==ru.World&&$.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=ru.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,"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.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}(su),Jf=function(){function e(e,t,i,r){void 0===t&&(t=1),void 0===i&&(i=ou.DefaultUtilityLayer),void 0===r&&(r=ou.DefaultKeepDepthUtilityLayer),this._scene=e,this.clearGizmoOnEmptyPointerEvent=!1,this.enableAutoPicking=!0,this.onAttachedToMeshObservable=new u,this.onAttachedToNodeObservable=new u,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObservers=[],this._attachedMesh=null,this._attachedNode=null,this._boundingBoxColor=B.FromHexString("#0984e3"),this._thickness=1,this._scaleRatio=1,this._coordinatesMode=ru.Local,this._gizmoAxisCache=new Map,this.boundingBoxDragBehavior=new Wo,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=su.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,"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}),e.prototype._attachToMeshPointerObserver=function(e){var t=this;return e.onPointerObservable.add((function(e){if(t.usePointerToAttachGizmos&&e.type==er.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 Vn?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 qf(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},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 Kf(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},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 Zf(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},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 jf(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},enumerable:!1,configurable:!0}),e.prototype.addToAxisCache=function(e){var t=this;e.size>0&&e.forEach((function(e,i){t._gizmoAxisCache.set(i,e)}))},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!==ou._DefaultKeepDepthUtilityLayer&&(null===(e=this._defaultKeepDepthUtilityLayer)||void 0===e||e.dispose()),this._defaultUtilityLayer!==ou._DefaultUtilityLayer&&(null===(t=this._defaultUtilityLayer)||void 0===t||t.dispose()),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},e}(),$f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._needProjectionMatrixCompute=!0,t}return W(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=R.Zero()),R.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=R.Zero()),R.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=R.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=R.Cross(this.direction,Cr.Y),t=R.Cross(e,this.direction);return R.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=R.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=I.Identity()),I.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)},X([Me()],t.prototype,"position",null),X([Me()],t.prototype,"direction",null),X([Ae()],t.prototype,"shadowMinZ",null),X([Ae()],t.prototype,"shadowMaxZ",null),t}(no);We.AddNodeConstructor("Light_Type_1",(function(e,t){return function(){return new e_(e,R.Zero(),t)}}));var e_=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 W(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 no.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&&I.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=R.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;I.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},X([Ae()],t.prototype,"shadowFrustumSize",null),X([Ae()],t.prototype,"shadowOrthoScale",null),X([Ae()],t.prototype,"autoUpdateExtends",void 0),X([Ae()],t.prototype,"autoCalcShadowZBounds",void 0),X([Ae("orthoLeft")],t.prototype,"_orthoLeft",void 0),X([Ae("orthoRight")],t.prototype,"_orthoRight",void 0),X([Ae("orthoTop")],t.prototype,"_orthoTop",void 0),X([Ae("orthoBottom")],t.prototype,"_orthoBottom",void 0),t}($f);function t_(e,t,i){void 0===t&&(t={}),t.diameter||(t.diameter=1),t.segments||(t.segments=16);var r=gu("",{slice:.5,diameter:t.diameter,segments:t.segments},i),n=Ru("",{radius:t.diameter/2,tessellation:3*t.segments+(4-t.segments)},i);n.rotation.x=-Math.PI/2,n.parent=r;var o=io.MergeMeshes([n,r],!0);return o.name=e,o}var i_={CreateHemisphere:t_};io.CreateHemisphere=function(e,t,i,r){return t_(e,{segments:t,diameter:i},r)},We.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new r_(e,R.Zero(),R.Zero(),0,0,t)}}));var r_=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,a)||this;return s._innerAngle=0,s._projectionTextureMatrix=I.Zero(),s._projectionTextureLightNear=1e-6,s._projectionTextureLightFar=1e3,s._projectionTextureUpDirection=R.Up(),s._projectionTextureViewLightDirty=!0,s._projectionTextureProjectionLightDirty=!0,s._projectionTextureDirty=!0,s._projectionTextureViewTargetVector=R.Zero(),s._projectionTextureViewLightMatrix=I.Zero(),s._projectionTextureProjectionLightMatrix=I.Zero(),s._projectionTextureScalingMatrix=I.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 W(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 no.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;I.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.direction,this._projectionTextureViewTargetVector),I.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);I.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 Eo){var e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;I.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=R.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),i=R.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()?R.Normalize(this.transformedDirection):R.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())},X([Ae()],t.prototype,"angle",null),X([Ae()],t.prototype,"innerAngle",null),X([Ae()],t.prototype,"shadowAngleScale",null),X([Ae()],t.prototype,"exponent",void 0),X([Ae()],t.prototype,"projectionTextureLightNear",null),X([Ae()],t.prototype,"projectionTextureLightFar",null),X([Ae()],t.prototype,"projectionTextureUpDirection",null),X([Re("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}($f),n_=function(e){function t(t){void 0===t&&(t=ou.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._cachedPosition=new R,i._cachedForward=new R(0,0,1),i._pointerObserver=null,i.onClickedObservable=new u,i._light=null,i.attachedMesh=new Vn("",i.gizmoLayer.utilityLayerScene),i._attachedMeshParent=new Ln("parent",i.gizmoLayer.utilityLayerScene),i.attachedMesh.parent=i._attachedMeshParent,i._material=new _c("light",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new B(.5,.5,.5),i._material.specularColor=new B(.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))}),er.POINTERDOWN),i}return W(t,e),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this.attachedMesh},set:function(e){console.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 nu?t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof e_?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof r_?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 P,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(O.Vector3[0]),e=O.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 R(t.x,t.y,t.z),this._cachedPosition.copyFrom(this.attachedMesh.position)}if(this._light.direction){var i=this._getMeshForward();if(R.DistanceSquared(i,this._cachedForward)>1e-4){var r=i;this._light.direction=new R(r.x,r.y,r.z),this._cachedForward.copyFrom(i)}else R.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 io("hemisphereLight",e),r=t_(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 io("pointLight",e),r=gu(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 io("spotLight",e);gu(i.name,{segments:10,diameter:1},e).parent=i;var r=t_(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 io("directionalLight",e),r=new io(i.name,e);r.parent=i,gu(i.name,{diameter:1.2,segments:10},e).parent=r;var n=eu(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=eu(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 io("root",t);i.rotation.x=Math.PI/2;var r=new io("linePivot",t);r.parent=i;var n=eu("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}(su),o_=function(e){function t(t){void 0===t&&(t=ou.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._pointerObserver=null,i.onClickedObservable=new u,i._camera=null,i._invProjection=new I,i._material=new _c("cameraGizmoMaterial",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new B(.5,.5,.5),i._material.specularColor=new B(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._camera&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._camera))}),er.POINTERDOWN),i}return W(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=this;if(this._camera=e,this.attachedNode=e,e){this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._cameraMesh=t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),this._cameraLinesMesh=t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene),this._cameraMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._cameraMesh.parent=this._rootMesh,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 r=this.gizmoLayer._getSharedGizmoLight();r.includedOnlyMeshes=r.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.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 io("rootCameraGizmo",e),r=new io(i.name,e);r.parent=i,fu(i.name,{width:1,height:.8,depth:.5},e).parent=r;var n=eu(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=eu(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=eu(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){var t=new io("rootCameraGizmo",e),i=new io(t.name,e);i.parent=t;for(var r=0;r<4;r+=2)for(var n=0;n<4;n+=2){var o=Hu("lines",{points:[new R(-1+n,-1+r,-1),new R(-1+n,-1+r,1)]},e);o.parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Hu("lines",{points:[new R(-1,-1+n,-1+r),new R(1,-1+n,-1+r)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Hu("lines",{points:[new R(-1+n,-1,-1+r),new R(-1+n,1,-1+r)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1}return t},t._Scale=.05,t}(su);kt.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";kt.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);}";kt.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";kt.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";kt.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}";kt.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";kt.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 a_=function(e){function t(t,i,r,n,o,s,l,c,u,h,d,p){void 0===s&&(s=Eo.BILINEAR_SAMPLINGMODE),void 0===u&&(u=a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=""),void 0===d&&(d=!1),void 0===p&&(p=a.TEXTUREFORMAT_RGBA);var f=e.call(this,t,"kernelBlur",["delta","direction"],["circleOfConfusionSampler"],n,o,s,l,c,null,u,"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 W(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 Ve.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)},X([Ae("kernel")],t.prototype,"_kernel",void 0),X([Ae("packedFloat")],t.prototype,"_packedFloat",void 0),X([Ie()],t.prototype,"direction",void 0),t}(Na);b("BABYLON.BlurPostProcess",a_);var s_=function(e){function t(t,i,r,n,o,s,l){void 0===o&&(o=a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=Eo.BILINEAR_SAMPLINGMODE),void 0===l&&(l=!0);var c=e.call(this,t,i,r,n,!0,o,!1,s,l)||this;if(c.mirrorPlane=new yr(0,1,0,1),c._transformMatrix=I.Zero(),c._mirrorMatrix=I.Zero(),c._adaptiveBlurKernel=0,c._blurKernelX=0,c._blurKernelY=0,c._blurRatio=1,!(r=c.getScene()))return c;c.ignoreCameraViewport=!0,c._updateGammaSpace(),c._imageProcessingConfigChangeObserver=r.imageProcessingConfiguration.onUpdateParameters.add((function(){c._updateGammaSpace()}));var u,h=r.getEngine();return h.supportsUniformBuffers&&(c._sceneUBO=r.createSceneUniformBuffer('Scene for Mirror Texture (name "'.concat(t,'")'))),c.onBeforeBindObservable.add((function(){var e;null===(e=h._debugPushGroup)||void 0===e||e.call(h,"mirror generation for ".concat(t),1)})),c.onAfterUnbindObservable.add((function(){var e;null===(e=h._debugPopGroup)||void 0===e||e.call(h,1)})),c.onBeforeRenderObservable.add((function(){c._sceneUBO&&(c._currentSceneUBO=r.getSceneUniformBuffer(),r.setSceneUniformBuffer(c._sceneUBO),r.getSceneUniformBuffer().unbindEffect()),I.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._mirrorMatrix.multiplyToRef(r.getViewMatrix(),c._transformMatrix),r.setTransformMatrix(c._transformMatrix,r.getProjectionMatrix()),u=r.clipPlane,r.clipPlane=c.mirrorPlane,r._mirroredCameraPosition=R.TransformCoordinates(r.activeCamera.globalPosition,c._mirrorMatrix)})),c.onAfterRenderObservable.add((function(){c._sceneUBO&&r.setSceneUniformBuffer(c._currentSceneUBO),r.updateTransformMatrix(),r._mirroredCameraPosition=null,r.clipPlane=u})),c}return W(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?a.TEXTURETYPE_FLOAT:a.TEXTURETYPE_HALF_FLOAT;this._blurX=new a_("horizontal blur",new A(1,0),this._blurKernelX,this._blurRatio,null,Eo.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 a_("vertical blur",new A(0,1),this._blurKernelY,this._blurRatio,null,Eo.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}(ns);Eo._CreateMirror=function(e,t,i,r){return new s_(e,t,i,r)};var l_=function(e){function t(t,i,r,n,o,s,l,c,h,d,p,f,_,m,g){void 0===r&&(r=null),void 0===n&&(n=!1),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=a.TEXTUREFORMAT_RGBA),void 0===h&&(h=!1),void 0===d&&(d=null),void 0===p&&(p=!1),void 0===f&&(f=.8),void 0===_&&(_=0);var v,y=this;return(y=e.call(this,i)||this)._lodScale=.8,y._lodOffset=0,y.onLoadObservable=new u,y.boundingBoxPosition=R.Zero(),y._rotationY=0,y._files=null,y._forcedExtension=null,y._extensions=null,y._textureMatrixRefraction=new I,y.name=t,y.url=t,y._noMipmap=n,y.hasAlpha=!1,y._format=c,y.isCube=!0,y._textureMatrix=I.Identity(),y._createPolynomials=p,y.coordinatesMode=Eo.CUBIC_MODE,y._extensions=r,y._files=o,y._forcedExtension=d,y._loaderOptions=m,y._useSRGBBuffer=g,y._lodScale=f,y._lodOffset=_,t||o?(y.updateURL(t,d,s,h,l,r,null===(v=y.getScene())||void 0===v?void 0:v.useDelayedTextureLoading,o),y):y}return W(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(a.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(I.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,s,l){void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=!1),void 0===l&&(l=null),this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,t&&(this._forcedExtension=t);var c=e.lastIndexOf("."),u=t||(c>-1?e.substring(c).toLowerCase():""),h=0===u.indexOf(".dds"),d=0===u.indexOf(".env"),p=0===u.indexOf(".basis");if(d?(this.gammaSpace=!1,this._prefiltered=!1,this.anisotropicFilteringLevel=1):(this._prefiltered=r,r&&(this.gammaSpace=!1,this.anisotropicFilteringLevel=1)),l)this._files=l;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,n.LODINREFLECTIONALPHA=s.lodLevelInAlpha,n.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,n.REFLECTIONBGR=this.switchToBGR,s.coordinatesMode===Eo.INVCUBIC_MODE&&(n.INVERTCUBICMAP=!0),n.REFLECTIONMAP_3D=s.isCube,n.REFLECTIONMAP_OPPOSITEZ=n.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,s.coordinatesMode){case Eo.EXPLICIT_MODE:n.REFLECTIONMAP_EXPLICIT=!0;break;case Eo.PLANAR_MODE:n.REFLECTIONMAP_PLANAR=!0;break;case Eo.PROJECTION_MODE:n.REFLECTIONMAP_PROJECTION=!0;break;case Eo.SKYBOX_MODE:n.REFLECTIONMAP_SKYBOX=!0;break;case Eo.SPHERICAL_MODE:n.REFLECTIONMAP_SPHERICAL=!0;break;case Eo.EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Eo.FIXED_EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Eo.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Eo.CUBIC_MODE:case Eo.INVCUBIC_MODE:default:n.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(n.REFLECTIONFRESNEL=!0,n.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):(n.REFLECTIONFRESNEL=!1,n.REFLECTIONFALLOFF=!1)}else n.REFLECTION=!1,n.REFLECTIONFRESNEL=!1,n.REFLECTIONFALLOFF=!1,n.REFLECTIONBLUR=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.INVERTCUBICMAP=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.LODINREFLECTIONALPHA=!1,n.GAMMAREFLECTION=!1,n.RGBDREFLECTION=!1}n.PREMULTIPLYALPHA=this.alphaMode===a.ALPHA_PREMULTIPLIED||this.alphaMode===a.ALPHA_PREMULTIPLIED_PORTERDUFF,n.USERGBCOLOR=this._useRGBColor,n.NOISE=this._enableNoise}if(n._areLightsDirty&&(n.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel),n.BACKMAT_SHADOWONLY=this._shadowOnly),n._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(n)}if(n._areMiscDirty&&(n.REFLECTIONMAP_3D&&this._enableGroundProjection?(n.PROJECTED_GROUND=!0,n.REFLECTIONMAP_SKYBOX=!0):n.PROJECTED_GROUND=!1),jn.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),jn.PrepareDefinesForFrameBoundValues(r,o,this,n,i,null,t.getRenderingMesh().hasThinInstances),jn.PrepareDefinesForAttributes(e,n,!1,!0,!1)&&e&&(r.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(ji.NormalKind)||(e.createNormals(!0),$.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var l=new Ma;n.FOG&&l.addFallback(0,"FOG"),n.POINTSIZE&&l.addFallback(1,"POINTSIZE"),n.MULTIVIEW&&l.addFallback(0,"MULTIVIEW"),jn.HandleFallbacksForShadows(n,l,this._maxSimultaneousLights);var c=[ji.PositionKind];n.NORMAL&&c.push(ji.NormalKind),n.UV1&&c.push(ji.UVKind),n.UV2&&c.push(ji.UV2Kind),jn.PrepareAttributesForBones(c,e,n,l),jn.PrepareAttributesForInstances(c,n);var u=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix","projectedGroundInfos"];kn(u);var h=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],d=["Material","Scene"];Li&&(Li.PrepareUniforms(u,n),Li.PrepareSamplers(h,n)),jn.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:n,maxSimultaneousLights:this._maxSimultaneousLights});var p=n.toString(),f=r.getEngine().createEffect("background",{attributes:c,uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:p,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},o);t.setEffect(f,n,this._materialContext),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady()||(n._renderId=r.getRenderId(),t.effect._wasPreviouslyReady=!0,t.effect._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),jn.BindBonesParameters(t,this._activeEffect);var a=this._mustRebind(r,o,t.visibility);if(a){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o);var s=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(r.texturesEnabled&&(this._diffuseTexture&&tc.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),jn.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&tc.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&&tc.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&tc.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)),Wn(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&&jn.BindLights(r,t,this._activeEffect,n,this._maxSimultaneousLights),this.bindView(o),jn.BindFogParameters(r,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect),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 Ve.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 Ve.Parse((function(){return new t(e.name,i)}),e,i,r)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,X([Ce()],t.prototype,"_primaryColor",void 0),X([xe("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),X([Ce()],t.prototype,"__perceptualColor",void 0),X([Ae()],t.prototype,"_primaryColorShadowLevel",void 0),X([Ae()],t.prototype,"_primaryColorHighlightLevel",void 0),X([xe("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),X([Re()],t.prototype,"_reflectionTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),X([Ae()],t.prototype,"_reflectionBlur",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),X([Re()],t.prototype,"_diffuseTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),X([Ae()],t.prototype,"_shadowLevel",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),X([Me()],t.prototype,"_sceneCenter",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),X([Ae()],t.prototype,"_opacityFresnel",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),X([Ae()],t.prototype,"_reflectionFresnel",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),X([Ae()],t.prototype,"_reflectionFalloffDistance",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),X([Ae()],t.prototype,"_reflectionAmount",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),X([Ae()],t.prototype,"_reflectionReflectance0",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),X([Ae()],t.prototype,"_reflectionReflectance90",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),X([Ae()],t.prototype,"_useRGBColor",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),X([Ae()],t.prototype,"_enableNoise",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),X([Ae()],t.prototype,"_maxSimultaneousLights",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),X([Ae()],t.prototype,"_shadowOnly",void 0),X([xe("_markAllSubMeshesAsLightsDirty")],t.prototype,"shadowOnly",void 0),X([Fe()],t.prototype,"_imageProcessingConfiguration",void 0),X([Ae(),xe("_markAllSubMeshesAsMiscDirty")],t.prototype,"enableGroundProjection",void 0),X([Ae()],t.prototype,"projectedGroundRadius",void 0),X([Ae()],t.prototype,"projectedGroundHeight",void 0),t}(oa);b("BABYLON.BackgroundMaterial",u_);var h_=function(){function e(t,i){var r=this;this._errorHandler=function(e,t){r.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=H(H({},e._GetDefaultOptions(i)),t),this._scene=i,this.onErrorObservable=new u,this._setupBackground(),this._setupImageProcessing()}return e._GetDefaultOptions=function(e){return{createGround:!0,groundSize:15,groundTexture:this._GroundTextureCDNUrl,groundColor:new B(.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:a.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._SkyboxTextureCDNUrl,skyboxColor:new B(.2,.2,.3).toLinearSpace(e.getEngine().useExactSrgbConversions).scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:R.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=H(H({},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 U(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 go)this._scene.environmentTexture=this._options.environmentTexture;else{var e=l_.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new io("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 ul&&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=Bo("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 u_("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=a.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 go?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new Eo(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=Eo.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new s_("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Eo.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new yr(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,X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),X([Ae()],t.prototype,"intensity",void 0),X([Ae()],t.prototype,"roughness",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"remapF0OnInterfaceChange",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTintEnabled",void 0),X([Ce()],t.prototype,"tintColor",void 0),X([Ae()],t.prototype,"tintColorAtDistance",void 0),X([Ae()],t.prototype,"tintThickness",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"tintTexture",void 0),t}(uc),T_=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.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE=!1,t}return W(t,e),t}(Di),E_=function(e){function t(i,r){void 0===r&&(r=!0);var n=e.call(this,i,"PBRIridescence",110,new T_,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[a.MATERIAL_TextureDirtyFlag],n}return W(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&&tc.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._thicknessTexture&&tc.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefinesBeforeAttributes=function(e,t){var i;this._isEnabled?(e.IRIDESCENCE=!0,e.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE=null!==this._texture&&this._texture._texture===(null===(i=this._thicknessTexture)||void 0===i?void 0:i._texture)&&this._texture.checkTransformsAreIdentical(this._thicknessTexture),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&tc.IridescenceTextureEnabled?jn.PrepareDefinesForMergedUV(this._texture,e,"IRIDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,!e.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE&&this._thicknessTexture&&tc.IridescenceTextureEnabled?jn.PrepareDefinesForMergedUV(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_USE_THICKNESS_FROM_MAINTEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=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,f=d.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE;e.useUbo&&p&&e.isSync||(f&&tc.IridescenceTextureEnabled?(e.updateFloat4("vIridescenceInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),jn.BindTextureMatrix(this._texture,e,"iridescence")):(this._texture||this._thicknessTexture)&&tc.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",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._thicknessTexture)||void 0===l?void 0:l.coordinatesIndex)&&void 0!==c?c:0,null!==(h=null===(u=this._thicknessTexture)||void 0===u?void 0:u.level)&&void 0!==h?h:0),this._texture&&jn.BindTextureMatrix(this._texture,e,"iridescence"),!this._thicknessTexture||f||d.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE||jn.BindTextureMatrix(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),t.texturesEnabled&&(this._texture&&tc.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&!f&&!d.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE&&tc.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,X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),X([Ae()],t.prototype,"intensity",void 0),X([Ae()],t.prototype,"minimumThickness",void 0),X([Ae()],t.prototype,"maximumThickness",void 0),X([Ae()],t.prototype,"indexOfRefraction",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"thicknessTexture",void 0),t}(uc),S_=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 W(t,e),t}(Di),x_=function(e){function t(t,i){void 0===i&&(i=!0);var r=e.call(this,t,"PBRAnisotropic",110,new S_,i)||this;return r._isEnabled=!1,r.isEnabled=!1,r.intensity=1,r.direction=new A(1,0),r._texture=null,r.texture=null,r._legacy=!1,r.legacy=!1,r._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],r._internalMarkAllSubMeshesAsMiscDirty=t._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag],r}return W(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&&tc.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},t.prototype.prepareDefinesBeforeAttributes=function(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(ji.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&tc.AnisotropicTextureEnabled?jn.PrepareDefinesForMergedUV(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&&tc.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),jn.BindTextureMatrix(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&tc.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)},X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),X([Ae()],t.prototype,"intensity",void 0),X([Ie()],t.prototype,"direction",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),X([Ae(),xe("_markAllSubMeshesAsMiscDirty")],t.prototype,"legacy",void 0),t}(uc),A_=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.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1,t}return W(t,e),t}(Di),R_=function(e){function t(t,i){void 0===i&&(i=!0);var r=e.call(this,t,"Sheen",120,new A_,i)||this;return r._isEnabled=!1,r.isEnabled=!1,r._linkSheenWithAlbedo=!1,r.linkSheenWithAlbedo=!1,r.intensity=1,r.color=B.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[a.MATERIAL_TextureDirtyFlag],r}return W(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&&tc.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&tc.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefinesBeforeAttributes=function(e,t){var i;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.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=null!==this._texture&&this._texture._texture===(null===(i=this._textureRoughness)||void 0===i?void 0:i._texture)&&this._texture.checkTransformsAreIdentical(this._textureRoughness),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&tc.SheenTextureEnabled?(jn.PrepareDefinesForMergedUV(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&tc.SheenTextureEnabled?jn.PrepareDefinesForMergedUV(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_TEXTURE_ROUGHNESS_IDENTICAL=!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,f=d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;e.useUbo&&p&&e.isSync||(f&&tc.SheenTextureEnabled?(e.updateFloat4("vSheenInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),jn.BindTextureMatrix(this._texture,e,"sheen")):(this._texture||this._textureRoughness)&&tc.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&&jn.BindTextureMatrix(this._texture,e,"sheen"),!this._textureRoughness||f||d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE||jn.BindTextureMatrix(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&&tc.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!f&&!d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&tc.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"}]}},X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkSheenWithAlbedo",void 0),X([Ae()],t.prototype,"intensity",void 0),X([Ce()],t.prototype,"color",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoScaling",void 0),t}(uc),C_=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_TEXTURE=!1,t.SS_TRANSLUCENCY=!1,t.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE=!1,t.SS_SCATTERING=!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_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_MASK_FROM_THICKNESS_TEXTURE=!1,t.SS_USE_GLTF_TEXTURES=!1,t}return W(t,e),t}(Di),P_=function(e){function t(t,i){void 0===i&&(i=!0);var r=e.call(this,t,"PBRSubSurface",130,new C_,i)||this;return r._isRefractionEnabled=!1,r.isRefractionEnabled=!1,r._isTranslucencyEnabled=!1,r.isTranslucencyEnabled=!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=B.White(),r.tintColorAtDistance=1,r.diffusionDistance=B.White(),r._useMaskFromThicknessTexture=!1,r.useMaskFromThicknessTexture=!1,r._refractionIntensityTexture=null,r.refractionIntensityTexture=null,r._translucencyIntensityTexture=null,r.translucencyIntensityTexture=null,r._useGltfStyleTextures=!1,r.useGltfStyleTextures=!1,r._scene=t.getScene(),r.registerForExtraEvents=!0,r._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],r._internalMarkScenePrePassDirty=t._dirtyCallbacks[a.MATERIAL_PrePassDirtyFlag],r}return W(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&&tc.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var i=this._getRefractionTexture(t);if(i&&tc.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_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE=!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_MASK_FROM_THICKNESS_TEXTURE=!1,void(e.SS_USE_GLTF_TEXTURES=!1);if(e._areTexturesDirty){e.SUBSURFACE=!0,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE=!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_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE=!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;var i=!!this._thicknessTexture&&!!this._refractionIntensityTexture&&this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture)&&this._refractionIntensityTexture._texture===this._thicknessTexture._texture,r=!!this._thicknessTexture&&!!this._translucencyIntensityTexture&&this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture)&&this._translucencyIntensityTexture._texture===this._thicknessTexture._texture,n=(i||!this._refractionIntensityTexture)&&(r||!this._translucencyIntensityTexture);if(e._areTexturesDirty&&t.texturesEnabled&&(this._thicknessTexture&&tc.ThicknessTextureEnabled&&jn.PrepareDefinesForMergedUV(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&tc.RefractionIntensityTextureEnabled&&!n&&jn.PrepareDefinesForMergedUV(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&tc.TranslucencyIntensityTextureEnabled&&!n&&jn.PrepareDefinesForMergedUV(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE")),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!=0,e.SS_MASK_FROM_THICKNESS_TEXTURE=(this._useMaskFromThicknessTexture||!!this._refractionIntensityTexture||!!this._translucencyIntensityTexture)&&n,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE=(this._useMaskFromThicknessTexture||!!this._refractionIntensityTexture)&&n,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE=(this._useMaskFromThicknessTexture||!!this._translucencyIntensityTexture)&&n,this._isRefractionEnabled&&t.texturesEnabled){var o=this._getRefractionTexture(t);o&&tc.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=o.isCube,e.SS_GAMMAREFRACTION=o.gammaSpace,e.SS_RGBDREFRACTION=o.isRGBD,e.SS_LINEARSPECULARREFRACTION=o.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=this._scene.useRightHandedSystem&&o.isCube?!o.invertZ:o.invertZ,e.SS_LODINREFRACTIONALPHA=o.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=o.isCube&&o.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(O.Vector3[0]);var n=Math.max(Math.abs(O.Vector3[0].x),Math.abs(O.Vector3[0].y),Math.abs(O.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*n,(this.maximumThickness-this.minimumThickness)*n)}},t.prototype.bindForSubMesh=function(e,t,i,r){if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled){var n=r.materialDefines,o=this._material.isFrozen,a=this._material.realTimeFiltering,s=n.LODBASEDMICROSFURACE,l=this._getRefractionTexture(t);if(!e.useUbo||!o||!e.isSync){if(this._thicknessTexture&&tc.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),jn.BindTextureMatrix(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&tc.RefractionIntensityTextureEnabled&&n.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),jn.BindTextureMatrix(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyIntensityTexture&&tc.TranslucencyIntensityTextureEnabled&&n.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),jn.BindTextureMatrix(this._translucencyIntensityTexture,e,"translucencyIntensity")),l&&tc.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",l.getRefractionTextureMatrix());var c=1;l.isCube||l.depth&&(c=l.depth);var u=l.getSize().width,d=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",l.level,1/d,c,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",u,l.lodGenerationScale,l.lodGenerationOffset,1/this.indexOfRefraction),a&&e.updateFloat2("vRefractionFilteringInfo",u,h.Log2(u)),l.boundingBoxSize){var p=l;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.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0)}t.texturesEnabled&&(this._thicknessTexture&&tc.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&tc.RefractionIntensityTextureEnabled&&n.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&tc.TranslucencyIntensityTextureEnabled&&n.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),l&&tc.RefractionTextureEnabled&&(s?e.setTexture("refractionSampler",l):(e.setTexture("refractionSampler",l._lodTextureMid||l),e.setTexture("refractionSamplerLow",l._lodTextureLow||l),e.setTexture("refractionSamplerHigh",l._lodTextureHigh||l))))}},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){tc.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},t.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e},t.prototype.hasRenderTargetTextures=function(){return!!(tc.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},t.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture)},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)},t.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.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")},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"}]}},X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isRefractionEnabled",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTranslucencyEnabled",void 0),X([Ae(),xe("_markScenePrePassDirty")],t.prototype,"isScatteringEnabled",void 0),X([Ae()],t.prototype,"_scatteringDiffusionProfileIndex",void 0),X([Ae()],t.prototype,"refractionIntensity",void 0),X([Ae()],t.prototype,"translucencyIntensity",void 0),X([Ae()],t.prototype,"useAlbedoToTintRefraction",void 0),X([Ae()],t.prototype,"useAlbedoToTintTranslucency",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"thicknessTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),X([Ae()],t.prototype,"_volumeIndexOfRefraction",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"volumeIndexOfRefraction",null),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),X([Ae()],t.prototype,"minimumThickness",void 0),X([Ae()],t.prototype,"maximumThickness",void 0),X([Ae()],t.prototype,"useThicknessAsDepth",void 0),X([Ce()],t.prototype,"tintColor",void 0),X([Ae()],t.prototype,"tintColorAtDistance",void 0),X([Ce()],t.prototype,"diffusionDistance",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMaskFromThicknessTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionIntensityTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"translucencyIntensityTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGltfStyleTextures",void 0),t}(uc),I_={effect:null,subMesh:null},M_=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=!1,i.TONEMAPPING_ACES=!1,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 W(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0},t}(Di),O_=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 C(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=B.White(),n._useOnlyMetallicFromMetallicReflectanceTexture=!1,n._metallicReflectanceTexture=null,n._reflectanceTexture=null,n._microSurfaceTexture=null,n._bumpTexture=null,n._lightmapTexture=null,n._ambientColor=new B(0,0,0),n._albedoColor=new B(1,1,1),n._reflectivityColor=new B(1,1,1),n._reflectionColor=new B(1,1,1),n._emissiveColor=new B(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=a.TEXTURE_FILTERING_QUALITY_LOW,n._forceNormalForward=!1,n._enableSpecularAntiAliasing=!1,n._imageProcessingObserver=null,n._renderTargets=new Ii(16),n._globalAmbientColor=new B(0,0,0),n._useLogarithmicDepth=!1,n._unlit=!1,n._applyDecalMapAfterDetailMap=!1,n._debugMode=0,n.debugMode=0,n.debugLimit=-1,n.debugFactor=1,n._cacheHasRenderTargetTextures=!1,n.brdf=new v_(n),n.clearCoat=new b_(n),n.iridescence=new E_(n),n.anisotropy=new x_(n),n.sheen=new R_(n),n.subSurface=new P_(n),n.detailMap=new dc(n),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),tc.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),n._eventInfo.renderTargets=n._renderTargets,n._callbackPluginEventFillRenderTargetTextures(n._eventInfo),n._renderTargets},n._environmentBRDFTexture=__(n.getScene()),n.prePassConfiguration=new ec,n}return W(t,e),Object.defineProperty(t.prototype,"realTimeFiltering",{get:function(){return this._realTimeFiltering},set:function(e){this._realTimeFiltering=e,this.markAsDirty(a.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"realTimeFilteringQuality",{get:function(){return this._realTimeFilteringQuality},set:function(e){this._realTimeFilteringQuality=e,this.markAsDirty(a.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!!(tc.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,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!1,configurable:!0}),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;if(this._uniformBufferLayoutBuilt||this.buildUniformLayout(),t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady&&t.effect._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(Xn.GetDefineNames,this._eventInfo),t.materialDefines=new M_(this._eventInfo.defineNames));var n=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;var o=this.getScene(),a=o.getEngine();if(n._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,o.texturesEnabled)){if(this._albedoTexture&&tc.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&tc.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&tc.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var s=this._getReflectionTexture();if(s&&tc.ReflectionTextureEnabled){if(!s.isReadyOrNotBlocking())return!1;if(s.irradianceTexture){if(!s.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!s.sphericalPolynomial&&(null===(r=s.getInternalTexture())||void 0===r?void 0:r._sphericalPolynomialPromise))return!1}if(this._lightmapTexture&&tc.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&tc.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(tc.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(a.getCaps().standardDerivatives&&this._bumpTexture&&tc.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&tc.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=n,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(n._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;a.getCaps().standardDerivatives||e.isVerticesDataPresent(ji.NormalKind)||(e.createNormals(!0),$.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var l=t.effect,c=n._areLightsDisposed,u=this._prepareEffect(e,n,this.onCompiled,this.onError,i,null,t.getRenderingMesh().hasThinInstances),h=!1;if(u)if(this._onEffectCreatedObservable&&(I_.effect=u,I_.subMesh=t,this._onEffectCreatedObservable.notifyObservers(I_)),this.allowShaderHotSwapping&&l&&!u.isReady()){if(u=l,n.markAsUnprocessed(),h=this.isFrozen,c)return n._areLightsDisposed=!0,!1}else o.resetCachedMaterial(),t.setEffect(u,n,this._materialContext);return!(!t.effect||!t.effect.isReady()||(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!h,t.effect._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,s){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,s),!t.isDirty)return null;t.markAsProcessed();var l=this.getScene().getEngine(),c=new Ma,u=0;t.USESPHERICALINVERTEX&&c.addFallback(u++,"USESPHERICALINVERTEX"),t.FOG&&c.addFallback(u,"FOG"),t.SPECULARAA&&c.addFallback(u,"SPECULARAA"),t.POINTSIZE&&c.addFallback(u,"POINTSIZE"),t.LOGARITHMICDEPTH&&c.addFallback(u,"LOGARITHMICDEPTH"),t.PARALLAX&&c.addFallback(u,"PARALLAX"),t.PARALLAX_RHS&&c.addFallback(u,"PARALLAX_RHS"),t.PARALLAXOCCLUSION&&c.addFallback(u++,"PARALLAXOCCLUSION"),t.ENVIRONMENTBRDF&&c.addFallback(u++,"ENVIRONMENTBRDF"),t.TANGENT&&c.addFallback(u++,"TANGENT"),t.BUMP&&c.addFallback(u++,"BUMP"),u=jn.HandleFallbacksForShadows(t,c,this._maxSimultaneousLights,u++),t.SPECULARTERM&&c.addFallback(u++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&c.addFallback(u++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&c.addFallback(u++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&c.addFallback(u++,"LIGHTMAP"),t.NORMAL&&c.addFallback(u++,"NORMAL"),t.AMBIENT&&c.addFallback(u++,"AMBIENT"),t.EMISSIVE&&c.addFallback(u++,"EMISSIVE"),t.VERTEXCOLOR&&c.addFallback(u++,"VERTEXCOLOR"),t.MORPHTARGETS&&c.addFallback(u++,"MORPHTARGETS"),t.MULTIVIEW&&c.addFallback(0,"MULTIVIEW");var h=[ji.PositionKind];t.NORMAL&&h.push(ji.NormalKind),t.TANGENT&&h.push(ji.TangentKind);for(var d=1;d<=a.MAX_SUPPORTED_UV_SETS;++d)t["UV"+d]&&h.push("uv".concat(1===d?"":d));t.VERTEXCOLOR&&h.push(ji.ColorKind),t.INSTANCESCOLOR&&h.push(ji.ColorInstanceKind),jn.PrepareAttributesForBones(h,e,t,c),jn.PrepareAttributesForInstances(h,t),jn.PrepareAttributesForMorphTargets(h,e,t),jn.PrepareAttributesForBakedVertexAnimation(h,e,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=c,this._eventInfo.fallbackRank=u,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(Xn.PrepareEffect,this._eventInfo),ec.AddUniforms(f),ec.AddSamplers(_),kn(f),Li&&(Li.PrepareUniforms(f,t),Li.PrepareSamplers(_,t)),jn.PrepareUniformsAndSamplersList({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=l.createEffect(p,{attributes:h,uniformsNames:f,uniformBuffersNames:m,samplers:_,defines:y,fallbacks:c,onCompiled:i,onError:r,indexParameters:g,processFinalCode:v.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:t.PREPASS},l);return this._eventInfo.customCode=void 0,b},t.prototype._prepareDefines=function(e,i,r,n,o){var s;void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=!1);var l=this.getScene(),c=l.getEngine();jn.PrepareDefinesForLights(l,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,jn.PrepareDefinesForMultiview(l,i);var u=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(jn.PrepareDefinesForPrePass(l,i,this.canRenderToMRT&&!u),jn.PrepareDefinesForOIT(l,i,u),i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){i._needUVs=!1;for(var h=1;h<=a.MAX_SUPPORTED_UV_SETS;++h)i["MAINUV"+h]=!1;if(l.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,c.getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&tc.DiffuseTextureEnabled?(jn.PrepareDefinesForMergedUV(this._albedoTexture,i,"ALBEDO"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._ambientTexture&&tc.AmbientTextureEnabled?(jn.PrepareDefinesForMergedUV(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&tc.OpacityTextureEnabled?(jn.PrepareDefinesForMergedUV(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;var d=this._getReflectionTexture();if(d&&tc.ReflectionTextureEnabled){switch(i.REFLECTION=!0,i.GAMMAREFLECTION=d.gammaSpace,i.RGBDREFLECTION=d.isRGBD,i.LODINREFLECTIONALPHA=d.lodLevelInAlpha,i.LINEARSPECULARREFLECTION=d.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(i.NUM_SAMPLES=""+this.realTimeFilteringQuality,c._features.needTypeSuffixInShaderConstants&&(i.NUM_SAMPLES=i.NUM_SAMPLES+"u"),i.REALTIME_FILTERING=!0):i.REALTIME_FILTERING=!1,i.INVERTCUBICMAP=d.coordinatesMode===Eo.INVCUBIC_MODE,i.REFLECTIONMAP_3D=d.isCube,i.REFLECTIONMAP_OPPOSITEZ=i.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!d.invertZ:d.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,d.coordinatesMode){case Eo.EXPLICIT_MODE:i.REFLECTIONMAP_EXPLICIT=!0;break;case Eo.PLANAR_MODE:i.REFLECTIONMAP_PLANAR=!0;break;case Eo.PROJECTION_MODE:i.REFLECTIONMAP_PROJECTION=!0;break;case Eo.SKYBOX_MODE:i.REFLECTIONMAP_SKYBOX=!0;break;case Eo.SPHERICAL_MODE:i.REFLECTIONMAP_SPHERICAL=!0;break;case Eo.EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Eo.FIXED_EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Eo.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Eo.CUBIC_MODE:case Eo.INVCUBIC_MODE:default:i.REFLECTIONMAP_CUBIC=!0,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!!d.boundingBoxSize}d.coordinatesMode!==Eo.SKYBOX_MODE&&(d.irradianceTexture?(i.USEIRRADIANCEMAP=!0,i.USESPHERICALFROMREFLECTIONMAP=!1):d.isCube&&(i.USESPHERICALFROMREFLECTIONMAP=!0,i.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||c.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;if(this._lightmapTexture&&tc.LightmapTextureEnabled?(jn.PrepareDefinesForMergedUV(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&tc.EmissiveTextureEnabled?(jn.PrepareDefinesForMergedUV(this._emissiveTexture,i,"EMISSIVE"),i.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):i.EMISSIVE=!1,tc.SpecularTextureEnabled){if(this._metallicTexture?(jn.PrepareDefinesForMergedUV(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?(jn.PrepareDefinesForMergedUV(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){var p=null!==this._metallicReflectanceTexture&&this._metallicReflectanceTexture._texture===(null===(s=this._reflectanceTexture)||void 0===s?void 0:s._texture)&&this._metallicReflectanceTexture.checkTransformsAreIdentical(this._reflectanceTexture);i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture&&!p,this._metallicReflectanceTexture?(jn.PrepareDefinesForMergedUV(this._metallicReflectanceTexture,i,"METALLIC_REFLECTANCE"),i.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):i.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&!p&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(jn.PrepareDefinesForMergedUV(this._reflectanceTexture,i,"REFLECTANCE"),i.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):i.REFLECTANCE=!1}else i.METALLIC_REFLECTANCE=!1,i.REFLECTANCE=!1;this._microSurfaceTexture?jn.PrepareDefinesForMergedUV(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1}else i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1;c.getCaps().standardDerivatives&&this._bumpTexture&&tc.BumpTextureEnabled&&!this._disableBumpMap?(jn.PrepareDefinesForMergedUV(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&tc.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAX_RHS=l.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&&tc.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=c.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE="".concat(this._alphaCutOff).concat(this._alphaCutOff%1==0?".":""),i.PREMULTIPLYALPHA=this.alphaMode===a.ALPHA_PREMULTIPLIED||this.alphaMode===a.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&&(jn.PrepareDefinesForMisc(e,l,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,i,this._applyDecalMapAfterDetailMap),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(ji.NormalKind),i.DEBUGMODE=this._debugMode),jn.PrepareDefinesForFrameBoundValues(l,c,this,i,!!r,n,o),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),jn.PrepareDefinesForAttributes(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=H({clipPlane:!1,useInstances:!1},i);this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(Xn.GetDefineNames,this._eventInfo);var o=new M_(this._eventInfo.defineNames),a=this._prepareEffect(e,o,void 0,void 0,n.useInstances,n.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(I_.effect=a,I_.subMesh=null,this._onEffectCreatedObservable.notifyObservers(I_)),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 d=c._forceRebindOnNextCall||this._mustRebind(s,c,t.visibility);jn.BindBonesParameters(t,this._activeEffect,this.prePassConfiguration);var p=null,f=this._uniformBuffer;if(d){if(this.bindViewProjection(c),p=this._getReflectionTexture(),!f.useUbo||!this.isFrozen||!f.isSync||c._forceRebindOnNextCall){if(s.texturesEnabled){if(this._albedoTexture&&tc.DiffuseTextureEnabled&&(f.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),jn.BindTextureMatrix(this._albedoTexture,f,"albedo")),this._ambientTexture&&tc.AmbientTextureEnabled&&(f.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),jn.BindTextureMatrix(this._ambientTexture,f,"ambient")),this._opacityTexture&&tc.OpacityTextureEnabled&&(f.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),jn.BindTextureMatrix(this._opacityTexture,f,"opacity")),p&&tc.ReflectionTextureEnabled){if(f.updateMatrix("reflectionMatrix",p.getReflectionTextureMatrix()),f.updateFloat2("vReflectionInfos",p.level,0),p.boundingBoxSize){var _=p;f.updateVector3("vReflectionPosition",_.boundingBoxPosition),f.updateVector3("vReflectionSize",_.boundingBoxSize)}if(this.realTimeFiltering){var m=p.getSize().width;f.updateFloat2("vReflectionFilteringInfo",m,h.Log2(m))}if(!l.USEIRRADIANCEMAP){var g=p.sphericalPolynomial;if(l.USESPHERICALFROMREFLECTIONMAP&&g)if(l.SPHERICAL_HARMONICS){var v=g.preScaledHarmonics;f.updateVector3("vSphericalL00",v.l00),f.updateVector3("vSphericalL1_1",v.l1_1),f.updateVector3("vSphericalL10",v.l10),f.updateVector3("vSphericalL11",v.l11),f.updateVector3("vSphericalL2_2",v.l2_2),f.updateVector3("vSphericalL2_1",v.l2_1),f.updateVector3("vSphericalL20",v.l20),f.updateVector3("vSphericalL21",v.l21),f.updateVector3("vSphericalL22",v.l22)}else f.updateFloat3("vSphericalX",g.x.x,g.x.y,g.x.z),f.updateFloat3("vSphericalY",g.y.x,g.y.y,g.y.z),f.updateFloat3("vSphericalZ",g.z.x,g.z.y,g.z.z),f.updateFloat3("vSphericalXX_ZZ",g.xx.x-g.zz.x,g.xx.y-g.zz.y,g.xx.z-g.zz.z),f.updateFloat3("vSphericalYY_ZZ",g.yy.x-g.zz.x,g.yy.y-g.zz.y,g.yy.z-g.zz.z),f.updateFloat3("vSphericalZZ",g.zz.x,g.zz.y,g.zz.z),f.updateFloat3("vSphericalXY",g.xy.x,g.xy.y,g.xy.z),f.updateFloat3("vSphericalYZ",g.yz.x,g.yz.y,g.yz.z),f.updateFloat3("vSphericalZX",g.zx.x,g.zx.y,g.zx.z)}f.updateFloat3("vReflectionMicrosurfaceInfos",p.getSize().width,p.lodGenerationScale,p.lodGenerationOffset)}this._emissiveTexture&&tc.EmissiveTextureEnabled&&(f.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),jn.BindTextureMatrix(this._emissiveTexture,f,"emissive")),this._lightmapTexture&&tc.LightmapTextureEnabled&&(f.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),jn.BindTextureMatrix(this._lightmapTexture,f,"lightmap")),tc.SpecularTextureEnabled&&(this._metallicTexture?(f.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),jn.BindTextureMatrix(this._metallicTexture,f,"reflectivity")):this._reflectivityTexture&&(f.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),jn.BindTextureMatrix(this._reflectivityTexture,f,"reflectivity")),this._metallicReflectanceTexture&&(f.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),jn.BindTextureMatrix(this._metallicReflectanceTexture,f,"metallicReflectance")),this._reflectanceTexture&&l.REFLECTANCE&&(f.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),jn.BindTextureMatrix(this._reflectanceTexture,f,"reflectance")),this._microSurfaceTexture&&(f.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),jn.BindTextureMatrix(this._microSurfaceTexture,f,"microSurfaceSampler"))),this._bumpTexture&&u.getCaps().standardDerivatives&&tc.BumpTextureEnabled&&!this._disableBumpMap&&(f.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),jn.BindTextureMatrix(this._bumpTexture,f,"bump"),s._mirroredCameraPosition?f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&f.updateFloat("pointSize",this.pointSize),l.METALLICWORKFLOW){V.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,V.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,f.updateColor4("vReflectivityColor",V.Color3[0],1);var y=null!==(n=null===(r=this.subSurface)||void 0===r?void 0:r._indexOfRefraction)&&void 0!==n?n:1.5,b=Math.pow((y-1)/(y+1),2);this._metallicReflectanceColor.scaleToRef(b*this._metallicF0Factor,V.Color3[0]);var T=this._metallicF0Factor;f.updateColor4("vMetallicReflectanceFactors",V.Color3[0],T)}else f.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);f.updateColor3("vEmissiveColor",tc.EmissiveTextureEnabled?this._emissiveColor:B.BlackReadOnly),f.updateColor3("vReflectionColor",this._reflectionColor),!l.SS_REFRACTION&&(null===(o=this.subSurface)||void 0===o?void 0:o._linkRefractionWithTransparency)?f.updateColor4("vAlbedoColor",this._albedoColor,1):f.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,f.updateVector4("vLightingIntensity",this._lightingInfos),s.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),f.updateColor3("vAmbientColor",this._globalAmbientColor),f.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}s.texturesEnabled&&(this._albedoTexture&&tc.DiffuseTextureEnabled&&f.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&tc.AmbientTextureEnabled&&f.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&tc.OpacityTextureEnabled&&f.setTexture("opacitySampler",this._opacityTexture),p&&tc.ReflectionTextureEnabled&&(l.LODBASEDMICROSFURACE?f.setTexture("reflectionSampler",p):(f.setTexture("reflectionSampler",p._lodTextureMid||p),f.setTexture("reflectionSamplerLow",p._lodTextureLow||p),f.setTexture("reflectionSamplerHigh",p._lodTextureHigh||p)),l.USEIRRADIANCEMAP&&f.setTexture("irradianceSampler",p.irradianceTexture)),l.ENVIRONMENTBRDF&&f.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&tc.EmissiveTextureEnabled&&f.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&tc.LightmapTextureEnabled&&f.setTexture("lightmapSampler",this._lightmapTexture),tc.SpecularTextureEnabled&&(this._metallicTexture?f.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&f.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&f.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&l.REFLECTANCE&&f.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&f.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&u.getCaps().standardDerivatives&&tc.BumpTextureEnabled&&!this._disableBumpMap&&f.setTexture("bumpSampler",this._bumpTexture)),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(c),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Wn(this._activeEffect,this,s),this.bindEyePosition(c)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!d&&this.isFrozen||(s.lightsEnabled&&!this._disableLighting&&jn.BindLights(s,t,this._activeEffect,l,this._maxSimultaneousLights),(s.fogEnabled&&t.applyFog&&s.fogMode!==Ar.FOGMODE_NONE||p||this.subSurface.refractionTexture||t.receiveShadows||l.PREPASS)&&this.bindView(c),jn.BindFogParameters(s,t,this._activeEffect,!0),l.NUM_MORPH_INFLUENCERS&&jn.BindMorphTargetParameters(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),jn.BindLogDepth(l,this._activeEffect,s)),this._afterBind(t,this._activeEffect),f.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=Kn.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=Kn.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=Kn.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=Kn.MATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,X([Fe()],t.prototype,"_imageProcessingConfiguration",void 0),X([xe("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),X([Ae()],t.prototype,"useLogarithmicDepth",null),t}(oa),D_=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=B.White(),n.useOnlyMetallicFromMetallicReflectanceTexture=!1,n.ambientColor=new B(0,0,0),n.albedoColor=new B(1,1,1),n.reflectivityColor=new B(1,1,1),n.reflectionColor=new B(1,1,1),n.emissiveColor=new B(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=__(n.getScene()),n}return W(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===O_.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?O_.LIGHTFALLOFF_PHYSICAL:O_.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===O_.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?O_.LIGHTFALLOFF_GLTF:O_.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=Ve.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=Ve.Parse((function(){return new t(e.name,i)}),e,i,r);return e.stencil&&n.stencil.parse(e.stencil,i,r),Kn._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=O_.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=O_.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=O_.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=O_.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=O_.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),X([Ce(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceColor",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectanceTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),X([Re(),xe("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),X([Ce("ambient"),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),X([Ce("albedo"),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),X([Ce("reflectivity"),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),X([Ce("reflection"),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),X([Ce("emissive"),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),X([Ae()],t.prototype,"usePhysicalLightFalloff",null),X([Ae()],t.prototype,"useGLTFLightFalloff",null),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),X([Ae(),xe("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),X([Ae(),xe("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),X([xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),X([Ae(),xe("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),X([Ae(),xe("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),X([Ae(),xe("_markAllSubMeshesAsMiscDirty")],t.prototype,"applyDecalMapAfterDetailMap",void 0),t}(O_);b("BABYLON.PBRMaterial",D_);var N_=131072,F_=131072;function L_(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var w_=L_("DXT1"),B_=L_("DXT3"),U_=L_("DXT5"),V_=L_("DX10"),k_=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]&N_&&(r=Math.max(1,t[7]));var n=t[21],o=n===V_?i[32]:0,s=a.TEXTURETYPE_UNSIGNED_INT;switch(n){case 113:s=a.TEXTURETYPE_HALF_FLOAT;break;case 116:s=a.TEXTURETYPE_FLOAT;break;case V_:if(10===o){s=a.TEXTURETYPE_HALF_FLOAT;break}if(2===o){s=a.TEXTURETYPE_FLOAT;break}}return{width:t[4],height:t[3],mipmapCount:r,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:(t[20]&F_)===F_,isCube:512==(512&t[28]),isCompressed:n===w_||n===B_||n===U_,dxgiFormat:o,textureType:s}},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]);R&&(E=t._getRGBABufferInternalSizedFormat(n.textureType)),v=1,b[2]&N_&&!1!==o&&(v=Math.max(1,b[7]));for(var D=c||0,N=t.getCaps(),F=D;F0?n.sphericalPolynomial=hd.ConvertCubeMapToSphericalPolynomial({size:b[4],right:h[0],left:h[1],up:h[2],down:h[3],front:h[4],back:h[5],format:a.TEXTUREFORMAT_RGBA,type:a.TEXTURETYPE_FLOAT,gammaSpace:!1}):n.sphericalPolynomial=void 0}else $.Error("Compressed textures are not supported on this platform.");else $.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else $.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();ri.prototype.createPrefilteredCubeTexture=function(e,t,i,r,n,o,s,l,c){var u=this;return void 0===n&&(n=null),void 0===o&&(o=null),void 0===l&&(l=null),void 0===c&&(c=!0),this.createCubeTexture(e,t,null,!1,(function(e){if(e){var o=e.texture;if(c?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new td,o._source=Ot.CubePrefiltered,u.getCaps().textureLOD)n&&n(o);else{var s=u._gl,l=e.width;if(l){for(var d=[],p=0;p<3;p++){var f=1-p/2,_=r,m=h.Log2(l)*i+r,g=_+(m-_)*f,v=Math.round(Math.min(Math.max(g,0),m)),y=new jt(u,Ot.Temp);if(y.type=o.type,y.format=o.format,y.width=Math.pow(2,Math.max(h.Log2(l)-v,0)),y.height=y.width,y.isCube=!0,y._cachedWrapU=a.TEXTURE_CLAMP_ADDRESSMODE,y._cachedWrapV=a.TEXTURE_CLAMP_ADDRESSMODE,u._bindTextureDirectly(s.TEXTURE_CUBE_MAP,y,!0),y.samplingMode=a.TEXTURE_LINEAR_LINEAR,s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),e.isDDS){var b=e.info,T=e.data;u._unpackFlipY(b.isCompressed),k_.UploadDDSLevels(u,y,T,b,!0,6,v)}else $.Warn("DDS is the only prefiltered cube map supported so far.");u._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null);var E=new go(t);E._isCube=!0,E._texture=y,y.isReady=!0,d.push(E)}o._lodTextureHigh=d[2],o._lodTextureMid=d[1],o._lodTextureLow=d[0],n&&n(o)}}}else n&&n(null)}),o,s,l,c,i,r)};var G_=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),k_.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=k_.GetDDSInfo(c),t.width=n.width,t.height=n.height,i&&(n.sphericalPolynomial=new td),a=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps,o._unpackFlipY(n.isCompressed),k_.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=k_.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(){k_.UploadDDSLevels(t.getEngine(),t,e,r,n,1)}))},e}();Nn._TextureLoaders.push(new G_);var z_=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=_d(e);if(o){t.width=o.width,t.height=o.width;try{Sd(t,o),bd(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}();Nn._TextureLoaders.push(new z_);var W_,H_,X_,j_=function(){function e(t,i){if(this.data=t,this.isInvalid=!1,!e.IsValid(t))return this.isInvalid=!0,void $.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?($.Error("only compressed formats currently supported"),void(this.isInvalid=!0)):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?($.Error("only 2D textures currently supported"),void(this.isInvalid=!0)):0!==this.numberOfArrayElements?($.Error("texture arrays not currently supported"),void(this.isInvalid=!0)):this.numberOfFaces!==i?($.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}(),Y_=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 q_,e}();function J_(){var e;onmessage=function(t){if(t.data)switch(t.data.action){case"init":var i=t.data.urls;importScripts(i.jsDecoderModule),Q_(i),e=new KTX2DECODER.KTX2Decoder,postMessage({action:"init"});break;case"setDefaultDecoderOptions":KTX2DECODER.KTX2Decoder.DefaultDecoderOptions=t.data.options;break;case"decode":e.decode(t.data.data,t.data.caps,t.data.options).then((function(e){for(var t=[],i=0;i1&&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(j_.IsValid(e)){t._invertVScale=!t.invertY;var n=new j_(e,1),o=function(e){switch(e){case a.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT:return a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;case a.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:return a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;case a.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:return a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;case a.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2:return a.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2;case a.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return a.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;case a.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return a.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case a.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:return a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;case a.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:return a.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 Z_.IsValid(e)?new Z_(t.getEngine()).uploadAsync(e,t,r).then((function(){i(t.width,t.height,t.generateMipMaps,!0,(function(){}),!1)}),(function(e){$.Warn("Failed to load KTX2 texture data: ".concat(e.message)),i(0,0,!1,!1,(function(){}),!0)})):($.Error("texture missing KTX identifier"),i(0,0,!1,!1,(function(){}),!0))},e}();Nn._TextureLoaders.unshift(new $_);var em=function(e){function t(t,i,r){var n=e.call(this,t,R.Zero(),i)||this;return n._xrSessionManager=r,n._firstFrame=!1,n._referenceQuaternion=P.Identity(),n._referencedPosition=new R,n._trackingState=gc.NOT_TRACKING,n.onXRCameraInitializedObservable=new u,n.onBeforeCameraTeleport=new u,n.onAfterCameraTeleport=new u,n.onTrackingStateChanged=new u,n.compensateOnFirstFrame=!0,n._rotate180=new P(0,1,0,0),n.minZ=.1,n.rotationQuaternion=new P,n.cameraRigMode=dn.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.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 W(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:0},enumerable:!1,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new hn(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new hn(.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,P.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=O.Vector3[1];e.subtractToRef(this.position,t),t.y=0,t.normalize();var i=Math.atan2(t.x,t.z);this.rotationQuaternion.toEulerAnglesToRef(t),P.FromEulerAnglesToRef(t.x,i,t.z,this.rotationQuaternion)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._lastXRViewerPose=void 0},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?gc.TRACKING_LOST:gc.TRACKING;if(this._setTrackingState(i),this.minZ!==this._cache.minZ||this.maxZ!==this._cache.maxZ){var r={depthFar:this.maxZ||1e4,depthNear:this.minZ};this._xrSessionManager.updateRenderState(r),this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ}if(t.transform){var n=t.transform.orientation;if(void 0===t.transform.orientation.x)return;var o=t.transform.position;this._referencedPosition.set(o.x,o.y,o.z),this._referenceQuaternion.set(n.x,n.y,n.z,n.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));var o=t.transform.position,a=t.transform.orientation;n.parent=e.parent,n.position.set(o.x,o.y,o.z),n.rotationQuaternion.set(a.x,a.y,a.z,a.w),e._scene.useRightHandedSystem?n.rotationQuaternion.multiplyInPlace(e._rotate180):(n.position.z*=-1,n.rotationQuaternion.z*=-1,n.rotationQuaternion.w*=-1),I.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,n._projectionMatrix),e._scene.useRightHandedSystem||n._projectionMatrix.toggleProjectionMatrixHandInPlace(),0===i&&e._projectionMatrix.copyFrom(n._projectionMatrix);var s=e._xrSessionManager.getRenderTargetTextureForView(t);e._renderingMultiview=(null===(r=null==s?void 0:s._texture)||void 0===r?void 0:r.isMultiview)||!1,e._renderingMultiview?0==i&&(e._xrSessionManager.trySetViewportForView(e.viewport,t),e.outputRenderTarget=s):(e._xrSessionManager.trySetViewportForView(n.viewport,t),n.outputRenderTarget=s||e._xrSessionManager.getRenderTargetTextureForView(t)),n.layerMask=e.layerMask}))}else this._setTrackingState(gc.NOT_TRACKING)},t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.lengthe;){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=O.Matrix[0],i=O.Matrix[1],r=O.Matrix[2];I.ComposeToRef(t._ScaleReadOnly,this._referenceQuaternion,this._referencedPosition,e),I.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,y:this._referencedPosition.y,z:this._referencedPosition.z},{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=R.One(),t}(ll),tm=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 u,this.onStateChangedObservable=new u,this.state=mc.NOT_IN_XR,this.sessionManager=new Pc(e),this.camera=new em("webxr",e,this.sessionManager),this.featuresManager=new Yo(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(mc.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={}),j(this,void 0,void 0,(function(){var s,l,c,u=this;return Y(this,(function(h){switch(h.label){case 0:if(!this._supported)throw"WebXR not supported in this browser or environment";return this._setState(mc.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&&$.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),h.label=2;case 2:return h.trys.push([2,6,,7]),[4,this.sessionManager.initializeSessionAsync(e,r)];case 3:return h.sent(),[4,this.sessionManager.setReferenceSpaceTypeAsync(t)];case 4:return h.sent(),[4,i.initializeXRLayerAsync(this.sessionManager.session)];case 5:return s=h.sent(),l={depthFar:this.camera.maxZ||1e4,depthNear:this.camera.minZ},this.featuresManager.getEnabledFeature(jo.LAYERS)||(l.baseLayer=s),this.sessionManager.updateRenderState(l),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!==mc.EXITING_XR&&u._setState(mc.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(mc.NOT_IN_XR)})),this.sessionManager.onXRFrameObservable.addOnce((function(){u._setState(mc.IN_XR)})),[2,this.sessionManager];case 6:throw c=h.sent(),console.log(c),console.log(c.message),this._setState(mc.NOT_IN_XR),c;case 7:return[2]}}))}))},e.prototype.exitXRAsync=function(){return this.state!==mc.IN_XR?Promise.resolve():(this._setState(mc.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===mc.IN_XR?(t._spectatorCamera=new Al("webxr-spectator",R.Zero(),t._scene),t._spectatorCamera.rotationQuaternion=new P,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===mc.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}(),im=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 u,this.onButtonStateChangedObservable=new u}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}(),rm=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 im(e,i,r,n)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new u,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 j(this,void 0,void 0,(function(){var e,t,i=this;return Y(this,(function(r){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?$.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)}na.ImportMesh("",t.path,t.filename,i.scene,(function(e){i._controllerCache&&i._controllerCache.push(H(H({},t),{meshes:e})),o(e)}),null,(function(e,r){$.Log(r),$.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;P.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,r,e.valueMesh.rotationQuaternion),R.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 io(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.parent||(e.isPickable=!1,e.setParent(t.rootMesh))})),this.rootMesh.rotationQuaternion=P.FromEulerAngles(0,Math.PI,0)},e}(),nm=function(e){function t(i,r,n){var o=e.call(this,i,om[n],r,n)||this;return o.profileId=t.ProfileId,o}return W(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 io(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.isPickable=!1,e.parent||e.setParent(t.rootMesh)})),this.rootMesh.rotationQuaternion=P.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(rm),om={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"}},am=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 W(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=na.IsPluginForExtensionAvailable(".glb");return e||$.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===im.TOUCHPAD_TYPE&&i.touchPointNodeName?i.touchPointNodeName:n.valueNodeName;if(t._buttonMeshMapping[e].states[r]={valueMesh:t._getChildByName(t.rootMesh,o)},i.type===im.TOUCHPAD_TYPE&&!t._touchDots[r]){var a=gu(r+"dot",{diameter:.0015,segments:8},t.scene);a.material=new _c(r+"mat",t.scene),a.material.diffuseColor=B.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 io(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;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)):!o||t._options.enablePointerSelectionOnAllControllers||t._options.disableSwitchOnClick||(t._attachedController=e.uniqueId)}}))};e.motionController?n(e.motionController):e.onMotionControllerInitObservable.add(n)}else{var o=function(e){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._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(R.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=jo.POINTER_SELECTION,t.Version=1,t}(Ko);Yo.AddWebXRFeature(fm.Name,(function(e,t){return function(){return new fm(e,t)}}),fm.Version,!0),xn.prototype._projectOnTrianglesToRef=function(e,t,i,r,n,o){for(var a=O.Vector3[0],s=O.Vector3[1],l=1/0,c=this.indexStart;ce.currentAnimationState)switch(e.currentAnimationState){case cm.DEHYDRATED:if(e.hydrateCollisionMeshFunction(!0),t===cm.HOVER)break;case cm.HOVER:if(e.touchCollisionMeshFunction(!0),t===cm.TOUCH)break}else switch(e.currentAnimationState){case cm.TOUCH:if(e.touchCollisionMeshFunction(!1),t===cm.HOVER)break;case cm.HOVER:if(e.hydrateCollisionMeshFunction(!1),t===cm.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(O.Vector3[0]),n.grabRay.direction.copyFrom(O.Vector3[0]),this._options.nearInteractionControllerMode!==um.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,n.touchCollisionMesh.position.copyFrom(n.grabRay.origin)},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;O.Vector3[0].set(s.transform.position.x,s.transform.position.y,s.transform.position.z*l),O.Quaternion[0].set(s.transform.orientation.x,s.transform.orientation.y,s.transform.orientation.z*l,s.transform.orientation.w*l),t._processTouchPoint(i,O.Vector3[0],O.Quaternion[0])}}}else if(n.xrController.inputSource.gamepad&&t._options.nearInteractionControllerMode!==um.DISABLED){var c=n.xrController.pointer;n.xrController.grip&&t._options.nearInteractionControllerMode===um.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,u.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"}(mm||(mm={}));var Tm=function(){function e(e){var t,i,r=this;this.onEachCountObservable=new u,this.onTimerAbortedObservable=new u,this.onTimerEndedObservable=new u,this.onStateChangedObservable=new u,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(mm.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===mm.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(mm.STARTED)},e.prototype.stop=function(){this._state===mm.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(mm.ENDED),t?this.onTimerAbortedObservable.notifyObservers(e):this.onTimerEndedObservable.notifyObservers(e)},e}(),Em=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 U(1,1,1,1),r._tmpRay=new Fo(new R,new R),r._tmpVector=new R,r._tmpQuaternion=new P,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 u,r.teleportationEnabled=!0,r._rotationEnabled=!0,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}};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(im.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(im.TOUCHPAD_TYPE);if(!i||r._options.useMainComponentOnly){var n=e.motionController.getMainComponent();if(!n)return;t.teleportationComponent=n,t.onButtonChangedObserver=n.onButtonStateChangedObservable.add((function(){r.teleportationEnabled&&n.changes.pressed&&(n.changes.pressed.current?(t.teleportationState.forward=!0,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,bm({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)}})):(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,P.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);P.FromEulerAngles(0,o,0).multiplyToRef(r._options.xrInput.xrCamera.rotationQuaternion,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 r._xrSessionManager.scene.onPointerObservable.add((function(i){i.type===er.POINTERDOWN?(t.teleportationState.forward=!0,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,bm({timeout:r._options.timeToTeleport||3e3,contextObservable:r._xrSessionManager.onXRFrameObservable,onEnded:function(){r._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&r._teleportForward(e.uniqueId)}})):i.type===er.POINTERUP&&(t.teleportationState.forward=!1,r._currentTeleportationControllerId="")}))}},r._options.teleportationTargetMesh||r._createDefaultTargetMesh(),r._floorMeshes=r._options.floorMeshes||[],r._snapToPositions=r._options.snapPositions||[],r._blockedRayColor=r._options.blockedRayColor||new U(1,0,0,.75),r._setTargetMeshVisibility(!1),r}return W(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)},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=p.video.HAVE_CURRENT_DATA;return!p._settings.poster||p._settings.autoPlay&&f?f&&p._createInternalTexture():(p._texture=p._getEngine().createTexture(p._settings.poster,!1,!p.invertY,r),p._displayingPosterTexture=!0),p}return W(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new u),this._onUserActionRequestedObservable},enumerable:!1,configurable:!0}),t.prototype._processError=function(e){this._errorFound=!0,this._onError?this._onError(null==e?void 0:e.message):$.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 $.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 Ri.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(Ri.SetCorsBehavior(e,t),t.src=e):(Ri.SetCorsBehavior(e[0],t),e.forEach((function(e){var i=document.createElement("source");i.src=e,t.appendChild(i)}))),this.onDisposeObservable.addOnce((function(){Rm(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("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 s=new t("video",o,e,!0,n,void 0,void 0,void 0,a.TEXTUREFORMAT_RGB);e.getEngine()._badOS&&s.onDisposeObservable.addOnce((function(){o.remove()})),s.onDisposeObservable.addOnce((function(){Rm(o)})),i(s),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),j(this,void 0,void 0,(function(){var n,o;return Y(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){$.Error(e.name)}))},X([Ae("settings")],t.prototype,"_settings",void 0),X([Ae("src")],t.prototype,"_currentSrc",void 0),X([Ae()],t.prototype,"isVideo",void 0),t}(Eo);Eo._CreateVideoTexture=function(e,t,i,r,n,o,s,l,c){return void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=Eo.TRILINEAR_SAMPLINGMODE),void 0===s&&(s={}),void 0===c&&(c=a.TEXTUREFORMAT_RGBA),new Cm(e,t,i,r,n,o,s,l,c)},b("BABYLON.VideoTexture",Cm);var Pm=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(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 Cm((this.name||"videoDome")+"_texture",e,t,i.generateMipMaps,this._useDirectMapping,Eo.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()}),er.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=d_.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=d_.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=d_.MODE_SIDEBYSIDE,t}(d_),Im=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new vr,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}(),Mm=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new vr,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new vr,this._captureFrameTime=!1,this._frameTime=new vr,this._captureRenderTime=!1,this._renderTime=new vr,this._captureInterFrameTime=!1,this._interFrameTime=new vr,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new vr,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new vr,this._capturePhysicsTime=!1,this._physicsTime=new vr,this._captureAnimationsTime=!1,this._animationsTime=new vr,this._captureCameraRenderTime=!1,this._cameraRenderTime=new vr,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&&(Ri.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&&(Ri.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(){Ri.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Ri.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(){Ri.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Ri.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(){Ri.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Ri.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(){Ri.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Ri.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(){Ri.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Ri.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(),Ri.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Ri.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(),Ri.StartPerformanceCounter("Rendering camera ".concat(e.name))})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Ri.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}();kt.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 Om=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 U},this._effectIntensity={},this.neutralColor=new U,this.isEnabled=!0,this.disableBoundingBoxesFromEffectLayer=!1,this.onDisposeObservable=new u,this.onBeforeRenderMainTextureObservable=new u,this.onBeforeComposeObservable=new u,this.onBeforeRenderMeshToEffect=new u,this.onAfterRenderMeshToEffect=new u,this.onAfterComposeObservable=new u,this.onSizeChangedObservable=new u,this._materialForRendering={},this.name=t,this._scene=i||S.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(ji.MatricesIndicesExtraKind),c.push(ji.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&&v.numInfluencers>0&&(l.push("#define MORPHTARGETS"),y=v.numInfluencers,l.push("#define NUM_MORPH_INFLUENCERS "+y),v.isUsingTextureForTargets&&l.push("#define MORPHTARGETS_TEXTURE"),jn.PrepareAttributesForMorphTargetsInfluencers(c,o,y)),t&&(l.push("#define INSTANCES"),jn.PushAttributesForInstances(c),e.getRenderingMesh().hasThinInstances&&l.push("#define THIN_INSTANCES")),Gn(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","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","glowIntensity"];kn(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 Ri.Instantiate(e.customType).Parse(e,t,i)},e._SceneComponentInitialization=function(e){throw ve("EffectLayerSceneComponent")},X([Ae()],e.prototype,"name",void 0),X([Ne()],e.prototype,"neutralColor",void 0),X([Ae()],e.prototype,"isEnabled",void 0),X([Be()],e.prototype,"camera",null),X([Ae()],e.prototype,"renderingGroupId",null),X([Ae()],e.prototype,"disableBoundingBoxesFromEffectLayer",void 0),e}();o.AddParser(Ji.NAME_EFFECTLAYER,(function(e,t,i,r){if(e.effectLayers){i.effectLayers||(i.effectLayers=new Array);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=Ve.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&&0!=(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}();kt.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}";kt.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 Bm=function(){function e(e,t,i,r,n){this.name=e,this._applyPostProcess=!0,this.scale=new A(1,1),this.offset=new A(0,0),this.alphaBlendingMode=a.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this.isEnabled=!0,this._vertexBuffers={},this.onDisposeObservable=new u,this.onBeforeRenderObservable=new u,this.onAfterRenderObservable=new u,this.texture=t?new Eo(t,i,!0):null,this.isBackground=void 0===r||r,this.color=void 0===n?new U(1,1,1,1):n,this._scene=i||S.LastCreatedScene;var o=this._scene._getComponent(Ji.NAME_LAYER);o||(o=new wm(this._scene),this._scene._addComponent(o)),this._scene.layers.push(this);var s=this._scene.getEngine();this._drawWrapper=new ei(s);var l=[];l.push(1,1),l.push(-1,1),l.push(-1,-1),l.push(1,-1);var c=new ji(s,l,ji.PositionKind,!1,!1,2);this._vertexBuffers[ji.PositionKind]=c,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[ji.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",[ji.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(Kn.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(Kn.TriangleFillMode,0,6),e.setAlphaMode(a.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}}},e.prototype.dispose=function(){var e=this._vertexBuffers[ji.PositionKind];e&&(e.dispose(),this._vertexBuffers[ji.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}(),Um=function(){function e(e,t,i,r,n){this.size=e,this.position=t,this.alphaMode=a.ALPHA_ONEONE,this.color=i||new B(1,1,1),this.texture=r?new Eo(r,n.getScene(),!0):null,this._system=n;var o=n.scene.getEngine();this._drawWrapper=new ei(o),this._drawWrapper.effect=o.createEffect("lensFlare",[ji.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}();kt.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}";kt.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 Vm=function(){function e(t,i,r){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=r||S.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&&0!=(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[ji.PositionKind]=new ji(n,o,ji.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=R.Project(t,I.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=R.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 Fo(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-h.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 s=r.x+r.width/2,l=r.y+r.height/2,c=s-this._positionX,u=l-this._positionY;i.setState(!1),i.setDepthBuffer(!1);for(var d=0;d0);for(var i=0,r=t;i0)}},e}();Vm._SceneComponentInitialization=function(e){var t=e._getComponent(Ji.NAME_LENSFLARESYSTEM);t||(t=new km(e),e._addComponent(t))};kt.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";kt.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";kt.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;";kt.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}";kt.IncludesShadersStore.sceneVertexDeclaration="uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;\n";kt.IncludesShadersStore.meshVertexDeclaration="uniform mat4 world;uniform float visibility;\n";kt.IncludesShadersStore.shadowMapVertexDeclaration="#include\n#include\n";kt.IncludesShadersStore.shadowMapUboDeclaration="layout(std140,column_major) uniform;\n#include\n#include\n";kt.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";kt.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";kt.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";kt.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}";kt.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)));}";kt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow="#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";var Gm=function(){function e(t,i,r,n,o){this.onBeforeShadowMapRenderObservable=new u,this.onAfterShadowMapRenderObservable=new u,this.onBeforeShadowMapRenderMeshObservable=new u,this.onAfterShadowMapRenderMeshObservable=new u,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=R.Zero(),this._viewMatrix=I.Zero(),this._projectionMatrix=I.Zero(),this._transformMatrix=I.Zero(),this._cachedPosition=new R(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new R(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=I.Identity(),this._mapSize=t,this._light=i,this._scene=i.getScene(),this._camera=null!=n?n:null,this._useRedTextureType=!!o;var s=i._shadowGenerators;s||(s=i._shadowGenerators=new Map),s.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 l=this._scene.getEngine().getCaps();r?l.textureFloatRender&&l.textureFloatLinearFiltering?this._textureType=a.TEXTURETYPE_FLOAT:l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering?this._textureType=a.TEXTURETYPE_HALF_FLOAT:this._textureType=a.TEXTURETYPE_UNSIGNED_INT:l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering?this._textureType=a.TEXTURETYPE_HALF_FLOAT:l.textureFloatRender&&l.textureFloatLinearFiltering?this._textureType=a.TEXTURETYPE_FLOAT:this._textureType=a.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!==a.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(ji.NormalKind)?"1":"0")),i.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===no.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=[ji.PositionKind],d=t.getMesh();this.normalBias&&d.isVerticesDataPresent(ji.NormalKind)&&(h.push(ji.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(ji.UVKind)&&(h.push(ji.UVKind),s.push("#define UV1")),d.isVerticesDataPresent(ji.UV2Kind)&&1===this._opacityTexture.coordinatesIndex&&(h.push(ji.UV2Kind),s.push("#define UV2"))}var _=new Ma;if(d.useBones&&d.computeBonesUsingShaders&&d.skeleton){h.push(ji.MatricesIndicesKind),h.push(ji.MatricesWeightsKind),d.numBoneInfluencers>4&&(h.push(ji.MatricesIndicesExtraKind),h.push(ji.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&&g.numInfluencers>0&&(s.push("#define MORPHTARGETS"),v=g.numInfluencers,s.push("#define NUM_MORPH_INFLUENCERS "+v),g.isUsingTextureForTargets&&s.push("#define MORPHTARGETS_TEXTURE"),jn.PrepareAttributesForMorphTargetsInfluencers(h,d,v)),Gn(o,this._scene,s),i&&(s.push("#define INSTANCES"),jn.PushAttributesForInstances(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(ji.MatricesIndicesExtraKind),c.push(ji.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&&h.numInfluencers>0&&(d=h.numInfluencers,l.push("#define MORPHTARGETS"),l.push("#define NUM_MORPH_INFLUENCERS "+d),h.isUsingTextureForTargets&&l.push("#define MORPHTARGETS_TEXTURE"),jn.PrepareAttributesForMorphTargetsInfluencers(c,n,d)),t&&(l.push("#define INSTANCES"),jn.PushAttributesForInstances(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"),Gn(s,o,l);var p=e._getDrawWrapper(void 0,!0),f=p.defines,_=l.join("\n");if(f!==_){var m=["world","mBones","boneTextureWidth","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"];kn(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||c>1;){l=Math.max(Math.round(l/2),1),c=Math.max(Math.round(c/2),1);var h=new Na("Reduction phase "+u,"minmaxRedux",["texSize"],null,{width:l,height:c},null,a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define "+(1==l&&1==c?"LAST":1==l||1==c?"ONEBEFORELAST":"MAIN"),i,void 0,void 0,void 0,a.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)}}(l,c),this._reductionSteps.push(h),u++,1==l&&1==c&&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)}}(l,c,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 R(-1,-1,-1),new R(1,-1,-1),new R(-1,1,-1),new R(1,1,-1)],e.FACE_RIGHT=[new R(1,-1,1),new R(-1,-1,1),new R(1,1,1),new R(-1,1,1)],e.FACE_FRONT=[new R(1,-1,-1),new R(1,-1,1),new R(1,1,-1),new R(1,1,1)],e.FACE_BACK=[new R(-1,-1,1),new R(-1,-1,-1),new R(-1,1,1),new R(-1,1,-1)],e.FACE_DOWN=[new R(1,1,-1),new R(1,1,1),new R(-1,1,-1),new R(-1,1,1)],e.FACE_UP=[new R(-1,-1,-1),new R(-1,-1,1),new R(1,-1,-1),new R(1,-1,1)],e}(),tg=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 eg.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 v=255/g;f*=v,_*=v,m*=v}l[3*p+0]=f,l[3*p+1]=_,l[3*p+2]=m}c?s.push(c):l?s.push(l):s.push(h)}return s}),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===a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=a.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(a.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=R.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(n.boundingBoxSize=R.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}(go);b("BABYLON.HDRCubeTexture",rg);var ng=function(){function e(e,t,i){void 0===t&&(t=0),void 0===i&&(i=null),this.name=e,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new u,this._onDataLayoutChanged=new u,this._animationPropertiesOverride=null,this._scene=i||S.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=Ve.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())),Ve.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,"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.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 $.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;ce&&(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,s=0;s-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 $.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 Qo.HingeJoint:case Qo.Hinge2Joint:r=new this.BJSCANNON.HingeConstraint(t,i,o);break;case Qo.DistanceJoint:r=new this.BJSCANNON.DistanceConstraint(t,i,n.maxDistance||2);break;case Qo.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 Qo.LockJoint:r=new this.BJSCANNON.LockConstraint(t,i,o);break;case Qo.PointToPointJoint:case Qo.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!==Qo.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!==Qo.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}();lg.DefaultPluginFactory=function(){return new cg};var ug=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=R.Zero(),this.BJSOIMO=i,this.world=new this.BJSOIMO.World({iterations:t}),this.world.clear(),this._raycastResult=new sg}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){$.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,_)},o=new P;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 ta.ParticleImpostor:$.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case ta.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 ta.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 ta.PlaneImpostor:case ta.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 Qo.BallAndSocketJoint:r="jointBall";break;case Qo.SpringJoint:$.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 Qo.DistanceJoint:r="jointDistance",a.max=n.maxDistance;break;case Qo.PrismaticJoint:r="jointPrisme";break;case Qo.SliderJoint:r="jointSlide";break;case Qo.WheelJoint:r="jointWheel";break;case Qo.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){$.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 R(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new R(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?$.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 $.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){$.Warn("raycast is not currently supported by the Oimo physics plugin"),i.reset(e,t)},e}(),hg=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 P,this._tmpContactCallbackResult=!1,this._tmpContactPoint=new R,this._tmpContactNormal=new R,this._tmpVec3=new R,this._tmpMatrix=new I,"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 sg,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)):$.Error("AmmoJS is not available. Please make sure you included the js file.")):$.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(ji.PositionKind);a||(a=[]),i.computeWorldMatrix(!1);for(var s=o.length/3,l=0;l0){if(e.type!=ta.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 ta.SphereImpostor:if(h.WithinEpsilon(o.x,o.y,1e-4)&&h.WithinEpsilon(o.x,o.z,1e-4))r=new this.bjsAMMO.btSphereShape(o.x/2);else{var c=[new this.bjsAMMO.btVector3(0,0,0)];(r=new this.bjsAMMO.btMultiSphereShape(c,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x/2,o.y/2,o.z/2))}break;case ta.CapsuleImpostor:var u=o.x/2;r=new this.bjsAMMO.btCapsuleShape(u,o.y-2*u);break;case ta.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case ta.PlaneImpostor:case ta.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case ta.MeshImpostor:if(0==e.getParam("mass")){if(this.onCreateCustomMeshImpostor)r=this.onCreateCustomMeshImpostor(e);else{var d=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(d);var p=this._addMeshVerts(d,n,n);r=0==p?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(d)}break}case ta.ConvexHullImpostor:if(this.onCreateCustomConvexHullImpostor)r=this.onCreateCustomConvexHullImpostor(e);else{var f=new this.bjsAMMO.btConvexHullShape;0==(p=this._addHullVerts(f,n,n))?(e._pluginData.toDispose.push(f),r=new this.bjsAMMO.btCompoundShape):r=f}break;case ta.NoImpostor:r=new this.bjsAMMO.btSphereShape(o.x/2);break;case ta.CustomImpostor:r=this._createCustom(e);break;case ta.SoftbodyImpostor:r=this._createSoftbody(e);break;case ta.ClothImpostor:r=this._createCloth(e);break;case ta.RopeImpostor:r=this._createRope(e);break;default:$.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)>_||Math.abs(r.getOrigin().y()-t.y)>_||Math.abs(r.getOrigin().z()-t.z)>_||Math.abs(r.getRotation().x()-i.x)>_||Math.abs(r.getRotation().y()-i.y)>_||Math.abs(r.getRotation().z()-i.z)>_||Math.abs(r.getRotation().w()-i.w)>_)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 R(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 R(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:($.Warn("Pressure is not a property of a rigid body"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===ta.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):$.Warn("Pressure can only be applied to a softbody")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:($.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):$.Warn("Stiffness cannot be applied to a rigid body")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:($.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):$.Warn("Velocity iterations cannot be applied to a rigid body")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:($.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):$.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(){$.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(){$.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._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._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}();o.prototype.removeReflectionProbe=function(e){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(e);return-1!==t&&this.reflectionProbes.splice(t,1),t},o.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var dg=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 s=this;if(this.name=e,this._viewMatrix=I.Identity(),this._target=R.Zero(),this._add=R.Zero(),this._invertYAxis=!1,this.position=R.Zero(),this.metadata=null,this._parentContainer=null,this._scene=i,i.getEngine().supportsUniformBuffers){this._sceneUBOs=[];for(var l=0;l<6;++l)this._sceneUBOs.push(i.createSceneUniformBuffer('Scene for Reflection Probe (name "'.concat(e,'") face #').concat(l)))}this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this);var c=a.TEXTURETYPE_UNSIGNED_BYTE;if(n){var u=this._scene.getEngine().getCaps();u.textureHalfFloatRender?c=a.TEXTURETYPE_HALF_FLOAT:u.textureFloatRender&&(c=a.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new ns(e,t,i,r,!0,c,!0),this._renderTargetTexture.gammaSpace=!o,this._renderTargetTexture.invertZ=i.useRightHandedSystem;var h,d=i.getEngine().useReverseDepthBuffer;this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(s._sceneUBOs&&(i.setSceneUniformBuffer(s._sceneUBOs[e]),i.getSceneUniformBuffer().unbindEffect()),e){case 0:s._add.copyFromFloats(1,0,0);break;case 1:s._add.copyFromFloats(-1,0,0);break;case 2:s._add.copyFromFloats(0,s._invertYAxis?1:-1,0);break;case 3:s._add.copyFromFloats(0,s._invertYAxis?-1:1,0);break;case 4:s._add.copyFromFloats(0,0,i.useRightHandedSystem?-1:1);break;case 5:s._add.copyFromFloats(0,0,i.useRightHandedSystem?1:-1)}s._attachedMesh&&s.position.copyFrom(s._attachedMesh.getAbsolutePosition()),s.position.addToRef(s._add,s._target);var t=i.useRightHandedSystem?I.LookAtRHToRef:I.LookAtLHToRef,r=i.useRightHandedSystem?I.PerspectiveFovRH:I.PerspectiveFovLH;t(s.position,s._target,R.Up(),s._viewMatrix),i.activeCamera&&(s._projectionMatrix=r(Math.PI/2,1,d?i.activeCamera.maxZ:i.activeCamera.minZ,d?i.activeCamera.minZ:i.activeCamera.maxZ,s._scene.getEngine().isNDCHalfZRange),i.setTransformMatrix(s._viewMatrix,s._projectionMatrix),i.activeCamera.isRigCamera&&!s._renderTargetTexture.activeCamera&&(s._renderTargetTexture.activeCamera=i.activeCamera.rigParent||null)),i._forcedViewPosition=s.position})),this._renderTargetTexture.onBeforeBindObservable.add((function(){var t,r;s._currentSceneUBO=i.getSceneUniformBuffer(),null===(r=(t=i.getEngine())._debugPushGroup)||void 0===r||r.call(t,"reflection probe generation for ".concat(e),1),h=s._scene.imageProcessingConfiguration.applyByPostProcess,o&&(i.imageProcessingConfiguration.applyByPostProcess=!0)})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){var e,t;i.imageProcessingConfiguration.applyByPostProcess=h,i._forcedViewPosition=null,s._sceneUBOs&&i.setSceneUniformBuffer(s._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;i0){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 Ri.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},bg=function(e,t,i){if("number"!=typeof e){var r=i.getLastEntryById(e);return r&&null!=t?r.instances[parseInt(t)]:r}var n=_g[e];return n&&null!=t?n.instances[parseInt(t)]:n},Tg=function(e,t){return"number"!=typeof e?t.getLastMaterialById(e,!0):mg[e]},Eg=function(e,t,i,r,n){void 0===n&&(n=!1);var a=new so(e),s="importScene has failed JSON parse";try{var l=JSON.parse(t);s="";var c=na.loggingLevel===na.DETAILED_LOGGING,u=void 0,h=void 0;if(void 0!==l.environmentTexture&&null!==l.environmentTexture){var d=void 0===l.isPBR||l.isPBR;if(l.environmentTextureType&&"BABYLON.HDRCubeTexture"===l.environmentTextureType){var p=l.environmentTextureSize?l.environmentTextureSize:128,f=new rg((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,p,!0,!d,void 0,l.environmentTexturePrefilterOnLoad);l.environmentTextureRotationY&&(f.rotationY=l.environmentTextureRotationY),e.environmentTexture=f}else if("object"==typeof l.environmentTexture){var _=l_.Parse(l.environmentTexture,e,i);e.environmentTexture=_}else if(l.environmentTexture.endsWith(".env")){var m=new l_((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,l.environmentTextureForcedExtension);l.environmentTextureRotationY&&(m.rotationY=l.environmentTextureRotationY),e.environmentTexture=m}else{var g=l_.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,l.environmentTextureForcedExtension);l.environmentTextureRotationY&&(g.rotationY=l.environmentTextureRotationY),e.environmentTexture=g}if(!0===l.createDefaultSkybox){var v=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,y=l.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,d,v,y)}a.environmentTexture=e.environmentTexture}if(void 0!==l.environmentIntensity&&null!==l.environmentIntensity&&(e.environmentIntensity=l.environmentIntensity),void 0!==l.lights&&null!==l.lights)for(u=0,h=l.lights.length;u0){for(var ne=0;ne0){for(var ae=0;ae-1))for(var R=0,C=h.skeletons.length;R-1&&void 0!==h.morphTargetManagers&&null!==h.morphTargetManagers&&!(S.indexOf(a.morphTargetManagerId)>-1))for(var M=0,O=h.morphTargetManagers.length;M-1&&_.splice(I,1)}C._waitingParentId=null}C._waitingData.lods&&yg(t,C)}for(var M=0,O=_;M0&&(_+1)%4==0)s[_]=255;else{var T=l[_];s[_]=T/f*255}e.is3D?(e.updateSize(u,u,u),r.updateRawTexture3D(e,s,a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(u*u,u),r.updateRawTexture(e,s,a.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===a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=a.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}(go);b("BABYLON.ColorGradingTexture",Pg);var Ig=function(e){function t(t,i,r,n,o,s,l,c){void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=!1);var u=e.call(this,i)||this;if(u._onLoad=null,u._onError=null,!t)throw new Error("Image url is not set");return u._coordinatesMode=Eo.CUBIC_MODE,u.name=t,u.url=t,u._size=r,u._supersample=c,u._noMipmap=n,u.gammaSpace=o,u._onLoad=s,u._onError=l,u.hasAlpha=!1,u.isCube=!0,u._texture=u._getFromCache(t,u._noMipmap,void 0,void 0,void 0,u.isCube),u._texture?s&&(u._texture.isReady?Ri.SetImmediate((function(){return s()})):u._texture.onLoadedObservable.add(s)):i.useDelayedTextureLoading?u.delayLoadState=a.DELAYLOADSTATE_NOTLOADED:u._loadImage((function(){return u._loadTexture()}),u._onError),u}return W(t,e),t.prototype._loadImage=function(e,t){var i=this,r=this.getScene();if(r){var n=r.getEngine().createRawCubeTexture(null,this._size,a.TEXTUREFORMAT_RGB,r.getEngine().getCaps().textureFloat?a.TEXTURETYPE_FLOAT:a.TEXTURETYPE_UNSIGNED_INTEGER,this._noMipmap,!1,a.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");di(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=eg.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)$.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 Fg:o=!0;case Og:a=!0;break;case Lg:o=!0;case Dg:break;case wg:o=!0;case Ng: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>Ug){default:case Gg:c=0,h=1,f=r.width,u=0,d=1,p=r.height;break;case Vg:c=0,h=1,f=r.width,u=r.height-1,d=-1,p=-1;break;case zg:c=r.width-1,h=-1,f=-1,u=0,d=1,p=r.height;break;case kg: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=Xg[E](r,l,n,u,d,p,c,h,f);e.getEngine()._uploadDataToTextureDirectly(e,S)}}}var Xg={GetTGAHeader:Wg,UploadContent:Hg,_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 _}},jg=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=Wg(r);i(n.width,n.height,t.generateMipMaps,!1,(function(){Hg(t,r)}))},e}();Nn._TextureLoaders.push(new jg);var Yg=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=tg.RGBE_ReadHeader(r),o=tg.RGBE_ReadPixels(r,n),s=n.width*n.height,l=new Float32Array(4*s),c=0;c1;var s=nv.GetInternalFormatFromBasisFormat(t.format,i);e.format=s,iv(e,i),t.fileInfo.images[r].levels.forEach((function(t,n){i._uploadCompressedDataToTextureDirectly(e,s,t.width,t.height,t.transcodedPixels,r,n)})),!i._features.basisNeedsPOT||h.Log2(e.width)%1==0&&h.Log2(e.height)%1==0||(Ri.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=Eo.CLAMP_ADDRESSMODE,e._cachedWrapV=Eo.CLAMP_ADDRESSMODE)}},n=0;n>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(!e){try{importScripts(i.data.url)}catch(e){postMessage({action:"error",error: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&&t.generateMipMaps;rv(t,e),t.getEngine()._setCubeMapTextureParams(t,i),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()})).catch((function(e){Ri.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}};tv(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(){rv(t,e)}))})).catch((function(e){Ri.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),Ri.Warn("Failed to transcode Basis file: ".concat(e)),i(0,0,!1,!1,(function(){}),!0)}))},e}();Nn._TextureLoaders.push(new av);var sv=function(e){function t(t,i,r,n,o,s){var l=this,c=!(!o||!o.generateMipMaps)&&o.generateMipMaps,u=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,h=o&&o.depthTextureFormat?o.depthTextureFormat:a.TEXTUREFORMAT_DEPTH16,d=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio,p=!(!o||!o.drawOnlyOnFirstAttachmentByDefault)&&o.drawOnlyOnFirstAttachmentByDefault;if(!(l=e.call(this,t,i,n,c,d,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0)||this).isSupported)return l.dispose(),l;l._textureNames=s;var f=[],_=[],m=[],g=[],v=[],y=[],b=[],T=[];l._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 l._multiRenderTargetOptions={samplingModes:_,generateMipMaps:c,generateDepthBuffer:E,generateStencilBuffer:S,generateDepthTexture:u,depthTextureFormat:h,types:f,textureCount:r,useSRGBBuffers:m,formats:g,targetTypes:v,faceIndex:y,layerIndex:b,layerCounts:T},l._count=r,l._drawOnlyOnFirstAttachmentByDefault=p,r>0&&(l._createInternalTextures(),l._createTextures(s)),l}return W(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}(ns),lv=function(e,t,i){this.id=e,this.scale=t,this.offset=i},cv=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:ji.UVKind,this.options.uvsOut=null!==(s=this.options.uvsOut)&&void 0!==s?s:ji.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 U(0,0,0,1)),this.sets={},this.frames=[],this}return e.prototype._createFrames=function(e){for(var t=this,i=this._calculateSize(),r=new A(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){$.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&&(jn.BindMorphTargetParameters(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="";(null==f?void 0:f.isUsingTextureForTargets)&&p>0&&(v+="float vertexID;\n");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+=this._declareOutput(this.output,t)+" = 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},X([_a("Invert X axis",pa.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertX",void 0),X([_a("Invert Y axis",pa.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertY",void 0),X([_a("Use parallax occlusion",pa.Boolean)],t.prototype,"useParallaxOcclusion",void 0),X([_a("Object Space Mode",pa.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"useObjectSpaceNormalMap",void 0),t}(ha);b("BABYLON.PerturbNormalBlock",Sv);var xv=function(e){function t(t){var i=e.call(this,t,ra.Fragment,!0)||this;return i.registerInput("value",ia.Float,!0),i.registerInput("cutoff",ia.Float,!0),i}return W(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}(ha);b("BABYLON.DiscardBlock",xv);var Av=function(e){function t(t){var i=e.call(this,t,ra.Fragment)||this;return i.registerOutput("output",ia.Float,ra.Fragment),i}return W(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===ra.Vertex)throw"FrontFacingBlock must only be used in a fragment shader";var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = gl_FrontFacing ? 1.0 : 0.0;\n",this},t}(ha);b("BABYLON.FrontFacingBlock",Av);var Rv=function(e){function t(t){var i=e.call(this,t,ra.Fragment)||this;return i.registerInput("input",ia.AutoDetect,!1),i.registerOutput("dx",ia.BasedOnInput),i.registerOutput("dy",ia.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._outputs[1]._typeConnectionSource=i._inputs[0],i}return W(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];return t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),i.hasEndpoints&&(t.compilationString+=this._declareOutput(i,t)+" = dFdx(".concat(this.input.associatedVariableName,");\n")),r.hasEndpoints&&(t.compilationString+=this._declareOutput(r,t)+" = dFdy(".concat(this.input.associatedVariableName,");\n")),this},t}(ha);b("BABYLON.DerivativeBlock",Rv);var Cv=function(e){function t(t){var i=e.call(this,t,ra.Fragment)||this;return i.registerOutput("xy",ia.Vector2,ra.Fragment),i.registerOutput("xyz",ia.Vector3,ra.Fragment),i.registerOutput("xyzw",ia.Vector4,ra.Fragment),i.registerOutput("x",ia.Float,ra.Fragment),i.registerOutput("y",ia.Float,ra.Fragment),i.registerOutput("z",ia.Float,ra.Fragment),i.registerOutput("w",ia.Float,ra.Fragment),i}return W(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;jn.PrepareUniformsAndSamplersForLight(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?jn.BindLight(this.light,this._lightId,r,e,!0):jn.BindLights(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,"vec4")&&(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===ra.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",replaceStrings:[{search:/vPositionW/g,replace:n+".xyz"}]}),0===this._lightId&&(t.compilationString+="aggShadow = aggShadow / numLights;\n");var o=this.diffuseOutput,a=this.specularOutput;return t.compilationString+=this._declareOutput(o,t)+" = diffuseBase".concat(this.diffuseColor.isConnected?" * "+this.diffuseColor.associatedVariableName:"",";\n"),a.hasEndpoints&&(t.compilationString+=this._declareOutput(a,t)+" = specularBase".concat(this.specularColor.isConnected?" * "+this.specularColor.associatedVariableName:"",";\n")),this.shadow.hasEndpoints&&(t.compilationString+=this._declareOutput(this.shadow,t)+" = 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()},X([_a("Generate only fragment code",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0,update:!0,onValidation:t._OnGenerateOnlyFragmentCodeChanged}})],t.prototype,"generateOnlyFragmentCode",void 0),t}(ha);b("BABYLON.LightBlock",wv);var Bv=function(e){function t(i){var r=e.call(this,i,ra.VertexAndFragment)||this;return r.registerOutput("source",ia.Object,ra.VertexAndFragment,new mv("source",r,sa.Output,t,"ImageSourceBlock")),r}return W(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:S.LastCreatedScene;!e&&r&&r.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i._texture)})),this._texture=e,e&&r&&r.markAllMaterialsAsDirty(a.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===ra.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){e.prototype._deserialize.call(this,t,i,r),t.texture&&!hs.IgnoreTexturesAtLoadTime&&void 0!==t.texture.url&&(r=0===t.texture.url.indexOf("data:")?"":r,this.texture=Eo.Parse(t.texture,i,r))},t}(ha);b("BABYLON.ImageSourceBlock",Bv);var Uv=function(e){function t(t,i){void 0===i&&(i=!1);var r=e.call(this,t,i?ra.Fragment:ra.VertexAndFragment)||this;return r._convertToGammaSpace=!1,r._convertToLinearSpace=!1,r.disableLevelMultiplication=!1,r._fragmentOnly=i,r.registerInput("uv",ia.AutoDetect,!1,ra.VertexAndFragment),r.registerInput("source",ia.Object,!0,ra.VertexAndFragment,new mv("source",r,sa.Input,Bv,"ImageSourceBlock")),r.registerInput("layer",ia.Float,!0),r.registerInput("lod",ia.Float,!0),r.registerOutput("rgba",ia.Color4,ra.Neutral),r.registerOutput("rgb",ia.Color3,ra.Neutral),r.registerOutput("r",ia.Float,ra.Neutral),r.registerOutput("g",ia.Float,ra.Neutral),r.registerOutput("b",ia.Float,ra.Neutral),r.registerOutput("a",ia.Float,ra.Neutral),r.registerOutput("level",ia.Float,ra.Neutral),r._inputs[0].addExcludedConnectionPointFromAllowedTypes(ia.Vector2|ia.Vector3|ia.Vector4),r._inputs[0]._prioritizeVertex=!i,r}return W(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:S.LastCreatedScene;!e&&r&&r.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i._texture)})),this._texture=e,e&&r&&r.markAllMaterialsAsDirty(a.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:S.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(a.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:S.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(a.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 ra.Fragment;if(!this.uv.isConnected)return ra.VertexAndFragment;if(this.uv.sourceBlock.isInput)return ra.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===ra.Fragment)return ra.Fragment;if(e.target===ra.Vertex)return ra.VertexAndFragment;if(e.target===ra.Neutral||e.target===ra.VertexAndFragment){var t=e.ownerBlock;if(t.target===ra.Fragment)return ra.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=ra[e.target],null===(t=e.inParameters)||void 0===t||t.forEach((function(e,t){var i=ia[e.type];"sampler2D"===e.type||"samplerCube"===e.type?(n._inputSamplers=n._inputSamplers||[],n._inputSamplers.push(e.name),n.registerInput(e.name,ia.Object,!0,ra.VertexAndFragment,new mv(e.name,n,sa.Input,Bv,"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,ia[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;jn.PrepareUniformsAndSamplersForLight(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?jn.BindLight(this.light,this._lightId,o,e,!0):jn.BindLights(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,V.Color3[0]);var u=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,V.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,"vec4")&&(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","vec4","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,"vec4"),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,R,C,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=__(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!==ra.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","vec2","defined(IGNORE) || DEBUGMODE > 0"),t._emitUniformFromString("ambientFromScene","vec3"),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","vec4"),(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,"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+=wy.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+=Ly.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!==(R=null==W?void 0:W._defineOppositeZ)&&void 0!==R?R:"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!==(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+=Uy.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",replaceStrings:[{search:/vPositionW/g,replace: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=O_.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,ae=this._outputs;oe ").concat(this.b.associatedVariableName," ? ").concat(r," : ").concat(n,";\n");break;case zy.GreaterOrEqual:t.compilationString+=this._declareOutput(i,t)+" = ".concat(this.a.associatedVariableName," >= ").concat(this.b.associatedVariableName," ? ").concat(r," : ").concat(n,";\n");break;case zy.Xor:t.compilationString+=this._declareOutput(i,t)+" = (mod(".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,", 2.0) > 0.0) ? ").concat(r," : ").concat(n,";\n");break;case zy.Or:t.compilationString+=this._declareOutput(i,t)+" = (min(".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,", 1.0) > 0.0) ? ").concat(r," : ").concat(n,";\n");break;case zy.And:t.compilationString+=this._declareOutput(i,t)+" = (".concat(this.a.associatedVariableName," * ").concat(this.b.associatedVariableName," > 0.0) ? ").concat(r," : ").concat(n,";\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(zy[this.condition],";\n")},t}(ha);b("BABYLON.ConditionalBlock",Hy);var Xy=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.octaves=6,i.registerInput("seed",ia.AutoDetect),i.registerInput("chaos",ia.AutoDetect,!0),i.registerInput("offsetX",ia.Float,!0),i.registerInput("offsetY",ia.Float,!0),i.registerInput("offsetZ",ia.Float,!0),i.registerOutput("output",ia.Float),i._inputs[0].acceptedConnectionPointTypes.push(ia.Vector2),i._inputs[0].acceptedConnectionPointTypes.push(ia.Vector3),i._linkConnectionTypes(0,1),i}return W(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)===ia.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)===ia.Vector2?"vec2(0., 0.)":"vec3(0., 0., 0.)",t.compilationString+=this._declareOutput(this._outputs[0],t)+" = ".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},X([_a("Octaves",pa.Int)],t.prototype,"octaves",void 0),t}(ha);b("BABYLON.CloudBlock",Xy);var jy=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.registerInput("seed",ia.Vector2),i.registerInput("offset",ia.Float),i.registerInput("density",ia.Float),i.registerOutput("output",ia.Float),i.registerOutput("cells",ia.Float),i}return W(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._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(x,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 ",t._emitFunction("voronoi",i,"// Voronoi");var r=t._getFreeVariableName("tempOutput"),n=t._getFreeVariableName("tempCells");return t.compilationString+="float ".concat(r," = 0.0;\n"),t.compilationString+="float ".concat(n," = 0.0;\n"),t.compilationString+="voronoi(".concat(this.seed.associatedVariableName,", ").concat(this.offset.associatedVariableName,", ").concat(this.density.associatedVariableName,", ").concat(r,", ").concat(n,");\n"),this.output.hasEndpoints&&(t.compilationString+=this._declareOutput(this.output,t)+" = ".concat(r,";\n")),this.cells.hasEndpoints&&(t.compilationString+=this._declareOutput(this.cells,t)+" = ".concat(n,";\n")),this}},t}(ha);b("BABYLON.VoronoiNoiseBlock",jy);var Yy=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.registerInput("input",ia.AutoDetect),i.registerOutput("output",ia.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return W(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!==ra.VertexAndFragment)return t.target;if(e.connectedPoint.target!==ra.VertexAndFragment)return e.connectedPoint.target}return this._target},set:function(e){0==(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+=this._declareOutput(i,t)+" = ".concat(r.associatedVariableName,";\n"),this},t}(ha);b("BABYLON.ElbowBlock",Yy);var Ky=function(e){function t(t,i){void 0===i&&(i=!1);var r=e.call(this,t,ra.Neutral)||this;return r.projectAsCube=!1,r._convertToGammaSpace=!1,r._convertToLinearSpace=!1,r.disableLevelMultiplication=!1,r.registerInput("position",ia.AutoDetect,!1),r.registerInput("normal",ia.AutoDetect,!1),r.registerInput("sharpness",ia.Float,!0),r.registerInput("source",ia.Object,!0,ra.VertexAndFragment,new mv("source",r,sa.Input,Bv,"ImageSourceBlock")),r.registerInput("sourceY",ia.Object,!0,ra.VertexAndFragment,new mv("sourceY",r,sa.Input,Bv,"ImageSourceBlock")),i||r.registerInput("sourceZ",ia.Object,!0,ra.VertexAndFragment,new mv("sourceZ",r,sa.Input,Bv,"ImageSourceBlock")),r.registerOutput("rgba",ia.Color4,ra.Neutral),r.registerOutput("rgb",ia.Color3,ra.Neutral),r.registerOutput("r",ia.Float,ra.Neutral),r.registerOutput("g",ia.Float,ra.Neutral),r.registerOutput("b",ia.Float,ra.Neutral),r.registerOutput("a",ia.Float,ra.Neutral),r.registerOutput("level",ia.Float,ra.Neutral),r._inputs[0].addExcludedConnectionPointFromAllowedTypes(ia.Color3|ia.Vector3|ia.Vector4),r._inputs[1].addExcludedConnectionPointFromAllowedTypes(ia.Color3|ia.Vector3|ia.Vector4),r}return W(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:S.LastCreatedScene;!e&&r&&r.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(i._texture)})),this._texture=e,e&&r&&r.markAllMaterialsAsDirty(a.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:S.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(a.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:S.LastCreatedScene;null==r||r.markAllMaterialsAsDirty(a.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(this._declareOutput(t,e)," = ").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,"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}(Ky);b("BABYLON.BiPlanarBlock",Qy);var qy=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.registerInput("input",ia.Matrix),i.registerOutput("output",ia.Float),i}return W(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+=this._declareOutput(i,t)+"".concat(i.associatedVariableName," = determinant(").concat(r.associatedVariableName,");\n"),this},t}(ha);b("BABYLON.MatrixDeterminantBlock",qy);var Zy,Jy=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.registerInput("input",ia.Matrix),i.registerOutput("output",ia.Matrix),i}return W(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+=this._declareOutput(i,t)+"".concat(i.associatedVariableName," = transpose(").concat(r.associatedVariableName,");\n"),this},t}(ha);b("BABYLON.MatrixTransposeBlock",Jy),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"}(Zy||(Zy={}));var $y,eb=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.attributeType=Zy.None,i.registerInput("input",ia.AutoDetect),i.registerInput("fallback",ia.AutoDetect),i.registerOutput("output",ia.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 Aa&&r.isAttribute)switch(r.name){case"color":i.attributeType=Zy.VertexColor;break;case"normal":i.attributeType=Zy.Normal;break;case"tangent":i.attributeType=Zy.Tangent;break;case"uv":i.attributeType=Zy.UV1;break;case"uv2":i.attributeType=Zy.UV2;break;case"uv3":i.attributeType=Zy.UV3;break;case"uv4":i.attributeType=Zy.UV4;break;case"uv5":i.attributeType=Zy.UV5;break;case"uv6":i.attributeType=Zy.UV6}else if(r instanceof yv)switch(null===(t=i.input.connectedPoint)||void 0===t?void 0:t.name){case"normalOutput":i.attributeType=Zy.Normal;break;case"tangentOutput":i.attributeType=Zy.Tangent;break;case"uvOutput":i.attributeType=Zy.UV1}}})),i}return W(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 Zy.VertexColor:i="VERTEXCOLOR_NME";break;case Zy.Normal:i="NORMAL";break;case Zy.Tangent:i="TANGENT";break;case Zy.UV1:i="UV1";break;case Zy.UV2:i="UV2";break;case Zy.UV3:i="UV3";break;case Zy.UV4:i="UV4";break;case Zy.UV5:i="UV5";break;case Zy.UV6:i="UV6"}var r=this._declareOutput(this.output,t);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:Zy.None},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".attributeType = ").concat(this.attributeType,";\n")},X([_a("Attribute lookup",pa.List,void 0,{notifiers:{update:!0},options:[{label:"(None)",value:Zy.None},{label:"Normal",value:Zy.Normal},{label:"Tangent",value:Zy.Tangent},{label:"Vertex Color",value:Zy.VertexColor},{label:"UV1",value:Zy.UV1},{label:"UV2",value:Zy.UV2},{label:"UV3",value:Zy.UV3},{label:"UV4",value:Zy.UV4},{label:"UV5",value:Zy.UV5},{label:"UV6",value:Zy.UV6}]})],t.prototype,"attributeType",void 0),t}(ha);b("BABYLON.MeshAttributeExistsBlock",eb),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"}($y||($y={}));var tb=function(e){function t(t){var i=e.call(this,t,ra.Neutral)||this;return i.type=$y.EaseInOutSine,i.registerInput("input",ia.AutoDetect),i.registerOutput("output",ia.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(ia.Matrix),i._inputs[0].excludedConnectionPointTypes.push(ia.Object),i._inputs[0].excludedConnectionPointTypes.push(ia.Int),i}return W(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){if("float"===t)return this._duplicateEntryDirect(e);for(var i=parseInt(t.replace("vec","")),r="\n vec".concat(i," ret = vec").concat(i,"(0.0);\n "),n=1;n<=i;n++)r+=this._duplicateEntry(e,1===n?"x":2===n?"y":3===n?"z":"w")+";\n";return r+"return ret;\n"},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i,r=this._outputs[0],n="",o="";switch(this.input.type){case ia.Float:o="float";break;case ia.Vector2:o="vec2";break;case ia.Vector3:case ia.Color3:o="vec3";break;case ia.Vector4:case ia.Color4:o="vec4"}switch(i=$y[this.type]+"_"+o,this.type){case $y.EaseInSine:n="return 1.0 - cos((v * 3.1415) / 2.0)";break;case $y.EaseOutSine:n="return sin((v * 3.1415) / 2.0)";break;case $y.EaseInOutSine:n="return -(cos(v * 3.1415) - 1.0) / 2.0";break;case $y.EaseInQuad:n="return v * v";break;case $y.EaseOutQuad:n="return (1.0 - v) * (1.0 - v)";break;case $y.EaseInOutQuad:var a="VAL < 0.5 ? 2.0 * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 2.0) / 2.0";n=this._duplicateVector(a,o);break;case $y.EaseInCubic:n="return v * v * v";break;case $y.EaseOutCubic:a="1.0 - pow(1.0 - VAL, 3.0)",n=this._duplicateVector(a,o);break;case $y.EaseInOutCubic:a="VAL < 0.5 ? 4.0 * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 3.0) / 2.0",n=this._duplicateVector(a,o);break;case $y.EaseInQuart:n="return v * v * v * v";break;case $y.EaseOutQuart:a="1.0 - pow(1.0 - VAL, 4.0)",n=this._duplicateVector(a,o);break;case $y.EaseInOutQuart:a="VAL < 0.5 ? 8.0 * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 4.0) / 2.0",n=this._duplicateVector(a,o);break;case $y.EaseInQuint:n="return v * v * v * v * v";break;case $y.EaseOutQuint:a="1.0 - pow(1.0 - VAL, 5.0)",n=this._duplicateVector(a,o);break;case $y.EaseInOutQuint:a="VAL < 0.5 ? 16.0 * VAL * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 5.0) / 2.0",n=this._duplicateVector(a,o);break;case $y.EaseInExpo:a="VAL == 0.0 ? 0.0 : pow(2.0, 10.0 * VAL - 10.0)",n=this._duplicateVector(a,o);break;case $y.EaseOutExpo:a="VAL == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * VAL)",n=this._duplicateVector(a,o);break;case $y.EaseInOutExpo:a="VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? pow(2.0, 20.0 * VAL - 10.0) / 2.0 : (2.0 - pow(2.0, -20.0 * VAL + 10.0)) / 2.0",n=this._duplicateVector(a,o);break;case $y.EaseInCirc:a="1.0 - sqrt(1.0 - pow(VAL, 2.0))",n=this._duplicateVector(a,o);break;case $y.EaseOutCirc:a="sqrt(1.0 - pow(VAL - 1.0, 2.0))",n=this._duplicateVector(a,o);break;case $y.EaseInOutCirc:a="VAL < 0.5 ? (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",n=this._duplicateVector(a,o);break;case $y.EaseInBack:n="return 2.70158 * v * v * v - 1.70158 * v * v";break;case $y.EaseOutBack:a="2.70158 * pow(VAL - 1.0, 3.0) + 1.70158 * pow(VAL - 1.0, 2.0)",n=this._duplicateVector(a,o);break;case $y.EaseInOutBack:a="VAL < 0.5 ? (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",n=this._duplicateVector(a,o);break;case $y.EaseInElastic:a="VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : -pow(2.0, 10.0 * VAL - 10.0) * sin((VAL * 10.0 - 10.75) * ((2.0 * 3.1415) / 3.0))",n=this._duplicateVector(a,o);break;case $y.EaseOutElastic:a="VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : pow(2.0, -10.0 * VAL) * sin((VAL * 10.0 - 0.75) * ((2.0 * 3.1415) / 3.0)) + 1.0",n=this._duplicateVector(a,o);break;case $y.EaseInOutElastic:a="VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? -(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",n=this._duplicateVector(a,o)}return t._emitFunction(i,"".concat(o," ").concat(i,"(").concat(o," v) {").concat(n,";}\n"),""),t.compilationString+=this._declareOutput(r,t)+" = ".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($y[this.type],";\n")},t}(ha);b("BABYLON.CurveBlock",tb);var ib,rb,nb,ob=function(){function e(){}return e.prototype.optimize=function(e,t){},e}(),ab=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}(),sb=function(){function e(e,t,i){var r=this;this._baseMaterial=e,this._scene=null!=t?t:S.LastCreatedScene,this._options=i,this._subMeshToEffect=new Map,this._subMeshToDepthWrapper=new ab,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 ei(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 ei(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:xi()}).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(","),")"):Gt.IncludesShadersStore.shadowMapVertexNormalBias,v=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):Gt.IncludesShadersStore.shadowMapVertexMetric,y=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):Gt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow,b=Gt.IncludesShadersStore.shadowMapFragment;_=(_=-1!==(_=(_=_.replace(/void\s+?main/g,Gt.IncludesShadersStore.shadowMapVertexExtraDeclaration+"\nvoid main")).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 T=m.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||m.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,E=-1!==m.indexOf("#define SHADOWDEPTH_FRAGMENT"),S="";T?m=m.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,y):S=y+"\n",m=m.replace(/void\s+?main/g,Gt.IncludesShadersStore.shadowMapFragmentExtraDeclaration+"\nvoid main"),E?m=m.replace(/#define SHADOWDEPTH_FRAGMENT/g,b):S+=b+"\n",S&&(m=m.replace(/}\s*$/g,S+"}")),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()},s);for(var x=0;x0&&Array.isArray(e[0])&&e[0].length>0&&e[0][0]instanceof R){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;i\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;\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;mat4 grlMatrix=viewProjection*finalWorld ;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=worldViewProjection*vec4( (position+grl_offsets)+grl_slopes*grl_widths ,1.0 ) ;gl_Position=grlFinalPosition;\n#endif\n}\n";var Tb,Eb=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(nb.COLOR_DISTRIBUTION_TYPE_LINE,"."),"COLOR_DISTRIBUTION_TYPE_SEGMENT ".concat(nb.COLOR_DISTRIBUTION_TYPE_SEGMENT,"."),"COLOR_MODE_SET ".concat(rb.COLOR_MODE_SET,"."),"COLOR_MODE_ADD ".concat(rb.COLOR_MODE_ADD,"."),"COLOR_MODE_MULTIPLY ".concat(rb.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=B.White(),v._colorsDistributionType=nb.COLOR_DISTRIBUTION_TYPE_SEGMENT,v._colorsTexture=null,r=r||{color:gb.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?gb.DEFAULT_WIDTH_ATTENUATED:gb.DEFAULT_WIDTH,v.sizeAttenuation=null!==(c=r.sizeAttenuation)&&void 0!==c&&c,v.color=null!==(u=r.color)&&void 0!==u?u:B.White(),v.useColors=null!==(h=r.useColors)&&void 0!==h&&h,v.colorsDistributionType=null!==(d=r.colorDistributionType)&&void 0!==d?d:nb.COLOR_DISTRIBUTION_TYPE_SEGMENT,v.colorsSampling=null!==(p=r.colorsSampling)&&void 0!==p?p:Ro.NEAREST_NEAREST,v.colorMode=null!==(f=r.colorMode)&&void 0!==f?f:rb.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 A(T.getRenderWidth(),T.getRenderHeight()),r.colorsTexture&&(v.colorsTexture=r.colorsTexture),v._colors&&v.setColors(v._colors),T.onDisposeObservable.add((function(){vb.DisposeEmptyColorsTexture()})),v}return W(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 A(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=vb.Color3toRGBAUint8(e);this._colorsTexture.update(l)}else null===(a=this._colorsTexture)||void 0===a||a.dispose(),this.colorsTexture=vb.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",vb.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",vb.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",vb.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:gb.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=vb.CreateColorsTexture("".concat(this.name,"-colors-texture"),o.colors,this.colorsSampling,this.getScene()):vb.PrepareEmptyColorsTexture(t),this._cameraFacing=null===(n=o.cameraFacing)||void 0===n||n,this.setDefine("GREASED_LINE_CAMERA_FACING",this._cameraFacing)},t}(Uu),Sb=[new B(.98,.26,.38),new B(.47,.75,.3),new B(0,.26,.77),new B(.97,.6,.76),new B(.19,.63,.78),new B(.98,.8,.6),new B(.65,.43,.15),new B(.15,.47,.22),new B(.67,.71,.86),new B(.09,.46,.56),new B(.8,.98,.02),new B(.39,.29,.13),new B(.53,.63,.06),new B(.95,.96,.41),new B(1,.72,.94),new B(.63,.08,.31),new B(.66,.96,.95),new B(.22,.14,.19),new B(.14,.65,.59),new B(.93,1,.68),new B(.93,.14,.44),new B(.47,.86,.67),new B(.85,.07,.78),new B(.53,.64,.98),new B(.43,.37,.56),new B(.71,.65,.25),new B(.66,.19,.01),new B(.94,.53,.12),new B(.41,.44,.44),new B(.24,.71,.96),new B(.57,.28,.56),new B(.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"}(Tb||(Tb={}));var xb=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.DBG_MODE=Tb.NONE,t.DBG_MULTIPLY=!0,t.DBG_ENABLED=!0,t}return W(t,e),t}(Di),Ab=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 xb;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 B(1,1,1),g.shadedSpecularColor=null!==(s=r.shadedSpecularColor)&&void 0!==s?s:new B(.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 B(0,0,0),g.wireframeVerticesColor=null!==(h=r.wireframeVerticesColor)&&void 0!==h?h:new B(.8,.8,.8),g.vertexColor=null!==(d=r.vertexColor)&&void 0!==d?d:new B(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 B(1,1,1),g.uvSecondaryColor=null!==(m=r.uvSecondaryColor)&&void 0!==m?m:new B(.5,.5,.5),g._materialColor=t.MaterialColors[t._PluginCount++%t.MaterialColors.length],g.isEnabled=!0,g}return W(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().webGLVersion)return $.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!=Tb.VERTICES&&this._mode!=Tb.TRIANGLES&&this._mode!=Tb.TRIANGLES_VERTICES||i.isVerticesDataPresent("dbg_initialPass")||$.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(UV1)\n dbg_color = mix(dbg_uvPrimaryColor, dbg_uvSecondaryColor, dbg_checkerboardFactor(vMainUV1));\n#elif DBG_MODE == 5 && defined(UV2)\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=Sb},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;ae.EPSILON?1:0;l|=u,c.push(u)}switch(l){case 0:(R.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 Lb(h,t.shared)).plane&&n.push(y),d.length>=3&&(y=new Lb(d,t.shared)).plane&&o.push(y)}},e.EPSILON=1e-5,e}(),Lb=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=Fb.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}(),wb=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);}\n";kt.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";var Ub=function(){function e(e,t,i){this._textureCreatedInternally=!1,this.clearColor=new U(0,0,0,0),this._mesh=e,this._scene=t,this._options=H({width:1024,height:1024,textureType:a.TEXTURETYPE_UNSIGNED_BYTE,generateMipMaps:!0,optimizeUVAllocation:!0},i)}return e._GetShader=function(e){if(!e._meshUVSpaceRendererShader){var t=new Uu("meshUVSpaceRendererShader",e,{vertex:"meshUVSpaceRenderer",fragment:"meshUVSpaceRenderer"},{attributes:["position","normal","uv"],uniforms:["world","projMatrix"],samplers:["textureSampler"],needAlphaBlending:!0});t.backFaceCulling=!1,t.alphaMode=a.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._IsRenderTargetTexture=function(e){return void 0!==e.renderList},e.prototype.isReady=function(){return this.texture||this._createDiffuseRTT(),e._IsRenderTargetTexture(this.texture)?this.texture.isReadyForRendering():this.texture.isReady()},e.prototype.renderTexture=function(t,i,r,n,o){if(void 0===o&&(o=0),this.texture||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(){if(e._IsRenderTargetTexture(this.texture)&&this.texture.renderTarget){var t=this._scene.getEngine();t.bindFramebuffer(this.texture.renderTarget),t.clear(this.clearColor,!0,!0,!0),t.unBindFramebuffer(this.texture.renderTarget)}},e.prototype.dispose=function(){this._textureCreatedInternally&&(this.texture.dispose(),this._textureCreatedInternally=!1)},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},e.prototype._createRenderTargetTexture=function(e,t){var i=this,r=new ns(this._mesh.name+"_uvspaceTexture",{width:e,height:t},this._scene,this._options.generateMipMaps,!0,this._options.textureType,!1,this._options.generateMipMaps?a.TEXTURE_TRILINEAR_SAMPLINGMODE:a.TEXTURE_BILINEAR_SAMPLINGMODE,!1,!1,!1,a.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=I.RotationYawPitchRoll(n,a,r).multiply(I.Translation(s.x,s.y,s.z)),c=I.Invert(l),u=I.FromArray([2/i.x,0,0,0,0,2/i.y,0,0,0,0,1/i.z,0,0,0,0,1]),h=I.FromArray([.5,0,0,0,0,.5,0,0,0,0,1,0,.5,.5,0,1]);return c.multiply(u).multiply(h)},e}();io._TrailMeshParser=function(e,t){return kb.Parse(e,t)};var Vb,kb=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;ls||i.deleted||i.isDirty))for(var n=function(e){if(i.error[e]>0,(function(e){if(n){var t=e+a.verticesStart,o=R.FromArray(n,3*t),l=function(e){if(i)for(var t=0;t0&&this._reconstructedMesh.setVerticesData(ji.NormalKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(ji.UVKind,s),l.length>0&&this._reconstructedMesh.setVerticesData(ji.ColorKind,l);var b=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],g.forEach((function(e){xn.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),xn.AddToMesh(b.materialIndex,m,d,_,3*n.length,this._reconstructedMesh))},e.prototype._initDecimatedMesh=function(){this._reconstructedMesh=new io(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=R.Cross(u,h).normalize();if(r[o]=!1,R.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;o0&&(s=t._CopyV3(l,e),r.push(s[0],s[1],s[2]),r.push(s[0],s[1],s[2]));return s=t._CompareV3(a-1,0,e)?t._CopyV3(1,e):t._CopyV3(a-1,e),r.push(s[0],s[1],s[2]),r.push(s[0],s[1],s[2]),{previous:i,next:r,uvs:o,side:n}},t.prototype._createVertexBuffers=function(){var t=e.prototype._createVertexBuffers.call(this),i=this._scene.getEngine(),r=new Xi(i,this._previousAndSide,!1,4);this.setVerticesBuffer(r.createVertexBuffer("grl_previousAndSide",0,4));var n=new Xi(i,this._nextAndCounters,!1,4);this.setVerticesBuffer(n.createVertexBuffer("grl_nextAndCounters",0,4));var o=new Xi(i,this._widths,this._updatable,1);this.setVerticesBuffer(o.createVertexBuffer("grl_widths",0,1)),this._widthsBuffer=o;var a=new Xi(i,this._colorPointers,this._updatable,1);return this.setVerticesBuffer(a.createVertexBuffer("grl_colorPointers",0,1)),this._colorPointersBuffer=a,t},t._V_START=new R,t._V_END=new R,t._V_OFFSET_START=new R,t._V_OFFSET_END=new R,t}(Jb);io._GreasedLineRibbonMeshParser=function(e,t){return oT.Parse(e,t)};var eT,tT,iT,rT,nT,oT=function(e){function t(t,i,r,n){var o,a=this;if((a=e.call(this,t,i,r)||this).name=t,!r.ribbonOptions)throw"'GreasedLineMeshOptions.ribbonOptions' is not set.";return a._paths=[],a._counters=[],a._slopes=[],a._widths=null!==(o=r.widths)&&void 0!==o?o:[],a._ribbonWidths=[],a._pathsOptions=null!=n?n:[],r.points&&a.addPoints(vb.ConvertPoints(r.points),r,!!n),a}return W(t,e),t.prototype.addPoints=function(t,i,r){if(void 0===r&&(r=!1),!i.ribbonOptions)throw"addPoints() on GreasedLineRibbonMesh instance requires 'GreasedLineMeshOptions.ribbonOptions'.";r||this._pathsOptions.push({options:i,pathCount:t.length}),e.prototype.addPoints.call(this,t,i)},t.prototype.getClassName=function(){return"GreasedLineRibbonMesh"},Object.defineProperty(t.prototype,"isFlatLine",{get:function(){return this._paths.length<3},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"slopes",{get:function(){return this._slopes},set:function(e){this._slopes=e},enumerable:!1,configurable:!0}),t.prototype._updateColorPointers=function(){var e;if(!this._options.colorPointers){var t=0;this._colorPointers=[];for(var i=0;i2)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=[];he.DeepCopy(this._pathsOptions,o,void 0,void 0,!0),he.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===tT.WIDTH_DISTRIBUTION_START_END){for(var s=Math.floor(t.length/2),l=0,c=0;l0){if(i===eT.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},io.prototype.thinInstanceSetAttributeAt=function(e,t,i,r){return void 0===r&&(r=!0),e===ji.ColorKind&&(e=ji.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(io.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}),io.prototype._thinInstanceCreateMatrixBuffer=function(e,t,i){void 0===i&&(i=!1),e===ji.ColorKind&&(e=ji.ColorInstanceKind);for(var r=new Xi(this.getEngine(),t,!i,16,!1,!0),n=0;n<4;n++)this.setVerticesBuffer(r.createVertexBuffer(e+n,4*n,4));return r},io.prototype.thinInstanceSetBuffer=function(e,t,i,r){var n,o,a;void 0===i&&(i=0),void 0===r&&(r=!1),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===ji.ColorKind&&(e=ji.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 ji(this.getEngine(),t,e,!r,!1,i,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])))},io.prototype.thinInstanceBufferUpdated=function(e){var t,i,r;"matrix"===e?null===(t=this._thinInstanceDataStorage.matrixBuffer)||void 0===t||t.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount):"previousMatrix"===e?null===(i=this._thinInstanceDataStorage.previousMatrixBuffer)||void 0===i||i.updateDirectly(this._thinInstanceDataStorage.previousMatrixData,0,this._thinInstanceDataStorage.instancesCount):(e===ji.ColorKind&&(e=ji.ColorInstanceKind),(null===(r=this._userThinInstanceBuffersStorage)||void 0===r?void 0:r.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e],0))},io.prototype.thinInstancePartialBufferUpdate=function(e,t,i){var r;"matrix"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,i):(e===ji.ColorKind&&(e=ji.ColorInstanceKind),(null===(r=this._userThinInstanceBuffersStorage)||void 0===r?void 0:r.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t,i))},io.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];var e=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=new Array;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.getConnectedValue=function(e){var t,i,r;return this.isConnected?(null===(t=this._connectedPoint)||void 0===t?void 0:t._storedFunction)?null===(i=this._connectedPoint)||void 0===i?void 0:i._storedFunction(e):null===(r=this._connectedPoint)||void 0===r?void 0:r._storedValue:this.value},e.prototype.getClassName=function(){return"NodeGeometryConnectionPoint"},e.prototype.canConnectTo=function(e){return this.checkCompatibilityState(e)===rT.Compatible},e.prototype.checkCompatibilityState=function(e){var t=this._ownerBlock,i=e.ownerBlock;if(this.type!==e.type&&e.innerType!==iT.AutoDetect)return e.acceptedConnectionPointTypes&&-1!==e.acceptedConnectionPointTypes.indexOf(this.type)?rT.Compatible:rT.TypeIncompatible;if(e.excludedConnectionPointTypes&&-1!==e.excludedConnectionPointTypes.indexOf(this.type))return rT.TypeIncompatible;var r=i,n=t;return this.direction===nT.Input&&(r=t,n=i),r.isAnAncestorOf(n)?rT.HierarchyIssue:rT.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},e.prototype.addExcludedConnectionPointFromAllowedTypes=function(e){for(var t=1;t0&&!this._outputs.some((function(e){return e.hasEndpoints}))&&!this.isDebug)return!1;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 uT.Positions:return this.executionContext.getOverridePositionsContextualValue?this.executionContext.getOverridePositionsContextualValue():this.geometryContext&&this.geometryContext.positions?R.FromArray(this.geometryContext.positions,3*i):R.Zero();case uT.Normals:return this.executionContext.getOverrideNormalsContextualValue?this.executionContext.getOverrideNormalsContextualValue():this.geometryContext&&this.geometryContext.normals?R.FromArray(this.geometryContext.normals,3*i):R.Zero();case uT.Colors:return this.geometryContext&&this.geometryContext.colors?C.FromArray(this.geometryContext.colors,4*i):C.Zero();case uT.Tangents:return this.geometryContext&&this.geometryContext.tangents?C.FromArray(this.geometryContext.tangents,4*i):C.Zero();case uT.UV:return this.executionContext.getOverrideUVs1ContextualValue?this.executionContext.getOverrideUVs1ContextualValue():this.geometryContext&&this.geometryContext.uvs?A.FromArray(this.geometryContext.uvs,2*i):A.Zero();case uT.UV2:return this.geometryContext&&this.geometryContext.uvs2?A.FromArray(this.geometryContext.uvs2,2*i):A.Zero();case uT.UV3:return this.geometryContext&&this.geometryContext.uvs3?A.FromArray(this.geometryContext.uvs3,2*i):A.Zero();case uT.UV4:return this.geometryContext&&this.geometryContext.uvs4?A.FromArray(this.geometryContext.uvs4,2*i):A.Zero();case uT.UV5:return this.geometryContext&&this.geometryContext.uvs5?A.FromArray(this.geometryContext.uvs5,2*i):A.Zero();case uT.UV6:return this.geometryContext&&this.geometryContext.uvs6?A.FromArray(this.geometryContext.uvs6,2*i):A.Zero();case uT.VertexID:return i;case uT.FaceID:return this.executionContext.getExecutionFaceIndex();case uT.LoopID:return this.executionContext.getExecutionLoopIndex();case uT.InstanceID:return this.instancingContext?this.instancingContext.getInstanceIndex():0;case uT.GeometryID:return this.geometryContext?this.geometryContext.uniqueId:0;case uT.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 iT.Vector2:return new A(i,i);case iT.Vector3:return new R(i,i,i);case iT.Vector4:return new C(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 iT.Vector2:return new A(n,n);case iT.Vector3:return new R(n,n,n);case iT.Vector4:return new C(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 wT.LessOrEqual:n=i<=r;break;case wT.GreaterOrEqual:n=i>=r;break;case wT.Xor:n=!!i&&!r||!i&&!!r;break;case wT.Or:n=!!i||!!r;break;case wT.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(wT[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},X([_a("Test",pa.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Equal",value:wT.Equal},{label:"NotEqual",value:wT.NotEqual},{label:"LessThan",value:wT.LessThan},{label:"GreaterThan",value:wT.GreaterThan},{label:"LessOrEqual",value:wT.LessOrEqual},{label:"GreaterOrEqual",value:wT.GreaterOrEqual},{label:"Xor",value:wT.Xor},{label:"Or",value:wT.Or},{label:"And",value:wT.And}]})],t.prototype,"test",void 0),t}(dT);b("BABYLON.ConditionBlock",VT),function(e){e[e.None=0]="None",e[e.LoopID=1]="LoopID",e[e.InstanceID=2]="InstanceID"}(UT||(UT={}));var kT=function(e){function t(t){var i=e.call(this,t)||this;return i._currentLockId=-1,i.lockMode=UT.None,i.registerInput("min",iT.AutoDetect),i.registerInput("max",iT.AutoDetect),i.registerOutput("output",iT.BasedOnInput),i._inputs[0].excludedConnectionPointTypes.push(iT.Matrix),i._inputs[0].excludedConnectionPointTypes.push(iT.Geometry),i._inputs[0].excludedConnectionPointTypes.push(iT.Texture),i._inputs[1].excludedConnectionPointTypes.push(iT.Matrix),i._inputs[1].excludedConnectionPointTypes.push(iT.Geometry),i._inputs[1].excludedConnectionPointTypes.push(iT.Texture),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return W(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 _T("Min");e.value=0,e.output.connectTo(this.min)}if(!this.max.isConnected){var t=new _T("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 iT.Int:case iT.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 iT.Vector2:t=function(t){var i=e.min.getConnectedValue(t)||A.Zero(),r=e.max.getConnectedValue(t)||A.Zero();return new A(i.x+Math.random()*(r.x-i.x),i.y+Math.random()*(r.y-i.y))};break;case iT.Vector3:t=function(t){var i=e.min.getConnectedValue(t)||R.Zero(),r=e.max.getConnectedValue(t)||R.Zero();return new R(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 iT.Vector4:t=function(t){var i=e.min.getConnectedValue(t)||C.Zero(),r=e.max.getConnectedValue(t)||C.Zero();return new C(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!==UT.None&&t?this.output._storedFunction=function(i){var r=0;switch(e.lockMode){case UT.InstanceID:r=i.getContextualValue(uT.InstanceID,!0)||0;break;case UT.LoopID:r=i.getContextualValue(uT.LoopID,!0)||0}return e._currentLockId!==r&&(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(UT[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},X([_a("LockMode",pa.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"None",value:UT.None},{label:"LoopID",value:UT.LoopID},{label:"InstanceID",value:UT.InstanceID}]})],t.prototype,"lockMode",void 0),t}(dT);b("BABYLON.RandomBlock",kT);var GT=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("offset",iT.Vector3,!0,R.Zero()),i.registerInput("scale",iT.Float,!0,1),i.registerInput("octaves",iT.Float,!0,2,0,16),i.registerInput("roughness",iT.Float,!0,.5,0,1),i.registerOutput("output",iT.Float),i}return W(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 R(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=h.Clamp(e,0,15)),d=0;d<=u;d++)c+=this._perlin(o.scale(a))*s,l+=s,s*=h.Clamp(t,0,1),a*=2;var p=e-Math.floor(e);if(0==p)return c/l;var f=c+this._perlin(o.scale(a))*s;return(1-p)*(c/=l)+p*(f/(l+s))},t.prototype._buildBlock=function(){var e=this;this.output._storedFunction=function(t){var i=t.getContextualValue(uT.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}(dT);b("BABYLON.NoiseBlock",GT);var zT=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!1,i.registerInput("geometry0",iT.Geometry),i.registerInput("geometry1",iT.Geometry,!0),i.registerInput("geometry2",iT.Geometry,!0),i.registerInput("geometry3",iT.Geometry,!0),i.registerInput("geometry4",iT.Geometry,!0),i.registerOutput("output",iT.Geometry),i}return W(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 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};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},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(dT);b("BABYLON.MergeGeometryBlock",zT);var WT=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!0,i.registerInput("geometry0",iT.Geometry,!0),i.registerInput("geometry1",iT.Geometry,!0),i.registerInput("geometry2",iT.Geometry,!0),i.registerInput("geometry3",iT.Geometry,!0),i.registerInput("geometry4",iT.Geometry,!0),i.registerInput("geometry5",iT.Geometry,!0),i.registerInput("geometry6",iT.Geometry,!0),i.registerInput("geometry7",iT.Geometry,!0),i.registerInput("geometry8",iT.Geometry,!0),i.registerInput("geometry9",iT.Geometry,!0),i.registerOutput("output",iT.Geometry),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return W(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},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(dT);b("BABYLON.GeometryCollectionBlock",WT);var HT=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("input",iT.AutoDetect),i.registerOutput("output",iT.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return W(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}(dT);b("BABYLON.GeometryElbowBlock",HT);var XT=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("geometry",iT.Geometry),i.registerOutput("output",iT.Geometry),i}return W(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=[]),Rn.ComputeNormals(i.positions,i.indices,i.normals),i}},t}(dT);b("BABYLON.ComputeNormalsBlock",XT);var jT=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("xyzw ",iT.Vector4,!0),i.registerInput("xyz ",iT.Vector3,!0),i.registerInput("xy ",iT.Vector2,!0),i.registerInput("zw ",iT.Vector2,!0),i.registerInput("x ",iT.Float,!0),i.registerInput("y ",iT.Float,!0),i.registerInput("z ",iT.Float,!0),i.registerInput("w ",iT.Float,!0),i.registerOutput("xyzw",iT.Vector4),i.registerOutput("xyz",iT.Vector3),i.registerOutput("xy",iT.Vector2),i.registerOutput("zw",iT.Vector2),i.registerOutput("x",iT.Float),i.registerOutput("y",iT.Float),i.registerOutput("z",iT.Float),i.registerOutput("w",iT.Float),i}return W(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 C(u,h,d,p)};u._storedFunction=function(e){return v(e)},h._storedFunction=function(e){var t=v(e);return new R(t.x,t.y,t.z)},d._storedFunction=function(e){var t=v(e);return new A(t.x,t.y)},p._storedFunction=function(e){var t=v(e);return new A(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}(dT);b("BABYLON.VectorConverterBlock",jT);var YT=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("input",iT.AutoDetect),i.registerOutput("output",iT.BasedOnInput),i._inputs[0].excludedConnectionPointTypes.push(iT.Float),i._inputs[0].excludedConnectionPointTypes.push(iT.Matrix),i._inputs[0].excludedConnectionPointTypes.push(iT.Geometry),i._inputs[0].excludedConnectionPointTypes.push(iT.Texture),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return W(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}(dT);b("BABYLON.NormalizeVectorBlock",YT);var KT,QT=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!0,i.registerInput("geometry",iT.Geometry),i.registerInput("id",iT.Int,!0,0),i.registerOutput("output",iT.Geometry),i.id.acceptedConnectionPointTypes.push(iT.Float),i}return W(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 An;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)},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(dT);b("BABYLON.SetMaterialIDBlock",QT),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"}(KT||(KT={}));var qT=function(e){function t(t){var i=e.call(this,t)||this;return i.operation=KT.Cos,i.registerInput("input",iT.AutoDetect),i.registerOutput("output",iT.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(iT.Matrix),i._inputs[0].excludedConnectionPointTypes.push(iT.Geometry),i._inputs[0].excludedConnectionPointTypes.push(iT.Texture),i}return W(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 KT.Cos:r=function(e){return Math.cos(e)};break;case KT.Sin:r=function(e){return Math.sin(e)};break;case KT.Abs:r=function(e){return Math.abs(e)};break;case KT.Exp:r=function(e){return Math.exp(e)};break;case KT.Round:r=function(e){return Math.round(e)};break;case KT.Floor:r=function(e){return Math.floor(e)};break;case KT.Ceiling:r=function(e){return Math.ceil(e)};break;case KT.Sqrt:r=function(e){return Math.sqrt(e)};break;case KT.Log:r=function(e){return Math.log(e)};break;case KT.Tan:r=function(e){return Math.tan(e)};break;case KT.ArcTan:r=function(e){return Math.atan(e)};break;case KT.ArcCos:r=function(e){return Math.acos(e)};break;case KT.ArcSin:r=function(e){return Math.asin(e)};break;case KT.Sign:r=function(e){return Math.sign(e)};break;case KT.Negate:r=function(e){return-e};break;case KT.OneMinus:r=function(e){return 1-e};break;case KT.Reciprocal:r=function(e){return 1/e};break;case KT.ToRadians:r=function(e){return e*Math.PI/180};break;case KT.ToDegrees:r=function(e){return 180*e/Math.PI}}if(!r)return this.input._storedFunction=null,void(this.input._storedValue=null);switch(this.input.type){case iT.Int:case iT.Float:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return r(t)};break;case iT.Vector2:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return new A(r(t.x),r(t.y))};break;case iT.Vector3:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return new R(r(t.x),r(t.y),r(t.z))};break;case iT.Vector4:this.output._storedFunction=function(e){var t=i.input.getConnectedValue(e);return new C(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(KT[this.operation],";\n")},X([_a("Operation",pa.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Cos",value:KT.Cos},{label:"Sin",value:KT.Sin},{label:"Abs",value:KT.Abs},{label:"Exp",value:KT.Exp},{label:"Round",value:KT.Round},{label:"Floor",value:KT.Floor},{label:"Ceiling",value:KT.Ceiling},{label:"Sqrt",value:KT.Sqrt},{label:"Log",value:KT.Log},{label:"Tan",value:KT.Tan},{label:"ArcTan",value:KT.ArcTan},{label:"ArcCos",value:KT.ArcCos},{label:"ArcSin",value:KT.ArcSin},{label:"Sign",value:KT.Sign},{label:"Negate",value:KT.Negate},{label:"OneMinus",value:KT.OneMinus},{label:"Reciprocal",value:KT.Reciprocal},{label:"ToDegrees",value:KT.ToDegrees},{label:"ToRadians",value:KT.ToRadians}]})],t.prototype,"operation",void 0),t}(dT);b("BABYLON.GeometryTrigonometryBlock",qT);var ZT=function(e){function t(t){var i=e.call(this,t)||this;return i._rotationMatrix=new I,i._scalingMatrix=new I,i._translationMatrix=new I,i._scalingRotationMatrix=new I,i._transformMatrix=new I,i.evaluateContext=!0,i.registerInput("value",iT.AutoDetect),i.registerInput("matrix",iT.Matrix,!0),i.registerInput("translation",iT.Vector3,!0,R.Zero()),i.registerInput("rotation",iT.Vector3,!0,R.Zero()),i.registerInput("scaling",iT.Vector3,!0,R.One()),i.registerOutput("output",iT.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(iT.Float),i._inputs[0].excludedConnectionPointTypes.push(iT.Matrix),i._inputs[0].excludedConnectionPointTypes.push(iT.Texture),i}return W(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);I.ScalingToRef(n.x,n.y,n.z,t._scalingMatrix),I.RotationYawPitchRollToRef(o.y,o.x,o.z,t._rotationMatrix),I.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 iT.Geometry:var s=r.clone();return s.transform(i),s;case iT.Vector2:return A.Transform(r,i);case iT.Vector3:return R.TransformCoordinates(r,i);case iT.Vector4:return C.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)},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(dT);b("BABYLON.GeometryTransformBlock",ZT);var JT=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("angle",iT.Float,!1,0),i.registerOutput("matrix",iT.Matrix),i}return W(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 _T("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 I.RotationX(i.angle.getConnectedValue(e))}},t}(dT);b("BABYLON.RotationXBlock",JT);var $T=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("angle",iT.Float,!1,0),i.registerOutput("matrix",iT.Matrix),i}return W(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 _T("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 I.RotationY(i.angle.getConnectedValue(e))}},t}(dT);b("BABYLON.RotationYBlock",$T);var eE=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("angle",iT.Float,!1,0),i.registerOutput("matrix",iT.Matrix),i}return W(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 _T("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 I.RotationZ(i.angle.getConnectedValue(e))}},t}(dT);b("BABYLON.RotationZBlock",eE);var tE=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("scale",iT.Vector3,!1,R.One()),i.registerOutput("matrix",iT.Matrix),i}return W(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 _T("Scale");e.value=new R(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 I.Scaling(t.x,t.y,t.z)}},t}(dT);b("BABYLON.ScalingBlock",tE);var iE=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("source",iT.Vector3,!0,R.Up()),i.registerInput("target",iT.Vector3,!0,R.Left()),i.registerOutput("matrix",iT.Matrix),i}return W(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 I;return t.normalize(),r.normalize(),I.RotationAlignToRef(t,r,n,!0),n}},t}(dT);b("BABYLON.AlignBlock",iE);var rE=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("translation",iT.Vector3,!1,R.Zero()),i.registerOutput("matrix",iT.Matrix),i}return W(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 _T("Translation");e.value=new R(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 I.Translation(t.x,t.y,t.z)}},t}(dT);b("BABYLON.TranslationBlock",rE);var nE=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",iT.Geometry),i.registerInput("instance",iT.Geometry,!0),i.registerInput("density",iT.Float,!0,1,0,1),i.registerInput("matrix",iT.Matrix,!0),i.registerInput("rotation",iT.Vector3,!0,R.Zero()),i.registerInput("scaling",iT.Vector3,!0,R.One()),i.scaling.acceptedConnectionPointTypes.push(iT.Float),i.registerOutput("output",iT.Geometry),i}return W(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 R,o=new Array,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 m=t.matrix.getConnectedValue(e);e._instantiateWithPositionAndMatrix(f,n,m,r)}else{var g=e.adaptInput(t.scaling,iT.Vector3,R.OneReadOnly),v=t.rotation.getConnectedValue(e)||R.ZeroReadOnly;e._instantiate(f,n,v,g,r)}t._currentLoopIndex++}}}if(e.restoreGeometryContext(),e.restoreExecutionContext(),e.restoreInstancingContext(),!r.length)return null;if(1===r.length)t._vertexData=r[0];else{var y=r.splice(0,1)[0];t._vertexData=y.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)},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),X([_a("Remove duplicated positions",pa.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"removeDuplicatedPositions",void 0),t}(dT);b("BABYLON.InstantiateOnVerticesBlock",nE);var oE=function(e){function t(t){var i=e.call(this,t)||this;return i._currentPosition=new R,i._currentUV=new A,i._vertex0=new R,i._vertex1=new R,i._vertex2=new R,i._tempVector0=new R,i._tempVector1=new R,i._uv0=new A,i._uv1=new A,i._uv2=new A,i.evaluateContext=!0,i.registerInput("geometry",iT.Geometry),i.registerInput("instance",iT.Geometry,!0),i.registerInput("count",iT.Int,!0,256),i.registerInput("matrix",iT.Matrix,!0),i.registerInput("rotation",iT.Vector3,!0,R.Zero()),i.registerInput("scaling",iT.Vector3,!0,R.One()),i.scaling.acceptedConnectionPointTypes.push(iT.Float),i.registerOutput("output",iT.Geometry),i}return W(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(),R.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,iT.Vector3,R.OneReadOnly),S=t.rotation.getConnectedValue(e)||R.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)},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(dT);b("BABYLON.InstantiateOnFacesBlock",oE);var aE=function(e){function t(t){var i=e.call(this,t)||this;return i._currentPosition=new R,i._vertex0=new R,i._vertex1=new R,i._vertex2=new R,i.evaluateContext=!0,i.registerInput("geometry",iT.Geometry),i.registerInput("instance",iT.Geometry,!0),i.registerInput("count",iT.Int,!0,256),i.registerInput("matrix",iT.Matrix,!0),i.registerInput("rotation",iT.Vector3,!0,R.Zero()),i.registerInput("scaling",iT.Vector3,!0,R.One()),i.scaling.acceptedConnectionPointTypes.push(iT.Float),i.registerOutput("output",iT.Geometry),i}return W(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=Sn(t._vertexData.positions,0,t._vertexData.positions.length/3),a=o.minimum,s=o.maximum,l=new R(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,iT.Vector3,R.OneReadOnly),v=t.rotation.getConnectedValue(e)||R.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)},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(dT);b("BABYLON.InstantiateOnVolumeBlock",aE);var sE=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!0,i.registerInput("instance",iT.Geometry,!0),i.registerInput("count",iT.Int,!0,1),i.registerOutput("output",iT.Geometry),i}return W(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)},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(dT),lE=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("matrix",iT.Matrix,!0),i.registerInput("position",iT.Vector3,!0,R.Zero()),i.registerInput("rotation",iT.Vector3,!0,R.Zero()),i.registerInput("scaling",iT.Vector3,!0,R.One()),i.scaling.acceptedConnectionPointTypes.push(iT.Float),i}return W(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 pE.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 pE.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(pE[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},X([_a("Mapping",pa.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Spherical",value:pE.Spherical},{label:"Cylindrical",value:pE.Cylindrical},{label:"Cubic",value:pE.Cubic}]})],t.prototype,"mapping",void 0),t}(dT);b("BABYLON.MappingBlock",_E);var mE=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("matrix0",iT.Matrix),i.registerInput("matrix1",iT.Matrix),i.registerOutput("output",iT.Matrix),i}return W(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}(dT);b("BABYLON.MatrixComposeBlock",mE);var gE=function(e){function t(t){var i=e.call(this,t)||this;return i._endpoints=[],i._isTeleportIn=!0,i.registerInput("input",iT.AutoDetect),i}return W(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 C.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},X([_a("Clamp Coordinates",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"clampCoordinates",void 0),t}(dT);b("BABYLON.GeometryTextureFetchBlock",bE);var TE,EE=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("geometry",iT.Geometry),i.registerOutput("min",iT.Vector3),i.registerOutput("max",iT.Vector3),i}return W(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?Sn(i.positions,0,i.positions.length/3).minimum:null},this.max._storedFunction=function(t){var i=e.geometry.getConnectedValue(t);return i?Sn(i.positions,0,i.positions.length/3).maximum:null}},t}(dT);b("BABYLON.BoundingBlock",EE),function(e){e[e.Intersect=0]="Intersect",e[e.Subtract=1]="Subtract",e[e.Union=2]="Union"}(TE||(TE={}));var SE=function(e){function t(t){var i=e.call(this,t)||this;return i.evaluateContext=!1,i.operation=TE.Intersect,i.registerInput("geometry0",iT.Geometry),i.registerInput("geometry1",iT.Geometry),i.registerOutput("output",iT.Geometry),i}return W(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=Bb.FromVertexData(i),s=Bb.FromVertexData(r);switch(t.operation){case TE.Intersect:o=a.intersect(s);break;case TE.Subtract:o=a.subtract(s);break;case TE.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(TE[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)},X([_a("Evaluate context",pa.Boolean,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),X([_a("Operation",pa.List,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Intersect",value:TE.Intersect},{label:"Subtract",value:TE.Subtract},{label:"Union",value:TE.Union}]})],t.prototype,"operation",void 0),t}(dT);b("BABYLON.BooleanGeometryBlock",SE);var xE=function(){function e(e){void 0===e&&(e=Recast),this.bjsRECAST={},this.name="RecastJSPlugin",this._maximumSubStepCount=10,this._timeStep=1/60,this._timeFactor=1,this._worker=null,"function"==typeof e?$.Error("RecastJS is not ready. Please make sure you await Recast() before using the plugin."):this.bjsRECAST=e,this.isSupported()?(this.setTimeStep(),this._tempVec1=new this.bjsRECAST.Vec3,this._tempVec2=new this.bjsRECAST.Vec3):$.Error("RecastJS is not available. Please make sure you included the js file.")}return e.prototype.setWorkerURL=function(e){return!(!window||!window.Worker||(this._worker=new Worker(e),0))},e.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._timeStep=e},e.prototype.getTimeStep=function(){return this._timeStep},e.prototype.setMaximumSubStepCount=function(e){void 0===e&&(e=10),this._maximumSubStepCount=e},e.prototype.getMaximumSubStepCount=function(){return this._maximumSubStepCount},Object.defineProperty(e.prototype,"timeFactor",{get:function(){return this._timeFactor},set:function(e){this._timeFactor=Math.max(e,0)},enumerable:!1,configurable:!0}),e.prototype.createNavMesh=function(e,t,i){var r,n,o;this._worker&&!i?console.warn("A worker is avaible but no completion callback. Defaulting to blocking navmesh creation"):!this._worker&&i&&console.warn("A completion callback is avaible but no worker. Defaulting to blocking navmesh creation"),this.navMesh=new this.bjsRECAST.NavMesh;var a=[],s=[],l=0;for(r=0;r-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<=_)){var t=this.bjsRECASTPlugin.getTimeStep(),i=this.bjsRECASTPlugin.getMaximumSubStepCount();if(t<=_)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(){$.Error("error on XHR request."),o&&o()}),!1),c.send()}else $.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=Wg(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}(),CE=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}();kt.ShadersStore.gpuUpdateParticlesPixelShader="#version 300 es\nvoid main() {discard;}\n";kt.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 PE=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 ja&&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 Gt("gpuUpdateParticles",this._updateEffectOptions,this._engine),new CE(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(a.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}(),LE=function(){function e(t){this.particleSystem=t,this.position=R.Zero(),this.direction=R.Zero(),this.color=new U(0,0,0,0),this.colorStep=new U(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new A(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new U(0,0,0,0),this._currentColor2=new U(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;i=this._initialSpriteCellLoop?h.Clamp(e*t%this.lifeTime/this.lifeTime):h.Clamp(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=O.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,O.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(O.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 C(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}();!function(e){e[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END"}(ME||(ME={}));var wE=function(){function e(e){if(this.particleSystem=e,this.type=ME.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!e.emitter||!e.emitter.dispose){var t=T("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 R?t=t.clone():-1!==t.getClassName().indexOf("Mesh")&&((t=new(T("BABYLON.Mesh"))("",t.getScene())).isVisible=!1):t=new R;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),ve("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}();kt.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#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#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}";kt.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#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)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include\n#include\n#define CUSTOM_VERTEX_MAIN_END\n}";var BE=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=I.Identity(),s._inheritedVelocityOffset=new R,s.onDisposeObservable=new u,s.onStoppedObservable=new u,s._particles=new Array,s._stockParticles=new Array,s._newPartsExcess=0,s._vertexBuffers={},s._scaledColorStep=new U(0,0,0,0),s._colorDiff=new U(0,0,0,0),s._scaledDirection=R.Zero(),s._scaledGravity=R.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._disposeEmitterOnDispose=!1,s.isLocal=!1,s.isGPU=!1,s._onBeforeDrawParticlesObservable=null,s.recycleParticle=function(e){var t=s._particles.pop();t!==e&&t.copyTo(e),s._stockParticles.push(t)},s._createParticle=function(){var e;if(0!==s._stockParticles.length?(e=s._stockParticles.pop())._reset():e=new LE(s),s._subEmitters&&s._subEmitters.length>0){var t=s._subEmitters[Math.floor(Math.random()*s._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===ME.ATTACHED){var i=t.clone();e._attachedSubEmitters.push(i),i.particleSystem.start()}}))}return e},s._emitFromParticle=function(e){if(s._subEmitters&&0!==s._subEmitters.length){var t=Math.floor(Math.random()*s._subEmitters.length);s._subEmitters[t].forEach((function(t){if(t.type===ME.END){var i=t.clone();e._inheritParticleInfoToSubEmitter(i),i.particleSystem._rootParticleSystem=s,s.activeSubSystems.push(i.particleSystem),i.particleSystem.start()}}))}},s._capacity=i,s._epsilon=a,s._isAnimationSheetEnabled=o,r&&"Scene"!==r.getClassName()?(s._engine=r,s.defaultProjectionMatrix=I.PerspectiveFovLH(.8,1,.1,100,s._engine.isNDCHalfZRange)):(s._scene=r||S.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 ei(s._engine)},s._customWrappers[0].effect=n,s._drawWrappers=[],s._useInstancing=s._engine.getCaps().instancedArrays,s._createIndexBuffer(),s._createVertexBuffers(),s.particleEmitterType=new Ua;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 d=o.age/o.lifeTime;s._colorGradients&&s._colorGradients.length>0?FE.GetCurrentGradient(d,s._colorGradients,(function(e,t,i){e!==o._currentColorGradient&&(o._currentColor1.copyFrom(o._currentColor2),t.getColorToRef(o._currentColor2),o._currentColorGradient=e),U.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&&FE.GetCurrentGradient(d,s._angularSpeedGradients,(function(e,t,i){e!==o._currentAngularSpeedGradient&&(o._currentAngularSpeed1=o._currentAngularSpeed2,o._currentAngularSpeed2=t.getFactor(),o._currentAngularSpeedGradient=e),o.angularSpeed=h.Lerp(o._currentAngularSpeed1,o._currentAngularSpeed2,i)})),o.angle+=o.angularSpeed*a;var p=a;if(s._velocityGradients&&s._velocityGradients.length>0&&FE.GetCurrentGradient(d,s._velocityGradients,(function(e,t,i){e!==o._currentVelocityGradient&&(o._currentVelocity1=o._currentVelocity2,o._currentVelocity2=t.getFactor(),o._currentVelocityGradient=e),p*=h.Lerp(o._currentVelocity1,o._currentVelocity2,i)})),o.direction.scaleToRef(p,s._scaledDirection),s._limitVelocityGradients&&s._limitVelocityGradients.length>0&&FE.GetCurrentGradient(d,s._limitVelocityGradients,(function(e,t,i){e!==o._currentLimitVelocityGradient&&(o._currentLimitVelocity1=o._currentLimitVelocity2,o._currentLimitVelocity2=t.getFactor(),o._currentLimitVelocityGradient=e);var r=h.Lerp(o._currentLimitVelocity1,o._currentLimitVelocity2,i);o.direction.length()>r&&o.direction.scaleInPlace(s.limitVelocityDamping)})),s._dragGradients&&s._dragGradients.length>0&&FE.GetCurrentGradient(d,s._dragGradients,(function(e,t,i){e!==o._currentDragGradient&&(o._currentDrag1=o._currentDrag2,o._currentDrag2=t.getFactor(),o._currentDragGradient=e);var r=h.Lerp(o._currentDrag1,o._currentDrag2,i);s._scaledDirection.scaleInPlace(1-r)})),s.isLocal&&o._localPosition?(o._localPosition.addInPlace(s._scaledDirection),R.TransformCoordinatesToRef(o._localPosition,s._emitterWorldMatrix,o.position)):o.position.addInPlace(s._scaledDirection),l&&i&&o._randomNoiseCoordinates1){var f=s._fetchR(o._randomNoiseCoordinates1.x,o._randomNoiseCoordinates1.y,i.width,i.height,l),_=s._fetchR(o._randomNoiseCoordinates1.z,o._randomNoiseCoordinates2.x,i.width,i.height,l),m=s._fetchR(o._randomNoiseCoordinates2.y,o._randomNoiseCoordinates2.z,i.width,i.height,l),g=O.Vector3[0],v=O.Vector3[1];g.copyFromFloats((2*f-1)*s.noiseStrength.x,(2*_-1)*s.noiseStrength.y,(2*m-1)*s.noiseStrength.z),g.scaleToRef(a,v),o.direction.addInPlace(v)}if(s.gravity.scaleToRef(a,s._scaledGravity),o.direction.addInPlace(s._scaledGravity),s._sizeGradients&&s._sizeGradients.length>0&&FE.GetCurrentGradient(d,s._sizeGradients,(function(e,t,i){e!==o._currentSizeGradient&&(o._currentSize1=o._currentSize2,o._currentSize2=t.getFactor(),o._currentSizeGradient=e),o.size=h.Lerp(o._currentSize1,o._currentSize2,i)})),s._useRampGradients&&(s._colorRemapGradients&&s._colorRemapGradients.length>0&&FE.GetCurrentGradient(d,s._colorRemapGradients,(function(e,t,i){var r=h.Lerp(e.factor1,t.factor1,i),n=h.Lerp(e.factor2,t.factor2,i);o.remapData.x=r,o.remapData.y=n-r})),s._alphaRemapGradients&&s._alphaRemapGradients.length>0&&FE.GetCurrentGradient(d,s._alphaRemapGradients,(function(e,t,i){var r=h.Lerp(e.factor1,t.factor1,i),n=h.Lerp(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 DE(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 OE(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,e&&this._stopSubEmitters())},t.prototype.reset=function(){this._stockParticles.length=0,this._particles.length=0},t.prototype._appendParticleVertex=function(e,i,r,n){var o=e*this._vertexBufferSize;if(this._vertexData[o++]=i.position.x+this.worldOffset.x,this._vertexData[o++]=i.position.y+this.worldOffset.y,this._vertexData[o++]=i.position.z+this.worldOffset.z,this._vertexData[o++]=i.color.r,this._vertexData[o++]=i.color.g,this._vertexData[o++]=i.color.b,this._vertexData[o++]=i.color.a,this._vertexData[o++]=i.angle,this._vertexData[o++]=i.scale.x*i.size,this._vertexData[o++]=i.scale.y*i.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=i.cellIndex),this._isBillboardBased)this.billboardMode!==t.BILLBOARDMODE_STRETCHED&&this.billboardMode!==t.BILLBOARDMODE_STRETCHED_LOCAL||(this._vertexData[o++]=i.direction.x,this._vertexData[o++]=i.direction.y,this._vertexData[o++]=i.direction.z);else if(i._initialDirection){var a=i._initialDirection;this.isLocal&&(R.TransformNormalToRef(a,this._emitterWorldMatrix,O.Vector3[0]),a=O.Vector3[0]),0===a.x&&0===a.z&&(a.x=.001),this._vertexData[o++]=a.x,this._vertexData[o++]=a.y,this._vertexData[o++]=a.z}else{var s=i.direction;this.isLocal&&(R.TransformNormalToRef(s,this._emitterWorldMatrix,O.Vector3[0]),s=O.Vector3[0]),0===s.x&&0===s.z&&(s.x=.001),this._vertexData[o++]=s.x,this._vertexData[o++]=s.y,this._vertexData[o++]=s.z}this._useRampGradients&&i.remapData&&(this._vertexData[o++]=i.remapData.x,this._vertexData[o++]=i.remapData.y,this._vertexData[o++]=i.remapData.z,this._vertexData[o++]=i.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),0===n?n=this._epsilon:1===n&&(n=1-this._epsilon)),this._vertexData[o++]=r,this._vertexData[o++]=n)},t.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach((function(e){e.stop(!0)})),this.activeSubSystems=new Array)},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._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=I.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=h.Clamp(a._actualFrame/a.targetStopDuration);FE.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=h.Lerp(a,s,l)}))}else t.lifeTime=h.RandomRange(a.minLifeTime,a.maxLifeTime);var n=h.RandomRange(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(),R.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=h.RandomRange(a.minSize,a.maxSize),t.scale.copyFromFloats(h.RandomRange(a.minScaleX,a.maxScaleX),h.RandomRange(a.minScaleY,a.maxScaleY)),a._startSizeGradients&&a._startSizeGradients[0]&&a.targetStopDuration){var o=a._actualFrame/a.targetStopDuration;FE.GetCurrentGradient(o,a._startSizeGradients,(function(e,r,n){e!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=r.getFactor(),i._currentStartSizeGradient=e);var o=h.Lerp(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=h.RandomRange(a.minAngularSpeed,a.maxAngularSpeed),t.angle=h.RandomRange(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=h.RandomRange(0,1);U.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 C(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 R(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new R(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;FE.GetCurrentGradient(o,this._emitRateGradients,(function(e,t,r){e!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=t.getFactor(),i._currentEmitRateGradient=e),n=h.Lerp(i._currentEmitRate1,i._currentEmitRate2,r)}))}r=n*this._scaledUpdateSpeed>>0,this._newPartsExcess+=n*this._scaledUpdateSpeed-r}if(this._newPartsExcess>1&&(r+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),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&&(f.invertToRef(O.Matrix[0]),d.setMatrix("invView",O.Matrix[0])),void 0!==this._vertexArrayObject?(null===(n=this._scene)||void 0===n?void 0:n.forceWireframe)?p.bindBuffers(this._vertexBuffers,this._linesIndexBufferUseInstancing,d):(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,null,d)),this._engine.bindVertexArrayObject(this._vertexArrayObject,(null===(o=this._scene)||void 0===o?void 0:o.forceWireframe)?this._linesIndexBufferUseInstancing:this._indexBuffer)):this._indexBuffer?p.bindBuffers(this._vertexBuffers,(null===(l=this._scene)||void 0===l?void 0:l.forceWireframe)?this._linesIndexBuffer:this._indexBuffer,d):p.bindBuffers(this._vertexBuffers,(null===(s=this._scene)||void 0===s?void 0:s.forceWireframe)?this._linesIndexBufferUseInstancing:null,d),this.useLogarithmicDepth&&this._scene&&jn.BindLogDepth(g,d,this._scene),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(d),e){case t.BLENDMODE_ADD:p.setAlphaMode(a.ALPHA_ADD);break;case t.BLENDMODE_ONEONE:p.setAlphaMode(a.ALPHA_ONEONE);break;case t.BLENDMODE_STANDARD:p.setAlphaMode(a.ALPHA_COMBINE);break;case t.BLENDMODE_MULTIPLY:p.setAlphaMode(a.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(d),this._useInstancing?(null===(c=this._scene)||void 0===c?void 0:c.forceWireframe)?p.drawElementsType(a.MATERIAL_LineStripDrawMode,0,10,this._particles.length):p.drawArraysType(a.MATERIAL_TriangleStripDrawMode,0,4,this._particles.length):(null===(u=this._scene)||void 0===u?void 0:u.forceWireframe)?p.drawElementsType(a.MATERIAL_WireFrameFillMode,0,10*this._particles.length):p.drawElementsType(a.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 i;return i=this.blendMode===t.BLENDMODE_MULTIPLYADD?this._render(t.BLENDMODE_MULTIPLY)+this._render(t.BLENDMODE_ADD):this._render(this.blendMode),this._engine.unbindInstanceAttributes(),this._engine.setAlphaMode(a.ALPHA_DISABLE),i},t.prototype.dispose=function(e){if(void 0===e&&(e=!0),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._removeFromRoot(),this.subEmitters&&!this._subEmitters&&this._prepareSubEmitterInternalArray(),this._subEmitters&&this._subEmitters.length){for(var t=0;t-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose()),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onStoppedObservable.clear(),this.reset()},t.prototype.clone=function(e,i,r){void 0===r&&(r=!1);var n=H({},this._customWrappers),o=null,a=this._engine;if(a.createEffectForParticles&&null!=this.customShader){var s=(o=this.customShader).shaderOptions.defines.length>0?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.prototype.serialize=function(e){void 0===e&&(e=!1);var i={};if(t._Serialize(i,this,e),i.textureMask=this.textureMask.asArray(),i.customShader=this.customShader,i.preventAutoStart=this.preventAutoStart,this.subEmitters){i.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var r=0,n=this._subEmitters;r0?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&&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 ei(this._engine),this._customWrappers[t].effect=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new u),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 OE(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 NE(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===BE.BILLBOARDMODE_STRETCHED&&(r.direction=t.createVertexBuffer("direction",n,3,this._attributesStrideSize,!0)),n+=3,this._platform.alignDataInBuffer&&(n+=1),this.particleEmitterType instanceof ja&&(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=new Array;this._attributesStrideSize=21,this._targetIndex=0,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1),this.particleEmitterType instanceof ja&&(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 ja,n=O.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 Xi(t,c,!1,this._attributesStrideSize),this._buffer1=new Xi(t,u,!1,this._attributesStrideSize),this._spriteBuffer=new Xi(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 ei(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=[ji.PositionKind,"age","life","size","angle"];return e||n.push(ji.ColorKind),t&&n.push("cellIndex"),i||n.push("initialDirection"),r&&n.push("direction"),n.push("offset",ji.UVKind),n},t._GetEffectCreationOptions=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1);var i=["emitterWM","worldOffset","view","projection","colorDead","invView","translationPivot","eyePosition"];return kn(i),e&&i.push("sheetInfos"),t&&i.push("logarithmicDepthConstant"),i},t.prototype.fillDefines=function(e,t){if(void 0===t&&(t=0),this._scene&&Gn(this,this._scene,e),t===BE.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 BE.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case BE.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case BE.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===BE.BILLBOARDMODE_STRETCHED)),e.push.apply(e,t._GetEffectCreationOptions(this._isAnimationSheetEnabled,this.useLogarithmicDepth)),r.push("diffuseSampler","colorGradientSampler"),this._imageProcessingConfiguration&&(Li.PrepareUniforms(e,this._imageProcessingConfigurationDefines),Li.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;FE.GetCurrentGradient(i,e,(function(e,i,n){r[t]=h.Lerp(e.factor1,i.factor1,n)}))},o=this,s=0;s=0){var f=u.clone();f.invert(),c.setMatrix("invView",f)}switch(this.useLogarithmicDepth&&this._scene&&jn.BindLogDepth(p,c,this._scene),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(c),e){case BE.BLENDMODE_ADD:this._engine.setAlphaMode(a.ALPHA_ADD);break;case BE.BLENDMODE_ONEONE:this._engine.setAlphaMode(a.ALPHA_ONEONE);break;case BE.BLENDMODE_STANDARD:this._engine.setAlphaMode(a.ALPHA_COMBINE);break;case BE.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(a.ALPHA_MULTIPLY)}return this._platform.bindDrawBuffers(this._targetIndex,c,(null===(n=this._scene)||void 0===n?void 0:n.forceWireframe)?this._linesIndexBufferUseInstancing:null),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(c),(null===(o=this._scene)||void 0===o?void 0:o.forceWireframe)?this._engine.drawElementsType(a.MATERIAL_LineStripDrawMode,0,10,this._currentActiveCount):this._engine.drawArraysType(a.MATERIAL_TriangleStripDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(a.ALPHA_DISABLE),(null===(s=this._scene)||void 0===s?void 0:s.forceWireframe)&&this._engine.unbindInstanceAttributes(),this._currentActiveCount},t.prototype._update=function(e){if(this.emitter&&this._targetBuffer&&this._recreateUpdateEffect()){if(!e)if(this.emitter.position)e=this.emitter.getWorldMatrix();else{var t=this.emitter;e=O.Matrix[0],I.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=O.Matrix[0],I.TranslationToRef(o.x,o.y,o.z,n)}var s=this._engine;this.updateInAnimate||this._update(n);var l=0;return e||t||(s.setState(!1),this.forceDepthWrite&&s.setDepthWrite(!0),l=this.blendMode===BE.BLENDMODE_MULTIPLYADD?this._render(BE.BLENDMODE_MULTIPLY,n)+this._render(BE.BLENDMODE_ADD,n):this._render(this.blendMode,n),this._engine.setAlphaMode(a.ALPHA_DISABLE)),l},t.prototype.rebuild=function(){var e=this,t=function(){e._recreateUpdateEffect()&&e._platform.isUpdateBufferReady()?e._initialize(!0):setTimeout(t,10)};this._createIndexBuffer(),this._cachedUpdateDefines="",this._platform.contextLost(),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 BE._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 ri?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),BE._Parse(e,l,i,r),e.preventAutoStart&&(l.preventAutoStart=e.preventAutoStart),n||l.preventAutoStart||l.start(),l},t}(Ka),VE=function(){function e(){this._emitterNodeIsOwned=!0,this.systems=new Array}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,ji.UVKind),this._colors32.length>0&&i.set(this._colors32,ji.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=R.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 P=this.nbParticles,I=this._posToShape(f),M=this._uvsToShapeUV(g),O=m.slice(),D=v.slice(),N=_.slice();y.copyFromFloats(0,0,0);var F=void 0;for(F=0;F65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var k=null!==b.materialIndex?b.materialIndex:0;this.depthSortedParticles.push(new HE(d,t,n.length,k))}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 B=this.mesh.getBoundingInfo();B&&(v.copyFrom(B.minimum),y.copyFrom(B.maximum))}var U=(M=this.particles[e]._pos)/3|0;N=4*U,L=2*U;for(var V=e;V<=t;V++){var k=this.particles[V];this.updateParticle(k);var G=k._model._shape,z=k._model._shapeUV,W=k._rotationMatrix,H=k.position,X=k.rotation,j=k.scaling,Y=k._globalPosition;if(p){var K=this.depthSortedParticles[V];K.idx=k.idx,K.ind=k._ind,K.indicesLength=k._model._indicesLength,K.sqDistance=R.DistanceSquared(k.position,b)}if(k.alive&&(!k._stillInvisible||k.isVisible||this._recomputeInvisibles)){if(k.isVisible){k._stillInvisible=!1;var Q=f[12];if(k.pivot.multiplyToRef(j,Q),this.billboard&&(X.x=0,X.y=0),(this._computeParticleRotation||this.billboard)&&k.getRotationMatrix(r),null!==k.parentId){var q=this.getParticleById(k.parentId);if(q){var Z=q._rotationMatrix,J=q._globalPosition,$=H.x*Z[1]+H.y*Z[4]+H.z*Z[7],ee=H.x*Z[0]+H.y*Z[3]+H.z*Z[6],te=H.x*Z[2]+H.y*Z[5]+H.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;W[0]=ie[0]*Z[0]+ie[1]*Z[3]+ie[2]*Z[6],W[1]=ie[0]*Z[1]+ie[1]*Z[4]+ie[2]*Z[7],W[2]=ie[0]*Z[2]+ie[1]*Z[5]+ie[2]*Z[8],W[3]=ie[4]*Z[0]+ie[5]*Z[3]+ie[6]*Z[6],W[4]=ie[4]*Z[1]+ie[5]*Z[4]+ie[6]*Z[7],W[5]=ie[4]*Z[2]+ie[5]*Z[5]+ie[6]*Z[8],W[6]=ie[8]*Z[0]+ie[9]*Z[3]+ie[10]*Z[6],W[7]=ie[8]*Z[1]+ie[9]*Z[4]+ie[10]*Z[7],W[8]=ie[8]*Z[2]+ie[9]*Z[5]+ie[10]*Z[8]}}else k.parentId=null}else Y.x=H.x,Y.y=H.y,Y.z=H.z,(this._computeParticleRotation||this.billboard)&&(ie=r.m,W[0]=ie[0],W[1]=ie[1],W[2]=ie[2],W[3]=ie[4],W[4]=ie[5],W[5]=ie[6],W[6]=ie[8],W[7]=ie[9],W[8]=ie[10]);var re=f[11];for(k.translateFromPivot?re.setAll(0):re.copyFrom(Q),w=0;w0)for(var t=0;t0&&t.set(this._uvs32,ji.UVKind);var i=0;this._colors32.length>0&&(i=1,t.set(this._colors32,ji.ColorKind));var r=new io(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 _c("point cloud material",this._scene)).emissiveColor=new B(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 YE(e,t,i,r,this);return this.particles.push(n),n},e.prototype._randomUnitVector=function(e){e.position=new R(Math.random(),Math.random(),Math.random()),e.color=new U(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 U(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(ji.PositionKind),u=e.getIndices(),d=e.getVerticesData(ji.UVKind+(s?s+1:"")),p=e.getVerticesData(ji.ColorKind),f=R.Zero();e.computeWorldMatrix();var _=e.getWorldMatrix();if(!_.isIdentity()){c=c.slice(0);for(var m=0;m1&&(Le=1),(we=Be.b+Ne)<0&&(we=0),we>1&&(we=1),B.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 U(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 $.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 $.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){go.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,_,m,g,v,y,b=new Array,T=R.Zero(),E=R.Zero(),S=R.Zero(),x=R.Zero(),A=R.Zero(),C=R.Zero(),P=new Array,I=0,M=i.length/3,O=0;O0&&(b=b.map((function(e){return e+F}))),O=0;O3)&&(o=GE.Random);var a=e.getVerticesData(ji.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new KE(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===GE.Color?l._textureNb=r||0:r=r||new U(1,1,1,1),o){case GE.Color:this._colorFromTexture(e,l,!1);break;case GE.UV:this._setPointsColorOrUV(e,l,!1,!1,!1);break;case GE.Random:this._setPointsColorOrUV(e,l,!1);break;case GE.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||GE.Random;(isNaN(o)||o<0||o>3)&&(o=GE.Random);var a=e.getVerticesData(ji.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new KE(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===GE.Color?l._textureNb=r||0:r=r||new U(1,1,1,1),o){case GE.Color:this._colorFromTexture(e,l,!0);break;case GE.UV:this._setPointsColorOrUV(e,l,!0,!1,!1);break;case GE.Random:this._setPointsColorOrUV(e,l,!0);break;case GE.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=O.Matrix[0],a=this.mesh,s=this._colors32,l=this._positions32,c=this._uvs32,u=O.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);I.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 R=this.particles[E.parentId],C=R._rotationMatrix,P=R._globalPosition,M=x.x*C[1]+x.y*C[4]+x.z*C[7],D=x.x*C[0]+x.y*C[3]+x.z*C[6],N=x.x*C[2]+x.y*C[5]+x.z*C[8];if(A.x=P.x+D,A.y=P.y+M,A.z=P.z+N,this._computeParticleRotation){var F=o.m;S[0]=F[0]*C[0]+F[1]*C[3]+F[2]*C[6],S[1]=F[0]*C[1]+F[1]*C[4]+F[2]*C[7],S[2]=F[0]*C[2]+F[1]*C[5]+F[2]*C[8],S[3]=F[4]*C[0]+F[5]*C[3]+F[6]*C[6],S[4]=F[4]*C[1]+F[5]*C[4]+F[6]*C[7],S[5]=F[4]*C[2]+F[5]*C[5]+F[6]*C[8],S[6]=F[8]*C[0]+F[9]*C[3]+F[10]*C[6],S[7]=F[8]*C[1]+F[9]*C[4]+F[10]*C[7],S[8]=F[8]*C[2]+F[9]*C[5]+F[10]*C[8]}}else A.x=0,A.y=0,A.z=0,this._computeParticleRotation&&(F=o.m,S[0]=F[0],S[1]=F[1],S[2]=F[2],S[3]=F[4],S[4]=F[5],S[5]=F[6],S[6]=F[8],S[7]=F[9],S[8]=F[10]);var L=u[11];E.translateFromPivot?L.setAll(0):L.copyFrom(E.pivot);var w=u[0];w.copyFrom(E.position);var B=w.x-E.pivot.x,U=w.y-E.pivot.y,V=w.z-E.pivot.z,k=B*S[0]+U*S[3]+V*S[6],G=B*S[1]+U*S[4]+V*S[7],z=B*S[2]+U*S[5]+V*S[8];k+=L.x,G+=L.y,z+=L.z;var W=l[v]=A.x+h.x*k+d.x*G+p.x*z,H=l[v+1]=A.y+h.y*k+d.y*G+p.y*z,X=l[v+2]=A.z+h.z*k+d.z*G+p.z*z;if(this._computeBoundingBox&&(f.minimizeInPlaceFromFloats(W,H,X),_.maximizeInPlaceFromFloats(W,H,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(ji.ColorKind,s,!1,!1),this._computeParticleTexture&&a.updateVerticesData(ji.UVKind,c,!1,!1),a.updateVerticesData(ji.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 R(-t,-t,-t),new R(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(Vn.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}),Vn.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},Vn.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},Vn.prototype.setPhysicsLinkWith=function(e,t,i,r){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,Qo.HingeJoint,{mainPivot:t,connectedPivot:i,nativeParams:r}),this):this};var qE,ZE,JE,$E,eS,tS,iS,rS=function(){function e(t,i){void 0===i&&(i=e.DefaultPluginFactory()),this._physicsPlugin=i,this._physicsBodies=[],this._subTimeStep=0,t=t||new R(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return e.prototype.getPluginVersion=function(){return this._physicsPlugin.getPluginVersion()},e.DefaultPluginFactory=function(){throw ve("")},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 sg;return this._physicsPlugin.raycast(e,t,r,i),r},e}(),nS=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._isDisposed=!1,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=P.FromEulerAngles(e.rotation.x,e.rotation.y,e.rotation.z)),this.startAsleep=i;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,"shape",{get:function(){return this._physicsPlugin.getShape(this)},set:function(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._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){return this._physicsPlugin.getLinearVelocityToRef(this,e,t)},e.prototype.getLinearVelocity=function(e){var t=new R;return this.getLinearVelocityToRef(t,e),t},e.prototype.setAngularVelocity=function(e,t){this._physicsPlugin.setAngularVelocity(this,e,t)},e.prototype.getAngularVelocityToRef=function(e,t){return this._physicsPlugin.getAngularVelocityToRef(this,e,t)},e.prototype.getAngularVelocity=function(e){var t=new R;return this.getAngularVelocityToRef(t,e),t},e.prototype.applyImpulse=function(e,t,i){this._physicsPlugin.applyImpulse(this,e,t,i)},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 R;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=O.Quaternion[0];e.getRotationQuaternionToRef(xr.WORLD,t,s),s.multiplyToRef(n,a.rotationQuaternion)}else e.getRotationQuaternionToRef(xr.WORLD,t,a.rotationQuaternion);var l=O.Vector3[0],c=O.Vector3[1];o||((o=O.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=O.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=O.Vector3[1];if(u.copyFrom(l.minimum),u.multiplyInPlace(this.transformNode.scaling),!this._options.center){var d=new R;d.copyFrom(l.center),d.multiplyInPlace(this.transformNode.scaling),this._options.center=d}switch(this.type){case $E.SPHERE:!this._options.radius&&h.WithinEpsilon(c.x,c.y,1e-4)&&h.WithinEpsilon(c.x,c.z,1e-4)?this._options.radius=c.x/2:this._options.radius||($.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 $E.CAPSULE:var p=c.x/2;this._options.radius=null!==(e=this._options.radius)&&void 0!==e?e:p,this._options.pointA=null!==(t=this._options.pointA)&&void 0!==t?t:new R(0,u.y+p,0),this._options.pointB=null!==(i=this._options.pointB)&&void 0!==i?i:new R(0,u.y+c.y-p,0);break;case $E.CYLINDER:p=c.x/2,this._options.radius=null!==(r=this._options.radius)&&void 0!==r?r:p,this._options.pointA=null!==(n=this._options.pointA)&&void 0!==n?n:new R(0,u.y,0),this._options.pointB=null!==(o=this._options.pointB)&&void 0!==o?o:new R(0,u.y+c.y,0);break;case $E.MESH:case $E.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 $E.BOX:this._options.extents=null!==(a=this._options.extents)&&void 0!==a?a:new R(c.x,c.y,c.z),this._options.rotation=null!==(s=this._options.rotation)&&void 0!==s?s:P.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}(),AS=function(){function e(e,t,i){this._vertices=[],this._indices=[],this._isRightHanded=i.useRightHandedSystem,this._collectIndices=t}return e.prototype.addNodeMeshes=function(e,t){var i=this;e.computeWorldMatrix(!0);var r=O.Matrix[0];if(I.ScalingToRef(e.absoluteScaling.x,e.absoluteScaling.y,e.absoluteScaling.z,r),e instanceof io?this._addMesh(e,r):e instanceof ro&&this._addMesh(e.sourceMesh,r),t){var n=O.Matrix[1];e.computeWorldMatrix().invertToRef(n);var o=O.Matrix[2];n.multiplyToRef(r,o),e.getChildMeshes(!1).filter((function(e){return!e.physicsBody})).forEach((function(e){var t=e.computeWorldMatrix(),r=O.Matrix[3];t.multiplyToRef(o,r),e instanceof io?i._addMesh(e,r):e instanceof ro&&i._addMesh(e.sourceMesh,r)}))}},e.prototype._addMesh=function(e,t){for(var i=e.getVerticesData(ji.PositionKind)||[],r=i.length/3,n=this._vertices.length,o=0;o0)for(var t=0,i=e._pluginDataInstances;ta){this._createOrUpdateBodyInstances(e,s,o,a,n,!1);for(var l=this._hknp.HP_Body_GetShape(e._pluginDataInstances[0].hpBodyId)[1],c=a;c0&&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)$.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(R.Zero()),m=null!==(a=h.axisA)&&void 0!==a?a:new R(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(R.Zero()),y=null!==(s=h.axisB)&&void 0!==s?s:new R(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 R(_[0],_[1],_[2]),pivotB:new R(v[0],v[1],v[2])}),u==JE.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==JE.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==JE.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==JE.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==JE.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==JE.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!=JE.SIX_DOF)throw new Error("Unsupported Constraint Type.");for(var S=0,x=e.limits;S0){var c=this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector,0)[1],u=c[1][3],h=c[1][4],d=c[1][5];i.setHitData({x:h[0],y:h[1],z:h[2]},{x:u[0],y:u[1],z:u[2]},d),i.calculateHitDistance();var p=this._bodies.get(c[1][0][0]);i.body=null==p?void 0:p.body,i.bodyIndex=null==p?void 0:p.index}},e.prototype.getCollisionObservable=function(e){var t=e._pluginData.hpBodyId[0],i=this._bodyCollisionObservable.get(t);return i||(i=new u,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 u,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 IS;e;){IS.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 PS,i=Number(this.world);e;){PS.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===tS.COLLISION_FINISHED)this.onCollisionEndedObservable.notifyObservers(o);else{t.contactOnB.position.subtractToRef(t.contactOnA.position,this._tmpVec3[0]);var a=R.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!==tS.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 eS.POSITION:return this._hknp.ConstraintMotorType.POSITION;case eS.VELOCITY:return this._hknp.ConstraintMotorType.VELOCITY}return this._hknp.ConstraintMotorType.NONE},e.prototype._nativeToMotorType=function(e){switch(e){case this._hknp.ConstraintMotorType.POSITION:return eS.POSITION;case this._hknp.ConstraintMotorType.VELOCITY:return eS.VELOCITY}return eS.NONE},e.prototype._materialCombineToNative=function(e){switch(e){case oS.GEOMETRIC_MEAN:return this._hknp.MaterialCombine.GEOMETRIC_MEAN;case oS.MINIMUM:return this._hknp.MaterialCombine.MINIMUM;case oS.MAXIMUM:return this._hknp.MaterialCombine.MAXIMUM;case oS.ARITHMETIC_MEAN:return this._hknp.MaterialCombine.ARITHMETIC_MEAN;case oS.MULTIPLY:return this._hknp.MaterialCombine.MULTIPLY}},e.prototype._constraintAxisToNative=function(e){switch(e){case ZE.LINEAR_X:return this._hknp.ConstraintAxis.LINEAR_X;case ZE.LINEAR_Y:return this._hknp.ConstraintAxis.LINEAR_Y;case ZE.LINEAR_Z:return this._hknp.ConstraintAxis.LINEAR_Z;case ZE.ANGULAR_X:return this._hknp.ConstraintAxis.ANGULAR_X;case ZE.ANGULAR_Y:return this._hknp.ConstraintAxis.ANGULAR_Y;case ZE.ANGULAR_Z:return this._hknp.ConstraintAxis.ANGULAR_Z;case ZE.LINEAR_DISTANCE:return this._hknp.ConstraintAxis.LINEAR_DISTANCE}},e.prototype._nativeToLimitMode=function(e){switch(e){case this._hknp.ConstraintAxisLimitMode.FREE:return qE.FREE;case this._hknp.ConstraintAxisLimitMode.LIMITED:return qE.LIMITED;case this._hknp.ConstraintAxisLimitMode.LOCKED:return qE.LOCKED}return qE.FREE},e.prototype._limitModeToNative=function(e){switch(e){case qE.FREE:return this._hknp.ConstraintAxisLimitMode.FREE;case qE.LIMITED:return this._hknp.ConstraintAxisLimitMode.LIMITED;case qE.LOCKED:return this._hknp.ConstraintAxisLimitMode.LOCKED}},e.prototype._nativeCollisionValueToCollisionType=function(e){switch(e){case this._hknp.EventType.COLLISION_STARTED.value:return tS.COLLISION_STARTED;case this._hknp.EventType.COLLISION_FINISHED.value:return tS.COLLISION_FINISHED;case this._hknp.EventType.COLLISION_CONTINUED.value:return tS.COLLISION_CONTINUED}return tS.COLLISION_STARTED},e.prototype._nativeTriggerCollisionValueToCollisionType=function(e){switch(e){case 8:return tS.TRIGGER_ENTERED;case 16:return tS.TRIGGER_EXITED}return tS.TRIGGER_ENTERED},e}();Ar.prototype.getPhysicsEngine=function(){return this._physicsEngine},Ar.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var i=this._getComponent(Ji.NAME_PHYSICSENGINE);i||(i=new OS(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 rS(e,t)}else this._physicsEngine=new lg(e,t);return this._physicsTimeAccumulator=0,!0}catch(e){return $.Error(e.message),!1}},Ar.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},Ar.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},Ar.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},Ar.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 OS=function(){function e(e){var t=this;this.name=Ji.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new u,this.scene.onAfterPhysicsObservable=new u,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(Ln.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}),Ln.prototype.getPhysicsBody=function(){return this.physicsBody},Ln.prototype.applyImpulse=function(e,t){if(!this.physicsBody)throw new Error("No Physics Body for TransformNode");return this.physicsBody.applyImpulse(e,t),this};var DS,NS,FS=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 Fo(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)===iS.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=O.Vector3[0];return e.subtractToRef(t,n),Math.abs(n.x)<=i&&Math.abs(n.z)<=i&&n.y>=0&&n.y<=r},e}(),LS=function(){function e(e){this._hitData={force:new R,contactPoint:new R,distanceFromOrigin:0},this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||$.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 $.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 kS).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 wS(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 $.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 kS).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 wS(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===DS.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(FS.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=gu("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}(),BS=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=H(H({},new kS),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}(),US=function(){function e(e,t,i){var r=this;this._scene=e,this._origin=t,this._options=i,this._originTop=R.Zero(),this._originDirection=R.Zero(),this._cylinderPosition=R.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=H(H({},new GS),this._options),this._origin.addToRef(new R(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new R(0,this._options.height,0),this._originTop),this._options.updraftMode===NS.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===NS.Perpendicular?this._originDirection:e.subtract(this._originTop);var r=R.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(FS.HasAppliedForces(e))return!1;var r=e.getObjectCenterWorld(i);return!!FS.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=eu("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 R,contactPoint:new R,distanceFromOrigin:0},e}(),VS=function(){function e(e,t,i){var r=this;this._scene=e,this._origin=t,this._options=i,this._originTop=R.Zero(),this._cylinderPosition=R.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=H(H({},new zS),this._options),this._origin.addToRef(new R(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new R(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=O.Vector3[0];i.subtractToRef(n,o);var a=O.Vector3[1];if(!FS.GetContactPointToRef(t,n,o,a,r.instanceIndex))return!1;var s,l,c,u=R.Distance(a,n)/this._options.radius,h=O.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=R.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=O.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(FS.HasAppliedForces(e,i))return!1;var r=e.transformNode,n=e.getObjectCenterWorld(i);return!!FS.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=eu("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=R.Zero(),e.hitData={force:new R,contactPoint:new R,distanceFromOrigin:0},e}(),kS=function(){this.radius=5,this.strength=10,this.falloff=DS.Constant,this.sphere={segments:32,diameter:1}},GS=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=NS.Center},zS=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"}(DS||(DS={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(NS||(NS={}));kt.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 WS=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 W(t,e),t.prototype.getClassName=function(){return"BlackAndWhitePostProcess"},t._Parse=function(e,i,r,n){return Ve.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.reusable)}),e,r,n)},X([Ae()],t.prototype,"degree",void 0),t}(Na);b("BABYLON.BlackAndWhitePostProcess",WS);var HS=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?a.TEXTUREFORMAT_RED:a.TEXTUREFORMAT_RGBA;s._circleOfConfusion=new QS("circleOfConfusion",i,1,null,Eo.BILINEAR_SAMPLINGMODE,l,!1,n,o),s._depthOfFieldBlurY=[],s._depthOfFieldBlurX=[];var u=1,h=15;switch(r){case $S.High:u=3,h=51;break;case $S.Medium:u=2,h=31;break;default:h=15,u=1}for(var d=h/Math.pow(2,u-1),p=1,f=0;f-1?"#define MALI 1\n":null},t._Parse=function(e,i,r,n){return Ve.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.reusable)}),e,r,n)},t}(Na);b("BABYLON.FxaaPostProcess",nx);kt.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 ox=function(e){function t(t,i,r,n,o,s,l,c){void 0===l&&(l=a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var u=e.call(this,t,"grain",["intensity","animatedSeed"],[],i,r,n,o,s,null,l,void 0,null,c)||this;return u.intensity=30,u.animated=!1,u.onApplyObservable.add((function(e){e.setFloat("intensity",u.intensity),e.setFloat("animatedSeed",u.animated?Math.random()+1:1)})),u}return W(t,e),t.prototype.getClassName=function(){return"GrainPostProcess"},t._Parse=function(e,i,r,n){return Ve.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.reusable)}),e,r,n)},X([Ae()],t.prototype,"intensity",void 0),X([Ae()],t.prototype,"animated",void 0),t}(Na);b("BABYLON.GrainPostProcess",ox);kt.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 ax=function(e){function t(t,i,r,n,o,s,l){return void 0===l&&(l=a.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,"highlights",null,null,i,r,n,o,s,null,l)||this}return W(t,e),t.prototype.getClassName=function(){return"HighlightsPostProcess"},t}(Na);kt.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 sx=function(e){function t(t,i,r,n,o,s,l,c){void 0===r&&(r=null),void 0===l&&(l=a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,t,"imageProcessing",[],[],i,r,n,o,s,null,l,"postprocess",null,!0)||this;return u._fromLinearSpace=!0,u._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,DITHER:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1,SKIPFINALCOLORCLAMP:!1},c?(c.applyByPostProcess=!0,u._attachImageProcessingConfiguration(c,!0),u._updateParameters()):(u._attachImageProcessingConfiguration(null,!0),u.imageProcessingConfiguration.applyByPostProcess=!0),u.onApply=function(e){u.imageProcessingConfiguration.bind(e,u.aspectRatio)},u}return W(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=S.LastCreatedScene;this._imageProcessingConfiguration=r?r.imageProcessingConfiguration:new Li}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)this._defines[t]&&(e+="#define ".concat(t,";\n"));var i=["textureSampler"],r=["scale"];Li&&(Li.PrepareSamplers(i,this._defines),Li.PrepareUniforms(r,this._defines)),this.updateEffect(e,r,i)},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)},X([Ae()],t.prototype,"_fromLinearSpace",void 0),t}(Na);kt.IncludesShadersStore.mrtFragmentDeclaration="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";kt.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 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";kt.IncludesShadersStore.geometryVertexDeclaration="uniform mat4 viewProjection;uniform mat4 view;";kt.IncludesShadersStore.geometryUboDeclaration="#include\n";kt.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 lx=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"];kn(lx);var cx=function(){function e(t,i,r){void 0===i&&(i=1),void 0===r&&(r=a.TEXTUREFORMAT_DEPTH16),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this.generateNormalsInWorldSpace=!1,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._clearColor=new U(0,0,0,0),this._clearDepthColor=new U(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._ratio=i,this._useUbo=t.getEngine().supportsUniformBuffers,this._depthFormat=r,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return 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 this._ratio},enumerable:!1,configurable:!0}),e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;var r=[],n=[ji.PositionKind,ji.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&&tc.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()?(null!==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&&(null!==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),null!==i.baseColor&&r.push("#define ALBEDOCOLOR"))):"PBRSpecularGlossinessMaterial"===i.getClassName()?(null!==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")):null!==i.specularColor&&r.push("#define REFLECTIVITYCOLOR"),null!==i.glossiness&&r.push("#define GLOSSINESS")):"PBRMaterial"===i.getClassName()?(null!==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?(null!==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),null!==i.albedoColor&&r.push("#define ALBEDOCOLOR")):(null!==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):null!==i.reflectivityColor&&r.push("#define REFLECTIVITYCOLOR"),null!==i.microSurface&&r.push("#define GLOSSINESS"))):"StandardMaterial"===i.getClassName()&&(null!==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),null!==i.specularColor&&r.push("#define REFLECTIVITYCOLOR"))}a&&(r.push("#define NEED_UV"),o.isVerticesDataPresent(ji.UVKind)&&(n.push(ji.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(ji.UV2Kind)&&(n.push(ji.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"),o.useBones&&o.computeBonesUsingShaders?(n.push(ji.MatricesIndicesKind),n.push(ji.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(ji.MatricesIndicesExtraKind),n.push(ji.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&&l.numInfluencers>0&&(c=l.numInfluencers,r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+c),l.isUsingTextureForTargets&&r.push("#define MORPHTARGETS_TEXTURE"),jn.PrepareAttributesForMorphTargetsInfluencers(n,o,c)),t&&(r.push("#define INSTANCES"),jn.PushAttributesForInstances(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),Gn(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:lx,samplers:["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets"],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 e=[],t=2;return e.push("gBuffer_Depth","gBuffer_Normal"),this._enablePosition&&(this._positionIndex=t,t++,e.push("gBuffer_Position")),this._enableVelocity&&(this._velocityIndex=t,t++,e.push("gBuffer_Velocity")),this._enableReflectivity&&(this._reflectivityIndex=t,t++,e.push("gBuffer_Reflectivity")),[t,e]},e.prototype._createRenderTargets=function(){var e,t=this,i=this._scene.getEngine(),r=(e=this._assignRenderTargetIndices())[0],n=e[1],o=a.TEXTURETYPE_UNSIGNED_BYTE;if(i._caps.textureFloat&&i._caps.textureFloatLinearFiltering?o=a.TEXTURETYPE_FLOAT:i._caps.textureHalfFloat&&i._caps.textureHalfFloatLinearFiltering&&(o=a.TEXTURETYPE_HALF_FLOAT),this._multiRenderTarget=new sv("gBuffer",{width:i.getRenderWidth()*this._ratio,height:i.getRenderHeight()*this._ratio},r,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:o,depthTextureFormat:this._depthFormat},n.concat("gBuffer_DepthBuffer")),this.isSupported){this._multiRenderTarget.wrapU=Eo.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Eo.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null;for(var s=[!0],l=[!1],c=[!0],u=1;u0){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 sx("imageProcessing",1,null,Eo.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),this._hdr?(this.addEffect(new HS(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 nx("fxaa",1,null,Eo.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new HS(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&&$.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",s.bilateralSamples),e.setFloat("soften",s.bilateralSoften),e.setFloat("tolerance",s.bilateralTolerance),s._geometryBufferRenderer?e.setTexture("depthSampler",s._geometryBufferRenderer.getGBuffer().textures[0]):s._prePassRenderer&&e.setTexture("depthSampler",s._prePassRenderer.getRenderTarget().textures[s._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)])}},l.samples=this.textureSamples,l},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 R(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; i>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join("\n"))},t._Parse=function(e,i,r,n){return Ve.Parse((function(){return new t(e.name,r,e.options,i,e.renderTargetSamplingMode,r.getEngine(),e.textureType,e.reusable)}),e,r,n)},X([Ae()],t.prototype,"threshold",void 0),X([Ae()],t.prototype,"strength",void 0),X([Ae()],t.prototype,"reflectionSpecularFalloffExponent",void 0),X([Ae()],t.prototype,"step",void 0),X([Ae()],t.prototype,"roughnessFactor",void 0),X([Ae()],t.prototype,"enableSmoothReflections",null),X([Ae()],t.prototype,"reflectionSamples",null),X([Ae()],t.prototype,"smoothSteps",null),t}(Na);b("BABYLON.ScreenSpaceReflectionPostProcess",xx);kt.ShadersStore.standardPixelShader="uniform sampler2D textureSampler;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{vec4 color=texture2D(textureSampler,vUV);gl_FragColor=color;}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];void main(void)\n{vec4 average=vec4(0.0,0.0,0.0,0.0);average=texture2D(textureSampler,vUV+dsOffsets[0]);average+=texture2D(textureSampler,vUV+dsOffsets[1]);average+=texture2D(textureSampler,vUV+dsOffsets[2]);average+=texture2D(textureSampler,vUV+dsOffsets[3]);average+=texture2D(textureSampler,vUV+dsOffsets[4]);average+=texture2D(textureSampler,vUV+dsOffsets[5]);average+=texture2D(textureSampler,vUV+dsOffsets[6]);average+=texture2D(textureSampler,vUV+dsOffsets[7]);average+=texture2D(textureSampler,vUV+dsOffsets[8]);average+=texture2D(textureSampler,vUV+dsOffsets[9]);average+=texture2D(textureSampler,vUV+dsOffsets[10]);average+=texture2D(textureSampler,vUV+dsOffsets[11]);average+=texture2D(textureSampler,vUV+dsOffsets[12]);average+=texture2D(textureSampler,vUV+dsOffsets[13]);average+=texture2D(textureSampler,vUV+dsOffsets[14]);average+=texture2D(textureSampler,vUV+dsOffsets[15]);average/=16.0;gl_FragColor=average;}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];uniform float brightThreshold;void main(void)\n{vec4 average=vec4(0.0,0.0,0.0,0.0);average=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));average*=0.25;float luminance=length(average.rgb);if (luminanceshadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));currentPosition+=stepL;}\naccumFog/=NB_STEPS;vec3 color=accumFog*scatteringPower;gl_FragColor=vec4(color*exp(color) ,1.0);}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;void main(void)\n{gl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];void main()\n{float average=0.0;vec4 color=vec4(0.0);float maximum=-1e20;vec3 weight=vec3(0.299,0.587,0.114);for (int i=0; i<4; i++)\n{color=texture2D(textureSampler,vUV+ lumOffsets[i]);float GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);average+=(0.25*log(1e-5+GreyValue));}\naverage=exp(average);gl_FragColor=vec4(average,maximum,0.0,1.0);}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];uniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\n#include\n#endif\nvoid main()\n{vec4 color=vec4(0.0);float average=0.0;for (int i=0; i<9; i++)\n{color=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);average+=color.r;}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;uniform float averageLuminance;void main()\n{vec4 color=texture2D(textureAdderSampler,vUV);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;color=adjustedColor;color.a=1.0;\n#endif\ngl_FragColor=color;}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;uniform float strength;uniform float ghostDispersal;uniform float haloWidth;uniform vec2 resolution;uniform float distortionStrength;float hash(vec2 p)\n{float h=dot(p,vec2(127.1,311.7));return -1.0+2.0*fract(sin(h)*43758.5453123);}\nfloat noise(in vec2 p)\n{vec2 i=floor(p);vec2 f=fract(p);vec2 u=f*f*(3.0-2.0*f);return mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);}\nfloat fbm(vec2 p)\n{float f=0.0;f+=0.5000*noise(p); p*=2.02;f+=0.2500*noise(p); p*=2.03;f+=0.1250*noise(p); p*=2.01;f+=0.0625*noise(p); p*=2.04;f/=0.9375;return f;}\nvec3 pattern(vec2 uv)\n{vec2 p=-1.0+2.0*uv;float p2=dot(p,p);float f=fbm(vec2(15.0*p2))/2.0;float r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));float g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));float b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));return (1.0-f)*vec3(r,g,b);}\nfloat luminance(vec3 color)\n{return dot(color.rgb,vec3(0.2126,0.7152,0.0722));}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{return vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);}\nvoid main(void)\n{vec2 uv=-vUV+vec2(1.0);vec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;vec2 texelSize=1.0/resolution;vec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);vec4 result=vec4(0.0);float ghostIndice=1.0;for (int i=0; i=nSamples)\nbreak;vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);result+=texture2D(textureSampler,offset1);}\ngl_FragColor=result/float(nSamples);}\n#endif\n";var Ax=function(e){function t(t,i,r,n,o){void 0===n&&(n=null);var s=e.call(this,i.getEngine(),t)||this;return s.downSampleX4PostProcess=null,s.brightPassPostProcess=null,s.blurHPostProcesses=[],s.blurVPostProcesses=[],s.textureAdderPostProcess=null,s.volumetricLightPostProcess=null,s.volumetricLightSmoothXPostProcess=null,s.volumetricLightSmoothYPostProcess=null,s.volumetricLightMergePostProces=null,s.volumetricLightFinalPostProcess=null,s.luminancePostProcess=null,s.luminanceDownSamplePostProcesses=[],s.hdrPostProcess=null,s.textureAdderFinalPostProcess=null,s.lensFlareFinalPostProcess=null,s.hdrFinalPostProcess=null,s.lensFlarePostProcess=null,s.lensFlareComposePostProcess=null,s.motionBlurPostProcess=null,s.depthOfFieldPostProcess=null,s.fxaaPostProcess=null,s.screenSpaceReflectionPostProcess=null,s.brightThreshold=1,s.blurWidth=512,s.horizontalBlur=!1,s.lensTexture=null,s.volumetricLightCoefficient=.2,s.volumetricLightPower=4,s.volumetricLightBlurScale=64,s.sourceLight=null,s.hdrMinimumLuminance=1,s.hdrDecreaseRate=.5,s.hdrIncreaseRate=.5,s.lensColorTexture=null,s.lensFlareStrength=20,s.lensFlareGhostDispersal=1.4,s.lensFlareHaloWidth=.7,s.lensFlareDistortionStrength=16,s.lensFlareBlurWidth=512,s.lensStarTexture=null,s.lensFlareDirtTexture=null,s.depthOfFieldDistance=10,s.depthOfFieldBlurWidth=64,s.animations=[],s._currentDepthOfFieldSource=null,s._fixedExposure=1,s._currentExposure=1,s._hdrAutoExposure=!1,s._hdrCurrentLuminance=1,s._motionStrength=1,s._isObjectBasedMotionBlur=!1,s._camerasToBeAttached=[],s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._vlsEnabled=!1,s._lensFlareEnabled=!1,s._hdrEnabled=!1,s._motionBlurEnabled=!1,s._fxaaEnabled=!1,s._screenSpaceReflectionsEnabled=!1,s._motionBlurSamples=64,s._volumetricLightStepsCount=50,s._samples=1,s._cameras=o||i.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._scene=i,s._basePostProcess=n,s._ratio=r,s._floatTextureType=i.getEngine().getCaps().textureFloatRender?a.TEXTURETYPE_FLOAT:a.TEXTURETYPE_HALF_FLOAT,i.postProcessRenderPipelineManager.addPipeline(s),s._buildPipeline(),s}return W(t,e),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._fixedExposure},set:function(e){this._fixedExposure=e,this._currentExposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hdrAutoExposure",{get:function(){return this._hdrAutoExposure},set:function(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){var t=["#define HDR"];e&&t.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(t.join("\n"))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionStrength",{get:function(){return this._motionStrength},set:function(e){this._motionStrength=e,this._isObjectBasedMotionBlur&&this.motionBlurPostProcess&&(this.motionBlurPostProcess.motionStrength=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"objectBasedMotionBlur",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var t=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,t&&this._buildPipeline()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e&&!this._scene.enableGeometryBufferRenderer())return void $.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screenSpaceReflectionsEnabled",{get:function(){return this._screenSpaceReflectionsEnabled},set:function(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS "+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&(this._isObjectBasedMotionBlur?this.motionBlurPostProcess.motionBlurSamples=e:this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!1,configurable:!0}),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}),t.prototype._buildPipeline=function(){var e=this,t=this._ratio,i=this._scene;this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new xx("HDRPass",i,t,null,Eo.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess})),this.addEffect(new HS(i.getEngine(),"HDRScreenSpaceReflections",(function(){return e.screenSpaceReflectionPostProcess}),!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new Na("HDRPass","standard",[],[],t,null,Eo.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.autoClear=!this.screenSpaceReflectionPostProcess,this.originalPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.originalPostProcess})),this.addEffect(new HS(i.getEngine(),"HDRPassPostProcess",(function(){return e.originalPostProcess}),!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(i,t/4),this._createBrightPassPostProcess(i,t/4),this._createBlurPostProcesses(i,t/4,1),this._createTextureAdderPostProcess(i,t),this.textureAdderFinalPostProcess=new Na("HDRDepthOfFieldSource","standard",[],[],t,null,Eo.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new HS(i.getEngine(),"HDRBaseDepthOfFieldSource",(function(){return e.textureAdderFinalPostProcess}),!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,t),this.volumetricLightFinalPostProcess=new Na("HDRVLSFinal","standard",[],[],t,null,Eo.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new HS(i.getEngine(),"HDRVLSFinal",(function(){return e.volumetricLightFinalPostProcess}),!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,t),this.lensFlareFinalPostProcess=new Na("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,Eo.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new HS(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function(){return e.lensFlareFinalPostProcess}),!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,t),this.hdrFinalPostProcess=new Na("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,Eo.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new HS(i.getEngine(),"HDRPostHDReDepthOfFieldSource",(function(){return e.hdrFinalPostProcess}),!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(i,t/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(i,t)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(i,t),this._fxaaEnabled&&(this.fxaaPostProcess=new nx("fxaa",1,null,Eo.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new HS(i.getEngine(),"HDRFxaa",(function(){return e.fxaaPostProcess}),!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&$.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 Na("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Eo.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 HS(e.getEngine(),"HDRDownSampleX4",(function(){return i.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var i=this,r=new Array(8);this.brightPassPostProcess=new Na("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Eo.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 HS(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 a_("HDRBlurH_"+i,new A(1,0),this[r],t,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),s=new a_("HDRBlurV_"+i,new A(0,1),this[r],t,null,Eo.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 HS(e.getEngine(),"HDRBlurH"+i,(function(){return a}),!0)),this.addEffect(new HS(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 Na("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Eo.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 HS(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 Na("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var o=A.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 HS(e.getEngine(),"HDRVLS",(function(){return i.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new Na("HDRVLSMerge","standard",[],["originalSampler"],t,null,Eo.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 HS(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 Na("HDRLuminance","standard",["lumOffsets"],[],{width:n,height:n},null,Eo.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 HS(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 Na("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:n,height:n},null,Eo.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 C(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 HS(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 Na("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r.join("\n"),a.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",i._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),n<0)n=i._hdrCurrentLuminance;else{var r=(s-o)/1e3;i._hdrCurrentLuminancen-i.hdrIncreaseRate*r?n-=i.hdrIncreaseRate*r:n=i._hdrCurrentLuminance}i.hdrAutoExposure?i._currentExposure=i._fixedExposure/n:(n=h.Clamp(n,i.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",n)),s=o,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new HS(e.getEngine(),"HDR",(function(){return i.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var i=this;this.lensFlarePostProcess=new Na("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new HS(e.getEngine(),"HDRLensFlare",(function(){return i.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new Na("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new HS(e.getEngine(),"HDRLensFlareCompose",(function(){return i.lensFlareComposePostProcess}),!0));var r=new A(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=I.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),o=I.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=R.Dot(t.toVector3(),new R(1,0,0))+R.Dot(r.toVector3(),new R(0,0,1));a*=4;var s=I.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 Na("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",a.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 HS(e.getEngine(),"HDRDepthOfField",(function(){return i.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var i=this;if(this._isObjectBasedMotionBlur){var r=new dx("HDRMotionBlur",e,t,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT);r.motionStrength=this.motionStrength,r.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=r}else{this.motionBlurPostProcess=new Na("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Eo.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),a.TEXTURETYPE_UNSIGNED_INT);var n=0,o=I.Identity(),s=I.Identity(),l=I.Identity(),c=A.Zero();this.motionBlurPostProcess.onApply=function(t){(l=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(s),t.setMatrix("inverseViewProjection",s),t.setMatrix("prevViewProjection",o),o=l,c.x=i.motionBlurPostProcess.width,c.y=i.motionBlurPostProcess.height,t.setVector2("screenSize",c),n=e.getEngine().getFps()/60,t.setFloat("motionScale",n),t.setFloat("motionStrength",i.motionStrength),t.setTexture("depthSampler",i._getDepthTexture())}}this.addEffect(new HS(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\nndc.z=-projection[2].z-projection[3].z/depth;\n#else\nndc.z=projection[2].z+projection[3].z/depth;\n#endif\nndc.w=1.0;vec4 eyePos=invProjectionMatrix*ndc;eyePos.xyz/=eyePos.w;return eyePos.xyz;}\n";kt.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; \nfloat depth=texelFetch(depthSampler,ivec2(vUV*texSize),0).r;vec3 csPosition=computeViewPosFromUVDepth(vUV,depth,projection,invProjectionMatrix);vec3 csViewDirection=normalize(csPosition);vec3 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";kt.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";kt.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 Cx=I.Compose(new R(.5,.5,.5),P.Identity(),new R(.5,.5,.5)),Px=I.Compose(new R(.5,.5,1),P.Identity(),new R(.5,.5,0)),Ix=function(e){function t(t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=a.TEXTURETYPE_UNSIGNED_BYTE);var s=e.call(this,i.getEngine(),t)||this;if(s.SSRRenderEffect="SSRRenderEffect",s.SSRBlurRenderEffect="SSRBlurRenderEffect",s.SSRCombineRenderEffect="SSRCombineRenderEffect",s._samples=1,s.maxDistance=1e3,s.step=1,s.thickness=.5,s.strength=1,s.reflectionSpecularFalloffExponent=1,s.maxSteps=1e3,s.roughnessFactor=.2,s.selfCollisionNumSkip=1,s._reflectivityThreshold=.04,s._ssrDownsample=0,s._blurDispersionStrength=.03,s._blurDownsample=0,s._enableSmoothReflections=!1,s._environmentTextureIsProbe=!1,s._attenuateScreenBorders=!0,s._attenuateIntersectionDistance=!0,s._attenuateIntersectionIterations=!0,s._attenuateFacingCamera=!1,s._attenuateBackfaceReflection=!1,s._clipToFrustum=!0,s._useFresnel=!1,s._enableAutomaticThicknessComputation=!1,s._backfaceDepthTextureDownsample=0,s._backfaceForceDepthWriteTransparentMeshes=!0,s._isEnabled=!0,s._inputTextureColorIsInGammaSpace=!0,s._generateOutputInGammaSpace=!0,s._debug=!1,s._forceGeometryBuffer=!1,s._isDirty=!1,s._camerasToBeAttached=[],s._cameras=r||i.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._scene=i,s._textureType=o,s._forceGeometryBuffer=n,s.isSupported){if(i.postProcessRenderPipelineManager.addPipeline(s),s._forceGeometryBuffer){var l=i.enableGeometryBufferRenderer();l&&(l.enableReflectivity=!0,l.useSpecificClearForDepthTexture=!0,l.generateNormalsInWorldSpace&&console.error("SSRRenderingPipeline does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!"))}else{var c=i.enablePrePassRenderer();c&&(c.useSpecificClearForDepthTexture=!0,c.markAsDirty(),c.generateNormalsInWorldSpace&&console.error("SSRRenderingPipeline does not support generateNormalsInWorldSpace=true for the prepass renderer!"))}s._buildPipeline()}return s}return W(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(a.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=[];(this._geometryBufferRenderer||this._prePassRenderer)&&t.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&t.push("#define SSRAYTRACE_ENABLE_REFINEMENT"),this._scene.useRightHandedSystem&&t.push("#define SSRAYTRACE_RIGHT_HANDED_SCENE"),this._environmentTexture&&(t.push("#define SSR_USE_ENVIRONMENT_CUBE"),this._environmentTexture.boundingBoxSize&&t.push("#define SSR_USE_LOCAL_REFLECTIONMAP_CUBIC"),this._environmentTexture.gammaSpace&&t.push("#define SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE")),this._environmentTextureIsProbe&&t.push("#define SSR_INVERTCUBICMAP"),this._enableAutomaticThicknessComputation&&t.push("#define SSRAYTRACE_USE_BACK_DEPTHBUFFER"),this._attenuateScreenBorders&&t.push("#define SSR_ATTENUATE_SCREEN_BORDERS"),this._attenuateIntersectionDistance&&t.push("#define SSR_ATTENUATE_INTERSECTION_DISTANCE"),this._attenuateIntersectionIterations&&t.push("#define SSR_ATTENUATE_INTERSECTION_NUMITERATIONS"),this._attenuateFacingCamera&&t.push("#define SSR_ATTENUATE_FACING_CAMERA"),this._attenuateBackfaceReflection&&t.push("#define SSR_ATTENUATE_BACKFACE_REFLECTION"),this._clipToFrustum&&t.push("#define SSRAYTRACE_CLIP_TO_FRUSTUM"),this._useBlur()&&t.push("#define SSR_USE_BLUR"),this._debug&&t.push("#define SSRAYTRACE_DEBUG"),this._inputTextureColorIsInGammaSpace&&t.push("#define SSR_INPUT_IS_GAMMA_SPACE"),this._generateOutputInGammaSpace&&t.push("#define SSR_OUTPUT_IS_GAMMA_SPACE"),this._useFresnel&&t.push("#define SSR_BLEND_WITH_FRESNEL"),0===this._reflectivityThreshold&&t.push("#define SSR_DISABLE_REFLECTIVITY_TEST"),null===(e=this._ssrPostProcess)||void 0===e||e.updateEffect(t.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 zm(this._scene,void 0,void 0,void 0,a.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 HS(i,this.SSRRenderEffect,(function(){return t._ssrPostProcess}),!0)),this._useBlur()&&(this._createBlurAndCombinerPostProcesses(),this.addEffect(new HS(i,this.SSRBlurRenderEffect,(function(){return[t._blurPostProcessX,t._blurPostProcessY]}),!0)),this.addEffect(new HS(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 ns("volumetricLightScatteringMap",{width:r.getRenderWidth()*t,height:r.getRenderHeight()*t},e,!1,!0,a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Eo.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Eo.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,s=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,Kn.TriangleFillMode,l,c,(function(e,t){e||d.setMatrix("world",t)}))}}}}},l=new U(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=e.clearColor,e.clearColor=l})),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})),l.setAlphaMode(a.ALPHA_COMBINE),o=0;o\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";kt.ShadersStore.lineVertexShader="#include\n#include\nattribute vec3 position;attribute vec4 normal;uniform mat4 viewProjection;uniform float width;uniform float aspectRatio;\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#define CUSTOM_VERTEX_MAIN_END\n}",Vn.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},Vn.prototype.enableEdgesRendering=function(e,t,i){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new kx(this,e,t,!0,i),this},Object.defineProperty(Vn.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),Vu.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Gx(this,e,t),this},ku.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),Vu.prototype.enableEdgesRendering.apply(this,arguments),this};var Vx=function(){this.edges=new Array,this.edgesConnectedCount=0},kx=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 Ii(32),this._source=e,this._checkVerticesInsteadOfIndices=i,this._options=null!=n?n:null,this._epsilon=t,this._source.getScene().getEngine().isWebGPU&&(this._drawWrapper=new ei(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 Uu("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[ji.PositionKind];e&&e._rebuild(),(e=this._buffers[ji.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[ji.PositionKind];t&&(t.dispose(),this._buffers[ji.PositionKind]=null),(t=this._buffers[ji.NormalKind])&&(t.dispose(),this._buffers[ji.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||R.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(ji.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;gL){var te=F;F=L,L=te}(re=$[ie=F+"_"+L])?re.done||(R.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 s=0,l=0;l0&&(this._useSpecificClearForDepthTexture&&this._mrtLayout[n]===a.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 $.Error("You already reached the maximum number of diffusion profiles."),0;for(var t=0;t4&&(n.push(ji.MatricesIndicesExtraKind),n.push(ji.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&&l.numInfluencers>0&&(c=l.numInfluencers,r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+c),l.isUsingTextureForTargets&&r.push("#define MORPHTARGETS_TEXTURE"),jn.PrepareAttributesForMorphTargetsInfluencers(n,o,c)),t&&(r.push("#define INSTANCES"),jn.PushAttributesForInstances(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","morphTargetTextureInfo","morphTargetTextureIndices"];kn(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(a.REPLACE),this._engine.setStencilFunction(a.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(a.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(a.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}(),qx=function(){function e(e){this.priority=0,this._particleSize=.1,this.onParticleSizeChanged=new u,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 Ja({engine:this._engine,useShaderStore:!0,vertexShader:"fluidRenderingParticleDepth",fragmentShader:"fluidRenderingParticleDepth",attributeNames:t,uniformNames:e,samplerNames:[],defines:i}),e.push("particleAlpha"),this._thicknessEffectWrapper=new Ja({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(a.MATERIAL_TriangleStripDrawMode,0,4,e):this._engine.drawElementsType(a.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(a.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(a.MATERIAL_TriangleStripDrawMode,0,4,e):this._engine.drawElementsType(a.MATERIAL_TriangleFillMode,0,e),this._engine.setDepthWrite(!0),this._engine.setAlphaMode(a.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}(),Zx=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 W(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(a.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}(qx),Jx=function(){function e(e,t,i,r,n,o,s,l,c,h,d,p,f,_){void 0===s&&(s=a.TEXTURETYPE_FLOAT),void 0===l&&(l=a.TEXTUREFORMAT_R),void 0===c&&(c=a.TEXTURETYPE_FLOAT),void 0===h&&(h=a.TEXTUREFORMAT_R),void 0===d&&(d=!1),void 0===p&&(p=null),void 0===f&&(f=!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 u,this._name=e,this._scene=t,this._camera=p,this._engine=t.getEngine(),this._width=i,this._height=r,this._blurTextureSizeX=n,this._blurTextureSizeY=o,this._textureType=s,this._textureFormat=l,this._blurTextureType=c,this._blurTextureFormat=h,this._useStandardBlur=d,this._generateDepthBuffer=f,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:a.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 Eo(null,this._scene),this._texture.name="rtt"+this._name,this._texture._texture=e,this._texture.wrapU=Eo.CLAMP_ADDRESSMODE,this._texture.wrapV=Eo.CLAMP_ADDRESSMODE,this._texture.anisotropicFilteringLevel=1},e.prototype._createBlurPostProcesses=function(e,t,i,r,n,o){var s=this;void 0===o&&(o=!1);var l=this._scene.getEngine(),c=new A(Math.floor(this._blurTextureSizeX/r),Math.floor(this._blurTextureSizeY/r)),u=t===a.TEXTURETYPE_FLOAT&&l.getCaps().textureFloatLinearFiltering||t===a.TEXTURETYPE_HALF_FLOAT&&l.getCaps().textureHalfFloatLinearFiltering,h=this._engine.createRenderTargetTexture({width:c.x,height:c.y},{generateMipMaps:!1,type:t,format:i,samplingMode:u?a.TEXTURE_BILINEAR_SAMPLINGMODE:a.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1,samples:this._samples,label:"FluidRenderingRTTBlur-".concat(n)}),d=h.texture;d.incrementReferences();var p=new Eo(null,this._scene);if(p.name="rttBlurred"+n,p._texture=d,p.wrapU=Eo.CLAMP_ADDRESSMODE,p.wrapV=Eo.CLAMP_ADDRESSMODE,p.anisotropicFilteringLevel=1,o){var f=new Na("BilateralBlurX","fluidRenderingStandardBlur",["filterSize","blurDir"],null,1,null,a.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,t,void 0,void 0,void 0,i);f.samples=this._samples,f.externalTextureSamplerBinding=!0,f.onApplyObservable.add((function(t){0===s._postProcessRunningIndex?t.setTexture("textureSampler",e):t._bindTexture("textureSampler",f.inputTexture.texture),t.setInt("filterSize",s.blurFilterSize),t.setFloat2("blurDir",1/s._blurTextureSizeX,0),s._postProcessRunningIndex++})),f.onSizeChangedObservable.add((function(){f._textures.forEach((function(e){e.texture.wrapU=Eo.CLAMP_ADDRESSMODE,e.texture.wrapV=Eo.CLAMP_ADDRESSMODE}))})),this._fixReusablePostProcess(f);var _=new Na("BilateralBlurY","fluidRenderingStandardBlur",["filterSize","blurDir"],null,1,null,a.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,t,void 0,void 0,void 0,i);_.samples=this._samples,_.onApplyObservable.add((function(e){e.setInt("filterSize",s.blurFilterSize),e.setFloat2("blurDir",0,1/s._blurTextureSizeY),s._postProcessRunningIndex++})),_.onSizeChangedObservable.add((function(){_._textures.forEach((function(e){e.texture.wrapU=Eo.CLAMP_ADDRESSMODE,e.texture.wrapV=Eo.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 Na("BilateralBlurX","fluidRenderingBilateralBlur",v,null,1,null,a.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,t,void 0,void 0,void 0,i);y.samples=this._samples,y.externalTextureSamplerBinding=!0,y.onApplyObservable.add((function(t){0===s._postProcessRunningIndex?t.setTexture("textureSampler",e):t._bindTexture("textureSampler",y.inputTexture.texture),t.setInt("maxFilterSize",s.blurMaxFilterSize),t.setFloat2("blurDir",1/s._blurTextureSizeX,0),t.setFloat("projectedParticleConstant",s._getProjectedParticleConstant()),t.setFloat("depthThreshold",s._getDepthThreshold()),s._postProcessRunningIndex++})),y.onSizeChangedObservable.add((function(){y._textures.forEach((function(e){e.texture.wrapU=Eo.CLAMP_ADDRESSMODE,e.texture.wrapV=Eo.CLAMP_ADDRESSMODE}))})),this._fixReusablePostProcess(y);var b=new Na("BilateralBlurY","fluidRenderingBilateralBlur",v,null,1,null,a.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,t,void 0,void 0,void 0,i);for(b.samples=this._samples,b.onApplyObservable.add((function(e){e.setInt("maxFilterSize",s.blurMaxFilterSize),e.setFloat2("blurDir",0,1/s._blurTextureSizeY),e.setFloat("projectedParticleConstant",s._getProjectedParticleConstant()),e.setFloat("depthThreshold",s._getDepthThreshold()),s._postProcessRunningIndex++})),b.onSizeChangedObservable.add((function(){b._textures.forEach((function(e){e.texture.wrapU=Eo.CLAMP_ADDRESSMODE,e.texture.wrapV=Eo.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"}(Kx||(Kx={}));var $x,eA=function(){function e(e,t){this._generateDiffuseTexture=!1,this.fluidColor=new B(.085,.6375,.765),this.density=2,this.refractionStrength=.1,this.fresnelClamp=1,this.specularPower=250,this.minimumThickness=0,this.dirLight=new R(-2,-1,1).normalize(),this._debugFeature=Kx.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 u,this._useVelocity=!1,this._depthMapSize=null,this._thicknessMapSize=null,this._diffuseMapSize=null,this._samples=1,this._scene=e,this._engine=e.getEngine(),this._camera=null!=t?t:e.activeCamera,this._needInitialization=!0,this._bgDepthTexture=null,this._invProjectionMatrix=new I,this._depthClearColor=new U(1e6,1e6,1e6,1),this._thicknessClearColor=new U(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,"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 Jx("Depth",this._scene,r,n,r,n,a.TEXTURETYPE_FLOAT,a.TEXTUREFORMAT_RG,a.TEXTURETYPE_FLOAT,a.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(),s=null!==this._diffuseMapSize?Math.round(this._diffuseMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();this._diffuseRenderTarget=new Jx("Diffuse",this._scene,o,s,0,0,a.TEXTURETYPE_UNSIGNED_BYTE,a.TEXTUREFORMAT_RGBA,a.TEXTURETYPE_UNSIGNED_BYTE,a.TEXTUREFORMAT_RGBA,!0,this._camera,!0,this._samples),this._initializeRenderTarget(this._diffuseRenderTarget)}var l=null!==(i=this._thicknessMapSize)&&void 0!==i?i:this._engine.getRenderWidth(),c=null!==this._thicknessMapSize?Math.round(this._thicknessMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();this._useFixedThickness||(this._thicknessRenderTarget=new Jx("Thickness",this._scene,l,c,l,c,a.TEXTURETYPE_HALF_FLOAT,a.TEXTUREFORMAT_R,a.TEXTURETYPE_HALF_FLOAT,a.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 s=this._depthRenderTarget.enableBlur?this._depthRenderTarget.textureBlur:this._depthRenderTarget.texture,l=new A(1/s.getSize().width,1/s.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._debug&&(o.push("#define FLUIDRENDERING_DEBUG"),this._debugFeature===Kx.Normals?o.push("#define FLUIDRENDERING_DEBUG_SHOWNORMAL"):this._debugFeature===Kx.DiffuseRendering?o.push("#define FLUIDRENDERING_DEBUG_DIFFUSERENDERING"):(o.push("#define FLUIDRENDERING_DEBUG_TEXTURE"),n.push("debugSampler"),this._debugFeature!==Kx.DepthTexture&&this._debugFeature!==Kx.DepthBlurredTexture||o.push("#define FLUIDRENDERING_DEBUG_DEPTH"))),this._renderPostProcess=new Na("FluidRendering","fluidRenderingRender",r,n,1,null,a.TEXTURE_BILINEAR_SAMPLINGMODE,i,!1,null,a.TEXTURETYPE_UNSIGNED_BYTE,void 0,void 0,!0,void 0),this._renderPostProcess.updateEffect(o.join("\n")),this._renderPostProcess.samples=this._samples,this._renderPostProcess.onApplyObservable.add((function(e){var r,n,o,a,s,c,u,h,d,p,f,_,m,g,v,y,b,T,E,S,x,A,R;if(t._invProjectionMatrix.copyFrom(t._scene.getProjectionMatrix()),t._invProjectionMatrix.invert(),i.isWebGPU&&e.setTextureSampler("textureSamplerSampler",t._renderPostProcess.inputTexture.texture),t._depthRenderTarget.enableBlur?(e.setTexture("depthSampler",t._depthRenderTarget.textureBlur),i.isWebGPU&&e.setTextureSampler("depthSamplerSampler",null!==(a=null===(o=t._depthRenderTarget.textureBlur)||void 0===o?void 0:o.getInternalTexture())&&void 0!==a?a:null)):(e.setTexture("depthSampler",t._depthRenderTarget.texture),i.isWebGPU&&e.setTextureSampler("depthSamplerSampler",null!==(n=null===(r=t._depthRenderTarget.texture)||void 0===r?void 0:r.getInternalTexture())&&void 0!==n?n:null)),t._diffuseRenderTarget?t._diffuseRenderTarget.enableBlur?(e.setTexture("diffuseSampler",t._diffuseRenderTarget.textureBlur),i.isWebGPU&&e.setTextureSampler("diffuseSamplerSampler",null!==(h=null===(u=t._diffuseRenderTarget.textureBlur)||void 0===u?void 0:u.getInternalTexture())&&void 0!==h?h:null)):(e.setTexture("diffuseSampler",t._diffuseRenderTarget.texture),i.isWebGPU&&e.setTextureSampler("diffuseSamplerSampler",null!==(c=null===(s=t._diffuseRenderTarget.texture)||void 0===s?void 0:s.getInternalTexture())&&void 0!==c?c:null)):e.setColor3("diffuseColor",t.fluidColor),t._useFixedThickness?(e.setFloat("thickness",t.minimumThickness),e._bindTexture("bgDepthSampler",t._bgDepthTexture),i.isWebGPU&&e.setTextureSampler("bgDepthSamplerSampler",null!==(d=t._bgDepthTexture)&&void 0!==d?d:null)):(t._thicknessRenderTarget.enableBlur?(e.setTexture("thicknessSampler",t._thicknessRenderTarget.textureBlur),i.isWebGPU&&e.setTextureSampler("thicknessSamplerSampler",null!==(m=null===(_=t._thicknessRenderTarget.textureBlur)||void 0===_?void 0:_.getInternalTexture())&&void 0!==m?m:null)):(e.setTexture("thicknessSampler",t._thicknessRenderTarget.texture),i.isWebGPU&&e.setTextureSampler("thicknessSamplerSampler",null!==(f=null===(p=t._thicknessRenderTarget.texture)||void 0===p?void 0:p.getInternalTexture())&&void 0!==f?f:null)),e.setFloat("minimumThickness",t.minimumThickness)),null!==t._environmentMap){var C=null!==(g=t._environmentMap)&&void 0!==g?g:t._scene.environmentTexture;C&&(e.setTexture("reflectionSampler",C),i.isWebGPU&&e.setTextureSampler("reflectionSamplerSampler",null!==(v=null==C?void 0:C.getInternalTexture())&&void 0!==v?v:null))}if(e.setMatrix("viewMatrix",t._scene.getViewMatrix()),e.setMatrix("invProjectionMatrix",t._invProjectionMatrix),e.setMatrix("projectionMatrix",t._scene.getProjectionMatrix()),e.setVector2("texelSize",l),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 P=null;switch(t._debugFeature){case Kx.DepthTexture:P=t._depthRenderTarget.texture;break;case Kx.DepthBlurredTexture:P=t._depthRenderTarget.enableBlur?t._depthRenderTarget.textureBlur:t._depthRenderTarget.texture;break;case Kx.ThicknessTexture:P=null!==(b=null===(y=t._thicknessRenderTarget)||void 0===y?void 0:y.texture)&&void 0!==b?b:null;break;case Kx.ThicknessBlurredTexture:P=(null===(T=t._thicknessRenderTarget)||void 0===T?void 0:T.enableBlur)?null!==(S=null===(E=t._thicknessRenderTarget)||void 0===E?void 0:E.textureBlur)&&void 0!==S?S:null:null!==(A=null===(x=t._thicknessRenderTarget)||void 0===x?void 0:x.texture)&&void 0!==A?A:null;break;case Kx.DiffuseTexture:t._diffuseRenderTarget&&(P=t._diffuseRenderTarget.texture)}t._debugFeature!==Kx.Normals&&(e.setTexture("debugSampler",P),i.isWebGPU&&e.setTextureSampler("debugSamplerSampler",null!==(R=null==P?void 0:P.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,s;if(!this._needInitialization&&e.isReady()){var l=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(a.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===(s=this._thicknessRenderTarget)||void 0===s||s.applyBlurPostProcesses(),l&&this._engine.bindFramebuffer(l)}},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}(),tA=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 W(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 ji(this._engine,e[t],t,!0,!1,i,r)}},t.prototype._createEffects=function(){e.prototype._createEffects.call(this),this._diffuseEffectWrapper=new Ja({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 ji(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(a.MATERIAL_TriangleStripDrawMode,0,4,e):this._engine.drawElementsType(a.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}(qx);kt.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"}($x||($x={}));var iA=function(){function e(e,t){void 0===t&&(t=!1);var i=this;this._engine=e,this._isDepthTexture=t,this._renderer=new Za(e),this._effectWrapper=new Ja({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=a.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=$x.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}(),rA=function(){function e(e,t,i,r){void 0===r&&(r=1),this._engine=e,this._copyTextureToTexture=new iA(e,!0),this._depthRTWrapper=this._engine.createRenderTargetTexture({width:t,height:i},{generateMipMaps:!1,type:a.TEXTURETYPE_UNSIGNED_BYTE,format:a.TEXTUREFORMAT_R,samplingMode:a.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:!0,generateStencilBuffer:!1,samples:r,noColorAttachment:!0,label:"FluidRenderingDepthTextureCopyRTT"}),this._depthRTWrapper.createDepthStencilTexture(0,!1,!1,1,void 0,"FluidRenderingDepthTextureCopyRTTDepthStencil")}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}();kt.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";kt.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";kt.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";kt.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";kt.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";kt.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";kt.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";kt.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 nA(e){return!!e.particleSystem}kt.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\nglFragColor=backColor;return;}\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);vec3 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(Ar.prototype,"fluidRenderer",{get:function(){return this._fluidRenderer},set:function(e){this._fluidRenderer=e},enumerable:!0,configurable:!0}),Ar.prototype.enableFluidRenderer=function(){return this._fluidRenderer||(this._fluidRenderer=new aA(this)),this._fluidRenderer},Ar.prototype.disableFluidRenderer=function(){var e;null===(e=this._fluidRenderer)||void 0===e||e.dispose(),this._fluidRenderer=null};var oA=function(){function e(e){this.name=Ji.NAME_FLUIDRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherActiveCameraRenderTargetsStage.registerStep(Ji.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER,this,this._gatherActiveCameraRenderTargets),this.scene._afterCameraDrawStage.registerStep(Ji.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(){this.scene._fluidRenderer&&(this.scene.disableFluidRenderer(),this.scene.enableFluidRenderer())},e.prototype.dispose=function(){this.scene.disableFluidRenderer()},e}(),aA=function(){function e(t){var i=this;this._scene=t,this._engine=t.getEngine(),this._onEngineResizeObserver=null,this.renderObjects=[],this.targetRenderers=[],this._cameras=new Map,e._SceneComponentInitialization(this._scene),this._onEngineResizeObserver=this._engine.onResizeObservable.add((function(){i._initialize()}))}return e._SceneComponentInitialization=function(e){var t=e._getComponent(Ji.NAME_FLUIDRENDERER);t||(t=new oA(e),e._addComponent(t))},e.prototype.recreate=function(){this._sortRenderingObjects(),this._initialize()},e.prototype.getRenderObjectFromParticleSystem=function(e){var t=this._getParticleSystemIndex(e);return-1!==t?this.renderObjects[t]:null},e.prototype.addParticleSystem=function(e,t,i,r){var n=this,o=new Zx(this._scene,e);o.onParticleSizeChanged.add((function(){return n._setParticleSizeForRenderTargets()})),i||(i=new eA(this._scene,r),this.targetRenderers.push(i)),i._onUseVelocityChanged.hasObservers()||i._onUseVelocityChanged.add((function(){return n._setUseVelocityForRenderObject()})),void 0!==t&&(i.generateDiffuseTexture=t);var a={object:o,targetRenderer:i};return this.renderObjects.push(a),this._sortRenderingObjects(),this._setParticleSizeForRenderTargets(),a},e.prototype.addCustomParticles=function(e,t,i,r,n){var o=this,a=new tA(this._scene,e,t);a.onParticleSizeChanged.add((function(){return o._setParticleSizeForRenderTargets()})),r||(r=new eA(this._scene,n),this.targetRenderers.push(r)),r._onUseVelocityChanged.hasObservers()||r._onUseVelocityChanged.add((function(){return o._setUseVelocityForRenderObject()})),void 0!==i&&(r.generateDiffuseTexture=i);var s={object:a,targetRenderer:r};return this.renderObjects.push(s),this._sortRenderingObjects(),this._setParticleSizeForRenderTargets(),s},e.prototype.removeRenderObject=function(e,t){void 0===t&&(t=!0);var i=this.renderObjects.indexOf(e);return-1!==i&&(e.object.dispose(),this.renderObjects.splice(i,1),t&&this._removeUnusedTargetRenderers()?this._initialize():this._setParticleSizeForRenderTargets(),!0)},e.prototype._sortRenderingObjects=function(){this.renderObjects.sort((function(e,t){return e.object.priorityt.object.priority?1:0}))},e.prototype._removeUnusedTargetRenderers=function(){for(var e,t={},i=0;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}());Ar.prototype._internalPickSprites=function(e,t,i,r){if(!Yi)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 Yi},Ar.prototype._internalMultiPickSprites=function(e,t,i){if(!Yi)return null;var r=new Array;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(a.ACTION_OnLeftPickTrigger,G.CreateNewFromSprite(i.pickedSprite,n,r));break;case 1:i.pickedSprite.actionManager.processTrigger(a.ACTION_OnCenterPickTrigger,G.CreateNewFromSprite(i.pickedSprite,n,r));break;case 2:i.pickedSprite.actionManager.processTrigger(a.ACTION_OnRightPickTrigger,G.CreateNewFromSprite(i.pickedSprite,n,r))}i.pickedSprite.actionManager&&i.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickDownTrigger,G.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 s=o.pickSprite(e,t,this._spritePredicate,!1,o.cameraToUseForPointers||void 0);s&&(s.hit&&s.pickedSprite&&s.pickedSprite.actionManager&&(s.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickUpTrigger,G.CreateNewFromSprite(s.pickedSprite,o,r)),s.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||s.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickTrigger,G.CreateNewFromSprite(s.pickedSprite,o,r)),n&&s.pickedSprite.actionManager.processTrigger(a.ACTION_OnDoublePickTrigger,G.CreateNewFromSprite(s.pickedSprite,o,r)))),o._pickedDownSprite&&o._pickedDownSprite.actionManager&&o._pickedDownSprite!==s.pickedSprite&&o._pickedDownSprite.actionManager.processTrigger(a.ACTION_OnPickOutTrigger,G.CreateNewFromSprite(o._pickedDownSprite,o,r)))}return i},e}();kt.IncludesShadersStore.imageProcessingCompatibility="#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif\n";kt.ShadersStore.spritesPixelShader="uniform bool alphaTest;varying vec4 vColor;varying vec2 vUV;uniform sampler2D diffuseSampler;\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\ngl_FragColor=color;\n#include\n#define CUSTOM_FRAGMENT_MAIN_END\n}";kt.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#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#define CUSTOM_VERTEX_MAIN_END\n}";var cA=function(){function e(e,t,i,r){void 0===i&&(i=.01),void 0===r&&(r=null),this.blendMode=a.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 Xi(e,this._vertexData,!0,this._vertexBufferSize);var n,o=this._buffer.createVertexBuffer(ji.PositionKind,0,4,this._vertexBufferSize,this._useInstancing),s=this._buffer.createVertexBuffer("options",4,2,this._vertexBufferSize,this._useInstancing),l=6;if(this._useInstancing){var c=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new Xi(e,c,!1,2),n=this._spriteBuffer.createVertexBuffer("offsets",0,2)}else n=this._buffer.createVertexBuffer("offsets",l,2,this._vertexBufferSize,this._useInstancing),l+=2;var u=this._buffer.createVertexBuffer("inverts",l,2,this._vertexBufferSize,this._useInstancing),h=this._buffer.createVertexBuffer("cellInfo",l+2,4,this._vertexBufferSize,this._useInstancing),d=this._buffer.createVertexBuffer(ji.ColorKind,l+6,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[ji.PositionKind]=o,this._vertexBuffers.options=s,this._vertexBuffers.offsets=n,this._vertexBuffers.inverts=u,this._vertexBuffers.cellInfo=h,this._vertexBuffers[ji.ColorKind]=d,this._createEffects()}return 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,i,r;null===(e=this._drawWrapperBase)||void 0===e||e.dispose(),null===(t=this._drawWrapperFog)||void 0===t||t.dispose(),null===(i=this._drawWrapperDepth)||void 0===i||i.dispose(),null===(r=this._drawWrapperFogDepth)||void 0===r||r.dispose(),this._drawWrapperBase=new ei(this._engine),this._drawWrapperFog=new ei(this._engine),this._drawWrapperDepth=new ei(this._engine,!1),this._drawWrapperFogDepth=new ei(this._engine,!1),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=this._useInstancing),this._drawWrapperFog.drawContext&&(this._drawWrapperFog.drawContext.useInstancing=this._useInstancing),this._drawWrapperDepth.drawContext&&(this._drawWrapperDepth.drawContext.useInstancing=this._useInstancing),this._drawWrapperFogDepth.drawContext&&(this._drawWrapperFogDepth.drawContext.useInstancing=this._useInstancing);var n=this._pixelPerfect?"#define PIXEL_PERFECT\n":"";this._drawWrapperBase.effect=this._engine.createEffect("sprites",[ji.PositionKind,"options","offsets","inverts","cellInfo",ji.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],n),this._drawWrapperDepth.effect=this._drawWrapperBase.effect,this._drawWrapperDepth.materialContext=this._drawWrapperBase.materialContext,this._scene&&(this._drawWrapperFog.effect=this._scene.getEngine().createEffect("sprites",[ji.PositionKind,"options","offsets","inverts","cellInfo",ji.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],n+"#define FOG"),this._drawWrapperFogDepth.effect=this._drawWrapperFog.effect,this._drawWrapperFogDepth.materialContext=this._drawWrapperFog.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,s=this._drawWrapperDepth,l=!1;this.fogEnabled&&this._scene&&this._scene.fogEnabled&&0!==this._scene.fogMode&&(o=this._drawWrapperFog,s=this._drawWrapperFogDepth,l=!0);var c=o.effect;if(c.isReady()){for(var u=this._engine,h=!(!this._scene||!this._scene.useRightHandedSystem),d=this.texture.getBaseSize(),p=Math.min(this._capacity,e.length),f=0,_=!0,m=0;m>0;t._xOffset=(t.cellIndex-c*l)*this.cellWidth/n.width,t._yOffset=c*this.cellHeight/n.height,t._xSize=this.cellWidth,t._ySize=this.cellHeight}this._vertexData[s]=t.position.x,this._vertexData[s+1]=t.position.y,this._vertexData[s+2]=t.position.z,this._vertexData[s+3]=t.angle,this._vertexData[s+4]=t.width,this._vertexData[s+5]=t.height,this._useInstancing?s-=2:(this._vertexData[s+6]=i,this._vertexData[s+7]=r),this._vertexData[s+8]=o?t.invertU?0:1:t.invertU?1:0,this._vertexData[s+9]=t.invertV?1:0,this._vertexData[s+10]=t._xOffset,this._vertexData[s+11]=t._yOffset,this._vertexData[s+12]=t._xSize/n.width,this._vertexData[s+13]=t._ySize/n.height,this._vertexData[s+14]=t.color.r,this._vertexData[s+15]=t.color.g,this._vertexData[s+16]=t.color.b,this._vertexData[s+17]=t.color.a},e.prototype._buildIndexBuffer=function(){for(var e=[],t=0,i=0;i0);var u=e.substring(0,c-1)+".json";Ri.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(){$.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=O.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=R.Zero(),a=R.Zero(),s=Number.MAX_VALUE,l=null,c=O.Vector3[0],u=O.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 Yi;h.invertToRef(O.Matrix[0]),g.hit=!0,g.pickedSprite=l,g.distance=s;var v=O.Vector3[2];return v.copyFrom(p.direction),v.normalize(),v.scaleInPlace(s),p.origin.addToRef(v,c),g.pickedPoint=R.TransformCoordinates(c,O.Matrix[0]),g}return null},e.prototype.multiIntersects=function(e,t,i){for(var r,n=Math.min(this.capacity,this.sprites.length),o=R.Zero(),a=R.Zero(),s=[],l=O.Vector3[0].copyFromFloats(0,0,0),c=O.Vector3[1].copyFromFloats(0,0,0),u=t.getViewMatrix(),h=0;h0.) {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;}";kt.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 hA,dA=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 A(1,1),r.outputSize=r.outputSize||r.stageSize,r.outputPosition=r.outputPosition||R.Zero(),r.outputRotation=r.outputRotation||R.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 R(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 _A(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){$.Error("Error running progress callbacks."),console.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){$.Error("Error running tasks-done callbacks."),console.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||$.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=new Array,r=[],n=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&$.ClearLogCache(),this._engine.stopRenderLoop()),na.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)}))):$.Error("Please provide a valid .babylon file.")},e}(),MA=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}(OA),NA=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 W(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}(OA),FA=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(OA),LA=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(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}(OA),wA=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(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}(OA),BA=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(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}(OA),UA=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(OA),VA=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return W(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(OA),kA=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof io))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 W(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){s.animationGroups=[];for(var p=0;p0)for(s.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&&Ri.Download(e,this._fileName)},e._DefaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},e}(),KA=null;function QA(e,t,i,r,n,o,a){void 0===n&&(n="image/png"),void 0===o&&(o=!1);var s=eR(e,t,i),l=s.height,c=s.width;if(l&&c){KA||(KA=document.createElement("canvas")),KA.width=c,KA.height=l;var u=KA.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?JA(e,t,i,(function(e){if(o){var t=new Blob([e]);Ri.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),KA&&(o?(Ri.EncodeScreenshotCanvasData(KA,void 0,n,void 0,a),r&&r("")):Ri.EncodeScreenshotCanvasData(KA,r,n,void 0,a))}))}else $.Error("Invalid 'size' parameter !")}function qA(e,t,i,r,n){return void 0===r&&(r="image/png"),new Promise((function(o,a){QA(e,t,i,(function(e){void 0!==e?o(e):a(new Error("Data is undefined"))}),r,void 0,n)}))}function ZA(e,t,i,r,n,o){return void 0===n&&(n="image/png"),new Promise((function(a){QA(e,t,{width:i,height:r},(function(){a()}),n,!0,o)}))}function JA(e,t,i,r,n,o,s,l,c,u,h,d,p){void 0===n&&(n="image/png"),void 0===o&&(o=1),void 0===s&&(s=!1),void 0===c&&(c=!1),void 0===u&&(u=!1),void 0===h&&(h=!0);var f=eR(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 ns("screenShot",y,T,!1,!1,a.TEXTURETYPE_UNSIGNED_INT,!1,Eo.BILINEAR_SAMPLINGMODE,void 0,u,void 0,void 0,void 0,o);E.renderList=T.meshes.slice(),E.samples=o,E.renderSprites=c,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){rs.DumpData(m,_,e,r,n,l,!0,void 0,d),E.dispose()})):rd("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){rs.DumpData(g,v,e,r,n,l,!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(s){var A=new nx("antialiasing",1,T.activeCamera);E.addPostProcess(A),A.getEffect().isReady()?x():A.getEffect().onCompiled=function(){x()}}else x()}else $.Error("Invalid 'size' parameter !")}function $A(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){JA(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 eR(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 tR,iR={CreateScreenshot:QA,CreateScreenshotAsync:qA,CreateScreenshotWithResizeAsync:ZA,CreateScreenshotUsingRenderTarget:JA,CreateScreenshotUsingRenderTargetAsync:$A};Ri.CreateScreenshot=QA,Ri.CreateScreenshotAsync=qA,Ri.CreateScreenshotUsingRenderTarget=JA,Ri.CreateScreenshotUsingRenderTargetAsync=$A,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"}(tR||(tR={}));var rR,nR=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 mt(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),oR=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}(),aR=function(){function e(){this._trackedScene=null}return e.prototype.track=function(e){this._trackedScene=e,Ve.AllowLoadingUniqueId=!0,this._savedJSON=jA.Serialize(e),Ve.AllowLoadingUniqueId=!1},e.prototype.getDelta=function(){if(!this._trackedScene)return null;var e=Eo.ForceSerializeBuffers;Eo.ForceSerializeBuffers=!1,Ve.AllowLoadingUniqueId=!0;var t=jA.Serialize(this._trackedScene);Ve.AllowLoadingUniqueId=!1;var i={};for(var r in t)this._compareCollections(r,this._savedJSON[r],t[r],i);return Eo.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||(R.CrossToRef(e._ForwardDir,e._InverseFromVec,e._UpDir),e._UpDir.normalize(),I.LookAtLHToRef(t,i,e._UpDir,e._LookMatrix),r.subtractToRef(i,e._FromToVec),e._FromToVec.normalize(),R.TransformNormalToRef(e._FromToVec,e._LookMatrix,n),0))},e._TokenizeSegment=function(t,i){e._BestMatch=0,e._Score=R.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 R,e._InverseFromVec=new R,e._UpDir=new R,e._FromToVec=new R,e._LookMatrix=new I,e}(),lR=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}(),hR=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=lR.Deserialize(i.vector3Alphabet),r._levenshteinAlphabet=rR.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}(),_R=1800,mR="timestamp",gR="numPoints",vR=/\r/g,yR=function(){function e(t,i){var r=this;this._scene=t,this._collectDataAtFrame=function(){var t=lt.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=[lt.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 fR(_R),this.datasets.ids.length=0,this.datasets.startingIndices=new fR(_R),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(vR,"").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 fR(_R),startingIndices:new fR(_R)},a=r[0],s=r.slice(1);if(a.length<2||a[0]!==mR||a[n]!==gR)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=jo.FEATURE_POINTS,t.Version=1,t}(Ko);Yo.AddWebXRFeature(DR.Name,(function(e){return function(){return new DR(e)}}),DR.Version);var NR,FR=0,LR=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 u,r.onMeshRemovedObservable=new u,r.onMeshUpdatedObservable=new u,r.xrNativeFeatureName="mesh-detection",r._xrSessionManager.session?r._init():r._xrSessionManager.onXRSessionInit.addOnce((function(){r._init()})),r}return W(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=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:FR++,xrMesh:t},n=i._updateVertexDataWithXRMesh(t,r,e);i._detectedMeshes.set(t,n),i.onMeshAddedObservable.notifyObservers(n)}}))}}catch(e){console.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){if(t.xrMesh=e,t.worldParentNode=this._options.worldParentNode,this._options.convertCoordinateSystems){if(this._xrSessionManager.scene.useRightHandedSystem)t.positions=e.positions,t.normals=e.normals;else{t.positions=new Float32Array(e.positions.length);for(var r=0;r0?NR.Received:NR.NotReceived,[2]}}))}))},t.Name=jo.IMAGE_TRACKING,t.Version=1,t}(Ko);Yo.AddWebXRFeature(wR.Name,(function(e,t){return function(){return new wR(e,t)}}),wR.Version,!1);var BR=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",Ri.Warn("dom-overlay is an experimental and unstable feature."),r}return W(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 j(this,void 0,void 0,(function(){var e;return Y(this,(function(t){if(void 0===this.options.element)return Ri.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 Ri.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=jo.DOM_OVERLAY,t.Version=1,t}(Ko);Yo.AddWebXRFeature(BR.Name,(function(e,t){return function(){return new BR(e,t)}}),BR.Version,!1);var UR=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 P,u._tmpRotationMatrix=I.Identity(),u._tmpTranslationDirection=new R,u._tmpMovementTranslation=new R,u._tempCacheQuaternion=new P,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:[im.THUMBSTICK_TYPE,im.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}(Ko);Yo.AddWebXRFeature(UR.Name,(function(e,t){return function(){return new UR(e,t)}}),UR.Version,!0);var VR=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=R.Up().negateInPlace(),r._lightColor=B.White(),r._intensity=1,r._sphericalHarmonics=new ed,r._cubeMapPollTime=Date.now(),r._lightEstimationPollTime=Date.now(),r._reflectionCubeMapTextureSize=16,r.directionalLight=null,r.onReflectionCubeMapUpdatedObservable=new u,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}(),zR=function(){function e(){this._samples=new GR(20),this._entropy=0,this.onFirstStepDetected=new u}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+=A.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 _=O.Vector3[0];_.set(i,r,0);var m=O.Vector3[1];m.set(h.x,h.y,0);var g=R.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}(),HR=function(){function e(t){var i=this;this._detector=new zR,this._walker=null,this._movement=new A,this._millisecondsSinceLastUpdate=e._MillisecondsPerUpdate,this.movementThisFrame=R.Zero(),this._engine=t,this._detector.onFirstStepDetected.add((function(e){i._walker||(i._walker=new WR(e.leftApex,e.rightApex,e.currentPosition,e.currentStepDirection),i._walker.onFootfall.add((function(){console.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}(),XR=function(e){function t(t,i){var r=e.call(this,t)||this;return r._up=new R,r._forward=new R,r._position=new R,r._movement=new R,r._sessionManager=t,r.locomotionTarget=i.locomotionTarget,r._isLocomotionTargetWebXRCamera&&$.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 W(t,e),Object.defineProperty(t,"Name",{get:function(){return jo.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 HR(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||R.TransformNormalToRef(this._movement,this.locomotionTarget.getWorldMatrix(),this._movement),this.locomotionTarget.position.addInPlace(this._movement)}},t}(Ko);Yo.AddWebXRFeature(XR.Name,(function(e,t){return function(){return new XR(e,t)}}),XR.Version,!1);var jR=function(e){function t(t,i,r,n,o,a){var s=e.call(this,t,i,r,n,a)||this;return s.getWidth=t,s.getHeight=i,s.layer=r,s.layerType=n,s.isMultiview=o,s.createRTTProvider=a,s}return W(t,e),t}(yc),YR=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._compositionLayer=r.layer,n}return W(t,e),t.prototype._getRenderTargetForSubImage=function(e,t){var i,r,n,o,a=this._lastSubImages.get(t),s="left"==t?0:1,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}}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(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.colorTextureWidth)&&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}(bc),KR=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 QR(e,r,n)}))||this;return n.layer=t,n}return W(t,e),t}(jR),QR=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 W(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}(YR),qR={},ZR={textureType:"texture",colorFormat:6408,depthFormat:35056,scaleFactor:1},JR=function(e){function t(t,i){void 0===i&&(i={});var r=e.call(this,t)||this;return r._options=i,r._existingLayers=[],r.xrNativeFeatureName="layers",r}return W(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=H({},ZR),r=this._options.preferMultiviewOnInit&&t.getCaps().multiview;return r&&(i.textureType="texture-array"),this.addXRSessionLayer(this.createProjectionLayer(i,r)),!0},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._existingLayers.length=0,!0)},t.prototype.createXRWebGLLayer=function(e){void 0===e&&(e=qR);var t=new XRWebGLLayer(this._xrSessionManager.session,this._glContext,e);return new Tc(t)},t.prototype.createProjectionLayer=function(e,t){if(void 0===e&&(e=ZR),void 0===t&&(t=!1),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'.");var i=this._xrWebGLBinding.createProjectionLayer(e);return new KR(i,t,this._xrWebGLBinding)},t.prototype.addXRSessionLayer=function(e){this.setXRSessionLayers(K(K([],this._existingLayers,!0),[e],!1))},t.prototype.setXRSessionLayers=function(e){this._existingLayers=e;var t=H({},this._xrSessionManager.session.renderState);t.baseLayer=void 0,t.layers=e.map((function(e){return e.layer})),this._xrSessionManager.updateRenderState(t),this._xrSessionManager._setBaseLayerWrapper(e.length>0?e[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){},t.Name=jo.LAYERS,t.Version=1,t}(Ko);Yo.AddWebXRFeature(JR.Name,(function(e,t){return function(){return new JR(e,t)}}),JR.Version,!1);var $R=function(e){function t(t,i){var r=e.call(this,t)||this;return r.options=i,r._width=null,r._height=null,r._rawValueToMeters=null,r._normDepthBufferFromNormView=null,r._cachedDepthBuffer=null,r._cachedWebGLTexture=null,r._cachedDepthImageTexture=null,r.onGetDepthInMetersAvailable=new u,r.xrNativeFeatureName="depth-sensing",Ri.Warn("depth-sensing is an experimental and unstable feature."),r}return W(t,e),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rawValueToMeters",{get:function(){return this._rawValueToMeters},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normDepthBufferFromNormView",{get:function(){return this._normDepthBufferFromNormView},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthUsage",{get:function(){switch(this._xrSessionManager.session.depthUsage){case"cpu-optimized":return"cpu";case"gpu-optimized":return"gpu"}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthDataFormat",{get:function(){switch(this._xrSessionManager.session.depthDataFormat){case"luminance-alpha":return"ushort";case"float32":return"float"}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"latestInternalTexture",{get:function(){var e,t;if(!this._cachedWebGLTexture)return null;var i=this._xrSessionManager.scene.getEngine(),r=new jt(i,Ot.Unknown);return r.isCube=!1,r.invertY=!1,r._useSRGBBuffer=!1,r.format="ushort"===this.depthDataFormat?a.TEXTUREFORMAT_LUMINANCE_ALPHA:a.TEXTUREFORMAT_RGBA,r.generateMipMaps=!1,r.type="ushort"===this.depthDataFormat?a.TEXTURETYPE_UNSIGNED_SHORT:a.TEXTURETYPE_FLOAT,r.samplingMode=a.TEXTURE_NEAREST_LINEAR,r.width=null!==(e=this.width)&&void 0!==e?e:0,r.height=null!==(t=this.height)&&void 0!==t?t:0,r._cachedWrapU=a.TEXTURE_WRAP_ADDRESSMODE,r._cachedWrapV=a.TEXTURE_WRAP_ADDRESSMODE,r._hardwareTexture=new $t(this._cachedWebGLTexture,i._gl),r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"latestDepthBuffer",{get:function(){return this._cachedDepthBuffer?"ushort"===this.depthDataFormat?new Uint16Array(this._cachedDepthBuffer):new Float32Array(this._cachedDepthBuffer):null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"latestDepthImageTexture",{get:function(){return this._cachedDepthImageTexture},enumerable:!1,configurable:!0}),t.prototype.attach=function(t){return!!e.prototype.attach.call(this,t)&&null!=this._xrSessionManager.session.depthDataFormat&&null!=this._xrSessionManager.session.depthUsage&&(this._glBinding=new XRWebGLBinding(this._xrSessionManager.session,this._xrSessionManager.scene.getEngine()._gl),!0)},t.prototype.dispose=function(){var e;null===(e=this._cachedDepthImageTexture)||void 0===e||e.dispose()},t.prototype._onXRFrame=function(e){var t=this._xrSessionManager.referenceSpace,i=e.getViewerPose(t);if(null!=i)for(var r=0,n=i.views;r0},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.onDone._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}(WC);b("FGThrottleBlock",ZC);var JC=function(e){function t(t){var i=e.call(this,t)||this;return i.timeout=i._registerDataInput("timeout",gC),i.onTimerDone=i._registerSignalOutput("onTimerDone"),i}return W(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 Tm({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.onDone._activateSignal(e)},t.prototype._onEnded=function(e,t){var i=t._getExecutionVariable(this,"runningTimers")||[],r=i.indexOf(e);-1!==r?i.splice(r,1):Ri.Warn("FlowGraphTimerBlock: Timer ended but was not found in the running timers list"),t._removePendingBlock(this),this.onTimerDone._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.onDone._activateSignal(e),r=0;r=i&&(this.onDone._activateSignal(e),e._setExecutionVariable(this,"debounceCount",0))}else e._setExecutionVariable(this,"debounceCount",0)},t.prototype.getClassName=function(){return"FGDebounceBlock"},t}(WC);b("FGDebounceBlock",nP);var oP=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",vC),i}return W(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}(MC);b("FGFlipFlopBlock",oP);var aP=function(e){function t(t){var i=e.call(this,t)||this;return i.target=i._registerDataInput("target",_C),i.animation=i._registerDataInput("animation",_C),i.speed=i._registerDataInput("speed",gC),i.loop=i._registerDataInput("loop",vC),i.from=i._registerDataInput("from",gC),i.to=i._registerDataInput("to",gC),i.onAnimationEnd=i._registerSignalOutput("onAnimationEnd"),i.runningAnimatable=i._registerDataOutput("runningAnimatable",_C),i}return W(t,e),t.prototype._preparePendingTasks=function(e){var t,i=this,r=this.target.getValue(e),n=this.animation.getValue(e);if(!r||!n)throw new Error("Cannot play animation without target or animation");var o=null!==(t=e._getExecutionVariable(this,"runningAnimatables"))&&void 0!==t?t:[],a=this.runningAnimatable.getValue(e);if(a&&a.paused)a.restart();else{var s=e.configuration.scene.beginDirectAnimation(r,[n],this.from.getValue(e),this.to.getValue(e),this.loop.getValue(e),this.speed.getValue(e),(function(){return i._onAnimationEnd(s,e)}));this.runningAnimatable.setValue(s,e),o.push(s)}e._setExecutionVariable(this,"runningAnimatables",o)},t.prototype._execute=function(e){this._startPendingTasks(e),this.onDone._activateSignal(e)},t.prototype._onAnimationEnd=function(e,t){var i,r=null!==(i=t._getExecutionVariable(this,"runningAnimatables"))&&void 0!==i?i:[],n=r.indexOf(e);-1!==n&&r.splice(n,1),t._removePendingBlock(this),this.onAnimationEnd._activateSignal(t)},t.prototype._cancelPendingTasks=function(e){for(var t,i=0,r=null!==(t=e._getExecutionVariable(this,"runningAnimatables"))&&void 0!==t?t:[];i>t}),"".concat(bP).concat(RP),t)||this}return W(t,e),t}(vP);b("".concat(bP).concat(RP),FP);var LP=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.clz32(e)}),"".concat(bP).concat(CP),t)||this}return W(t,e),t}(yP);b("".concat(bP).concat(CP),LP);var wP=function(e){function t(t){var i=e.call(this,gC,gC,(function(e){return i._ctrz(e)}),"".concat(bP).concat(PP),t)||this;return i}return W(t,e),t.prototype._ctrz=function(e){return 0==(e>>>=0)?32:(e&=-e,31-Math.clz32(e))},t}(yP);b("".concat(bP).concat(PP),wP);var BP="FGLogic",UP="AndBlock",VP="OrBlock",kP="NotBlock",GP=function(e){function t(t){return e.call(this,vC,vC,vC,(function(e,t){return e&&t}),"".concat(BP).concat(UP),t)||this}return W(t,e),t}(vP);b("".concat(BP).concat(UP),GP);var zP=function(e){function t(t){return e.call(this,vC,vC,vC,(function(e,t){return e||t}),"".concat(BP).concat(VP),t)||this}return W(t,e),t}(vP);b("".concat(BP).concat(VP),zP);var WP=function(e){function t(t){return e.call(this,vC,vC,(function(e){return!e}),"".concat(BP).concat(kP),t)||this}return W(t,e),t}(yP);b("".concat(BP).concat(kP),WP);var HP=function(e){function t(t,i,r,n){var o=e.call(this,t,n)||this;return o._operation=i,o._className=r,o}return W(t,e),t.prototype._doOperation=function(e){return this._operation()},t.prototype.getClassName=function(){return this._className},t}(gP),XP="FGAddNumberBlock",jP=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return e+t}),XP,t)||this}return W(t,e),t}(vP);b(XP,jP);var YP="FGSubtractNumberBlock",KP=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return e-t}),YP,t)||this}return W(t,e),t}(vP);b(YP,KP);var QP="FGMultiplyNumberBlock",qP=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return e*t}),QP,t)||this}return W(t,e),t}(vP);b(QP,qP);var ZP="FGDivideNumberBlock",JP=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return e/t}),ZP,t)||this}return W(t,e),t}(vP);b(ZP,JP);var $P="FGModNumberBlock",eI=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return e%t}),$P,t)||this}return W(t,e),t}(vP);b($P,eI);var tI="FGPowNumberBlock",iI=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return Math.pow(e,t)}),tI,t)||this}return W(t,e),t}(vP);b(tI,iI);var rI="FGIsNaNNumberBlock",nI=function(e){function t(t){return e.call(this,gC,vC,(function(e){return isNaN(e)}),rI,t)||this}return W(t,e),t}(yP);b(rI,nI);var oI="FGIsInfinityNumberBlock",aI=function(e){function t(t){return e.call(this,gC,vC,(function(e){return!isFinite(e)}),oI,t)||this}return W(t,e),t}(yP);b(oI,aI);var sI="FGSqrtNumberBlock",lI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.sqrt(e)}),sI,t)||this}return W(t,e),t}(yP);b(sI,lI);var cI="FGAbsNumberBlock",uI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.abs(e)}),cI,t)||this}return W(t,e),t}(yP);b(cI,uI);var hI="FGNegateNumberBlock",dI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return-e}),hI,t)||this}return W(t,e),t}(yP);b(hI,dI);var pI="FGFloorNumberBlock",fI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.floor(e)}),pI,t)||this}return W(t,e),t}(yP);b(pI,fI);var _I="FGCeilNumberBlock",mI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.ceil(e)}),_I,t)||this}return W(t,e),t}(yP);b(_I,mI);var gI="FGRoundNumberBlock",vI=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return Math.round(e/Math.pow(10,t))/Math.pow(10,t)}),gI,t)||this}return W(t,e),t}(vP);b(gI,vI);var yI="FGTruncNumberBlock",bI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.trunc(e)}),yI,t)||this}return W(t,e),t}(yP);b(yI,bI);var TI="FGExpNumberBlock",EI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.exp(e)}),TI,t)||this}return W(t,e),t}(yP);b(TI,EI);var SI="FGLog10NumberBlock",xI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.log10(e)}),SI,t)||this}return W(t,e),t}(yP);b(SI,xI);var AI="FGLogNumberBlock",RI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.log(e)}),AI,t)||this}return W(t,e),t}(yP);b(AI,RI);var CI="FGLnNumberBlock",PI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.log(e)/Math.LN2}),CI,t)||this}return W(t,e),t}(yP);b(CI,PI);var II="FGSineNumberBlock",MI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.sin(e)}),II,t)||this}return W(t,e),t}(yP);b(II,MI);var OI="FGCosNumberBlock",DI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.cos(e)}),OI,t)||this}return W(t,e),t}(yP);b(OI,DI);var NI="FGTanNumberBlock",FI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.tan(e)}),NI,t)||this}return W(t,e),t}(yP);b(NI,FI);var LI="FGASineNumberBlock",wI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.asin(e)}),LI,t)||this}return W(t,e),t}(yP);b(LI,wI);var BI="FGACosNumberBlock",UI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.acos(e)}),BI,t)||this}return W(t,e),t}(yP);b(BI,UI);var VI="FGATanNumberBlock",kI=function(e){function t(t){return e.call(this,gC,gC,(function(e){return Math.atan(e)}),VI,t)||this}return W(t,e),t}(yP);b(VI,kI);var GI="FGENumberBlock",zI=function(e){function t(t){return e.call(this,gC,(function(){return Math.E}),GI,t)||this}return W(t,e),t}(HP);b(GI,zI);var WI="FGPiNumberBlock",HI=function(e){function t(t){return e.call(this,gC,(function(){return Math.PI}),WI,t)||this}return W(t,e),t}(HP);b(WI,HI);var XI="FGATan2NumberBlock",jI=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return Math.atan2(e,t)}),XI,t)||this}return W(t,e),t}(vP);b(XI,jI);var YI="FGRandomNumberBlock",KI=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return e+Math.random()*(t-e)}),YI,t)||this}return W(t,e),t}(vP);b(YI,KI);var QI="FGMinNumberBlock",qI=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return Math.min(e,t)}),QI,t)||this}return W(t,e),t}(vP);b(QI,qI);var ZI="FGMaxNumberBlock",JI=function(e){function t(t){return e.call(this,gC,gC,gC,(function(e,t){return Math.max(e,t)}),ZI,t)||this}return W(t,e),t}(vP);b(ZI,JI);var $I="FGEqualsNumberBlock",eM=function(e){function t(t){return e.call(this,gC,gC,vC,(function(e,t){return e===t}),$I,t)||this}return W(t,e),t}(vP);b($I,eM);var tM="FGGreaterThanNumberBlock",iM=function(e){function t(t){return e.call(this,gC,gC,vC,(function(e,t){return e>t}),tM,t)||this}return W(t,e),t}(vP);b(tM,iM);var rM="FGGreaterThanOrEqualsNumberBlock",nM=function(e){function t(t){return e.call(this,gC,gC,vC,(function(e,t){return e>=t}),rM,t)||this}return W(t,e),t}(vP);b(rM,nM);var oM="FGLessThanNumberBlock",aM=function(e){function t(t){return e.call(this,gC,gC,vC,(function(e,t){return e